Package org.infoglue.cms.entities.content

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


          if(this.synchronizationMethod.equalsIgnoreCase("pull"))
          {
            Iterator remoteContentVOListIterator = remoteContentVOList.iterator();
            while(remoteContentVOListIterator.hasNext())
            {
              ContentVO remoteContentVO = (ContentVO)remoteContentVOListIterator.next();
              //logger.info("remoteContentVO:" + remoteContentVO.getName());
              //logger.info("Versions:" + remoteContentVO.getContentVersion());
             
              Iterator componentsIterator = components.iterator();
              ContentVO localContentVO = null;
              while(componentsIterator.hasNext())
              {
                ContentVO candidate = (ContentVO)componentsIterator.next();
                if(candidate.getName().equals(remoteContentVO.getName()))
                {
                  localContentVO = candidate;
                }
              }
   
              DeploymentCompareBean bean = new DeploymentCompareBean();
              bean.setRemoteVersion(remoteContentVO);
              if(localContentVO != null)
              {
                  bean.setLocalVersion(localContentVO);
              LanguageVO languageVO = LanguageController.getController().getMasterLanguage(localContentVO.getRepositoryId());
              ContentVersionVO contentVersionVO = ContentVersionController.getContentVersionController().getLatestActiveContentVersionVO(localContentVO.getId(), languageVO.getId());
              if(contentVersionVO != null)
              {
                localContentVO.setVersions(new String[]{contentVersionVO.getVersionValue()});
                localContentVO.setVersionComments(new String[]{contentVersionVO.getVersionComment()});
                localContentVO.setContentVersion(contentVersionVO);
              }
              }
   
              deviatingContents.add(bean);
            }
          }
          else
          {
            Iterator componentsIterator = components.iterator();
            while(componentsIterator.hasNext())
            {
              ContentVO localContentVO = (ContentVO)componentsIterator.next();
            String fullPath = ContentController.getContentController().getContentPath(localContentVO.getId(), true, true);
            localContentVO.setFullPath(fullPath);
 
            Iterator remoteContentVOListIterator = remoteContentVOList.iterator();
              ContentVO remoteContentVO = null;
              while(remoteContentVOListIterator.hasNext())
              {
                ContentVO remoteContentVOCandidate = (ContentVO)remoteContentVOListIterator.next();
                if(localContentVO.getName().equals(remoteContentVOCandidate.getName()))
                  remoteContentVO = remoteContentVOCandidate;
              }
             
              DeploymentCompareBean bean = new DeploymentCompareBean();
            LanguageVO languageVO = LanguageController.getController().getMasterLanguage(localContentVO.getRepositoryId());
View Full Code Here


            logger.info("Updating remote component with missingRemoteContentId:" + missingRemoteContentId);
           
            Iterator remoteContentVOListIterator = remoteContentVOList.iterator();
            while(remoteContentVOListIterator.hasNext())
            {
              ContentVO remoteContentVO = (ContentVO)remoteContentVOListIterator.next();
              if(remoteContentVO.getId().toString().equals(missingRemoteContentId))
              {
                logger.info("Creating local copy of " + remoteContentVO.getName() + " - " + remoteContentVO.getFullPath());
               
                String fullPath = remoteContentVO.getFullPath();
                logger.info("fullPath:" + fullPath);
                int siteNodeEnd = fullPath.indexOf(" - /");
                String repositoryString = fullPath.substring(0, siteNodeEnd);
                String restString = fullPath.substring(siteNodeEnd + 4);
                logger.info("restString:" + restString);
                restString = restString.substring(0, restString.lastIndexOf("/"));
                logger.info("restString:" + restString);
                if(restString.indexOf("/") > -1)
                  restString = restString.substring(restString.indexOf("/") + 1);
                else
                  restString = "";
               
                logger.info("restString:" + restString);
               
                logger.info("repositoryString:" + repositoryString);
                logger.info("restString:" + restString);
                try
                {
                  RepositoryVO repositoryVO = RepositoryController.getController().getRepositoryVOWithName(repositoryString);
                  logger.info("repositoryVO:" + repositoryVO);
                  if(repositoryVO == null)
                  {
                    logger.warn("No repository found by name " + repositoryString + ". Looking for a default repository where other templates are located.");
                    List templates = ContentController.getContentController().getContentVOWithContentTypeDefinition("HTMLTemplate");
                    if(templates != null && templates.size() > 0)
                    {
                      ContentVO contentVO = (ContentVO)templates.get(0);
                      repositoryVO = RepositoryController.getController().getRepositoryVOWithId(contentVO.getRepositoryId());
                      logger.info("repositoryVO:" + repositoryVO);
                    }
                  }
                 
                  if(repositoryVO != null)
                  {
                    LanguageVO languageVO = LanguageController.getController().getMasterLanguage(repositoryVO.getRepositoryId());
 
                    ContentVO parentContent = ContentController.getContentController().getContentVOWithPath(repositoryVO.getId(), restString, true, this.getInfoGluePrincipal());
                    logger.info("parentContent:" + parentContent);
                    ContentVO newContentVO = ContentController.getContentController().create(parentContent.getId(), contentTypeDefinitionVO.getContentTypeDefinitionId(), parentContent.getRepositoryId(), remoteContentVO);
                    logger.info("Now we want to create the version also on:" + newContentVO.getName());
                    ContentVersionVO contentVersionVO = new ContentVersionVO();
                    contentVersionVO.setVersionComment("deployment");
                    contentVersionVO.setVersionModifier(this.getInfoGluePrincipal().getName());
                    if(remoteContentVO.getVersions() != null && remoteContentVO.getVersions().length > 0)
                    {
                      contentVersionVO.setVersionValue(remoteContentVO.getVersions()[0]);
                      ContentVersionController.getContentVersionController().create(newContentVO.getId(), languageVO.getId(), contentVersionVO, null);
                    }
                  }
                }
                catch (Exception e)
                {
                  e.printStackTrace();
                }

                break;
              }
            }
            /*
            ContentVO contentVO = ContentController.getContentController().getContentVOWithId(new Integer(missingLocalContentId).intValue());
            if(contentVO != null)
            {
            LanguageVO languageVO = LanguageController.getController().getMasterLanguage(contentVO.getRepositoryId());
           
            String fullPath = ContentController.getContentController().getContentPath(contentVO.getId(), true, true);
           
            ContentVersionVO contentVersionVO = ContentVersionController.getContentVersionController().getLatestActiveContentVersionVO(contentVO.getId(), languageVO.getId());
            if(contentVersionVO != null)
              contentVO.setVersions(new String[]{contentVersionVO.getVersionValue()});
           
            contentVO.setFullPath(fullPath);

            missingComponents.add(contentVO);
            }
            */
          }
        }

       
        String[] deviatingRemoteContentIdArray = this.getRequest().getParameterValues("deviatingContentId");
        //logger.info("deviatingRemoteContentIdArray:" + deviatingRemoteContentIdArray);
       
        List components = ContentController.getContentController().getContentVOWithContentTypeDefinition("HTMLTemplate");
       
        if(deviatingRemoteContentIdArray != null)
        {
          for(int i=0; i<deviatingRemoteContentIdArray.length; i++)
          {
            String deviatingRemoteContentId = deviatingRemoteContentIdArray[i];
           
            //String deviatingContentName = deviatingRemoteContentIdArray[i];
            //logger.info("Updating deviatingContentName:" + deviatingContentName);
   
              Iterator remoteContentVOListIterator = remoteContentVOList.iterator();
              while(remoteContentVOListIterator.hasNext())
              {
                ContentVO remoteContentVO = (ContentVO)remoteContentVOListIterator.next();
                //logger.info("remoteContentVO:" + remoteContentVO.getName());
                if(remoteContentVO.getId().toString().equals(deviatingRemoteContentId))
                {
                  String[] versionValues = remoteContentVO.getVersions();
                  if(versionValues != null && versionValues.length > 0)
                  {
                    String remoteVersionValue = versionValues[0];
 
                    Iterator componentsIterator = components.iterator();
                      ContentVO localContentVO = null;
                      while(componentsIterator.hasNext())
                      {
                        ContentVO candidate = (ContentVO)componentsIterator.next();
                        if(candidate.getName().equals(remoteContentVO.getName()))
                        {
                          localContentVO = candidate;
                        }
                      }
                     
                  LanguageVO languageVO = LanguageController.getController().getMasterLanguage(localContentVO.getRepositoryId());
                  ContentVersionVO contentVersionVO = ContentVersionController.getContentVersionController().getLatestActiveContentVersionVO(localContentVO.getId(), languageVO.getId());
                  if(contentVersionVO != null)
                  {
                    contentVersionVO.setVersionValue(remoteVersionValue);
                    //logger.info("Updating :" + localContentVO.getName() + " with new latest versionValue");
                    ContentVersionController.getContentVersionController().update(contentVersionVO.getId(), contentVersionVO);
                  }
                  }
                }
              }
          }
        }
      }
      else
      {
        logger.info("Updating components with push....");

        Map input = new HashMap();

        String[] missingLocalContentIdArray = this.getRequest().getParameterValues("missingContentId");
        logger.info("missingLocalContentIdArray:" + missingLocalContentIdArray);
       
        List missingComponents = new ArrayList();
        if(missingLocalContentIdArray != null)
        {
          for(int i=0; i<missingLocalContentIdArray.length; i++)
          {
            String missingLocalContentId = missingLocalContentIdArray[i];
            ContentVO contentVO = ContentController.getContentController().getContentVOWithId(new Integer(missingLocalContentId).intValue());
            if(contentVO != null)
            {
            LanguageVO languageVO = LanguageController.getController().getMasterLanguage(contentVO.getRepositoryId());
           
            String fullPath = ContentController.getContentController().getContentPath(contentVO.getId(), true, true);
           
            ContentVersionVO contentVersionVO = ContentVersionController.getContentVersionController().getLatestActiveContentVersionVO(contentVO.getId(), languageVO.getId());
            if(contentVersionVO != null)
            {
              contentVO.setVersions(new String[]{contentVersionVO.getVersionValue()});
              contentVO.setVersionComments(new String[]{"BBBBBB:" + contentVersionVO.getVersionComment()});
            }
            contentVO.setFullPath(fullPath);

            missingComponents.add(contentVO);
            }
          }
        }

        String[] deviatingLocalContentIdArray = this.getRequest().getParameterValues("deviatingContentId");
        logger.info("deviatingLocalContentIdArray:" + deviatingLocalContentIdArray);
       
        List deviatingComponents = new ArrayList();
        if(deviatingLocalContentIdArray != null)
        {
          for(int i=0; i<deviatingLocalContentIdArray.length; i++)
          {
            String deviatingLocalContentId = deviatingLocalContentIdArray[i];
            ContentVO contentVO = ContentController.getContentController().getContentVOWithId(new Integer(deviatingLocalContentId).intValue());
            if(contentVO != null)
            {
            LanguageVO languageVO = LanguageController.getController().getMasterLanguage(contentVO.getRepositoryId());
           
            String fullPath = ContentController.getContentController().getContentPath(contentVO.getId(), true, true);
           
            ContentVersionVO contentVersionVO = ContentVersionController.getContentVersionController().getLatestActiveContentVersionVO(contentVO.getId(), languageVO.getId());
            if(contentVersionVO != null)
            { 
              contentVO.setVersions(new String[]{contentVersionVO.getVersionValue()});
              contentVO.setVersionComments(new String[]{"AAAAAAA:" + contentVersionVO.getVersionComment()});
            }
            contentVO.setFullPath(fullPath);

            deviatingComponents.add(contentVO);
            }
          }
        }
View Full Code Here

   */
         
  public ContentVO getRootContentVO(Database db, Integer repositoryId, String userName, boolean createIfNonExisting) throws ConstraintException, SystemException, Exception
  {
    String key = "root_" + repositoryId;
    ContentVO contentVO = (ContentVO)CacheController.getCachedObjectFromAdvancedCache("rootContentCache", key);
    if(contentVO != null)
    {
      return contentVO;
    }

    logger.info("Fetching the root content for the repository " + repositoryId);
    OQLQuery oql = db.getOQLQuery( "SELECT c FROM org.infoglue.cms.entities.content.impl.simple.SmallContentImpl c WHERE is_undefined(c.parentContentId) AND c.repositoryId = $1");
    oql.bind(repositoryId);
     
    QueryResults results = oql.execute(Database.READONLY);     
    if (results.hasMore())
    {
      SmallContentImpl contentImpl = (SmallContentImpl)results.next();
      contentVO = contentImpl.getValueObject();
    }
    else
    {
      if(createIfNonExisting)
      {
        //None found - we create it and give it the name of the repository.
        logger.info("Found no rootContent so we create a new....");
        ContentVO rootContentVO = new ContentVO();
        RepositoryVO repositoryVO = RepositoryController.getController().getRepositoryVOWithId(repositoryId);
        rootContentVO.setCreatorName(userName);
        rootContentVO.setName(repositoryVO.getName());
        rootContentVO.setIsBranch(new Boolean(true));
        contentVO = create(db, null, null, repositoryId, rootContentVO).getValueObject();
      }
    }
   
    if(contentVO != null)
View Full Code Here

    {
      if(createIfNonExisting)
      {
        //None found - we create it and give it the name of the repository.
        logger.info("Found no rootContent so we create a new....");
        ContentVO rootContentVO = new ContentVO();
        RepositoryVO repositoryVO = RepositoryController.getController().getRepositoryVOWithId(repositoryId);
        rootContentVO.setCreatorName(userName);
        rootContentVO.setName(repositoryVO.getName());
        rootContentVO.setIsBranch(new Boolean(true));
        content = create(db, null, null, repositoryId, rootContentVO);
      }
    }
   
    results.close();
View Full Code Here

       
        beginTransaction(db);

        try
        {
          ContentVO smallContentVO = getSmallContentVOWithId(contentId, db);
          if(smallContentVO != null && smallContentVO.getContentTypeDefinitionId() != null)
            contentTypeDefinitionVO = ContentTypeDefinitionController.getController().getContentTypeDefinitionVOWithId(smallContentVO.getContentTypeDefinitionId(), db);
         
            //If any of the validations or setMethods reported an error, we throw them up now before create.
            ceb.throwIfNotEmpty();
           
            commitTransaction(db);
View Full Code Here

        if(contents != null)
        {
          Iterator i = contents.iterator();
          while(i.hasNext())
          {
            ContentVO candidate = (ContentVO)i.next();
            result.add(candidate);           
          }
        }
      }
    }
View Full Code Here

          if(contents != null)
          {
            Iterator i = contents.iterator();
            while(i.hasNext())
            {
              ContentVO candidate = (ContentVO)i.next();
              result.add(candidate);           
            }
          }
        }
        catch (SystemException e)
