Package org.infoglue.cms.util

Examples of org.infoglue.cms.util.ConstraintExceptionBuffer


            throw new SystemException(e.getMessage());
        }
       
      db = CastorDatabaseService.getDatabase();

        ConstraintExceptionBuffer ceb = new ConstraintExceptionBuffer();

        beginTransaction(db);

        try
        {
            if(beforeSiteNodeId == null && direction == null)
            {
              logger.warn("You must specify the either new location with beforeSiteNodeId or sortDirection");
              throw new ConstraintException("SiteNode.parentSiteNodeId", "3403"); //TODO
            }
           
            //logger.info("siteNodeId:" + siteNodeId);
            //logger.info("beforeSiteNodeId:" + beforeSiteNodeId);
            //logger.info("direction:" + direction);
           
            if(beforeSiteNodeId != null)
            {
              Integer oldSortOrder = 0;
              Integer newSortOrder = 0;

                SiteNodeVO siteNodeVO = getSiteNodeVOWithId(siteNodeId, db);
              SiteNodeVO beforeSiteNodeVO = getSiteNodeVOWithId(beforeSiteNodeId, db);
              if(beforeSiteNodeVO.getParentSiteNodeId().intValue() != siteNodeVO.getParentSiteNodeId().intValue())
              {
                logger.info("Was new parent - let's fix that as well");
              }
              else
              {
                logger.info("Parent was the same...");

                List<SiteNodeVO> newChildSiteNodeList = new ArrayList<SiteNodeVO>();
                 
                int insertPosition = 0;
                List<SiteNodeVO> childrenVOList = SiteNodeController.getController().getChildSiteNodeVOList(siteNodeVO.getParentSiteNodeId(), false, db, sortLanguageId);
            Iterator<SiteNodeVO> childrenVOListIterator = childrenVOList.iterator();
            while(childrenVOListIterator.hasNext())
            {
              SiteNodeVO childSiteNodeVO = childrenVOListIterator.next();
              if(childSiteNodeVO.getSiteNodeId().equals(beforeSiteNodeId))
              {
                insertPosition = newChildSiteNodeList.size();
              }

              if(!childSiteNodeVO.getSiteNodeId().equals(siteNodeId))
              {
                newChildSiteNodeList.add(childSiteNodeVO);
              }
            }

            newChildSiteNodeList.add(insertPosition, siteNodeVO);
           
            Iterator<SiteNodeVO> newChildSiteNodeListIterator = newChildSiteNodeList.iterator();
            int i=0;
            int highestSortOrder = 0;
            while(newChildSiteNodeListIterator.hasNext())
            {
              logger.info("i:" + i);
              logger.info("highestSortOrder:" + highestSortOrder);
              SiteNodeVO orderedSiteNodeVO = newChildSiteNodeListIterator.next();
             
              List events = new ArrayList();
              SiteNodeVersionVO siteNodeVersionVO = SiteNodeVersionController.getController().getLatestSiteNodeVersionVO(db, orderedSiteNodeVO.getId());
              Integer localizedSortOrder = 100;
              if(CmsPropertyHandler.getAllowLocalizedSortAndVisibilityProperties())
            {
                ContentVersionVO cvVO = ContentVersionController.getContentVersionController().getLatestActiveContentVersionVO(orderedSiteNodeVO.getMetaInfoContentId(), sortLanguageId, db)
                if(cvVO != null)
                {
                  String localizedSortOrderString = ContentVersionController.getContentVersionController().getAttributeValue(cvVO.getId(), "SortOrder", false);
                  if(localizedSortOrderString != null && !localizedSortOrderString.equals(""))
                    localizedSortOrder = new Integer(localizedSortOrderString);
                }
              }
             
              //if(siteNodeVersionVO.getSortOrder() < highestSortOrder || localizedSortOrder < highestSortOrder)
              if(siteNodeVersionVO.getSortOrder() < highestSortOrder || localizedSortOrder < highestSortOrder || i != localizedSortOrder)
                {
                if(!siteNodeVersionVO.getStateId().equals(SiteNodeVersionVO.WORKING_STATE))
                { 
                  siteNodeVersionVO = SiteNodeStateController.getController().changeState(siteNodeVersionVO.getId(), SiteNodeVersionVO.WORKING_STATE, "Changed sortOrder", false, infoGluePrincipal, siteNodeVersionVO.getSiteNodeId(), events);
                }
                siteNodeVersionVO.setSortOrder(i);
               
                if(CmsPropertyHandler.getAllowLocalizedSortAndVisibilityProperties())
                {
                  ContentVersionVO cvVO = ContentVersionController.getContentVersionController().getLatestActiveContentVersionVO(orderedSiteNodeVO.getMetaInfoContentId(), sortLanguageId, db)
                  if(cvVO != null)
                    ContentVersionController.getContentVersionController().updateAttributeValue(cvVO.getContentVersionId(), "SortOrder", "" + i, infoGluePrincipal, db, true);
                }

                SiteNodeVersionController.getController().update(siteNodeVersionVO);
              }
              else
                logger.info("No action - sort order was ok");
              /*
              if(CmsPropertyHandler.getAllowLocalizedSortAndVisibilityProperties())
            {
                if(localizedSortOrder < 100 && localizedSortOrder > highestSortOrder)
                  highestSortOrder = localizedSortOrder;
             
                if(highestSortOrder > i)
                  i = highestSortOrder;
              }
              else
              {
                highestSortOrder = siteNodeVersionVO.getSortOrder();
                  if(highestSortOrder > i)
                  i = highestSortOrder;
              }
              */
              i++;
            }
              }
            }
            else if(direction.equalsIgnoreCase("up") || direction.equalsIgnoreCase("down"))
            {
              Integer oldSortOrder = 0;
              Integer newSortOrder = 0;
              SiteNodeVO siteNodeVO = getSiteNodeVOWithId(siteNodeId, db);

                SiteNodeVersion latestSiteNodeVersion = SiteNodeVersionController.getController().getLatestActiveSiteNodeVersion(db, siteNodeId);
              if(latestSiteNodeVersion != null)
        {
          oldSortOrder = latestSiteNodeVersion.getSortOrder();
          if(direction.equalsIgnoreCase("up"))
            newSortOrder = oldSortOrder - 1;
          else if(direction.equalsIgnoreCase("down"))
            newSortOrder = oldSortOrder + 1;
        }
       
              logger.info("OldSortOrder:" + oldSortOrder);
        List<SiteNodeVO> childrenVOList = SiteNodeController.getController().getChildSiteNodeVOList(siteNodeVO.getParentSiteNodeId(), false, db, sortLanguageId);
        Iterator<SiteNodeVO> childrenVOListIterator = childrenVOList.iterator();
        while(childrenVOListIterator.hasNext())
        {
          SiteNodeVO childSiteNodeVO = childrenVOListIterator.next();
          logger.info("childSiteNodeVO:" + childSiteNodeVO.getId() + ":" + childSiteNodeVO.getSortOrder());
          SiteNodeVersion latestChildSiteNodeVersion = SiteNodeVersionController.getController().getLatestActiveSiteNodeVersion(db, childSiteNodeVO.getId());
          //logger.info("latestChildSiteNodeVersion:" + latestChildSiteNodeVersion.getId());
          Integer currentSortOrder = latestChildSiteNodeVersion.getSortOrder();
          logger.info("currentSortOrder:" + currentSortOrder);
          if(currentSortOrder.equals(oldSortOrder))
          {
            latestChildSiteNodeVersion = SiteNodeStateController.getController().updateStateId(latestChildSiteNodeVersion, SiteNodeVersionVO.WORKING_STATE, "Changed sortOrder", infoGluePrincipal, db);
            latestChildSiteNodeVersion.setSortOrder(newSortOrder);
            //logger.info("Changed sort order on:" + latestChildSiteNodeVersion.getId() + " into " + newSortOrder);

            if(CmsPropertyHandler.getAllowLocalizedSortAndVisibilityProperties())
            {
              ContentVersionVO cvVO = ContentVersionController.getContentVersionController().getLatestActiveContentVersionVO(childSiteNodeVO.getMetaInfoContentId(), sortLanguageId, db)
              if(cvVO != null)
                ContentVersionController.getContentVersionController().updateAttributeValue(cvVO.getContentVersionId(), "SortOrder", "" + newSortOrder, infoGluePrincipal, db, true);
            }
          }
          else if(currentSortOrder.equals(newSortOrder))
          {
            latestChildSiteNodeVersion = SiteNodeStateController.getController().updateStateId(latestChildSiteNodeVersion, SiteNodeVersionVO.WORKING_STATE, "Changed sortOrder", infoGluePrincipal, db);
            latestChildSiteNodeVersion.setSortOrder(oldSortOrder);
            //logger.info("Changed sort order on:" + latestChildSiteNodeVersion.getId() + " into " + oldSortOrder);

            if(CmsPropertyHandler.getAllowLocalizedSortAndVisibilityProperties())
            {
              ContentVersionVO cvVO = ContentVersionController.getContentVersionController().getLatestActiveContentVersionVO(childSiteNodeVO.getMetaInfoContentId(), sortLanguageId, db)
              if(cvVO != null)
                ContentVersionController.getContentVersionController().updateAttributeValue(cvVO.getContentVersionId(), "SortOrder", "" + oldSortOrder, infoGluePrincipal, db, true);
            }
          }
        }
            }

            //If any of the validations or setMethods reported an error, we throw them up now before create.
            ceb.throwIfNotEmpty();
           
            commitTransaction(db);
        }
        catch(Exception e)
        {
View Full Code Here


   */
 
    public void toggleSiteNodeHidden(Integer siteNodeId, InfoGluePrincipal infoGluePrincipal, Integer sortLanguageId) throws ConstraintException, SystemException
    {
      Database db = CastorDatabaseService.getDatabase();
        ConstraintExceptionBuffer ceb = new ConstraintExceptionBuffer();

      if(CmsPropertyHandler.getAllowLocalizedSortAndVisibilityProperties())
    {
          beginTransaction(db);
 
          try
          {
        SiteNodeVO siteNodeVO = SiteNodeController.getController().getSiteNodeVOWithId(siteNodeId, db);
        ContentVersionVO cvVO = ContentVersionController.getContentVersionController().getLatestActiveContentVersionVO(siteNodeVO.getMetaInfoContentId(), sortLanguageId, db)
        if(cvVO != null)
        {
          String hideInNavigation = ContentVersionController.getContentVersionController().getAttributeValue(cvVO, "HideInNavigation", false);
          //System.out.println("hideInNavigation:" + hideInNavigation + " on " + sortLanguageId + "/" + cvVO.getContentVersionId());
          if(hideInNavigation == null || hideInNavigation.equals("") || hideInNavigation.equalsIgnoreCase("false"))
            ContentVersionController.getContentVersionController().updateAttributeValue(cvVO.getContentVersionId(), "HideInNavigation", "" + true, infoGluePrincipal, db);
          else
            ContentVersionController.getContentVersionController().updateAttributeValue(cvVO.getContentVersionId(), "HideInNavigation", "" + false, infoGluePrincipal, db);
        }
             
              commitTransaction(db);
          }
          catch(Exception e)
          {
              logger.error("An error occurred so we should not complete the transaction:" + e, e);
              rollbackTransaction(db);
              throw new SystemException(e.getMessage());
          }
    }
       
        db = CastorDatabaseService.getDatabase();

        beginTransaction(db);

        try
        {
            SiteNodeVersion latestSiteNodeVersion = SiteNodeVersionController.getController().getLatestActiveSiteNodeVersion(db, siteNodeId);
            //logger.info("latestSiteNodeVersion:" + latestSiteNodeVersion);
            if(latestSiteNodeVersion != null)
      {
            latestSiteNodeVersion = SiteNodeStateController.getController().updateStateId(latestSiteNodeVersion, SiteNodeVersionVO.WORKING_STATE, "Changed hidden", infoGluePrincipal, db);
            if(latestSiteNodeVersion.getIsHidden())
              latestSiteNodeVersion.setIsHidden(false);
            else
              latestSiteNodeVersion.setIsHidden(true);
      }
     
            ceb.throwIfNotEmpty();
           
            commitTransaction(db);
        }
        catch(Exception e)
        {
View Full Code Here

    {
      logger.error("The system could not find the default content type definition:" + e.getMessage(), e);
    }
   
    this.contentTypeDefinitionVO.setSchemaValue(schemaValue);
    this.ceb = new ConstraintExceptionBuffer();
     
 
View Full Code Here

  }
 
  public UpdateSystemUserAction(SystemUserVO systemUserVO)
  {
    this.systemUserVO = systemUserVO;
    this.ceb = new ConstraintExceptionBuffer();   
  }
View Full Code Here

  }
 
  public UpdateRepositoryAction(RepositoryVO repositoryVO)
  {
    this.repositoryVO = repositoryVO;
    this.ceb = new ConstraintExceptionBuffer()
  }
View Full Code Here

    private final static Logger logger = Logger.getLogger(ViewSiteNodeUCCImpl.class.getName());

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

        SiteNode siteNode = null;

        beginTransaction(db);

        try
        {
            siteNode = SiteNodeController.getController().getSiteNodeWithId(siteNodeId, db);
       
            //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.value = value;
    }

  public ConstraintExceptionBuffer validate()
  {
      ConstraintExceptionBuffer ceb = new ConstraintExceptionBuffer();
     
    return ceb;
  }
View Full Code Here

  /**
   * @see org.infoglue.cms.entities.kernel.BaseEntityVO#validate()
   */
  public ConstraintExceptionBuffer validate()
  {
      ConstraintExceptionBuffer ceb = new ConstraintExceptionBuffer();
     
      return ceb;
  }
View Full Code Here

    private final static Logger logger = Logger.getLogger(UpdateSiteNodeUCCImpl.class.getName());

    public SiteNodeVO updateSiteNode(InfoGluePrincipal infoGluePrincipal, SiteNodeVO siteNodeVO, SiteNodeVersionVO updatedSiteNodeVersionVO) throws ConstraintException, SystemException
    {
        Database db = CastorDatabaseService.getDatabase();
        ConstraintExceptionBuffer ceb = new ConstraintExceptionBuffer();

        SiteNode siteNode = null;

        beginTransaction(db);

        try
        {
            //add validation here if needed
            siteNode = SiteNodeController.getController().getSiteNodeWithId(siteNodeVO.getSiteNodeId(), db);
            siteNode.setValueObject(siteNodeVO);

      SiteNodeVersionVO latestSiteNodeVersionVO = SiteNodeVersionController.getController().getLatestSiteNodeVersion(db, siteNodeVO.getSiteNodeId(), false).getValueObject();
      latestSiteNodeVersionVO.setContentType(updatedSiteNodeVersionVO.getContentType());
      latestSiteNodeVersionVO.setPageCacheKey(updatedSiteNodeVersionVO.getPageCacheKey());
      latestSiteNodeVersionVO.setPageCacheTimeout(updatedSiteNodeVersionVO.getPageCacheTimeout());
      latestSiteNodeVersionVO.setDisableEditOnSight(updatedSiteNodeVersionVO.getDisableEditOnSight());
      latestSiteNodeVersionVO.setDisablePageCache(updatedSiteNodeVersionVO.getDisablePageCache());
      latestSiteNodeVersionVO.setDisableLanguages(updatedSiteNodeVersionVO.getDisableLanguages());
     
      Integer protectecSiteNodeVersionId = SiteNodeVersionControllerProxy.getSiteNodeVersionControllerProxy().getProtectedSiteNodeVersionId(latestSiteNodeVersionVO.getId(), db);
      if(protectecSiteNodeVersionId == null || AccessRightController.getController().getIsPrincipalAuthorized(infoGluePrincipal, "SiteNodeVersion.ChangeAccessRights", "" + protectecSiteNodeVersionId))
      {
        latestSiteNodeVersionVO.setIsProtected(updatedSiteNodeVersionVO.getIsProtected());
        latestSiteNodeVersionVO.setVersionModifier(updatedSiteNodeVersionVO.getVersionModifier());
      }

      latestSiteNodeVersionVO.setIsHidden(updatedSiteNodeVersionVO.getIsHidden());
      latestSiteNodeVersionVO.setDisableForceIdentityCheck(updatedSiteNodeVersionVO.getDisableForceIdentityCheck());
      latestSiteNodeVersionVO.setForceProtocolChange(updatedSiteNodeVersionVO.getForceProtocolChange());
      latestSiteNodeVersionVO.setModifiedDateTime(DateHelper.getSecondPreciseDate());
     
      SiteNodeVersionControllerProxy.getSiteNodeVersionControllerProxy().acUpdate(infoGluePrincipal, latestSiteNodeVersionVO, db);

            //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 SiteNodeVO updateSiteNode(InfoGluePrincipal infoGluePrincipal, SiteNodeVO siteNodeVO, Integer siteNodeTypeDefinitionId, SiteNodeVersionVO updatedSiteNodeVersionVO) throws AccessConstraintException, ConstraintException, SystemException
    {
        Database db = CastorDatabaseService.getDatabase();
        ConstraintExceptionBuffer ceb = new ConstraintExceptionBuffer();

        SiteNode siteNode = null;

        beginTransaction(db);

        try
        {
            //add validation here if needed
            siteNode = SiteNodeController.getController().getSiteNodeWithId(siteNodeVO.getSiteNodeId(), db);
            siteNode.setValueObject(siteNodeVO);
           
            if(siteNodeTypeDefinitionId != null)
              siteNode.setSiteNodeTypeDefinition((SiteNodeTypeDefinitionImpl)SiteNodeTypeDefinitionController.getController().getSiteNodeTypeDefinitionWithId(siteNodeTypeDefinitionId, db));

            if(updatedSiteNodeVersionVO != null)
            {
        SiteNodeVersionVO latestSiteNodeVersionVO = SiteNodeVersionController.getController().getLatestActiveSiteNodeVersionVO(db, siteNodeVO.getSiteNodeId());
       
        latestSiteNodeVersionVO.setContentType(updatedSiteNodeVersionVO.getContentType());
        latestSiteNodeVersionVO.setPageCacheKey(updatedSiteNodeVersionVO.getPageCacheKey());
        latestSiteNodeVersionVO.setPageCacheTimeout(updatedSiteNodeVersionVO.getPageCacheTimeout());
        latestSiteNodeVersionVO.setDisableEditOnSight(updatedSiteNodeVersionVO.getDisableEditOnSight());
        latestSiteNodeVersionVO.setDisableLanguages(updatedSiteNodeVersionVO.getDisableLanguages());
        latestSiteNodeVersionVO.setDisablePageCache(updatedSiteNodeVersionVO.getDisablePageCache());
 
        Integer protectecSiteNodeVersionId = SiteNodeVersionControllerProxy.getSiteNodeVersionControllerProxy().getProtectedSiteNodeVersionId(latestSiteNodeVersionVO.getId(), db);
        if(protectecSiteNodeVersionId == null || AccessRightController.getController().getIsPrincipalAuthorized(infoGluePrincipal, "SiteNodeVersion.ChangeAccessRights", "" + protectecSiteNodeVersionId))
        {
          latestSiteNodeVersionVO.setIsProtected(updatedSiteNodeVersionVO.getIsProtected());
          latestSiteNodeVersionVO.setVersionModifier(infoGluePrincipal.getName());
        }

        latestSiteNodeVersionVO.setIsHidden(updatedSiteNodeVersionVO.getIsHidden());
        latestSiteNodeVersionVO.setDisableForceIdentityCheck(updatedSiteNodeVersionVO.getDisableForceIdentityCheck());
        latestSiteNodeVersionVO.setForceProtocolChange(updatedSiteNodeVersionVO.getForceProtocolChange());
        latestSiteNodeVersionVO.setModifiedDateTime(DateHelper.getSecondPreciseDate());
 
        SiteNodeVersionControllerProxy.getSiteNodeVersionControllerProxy().acUpdate(infoGluePrincipal, latestSiteNodeVersionVO, db);
            }

      //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

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.