Search in sources :

Example 96 with ServerException

use of org.bimserver.shared.exceptions.ServerException in project BIMserver by opensourceBIM.

the class ServiceImpl method getAllUsers.

@Override
public List<SUser> getAllUsers() throws ServerException, UserException {
    if (getBimServer().getServerSettingsCache().getServerSettings().getHideUserListForNonAdmin()) {
        if (getCurrentUser() == null || getCurrentUser().getUserType() != SUserType.ADMIN) {
            throw new UserException("Admin rights required to list users");
        }
    }
    requireRealUserAuthentication();
    DatabaseSession session = getBimServer().getDatabase().createSession(OperationType.READ_ONLY);
    try {
        BimDatabaseAction<Set<User>> action = new GetAllUsersDatabaseAction(session, getInternalAccessMethod(), getAuthorization());
        List<SUser> convertToSListUser = getBimServer().getSConverter().convertToSListUser(session.executeAndCommitAction(action));
        Collections.sort(convertToSListUser, new SUserComparator());
        return convertToSListUser;
    } catch (Exception e) {
        return handleException(e);
    } finally {
        session.close();
    }
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) LinkedHashSet(java.util.LinkedHashSet) DatabaseSession(org.bimserver.database.DatabaseSession) SUser(org.bimserver.interfaces.objects.SUser) UserException(org.bimserver.shared.exceptions.UserException) GetAllUsersDatabaseAction(org.bimserver.database.actions.GetAllUsersDatabaseAction) SUserComparator(org.bimserver.webservices.SUserComparator) ServiceException(org.bimserver.shared.exceptions.ServiceException) 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) PluginException(org.bimserver.shared.exceptions.PluginException) MessagingException(javax.mail.MessagingException) AddressException(javax.mail.internet.AddressException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) MalformedURLException(java.net.MalformedURLException) FileAlreadyExistsException(java.nio.file.FileAlreadyExistsException)

Example 97 with ServerException

use of org.bimserver.shared.exceptions.ServerException in project BIMserver by opensourceBIM.

the class ServiceImpl method getAllCheckoutsByUser.

@Override
public List<SCheckout> getAllCheckoutsByUser(Long uoid) throws ServerException, UserException {
    requireRealUserAuthentication();
    DatabaseSession session = getBimServer().getDatabase().createSession(OperationType.READ_ONLY);
    try {
        BimDatabaseAction<List<Checkout>> action = new GetAllCheckoutsByUserDatabaseAction(session, getInternalAccessMethod(), uoid);
        List<Checkout> list = session.executeAndCommitAction(action);
        Collections.sort(list, new CheckoutComparator());
        return getBimServer().getSConverter().convertToSListCheckout(list);
    } catch (Exception e) {
        return handleException(e);
    } finally {
        session.close();
    }
}
Also used : SCheckout(org.bimserver.interfaces.objects.SCheckout) Checkout(org.bimserver.models.store.Checkout) DatabaseSession(org.bimserver.database.DatabaseSession) CheckoutComparator(org.bimserver.webservices.CheckoutComparator) ArrayList(java.util.ArrayList) List(java.util.List) EList(org.eclipse.emf.common.util.EList) GetAllCheckoutsByUserDatabaseAction(org.bimserver.database.actions.GetAllCheckoutsByUserDatabaseAction) ServiceException(org.bimserver.shared.exceptions.ServiceException) 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) PluginException(org.bimserver.shared.exceptions.PluginException) MessagingException(javax.mail.MessagingException) AddressException(javax.mail.internet.AddressException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) MalformedURLException(java.net.MalformedURLException) FileAlreadyExistsException(java.nio.file.FileAlreadyExistsException)

Example 98 with ServerException

use of org.bimserver.shared.exceptions.ServerException in project BIMserver by opensourceBIM.

the class ServiceImpl method validateModelChecker.

@Override
public void validateModelChecker(Long oid) throws UserException, ServerException {
    requireRealUserAuthentication();
    DatabaseSession session = getBimServer().getDatabase().createSession(OperationType.POSSIBLY_WRITE);
    try {
        BimDatabaseAction<Void> action = new ValidateModelCheckerDatabaseAction(getBimServer(), session, getInternalAccessMethod(), oid);
        session.executeAndCommitAction(action);
    } catch (Exception e) {
        handleException(e);
    } finally {
        session.close();
    }
}
Also used : ValidateModelCheckerDatabaseAction(org.bimserver.database.actions.ValidateModelCheckerDatabaseAction) DatabaseSession(org.bimserver.database.DatabaseSession) ServiceException(org.bimserver.shared.exceptions.ServiceException) 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) PluginException(org.bimserver.shared.exceptions.PluginException) MessagingException(javax.mail.MessagingException) AddressException(javax.mail.internet.AddressException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) MalformedURLException(java.net.MalformedURLException) FileAlreadyExistsException(java.nio.file.FileAlreadyExistsException)

