KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > opencms > module > CmsModuleXmlHandler


1 /*
2  * File : $Source: /usr/local/cvs/opencms/src/org/opencms/module/CmsModuleXmlHandler.java,v $
3  * Date : $Date: 2006/03/27 14:53:03 $
4  * Version: $Revision: 1.22 $
5  *
6  * This library is part of OpenCms -
7  * the Open Source Content Mananagement System
8  *
9  * Copyright (c) 2005 Alkacon Software GmbH (http://www.alkacon.com)
10  *
11  * This library is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU Lesser General Public
13  * License as published by the Free Software Foundation; either
14  * version 2.1 of the License, or (at your option) any later version.
15  *
16  * This library is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  * Lesser General Public License for more details.
20  *
21  * For further information about Alkacon Software GmbH, please see the
22  * company website: http://www.alkacon.com
23  *
24  * For further information about OpenCms, please see the
25  * project website: http://www.opencms.org
26  *
27  * You should have received a copy of the GNU Lesser General Public
28  * License along with this library; if not, write to the Free Software
29  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
30  */

31
32 package org.opencms.module;
33
34 import org.opencms.configuration.CmsVfsConfiguration;
35 import org.opencms.configuration.CmsWorkplaceConfiguration;
36 import org.opencms.configuration.I_CmsConfigurationParameterHandler;
37 import org.opencms.configuration.I_CmsXmlConfiguration;
38 import org.opencms.db.CmsExportPoint;
39 import org.opencms.file.types.I_CmsResourceType;
40 import org.opencms.main.CmsLog;
41 import org.opencms.util.CmsDateUtil;
42 import org.opencms.util.CmsStringUtil;
43 import org.opencms.workplace.CmsWorkplace;
44 import org.opencms.workplace.explorer.CmsExplorerTypeSettings;
45
46 import java.text.ParseException JavaDoc;
47 import java.util.ArrayList JavaDoc;
48 import java.util.Collections JavaDoc;
49 import java.util.HashMap JavaDoc;
50 import java.util.Iterator JavaDoc;
51 import java.util.List JavaDoc;
52 import java.util.Map JavaDoc;
53 import java.util.SortedMap JavaDoc;
54
55 import org.apache.commons.digester.Digester;
56 import org.apache.commons.logging.Log;
57
58 import org.dom4j.Document;
59 import org.dom4j.DocumentHelper;
60 import org.dom4j.Element;
61
62 /**
63  * Adds the XML handler rules for import and export of a single module.<p>
64  *
65  * @author Alexander Kandzior
66  *
67  * @version $Revision: 1.22 $
68  *
69  * @since 6.0.0
70  */

