Examples of ContentVersion


Examples of com.agiletec.plugins.jpversioning.aps.system.services.versioning.ContentVersion

  public void testHistory() throws Throwable {
    String result = this.executeHistory("admin", "ART1");
    assertEquals(Action.SUCCESS, result);
    List<Long> versions = ((VersionAction) this.getAction()).getContentVersions();
    assertEquals(3, versions.size());
    ContentVersion version = ((VersionAction) this.getAction()).getContentVersion(1);
    assertEquals("Articolo", version.getDescr());
   
    result = this.executeHistory("admin", "ART2");
    assertEquals(Action.SUCCESS, result);
    versions = ((VersionAction) this.getAction()).getContentVersions();
    assertNull(versions);
View Full Code Here

Examples of com.agiletec.plugins.jpversioning.aps.system.services.versioning.ContentVersion

  }
 
  public void initContentVersions() throws ApsSystemException {
    this.cleanContentVersions();
    ContentRecordVO record = this._contentManager.loadContentVO("ART1");
    ContentVersion version1 = this.createContentVersion(1, record.getId(), record.getTypeCode(),
        "Articolo", Content.STATUS_DRAFT, record.getXmlWork(), DateConverter.parseDate("2005-02-13", "yyyy-MM-dd"),
        "0.0", 0, true, "admin");
    this.addContentVersion(version1);
    ContentVersion version2 = this.createContentVersion(2, record.getId(), record.getTypeCode(),
        "Articolo 2", Content.STATUS_DRAFT, record.getXmlWork(), DateConverter.parseDate("2005-02-14", "yyyy-MM-dd"),
        "0.1", 0, false, "mainEditor");
    this.addContentVersion(version2);
    ContentVersion version3 = this.createContentVersion(3, record.getId(), record.getTypeCode(),
        "Articolo 3", Content.STATUS_READY, record.getXmlWork(), DateConverter.parseDate("2005-02-15", "yyyy-MM-dd"),
        "1.0", 1, true, "mainEditor");
    this.addContentVersion(version3);
  }
View Full Code Here

Examples of com.agiletec.plugins.jpversioning.aps.system.services.versioning.ContentVersion

  }
 
  public ContentVersion createContentVersion(long id, String contentId, String contentType,
      String descr, String status, String xml, Date versionDate, String version,
      int onlineVersion, boolean approved, String username) {
    ContentVersion contentVersion = new ContentVersion();
    contentVersion.setId(id);
    contentVersion.setContentId(contentId);
    contentVersion.setContentType(contentType);
    contentVersion.setDescr(descr);
    contentVersion.setStatus(status);
    contentVersion.setXml(xml);
    contentVersion.setVersionDate(versionDate);
    contentVersion.setVersion(version);
    contentVersion.setOnlineVersion(onlineVersion);
    contentVersion.setApproved(approved);
    contentVersion.setUsername(username);
    return contentVersion;
  }
