Examples of ContentVersion


Examples of org.infoglue.cms.entities.content.ContentVersion

      logger.info("org contentVersions:" + contentVersions.size());
      List selectedContentVersions = new ArrayList();
      Iterator realContentVersionsIterator = contentVersions.iterator();
      while(realContentVersionsIterator.hasNext())
      {
        ContentVersion contentVersion = (ContentVersion)realContentVersionsIterator.next();     
        Iterator selectedContentVersionsIterator = selectedContentVersions.iterator();
        boolean addLanguageVersion = true;
        boolean noLanguageVersionFound = true;
        while(selectedContentVersionsIterator.hasNext())
        {
          ContentVersion currentContentVersion = (ContentVersion)selectedContentVersionsIterator.next();
          logger.info("" + currentContentVersion.getLanguage().getLanguageCode() + "=" + contentVersion.getLanguage().getLanguageCode());
          if(currentContentVersion.getLanguage().getLanguageCode().equals(contentVersion.getLanguage().getLanguageCode()))
          {
            noLanguageVersionFound = false;
           
            logger.info("" + contentVersion.getIsActive() + "=" + contentVersion.getLanguage().getLanguageCode());
            if(contentVersion.getIsActive().booleanValue() && contentVersion.getContentVersionId().intValue() > currentContentVersion.getContentVersionId().intValue())
            {
              logger.info("A later version was found... removing this one..");
              selectedContentVersionsIterator.remove();
              addLanguageVersion = true;
            }           
          }
        }
 
        if(addLanguageVersion || noLanguageVersionFound)
          selectedContentVersions.add(contentVersion);
     
     
      contentVersions = selectedContentVersions;
    }
   
    if(logger.isInfoEnabled())
    {
      logger.info("new contentVersions:" + contentVersions.size());
      Iterator contentVersionsIteratorDebug = contentVersions.iterator();
      while(contentVersionsIteratorDebug.hasNext())
      {
        ContentVersion contentVersion = (ContentVersion)contentVersionsIteratorDebug.next();
        logger.info("debug contentVersion:" + contentVersion.getId());
      }
    }
   
    Collections.sort((List)contentVersions, new ReflectionComparator("id"));

    if(logger.isInfoEnabled())
    {
      logger.info("new contentVersions:" + contentVersions.size());
      Iterator contentVersionsIteratorDebug = contentVersions.iterator();
      while(contentVersionsIteratorDebug.hasNext())
      {
        ContentVersion contentVersion = (ContentVersion)contentVersionsIteratorDebug.next();
        logger.info("debug contentVersion:" + contentVersion.getId());
      }
    }

    //Collection contentVersions = content.getContentVersions();
    Iterator contentVersionsIterator = contentVersions.iterator();
    while(contentVersionsIterator.hasNext())
    {
      ContentVersion contentVersion = (ContentVersion)contentVersionsIterator.next();
      Language language = null;
      if(contentVersion.getLanguage() != null)
        language = LanguageController.getController().getLanguageWithCode(contentVersion.getLanguage().getLanguageCode(), db);
      else
        language = LanguageController.getController().getLanguageWithId(contentVersion.getLanguageId(), db);
       
      logger.info("Creating contentVersion for language:" + language.getLanguageCode() + " on content " + content.getName());

      contentVersion.setOwningContent((ContentImpl)content);
      contentVersion.setLanguage((LanguageImpl)language);
     
      Collection digitalAssets = contentVersion.getDigitalAssets();
      if(digitalAssets != null)
      {
        List initialDigitalAssets = new ArrayList();
         
        Iterator digitalAssetsIterator = digitalAssets.iterator();
        while(digitalAssetsIterator.hasNext())
        {
          DigitalAsset digitalAsset = (DigitalAsset)digitalAssetsIterator.next();
         
          List initialContentVersions = new ArrayList();
          initialContentVersions.add(contentVersion);
          digitalAsset.setContentVersions(initialContentVersions);
 
          db.create(digitalAsset);
         
          initialDigitalAssets.add(digitalAsset);
        }
       
        contentVersion.setDigitalAssets(initialDigitalAssets);
      }

      Collection contentCategories = contentVersion.getContentCategories();
      logger.info("contentCategories:" + contentCategories.size());
     
      db.create(contentVersion);
     
      if(contentCategories != null)
      {
        List initialContentCategories = new ArrayList();
         
        Iterator contentCategoriesIterator = contentCategories.iterator();
        while(contentCategoriesIterator.hasNext())
        {
          ContentCategory contentCategory = (ContentCategory)contentCategoriesIterator.next();
          logger.info("contentCategory:" + contentCategory);
          contentCategory.setContentVersion((ContentVersionImpl)contentVersion);
         
          Integer oldCategoryId = contentCategory.getCategoryId();
          logger.info("oldCategoryId:" + oldCategoryId);
          Integer newCategoryId = (Integer)categoryIdMap.get(oldCategoryId);
          logger.info("newCategoryId:" + newCategoryId);
          if(newCategoryId == null)
            newCategoryId = oldCategoryId;
         
          if(newCategoryId != null)
          {
            Category category = CategoryController.getController().findById(newCategoryId, db);
            logger.info("Got category:" + category);
            if(category != null)
            {
              contentCategory.setCategory((CategoryImpl)category);
              logger.info("Creating content category:" + contentCategory);
             
              db.create(contentCategory);
           
              initialContentCategories.add(contentCategory);
            }
          }
        }
       
        contentVersion.setContentCategories(initialContentCategories);
      }

    }   
   
    Collection childContents = content.getChildren();
