Exemplo n.º 1
0
 public long getUserCount() {
   long count = 0;
   try {
     Weblogger roller = WebloggerFactory.getWeblogger();
     UserManager mgr = roller.getUserManager();
     count = mgr.getUserCount();
   } catch (WebloggerException e) {
     log.error("Error getting user count for site", e);
   }
   return count;
 }
Exemplo n.º 2
0
 /**
  * Get map with 26 entries, one for each letter A-Z and containing integers reflecting the number
  * of users whose names start with each letter.
  */
 public Map getUserNameLetterMap() {
   Map results = new HashMap();
   try {
     Weblogger roller = WebloggerFactory.getWeblogger();
     UserManager umgr = roller.getUserManager();
     results = umgr.getUserNameLetterMap();
   } catch (Exception e) {
     log.error("ERROR: fetching username letter map", e);
   }
   return results;
 }
Exemplo n.º 3
0
 /** Get User object by username */
 public UserWrapper getUser(String username) {
   UserWrapper wrappedUser = null;
   try {
     Weblogger roller = WebloggerFactory.getWeblogger();
     UserManager umgr = roller.getUserManager();
     User user = umgr.getUserByUserName(username, Boolean.TRUE);
     wrappedUser = UserWrapper.wrap(user);
   } catch (Exception e) {
     log.error("ERROR: fetching users by letter", e);
   }
   return wrappedUser;
 }
Exemplo n.º 4
0
 /*
  * Get most recent User objects, in reverse chrono order by creationDate.
  * @param offset   Offset into results (for paging)
  * @param len      Max number of results to return
  */
 public List getNewUsers(int sinceDays, int length) {
   List results = new ArrayList();
   try {
     Weblogger roller = WebloggerFactory.getWeblogger();
     UserManager umgr = roller.getUserManager();
     List users = umgr.getUsers(Boolean.TRUE, null, null, 0, length);
     for (Iterator it = users.iterator(); it.hasNext(); ) {
       User user = (User) it.next();
       results.add(UserWrapper.wrap(user));
     }
   } catch (Exception e) {
     log.error("ERROR: fetching weblog list", e);
   }
   return results;
 }
Exemplo n.º 5
0
 /** Return list of users that belong to website. */
 public List getWeblogsUsers(String handle) {
   List results = new ArrayList();
   try {
     Weblogger roller = WebloggerFactory.getWeblogger();
     UserManager umgr = roller.getUserManager();
     Weblog website = WebloggerFactory.getWeblogger().getWeblogManager().getWeblogByHandle(handle);
     List<WeblogPermission> perms = umgr.getWeblogPermissions(website);
     for (WeblogPermission perm : perms) {
       results.add(UserWrapper.wrap(perm.getUser()));
     }
   } catch (Exception e) {
     log.error("ERROR: fetching weblog list", e);
   }
   return results;
 }
Exemplo n.º 6
0
 /** Return list of weblogs that user belongs to. */
 public List getUsersWeblogs(String userName) {
   List results = new ArrayList();
   try {
     Weblogger roller = WebloggerFactory.getWeblogger();
     UserManager umgr = roller.getUserManager();
     User user = umgr.getUserByUserName(userName);
     List<WeblogPermission> perms = umgr.getWeblogPermissions(user);
     for (WeblogPermission perm : perms) {
       results.add(WeblogWrapper.wrap(perm.getWeblog(), urlStrategy));
     }
   } catch (Exception e) {
     log.error("ERROR: fetching weblog list", e);
   }
   return results;
 }