Package org.infoglue.cms.util

Examples of org.infoglue.cms.util.ConstraintExceptionBuffer


   */
    
  public List getSiteNodeChildren(Integer parentSiteNodeId) throws ConstraintException, SystemException
  {
    Database db = CastorDatabaseService.getDatabase();
    ConstraintExceptionBuffer ceb = new ConstraintExceptionBuffer();

    List childrenVOList = null;

    beginTransaction(db);

    try
    {
      SiteNode siteNode = getSiteNodeWithId(parentSiteNodeId, db);
      Collection children = siteNode.getChildSiteNodes();
      childrenVOList = SiteNodeController.toVOList(children);
         
      //If any of the validations or setMethods reported an error, we throw them up now before create.
      ceb.throwIfNotEmpty();
           
      commitTransaction(db);
    }
    catch(ConstraintException ce)
    {
View Full Code Here


   * This method moves a siteNode after first making a couple of controls that the move is valid.
   */
  public void moveSiteNode(SiteNodeVO siteNodeVO, Integer newParentSiteNodeId, InfoGluePrincipal principal) throws ConstraintException, SystemException
  {
    Database db = CastorDatabaseService.getDatabase();
    ConstraintExceptionBuffer ceb = new ConstraintExceptionBuffer();

    SiteNode siteNode          = null;
    SiteNode newParentSiteNode = null;
    SiteNode oldParentSiteNode = null;
   
    Map<String,String> pageUrls = new HashMap<String, String>();

    beginTransaction(db);

    try
    {
      //Validation that checks the entire object
      siteNodeVO.validate();

      if(newParentSiteNodeId == null)
      {
        logger.warn("You must specify the new parent-siteNode......");
        throw new ConstraintException("SiteNode.parentSiteNodeId", "3403");
      }

      if(siteNodeVO.getId().intValue() == newParentSiteNodeId.intValue())
      {
        logger.warn("You cannot have the siteNode as it's own parent......");
        throw new ConstraintException("SiteNode.parentSiteNodeId", "3401");
      }
     
      siteNode          = getSiteNodeWithId(siteNodeVO.getSiteNodeId(), db);
      oldParentSiteNode = siteNode.getParentSiteNode();
      newParentSiteNode = getSiteNodeWithId(newParentSiteNodeId, db);

      if(oldParentSiteNode.getId().intValue() == newParentSiteNodeId.intValue())
      {
        logger.warn("You cannot specify the same node as it originally was located in......");
        throw new ConstraintException("SiteNode.parentSiteNodeId", "3404");
      }

      SiteNode tempSiteNode = newParentSiteNode.getParentSiteNode();
      while(tempSiteNode != null)
      {
        if(tempSiteNode.getId().intValue() == siteNode.getId().intValue())
        {
          logger.warn("You cannot move the node to a child under it......");
          throw new ConstraintException("SiteNode.parentSiteNodeId", "3402");
        }
        tempSiteNode = tempSiteNode.getParentSiteNode();
      }

      pageUrls = RedirectController.getController().getNiceURIMapBeforeMove(db, siteNodeVO.getRepositoryId(), siteNodeVO.getSiteNodeId(), principal);

      logger.info("Setting the new Parent siteNode:" + siteNode.getSiteNodeId() + " " + newParentSiteNode.getSiteNodeId());
      siteNode.setParentSiteNode((SiteNodeImpl)newParentSiteNode);

      changeRepositoryRecursive(siteNode, newParentSiteNode.getRepository(), principal, db);
      //siteNode.setRepository(newParentSiteNode.getRepository());
      newParentSiteNode.getChildSiteNodes().add(siteNode);
      oldParentSiteNode.getChildSiteNodes().remove(siteNode);

      try
      {
        SiteNodeVersionVO publishedVersion = SiteNodeVersionController.getController().getLatestPublishedSiteNodeVersionVO(siteNode.getId(), db);
        SiteNodeVersionVO publishedVersionNewParent = SiteNodeVersionController.getController().getLatestPublishedSiteNodeVersionVO(newParentSiteNode.getId(), db);
        SiteNodeVersionVO publishedVersionOldParent = SiteNodeVersionController.getController().getLatestPublishedSiteNodeVersionVO(oldParentSiteNode.getId(), db);
        List<EventVO> events = new ArrayList<EventVO>();

        logger.info("publishedVersion:" + publishedVersion);
        if(publishedVersion != null)
        {
          EventVO eventVO = new EventVO();
          eventVO.setDescription("Moved page");
          eventVO.setEntityClass(SiteNodeVersion.class.getName());
          eventVO.setEntityId(publishedVersion.getId());
          eventVO.setName(siteNode.getName());
          eventVO.setTypeId(EventVO.MOVED);
          eventVO = EventController.create(eventVO, newParentSiteNode.getRepository().getId(), principal);
          events.add(eventVO);
        }
       
        logger.info("publishedVersionOldParent:" + publishedVersionOldParent);
        if(publishedVersionNewParent != null)
        {
          EventVO eventVO = new EventVO();
          eventVO.setDescription("New parent page");
          eventVO.setEntityClass(SiteNodeVersion.class.getName());
          eventVO.setEntityId(publishedVersionNewParent.getId());
          eventVO.setName(newParentSiteNode.getName());
          eventVO.setTypeId(EventVO.PUBLISH);
          eventVO = EventController.create(eventVO, newParentSiteNode.getRepository().getId(), principal);
          events.add(eventVO);
        }
       
        logger.info("publishedVersionOldParent:" + publishedVersionOldParent);
        if(publishedVersionOldParent != null)
        {
          EventVO eventVO = new EventVO();
          eventVO.setDescription("Move page");
          eventVO.setEntityClass(SiteNodeVersion.class.getName());
          eventVO.setEntityId(publishedVersionOldParent.getId());
          eventVO.setName(oldParentSiteNode.getName());
          eventVO.setTypeId(EventVO.PUBLISH);
          eventVO = EventController.create(eventVO, oldParentSiteNode.getRepository().getId(), principal);
          events.add(eventVO);
        }

        /*
        EventVO eventVO = new EventVO();
        eventVO.setDescription("Moved page");
        eventVO.setEntityClass(SiteNodeVersion.class.getName());
        eventVO.setEntityId(publishedVersion.getId());
        eventVO.setName(siteNode.getName());
        eventVO.setTypeId(EventVO.MOVED);
        eventVO = EventController.create(eventVO, siteNode.getRepository().getId(), principal);
        events.add(eventVO);
        */
       
        logger.info("events:" + events.size());
        if(events != null && events.size() > 0)
        {
          //Create publication if nodes has published version
          PublicationVO publicationVO = new PublicationVO();
          publicationVO.setName("Move of page - auto publication");
          publicationVO.setDescription("System did an automatic publication");
          publicationVO.setPublisher(principal.getName());
          publicationVO.setRepositoryId(newParentSiteNode.getRepository().getId());
         
          publicationVO = PublicationController.getController().createAndPublish(publicationVO, events, false, principal);
        }
      }
      catch (Exception e)
      {
        logger.error("Error publishing move:" + e.getMessage(), e);
      }

      // If any of the validations or setMethods reported an error, we throw them up now before create.
      ceb.throwIfNotEmpty();

      commitTransaction(db);
    }
    catch(ConstraintException ce)
    {
View Full Code Here


    public void setMetaInfoContentId(Integer siteNodeId, Integer metaInfoContentId) throws ConstraintException, SystemException
    {
        Database db = CastorDatabaseService.getDatabase();
        ConstraintExceptionBuffer ceb = new ConstraintExceptionBuffer();

        beginTransaction(db);

        try
        {
View Full Code Here

    public List getSiteNodeVOListWithoutMetaInfoContentId() throws ConstraintException, SystemException
    {
    List siteNodeVOList = new ArrayList();

    Database db = CastorDatabaseService.getDatabase();
        ConstraintExceptionBuffer ceb = new ConstraintExceptionBuffer();

        beginTransaction(db);

        try
        {
View Full Code Here

    public List getSiteNodeVOListWithMetaInfoContentId() throws ConstraintException, SystemException
    {
    List siteNodeVOList = new ArrayList();

    Database db = CastorDatabaseService.getDatabase();
        ConstraintExceptionBuffer ceb = new ConstraintExceptionBuffer();

        beginTransaction(db);

        try
        {
View Full Code Here

      siteNodeVO = getSiteNodeVOWithId(cachedSiteNodeId, false);
    }
    else
    {
      Database db = CastorDatabaseService.getDatabase();
          ConstraintExceptionBuffer ceb = new ConstraintExceptionBuffer();
 
          beginTransaction(db);
 
          try
          {
View Full Code Here

  public String getSiteNodePath(Integer siteNodeId, boolean includeRootSiteNode, boolean includeRepositoryName) throws ConstraintException, SystemException
    {
    String path = "";
   
    Database db = CastorDatabaseService.getDatabase();
        ConstraintExceptionBuffer ceb = new ConstraintExceptionBuffer();

        beginTransaction(db);

        try
        {
View Full Code Here

     
      logger.info("siteNodeVO:" + siteNodeVO);
      logger.info("newParentSiteNodeId:" + newParentSiteNodeId);
      logger.info("principal:" + principal);
      Database db = CastorDatabaseService.getDatabase();
        ConstraintExceptionBuffer ceb = new ConstraintExceptionBuffer();

        beginTransaction(db);

        try
        {
            //Validation that checks the entire object
            siteNodeVO.validate();
           
            if(newParentSiteNodeId == null)
            {
              logger.warn("You must specify the new parent-siteNode......");
              throw new ConstraintException("SiteNode.parentSiteNodeId", "3403");
            }
            /*
            if(siteNodeVO.getId().intValue() == newParentSiteNodeId.intValue())
            {
              logger.warn("You cannot have the siteNode as it's own parent......");
              throw new ConstraintException("SiteNode.parentSiteNodeId", "3401");
            }
            */

            SiteNodeVO siteNode = getSiteNodeVOWithId(siteNodeVO.getSiteNodeId(), db);
            SiteNodeVO oldParentSiteNode = getSiteNodeVOWithId(siteNodeVO.getParentSiteNodeId(), db); //siteNode.getParentSiteNode();
            SiteNodeVO newParentSiteNode = getSiteNodeVOWithId(newParentSiteNodeId, db);

            SiteNodeVO tempSiteNode = getSiteNodeVOWithId(newParentSiteNode.getParentSiteNodeId(), db); //siteNode.getParentSiteNode();
            //SiteNode tempSiteNode = newParentSiteNode.getParentSiteNode();
      while(tempSiteNode != null)
      {
        if(tempSiteNode.getId().intValue() == siteNode.getId().intValue())
        {
          logger.warn("You cannot move the node to a child under it......");
                throw new ConstraintException("SiteNode.parentSiteNodeId", "3402");
        }
        tempSiteNode = getSiteNodeVOWithId(tempSiteNode.getParentSiteNodeId(), db); //siteNode.getParentSiteNode();
        //tempSiteNode = tempSiteNode.getParentSiteNode();
     
     
      processBean.updateProcess("Checked for constraints");
     
      Map<Integer,Integer> siteNodeIdsMapping = new HashMap<Integer,Integer>();

      Map<Integer,Integer> contentIdsMapping = new HashMap<Integer,Integer>();
      Set<Integer> siteNodeIdsToCopy = new HashSet<Integer>();
      Set<Integer> contentIdsToCopy = new HashSet<Integer>();
      List<ContentVersion> newCreatedContentVersions = new ArrayList<ContentVersion>();

      String newNameSuffix = getNewNameSuffixForCopy(principal, db, newParentSiteNode);

      copySiteNodeRecursive(siteNode, newParentSiteNode, principal, siteNodeIdsMapping, contentIdsMapping, contentIdsToCopy, newCreatedContentVersions, newNameSuffix, db, processBean);
      //After this all sitenodes main should be copied but then we have to round up some related nodes later
      RequestAnalyser.getRequestAnalyser().registerComponentStatistics("copySiteNodeRecursive", t.getElapsedTime());
     
      processBean.updateProcess("Now we search for related contents to copy");
      //Now let's go through all contents
      for(ContentVersion version : newCreatedContentVersions)
          {
        getRelatedEntities(newParentSiteNode, principal, version.getVersionValue(), siteNodeVO.getRepositoryId(), newParentSiteNode.getRepositoryId(), siteNodeIdsMapping, contentIdsMapping, siteNodeIdsToCopy, contentIdsToCopy, newCreatedContentVersions, 0, 3, newNameSuffix, db, processBean);
            //getContentRelationsChain(siteNodesIdsMapping, contentIdsMapping, newParentSiteNode.getRepository().getId(), oldSiteNodeVO.getRepositoryId(), principal, versions, 0, 3, db);
          }
      RequestAnalyser.getRequestAnalyser().registerComponentStatistics("getRelatedEntities", t.getElapsedTime());
         
      processBean.updateProcess("Copying " + contentIdsToCopy.size() + " contents");

      //After this all related sitenodes should have been created and all related contents accounted for
      copyContents(newParentSiteNode, principal, contentIdsToCopy, siteNodeVO.getRepositoryId(), newParentSiteNode.getRepositoryId(), contentIdsMapping, newCreatedContentVersions, db);
      RequestAnalyser.getRequestAnalyser().registerComponentStatistics("copyContents", t.getElapsedTime());

      processBean.updateProcess("Remapping relations");
            rewireBindingsAndRelations(siteNodeIdsMapping, contentIdsMapping, newCreatedContentVersions, db);
      RequestAnalyser.getRequestAnalyser().registerComponentStatistics("rewireBindingsAndRelations", t.getElapsedTime());
     
            //If any of the validations or setMethods reported an error, we throw them up now before create.
            ceb.throwIfNotEmpty();
           
            commitTransaction(db);
        }
        catch(ConstraintException ce)
        {
View Full Code Here

  public List<SiteNodeVO> getUpcomingExpiringSiteNodes(int numberOfWeeks) throws Exception
  {
    List<SiteNodeVO> siteNodeVOList = new ArrayList<SiteNodeVO>();

    Database db = CastorDatabaseService.getDatabase();
        ConstraintExceptionBuffer ceb = new ConstraintExceptionBuffer();

        beginTransaction(db);

        try
        {
View Full Code Here

  public List<SiteNodeVO> getUpcomingExpiringSiteNodes(int numberOfDays, InfoGluePrincipal principal) throws Exception
  {
    List<SiteNodeVO> siteNodeVOList = new ArrayList<SiteNodeVO>();

    Database db = CastorDatabaseService.getDatabase();
        ConstraintExceptionBuffer ceb = new ConstraintExceptionBuffer();

        beginTransaction(db);

        try
        {
View Full Code Here

TOP

Related Classes of org.infoglue.cms.util.ConstraintExceptionBuffer

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.