Search in sources :

Example 1 with ServerSettingsSetter

use of org.bimserver.database.actions.ServerSettingsSetter in project BIMserver by opensourceBIM.

the class WebModuleManager method setDefault.

public void setDefault(Long oid) throws BimserverDatabaseException, UserException, ServerException {
    DatabaseSession session = bimServer.getDatabase().createSession();
    try {
        final WebModulePluginConfiguration defaultWebModule = session.get(StorePackage.eINSTANCE.getWebModulePluginConfiguration(), oid, OldQuery.getDefault());
        bimServer.setDefaultWebModule((WebModulePlugin) bimServer.getPluginManager().getPlugin(defaultWebModule.getPluginDescriptor().getPluginClassName(), true));
        SetServerSettingDatabaseAction action = new SetServerSettingDatabaseAction(bimServer, session, AccessMethod.INTERNAL, new ServerSettingsSetter() {

            @Override
            public void set(ServerSettings serverSettings) {
                serverSettings.setWebModule(defaultWebModule);
            }
        });
        session.executeAndCommitAction(action);
    } finally {
        session.close();
    }
}
Also used : ServerSettingsSetter(org.bimserver.database.actions.ServerSettingsSetter) DatabaseSession(org.bimserver.database.DatabaseSession) SetServerSettingDatabaseAction(org.bimserver.database.actions.SetServerSettingDatabaseAction) ServerSettings(org.bimserver.models.store.ServerSettings) WebModulePluginConfiguration(org.bimserver.models.store.WebModulePluginConfiguration)

Example 2 with ServerSettingsSetter

use of org.bimserver.database.actions.ServerSettingsSetter in project BIMserver by opensourceBIM.

the class SettingsServiceImpl method setAllowUsersToCreateTopLevelProjects.

@Override
public void setAllowUsersToCreateTopLevelProjects(final Boolean allowUsersToCreateTopLevelProjects) throws ServerException, UserException {
    requireAdminAuthenticationAndRunningServer();
    DatabaseSession session = getBimServer().getDatabase().createSession();
    try {
        SetServerSettingDatabaseAction action = new SetServerSettingDatabaseAction(getBimServer(), session, getInternalAccessMethod(), new ServerSettingsSetter() {

            @Override
            public void set(ServerSettings serverSettings) {
                serverSettings.setAllowUsersToCreateTopLevelProjects(allowUsersToCreateTopLevelProjects);
            }
        });
        session.executeAndCommitAction(action);
    } catch (BimserverDatabaseException e) {
        handleException(e);
    } finally {
        session.close();
    }
}
Also used : ServerSettingsSetter(org.bimserver.database.actions.ServerSettingsSetter) BimserverDatabaseException(org.bimserver.BimserverDatabaseException) DatabaseSession(org.bimserver.database.DatabaseSession) SetServerSettingDatabaseAction(org.bimserver.database.actions.SetServerSettingDatabaseAction) SServerSettings(org.bimserver.interfaces.objects.SServerSettings) ServerSettings(org.bimserver.models.store.ServerSettings)

Example 3 with ServerSettingsSetter

use of org.bimserver.database.actions.ServerSettingsSetter in project BIMserver by opensourceBIM.

the class SettingsServiceImpl method setEmailSenderAddress.

@Override
public void setEmailSenderAddress(final String emailSenderAddress) throws ServerException, UserException {
    if (getBimServer().getServerInfo().getServerState() != ServerState.NOT_SETUP) {
        requireAdminAuthentication();
    }
    if (emailSenderAddress.trim().isEmpty()) {
        throw new UserException("Email sender address cannot be empty");
    }
    DatabaseSession session = getBimServer().getDatabase().createSession();
    try {
        SetServerSettingDatabaseAction action = new SetServerSettingDatabaseAction(getBimServer(), session, getInternalAccessMethod(), new ServerSettingsSetter() {

            @Override
            public void set(ServerSettings serverSettings) {
                serverSettings.setEmailSenderAddress(emailSenderAddress);
            }
        });
        session.executeAndCommitAction(action);
    } catch (BimserverDatabaseException e) {
        handleException(e);
    } finally {
        session.close();
    }
}
Also used : ServerSettingsSetter(org.bimserver.database.actions.ServerSettingsSetter) BimserverDatabaseException(org.bimserver.BimserverDatabaseException) DatabaseSession(org.bimserver.database.DatabaseSession) SetServerSettingDatabaseAction(org.bimserver.database.actions.SetServerSettingDatabaseAction) SServerSettings(org.bimserver.interfaces.objects.SServerSettings) ServerSettings(org.bimserver.models.store.ServerSettings) UserException(org.bimserver.shared.exceptions.UserException)

