avatarDetail = "low";
}
// Check to see if there is no avatar configuration info and/or if we
// have the avatar details set to "low". If so, then use the default
AvatarLoaderRegistry registry = AvatarLoaderRegistry.getAvatarLoaderRegistry();
if (avatarConfigInfo == null || avatarDetail.equalsIgnoreCase("low")) {
// Find the "default" factory to generate an avatar. Ask it to
// loader the avatar. If it does not exist (it should), simply
// log an error andr return.
AvatarLoaderFactorySPI factory = registry.getDefaultAvatarLoaderFactory();
if (factory == null) {
logger.warning("No default avatar factory is registered.");
return null;
}
// We need to rewrite the AvatarConfigInfo object here a bit,
// otherwise, the loader may still loader the wrong avatar. If
// we set the URL in the AvatarConfigInfo to null, that should do
// the trick. (Note that since we manually obtained the
// AvatarLoaderFactorySPI, we don't need to update the factory
// class name in the AvatarConfigInfo object, but we do anyway).
String defaultClassName = factory.getClass().getName();
AvatarConfigInfo defaultInfo =
new AvatarConfigInfo(null, defaultClassName);
// Go ahead and load the default avatar
ret = factory.getAvatarLoader().getAvatarCharacter(cell, username,
defaultInfo);
}
else {
// If the avatar has a non-null configuration information, then
// ask the loader factory to generate a new loader for this avatar
String className = avatarConfigInfo.getLoaderFactoryClassName();
if (className == null) {
logger.warning("No class name given for avatar configuration" +
" with url " + avatarConfigInfo.getAvatarConfigURL());
return null;
}
// Find the avatar factory, if it does not exist, return an error
AvatarLoaderFactorySPI factory = registry.getAvatarLoaderFactory(className);
if (factory == null) {
logger.warning("No avatar loader factory for the class name " +
className + " with url " + avatarConfigInfo.getAvatarConfigURL());
return null;
}