Package org.infoglue.cms.entities.content

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


  {
    boolean isContentProtected = false;
 
    try
    {
      ContentVO contentVO = ContentController.getContentController().getContentVOWithId(contentId);
      if(contentVO != null && contentVO.getIsProtected() != null)
      { 
        if(contentVO.getIsProtected().intValue() == NO.intValue())
          isContentProtected = false;
        else if(contentVO.getIsProtected().intValue() == YES.intValue())
          isContentProtected = true;
        else if(contentVO.getIsProtected().intValue() == INHERITED.intValue())
        {
          //ContentVO parentContentVO = ContentController.getParentContent(contentId);
          ContentVO parentContentVO = ContentController.getParentContent(contentVO);
          if(parentContentVO != null)
            isContentProtected = getIsContentProtected(parentContentVO.getId());
        }
      }

    }
    catch(Exception e)
View Full Code Here


          logger.info("siteNodePath:" + siteNodePath);
          if(siteNodePath.indexOf("/", 2) > -1)
            siteNodePath = siteNodePath.substring(siteNodePath.indexOf("/", 2));
          logger.info("siteNodePath:" + siteNodePath);
         
          ContentVO newParentContent = ContentController.getContentController().getContentVOWithPath(newRepository.getId(), "Meta info folder" + siteNodePath, true, principal, db);
          if(metaInfoContent != null && newParentContent != null)
          {
            logger.info("Moving:" + metaInfoContent.getName() + " to " + newParentContent.getName());
            //newParentContent.getChildren().add(metaInfoContent);
            //Content previousParentContent = metaInfoContent.getParentContent();
            metaInfoContent.setParentContentId(newParentContent.getId());
            //previousParentContent.getChildren().remove(metaInfoContent);
           
            LanguageVO oldMasterLanguage = LanguageController.getController().getMasterLanguage(metaInfoContent.getRepositoryId(), db);
            LanguageVO newMasterLanguage = LanguageController.getController().getMasterLanguage(newParentContent.getRepositoryId(), db);
           
            ContentVersionVO oldMasterContentVersionVO = ContentVersionController.getContentVersionController().getLatestContentVersionVO(metaInfoContent.getId(), oldMasterLanguage.getId(), db);
            ContentVersionVO newMasterContentVersionVO = ContentVersionController.getContentVersionController().getLatestContentVersionVO(metaInfoContent.getId(), newMasterLanguage.getId(), db);
            if(oldMasterContentVersionVO != null && newMasterContentVersionVO == null)
            {
              ContentVersionController.getContentVersionController().create(metaInfoContentId, newMasterLanguage.getId(), oldMasterContentVersionVO, null, db);
            }
            else if(oldMasterContentVersionVO != null && newMasterContentVersionVO != null)
            {
              String oldComponentStructure = ContentVersionController.getContentVersionController().getAttributeValue(oldMasterContentVersionVO, "ComponentStructure", false);
              String newComponentStructure = ContentVersionController.getContentVersionController().getAttributeValue(newMasterContentVersionVO, "ComponentStructure", false);
              if(oldComponentStructure != null && !oldComponentStructure.equals("") && (newComponentStructure == null || newComponentStructure.equals("")))
              {
                ContentVersionController.getContentVersionController().updateAttributeValue(newMasterContentVersionVO.getId(), "ComponentStructure", oldComponentStructure, principal, true);
              }
            }
            metaInfoContent.setRepositoryId(newParentContent.getRepositoryId());
            //changeRepositoryRecursiveForContent(metaInfoContent, newRepository);
          }

          siteNode.setRepository((RepositoryImpl)newRepository);
        Iterator ChildSiteNodesIterator = siteNode.getChildSiteNodes().iterator();
View Full Code Here

            String[] values = {serviceDefinition.getId().toString()};
            AvailableServiceBindingController.getController().update(availableServiceBindingId, values, db);
        }
        RequestAnalyser.getRequestAnalyser().registerComponentStatistics("getAvailableServiceBindingVOWithName", t.getElapsedTime());

        ContentVO rootContent = ContentControllerProxy.getController().getRootContentVO(db, repositoryId, principal.getName(), true);
        RequestAnalyser.getRequestAnalyser().registerComponentStatistics("getRootContentVO", t.getElapsedTime());

        if(rootContent != null)
        {
            ContentVO parentFolderContent = ContentController.getContentController().getContentVOWithPath(repositoryId, path, true, principal, db);
            RequestAnalyser.getRequestAnalyser().registerComponentStatistics("getContentVOWithPath", t.getElapsedTime());
           
          ContentVO contentVO = new ContentVO();
          contentVO.setCreatorName(principal.getName());
          contentVO.setIsBranch(new Boolean(false));
          contentVO.setName(newSiteNode.getName() + " Metainfo");
          contentVO.setRepositoryId(repositoryId);

          content = ContentControllerProxy.getController().create(db, parentFolderContent.getId(), metaInfoContentTypeDefinitionId, repositoryId, contentVO);
          RequestAnalyser.getRequestAnalyser().registerComponentStatistics("content.create", t.getElapsedTime());
         
          newSiteNode.setMetaInfoContentId(contentVO.getId());
         
          LanguageVO masterLanguageVO = LanguageController.getController().getMasterLanguage(repositoryId, db);

          String componentStructure = "<?xml version=\"1.0\" encoding=\"UTF-8\"?><components></components>";
          if(pageTemplateContentId != null)
          {
            ContentVersionVO contentVersionVO = ContentVersionController.getContentVersionController().getLatestActiveContentVersionVO(pageTemplateContentId, masterLanguageVO.getId(), db);
           
              componentStructure = ContentVersionController.getContentVersionController().getAttributeValue(contentVersionVO, "ComponentStructure", false);
         
          Document document = XMLHelper.readDocumentFromByteArray(componentStructure.getBytes("UTF-8"));
          String componentXPath = "//component";
          NodeList componentNodes = org.apache.xpath.XPathAPI.selectNodeList(document.getDocumentElement(), componentXPath);
          for(int i=0; i < componentNodes.getLength(); i++)
          {
            Element element = (Element)componentNodes.item(i);
            String componentId = element.getAttribute("id");
            String componentContentId = element.getAttribute("contentId");
           
            ComponentController.getController().checkAndAutoCreateContents(db, newSiteNode.getId(), masterLanguageVO.getId(), masterLanguageVO.getId(), null, new Integer(componentId), document, new Integer(componentContentId), principal);
            componentStructure = XMLHelper.serializeDom(document, new StringBuffer()).toString();
          }
              RequestAnalyser.getRequestAnalyser().registerComponentStatistics("meta info create 1", t.getElapsedTime());
          }
         
          List<LanguageVO> languageVOList = RepositoryLanguageController.getController().getLanguageVOListForRepositoryId(repositoryId, db);
          for(LanguageVO languageVO : languageVOList)
          {
            //Create initial content version also... in languageVO
            String versionValue = "<?xml version='1.0' encoding='UTF-8'?><article xmlns=\"x-schema:ArticleSchema.xml\"><attributes>";
            if(metaAttributes == null || !metaAttributes.containsKey(languageVO.getLanguageCode() + "_Title"))
              versionValue += "<Title><![CDATA[" + newSiteNode.getName() + "]]></Title>";
            if(metaAttributes == null || !metaAttributes.containsKey(languageVO.getLanguageCode() + "_NavigationTitle"))
                versionValue += "<NavigationTitle><![CDATA[" + newSiteNode.getName() + "]]></NavigationTitle>";
            if(metaAttributes == null || !metaAttributes.containsKey(languageVO.getLanguageCode() + "_NiceURIName"))
                versionValue += "<NiceURIName><![CDATA[" + new VisualFormatter().replaceNiceURINonAsciiWithSpecifiedChars(newSiteNode.getName(), CmsPropertyHandler.getNiceURIDefaultReplacementCharacter()) + "]]></NiceURIName>";
            if(metaAttributes == null || !metaAttributes.containsKey(languageVO.getLanguageCode() + "_Description"))
                versionValue += "<Description><![CDATA[" + newSiteNode.getName() + "]]></Description>";
            if(metaAttributes == null || !metaAttributes.containsKey(languageVO.getLanguageCode() + "_MetaInfo"))
                versionValue += "<MetaInfo><![CDATA[" + newSiteNode.getName() + "]]></MetaInfo>";
           
            boolean saveVersion = false;
            boolean realValue = false;
            if(metaAttributes != null)
            {
              for(String metaAttributeName : metaAttributes.keySet())
              {
                if(metaAttributeName.startsWith(languageVO.getLanguageCode() + "_"))
                {
                  versionValue += "<" + metaAttributeName.replaceFirst(languageVO.getLanguageCode() + "_", "") + "><![CDATA[" + metaAttributes.get(metaAttributeName) + "]]></" + metaAttributeName.replaceFirst(languageVO.getLanguageCode() + "_", "") + ">";
                  saveVersion = true;
                  realValue = true;
                }
              }
            }
                       
            if(!realValue) //No other values
              versionValue = "<?xml version='1.0' encoding='UTF-8'?><article xmlns=\"x-schema:ArticleSchema.xml\"><attributes>";
           
            if(languageVO.getId().equals(masterLanguageVO.getId()))
            {
              versionValue += "<ComponentStructure><![CDATA[" + componentStructure + "]]></ComponentStructure>";
              saveVersion = true;
            }
           
            versionValue += "</attributes></article>";
           
            if(saveVersion)
            {
              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());
          }
        }

        logger.info("Transforming NavigationTitle for copied Meta info. Content.id " + contentVO.getId());
        List<ContentVersionVO> newContentsVersions = ContentVersionController.getContentVersionController().getContentVersionVOList(contentVO.getId(), db);
        Pattern navigationTransformPattern = Pattern.compile(Pattern.quote("<NavigationTitle><![CDATA[") + "(.+?)" + Pattern.quote("]]></NavigationTitle>"));
        for (ContentVersionVO contentVersionVO : newContentsVersions)
        {
          String versionValue = contentVersionVO.getVersionValue();
          Matcher matcher = navigationTransformPattern.matcher(versionValue);

          versionValue = matcher.replaceFirst(Matcher.quoteReplacement("<NavigationTitle><![CDATA[") + "$1" + navigationTitleSuffix + Matcher.quoteReplacement("]]></NavigationTitle>"));
          contentVersionVO.setVersionValue(versionValue);
          if (logger.isTraceEnabled())
          {
            logger.trace("Version value after copy transformation (ContentVersion.id: " + contentVersionVO.getContentVersionId() + "). VersionValue: " + contentVersionVO.getVersionValue());
          }
          ContentVersionController.getContentVersionController().update(contentVO.getId(), contentVersionVO.getLanguageId(), contentVersionVO, db);
        }
      }

          ServiceBindingVO serviceBindingVO = new ServiceBindingVO();
          serviceBindingVO.setName(newSiteNode.getName() + " Metainfo");
          serviceBindingVO.setPath("/None specified/");
       
          String qualifyerXML = "<?xml version='1.0' encoding='UTF-8'?><qualifyer><contentId>" + contentVO.getId() + "</contentId></qualifyer>";
       
          //ServiceBindingController.getController().create(db, serviceBindingVO, qualifyerXML, availableServiceBindingId, siteNodeVersionVO.getId(), singleServiceDefinitionVO.getId()); 
          //RequestAnalyser.getRequestAnalyser().registerComponentStatistics("meta info service bind", t.getElapsedTime());
         
          if(checkIfMetaInfoIsBroken)
