Package edu.uga.galileo.voci.model

Examples of edu.uga.galileo.voci.model.CommunityManager$CommunityUpdateListenerNotifier


          command.getOther().size() - 1));
      ContentType contentType = DAOFactory.getHelperDAO()
          .getContentTypeById(elementId);

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

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

   *         <code>false</code> if all's well.
   */
  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 {
            // user has permission, so get the existing
            // community
            try {
              community = communityManager.getCommunityForUpdate(
                  command, communityId, false, request
                      .getSession());
            } catch (NoSuchCommunityException e) {
              Logger.warn("Requested community (" + communityId
                  + ") couldn't be retrieved", e);
              errors.add("Requested community (" + communityId
                  + ") couldn't be retrieved");
              goToList = true;
            } catch (ContentLockedException e) {
              errors.add(e.getMessage());
              goToList = true;
            }
          }
        }

        // if all's well so far....
        if ((isFormSubmission) && (community != null)) {
          String oldData = community.toString();

          populateVBOFromRequest(community, request, fieldMessages,
              true);

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

          if ((errors.size() == 0) && (fieldMessages.size() == 0)) {
            // perform the add or update with the community
            // manager
            try {
              if (community.getId() == -1) {
                communityManager.addCommunity(user, community,
                    parentId);
                request.setAttribute("successMessage",
                    "Community successfully added.");
              } else {
                communityManager
                    .updateCommunity(community,
                        ((User) request.getSession()
                            .getAttribute("user")),
                        oldData);
                request
View Full Code Here

   *            The user making the request.
   * @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 {
          // get and delete the community
          community = communityManager.getCommunityForUpdate(command,
              communityId, false, request.getSession());
          communityManager.deleteCommunity(community, ((User) request
              .getSession().getAttribute("user")));
          request.setAttribute("successMessage", "Community "
              + communityId + " successfully deleted.");
        } catch (NoSuchCommunityException e) {
          errors.add("The community to delete either doesn't exist, "
View Full Code Here

   *         the content list rather than the community form;
   *         <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 {
        AuditLog record = alm.getRecord(Integer.parseInt(vals[0]),
            ContentType.valueOf(Integer.parseInt(vals[1])),
            (communityId = Integer.parseInt(vals[2])), Timestamp
                .valueOf(vals[3]));
        String data = record.getDataExport();
        community = new Community();
        community.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 no errors occurred so far...
    if (!goToList) {
      if (community == null) {
        // the community couldn't be retrieved from the history, so
        // we get the current one instead (the error message will
        // let the user know there was a problem)
        try {
          community = communityManager.getCommunity(command,
              communityId, false);
        } catch (NoSuchCommunityException e) {
          goToList = true;
          errors
              .add("No such community (" + communityId
View Full Code Here

   *         the content list rather than the community viewing page;
   *         <code>false</code> if all's well.
   */
  public boolean handleCommunityViewRequest(HttpServletRequest request,
      Command command) {
    CommunityManager communityManager = new CommunityManager();
    Community community = null;
    boolean goToList = false;
    try {
      community = communityManager.getCommunity(command, Integer
          .parseInt(command.getOther().get(0)), true);
    } catch (NumberFormatException e) {
      Logger.warn("Couldn't get requested community: "
          + (command.getOther() == null ? "{null}" : command
              .getOther().get(0)));
View Full Code Here

TOP

Related Classes of edu.uga.galileo.voci.model.CommunityManager$CommunityUpdateListenerNotifier

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.