diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/api/v1/GeneralInformationService.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/api/v1/GeneralInformationService.java index 77a9be667a8c4819752f8994b609702d97206ee1..cbb24e6421d5fdad0d886d8978ca90f0af4fb437 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/api/v1/GeneralInformationService.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/api/v1/GeneralInformationService.java @@ -73,6 +73,7 @@ import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataSet.Connections; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataSetFetchOption; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataSetFetchOptions; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataSetType; +import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataStoreForDataSets; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.Experiment; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.Material; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.MaterialIdentifier; @@ -220,7 +221,7 @@ public class GeneralInformationService extends AbstractServer<IGeneralInformatio @Override public int getMinorVersion() { - return 18; + return 19; } private Map<String, List<RoleAssignmentPE>> getRoleAssignmentsPerSpace() @@ -586,14 +587,27 @@ public class GeneralInformationService extends AbstractServer<IGeneralInformatio { checkSession(sessionToken); - IDataDAO dataDAO = getDAOFactory().getDataDAO(); - DataPE data = dataDAO.tryToFindDataSetByCode(dataSetCode); - if (data == null) + final IDataSetLister lister = new DataSetLister(getDAOFactory()); + final List<DataStoreForDataSets> dataStores = + lister.getDataStoreBaseURLs(Collections.singletonList(dataSetCode)); + if (dataStores.isEmpty()) { return null; } + return dataStores.get(0).getDataStoreDownloadURL(); + } + + @Override + @Transactional(readOnly = true) + @RolesAllowed(value = + { RoleWithHierarchy.SPACE_OBSERVER, RoleWithHierarchy.SPACE_ETL_SERVER }) + public List<DataStoreForDataSets> getDataStoreBaseURLs(String sessionToken, + List<String> dataSetCodes) + { + checkSession(sessionToken); - return data.getDataStore().getDownloadUrl(); + final IDataSetLister lister = new DataSetLister(getDAOFactory()); + return lister.getDataStoreBaseURLs(dataSetCodes); } @Override @@ -793,7 +807,7 @@ public class GeneralInformationService extends AbstractServer<IGeneralInformatio DataSetFetchOption.CHILDREN)) { checkSession(sessionToken); - IDataSetLister lister = new DataSetLister(getDAOFactory()); + final IDataSetLister lister = new DataSetLister(getDAOFactory()); return lister.getDataSetMetaData(dataSetCodes, dataSetFetchOptions); } else { @@ -1002,4 +1016,5 @@ public class GeneralInformationService extends AbstractServer<IGeneralInformatio return result; } + } diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/api/v1/GeneralInformationServiceLogger.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/api/v1/GeneralInformationServiceLogger.java index f4980b7437b2cfc43e1e1b54b8c616f9c7ad92ce..575c32799815cbded3124ea8a398d3b2e87ebbf4 100644 --- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/api/v1/GeneralInformationServiceLogger.java +++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/api/v1/GeneralInformationServiceLogger.java @@ -31,6 +31,7 @@ import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataSet; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataSet.Connections; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataSetFetchOption; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataSetType; +import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataStoreForDataSets; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.Experiment; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.Material; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.MaterialIdentifier; @@ -203,6 +204,15 @@ class GeneralInformationServiceLogger extends AbstractServerLogger implements return null; } + @Override + public List<DataStoreForDataSets> getDataStoreBaseURLs(String sessionToken, + List<String> dataSetCodes) + { + logAccess(sessionToken, "get-data-store-base-urls", "DATA_SETS(%s)", + abbreviate(dataSetCodes)); + return null; + } + @Override public List<DataSetType> listDataSetTypes(String sessionToken) { diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/business/bo/fetchoptions/datasetlister/DataSetListerTest.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/business/bo/fetchoptions/datasetlister/DataSetListerTest.java index 4b40bf1741a2e3aa88d96633b6de9e4d0c1d1643..cd969721383c28afdd6090aa88aeb1baed8f354b 100644 --- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/business/bo/fetchoptions/datasetlister/DataSetListerTest.java +++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/business/bo/fetchoptions/datasetlister/DataSetListerTest.java @@ -141,11 +141,12 @@ public class DataSetListerTest extends AbstractDAOTest codes.add("20081105092259000-20"); codes.add("20081105092259000-21"); List<DataStoreForDataSets> result = lister.getDataStoreBaseURLs(codes); - assertEquals("http://download_1", result.get(0).getDataStoreBaseURL()); + assertEquals(2, result.size()); + assertEquals("http://download_1", result.get(0).getDataStoreDownloadURL()); assertEquals( Arrays.asList("20081105092159188-3", "20081105092159111-1", "20081105092259000-19"), result.get(0).getDataSetCodes()); - assertEquals("http://download_2", result.get(1).getDataStoreBaseURL()); + assertEquals("http://download_2", result.get(1).getDataStoreDownloadURL()); assertEquals(Arrays.asList("20081105092259000-20", "20081105092259000-21"), result.get(1) .getDataSetCodes()); } diff --git a/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/IGeneralInformationService.java b/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/IGeneralInformationService.java index 7c300649a7991309670b73b8ba64262028f744a7..53f6c4db500af04575447642e5be83597496fd92 100644 --- a/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/IGeneralInformationService.java +++ b/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/IGeneralInformationService.java @@ -28,6 +28,7 @@ import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataSet; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataSet.Connections; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataSetFetchOption; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataSetType; +import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataStoreForDataSets; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.Experiment; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.Material; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.MaterialIdentifier; @@ -288,6 +289,16 @@ public interface IGeneralInformationService extends IRpcService */ public String tryGetDataStoreBaseURL(String sessionToken, String dataSetCode); + /** + * Returns the download URL for the data store of specified data sets. + * + * @return One entry for each data store that has data sets from <var>dataSetCodes</var>, + * together with the data set codes that are in this data store. + * @since 1.19 + */ + public List<DataStoreForDataSets> getDataStoreBaseURLs(String sessionToken, + List<String> dataSetCodes); + /** * Returns the URL for the default data store server for this openBIS AS. * diff --git a/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/dto/DataStoreForDataSets.java b/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/dto/DataStoreForDataSets.java index 5b949cb5b229458e46987982ff0e5a9f360ab0c5..bc1c4a2df705e860d2914ebb4dbda0cac26600da 100644 --- a/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/dto/DataStoreForDataSets.java +++ b/openbis_api/source/java/ch/systemsx/cisd/openbis/generic/shared/api/v1/dto/DataStoreForDataSets.java @@ -24,30 +24,31 @@ import ch.systemsx.cisd.base.annotation.JsonObject; /** * The data store URL for a list of data sets. - * + * + * @since 1.19 * @author Bernd Rinn */ @JsonObject("DataStoreForDataSets") public class DataStoreForDataSets implements Serializable { private static final long serialVersionUID = 1L; - - private final String dataStoreBaseURL; - + + private final String dataStoreDownloadURL; + private final String[] dataSetCodes; public DataStoreForDataSets(String dataStoreBaseURL, String[] dataSetCodes) { - this.dataStoreBaseURL = dataStoreBaseURL; + this.dataStoreDownloadURL = dataStoreBaseURL; this.dataSetCodes = dataSetCodes; } /** * The base URL of the data store (can be used for download from a client). */ - public String getDataStoreBaseURL() + public String getDataStoreDownloadURL() { - return dataStoreBaseURL; + return dataStoreDownloadURL; } /**