use of org.bimserver.BimserverDatabaseException in project BIMserver by opensourceBIM.
the class AdminServiceImpl method setup.
@Override
public void setup(String siteAddress, String serverName, String serverDescription, String serverIcon, String adminName, String adminUsername, String adminPassword) throws ServerException, UserException {
SettingsInterface settingsInterface = getServiceMap().get(SettingsInterface.class);
if (!siteAddress.startsWith("http://") && !siteAddress.startsWith("https://")) {
throw new UserException("Site address should start with \"http://\" or \"https://\"");
}
if (siteAddress.startsWith("http://http://") || siteAddress.startsWith("https://https://")) {
throw new UserException("Site address should not have duplicate protocols");
}
settingsInterface.setSiteAddress(siteAddress);
settingsInterface.setServerName(serverName);
settingsInterface.setServerDescription(serverDescription);
settingsInterface.setServerIcon(serverIcon);
if (adminUsername.trim().isEmpty()) {
throw new UserException("Admin Username cannot be empty");
}
if (adminPassword.trim().isEmpty()) {
throw new UserException("Admin Password cannot be empty");
}
DatabaseSession session = getBimServer().getDatabase().createSession();
try {
AddUserDatabaseAction addUserDatabaseAction = new AddUserDatabaseAction(getBimServer(), session, AccessMethod.INTERNAL, adminUsername, adminPassword, adminName, UserType.ADMIN, getAuthorization(), false, "");
session.executeAndCommitAction(addUserDatabaseAction);
} catch (BimserverDatabaseException e) {
LOGGER.error("", e);
} finally {
session.close();
}
getBimServer().getServerInfoManager().update();
}
use of org.bimserver.BimserverDatabaseException 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;
}
use of org.bimserver.BimserverDatabaseException 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();
}
}
use of org.bimserver.BimserverDatabaseException 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();
}
}
use of org.bimserver.BimserverDatabaseException 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();
}
}
Aggregations