View Full Code Here

   * @param forceFolders if true then non-existing folders will be created; otherwise an exception will be thrown
   * @param db the database to use
   */
  public ContentVO getContentVOWithPath(Integer repositoryId, String path, boolean forceFolders, InfoGluePrincipal creator) throws SystemException, Exception
  {
    ContentVO contentVO = null;
   
    Database db = CastorDatabaseService.getDatabase();

    beginTransaction(db);
   
View Full Code Here

   * @param forceFolders if true then non-existing folders will be created; otherwise an exception will be thrown
   * @param db the database to use
   */
  public ContentVO getContentVOWithPath(Integer repositoryId, String path, boolean forceFolders, InfoGluePrincipal creator, Database db) throws SystemException, Exception
  {
    ContentVO content = getRootContentVO(db, repositoryId, creator.getName(), false);
    final String paths[] = path.split("/");
    if(path.equals(""))
      return content;
   
    for(int i=0; i<paths.length; ++i)
    {
      final String name = paths[i];
      if(!name.equals(""))
      {
        final ContentVO childContent = getChildVOWithName(content.getContentId(), name, db);
        if(childContent != null)
          content = childContent;
        else if(childContent == null && !forceFolders)
          throw new SystemException("There exists no content with the path [" + path + "].");
        else
        {
          ContentVO contentVO = new ContentVO();
          contentVO.setIsBranch(Boolean.TRUE);
          contentVO.setCreatorName(creator.getName());
          contentVO.setName(name);
          Content newContent = create(db, content.getId(), null, repositoryId, contentVO);
          if(newContent != null)
            content = newContent.getValueObject();
        }
      }
View Full Code Here

      else if(childContent == null && !forceFolders)
        throw new SystemException("There exists no content with the path [" + path + "].");
      else
      {
          logger.info("   CREATE " + name);
        ContentVO contentVO = new ContentVO();
        contentVO.setIsBranch(Boolean.TRUE);
        contentVO.setCreatorName(creator.getName());
        contentVO.setName(name);
        Content newContent = create(db, content.getId(), null, repositoryId, contentVO);
        if(newContent != null)
          content = newContent;
      }
    }
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.