Search in sources :

Example 86 with ServerException

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

the class ServiceImpl method getModelBounds.

@Override
public SBounds getModelBounds(Long roid) throws ServerException, UserException {
    DatabaseSession session = getBimServer().getDatabase().createSession(OperationType.READ_ONLY);
    try {
        Revision revision = session.get(roid, OldQuery.getDefault());
        ConcreteRevision lastConcreteRevision = revision.getLastConcreteRevision();
        Bounds bounds = lastConcreteRevision.getBounds();
        Vector3f min = bounds.getMin();
        Vector3f max = bounds.getMax();
        if (lastConcreteRevision.getMultiplierToMm() != 1f) {
            min.setX(min.getX() * lastConcreteRevision.getMultiplierToMm());
            min.setY(min.getY() * lastConcreteRevision.getMultiplierToMm());
            min.setZ(min.getZ() * lastConcreteRevision.getMultiplierToMm());
            max.setX(max.getX() * lastConcreteRevision.getMultiplierToMm());
            max.setY(max.getY() * lastConcreteRevision.getMultiplierToMm());
            max.setZ(max.getZ() * lastConcreteRevision.getMultiplierToMm());
        }
        return getBimServer().getSConverter().convertToSObject(bounds);
    } catch (Exception e) {
        return handleException(e);
    } finally {
        session.close();
    }
}
Also used : 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) DatabaseSession(org.bimserver.database.DatabaseSession) Bounds(org.bimserver.models.geometry.Bounds) SBounds(org.bimserver.interfaces.objects.SBounds) SVector3f(org.bimserver.interfaces.objects.SVector3f) Vector3f(org.bimserver.models.geometry.Vector3f) 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 87 with ServerException

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

the class ServiceImpl method sendCompareEmail.

@Override
public void sendCompareEmail(SCompareType sCompareType, Long mcid, Long poid, Long roid1, Long roid2, String address) throws ServerException, UserException {
    requireRealUserAuthentication();
    DatabaseSession session = getBimServer().getDatabase().createSession(OperationType.READ_ONLY);
    try {
        SUser currentUser = getCurrentUser(session);
        Revision revision1 = session.get(StorePackage.eINSTANCE.getRevision(), roid1, OldQuery.getDefault());
        Revision revision2 = session.get(StorePackage.eINSTANCE.getRevision(), roid2, OldQuery.getDefault());
        String senderName = currentUser.getName();
        String senderAddress = currentUser.getUsername();
        if (!senderAddress.contains("@") || !senderAddress.contains(".")) {
            senderAddress = getBimServer().getServerSettingsCache().getServerSettings().getEmailSenderAddress();
        }
        EmailMessage message = getBimServer().getMailSystem().createMessage();
        try {
            InternetAddress addressFrom = new InternetAddress(senderAddress);
            addressFrom.setPersonal(senderName);
            message.setFrom(addressFrom);
            InternetAddress[] addressTo = new InternetAddress[1];
            addressTo[0] = new InternetAddress(address);
            message.setRecipients(Message.RecipientType.TO, addressTo);
            message.setSubject("BIMserver Model Comparator");
            SCompareResult compareResult = compare(roid1, roid2, sCompareType, mcid);
            String html = CompareWriter.writeCompareResult(compareResult, revision1.getId(), revision2.getId(), sCompareType, getServiceMap().getServiceInterface().getProjectByPoid(poid), false);
            message.setContent(html, "text/html");
            message.send();
        } catch (AddressException e) {
            throw new UserException(e);
        } catch (UnsupportedEncodingException e) {
            throw new UserException(e);
        } catch (MessagingException e) {
            throw new UserException(e);
        }
    } catch (Exception e) {
        handleException(e);
    } finally {
        session.close();
    }
}
Also used : EmailMessage(org.bimserver.mail.EmailMessage) InternetAddress(javax.mail.internet.InternetAddress) DatabaseSession(org.bimserver.database.DatabaseSession) MessagingException(javax.mail.MessagingException) SUser(org.bimserver.interfaces.objects.SUser) UnsupportedEncodingException(java.io.UnsupportedEncodingException) 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) 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) AddressException(javax.mail.internet.AddressException) SCompareResult(org.bimserver.interfaces.objects.SCompareResult) UserException(org.bimserver.shared.exceptions.UserException)

Example 88 with ServerException

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

the class ServiceImpl method getAllAuthorizedUsersOfProject.

@Override
public List<SUser> getAllAuthorizedUsersOfProject(Long poid) throws ServerException, UserException {
    requireRealUserAuthentication();
    DatabaseSession session = getBimServer().getDatabase().createSession(OperationType.READ_ONLY);
    try {
        BimDatabaseAction<Set<User>> action = new GetAllAuthorizedUsersOfProjectDatabaseAction(session, getInternalAccessMethod(), poid);
        return new ArrayList<SUser>(getBimServer().getSConverter().convertToSSetUser(session.executeAndCommitAction(action)));
    } 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) GetAllAuthorizedUsersOfProjectDatabaseAction(org.bimserver.database.actions.GetAllAuthorizedUsersOfProjectDatabaseAction) 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)

Example 89 with ServerException

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

the class ServiceImpl method getSerializerByName.

@Override
public SSerializerPluginConfiguration getSerializerByName(String serializerName) throws ServerException, UserException {
    requireAuthentication();
    DatabaseSession session = getBimServer().getDatabase().createSession(OperationType.READ_ONLY);
    try {
        return getBimServer().getSConverter().convertToSObject(session.executeAndCommitAction(new GetSerializerByNameDatabaseAction(session, getInternalAccessMethod(), serializerName)));
    } catch (Exception e) {
        handleException(e);
    } finally {
        session.close();
    }
    return null;
}
Also used : DatabaseSession(org.bimserver.database.DatabaseSession) GetSerializerByNameDatabaseAction(org.bimserver.database.actions.GetSerializerByNameDatabaseAction) 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 90 with ServerException

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

the class ServiceImpl method addExtendedDataToRevision.

@Override
public void addExtendedDataToRevision(Long roid, SExtendedData extendedData) throws ServerException, UserException {
    requireAuthenticationAndRunningServer();
    DatabaseSession session = getBimServer().getDatabase().createSession(OperationType.POSSIBLY_WRITE);
    try {
        ExtendedData convert = getBimServer().getSConverter().convertFromSObject(extendedData, session.create(ExtendedData.class), session);
        session.executeAndCommitAction(new AddExtendedDataToRevisionDatabaseAction(getBimServer(), session, getInternalAccessMethod(), roid, getAuthorization(), convert));
    } catch (Exception e) {
        handleException(e);
    } finally {
        session.close();
    }
}
Also used : ExtendedData(org.bimserver.models.store.ExtendedData) StoreExtendedData(org.bimserver.models.store.StoreExtendedData) SExtendedData(org.bimserver.interfaces.objects.SExtendedData) DatabaseSession(org.bimserver.database.DatabaseSession) AddExtendedDataToRevisionDatabaseAction(org.bimserver.database.actions.AddExtendedDataToRevisionDatabaseAction) 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)

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