View Full Code Here

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

  {
    boolean hasPublishedVersion = false;
   
    try
    {
      ContentVersion contentVersion = ContentVersionController.getContentVersionController().getLatestPublishedContentVersion(this.contentId);
      if(contentVersion != null)
      {
        hasPublishedVersion = true;
        lastPublishedContentVersionId = contentVersion.getContentVersionId();
        this.repositoryId = contentVersion.getOwningContent().getRepository().getId();
        this.name = contentVersion.getOwningContent().getName();
        this.languageName = contentVersion.getLanguage().getName();
        this.contentId = contentVersion.getOwningContent().getId();
        this.languageId = contentVersion.getLanguage().getId();
      }
    }
    catch(Exception e){}
       
    return hasPublishedVersion;
View Full Code Here

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

  {
    boolean hasPublishedVersion = false;
   
    try
    {
      ContentVersion contentVersion = ContentVersionController.getContentVersionController().getLatestPublishedContentVersion(this.contentId, this.languageId);
      if(contentVersion != null)
      {
        hasPublishedVersion = true;
        lastPublishedContentVersionId = contentVersion.getContentVersionId();
        this.repositoryId = contentVersion.getOwningContent().getRepository().getId();
        this.name = contentVersion.getOwningContent().getName();
        this.languageName = contentVersion.getLanguage().getName();
        this.contentId = contentVersion.getOwningContent().getId();
        this.languageId = contentVersion.getLanguage().getId();
      }
    }
    catch(Exception e){}
       
    return hasPublishedVersion;
View Full Code Here

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

      logger.info("org contentVersions:" + contentVersions.size());
      List selectedContentVersions = new ArrayList();
      Iterator realContentVersionsIterator = contentVersions.iterator();
      while(realContentVersionsIterator.hasNext())
      {
        ContentVersion contentVersion = (ContentVersion)realContentVersionsIterator.next();     
        Iterator selectedContentVersionsIterator = selectedContentVersions.iterator();
        boolean addLanguageVersion = true;
        boolean noLanguageVersionFound = true;
        while(selectedContentVersionsIterator.hasNext())
        {
          ContentVersion currentContentVersion = (ContentVersion)selectedContentVersionsIterator.next();
          logger.info("" + currentContentVersion.getLanguage().getLanguageCode() + "=" + contentVersion.getLanguage().getLanguageCode());
          if(currentContentVersion.getLanguage().getLanguageCode().equals(contentVersion.getLanguage().getLanguageCode()))
          {
            noLanguageVersionFound = false;
           
            logger.info("" + contentVersion.getIsActive() + "=" + contentVersion.getLanguage().getLanguageCode());
            if(contentVersion.getIsActive().booleanValue() && contentVersion.getContentVersionId().intValue() > currentContentVersion.getContentVersionId().intValue())
            {
              logger.info("A later version was found... removing this one..");
              selectedContentVersionsIterator.remove();
              addLanguageVersion = true;
            }           
          }
        }
 
        if(addLanguageVersion || noLanguageVersionFound)
          selectedContentVersions.add(contentVersion);
     
     
      contentVersions = selectedContentVersions;
    }
   
    if(logger.isInfoEnabled())
    {
      logger.info("new contentVersions:" + contentVersions.size());
      Iterator contentVersionsIteratorDebug = contentVersions.iterator();
      while(contentVersionsIteratorDebug.hasNext())
      {
        ContentVersion contentVersion = (ContentVersion)contentVersionsIteratorDebug.next();
        logger.info("debug contentVersion:" + contentVersion.getId());
      }
    }
   
    Collections.sort((List)contentVersions, new ReflectionComparator("id"));

    if(logger.isInfoEnabled())
    {
      logger.info("new contentVersions:" + contentVersions.size());
      Iterator contentVersionsIteratorDebug = contentVersions.iterator();
      while(contentVersionsIteratorDebug.hasNext())
      {
        ContentVersion contentVersion = (ContentVersion)contentVersionsIteratorDebug.next();
        logger.info("debug contentVersion:" + contentVersion.getId());
      }
    }

    //Collection contentVersions = content.getContentVersions();
    Iterator contentVersionsIterator = contentVersions.iterator();
    while(contentVersionsIterator.hasNext())
    {
      ContentVersion contentVersion = (ContentVersion)contentVersionsIterator.next();
     
      Integer languageId = contentVersion.getLanguageId();
      logger.info("languageId:" + languageId);
      Language language = null;
      if(languageIdMap.containsKey(languageId))
      {
        language = languageIdMap.get(languageId);
        logger.info("found match:" + language);
      }
      else
      {
        throw new SystemException("No matching language found in the target repository");
      }
           
      logger.info("Creating contentVersion for language:" + language.getLanguageCode() + " on content " + content.getName());
     
      contentVersion.setOwningContent((ContentImpl)content);
      contentVersion.setLanguage((LanguageImpl)language);
     
      Collection digitalAssets = contentVersion.getDigitalAssets();
      if(digitalAssets != null)
      {
        List initialDigitalAssets = new ArrayList();
         
        Iterator digitalAssetsIterator = digitalAssets.iterator();
        while(digitalAssetsIterator.hasNext())
        {
          DigitalAsset digitalAsset = (DigitalAsset)digitalAssetsIterator.next();
         
          List initialContentVersions = new ArrayList();
          initialContentVersions.add(contentVersion);
          digitalAsset.setContentVersions(initialContentVersions);
 
          db.create(digitalAsset);
         
          initialDigitalAssets.add(digitalAsset);
        }
       
        contentVersion.setDigitalAssets(initialDigitalAssets);
      }

      Collection contentCategories = contentVersion.getContentCategories();
      logger.info("contentCategories:" + contentCategories.size());
     
      db.create(contentVersion);
     
      if(contentCategories != null)
      {
        List initialContentCategories = new ArrayList();
         
        Iterator contentCategoriesIterator = contentCategories.iterator();
        while(contentCategoriesIterator.hasNext())
        {
          ContentCategory contentCategory = (ContentCategory)contentCategoriesIterator.next();
          logger.info("contentCategory:" + contentCategory);
          contentCategory.setContentVersion((ContentVersionImpl)contentVersion);
         
          Integer oldCategoryId = contentCategory.getCategoryId();
          logger.info("oldCategoryId:" + oldCategoryId);
          Integer newCategoryId = (Integer)categoryIdMap.get(oldCategoryId);
          logger.info("newCategoryId:" + newCategoryId);
          if(newCategoryId == null)
            newCategoryId = oldCategoryId;
         
          if(newCategoryId != null)
          {
            Category category = CategoryController.getController().findById(newCategoryId, db);
            logger.info("Got category:" + category);
            if(category != null)
            {
              contentCategory.setCategory((CategoryImpl)category);
              logger.info("Creating content category:" + contentCategory);
             
              db.create(contentCategory);
           
              initialContentCategories.add(contentCategory);
            }
          }
        }
       
        contentVersion.setContentCategories(initialContentCategories);
      }

    }   
   
    Collection childContents = content.getChildren();
View Full Code Here

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

      logger.info("org contentVersions:" + contentVersions.size());
        List selectedContentVersions = new ArrayList();
      Iterator realContentVersionsIterator = contentVersions.iterator();
      while(realContentVersionsIterator.hasNext())
      {
        ContentVersion contentVersion = (ContentVersion)realContentVersionsIterator.next();     
        Iterator selectedContentVersionsIterator = selectedContentVersions.iterator();
        boolean addLanguageVersion = true;
        boolean noLanguageVersionFound = true;
        while(selectedContentVersionsIterator.hasNext())
        {
          ContentVersion currentContentVersion = (ContentVersion)selectedContentVersionsIterator.next();
          logger.info("" + currentContentVersion.getLanguage().getLanguageCode() + "=" + contentVersion.getLanguage().getLanguageCode());
          if(currentContentVersion.getLanguage().getLanguageCode().equals(contentVersion.getLanguage().getLanguageCode()))
          {
            noLanguageVersionFound = false;
           
            logger.info("" + contentVersion.getIsActive() + "=" + contentVersion.getLanguage().getLanguageCode());
            if(contentVersion.getIsActive().booleanValue() && contentVersion.getContentVersionId().intValue() > currentContentVersion.getContentVersionId().intValue())
            {
              logger.info("A later version was found... removing this one..");
              selectedContentVersionsIterator.remove();
              addLanguageVersion = true;
            }           
          }
        }
 
        if(addLanguageVersion || noLanguageVersionFound)
          selectedContentVersions.add(contentVersion);
     
     
      contentVersions = selectedContentVersions;
    }

       
        Iterator contentVersionIterator = contentVersions.iterator();
        while(contentVersionIterator.hasNext())
        {
            ContentVersion contentVersion = (ContentVersion)contentVersionIterator.next();
      logger.info("contentVersion:" + contentVersion.getId() + ":" + contentVersion.getContentVersionId());

            String contentVersionValue = contentVersion.getVersionValue();

            contentVersionValue = contentVersionValue.replaceAll("contentId=\"", "contentId=\"oldContentId_");
            contentVersionValue = contentVersionValue.replaceAll("\\?contentId=", "\\?contentId=oldContentId_");
            contentVersionValue = contentVersionValue.replaceAll("getInlineAssetUrl\\(", "getInlineAssetUrl\\(oldContentId_");
            contentVersionValue = contentVersionValue.replaceAll("languageId,", "languageId,oldContentId_");
            contentVersionValue = contentVersionValue.replaceAll("entity=\"Content\" entityId=\"", "entity=\"Content\" entityId=\"oldContentId_");
            //contentVersionValue = contentVersionValue.replaceAll("entity='Content'><id>", "entity='Content'><id>oldContentId_");
            contentVersionValue = contentVersionValue.replaceAll("siteNodeId=\"", "siteNodeId=\"oldSiteNodeId_");
            contentVersionValue = contentVersionValue.replaceAll("detailSiteNodeId=\"", "detailSiteNodeId=\"oldSiteNodeId_");
            contentVersionValue = contentVersionValue.replaceAll("getPageUrl\\((\\d)", "getPageUrl\\(oldSiteNodeId_$1");
            contentVersionValue = contentVersionValue.replaceAll("entity=\"SiteNode\" entityId=\"", "entity=\"SiteNode\" entityId=\"oldSiteNodeId_");
            //contentVersionValue = contentVersionValue.replaceAll("entity='SiteNode'><id>", "entity='SiteNode'><id>old_");

            contentVersionValue = this.prepareAllRelations(contentVersionValue);
                         
           
            //logger.info("contentVersionValue before:" + contentVersionValue);
           
            Iterator contentIdMapIterator = contentIdMap.keySet().iterator();
            while (contentIdMapIterator.hasNext())
            {
                String oldContentId = (String)contentIdMapIterator.next();
                String newContentId = (String)contentIdMap.get(oldContentId);
               
                //logger.info("Replacing all:" + oldContentId + " with " + newContentId);
               
                contentVersionValue = contentVersionValue.replaceAll("contentId=\"oldContentId_" + oldContentId + "\"", "contentId=\"" + newContentId + "\"");
                contentVersionValue = contentVersionValue.replaceAll("\\?contentId=oldContentId_" + oldContentId + "&", "\\?contentId=" + newContentId + "&");
                contentVersionValue = contentVersionValue.replaceAll("getInlineAssetUrl\\(oldContentId_" + oldContentId + ",", "getInlineAssetUrl\\(" + newContentId + ",");
                contentVersionValue = contentVersionValue.replaceAll("languageId,oldContentId_" + oldContentId + "\\)", "languageId," + newContentId + "\\)");
                contentVersionValue = contentVersionValue.replaceAll("entity=\"Content\" entityId=\"oldContentId_" + oldContentId + "\"", "entity=\"Content\" entityId=\"" + newContentId + "\"");
                contentVersionValue = contentVersionValue.replaceAll("<id>oldContentId_" + oldContentId + "</id>", "<id>" + newContentId + "</id>");
                //contentVersionValue = contentVersionValue.replaceAll("entity='Content'><id>old_" + oldContentId + "</id>", "entity='Content'><id>" + newContentId + "</id>");
                //contentVersionValue = contentVersionValue.replaceAll("<id>" + oldContentId + "</id>", "<id>" + newContentId + "</id>");
            }
           
            Iterator siteNodeIdMapIterator = siteNodeIdMap.keySet().iterator();
            while (siteNodeIdMapIterator.hasNext())
            {
                String oldSiteNodeId = (String)siteNodeIdMapIterator.next();
                String newSiteNodeId = (String)siteNodeIdMap.get(oldSiteNodeId);
               
                //logger.info("Replacing all:" + oldSiteNodeId + " with " + newSiteNodeId);
               
                contentVersionValue = contentVersionValue.replaceAll("siteNodeId=\"oldSiteNodeId_" + oldSiteNodeId + "\"", "siteNodeId=\"" + newSiteNodeId + "\"");
                contentVersionValue = contentVersionValue.replaceAll("detailSiteNodeId=\"oldSiteNodeId_" + oldSiteNodeId + "\"", "detailSiteNodeId=\"" + newSiteNodeId + "\"");
                contentVersionValue = contentVersionValue.replaceAll("getPageUrl\\(oldSiteNodeId_" + oldSiteNodeId + ",", "getPageUrl\\(" + newSiteNodeId + ",");
                contentVersionValue = contentVersionValue.replaceAll("entity=\"SiteNode\" entityId=\"oldSiteNodeId_" + oldSiteNodeId + "\"", "entity=\"SiteNode\" entityId=\"" + newSiteNodeId + "\"");
                //contentVersionValue = contentVersionValue.replaceAll("entity='SiteNode'><id>old_" + oldSiteNodeId + "</id>", "entity='SiteNode'><id>" + newSiteNodeId + "</id>");
                contentVersionValue = contentVersionValue.replaceAll("<id>oldSiteNodeId_" + oldSiteNodeId + "</id>", "<id>" + newSiteNodeId + "</id>");
            }
           
            //logger.info("contentVersionValue after:" + contentVersionValue);
           
            //Now replace all occurrances of old as they should never be there.
            contentVersionValue = contentVersionValue.replaceAll("oldContentId_", "");
            contentVersionValue = contentVersionValue.replaceAll("oldSiteNodeId_", "");

            logger.info("new contentVersionValue:" + contentVersionValue);
            contentVersion.setVersionValue(contentVersionValue);
        }
  }
View Full Code Here

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

        //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)
        {
            //TODO - lets keep the ref to meta info alive...
View Full Code Here

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

    // Need this crappy hack to forge the relationship (castor completely sucks like this)
    // TODO: When hibernate comes, just save the VOs and if it has a child VO with an id set
    // TODO: it is used to make the relationship...ask me for clarification -frank
    Category category = (Category)getObjectWithId(CategoryImpl.class, c.getCategory().getId(), db);
    //ContentVersion contentVersion = (ContentVersion)getObjectWithId(ContentVersionImpl.class, c.getContentVersionId(), db);
    ContentVersion contentVersion = ContentVersionController.getContentVersionController().getMediumContentVersionWithId(c.getContentVersionId(), db);
    ContentCategory contentCategory = null;
   
    List existingContentCategories = ContentCategoryController.getController().findByContentVersionAttribute(c.getAttributeName(), contentVersion.getContentVersionId(), db);
    boolean exists = false;
    Iterator existingContentCategoriesIterator = existingContentCategories.iterator();
    while(existingContentCategoriesIterator.hasNext())
    {
      ContentCategory contentCategoryCandidate = (ContentCategory)existingContentCategoriesIterator.next();
      if(contentCategoryCandidate.getCategoryId().equals(category.getId()))
      {
        exists = true;
        contentCategory = contentCategoryCandidate;
        logger.info("The category " + category.getName() + " was allready set on this version");
        break;
      }
    }
   
    if(!exists)
    {
      logger.info("Creating the category " + category.getName() + " as it was not set on this version");
 
      contentCategory = new MediumContentCategoryImpl();
      contentCategory.setValueObject(c);
      contentCategory.setCategory((CategoryImpl)category);
      contentCategory.setContentVersion((MediumContentVersionImpl)contentVersion);
      db.create(contentCategory);
      contentVersion.getContentCategories().add(contentCategory);
    }
    else
    {
      logger.info("Skipping the category " + category.getName() + " as it was allready set on this version");
    }
View Full Code Here

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

      Iterator categoryVOListIterator = categoryVOList.iterator();
      while(categoryVOListIterator.hasNext())
      {
          CategoryVO categoryVO = (CategoryVO)categoryVOListIterator.next();
        Category category = (Category)getObjectWithId(CategoryImpl.class, categoryVO.getId(), db);
        ContentVersion contentVersion = (ContentVersion)getObjectWithId(ContentVersionImpl.class, contentVersionVO.getId(), db);
       
        List existingContentCategories = ContentCategoryController.getController().findByContentVersionAttribute(attributeName, contentVersion.getContentVersionId(), db, true);
        boolean exists = false;
        Iterator existingContentCategoriesIterator = existingContentCategories.iterator();
        while(existingContentCategoriesIterator.hasNext())
        {
          ContentCategory contentCategory = (ContentCategory)existingContentCategoriesIterator.next();
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.