KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > infoglue > cms > controllers > kernel > impl > simple > SiteNodeStateController


1 /* ===============================================================================
2  *
3  * Part of the InfoGlue Content Management Platform (www.infoglue.org)
4  *
5  * ===============================================================================
6  *
7  * Copyright (C)
8  *
9  * This program is free software; you can redistribute it and/or modify it under
10  * the terms of the GNU General Public License version 2, as published by the
11  * Free Software Foundation. See the file LICENSE.html for more information.
12  *
13  * This program is distributed in the hope that it will be useful, but WITHOUT
14  * ANY WARRANTY, including the implied warranty of MERCHANTABILITY or FITNESS
15  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License along with
18  * this program; if not, write to the Free Software Foundation, Inc. / 59 Temple
19  * Place, Suite 330 / Boston, MA 02111-1307 / USA.
20  *
21  * ===============================================================================
22  */

23
24 package org.infoglue.cms.controllers.kernel.impl.simple;
25
26 import java.util.ArrayList JavaDoc;
27 import java.util.Collection JavaDoc;
28 import java.util.Iterator JavaDoc;
29 import java.util.List JavaDoc;
30
31 import org.apache.log4j.Logger;
32 import org.exolab.castor.jdo.Database;
33 import org.infoglue.cms.entities.content.ContentVO;
34 import org.infoglue.cms.entities.content.ContentVersion;
35 import org.infoglue.cms.entities.kernel.BaseEntityVO;
36 import org.infoglue.cms.entities.management.AccessRight;
37 import org.infoglue.cms.entities.management.AccessRightGroup;
38 import org.infoglue.cms.entities.management.AccessRightGroupVO;
39 import org.infoglue.cms.entities.management.AccessRightRole;
40 import org.infoglue.cms.entities.management.AccessRightRoleVO;
41 import org.infoglue.cms.entities.management.AccessRightUser;
42 import org.infoglue.cms.entities.management.AccessRightUserVO;
43 import org.infoglue.cms.entities.management.AccessRightVO;
44 import org.infoglue.cms.entities.management.AvailableServiceBinding;
45 import org.infoglue.cms.entities.management.InterceptionPoint;
46 import org.infoglue.cms.entities.management.Language;
47 import org.infoglue.cms.entities.structure.Qualifyer;
48 import org.infoglue.cms.entities.structure.QualifyerVO;
49 import org.infoglue.cms.entities.structure.ServiceBinding;
50 import org.infoglue.cms.entities.structure.ServiceBindingVO;
51 import org.infoglue.cms.entities.structure.SiteNodeVersion;
52 import org.infoglue.cms.entities.structure.SiteNodeVersionVO;
53 import org.infoglue.cms.entities.structure.impl.simple.QualifyerImpl;
54 import org.infoglue.cms.entities.structure.impl.simple.ServiceBindingImpl;
55 import org.infoglue.cms.entities.workflow.EventVO;
56 import org.infoglue.cms.exception.ConstraintException;
57 import org.infoglue.cms.exception.SystemException;
58 import org.infoglue.cms.security.InfoGluePrincipal;
59 import org.infoglue.cms.util.ConstraintExceptionBuffer;
60 import org.infoglue.cms.util.DateHelper;
61
62 public class SiteNodeStateController extends BaseController
63 {
64     private final static Logger logger = Logger.getLogger(SiteNodeStateController.class.getName());
65
66     /**
67      * Factory method
68      */

69
70     public static SiteNodeStateController getController()
71     {
72         return new SiteNodeStateController();
73     }
74     
75     /**
76      * This method handles versioning and state-control of siteNodes.
77      * Se inline documentation for further explainations.
78      */

79     
80     public SiteNodeVersion changeState(Integer JavaDoc oldSiteNodeVersionId, Integer JavaDoc stateId, String JavaDoc versionComment, boolean overrideVersionModifyer, InfoGluePrincipal infoGluePrincipal, Integer JavaDoc siteNodeId, List JavaDoc resultingEvents) throws ConstraintException, SystemException
81     {
82         SiteNodeVersion newSiteNodeVersion = null;
83         
84         Database db = CastorDatabaseService.getDatabase();
85         ConstraintExceptionBuffer ceb = new ConstraintExceptionBuffer();
86         
87         beginTransaction(db);
88
89         try
90         {
91             SiteNodeVersion siteNodeVersion = SiteNodeVersionController.getSiteNodeVersionWithIdAsReadOnly(oldSiteNodeVersionId, db);
92             logger.info("siteNodeVersion:" + siteNodeVersion.getId() + ":" + siteNodeVersion.getStateId());
93             
94             newSiteNodeVersion = changeState(oldSiteNodeVersionId, stateId, versionComment, overrideVersionModifyer, infoGluePrincipal, siteNodeId, db, resultingEvents);
95             
96             commitTransaction(db);
97         }
98         catch(Exception JavaDoc e)
99         {
100             logger.error("An error occurred so we should not complete the transaction:" + e, e);
101             rollbackTransaction(db);
102             throw new SystemException(e.getMessage());
103         }
104         
105         return newSiteNodeVersion;
106     }
107
108
109     /**
110      * This method handles versioning and state-control of siteNodes.
111      * Se inline documentation for further explainations.
112      */

113     
114     public SiteNodeVersion changeState(Integer JavaDoc oldSiteNodeVersionId, Integer JavaDoc stateId, String JavaDoc versionComment, boolean overrideVersionModifyer, InfoGluePrincipal infoGluePrincipal, Integer JavaDoc siteNodeId, Database db, List JavaDoc resultingEvents) throws ConstraintException, SystemException
115     {
116         SiteNodeVersion newSiteNodeVersion = null;
117         
118         try
119         {
120             SiteNodeVersion oldSiteNodeVersion = SiteNodeVersionController.getController().getSiteNodeVersionWithId(oldSiteNodeVersionId, db);
121
122             //Here we create a new version if it was a state-change back to working, it's a copy of the publish-version
123
if(stateId.intValue() == SiteNodeVersionVO.WORKING_STATE.intValue())
124             {
125                 logger.info("About to create a new working version");
126                 
127                 if (siteNodeId == null)
128                     siteNodeId = new Integer JavaDoc(oldSiteNodeVersion.getOwningSiteNode().getId().intValue());
129
130                 SiteNodeVersionVO newSiteNodeVersionVO = new SiteNodeVersionVO();
131                 newSiteNodeVersionVO.setStateId(stateId);
132                 newSiteNodeVersionVO.setVersionComment("New working version");
133                 newSiteNodeVersionVO.setModifiedDateTime(DateHelper.getSecondPreciseDate());
134                 if(overrideVersionModifyer)
135                     newSiteNodeVersionVO.setVersionModifier(infoGluePrincipal.getName());
136                 else
137                     newSiteNodeVersionVO.setVersionModifier(oldSiteNodeVersion.getVersionModifier());
138                     
139                 newSiteNodeVersionVO.setContentType(oldSiteNodeVersion.getContentType());
140                 newSiteNodeVersionVO.setPageCacheKey(oldSiteNodeVersion.getPageCacheKey());
141                 newSiteNodeVersionVO.setDisableEditOnSight(oldSiteNodeVersion.getDisableEditOnSight());
142                 newSiteNodeVersionVO.setDisableLanguages(oldSiteNodeVersion.getDisableLanguages());
143                 newSiteNodeVersionVO.setDisablePageCache(oldSiteNodeVersion.getDisablePageCache());
144                 newSiteNodeVersionVO.setIsProtected(oldSiteNodeVersion.getIsProtected());
145                 
146                 newSiteNodeVersion = SiteNodeVersionController.create(siteNodeId, infoGluePrincipal, newSiteNodeVersionVO, db);
147                 copyServiceBindings(oldSiteNodeVersion, newSiteNodeVersion, db);
148                 copyAccessRights(oldSiteNodeVersion, newSiteNodeVersion, db);
149             }
150     
151             //If the user changes the state to publish we create a copy and set that copy to publish.
152
if(stateId.intValue() == SiteNodeVersionVO.PUBLISH_STATE.intValue())
153             {
154                 logger.info("About to copy the working copy to a publish-one");
155                 //First we update the old working-version so it gets a comment
156

157                 if (siteNodeId == null)
158                     siteNodeId = new Integer JavaDoc(oldSiteNodeVersion.getOwningSiteNode().getId().intValue());
159
160                 SiteNodeVersionVO oldSiteNodeVersionVO = oldSiteNodeVersion.getValueObject();
161                 oldSiteNodeVersion.setVersionComment(versionComment);
162     
163                 //Now we create a new version which is basically just a copy of the working-version
164
SiteNodeVersionVO newSiteNodeVersionVO = new SiteNodeVersionVO();
165                 newSiteNodeVersionVO.setStateId(stateId);
166                 newSiteNodeVersionVO.setVersionComment(versionComment);
167                 if(overrideVersionModifyer)
168                     newSiteNodeVersionVO.setVersionModifier(infoGluePrincipal.getName());
169                 else
170                     newSiteNodeVersionVO.setVersionModifier(oldSiteNodeVersion.getVersionModifier());
171                 
172                 newSiteNodeVersionVO.setModifiedDateTime(DateHelper.getSecondPreciseDate());
173                 
174                 newSiteNodeVersionVO.setContentType(oldSiteNodeVersion.getContentType());
175                 newSiteNodeVersionVO.setPageCacheKey(oldSiteNodeVersion.getPageCacheKey());
176                 newSiteNodeVersionVO.setDisableEditOnSight(oldSiteNodeVersion.getDisableEditOnSight());
177                 newSiteNodeVersionVO.setDisableLanguages(oldSiteNodeVersion.getDisableLanguages());
178                 newSiteNodeVersionVO.setDisablePageCache(oldSiteNodeVersion.getDisablePageCache());
179                 newSiteNodeVersionVO.setIsProtected(oldSiteNodeVersion.getIsProtected());
180                 
181                 newSiteNodeVersion = SiteNodeVersionController.create(siteNodeId, infoGluePrincipal, newSiteNodeVersionVO, db);
182                 copyServiceBindings(oldSiteNodeVersion, newSiteNodeVersion, db);
183                 copyAccessRights(oldSiteNodeVersion, newSiteNodeVersion, db);
184             
185                 //Creating the event that will notify the editor...
186
EventVO eventVO = new EventVO();
187                 eventVO.setDescription(newSiteNodeVersion.getVersionComment());
188                 eventVO.setEntityClass(SiteNodeVersion.class.getName());
189                 eventVO.setEntityId(new Integer JavaDoc(newSiteNodeVersion.getId().intValue()));
190                 eventVO.setName(newSiteNodeVersion.getOwningSiteNode().getName());
191                 eventVO.setTypeId(EventVO.PUBLISH);
192                 eventVO = EventController.create(eventVO, newSiteNodeVersion.getOwningSiteNode().getRepository().getId(), infoGluePrincipal, db);
193                 resultingEvents.add(eventVO);
194             }
195     
196             if(stateId.intValue() == SiteNodeVersionVO.PUBLISHED_STATE.intValue())
197             {
198                 logger.info("About to publish an existing version");
199                 oldSiteNodeVersion.setStateId(stateId);
200                 oldSiteNodeVersion.setIsActive(new Boolean JavaDoc(true));
201                 newSiteNodeVersion = oldSiteNodeVersion;
202             }
203             
204             changeStateOnMetaInfo(db, newSiteNodeVersion, stateId, versionComment, overrideVersionModifyer, infoGluePrincipal, resultingEvents);
205         }
206         catch(Exception JavaDoc e)
207         {
208             logger.error("An error occurred so we should not complete the transaction:" + e, e);
209             throw new SystemException(e.getMessage());
210         }
211             
212         return newSiteNodeVersion;
213     }
214
215     
216     /**
217      * This method checks if the siteNodes latest metainfo is working - if so - it get published with the sitenode.
218      * @param db
219      * @throws ConstraintException
220      * @throws SystemException
221      * @throws Exception
222      */

223     public void changeStateOnMetaInfo(Database db, SiteNodeVersion siteNodeVersion, Integer JavaDoc stateId, String JavaDoc versionComment, boolean overrideVersionModifyer, InfoGluePrincipal infoGluePrincipal, List JavaDoc events) throws ConstraintException, SystemException, Exception JavaDoc
224     {
225         logger.info("start changeStateOnMetaInfo");
226         
227         List JavaDoc languages = LanguageController.getController().getLanguageList(siteNodeVersion.getOwningSiteNode().getRepository().getId(), db);
228         Language masterLanguage = LanguageController.getController().getMasterLanguage(db, siteNodeVersion.getOwningSiteNode().getRepository().getId());
229
230         logger.info("after languages");
231
232         ContentVO contentVO = null;
233         if(siteNodeVersion.getOwningSiteNode().getMetaInfoContentId() != null)
234         {
235             contentVO = ContentController.getContentController().getContentVOWithId(siteNodeVersion.getOwningSiteNode().getMetaInfoContentId(), db);
236         }
237         else
238         {
239             logger.warn("There was no metaInfoContentId on the siteNode... run validation to improve performance..");
240
241             Integer JavaDoc metaInfoAvailableServiceBindingId = null;
242             Integer JavaDoc serviceBindingId = null;
243             AvailableServiceBinding availableServiceBinding = AvailableServiceBindingController.getController().getAvailableServiceBindingWithName("Meta information", db, true);
244             if(availableServiceBinding != null)
245                 metaInfoAvailableServiceBindingId = availableServiceBinding.getAvailableServiceBindingId();
246
247             logger.info("after loading service binding for meta info");
248
249             Collection JavaDoc serviceBindings = siteNodeVersion.getServiceBindings();
250             Iterator JavaDoc serviceBindingIterator = serviceBindings.iterator();
251             while(serviceBindingIterator.hasNext())
252             {
253                 ServiceBinding serviceBinding = (ServiceBinding)serviceBindingIterator.next();
254                 if(serviceBinding.getAvailableServiceBinding().getId().intValue() == metaInfoAvailableServiceBindingId.intValue())
255                 {
256                     serviceBindingId = serviceBinding.getId();
257                     break;
258                 }
259             }
260
261             if(serviceBindingId != null)
262             {
263                 List JavaDoc boundContents = ContentController.getBoundContents(db, serviceBindingId);
264                 logger.info("boundContents:" + boundContents.size());
265                 if(boundContents.size() > 0)
266                 {
267                     contentVO = (ContentVO)boundContents.get(0);
268                     logger.info("contentVO:" + contentVO.getId());
269                 }
270             }
271         }
272         
273         if(contentVO != null)
274         {
275             Iterator JavaDoc languageIterator = languages.iterator();
276             while(languageIterator.hasNext())
277             {
278                 Language language = (Language)languageIterator.next();
279                 ContentVersion contentVersion = ContentVersionController.getContentVersionController().getLatestActiveContentVersion(contentVO.getId(), language.getId(), db);
280                 
281                 logger.info("language:" + language.getId());
282                 
283                 //if(language.getId().equals(masterLanguage.getId()) && contentVersion == null)
284
// throw new Exception("The contentVersion was null or states did not match.. the version and meta info content should allways match when it comes to master language version...");
285

286                 if(contentVersion != null)
287                 {
288                     logger.info("contentVersion:" + contentVersion.getId() + ":" + contentVersion.getStateId());
289                     logger.info("State wanted:" + stateId);
290                 }
291                 
292                 //if(contentVersion != null && contentVersion.getStateId().intValue() == siteNodeVersion.getStateId().intValue())
293
if(contentVersion != null && contentVersion.getStateId().intValue() != stateId.intValue())
294                 {
295                     logger.info("State on current:" + contentVersion.getStateId());
296                     logger.info("changing state on contentVersion:" + contentVersion.getId());
297                     contentVersion = ContentStateController.changeState(contentVersion.getId(), stateId, versionComment, overrideVersionModifyer, infoGluePrincipal, contentVO.getId(), db, events);
298                 }
299                 
300                 if(language.getId().equals(masterLanguage.getId()) && contentVersion != null)
301                 {
302                     //TODO - lets keep the ref to meta info alive...
303
//RegistryController.getController().updateSiteNodeVersion(siteNodeVersion, db);
304
RegistryController.getController().updateContentVersion(contentVersion, siteNodeVersion, db);
305                 }
306             }
307         }
308     }
309
310     /**
311      * This method checks if the siteNodes latest metainfo is working - if so - it get published with the sitenode.
312      * @param db
313      * @throws ConstraintException
314      * @throws SystemException
315      * @throws Exception
316      */

317     /*
318     public void changeStateOnMetaInfo(Database db, SiteNodeVersion siteNodeVersion, Integer stateId, String versionComment, boolean overrideVersionModifyer, InfoGluePrincipal infoGluePrincipal, List events) throws ConstraintException, SystemException, Exception
319     {
320         logger.info("start changeStateOnMetaInfo");
321         
322         List languages = LanguageController.getController().getLanguageList(siteNodeVersion.getOwningSiteNode().getRepository().getId(), db);
323         Language masterLanguage = LanguageController.getController().getMasterLanguage(db, siteNodeVersion.getOwningSiteNode().getRepository().getId());
324
325         logger.info("after languages");
326
327         Integer metaInfoAvailableServiceBindingId = null;
328         Integer serviceBindingId = null;
329         AvailableServiceBinding availableServiceBinding = AvailableServiceBindingController.getController().getAvailableServiceBindingWithName("Meta information", db, true);
330         if(availableServiceBinding != null)
331             metaInfoAvailableServiceBindingId = availableServiceBinding.getAvailableServiceBindingId();
332
333         logger.info("after loading service binding for meta info");
334
335         Collection serviceBindings = siteNodeVersion.getServiceBindings();
336         Iterator serviceBindingIterator = serviceBindings.iterator();
337         while(serviceBindingIterator.hasNext())
338         {
339             ServiceBinding serviceBinding = (ServiceBinding)serviceBindingIterator.next();
340             if(serviceBinding.getAvailableServiceBinding().getId().intValue() == metaInfoAvailableServiceBindingId.intValue())
341             {
342                 serviceBindingId = serviceBinding.getId();
343                 break;
344             }
345         }
346
347         if(serviceBindingId != null)
348         {
349             List boundContents = ContentController.getBoundContents(db, serviceBindingId);
350             logger.info("boundContents:" + boundContents.size());
351             if(boundContents.size() > 0)
352             {
353                 ContentVO contentVO = (ContentVO)boundContents.get(0);
354                 logger.info("contentVO:" + contentVO.getId());
355                 
356                 Iterator languageIterator = languages.iterator();
357                 while(languageIterator.hasNext())
358                 {
359                     Language language = (Language)languageIterator.next();
360                     ContentVersion contentVersion = ContentVersionController.getContentVersionController().getLatestActiveContentVersion(contentVO.getId(), language.getId(), db);
361                     
362                     logger.info("language:" + language.getId());
363                     
364                     //if(language.getId().equals(masterLanguage.getId()) && contentVersion == null)
365                     // throw new Exception("The contentVersion was null or states did not match.. the version and meta info content should allways match when it comes to master language version...");
366     
367                     if(contentVersion != null)
368                     {
369                         logger.info("contentVersion:" + contentVersion.getId() + ":" + contentVersion.getStateId());
370                         logger.info("State wanted:" + stateId);
371                     }
372                     
373                     //if(contentVersion != null && contentVersion.getStateId().intValue() == siteNodeVersion.getStateId().intValue())
374                     if(contentVersion != null && contentVersion.getStateId().intValue() != stateId.intValue())
375                     {
376                         logger.info("State on current:" + contentVersion.getStateId());
377                         logger.info("changing state on contentVersion:" + contentVersion.getId());
378                         contentVersion = ContentStateController.changeState(contentVersion.getId(), stateId, versionComment, overrideVersionModifyer, infoGluePrincipal, contentVO.getId(), db, events);
379                     }
380                     
381                     if(language.getId().equals(masterLanguage.getId()) && contentVersion != null)
382                     {
383                         //TODO - lets keep the ref to meta info alive...
384                         //RegistryController.getController().updateSiteNodeVersion(siteNodeVersion, db);
385                         RegistryController.getController().updateContentVersion(contentVersion, siteNodeVersion, db);
386                     }
387                 }
388                 
389             }
390         }
391     }
392     */

393     
394     /**
395      * This method copies all serviceBindings a siteNodeVersion has to the new siteNodeVersion.
396      */

397
398     private static void copyServiceBindings(SiteNodeVersion originalSiteNodeVersion, SiteNodeVersion newSiteNodeVersion, Database db) throws ConstraintException, SystemException, Exception JavaDoc
399     {
400         Collection JavaDoc serviceBindings = originalSiteNodeVersion.getServiceBindings();
401         Iterator JavaDoc iterator = serviceBindings.iterator();
402         while(iterator.hasNext())
403         {
404             ServiceBinding serviceBinding = (ServiceBinding)iterator.next();
405             ServiceBindingVO serviceBindingVO = serviceBinding.getValueObject();
406             ServiceBindingVO newServiceBindingVO = new ServiceBindingVO();
407             newServiceBindingVO.setBindingTypeId(serviceBindingVO.getBindingTypeId());
408             newServiceBindingVO.setName(serviceBindingVO.getName());
409             newServiceBindingVO.setPath(serviceBindingVO.getPath());
410             ServiceBinding newServiceBinding = ServiceBindingController.create(newServiceBindingVO, serviceBinding.getAvailableServiceBinding().getAvailableServiceBindingId(), newSiteNodeVersion.getSiteNodeVersionId(), serviceBinding.getServiceDefinition().getServiceDefinitionId(), db);
411             newSiteNodeVersion.getServiceBindings().add(newServiceBinding);
412             copyQualifyers(serviceBinding, newServiceBinding, db);
413         }
414     }
415
416
417     /**
418      * This method copies all qualifyers a serviceBinding has to the new serviceBinding.
419      */

420     private static void copyQualifyers(ServiceBinding originalServiceBinding, ServiceBinding newServiceBinding, Database db) throws ConstraintException, SystemException, Exception JavaDoc
421     {
422         Collection JavaDoc qualifyers = originalServiceBinding.getBindingQualifyers();
423         Collection JavaDoc newBindingQualifyers = new ArrayList JavaDoc();
424         
425         Iterator JavaDoc iterator = qualifyers.iterator();
426         while(iterator.hasNext())
427         {
428             Qualifyer qualifyer = (Qualifyer)iterator.next();
429             QualifyerVO qualifyerVO = qualifyer.getValueObject();
430             Qualifyer newQualifyer = new QualifyerImpl();
431             newQualifyer.setValueObject(qualifyerVO);
432             newQualifyer.setServiceBinding((ServiceBindingImpl)newServiceBinding);
433             newBindingQualifyers.add(newQualifyer);
434             //QualifyerController.create(newQualifyerVO, newServiceBinding.getServiceBindingId(), db);
435
}
436         newServiceBinding.setBindingQualifyers(newBindingQualifyers);
437                     
438     }
439
440     /**
441      * This method assigns the same access rights as the old content-version has.
442      */

443     
444     private static void copyAccessRights(SiteNodeVersion originalSiteNodeVersion, SiteNodeVersion newSiteNodeVersion, Database db) throws ConstraintException, SystemException, Exception JavaDoc
445     {
446         List JavaDoc interceptionPointList = InterceptionPointController.getController().getInterceptionPointList("SiteNodeVersion", db);
447         logger.info("interceptionPointList:" + interceptionPointList.size());
448         Iterator JavaDoc interceptionPointListIterator = interceptionPointList.iterator();
449         while(interceptionPointListIterator.hasNext())
450         {
451             InterceptionPoint interceptionPoint = (InterceptionPoint)interceptionPointListIterator.next();
452             List JavaDoc accessRightList = AccessRightController.getController().getAccessRightListForEntity(interceptionPoint.getId(), originalSiteNodeVersion.getId().toString(), db);
453             logger.info("accessRightList:" + accessRightList.size());
454             Iterator JavaDoc accessRightListIterator = accessRightList.iterator();
455             while(accessRightListIterator.hasNext())
456             {
457                 AccessRight accessRight = (AccessRight)accessRightListIterator.next();
458                 logger.info("accessRight:" + accessRight.getId());
459                 
460                 AccessRightVO copiedAccessRight = accessRight.getValueObject().createCopy();
461                 copiedAccessRight.setParameters(newSiteNodeVersion.getId().toString());
462                 AccessRight newAccessRight = AccessRightController.getController().create(copiedAccessRight, interceptionPoint, db);
463                 
464                 Iterator JavaDoc groupsIterator = accessRight.getGroups().iterator();
465                 while(groupsIterator.hasNext())
466                 {
467                     AccessRightGroup accessRightGroup = (AccessRightGroup)groupsIterator.next();
468                     AccessRightGroupVO newAccessRightGroupVO = new AccessRightGroupVO();
469                     newAccessRightGroupVO.setGroupName(accessRightGroup.getGroupName());
470                     AccessRightGroup newAccessRightGroup = AccessRightController.getController().createAccessRightGroup(db, newAccessRightGroupVO, newAccessRight);
471                     newAccessRight.getGroups().add(newAccessRightGroup);
472                 }
473
474                 Iterator JavaDoc rolesIterator = accessRight.getRoles().iterator();
475                 while(rolesIterator.hasNext())
476                 {
477                     AccessRightRole accessRightRole = (AccessRightRole)rolesIterator.next();
478                     AccessRightRoleVO newAccessRightRoleVO = new AccessRightRoleVO();
479                     newAccessRightRoleVO.setRoleName(accessRightRole.getRoleName());
480                     AccessRightRole newAccessRightRole = AccessRightController.getController().createAccessRightRole(db, newAccessRightRoleVO, newAccessRight);
481                     newAccessRight.getRoles().add(newAccessRightRole);
482                 }
483
484                 Iterator JavaDoc usersIterator = accessRight.getUsers().iterator();
485                 while(usersIterator.hasNext())
486                 {
487                     AccessRightUser accessRightUser = (AccessRightUser)usersIterator.next();
488                     AccessRightUserVO newAccessRightUserVO = new AccessRightUserVO();
489                     newAccessRightUserVO.setUserName(accessRightUser.getUserName());
490                     AccessRightUser newAccessRightUser = AccessRightController.getController().createAccessRightUser(db, newAccessRightUserVO, newAccessRight);
491                     newAccessRight.getUsers().add(newAccessRightUser);
492                 }
493
494             }
495         }
496     }
497     
498     /**
499      * This is a method that never should be called.
500      */

501
502     public BaseEntityVO getNewVO()
503     {
504         return null;
505     }
506
507 }
508  
509
Popular Tags