Example 4 with ServerSettingsSetter

use of org.bimserver.database.actions.ServerSettingsSetter in project BIMserver by opensourceBIM.

the class SettingsServiceImpl method setAllowSelfRegistration.

@Override
public void setAllowSelfRegistration(final Boolean allowSelfRegistration) throws ServerException, UserException {
    requireAdminAuthenticationAndRunningServer();
    DatabaseSession session = getBimServer().getDatabase().createSession();
    try {
        SetServerSettingDatabaseAction action = new SetServerSettingDatabaseAction(getBimServer(), session, getInternalAccessMethod(), new ServerSettingsSetter() {

            @Override
            public void set(ServerSettings serverSettings) {
                serverSettings.setAllowSelfRegistration(allowSelfRegistration);
            }
        });
        session.executeAndCommitAction(action);
    } catch (BimserverDatabaseException e) {
        handleException(e);
    } finally {
        session.close();
    }
}
Also used : ServerSettingsSetter(org.bimserver.database.actions.ServerSettingsSetter) BimserverDatabaseException(org.bimserver.BimserverDatabaseException) DatabaseSession(org.bimserver.database.DatabaseSession) SetServerSettingDatabaseAction(org.bimserver.database.actions.SetServerSettingDatabaseAction) SServerSettings(org.bimserver.interfaces.objects.SServerSettings) ServerSettings(org.bimserver.models.store.ServerSettings)

Example 5 with ServerSettingsSetter

use of org.bimserver.database.actions.ServerSettingsSetter in project BIMserver by opensourceBIM.

the class SettingsServiceImpl method setProtocolBuffersPort.

@Override
public void setProtocolBuffersPort(final Integer port) throws ServerException, UserException {
    requireAdminAuthenticationAndRunningServer();
    DatabaseSession session = getBimServer().getDatabase().createSession();
    try {
        SetServerSettingDatabaseAction action = new SetServerSettingDatabaseAction(getBimServer(), session, getInternalAccessMethod(), new ServerSettingsSetter() {

            @Override
            public void set(ServerSettings serverSettings) {
                serverSettings.setProtocolBuffersPort(port);
            }
        });
        session.executeAndCommitAction(action);
    } catch (BimserverDatabaseException e) {
        handleException(e);
    } finally {
        session.close();
    }
}
Also used : ServerSettingsSetter(org.bimserver.database.actions.ServerSettingsSetter) BimserverDatabaseException(org.bimserver.BimserverDatabaseException) DatabaseSession(org.bimserver.database.DatabaseSession) SetServerSettingDatabaseAction(org.bimserver.database.actions.SetServerSettingDatabaseAction) SServerSettings(org.bimserver.interfaces.objects.SServerSettings) ServerSettings(org.bimserver.models.store.ServerSettings)

Aggregations

DatabaseSession (org.bimserver.database.DatabaseSession)18 ServerSettingsSetter (org.bimserver.database.actions.ServerSettingsSetter)18 SetServerSettingDatabaseAction (org.bimserver.database.actions.SetServerSettingDatabaseAction)18 ServerSettings (org.bimserver.models.store.ServerSettings)18 BimserverDatabaseException (org.bimserver.BimserverDatabaseException)17 SServerSettings (org.bimserver.interfaces.objects.SServerSettings)17 UserException (org.bimserver.shared.exceptions.UserException)4 WebModulePluginConfiguration (org.bimserver.models.store.WebModulePluginConfiguration)1 ServerException (org.bimserver.shared.exceptions.ServerException)1