View Full Code Here

    Map args = new HashMap();
      args.put("globalKey", "infoglue");
      PropertySet ps = PropertySetManager.getInstance("jdbc", args);

      String initialLanguageId = ps.getString("content_" + contentId + "_initialLanguageId");
      ContentVO content = ContentController.getContentController().getContentVOWithId(contentId, db);
      ContentVO parentContent = ContentController.getContentController().getContentVOWithId(content.getParentContentId(), db);
      while((initialLanguageId == null || initialLanguageId.equalsIgnoreCase("-1")) && parentContent != null)
      {
          initialLanguageId = ps.getString("content_" + parentContent.getId() + "_initialLanguageId");
          if(parentContent.getParentContentId() != null)
            parentContent = ContentController.getContentController().getContentVOWithId(parentContent.getParentContentId(), db);
          else
            parentContent = null;
          //parentContent = parentContent.getParentContent();
      }
     
View Full Code Here

      logger.warn("Returning as this sitenode has allready been copied... no recusion please");
      return;
    }
   
    SiteNodeVO oldSiteNodeVO = SiteNodeController.getController().getSiteNodeVOWithId(siteNode.getId(), db);
        ContentVO oldMetaInfoContentVO = ContentController.getContentController().getContentVOWithId(oldSiteNodeVO.getMetaInfoContentId(), db);

        LanguageVO masterLanguage = LanguageController.getController().getMasterLanguage(siteNode.getRepositoryId(), db);
        ContentVersionVO oldCVVO = ContentVersionController.getContentVersionController().getLatestActiveContentVersionVO(oldMetaInfoContentVO.getId(), masterLanguage.getId(), db);
        RequestAnalyser.getRequestAnalyser().registerComponentStatistics("getLatestActiveContentVersionVO", t.getElapsedTime());

    SiteNodeVO newSiteNodeVO = new SiteNodeVO();
    newSiteNodeVO.setName(oldSiteNodeVO.getName() + newNameSuffix);
    newSiteNodeVO.setIsBranch(oldSiteNodeVO.getIsBranch());
