Examples of WorkflowManager


Examples of edu.uga.galileo.voci.model.WorkflowManager

   *         <code>false</code> if all's well.
   */
  public boolean handleHistoryRequest(HttpServletRequest request,
      Command command, ArrayList<String> errors, User user) {
    CollectionManager collectionManager = new CollectionManager();
    WorkflowManager workflowManager = new WorkflowManager();
    Collection collection = null;
    boolean goToList = false;

    String[] vals = command.getOther().get(0).split("\\|");
    AuditLogManager alm = new AuditLogManager();
    int collectionId = -1;
    try {
      collectionId = Integer.parseInt(vals[2]);
      if (!workflowManager.canEdit(user, command.getProject(), command
          .getCommand(), collectionId)) {
        errors.add("You don't have permission to edit "
            + "the requested collection.");
        goToList = true;
      } else {
View Full Code Here

Examples of edu.uga.galileo.voci.model.WorkflowManager

  @Override
  protected void handleRequest(HttpServletRequest request,
      HttpServletResponse response) {
    Command command = (Command) request.getAttribute("command");
    ItemManager itemManager = new ItemManager();
    WorkflowManager workflowManager = new WorkflowManager();
    User user = (User) request.getSession().getAttribute("user");
    ArrayList<String> errors = new ArrayList<String>();
    HashMap<String, String> fieldMessages = new HashMap<String, String>();
    Item item = null;
    boolean updated = false;

    // handle the "view vs. admin"-specific changes
    String openNodesAttributeName = command.isViewCommand() ? "openViewNodes"
        : "openTreeNodes";
    String contentListPage = "/"
        + command.getDisplayProject()
        + (command.isViewCommand() ? "/Content.jsp"
            : "/admin/ContentList.jsp");
    String vboViewPage = "/"
        + command.getDisplayProject()
        + (command.isViewCommand() ? "/VBODisplay.jsp"
            : "/admin/Item.jsp");
    if (command.isViewCommand()) {
      request.setAttribute("vboType", "Item");
    }

    // then do the regular page processing
    ArrayList<Integer> openNodes = (ArrayList<Integer>) request
        .getSession().getAttribute(openNodesAttributeName);
    if (openNodes == null) {
      openNodes = new ArrayList<Integer>();
    }

    boolean goToList = true;
    String cancel;

    if ((command.getModifier() != null)
        && (command.getModifier().equals("search"))) {
      // prep for search functions
      setSearchObject(command, new ItemManager(), request, errors);
    } else if ((command.getModifier() != null)
        && (command.getModifier().equals("open"))) {
      // open nodes in the content tree
      openNodes(command, request, "openTreeNodes", openNodes);
    } else if ((command.getModifier() != null)
        && (command.getModifier().equals("close"))) {
      // close nodes in the content tree
      closeNodes(command, request, "openTreeNodes", openNodes);
    } else if (((cancel = request.getParameter("cancelChanges")) != null)
        && (cancel.equals("yes"))) {
      // user is canceling changes made to the item edit form
      request.setAttribute("successMessages",
          "Your changes have been cancelled.");
      int idToCancel = Integer.parseInt(request.getParameter("itemId"));
      ContentLockManager.unlockContentByTypeAndID(ContentType.ITEM
          .getValue(), idToCancel);
      goToList = true;
    } else if ((command.getModifier() != null)
        && (command.getModifier().equals("add"))) {
      // user has requested an item to add
      goToList = false;
      try {
        item = itemManager.getItem(command, -1, false);
        if ((command.getOther() != null)
            && (command.getOther().get(0).equals("to"))) {
          int parentId = Integer.parseInt(command.getOther().get(1));
          // verify that the user can edit the requested parent
          if (!workflowManager.canEdit(user, command.getProject(),
              command.getCommand(), parentId)) {
            errors.add("You don't have permission to add a "
                + "item to the requested object.");
            goToList = true;
          } else {
            try {
              ContentType parentType = DAOFactory.getHelperDAO()
                  .getContentTypeById(parentId);
              if (parentType != ContentType.ITEM) {
                if (!openNodes.contains(parentId)) {
                  openNodes.add(parentId);
                  request.getSession().setAttribute(
                      "openTreeNodes", openNodes);
                }
                request.setAttribute("parentId", String
                    .valueOf(parentId));
              } else {
                errors.add("You can't add a bundle to "
                    + "the requested element type.");
                goToList = true;
              }
            } catch (NoAvailableDAOException e) {
              Logger.fatal("Couldn't get helper DAO", e);
              errors
                  .add("A fatal internal error has occurred.  "
                      + "Please contact the system administrator.");
              goToList = true;
            }
          }
        } else {
          errors
              .add("An item must be added to a parent collection or community.");
        }
      } catch (NoSuchItemException e) {
        Logger.error("An empty item couldn't be created.", e);
        errors.add("Empty item couldn't be constructed.");
        goToList = true;
      }
    } else if ((command.getModifier() != null)
        && (command.getModifier().equals("delete"))) {
      // user is deleting an item
      try {
        int itemId = Integer.parseInt(command.getOther().get(0));
        if (!workflowManager.canEdit(user, command.getProject(),
            command.getCommand(), itemId)) {
          errors.add("You don't have permission to delete "
              + "the requested item.");
        } else {
          try {
            item = itemManager.getItemForUpdate(command, itemId,
                false, request.getSession());
            itemManager.deleteItem(item, ((User) request
                .getSession().getAttribute("user")));
            updated = true;
            request.setAttribute("successMessage", "Item " + itemId
                + " successfully deleted.");
          } catch (NoSuchItemException e) {
            errors.add("The item to delete either doesn't exist, "
                + "or it isn't empty and can't be deleted.");
          } catch (SQLException e) {
            Logger.error("Couldn't delete item.", e);
            errors
                .add("A database error occurred processing your request.");
          } catch (ContentLockedException e) {
            errors.add(e.getMessage());
          }
        }
      } catch (NumberFormatException e) {
        errors.add("Invalid item ID format.");
      } catch (NullPointerException e) {
        errors.add("Invalid item ID format.");
      }
      goToList = true;
    } else if ((command.getModifier() != null)
        && (command.getModifier().equals("view"))
        && (command.isViewCommand())) {
      // user is requesting a page from the public face
      goToList = false;

      try {
        item = itemManager.getItem(command, Integer.parseInt(command
            .getOther().get(0)), true);
      } catch (NumberFormatException e) {
        Logger.warn("Couldn't get requested item: "
            + command.getOther() == null ? "{null}" : command
            .getOther().get(0));
        goToList = true;
      } catch (NoSuchItemException e) {
        Logger.warn("Couldn't get requested item: "
            + command.getOther() == null ? "{null}" : command
            .getOther().get(0));
        goToList = true;
      }

      if (item != null) {
        request.setAttribute("vbo", item);
        int resultsPerPage = Configuration.getInt("publicItemsPerPage");
        request.setAttribute("resultsPerPage", resultsPerPage);
        request
            .setAttribute("crumbSet", TreeManager.getInstance()
                .getBreadCrumbsForVBO(command.getProject(),
                    item, true));
      }
    } else if ((command.getModifier() != null)
        && (command.getModifier().equals("update"))
        && (!command.isViewCommand())) {
      // user has requested a document to update, or has submitted an
      // update to a document from the form
      if ((command.getOther() != null) && (command.getOther().size() > 1)) {
        request.getSession().setAttribute("itemListStart",
            command.getOther().get(1));
        request.getSession().setAttribute("itemListCount",
            command.getOther().get(2));
        request.getSession().setAttribute("itemListParent",
            command.getOther().get(3));
      }

      int parentId = -1;
      goToList = false;
      if (request.getParameter("parentId") != null) {
        parentId = Integer.parseInt(request.getParameter("parentId"));
        // verify that the user can edit the requested parent
        if (!workflowManager.canEdit(user, command.getProject(),
            command.getCommand(), parentId)) {
          errors.add("You don't have permission to add a "
              + "item to the requested object.");
          goToList = true;
        } else {
          request.setAttribute("parentId", request
              .getParameter("parentId"));
        }
      }

      if (!goToList) {
        try {
          int itemId;
          boolean isFormSubmission = false;
          if (request.getParameter("itemId") != null) {
            // the id comes from the request if it's a form
            // submission
            itemId = Integer.parseInt(request
                .getParameter("itemId"));
            isFormSubmission = true;
          } else {
            // the id comes from the "other" portion of the command
            // if the user's clicked the item for editing
            itemId = Integer.parseInt(command.getOther().get(0));
          }

          if (itemId == -1) {
            // this is a new item
            try {
              item = itemManager.getItem(command, -1, false);
            } catch (NoSuchItemException e) {
              Logger.error("An empty item couldn't be created.",
                  e);
              errors.add("Empty item couldn't be constructed.");
              goToList = true;
            }
          } else {
            // this is an existing item
            // first make sure that the user can edit it
            if (!workflowManager.canEdit(user,
                command.getProject(), command.getCommand(),
                itemId)) {
              errors.add("You don't have permission to edit "
                  + "the requested item.");
              goToList = true;
            } else {
              try {
                item = itemManager.getItemForUpdate(command,
                    itemId, false, request.getSession());
              } catch (NoSuchItemException e) {
                Logger.warn("Requested item (" + itemId
                    + ") couldn't be retrieved", e);
                errors.add("Requested item (" + itemId
                    + ") couldn't be retrieved");
                goToList = true;
              } catch (ContentLockedException e) {
                errors.add(e.getMessage());
                goToList = true;
              }
            }
          }

          if ((isFormSubmission) && (item != null)) {
            String oldData = item.toString();

            populateVBOFromRequest(item, request, fieldMessages,
                true);

            String addToRepeatables = request
                .getParameter("addToRepeatables");
            if ((addToRepeatables == null)
                || (addToRepeatables.trim().length() == 0)) {

              if (oldData.equals(item.toString())) {
                errors.add("No changes detected.");
              }

              if ((errors.size() == 0)
                  && (fieldMessages.size() == 0)) {
                try {
                  if (item.getId() == -1) {
                    itemManager.addItem(user, item,
                        parentId);
                    request.setAttribute("successMessage",
                        "Item successfully added.");
                  } else {
                    itemManager.updateItem(item,
                        ((User) request.getSession()
                            .getAttribute("user")),
                        oldData);
                    updated = true;
                    request
                        .setAttribute(
                            "successMessage",
                            "Item '"
                                + item
                                    .getMetadataBasedTitle()
                                + "' successfully updated.");
                    if ((request.getParameter("fs") != null)
                        && (request
                            .getSession()
                            .getAttribute(
                                "searchResults") != null)) {
                      SearchManager
                          .updateSessionSearchResults(
                              request, item);
                    }
                  }

                  goToList = true;
                } catch (NoSuchItemException e) {
                  Logger.warn("Item " + item.getItemId()
                      + " couldn't be found for update",
                      e);
                  errors.add(e.getMessage());
                } catch (SQLException e) {
                  Logger
                      .error(
                          "Couldn't add an item to the database",
                          e);
                  errors
                      .add("A database problem occurred while updating your item: "
                          + e.getMessage());
                }
              }
            }
          }

          request.setAttribute("item", item);
        } catch (NumberFormatException e) {
          errors.add("Invalid item ID");
          goToList = true;
        }

        if (fieldMessages.size() != 0) {
          String plural = "";
          if (fieldMessages.size() > 1) {
            plural = "s";
          }
          errors.add("Form field" + plural
              + " failed validation (see below).");
        }
      }
    } else if ((command.getModifier() != null)
        && (command.getModifier().equals("history"))) {
      // user is requesting an old item record from the audit log
      goToList = false;

      String[] vals = command.getOther().get(0).split("\\|");
      AuditLogManager alm = new AuditLogManager();
      int itemId = -1;
      try {
        itemId = Integer.parseInt(vals[2]);
        if (!workflowManager.canEdit(user, command.getProject(),
            command.getCommand(), itemId)) {
          errors.add("You don't have permission to edit "
              + "the requested item.");
          goToList = true;
        } else {
          AuditLog record = alm.getRecord(Integer.parseInt(vals[0]),
              ContentType.valueOf(Integer.parseInt(vals[1])),
              (itemId = Integer.parseInt(vals[2])), Timestamp
                  .valueOf(vals[3]));
          String data = record.getDataExport();
          item = new Item();
          item.fromString(data);
        }
      } catch (NullPointerException e) {
        goToList = true;
        errors.add("Invalid history request format.");
      } catch (NumberFormatException e) {
        goToList = true;
        errors.add("Invalid history request format.");
      } catch (NoSuchAuditLogRecordException e) {
        errors.add("The history record requested couldn't be located.");
      } catch (DataTypeMismatchException e) {
        Logger.error("Data type mismatch occurred pulling "
            + command.getOther().get(0) + " from the audit log", e);
        errors
            .add("A system error was encountered (DataTypeMismatch). "
                + "Please contact a system administrator.");
      }

      if (!goToList) {
        if (item == null) {
          try {
            item = itemManager.getItem(command, itemId, false);
          } catch (NoSuchItemException e) {
            goToList = true;
            errors.add("No such item (" + itemId + ") found.");
          }
        }
      }

      request.setAttribute("isDirty", "t");
    }

    // one last permissions check if we're on our way to the edit page
    if ((item != null)
        && (!command.isViewCommand())
        && (errors.size() == 0)
        && (fieldMessages.size() == 0)
        && (!goToList)
        && (!workflowManager.canEdit(user, command.getProject(),
            command.getCommand(), item.getItemId()))) {
      errors.add("You don't have permission to "
          + "work on the requested content.");
      goToList = true;
    }
View Full Code Here

Examples of edu.uga.galileo.voci.model.WorkflowManager

   * @return <code>true</code>.
   */
  public boolean handleCommunityDeleteRequest(HttpServletRequest request,
      Command command, ArrayList<String> errors, User user) {
    CommunityManager communityManager = new CommunityManager();
    WorkflowManager workflowManager = new WorkflowManager();
    Community community = null;

    // user is deleting a community
    try {
      int communityId = Integer.parseInt(command.getOther().get(0));
      // first check permissions
      if (!workflowManager.canEdit(user, command.getProject(), command
          .getCommand(), communityId)) {
        errors.add("You don't have permission to delete "
            + "the requested community.");
      } else {
        try {
View Full Code Here

Examples of edu.uga.galileo.voci.model.WorkflowManager

   *         <code>false</code> if all's well.
   */
  public boolean handleHistoryRequest(HttpServletRequest request,
      Command command, ArrayList<String> errors, User user) {
    CommunityManager communityManager = new CommunityManager();
    WorkflowManager workflowManager = new WorkflowManager();
    Community community = null;

    // user is requesting a previous revision to a community
    boolean goToList = false;

    String[] vals = command.getOther().get(0).split("\\|");
    AuditLogManager alm = new AuditLogManager();
    int communityId = -1;
    try {
      communityId = Integer.parseInt(vals[2]);
      if (!workflowManager.canEdit(user, command.getProject(), command
          .getCommand(), communityId)) {
        errors.add("You don't have permission to edit "
            + "the requested community.");
        goToList = true;
      } else {
View Full Code Here

Examples of gri.tasks.managers.workflows.WorkflowManager

    public static void testWorkflow() throws Exception {
 
  //Create Manager:
  TaskProvider taskProvider = loadTaskProvider();
  //WorkflowManager wkflManager = createLocalWorkflowManager(taskProvider);
  WorkflowManager wkflManager = createRemoteWorkflowManager(taskProvider);
 
  //Define workflow:
  //WorkflowSubmission wkfl = createSimpleWorkflow();
  WorkflowSubmission wkfl = createFileWorkflow();
 
  //Execute:
  String id = wkflManager.submitWorkflow(wkfl);
  while (wkflManager.getWorkflowInfo(id).getStatus() != JobManager.COMPLETE) {
      System.out.println("Running...");
     
      try {
    Thread.sleep(200);
      }
      catch(Exception e) {};
  }
 
  System.out.println("Complete");
 
  //Print outputs:
  Map outputs1 = wkflManager.getWorkflowOutputs(id, 0);
  Map outputs2 = wkflManager.getWorkflowOutputs(id, 1);
 
  System.out.println("OUTPUT 1: " + String.valueOf(outputs1));
  System.out.println("OUTPUT 2: " + String.valueOf(outputs2));
 
  //Free workflow:
  wkflManager.freeWorkflow(id);
 
  System.out.println();
  System.out.println(wkflManager.listWorkflows().length + " workflows remain");
 
    }
View Full Code Here

Examples of gri.tasks.managers.workflows.WorkflowManager

     * WorkflowManagerService to another WorkflowManager.  This imitates the
     * way in which a remote system would act as all messages pass through
     * the service tunnel as XML.
     */
    protected static WorkflowManager createRemoteWorkflowManager(TaskProvider taskProvider) throws Exception {
        WorkflowManager localManager = createLocalWorkflowManager(taskProvider);
 
        File baseDir = new File("C:\\GRIDP_EXEC");
  SimpleJobFolderFactory jobFolderFactory = new SimpleJobFolderFactory(baseDir);
 
        WorkflowManagerServiceImpl webService = new WorkflowManagerServiceImpl(localManager, new BasicSerializerSet(), jobFolderFactory);
View Full Code Here

Examples of gri.tasks.managers.workflows.WorkflowManager

        try {
           
            //parse input:
            Element rootElem = xmlUtil.parseXML(xml).getRootElement();
           
            WorkflowManager wkflManager = getWorkflowManager();
           
            Map config = new HashMap();
            config.put("TASK_INFO_MANAGER", wkflManager);
            config.put("WORKFLOW_MANAGER", wkflManager);
            config.put("WORKFLOW_MANAGER_SERVICE", this);
            config.put("WORKING_DIRECTORY", workDir);
                  
            WorkflowSubmissionSerializer wkflSerializer = serializers
                .getWorkflowSerializerSet(wkflManager)
                .getWorkflowSubmissionSerializer(config);
           
            WorkflowSubmission wkfl = wkflSerializer.readWorkflow(rootElem);
            wkfl.setContextParam("WORKING_DIRECTORY", workDir);

            List jobs = wkfl.getJobs();
            for (int i=0; i<jobs.size(); i++) {
          JobSubmission job = (JobSubmission)jobs.get(i);
         
          String jobId = "job_" + (i+1);
          File subWorkDir = new File(workDir, jobId);
         
          job.setContextParam("WORKING_DIRECTORY", subWorkDir);
            }
           
            //submit:
            String wkflId = wkflManager.submitWorkflow(wkfl);
            logger.debug("Workflow submitted: " + wkflId);
           
            RunningJobInfo jobInfo = new RunningJobInfo(wkflId, null, workDir);
            jobInfoManager.storeJobInfo(jobInfo);
View Full Code Here

Examples of gri.tasks.managers.workflows.WorkflowManager

  int jobIndex = Integer.parseInt(req.getParameter("JOB_INDEX"));
 
  //process:
  try {
     
      WorkflowManager wkflManager = getWorkflowManager();
      WorkflowInfo wkflInfo = wkflManager.getWorkflowInfo(wkflId);
      String taskId = wkflInfo.getJobInfo(jobIndex).getTaskId();
     
      RunningJobInfo jobInfo = jobInfoManager.getJobInfo(wkflId);
                
            //create serializer config:
            Map config = new HashMap();
           
            config.putAll(req.getParameters())//do first (so user can't overwrite following params)
           
            config.put("WORKFLOW_MANAGER", wkflManager);
            config.put("WORKFLOW_MANAGER_SERVICE", this);
            config.put("WORKFLOW_ID", req.getJobId());
            config.put("WORKFLOW_ID", wkflId);
            config.put("WORKING_DIRECTORY", jobInfo.getWorkingDirectory())//TODO: this is wrong
           
           
            JDOMSerializer paramSerializer = serializers
              .getWorkflowSerializerSet(wkflManager)
              .getOutputParameterSerializer(jobIndex, taskId, config);
           
            //serialize:
            Map outputs = wkflManager.getWorkflowOutputs(wkflId, jobIndex);
           
            Element elem = new Element("outputs");
            paramSerializer.write(outputs, elem);
            return xmlUtil.writeXML(elem);
        }
View Full Code Here

Examples of org.apache.lenya.workflow.WorkflowManager

     * @see org.apache.lenya.cms.usecase.AbstractUsecase#initParameters()
     */
    protected void initParameters() {
        super.initParameters();

        WorkflowManager resolver = null;
        try {
            Document doc = getSourceDocument();
            if (doc != null) {
                // read parameters from Dublin Core meta-data
                MetaData dc = doc.getMetaData(DublinCore.DC_NAMESPACE);
                setParameter(DublinCore.ELEMENT_TITLE, dc.getFirstValue(DublinCore.ELEMENT_TITLE));
                setParameter(DublinCore.ELEMENT_DESCRIPTION, dc
                        .getFirstValue(DublinCore.ELEMENT_DESCRIPTION));

                // read parameters from document attributes
                setParameter(LANGUAGES, doc.getLanguages());
                SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss Z");
                String lastModified = format
                        .format(new Date(getSourceDocument().getLastModified()));
                setParameter(LASTMODIFIED, lastModified);
                boolean visible = doc.getLink().getNode().isVisible();
                setParameter(VISIBLE_IN_NAVIGATION, Boolean.valueOf(visible));

                Workflowable workflowable = WorkflowUtil.getWorkflowable(this.manager,
                        getSession(), getLogger(), doc);
                resolver = (WorkflowManager) this.manager.lookup(WorkflowManager.ROLE);
                if (resolver.hasWorkflow(workflowable)) {
                    Workflow workflow = resolver.getWorkflowSchema(workflowable);
                    String[] variableNames = workflow.getVariableNames();
                    Version latestVersion = workflowable.getLatestVersion();
                    Boolean isLive = null;
                    if (latestVersion != null) {
                        setParameter(STATE, latestVersion.getState());
View Full Code Here

Examples of org.apache.lenya.workflow.WorkflowManager

     */
    public Object getAttribute(String name, Configuration modeConf, Map objectModel)
            throws ConfigurationException {

        Object value = null;
        WorkflowManager wfManager = null;

        try {
            PageEnvelope envelope = getEnvelope(objectModel, name);
            Document document = envelope.getDocument();
            if (document != null && document.exists()) {
                wfManager = (WorkflowManager) this.manager.lookup(WorkflowManager.ROLE);
                Session session = RepositoryUtil.getSession(this.manager,
                        ObjectModelHelper.getRequest(objectModel));
                Workflowable workflowable = WorkflowUtil.getWorkflowable(this.manager,
                        session,
                        getLogger(),
                        document);
                if (wfManager.hasWorkflow(workflowable)) {

                    Version latestVersion = workflowable.getLatestVersion();

                    if (name.equals(STATE)) {
                        if (latestVersion == null) {
                            Workflow workflow = wfManager.getWorkflowSchema(workflowable);
                            value = workflow.getInitialState();
                        } else {
                            value = latestVersion.getState();
                        }
                    } else if (name.startsWith(VARIABLE_PREFIX)) {
                        String variableName = name.substring(VARIABLE_PREFIX.length());
                        Workflow workflow = wfManager.getWorkflowSchema(workflowable);
                        String[] variableNames = workflow.getVariableNames();
                        if (Arrays.asList(variableNames).contains(variableName)) {
                            if (latestVersion == null) {
                                value = Boolean.valueOf(workflow.getInitialValue(variableName));
                            } else {
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.