String fileContent = "";
if(missingRemoteContentFile.exists())
fileContent = FileHelper.getFileAsString(missingRemoteContentFile, "iso-8859-1");
ContentVersionVO newContentVersionVO = new ContentVersionVO();
newContentVersionVO.setVersionComment("Checked out from version control system (tag: " + tagName + ")");
newContentVersionVO.setVersionModifier(getInfoGluePrincipal().getName());
newContentVersionVO.setVersionValue(fileContent);
ContentVersionController.getContentVersionController().create(newlyCreatedContentVO.getId(), masterLanguageVO.getId(), newContentVersionVO, null);
}
else
{
ContentVO newContentVO = new ContentVO();
newContentVO.setCreatorName(getInfoGluePrincipal().getName());
newContentVO.setIsBranch(true);
newContentVO.setName(plainName);
ContentVO newlyCreatedContentVO = ContentController.getContentController().create(contentVO.getId(), ctdFolder.getContentTypeDefinitionId(), contentVO.getRepositoryId(), newContentVO);
logger.info("Created content:" + newlyCreatedContentVO.getName());
}
}
}
}
String[] deviatingLocalContentIdArray = this.getRequest().getParameterValues("deviatingContentId");
logger.info("deviatingLocalContentIdArray:" + deviatingLocalContentIdArray);
List deviatingComponents = new ArrayList();
if(deviatingLocalContentIdArray != null)
{
for(int i=0; i<deviatingLocalContentIdArray.length; i++)
{
String deviatingLocalContentId = deviatingLocalContentIdArray[i];
logger.info("deviatingLocalContentId:" + deviatingLocalContentId);
String deviatingFilePath = this.getRequest().getParameter("deviatingRemoteVersionId_" + deviatingLocalContentId);
logger.info("deviatingFilePath:" + deviatingFilePath);
ContentVO contentVO = ContentController.getContentController().getContentVOWithId(new Integer(deviatingLocalContentId).intValue());
if(contentVO != null)
{
LanguageVO languageVO = LanguageController.getController().getMasterLanguage(contentVO.getRepositoryId());
ContentVersionVO contentVersionVO = ContentVersionController.getContentVersionController().getLatestActiveContentVersionVO(contentVO.getId(), languageVO.getId());
String fileContent = FileHelper.getFileAsString(new File(deviatingFilePath), "iso-8859-1");
contentVersionVO.setVersionValue(fileContent);
contentVersionVO.setVersionComment("Checked out from version control system (tag: " + tagName + ")");
logger.info("We are going to replace local content: " + contentVO.getName() + " with contents in " + deviatingFilePath);
ContentVersionController.getContentVersionController().update(contentVersionVO.getContentId(), contentVersionVO.getLanguageId(), contentVersionVO, getInfoGluePrincipal());
}
}
}
return "success";