diff --git a/openbis/dist/server/service.properties b/openbis/dist/server/service.properties index bc20f392eb9bfc3bb950a8a6c01828f7ecf3fb52..52f97a589c6c2fe15eaf72d196c9a009f8cd711d 100644 --- a/openbis/dist/server/service.properties +++ b/openbis/dist/server/service.properties @@ -164,6 +164,13 @@ cifex-url = https://cifex.ethz.ch:443 # cifex-recipient = id:dropboxuser, id:backpuser cifex-recipient = +# --------------------------------------------------------------------------- +# RPC Dropbox Default DSS configuration +# --------------------------------------------------------------------------- +# Set this to the DSS code of the DSS handling RPC Dropboxes for this user. +# Note: This is only required if more than one DSS is connected to this openBIS server. +dss-rpc.put.dss-code = + # --------------------------------------------------------------------------- # Hibernate Search # --------------------------------------------------------------------------- diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/AbstractServer.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/AbstractServer.java index ad201071eba6e7adbecb8b5b61625d34e4573597..d17ec12802a32e21806ad2c5e539272880ba6b55 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/AbstractServer.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/AbstractServer.java @@ -33,6 +33,7 @@ import java.util.concurrent.TimeUnit; import javax.annotation.Resource; +import org.apache.commons.lang.StringUtils; import org.springframework.dao.DataAccessException; import org.springframework.transaction.annotation.Transactional; @@ -206,7 +207,7 @@ public abstract class AbstractServer<T> extends AbstractServiceWithLogger<T> imp public final void setUserForAnonymousLogin(String userID) { - userForAnonymousLogin = userID != null && userID.startsWith("$") == false ? userID : null; + userForAnonymousLogin = isResolved(userID) ? userID : null; } public final void setCISDHelpdeskEmail(String cisdHelpdeskEmail) @@ -996,4 +997,10 @@ public abstract class AbstractServer<T> extends AbstractServiceWithLogger<T> imp { return subject + " (initiated at " + startDate + ")"; } + + static boolean isResolved(String name) + { + return StringUtils.isNotBlank(name) && name.startsWith("${") == false; + } + } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/CommonServer.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/CommonServer.java index 32c0316384086f841687d94771779774d5d88897..e21ed5eeae6ef856988b130f28a0f467a9120221 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/CommonServer.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/CommonServer.java @@ -39,7 +39,7 @@ import org.springframework.dao.DataIntegrityViolationException; import ch.systemsx.cisd.authentication.IAuthenticationService; import ch.systemsx.cisd.authentication.ISessionManager; -import ch.systemsx.cisd.common.exceptions.EnvironmentFailureException; +import ch.systemsx.cisd.common.exceptions.ConfigurationFailureException; import ch.systemsx.cisd.common.exceptions.UserFailureException; import ch.systemsx.cisd.common.mail.IMailClient; import ch.systemsx.cisd.common.mail.MailClient; @@ -341,6 +341,8 @@ public final class CommonServer extends AbstractCommonServer<ICommonServerForInt private final IDataStoreServiceRegistrator dataStoreServiceRegistrator; + private String defaultPutDataStoreServerCodeOrNull; + public CommonServer(final IAuthenticationService authenticationService, final ISessionManager<Session> sessionManager, final IDAOFactory daoFactory, final ICommonBusinessObjectFactory businessObjectFactory, @@ -3461,14 +3463,42 @@ public final class CommonServer extends AbstractCommonServer<ICommonServerForInt checkSession(sessionToken); IDataStoreDAO dataStoreDAO = getDAOFactory().getDataStoreDAO(); List<DataStorePE> dataStores = dataStoreDAO.listDataStores(); - if (dataStores.size() != 1) + // Easy case: exactly one DSS + if (dataStores.size() == 1) + { + return dataStores.get(0).getDownloadUrl(); + } + // Error: No DSS at all + if (dataStores.isEmpty()) { - throw EnvironmentFailureException - .fromTemplate( - "Expected exactly one Data Store Server to be registered in openBIS but found %s.", + throw new ConfigurationFailureException("No Data Store Server registered to openBIS."); + } + // More than one DSS: see whether dss-rpc.put.dss-code is configured to tell us which one to + // use. + if (defaultPutDataStoreServerCodeOrNull == null) + { + throw ConfigurationFailureException + .fromTemplate + ("There are %d Data Store Servers registered in openBIS, but property dss-rpc.put.dss-code is not set.", dataStores.size()); } - return dataStores.get(0).getDownloadUrl(); + for (DataStorePE store : dataStores) + { + if (defaultPutDataStoreServerCodeOrNull.equalsIgnoreCase(store.getCode())) + { + return store.getDownloadUrl(); + } + } + throw ConfigurationFailureException + .fromTemplate( + "Property dss-rpc.put.dss-code is set to '%s', but no Data Store Server with that code is known.", + defaultPutDataStoreServerCodeOrNull); + } + + public void setDefaultPutDataStoreServerCode(String defaultPutDataStoreServerCode) + { + this.defaultPutDataStoreServerCodeOrNull = + isResolved(defaultPutDataStoreServerCode) ? defaultPutDataStoreServerCode : null; } @Override diff --git a/openbis/source/java/genericApplicationContext.xml b/openbis/source/java/genericApplicationContext.xml index 1ca5fc4f561c5cb3b3613d3a75311b8565440b1f..9861c09abba5f698c44ef791a4ae598936a8cdb1 100644 --- a/openbis/source/java/genericApplicationContext.xml +++ b/openbis/source/java/genericApplicationContext.xml @@ -137,6 +137,7 @@ <constructor-arg ref="last-modification-state" /> <property name="userForAnonymousLogin" value="${user-for-anonymous-login}"/> <property name="CISDHelpdeskEmail" value="cisd.helpdesk@bsse.ethz.ch" /> + <property name="defaultPutDataStoreServerCode" value="${dss-rpc.put.dss-code}" /> </bean> <bean id="web-client-configuration-provider"