KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > opencms > workplace > CmsAdminProjectNew


1 /*
2 * File : $Source: /usr/local/cvs/opencms/src-modules/com/opencms/workplace/CmsAdminProjectNew.java,v $
3 * Date : $Date: 2005/06/27 23:22:07 $
4 * Version: $Revision: 1.5 $
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
30 package com.opencms.workplace;
31
32 import org.opencms.file.CmsGroup;
33 import org.opencms.file.CmsObject;
34 import org.opencms.file.CmsProject;
35 import org.opencms.file.CmsRequestContext;
36 import org.opencms.file.CmsResource;
37 import org.opencms.main.CmsException;
38 import org.opencms.main.CmsLog;
39 import org.opencms.main.OpenCms;
40 import org.opencms.workplace.CmsWorkplace;
41
42 import com.opencms.core.I_CmsSession;
43 import com.opencms.legacy.CmsXmlTemplateLoader;
44 import com.opencms.template.CmsXmlTemplateFile;
45
46 import java.util.Collections JavaDoc;
47 import java.util.Hashtable JavaDoc;
48 import java.util.List JavaDoc;
49 import java.util.StringTokenizer JavaDoc;
50 import java.util.Vector JavaDoc;
51
52 /**
53  * Template class for displaying OpenCms workplace admin project screens.
54  * <P>
55  *
56  * @author Andreas Schouten
57  * @author Michael Emmerich
58  * @author Mario Stanke
59  * @version $Revision: 1.5 $ $Date: 2005/06/27 23:22:07 $
60  * @see com.opencms.workplace.CmsXmlWpTemplateFile
61  *
62  * @deprecated Will not be supported past the OpenCms 6 release.
63  */

