public SiteNodeVersionVO changeState(Integer oldSiteNodeVersionId, SiteNodeVO siteNodeVO, Integer stateId, String versionComment, boolean overrideVersionModifyer, String recipientFilter, InfoGluePrincipal infoGluePrincipal, Database db, List<EventVO> resultingEvents) throws ConstraintException, SystemException
{
Timer t = new Timer();
SiteNodeVersionVO returnSiteNodeVersionVO = null;
MediumSiteNodeVersionImpl returnSiteNodeVersionImpl = null;
try
{
MediumSiteNodeVersionImpl oldMediumSiteNodeVersionImpl = SiteNodeVersionController.getController().getMediumSiteNodeVersionWithId(oldSiteNodeVersionId, db);
returnSiteNodeVersionVO = oldMediumSiteNodeVersionImpl.getValueObject();
//t.printElapsedTime("oldMediumSiteNodeVersionImpl:" + oldMediumSiteNodeVersionImpl.getSiteNodeId());
//Here we create a new version if it was a state-change back to working, it's a copy of the publish-version
if(stateId.intValue() == SiteNodeVersionVO.WORKING_STATE.intValue())
{
logger.info("About to create a new working version");
SiteNodeVersionVO newSiteNodeVersionVO = new SiteNodeVersionVO();
newSiteNodeVersionVO.setStateId(stateId);
newSiteNodeVersionVO.setVersionComment("New working version");
newSiteNodeVersionVO.setModifiedDateTime(DateHelper.getSecondPreciseDate());
if(overrideVersionModifyer)
newSiteNodeVersionVO.setVersionModifier(infoGluePrincipal.getName());
else
newSiteNodeVersionVO.setVersionModifier(oldMediumSiteNodeVersionImpl.getVersionModifier());
newSiteNodeVersionVO.setContentType(oldMediumSiteNodeVersionImpl.getContentType());
newSiteNodeVersionVO.setPageCacheKey(oldMediumSiteNodeVersionImpl.getPageCacheKey());
newSiteNodeVersionVO.setPageCacheTimeout(oldMediumSiteNodeVersionImpl.getPageCacheTimeout());
newSiteNodeVersionVO.setDisableEditOnSight(oldMediumSiteNodeVersionImpl.getDisableEditOnSight());
newSiteNodeVersionVO.setDisableLanguages(oldMediumSiteNodeVersionImpl.getDisableLanguages());
newSiteNodeVersionVO.setDisablePageCache(oldMediumSiteNodeVersionImpl.getDisablePageCache());
newSiteNodeVersionVO.setIsProtected(oldMediumSiteNodeVersionImpl.getIsProtected());
newSiteNodeVersionVO.setDisableForceIdentityCheck(oldMediumSiteNodeVersionImpl.getDisableForceIdentityCheck());
newSiteNodeVersionVO.setForceProtocolChange(oldMediumSiteNodeVersionImpl.getForceProtocolChange());
newSiteNodeVersionVO.setIsHidden(oldMediumSiteNodeVersionImpl.getIsHidden());
newSiteNodeVersionVO.setSortOrder(oldMediumSiteNodeVersionImpl.getSortOrder());
RequestAnalyser.getRequestAnalyser().registerComponentStatistics("changeState 1", t.getElapsedTime());
//returnSiteNodeVersionVO = SiteNodeVersionController.createFull(siteNodeId, infoGluePrincipal, newSiteNodeVersionVO, db).getValueObject();
returnSiteNodeVersionImpl = SiteNodeVersionController.createSmall(siteNodeVO.getId(), infoGluePrincipal, newSiteNodeVersionVO, db);
returnSiteNodeVersionVO = returnSiteNodeVersionImpl.getValueObject();
RequestAnalyser.getRequestAnalyser().registerComponentStatistics("changeState createSmall", t.getElapsedTime());
returnSiteNodeVersionImpl.setSiteNodeId(oldMediumSiteNodeVersionImpl.getSiteNodeId());
copyServiceBindings(oldMediumSiteNodeVersionImpl, returnSiteNodeVersionImpl, db);
RequestAnalyser.getRequestAnalyser().registerComponentStatistics("changeState copyServiceBindings", t.getElapsedTime());
if(returnSiteNodeVersionImpl.getIsProtected().intValue() == SiteNodeVersionVO.YES || returnSiteNodeVersionImpl.getIsProtected().intValue() == SiteNodeVersionVO.YES_WITH_INHERIT_FALLBACK)
{
copyAccessRights("SiteNodeVersion", oldMediumSiteNodeVersionImpl.getId(), returnSiteNodeVersionImpl.getId(), db);
RequestAnalyser.getRequestAnalyser().registerComponentStatistics("changeState copyAccessRights", t.getElapsedTime());
}
}
//If the user changes the state to publish we create a copy and set that copy to publish.
if(stateId.intValue() == SiteNodeVersionVO.PUBLISH_STATE.intValue())
{
logger.info("About to copy the working copy to a publish-one");
//First we update the old working-version so it gets a comment
//SiteNodeVersionVO oldSiteNodeVersionVO = oldSiteNodeVersion.getValueObject();
oldMediumSiteNodeVersionImpl.setVersionComment(versionComment);
if(CmsPropertyHandler.getUseApprovalFlow().equals("true"))
{
//Now we create a new version which is basically just a copy of the working-version
SiteNodeVersionVO newSiteNodeVersionVO = new SiteNodeVersionVO();
newSiteNodeVersionVO.setSiteNodeId(siteNodeVO.getId());
newSiteNodeVersionVO.setStateId(stateId);
newSiteNodeVersionVO.setVersionComment(versionComment);
if(overrideVersionModifyer)
newSiteNodeVersionVO.setVersionModifier(infoGluePrincipal.getName());
else
newSiteNodeVersionVO.setVersionModifier(oldMediumSiteNodeVersionImpl.getVersionModifier());
newSiteNodeVersionVO.setModifiedDateTime(DateHelper.getSecondPreciseDate());
newSiteNodeVersionVO.setContentType(oldMediumSiteNodeVersionImpl.getContentType());
newSiteNodeVersionVO.setPageCacheKey(oldMediumSiteNodeVersionImpl.getPageCacheKey());
newSiteNodeVersionVO.setPageCacheTimeout(oldMediumSiteNodeVersionImpl.getPageCacheTimeout());
newSiteNodeVersionVO.setDisableEditOnSight(oldMediumSiteNodeVersionImpl.getDisableEditOnSight());
newSiteNodeVersionVO.setDisableLanguages(oldMediumSiteNodeVersionImpl.getDisableLanguages());
newSiteNodeVersionVO.setDisablePageCache(oldMediumSiteNodeVersionImpl.getDisablePageCache());
newSiteNodeVersionVO.setIsProtected(oldMediumSiteNodeVersionImpl.getIsProtected());
newSiteNodeVersionVO.setDisableForceIdentityCheck(oldMediumSiteNodeVersionImpl.getDisableForceIdentityCheck());
newSiteNodeVersionVO.setForceProtocolChange(oldMediumSiteNodeVersionImpl.getForceProtocolChange());
newSiteNodeVersionVO.setIsHidden(oldMediumSiteNodeVersionImpl.getIsHidden());
newSiteNodeVersionVO.setSortOrder(oldMediumSiteNodeVersionImpl.getSortOrder());
RequestAnalyser.getRequestAnalyser().registerComponentStatistics("changeState publish1", t.getElapsedTime());
//returnSiteNodeVersionVO = SiteNodeVersionController.createFull(siteNodeId, infoGluePrincipal, newSiteNodeVersionVO, db).getValueObject();
returnSiteNodeVersionImpl = SiteNodeVersionController.createSmall(siteNodeVO.getId(), infoGluePrincipal, newSiteNodeVersionVO, db);
RequestAnalyser.getRequestAnalyser().registerComponentStatistics("changeState publish createSmall", t.getElapsedTime());
returnSiteNodeVersionVO = returnSiteNodeVersionImpl.getValueObject();
//returnSiteNodeVersionVO.setSiteNodeId(oldSiteNodeVersion.getValueObject().getSiteNodeId());
//copyServiceBindings(oldSiteNodeVersion, newSiteNodeVersion, db);
if(returnSiteNodeVersionImpl.getIsProtected().intValue() == SiteNodeVersionVO.YES || returnSiteNodeVersionImpl.getIsProtected().intValue() == SiteNodeVersionVO.YES_WITH_INHERIT_FALLBACK)
{
copyAccessRights("SiteNodeVersion", oldMediumSiteNodeVersionImpl.getId(), returnSiteNodeVersionImpl.getId(), db);
RequestAnalyser.getRequestAnalyser().registerComponentStatistics("changeState publish copyAccessRights", t.getElapsedTime());
}
//Creating the event that will notify the editor...
EventVO eventVO = new EventVO();
eventVO.setDescription(returnSiteNodeVersionImpl.getVersionComment());
eventVO.setEntityClass(SiteNodeVersion.class.getName());
eventVO.setEntityId(new Integer(returnSiteNodeVersionImpl.getId().intValue()));
eventVO.setName(siteNodeVO.getName());
eventVO.setTypeId(EventVO.PUBLISH);
eventVO = EventController.create(eventVO, siteNodeVO.getRepositoryId(), infoGluePrincipal, db);
eventVO.setName(siteNodeVO.getName());
resultingEvents.add(eventVO);
}
else
{
oldMediumSiteNodeVersionImpl.setVersionComment(versionComment);
//Creating the event that will notify the editor...
EventVO eventVO = new EventVO();
eventVO.setDescription(oldMediumSiteNodeVersionImpl.getVersionComment());
eventVO.setEntityClass(SiteNodeVersion.class.getName());
eventVO.setEntityId(new Integer(oldMediumSiteNodeVersionImpl.getId().intValue()));
eventVO.setName(siteNodeVO.getName());
eventVO.setTypeId(EventVO.PUBLISH);
eventVO = EventController.create(eventVO, siteNodeVO.getRepositoryId(), infoGluePrincipal, db);
eventVO.setName(siteNodeVO.getName());
resultingEvents.add(eventVO);
}
//if(recipientFilter != null && !recipientFilter.equals(""))
// PublicationController.mailPublishNotification(resultingEvents, siteNodeVO.getRepositoryId(), infoGluePrincipal, recipientFilter, db);
RequestAnalyser.getRequestAnalyser().registerComponentStatistics("changeState publish create event", t.getElapsedTime());
}
if(stateId.intValue() == SiteNodeVersionVO.PUBLISHED_STATE.intValue())
{
logger.info("About to publish an existing version");
oldMediumSiteNodeVersionImpl.setStateId(stateId);
oldMediumSiteNodeVersionImpl.setIsActive(new Boolean(true));
returnSiteNodeVersionImpl = oldMediumSiteNodeVersionImpl;
}
if(stateId.intValue() != SiteNodeVersionVO.PUBLISH_STATE.intValue() || CmsPropertyHandler.getUseApprovalFlow().equals("true"))
{