logger.info("Page component binding:" + registryVO.getId() + " - " + registryVO.getReferencingEntityName() + ":" + registryVO.getReferencingEntityId() + ":" + registryVO.getReferencingEntityCompletingName() + ":" + registryVO.getReferencingEntityCompletingId());
boolean add = true;
String key = "" + registryVO.getReferencingEntityCompletingName() + "_" + registryVO.getReferencingEntityCompletingId();
ReferenceBean existingReferenceBean = (ReferenceBean)entries.get(key);
if(existingReferenceBean == null)
{
existingReferenceBean = new ReferenceBean();
logger.info("Adding referenceBean to entries with key:" + key);
entries.put(key, existingReferenceBean);
referenceBeanList.add(existingReferenceBean);
}
ReferenceVersionBean referenceVersionBean = new ReferenceVersionBean();
try
{
SiteNodeVersionVO siteNodeVersion = SiteNodeVersionController.getController().getSiteNodeVersionVOWithId(new Integer(registryVO.getReferencingEntityId()), db);
SiteNodeVO siteNodeVO = SiteNodeController.getController().getSiteNodeVOWithId(siteNodeVersion.getSiteNodeId(), db);
logger.info("siteNodeVersion:" + siteNodeVersion.getSiteNodeVersionId());
logger.info("siteNode:" + siteNodeVO.getId());
existingReferenceBean.setName(siteNodeVO.getName());
existingReferenceBean.setReferencingCompletingObject(siteNodeVO);
existingReferenceBean.setPath(SiteNodeController.getController().getSiteNodePath(siteNodeVO.getSiteNodeId(), false, true, db));
try
{
String userName = siteNodeVersion.getVersionModifier();
if(userName == null || userName.equals(""))
userName = siteNodeVO.getCreatorName();
InfoGluePrincipal user = UserControllerProxy.getController().getUser(userName);
if(user != null)
existingReferenceBean.setContactPersonEmail(user.getEmail());
else
existingReferenceBean.setContactPersonEmail(userName);
}
catch (Exception e)
{
logger.warn("Problem getting version modifier email: " + e.getMessage());
}
referenceVersionBean.setReferencingObject(siteNodeVersion);
referenceVersionBean.getRegistryVOList().add(registryVO);
LanguageVO masterLanguageVO = LanguageController.getController().getMasterLanguage(siteNodeVO.getRepositoryId(), db);
ContentVersionVO cvVO = ContentVersionController.getContentVersionController().getLatestActiveContentVersionVO(siteNodeVO.getMetaInfoContentId(), masterLanguageVO.getId(), db);
logger.info("cvVO:" + cvVO.getId());
String assetExtraInfo = RegistryController.getController().getInlineAssetInformation(cvVO.getVersionValue(), new Integer(registryVO.getEntityId()), masterLanguageVO.getLanguageId(), assetKey, false, db);
logger.info("assetExtraInfo:" + assetExtraInfo);
if(assetExtraInfo != null && !assetExtraInfo.equals(""))
referenceVersionBean.setReferencingExtraInfo(assetExtraInfo);
else if(discardMiss)
{
add = false;
}
}
catch(Exception e)
{
add = false;
logger.info("siteNode:" + registryVO.getReferencingEntityId() + " did not exist - skipping..");
}
if(add)
{
boolean exists = false;
ReferenceVersionBean existingReferenceVersionBean = null;
Iterator versionsIterator = existingReferenceBean.getVersions().iterator();
while(versionsIterator.hasNext())
{
existingReferenceVersionBean = (ReferenceVersionBean)versionsIterator.next();
if(existingReferenceVersionBean == null || existingReferenceVersionBean.getReferencingObject() == null || referenceVersionBean.getReferencingObject() == null || referenceVersionBean == null || existingReferenceVersionBean.getReferencingObject().equals(referenceVersionBean.getReferencingObject()))
{
exists = true;
break;
}
}
if(!exists)
existingReferenceBean.getVersions().add(referenceVersionBean);
else
existingReferenceVersionBean.getRegistryVOList().add(registryVO);
logger.info("existingReferenceBean.getVersions():" + existingReferenceBean.getVersions());
}
}
else
{
logger.info("Inline ASSET binding: " + assetKey);
boolean add = true;
String key = "" + registryVO.getReferencingEntityCompletingName() + "_" + registryVO.getReferencingEntityCompletingId();
ReferenceBean existingReferenceBean = (ReferenceBean)entries.get(key);
if(existingReferenceBean == null)
{
existingReferenceBean = new ReferenceBean();
logger.info("Adding referenceBean to entries with key:" + key);
entries.put(key, existingReferenceBean);
referenceBeanList.add(existingReferenceBean);
}
ReferenceVersionBean referenceVersionBean = new ReferenceVersionBean();
if(registryVO.getReferencingEntityName().indexOf("Content") > -1)
{
try
{
ContentVersionVO cv = ContentVersionController.getContentVersionController().getContentVersionVOWithId(new Integer(registryVO.getReferencingEntityId()), db);
ContentVersionVO latestContentVersion = ContentVersionController.getContentVersionController().getLatestActiveContentVersionVO(new Integer(registryVO.getReferencingEntityCompletingId()), cv.getLanguageId(), db);
Boolean hasVersion = checkedLanguageVersions.get("" + latestContentVersion.getContentId() + "_" + latestContentVersion.getLanguageId());
if(hasVersion != null && onlyLatestVersionPerLanguage)
{
continue;
//referenceBeanList.remove(existingReferenceBean);
}
else if(excludeInternalContentReferences && latestContentVersion.getContentId().equals(contentId))
{
logger.info("Skipping internal reference " + contentId + " had on itself.");
referenceBeanList.remove(existingReferenceBean);
}
else
{
logger.info("contentVersion:" + latestContentVersion.getId() + " : " + assetKey);
boolean includesAsset = RegistryController.getController().hasInlineAsset(latestContentVersion.getVersionValue(), new Integer(registryVO.getEntityId()), assetKey, db);
logger.info("includesAsset:" + includesAsset);
if(includesAsset)
{
ContentVO contentVO = ContentController.getContentController().getContentVOWithId(latestContentVersion.getContentId(), db);
existingReferenceBean.setName(contentVO.getName());
existingReferenceBean.setReferencingCompletingObject(contentVO);
existingReferenceBean.setPath(ContentController.getContentController().getContentPath(contentVO.getContentId(), false, true, db));
try
{
String userName = latestContentVersion.getVersionModifier();
if(userName == null || userName.equals(""))
userName = contentVO.getCreatorName();
InfoGluePrincipal user = UserControllerProxy.getController().getUser(userName);
if(user != null)
existingReferenceBean.setContactPersonEmail(user.getEmail());
else
existingReferenceBean.setContactPersonEmail(userName);
}
catch (Exception e)
{
logger.warn("Problem getting version modifier email: " + e.getMessage());
}
referenceVersionBean.setReferencingObject(latestContentVersion);
referenceVersionBean.getRegistryVOList().add(registryVO);
checkedLanguageVersions.put("" + latestContentVersion.getContentId() + "_" + latestContentVersion.getLanguageId(), new Boolean(true));
}
else
{
//if(existingReferenceBean.getVersions().size() == 0)
referenceBeanList.remove(existingReferenceBean);
//logger.info("NOOOOOOOO: This version had no asset reference...");
}
}
}
catch(Exception e)
{
add = false;
logger.info("content:" + registryVO.getReferencingEntityId() + " did not exist - skipping..");
}
}
else
{
try
{
SiteNodeVersionVO siteNodeVersion = SiteNodeVersionController.getController().getSiteNodeVersionVOWithId(new Integer(registryVO.getReferencingEntityId()), db);
SiteNodeVO siteNodeVO = SiteNodeController.getController().getSiteNodeVOWithId(siteNodeVersion.getSiteNodeId(), db);
logger.info("siteNodeVersion:" + siteNodeVersion.getSiteNodeVersionId());
logger.info("siteNode:" + siteNodeVO.getId());
existingReferenceBean.setName(siteNodeVO.getName());
existingReferenceBean.setReferencingCompletingObject(siteNodeVO);
existingReferenceBean.setPath(SiteNodeController.getController().getSiteNodePath(siteNodeVO.getSiteNodeId(), false, true, db));
try
{
String userName = siteNodeVersion.getVersionModifier();
if(userName == null || userName.equals(""))
userName = siteNodeVO.getCreatorName();
InfoGluePrincipal user = UserControllerProxy.getController().getUser(userName);
if(user != null)
existingReferenceBean.setContactPersonEmail(user.getEmail());
else
existingReferenceBean.setContactPersonEmail(userName);
}
catch (Exception e)
{
logger.warn("Problem getting version modifier email: " + e.getMessage());
}
referenceVersionBean.setReferencingObject(siteNodeVersion);
referenceVersionBean.getRegistryVOList().add(registryVO);
LanguageVO masterLanguageVO = LanguageController.getController().getMasterLanguage(siteNodeVO.getRepositoryId(), db);
ContentVersionVO cvVO = ContentVersionController.getContentVersionController().getLatestActiveContentVersionVO(siteNodeVO.getMetaInfoContentId(), masterLanguageVO.getId(), db);
String assetExtraInfo = RegistryController.getController().getInlineAssetInformation(cvVO.getVersionValue(), new Integer(registryVO.getEntityId()), masterLanguageVO.getLanguageId(), assetKey, false, db);
if(assetExtraInfo != null && !assetExtraInfo.equals(""))
referenceVersionBean.setReferencingExtraInfo(assetExtraInfo);
else
add = false;
}
catch(Exception e)
{
add = false;
logger.info("siteNode:" + registryVO.getReferencingEntityId() + " did not exist - skipping..");
}
}
if(add)
{
boolean exists = false;
ReferenceVersionBean existingReferenceVersionBean = null;
Iterator versionsIterator = existingReferenceBean.getVersions().iterator();
while(versionsIterator.hasNext())
{
existingReferenceVersionBean = (ReferenceVersionBean)versionsIterator.next();
if(existingReferenceVersionBean == null || existingReferenceVersionBean.getReferencingObject() == null || referenceVersionBean.getReferencingObject() == null || referenceVersionBean == null || existingReferenceVersionBean.getReferencingObject().equals(referenceVersionBean.getReferencingObject()))
{
exists = true;
break;
}
}
if(!exists)
existingReferenceBean.getVersions().add(referenceVersionBean);
else
existingReferenceVersionBean.getRegistryVOList().add(registryVO);
}
}
}
Iterator i = referenceBeanList.iterator();
while(i.hasNext())
{
ReferenceBean referenceBean = (ReferenceBean)i.next();
logger.info("referenceBean:" + referenceBean.getPath() + "/" + referenceBean.getVersions().size());
if(referenceBean.getVersions().size() == 0)
i.remove();
}
logger.info("referenceBeanList:" + referenceBeanList.size());