Package edu.uga.galileo.voci.model

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


      if (contentType == ContentType.COMMUNITY) {
        request.setAttribute("vbo", (new CommunityManager())
            .getCommunity(command, elementId, command
                .isViewCommand() ? true : false));
      } else if (contentType == ContentType.COLLECTION) {
        request.setAttribute("vbo", (new CollectionManager())
            .getCollection(command, elementId, command
                .isViewCommand() ? true : false));
      } else if (contentType == ContentType.BUNDLE) {
        request.setAttribute("vbo", (new BundleManager()).getBundle(
            command, elementId, command.isViewCommand() ? true
View Full Code Here


      getItemWrappersForNode(command, (User) request.getSession()
          .getAttribute("user"), request);
    } else if ((command.getModifier() != null)
        && (command.getModifier().equals("search"))) {
      // prep for search functions
      setSearchObject(command, new CollectionManager(), 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)
View Full Code Here

   *         <code>false</code> if all's well.
   */
  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)
          && (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(),
View Full Code Here

   *         <code>false</code> if all's well.
   */
  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(
View Full Code Here

   *            The user making the request.
   * @return <code>true</code>.
   */
  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)) {
        errors.add("You don't have permission to delete "
            + "the requested collection.");
      } else {
        try {
          collection = collectionManager.getCollectionForUpdate(
              command, collectionId, false, request.getSession());
          collectionManager.deleteCollection(collection,
              ((User) request.getSession().getAttribute("user")));
          request.setAttribute("successMessage", "Collection "
              + collectionId + " successfully deleted.");
        } catch (NoSuchCollectionException e) {
          errors
View Full Code Here

   *         the content list rather than the collection form;
   *         <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 {
        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) {
      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 (collection == null) {
        try {
          collection = collectionManager.getCollection(command,
              collectionId, false);
        } catch (NoSuchCollectionException e) {
          goToList = true;
          errors.add("No such collection (" + collectionId
              + ") found.");
View Full Code Here

   *         the content list rather than the collection viewing page;
   *         <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);
    } catch (NumberFormatException e) {
      Logger.warn("Couldn't get requested collection: "
          + command.getOther() == null ? "{null}" : command
          .getOther().get(0));
View Full Code Here

TOP

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

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.