Exemple #1
0
 private void printUsers(Iterable<User> users) {
   if (users != null) {
     int maxCreateDateWidth = 1;
     int maxIdWidth = 1;
     int maxUsernameWidth = 1;
     int maxEmailAddressWidth = 1;
     int maxDisplayNameWidth = 1;
     int maxLoginCountWidth = 1;
     int maxPrivilegesWidth = privilegesAsString(Privilege.ALL).length();
     for (User user : users) {
       maxCreateDateWidth = maxWidth(user.getCreateDate(), maxCreateDateWidth);
       maxIdWidth = maxWidth(user.getUserId(), maxIdWidth);
       maxUsernameWidth = maxWidth(user.getUsername(), maxUsernameWidth);
       maxEmailAddressWidth = maxWidth(user.getEmailAddress(), maxEmailAddressWidth);
       maxDisplayNameWidth = maxWidth(user.getDisplayName(), maxDisplayNameWidth);
       maxLoginCountWidth = maxWidth(Integer.toString(user.getLoginCount()), maxLoginCountWidth);
     }
     String format =
         String.format(
             "%%%ds %%%ds %%%ds %%%ds %%%ds %%%dd %%%ds%%n",
             -1 * maxCreateDateWidth,
             -1 * maxIdWidth,
             -1 * maxUsernameWidth,
             -1 * maxEmailAddressWidth,
             -1 * maxDisplayNameWidth,
             maxLoginCountWidth,
             -1 * maxPrivilegesWidth);
     for (User user : users) {
       System.out.printf(
           format,
           valueOrBlank(user.getCreateDate()),
           user.getUserId(),
           user.getUsername(),
           valueOrBlank(user.getEmailAddress()),
           user.getDisplayName(),
           user.getLoginCount(),
           privilegesAsString(getUserRepository().getPrivileges(user)));
     }
   } else {
     System.out.println("No users");
   }
 }
Exemple #2
0
 private void printUser(User user) {
   System.out.println("                        ID: " + user.getUserId());
   System.out.println("                  Username: "******"            E-Mail Address: " + valueOrBlank(user.getEmailAddress()));
   System.out.println("              Display Name: " + user.getDisplayName());
   System.out.println("               Create Date: " + valueOrBlank(user.getCreateDate()));
   System.out.println("        Current Login Date: " + valueOrBlank(user.getCurrentLoginDate()));
   System.out.println(
       " Current Login Remote Addr: " + valueOrBlank(user.getCurrentLoginRemoteAddr()));
   System.out.println("       Previous Login Date: " + valueOrBlank(user.getPreviousLoginDate()));
   System.out.println(
       "Previous Login Remote Addr: " + valueOrBlank(user.getPreviousLoginRemoteAddr()));
   System.out.println("               Login Count: " + user.getLoginCount());
   System.out.println(
       "                Privileges: "
           + privilegesAsString(getUserRepository().getPrivileges(user)));
   System.out.println(
       "            Authorizations: "
           + authorizationsAsString(getUserRepository().getAuthorizations(user)));
   System.out.println("");
 }