Package org.infoglue.cms.entities.content

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


      {       
      Iterator<LanguageVO> languageIterator = languages.iterator();
      while(languageIterator.hasNext())
      {
        LanguageVO language = languageIterator.next();
        ContentVersionVO contentVersionVO = ContentVersionController.getContentVersionController().getLatestActiveContentVersionVO(contentVO.getId(), language.getId(), db);

        //if(contentVersion != null && contentVersion.getStateId().intValue() == siteNodeVersion.getStateId().intValue())
        if(contentVersionVO != null && contentVersionVO.getStateId().intValue() != stateId.intValue())
        {
          logger.info("State on current:" + contentVersionVO.getStateId());
            logger.info("changing state on contentVersion:" + contentVersionVO.getId());
            ContentVersion contentVersion = ContentStateController.changeState(contentVersionVO.getId(), contentVO, stateId, versionComment, overrideVersionModifyer, null, infoGluePrincipal, contentVO.getId(), db, events);
            contentVersionVO = contentVersion.getValueObject();
        }

        if(language.getId().equals(masterLanguage.getId()) && contentVersionVO != null)
        {
View Full Code Here


   * @return  The saved ContentCategoryVO
   * @throws  SystemException If an error happens
   */
  public ContentCategoryVO save(ContentCategoryVO c, InfoGluePrincipal principal) throws SystemException
  {
    ContentVersionVO contentVersionVO = ContentVersionController.getContentVersionController().checkStateAndChangeIfNeeded(c.getContentVersionId(), principal);
    c.setContentVersionId(contentVersionVO.getId());
   
    return c.isUnsaved() ? create(c) : (ContentCategoryVO)updateEntity(ContentCategoryImpl.class, c);
  }
View Full Code Here

      }
    }

    if(this.contentVersionId == null)
    {
      ContentVersionVO newContentVersion = ContentVersionController.getContentVersionController().getLatestActiveContentVersionVO(createContentWizardInfoBean.getContentVO().getId(), languageId);
      this.contentVersionId = newContentVersion.getId();
    }

    boolean hasMandatoryAssets = false;
    boolean missingAsset = false;
    Iterator assetKeysIterator = assetKeys.iterator();
View Full Code Here

     
      if(createContentWizardInfoBean.getContentVersions().size() == 0)
      {
        String versionValue = "<?xml version='1.0' encoding='UTF-8'?><article xmlns=\"x-schema:ArticleSchema.xml\"><attributes></attributes></article>";
 
        ContentVersionVO initialContentVersionVO = new ContentVersionVO();
        initialContentVersionVO.setVersionComment("Preversion");
        initialContentVersionVO.setVersionModifier(this.getInfoGluePrincipal().getName());
        initialContentVersionVO.setVersionValue(versionValue);
       
        createContentWizardInfoBean.getContentVersions().put(languageId, initialContentVersionVO);
 
          ContentVO contentVO = ContentControllerProxy.getController().acCreate(this.getInfoGluePrincipal(), createContentWizardInfoBean);
        this.contentId = contentVO.getContentId();
        createContentWizardInfoBean.setContentVO(contentVO);
     
        ContentVersionVO newContentVersion = (ContentVersionVO)createContentWizardInfoBean.getContentVersions().get(languageId);
        this.contentVersionId = newContentVersion.getId();
      }
     
      ContentTypeDefinitionVO contentTypeDefinitionVO = ContentTypeDefinitionController.getController().getContentTypeDefinitionVOWithId(createContentWizardInfoBean.getContentTypeDefinitionId());
      List assetKeys = ContentTypeDefinitionController.getController().getDefinedAssetKeys(contentTypeDefinitionVO, true);
     
View Full Code Here

     
      if(createContentWizardInfoBean.getContentVersions().size() == 0)
      {
        String versionValue = "<?xml version='1.0' encoding='UTF-8'?><article xmlns=\"x-schema:ArticleSchema.xml\"><attributes></attributes></article>";
 
        ContentVersionVO initialContentVersionVO = new ContentVersionVO();
        initialContentVersionVO.setVersionComment("Preversion");
        initialContentVersionVO.setVersionModifier(this.getInfoGluePrincipal().getName());
        initialContentVersionVO.setVersionValue(versionValue);
       
        createContentWizardInfoBean.getContentVersions().put(languageId, initialContentVersionVO);
 
          ContentVO contentVO = ContentControllerProxy.getController().acCreate(this.getInfoGluePrincipal(), createContentWizardInfoBean);
        this.contentId = contentVO.getContentId();
        createContentWizardInfoBean.setContentVO(contentVO);
     
        ContentVersionVO newContentVersion = (ContentVersionVO)createContentWizardInfoBean.getContentVersions().get(languageId);
        this.contentVersionId = newContentVersion.getId();
      }
     
      String returnAddress = createContentWizardInfoBean.getReturnAddress();
      returnAddress = returnAddress.replaceAll("#entityId", createContentWizardInfoBean.getContentVO().getId().toString());
      returnAddress = returnAddress.replaceAll("#path", createContentWizardInfoBean.getContentVO().getName());
View Full Code Here

      List<LanguageVO> languageVOList =  LanguageController.getController().getLanguageVOList(repositoryId, db);
      SiteNodeVO siteNodeVO = SiteNodeController.getSiteNodeVOWithId(siteNodeId, db);
      for(LanguageVO languageVO : languageVOList)
      {
        ContentVersionVO currentPublishedMetainfoVersion = ContentVersionController.getContentVersionController().getLatestActiveContentVersionVO(siteNodeVO.getMetaInfoContentId(), languageVO.getLanguageId(), ContentVersionVO.PUBLISHED_STATE, db);
        if (logger.isDebugEnabled())
        {
          logger.debug("Getting NiceUri path for SiteNode: " + siteNodeId + ", in language: " + languageVO.getLanguageId() + ". SiteNode has version in current language: " + (currentPublishedMetainfoVersion != null));
        }
        if (currentPublishedMetainfoVersion != null)
View Full Code Here

      Iterator it = createContentWizardInfoBean.getContentVersions().keySet().iterator();
      while (it.hasNext())
      {
        Integer languageId = (Integer)it.next();
        logger.info("languageId:" + languageId);
        ContentVersionVO contentVersionVO = (ContentVersionVO)createContentWizardInfoBean.getContentVersions().get(languageId);
        contentVersionVO = ContentVersionController.getContentVersionController().createMedium(content.getContentId(), languageId, contentVersionVO, db).getValueObject();
      }
     
      //Bind if needed?
     
View Full Code Here

      logger.warn("You must specify the new content......");
      throw new ConstraintException("Content.mustHaveSameLanguage", "3309");
    }
   
    MediumContentVersionImpl selfNewVersion = null;
    ContentVersionVO contentVersionVO = ContentVersionController.getContentVersionController().getLatestActiveContentVersionVO(contentId, languageId, db);

    if(contentVersionVO == null)
    {
      logger.warn("There must be a version....");
      throw new ConstraintException("Content.mustHaveSameLanguage", "3309");
    }
 
    MediumContentVersionImpl contentVersion = ContentVersionController.getContentVersionController().checkStateAndChangeIfNeeded(contentVersionVO.getId(), principal, db);
    if(contentVersion.getId() > contentVersionVO.getId())
    {
      selfNewVersion = contentVersion;
    }
   
    MediumDigitalAssetImpl asset = DigitalAssetController.getController().getMediumDigitalAssetWithId(digitalAssetId, db);

    Map<Integer,Integer> replaceMap = new HashMap<Integer,Integer>();
   
    List<Integer> selfContentVersionIDList = new ArrayList<Integer>();
   
    Iterator<MediumContentVersionImpl> versionIterator = asset.getContentVersions().iterator();
    while(versionIterator.hasNext())
    {
      MediumContentVersionImpl version = versionIterator.next();
      for(SmallestContentVersionVO cvVO : versions)
      {
        if(version.getContentVersionId().equals(cvVO.getId()))
        {
          logger.info("Removing from:" + cvVO.getId());
          selfContentVersionIDList.add(version.getContentVersionId());
          versionIterator.remove();
          replaceMap.put(version.getContentId(), contentId);
          break;
        }
      }
    }
    contentVersion.getDigitalAssets().add(asset);
    asset.getContentVersions().add(contentVersion);
     
    if(fixReferences)
    {
      for(Integer oldContentId : replaceMap.keySet())
      {
        Integer newContentId = replaceMap.get(oldContentId);
        logger.info("We should replace all instances of " + oldContentId + "(" + asset.getAssetKey() + ") --> " + newContentId + "(" + asset.getAssetKey() + ")");
           List<ReferenceBean> referenceBeans = RegistryController.getController().getReferencingObjectsForContentAsset(oldContentId, asset.getAssetKey(), 100, true, true, false);

           logger.info("referenceBeans:" + referenceBeans.size());
           for(Integer cvID : selfContentVersionIDList)
           {
             ContentVersionVO cvVO = ContentVersionController.getContentVersionController().getContentVersionVOWithId(cvID, db);
            
             ReferenceBean bean = new ReferenceBean();
             ReferenceVersionBean versionBean = new ReferenceVersionBean();
             versionBean.setReferencingObject(cvVO);
             //bean.setReferencingCompletingObject(versionBean);
             bean.getVersions().add(versionBean);
             referenceBeans.add(bean);
           }
          
           logger.info("referenceBeans:" + referenceBeans.size());
           for(ReferenceBean referenceBean : referenceBeans)
           {
             logger.info("ReferenceBean:" + referenceBean.getName() + ":" + referenceBean.getReferencingCompletingObject());
               
             for(ReferenceVersionBean referenceVersionBean : referenceBean.getVersions())
             {
               Object o = referenceVersionBean.getReferencingObject();
               logger.info("o:" + o.getClass().getName());
               try
               {
                 if(o instanceof ContentVersionVO)
                 {
                   ContentVersionVO cv = (ContentVersionVO)o;
                   logger.info("Replacing in:" + cv.getId());
                      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);
                       //newVersionValue = newVersionValue.replaceAll(m.group(), binding);
                       logger.info("newVersionValue: " + newVersionValue);
                     }
                   }
                  
                     Pattern pInlineAssets = Pattern.compile("getInlineAssetUrl\\(.*?\\)");
                  Matcher mInlineAssets = pInlineAssets.matcher(newVersionValue);
                  while (mInlineAssets.find())
                   {
                    logger.info("Found a " + mInlineAssets.group() + ".");
                     String assetCall = mInlineAssets.group();
                     if(assetCall.contains(oldContentId + ",") && (assetCall.contains("\"" + asset.getAssetKey() + "\"") || URLDecoder.decode(assetCall, "utf-8").contains("\"" + asset.getAssetKey() + "\"")))
                     {
                       logger.info("Replacing:" + mInlineAssets.group() + ":" + assetCall);
 
                       assetCall = assetCall.replaceFirst("" + oldContentId + ",", "" + newContentId + ",");
                       newVersionValue = StringUtils.replace(newVersionValue, mInlineAssets.group(), assetCall);
                       //newVersionValue = newVersionValue.replaceAll(mInlineAssets.group(), assetCall);
                       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());
                  
View Full Code Here

  {
      String attribute = "Undefined";
     
      ContentVO contentVO = ContentController.getContentController().getContentVOWithId(contentId);
   
    ContentVersionVO contentVersionVO = ContentVersionController.getContentVersionController().getLatestActiveContentVersionVO(contentVO.getId(), languageId);
    if(contentVersionVO != null)
      attribute = ContentVersionController.getContentVersionController().getAttributeValue(contentVersionVO, attributeName, false);
   
    return attribute;
 
View Full Code Here

  {
      String attribute = "Undefined";
     
      ContentVO contentVO = ContentController.getContentController().getContentVOWithId(contentId, db);
   
    ContentVersionVO contentVersionVO = ContentVersionController.getContentVersionController().getLatestActiveContentVersionVO(contentVO.getId(), languageId, db);
    if(contentVersionVO != null)
      attribute = ContentVersionController.getContentVersionController().getAttributeValue(contentVersionVO, attributeName, false);
   
    return attribute;
 
View Full Code Here

TOP

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

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.