Package edu.uga.galileo.voci.model

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


        // '/do/...' urls are for admin areas, so we need to check user
        // editing permission for each, and attach that data to the
        // search results
        if ((forwardRequestTo.indexOf("/do/") != -1)
            && (results != null)) {
          WorkflowManager wm = new WorkflowManager();
          ProjectManager pm = new ProjectManager();
          User user = (User) request.getSession()
              .getAttribute("user");
          // if user is null, stick with the default that none of
          // the results is editable
          if (user != null) {
            SearchResult result;
            boolean includeExtras = request
                .getParameter("includeExtras") == null ? false
                : true;
            for (int m = results.size() - 1; m >= 0; m--) {
              result = results.get(m);
              try {
                if (wm.canEdit(user, pm.getProjectHandle(result
                    .getProjectId()), ContentType.valueOf(
                    result.getVBO().getType()).getPlural(),
                    result.getVBO().getId())) {
                  result.setUserEditable(true);
                } else if (!includeExtras) {
View Full Code Here


   * @return <code>true</code> if an admin check was necessary;
   *         <code>false</code> otherwise.
   */
  protected boolean needsAdminCheck(HttpServletRequest request,
      HttpServletResponse response) {
    WorkflowManager wm = new WorkflowManager();
    Command command = (Command) request.getAttribute("command");

    // first, block admin requests in production if that's what's
    // specified in the deployment descriptor
    if (Configuration.getString("serverType").equals("production")
        && (Configuration.getString("adminInProduction")
            .equals("false"))) {
      request
          .setAttribute("errorMessage",
              "Administrative functions are not available in this environment.");
      try {
        request.getRequestDispatcher(
            response.encodeURL("/" + command.getProject()
                + "/Error.jsp")).forward(request, response);
        return true;
      } catch (ServletException e) {
        Logger.warn("Couldn't forward request to the error page", e);
      } catch (IOException e) {
        Logger.warn("Couldn't forward request to the error page", e);
      }
    }

    // now do the real checks
    HttpSession session = request.getSession();
    // check to see if the user's already logged in, and if so,
    // check permissions for the command
    if (session.getAttribute("user") != null) {
      User user = (User) session.getAttribute("user");

      // this is a basic workflow check, and it only makes sure that the
      // user is allowed to perform administration on the requested
      // content type. specific item editing-related checks should be
      // done in the respective servlets.
      if (wm
          .canEdit(user, command.getProject(), command.getCommand(),
              -1)) {
        // user can manage command, so all's well
        Logger.debug("user '" + user.getUserName() + "' is an admin");
        return false;
View Full Code Here

        return "ERROR: Requested session doesn't exist.";
      }

      if (session.getAttribute("user") == null) {
        return "ERROR: You're not logged in.";
      } else if (!(new WorkflowManager().canEdit((User) session
          .getAttribute("user"), command.getProject(), command
          .getCommand(), -1))) {
        return "ERROR: You don't have permission to make this request.";
      }
View Full Code Here

      HttpServletResponse response) {
    User user = (User) request.getSession().getAttribute("user");
    ArrayList<String> errors = new ArrayList<String>();
    HashMap<String, String> fieldMessages = new HashMap<String, String>();
    Command command = (Command) request.getAttribute("command");
    WorkflowManager workflowManager = new WorkflowManager();

    // 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/Community.jsp");
    if (command.isViewCommand()) {
      request.setAttribute("vboType", "Community");
    }

    // 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("items"))) {
      // get the listing of items that belong to this community
      getItemWrappersForNode(command, (User) request.getSession()
          .getAttribute("user"), request);
    } else if ((command.getModifier() != null)
        && (command.getModifier().equals("search"))) {
      // prep for search functions
      setSearchObject(command, new CommunityManager(), request, errors);
    } else if ((command.getModifier() != null)
        && (command.getModifier().equals("open"))) {
      // open nodes in the content tree
      openNodes(command, request, openNodesAttributeName, openNodes);
    } else if ((command.getModifier() != null)
        && (command.getModifier().equals("close"))) {
      // close nodes in the content tree
      closeNodes(command, request, openNodesAttributeName, openNodes);
    } else if (((cancel = request.getParameter("cancelChanges")) != null)
        && (cancel.equals("yes"))) {
      // user has elected to cancel changes made to a form
      request.setAttribute("successMessages",
          "Your changes have been cancelled.");
      int idToCancel = Integer.parseInt(request
          .getParameter("communityId"));
      ContentLockManager.unlockContentByTypeAndID(ContentType.COMMUNITY
          .getValue(), idToCancel);
      goToList = true;
    } else if ((command.getModifier() != null)
        && (command.getModifier().equals("add"))) {
      goToList = handleCommunityAddRequest(request, command, errors,
          user, openNodes, openNodesAttributeName);
    } else if ((command.getModifier() != null)
        && (command.getModifier().equals("update"))
        && (!command.isViewCommand())) {
      goToList = handleCommunityUpdateRequest(request, command, errors,
          user, openNodes, fieldMessages);
    } else if ((command.getModifier() != null)
        && (command.getModifier().equals("view"))
        && (command.isViewCommand())) {
      goToList = handleCommunityViewRequest(request, command);
    } else if ((command.getModifier() != null)
        && (command.getModifier().equals("delete"))) {
      goToList = handleCommunityDeleteRequest(request, command, errors,
          user);
    } else if ((command.getModifier() != null)
        && (command.getModifier().equals("history"))) {
      goToList = handleHistoryRequest(request, command, errors, user);
    }

    Community community = request.getAttribute("community") == null ? null
        : (Community) request.getAttribute("community");

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

   */
  private boolean handleCommunityAddRequest(HttpServletRequest request,
      Command command, ArrayList<String> errors, User user,
      ArrayList<Integer> openNodes, String openNodesAttributeName) {
    CommunityManager communityManager = new CommunityManager();
    WorkflowManager workflowManager = new WorkflowManager();
    Community community = null;

    // user is adding a new community
    boolean goToList = false;
    try {
      community = communityManager.getCommunity(command, -1, false);
      if ((command.getOther() != null)
          && (command.getOther().get(0).equals("to"))) {
        // verify that the user can edit the requested parent
        int parentId = Integer.parseInt(command.getOther().get(1));
        if (!workflowManager.canEdit(user, command.getProject(),
            command.getCommand(), parentId)) {
          errors.add("You don't have permission to add a "
              + "subcommunity to the requested community.");
          goToList = true;
        } else {
View Full Code Here

   */
  private boolean handleCommunityUpdateRequest(HttpServletRequest request,
      Command command, ArrayList<String> errors, User user,
      ArrayList<Integer> openNodes, HashMap<String, String> fieldMessages) {
    CommunityManager communityManager = new CommunityManager();
    WorkflowManager workflowManager = new WorkflowManager();
    Community community = null;

    // user is updating an existing community
    boolean goToList = false;

    int parentId = -1;
    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 "
            + "subcommunity to the requested community.");
        goToList = true;
      } else {
        request.setAttribute("parentId", request
            .getParameter("parentId"));
      }
    }

    // continue processing the update request if no errors have been
    // encountered so far
    if (!goToList) {
      try {
        int communityId;
        boolean isFormSubmission = false;
        if (request.getParameter("communityId") != null) {
          // the id comes from the request if it's a form
          // submission
          communityId = Integer.parseInt(request
              .getParameter("communityId"));
          isFormSubmission = true;
        } else {
          // the id comes from the "other" portion of the command
          // if the user's clicked the community for editing
          communityId = Integer.parseInt(command.getOther().get(0));
        }

        if (communityId == -1) {
          // this is a new community
          try {
            community = communityManager.getCommunity(command, -1,
                false);
          } catch (NoSuchCommunityException e) {
            Logger.error("An empty community couldn't be created.",
                e);
            errors.add("Empty community couldn't be constructed.");
            goToList = true;
          }
        } else {
          // this is an existing community
          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

      HttpServletResponse response) {
    User user = (User) request.getSession().getAttribute("user");
    ArrayList<String> errors = new ArrayList<String>();
    HashMap<String, String> fieldMessages = new HashMap<String, String>();
    Command command = (Command) request.getAttribute("command");
    WorkflowManager workflowManager = new WorkflowManager();

    // 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/Bundle.jsp");
    if (command.isViewCommand()) {
      request.setAttribute("vboType", "Bundle");
    }

    // 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("items"))) {
      // get the listing of items that belong to this bundle
      getItemWrappersForNode(command, (User) request.getSession()
          .getAttribute("user"), request);
    } else if ((command.getModifier() != null)
        && (command.getModifier().equals("search"))) {
      // prep for search functions
      setSearchObject(command, new BundleManager(), request, errors);
    } else if ((command.getModifier() != null)
        && (command.getModifier().equals("open"))) {
      // open nodes in the content tree
      openNodes(command, request, openNodesAttributeName, openNodes);
    } else if ((command.getModifier() != null)
        && (command.getModifier().equals("close"))) {
      // close nodes in the content tree
      closeNodes(command, request, openNodesAttributeName, openNodes);
    } else if (((cancel = request.getParameter("cancelChanges")) != null)
        && (cancel.equals("yes"))) {
      // user has elected to cancel changes made to a form
      request.setAttribute("successMessages",
          "Your changes have been cancelled.");
      int idToCancel = Integer.parseInt(request.getParameter("bundleId"));
      ContentLockManager.unlockContentByTypeAndID(ContentType.COMMUNITY
          .getValue(), idToCancel);
      goToList = true;
    } else if ((command.getModifier() != null)
        && (command.getModifier().equals("add"))) {
      goToList = handleBundleAddRequest(request, command, errors, user,
          openNodes, openNodesAttributeName);
    } else if ((command.getModifier() != null)
        && (command.getModifier().equals("delete"))) {
      goToList = handleBundleDeleteRequest(request, command, errors, user);
    } else if ((command.getModifier() != null)
        && (command.getModifier().equals("update"))
        && (!command.isViewCommand())) {
      goToList = handleBundleUpdateRequest(request, command, errors,
          user, openNodes, fieldMessages);
    } else if ((command.getModifier() != null)
        && (command.getModifier().equals("view"))
        && (command.isViewCommand())) {
      goToList = handleBundleViewRequest(request, command);
    } else if ((command.getModifier() != null)
        && (command.getModifier().equals("history"))) {
      goToList = handleHistoryRequest(request, command, errors, user);
    }

    Bundle bundle = request.getAttribute("bundle") == null ? null
        : (Bundle) request.getAttribute("bundle");

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

   */
  private boolean handleBundleAddRequest(HttpServletRequest request,
      Command command, ArrayList<String> errors, User user,
      ArrayList<Integer> openNodes, String openNodesAttributeName) {
    BundleManager bundleManager = new BundleManager();
    WorkflowManager workflowManager = new WorkflowManager();
    Bundle bundle = null;

    boolean goToList = false;
    try {
      bundle = bundleManager.getBundle(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 "
              + "bundle to the requested object.");
          goToList = true;
        } else {
View Full Code Here

   * @return <code>true</code>.
   */
  public boolean handleBundleDeleteRequest(HttpServletRequest request,
      Command command, ArrayList<String> errors, User user) {
    BundleManager bundleManager = new BundleManager();
    WorkflowManager workflowManager = new WorkflowManager();
    Bundle bundle = null;

    try {
      int bundleId = Integer.parseInt(command.getOther().get(0));
      if (!workflowManager.canEdit(user, command.getProject(), command
          .getCommand(), bundleId)) {
        errors.add("You don't have permission to delete "
            + "the requested bundle.");
      } else {
        try {
View Full Code Here

   */
  private boolean handleBundleUpdateRequest(HttpServletRequest request,
      Command command, ArrayList<String> errors, User user,
      ArrayList<Integer> openNodes, HashMap<String, String> fieldMessages) {
    BundleManager bundleManager = new BundleManager();
    WorkflowManager workflowManager = new WorkflowManager();
    Bundle bundle = null;

    int parentId = -1;
    boolean 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 "
            + "bundle to the requested object.");
        goToList = true;
      } else {
        request.setAttribute("parentId", request
            .getParameter("parentId"));
      }
    }

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

        if (bundleId == -1) {
          // this is a new bundle
          try {
            bundle = bundleManager.getBundle(command, -1, false);
          } catch (NoSuchBundleException e) {
            Logger.error("An empty bundle couldn't be created.", e);
            errors.add("Empty bundle couldn't be constructed.");
            goToList = true;
          }
        } else {
          // this is an existing bundle
          // first make sure that the user can edit it
          if (!workflowManager.canEdit(user, command.getProject(),
              command.getCommand(), bundleId)) {
            errors.add("You don't have permission to edit "
                + "the requested bundle.");
            goToList = true;
          } else {
View Full Code Here

TOP

Related Classes of edu.uga.galileo.voci.model.WorkflowManager

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.