Package org.jamwiki.model

Examples of org.jamwiki.model.Role


  /**
   *
   */
  private void modifyRole(HttpServletRequest request, ModelAndView next, WikiPageInfo pageInfo) throws Exception {
    String updateRole = request.getParameter("updateRole");
    Role role = null;
    if (!StringUtils.isBlank(request.getParameter("Submit"))) {
      try {
        // once created a role name cannot be modified, so the text field
        // will be disabled in the form.
        boolean update = StringUtils.isBlank(request.getParameter("roleName"));
        String roleName = (update) ? updateRole : request.getParameter("roleName");
        role = new RoleImpl(roleName);
        role.setDescription(request.getParameter("roleDescription"));
        WikiUtil.validateRole(role);
        WikiBase.getDataHandler().writeRole(role, update);
        if (!StringUtils.isBlank(updateRole) && updateRole.equals(role.getAuthority())) {
          next.addObject("message", new WikiMessage("roles.message.roleupdated", role.getAuthority()));
        } else {
          next.addObject("message", new WikiMessage("roles.message.roleadded", role.getAuthority()));
        }
      } catch (WikiException e) {
        next.addObject("message", e.getWikiMessage());
      } catch (Exception e) {
        logger.severe("Failure while adding role", e);
        next.addObject("message", new WikiMessage("roles.message.rolefail", e.getMessage()));
      }
    } else if (!StringUtils.isBlank(updateRole)) {
      // FIXME - use a cached list of roles instead of iterating
      // load details for the selected role
      List<Role> roles = WikiBase.getDataHandler().getAllRoles();
      for (Role tempRole : roles) {
        if (tempRole.getAuthority().equals(updateRole)) {
          role = tempRole;
        }
      }
    }
    if (role != null) {
      next.addObject("roleName", role.getAuthority());
      next.addObject("roleDescription", role.getDescription());
    }
    this.view(request, next, pageInfo);
  }
View Full Code Here


  /**
   *
   */
  protected static void setupRoles() throws DataAccessException, WikiException {
    Role role = RoleImpl.ROLE_ADMIN;
    // FIXME - use message key
    role
        .setDescription("Provides the ability to perform wiki maintenance tasks not available to normal users.");
    WikiBase.getDataHandler().writeRole(role, false);
    role = RoleImpl.ROLE_EDIT_EXISTING;
    // FIXME - use message key
    role.setDescription("Allows a user to edit an existing topic.");
    WikiBase.getDataHandler().writeRole(role, false);
    role = RoleImpl.ROLE_EDIT_NEW;
    // FIXME - use message key
    role.setDescription("Allows a user to create a new topic.");
    WikiBase.getDataHandler().writeRole(role, false);
    role = RoleImpl.ROLE_IMPORT;
    // FIXME - use message key
    role.setDescription("Allows a user to import data from a file.");
    WikiBase.getDataHandler().writeRole(role, false);
    role = RoleImpl.ROLE_MOVE;
    // FIXME - use message key
    role.setDescription("Allows a user to move a topic to a different name.");
    WikiBase.getDataHandler().writeRole(role, false);
    role = RoleImpl.ROLE_SYSADMIN;
    // FIXME - use message key
    role
        .setDescription("Allows access to set database parameters, modify parser settings, and set other wiki system settings.");
    WikiBase.getDataHandler().writeRole(role, false);
    role = RoleImpl.ROLE_TRANSLATE;
    // FIXME - use message key
    role
        .setDescription("Allows access to the translation tool used for modifying the values of message keys used to display text on the wiki.");
    WikiBase.getDataHandler().writeRole(role, false);
    role = RoleImpl.ROLE_UPLOAD;
    // FIXME - use message key
    role.setDescription("Allows a user to upload a file to the wiki.");
    WikiBase.getDataHandler().writeRole(role, false);
    role = RoleImpl.ROLE_VIEW;
    // FIXME - use message key
    role.setDescription("Allows a user to view topics on the wiki.");
    WikiBase.getDataHandler().writeRole(role, false);
  }
View Full Code Here

    throw new NotImplementedException("getWatchlist");
    // return null;
  }

  private Role initRole(RoleEntity rs) {
    Role role = new RoleImpl(rs.getName());
    role.setDescription(rs.getDescription());
    return role;
  }
View Full Code Here

TOP

Related Classes of org.jamwiki.model.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.