}
public String doExecute() throws Exception
{
ContentTypeDefinitionVO ctd = ContentTypeDefinitionController.getController().getContentTypeDefinitionVOWithName("HTMLTemplate");
ContentTypeDefinitionVO ctdFolder = ContentTypeDefinitionController.getController().getContentTypeDefinitionVOWithName("Folder");
String[] missingRemoteContentPathArray = this.getRequest().getParameterValues("missingRemoteContentPath");
logger.info("missingRemoteContentPathArray:" + missingRemoteContentPathArray);
//List deviatingComponents = new ArrayList();
if(missingRemoteContentPathArray != null)
{
for(int i=0; i<missingRemoteContentPathArray.length; i++)
{
String missingRemoteContentPath = missingRemoteContentPathArray[i];
logger.info("missingRemoteContentPath:" + missingRemoteContentPath);
File missingRemoteContentFile = new File(missingRemoteContentPath);
String templateLanguageCode = null;
String plainName = missingRemoteContentFile.getName();
if(plainName.indexOf(".xml") > -1)
{
plainName = plainName.substring(0, plainName.indexOf(".xml"));
logger.info("Plain name:" + plainName);
if(plainName.lastIndexOf("_") > -1)
{
templateLanguageCode = plainName.substring(plainName.lastIndexOf("_") + 1);
plainName = plainName.substring(0, plainName.lastIndexOf("_"));
logger.info("templateLanguageCode:" + templateLanguageCode);
logger.info("Plain name:" + plainName);
}
}
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());
}
}
}