Package edu.uga.galileo.voci.bo

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


  {
    VociBusinessObject vbo = null;

    if (type == ContentType.COMMUNITY)
    {
      Community community = new Community();
      community.setCommunityId(-1);
      community.setProjectId(projectId);
      community.setActive(active);
      vbo = community;
    }
    if (type == ContentType.COLLECTION)
    {
      Collection collection = new Collection();
View Full Code Here


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

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

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

    if (goToList) {
      // we're on our way back to the content tree

      // 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 (community != null) {
        request.setAttribute("jumpToTarget", "#node"
            + community.getCommunityId());
      }

      // only get the content tree if we're not on the search page
      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 {
      // we're going to the community add/edit or view page
      request.setAttribute(command.isViewCommand() ? "vbo" : "community",
          community);
      ArrayList<AuditLog> historyRecords = (new AuditLogManager())
          .getUpdateRecords(
              ((HashMap<String, Project>) getServletContext()
                  .getAttribute("projectMap")).get(
                  command.getProject()).getProjectId(),
              ContentType.COMMUNITY, community.getCommunityId());
      if ((historyRecords != null) && (historyRecords.size() > 0)) {
        request.setAttribute("history", historyRecords);
      }

      try {
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);
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 {
            // 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
                    .setAttribute(
                        "successMessage",
                        "Community '"
                            + community
                                .getMetadataBasedTitle()
                            + "' successfully updated.");
                if ((request.getParameter("fs") != null)
                    && (request.getSession().getAttribute(
                        "searchResults") != null)) {
                  SearchManager.updateSessionSearchResults(
                      request, community);
                }
              }

              goToList = true;
            } catch (NoSuchCommunityException e) {
              Logger.warn("Community "
                  + community.getCommunityId()
                  + " couldn't be found for update", e);
              errors.add(e.getMessage());
            } catch (SQLException e) {
              Logger.error(
                  "Couldn't add a community to the database",
View Full Code Here

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

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

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

   *             If no matching community is found.
   */
  public Community getCommunity(Command command, int communityId,
      boolean mustBeActive, boolean addMetadata)
      throws NoSuchCommunityException {
    Community community;

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

    if (communityId == -1) {
      community = new Community();
      community.setCommunityId(-1);
      community.setProjectId(projectId);
    } else {
      community = cdao.getCommunity(communityId, projectId);
    }

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

    if (addMetadata) {
View Full Code Here

   *             If the element is locked by another user.
   */
  public Community getCommunityForUpdate(Command command, int communityId,
      boolean mustBeActive, HttpSession session)
      throws NoSuchCommunityException, ContentLockedException {
    Community community = getCommunity(command, communityId, mustBeActive,
        true);
    ContentLockManager.lockContentToSession(community, session);
    return community;
  }
View Full Code Here

TOP

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

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.