Package org.infoglue.cms.applications.databeans

Examples of org.infoglue.cms.applications.databeans.ReferenceBean


           logger.info("referenceBeans:" + referenceBeans.size());
           for(Integer cvID : selfContentVersionIDList)
           {
             ContentVersionVO cvVO = ContentVersionController.getContentVersionController().getContentVersionVOWithId(cvID, db);
            
             ReferenceBean bean = new ReferenceBean();
             ReferenceVersionBean versionBean = new ReferenceVersionBean();
             versionBean.setReferencingObject(cvVO);
             //bean.setReferencingCompletingObject(versionBean);
             bean.getVersions().add(versionBean);
             referenceBeans.add(bean);
           }
          
           logger.info("referenceBeans:" + referenceBeans.size());
           for(ReferenceBean referenceBean : referenceBeans)
View Full Code Here


        List referencingObjects = RegistryController.getController().getReferencingObjectsForContent(contentId, maxRows, false, true, db);
       
        Iterator referencingObjectsIterator = referencingObjects.iterator();
        while(referencingObjectsIterator.hasNext())
        {
          ReferenceBean referenceBean = (ReferenceBean)referencingObjectsIterator.next();
          Object pageCandidate = referenceBean.getReferencingCompletingObject();
          if(pageCandidate instanceof SiteNodeVO)
          {
            if(!excludeCurrentPage || !((SiteNodeVO)pageCandidate).getId().equals(siteNodeId))
              referencingPages.add(pageCandidate);
          }
View Full Code Here

      RegistryVO registryVO = getRegistryVOWithId(new Integer(registryIdString), db);
      if (logger.isInfoEnabled())
      {
        logger.info("About to remove registry bean. Referencing-type: " + registryVO.getReferencingEntityName() + ", referencing-id: " + registryVO.getReferencingEntityId());
      }
      ReferenceBean referenceBean = getReferenceBeanFromRegistryVO(registryVO, entries, checkedLanguageVersions, onlyLatest, true, db);
      if (referenceBean != null)
      {
        references.add(referenceBean);
      }
        delete(registryVO.getRegistryId(), db);
View Full Code Here

      {
        if (logger.isInfoEnabled())
      {
        logger.info("About to remove registry bean. Referencing-type: " + registryVO.getReferencingEntityName() + ", referencing-id: " + registryVO.getReferencingEntityId());
      }
      ReferenceBean referenceBean = getReferenceBeanFromRegistryVO(registryVO, entries, checkedLanguageVersions, onlyLatest, false, db);
      if (referenceBean != null)
      {
        references.add(referenceBean);
      }
      delete(registryVO.getRegistryId(), db);
View Full Code Here

            logger.info("registryVO:" + registryVO.getReferencingEntityName() + ":" + registryVO.getReferencingEntityId() + ":" + registryVO.getReferencingEntityCompletingName() + ":" + registryVO.getReferencingEntityCompletingId());
            boolean add = true;
           
            String key = "" + registryVO.getReferencingEntityCompletingName() + "_" + registryVO.getReferencingEntityCompletingId();
            //String key = "" + registryVO.getReferencingEntityName() + "_" + registryVO.getReferencingEntityId();
            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 contentVersion = ContentVersionController.getContentVersionController().getContentVersionVOWithId(new Integer(registryVO.getReferencingEntityId()), db);
                    //logger.info("content: " + contentVersion.getOwningContent().getContentId() + " - contentVersion: " + contentVersion.getId());
                    Boolean hasVersion = checkedLanguageVersions.get("" + contentVersion.getContentId() + "_" + contentVersion.getLanguageId());
                    if(hasVersion != null && onlyOneVersionPerLanguage)
                    {
                      continue;
                      //referenceBeanList.remove(existingReferenceBean);
                    }
                    else if(excludeInternalContentReferences && contentVersion.getContentId().equals(contentId))
            {
              logger.info("Skipping internal reference " + contentId + " had on itself.");
              referenceBeanList.remove(existingReferenceBean);
            }
            else
            {
              ContentVO contentVO = ContentController.getContentController().getContentVOWithId(contentVersion.getContentId(), db);

              existingReferenceBean.setName(contentVO.getName());
              existingReferenceBean.setReferencingCompletingObject(contentVO);
              existingReferenceBean.setPath(ContentController.getContentController().getContentPath(contentVersion.getContentId(), false, true, db));
              try
              {
                String userName = contentVersion.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(contentVersion);
              referenceVersionBean.getRegistryVOList().add(registryVO);
             
              String assetExtraInfo = RegistryController.getController().getInlineAssetInformation(contentVersion.getVersionValue(), new Integer(registryVO.getEntityId()), contentVersion.getLanguageId(), null, true, db);
              if(assetExtraInfo != null)
                referenceVersionBean.setReferencingExtraInfo(assetExtraInfo);
             
              logger.info("assetExtraInfo:" + assetExtraInfo);

              checkedLanguageVersions.put("" + contentVersion.getContentId() + "_" + contentVersion.getLanguageId(), new Boolean(true));
            }
                }
                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);
                  if(!siteNodeVersion.getIsActive())
                    add = false;
                 
                  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(), null, true, db);
            logger.info("assetExtraInfo:" + assetExtraInfo);
            if(assetExtraInfo != null)
              referenceVersionBean.setReferencingExtraInfo(assetExtraInfo);
                }
                catch(Exception e)
                {
                  add = false;
                    logger.info("siteNode:" + registryVO.getReferencingEntityId() + " did not exist - skipping:" + e.getMessage());
                }
            }
           
            logger.info("Add:" + add);
            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();
            if(referenceBean.getVersions().size() == 0)
                i.remove();
        }
     
    logger.info("referenceBeanList:" + referenceBeanList.size());
   