Example 99 with ServerException

use of org.bimserver.shared.exceptions.ServerException in project BIMserver by opensourceBIM.

the class ServiceImpl method getAllServicesOfProject.

@Override
public List<org.bimserver.interfaces.objects.SService> getAllServicesOfProject(Long poid) throws ServerException, UserException {
    requireRealUserAuthentication();
    DatabaseSession session = getBimServer().getDatabase().createSession(OperationType.READ_ONLY);
    try {
        BimDatabaseAction<Set<org.bimserver.models.store.Service>> action = new GetAllServicesOfProjectDatabaseAction(session, getInternalAccessMethod(), poid);
        List<org.bimserver.interfaces.objects.SService> convertToSListRevision = getBimServer().getSConverter().convertToSListService(session.executeAndCommitAction(action));
        Collections.sort(convertToSListRevision, new SServiceComparator());
        return convertToSListRevision;
    } catch (Exception e) {
        return handleException(e);
    } finally {
        session.close();
    }
}
Also used : HashSet(java.util.HashSet) Set(java.util.Set) LinkedHashSet(java.util.LinkedHashSet) DatabaseSession(org.bimserver.database.DatabaseSession) GetAllServicesOfProjectDatabaseAction(org.bimserver.database.actions.GetAllServicesOfProjectDatabaseAction) SServiceComparator(org.bimserver.webservices.SServiceComparator) ServiceException(org.bimserver.shared.exceptions.ServiceException) 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) PluginException(org.bimserver.shared.exceptions.PluginException) MessagingException(javax.mail.MessagingException) AddressException(javax.mail.internet.AddressException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) MalformedURLException(java.net.MalformedURLException) FileAlreadyExistsException(java.nio.file.FileAlreadyExistsException)

Example 100 with ServerException

use of org.bimserver.shared.exceptions.ServerException in project BIMserver by opensourceBIM.

the class PluginServiceImpl method installPluginBundleFromUrl.

public void installPluginBundleFromUrl(String url, Boolean installAllPluginsForAllUsers, Boolean installAllPluginsForNewUsers) throws UserException, ServerException {
    requireRealUserAuthentication();
    DatabaseSession session = getBimServer().getDatabase().createSession(OperationType.POSSIBLY_WRITE);
    try {
        byte[] data = NetUtils.getContentAsBytes(new URL(url), 5000);
        session.executeAndCommitAction(new InstallPluginBundleFromBytes(session, getInternalAccessMethod(), getBimServer(), data, installAllPluginsForAllUsers, installAllPluginsForNewUsers));
    } catch (Exception e) {
        handleException(e);
    } finally {
        session.close();
    }
}
Also used : DatabaseSession(org.bimserver.database.DatabaseSession) URL(java.net.URL) InstallPluginBundleFromBytes(org.bimserver.database.actions.InstallPluginBundleFromBytes) UserException(org.bimserver.shared.exceptions.UserException) IOException(java.io.IOException) ServerException(org.bimserver.shared.exceptions.ServerException) BimserverDatabaseException(org.bimserver.BimserverDatabaseException)

Aggregations

ServerException (org.bimserver.shared.exceptions.ServerException)281 UserException (org.bimserver.shared.exceptions.UserException)277 BimserverDatabaseException (org.bimserver.BimserverDatabaseException)242 IOException (java.io.IOException)234 DatabaseSession (org.bimserver.database.DatabaseSession)234 ServiceException (org.bimserver.shared.exceptions.ServiceException)127 SerializerException (org.bimserver.plugins.serializers.SerializerException)124 PluginException (org.bimserver.shared.exceptions.PluginException)124 DeserializeException (org.bimserver.plugins.deserializers.DeserializeException)122 MalformedURLException (java.net.MalformedURLException)120 BcfException (org.opensourcebim.bcf.BcfException)120 UnsupportedEncodingException (java.io.UnsupportedEncodingException)119 FileAlreadyExistsException (java.nio.file.FileAlreadyExistsException)119 MessagingException (javax.mail.MessagingException)119 AddressException (javax.mail.internet.AddressException)119 CannotBeScheduledException (org.bimserver.longaction.CannotBeScheduledException)119 ArrayList (java.util.ArrayList)30 SProject (org.bimserver.interfaces.objects.SProject)30 User (org.bimserver.models.store.User)27 PublicInterfaceNotFoundException (org.bimserver.shared.exceptions.PublicInterfaceNotFoundException)24