Search in sources :

Example 61 with UserException

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

the class ServiceImpl method getProjectSmallByPoid.

@Override
public SProjectSmall getProjectSmallByPoid(Long poid) throws ServerException, UserException {
    requireAuthenticationAndRunningServer();
    DatabaseSession session = getBimServer().getDatabase().createSession();
    try {
        GetProjectByPoidDatabaseAction action = new GetProjectByPoidDatabaseAction(session, getInternalAccessMethod(), poid, getAuthorization());
        Project project = session.executeAndCommitAction(action);
        User user = session.get(getAuthorization().getUoid(), OldQuery.getDefault());
        return GetAllProjectsSmallDatabaseAction.createSmallProject(getAuthorization(), getBimServer(), project, user);
    } catch (Exception e) {
        return handleException(e);
    } finally {
        session.close();
    }
}
Also used : GetProjectByPoidDatabaseAction(org.bimserver.database.actions.GetProjectByPoidDatabaseAction) Project(org.bimserver.models.store.Project) SProject(org.bimserver.interfaces.objects.SProject) SUser(org.bimserver.interfaces.objects.SUser) User(org.bimserver.models.store.User) 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 62 with UserException

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

the class ServiceImpl method getArea.

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

Example 63 with UserException

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

the class ServiceImpl method getRevision.

@Override
public SRevision getRevision(Long roid) throws ServerException, UserException {
    requireAuthenticationAndRunningServer();
    DatabaseSession session = getBimServer().getDatabase().createSession();
    try {
        BimDatabaseAction<Revision> action = new GetRevisionDatabaseAction(session, getInternalAccessMethod(), roid, getAuthorization());
        return getBimServer().getSConverter().convertToSObject(session.executeAndCommitAction(action));
    } catch (Exception e) {
        return handleException(e);
    } finally {
        session.close();
    }
}
Also used : GetRevisionDatabaseAction(org.bimserver.database.actions.GetRevisionDatabaseAction) 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) 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 64 with UserException

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

the class ServiceImpl method checkout.

@Override
public Long checkout(Long roid, Long serializerOid, Boolean sync) throws ServerException, UserException {
    requireAuthenticationAndRunningServer();
    getAuthorization().canDownload(roid);
    DatabaseSession session = getBimServer().getDatabase().createSession();
    User user = null;
    try {
        SerializerPluginConfiguration serializerPluginConfiguration = (SerializerPluginConfiguration) session.get(serializerOid, OldQuery.getDefault());
        // org.bimserver.plugins.serializers.Serializer serializer = getBimServer().getEmfSerializerFactory().get(serializerOid).createSerializer(new org.bimserver.plugins.serializers.PluginConfiguration());
        if (serializerPluginConfiguration == null) {
            throw new UserException("No serializer with id " + serializerOid + " could be found");
        }
        if (!serializerPluginConfiguration.getPluginDescriptor().getPluginClassName().equals("org.bimserver.ifc.step.serializer.IfcStepSerializerPlugin") && !serializerPluginConfiguration.getPluginDescriptor().getPluginClassName().equals("org.bimserver.ifc.xml.serializer.IfcXmlSerializerPlugin")) {
            throw new UserException("Only IFC or IFCXML allowed when checking out");
        }
        DownloadParameters downloadParameters = new DownloadParameters(getBimServer(), DownloadType.DOWNLOAD_PROJECTS);
        downloadParameters.setRoid(roid);
        downloadParameters.setSerializerOid(serializerOid);
        user = (User) session.get(StorePackage.eINSTANCE.getUser(), getAuthorization().getUoid(), OldQuery.getDefault());
        LongDownloadOrCheckoutAction longDownloadAction = new LongCheckoutAction(getBimServer(), user.getName(), user.getUsername(), downloadParameters, getAuthorization(), getInternalAccessMethod());
        try {
            getBimServer().getLongActionManager().start(longDownloadAction);
        } catch (CannotBeScheduledException e) {
            LOGGER.error("", e);
        }
        if (sync) {
            longDownloadAction.waitForCompletion();
        }
        return longDownloadAction.getProgressTopic().getKey().getId();
    } catch (Exception e) {
        return handleException(e);
    } finally {
        session.close();
    }
}
Also used : LongCheckoutAction(org.bimserver.longaction.LongCheckoutAction) CannotBeScheduledException(org.bimserver.longaction.CannotBeScheduledException) LongDownloadOrCheckoutAction(org.bimserver.longaction.LongDownloadOrCheckoutAction) SUser(org.bimserver.interfaces.objects.SUser) User(org.bimserver.models.store.User) DatabaseSession(org.bimserver.database.DatabaseSession) SerializerPluginConfiguration(org.bimserver.models.store.SerializerPluginConfiguration) SSerializerPluginConfiguration(org.bimserver.interfaces.objects.SSerializerPluginConfiguration) 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) DownloadParameters(org.bimserver.longaction.DownloadParameters)

Example 65 with UserException

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

the class ServiceImpl method branchToExistingProject.

@Override
public Long branchToExistingProject(Long roid, Long destPoid, String comment, Boolean sync) throws UserException, ServerException {
    requireRealUserAuthentication();
    final DatabaseSession session = getBimServer().getDatabase().createSession();
    try {
        BranchToExistingProjectDatabaseAction action = new BranchToExistingProjectDatabaseAction(session, getInternalAccessMethod(), getBimServer(), getAuthorization(), roid, destPoid, comment);
        User user = (User) session.get(StorePackage.eINSTANCE.getUser(), getAuthorization().getUoid(), OldQuery.getDefault());
        String username = user.getName();
        String userUsername = user.getUsername();
        LongBranchAction longBranchAction = new LongBranchAction(getBimServer(), username, userUsername, getAuthorization(), action);
        getBimServer().getLongActionManager().start(longBranchAction);
        if (sync) {
            longBranchAction.waitForCompletion();
        }
        return longBranchAction.getProgressTopic().getKey().getId();
    } catch (Exception e) {
        return handleException(e);
    } finally {
        session.close();
    }
}
Also used : LongBranchAction(org.bimserver.longaction.LongBranchAction) SUser(org.bimserver.interfaces.objects.SUser) User(org.bimserver.models.store.User) DatabaseSession(org.bimserver.database.DatabaseSession) BranchToExistingProjectDatabaseAction(org.bimserver.database.actions.BranchToExistingProjectDatabaseAction) 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