Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: com/opencms/core/CmsShellCommands.java


1   /*
2   * File   : $Source: /usr/local/cvs/opencms/src/com/opencms/core/Attic/CmsShellCommands.java,v $
3   * Date   : $Date: 2003/03/19 08:43:10 $
4   * Version: $Revision: 1.67 $
5   *
6   * This library is part of OpenCms -
7   * the Open Source Content Mananagement System
8   *
9   * Copyright (C) 2001  The OpenCms Group
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 OpenCms, please see the
22  * OpenCms Website: http://www.opencms.org
23  *
24  * You should have received a copy of the GNU Lesser General Public
25  * License along with this library; if not, write to the Free Software
26  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
27  */
28  
29  package com.opencms.core;
30  
31  import com.opencms.file.*;
32  import com.opencms.report.CmsShellReport;
33  
34  import java.io.File;
35  import java.io.FileInputStream;
36  import java.lang.reflect.Method;
37  import java.lang.reflect.Modifier;
38  import java.util.Enumeration;
39  import java.util.HashMap;
40  import java.util.Hashtable;
41  import java.util.Iterator;
42  import java.util.Map;
43  import java.util.StringTokenizer;
44  import java.util.Vector;
45  
46  /**
47   * This class is a commad line interface to OpenCms which 
48   * can be used for the initial setup and to test the system.<p>
49   *
50   * @author Andreas Schouten
51   * @author Anders Fugmann
52   * 
53   * @version $Revision: 1.67 $ $Date: 2003/03/19 08:43:10 $
54   * 
55   * @see com.opencms.file.CmsObject
56   */
57  class CmsShellCommands implements I_CmsConstants {
58  
59      /**
60       * The CmsObject object which provides access to the VFS..
61       */
62      private CmsObject m_cms;
63  
64      /**
65       * The wrapped OpenCms object which provides the system environment.
66       */
67      private OpenCms m_openCms;
68  
69      /**
70       * Generate a new instance of CmsShellCommands.<p>
71       * 
72       * @param openCms an initialized OpenCms object (i.e. "operating system")
73       * @param cms an initialized CmsObject (i.e. "command shell")
74       */
75      public CmsShellCommands(OpenCms openCms, CmsObject cms) throws Exception {
76          m_openCms = openCms;
77          m_cms = cms;
78          m_openCms.initUser(m_cms, null, null, C_USER_GUEST, C_GROUP_GUEST, C_PROJECT_ONLINE_ID, null);
79  
80          // print the version-string
81          version();
82          copyright();
83          printHelpText();
84      }
85  
86      /**
87       * Accept a task from the Cms.
88       *
89       * @param taskid the id of the task to accept.
90       */
91      public void acceptTask(String taskId) {
92          try {
93              int id = Integer.parseInt(taskId);
94              m_cms.acceptTask(id);
95          }
96          catch(Exception exc) {
97              CmsShell.printException(exc);
98          }
99      }
100 
101     /**
102      * Checks, if the user may create this resource.
103      *
104      * @param resource the resource to check.
105      */
106     public void accessCreate(String resource) {
107         try {
108 
109             //System.out.println(m_cms.accessCreate(m_cms.readFileHeader(resource)));
110             // ednfal: resource is read later in resourcebroker
111             System.out.println(m_cms.accessCreate(resource));
112         }
113         catch(Exception exc) {
114             CmsShell.printException(exc);
115         }
116     }
117 
118     /**
119      * Checks, if the user may lock this resource.
120      *
121      * @param resource the resource to check.
122      */
123     public void accessLock(String resource) {
124         try {
125 
126             //System.out.println(m_cms.accessLock(m_cms.readFileHeader(resource)));
127             // ednfal: resource is read later in resourcebroker
128             System.out.println(m_cms.accessLock(resource));
129         }
130         catch(Exception exc) {
131             CmsShell.printException(exc);
132         }
133     }
134 
135     /**
136      * Tests if the user can access the project.
137      *
138      * @param id the id of the project.
139      */
140     public void accessProject(String id) {
141         try {
142             int projectId = Integer.parseInt(id);
143             System.out.println(m_cms.accessProject(projectId));
144         }
145         catch(Exception exc) {
146             CmsShell.printException(exc);
147         }
148     }
149 
150     /**
151      * Checks, if the user may read this resource.
152      *
153      * @param resource The resource to check.
154      */
155     public void accessRead(String resource) {
156         try {
157 
158             //System.out.println(m_cms.accessRead(m_cms.readFileHeader(resource)));
159             // ednfal: resource is read later in resourcebroker
160             System.out.println(m_cms.accessRead(resource));
161         }
162         catch(Exception exc) {
163             CmsShell.printException(exc);
164         }
165     }
166 
167     /**
168      * Tests if the user can write the resource.
169      *
170      * @param resource the name of the resource.
171      */
172     public void accessWrite(String resource) {
173         try {
174 
175             //CmsResource res = m_cms.readFileHeader(resource);
176             //System.out.println( m_cms.accessWrite(res) );
177             // ednfal: resource is read later in resourcebroker
178             System.out.println(m_cms.accessWrite(resource));
179         }
180         catch(Exception exc) {
181             CmsShell.printException(exc);
182         }
183     }
184 
185     /**
186      * adds a file extension.
187      * @param extension a file extension, e.g. 'html'
188      * @param resourceType, name of a resource type like 'page'
189      */
190     public void addFileExtension(String extension, String resourceType) {
191         try {
192             m_cms.addFileExtension(extension, resourceType);
193         }
194         catch(Exception exc) {
195             CmsShell.printException(exc);
196         }
197     }
198 
199     /**
200      * Adds a Group to the cms.
201      *
202      * @param name The name of the new group.
203      * @param description The description for the new group.
204      */
205     public void addGroup(String name, String description) {
206         try {
207             m_cms.addGroup(name, description, C_FLAG_ENABLED, null);
208         }
209         catch(Exception exc) {
210             CmsShell.printException(exc);
211         }
212     }
213 
214     /**
215      * Adds a Group to the cms.
216      *
217      * @param name The name of the new group.
218      * @param description The description for the new group.
219      * @param flags The flags for the new group.
220      * @param name The name of the parent group (or null).
221      */
222     public void addGroup(String name, String description, String flags, String parent) {
223         try {
224             m_cms.addGroup(name, description, Integer.parseInt(flags), parent);
225         }
226         catch(Exception exc) {
227             CmsShell.printException(exc);
228         }
229     }
230 
231     /**
232      * Adds a user to the cms.
233      *
234      * @param name The new name for the user.
235      * @param password The new password for the user.
236      * @param group The default groupname for the user.
237      * @param description The description for the user.
238      */
239     public void addUser(String name, String password, String group, String description) {
240         try {
241             System.out.println(m_cms.addUser(name, password, group, description, new Hashtable(), C_FLAG_ENABLED));
242         }
243         catch(Exception exc) {
244             CmsShell.printException(exc);
245         }
246     }
247 
248     /**
249      * Adds a user to the cms.
250      *
251      * @param name The new name for the user.
252      * @param password The new password for the user.
253      * @param group The default groupname for the user.
254      * @param description The description for the user.
255      * @param flags The flags for the user.
256      */
257     public void addUser(String name, String password, String group, String description, String flags) {
258         try {
259             System.out.println(m_cms.addUser(name, password, group, description, new Hashtable(), Integer.parseInt(flags)));
260         }
261         catch(Exception exc) {
262             CmsShell.printException(exc);
263         }
264     }
265 
266     /**
267      * Adds a user to the cms.
268      *
269      * @param name The new name for the user.
270      * @param password The new password for the user.
271      * @param group The default groupname for the user.
272      * @param description The description for the user.
273      * @param flags The flags for the user.
274      */
275     public void addUser(String name, String password, String group, String description, String firstname, String lastname, String email) {
276         try {
277             CmsUser user = m_cms.addUser(name, password, group, description, new Hashtable(), C_FLAG_ENABLED);
278             user.setEmail(email);
279             user.setFirstname(firstname);
280             user.setLastname(lastname);
281             m_cms.writeUser(user);
282         }
283         catch(Exception exc) {
284             CmsShell.printException(exc);
285         }
286     }
287 
288     /**
289      * Adds a user to a group.
290      *
291      * @param username The name of the user that is to be added to the group.
292      * @param groupname The name of the group.
293      */
294     public void addUserToGroup(String username, String groupname) {
295         try {
296             m_cms.addUserToGroup(username, groupname);
297         }
298         catch(Exception exc) {
299             CmsShell.printException(exc);
300         }
301     }
302 
303     /**
304      * Adds a web user to the Cms.
305      * <br>
306      * A web user has no access to the workplace but is able to access personalized
307      * functions controlled by the OpenCms.
308      *
309      * @param name the new name for the user.
310      * @param password the new password for the user.
311      * @param group the default groupname for the user.
312      * @param description the description for the user.
313      * @param flags the flags for a user (e.g. C_FLAG_ENABLED)
314      *
315      */
316     public void addWebUser(String name, String password, String group, String description, String flags) {
317         try {
318             int intFlags = Integer.parseInt(flags);
319             System.out.println(m_cms.addWebUser(name, password, group, description, new Hashtable(), intFlags));
320         }
321         catch(Exception exc) {
322             CmsShell.printException(exc);
323         }
324     }
325 
326     /**
327      * Adds a web user to the Cms.
328      * <br>
329      * A web user has no access to the workplace but is able to access personalized
330      * functions controlled by the OpenCms.
331      *
332      * @param name the new name for the user.
333      * @param password the new password for the user.
334      * @param group the default groupname for the user.
335      * @param additionalGroup the additional group for the user.
336      * @param description the description for the user.
337      * @param flags the flags for a user (e.g. C_FLAG_ENABLED)
338      *
339      */
340     public void addWebUser(String name, String password, String group, String additionalGroup, String description, String flags) {
341         try {
342             int intFlags = Integer.parseInt(flags);
343             System.out.println(m_cms.addWebUser(name, password, group, additionalGroup, description, new Hashtable(), intFlags));
344         }
345         catch(Exception exc) {
346             CmsShell.printException(exc);
347         }
348     }
349 
350     /**
351      * Returns the anonymous user object.
352      *
353      * @return a <code>CmsUser</code> object representing the anonymous user.
354      */
355     public void anonymousUser() {
356         try {
357             System.out.println(m_cms.anonymousUser());
358         }
359         catch(Exception exc) {
360             CmsShell.printException(exc);
361         }
362     }
363 
364     /**
365      * Changes the group for this resource<BR/>
366      *
367      * The user may change this, if he is admin of the resource.
368      *
369      * @param filename The complete path to the resource.
370      * @param newGroup The new of the new group for this resource.
371      */
372     public void chgrp(String filename, String newGroup) {
373         try {
374             m_cms.chgrp(filename, newGroup);
375         }
376         catch(Exception exc) {
377             CmsShell.printException(exc);
378         }
379     }
380 
381     /**
382      * Changes the flags for this resource<BR/>
383      *
384      * The user may change the flags, if he is admin of the resource.
385      *
386      * @param filename The complete path to the resource.
387      * @param flags The new flags for the resource.
388      */
389     public void chmod(String filename, String flags) {
390         try {
391             m_cms.chmod(filename, Integer.parseInt(flags));
392         }
393         catch(Exception exc) {
394             CmsShell.printException(exc);
395         }
396     }
397 
398     /**
399      * Changes the owner for this resource<BR/>
400      *
401      * The user may change this, if he is admin of the resource.
402      *
403      * @param filename The complete path to the resource.
404      * @param newOwner The name of the new owner for this resource.
405      */
406     public void chown(String filename, String newOwner) {
407         try {
408             m_cms.chown(filename, newOwner);
409         }
410         catch(Exception exc) {
411             CmsShell.printException(exc);
412         }
413     }
414 
415     /**
416      * Changes the resourcetype for this resource<BR/>
417      *
418      * The user may change this, if he is admin of the resource.
419      *
420      * @param filename The complete path to the resource.
421      * @param newType The name of the new resourcetype for this resource.
422      */
423     public void chtype(String filename, String newType) {
424         try {
425             m_cms.chtype(filename, newType);
426         }
427         catch(Exception exc) {
428             CmsShell.printException(exc);
429         }
430     }
431 
432     /**
433      * Clears all internal DB-Caches.
434      */
435     public void clearcache() {
436         try {
437             m_cms.clearcache();
438         }
439         catch(Exception exc) {
440             CmsShell.printException(exc);
441         }
442     }
443 
444     /**
445      * Copies the file.
446      *
447      * @param source The complete path of the sourcefile.
448      * @param destination The complete path of the destination.
449      *
450      * @throws CmsException will be thrown, if the file couldn't be copied.
451      * The CmsException will also be thrown, if the user has not the rights
452      * for this resource.
453      */
454     public void copyFile(String source, String destination) {
455         try {
456             m_cms.copyResource(source, destination);
457         }
458         catch(Exception exc) {
459             CmsShell.printException(exc);
460         }
461     }
462 
463     /**
464      * Copies a folder.
465      *
466      * @param source the complete path of the sourcefolder.
467      * @param destination the complete path of the destinationfolder.
468      */
469     public void copyFolder(String source, String destination) {
470         try {
471             // copy the folder with keeping the flags
472             m_cms.copyResource(source, destination, true);
473         }
474         catch(Exception exc) {
475             CmsShell.printException(exc);
476         }
477     }
478 
479     /**
480      * Copies a resource.
481      *
482      * @param source the complete path of the sourcefolder.
483      * @param destination the complete path of the destinationfolder.
484      */
485     public void copyResource(String source, String destination) {
486         try {
487             m_cms.copyResource(source, destination);
488         }
489         catch(Exception exc) {
490             CmsShell.printException(exc);
491         }
492     }
493 
494     /**
495      * Copies a resource from the online project to a new, specified project.<br>
496      * Copying a resource will copy the file header or folder into the specified
497      * offline project and set its state to UNCHANGED.
498      *
499      * @param resource The name of the resource.
500      */
501     public void copyResourceToProject(String resource) {
502         try {
503             m_cms.copyResourceToProject(resource);
504         }
505         catch(Exception exc) {
506             CmsShell.printException(exc);
507         }
508     }
509 
510     /**
511      * Returns a copyright-string for this OpenCms.
512      */
513     public void copyright() {
514         String[] copy = C_COPYRIGHT;
515         for(int i = 0;i < copy.length;i++) {
516             System.out.println(copy[i]);
517         }
518     }
519 
520     /**
521      * Counts the locked resources in a project.
522      *
523      * @param id the id of the project
524      */
525     public void countLockedResources(String id) {
526         try {
527             int intId = Integer.parseInt(id);
528             System.out.println(m_cms.countLockedResources(intId));
529         }
530         catch(Exception exc) {
531             CmsShell.printException(exc);
532         }
533     }
534 
535     /**
536      * Creates a new folder.
537      *
538      * @param folder The complete path to the folder in which the new folder
539      * will be created.
540      * @param newFolderName The name of the new folder (No pathinformation allowed).
541      */
542     public void createFolder(String folder, String newFolderName) {
543         try {
544             System.out.println((CmsFolder)m_cms.createResource(folder, newFolderName, C_TYPE_FOLDER_NAME));
545         }
546         catch(Exception exc) {
547             CmsShell.printException(exc);
548         }
549     }
550 
551     /**
552      * This method creates a new module in the repository.
553      *
554      * @param String modulename the name of the module.
555      * @param String niceModulename another name of the module.
556      * @param String description the description of the module.
557      * @param String author the name of the author.
558      * @param String createDate the creation date of the module
559      * @param String version the version number of the module.
560      */
561     public void createModule(String modulename, String niceModulename, String description, String author, String type, String createDate, String version) {
562 
563         // create the module
564         try {
565             I_CmsRegistry reg = m_cms.getRegistry();
566             int ver = Integer.parseInt(version);
567             long date = Long.parseLong(createDate);
568             reg.createModule(modulename, niceModulename, description, author, type, new HashMap(), date, ver);
569         }
570         catch(Exception exc) {
571             CmsShell.printException(exc);
572         }
573     }
574 
575     /**
576      * Creates a project.
577      *
578      * @param name The name of the project to create
579      * @param description The description for the new project
580      * @param groupname the name of the group to be set
581      */
582     public void createProject(String name, String description, String groupname, String managergroupname) {
583         try {
584             System.out.println(m_cms.createProject(name, description, groupname, managergroupname));
585         }
586         catch(Exception exc) {
587             CmsShell.printException(exc);
588         }
589     }
590 
591     /**
592      * Creates a project.
593      *
594      * @param name The name of the project to create
595      * @param description The description for the new project
596      * @param groupname the name of the group to be set
597      */
598     public void createProject(String name, String description, String groupname, String managergroupname, String projecttype) {
599         try {
600             System.out.println(m_cms.createProject(name, description, groupname, managergroupname, Integer.parseInt(projecttype)));
601         }
602         catch(Exception exc) {
603             CmsShell.printException(exc);
604         }
605     }
606 
607     /**
608      * Creates a default cms project.
609      * This default project has the following properties:<ul>
610      * <li>The users groups is "Users"
611      * <li>The project managers group is "Projectmanager"
612      * <li>All resources are contained in the project
613      * <li>The project will remain after publishing</ul>
614      * 
615      * @param name The name of the project to create
616      * @param description The description for the new project
617      * 
618      */    
619     public void createDefaultProject(String name, String description) {              
620         try {
621             CmsProject project = m_cms.createProject(name, description, C_GROUP_USERS, C_GROUP_PROJECTLEADER, C_PROJECT_TYPE_NORMAL);
622             int id = project.getId();
623             m_cms.getRequestContext().setCurrentProject(id);
624             // copy the VFS folders to the project
625             m_cms.copyResourceToProject(C_ROOT);
626             // copy the COS channels to the project
627             m_cms.setContextToCos();
628             m_cms.copyResourceToProject(C_ROOT);
629             m_cms.setContextToVfs();            
630         }
631         catch(Exception exc) {
632             CmsShell.printException(exc);
633         }
634     }    
635     
636     /**
637      * Creates a new project for the temporary files.
638      *
639      * @throws CmsException if operation was not successful.
640      */
641     public void createTempfileProject() throws CmsException
642     {
643         try {
644             System.out.println(m_cms.createTempfileProject());
645         }
646         catch(Exception exc) {
647             CmsShell.printException(exc);
648         }
649     }
650 
651     /**
652      * Creates the propertydefinition for the resource type.<BR/>
653      *
654      * @param name The name of the propertydefinition to overwrite.
655      * @param resourcetype The name of the resource-type for the propertydefinition.
656      *
657      * @throws CmsException Throws CmsException if something goes wrong.
658      */
659     public void createPropertydefinition(String name, String resourcetype) throws CmsException {
660         try {
661             System.out.println(m_cms.createPropertydefinition(name, resourcetype));
662         }
663         catch(Exception exc) {
664             CmsShell.printException(exc);
665         }
666     }
667 
668     /**
669      * Creates a new task.
670      * <p>
671      * <B>Security:</B>
672      * All users can create a new task.
673      * @param agent the User who will edit the task.
674      * @param role a Usergroup for the task.
675      * @param taskname the name of the task.
676      * @param taskcomment a description of the task.
677      * @param timeout the time when the task must finished.
678      * @param priority the Id for the priority of the task.
679      */
680     public void createTask(String agentName, String roleName, String taskname, String taskcomment, String timeout, String priority) {
681         try {
682             int intPriority = Integer.parseInt(priority);
683             long longTimeout = Long.parseLong(timeout);
684             System.out.println(m_cms.createTask(agentName, roleName, taskname, taskcomment, longTimeout, intPriority));
685         }
686         catch(Exception exc) {
687             CmsShell.printException(exc);
688         }
689     }
690 
691     /**
692      * Creates a new task.
693      * <p>
694      * <B>Security:</B>
695      * All users can create a new task.
696      *
697      * @param projectid the Id of the current project task of the user.
698      * @param agentname the User who will edit the task.
699      * @param rolename a Usergroup for the task.
700      * @param taskname a Name of the task.
701      * @param tasktype the type of the task.
702      * @param taskcomment a description of the task.
703      * @param timeout the time when the task must finished.
704      * @param priority the Id for the priority of the task.
705      */
706     public void createTask(String projectid, String agentName, String roleName,
707             String taskname, String taskcomment, String tasktype, String timeout, String priority) {
708         try {
709             System.out.println(m_cms.createTask(Integer.parseInt(projectid), agentName, roleName, taskname, taskcomment,
710                     Integer.parseInt(tasktype), Long.parseLong(timeout), Integer.parseInt(priority)));
711         }
712         catch(Exception exc) {
713             CmsShell.printException(exc);
714         }
715     }
716 
717     /**
718      * Deletes all propertyinformation for a file or folder.
719      *
720      * @param resource The name of the resource of which the propertyinformations
721      * have to be deleted.
722      */
723     public void deleteAllProperties(String resource) {
724         try {
725             m_cms.deleteAllProperties(resource);
726         }
727         catch(Exception exc) {
728             CmsShell.printException(exc);
729         }
730     }
731 
732     /**
733      * Deletes the file.
734      *
735      * @param filename The complete path of the file.
736      */
737     public void deleteFile(String filename) {
738         try {
739             m_cms.deleteResource(filename);
740         }
741         catch(Exception exc) {
742             CmsShell.printException(exc);
743         }
744     }
745 
746     /**
747      * Deletes the folder.
748      *
749      * @param foldername The complete path of the folder.
750      */
751     public void deleteFolder(String foldername) {
752         try {
753             m_cms.deleteResource(foldername);
754         }
755         catch(Exception exc) {
756             CmsShell.printException(exc);
757         }
758     }
759 
760     /**
761      * Deletes a Resource.
762      *
763      * @param filename the complete path of the sourcefolder.
764      */
765     public void deleteResource(String filename) {
766         try {
767             m_cms.deleteResource(filename);
768         } catch (Exception exc) {
769             CmsShell.printException(exc);
770         }
771     }
772     /**
773      * Undeletes the resource.
774      *
775      * @param resourcename The complete path of the resource.
776      */
777     public void undeleteResource(String resourcename) {
778         try {
779             m_cms.undeleteResource(resourcename);
780         }
781         catch(Exception exc) {
782             CmsShell.printException(exc);
783         }
784     }
785 
786     /**
787      * Delete a group from the Cms.<BR/>
788      *
789      * @param delgroup The name of the group that is to be deleted.
790      */
791     public void deleteGroup(String delgroup) {
792         try {
793             m_cms.deleteGroup(delgroup);
794         }
795         catch(Exception exc) {
796             CmsShell.printException(exc);
797         }
798     }
799 
800     /**
801      * Deletes a module from the cms.
802      *
803      * @param module The name of module to delete.
804      */
805     public void deleteModule(String module) {
806         try {
807             I_CmsRegistry reg = m_cms.getRegistry();
808             reg.deleteModule(module, new Vector(), false, new CmsShellReport());
809         }
810         catch(Exception exc) {
811             CmsShell.printException(exc);
812         }
813     }
814 
815     /**
816      * This method deletes the view for an module.
817      *
818      * @param String the name of the module.
819      */
820     public void deleteModuleView(String modulename) {
821         try {
822             I_CmsRegistry reg = m_cms.getRegistry();
823             reg.deleteModuleView(modulename);
824         }
825         catch(Exception exc) {
826             CmsShell.printException(exc);
827         }
828     }
829 
830     /**
831      * Deletes a project.
832      *
833      * @param id The id of the project to delete.
834      */
835     public void deleteProject(String id) {
836         try {
837             m_cms.deleteProject(Integer.parseInt(id));
838         }
839         catch(Exception exc) {
840             CmsShell.printException(exc);
841         }
842     }
843 
844     /**
845      * Deletes a propertyinformation for a file or folder.
846      *
847      * @param resourcename The resource-name of which the propertyinformation has to be delteted.
848      * @param property The propertydefinition-name of which the propertyinformation has to be set.
849      */
850     public void deleteProperty(String resourcename, String property) {
851         try {
852             m_cms.deleteProperty(resourcename, property);
853         }
854         catch(Exception exc) {
855             CmsShell.printException(exc);
856         }
857     }
858 
859     /**
860      * Delete the propertydefinition for the resource type.<BR/>
861      *
862      * @param name The name of the propertydefinition to overwrite.
863      * @param resourcetype The name of the resource-type for the propertydefinition.
864      */
865     public void deletepropertydefinition(String name, String resourcetype) {
866         try {
867             m_cms.deletePropertydefinition(name, resourcetype);
868         }
869         catch(Exception exc) {
870             CmsShell.printException(exc);
871         }
872     }
873 
874     /**
875      * Deletes a user from the Cms.
876      *
877      * @param name The name of the user to be deleted.
878      */
879     public void deleteUser(String name) {
880         try {
881             m_cms.deleteUser(name);
882         }
883         catch(Exception exc) {
884             CmsShell.printException(exc);
885         }
886     }
887 
888     /**
889      * Deletes a web user from the Cms.
890      *
891      * @param name the id of the user to be deleted.
892      */
893     public void deleteWebUser(String userId) {
894         try {
895             m_cms.deleteWebUser(Integer.parseInt(userId));
896         }
897         catch(Exception exc) {
898             CmsShell.printException(exc);
899         }
900     }
901 
902     /**
903      * Echos the input to output.
904      *
905      * @param echo The echo to be written to output.
906      */
907     public void echo(String echo) {
908         if(echo.toLowerCase().equals("on")) {
909             CmsShell.m_echo = true;
910         }
911         else {
912             if(echo.toLowerCase().equals("off")) {
913                 CmsShell.m_echo = false;
914             }
915             else {
916                 System.out.println(echo);
917             }
918         }
919     }
920 
921     /**
922      * Ends a task of the Cms.
923      *
924      * @param taskid the ID of the task to end.
925      */
926     public void endTask(String taskid) {
927         try {
928             m_cms.endTask(Integer.parseInt(taskid));
929         }
930         catch(Exception exc) {
931             CmsShell.printException(exc);
932         }
933     }
934 
935     /**
936      * Exits the commandline-interface
937      */
938     public void exit() {
939         try {
940             m_openCms.destroy();
941         }
942         catch(CmsException e) {
943             e.printStackTrace();
944         }
945         CmsShell.m_exitCalled = true;
946     }
947 
948     /**
949      * Exports cms-resources to zip. In the zip-file the system - path will be included.
950      *
951      * @param exportFile the name (absolute Path) of the export resource (zip)
952      *
953      * @throws Throws CmsException if something goes wrong.
954      */
955     public void exportAllResources(String exportFile) throws CmsException {
956 
957         // export the resources
958         String[] exportPaths =  {
959             C_ROOT
960         };
961         try {
962             m_cms.exportResources(exportFile, exportPaths, false, false);
963         }
964         catch(Exception exc) {
965             CmsShell.printException(exc);
966         }
967     }
968 
969     /**
970      * Exports cms-resources to zip. In the zip-file the system - path will be included.
971      * Unchanged resources will be ignored.
972      *
973      * @param exportFile the name (absolute Path) of the export resource (zip)
974      *
975      * @throws Throws CmsException if something goes wrong.
976      */
977     public void exportAllResourcesOnlyChanged(String exportFile) throws CmsException {
978 
979         // export the resources
980         String[] exportPaths =  {
981             C_ROOT
982         };
983         try {
984             m_cms.exportResources(exportFile, exportPaths, false, true);
985         }
986         catch(Exception exc) {
987             CmsShell.printException(exc);
988         }
989     }
990 
991     /**
992      * Exports a module.
993      *
994      * @param modulename the name of the module to export
995      * @param resource the folder to export.
996      * @param filename the name of the file to export to.
997      */
998     public void exportModule(String modulename, String resource, String filename) {
999         try {
1000            String[] resources =  {
1001                resource
1002            };
1003            I_CmsRegistry reg = m_cms.getRegistry();
1004            reg.exportModule(modulename, resources, filename, new CmsShellReport());
1005        }
1006        catch(Exception exc) {
1007            CmsShell.printException(exc);
1008        }
1009    }
1010
1011    /**
1012     * Exports cms-resources to zip.
1013     *
1014     * @param exportFile the name (absolute Path) of the export resource (zip)
1015     * @param pathList the names (absolute Path) of folders from which should be exported
1016     *          separated by semicolons
1017     *
1018     * @throws Throws CmsException if something goes wrong.
1019     */
1020    public void exportResources(String exportFile, String pathList) throws CmsException {
1021
1022        // export the resources
1023        StringTokenizer tok = new StringTokenizer(pathList, ";");
1024        Vector paths = new Vector();
1025        while(tok.hasMoreTokens()) {
1026            paths.addElement(tok.nextToken());
1027        }
1028        String exportPaths[] = new String[paths.size()];
1029        for(int i = 0;i < paths.size();i++) {
1030            exportPaths[i] = (String)paths.elementAt(i);
1031        }
1032        boolean excludeSystem = true;
1033        if(pathList.startsWith("/system/") || (pathList.indexOf(";/system/") > -1)) {
1034            excludeSystem = false;
1035        }
1036        try {
1037            m_cms.exportResources(exportFile, exportPaths, excludeSystem, false);
1038        }
1039        catch(Exception exc) {
1040            CmsShell.printException(exc);
1041        }
1042    }
1043
1044    /**
1045     * Exports cms-resources to zip.
1046     *
1047     * @param exportFile the name (absolute Path) of the export resource (zip)
1048     * @param pathList the names (absolute Path) of folders from which should be exported
1049     *          separated by semicolons
1050     *
1051     * @throws Throws CmsException if something goes wrong.
1052     */
1053    public void exportResourcesAndUserdata(String exportFile, String pathList) throws CmsException {
1054
1055        // export the resources
1056        StringTokenizer tok = new StringTokenizer(pathList, ";");
1057        Vector paths = new Vector();
1058        while(tok.hasMoreTokens()) {
1059            paths.addElement(tok.nextToken());
1060        }
1061        String exportPaths[] = new String[paths.size()];
1062        for(int i = 0;i < paths.size();i++) {
1063            exportPaths[i] = (String)paths.elementAt(i);
1064        }
1065        boolean excludeSystem = true;
1066        if(pathList.startsWith("/system/") || (pathList.indexOf(";/system/") > -1)) {
1067            excludeSystem = false;
1068        }
1069        try {
1070            m_cms.exportResources(exportFile, exportPaths, excludeSystem, false, true);
1071        }
1072        catch(Exception exc) {
1073            CmsShell.printException(exc);
1074        }
1075    }
1076
1077    /**
1078     * Exports cms-resources to zip.
1079     * Unchanged resources will be ignored.
1080     *
1081     * @param exportFile the name (absolute Path) of the export resource (zip)
1082     * @param pathList the names (absolute Path) of folders from which should be exported
1083     *          separated by semicolons
1084     *
1085     * @throws Throws CmsException if something goes wrong.
1086     */
1087    public void exportResourcesOnlyChanged(String exportFile, String pathList) throws CmsException {
1088
1089        // export the resources
1090        StringTokenizer tok = new StringTokenizer(pathList, ";");
1091        Vector paths = new Vector();
1092        while(tok.hasMoreTokens()) {
1093            paths.addElement(tok.nextToken());
1094        }
1095        String exportPaths[] = new String[paths.size()];
1096        for(int i = 0;i < paths.size();i++) {
1097            exportPaths[i] = (String)paths.elementAt(i);
1098        }
1099        boolean excludeSystem = true;
1100        if(pathList.startsWith("/system/") || (pathList.indexOf(";/system/") > -1)) {
1101            excludeSystem = false;
1102        }
1103        try {
1104            m_cms.exportResources(exportFile, exportPaths, excludeSystem, true);
1105        }
1106        catch(Exception exc) {
1107            CmsShell.printException(exc);
1108        }
1109    }
1110
1111    /**
1112     * Forwards a task to a new user.
1113     *
1114     * @param taskid the id of the task which will be forwarded.
1115     * @param newRole the new group for the task.
1116     * @param newUser the new user who gets the task.
1117     */
1118    public void forwardTask(String taskid, String newRoleName, String newUserName) {
1119        try {
1120            m_cms.forwardTask(Integer.parseInt(taskid), newRoleName, newUserName);
1121        }
1122        catch(Exception exc) {
1123            CmsShell.printException(exc);
1124        }
1125    }
1126
1127    /**
1128     * Returns all projects, which the user may access.
1129     *
1130     * @return a Vector of projects.
1131     */
1132    public void getAllAccessibleProjects() {
1133        try {
1134            Vector projects = m_cms.getAllAccessibleProjects();
1135            for(int i = 0;i < projects.size();i++) {
1136                System.out.println((CmsProject)projects.elementAt(i));
1137            }
1138        }
1139        catch(Exception exc) {
1140            CmsShell.printException(exc);
1141        }
1142    }
1143
1144    /**
1145     * Returns all projects which are owned by the current user or which are manageable
1146     * for the group of the user.
1147     */
1148    public void getAllManageableProjects() {
1149        try {
1150            Vector projects = m_cms.getAllManageableProjects();
1151            for(int i = 0;i < projects.size();i++) {
1152                CmsProject project = (CmsProject)projects.elementAt(i);
1153                System.out.println(project);
1154            }
1155        }
1156        catch(Exception exc) {
1157            CmsShell.printException(exc);
1158        }
1159    }
1160
1161    /**
1162     * Returns  all I_CmsResourceTypes.
1163     */
1164    public void getAllResourceTypes() {
1165        try {
1166            Hashtable resourceTypes = m_cms.getAllResourceTypes();
1167            Enumeration keys = resourceTypes.keys();
1168            while(keys.hasMoreElements()) {
1169                System.out.println(resourceTypes.get(keys.nextElement()));
1170            }
1171        }
1172        catch(Exception exc) {
1173            CmsShell.printException(exc);
1174        }
1175    }
1176
1177    /**
1178     * Gets information about the cache size.
1179     * <br>
1180     * The size of the following caching areas is returned:
1181     * <ul>
1182     *  <li>GroupCache</li>
1183     *  <li>UserGroupCache</li>
1184     *  <li>ResourceCache</li>
1185     *  <li>SubResourceCache</li>
1186     *  <li>ProjectCache</li>
1187     *  <li>PropertyCache</li>
1188     *  <li>PropertyDefinitionCache</li>
1189     *  <li>PropertyDefinitionVectorCache</li>
1190     * </ul>
1191     */
1192    public void getCacheInfo() {
1193        try {
1194            Hashtable cacheInfo = m_cms.getCacheInfo();
1195            Enumeration keys = cacheInfo.keys();
1196            while(keys.hasMoreElements()) {
1197                String key = (String)keys.nextElement();
1198                String info = (String)cacheInfo.get(key);
1199                System.out.println("\t" + key + ": " + info);
1200            }
1201        }
1202        catch(Exception exc) {
1203            CmsShell.printException(exc);
1204        }
1205    }
1206
1207    /**
1208     * Returns all child groups of a group<P/>
1209     *
1210     * @param groupname The name of the group.
1211     */
1212    public void getChild(String groupname) {
1213        try {
1214            Vector groups = m_cms.getChild(groupname);
1215            for(int i = 0;i < groups.size();i++) {
1216                System.out.println((CmsGroup)groups.elementAt(i));
1217            }
1218        }
1219        catch(Exception exc) {
1220            CmsShell.printException(exc);
1221        }
1222    }
1223
1224    /**
1225     * Returns all child groups of a group<P/>
1226     * This method also returns all sub-child groups of the current group.
1227     *
1228     * @param groupname The name of the group.
1229     */
1230    public void getChilds(String groupname) {
1231        try {
1232            Vector groups = m_cms.getChilds(groupname);
1233            for(int i = 0;i < groups.size();i++) {
1234                System.out.println((CmsGroup)groups.elementAt(i));
1235            }
1236        }
1237        catch(Exception exc) {
1238            CmsShell.printException(exc);
1239        }
1240    }
1241
1242    /**
1243     * Returns the current project for the user.
1244     */
1245    public void getCurrentProject() {
1246        System.out.println(m_cms.getRequestContext().currentProject().toString());
1247    }
1248
1249    /**
1250     * Gets all groups to which a given user directly belongs.
1251     *
1252     * @param username the name of the user to get all groups for.
1253     * @return a Vector of all groups of a user.
1254     */
1255    public void getDirectGroupsOfUser(String username) {
1256        try {
1257            Vector groups = m_cms.getDirectGroupsOfUser(username);
1258            for(int i = 0;i < groups.size();i++) {
1259                System.out.println((CmsGroup)groups.elementAt(i));
1260            }
1261        }
1262        catch(Exception exc) {
1263            CmsShell.printException(exc);
1264        }
1265    }
1266
1267    /**
1268     * Returns a Vector with all subfiles.<BR/>
1269     *
1270     * @param foldername the complete path to the folder.
1271     *
1272     * @return subfiles A Vector with all subfiles for the overgiven folder.
1273     *
1274     * @throws CmsException will be thrown, if the user has not the rights
1275     * for this resource.
1276     */
1277    public void getFilesInFolder(String foldername) {
1278        try {
1279            Vector files = m_cms.getFilesInFolder(foldername);
1280            for(int i = 0;i < files.size();i++) {
1281                System.out.println((CmsFile)files.elementAt(i));
1282            }
1283        }
1284        catch(Exception exc) {
1285            CmsShell.printException(exc);
1286        }
1287    }
1288
1289    /**
1290     * Returns a Vector with all resource-names of the resources that have set the given property to the given value.
1291     *
1292     * @param propertydef the name of the property-definition to check.
1293     * @param property the value of the property for the resource.
1294     */
1295    public void getFilesWithProperty(String propertyDefinition, String propertyValue) {
1296        try {
1297            Vector files = m_cms.getFilesWithProperty(propertyDefinition, propertyValue);
1298            for(int i = 0;i < files.size();i++) {
1299                System.out.println((CmsFile)files.elementAt(i));
1300            }
1301        }
1302        catch(Exception exc) {
1303            CmsShell.printException(exc);
1304        }
1305    }
1306
1307    /**
1308     * This method can be called, to determine if the file-system was changed
1309     * in the past. A module can compare its previosly stored number with this
1310     * returned number. If they differ, a change was made.
1311     *
1312     * @return the number of file-system-changes.
1313     */
1314    public void getFileSystemChanges() {
1315        System.out.println(m_cms.getFileSystemChanges());
1316    }
1317
1318    /**
1319     * Returns a Vector with the complete folder-tree for this project.<br>
1320     *
1321     * Subfolders can be read from an offline project and the online project. <br>
1322     */
1323    public void getFolderTree() {
1324        try {
1325            Vector folders = m_cms.getFolderTree();
1326            for(int i = 0;i < folders.size();i++) {
1327                System.out.println((CmsFolder)folders.elementAt(i));
1328            }
1329        }
1330        catch(Exception exc) {
1331            CmsShell.printException(exc);
1332        }
1333    }
1334
1335    /**
1336     * Returns all users of the cms.
1337     */
1338    public void getGroups() {
1339        try {
1340            Vector groups = m_cms.getGroups();
1341            for(int i = 0;i < groups.size();i++) {
1342                System.out.println((CmsGroup)groups.elementAt(i));
1343            }
1344        }
1345        catch(Exception exc) {
1346            CmsShell.printException(exc);
1347        }
1348    }
1349
1350    /**
1351     * Returns all groups of a user.
1352     *
1353     * @param username The name of the user.
1354     */
1355    public void getGroupsOfUser(String username) {
1356        try {
1357            Vector groups = m_cms.getGroupsOfUser(username);
1358            for(int i = 0;i < groups.size();i++) {
1359                System.out.println((CmsGroup)groups.elementAt(i));
1360            }
1361        }
1362        catch(Exception exc) {
1363            CmsShell.printException(exc);
1364        }
1365    }
1366
1367    /**
1368     * Prints out all files for a module.
1369     *
1370     * @param moduleZip The file-name of module to import.
1371     */
1372    public void getModuleFiles(String name) {
1373        try {
1374            I_CmsRegistry reg = m_cms.getRegistry();
1375            Vector names = new Vector();
1376            Vector codes = new Vector();
1377            reg.getModuleFiles(name, names, codes);
1378            for(int i = 0;i < names.size();i++) {
1379                System.out.print(names.elementAt(i));
1380                System.out.print(" -> ");
1381                System.out.println(codes.elementAt(i));
1382            }
1383        }
1384        catch(Exception exc) {
1385            CmsShell.printException(exc);
1386        }
1387    }
1388
1389    /**
1390     * Imports a module into the cms.
1391     *
1392     * @param moduleZip The file-name of module to import.
1393     */
1394    public void getModuleInfo() {
1395        try {
1396            I_CmsRegistry reg = m_cms.getRegistry();
1397            java.util.Enumeration names = reg.getModuleNames();
1398
1399            // print out the available modules
1400            while(names.hasMoreElements()) {
1401                String name = (String)names.nextElement();
1402                getModuleInfo(name);
1403            }
1404            System.out.println("\ngeneral stuff");
1405            System.out.println("\tall repositories: ");
1406            String[] repositories = reg.getRepositories();
1407            for(int i = 0;i < repositories.length;i++) {
1408                System.out.println("\t\t" + repositories[i]);
1409            }
1410            System.out.println("\tall views: ");
1411            java.util.Vector views = new java.util.Vector();
1412            java.util.Vector urls = new java.util.Vector();
1413            int max = reg.getViews(views, urls);
1414            for(int i = 0;i < max;i++) {
1415                System.out.println("\t\t" + views.elementAt(i) + " -> " + urls.elementAt(i));
1416            }
1417        }
1418        catch(Exception exc) {
1419            CmsShell.printException(exc);
1420        }
1421    }
1422
1423    /**
1424     * Prints out informations about a module.
1425     *
1426     * @param String module the name of the module to get infos about.
1427     */
1428    public void getModuleInfo(String name) {
1429        try {
1430            I_CmsRegistry reg = m_cms.getRegistry();
1431            if(reg.moduleExists(name)) {
1432                System.out.println("\nModule: " + name + " v" + reg.getModuleVersion(name));
1433                System.out.println("\tNice Name: " + reg.getModuleNiceName(name));
1434                System.out.println("\tDescription: " + reg.getModuleDescription(name));
1435                System.out.println("\tAuthor: " + reg.getModuleAuthor(name));
1436                System.out.println("\tUploaded by: " + reg.getModuleUploadedBy(name));
1437                System.out.println("\tEmail: " + reg.getModuleAuthorEmail(name));
1438                System.out.println("\tCreationdate: " + new java.util.Date(reg.getModuleCreateDate(name)));
1439                System.out.println("\tUploaddate: " + new java.util.Date(reg.getModuleUploadDate(name)));
1440                System.out.println("\tDocumentationPath: " + reg.getModuleDocumentPath(name));
1441                String[] repositories = reg.getModuleRepositories(name);
1442                System.out.println("\trepositories: ");
1443                if(repositories != null) {
1444                    for(int i = 0;i < repositories.length;i++) {
1445                        System.out.println("\t\t" + repositories[i]);
1446                    }
1447                }
1448                String[] parameters = reg.getModuleParameterNames(name);
1449                System.out.println("\tparameters: ");
1450                if(parameters != null) {
1451                    for(int i = 0;i < parameters.length;i++) {
1452                        System.out.print("\t\t" + parameters[i]);
1453                        System.out.print(" = " + reg.getModuleParameter(name, parameters[i]));
1454                        System.out.print(" is " + reg.getModuleParameterType(name, parameters[i]));
1455                        System.out.println("  (" + reg.getModuleParameterDescription(name, parameters[i]) + ")");
1456                    }
1457                }
1458                System.out.println("\tWiew name: "<