Package org.infoglue.cms.entities.content.impl.simple

Examples of org.infoglue.cms.entities.content.impl.simple.MediumContentVersionImpl


    Database db = beginTransaction();

    try
    {
      ContentCategory contentCategory = (ContentCategory)getObjectWithId(MediumContentCategoryImpl.class, id, db);
        MediumContentVersionImpl contentVersion = ContentVersionController.getContentVersionController().checkStateAndChangeIfNeeded(contentCategory.getContentVersionId(), principal, db);
           
        //ContentCategory contentCategory = (ContentCategory)getObjectWithId(ContentCategoryImpl.class, id, db);
        //ContentVersion contentVersion = (ContentVersion)getObjectWithId(ContentVersionImpl.class, contentCategory.getContentVersionId(), db);
        Iterator contentCategoriesIterator = contentVersion.getContentCategories().iterator();
        while(contentCategoriesIterator.hasNext())
        {
          MediumContentCategoryImpl currentContentCategory = (MediumContentCategoryImpl)contentCategoriesIterator.next();
          ContentCategoryVO currentContentCategoryVO = currentContentCategory.getValueObject();
          if(currentContentCategoryVO.getAttributeName().equals(contentCategory.getAttributeName()) && currentContentCategory.getCategory().getId().equals(contentCategory.getCategory().getId()))
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);
View Full Code Here

      {
        try
        {
          ContentTypeDefinitionVO htmlTemplateMetaInfoCTDVO = ContentTypeDefinitionController.getController().getContentTypeDefinitionVOWithName("HTMLTemplate");
          ContentTypeDefinitionVO pagePartTemplateMetaInfoCTDVO = ContentTypeDefinitionController.getController().getContentTypeDefinitionVOWithName("PagePartTemplate");
          MediumContentVersionImpl contentVersion = (MediumContentVersionImpl)object;
          ContentVO contentVO = ContentController.getContentController().getContentVOWithId(contentVersion.getContentId(), true);
          if(contentVO.getContentTypeDefinitionId() == null || (
             contentVO.getContentTypeDefinitionId().equals(htmlTemplateMetaInfoCTDVO.getId()) ||
             contentVO.getContentTypeDefinitionId().equals(pagePartTemplateMetaInfoCTDVO.getId())))
          {
            ComponentController.getController().reIndexComponentContentsDelayed(contentVersion.getContentId());
          }

          CacheController.clearCacheForGroup("registryCache", "" + ("org.infoglue.cms.entities.content.ContentVersion_" + getObjectIdentity(object)).hashCode());

          CacheController.clearCacheForGroup("childContentCache", "content_" + contentVO.getId());
          if(contentVO.getParentContentId() != null)
            CacheController.clearCacheForGroup("childContentCache", "content_" + contentVO.getParentContentId());

          CacheController.clearCacheForGroup("contentVersionCache", "content_" + contentVersion.getContentId());
          CacheController.clearCacheForGroup("contentVersionCache", "contentVersion_" + contentVersion.getId());

          CacheController.clearCacheForGroup("contentAttributeCache", "content_" + contentVersion.getContentId());
        }
        catch (Exception e)
        {
          logger.warn("Error in JDOCallback:" + e.getMessage());
        }
View Full Code Here

        clearCache(SmallContentVersionImpl.class);
        clearCache(SmallestContentVersionImpl.class);
      }
      else if(object.getClass().getName().equals(MediumContentVersionImpl.class.getName()))
      {
        MediumContentVersionImpl contentVersion = (MediumContentVersionImpl)object;

        CacheController.clearCacheForGroup("contentVersionCache", "content_" + contentVersion.getContentId());

        clearCache(ContentVersionImpl.class);
        clearCache(SmallContentVersionImpl.class);
        clearCache(SmallestContentVersionImpl.class);
      }
View Full Code Here

        RegistryController.getController().clearRegistryForReferencingEntityNameThreaded(ContentVersion.class.getName(), getObjectIdentity(object).toString());
        //RegistryController.getController().clearRegistryForReferencingEntityName(ContentVersion.class.getName(), getObjectIdentity(object).toString());
      }
      else if(object.getClass().getName().equals(MediumContentVersionImpl.class.getName()))
      {
        MediumContentVersionImpl contentVersion = (MediumContentVersionImpl)object;
        try
        {
          ContentTypeDefinitionVO htmlTemplateMetaInfoCTDVO = ContentTypeDefinitionController.getController().getContentTypeDefinitionVOWithName("HTMLTemplate");
          ContentTypeDefinitionVO pagePartTemplateMetaInfoCTDVO = ContentTypeDefinitionController.getController().getContentTypeDefinitionVOWithName("PagePartTemplate");
          ContentVO contentVO = ContentController.getContentController().getContentVOWithId(contentVersion.getContentId(), true);
          if(contentVO.getContentTypeDefinitionId() == null || (
             contentVO.getContentTypeDefinitionId().equals(htmlTemplateMetaInfoCTDVO.getId()) ||
             contentVO.getContentTypeDefinitionId().equals(pagePartTemplateMetaInfoCTDVO.getId())))
          {
            ComponentController.getController().reIndexComponentContentsDelayed(contentVersion.getContentId());
          }
          CacheController.clearCacheForGroup("contentVersionCache", "content_" + contentVersion.getContentId());
        }
        catch (Exception e)
        {
          logger.warn("Error in JDOCallback:" + e.getMessage(), e);
        }

        clearCache(ContentVersionImpl.class);
        clearCache(SmallContentVersionImpl.class);
        clearCache(SmallestContentVersionImpl.class);
        clearCache(ContentImpl.class, contentVersion.getValueObject().getContentId());

        RegistryController.getController().clearRegistryForReferencingEntityNameThreaded(ContentVersion.class.getName(), getObjectIdentity(object).toString());
        //RegistryController.getController().clearRegistryForReferencingEntityName(ContentVersion.class.getName(), getObjectIdentity(object).toString());
      }
      else if(object.getClass().getName().equals(RepositoryLanguageImpl.class.getName()))
