Package com.comcast.cmb.common.persistence

Examples of com.comcast.cmb.common.persistence.IUserPersistence


        List<String> userList = new ArrayList<String>();
        int index = 1;
       
        String userId = request.getParameter(CQSConstants.AWS_ACCOUNT_ID + "." + index);

        IUserPersistence userHandler = PersistenceFactory.getUserPersistence();
       
        while (userId != null) {

          if (userId.equals("*") || userHandler.getUserById(userId) != null) { // only add user if they exist
                userList.add(userId);
            }
           
          index++;
            userId = request.getParameter(CQSConstants.AWS_ACCOUNT_ID + "." + index);
View Full Code Here


    Map<?, ?> parameters = request.getParameterMap();
    String userName = request.getParameter("user");
    String passwd = request.getParameter("password");
    String isAdminStr = request.getParameter("isAdmin");
    String description = request.getParameter("description") + "";
    IUserPersistence userHandler = PersistenceFactory.getUserPersistence();
   
    if (parameters.containsKey("Create")) {
     
      try {
        if (userHandler.getUserByName(userName) != null) {
          out.println("<p><i>User already exists!</i></p>");
          logger.debug("event=user_already_exists user_name=" + userName);
        } else {
          Boolean isAdmin = Boolean.parseBoolean(isAdminStr);
          userHandler.createUser(userName, passwd, isAdmin, description);
          logger.debug("event=create_user user_name=" + userName);
        }
      } catch (PersistenceException ex) {
        logger.error("event=create_user user_name=" + userName, ex);
        throw new ServletException(ex);
      }
     
    } else if (parameters.containsKey("Delete")) {
     
      try {
        userHandler.deleteUser(userName);
        logger.debug("event=delete_user user_name=" + userName);
      } catch (PersistenceException ex) {
        logger.error("event=delete_user user_name=" + userName, ex);
        throw new ServletException(ex);
      }
    }
   
    out.println("<html>");

    header(request, out, "All Users");
   
    out.println("<body>");
   
    out.println("<h2>All Users</h2>");
    out.print("<form action=\"/webui\" method=POST>");
        out.print("<table><tr><td>Username:</td><td>Password:</td><td>Description:</td><td></td></tr>");
        out.print("<tr>" +
            "<td><input type='text' name='user'/></td>" +
            "<td><input type='password' name='password'></td>" +
            "<td><input type='text' name='description'/></td>" +
            "<td><input type='checkbox' id='isAdmin' name='isAdmin' value='true'><label for='isAdmin'>Is Admin</label></td>" +
            "<td><input type='submit' value='Create' name='Create' /></td></tr>");
        out.print("</table>");
        out.print("</form>");
        List<User> users = new ArrayList<User>();
   
        try {
     
          users = userHandler.getAllUsers();
      Collections.sort(users, new Comparator() {
              public int compare(Object o1, Object o2) {
                  User u1 = (User) o1;
                  User u2 = (User) o2;
                 return u1.getUserName().compareToIgnoreCase(u2.getUserName());
View Full Code Here

   
    @Before
    public void setUp() throws Exception {
        Util.initLog4jTest();

        IUserPersistence userHandler = new UserCassandraPersistence();
       
        User user = userHandler.getUserByName("cmb_unit_test");

        if (user == null) {
            user = userHandler.createUser("cmb_unit_test", "cmb_unit_test");
        }

        authModule = new UserAuthModule();
        authModule.setUserPersistence(userHandler);
        CMBControllerServlet.valueAccumulator.initializeAllCounters();
View Full Code Here

TOP

Related Classes of com.comcast.cmb.common.persistence.IUserPersistence

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.