logger.info("newVersionValue: " + newVersionValue);
}
}
//newVersionValue = newVersionValue.replaceAll("getInlineAssetUrl\\(" + oldContentId + ",", "getInlineAssetUrl(" + newContentId + ",");
ContentVersion cvReal = ContentVersionController.getContentVersionController().getMediumContentVersionWithId(cv.getId(), db);
logger.info("cvReal:" + cvReal.getId());
if(selfNewVersion != null && selfNewVersion.getContentId().intValue() == cvReal.getValueObject().getContentId().intValue() && selfNewVersion.getLanguageId().intValue() == cvReal.getValueObject().getLanguageId().intValue() && selfNewVersion.getId().intValue() > cvReal.getId().intValue())
{
logger.info("Was itself - lets use the new version instead...");
cvReal = selfNewVersion;
}
cvReal.setVersionValue(newVersionValue);
cvReal.setVersionComment("Asset moved...");
cvReal.setVersionModifier(principal.getName());
cvReal.setModifiedDateTime(new Date());
RegistryController.getController().updateContentVersion(cvReal.getValueObject(), null, db);
}
else if(o instanceof SiteNodeVersionVO)
{
SiteNodeVersionVO snvo = (SiteNodeVersionVO)o;
logger.info("Replacing in sn:" + snvo.getId());
SiteNodeVO siteNodeVO = SiteNodeController.getController().getSiteNodeVOWithId(snvo.getSiteNodeId(), db);
LanguageVO masterLanguageVO = LanguageController.getController().getMasterLanguage(siteNodeVO.getRepositoryId(), db);
ContentVersionVO cv = ContentVersionController.getContentVersionController().getLatestActiveContentVersionVO(siteNodeVO.getMetaInfoContentId(), masterLanguageVO.getId(), db);
logger.info("Replacing in:" + cv.getVersionValue());
String newVersionValue = cv.getVersionValue(); //.replaceAll("\"" + oldContentId + "\"", "\"" + newContentId + "\"");
Pattern p = Pattern.compile("<binding.*?>");
Matcher m = p.matcher(newVersionValue);
while (m.find())
{
logger.info("Found a " + m.group() + ".");
String binding = m.group();
if(binding.contains("\"" + oldContentId + "\"") && binding.contains("\"" + asset.getAssetKey() + "\""))
{
binding = binding.replaceFirst("\"" + oldContentId + "\"", "\"" + newContentId + "\"");
logger.info("Replacing:" + m.group() + ":" + binding);
newVersionValue = StringUtils.replace(newVersionValue, m.group(), binding);
logger.info("newVersionValue: " + newVersionValue);
}
}
ContentVersion cvReal = ContentVersionController.getContentVersionController().getMediumContentVersionWithId(cv.getId(), db);
cvReal.setVersionValue(newVersionValue);
cvReal.setVersionComment("Asset moved...");
cvReal.setVersionModifier(principal.getName());
cvReal.setModifiedDateTime(new Date());
RegistryController.getController().updateContentVersion(cvReal.getValueObject(), snvo, db);
}
}
catch (Throwable e)
{
e.printStackTrace();