71 public class CmsModuleXmlHandler {
72
73     /** The "name" attribute. */
74     public static final String JavaDoc A_NAME = "name";
75
76     /** The "version" attribute. */
77     public static final String JavaDoc A_VERSION = "version";
78
79     /** The node name for the authoremail node. */
80     public static final String JavaDoc N_AUTHOREMAIL = "authoremail";
81
82     /** The node name for the authorname node. */
83     public static final String JavaDoc N_AUTHORNAME = "authorname";
84
85     /** The node name for the class node. */
86     public static final String JavaDoc N_CLASS = "class";
87
88     /** The node name for the datecreated node. */
89     public static final String JavaDoc N_DATECREATED = "datecreated";
90
91     /** The node name for the date installed node. */
92     public static final String JavaDoc N_DATEINSTALLED = "dateinstalled";
93
94     /** The node name for the dependencies node. */
95     public static final String JavaDoc N_DEPENDENCIES = "dependencies";
96
97     /** The node name for the dependency node. */
98     public static final String JavaDoc N_DEPENDENCY = "dependency";
99
100     /** The node name for the description node. */
101     public static final String JavaDoc N_DESCRIPTION = "description";
102
103     /** The node name for the group node. */
104     public static final String JavaDoc N_GROUP = "group";
105
106     /** The node name for a module. */
107     public static final String JavaDoc N_MODULE = "module";
108
109     /** The node name for the name node. */
110     public static final String JavaDoc N_NAME = "name";
111
112     /** The node name for the nicename node. */
113     public static final String JavaDoc N_NICENAME = "nicename";
114
115     /** The "param" node name for generic parameters. */
116     public static final String JavaDoc N_PARAM = "param";
117
118     /** The node name for the parameters node. */
119     public static final String JavaDoc N_PARAMETERS = "parameters";
120
121     /** The node name for the resources node. */
122     public static final String JavaDoc N_RESOURCES = "resources";
123
124     /** The node name for the user installed node. */
125     public static final String JavaDoc N_USERINSTALLED = "userinstalled";
126
127     /** The node name for the version node. */
128     public static final String JavaDoc N_VERSION = "version";
129
130     /** The log object for this class. */
131     private static final Log LOG = CmsLog.getLog(CmsModuleXmlHandler.class);
132
133     /** The list of dependencies for a module. */
134     private List JavaDoc m_dependencies;
135
136     /** The explorer type settings. */
137     private List JavaDoc m_explorerTypeSettings;
138
139     /** The list of export points for a module. */
140     private List JavaDoc m_exportPoints;
141
142     /** The generated module. */
143     private CmsModule m_module;
144
145     /** Indicates if the module was an old (5.0.x) style module. */
146     private boolean m_oldModule;
147
148     /** The module parameters. */
149     private Map JavaDoc m_parameters;
150
151     /** The list of resources for a module. */
152     private List JavaDoc m_resources;
153
154     /** The list of additional resource types. */
155     private List JavaDoc m_resourceTypes;
156
157     /**
158      * Public constructor, will be called by digester during import.<p>
159      */

160     public CmsModuleXmlHandler() {
161
162         m_exportPoints = new ArrayList JavaDoc();
163         m_dependencies = new ArrayList JavaDoc();
164         m_resources = new ArrayList JavaDoc();
165         m_parameters = new HashMap JavaDoc();
166         m_resourceTypes = new ArrayList JavaDoc();
167         m_explorerTypeSettings = new ArrayList JavaDoc();
168     }
169
170     /**
171      * Adds the XML digester rules for a single module.<p>
172      *
173      * @param digester the digester to add the rules to
174      */

175     public static void addXmlDigesterRules(Digester digester) {
176
177         // add class generation rule
178
digester.addObjectCreate("*/" + N_MODULE, CmsModuleXmlHandler.class);
179         digester.addSetNext("*/" + N_MODULE, "setModule");
180
181         // add rules for base module information
182
digester.addCallMethod("*/" + N_MODULE, "createdModule", 11);
183         digester.addCallParam("*/" + N_MODULE + "/" + N_NAME, 0);
184         digester.addCallParam("*/" + N_MODULE + "/" + N_NICENAME, 1);
185         digester.addCallParam("*/" + N_MODULE + "/" + N_GROUP, 2);
186         digester.addCallParam("*/" + N_MODULE + "/" + N_CLASS, 3);
187         digester.addCallParam("*/" + N_MODULE + "/" + N_DESCRIPTION, 4);
188         digester.addCallParam("*/" + N_MODULE + "/" + N_VERSION, 5);
189         digester.addCallParam("*/" + N_MODULE + "/" + N_AUTHORNAME, 6);
190         digester.addCallParam("*/" + N_MODULE + "/" + N_AUTHOREMAIL, 7);
191         digester.addCallParam("*/" + N_MODULE + "/" + N_DATECREATED, 8);
192         digester.addCallParam("*/" + N_MODULE + "/" + N_USERINSTALLED, 9);
193         digester.addCallParam("*/" + N_MODULE + "/" + N_DATEINSTALLED, 10);
194
195         // add rules for module dependencies
196
digester.addCallMethod("*/" + N_MODULE + "/" + N_DEPENDENCIES + "/" + N_DEPENDENCY, "addDependency", 2);
197         digester.addCallParam(
198             "*/" + N_MODULE + "/" + N_DEPENDENCIES + "/" + N_DEPENDENCY,
199             0,
200             I_CmsXmlConfiguration.A_NAME);
201         digester.addCallParam("*/" + N_MODULE + "/" + N_DEPENDENCIES + "/" + N_DEPENDENCY, 1, A_VERSION);
202
203         // add rules for the module export points
204
digester.addCallMethod("*/"
205             + N_MODULE
206             + "/"
207             + I_CmsXmlConfiguration.N_EXPORTPOINTS
208             + "/"
209             + I_CmsXmlConfiguration.N_EXPORTPOINT, "addExportPoint", 2);
210         digester.addCallParam("*/"
211             + N_MODULE
212             + "/"
213             + I_CmsXmlConfiguration.N_EXPORTPOINTS
214             + "/"
215             + I_CmsXmlConfiguration.N_EXPORTPOINT, 0, I_CmsXmlConfiguration.A_URI);
216         digester.addCallParam("*/"
217             + N_MODULE
218             + "/"
219             + I_CmsXmlConfiguration.N_EXPORTPOINTS
220             + "/"
221             + I_CmsXmlConfiguration.N_EXPORTPOINT, 1, I_CmsXmlConfiguration.A_DESTINATION);
222
223         // add rules for the module resources
224
digester.addCallMethod(
225             "*/" + N_MODULE + "/" + N_RESOURCES + "/" + I_CmsXmlConfiguration.N_RESOURCE,
226             "addResource",
227             1);
228         digester.addCallParam(
229             "*/" + N_MODULE + "/" + N_RESOURCES + "/" + I_CmsXmlConfiguration.N_RESOURCE,
230             0,
231             I_CmsXmlConfiguration.A_URI);
232
233         // add rules for the module parameters
234
digester.addCallMethod(
235             "*/" + N_MODULE + "/" + N_PARAMETERS + "/" + I_CmsXmlConfiguration.N_PARAM,
236             "addParameter",
237             2);
238         digester.addCallParam(
239             "*/" + N_MODULE + "/" + N_PARAMETERS + "/" + I_CmsXmlConfiguration.N_PARAM,
240             0,
241             I_CmsXmlConfiguration.A_NAME);
242         digester.addCallParam("*/" + N_MODULE + "/" + N_PARAMETERS + "/" + I_CmsXmlConfiguration.N_PARAM, 1);
243
244         // generic <param> parameter rules
245
digester.addCallMethod(
246             "*/" + I_CmsXmlConfiguration.N_PARAM,
247             I_CmsConfigurationParameterHandler.ADD_PARAMETER_METHOD,
248             2);
249         digester.addCallParam("*/" + I_CmsXmlConfiguration.N_PARAM, 0, I_CmsXmlConfiguration.A_NAME);
250         digester.addCallParam("*/" + I_CmsXmlConfiguration.N_PARAM, 1);
251
252         // add resource type rules from VFS
253
CmsVfsConfiguration.addResourceTypeXmlRules(digester);
254
255         // add explorer type rules from workplace
256
CmsWorkplaceConfiguration.addExplorerTypeXmlRules(digester);
257
258         // finally add all rules for backward compatibility with OpenCms 5.0
259
addXmlDigesterRulesForVersion5Modules(digester);
260     }
261
262     /**
263      * Generates a detached XML element for a module.<p>
264      *
265      * @param module the module to genterate the XML element for
266      * @return the detached XML element for the module
267      */

268     public static Element generateXml(CmsModule module) {
269
270         Document doc = DocumentHelper.createDocument();
271
272         Element moduleElement = doc.addElement(N_MODULE);
273
274         moduleElement.addElement(N_NAME).setText(module.getName());
275         if (!module.getName().equals(module.getNiceName())) {
276             moduleElement.addElement(N_NICENAME).addCDATA(module.getNiceName());
277         } else {
278             moduleElement.addElement(N_NICENAME);
279         }
280         if (CmsStringUtil.isNotEmpty(module.getGroup())) {
281             moduleElement.addElement(N_GROUP).setText(module.getGroup());
282         }
283         if (CmsStringUtil.isNotEmpty(module.getActionClass())) {
284             moduleElement.addElement(N_CLASS).setText(module.getActionClass());
285         } else {
286             moduleElement.addElement(N_CLASS);
287         }
288         if (CmsStringUtil.isNotEmpty(module.getDescription())) {
289             moduleElement.addElement(N_DESCRIPTION).addCDATA(module.getDescription());
290         } else {
291             moduleElement.addElement(N_DESCRIPTION);
292         }
293         moduleElement.addElement(N_VERSION).setText(module.getVersion().toString());
294         if (CmsStringUtil.isNotEmpty(module.getAuthorName())) {
295             moduleElement.addElement(N_AUTHORNAME).addCDATA(module.getAuthorName());
296         } else {
297             moduleElement.addElement(N_AUTHORNAME);
298         }
299         if (CmsStringUtil.isNotEmpty(module.getAuthorEmail())) {
300             moduleElement.addElement(N_AUTHOREMAIL).addCDATA(module.getAuthorEmail());
301         } else {
302             moduleElement.addElement(N_AUTHOREMAIL);
303         }
304         if (module.getDateCreated() != CmsModule.DEFAULT_DATE) {
305             moduleElement.addElement(N_DATECREATED).setText(CmsDateUtil.getHeaderDate(module.getDateCreated()));
306         } else {
307             moduleElement.addElement(N_DATECREATED);
308         }
309
310         if (CmsStringUtil.isNotEmpty(module.getUserInstalled())) {
311             moduleElement.addElement(N_USERINSTALLED).setText(module.getUserInstalled());
312         } else {
313             moduleElement.addElement(N_USERINSTALLED);
314         }
315         if (module.getDateInstalled() != CmsModule.DEFAULT_DATE) {
316             moduleElement.addElement(N_DATEINSTALLED).setText(CmsDateUtil.getHeaderDate(module.getDateInstalled()));
317         } else {
318             moduleElement.addElement(N_DATEINSTALLED);
319         }
320         Element dependenciesElement = moduleElement.addElement(N_DEPENDENCIES);
321         for (int i = 0; i < module.getDependencies().size(); i++) {
322             CmsModuleDependency dependency = (CmsModuleDependency)module.getDependencies().get(i);
323             dependenciesElement.addElement(N_DEPENDENCY).addAttribute(
324                 I_CmsXmlConfiguration.A_NAME,
325                 dependency.getName()).addAttribute(A_VERSION, dependency.getVersion().toString());
326         }
327         Element exportpointsElement = moduleElement.addElement(I_CmsXmlConfiguration.N_EXPORTPOINTS);
328         for (int i = 0; i < module.getExportPoints().size(); i++) {
329             CmsExportPoint point = (CmsExportPoint)module.getExportPoints().get(i);
330             exportpointsElement.addElement(I_CmsXmlConfiguration.N_EXPORTPOINT).addAttribute(
331                 I_CmsXmlConfiguration.A_URI,
332                 point.getUri()).addAttribute(I_CmsXmlConfiguration.A_DESTINATION, point.getConfiguredDestination());
333         }
334         Element resourcesElement = moduleElement.addElement(N_RESOURCES);
335         for (int i = 0; i < module.getResources().size(); i++) {
336             String JavaDoc resource = (String JavaDoc)module.getResources().get(i);
337             resourcesElement.addElement(I_CmsXmlConfiguration.N_RESOURCE).addAttribute(
338                 I_CmsXmlConfiguration.A_URI,
339                 resource);
340         }
341         Element parametersElement = moduleElement.addElement(N_PARAMETERS);
342         SortedMap JavaDoc parameters = module.getParameters();
343         if (parameters != null) {
344             List JavaDoc parameterList = new ArrayList JavaDoc(parameters.keySet());
345             Collections.sort(parameterList);
346             Iterator JavaDoc it = parameterList.iterator();
347             while (it.hasNext()) {
348                 String JavaDoc name = (String JavaDoc)it.next();
349                 String JavaDoc value = parameters.get(name).toString();
350                 Element paramNode = parametersElement.addElement(I_CmsXmlConfiguration.N_PARAM);
351                 paramNode.addAttribute(I_CmsXmlConfiguration.A_NAME, name);
352                 paramNode.addText(value);
353             }
354         }
355
356         // add resource types
357
List JavaDoc resourceTypes = module.getResourceTypes();
358         if (resourceTypes.size() > 0) {
359             Element resourcetypesElement = moduleElement.addElement(CmsVfsConfiguration.N_RESOURCETYPES);
360             CmsVfsConfiguration.generateResourceTypeXml(resourcetypesElement, resourceTypes, true);
361         }
362
363         List JavaDoc explorerTypes = module.getExplorerTypes();
364         if (explorerTypes.size() > 0) {
365             Element explorerTypesElement = moduleElement.addElement(CmsWorkplaceConfiguration.N_EXPLORERTYPES);
366             CmsWorkplaceConfiguration.generateExplorerTypesXml(explorerTypesElement, explorerTypes, true);
367         }
368
369         // return the modules node
370
moduleElement.detach();
371         return moduleElement;
372     }
373
374     /**
375      * Generates a (hopefully) valid Java class name from an invalid class name.<p>
376      *
377      * All invalid characters are replaced by an underscore "_".
378      * This is for example used to make sure old (5.0) modules can still be imported,
379      * by converting the name to a valid class name.<p>
380      *
381      * @param className the class name to make valid
382      * @return a valid Java class name from an invalid class name
383      */

384     public static String JavaDoc makeValidJavaClassName(String JavaDoc className) {
385
386         StringBuffer JavaDoc result = new StringBuffer JavaDoc(className.length());
387         int length = className.length();
388         boolean nodot = true;
389         for (int i = 0; i < length; i++) {
390             char ch = className.charAt(i);
391             if (nodot) {
392                 if (ch == '.') {
393                     // ignore, remove
394
} else if (Character.isJavaIdentifierStart(ch)) {
395                     nodot = false;
396                     result.append(ch);
397                 } else {
398                     result.append('_');
399                 }
400             } else {
401                 if (ch == '.') {
402                     nodot = true;
403                     result.append(ch);
404                 } else if (Character.isJavaIdentifierPart(ch)) {
405                     nodot = false;
406                     result.append(ch);
407                 } else {
408                     result.append('_');
409                 }
410             }
411         }
412         return result.toString();
413     }
414
415     /**
416      * Adds the digester rules for OpenCms version 5 modules.<p>
417      *
418      * @param digester the digester to add the rules to
419      */

420     private static void addXmlDigesterRulesForVersion5Modules(Digester digester) {
421
422         // mark method
423
digester.addCallMethod("*/" + N_MODULE + "/author", "setOldModule");
424
425         // base module information
426
digester.addCallParam("*/" + N_MODULE + "/author", 6);
427         digester.addCallParam("*/" + N_MODULE + "/email", 7);
428         digester.addCallParam("*/" + N_MODULE + "/creationdate", 8);
429
430         // dependencies
431
digester.addCallParam("*/" + N_MODULE + "/dependencies/dependency/name", 0);
432         digester.addCallParam("*/" + N_MODULE + "/dependencies/dependency/minversion", 1);
433
434         // export points
435
digester.addCallMethod("*/" + N_MODULE + "/exportpoint", "addExportPoint", 2);
436         digester.addCallParam("*/" + N_MODULE + "/exportpoint/source", 0);
437         digester.addCallParam("*/" + N_MODULE + "/exportpoint/destination", 1);
438
439         // parameters
440
digester.addCallMethod("*/" + N_MODULE + "/parameters/para", "addParameter", 2);
441         digester.addCallParam("*/" + N_MODULE + "/parameters/para/name", 0);
442         digester.addCallParam("*/" + N_MODULE + "/parameters/para/value", 1);
443     }
444
445     /**
446      * Adds a module dependency to the current module.<p>
447      *
448      * @param name the module name of the dependency
449      * @param version the module version of the dependency
450      */

451     public void addDependency(String JavaDoc name, String JavaDoc version) {
452
453         CmsModuleVersion moduleVersion = new CmsModuleVersion(version);
454
455         CmsModuleDependency dependency = new CmsModuleDependency(name, moduleVersion);
456         m_dependencies.add(dependency);
457
458         if (LOG.isDebugEnabled()) {
459             LOG.debug(Messages.get().getBundle().key(Messages.LOG_ADD_MOD_DEPENDENCY_2, name, version));
460         }
461     }
462
463     /**
464      * Adds an explorer type setting object to the list of type settings.<p>
465      *
466      * Adds the type setting as well to a map with the resource type name as key.
467      *
468      * @param settings the explorer type settings
469      */

470     public void addExplorerTypeSetting(CmsExplorerTypeSettings settings) {
471
472         settings.setAddititionalModuleExplorerType(true);
473         m_explorerTypeSettings.add(settings);
474     }
475
476     /**
477      * Adds an export point to the module configuration.<p>
478      *
479      * @param uri the export point uri
480      * @param destination the export point destination
481      */

482     public void addExportPoint(String JavaDoc uri, String JavaDoc destination) {
483
484         CmsExportPoint point = new CmsExportPoint(uri, destination);
485         m_exportPoints.add(point);
486         if (CmsLog.INIT.isInfoEnabled() && (point.getDestinationPath() != null)) {
487             CmsLog.INIT.info(Messages.get().getBundle().key(
488                 Messages.INIT_ADD_EXPORT_POINT_2,
489                 point.getUri(),
490                 point.getDestinationPath()));
491         }
492     }
493
494     /**
495      * Adds a module parameter to the module configuration.<p>
496      *
497      * @param key the parameter key
498      * @param value the parameter value
499      */

500     public void addParameter(String JavaDoc key, String JavaDoc value) {
501
502         if (CmsStringUtil.isNotEmpty(key)) {
503             key = key.trim();
504         }
505         if (CmsStringUtil.isNotEmpty(value)) {
506             value = value.trim();
507         }
508         m_parameters.put(key, value);
509         if (LOG.isDebugEnabled()) {
510             LOG.debug(Messages.get().getBundle().key(Messages.LOG_ADD_MOD_PARAM_KEY_2, key, value));
511         }
512     }
513
514     /**
515      * Adds a resource to the list module resources.<p>
516      *
517      * @param resource a resources uri in the OpenCms VFS
518      */

519     public void addResource(String JavaDoc resource) {
520
521         if (LOG.isDebugEnabled()) {
522             LOG.debug(Messages.get().getBundle().key(Messages.LOG_ADD_MOD_RESOURCE_1, resource));
523         }
524         m_resources.add(resource);
525     }
526
527     /**
528      * Adds a new resource type to the internal list of loaded resource types.<p>
529      *
530      * @param resourceType the resource type to add
531      *
532      * @see I_CmsResourceType#ADD_RESOURCE_TYPE_METHOD
533      */

534     public void addResourceType(I_CmsResourceType resourceType) {
535
536         resourceType.setAdditionalModuleResourceType(true);
537         m_resourceTypes.add(resourceType);
538     }
539
540     /**
541      * Created a new module from the provided parameters.<p>
542      *
543      * @param name the name of this module, usually looks like a java package name
544      * @param niceName the "nice" display name of this module
545      * @param group the group of the module
546      * @param actionClass the (optional) module action class name
547      * @param description the description of this module
548      * @param version the version of this module
549      * @param authorName the name of the author of this module
550      * @param authorEmail the email of the module author
551      * @param dateCreated the date this module was created by the author
552      * @param userInstalled the name of the user who uploaded this module
553      * @param dateInstalled the date this module was uploaded
554      */

555     public void createdModule(
556         String JavaDoc name,
557         String JavaDoc niceName,
558         String JavaDoc group,
559         String JavaDoc actionClass,
560         String JavaDoc description,
561         String JavaDoc version,
562         String JavaDoc authorName,
563         String JavaDoc authorEmail,
564         String JavaDoc dateCreated,
565         String JavaDoc userInstalled,
566         String JavaDoc dateInstalled) {
567
568         String JavaDoc moduleName;
569
570         if (!CmsStringUtil.isValidJavaClassName(name)) {
571             // ensure backward compatibility with old (5.0) module names
572
LOG.error(Messages.get().getBundle().key(Messages.LOG_INVALID_MOD_NAME_IMPORTED_1, name));
573             moduleName = makeValidJavaClassName(name);
574             LOG.error(Messages.get().getBundle().key(Messages.LOG_CORRECTED_MOD_NAME_1, moduleName));
575         } else {
576             moduleName = name;
577         }
578
579         // parse the module version
580
CmsModuleVersion moduleVersion = new CmsModuleVersion(version);
581
582         // parse date created
583
long moduleDateCreated = CmsModule.DEFAULT_DATE;
584         if (dateCreated != null) {
585             try {
586                 moduleDateCreated = CmsDateUtil.parseHeaderDate(dateCreated);
587             } catch (ParseException JavaDoc e) {
588                 // noop
589
}
590         }
591
592         // parse date installed
593
long moduleDateInstalled = CmsModule.DEFAULT_DATE;
594         if (dateInstalled != null) {
595             try {
596                 moduleDateInstalled = CmsDateUtil.parseHeaderDate(dateInstalled);
597             } catch (ParseException JavaDoc e1) {
598                 // noop
599
}
600         }
601
602         if (m_oldModule) {
603             // make sure module path is added to resources for "old" (5.0.x) modules
604
String JavaDoc modulePath = CmsWorkplace.VFS_PATH_MODULES + name + "/";
605             m_resources.add(modulePath);
606         }
607
608         // now create the module
609
m_module = new CmsModule(
610             moduleName,
611             niceName,
612             group,
613             actionClass,
614             description,
615             moduleVersion,
616             authorName,
617             authorEmail,
618             moduleDateCreated,
619             userInstalled,
620             moduleDateInstalled,
621             m_dependencies,
622             m_exportPoints,
623             m_resources,
624             m_parameters);
625
626         // set the additional resource types;
627
m_module.setResourceTypes(m_resourceTypes);
628
629         // set the additional explorertypes
630
m_module.setExplorerTypes(m_explorerTypeSettings);
631     }
632
633     /**
634      * Returns the generated module.<p>
635      *
636      * @return the generated module
637      */

638     public CmsModule getModule() {
639
640         return m_module;
641     }
642
643     /**
644      * Sets the current imported module to an old (5.0.x) style module.
645      */

646     public void setOldModule() {
647
648         m_oldModule = true;
649         if (LOG.isDebugEnabled()) {
650             LOG.debug(Messages.get().getBundle().key(Messages.LOG_OLD_MODULE_IMPORTED_0));
651         }
652     }
653 }
Popular Tags