Collection<String> mappings = new ArrayList<String>();
try {
User user = getUserByName(username);
if (user instanceof JamesUser) {
JamesUser jUser = (JamesUser) user;
if (enableAliases && jUser.getAliasing()) {
String alias = jUser.getAlias();
if (alias != null) {
mappings.add(alias + "@" + domain);
}
}
if (enableForwarding && jUser.getForwarding()) {
String forward;
if (jUser.getForwardingDestination() != null && ((forward = jUser.getForwardingDestination().toString()) != null)) {
mappings.add(forward);
} else {
String errorBuffer = "Forwarding was enabled for " + username + " but no forwarding address was set for this account.";
getLogger().error(errorBuffer);
}