View Full Code Here

Examples of org.infoglue.cms.entities.content.ContentVersion

      logger.info("org contentVersions:" + contentVersions.size());
      List selectedContentVersions = new ArrayList();
      Iterator realContentVersionsIterator = contentVersions.iterator();
      while(realContentVersionsIterator.hasNext())
      {
        ContentVersion contentVersion = (ContentVersion)realContentVersionsIterator.next();     
        Iterator selectedContentVersionsIterator = selectedContentVersions.iterator();
        boolean addLanguageVersion = true;
        boolean noLanguageVersionFound = true;
        while(selectedContentVersionsIterator.hasNext())
        {
          ContentVersion currentContentVersion = (ContentVersion)selectedContentVersionsIterator.next();
          logger.info("" + currentContentVersion.getLanguage().getLanguageCode() + "=" + contentVersion.getLanguage().getLanguageCode());
          if(currentContentVersion.getLanguage().getLanguageCode().equals(contentVersion.getLanguage().getLanguageCode()))
          {
            noLanguageVersionFound = false;
           
            logger.info("" + contentVersion.getIsActive() + "=" + contentVersion.getLanguage().getLanguageCode());
            if(contentVersion.getIsActive().booleanValue() && contentVersion.getContentVersionId().intValue() > currentContentVersion.getContentVersionId().intValue())
            {
              logger.info("A later version was found... removing this one..");
              selectedContentVersionsIterator.remove();
              addLanguageVersion = true;
            }           
          }
        }
 
        if(addLanguageVersion || noLanguageVersionFound)
          selectedContentVersions.add(contentVersion);
     
     
      contentVersions = selectedContentVersions;
    }

       
    if(logger.isInfoEnabled())
    {
      logger.info("new contentVersions:" + contentVersions.size());
      Iterator contentVersionsIteratorDebug = contentVersions.iterator();
      while(contentVersionsIteratorDebug.hasNext())
      {
        ContentVersion contentVersion = (ContentVersion)contentVersionsIteratorDebug.next();
        logger.info("debug contentVersion:" + contentVersion.getId());
      }
    }
   
    List<ContentVersion> sortedVersions = new ArrayList<ContentVersion>();
    sortedVersions.addAll(contentVersions);
   
    Collections.sort(sortedVersions, new ReflectionComparator("id"));

    if(true)
    {
      logger.info("sortedVersions:" + sortedVersions.size());
      Iterator contentVersionsIteratorDebug = sortedVersions.iterator();
      while(contentVersionsIteratorDebug.hasNext())
      {
        ContentVersion contentVersion = (ContentVersion)contentVersionsIteratorDebug.next();
        logger.info("debug sortedVersion 2:" + contentVersion.getId() + ":" + contentVersion.getOwningContent());
      }
    }
   
    contentVersions.clear();
    contentVersions.addAll(sortedVersions);

    if(logger.isInfoEnabled())
    {
      logger.info("new contentVersions:" + contentVersions.size());
      Iterator contentVersionsIteratorDebug = contentVersions.iterator();
      while(contentVersionsIteratorDebug.hasNext())
      {
        ContentVersion contentVersion = (ContentVersion)contentVersionsIteratorDebug.next();
        logger.info("debug contentVersion:" + contentVersion.getId());
      }
    }

        Iterator contentVersionIterator = contentVersions.iterator();
        while(contentVersionIterator.hasNext())
        {
            ContentVersion contentVersion = (ContentVersion)contentVersionIterator.next();
      logger.info("contentVersion:" + contentVersion.getId() + ":" + contentVersion.getContentVersionId());

      String contentVersionValue = contentVersion.getVersionValue();

            contentVersionValue = contentVersionValue.replaceAll("contentId=\"", "contentId=\"oldContentId_");
            contentVersionValue = contentVersionValue.replaceAll("\\?contentId=", "\\?contentId=oldContentId_");
            contentVersionValue = contentVersionValue.replaceAll("getInlineAssetUrl\\(", "getInlineAssetUrl\\(oldContentId_");
            contentVersionValue = contentVersionValue.replaceAll("languageId,", "languageId,oldContentId_");
            contentVersionValue = contentVersionValue.replaceAll("entity=\"Content\" entityId=\"", "entity=\"Content\" entityId=\"oldContentId_");
            //contentVersionValue = contentVersionValue.replaceAll("entity='Content'><id>", "entity='Content'><id>oldContentId_");
            contentVersionValue = contentVersionValue.replaceAll("siteNodeId=\"", "siteNodeId=\"oldSiteNodeId_");
            contentVersionValue = contentVersionValue.replaceAll("detailSiteNodeId=\"", "detailSiteNodeId=\"oldSiteNodeId_");
            contentVersionValue = contentVersionValue.replaceAll("getPageUrl\\((\\d)", "getPageUrl\\(oldSiteNodeId_$1");
            contentVersionValue = contentVersionValue.replaceAll("entity=\"SiteNode\" entityId=\"", "entity=\"SiteNode\" entityId=\"oldSiteNodeId_");
            //contentVersionValue = contentVersionValue.replaceAll("entity='SiteNode'><id>", "entity='SiteNode'><id>old_");

            contentVersionValue = this.prepareAllRelations(contentVersionValue);
                         
           
            //logger.info("contentVersionValue before:" + contentVersionValue);
           
            Iterator contentIdMapIterator = contentIdMap.keySet().iterator();
            while (contentIdMapIterator.hasNext())
            {
                String oldContentId = (String)contentIdMapIterator.next();
                String newContentId = (String)contentIdMap.get(oldContentId);
               
                //logger.info("Replacing all:" + oldContentId + " with " + newContentId);
               
                contentVersionValue = contentVersionValue.replaceAll("contentId=\"oldContentId_" + oldContentId + "\"", "contentId=\"" + newContentId + "\"");
                contentVersionValue = contentVersionValue.replaceAll("\\?contentId=oldContentId_" + oldContentId + "&", "\\?contentId=" + newContentId + "&");
                contentVersionValue = contentVersionValue.replaceAll("getInlineAssetUrl\\(oldContentId_" + oldContentId + ",", "getInlineAssetUrl\\(" + newContentId + ",");
                contentVersionValue = contentVersionValue.replaceAll("languageId,oldContentId_" + oldContentId + "\\)", "languageId," + newContentId + "\\)");
                contentVersionValue = contentVersionValue.replaceAll("entity=\"Content\" entityId=\"oldContentId_" + oldContentId + "\"", "entity=\"Content\" entityId=\"" + newContentId + "\"");
                contentVersionValue = contentVersionValue.replaceAll("<id>oldContentId_" + oldContentId + "</id>", "<id>" + newContentId + "</id>");
                //contentVersionValue = contentVersionValue.replaceAll("entity='Content'><id>old_" + oldContentId + "</id>", "entity='Content'><id>" + newContentId + "</id>");
                //contentVersionValue = contentVersionValue.replaceAll("<id>" + oldContentId + "</id>", "<id>" + newContentId + "</id>");
            }
           
            Iterator siteNodeIdMapIterator = siteNodeIdMap.keySet().iterator();
            while (siteNodeIdMapIterator.hasNext())
            {
                String oldSiteNodeId = (String)siteNodeIdMapIterator.next();
                String newSiteNodeId = (String)siteNodeIdMap.get(oldSiteNodeId);
               
                //logger.info("Replacing all:" + oldSiteNodeId + " with " + newSiteNodeId);
               
                contentVersionValue = contentVersionValue.replaceAll("siteNodeId=\"oldSiteNodeId_" + oldSiteNodeId + "\"", "siteNodeId=\"" + newSiteNodeId + "\"");
                contentVersionValue = contentVersionValue.replaceAll("detailSiteNodeId=\"oldSiteNodeId_" + oldSiteNodeId + "\"", "detailSiteNodeId=\"" + newSiteNodeId + "\"");
                contentVersionValue = contentVersionValue.replaceAll("getPageUrl\\(oldSiteNodeId_" + oldSiteNodeId + ",", "getPageUrl\\(" + newSiteNodeId + ",");
                contentVersionValue = contentVersionValue.replaceAll("entity=\"SiteNode\" entityId=\"oldSiteNodeId_" + oldSiteNodeId + "\"", "entity=\"SiteNode\" entityId=\"" + newSiteNodeId + "\"");
                //contentVersionValue = contentVersionValue.replaceAll("entity='SiteNode'><id>old_" + oldSiteNodeId + "</id>", "entity='SiteNode'><id>" + newSiteNodeId + "</id>");
                contentVersionValue = contentVersionValue.replaceAll("<id>oldSiteNodeId_" + oldSiteNodeId + "</id>", "<id>" + newSiteNodeId + "</id>");
            }
           
            //logger.info("contentVersionValue after:" + contentVersionValue);
           
            //Now replace all occurrances of old as they should never be there.
            contentVersionValue = contentVersionValue.replaceAll("oldContentId_", "");
            contentVersionValue = contentVersionValue.replaceAll("oldSiteNodeId_", "");

            logger.info("new contentVersionValue:" + contentVersionValue);
            contentVersion.setVersionValue(contentVersionValue);
        }
  }
