UserManagerをみる

数万ユーザーの現実的な管理に向けて、調べ始める。Jetspeed API の UserManager から見ていく。見ていくと、いかような感じで呼ばれていく。

./components/security/src/java/org/apache/jetspeed/security/impl/UserManagerImpl.java:
public Iterator getUsers(String filter) throws SecurityException
{
List users = new LinkedList();
Iterator userPrincipals = atnProviderProxy.getUserPrincipals(filter)
.iterator();
while (userPrincipals.hasNext())
{
String username = ((Principal) userPrincipals.next()).getName();
User user = getUser(username);
users.add(user);
}
return users.iterator();
}
./components/security/src/java/org/apache/jetspeed/security/impl/AuthenticationProviderProxyImpl.java
public List getUserPrincipals(String filter)
{
List userPrincipals = new LinkedList();
for (int i = 0; i < authenticationProviders.size(); i++)
{
userPrincipals.addAll(((AuthenticationProvider)authenticationProviders.get(i)).getUserSecurityHandler().getUserPrincipals(filter));
}
return userPrincipals;
}
./components/security/src/java/org/apache/jetspeed/security/spi/impl/DefaultUserSecurityHandler.java:
public List getUserPrincipals(String filter)
{
List userPrincipals = new LinkedList();
Iterator result = securityAccess.getInternalUserPrincipals(filter);
while (result.hasNext())
{
InternalUserPrincipal internalUser = (InternalUserPrincipal) result.next();
String path = internalUser.getFullPath();
if (path == null)
{
continue;
}
userPrincipals.add(new UserPrincipalImpl(UserPrincipalImpl.getPrincipalNameFromFullPath(internalUser.getFullPath())));
}
return userPrincipals;
}
./components/security/src/java/org/apache/jetspeed/security/spi/impl/SecurityAccessImpl.java
public Iterator getInternalUserPrincipals(String filter)
{
Criteria queryCriteria = new Criteria();
queryCriteria.addEqualTo("isMappingOnly", new Boolean(false));
queryCriteria.addLike("fullPath", UserPrincipal.PREFS_USER_ROOT + filter + "%");
Query query = QueryFactory.newQuery(InternalUserPrincipalImpl.class, queryCriteria);
Iterator result = getPersistenceBrokerTemplate().getIteratorByQuery(query);
return result;
}

と言う感じで、OJBを呼んでいる(UserManager に渡すフィルタは、ユーザー名に含まれる文字列じゃなくて、フィルタの文字列で始まるユーザー名を引っ張ってくるのね)。で、OJBでページングができれば、問題解決なのだが、OJBのFAQを見ると、できんと言っている。IteratorかCollectionで取得して、自分で取り出せという感じみたい。うーん・・・、別な方法を考えよっと・・・。

http://db.apache.org/ojb/docu/faq.html

追記:Jetspeedで使っているOJBのバージョンは、1.0.3だけど、そのソースコードを見ると、QueryにsetStartAtIndexとsetEndAtIndexみたいのがあることに気がつく。その周辺のコードをみても、それらを使えば、良さそうな気がしてくる。というわけで、これで試してみよう。

コメントを残す

メールアドレスが公開されることはありません。 が付いている欄は必須項目です