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();
              contentVersionVO = contentVersion.getValueObject();

          CacheController.cacheObjectInAdvancedCache("contentVersionCache", versionKey, contentVersionVO, new String[]{CacheController.getPooledString(2, contentVersionVO.getId()), CacheController.getPooledString(1, contentVersionVO.getContentId())}, true);
            }
        else
        {
View Full Code Here


      oql.bind(operatingMode);
      oql.bind(true);

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

          if(contentVersion != null)
            deliveryContext.addUsedContentVersion(CacheController.getPooledString(2, contentVersion.getId()));

        contentVersionVOList.add(contentVersion.getValueObject());
        }

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

      oql.bind(operatingMode);
      oql.bind(true);

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

          if(contentVersion != null)
            deliveryContext.addUsedContentVersion(CacheController.getPooledString(2, contentVersion.getId()));

        contentVersionVOList.add(contentVersion.getValueObject());
        }

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

    List versions = findContentVersionsForCategories(results, db);

    // Weed out irrelevant versions
    for (Iterator iter = versions.iterator(); iter.hasNext();)
    {
      ContentVersion version = (ContentVersion) iter.next();
      if(!isValidContentVersion(version, infoGluePrincipal, siteNodeId, languageId, useLanguageFallback, db, deliveryContext))
        iter.remove();
    }

    return toVOList(versions);
View Full Code Here

  public List getAssignedCategoryVOsForContentVersionId(Database db, Integer contentId, Integer languageId, String categoryKey, Integer siteNodeId, boolean useLanguageFallback, DeliveryContext deliveryContext, InfoGluePrincipal infoGluePrincipal) throws Exception
  {
    List assignedCategoryVOList = new ArrayList();
   
    ContentVersion contentVersion = getContentVersion(siteNodeId, contentId, languageId, db, useLanguageFallback, deliveryContext, infoGluePrincipal);
   
    List assignedContentCategories = ContentCategoryController.getController().findByContentVersionAttribute(categoryKey, contentVersion, db);
    //List assignedContentCategories = findContentCategoriesForContentVersionId(db, contentVersionVO.getId(), categoryKey, deliveryContext);
    if((assignedCategoryVOList == null || assignedCategoryVOList.size() == 0) && useLanguageFallback)
    {
View Full Code Here

 
    public static ContentVersionVO changeState(Integer oldContentVersionId, Integer stateId, String versionComment, boolean overrideVersionModifyer, InfoGluePrincipal infoGluePrincipal, Integer contentId, Database db, List resultingEvents) throws ConstraintException, SystemException
    {
      ContentVO contentVO = ContentController.getContentController().getContentVOWithId(contentId, db);
   
      ContentVersion newContentVersion = changeState(oldContentVersionId, contentVO, stateId, versionComment, overrideVersionModifyer, null, infoGluePrincipal, contentId, db, resultingEvents);
     
      return newContentVersion.getValueObject();
    }  
View Full Code Here

      if(contentId == null)
      {
        SmallestContentVersionVO contentVersionVO = ContentVersionController.getContentVersionController().getSmallestContentVersionVOWithId(oldContentVersionId, db);
        contentId = contentVersionVO.getContentId();
      }
      ContentVersion newContentVersion = changeState(oldContentVersionId, contentVO, stateId, versionComment, overrideVersionModifyer, recipientFilter, infoGluePrincipal, contentId, db, resultingEvents);
      if(newContentVersion != null)
        newContentVersionVO = newContentVersion.getValueObject();
     
      commitRegistryAwareTransaction(db);
        }
        catch(ConstraintException ce)
        {
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;
    }
   
    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

      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

          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

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.