From db6b3bd2332f754965acb06f0976358f4caaaace Mon Sep 17 00:00:00 2001 From: brinn <brinn> Date: Thu, 4 Oct 2012 18:06:37 +0000 Subject: [PATCH] Add method IGeneralInformationService.getDataStoreBaseURLs(). SVN: 26998 --- .../api/v1/GeneralInformationService.java | 27 ++++++++++++++----- .../v1/GeneralInformationServiceLogger.java | 10 +++++++ .../datasetlister/DataSetListerTest.java | 5 ++-- .../api/v1/IGeneralInformationService.java | 11 ++++++++ .../api/v1/dto/DataStoreForDataSets.java | 15 ++++++----- 5 files changed, 53 insertions(+), 15 deletions(-) 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 77a9be667a8..cbb24e6421d 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 f4980b7437b..575c3279981 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 4b40bf1741a..cd969721383 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 7c300649a79..53f6c4db500 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 5b949cb5b22..bc1c4a2df70 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; } /** -- GitLab