1
2
3
4
5
6
7
8
9
10 package net.sf.mmapps.modules.cloudprovider.impl;
11
12 import net.sf.mmapps.modules.cloudprovider.CloudProvider;
13
14 import org.mmbase.bridge.Cloud;
15 import org.mmbase.bridge.ContextProvider;
16
17 /***
18 * This {@link net.sf.mmapps.modules.cloudprovider.CloudProvider} logs in to MMBase as anonymous user
19 * @author Wouter Heijke <wheijke@users.sourceforge.net>
20 * @version $Id: DefaultCloudProvider.java,v 1.5 2005/07/31 12:39:22 keesj Exp $
21 */
22 public class DefaultCloudProvider implements CloudProvider,Configurable {
23
24 /***
25 * The default cloud name to use when acquiring a cloud from MMBase.
26 */
27 public static final String DEFAULT_CLOUD_NAME = "mmbase";
28
29 /***
30 * The name of the property that can be used to set the cloud name to use
31 * @see #setProperty(String, String)
32 */
33 public final static String CLOUDNAME_PROPERTY_NAME = "cloudname";
34
35 /***
36 * The name of the property that can be used to set teh cloudcontext name
37 * @see #setProperty(String, String)
38 */
39 public final static String CLOUDCONTEXTNAME_PROPERTY_NAME = "cloudcontextname";
40
41
42 protected String cloudcontextname = ContextProvider.getDefaultCloudContextName();
43
44 protected String cloudname = DEFAULT_CLOUD_NAME;
45
46
47 /***
48 * @return an anonymous cloud
49 * @see net.sf.mmapps.modules.cloudprovider.CloudProvider#getAnonymousCloud()
50 */
51 public Cloud getAnonymousCloud() {
52 return ContextProvider.getCloudContext(cloudcontextname).getCloud(cloudname);
53 }
54
55 /***
56 * @return an anonymous cloud
57 * @see net.sf.mmapps.modules.cloudprovider.CloudProvider#getAdminCloud()
58 */
59 public Cloud getAdminCloud() {
60 return getAnonymousCloud();
61 }
62
63 /***
64 * @return an anonymous cloud
65 * @see net.sf.mmapps.modules.cloudprovider.CloudProvider#getCloud()
66 */
67 public Cloud getCloud() {
68 return getAnonymousCloud();
69 }
70
71 /***
72 * Allows the cloudname and cloudcontextname to be set
73 */
74 public void setProperty(String name, String value) {
75 if (CLOUDNAME_PROPERTY_NAME.equals(name)) {
76 cloudname = value;
77 }
78 if (CLOUDCONTEXTNAME_PROPERTY_NAME.equals(name)) {
79 cloudcontextname = value;
80 }
81 }
82 }