Search in sources :

Example 66 with UserException

use of org.bimserver.shared.exceptions.UserException 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();
    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) 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)

Example 67 with UserException

use of org.bimserver.shared.exceptions.UserException 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();
    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) 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)

Example 68 with UserException

use of org.bimserver.shared.exceptions.UserException 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();
    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) 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) 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 69 with UserException

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

the class ServiceImpl method getAllCheckoutsOfRevision.

@Override
public List<SCheckout> getAllCheckoutsOfRevision(Long roid) throws ServerException, UserException {
    requireRealUserAuthentication();
    DatabaseSession session = getBimServer().getDatabase().createSession();
    try {
        BimDatabaseAction<List<Checkout>> action = new GetAllCheckoutsOfRevisionDatabaseAction(session, getInternalAccessMethod(), roid);
        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) GetAllCheckoutsOfRevisionDatabaseAction(org.bimserver.database.actions.GetAllCheckoutsOfRevisionDatabaseAction) 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)

Example 70 with UserException

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

the class ServiceImpl method triggerNewRevision.

@Override
public void triggerNewRevision(Long roid, Long soid) throws ServerException, UserException {
    DatabaseSession session = getBimServer().getDatabase().createSession();
    try {
        Revision revision = (Revision) session.get(StorePackage.eINSTANCE.getRevision(), roid, OldQuery.getDefault());
        if (revision == null) {
            throw new UserException("No revision found for roid " + roid);
        }
        getBimServer().getNotificationsManager().notify(new NewRevisionNotification(getBimServer(), revision.getProject().getOid(), revision.getOid(), soid));
    } catch (Exception e) {
        handleException(e);
    } finally {
        session.close();
    }
}
Also used : NewRevisionNotification(org.bimserver.notifications.NewRevisionNotification) SRevision(org.bimserver.interfaces.objects.SRevision) Revision(org.bimserver.models.store.Revision) CheckinRevision(org.bimserver.models.store.CheckinRevision) SExtendedDataAddedToRevision(org.bimserver.interfaces.objects.SExtendedDataAddedToRevision) DatabaseSession(org.bimserver.database.DatabaseSession) UserException(org.bimserver.shared.exceptions.UserException) 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

UserException (org.bimserver.shared.exceptions.UserException)362 ServerException (org.bimserver.shared.exceptions.ServerException)253 BimserverDatabaseException (org.bimserver.BimserverDatabaseException)241 DatabaseSession (org.bimserver.database.DatabaseSession)227 IOException (java.io.IOException)220 SerializerException (org.bimserver.plugins.serializers.SerializerException)113 DeserializeException (org.bimserver.plugins.deserializers.DeserializeException)112 MalformedURLException (java.net.MalformedURLException)109 MessagingException (javax.mail.MessagingException)109 BcfException (org.opensourcebim.bcf.BcfException)109 UnsupportedEncodingException (java.io.UnsupportedEncodingException)108 AddressException (javax.mail.internet.AddressException)108 CannotBeScheduledException (org.bimserver.longaction.CannotBeScheduledException)108 User (org.bimserver.models.store.User)65 Project (org.bimserver.models.store.Project)48 Revision (org.bimserver.models.store.Revision)39 ArrayList (java.util.ArrayList)35 Date (java.util.Date)34 SProject (org.bimserver.interfaces.objects.SProject)31 PackageMetaData (org.bimserver.emf.PackageMetaData)30