}
// Generate the avatar character from the avatar configuration. We will
// use this to write out its parameters
WonderlandCharacterParams params = avatar.getAvatarParams(false);
WlAvatarCharacter character = ImiAvatar.getAvatarCharacter(params);
// Create a file to hold the avatar configuration locally if it does
// not yet exist.
String fileName = avatar.getFilename();
ContentResource file = (ContentResource) imiCollection.createChild(fileName, Type.RESOURCE);
if (file == null) {
file = (ContentResource) imiCollection.createChild(fileName, Type.RESOURCE);
}
logger.info("Writing avatar to resource " + file.getPath());
// Write out the avatar configuration to a byte avatar.
ByteArrayOutputStream out = new ByteArrayOutputStream();
character.saveConfiguration(out);
out.close();
// Then write out the XML to the local repository. Update the avatar
// to point to this local avatar resource
file.put(out.toByteArray());