View Full Code Here

Examples of org.infoglue.cms.entities.content.ContentVersion

          if(event.getTypeId().intValue() == EventVO.PUBLISH.intValue())
          {
            event.setTypeId(EventVO.PUBLISH_DENIED);
            if(event.getEntityClass().equals(ContentVersion.class.getName()))
            {
              ContentVersion contentVersion = ContentVersionController.getContentVersionController().getContentVersionWithId(event.getEntityId(), db);
              if(contentVersion.getStateId().intValue() == ContentVersionVO.PUBLISHED_STATE.intValue())
              {
                //If its a published version we just deletes the event - we don't want to delete the version.
                EventController.delete(event, db);
              }
              else
              {
                Content content = contentVersion.getOwningContent();
                Language language = contentVersion.getLanguage();
                //event.setEntityId(ContentVersionController.getPreviousContentVersionVO(content.getId(), language.getId(), contentVersion.getId()).getId());
                event.setEntityId(ContentVersionController.getContentVersionController().getPreviousActiveContentVersionVO(content.getId(), language.getId(), contentVersion.getId(), db).getId());
                ContentVersionController.getContentVersionController().delete(contentVersion, db);
              }
            }
            else if(event.getEntityClass().equals(SiteNodeVersion.class.getName()))
            {
View Full Code Here

Examples of org.infoglue.cms.entities.content.ContentVersion

        if(event.getTypeId().intValue() == EventVO.PUBLISH.intValue())
        {
          event.setTypeId(EventVO.PUBLISH_DENIED);
          if(event.getEntityClass().equals(ContentVersion.class.getName()))
          {
            ContentVersion contentVersion = ContentVersionController.getContentVersionController().getContentVersionWithId(event.getEntityId(), db);
            if(contentVersion.getStateId().intValue() == ContentVersionVO.PUBLISHED_STATE.intValue())
            {
              //If its a published version we just deletes the event - we don't want to delete the version.
              EventController.delete(event, db);
            }
            else
            {
              Content content = contentVersion.getOwningContent();
              Language language = contentVersion.getLanguage();
              //event.setEntityId(ContentVersionController.getPreviousContentVersionVO(content.getId(), language.getId(), contentVersion.getId()).getId());
              ContentVersionVO contentVersionVO = ContentVersionController.getContentVersionController().getPreviousActiveContentVersionVO(content.getId(), language.getId(), contentVersion.getId(), db);
              if(contentVersionVO != null && event != null)
                event.setEntityId(contentVersionVO.getId());
             
              ContentVersionController.getContentVersionController().delete(contentVersion, db);
            }
View Full Code Here

Examples of org.infoglue.cms.entities.content.ContentVersion

    logger.info("typeId:" + typeId);
   
    // Publish contentversions
        if(entityClass.equals(ContentVersion.class.getName()))
    {
      ContentVersion contentVersion = null;
      ContentVersion oldContentVersion = null;
      if(!isDeleteOperation)
        oldContentVersion = ContentVersionController.getContentVersionController().getMediumContentVersionWithId(entityId, db);
      else
        oldContentVersion = ContentVersionController.getContentVersionController().getReadOnlyMediumContentVersionWithId(entityId, db);
     
      if(oldContentVersion != null && typeId.intValue() == EventVO.UNPUBLISH_LATEST.intValue())
      {
          oldContentVersion.setIsActive(new Boolean(false));
          contentVersion = oldContentVersion;
          /*
        contentVersion = ContentVersionController.getContentVersionController().getLatestPublishedContentVersion(oldContentVersion.getOwningContent().getContentId(), oldContentVersion.getLanguage().getLanguageId(), db);
        if(contentVersion != null)
        {
          //We just set the published version to not active.
          contentVersion.setIsActive(new Boolean(false));
        }
        */
      }
      /*
      else if(oldContentVersion != null && oldContentVersion.getOwningContent() != null && typeId.intValue() == EventVO.UNPUBLISH_ALL.intValue())
      {
        //We just set the published version to not active.
          oldContentVersion.setIsActive(new Boolean(false));
      }
      */
      else if(oldContentVersion != null && oldContentVersion.getValueObject().getContentId() != null)
      {
          List events = new ArrayList();
        Integer contentId = oldContentVersion.getValueObject().getContentId();
          ContentVersion newContentVersion = ContentStateController.changeState(entityId, contentVO, ContentVersionVO.PUBLISHED_STATE, "Published", overrideVersionModifyer, null, infoGluePrincipal, contentId, db, events);
          contentVersion = null;
          if(!isDeleteOperation)
            contentVersion = ContentVersionController.getContentVersionController().getMediumContentVersionWithId(newContentVersion.getContentVersionId(), db);
          else
            contentVersion = ContentVersionController.getContentVersionController().getReadOnlyMediumContentVersionWithId(newContentVersion.getContentVersionId(), db);
      }

      if(contentVersion != null)
      {
        //The contentVersion in here is the version we have done something with...
View Full Code Here

Examples of org.infoglue.cms.entities.content.ContentVersion

    try
    {
      if(publicationDetail.getEntityClass().equals(ContentVersion.class.getName()))
      {
        ContentVersion contentVersion = ContentVersionController.getContentVersionController().getContentVersionWithId(publicationDetail.getEntityId(), db);
        contentVersion.setIsActive(new Boolean(false));
        repositoryId = contentVersion.getOwningContent().getRepository().getId();
      }
      else if(publicationDetail.getEntityClass().equals(SiteNodeVersion.class.getName()))
      {
          SiteNodeVersion siteNodeVersion = SiteNodeVersionController.getController().getSiteNodeVersionWithId(publicationDetail.getEntityId(), db);
          siteNodeVersion.setIsActive(new Boolean(false));
View Full Code Here

Examples of org.infoglue.cms.entities.content.ContentVersion

    {
        boolean createEvent = false;
       
      if(publicationDetail.getEntityClass().equals(ContentVersion.class.getName()))
      {
        ContentVersion contentVersion = ContentVersionController.getContentVersionController().getContentVersionWithId(publicationDetail.getEntityId(), db);
        if(contentVersion.getOwningContent() != null)
        {
          contentVersion.setIsActive(new Boolean(true));
          repositoryId = contentVersion.getOwningContent().getRepository().getId();
             createEvent = true;
        }
         else
         {
             logger.warn("The contentVersion:" + contentVersion.getId() + " had no content - this should never happen, investigate why. Removing invalid content version.");
          ContentVersionController.getContentVersionController().delete(contentVersion, db);
         }
      }
      else if(publicationDetail.getEntityClass().equals(SiteNodeVersion.class.getName()))
      {
View Full Code Here

Examples of org.infoglue.cms.entities.content.ContentVersion

  public static ContentVO getOwningContentVO(Integer id) throws SystemException
    {
      ContentVO contentVO = null;

      Database db = CastorDatabaseService.getDatabase();
    ContentVersion contentVersion = null;
        beginTransaction(db);
        try
        {
        contentVersion = ContentVersionController.getContentVersionController().getContentVersionWithId(id, db);
        contentVO = contentVersion.getOwningContent().getValueObject();
        //Content content = ContentController.getContentController().getContentWithId(contentVersion.getValueObject().getContentId(), db);
        //contentVO = content.getValueObject();

        commitTransaction(db);
        }
View Full Code Here

Examples of org.infoglue.cms.entities.content.ContentVersion

        beginTransaction(db);

        try
        {
          ContentVersion contentVersion = getAndRepairLatestContentVersion(db, contentId, languageId);
          if(contentVersion != null)
            contentVersionVO = contentVersion.getValueObject();
             
            commitTransaction(db);
        }
        catch(Exception e)
        {
View Full Code Here

Examples of org.infoglue.cms.entities.content.ContentVersion

    return contentVersionVO;
    }

  public ContentVersion getAndRepairLatestContentVersion(Database db, Integer contentId, Integer languageId) throws SystemException, Bug, Exception
    {
      ContentVersion contentVersion = ContentVersionController.getContentVersionController().getLatestContentVersion(contentId, languageId, db);
      if(contentVersion != null)
      {
        contentVersion.setIsActive(true);
        contentVersion.setStateId(ContentVersionVO.WORKING_STATE);
        }
       
    return contentVersion;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.