Package edu.uga.galileo.voci.bo

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


    } else if ((command.getModifier() != null)
        && (command.getModifier().equals("history"))) {
      goToList = handleHistoryRequest(request, command, errors, user);
    }

    Collection collection = request.getAttribute("collection") == null ? null
        : (Collection) request.getAttribute("collection");

    // one last permissions check if we're on our way to the edit page
    if ((collection != null)
        && (!command.isViewCommand())
        && (errors.size() == 0)
        && (fieldMessages.size() == 0)
        && (!goToList)
        && (!workflowManager.canEdit(user, command.getProject(),
            command.getCommand(), collection.getCollectionId()))) {
      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 (collection != null) {
        request.setAttribute("jumpToTarget", "#node"
            + collection.getCollectionId());
      }

      if ((command.getModifier() == null)
          || (!command.getModifier().equals("search"))) {
        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 = collection.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" : "collection", collection);
      ArrayList<AuditLog> historyRecords = (new AuditLogManager())
          .getUpdateRecords(
              ((HashMap<String, Project>) getServletContext()
                  .getAttribute("projectMap")).get(
                  command.getProject()).getProjectId(),
              ContentType.COLLECTION, collection
                  .getCollectionId());
      if ((historyRecords != null) && (historyRecords.size() > 0)) {
        request.setAttribute("history", historyRecords);
      }
View Full Code Here


  private boolean handleCollectionAddRequest(HttpServletRequest request,
      Command command, ArrayList<String> errors, User user,
      ArrayList<Integer> openNodes, String openNodesAttributeName) {
    CollectionManager collectionManager = new CollectionManager();
    WorkflowManager workflowManager = new WorkflowManager();
    Collection collection = null;

    boolean goToList = false;
    try {
      collection = collectionManager.getCollection(command, -1, false);
      if ((command.getOther() != null)
View Full Code Here

  private boolean handleCollectionUpdateRequest(HttpServletRequest request,
      Command command, ArrayList<String> errors, User user,
      ArrayList<Integer> openNodes, HashMap<String, String> fieldMessages) {
    CollectionManager collectionManager = new CollectionManager();
    WorkflowManager workflowManager = new WorkflowManager();
    Collection collection = 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 "
            + "collection to the requested object.");
        goToList = true;
      } else {
        request.setAttribute("parentId", request
            .getParameter("parentId"));
      }
    }

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

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

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

          populateVBOFromRequest(collection, request, fieldMessages,
              true);

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

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

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

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

   */
  public boolean handleCollectionDeleteRequest(HttpServletRequest request,
      Command command, ArrayList<String> errors, User user) {
    CollectionManager collectionManager = new CollectionManager();
    WorkflowManager workflowManager = new WorkflowManager();
    Collection collection = null;

    try {
      int collectionId = Integer.parseInt(command.getOther().get(0));
      if (!workflowManager.canEdit(user, command.getProject(), command
          .getCommand(), collectionId)) {
View Full Code Here

   */
  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 {
        AuditLog record = alm.getRecord(Integer.parseInt(vals[0]),
            ContentType.valueOf(Integer.parseInt(vals[1])),
            (collectionId = Integer.parseInt(vals[2])), Timestamp
                .valueOf(vals[3]));
        String data = record.getDataExport();
        collection = new Collection();
        collection.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 handleCollectionViewRequest(HttpServletRequest request,
      Command command) {
    CollectionManager collectionManager = new CollectionManager();
    Collection collection = null;

    boolean goToList = false;
    try {
      collection = collectionManager.getCollection(command, Integer
          .parseInt(command.getOther().get(0)), true);
View Full Code Here

      community.setActive(active);
      vbo = community;
    }
    if (type == ContentType.COLLECTION)
    {
      Collection collection = new Collection();
      collection.setCollectionId(-1);
      collection.setProjectId(projectId);
      collection.setActive(active);
      vbo = collection;
    }
    if (type == ContentType.BUNDLE)
    {
      Bundle bundle = new Bundle();
View Full Code Here

   *             If no matching collection is found.
   */
  public Collection getCollection(Command command, int collectionId,
      boolean mustBeActive, boolean addMetadata)
      throws NoSuchCollectionException {
    Collection collection;

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

    if (collectionId == -1) {
      collection = new Collection();
      collection.setCollectionId(-1);
      collection.setProjectId(projectId);
    } else {
      collection = cldao.getCollection(collectionId, projectId);
    }

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

    if (addMetadata) {
View Full Code Here

   *             If the element is locked by another user.
   */
  public Collection getCollectionForUpdate(Command command, int collectionId,
      boolean mustBeActive, HttpSession session)
      throws NoSuchCollectionException, ContentLockedException {
    Collection collection = getCollection(command, collectionId,
        mustBeActive);
    ContentLockManager.lockContentToSession(collection, session);
    return collection;
  }
View Full Code Here

TOP

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

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.