Search in sources :

Example 86 with DatabaseSession

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

the class PluginServiceImpl method getAllWebModulePluginDescriptors.

@Override
public List<SPluginDescriptor> getAllWebModulePluginDescriptors() throws UserException, ServerException {
    requireRealUserAuthentication();
    requireRealUserAuthentication();
    DatabaseSession session = getBimServer().getDatabase().createSession();
    try {
        return session.executeAndCommitAction(new GetAllPluginDescriptorsDatabaseAction(session, getInternalAccessMethod(), getBimServer(), WebModulePlugin.class.getName()));
    } catch (Exception e) {
        return handleException(e);
    } finally {
        session.close();
    }
}
Also used : DatabaseSession(org.bimserver.database.DatabaseSession) GetAllPluginDescriptorsDatabaseAction(org.bimserver.database.actions.GetAllPluginDescriptorsDatabaseAction) IOException(java.io.IOException) ServerException(org.bimserver.shared.exceptions.ServerException) BimserverDatabaseException(org.bimserver.BimserverDatabaseException) UserException(org.bimserver.shared.exceptions.UserException)

Example 87 with DatabaseSession

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

the class PluginServiceImpl method getModelMergerById.

@Override
public SModelMergerPluginConfiguration getModelMergerById(Long oid) throws ServerException, UserException {
    requireRealUserAuthentication();
    DatabaseSession session = getBimServer().getDatabase().createSession();
    try {
        return getBimServer().getSConverter().convertToSObject(session.executeAndCommitAction(new GetModelMergerByIdDatabaseAction(session, getInternalAccessMethod(), oid)));
    } catch (Exception e) {
        return handleException(e);
    } finally {
        session.close();
    }
}
Also used : DatabaseSession(org.bimserver.database.DatabaseSession) GetModelMergerByIdDatabaseAction(org.bimserver.database.actions.GetModelMergerByIdDatabaseAction) IOException(java.io.IOException) ServerException(org.bimserver.shared.exceptions.ServerException) BimserverDatabaseException(org.bimserver.BimserverDatabaseException) UserException(org.bimserver.shared.exceptions.UserException)

Example 88 with DatabaseSession

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

the class PluginServiceImpl method getWebModuleByName.

@Override
public SWebModulePluginConfiguration getWebModuleByName(String name) throws ServerException, UserException {
    requireAuthentication();
    DatabaseSession session = getBimServer().getDatabase().createSession();
    try {
        return getBimServer().getSConverter().convertToSObject(session.executeAndCommitAction(new GetWebModuleByNameDatabaseAction(session, getInternalAccessMethod(), name)));
    } catch (Exception e) {
        handleException(e);
    } finally {
        session.close();
    }
    return null;
}
Also used : DatabaseSession(org.bimserver.database.DatabaseSession) GetWebModuleByNameDatabaseAction(org.bimserver.database.actions.GetWebModuleByNameDatabaseAction) IOException(java.io.IOException) ServerException(org.bimserver.shared.exceptions.ServerException) BimserverDatabaseException(org.bimserver.BimserverDatabaseException) UserException(org.bimserver.shared.exceptions.UserException)

Example 89 with DatabaseSession

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

the class PluginServiceImpl method setDefaultModelMerger.

public void setDefaultModelMerger(final Long oid) throws ServerException, UserException {
    requireRealUserAuthentication();
    DatabaseSession session = getBimServer().getDatabase().createSession();
    try {
        SetUserSettingDatabaseAction action = new SetUserSettingDatabaseAction(session, getInternalAccessMethod(), getAuthorization(), new UserSettingsSetter() {

            @Override
            public void set(UserSettings userSettings) {
                userSettings.setDefaultModelMerger(find(userSettings.getModelMergers(), oid));
            }
        });
        session.executeAndCommitAction(action);
    } catch (BimserverDatabaseException e) {
        handleException(e);
    } finally {
        session.close();
    }
}
Also used : BimserverDatabaseException(org.bimserver.BimserverDatabaseException) UserSettingsSetter(org.bimserver.database.actions.UserSettingsSetter) DatabaseSession(org.bimserver.database.DatabaseSession) UserSettings(org.bimserver.models.store.UserSettings) SetUserSettingDatabaseAction(org.bimserver.database.actions.SetUserSettingDatabaseAction)

Example 90 with DatabaseSession

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

the class PluginServiceImpl method installPluginBundleFromUrl.

public void installPluginBundleFromUrl(String url, Boolean installAllPluginsForAllUsers, Boolean installAllPluginsForNewUsers) throws UserException, ServerException {
    requireRealUserAuthentication();
    DatabaseSession session = getBimServer().getDatabase().createSession();
    try {
        byte[] data = NetUtils.getContentAsBytes(new URL(url), 5000);
        session.executeAndCommitAction(new InstallPluginBundleFromBytes(session, getInternalAccessMethod(), getBimServer(), data, installAllPluginsForAllUsers, installAllPluginsForNewUsers));
    } catch (Exception e) {
        handleException(e);
    } finally {
        session.close();
    }
}
Also used : DatabaseSession(org.bimserver.database.DatabaseSession) URL(java.net.URL) InstallPluginBundleFromBytes(org.bimserver.database.actions.InstallPluginBundleFromBytes) IOException(java.io.IOException) ServerException(org.bimserver.shared.exceptions.ServerException) BimserverDatabaseException(org.bimserver.BimserverDatabaseException) UserException(org.bimserver.shared.exceptions.UserException)

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