use of org.bimserver.models.log.UserUndeleted in project BIMserver by opensourceBIM.
the class UndeleteUserDatabaseAction method execute.
@Override
public Boolean execute() throws UserException, BimserverDatabaseException, BimserverLockConflictException {
User actingUser = getUserByUoid(authorization.getUoid());
if (actingUser.getUserType() != UserType.ADMIN) {
throw new UserException("Only administrators can undelete users");
}
final User user = getUserByUoid(uoid);
if (user == null) {
throw new UserException("No User with oid " + uoid + " found");
}
final UserUndeleted userUndeleted = getDatabaseSession().create(UserUndeleted.class);
userUndeleted.setAccessMethod(getAccessMethod());
userUndeleted.setDate(new Date());
userUndeleted.setExecutor(actingUser);
userUndeleted.setUser(user);
getDatabaseSession().addPostCommitAction(new PostCommitAction() {
@Override
public void execute() throws UserException {
bimServer.getNotificationsManager().notify(new SConverter().convertToSObject(userUndeleted));
}
});
user.setState(ObjectState.ACTIVE);
getDatabaseSession().store(user);
return true;
}
Aggregations