From 20565a414b32b938d572cea9c1dff2b1e0f77405 Mon Sep 17 00:00:00 2001 From: cramakri <cramakri> Date: Fri, 4 Jun 2010 09:47:04 +0000 Subject: [PATCH] MINOR: Refactored and extracted shared code. SVN: 16271 --- .../api/v1/DataStoreApiUrlUtilities.java | 50 +++++++++++++++++++ .../server/logic/PlateDatasetLoader.java | 19 +------ 2 files changed, 52 insertions(+), 17 deletions(-) create mode 100644 datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/api/v1/DataStoreApiUrlUtilities.java diff --git a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/api/v1/DataStoreApiUrlUtilities.java b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/api/v1/DataStoreApiUrlUtilities.java new file mode 100644 index 00000000000..2ec72401201 --- /dev/null +++ b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/api/v1/DataStoreApiUrlUtilities.java @@ -0,0 +1,50 @@ +/* + * Copyright 2010 ETH Zuerich, CISD + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ch.systemsx.cisd.openbis.dss.generic.shared.api.v1; + +import static ch.systemsx.cisd.openbis.generic.shared.GenericSharedConstants.DATA_STORE_SERVER_WEB_APPLICATION_NAME; + +import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DataStore; + +/** + * @author Chandrasekhar Ramakrishnan + */ +public class DataStoreApiUrlUtilities +{ + /** + * Converts the download url to a server url. + */ + public static String getDataStoreUrlFromDataStore(DataStore dataStore) + { + String datastoreUrl = dataStore.getDownloadUrl(); + System.out.println("Data store url : " + datastoreUrl); + // The url objained form a DataStore object is the *download* url. Convert this to the + // datastore URL + if (datastoreUrl.endsWith(DATA_STORE_SERVER_WEB_APPLICATION_NAME)) + { + datastoreUrl = + datastoreUrl.substring(0, datastoreUrl.length() + - DATA_STORE_SERVER_WEB_APPLICATION_NAME.length()); + } + if (datastoreUrl.endsWith("/")) + { + datastoreUrl = datastoreUrl.substring(0, datastoreUrl.length() - 1); + } + + return datastoreUrl; + } +} diff --git a/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/server/logic/PlateDatasetLoader.java b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/server/logic/PlateDatasetLoader.java index 3629d4b483f..e1223a008da 100644 --- a/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/server/logic/PlateDatasetLoader.java +++ b/screening/source/java/ch/systemsx/cisd/openbis/plugin/screening/server/logic/PlateDatasetLoader.java @@ -1,12 +1,11 @@ package ch.systemsx.cisd.openbis.plugin.screening.server.logic; -import static ch.systemsx.cisd.openbis.generic.shared.GenericSharedConstants.DATA_STORE_SERVER_WEB_APPLICATION_NAME; - import java.util.ArrayList; import java.util.HashMap; import java.util.List; import ch.systemsx.cisd.common.exceptions.UserFailureException; +import ch.systemsx.cisd.openbis.dss.generic.shared.api.v1.DataStoreApiUrlUtilities; import ch.systemsx.cisd.openbis.generic.server.business.bo.datasetlister.IDatasetLister; import ch.systemsx.cisd.openbis.generic.server.business.bo.samplelister.ISampleLister; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DataStore; @@ -230,21 +229,7 @@ class PlateDatasetLoader protected String getDataStoreUrlFromDataStore(DataStore dataStore) { - String datastoreUrl = dataStore.getDownloadUrl(); - // The url objained form a DataStore object is the *download* url. Convert this to the - // datastore URL - if (datastoreUrl.endsWith(DATA_STORE_SERVER_WEB_APPLICATION_NAME)) - { - datastoreUrl = - datastoreUrl.substring(0, datastoreUrl.length() - - DATA_STORE_SERVER_WEB_APPLICATION_NAME.length()); - } - if (datastoreUrl.endsWith("/")) - { - datastoreUrl = datastoreUrl.substring(0, datastoreUrl.length() - 1); - } - - return datastoreUrl; + return DataStoreApiUrlUtilities.getDataStoreUrlFromDataStore(dataStore); } protected static SampleIdentifier createSampleIdentifier(PlateIdentifier plate) -- GitLab