private boolean anonymousNoAccessWarning = false;
protected String doExecute() throws Exception
{
ProcessBean processBean = ProcessBean.createProcessBean(ViewListContentVersionAction.class.getName(), "" + getInfoGluePrincipal().getName());
processBean.setStatus(ProcessBean.RUNNING);
try
{
if(this.contentId != null)
{
Timer t = new Timer();
ContentVO contentVO = ContentController.getContentController().getContentVOWithId(this.contentId);
this.repositoryId = contentVO.getRepositoryId();
AccessConstraintExceptionBuffer ceb = new AccessConstraintExceptionBuffer();
Integer protectedContentId = ContentControllerProxy.getController().getProtectedContentId(contentId);
if(protectedContentId != null && !AccessRightController.getController().getIsPrincipalAuthorized(this.getInfoGluePrincipal(), "Content.SubmitToPublish", protectedContentId.toString()))
ceb.add(new AccessConstraintException("Content.contentId", "1005"));
ceb.throwIfNotEmpty();
RequestAnalyser.getRequestAnalyser().registerComponentStatistics("ViewListContentVersion part 1", t.getElapsedTime());
//Set<SiteNodeVersionVO> siteNodeVersionVOList = new HashSet<SiteNodeVersionVO>();
//Set<ContentVersionVO> contentVersionVOList = new HashSet<ContentVersionVO>();
ContentVersionController.getContentVersionController().getContentAndAffectedItemsRecursive(this.contentId, ContentVersionVO.WORKING_STATE, this.siteNodeVersionVOList, this.contentVersionVOList, true, true, processBean);
RequestAnalyser.getRequestAnalyser().registerComponentStatistics("ViewListContentVersion getContentAndAffectedItemsRecursive", t.getElapsedTime());
processBean.updateProcess("Found " + this.siteNodeVersionVOList.size() + " pages and " + this.contentVersionVOList.size() + " contents");
/*
Set<ContentVersionVO> contentVersionVOListSet = new HashSet<ContentVersionVO>();
for(Integer contentVersionId : contentVersionVOSet)
{
contentVersionVOListSet.add(ContentVersionController.getContentVersionController().getContentVersionVOWithId(contentVersionId));
}
*/
RequestAnalyser.getRequestAnalyser().registerComponentStatistics("ViewListContentVersion versions", t.getElapsedTime());
Database db = CastorDatabaseService.getDatabase();
beginTransaction(db);
try
{
boolean skipDisplayName = false;
for(ContentVersionVO contentVersionVO : contentVersionVOList)
{
if(contentVersionVO.getStateId() == 0)
{
Integer localProtectedContentId = ContentControllerProxy.getController().getProtectedContentId(contentVersionVO.getContentId());
if(localProtectedContentId != null)
{
boolean hasAnonymousUserAccess = AccessRightController.getController().getIsPrincipalAuthorized(db, UserControllerProxy.getController().getUser(CmsPropertyHandler.getAnonymousUser()), "Content.Read", localProtectedContentId.toString(), false);
if(!hasAnonymousUserAccess)
{
anonymousNoAccessWarning = true;
contentVersionVO.setHasAnonymousUserAccess(false);
}
}
if(!skipDisplayName)
{
InfoGluePrincipal principal = (InfoGluePrincipal)getInfoGluePrincipal(contentVersionVO.getVersionModifier(), db);
if(principal != null)
{
if(principal.getName().equalsIgnoreCase(principal.getDisplayName()))
skipDisplayName = true;
contentVersionVO.setVersionModifierDisplayName(principal.getDisplayName());
}
}
contentVersionVO.setPath(getContentPath(contentVersionVO.getContentId(), db));
contentVersionVO.setLanguageName(LanguageController.getController().getLanguageVOWithId(contentVersionVO.getLanguageId()).getName());
}
else
logger.info("Not adding contentVersion..");
}
for(SiteNodeVersionVO snVO : siteNodeVersionVOList)
{
if(snVO.getStateId() == 0)
{
Integer protectedSiteNodeVersionId = SiteNodeVersionControllerProxy.getSiteNodeVersionControllerProxy().getProtectedSiteNodeVersionId(snVO.getId(), db);
if(protectedSiteNodeVersionId != null)
{
boolean hasAnonymousUserAccess = AccessRightController.getController().getIsPrincipalAuthorized(db, UserControllerProxy.getController().getUser(CmsPropertyHandler.getAnonymousUser()), "SiteNodeVersion.Read", protectedSiteNodeVersionId.toString(), false);
if(!hasAnonymousUserAccess)
{
anonymousNoAccessWarning = true;
snVO.setHasAnonymousUserAccess(false);
}
}
if(!skipDisplayName)
{
InfoGluePrincipal principal = (InfoGluePrincipal)getInfoGluePrincipal(snVO.getVersionModifier(), db);
if(principal != null)
{
if(principal.getName().equalsIgnoreCase(principal.getDisplayName()))
skipDisplayName = true;
snVO.setVersionModifierDisplayName(principal.getDisplayName());
}
}
snVO.setPath(getSiteNodePath(snVO.getSiteNodeId(), db));
}
else
logger.info("Not adding siteNodeVersion..");
}
commitTransaction(db);
}
catch(Exception e)
{
logger.error("An error occurred so we should not complete the transaction:" + e);
logger.warn("An error occurred so we should not complete the transaction:" + e, e);
rollbackTransaction(db);
throw new SystemException(e.getMessage());
}
processBean.updateProcess("Added metadata");
Collections.sort(contentVersionVOList, Collections.reverseOrder(new ReflectionComparator("modifiedDateTime")));
Set siteNodeVersionVOListSet = new HashSet();
siteNodeVersionVOListSet.addAll(siteNodeVersionVOList);
siteNodeVersionVOList.clear();
siteNodeVersionVOList.addAll(siteNodeVersionVOListSet);
Collections.sort(siteNodeVersionVOList, Collections.reverseOrder(new ReflectionComparator("modifiedDateTime")));
RequestAnalyser.getRequestAnalyser().registerComponentStatistics("ViewListContentVersion end", t.getElapsedTime());
}
}
finally
{
processBean.setStatus(ProcessBean.FINISHED);
processBean.removeProcess();
}
return "success";
}