View Full Code Here

            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());
   
View Full Code Here

        List referencingObjects = RegistryController.getController().getReferencingObjectsForContent(contentId, maxRows, false, false, db);
       
        Iterator referencingObjectsIterator = referencingObjects.iterator();
        while(referencingObjectsIterator.hasNext())
        {
          ReferenceBean referenceBean = (ReferenceBean)referencingObjectsIterator.next();
          Object pageCandidate = referenceBean.getReferencingCompletingObject();
          if(pageCandidate instanceof SiteNodeVO)
          {
            referencingSiteNodeVOList.add((SiteNodeVO) pageCandidate);
          }
        }
View Full Code Here

        Iterator<RegistryVO> registryEntiresIterator = registryEntires.iterator();
        while(registryEntiresIterator.hasNext())
        {
            RegistryVO registryVO = registryEntiresIterator.next();
            logger.info("registryVO:" + registryVO.getReferencingEntityId() + ":" +  registryVO.getReferencingEntityCompletingId());
            ReferenceBean referenceBean = getReferenceBeanFromRegistryVO(registryVO, entries, checkedLanguageVersions, onlyLatestVersion, onlyOneVersionPerLanguage, db);
            if (referenceBean != null)
            {
              referenceBeanList.add(referenceBean);
            }
        }

        Iterator<ReferenceBean> i = referenceBeanList.iterator();
        while(i.hasNext())
        {
            ReferenceBean referenceBean = i.next();
            if(referenceBean.getVersions().size() == 0)
                i.remove();
        }

        return referenceBeanList;
    }
