role = roleNode.asText();
} else {
throw new CommandParsingException(command,"role parameter is not valid");
}
if (!RoleService.exists(role)){
throw new CommandExecutionException(command,"required role does not exists: "+role);
}
JsonNode userVisible = params.get(UserDao.ATTRIBUTES_VISIBLE_BY_ANONYMOUS_USER);
JsonNode friendsVisible = params.get(UserDao.ATTRIBUTES_VISIBLE_BY_FRIENDS_USER);
JsonNode registeredVisible = params.get(UserDao.ATTRIBUTES_VISIBLE_BY_REGISTERED_USER);
JsonNode anonymousVisible = params.get(UserDao.ATTRIBUTES_VISIBLE_BY_ANONYMOUS_USER);
ODocument user = UserService.signUp(username, password.asText(),
new Date(), role,
anonymousVisible,userVisible,friendsVisible, registeredVisible, false);
String userNode = JSONFormats.prepareDocToJson(user, JSONFormats.Formats.USER);
return Json.mapper().readTree(userNode);
} catch (InvalidJsonException | IOException e) {
throw new CommandExecutionException(command,"invalid json",e);
} catch (UserAlreadyExistsException e) {
return NullNode.getInstance();
}
}