return create(username, password, null);
};
public ODocument create(String username, String password, String role) throws UserAlreadyExistsException {
OrientGraph db = DbHelper.getOrientGraphConnection();
if (existsUserName(username)) throw new UserAlreadyExistsException("User " + username + " already exists");
OUser user=null;
if (role==null) user=db.getRawGraph().getMetadata().getSecurity().createUser(username,password,new String[]{DefaultRoles.REGISTERED_USER.toString()});
else {
ORole orole = RoleDao.getRole(role);
if (orole==null) throw new InvalidParameterException("Role " + role + " does not exists");
user=db.getRawGraph().getMetadata().getSecurity().createUser(username,password,new String[]{role});
}
ODocument doc = new ODocument(this.MODEL_NAME);
ODocument vertex = db.addVertex("class:"+CLASS_VERTEX_NAME,FIELD_TO_DOCUMENT_FIELD,doc).getRecord();
doc.field(FIELD_LINK_TO_VERTEX,vertex);
doc.field(FIELD_CREATION_DATE,new Date());
doc.field(USER_LINK,user.getDocument().getIdentity());
doc.save();