Package org.infoglue.cms.applications.databeans

Examples of org.infoglue.cms.applications.databeans.ProcessBean


   * This method will try to unpublish latest live versions of this sitenode.
   */
    
    public String doUnpublishLatest() throws Exception
    {  
      ProcessBean processBean = ProcessBean.createProcessBean(UnpublishSiteNodeVersionAction.class.getName(), "" + getInfoGluePrincipal().getName());
    processBean.setStatus(ProcessBean.RUNNING);

    try
    {
      String[] siteNodeIds = getRequest().getParameterValues("sel");
 
      List<EventVO> events = new ArrayList<EventVO>();
 
      List<Integer> siteNodeVersionIdList = new ArrayList<Integer>();
      for(int i=0; i < siteNodeIds.length; i++)
        siteNodeVersionIdList.add(new Integer(siteNodeIds[i]));
 
      Map<Integer,SiteNodeVO> siteNodeMap = SiteNodeController.getController().getSiteNodeVOMapWithNoStateCheck(siteNodeVersionIdList);
      Map<Integer,ContentVO> contentMap = new HashMap<Integer,ContentVO>();
 
      processBean.updateProcess("Found " + siteNodeMap.size() + " pages")
      processBean.updateProcess("Processing " + siteNodeIds.length + " pages");
     
          for(int i=0; i < siteNodeIds.length; i++)
      {
            if (i % 10 == 0)
              processBean.updateLastDescription("Unpublished " + i + " pages");

              String siteNodeIdString = siteNodeIds[i];
              SiteNodeVersionVO siteNodeVersionVO = SiteNodeVersionController.getController().getLatestPublishedSiteNodeVersionVO(new Integer(siteNodeIdString));

              SiteNodeVersionVO latestSiteNodeVersionVO = SiteNodeVersionController.getController().getLatestActiveSiteNodeVersionVO(siteNodeVersionVO.getSiteNodeId());
        //SiteNodeVO siteNodeVO = siteNodeMap.get(siteNodeVersionVO.getId());
        //if(siteNodeVO == null)
        SiteNodeVO siteNodeVO = SiteNodeController.getController().getSiteNodeVOWithId(siteNodeVersionVO.getSiteNodeId());
       
        if(attemptDirectPublishing.equals("true"))
        {
          if(siteNodeVersionVO.getId().equals(latestSiteNodeVersionVO.getId()))
          {
            logger.info("Creating a new working version as there was no active working version left...");
            SiteNodeVersionVO newSiteNodeVersionVO = SiteNodeStateController.getController().changeState(siteNodeVersionVO.getId(), siteNodeVO, SiteNodeVersionVO.WORKING_STATE, "new working version", false, this.getInfoGluePrincipal(), events);
            siteNodeMap.put(newSiteNodeVersionVO.getId(), siteNodeVO);
          }
        }
       
        EventVO eventVO = new EventVO();
        eventVO.setDescription(this.versionComment);
        eventVO.setEntityClass(SiteNodeVersion.class.getName());
        eventVO.setEntityId(siteNodeVersionVO.getId());
        eventVO.setName(siteNodeVO.getName());
        eventVO.setTypeId(EventVO.UNPUBLISH_LATEST);
        eventVO = EventController.create(eventVO, this.repositoryId, this.getInfoGluePrincipal());
        events.add(eventVO);
       
        List contentVersionVOList = SiteNodeVersionController.getController().getMetaInfoContentVersionVOList(siteNodeVersionVO, siteNodeVO, this.getInfoGluePrincipal());
        Iterator contentVersionVOListIterator = contentVersionVOList.iterator();
        while(contentVersionVOListIterator.hasNext())
        {
            ContentVersionVO currentContentVersionVO = (ContentVersionVO)contentVersionVOListIterator.next();
           
          ContentVersionVO latestContentVersionVO = ContentVersionController.getContentVersionController().getLatestActiveContentVersionVO(currentContentVersionVO.getContentId(), currentContentVersionVO.getLanguageId());
          ContentVO contentVO = ContentController.getContentController().getContentVOWithId(currentContentVersionVO.getContentId());
          contentMap.put(currentContentVersionVO.getId(), contentVO);
          if(attemptDirectPublishing.equals("true"))
          {
            if(currentContentVersionVO.getId().equals(latestContentVersionVO.getId()))
            {
              logger.info("Creating a new working version as there was no active working version left...:" + currentContentVersionVO.getLanguageName());
              ContentStateController.changeState(currentContentVersionVO.getId(), contentVO, ContentVersionVO.WORKING_STATE, "new working version", false, null, this.getInfoGluePrincipal(), currentContentVersionVO.getContentId(), events);
            }
           
            EventVO versionEventVO = new EventVO();
            versionEventVO.setDescription(this.versionComment);
            versionEventVO.setEntityClass(ContentVersion.class.getName());
            versionEventVO.setEntityId(currentContentVersionVO.getId());
            versionEventVO.setName(contentVO.getName());
            versionEventVO.setTypeId(EventVO.UNPUBLISH_LATEST);
            versionEventVO = EventController.create(versionEventVO, this.repositoryId, this.getInfoGluePrincipal());
            events.add(versionEventVO);         
          }
        }
      }

     
      if(!attemptDirectPublishing.equalsIgnoreCase("true"))
      {
        if(recipientFilter != null && !recipientFilter.equals("") && events != null && events.size() > 0)
          PublicationController.mailPublishNotification(events, repositoryId, getInfoGluePrincipal(), recipientFilter, true);
      }

      if(attemptDirectPublishing.equalsIgnoreCase("true"))
      {
          PublicationVO publicationVO = new PublicationVO();
          publicationVO.setName("Direct publication by " + this.getInfoGluePrincipal().getName());
          publicationVO.setDescription(getVersionComment());
          //publicationVO.setPublisher(this.getInfoGluePrincipal().getName());
          publicationVO.setRepositoryId(repositoryId);
          publicationVO = PublicationController.getController().createAndPublish(publicationVO, events, siteNodeMap, contentMap, false, this.getInfoGluePrincipal());
      }
    }
    finally
    {
      processBean.setStatus(ProcessBean.FINISHED);
      processBean.removeProcess();
    }
   
    if(this.returnAddress != null && !this.returnAddress.equals(""))
        {
          String arguments   = "userSessionKey=" + userSessionKey + "&attemptDirectPublishing=" + attemptDirectPublishing + "&isAutomaticRedirect=false";
View Full Code Here


    StringBuffer sb = new StringBuffer();
    sb.append("<html><body>");
   
    try
    {
      ProcessBean processBean = getProcessBean();
      if(processBean != null && processBean.getStatus() != ProcessBean.FINISHED)
      {
        sb.append("<h2>" + getLocalizedString(getLocale(), "tool.structuretool.publicationProcess.publicationProcessInfo") + "</h2>");

        sb.append("<ol>");
        for(String event : processBean.getProcessEvents())
          sb.append("<li>" + event + "</li>");
        sb.append("</ol>");
        sb.append("<div style='text-align: center'><img src='images/loading.gif' /></div>");
      }
      else
View Full Code Here

  public String doDeleteProcessBean() throws Exception
  {
    if(this.processId != null)
    {
      ProcessBean pb = ProcessBean.getProcessBean(ExportRepositoryAction.class.getName(), processId);
      if(pb != null)
        pb.removeProcess();
    }
   
    return "successRedirectToProcesses";
  }
View Full Code Here

  protected String doExecuteV3() throws Exception
  {
    String[] repositories = getRequest().getParameterValues("repositoryId");

    String exportId = "Export_" + visualFormatter.formatDate(new Date(), "yyyy-MM-dd_HHmm");
    ProcessBean processBean = ProcessBean.createProcessBean(ExportRepositoryAction.class.getName(), exportId);
    processBean.setStatus(ProcessBean.RUNNING);
   
    OptimizedExportController.export(repositories, assetMaxSize, onlyPublishedVersions, exportFileName, processBean);
   
    return "successRedirectToProcesses";
  }
View Full Code Here

      logger.debug("Number of processes before filtering: " + processes.size());
    }
    if (this.processStatus != -1)
    {
      Iterator<ProcessBean> processIterator = processes.iterator();
      ProcessBean process;
      while (processIterator.hasNext())
      {
        process = processIterator.next();
        if (process.getStatus() != this.processStatus)
        {
          logger.debug("Removing (filtering) process with Id: " + process.getProcessId());
          processIterator.remove();
        }
      }
    }
    if (logger.isDebugEnabled())
View Full Code Here

     private boolean anonymousNoAccessWarning = false;

  protected String doExecute() throws Exception
  {
    ProcessBean processBean = ProcessBean.createProcessBean(ViewListContentVersionAction.class.getName(), "" + getInfoGluePrincipal().getName());
    processBean.setStatus(ProcessBean.RUNNING);

    try
    {
      if(this.contentId != null)
      {
        Timer t = new Timer();
          ContentVO contentVO = ContentController.getContentController().getContentVOWithId(this.contentId);
          this.repositoryId = contentVO.getRepositoryId();
         
        AccessConstraintExceptionBuffer ceb = new AccessConstraintExceptionBuffer();
     
        Integer protectedContentId = ContentControllerProxy.getController().getProtectedContentId(contentId);
        if(protectedContentId != null && !AccessRightController.getController().getIsPrincipalAuthorized(this.getInfoGluePrincipal(), "Content.SubmitToPublish", protectedContentId.toString()))
          ceb.add(new AccessConstraintException("Content.contentId", "1005"));
       
        ceb.throwIfNotEmpty();
 
        RequestAnalyser.getRequestAnalyser().registerComponentStatistics("ViewListContentVersion part 1", t.getElapsedTime());
       
        //Set<SiteNodeVersionVO> siteNodeVersionVOList = new HashSet<SiteNodeVersionVO>();
        //Set<ContentVersionVO> contentVersionVOList = new HashSet<ContentVersionVO>();
 
        ContentVersionController.getContentVersionController().getContentAndAffectedItemsRecursive(this.contentId, ContentVersionVO.WORKING_STATE, this.siteNodeVersionVOList, this.contentVersionVOList, true, true, processBean);
        RequestAnalyser.getRequestAnalyser().registerComponentStatistics("ViewListContentVersion getContentAndAffectedItemsRecursive", t.getElapsedTime());
       
        processBean.updateProcess("Found " + this.siteNodeVersionVOList.size() + " pages and " + this.contentVersionVOList.size() + " contents");
       
        /*
        Set<ContentVersionVO> contentVersionVOListSet = new HashSet<ContentVersionVO>();
        for(Integer contentVersionId : contentVersionVOSet)
        {
          contentVersionVOListSet.add(ContentVersionController.getContentVersionController().getContentVersionVOWithId(contentVersionId));
        }
        */
       
        RequestAnalyser.getRequestAnalyser().registerComponentStatistics("ViewListContentVersion versions", t.getElapsedTime());
 
        Database db = CastorDatabaseService.getDatabase();
 
            beginTransaction(db);
 
            try
            {
              boolean skipDisplayName = false;
          for(ContentVersionVO contentVersionVO : contentVersionVOList)
          {
            if(contentVersionVO.getStateId() == 0
            {
              Integer localProtectedContentId = ContentControllerProxy.getController().getProtectedContentId(contentVersionVO.getContentId());
              if(localProtectedContentId != null)
              {
                boolean hasAnonymousUserAccess = AccessRightController.getController().getIsPrincipalAuthorized(db, UserControllerProxy.getController().getUser(CmsPropertyHandler.getAnonymousUser()), "Content.Read", localProtectedContentId.toString(), false);
                if(!hasAnonymousUserAccess)
                {
                  anonymousNoAccessWarning = true;
                  contentVersionVO.setHasAnonymousUserAccess(false);
                }
              }

              if(!skipDisplayName)
              {
                InfoGluePrincipal principal = (InfoGluePrincipal)getInfoGluePrincipal(contentVersionVO.getVersionModifier(), db);
                if(principal != null)
                {
                  if(principal.getName().equalsIgnoreCase(principal.getDisplayName()))
                    skipDisplayName = true;
                 
                  contentVersionVO.setVersionModifierDisplayName(principal.getDisplayName());
                }
              }
              contentVersionVO.setPath(getContentPath(contentVersionVO.getContentId(), db));
              contentVersionVO.setLanguageName(LanguageController.getController().getLanguageVOWithId(contentVersionVO.getLanguageId()).getName());
            }
            else
              logger.info("Not adding contentVersion..");
          }
         
          for(SiteNodeVersionVO snVO : siteNodeVersionVOList)
          {
            if(snVO.getStateId() == 0)
            {
              Integer protectedSiteNodeVersionId = SiteNodeVersionControllerProxy.getSiteNodeVersionControllerProxy().getProtectedSiteNodeVersionId(snVO.getId(), db);
              if(protectedSiteNodeVersionId != null)
              {
                boolean hasAnonymousUserAccess = AccessRightController.getController().getIsPrincipalAuthorized(db, UserControllerProxy.getController().getUser(CmsPropertyHandler.getAnonymousUser()), "SiteNodeVersion.Read", protectedSiteNodeVersionId.toString(), false);
                if(!hasAnonymousUserAccess)
                {
                  anonymousNoAccessWarning = true;
                  snVO.setHasAnonymousUserAccess(false);
                }
              }
             
              if(!skipDisplayName)
              {
                InfoGluePrincipal principal = (InfoGluePrincipal)getInfoGluePrincipal(snVO.getVersionModifier(), db);
                if(principal != null)
                {
                  if(principal.getName().equalsIgnoreCase(principal.getDisplayName()))
                    skipDisplayName = true;
                 
                  snVO.setVersionModifierDisplayName(principal.getDisplayName());
                }
              }
              snVO.setPath(getSiteNodePath(snVO.getSiteNodeId(), db));
            }
            else
              logger.info("Not adding siteNodeVersion..");
          }
         
          commitTransaction(db);
            }
            catch(Exception e)
            {
                logger.error("An error occurred so we should not complete the transaction:" + e);
                logger.warn("An error occurred so we should not complete the transaction:" + e, e);
                rollbackTransaction(db);
                throw new SystemException(e.getMessage());
            }
 
        processBean.updateProcess("Added metadata");

          Collections.sort(contentVersionVOList, Collections.reverseOrder(new ReflectionComparator("modifiedDateTime")));
             
        Set siteNodeVersionVOListSet = new HashSet();
        siteNodeVersionVOListSet.addAll(siteNodeVersionVOList);
        siteNodeVersionVOList.clear();
        siteNodeVersionVOList.addAll(siteNodeVersionVOListSet);
 
          Collections.sort(siteNodeVersionVOList, Collections.reverseOrder(new ReflectionComparator("modifiedDateTime")));
         
          RequestAnalyser.getRequestAnalyser().registerComponentStatistics("ViewListContentVersion end", t.getElapsedTime());
      }
    }
    finally
    {
      processBean.setStatus(ProcessBean.FINISHED);
      processBean.removeProcess();
    }
   
      return "success";
  }
View Full Code Here

  public String doDeleteProcessBean() throws Exception
  {
    if(this.processId != null)
    {
      ProcessBean pb = ProcessBean.getProcessBean(ImportRepositoryAction.class.getName(), processId);
      if(pb != null)
        pb.removeProcess();
    }
   
    return "successRedirectToProcesses";
  }
View Full Code Here

   */
 
  protected String importV3(File file) throws Exception
  {
    String exportId = "Import_" + visualFormatter.formatDate(new Date(), "yyyy-MM-dd_HHmm");
    ProcessBean processBean = ProcessBean.createProcessBean(ImportRepositoryAction.class.getName(), exportId);
   
    OptimizedImportController.importRepositories(file, this.onlyLatestVersions, this.standardReplacement, this.replacements, processBean);
   
    return "successRedirectToProcesses";
  }
View Full Code Here

      if(exportFormat.equalsIgnoreCase("3") || this.exportFormat.equals("3") || requestExportFormat.equals("3"))
      {
        String[] repositories = getRequest().getParameterValues("repositoryId");
       
        String exportId = "Copy_Import_" + visualFormatter.formatDate(new Date(), "yyyy-MM-dd_HHmm");
        ProcessBean processBean = ProcessBean.createProcessBean(ImportRepositoryAction.class.getName(), exportId);
       
        OptimizedExportController.copy(repositories, -1, false, null, processBean, onlyLatestVersions, standardReplacement, replacements);

        return "successRedirectToProcesses";
      }
View Full Code Here

    File file = new File(CmsPropertyHandler.getSQLUpgradePath() + File.separator + "www.infoglue.org.zip");
    if(file == null || !file.exists())
      throw new SystemException("The file upload must have gone bad as no example site was found.");
   
    String exportId = "Import_" + visualFormatter.formatDate(new Date(), "yyyy-MM-dd_HHmm");
    ProcessBean processBean = ProcessBean.createProcessBean(ImportRepositoryAction.class.getName(), exportId);
    try
    {
      OptimizedImportController.importRepositories(file, "false", null, null, processBean);
     
      int count = 0;
      while(processBean.getStatus() != ProcessBean.FINISHED && count < 30)
      {
        Thread.sleep(1000);
        count++;
      }
    }
View Full Code Here

TOP

Related Classes of org.infoglue.cms.applications.databeans.ProcessBean

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.