Search in sources :

Example 26 with DatabaseSession

use of org.bimserver.database.DatabaseSession in project BIMserver by opensourceBIM.

the class ServiceImpl method getCheckoutWarnings.

@Override
public Set<String> getCheckoutWarnings(Long poid) throws ServerException, UserException {
    requireRealUserAuthentication();
    DatabaseSession session = getBimServer().getDatabase().createSession();
    try {
        BimDatabaseAction<Set<String>> action = new GetCheckoutWarningsDatabaseAction(session, getInternalAccessMethod(), poid, getAuthorization());
        return session.executeAndCommitAction(action);
    } catch (Exception e) {
        return handleException(e);
    } finally {
        session.close();
    }
}
Also used : Set(java.util.Set) LinkedHashSet(java.util.LinkedHashSet) DatabaseSession(org.bimserver.database.DatabaseSession) GetCheckoutWarningsDatabaseAction(org.bimserver.database.actions.GetCheckoutWarningsDatabaseAction) 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 27 with DatabaseSession

use of org.bimserver.database.DatabaseSession in project BIMserver by opensourceBIM.

the class ServiceImpl method branchToNewProject.

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

use of org.bimserver.database.DatabaseSession in project BIMserver by opensourceBIM.

the class ServiceImpl method getAvailableClassesInRevision.

@Override
public List<String> getAvailableClassesInRevision(Long roid) throws ServerException, UserException {
    requireRealUserAuthentication();
    DatabaseSession session = getBimServer().getDatabase().createSession();
    try {
        BimDatabaseAction<List<String>> action = new GetAvailableClassesInRevisionDatabaseAction(getBimServer(), session, getInternalAccessMethod(), roid);
        return session.executeAndCommitAction(action);
    } catch (BimserverDatabaseException e) {
        handleException(e);
    } finally {
        session.close();
    }
    return null;
}
Also used : BimserverDatabaseException(org.bimserver.BimserverDatabaseException) DatabaseSession(org.bimserver.database.DatabaseSession) GetAvailableClassesInRevisionDatabaseAction(org.bimserver.database.actions.GetAvailableClassesInRevisionDatabaseAction) ArrayList(java.util.ArrayList) List(java.util.List) EList(org.eclipse.emf.common.util.EList)

Example 29 with DatabaseSession

use of org.bimserver.database.DatabaseSession 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();
    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) 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 30 with DatabaseSession

use of org.bimserver.database.DatabaseSession in project BIMserver by opensourceBIM.

the class ServiceImpl method getExtendedDataSchemaById.

@Override
public SExtendedDataSchema getExtendedDataSchemaById(Long oid) throws ServerException, UserException {
    requireAuthenticationAndRunningServer();
    DatabaseSession session = getBimServer().getDatabase().createSession();
    try {
        return getBimServer().getSConverter().convertToSObject(session.executeAndCommitAction(new GetExtendedDataSchemaByIdDatabaseAction(session, getInternalAccessMethod(), oid)));
    } catch (Exception e) {
        handleException(e);
    } finally {
        session.close();
    }
    return null;
}
Also used : DatabaseSession(org.bimserver.database.DatabaseSession) GetExtendedDataSchemaByIdDatabaseAction(org.bimserver.database.actions.GetExtendedDataSchemaByIdDatabaseAction) 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

DatabaseSession (org.bimserver.database.DatabaseSession)279 BimserverDatabaseException (org.bimserver.BimserverDatabaseException)258 UserException (org.bimserver.shared.exceptions.UserException)228 ServerException (org.bimserver.shared.exceptions.ServerException)217 IOException (java.io.IOException)194 DeserializeException (org.bimserver.plugins.deserializers.DeserializeException)105 SerializerException (org.bimserver.plugins.serializers.SerializerException)105 UnsupportedEncodingException (java.io.UnsupportedEncodingException)103 MalformedURLException (java.net.MalformedURLException)103 MessagingException (javax.mail.MessagingException)103 AddressException (javax.mail.internet.AddressException)103 CannotBeScheduledException (org.bimserver.longaction.CannotBeScheduledException)103 BcfException (org.opensourcebim.bcf.BcfException)103 User (org.bimserver.models.store.User)34 ArrayList (java.util.ArrayList)29 UserSettings (org.bimserver.models.store.UserSettings)29 Project (org.bimserver.models.store.Project)25 ServerSettings (org.bimserver.models.store.ServerSettings)21 ServerSettingsSetter (org.bimserver.database.actions.ServerSettingsSetter)18 SetServerSettingDatabaseAction (org.bimserver.database.actions.SetServerSettingDatabaseAction)18