private void changeRepositoryRecursive(SiteNode siteNode, Repository newRepository, InfoGluePrincipal principal, Database db) throws Exception
{
if(siteNode.getRepository().getId().intValue() != newRepository.getId().intValue())
{
Integer metaInfoContentId = siteNode.getMetaInfoContentId();
MediumContentImpl metaInfoContent = (MediumContentImpl)ContentController.getContentController().getMediumContentWithId(metaInfoContentId, db);
//String previousPath = ContentController.getContentController().getContentPath(metaInfoContentId, db);
String siteNodePath = SiteNodeController.getController().getSiteNodePath(siteNode.getId(), db);
logger.info("siteNodePath:" + siteNodePath);
if(siteNodePath.indexOf("/", 2) > -1)
siteNodePath = siteNodePath.substring(siteNodePath.indexOf("/", 2));
logger.info("siteNodePath:" + siteNodePath);
ContentVO newParentContent = ContentController.getContentController().getContentVOWithPath(newRepository.getId(), "Meta info folder" + siteNodePath, true, principal, db);
if(metaInfoContent != null && newParentContent != null)
{
logger.info("Moving:" + metaInfoContent.getName() + " to " + newParentContent.getName());
//newParentContent.getChildren().add(metaInfoContent);
//Content previousParentContent = metaInfoContent.getParentContent();
metaInfoContent.setParentContentId(newParentContent.getId());
//previousParentContent.getChildren().remove(metaInfoContent);
LanguageVO oldMasterLanguage = LanguageController.getController().getMasterLanguage(metaInfoContent.getRepositoryId(), db);
LanguageVO newMasterLanguage = LanguageController.getController().getMasterLanguage(newParentContent.getRepositoryId(), db);
ContentVersionVO oldMasterContentVersionVO = ContentVersionController.getContentVersionController().getLatestContentVersionVO(metaInfoContent.getId(), oldMasterLanguage.getId(), db);
ContentVersionVO newMasterContentVersionVO = ContentVersionController.getContentVersionController().getLatestContentVersionVO(metaInfoContent.getId(), newMasterLanguage.getId(), db);
if(oldMasterContentVersionVO != null && newMasterContentVersionVO == null)
{
ContentVersionController.getContentVersionController().create(metaInfoContentId, newMasterLanguage.getId(), oldMasterContentVersionVO, null, db);
}
else if(oldMasterContentVersionVO != null && newMasterContentVersionVO != null)
{
String oldComponentStructure = ContentVersionController.getContentVersionController().getAttributeValue(oldMasterContentVersionVO, "ComponentStructure", false);
String newComponentStructure = ContentVersionController.getContentVersionController().getAttributeValue(newMasterContentVersionVO, "ComponentStructure", false);
if(oldComponentStructure != null && !oldComponentStructure.equals("") && (newComponentStructure == null || newComponentStructure.equals("")))
{
ContentVersionController.getContentVersionController().updateAttributeValue(newMasterContentVersionVO.getId(), "ComponentStructure", oldComponentStructure, principal, true);
}
}
metaInfoContent.setRepositoryId(newParentContent.getRepositoryId());
//changeRepositoryRecursiveForContent(metaInfoContent, newRepository);
}
siteNode.setRepository((RepositoryImpl)newRepository);
Iterator ChildSiteNodesIterator = siteNode.getChildSiteNodes().iterator();