64
65 public class CmsAdminProjectNew extends CmsWorkplaceDefault {
66
67
68     /** Session key */
69     private static String JavaDoc C_NEWNAME = "new_project_name";
70
71
72     /** Session key */
73     private static String JavaDoc C_NEWDESCRIPTION = "new_project_description";
74
75
76     /** Session key */
77     private static String JavaDoc C_NEWGROUP = "new_project_group";
78
79
80     /** Session key */
81     private static String JavaDoc C_NEWMANAGERGROUP = "new_project_managergroup";
82
83     /** Session key */
84     private static String JavaDoc C_NEWFOLDER = "new_project_folder";
85
86
87     /** Session key */
88     private static String JavaDoc C_NEWTYPE = "projecttype";
89
90     /** Session key */
91     private static String JavaDoc C_NEWRESOURCES = "ALLRES";
92
93     /** Session key */
94     private static String JavaDoc C_NEWCHANNELS = "ALLCHAN";
95
96     /** Check whether some of the resources are redundant because a superfolder has also
97      * been selected.
98      *
99      * @param resources containts the full pathnames of all the resources
100      * @return A vector with the same resources, but the paths in the return value are disjoint
101      */

102
103     private void checkRedundancies(Vector JavaDoc resources) {
104         int i, j;
105         if(resources == null) {
106             return ;
107         }
108         Vector JavaDoc redundant = new Vector JavaDoc();
109         int n = resources.size();
110         if(n < 2) {
111
112             // no check needed, because there is only one resource or
113
// no resources selected, return empty Vector
114
return ;
115         }
116         for(i = 0;i < n;i++) {
117             redundant.addElement(new Boolean JavaDoc(false));
118         }
119         for(i = 0;i < n - 1;i++) {
120             for(j = i + 1;j < n;j++) {
121                 if(((String JavaDoc)resources.elementAt(i)).length() <
122                         ((String JavaDoc)resources.elementAt(j)).length()) {
123                     if(((String JavaDoc)resources.elementAt(j)).startsWith((String JavaDoc)resources.elementAt(i))) {
124                         redundant.setElementAt(new Boolean JavaDoc(true), j);
125                     }
126                 }
127                 else {
128                     if(((String JavaDoc)resources.elementAt(i)).startsWith((String JavaDoc)resources.elementAt(j))) {
129                         redundant.setElementAt(new Boolean JavaDoc(true), i);
130                     }
131                 }
132             }
133         }
134         for(i = n - 1;i >= 0;i--) {
135             if(((Boolean JavaDoc)redundant.elementAt(i)).booleanValue()) {
136                 resources.removeElementAt(i);
137             }
138         }
139     }
140
141     /**
142      * Gets the content of a defined section in a given template file and its subtemplates
143      * with the given parameters.
144      *
145      * @see #getContent(CmsObject, String, String, Hashtable, String)
146      * @param cms CmsObject Object for accessing system resources.
147      * @param templateFile Filename of the template file.
148      * @param elementName Element name of this template in our parent template.
149      * @param parameters Hashtable with all template class parameters.
150      * @param templateSelector template section that should be processed.
151      */

152     public byte[] getContent(CmsObject cms, String JavaDoc templateFile, String JavaDoc elementName,
153             Hashtable JavaDoc parameters, String JavaDoc templateSelector) throws CmsException {
154         if(CmsLog.getLog(this).isDebugEnabled() && C_DEBUG) {
155             CmsLog.getLog(this).debug("Getting content of element " + ((elementName==null)?"<root>":elementName));
156             CmsLog.getLog(this).debug("Template file is: " + templateFile);
157             CmsLog.getLog(this).debug("Selected template section is: " + ((templateSelector==null)?"<default>":templateSelector));
158         }
159         I_CmsSession session = CmsXmlTemplateLoader.getSession(cms.getRequestContext(), true);
160         CmsRequestContext reqCont = cms.getRequestContext();
161         CmsXmlLanguageFile lang = new CmsXmlLanguageFile(cms);
162         // clear session values on first load
163
String JavaDoc initial = (String JavaDoc)parameters.get(CmsWorkplaceDefault.C_PARA_INITIAL);
164         if(initial != null) {
165
166             // remove all session values
167
session.removeValue(C_NEWNAME);
168             session.removeValue(C_NEWGROUP);
169             session.removeValue(C_NEWDESCRIPTION);
170             session.removeValue(C_NEWMANAGERGROUP);
171             session.removeValue(C_NEWFOLDER);
172             session.removeValue(C_NEWRESOURCES);
173             session.removeValue(C_NEWCHANNELS);
174             session.removeValue(C_NEWTYPE);
175             session.removeValue("lasturl");
176             session.removeValue("newProjectCallingFrom");
177             reqCont.setCurrentProject(cms.readProject(CmsProject.ONLINE_PROJECT_ID));
178         }
179         String JavaDoc newName, newGroup, newDescription, newManagerGroup;
180         int projectType = 0;
181         String JavaDoc newType = new String JavaDoc();
182         String JavaDoc action = new String JavaDoc();
183         action = (String JavaDoc)parameters.get("action");
184         CmsXmlTemplateFile xmlTemplateDocument = getOwnTemplateFile(cms, templateFile,
185                 elementName, parameters, templateSelector);
186
187         //look if we come from the explorer view
188
String JavaDoc fileToGo = (String JavaDoc)parameters.get(CmsWorkplaceDefault.C_PARA_RESOURCE);
189         if (fileToGo == null){
190             fileToGo = (String JavaDoc)session.getValue("newProjectCallingFrom");
191         } else {
192             CmsResource resource = cms.readResource(fileToGo);
193             if (resource.isFolder() && !resource.getRootPath().endsWith("/")) {
194                 fileToGo += "/";
195             }
196         }
197         String JavaDoc lasturl = (String JavaDoc)parameters.get("lasturl");
198         if (lasturl == null){
199             lasturl = (String JavaDoc)session.getValue("lasturl");
200         }
201         newName = (String JavaDoc)parameters.get(CmsWorkplaceDefault.C_PROJECTNEW_NAME);
202         if(newName == null) {
203             newName = (String JavaDoc)session.getValue(C_NEWNAME);
204         }
205         String JavaDoc errorTemplateAddOn = "";
206         if (fileToGo != null){
207             // this is from the explorer view
208
if(!cms.isManagerOfProject()){
209                 // user has no rights to create a project
210
return startProcessing(cms, xmlTemplateDocument, elementName,parameters, "norigths");
211             }
212             errorTemplateAddOn = "explorer";
213             session.putValue("newProjectCallingFrom", fileToGo);
214             xmlTemplateDocument.setData("pathCorrection","");
215             xmlTemplateDocument.setData("backButton",lasturl);
216             xmlTemplateDocument.setData("myUrl","resource_to_project.html");
217             xmlTemplateDocument.setData("dontDoIt", " //");
218             // we have to put the file in the box and set the projectname
219
xmlTemplateDocument.setData("doThis","addFolder(document.PROJECTNEW.new_ressources,'"+fileToGo+"');");
220             if (newName == null){
221                 newName = getProjectName(cms,fileToGo);
222             }
223         }else{
224             // this is from the administration view
225
xmlTemplateDocument.setData("pathCorrection","../../");
226             xmlTemplateDocument.setData("backButton","../../../action/administration_content_top.html?sender=" + CmsWorkplace.VFS_PATH_WORKPLACE + "administration/project/");
227             xmlTemplateDocument.setData("myUrl","index.html");
228             xmlTemplateDocument.setData("dontDoIt", "");
229             xmlTemplateDocument.setData("doThis","");
230         }
231
232         xmlTemplateDocument.setData("onlineId", "" + CmsProject.ONLINE_PROJECT_ID);
233
234         newGroup = (String JavaDoc)parameters.get(CmsWorkplaceDefault.C_PROJECTNEW_GROUP);
235         newDescription = (String JavaDoc)parameters.get(CmsWorkplaceDefault.C_PROJECTNEW_DESCRIPTION);
236         newManagerGroup = (String JavaDoc)parameters.get(CmsWorkplaceDefault.C_PROJECTNEW_MANAGERGROUP);
237         String JavaDoc allResources = (String JavaDoc)parameters.get(C_NEWRESOURCES);
238         String JavaDoc allChannels = (String JavaDoc)parameters.get(C_NEWCHANNELS);
239         newType = (String JavaDoc)parameters.get(C_NEWTYPE);
240
241         // if there are still values in the session (like after an error), use them
242
if(newGroup == null) {
243             newGroup = (String JavaDoc)session.getValue(C_NEWGROUP);
244         }
245         if(newDescription == null) {
246             newDescription = (String JavaDoc)session.getValue(C_NEWDESCRIPTION);
247         }
248         if(newManagerGroup == null) {
249             newManagerGroup = (String JavaDoc)session.getValue(C_NEWMANAGERGROUP);
250         }
251         if(allResources == null) {
252             allResources = (String JavaDoc)session.getValue(C_NEWRESOURCES);
253         }
254         if(allChannels == null) {
255             allChannels = (String JavaDoc)session.getValue(C_NEWCHANNELS);
256         }
257         if(newType == null) {
258             newType = (String JavaDoc)session.getValue(C_NEWTYPE);
259         }
260         if(newName == null) {
261             newName = "";
262         }
263         if(newGroup == null) {
264             newGroup = "";
265         }
266         if(newDescription == null) {
267             newDescription = "";
268         }
269         if(newManagerGroup == null) {
270             newManagerGroup = "";
271         }
272         if(allResources == null) {
273             allResources = "";
274         }
275         if(allChannels == null) {
276             allChannels = "";
277         }
278         if(newType == null || "".equals(newType)) {
279             projectType = CmsProject.PROJECT_TYPE_NORMAL;
280             newType = "";
281         } else {
282             projectType = CmsProject.PROJECT_TYPE_TEMPORARY;
283         }
284
285         if(parameters.get("submitform") != null) {
286             // the form has just been submitted, store the data in the session
287
session.putValue(C_NEWNAME, newName);
288             session.putValue(C_NEWGROUP, newGroup);
289             session.putValue(C_NEWDESCRIPTION, newDescription);
290             session.putValue(C_NEWMANAGERGROUP, newManagerGroup);
291             session.putValue(C_NEWTYPE, newType);
292             session.putValue(C_NEWCHANNELS, allChannels);
293             if(newName.equals("") || newGroup.equals("") || newManagerGroup.equals("")
294                     || (allResources.equals("") && allChannels.equals(""))) {
295                 templateSelector = "datamissing"+errorTemplateAddOn;
296             }
297             else {
298                 session.putValue(C_NEWRESOURCES, allResources);
299                 // all the required data has been entered, display 'Please wait'
300
templateSelector = "wait";
301                 action = "start";
302             }
303         }
304
305         // is the wait-page showing?
306
if("working".equals(action)) {
307             // create new Project
308
try {
309                 // append the C_VFS_GALLERY_PICS and C_VFS_GALLERY_DOWNLOAD path to the list of all resources
310
String JavaDoc picspath = getConfigFile(cms).getPicGalleryPath();
311                 String JavaDoc downloadpath = getConfigFile(cms).getDownGalleryPath();
312                 String JavaDoc linkpath = getConfigFile(cms).getLinkGalleryPath();
313                 String JavaDoc htmlPath = getConfigFile(cms).getHtmlGalleryPath();
314                 allResources = allResources + ";" + picspath + ";"
315                         + downloadpath + ";" + linkpath + ";" + htmlPath;
316                 // 'allResurces' has the "form res1;res2;...resk;"
317
// this is because the simpler 'getParameterValues' method doesn't work with Silverstream
318
Vector JavaDoc folders = parseResources(allResources);
319                 int numRes = folders.size();
320                 for(int i = 0;i < numRes;i++) {
321                     // modify the foldername if nescessary (the root folder is always given
322
// as a nice name)
323
if(lang.getLanguageValue("title.rootfolder").equals(folders.elementAt(i))) {
324                         folders.setElementAt("/", i);
325                     }
326                 }
327                 checkRedundancies(folders);
328                 numRes = folders.size(); // could have been changed
329
// now get the vector for the channels
330
Vector JavaDoc channels = parseResources(allChannels);
331                 int numChan = channels.size();
332                 for(int j = 0;j < numChan;j++) {
333                     // modify the channelname if nescessary (the root folder is always given
334
// as a nice name)
335
if(lang.getLanguageValue("title.rootfolder").equals(channels.elementAt(j))) {
336                         channels.setElementAt("/", j);
337                     }
338                 }
339                 checkRedundancies(channels);
340                 numChan = channels.size();
341                 // finally create the project
342
CmsProject project = cms.createProject(newName, newDescription, newGroup,
343                         newManagerGroup, projectType);
344                 // change the current project
345
reqCont.setCurrentProject(project);
346                 // copy the resources to the current project
347
try {
348                     for(int i = 0;i < folders.size();i++) {
349                         cms.copyResourceToProject((String JavaDoc)folders.elementAt(i));
350                     }
351                     //now copy the channels to the project
352
cms.getRequestContext().saveSiteRoot();
353                     cms.getRequestContext().setSiteRoot(CmsResource.VFS_FOLDER_CHANNELS);
354                     for(int j = 0; j < channels.size(); j++){
355                         cms.copyResourceToProject((String JavaDoc)channels.elementAt(j));
356                     }
357                     cms.getRequestContext().restoreSiteRoot();
358                 } catch(CmsException e) {
359                     cms.getRequestContext().restoreSiteRoot();
360                     // if there are no projectresources in the project delete the project
361
List JavaDoc projectResources = cms.readProjectResources(project);
362                     if(projectResources == null || projectResources == Collections.EMPTY_LIST || projectResources.size() == 0){
363                         cms.deleteProject(project.getId());
364                         reqCont.setCurrentProject(cms.readProject(CmsProject.ONLINE_PROJECT_ID));
365                     }
366                     if(CmsLog.getLog(this).isWarnEnabled() ) {
367                         CmsLog.getLog(this).warn(e.getMessage(), e);
368                     }
369                     throw e;
370                 }
371                 // project ready; clear the session
372
session.removeValue(C_NEWNAME);
373                 session.removeValue(C_NEWGROUP);
374                 session.removeValue(C_NEWDESCRIPTION);
375                 session.removeValue(C_NEWMANAGERGROUP);
376                 session.removeValue(C_NEWFOLDER);
377                 session.removeValue(C_NEWTYPE);
378                 session.removeValue(C_NEWRESOURCES);
379                 session.removeValue(C_NEWCHANNELS);
380                 session.removeValue("lasturl");
381                 session.removeValue("newProjectCallingFrom");
382                 return startProcessing(cms, xmlTemplateDocument, elementName, parameters, "done");
383             } catch(CmsException exc) {
384                 xmlTemplateDocument.setData("details", CmsException.getStackTraceAsString(exc));
385                 templateSelector = "errornewproject"+errorTemplateAddOn;
386             }
387         }
388         // after an error the form data is retrieved and filled into the template
389
xmlTemplateDocument.setData(C_NEWNAME, newName);
390         xmlTemplateDocument.setData(C_NEWDESCRIPTION, newDescription);
391         xmlTemplateDocument.setData(C_NEWTYPE, newType);
392
393         // Now load the template file and start the processing
394
return startProcessing(cms, xmlTemplateDocument, elementName, parameters,
395                 templateSelector);
396     }
397
398     /**
399      * Gets all groups, that may work for a project.
400      * <P>
401      * The given vectors <code>names</code> and <code>values</code> will
402      * be filled with the appropriate information to be used for building
403      * a select box.
404      *
405      * @param cms CmsObject Object for accessing system resources.
406      * @param names Vector to be filled with the appropriate values in this method.
407      * @param values Vector to be filled with the appropriate values in this method.
408      * @param parameters Hashtable containing all user parameters <em>(not used here)</em>.
409      * @return Index representing the current value in the vectors.
410      * @throws CmsException
411      */

412
413     public Integer JavaDoc getGroups(CmsObject cms, CmsXmlLanguageFile lang, Vector JavaDoc names,
414             Vector JavaDoc values, Hashtable JavaDoc parameters) throws CmsException {
415
416         // get all groups
417
List JavaDoc groups = cms.getGroups();
418         int retValue = -1;
419         String JavaDoc defaultGroup = OpenCms.getDefaultUsers().getGroupUsers();
420         I_CmsSession session = CmsXmlTemplateLoader.getSession(cms.getRequestContext(), true);
421         String JavaDoc enteredGroup = (String JavaDoc)session.getValue(C_NEWGROUP);
422         if(enteredGroup != null && !enteredGroup.equals("")) {
423
424             // if an error has occurred before, take the previous entry of the user
425
defaultGroup = enteredGroup;
426         }
427
428         // fill the names and values
429
int n = 0;
430         for(int z = 0;z < groups.size();z++) {
431             if(((CmsGroup)groups.get(z)).getProjectCoWorker()) {
432                 String JavaDoc name = ((CmsGroup)groups.get(z)).getName();
433                 if(defaultGroup.equals(name)) {
434                     retValue = n;
435                 }
436                 names.addElement(name);
437                 values.addElement(name);
438                 n++; // count the number of ProjectCoWorkers
439
}
440         }
441         return new Integer JavaDoc(retValue);
442     }
443
444     /**
445      * Gets all groups, that may manage a project.
446      * <P>
447      * The given vectors <code>names</code> and <code>values</code> will
448      * be filled with the appropriate information to be used for building
449      * a select box.
450      *
451      * @param cms CmsObject Object for accessing system resources.
452      * @param names Vector to be filled with the appropriate values in this method.
453      * @param values Vector to be filled with the appropriate values in this method.
454      * @param parameters Hashtable containing all user parameters <em>(not used here)</em>.
455      * @return Index representing the current value in the vectors.
456      * @throws CmsException
457      */

458
459     public Integer JavaDoc getManagerGroups(CmsObject cms, CmsXmlLanguageFile lang, Vector JavaDoc names,
460             Vector JavaDoc values, Hashtable JavaDoc parameters) throws CmsException {
461
462         // get all groups
463
List JavaDoc groups = cms.getGroups();
464         int retValue = -1;
465         String JavaDoc defaultGroup = OpenCms.getDefaultUsers().getGroupProjectmanagers();
466         I_CmsSession session = CmsXmlTemplateLoader.getSession(cms.getRequestContext(), true);
467         String JavaDoc enteredGroup = (String JavaDoc)session.getValue(C_NEWMANAGERGROUP);
468         if(enteredGroup != null && !enteredGroup.equals("")) {
469
470             // if an error has occurred before, take the previous entry of the user
471
defaultGroup = enteredGroup;
472         }
473
474         // fill the names and values
475
int n = 0;
476         for(int z = 0;z < groups.size();z++) {
477             if(((CmsGroup)groups.get(z)).getProjectManager()) {
478                 String JavaDoc name = ((CmsGroup)groups.get(z)).getName();
479                 if(defaultGroup.equals(name)) {
480                     retValue = n;
481                 }
482                 names.addElement(name);
483                 values.addElement(name);
484                 n++; // count the number of project managers
485
}
486         }
487         return new Integer JavaDoc(retValue);
488     }
489
490     public Integer JavaDoc getSelectedResources(CmsObject cms, CmsXmlLanguageFile lang, Vector JavaDoc names,
491             Vector JavaDoc values, Hashtable JavaDoc parameters) throws CmsException {
492         I_CmsSession session = CmsXmlTemplateLoader.getSession(cms.getRequestContext(), true);
493         String JavaDoc[] newProjectResources = (String JavaDoc[])session.getValue(C_NEWRESOURCES);
494         if(newProjectResources != null) {
495             for(int i = 0;i < newProjectResources.length;i++) {
496                 names.addElement(newProjectResources[i]);
497                 values.addElement(newProjectResources[i]);
498             }
499         }
500
501         // no current folder, set index to -1
502
return new Integer JavaDoc(-1);
503     }
504
505     /**
506      * Indicates if the results of this class are cacheable.
507      *
508      * @param cms CmsObject Object for accessing system resources
509      * @param templateFile Filename of the template file
510      * @param elementName Element name of this template in our parent template.
511      * @param parameters Hashtable with all template class parameters.
512      * @param templateSelector template section that should be processed.
513      * @return <EM>true</EM> if cacheable, <EM>false</EM> otherwise.
514      */

515
516     public boolean isCacheable(CmsObject cms, String JavaDoc templateFile, String JavaDoc elementName,
517             Hashtable JavaDoc parameters, String JavaDoc templateSelector) {
518         return false;
519     }
520
521     /** Parse the string which holds all resources
522      *
523      * @param resources containts the full pathnames of all the resources, separated by semicolons
524      * @return A vector with the same resources
525      */

526
527     private Vector JavaDoc parseResources(String JavaDoc resources) {
528         Vector JavaDoc ret = new Vector JavaDoc();
529         if(resources != null) {
530             StringTokenizer JavaDoc resTokenizer = new StringTokenizer JavaDoc(resources, ";");
531             while(resTokenizer.hasMoreElements()) {
532                 String JavaDoc path = (String JavaDoc)resTokenizer.nextElement();
533                 ret.addElement(path);
534             }
535         }
536         return ret;
537     }
538
539     /** gets the projectname for a contexgenerated project
540      *
541      * @param cms the cmsObject
542      * @param resource the name of the resource
543      * @return A vector with the same resources
544      */

545
546     private String JavaDoc getProjectName(CmsObject cms, String JavaDoc resource) {
547         String JavaDoc ret = resource;
548         if (ret.endsWith("/")){
549             ret = ret.substring(0, ret.length()-1);
550         }
551         ret = ret.substring(ret.lastIndexOf('/')+1);
552         if (ret.length() > 14){
553             ret = ret.substring(0,13);
554         }
555         try{
556             Vector JavaDoc allProjects = new Vector JavaDoc(cms.getAllAccessibleProjects());
557             Vector JavaDoc theNames = new Vector JavaDoc();
558             // count all projects starting with the same name
559
int count = 0;
560             for (int i = 0; i < allProjects.size(); i++){
561                 String JavaDoc currProject = ((CmsProject)allProjects.elementAt(i)).getName();
562                 if (currProject.startsWith(ret)){
563                     count++;
564                     theNames.addElement(currProject);
565                 }
566             }
567             if ((count > 0) && (count < 99)){
568                 // get the highest version nummber
569
int version = 1;
570                 for (int i = 0; i<theNames.size(); i++){
571                     int currVersion = 0;
572                     try{
573                         currVersion = Integer.parseInt(((String JavaDoc)theNames.elementAt(i)).substring(ret.length()+1));
574                     }catch(Exception JavaDoc e){
575                     }
576                     if ((currVersion > version)&& (currVersion < 100)){
577                         version = currVersion;
578                     }
579                 }
580                 if (version < 99){
581                     ret = ret + "_" + (version + 1);
582                 }
583             }
584         }catch(CmsException e){
585         }
586         return ret;
587     }
588 }
589
Popular Tags