RegistryController.getController().updateContentVersionThreaded(newContentVersion.getValueObject(), null);
ContentTypeDefinitionVO metaInfoCTDVO = ContentTypeDefinitionController.getController().getContentTypeDefinitionVOWithName("Meta info");
if(contentVO.getContentTypeDefinitionId() != null && !contentVO.getContentTypeDefinitionId().equals(metaInfoCTDVO.getId()))
{
EventVO eventVO = new EventVO();
eventVO.setDescription(newContentVersion.getVersionComment());
eventVO.setEntityClass(ContentVersion.class.getName());
eventVO.setEntityId(new Integer(newContentVersion.getId().intValue()));
eventVO.setName(contentVO.getName());
eventVO.setTypeId(EventVO.PUBLISH);
eventVO = EventController.create(eventVO, contentVO.getRepositoryId(), infoGluePrincipal, db);
resultingEvents.add(eventVO);
}
}
else
{
oldContentVersion = ContentVersionController.getContentVersionController().getMediumContentVersionWithId(oldContentVersionId, db);
oldContentVersion.setVersionComment(versionComment);
EventVO eventVO = new EventVO();
eventVO.setDescription(versionComment);
eventVO.setEntityClass(ContentVersion.class.getName());
eventVO.setEntityId(new Integer(newContentVersion.getId().intValue()));
eventVO.setName(contentVO.getName());
eventVO.setTypeId(EventVO.PUBLISH);
eventVO = EventController.create(eventVO, contentVO.getRepositoryId(), infoGluePrincipal, db);
resultingEvents.add(eventVO);
}
//if(recipientFilter != null && !recipientFilter.equals(""))
// PublicationController.mailPublishNotification(resultingEvents, contentVO.getRepositoryId(), infoGluePrincipal, recipientFilter, db);
}
//If the user in the publish-app publishes a publish-version we change state to published.
if (stateId.intValue() == ContentVersionVO.PUBLISHED_STATE.intValue())
{
oldContentVersion = ContentVersionController.getContentVersionController().getMediumContentVersionWithId(oldContentVersionId, db);
logger.info("About to publish an existing version:" + oldContentVersion.getId() + ":" + oldContentVersion.getStateId());
Integer oldContentVersionStateId = oldContentVersion.getStateId();
oldContentVersion.setStateId(stateId);
oldContentVersion.setIsActive(new Boolean(true));
//New logic to add meta data in some cases... ugly but needed if users are removed.
insertIGMetaDataAttributes(oldContentVersion, infoGluePrincipal);
//End new logic
newContentVersion = oldContentVersion;
//Creating the event that will notify the editor...
if(oldContentVersionStateId.intValue() == ContentVersionVO.WORKING_STATE.intValue())
{
ContentTypeDefinitionVO metaInfoCTDVO = ContentTypeDefinitionController.getController().getContentTypeDefinitionVOWithName("Meta info");
if(contentVO.getContentTypeDefinitionId() != null && !contentVO.getContentTypeDefinitionId().equals(metaInfoCTDVO.getId()))
{
EventVO eventVO = new EventVO();
eventVO.setDescription(newContentVersion.getVersionComment());
eventVO.setEntityClass(ContentVersion.class.getName());
eventVO.setEntityId(new Integer(newContentVersion.getId().intValue()));
eventVO.setName(contentVO.getName());
eventVO.setTypeId(EventVO.PUBLISH);
eventVO = EventController.create(eventVO, contentVO.getRepositoryId(), infoGluePrincipal, db);
resultingEvents.add(eventVO);
}
}