001: /**
002: * @author <a href="mailto:docentt@man.poznan.pl">Tomasz Kuczynski</a>, PSNC
003: * @version $Id$
004: */package org.gridsphere.services.core.setup.modules.impl.descriptor;
005:
006: import org.gridsphere.portlet.service.spi.impl.descriptor.ConfigParam;
007:
008: import java.util.*;
009:
010: /**
011: * The <code>PortletsSetupModuleDefinition</code> defines
012: */
013: public class PortletsSetupModuleDefinition {
014: protected PortletsSetupModulesDescriptor portletsSetupDescriptor = null;
015: // private String oid = null;
016: protected String moduleName = "";
017:
018: private List moduleDescriptions = new Vector();
019: private List moduleDefaultJSPs = new Vector();
020: private List moduleTitles = new Vector();
021: private List moduleErrors = new Vector();
022:
023: protected int priority = 100;
024: protected String moduleImplementation = "";
025: protected String portletName = "";
026: protected String contextName = "";
027: protected boolean moduleActive = false;
028: protected boolean preInitModule = false;
029: protected boolean postInitModule = false;
030:
031: protected List configParamList = new Vector();
032: protected Map attributes = new HashMap();
033: protected Properties configProps = null;
034:
035: /*
036: public String getOid() {
037: return oid;
038: }
039:
040: public void setOid(String oid) {
041: this.oid = oid;
042: }
043: */
044:
045: /**
046: * Sets the portlets setup module descriptor
047: *
048: * @param descriptor the portlets setup module descriptor
049: */
050: public void setDescriptor(PortletsSetupModulesDescriptor descriptor) {
051: this .portletsSetupDescriptor = descriptor;
052: }
053:
054: /**
055: * Returns the portlets setup module descriptor
056: *
057: * @return descriptor the portlets setup module descriptor
058: */
059: public PortletsSetupModulesDescriptor getDescriptor() {
060: return portletsSetupDescriptor;
061: }
062:
063: /**
064: * Sets the portlets setup module name
065: *
066: * @param moduleName the portlets setup module name
067: */
068: public void setModuleName(String moduleName) {
069: this .moduleName = moduleName;
070: }
071:
072: /**
073: * Returns the portlets setup module name
074: *
075: * @return the portlets setup module name
076: */
077: public String getModuleName() {
078: return this .moduleName;
079: }
080:
081: /**
082: * Returns the name of portlet which the module is for (if null or empty invoke method of module will receive null PortletDefinition or null Portlet object as a parameter)
083: *
084: * @return the name of the portlet
085: */
086: public String getPortletName() {
087: return portletName;
088: }
089:
090: /**
091: * Sets the name of portlet which the module is for (if null or empty invoke method of module will receive null PortletDefinition or null Portlet object as a parameter)
092: *
093: * @param portletName the name of the portlet
094: */
095: public void setPortletName(String portletName) {
096: this .portletName = portletName;
097: }
098:
099: /**
100: * Returns the context name
101: *
102: * @return the context name
103: */
104: public String getContextName() {
105: return contextName;
106: }
107:
108: /**
109: * Sets the context name
110: *
111: * @param contextName context name
112: */
113: protected void setContextName(String contextName) {
114: this .contextName = contextName;
115: }
116:
117: /**
118: * Returns the module descriptions
119: *
120: * @return the module descriptions
121: */
122: public List getModuleDescriptions() {
123: return this .moduleDescriptions;
124: }
125:
126: /**
127: * Sets the list of module descriptions
128: *
129: * @param moduleDescriptions the list of module descriptions
130: */
131: public void setModuleDescriptions(List moduleDescriptions) {
132: this .moduleDescriptions = moduleDescriptions;
133: }
134:
135: /**
136: * Returns the module titles
137: *
138: * @return the module titles
139: */
140: public List getModuleTitles() {
141: return moduleTitles;
142: }
143:
144: /**
145: * Sets the list of module titles
146: *
147: * @param moduleTitles the list of module titles
148: */
149: public void setModuleTitles(List moduleTitles) {
150: this .moduleTitles = moduleTitles;
151: }
152:
153: /**
154: * Returns the module default JSPs
155: *
156: * @return the module default JSPs
157: */
158: public List getModuleDefaultJSPs() {
159: return moduleDefaultJSPs;
160: }
161:
162: /**
163: * Sets the list of module default JSPs
164: *
165: * @param moduleDefaultJSPs the list of module default JSPs
166: */
167: public void setModuleDefaultJSPs(List moduleDefaultJSPs) {
168: this .moduleDefaultJSPs = moduleDefaultJSPs;
169: }
170:
171: /**
172: * Sets the list of module errors
173: *
174: * @param moduleErrors the list of module errors
175: */
176: public void setModuleErrors(List moduleErrors) {
177: this .moduleErrors = moduleErrors;
178: }
179:
180: /**
181: * Returns the module errors
182: *
183: * @return the module errors
184: */
185: public List getModuleErrors() {
186: return this .moduleErrors;
187: }
188:
189: /**
190: * Returns the portlet service implementation
191: *
192: * @return the portlet service implementation
193: */
194: public String getModuleImplementation() {
195: return this .moduleImplementation;
196: }
197:
198: /**
199: * Sets the portlets setup module implementation
200: *
201: * @param moduleImplementation the portlets setup module implementation
202: */
203: public void setModuleImplementation(String moduleImplementation) {
204: this .moduleImplementation = moduleImplementation;
205: }
206:
207: /**
208: * Returns the module priority
209: *
210: * @return the module priority
211: */
212: public int getModulePriority() {
213: return priority;
214: }
215:
216: /**
217: * Sets the module priority
218: *
219: * @param priority priority
220: */
221: public void setModulePriority(int priority) {
222: this .priority = priority;
223: }
224:
225: /**
226: * Returns true of this module is turned on for all users
227: *
228: * @return true of this module is turned on for all users
229: */
230: public boolean getModuleActive() {
231: return moduleActive;
232: }
233:
234: /**
235: * If true, this module will be active for all users
236: *
237: * @param moduleActive if true, this module will be active for all users
238: */
239: public void setModuleActive(boolean moduleActive) {
240: this .moduleActive = moduleActive;
241: }
242:
243: /**
244: * Returns true if this module is pre portlets initialization module
245: *
246: * @return true if this module is pre portlets initialization module
247: */
248: public boolean getPreInitModule() {
249: return preInitModule;
250: }
251:
252: /**
253: * If true, this module will be pre portlets initialization module
254: *
255: * @param preInitModule if true, this module will be pre portlets initialization module
256: */
257: public void setPreInitModule(boolean preInitModule) {
258: this .preInitModule = preInitModule;
259: }
260:
261: /**
262: * Returns true if this module is post portlets initialization module
263: *
264: * @return true if this module is post portlets initialization module
265: */
266: public boolean getPostInitModule() {
267: return postInitModule;
268: }
269:
270: /**
271: * If true, this module will be post portlets initialization module
272: *
273: * @param postInitModule if true, this module will be post portlets initialization module
274: */
275: public void setPostInitModule(boolean postInitModule) {
276: this .postInitModule = postInitModule;
277: }
278:
279: /**
280: * Sets the service configuration parameter list
281: *
282: * @param configParamList the configuration parameter list
283: */
284: public void setConfigParamList(List configParamList) {
285: this .configParamList = configParamList;
286: }
287:
288: /**
289: * Returns the service configuration parameter list
290: *
291: * @return the configuration parameter list
292: */
293: public List getConfigParamList() {
294: return this .configParamList;
295: }
296:
297: public String getAttribute(String name) {
298: return (String) attributes.get(name);
299: }
300:
301: public Map getAttributes() {
302: return attributes;
303: }
304:
305: public void setAttributes(Map attributes) {
306: this .attributes = attributes;
307: }
308:
309: /**
310: * Creates a properties from the ConfigParamList
311: *
312: * @see #getConfigParamList
313: */
314: private void createProperties() {
315: configProps = new Properties();
316: Iterator it = this .configParamList.iterator();
317: ConfigParam param;
318: while (it.hasNext()) {
319: param = (ConfigParam) it.next();
320: configProps.setProperty(param.getParamName(), param
321: .getParamValue());
322: }
323: }
324:
325: /**
326: * Return the configuration properties
327: *
328: * @return the configuration properties
329: */
330: public Properties getConfigProperties() {
331: if (configProps == null)
332: createProperties();
333: return configProps;
334: }
335:
336: /**
337: * Sets the configuration properties
338: *
339: * @param props the configuration properties
340: */
341: public void setConfigProperties(Properties props) {
342: Enumeration e = props.keys();
343: if (!props.isEmpty()) {
344: configParamList = new Vector();
345: }
346: while (e.hasMoreElements()) {
347: String key = (String) e.nextElement();
348: ConfigParam param = new ConfigParam(key, props
349: .getProperty(key));
350: configParamList.add(param);
351: }
352: }
353:
354: /**
355: * Returns a <code>String</code> representation of this portlets setup module
356: * definition
357: *
358: * @return the portlets setup module definition as a <code>String</code>
359: */
360: public String toString() {
361: StringBuffer sb = new StringBuffer("\n");
362: sb.append("portlets setup module name: " + this .moduleName
363: + "\n");
364: sb.append("portlets setup module description: "
365: + this .moduleDescriptions.get(0) + "\n");
366: sb.append("portlets setup module implementation: "
367: + this .moduleImplementation + "\n");
368: if (null != portletName)
369: sb.append("portlets setup module portlet name: "
370: + this .portletName + "\n");
371: sb.append("portlets setup module context: " + this .contextName
372: + "\n");
373: sb.append("portlets setup module priority: " + this .priority
374: + "\n");
375: sb
376: .append("portlets setup module pre portlets initialization : "
377: + this .preInitModule + "\n");
378: sb
379: .append("portlets setup module post portlets initialization : "
380: + this .postInitModule + "\n");
381: sb.append("config properties: ");
382: Iterator it = this .configParamList.iterator();
383: ConfigParam c;
384: while (it.hasNext()) {
385: c = (ConfigParam) it.next();
386: sb.append("\tname: " + c.getParamName() + "\tvalue: "
387: + c.getParamValue());
388: }
389: return sb.toString();
390: }
391: }
|