Examples of ContentVersion


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

      {
        List<ContentVersion> assetRelatedContentVersions = new ArrayList<ContentVersion>();
        List<Integer> versionIdsUsingAsset = assetVersionsMap.get(asset.getId());
        for(Integer cvId : versionIdsUsingAsset)
        {
          ContentVersion cv = ContentVersionController.getContentVersionController().getContentVersionWithId(cvId, dbStructure);
          assetRelatedContentVersions.add(cv);
        }
 
        File assetFile = new File(archiveFolder.getPath() + File.separator + asset.getId() + ".file");
        //logger.info("assetFile:" + assetFile.exists());
View Full Code Here

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

        }
       
        Language language = LanguageController.getController().getLanguageWithCode(oldLanguage.getLanguageCode(), db);
        logger.info("Creating contentVersion for language:" + oldLanguage + " on content " + content.getName());
 
        ContentVersion cv = new ContentVersionImpl();
        cv.setValueObject(contentVersion.getValueObject());
       
        cv.setOwningContent((ContentImpl)content);
        cv.setLanguage((LanguageImpl)language);
       
        db.create(cv);

        List<SmallDigitalAssetImpl> smallDigitalAssets = (List)contentVersion.getSmallDigitalAssets();
        //logger.info("AAAAAAAAAAAAA: on " + content.getName() + "/" + contentVersion.getId() + " was " + (smallDigitalAssets == null ? "null" : smallDigitalAssets.size()) + " assets");
        if(smallDigitalAssets != null)
        {
          List initialDigitalAssets = new ArrayList();
           
          for(SmallDigitalAssetImpl asset : smallDigitalAssets)
          {
            if(!handledSmallAssets.containsKey(asset.getId()))
            {
              allSmallAssets.add(asset);
              handledSmallAssets.put(asset.getId(), true);
            }

            List<Integer> versionIdsUsingAsset = assetVersionsMap.get(asset.getId());
            if(versionIdsUsingAsset == null)
            {
              versionIdsUsingAsset = new ArrayList<Integer>();
              assetVersionsMap.put(asset.getId(), versionIdsUsingAsset);
            }
            versionIdsUsingAsset.add(cv.getId());
          }
        }
 
        Collection contentCategories = contentVersion.getContentCategories();
        logger.info("contentCategories:" + contentCategories.size());
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;
    }

       
        Iterator contentVersionIterator = contentVersions.iterator();
        while(contentVersionIterator.hasNext())
        {
            ContentVersion contentVersion = (ContentVersion)contentVersionIterator.next();
            try
            {
              String contentVersionValue = contentVersion.getVersionValue();
             
              contentVersionValue = substituteStrings(contentVersionValue, replaceMap);
             
              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_");
             
              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 = 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);
              contentVersion.getValueObject().setVersionValue(contentVersionValue);
            }
            catch(Exception e)
            {
              logger.error("Problem substituting content ids: " + e.getMessage(), e);
            }
View Full Code Here

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

   
        Collection contentVersions = content.getContentVersions();
      Iterator versionIterator = contentVersions.iterator();
    while (versionIterator.hasNext())
        {
          ContentVersion contentVersion = (ContentVersion)versionIterator.next();
          if(contentVersion.getStateId().intValue() == ContentVersionVO.PUBLISHED_STATE.intValue() && contentVersion.getIsActive().booleanValue() == true)
          {
            logger.info("The content had a published version so we cannot delete it..");
        isDeletable = false;
            break;
          }
View Full Code Here

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

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

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

    logger.warn("Query for component content versions took:" + t.getElapsedTime());

      QueryResults results = oql.execute(Database.READONLY);
    while (results.hasMore())
        {
      ContentVersion contentVersion = (ContentVersion)results.next();
      contentVersionVOList.add(contentVersion.getValueObject());
      }

    logger.warn("Read of component content versions took:" + t.getElapsedTime());

    results.close();
View Full Code Here

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

        siteNodesIdsMapping.put(oldSiteNodeVO.getId(), newSiteNode.getId());

    String versionValue = oldCVVO.getVersionValue();
    if(newContentVersions.size() > 0)
    {
      ContentVersion newCV = newContentVersions.get(0);
      versionValue = versionValue.replaceFirst(Pattern.quote("<NavigationTitle><![CDATA[") + "(.+?)" + Pattern.quote("]]></NavigationTitle>"), Matcher.quoteReplacement("<NavigationTitle><![CDATA[") + "$1" + newNameSuffix + Matcher.quoteReplacement("]]></NavigationTitle>"));
      newCV.getValueObject().setVersionValue(versionValue);
    }

        for(SiteNodeVO childNode : (Collection<SiteNodeVO>)getChildSiteNodeVOList(siteNode.getId(), false, db, null))
        {
          copySiteNodeRecursive(childNode, newSiteNode, principal, siteNodesIdsMapping, contentIdsMapping, contentIdsToCopy, newCreatedContentVersions, newNameSuffix, db, processBean);
View Full Code Here

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

              newContentVersionVO.setStateId(0);
              newContentVersionVO.setVersionModifier(contentVersionVO.getVersionModifier());
              newContentVersionVO.setModifiedDateTime(contentVersionVO.getModifiedDateTime());
              newContentVersionVO.setVersionValue(contentVersionVO.getVersionValue());

              ContentVersion contentVersion = ContentVersionController.getContentVersionController().createMedium(copiedContent.getId(), contentVersionVO.getLanguageId(), contentVersionVO, db);
             
              //contentVersion.getOwningContent().setContentTypeDefinition((ContentTypeDefinitionImpl)ctd);
             
                    logger.info("contentVO.getId():" + contentVO.getId() + "");
View Full Code Here

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

        logger.info("contentVersionVO:" + contentVersionVO);
        logger.info("categories:" + categories);
        }
       
      final Content content = ContentControllerProxy.getContentController().create(db, parentContent.getId(), contentTypeDefinitionVO.getId(), parentContent.getRepositoryId(), contentVO);
      final ContentVersion newContentVersion = ContentVersionController.getContentVersionController().create(content.getId(), language.getId(), contentVersionVO, null, db);
      createCategories(newContentVersion, categories);
     
      if(logger.isDebugEnabled())
        logger.info("Returning:" + content + ":" + content.getValueObject());
     
View Full Code Here

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

  {
    try
    {
      final Content content = ContentControllerProxy.getContentController().getContentWithId(contentVO.getId(), db);
      content.setValueObject(contentVO);
      final ContentVersion contentVersion = ContentVersionController.getContentVersionController().getLatestActiveContentVersion(content.getId(), language.getId(), db);
      if(contentVersion != null)
      {
        contentVersion.getValueObject().setVersionValue(contentVersionVO.getVersionValue());
        deleteCategories(contentVersion);
        createCategories(contentVersion, categories);
      }
      else
      {
        final ContentVersion newContentVersion = ContentVersionController.getContentVersionController().create(content.getId(), language.getId(), contentVersionVO, null, db);
        createCategories(newContentVersion, categories);
      }
     
      return content.getValueObject();
      }
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.