use of org.bimserver.models.log.UserChanged in project BIMserver by opensourceBIM.
the class ChangeUserTypeDatabaseAction method execute.
@Override
public Void execute() throws UserException, BimserverLockConflictException, BimserverDatabaseException {
User actingUser = getUserByUoid(authorization.getUoid());
if (actingUser.getUserType() != UserType.ADMIN) {
throw new UserException("Only admin users can change other user's types");
}
User user = getUserByUoid(uoid);
if (user.getUserType() == UserType.SYSTEM) {
throw new UserException("Type of system user cannot be changed");
}
user.setUserType(UserType.get(userType.getOrdinal()));
final UserChanged userChanged = getDatabaseSession().create(UserChanged.class);
userChanged.setAccessMethod(getAccessMethod());
userChanged.setDate(new Date());
userChanged.setExecutor(actingUser);
userChanged.setUser(user);
getDatabaseSession().addPostCommitAction(new PostCommitAction() {
@Override
public void execute() throws UserException {
bimServer.getNotificationsManager().notify(new SConverter().convertToSObject(userChanged));
}
});
getDatabaseSession().store(user);
return null;
}
Aggregations