Package edu.uga.galileo.voci.bo

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


  /**
   * @see edu.uga.galileo.voci.db.dao.RoleDAO#getRoleByRoleId(int roleId)
   */
  public Role getRoleByRoleId( int roleId ) throws NoSuchRoleException
  {
    Role role = new Role();
    StringBuffer sql = new StringBuffer();
    sql.append(" select * ");
    sql.append(" from roles ");
    sql.append(" where role_id=? ");

View Full Code Here


   *            The roleId.
   * @return Role that represents the user's role.
   * @throws NoSuchRoleException
   */
  public Role getRoleByRoleId(int roleId) throws NoSuchRoleException {
    Role role = new Role();

    try {
      role = rdao.getRoleByRoleId(roleId);
    } catch (NoSuchRoleException nsrex) {
      role = null;
View Full Code Here

  private void deleteRole(HttpServletRequest request,
      HttpServletResponse response, Command command) {
    ArrayList<String> errors = new ArrayList<String>();
    HashMap<String, String> fieldMessages = new HashMap<String, String>();
    RoleManager roleManager = new RoleManager();
    Role role = new Role();
    int roleId = Integer.valueOf(command.getOther().get(0));
    role.setRoleId(roleId);

    // get role record from database
    try {
      role = new RoleManager().getRoleByRoleId(roleId);
    } catch (NoSuchRoleException nsue) {
      Logger.error(
          "\n Attempting to delete Role but could not retrieve role by role_id "
              + roleId + "\n", nsue);
      errors.add("Role ID was not found");
    }

    // if errors occurred, we will not delete
    if (errors.isEmpty()) {
      try {
        User sessionUser = (User) request.getSession().getAttribute(
            "user");
        roleManager.deleteRole(new ProjectManager().getProject(command
            .getProject()), sessionUser, role, role.toString());
        // if delete successful send messages....
        request.setAttribute("successMessage",
            "Role successfully deleted <span class=\"tinyformtext\">("
                + Calendar.getInstance().getTime().toString()
                + ")</span>");
View Full Code Here

  private void updateRole(HttpServletRequest request,
      HttpServletResponse response, Command command) {
    ArrayList<String> errors = new ArrayList<String>();
    HashMap<String, String> fieldMessages = new HashMap<String, String>();
    RoleManager roleManager = new RoleManager();
    Role role = new Role();
    populateVBOFromRequest(role, request, fieldMessages, true);
    int roleId = role.getRoleId();
    boolean isErrors = false;
    Role oldRole = null;
    Project project = null;

    // get original role record from database
    try {
      oldRole = new RoleManager().getRoleByRoleId(roleId);
      if (oldRole == null) {
        isErrors = true;
        errors.add("Role ID was not found");
      }
    } catch (NoSuchRoleException nsue) {
      isErrors = true;
      Logger.error(
          "\n Attempting to update Role but could not retrieve role by role_id "
              + roleId + "\n", nsue);
      errors.add("Role ID was not found");
    }

    String oldContent = oldRole.toString();
    // set parentId of new Info if its > 0
    role.setParentRoleId(oldRole.getParentRoleId());

    // detect whether role data changed
    if (oldContent.equals(role.toString())) {
      errors.add("No changes detected.");
      isErrors = true;
    }

    // if user is attempting to change role name,
    // the system must validate role name/manager pair doesn't already exist
    if ((!oldRole.getName().equalsIgnoreCase(role.getName()))
        && (!oldRole.isManager() == role.isManager())) {
      // if role exist add to errors messaging
      if (roleManager.isRoleExist(role.getName().toLowerCase(), role
          .isManager(), role.getParentRoleId())) {
        errors.add("Role Name: " + role.getName()
            + " already exist.  Please enter another role name.");
View Full Code Here

  private void addTopLevelRole(HttpServletRequest request,
      HttpServletResponse response, Command command) {
    ArrayList<String> errors = new ArrayList<String>();
    HashMap<String, String> fieldMessages = new HashMap<String, String>();
    RoleManager roleManager = new RoleManager();
    Role role = new Role();
    populateVBOFromRequest(role, request, fieldMessages, true);
    boolean isErrors = false;

    // if role/pair exist add to errors log
    // condition: role name + manager flag should be unique
    if (roleManager.isRoleExist(role.getName().toLowerCase().trim(), role
        .isManager(), role.getParentRoleId())) {
      errors
          .add("Role Name: "
              + role.getName()
              + " and manager value entered already exist.  Please enter another role name.");
      isErrors = true;
    }
    // if no errors and role doesn't already exist add new role record
    if ((!isErrors) && (fieldMessages.size() == 0) && (errors.isEmpty())) {
View Full Code Here

  private void addChildRole(HttpServletRequest request,
      HttpServletResponse response, Command command) {
    ArrayList<String> errors = new ArrayList<String>();
    HashMap<String, String> fieldMessages = new HashMap<String, String>();
    RoleManager roleManager = new RoleManager();
    Role role = new Role();
    populateVBOFromRequest(role, request, fieldMessages, true);
    role.setParentRoleId(role.getRoleId());
    boolean isErrors = false;

    // if role/pair exist add to errors log
    // condition: role name + manager flag should be unique
    if (roleManager.isRoleExist(role.getName().toLowerCase().trim(), role
        .isManager(), role.getParentRoleId())) {
      errors
          .add("Role Name: "
              + role.getName()
              + " and manager value entered already exist.  Please enter another role name.");
      isErrors = true;
    }
    // if no errors and role doesn't already exist add new role record
    if ((!isErrors) && (fieldMessages.size() == 0) && (errors.isEmpty())) {
      try {
        Role roleParent = null;
        roleParent = roleManager.getRoleByRoleId(role.getRoleId());
        if (roleParent != null) {
          roleManager.addChildRole(((User) request.getSession()
              .getAttribute("user")), role);
          // if add was successful send messages....
View Full Code Here

      HttpServletResponse response, Command command) {
    ArrayList<String> errors = new ArrayList<String>();
    String[] vals = command.getOther().get(0).split("\\|");
    AuditLogManager alm = new AuditLogManager();
    boolean isErrors = false;
    Role role = new Role();
    int projectId = -1;
    String data = "";

    try {
      // roleId/type/date
      // getRecord(int projectId, ContentType contentType, int contentId,
      // Timestamp update)
      projectId = new ProjectManager().getProjectID(command.getProject());
      AuditLog record = alm.getRecord(projectId, ContentType
          .valueOf(Integer.parseInt(vals[1])), Integer
          .parseInt(vals[0]), Timestamp.valueOf(vals[2].replace(
          "%20", " ")));
      data = record.getDataExport();

      Logger.debug("\n\n the data looks like : " + data + "\n\n");

      role = new Role();
      role.fromString(data);
      request.setAttribute("isDirty", "t");
    } catch (NullPointerException e) {
      errors.add("Invalid history request format.");
    } catch (NumberFormatException e) {
      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.");
    } catch (NoSuchProjectException ex) {
      Logger
          .debug("\n\n Could not retrieve projectId - RoleServlet.processUpdateRequest \n\n");
      errors.add("Could not retrieve projectId.");
    }

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

    request.setAttribute("role", role);

    projectId = -1;
    ArrayList historyRecords = new ArrayList();
    try {
      projectId = new ProjectManager().getProjectID(command.getProject());
      historyRecords = (new AuditLogManager()).getUpdateRecords(projectId,
          ContentType.ROLE, role.getRoleId());
    } catch (NoSuchProjectException ex) {
      Logger
          .debug("\n\n Could not retrieve projectId - RoleServlet.handleHistory \n\n");
    }

    if ((!historyRecords.isEmpty()) && (historyRecords.size() > 0)) {
      request.setAttribute("history", historyRecords);
    }

    if ((errors.size() > 0) || (isErrors)) {
      // go back to role.jsp and state error
      sendRequestToRoleJSP(request, response, command);
      Logger.debug("\n\n this role data had erros : " + role.toString()
          + "\n\n");
    } else {
      sendRequestToRoleJSP(request, response, command);
    }
  }// end handleHistory()
View Full Code Here

      errors.add("System error occurred: roleId is null.");
      request.setAttribute("errorMessage", generateErrorMessage(errors));
      sendRequestToRoleListJSP(request, response, command);
    }
    roleId = Integer.valueOf(command.getOther().get(0));
    Role role = new Role();

    try {
      role = new RoleManager().getRoleByRoleId(roleId);
    } catch (NoSuchRoleException nsuex) {
      Logger.debug("Could not retrieve roleId", nsuex);
      request.setAttribute("errorMessage",
          "Could not retrieve role by roleId..." + roleId);
    }

    request.setAttribute("role", role);
    int projectId = -1;
    ArrayList historyRecords = new ArrayList();
    try {
      projectId = new ProjectManager().getProjectID(command.getProject());
      historyRecords = (new AuditLogManager()).getUpdateRecords(projectId,
          ContentType.ROLE, role.getRoleId());
    } catch (NoSuchProjectException ex) {
      Logger
          .debug("\n\n Could not retrieve projectId - RoleServlet.processUpdateRequest \n\n");
    }
View Full Code Here

   *            The url command.
   */
  private void processAddTopRoleRequest(HttpServletRequest request,
      HttpServletResponse response, Command command) {

    Role role = new Role();
    role.setRoleId(-1);
    role.setParentRoleId(-1);
    request.setAttribute("role", role);

    sendRequestToRoleJSP(request, response, command);

  }// end processAddTopRoleRequest()
View Full Code Here

   *            The url command.
   */
  private void processAddChildRoleRequest(HttpServletRequest request,
      HttpServletResponse response, Command command) {

    Role role = new Role();
    // role.setRoleId(-2);
    Logger.debug("\n\n role id is : " + request.getParameter("roleId")
        + "\n\n");
    role.setRoleId(Integer.valueOf(Integer.valueOf(command.getOther()
        .get(0))));
    role.setParentRoleId(-1);
    role.setManager(Boolean.valueOf(command.getOther().get(1)));
    request.setAttribute("isChild", "true");
    request.setAttribute("role", role);

    sendRequestToRoleJSP(request, response, command);

View Full Code Here

TOP

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

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.