View Full Code Here

        return referenceBeanList;
    }

    private ReferenceBean getReferenceBeanFromRegistryVO(RegistryVO registryVO, Map<String, ReferenceBean> entries, Map<String,Boolean> checkedLanguageVersions, boolean onlyLatestVersion, boolean onlyOneVersionPerLanguage, Database db)
    {
      ReferenceBean result = null;
      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);
            result = existingReferenceBean;
        }
        else if (logger.isDebugEnabled())
        {
          logger.info("Already had ReferenceBean for key: " + key);
        }

        ReferenceVersionBean referenceVersionBean = new ReferenceVersionBean();

        if(registryVO.getReferencingEntityName().indexOf("Content") > -1)
        {
            try
            {
              logger.info("RegistryVO references Content");
        ContentVersionVO contentVersion = null;
        try
        {
          contentVersion = ContentVersionController.getContentVersionController().getContentVersionVOWithId(new Integer(registryVO.getReferencingEntityId()), db);
        }
        catch(Exception ex)
        {
          add = false;
          result = null;
          logger.info("content:" + registryVO.getReferencingEntityId() + " did not exist - skipping..");
        }
        if (contentVersion != null)
        {
          if (!contentVersion.getIsActive())
          {
            add = false;
            logger.info("ContentVersion was not active. Will not add to reference list. ContentVersion.id: " + contentVersion.getContentVersionId());
          }
          else
          {
            ContentVO contentVO = ContentController.getContentController().getContentVOWithId(contentVersion.getContentId(), db);
            if (contentVO.getIsDeleted())
            {
              add = false;
              logger.info("Content is deleted. Will not add to reference list. Content.id: " + contentVO.getContentId());
            }
            else
            {
                        Boolean hasVersion = checkedLanguageVersions.get("" + contentVersion.getContentId() + "_" + contentVersion.getLanguageId());
                        if(hasVersion != null && onlyOneVersionPerLanguage)
                        {
                          add = false;
                          //referenceBeanList.remove(existingReferenceBean);
                        }
                        else if (onlyLatestVersion)
              {
                ContentVersionVO latestContentVersion = ContentVersionController.getContentVersionController().getLatestActiveContentVersionVO(contentVersion.getContentId(), contentVersion.getLanguageId(), ContentVersionVO.WORKING_STATE, db);

                if (logger.isDebugEnabled())
                {
                  logger.info("Latest version in working state for content.id: " + contentVersion.getContentId() + ". latestContentVersion.id: " + (latestContentVersion == null ? "null" : latestContentVersion.getContentVersionId()));
                }

                if (latestContentVersion != null && latestContentVersion.getContentVersionId().intValue() != contentVersion.getContentVersionId().intValue())
                {
                  logger.debug("ContentVersion was not latest version. Will not add. ContentVersion-Id: " + contentVersion.getId());
                  add = false;
                }
              }
                      if (add)
                      {
                existingReferenceBean.setName(contentVO.getName());
                existingReferenceBean.setPath(ContentController.getContentController().getContentPath(contentVO.getContentId(), false, true, db));
                existingReferenceBean.setReferencingCompletingObject(contentVO);

                String contactPersonEmail = getContactPersonEmail(contentVO, db);
                existingReferenceBean.setContactPersonEmail(contactPersonEmail);

                contentVersion.setLanguageName(LanguageController.getController().getLanguageVOWithId(contentVersion.getLanguageId(), db).getName());
                referenceVersionBean.setReferencingObject(contentVersion);
                referenceVersionBean.getRegistryVOList().add(registryVO);
               
                  checkedLanguageVersions.put("" + contentVersion.getContentId() + "_" + contentVersion.getLanguageId(), new Boolean(true));
                      }
            }
          }
        }
      }
      catch(Exception ex)
      {
        add = false;
        result = null;
        logger.error("Error when creating reference bean from Registry entry for Content. Message: " + ex.getMessage() + ". Class: " + ex.getClass());
        logger.warn("Error when creating reference bean from Registry entry for Content.", ex);
      }
    }
    else
    {
      try
      {
        logger.debug("RegistryVO references SiteNode");
        SiteNodeVersionVO siteNodeVersion = null;
        try
                {
          siteNodeVersion = SiteNodeVersionController.getController().getSiteNodeVersionVOWithId(new Integer(registryVO.getReferencingEntityId()), db);
                }
        catch (Exception ex)
        {
          add = false;
          result = null;
          logger.info("siteNode:" + registryVO.getReferencingEntityId() + " did not exist - skipping..");
        }
        if (siteNodeVersion != null)
        {
          logger.info("siteNodeVersion:" + siteNodeVersion);
          if (!siteNodeVersion.getIsActive())
          {
            add = false;
            logger.debug("SiteNodeVersion was not active. Will not add to reference list. SiteNodeVersion.id: " + siteNodeVersion.getSiteNodeVersionId());
          }
          else
          {
            SiteNodeVO siteNodeVO = SiteNodeController.getSiteNodeVOWithId(siteNodeVersion.getSiteNodeId(), db);
            if (siteNodeVO.getIsDeleted())
            {
              add = false;
              logger.debug("SiteNode is deleted. Will not add to reference list. Content.id: " + siteNodeVO.getSiteNodeId());
            }
            else
            {
              if (onlyLatestVersion)
              {
                SiteNodeVersionVO latestSiteNodeVersion = SiteNodeVersionController.getController().getLatestActiveSiteNodeVersionVO(db, siteNodeVersion.getSiteNodeId(), SiteNodeVersionVO.WORKING_STATE);
                if (latestSiteNodeVersion != null && latestSiteNodeVersion.getSiteNodeVersionId() != siteNodeVersion.getSiteNodeVersionId())
                {
                  logger.debug("ContentVersion was not latest version. Will not add. ContentVersion-Id: " + siteNodeVersion.getId());
                  add = false;
                }
              }

              if (add)
              {
                existingReferenceBean.setName(siteNodeVO.getName());
                existingReferenceBean.setPath(SiteNodeController.getController().getSiteNodePath(siteNodeVO, false, true, db));
                existingReferenceBean.setReferencingCompletingObject(siteNodeVO);
                referenceVersionBean.setReferencingObject(siteNodeVersion);

                String contactPersonEmail = getContactPersonEmail(siteNodeVO, db);
                existingReferenceBean.setContactPersonEmail(contactPersonEmail);

                referenceVersionBean.getRegistryVOList().add(registryVO);
              }
            }
          }
        }
      }
      catch(Exception ex)
      {
        add = false;
        result = null;
        logger.error("Error when creating reference bean from Registry entry for SiteNode. Message: " + ex.getMessage() + ". Class: " + ex.getClass());
        logger.warn("Error when creating reference bean from Registry entry for SiteNode.", ex);
      }
        }

        if(add)
        {
            boolean exists = false;
            ReferenceVersionBean existingReferenceVersionBean = null;
            Iterator<ReferenceVersionBean> versionsIterator = existingReferenceBean.getVersions().iterator();
            while(versionsIterator.hasNext())
            {
                existingReferenceVersionBean = (ReferenceVersionBean)versionsIterator.next();
                if(existingReferenceVersionBean.getReferencingObject().equals(referenceVersionBean.getReferencingObject()))
                {
                    exists = true;
                    break;
                }
            }

            if(!exists)
                existingReferenceBean.getVersions().add(referenceVersionBean);
            else
                existingReferenceVersionBean.getRegistryVOList().add(registryVO);

            logger.debug("Number of versions: " + existingReferenceBean.getVersions());
        }


        return result;
    }
View Full Code Here

TOP

Related Classes of org.infoglue.cms.applications.databeans.ReferenceBean

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.