Search in sources :

Example 1 with GetUserByUserNameDatabaseAction

use of org.bimserver.database.actions.GetUserByUserNameDatabaseAction in project BIMserver by opensourceBIM.

the class ServiceImpl method getUserByUserName.

@Override
public SUser getUserByUserName(String username) throws ServerException, UserException {
    requireRealUserAuthentication();
    DatabaseSession session = getBimServer().getDatabase().createSession();
    try {
        BimDatabaseAction<User> action = new GetUserByUserNameDatabaseAction(session, getInternalAccessMethod(), username);
        SUser convert = getBimServer().getSConverter().convertToSObject(session.executeAndCommitAction(action));
        if (convert == null) {
            throw new UserException("User with username \"" + username + "\" not found");
        }
        return convert;
    } catch (Exception e) {
        return handleException(e);
    } finally {
        session.close();
    }
}
Also used : SUser(org.bimserver.interfaces.objects.SUser) User(org.bimserver.models.store.User) DatabaseSession(org.bimserver.database.DatabaseSession) SUser(org.bimserver.interfaces.objects.SUser) UserException(org.bimserver.shared.exceptions.UserException) GetUserByUserNameDatabaseAction(org.bimserver.database.actions.GetUserByUserNameDatabaseAction) IOException(java.io.IOException) BimserverDatabaseException(org.bimserver.BimserverDatabaseException) SerializerException(org.bimserver.plugins.serializers.SerializerException) BcfException(org.opensourcebim.bcf.BcfException) UserException(org.bimserver.shared.exceptions.UserException) CannotBeScheduledException(org.bimserver.longaction.CannotBeScheduledException) DeserializeException(org.bimserver.plugins.deserializers.DeserializeException) ServerException(org.bimserver.shared.exceptions.ServerException) MessagingException(javax.mail.MessagingException) AddressException(javax.mail.internet.AddressException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) MalformedURLException(java.net.MalformedURLException)

Aggregations

IOException (java.io.IOException)1 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 MalformedURLException (java.net.MalformedURLException)1 MessagingException (javax.mail.MessagingException)1 AddressException (javax.mail.internet.AddressException)1 BimserverDatabaseException (org.bimserver.BimserverDatabaseException)1 DatabaseSession (org.bimserver.database.DatabaseSession)1 GetUserByUserNameDatabaseAction (org.bimserver.database.actions.GetUserByUserNameDatabaseAction)1 SUser (org.bimserver.interfaces.objects.SUser)1 CannotBeScheduledException (org.bimserver.longaction.CannotBeScheduledException)1 User (org.bimserver.models.store.User)1 DeserializeException (org.bimserver.plugins.deserializers.DeserializeException)1 SerializerException (org.bimserver.plugins.serializers.SerializerException)1 ServerException (org.bimserver.shared.exceptions.ServerException)1 UserException (org.bimserver.shared.exceptions.UserException)1 BcfException (org.opensourcebim.bcf.BcfException)1