Package org.infoglue.cms.entities.content

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


                       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

    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

        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

              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

        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

  {
    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

        final List<ContentVersionVO> contentVersionsList2Retain =
            contentVersionController.getLatestActiveContentVersionsForHitSize(contentId, languageId, hitSize, db);
        // If none of them is published, fetch the latest published to this list also
        if (!hasState(contentVersionsList2Retain, ContentVersionVO.PUBLISHED_STATE))
        {
            final ContentVersion latestPublished =
                contentVersionController.getLatestPublishedContentVersion(contentId, languageId, db);
            if (latestPublished != null)
            {
                contentVersionsList2Retain.add(latestPublished.getValueObject());
            }
        }
        commitTransaction(db);
        return contentVersionsList2Retain;
    }
View Full Code Here

  private ContentVersion getContentVersion(Integer siteNodeId, Integer contentId, Integer languageId, Database db, boolean useLanguageFallback, DeliveryContext deliveryContext, InfoGluePrincipal infoGluePrincipal) throws SystemException, Exception
  {
    if(contentId == null || contentId.intValue() < 1)
      return null;
   
    ContentVersion contentVersion = null;
   
    //MediumContentImpl content = (MediumContentImpl)getObjectWithId(MediumContentImpl.class, contentId, db);
    ContentVO content = ContentController.getContentController().getSmallContentVOWithId(contentId, db, deliveryContext);
   
    boolean isValidContent = isValidContent(infoGluePrincipal, content, languageId, useLanguageFallback, false, db, deliveryContext);
View Full Code Here

   * This method gets a contentVersion with a state and a language which is active.
   */

  private ContentVersion getContentVersion(ContentVO content, Integer languageId, Integer operatingMode, DeliveryContext deliveryContext, Database db) throws Exception
    {
      ContentVersion contentVersion = null;
   
      String versionKey = "" + content.getId() + "_" + languageId + "_" + operatingMode + "_contentVersionId";
      //logger.info("versionKey:" + versionKey);
   
    Object object = CacheController.getCachedObjectFromAdvancedCache("contentVersionIdCache", versionKey);
    if(object instanceof NullObject)
    {
      logger.info("There was an cached parentSiteNodeVO but it was null:" + object);
    }
    else if(object != null)
    {
      Integer contentVersionId = (Integer)object;
      contentVersion = (ContentVersion)getObjectWithId(ContentVersionImpl.class, contentVersionId, db);
        //logger.info("Loaded the version from cache instead of querying it:" + contentVersionId);
    }
    else
    {
      //logger.info("Querying for verson: " + versionKey);
     
        OQLQuery oql = db.getOQLQuery( "SELECT cv FROM org.infoglue.cms.entities.content.impl.simple.ContentVersionImpl cv WHERE cv.contentId = $1 AND cv.language.languageId = $2 AND cv.stateId >= $3 AND cv.isActive = $4 ORDER BY cv.contentVersionId desc");
        oql.bind(content.getId());
        oql.bind(languageId);
        oql.bind(operatingMode);
        oql.bind(true);
 
        QueryResults results = oql.execute(Database.READONLY);

      if (results.hasMore())
          {
            contentVersion = (ContentVersion)results.next();
        CacheController.cacheObjectInAdvancedCache("contentVersionIdCache", versionKey, contentVersion.getId(), new String[]{CacheController.getPooledString(2, contentVersion.getId()), CacheController.getPooledString(1, contentVersion.getValueObject().getContentId())}, true);
          }
      else
      {
        CacheController.cacheObjectInAdvancedCache("contentVersionIdCache", versionKey, new NullObject(), new String[]{CacheController.getPooledString(1, content.getId())}, true);
      }

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

    return contentVersion;
    }
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.