Package org.infoglue.cms.entities.content

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


         
          QueryResults results = oql.execute(Database.READONLY);
     
      if (results.hasMore())
            {
              ContentVersion contentVersion = (ContentVersion)results.next();
              logger.info("found one:" + contentVersion.getValueObject());
              contentVersionVO = contentVersion.getValueObject();
            }
           
      results.close();
      oql.close();
View Full Code Here


     
      QueryResults results = oql.execute(Database.READONLY);
   
    if (results.hasMore())
        {
          ContentVersion contentVersion = (ContentVersion)results.next();
          logger.info("found one:" + contentVersion.getValueObject());
          contentVersionVO = contentVersion.getValueObject();
        }
     
    results.close();
    oql.close();
View Full Code Here

    {
      results.next();
      logger.debug("found first latest content version");
      if (results.hasMore())
      {
        ContentVersion contentVersion = (ContentVersion)results.next();
        if (logger.isInfoEnabled())
        {
          logger.info("found second latest content version:" + contentVersion.getValueObject());
        }
        contentVersionVO = contentVersion.getValueObject();
      }
    }

    results.close();
    oql.close();
View Full Code Here

      Database db = CastorDatabaseService.getDatabase();
        beginTransaction(db);

        try
        {     
          ContentVersion contentVersion = null;
          ContentVersionVO contentVersionVO = ContentVersionController.getContentVersionController().getContentVersionVOWithId(contentVersionId, db);
          DigitalAssetVO digitalAssetVO = DigitalAssetController.getController().getDigitalAssetVOWithId(digitalAssetId, db);
          if(!contentVersionVO.getStateId().equals(ContentVersionVO.WORKING_STATE))
      {
          List events = new ArrayList();
          ContentVO contentVO = ContentController.getContentController().getContentVOWithId(contentVersionVO.getContentId(), db);
          contentVersion = ContentStateController.changeState(contentVersionVO.getId(), contentVO, ContentVersionVO.WORKING_STATE, "new working version", false, null, principal, contentVersionVO.getContentId(), db, events, digitalAssetId);
        //digitalAssetVO = DigitalAssetController.getController().getLatestDigitalAssetVO(contentVersion.getId(), digitalAssetVO.getAssetKey(), db);
      }
      else
      {
        contentVersion = ContentVersionController.getContentVersionController().getContentVersionWithId(contentVersionVO.getId(), db);

        DigitalAsset digitalAsset = DigitalAssetController.getDigitalAssetWithId(digitalAssetVO.getId(), db);     
          contentVersion.getDigitalAssets().remove(digitalAsset);
          digitalAsset.getContentVersions().remove(contentVersion);
         
              logger.info("digitalAsset size after:" + digitalAsset.getContentVersions().size());
              if(digitalAsset.getContentVersions().size() == 0)
                db.remove(digitalAsset);
      }
         
          editedContentVersionVO = contentVersion.getValueObject();
         
          /*
        DigitalAsset digitalAsset = DigitalAssetController.getDigitalAssetWithId(digitalAssetVO.getId(), db);     
        contentVersion.getDigitalAssets().remove(digitalAsset);
        digitalAsset.getContentVersions().remove(contentVersion);
View Full Code Here

  /**
   * This method deletes the relation to a digital asset - not the asset itself.
   */
  public void deleteDigitalAssetRelation(Integer contentVersionId, DigitalAsset digitalAsset, Database db) throws SystemException, Bug
    {
      ContentVersion contentVersion = getContentVersionWithId(contentVersionId, db);
    contentVersion.getDigitalAssets().remove(digitalAsset);
        digitalAsset.getContentVersions().remove(contentVersion);
    }
View Full Code Here

              if(digitalAsset.getAssetKey().equals("portletentityregistry.xml"))
                keep = false;
             
              Collection contentVersions = digitalAsset.getContentVersions();
              Iterator contentVersionsIterator = contentVersions.iterator();
              ContentVersion contentVersion = null;
              while(contentVersionsIterator.hasNext())
              {
                contentVersion = (ContentVersion)contentVersionsIterator.next();
                if(!isOldVersion(contentVersion, numberOfVersionsToKeep))
                  keep = false;
              }
             
              if(contentVersion != null && keep)
              {
                if(contentVersion.getOwningContent() != null)
                {
                  String contentPath = ContentController.getContentController().getContentPath(contentVersion.getOwningContent().getId(), true, true);
                  optimizationBeanList.addDigitalAsset(digitalAsset);
                  optimizationBeanList.addEventVersions(toVOList(contentVersions));
                  optimizationBeanList.setContentPath(digitalAsset.getId(), contentPath);
                  i++;
                }
                else
                {
                  logger.error("ContentVersion with id:" + contentVersion.getId() + " had no ownningcontent");
                }
              }
            }
           
      results.close();
View Full Code Here

      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;
    }
   
    logger.info("new contentVersions:" + contentVersions.size());
    //Collection contentVersions = content.getContentVersions();
    Iterator contentVersionsIterator = contentVersions.iterator();
    while(contentVersionsIterator.hasNext())
    {
      ContentVersion contentVersion = (ContentVersion)contentVersionsIterator.next();
      Language language = LanguageController.getController().getLanguageWithCode(contentVersion.getLanguage().getLanguageCode(), db);
      logger.info("Creating contentVersion for language:" + contentVersion.getLanguage().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);
         
          if(digitalAsset.getAssetFileSize() == -1)
          {
            logger.info("digitalAsset:" + digitalAsset.getId() + "-" + digitalAsset.getAssetKey() + " was archived - let's fake it..");
            digitalAsset.setAssetBytes("archived".getBytes());           
          }
         
          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);
          if(!isCopyAction)
          {
            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);
              }
            }
          }
          else
          {
            Category category = CategoryController.getController().findById(oldCategoryId, 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

      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;
    }

       
        Iterator contentVersionIterator = contentVersions.iterator();
        while(contentVersionIterator.hasNext())
        {
            ContentVersion contentVersion = (ContentVersion)contentVersionIterator.next();
            String contentVersionValue = contentVersion.getVersionValue();

            Iterator<String> replaceMapIterator = replaceMap.keySet().iterator();
            while(replaceMapIterator.hasNext())
            {
              String key = replaceMapIterator.next();
              String value = (String)replaceMap.get(key);
              contentVersionValue = contentVersionValue.replaceAll(key, value);
            }

            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

TOP

Related Classes of org.infoglue.cms.entities.content.ContentVersion

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.