Search in sources :

Example 71 with ServerException

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

the class ServiceImpl method getOidByGuid.

public Long getOidByGuid(Long roid, String guid) throws ServerException, UserException {
    requireAuthenticationAndRunningServer();
    DatabaseSession session = getBimServer().getDatabase().createSession(OperationType.READ_ONLY);
    try {
        BimDatabaseAction<Long> action = new GetOidByGuidDatabaseAction(session, getInternalAccessMethod(), roid, guid);
        return session.executeAndCommitAction(action);
    } catch (Exception e) {
        return handleException(e);
    } finally {
        session.close();
    }
}
Also used : GetOidByGuidDatabaseAction(org.bimserver.database.actions.GetOidByGuidDatabaseAction) 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 72 with ServerException

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

the class ServiceImpl method getGeometryInfo.

@Override
public SGeometryInfo getGeometryInfo(Long roid, Long oid) throws UserException, ServerException {
    requireAuthentication();
    DatabaseSession session = getBimServer().getDatabase().createSession(OperationType.READ_ONLY);
    try {
        BimDatabaseAction<SGeometryInfo> action = new GetGeometryInfoDatabaseAction(getBimServer(), session, getInternalAccessMethod(), roid, oid, getAuthorization());
        return session.executeAndCommitAction(action);
    } catch (Exception e) {
        return handleException(e);
    } finally {
        session.close();
    }
}
Also used : SGeometryInfo(org.bimserver.interfaces.objects.SGeometryInfo) DatabaseSession(org.bimserver.database.DatabaseSession) GetGeometryInfoDatabaseAction(org.bimserver.database.actions.GetGeometryInfoDatabaseAction) 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 73 with ServerException

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

the class ServiceImpl method getQueryEngineById.

@Override
public SQueryEnginePluginConfiguration getQueryEngineById(Long oid) throws ServerException, UserException {
    requireRealUserAuthentication();
    DatabaseSession session = getBimServer().getDatabase().createSession(OperationType.READ_ONLY);
    try {
        return getBimServer().getSConverter().convertToSObject(session.executeAndCommitAction(new GetQueryEngineByIdDatabaseAction(session, getInternalAccessMethod(), oid)));
    } catch (Exception e) {
        return handleException(e);
    } finally {
        session.close();
    }
}
Also used : DatabaseSession(org.bimserver.database.DatabaseSession) GetQueryEngineByIdDatabaseAction(org.bimserver.database.actions.GetQueryEngineByIdDatabaseAction) 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 74 with ServerException

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

the class ServiceImpl method addExtendedDataSchema.

@Override
public Long addExtendedDataSchema(SExtendedDataSchema extendedDataSchema) throws ServerException, UserException {
    // requireAdminAuthenticationAndRunningServer();
    DatabaseSession session = getBimServer().getDatabase().createSession(OperationType.POSSIBLY_WRITE);
    try {
        ExtendedDataSchema create = session.create(ExtendedDataSchema.class);
        ExtendedDataSchema convert = getBimServer().getSConverter().convertFromSObject(extendedDataSchema, create, session);
        return session.executeAndCommitAction(new AddExtendedDataSchemaDatabaseAction(session, getInternalAccessMethod(), convert));
    } catch (Exception e) {
        return handleException(e);
    } finally {
        session.close();
    }
}
Also used : DatabaseSession(org.bimserver.database.DatabaseSession) SExtendedDataSchema(org.bimserver.interfaces.objects.SExtendedDataSchema) ExtendedDataSchema(org.bimserver.models.store.ExtendedDataSchema) AddExtendedDataSchemaDatabaseAction(org.bimserver.database.actions.AddExtendedDataSchemaDatabaseAction) 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 75 with ServerException

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

the class ServiceImpl method listBoundingBoxes.

public List<SBounds> listBoundingBoxes(Set<Long> roids) throws ServerException, UserException {
    try (DatabaseSession session = getBimServer().getDatabase().createSession(OperationType.READ_ONLY)) {
        List<SBounds> results = new ArrayList<>();
        Set<Region> regions = new HashSet<>();
        for (long roid : roids) {
            Revision revision = session.get(roid, OldQuery.getDefault());
            for (ConcreteRevision concreteRevision : revision.getConcreteRevisions()) {
                Bounds bounds = concreteRevision.getBounds();
                if (bounds.getMin().getX() == Double.MAX_VALUE || bounds.getMin().getY() == Double.MAX_VALUE || bounds.getMin().getZ() == Double.MAX_VALUE || bounds.getMax().getX() == -Double.MAX_VALUE || bounds.getMax().getY() == -Double.MAX_VALUE || bounds.getMax().getZ() == -Double.MAX_VALUE) {
                    // Probably no objects or weird error, let's skip this one
                    continue;
                }
                scaleBounds(bounds, concreteRevision.getMultiplierToMm());
                boolean integrated = false;
                for (Region region : regions) {
                    if (region.canAccept(bounds)) {
                        region.integrate(bounds);
                        integrated = true;
                        break;
                    }
                }
                if (!integrated) {
                    Region region = new Region(bounds);
                    regions.add(region);
                }
            }
        }
        for (Region region : regions) {
            results.add(region.toSBounds());
        }
        return results;
    } catch (Exception e) {
        return handleException(e);
    }
}
Also used : DatabaseSession(org.bimserver.database.DatabaseSession) Bounds(org.bimserver.models.geometry.Bounds) SBounds(org.bimserver.interfaces.objects.SBounds) ArrayList(java.util.ArrayList) 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) SBounds(org.bimserver.interfaces.objects.SBounds) ConcreteRevision(org.bimserver.models.store.ConcreteRevision) SRevision(org.bimserver.interfaces.objects.SRevision) Revision(org.bimserver.models.store.Revision) CheckinRevision(org.bimserver.models.store.CheckinRevision) SExtendedDataAddedToRevision(org.bimserver.interfaces.objects.SExtendedDataAddedToRevision) ConcreteRevision(org.bimserver.models.store.ConcreteRevision) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet)

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