View Full Code Here

              ContentVersionVO contentVersionVO = new ContentVersionVO();
              contentVersionVO.setVersionComment("Autogenerated version");
              contentVersionVO.setVersionModifier(principal.getName());
              contentVersionVO.setVersionValue(versionValue);
              //ContentVersionController.getContentVersionController().create(contentVO.getId(), masterLanguage.getId(), contentVersionVO, null, db);
              MediumContentVersionImpl contentVersionImpl = ContentVersionController.getContentVersionController().createMedium(contentVO.getId(), languageVO.getId(), contentVersionVO, db);
              if(newContentVersions != null)
                newContentVersions.add(contentVersionImpl);
 
              RequestAnalyser.getRequestAnalyser().registerComponentStatistics("meta info create 2", t.getElapsedTime());
            }
          }
         
         
          LanguageVO localMasterLanguageVO = getInitialLanguageVO(db, parentFolderContent.getId(), repositoryId);
          //Also created a version in the local master language for this part of the site if any
          /*
          if(localMasterLanguageVO.getId().intValue() != masterLanguage.getId().intValue())
          {
            String versionValueLocalMaster = "<?xml version='1.0' encoding='UTF-8'?><article xmlns=\"x-schema:ArticleSchema.xml\"><attributes><Title><![CDATA[" + newSiteNode.getName() + "]]></Title><NavigationTitle><![CDATA[" + newSiteNode.getName() + "]]></NavigationTitle><NiceURIName><![CDATA[" + new VisualFormatter().replaceNiceURINonAsciiWithSpecifiedChars(newSiteNode.getName(), CmsPropertyHandler.getNiceURIDefaultReplacementCharacter()) + "]]></NiceURIName><Description><![CDATA[" + newSiteNode.getName() + "]]></Description><MetaInfo><![CDATA[" + newSiteNode.getName() + "]]></MetaInfo><ComponentStructure><![CDATA[]]></ComponentStructure></attributes></article>";
              ContentVersionVO contentVersionVOLocalMaster = new ContentVersionVO();
            contentVersionVOLocalMaster.setVersionComment("Autogenerated version");
            contentVersionVOLocalMaster.setVersionModifier(principal.getName());
            contentVersionVOLocalMaster.setVersionValue(versionValueLocalMaster);
            //ContentVersionController.getContentVersionController().create(contentVO.getId(), localMasterLanguageVO.getId(), contentVersionVOLocalMaster, null, db);
            MediumContentVersionImpl contentVersionImplLocal = ContentVersionController.getContentVersionController().createMedium(contentVO.getId(), localMasterLanguageVO.getId(), contentVersionVOLocalMaster, db);
            if(newContentVersions != null)
              newContentVersions.add(contentVersionImplLocal);
            RequestAnalyser.getRequestAnalyser().registerComponentStatistics("meta info create 3", t.getElapsedTime());
          }
          */

      // If there is an old meta info content this is a copy action and we should take appropriate actions
      if (oldMetaInfoContentVO != null)
      {
        List<ContentVersionVO> contentVersions = ContentVersionController.getContentVersionController().getContentVersionVOList(oldMetaInfoContentVO.getId(), db);
        if (logger.isDebugEnabled())
        {
          StringBuilder sb = new StringBuilder();
          sb.append("Copying ContentVersions to new Meta info. Old Content.id: " + oldMetaInfoContentVO.getContentId());
          sb.append("\n\tNumber of contentVersions: " + contentVersions.size());
          sb.append("\n\tSite master language.id: " + masterLanguage.getId());
          sb.append("\n\tParent folder master language: " + localMasterLanguageVO.getId());
          logger.debug(sb);
        }
        else
        {
          logger.info("Copying ContentVersions to new Meta info. Old Content.id: " + oldMetaInfoContentVO.getContentId());
        }
        for(ContentVersionVO cv : contentVersions)
        {
          logger.debug("cv " + cv.getLanguageId() + ":" + cv.getId());
          if(!cv.getLanguageId().equals(masterLanguage.getId()) && !cv.getLanguageId().equals(localMasterLanguageVO.getId()))
          {
            logger.info("Should create version for content <" + contentVO.getId() + "> with language.id " + cv.getLanguageId());
            String versionValueOtherVersion = cv.getVersionValue();
            ContentVersionVO contentVersionVOLocalMaster = new ContentVersionVO();
            contentVersionVOLocalMaster.setVersionComment("Autogenerated version");
            contentVersionVOLocalMaster.setVersionModifier(principal.getName());
            contentVersionVOLocalMaster.setVersionValue(versionValueOtherVersion);
            MediumContentVersionImpl contentVersionImplLocal = ContentVersionController.getContentVersionController().createMedium(contentVO.getId(), cv.getLanguageId(), contentVersionVOLocalMaster, db);
            if(newContentVersions != null)
              newContentVersions.add(contentVersionImplLocal);
            RequestAnalyser.getRequestAnalyser().registerComponentStatistics("meta info create 4", t.getElapsedTime());
          }
        }
View Full Code Here

  }
 
  public static MediumContentVersionImpl changeState(Integer oldContentVersionId, ContentVO contentVO, Integer stateId, String versionComment, boolean overrideVersionModifyer, String recipientFilter, InfoGluePrincipal infoGluePrincipal, Integer contentId, Database db, List resultingEvents, Integer excludedAssetId) throws SystemException, ConstraintException
  {
    Timer t = new Timer();
    MediumContentVersionImpl newContentVersion = null;

    try
    {
      MediumContentVersionImpl oldContentVersion = ContentVersionController.getContentVersionController().getReadOnlyMediumContentVersionWithId(oldContentVersionId, db);
      newContentVersion = oldContentVersion;
      logger.info("oldContentVersion:" + oldContentVersion.getId());
      //t.printElapsedTime("oldContentVersion");
     
      if (contentId == null && contentVO != null)
        contentId = contentVO.getContentId();
      else if(contentId == null)
        contentId = oldContentVersion.getValueObject().getContentId();
       
      if(contentId != null && contentVO == null)
          contentVO = ContentController.getContentController().getContentVOWithId(contentId, db);

      boolean duplicateAssets = CmsPropertyHandler.getDuplicateAssetsBetweenVersions();
     
      //Here we create a new version if it was a state-change back to working, it's a copy of the publish-version
      if (stateId.intValue() == ContentVersionVO.WORKING_STATE.intValue())
      {
        logger.info("About to create a new working version");
        ContentVersionVO newContentVersionVO = new ContentVersionVO();
        newContentVersionVO.setStateId(stateId);
        if(versionComment != null && !versionComment.equals(""))
          newContentVersionVO.setVersionComment(versionComment);
        else
            newContentVersionVO.setVersionComment("New working version");
        newContentVersionVO.setModifiedDateTime(DateHelper.getSecondPreciseDate());
        if(overrideVersionModifyer)
            newContentVersionVO.setVersionModifier(infoGluePrincipal.getName());
          else
              newContentVersionVO.setVersionModifier(oldContentVersion.getVersionModifier());

        newContentVersionVO.setVersionValue(oldContentVersion.getVersionValue());
        newContentVersion = ContentVersionController.getContentVersionController().createMedium(oldContentVersion, contentId, oldContentVersion.getValueObject().getLanguageId(), newContentVersionVO, oldContentVersion.getContentVersionId(), (oldContentVersion.getDigitalAssets().size() > 0), true, duplicateAssets, excludedAssetId, db);
        //newContentVersion = ContentVersionController.getContentVersionController().create(contentId, oldContentVersion.getLanguage().getLanguageId(), newContentVersionVO, oldContentVersion.getContentVersionId(), true, duplicateAssets, excludedAssetId, db);

        //ContentVersionController.getContentVersionController().copyDigitalAssets(oldContentVersion, newContentVersion, db);
        if(contentVO.getIsProtected().equals(ContentVO.YES))
          copyAccessRights(oldContentVersion.getId(), newContentVersion.getId(), db);
        copyContentCategories(oldContentVersion.getId(), newContentVersion.getId(), db);

        RegistryController.getController().updateContentVersionThreaded(newContentVersion.getValueObject(), null);
      }

      //If the user changes the state to publish we create a copy and set that copy to publish.
      if (stateId.intValue() == ContentVersionVO.PUBLISH_STATE.intValue())
      {
        logger.info("About to copy the working copy to a publish-one");

        //First we update the old working-version so it gets a comment
        logger.info("Setting comment " + versionComment + " on " + oldContentVersion.getId());
        //oldContentVersion.setVersionComment(versionComment);
       
        if(CmsPropertyHandler.getUseApprovalFlow().equals("true"))
        {
          //Now we create a new version which is basically just a copy of the working-version
          ContentVersionVO newContentVersionVO = new ContentVersionVO();
          newContentVersionVO.setStateId(stateId);
          newContentVersionVO.setVersionComment(versionComment);
          newContentVersionVO.setModifiedDateTime(DateHelper.getSecondPreciseDate());
          if(overrideVersionModifyer)
              newContentVersionVO.setVersionModifier(infoGluePrincipal.getName());
            else
                newContentVersionVO.setVersionModifier(oldContentVersion.getVersionModifier());
          newContentVersionVO.setVersionValue(oldContentVersion.getVersionValue());
          newContentVersion = ContentVersionController.getContentVersionController().createMedium(oldContentVersion, contentId, oldContentVersion.getValueObject().getLanguageId(), newContentVersionVO, oldContentVersion.getContentVersionId(), (oldContentVersion.getDigitalAssets().size() > 0), false, duplicateAssets, excludedAssetId, db);
          logger.info("Creating " + newContentVersion.getId());
         
          //ContentVersionController.getContentVersionController().copyDigitalAssets(oldContentVersion, newContentVersion, db);
          if(contentVO.getIsProtected().equals(ContentVO.YES))
            copyAccessRights(oldContentVersion.getId(), newContentVersion.getId(), db);
          copyContentCategories(oldContentVersion.getId(), newContentVersion.getId(), db);
 
          //Creating the event that will notify the editor...
 
          RegistryController.getController().updateContentVersionThreaded(newContentVersion.getValueObject(), null);
 
          ContentTypeDefinitionVO metaInfoCTDVO = ContentTypeDefinitionController.getController().getContentTypeDefinitionVOWithName("Meta info");
          if(contentVO.getContentTypeDefinitionId() != null && !contentVO.getContentTypeDefinitionId().equals(metaInfoCTDVO.getId()))
          {
            EventVO eventVO = new EventVO();
            eventVO.setDescription(newContentVersion.getVersionComment());
            eventVO.setEntityClass(ContentVersion.class.getName());
            eventVO.setEntityId(new Integer(newContentVersion.getId().intValue()));
            eventVO.setName(contentVO.getName());
            eventVO.setTypeId(EventVO.PUBLISH);
            eventVO = EventController.create(eventVO, contentVO.getRepositoryId(), infoGluePrincipal, db);
 
            resultingEvents.add(eventVO);
          }
         
        }
        else
        {
          oldContentVersion = ContentVersionController.getContentVersionController().getMediumContentVersionWithId(oldContentVersionId, db);
          oldContentVersion.setVersionComment(versionComment);

          EventVO eventVO = new EventVO();
          eventVO.setDescription(versionComment);
          eventVO.setEntityClass(ContentVersion.class.getName());
          eventVO.setEntityId(new Integer(newContentVersion.getId().intValue()));
          eventVO.setName(contentVO.getName());
          eventVO.setTypeId(EventVO.PUBLISH);
          eventVO = EventController.create(eventVO, contentVO.getRepositoryId(), infoGluePrincipal, db);

          resultingEvents.add(eventVO);
        }

        //if(recipientFilter != null && !recipientFilter.equals(""))
        //  PublicationController.mailPublishNotification(resultingEvents, contentVO.getRepositoryId(), infoGluePrincipal, recipientFilter, db);
      }

      //If the user in the publish-app publishes a publish-version we change state to published.
      if (stateId.intValue() == ContentVersionVO.PUBLISHED_STATE.intValue())
      {
        oldContentVersion = ContentVersionController.getContentVersionController().getMediumContentVersionWithId(oldContentVersionId, db);

        logger.info("About to publish an existing version:" + oldContentVersion.getId() + ":" + oldContentVersion.getStateId());
        Integer oldContentVersionStateId = oldContentVersion.getStateId();

        oldContentVersion.setStateId(stateId);
        oldContentVersion.setIsActive(new Boolean(true));

        //New logic to add meta data in some cases... ugly but needed if users are removed.
        insertIGMetaDataAttributes(oldContentVersion, infoGluePrincipal);

        //End new logic
View Full Code Here

    beginTransaction(db);
   
    try
    {     
          MediumContentVersionImpl contentVersion = ContentVersionController.getContentVersionController().checkStateAndChangeIfNeeded(contentVersionId, principal, db);
      //ContentVersion contentVersion = ContentVersionController.getContentVersionController().getContentVersionWithId(contentVersionId, db);
          returningContentVersionId.add(contentVersion.getId());
         
      digitalAssetVO = create(digitalAssetVO, is, contentVersion, db);
       
      commitTransaction(db);
    }
View Full Code Here

    oql.bind(languageId);
     
      QueryResults results = oql.execute();
    while (results.hasMore())
        {
      MediumContentVersionImpl contentVersion = (MediumContentVersionImpl)results.next();
      contentVersionList.add(contentVersion);
        }
   
    results.close();
    oql.close();
View Full Code Here

   */
 
    public ContentVersionVO create(Integer contentId, Integer languageId, ContentVersionVO contentVersionVO, Integer oldContentVersionId, boolean allowBrokenAssets, boolean duplicateAssets) throws ConstraintException, SystemException
    {
    Database db = CastorDatabaseService.getDatabase();
        MediumContentVersionImpl contentVersion = null;

        beginTransaction(db);
    try
        {
      contentVersion = create(contentId, languageId, contentVersionVO, oldContentVersionId, allowBrokenAssets, duplicateAssets, null, db);
      commitTransaction(db);
    }
        catch(Exception e)
        {
            logger.error("An error occurred so we should not complete the transaction:" + e);
            logger.warn("An error occurred so we should not complete the transaction:" + e, e);
            rollbackTransaction(db);
            throw new SystemException(e.getMessage());
        }
       
        return contentVersion.getValueObject();
    }
View Full Code Here

TOP

Related Classes of org.infoglue.cms.entities.content.impl.simple.MediumContentVersionImpl

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.