String repositoryName = getRepositoryNameFromCheckoutFile(missingRemoteContentFile);
logger.info("repositoryName:" + repositoryName);
logger.info("templateLanguageCode:" + templateLanguageCode);
RepositoryVO repositoryVO = RepositoryController.getController().getRepositoryVOWithName(repositoryName);
LanguageVO masterLanguageVO = LanguageController.getController().getLanguageVOWithCode(templateLanguageCode);
ContentVO localParentContentVO = null;
if(repositoryVO == null)
{
RepositoryVO newRepositoryVO = new RepositoryVO();
newRepositoryVO.setName(repositoryName);
newRepositoryVO.setDnsName("undefined");
newRepositoryVO.setDescription("Autogenerated during cvs sync");
repositoryVO = RepositoryController.getController().create(newRepositoryVO);
if(masterLanguageVO == null)
masterLanguageVO = (LanguageVO)LanguageController.getController().getLanguageVOList().get(0);
RepositoryLanguageController.getController().createRepositoryLanguage(repositoryVO.getId(), masterLanguageVO.getId(), 0);
localParentContentVO = ContentController.getContentController().getRootContentVO(repositoryVO.getId(), getInfoGluePrincipal().getName(), true);
this.repositoryCreated = true;
}
else
{
logger.info("Found repository:" + repositoryVO.getName());
localParentContentVO = ContentController.getContentController().getRootContentVO(repositoryVO.getId(), getInfoGluePrincipal().getName(), true);
masterLanguageVO = LanguageController.getController().getMasterLanguage(repositoryVO.getId());
}
String contentPath = getContentPathAsListFromCheckoutFile(missingRemoteContentFile);
logger.info("contentPath:" + contentPath);
ContentVO contentVO = ContentController.getContentController().getContentVOWithPath(repositoryVO.getId(), contentPath, true, getInfoGluePrincipal());
if(contentVO != null)
{
if(missingRemoteContentFile.isFile())
{
ContentVO newContentVO = new ContentVO();
newContentVO.setCreatorName(getInfoGluePrincipal().getName());
newContentVO.setIsBranch(false);
newContentVO.setName(plainName);
ContentVO newlyCreatedContentVO = ContentController.getContentController().create(contentVO.getId(), ctd.getContentTypeDefinitionId(), contentVO.getRepositoryId(), newContentVO);
logger.info("Created content:" + newlyCreatedContentVO.getName());
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 + ")");