Search in sources :

Example 21 with ServerSettings

use of org.bimserver.models.store.ServerSettings in project BIMserver by opensourceBIM.

the class SettingsServiceImpl method setSmtpServer.

@Override
public void setSmtpServer(final String smtpServer) throws ServerException, UserException {
    if (getBimServer().getServerInfo().getServerState() != ServerState.NOT_SETUP) {
        requireAdminAuthentication();
    }
    if (smtpServer.trim().isEmpty()) {
        throw new UserException("SMTP server 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.setSmtpServer(smtpServer);
            }
        });
        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 22 with ServerSettings

use of org.bimserver.models.store.ServerSettings in project BIMserver by opensourceBIM.

the class SettingsServiceImpl method setServerIcon.

@Override
public void setServerIcon(final String serverIcon) throws ServerException, UserException {
    if (getBimServer().getServerInfo().getServerState() != ServerState.NOT_SETUP) {
        requireAdminAuthentication();
    }
    DatabaseSession session = getBimServer().getDatabase().createSession();
    try {
        SetServerSettingDatabaseAction action = new SetServerSettingDatabaseAction(getBimServer(), session, getInternalAccessMethod(), new ServerSettingsSetter() {

            @Override
            public void set(ServerSettings serverSettings) {
                serverSettings.setIcon(serverIcon);
            }
        });
        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 23 with ServerSettings

use of org.bimserver.models.store.ServerSettings in project BIMserver by opensourceBIM.

the class SettingsServiceImpl method setServerDescription.

@Override
public void setServerDescription(final String serverDescription) throws ServerException, UserException {
    if (getBimServer().getServerInfo().getServerState() != ServerState.NOT_SETUP) {
        requireAdminAuthentication();
    }
    DatabaseSession session = getBimServer().getDatabase().createSession();
    try {
        SetServerSettingDatabaseAction action = new SetServerSettingDatabaseAction(getBimServer(), session, getInternalAccessMethod(), new ServerSettingsSetter() {

            @Override
            public void set(ServerSettings serverSettings) {
                serverSettings.setDescription(serverDescription);
            }
        });
        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 24 with ServerSettings

use of org.bimserver.models.store.ServerSettings in project BIMserver by opensourceBIM.

the class SettingsServiceImpl method setWhiteListedDomains.

@Override
public void setWhiteListedDomains(final List<String> domains) throws ServerException, UserException {
    DatabaseSession session = getBimServer().getDatabase().createSession();
    try {
        SetServerSettingDatabaseAction action = new SetServerSettingDatabaseAction(getBimServer(), session, getInternalAccessMethod(), new ServerSettingsSetter() {

            @Override
            public void set(ServerSettings serverSettings) {
                serverSettings.getWhitelistedDomains().clear();
                serverSettings.getWhitelistedDomains().addAll(domains);
            }
        });
        session.executeAndCommitAction(action);
        getBimServer().getServerSettingsCache().updateCache();
    } catch (Exception e) {
        handleException(e);
    } finally {
        session.close();
    }
}
Also used : ServerSettingsSetter(org.bimserver.database.actions.ServerSettingsSetter) 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) ServerException(org.bimserver.shared.exceptions.ServerException) BimserverDatabaseException(org.bimserver.BimserverDatabaseException)

Example 25 with ServerSettings

use of org.bimserver.models.store.ServerSettings in project BIMserver by opensourceBIM.

the class SettingsServiceImpl method setServerName.

@Override
public void setServerName(final String serverName) throws ServerException, UserException {
    if (getBimServer().getServerInfo().getServerState() != ServerState.NOT_SETUP) {
        requireAdminAuthentication();
    }
    DatabaseSession session = getBimServer().getDatabase().createSession();
    try {
        SetServerSettingDatabaseAction action = new SetServerSettingDatabaseAction(getBimServer(), session, getInternalAccessMethod(), new ServerSettingsSetter() {

            @Override
            public void set(ServerSettings serverSettings) {
                serverSettings.setName(serverName);
            }
        });
        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

ServerSettings (org.bimserver.models.store.ServerSettings)29 BimserverDatabaseException (org.bimserver.BimserverDatabaseException)21 DatabaseSession (org.bimserver.database.DatabaseSession)21 ServerSettingsSetter (org.bimserver.database.actions.ServerSettingsSetter)18 SetServerSettingDatabaseAction (org.bimserver.database.actions.SetServerSettingDatabaseAction)18 SServerSettings (org.bimserver.interfaces.objects.SServerSettings)18 UserException (org.bimserver.shared.exceptions.UserException)10 User (org.bimserver.models.store.User)5 ServerException (org.bimserver.shared.exceptions.ServerException)5 Date (java.util.Date)4 HashMap (java.util.HashMap)3 BimserverLockConflictException (org.bimserver.database.BimserverLockConflictException)3 IOException (java.io.IOException)2 URL (java.net.URL)2 ArrayList (java.util.ArrayList)2 GregorianCalendar (java.util.GregorianCalendar)2 Map (java.util.Map)2 InternetAddress (javax.mail.internet.InternetAddress)2 PostCommitAction (org.bimserver.database.PostCommitAction)2 DatabaseInitException (org.bimserver.database.berkeley.DatabaseInitException)2