View Full Code Here

    {
      Integer contentId = (Integer)relatedContentIdsIterator.next();
      logger.info("contentId:" + contentId);
      try
      {
        ContentVO contentVO = ContentController.getContentController().getContentVOWithId(contentId, db);
       
        if(contentVO != null)
        {
          logger.info("The contentVO 1: " + contentVO.getName() + " from repo " + contentVO.getRepositoryId());
          if(contentVO.getRepositoryId().intValue() == oldRepositoryId.intValue())
          {
            logger.info("The related content was in the old repo as well - let's copy that as well");
           
            /*
            if(contentIdsToCopy.contains(contentId))
 
View Full Code Here

    for(Integer contentId : contentIdsToCopy)
    {
      logger.info("contentId:" + contentId);
      try
      {
        ContentVO contentVO = ContentController.getContentController().getContentVOWithId(contentId, db);
        if(contentVO != null && newRepositoryId.intValue() != contentVO.getRepositoryId().intValue())
        {
          logger.info("The contentVO: " + contentVO.getName() + " from repo " + contentVO.getRepositoryId());
          if(contentVO.getRepositoryId().intValue() == oldRepositoryId.intValue())
          {
            logger.info("The related content was in the old repo as well - let's copy that as well");
            if(contentIdsMapping.containsKey(contentId))
            {
              logger.info("Allready transferred content so skipping:" + contentVO.getName());
              continue;
            }
           
            String path = ContentController.getContentController().getContentPath(contentId, true, false, db);
            logger.info("path:" + path);
            ContentVO copiedContent = ContentController.getContentController().getContentVOWithPath(newRepositoryId, path, true, principal, db);
            logger.info("copiedContent:" + copiedContent);
           
                  logger.info("Mapping content " + contentVO.getId() + " to " + copiedContent.getId());
                  contentIdsMapping.put(contentVO.getId(), copiedContent.getId());
           
            copiedContent.setName(contentVO.getName());
            copiedContent.setExpireDateTime(contentVO.getExpireDateTime());
            copiedContent.setIsBranch(contentVO.getIsBranch());
            copiedContent.setIsProtected(contentVO.getIsProtected());
            copiedContent.setPublishDateTime(contentVO.getPublishDateTime());
            copiedContent.setCreatorName(principal.getName());
           
              SiteNodeStateController.getController().copyAccessRights("Content", contentVO.getId(), copiedContent.getId(), db);

            /*
              copyAccessRights(db, contentVO.getId().toString(), copiedContent.getId().toString(), "Content.Read");
              copyAccessRights(db, contentVO.getId().toString(), copiedContent.getId().toString(), "Content.Write");
              copyAccessRights(db, contentVO.getId().toString(), copiedContent.getId().toString(), "Content.Create");
              copyAccessRights(db, contentVO.getId().toString(), copiedContent.getId().toString(), "Content.Delete");
              copyAccessRights(db, contentVO.getId().toString(), copiedContent.getId().toString(), "Content.Move");
              copyAccessRights(db, contentVO.getId().toString(), copiedContent.getId().toString(), "Content.SubmitToPublish");
              copyAccessRights(db, contentVO.getId().toString(), copiedContent.getId().toString(), "Content.ChangeAccessRights");
              copyAccessRights(db, contentVO.getId().toString(), copiedContent.getId().toString(), "Content.CreateVersion");
              */
             
              Map<Integer,Integer> assetIdMap = new HashMap<Integer,Integer>();
            Collection<ContentVersionVO> contentVersionVOList = ContentVersionController.getContentVersionController().getContentVersionVOList(contentVO.getId());
            for(ContentVersionVO contentVersionVO : contentVersionVOList)
            {
              logger.info("contentVersionVO:" + contentVersionVO.getId());
              Integer oldContentVersionId = contentVersionVO.getId();
              logger.info("oldContentVersionId:" + oldContentVersionId);
              //List assets = DigitalAssetController.getDigitalAssetVOList(contentVersionVO.getId());
              List<ContentCategory> contentCategories = ContentCategoryController.getController().findByContentVersionReadOnly(contentVersionVO.getId(), db);
              //logger.info("assets:" + assets);
              logger.info("contentCategories:" + contentCategories);
             
              //ContentTypeDefinition ctd = ContentTypeDefinitionController.getController().getContentTypeDefinitionWithId(contentVO.getContentTypeDefinitionId(), db);
              contentVersionVO.setStateId(0);
             
              ContentVersionVO newContentVersionVO = new ContentVersionVO();
              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("parentContent:" + parentContent);
      logger.info("categories:" + categories);
    }
   
    this.db = db;
    final ContentVO contentVO = createContentVO();
    final Document contentVersionDocument = buildContentVersionDocument();
    final ContentVersionVO contentVersionVO = createContentVersionVO(contentVersionDocument.asXML());
   
    ConstraintExceptionBuffer ceb = validate(contentVO, contentVersionVO);
    if(ceb.isEmpty())
View Full Code Here

   *
   * @return
   */
  public ConstraintExceptionBuffer validate()
  {
    final ContentVO contentVO               = createContentVO();
    final ContentVersionVO contentVersionVO = createContentVersionVO(buildContentVersionDocument().asXML());
    return validate(contentVO, contentVersionVO);
  }
View Full Code Here

   *
   * @return the content value object.
   */
  private ContentVO createContentVO()
  {
    final ContentVO contentVO = new ContentVO();
    populateContentVO(contentVO);
    return contentVO;
  }
View Full Code Here

TOP

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

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.