Package edu.uga.galileo.voci.bo

Examples of edu.uga.galileo.voci.bo.Bundle


      collection.setActive(active);
      vbo = collection;
    }
    if (type == ContentType.BUNDLE)
    {
      Bundle bundle = new Bundle();
      bundle.setBundleId(-1);
      bundle.setProjectId(projectId);
      bundle.setActive(active);
      vbo = bundle;
    }
    if (type == ContentType.ITEM)
    {
      Item item = new Item();
View Full Code Here


    } 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;
    }

    if (errors.size() > 0) {
      request.setAttribute("errorMessage", generateErrorMessage(errors));
    }

    if (fieldMessages.size() > 0) {
      request.setAttribute("fieldMessages", fieldMessages);
    }

    if (goToList) {
      // the request dispatcher's forward method strips anchors, so we
      // set page target here and let the ContentList.jsp handle it
      // in the body tag's onload event.
      if (bundle != null) {
        request.setAttribute("jumpToTarget", "#node"
            + bundle.getBundleId());
      }

      ArrayList<VBOTreeNodeWrapper> tree = TreeManager.getInstance()
          .getTreeNodeWrappers(command.getProject(), openNodes,
              command.isViewCommand() ? true : false, -1,
              (User) request.getSession().getAttribute("user"));
      request.setAttribute("tree", tree);

      // if this is from a search, flag it as such for the ContentList.jsp
      // page
      if (request.getParameter("fs") != null) {
        command.setModifier("search");
        ArrayList<String> other = new ArrayList<String>();
        other.add("results");
        command.setOther(other);
      }

      try {
        request.getRequestDispatcher(
            response.encodeURL(contentListPage)).forward(request,
            response);
      } catch (ServletException e) {
        Logger.error("Couldn't forward request to " + contentListPage,
            e);
      } catch (IOException e) {
        Logger.error("Couldn't forward request to " + contentListPage,
            e);
      }
    } else {
      ArrayList<GUIElement> guiElements = bundle.getGUIElements();
      String addToRepeatables = request.getParameter("addToRepeatables");
      if ((addToRepeatables != null)
          && (addToRepeatables.trim().length() > 0)) {
        for (GUIElement guiElem : guiElements) {
          if (guiElem.getName().equals(addToRepeatables)) {
            guiElem.setRepeatableElementsToAdd(3);
            request.setAttribute("isDirty", "t");
            break;
          }
        }
      }
      request.setAttribute("elements", guiElements);

      request.setAttribute(command.isViewCommand() ? "vbo" : "bundle",
          bundle);
      ArrayList<AuditLog> historyRecords = (new AuditLogManager())
          .getUpdateRecords(
              ((HashMap<String, Project>) getServletContext()
                  .getAttribute("projectMap")).get(
                  command.getProject()).getProjectId(),
              ContentType.BUNDLE, bundle.getBundleId());
      if ((historyRecords != null) && (historyRecords.size() > 0)) {
        request.setAttribute("history", historyRecords);
      }

      try {
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)
View Full Code Here

   */
  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)) {
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 {
            try {
              bundle = bundleManager.getBundleForUpdate(command,
                  bundleId, false, request.getSession());
            } catch (NoSuchBundleException e) {
              Logger.warn("Requested bundle (" + bundleId
                  + ") couldn't be retrieved", e);
              errors.add("Requested bundle (" + bundleId
                  + ") couldn't be retrieved");
              goToList = true;
            } catch (ContentLockedException e) {
              errors.add(e.getMessage());
              goToList = true;
            }
          }
        }

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

          populateVBOFromRequest(bundle, request, fieldMessages, true);

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

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

            if ((errors.size() == 0) && (fieldMessages.size() == 0)) {
              try {
                if (bundle.getId() == -1) {
                  bundleManager.addBundle(user, bundle,
                      parentId);
                  request.setAttribute("successMessage",
                      "Bundle successfully added.");
                } else {
                  bundleManager.updateBundle(bundle,
                      ((User) request.getSession()
                          .getAttribute("user")),
                      oldData);
                  request
                      .setAttribute(
                          "successMessage",
                          "Bundle '"
                              + bundle
                                  .getMetadataBasedTitle()
                              + "' successfully updated.");
                  if ((request.getParameter("fs") != null)
                      && (request.getSession()
                          .getAttribute(
                              "searchResults") != null)) {
                    SearchManager
                        .updateSessionSearchResults(
                            request, bundle);
                  }
                }

                goToList = true;
              } catch (NoSuchBundleException e) {
                Logger.warn("Bundle " + bundle.getBundleId()
                    + " couldn't be found for update", e);
                errors.add(e.getMessage());
              } catch (SQLException e) {
                Logger
                    .error(
View Full Code Here

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

    boolean goToList = false;

    String[] vals = command.getOther().get(0).split("\\|");
    AuditLogManager alm = new AuditLogManager();
    int bundleId = -1;
    try {
      bundleId = Integer.parseInt(vals[2]);
      if (!workflowManager.canEdit(user, command.getProject(), command
          .getCommand(), bundleId)) {
        errors.add("You don't have permission to edit "
            + "the requested bundle.");
        goToList = true;
      } else {
        AuditLog record = alm.getRecord(Integer.parseInt(vals[0]),
            ContentType.valueOf(Integer.parseInt(vals[1])),
            (bundleId = Integer.parseInt(vals[2])), Timestamp
                .valueOf(vals[3]));
        String data = record.getDataExport();
        bundle = new Bundle();
        bundle.fromString(data);
      }
    } catch (NullPointerException e) {
      goToList = true;
      errors.add("Invalid history request format.");
    } catch (NumberFormatException e) {
View Full Code Here

   *         <code>false</code> if all's well.
   */
  public boolean handleBundleViewRequest(HttpServletRequest request,
      Command command) {
    BundleManager bundleManager = new BundleManager();
    Bundle bundle = null;
    boolean goToList = false;
    try {
      bundle = bundleManager.getBundle(command, Integer.parseInt(command
          .getOther().get(0)), true);
    } catch (NumberFormatException e) {
View Full Code Here

   *             If no matching bundle is found.
   */
  public Bundle getBundle(Command command, int bundleId,
      boolean mustBeActive, boolean addMetadata)
      throws NoSuchBundleException {
    Bundle bundle;

    int projectId;
    try {
      projectId = (new ProjectManager()).getProjectID(command
          .getProject());
    } catch (NoSuchProjectException e) {
      throw new NoSuchBundleException("The project associated with this "
          + "bundle couldn't be found.");
    }

    if (bundleId == -1) {
      bundle = new Bundle();
      bundle.setBundleId(-1);
      bundle.setProjectId(projectId);
    } else {
      bundle = bdao.getBundle(bundleId, projectId);
    }

    if ((mustBeActive) && (!bundle.isActive())) {
      throw new NoSuchBundleException("No matching, active bundle found.");
    }

    if (addMetadata) {
      metadataManager.populateVBOWithMetadata(bundle);
View Full Code Here

   *             If the element is locked by another user.
   */
  public Bundle getBundleForUpdate(Command command, int bundleId,
      boolean mustBeActive, HttpSession session)
      throws NoSuchBundleException, ContentLockedException {
    Bundle bundle = getBundle(command, bundleId, mustBeActive);
    ContentLockManager.lockContentToSession(bundle, session);
    return bundle;
  }
View Full Code Here

TOP

Related Classes of edu.uga.galileo.voci.bo.Bundle

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.