From 8463f00ba348e3eb92dbd637582af18ba83c702c Mon Sep 17 00:00:00 2001
From: felmer <felmer>
Date: Tue, 8 Feb 2011 09:42:00 +0000
Subject: [PATCH] LMS-1995 handling default share in DSS

SVN: 19805
---
 ...AbstractStrorageProcessorWithUploader.java |  2 +-
 .../DataSetRegistrationAlgorithm.java         |  6 +-
 .../etlserver/IdentifiedDataStrategy.java     |  4 +-
 .../cisd/etlserver/NamedDataStrategy.java     |  3 +-
 .../etlserver/api/v1/PutDataSetExecutor.java  |  3 +-
 .../AbstractDatasetDownloadServlet.java       | 11 ++-
 .../generic/server/AbstractDssServiceRpc.java | 40 +++++++--
 .../server/DataSetCommandExecutor.java        |  4 +-
 .../dss/generic/server/DataStoreService.java  | 84 +++++++++++++++++--
 .../server/DataStoreServiceLogger.java        |  8 +-
 .../dss/generic/server/DeletionCommand.java   | 16 ++--
 .../server/EncapsulatedOpenBISService.java    | 62 +++++++++++---
 .../server/IDataSetCommandExecutor.java       |  4 +-
 .../dss/generic/server/UploadingCommand.java  |  7 +-
 .../shared/IEncapsulatedOpenBISService.java   |  8 ++
 .../shared/dto/DataSetInformation.java        | 12 +++
 .../shared/utils/DatasetLocationUtil.java     | 12 +--
 .../source/java/dssApplicationContext.xml     |  2 +
 .../etlserver/IdentifiedDataStrategyTest.java |  5 +-
 .../cisd/etlserver/NamedDataStrategyTest.java |  9 +-
 .../TransferredDataSetHandlerTest.java        | 17 ++--
 ...mpleAndDatasetRegistrationHandlerTest.java | 30 +++----
 .../JythonTopLevelDataSetRegistratorTest.java | 23 +++--
 .../systemtests/DssComponentTest.java         |  5 +-
 .../generic/server/DataStoreServiceTest.java  | 48 +++++++++--
 .../server/DatasetDownloadServletTest.java    | 35 ++++++--
 .../generic/server/DssServiceRpcV1Test.java   | 30 ++++++-
 .../EncapsulatedOpenBISServiceTest.java       |  4 +-
 .../generic/server/UploadingCommandTest.java  |  9 +-
 .../api/v1/DssServiceRpcGenericTest.java      | 20 ++++-
 .../openbis/generic/server/ETLService.java    |  7 ++
 .../generic/server/ETLServiceLogger.java      |  7 ++
 .../server/business/bo/ExternalDataTable.java | 31 +++----
 .../bo/datasetlister/DatasetLister.java       |  2 +-
 .../bo/datasetlister/IDatasetLister.java      |  2 +-
 .../generic/shared/IDataStoreService.java     |  7 +-
 .../generic/shared/IETLLIMSService.java       | 12 +++
 .../business/bo/ExternalDataTableTest.java    | 38 ++++-----
 .../bo/datasetlister/DatasetListerTest.java   |  2 +-
 .../shared/IETLLIMSService.java.expected      | 12 +++
 .../basic/dto/builders/DataSetBuilder.java    |  6 ++
 .../builders/DatasetDescriptionBuilder.java   |  6 ++
 .../migration/MigrationStepFrom003To004.java  |  2 +-
 .../server/AbstractImagesDownloadServlet.java |  9 +-
 .../server/DssServiceRpcScreening.java        |  4 +-
 45 files changed, 507 insertions(+), 163 deletions(-)

diff --git a/datastore_server/source/java/ch/systemsx/cisd/etlserver/AbstractStrorageProcessorWithUploader.java b/datastore_server/source/java/ch/systemsx/cisd/etlserver/AbstractStrorageProcessorWithUploader.java
index 488263f9315..ccd950e0f69 100644
--- a/datastore_server/source/java/ch/systemsx/cisd/etlserver/AbstractStrorageProcessorWithUploader.java
+++ b/datastore_server/source/java/ch/systemsx/cisd/etlserver/AbstractStrorageProcessorWithUploader.java
@@ -82,7 +82,7 @@ public abstract class AbstractStrorageProcessorWithUploader extends
             uploader.rollback();
         }
         logDataSetFileError(incomingDataSetDirectory, exception);
-        return UnstoreDataAction.LEAVE_UNTOUCHED;
+        return UnstoreDataAction.MOVE_TO_ERROR;
     }
 
     @Override
diff --git a/datastore_server/source/java/ch/systemsx/cisd/etlserver/DataSetRegistrationAlgorithm.java b/datastore_server/source/java/ch/systemsx/cisd/etlserver/DataSetRegistrationAlgorithm.java
index d51c91f3a81..c37da5887dc 100644
--- a/datastore_server/source/java/ch/systemsx/cisd/etlserver/DataSetRegistrationAlgorithm.java
+++ b/datastore_server/source/java/ch/systemsx/cisd/etlserver/DataSetRegistrationAlgorithm.java
@@ -40,6 +40,7 @@ import ch.systemsx.cisd.common.types.BooleanOrUnknown;
 import ch.systemsx.cisd.common.utilities.IDelegatedActionWithResult;
 import ch.systemsx.cisd.etlserver.IStorageProcessor.UnstoreDataAction;
 import ch.systemsx.cisd.etlserver.validation.IDataSetValidator;
+import ch.systemsx.cisd.openbis.dss.generic.server.DataStoreService;
 import ch.systemsx.cisd.openbis.dss.generic.shared.IEncapsulatedOpenBISService;
 import ch.systemsx.cisd.openbis.dss.generic.shared.dto.DataSetInformation;
 import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DataSetType;
@@ -300,6 +301,8 @@ public class DataSetRegistrationAlgorithm
     public final File createBaseDirectory(final IDataStoreStrategy strategy, final File baseDir,
             final DataSetInformation dataSetInfo)
     {
+        // TODO replace by mapping
+        dataSetInfo.setShareId(DataStoreService.DEFAULT_SHARE_ID);
         final File baseDirectory =
                 strategy.getBaseDirectory(baseDir, dataSetInfo, state.dataSetType);
         baseDirectory.mkdirs();
@@ -451,6 +454,7 @@ public class DataSetRegistrationAlgorithm
         data.setUserId(dataSetInformation.getUploadingUserIdOrNull());
         data.setUserEMail(dataSetInformation.tryGetUploadingUserEmail());
         data.setExtractableData(dataSetInformation.getExtractableData());
+        data.setShareId(dataSetInformation.getShareId());
         data.setLocatorType(getTypeExtractor().getLocatorType(incomingDataSetFile));
         data.setDataSetType(getTypeExtractor().getDataSetType(incomingDataSetFile));
         data.setFileFormatType(getTypeExtractor().getFileFormatType(incomingDataSetFile));
@@ -564,7 +568,7 @@ public class DataSetRegistrationAlgorithm
             final BooleanOrUnknown isCompleteFlag)
     {
         data.setComplete(isCompleteFlag);
-        data.setLocation(relativePath);
+        data.setLocation(relativePath.substring(data.getShareId().length() + 1));
         data.setStorageFormat(storageFormat);
         return data;
     }
diff --git a/datastore_server/source/java/ch/systemsx/cisd/etlserver/IdentifiedDataStrategy.java b/datastore_server/source/java/ch/systemsx/cisd/etlserver/IdentifiedDataStrategy.java
index a46fccb117c..e748ef2b729 100644
--- a/datastore_server/source/java/ch/systemsx/cisd/etlserver/IdentifiedDataStrategy.java
+++ b/datastore_server/source/java/ch/systemsx/cisd/etlserver/IdentifiedDataStrategy.java
@@ -63,8 +63,10 @@ public final class IdentifiedDataStrategy implements IDataStoreStrategy
     static File createBaseDirectory(final File baseDir, final DataSetInformation dataSetInfo)
     {
         String dataSetCode = dataSetInfo.getDataSetCode();
+        String shareId = dataSetInfo.getShareId();
         final String instanceUUID = dataSetInfo.getInstanceUUID();
-        return DatasetLocationUtil.getDatasetLocationPath(baseDir, dataSetCode, instanceUUID);
+        return DatasetLocationUtil.getDatasetLocationPath(baseDir, dataSetCode, shareId,
+                instanceUUID);
     }
 
     //
diff --git a/datastore_server/source/java/ch/systemsx/cisd/etlserver/NamedDataStrategy.java b/datastore_server/source/java/ch/systemsx/cisd/etlserver/NamedDataStrategy.java
index 5278c9f4d19..3e6bc69db8d 100644
--- a/datastore_server/source/java/ch/systemsx/cisd/etlserver/NamedDataStrategy.java
+++ b/datastore_server/source/java/ch/systemsx/cisd/etlserver/NamedDataStrategy.java
@@ -82,7 +82,8 @@ final class NamedDataStrategy implements IDataStoreStrategy
     {
         assertBaseDirectory(baseDirectory);
         assert dataSetType != null : "Missing data set type.";
-        return new File(new File(baseDirectory, getDirectoryName()), IdentifiedDataStrategy
+        File share = new File(baseDirectory, dataSetInfo.getShareId());
+        return new File(new File(share, getDirectoryName()), IdentifiedDataStrategy
                 .createDataSetTypeDirectory(dataSetType));
     }
 
diff --git a/datastore_server/source/java/ch/systemsx/cisd/etlserver/api/v1/PutDataSetExecutor.java b/datastore_server/source/java/ch/systemsx/cisd/etlserver/api/v1/PutDataSetExecutor.java
index de57e604fb1..c7fcac1d6f9 100644
--- a/datastore_server/source/java/ch/systemsx/cisd/etlserver/api/v1/PutDataSetExecutor.java
+++ b/datastore_server/source/java/ch/systemsx/cisd/etlserver/api/v1/PutDataSetExecutor.java
@@ -222,7 +222,8 @@ class PutDataSetExecutor implements IDataSetHandlerRpc
 
     public File getFileForExternalData(ExternalData externalData)
     {
-        File dataSetFile = new File(service.getStoreRootDirectory(), externalData.getLocation());
+        File share = new File(service.getStoreRootDirectory(), externalData.getShareId());
+        File dataSetFile = new File(share, externalData.getLocation());
         return DefaultStorageProcessor.getOriginalDirectory(dataSetFile);
     }
 
diff --git a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/AbstractDatasetDownloadServlet.java b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/AbstractDatasetDownloadServlet.java
index 48d4f7bca7f..2fba03b0ec6 100644
--- a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/AbstractDatasetDownloadServlet.java
+++ b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/AbstractDatasetDownloadServlet.java
@@ -21,8 +21,10 @@ import java.io.File;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.PrintWriter;
+import java.util.Arrays;
 import java.util.Enumeration;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 
 import javax.activation.MimetypesFileTypeMap;
@@ -313,8 +315,15 @@ abstract public class AbstractDatasetDownloadServlet extends HttpServlet
 
     protected final File createDataSetRootDirectory(String dataSetCode, HttpSession session)
     {
+        List<ExternalData> list =
+                applicationContext.getDataSetService().listDataSetsByCode(
+                        Arrays.asList(dataSetCode));
+        if (list.isEmpty())
+        {
+            throw new IllegalArgumentException("Unknown data set " + dataSetCode);
+        }
         return DatasetLocationUtil.getDatasetLocationPathCheckingIfExists(dataSetCode,
-                getDatabaseInstance(session), getStoreRootPath());
+                list.get(0).getShareId(), getDatabaseInstance(session), getStoreRootPath());
     }
 
     protected final File getStoreRootPath()
diff --git a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/AbstractDssServiceRpc.java b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/AbstractDssServiceRpc.java
index c3ccf5fe0c5..88a486953fa 100644
--- a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/AbstractDssServiceRpc.java
+++ b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/AbstractDssServiceRpc.java
@@ -19,12 +19,16 @@ package ch.systemsx.cisd.openbis.dss.generic.server;
 import java.io.File;
 import java.io.IOException;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.HashMap;
+import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
 import org.apache.log4j.Logger;
 
+import ch.systemsx.cisd.common.collections.IKeyExtractor;
+import ch.systemsx.cisd.common.collections.TableMap;
 import ch.systemsx.cisd.common.exceptions.UserFailureException;
 import ch.systemsx.cisd.common.logging.LogCategory;
 import ch.systemsx.cisd.common.logging.LogFactory;
@@ -206,14 +210,24 @@ public abstract class AbstractDssServiceRpc<T> extends AbstractServiceWithLogger
 
         return access;
     }
+    
+    protected File getRootDirectory(String datasetCode)
+    {
+        List<ExternalData> list = getOpenBISService().listDataSetsByCode(Arrays.asList(datasetCode));
+        if (list.isEmpty())
+        {
+            throw new IllegalArgumentException("Unknown data set " + datasetCode);
+        }
+        return getRootDirectoryForDataSet(datasetCode, list.get(0).getShareId());
+    }
 
     /**
      * Get the top level of the folder for the data set.
      */
-    protected File getRootDirectoryForDataSet(String code)
+    protected File getRootDirectoryForDataSet(String code, String shareId)
     {
         File dataSetRootDirectory =
-                DatasetLocationUtil.getDatasetLocationPath(getStoreDirectory(), code,
+                DatasetLocationUtil.getDatasetLocationPath(getStoreDirectory(), code, shareId,
                         getHomeDatabaseInstance().getUuid());
         return dataSetRootDirectory;
     }
@@ -240,16 +254,32 @@ public abstract class AbstractDssServiceRpc<T> extends AbstractServiceWithLogger
         }
 
         HashMap<String, File> rootDirectories = new HashMap<String, File>();
+        List<ExternalData> dataSets =
+                openBISService.listDataSetsByCode(new ArrayList<String>(dataSetCodes));
+        TableMap<String, ExternalData> tableMap =
+                new TableMap<String, ExternalData>(dataSets,
+                        new IKeyExtractor<String, ExternalData>()
+                            {
+                                public String getKey(ExternalData e)
+                                {
+                                    return e.getCode();
+                                }
+                            });
         for (String datasetCode : dataSetCodes)
         {
-            rootDirectories.put(datasetCode, getRootDirectory(datasetCode));
+            ExternalData dataSet = tableMap.tryGet(datasetCode);
+            if (dataSet == null)
+            {
+                throw new IllegalArgumentException("Unknown data set " + datasetCode);
+            }
+            rootDirectories.put(datasetCode, getRootDirectory(datasetCode, dataSet.getShareId()));
         }
         return rootDirectories;
     }
 
-    private File getRootDirectory(String dataSetCode)
+    private File getRootDirectory(String dataSetCode, String shareId)
     {
-        File dataSetRootDirectory = getRootDirectoryForDataSet(dataSetCode);
+        File dataSetRootDirectory = getRootDirectoryForDataSet(dataSetCode, shareId);
         if (dataSetRootDirectory.exists() == false)
         {
             throw new IllegalArgumentException("Path does not exist: " + dataSetRootDirectory);
diff --git a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/DataSetCommandExecutor.java b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/DataSetCommandExecutor.java
index 034358e6344..c729cde167b 100644
--- a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/DataSetCommandExecutor.java
+++ b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/DataSetCommandExecutor.java
@@ -110,9 +110,9 @@ class DataSetCommandExecutor implements IDataSetCommandExecutor
         thread.start();
     }
 
-    public void scheduleDeletionOfDataSets(List<String> locations)
+    public void scheduleDeletionOfDataSets(List<DatasetDescription> dataSets)
     {
-        scheduleCommand(new DeletionCommand(locations));
+        scheduleCommand(new DeletionCommand(dataSets));
     }
 
     public void scheduleUploadingDataSetsToCIFEX(ICIFEXRPCServiceFactory cifexServiceFactory,
diff --git a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/DataStoreService.java b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/DataStoreService.java
index ae3c228c512..044e5a1400d 100644
--- a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/DataStoreService.java
+++ b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/DataStoreService.java
@@ -17,6 +17,7 @@
 package ch.systemsx.cisd.openbis.dss.generic.server;
 
 import java.io.File;
+import java.io.FilenameFilter;
 import java.io.IOException;
 import java.util.ArrayList;
 import java.util.Collections;
@@ -49,6 +50,7 @@ import ch.systemsx.cisd.openbis.generic.shared.basic.dto.LinkModel;
 import ch.systemsx.cisd.openbis.generic.shared.basic.dto.TableModel;
 import ch.systemsx.cisd.openbis.generic.shared.dto.DataSetUploadContext;
 import ch.systemsx.cisd.openbis.generic.shared.dto.DatasetDescription;
+import ch.systemsx.cisd.openbis.generic.shared.util.UuidUtil;
 
 /**
  * Implementation of {@link IDataStoreService} which will be accessed remotely by the opneBIS
@@ -59,6 +61,8 @@ import ch.systemsx.cisd.openbis.generic.shared.dto.DatasetDescription;
 public class DataStoreService extends AbstractServiceWithLogger<IDataStoreService> implements
         IDataStoreService, InitializingBean
 {
+    public static final String DEFAULT_SHARE_ID = "1";
+    
     private final SessionTokenManager sessionTokenManager;
 
     private final IDataSetCommandExecutorFactory commandExecutorFactory;
@@ -67,6 +71,8 @@ public class DataStoreService extends AbstractServiceWithLogger<IDataStoreServic
 
     private final PluginTaskProviders pluginTaskParameters;
 
+    private final String defaultShareId;
+    
     private String cifexAdminUserOrNull;
 
     private String cifexAdminPasswordOrNull;
@@ -78,7 +84,7 @@ public class DataStoreService extends AbstractServiceWithLogger<IDataStoreServic
     private IDataSetCommandExecutor commandExecutor;
 
     public DataStoreService(SessionTokenManager sessionTokenManager,
-            MailClientParameters mailClientParameters, PluginTaskProviders pluginTaskParameters)
+            MailClientParameters mailClientParameters, PluginTaskProviders pluginTaskParameters, String defaultShareId)
     {
         this(sessionTokenManager, new IDataSetCommandExecutorFactory()
             {
@@ -86,17 +92,18 @@ public class DataStoreService extends AbstractServiceWithLogger<IDataStoreServic
                 {
                     return new DataSetCommandExecutor(store, queueDir);
                 }
-            }, mailClientParameters, pluginTaskParameters);
+            }, mailClientParameters, pluginTaskParameters, defaultShareId);
     }
 
     DataStoreService(SessionTokenManager sessionTokenManager,
             IDataSetCommandExecutorFactory commandExecutorFactory,
-            MailClientParameters mailClientParameters, PluginTaskProviders pluginTaskParameters)
+            MailClientParameters mailClientParameters, PluginTaskProviders pluginTaskParameters, String defaultShareId)
     {
         this.sessionTokenManager = sessionTokenManager;
         this.commandExecutorFactory = commandExecutorFactory;
         this.mailClientParameters = mailClientParameters;
         this.pluginTaskParameters = pluginTaskParameters;
+        this.defaultShareId = defaultShareId.startsWith("$") ? DEFAULT_SHARE_ID : defaultShareId;
         storeRoot = pluginTaskParameters.getStoreRoot();
     }
 
@@ -152,6 +159,37 @@ public class DataStoreService extends AbstractServiceWithLogger<IDataStoreServic
         }
         commandExecutor = commandExecutorFactory.create(storeRoot, commandQueueDirOrNull);
         commandExecutor.start();
+        migrateStore();
+    }
+
+    private void migrateStore()
+    {
+        File defaultShare = new File(storeRoot, defaultShareId);
+        if (defaultShare.exists() == false)
+        {
+            if (defaultShare.mkdirs() == false)
+            {
+                throw new IOExceptionUnchecked(new IOException(
+                        "Couldn't create default share in data store: " + defaultShare));
+            }
+            File[] stores = storeRoot.listFiles(new FilenameFilter()
+                {
+                    
+                    public boolean accept(File dir, String name)
+                    {
+                        return UuidUtil.isValidUUID(name);
+                    }
+                });
+            for (File file : stores)
+            {
+                if (file.renameTo(new File(defaultShare, file.getName())) == false)
+                {
+                    throw new IOExceptionUnchecked(new IOException("Couldn't move '" + file
+                            + "' into default share '" + defaultShare + "'."));
+                }
+            }
+            operationLog.info("Store migrated to default share");
+        }
     }
 
     public IDataStoreService createLogger(IInvocationLoggerContext context)
@@ -166,15 +204,17 @@ public class DataStoreService extends AbstractServiceWithLogger<IDataStoreServic
         return IDataStoreService.VERSION;
     }
 
-    public List<String> getKnownDataSets(String sessionToken, List<String> dataSetLocations)
+    public List<String> getKnownDataSets(String sessionToken, List<DatasetDescription> dataSets)
             throws InvalidAuthenticationException
     {
         sessionTokenManager.assertValidSessionToken(sessionToken);
+        injectDefaultShareId(dataSets);
 
         List<String> knownLocations = new ArrayList<String>();
-        for (String location : dataSetLocations)
+        for (DatasetDescription dataSet : dataSets)
         {
-            if (new File(storeRoot, location).exists())
+            String location = dataSet.getDataSetLocation();
+            if (new File(new File(storeRoot, dataSet.getDataSetShareId()), location).exists())
             {
                 knownLocations.add(location);
             }
@@ -182,18 +222,26 @@ public class DataStoreService extends AbstractServiceWithLogger<IDataStoreServic
         return knownLocations;
     }
 
-    public void deleteDataSets(String sessionToken, final List<String> dataSetLocations)
+    public void deleteDataSets(String sessionToken, final List<DatasetDescription> dataSets)
             throws InvalidAuthenticationException
     {
         sessionTokenManager.assertValidSessionToken(sessionToken);
+        injectDefaultShareId(dataSets);
 
-        commandExecutor.scheduleDeletionOfDataSets(dataSetLocations);
+        commandExecutor.scheduleDeletionOfDataSets(dataSets);
     }
 
     public void uploadDataSetsToCIFEX(String sessionToken, List<ExternalData> dataSets,
             DataSetUploadContext context) throws InvalidAuthenticationException
     {
         sessionTokenManager.assertValidSessionToken(sessionToken);
+        for (ExternalData dataSet : dataSets)
+        {
+            if (dataSet.getShareId() == null)
+            {
+                dataSet.setShareId(defaultShareId);
+            }
+        }
 
         if (context.getCifexURL() == null)
         {
@@ -223,6 +271,7 @@ public class DataStoreService extends AbstractServiceWithLogger<IDataStoreServic
             List<DatasetDescription> datasets)
     {
         sessionTokenManager.assertValidSessionToken(sessionToken);
+        injectDefaultShareId(datasets);
 
         PluginTaskProvider<IReportingPluginTask> reportingPlugins =
                 pluginTaskParameters.getReportingPluginsProvider();
@@ -235,6 +284,7 @@ public class DataStoreService extends AbstractServiceWithLogger<IDataStoreServic
             String userEmailOrNull)
     {
         sessionTokenManager.assertValidSessionToken(sessionToken);
+        injectDefaultShareId(datasets);
 
         PluginTaskProvider<IProcessingPluginTask> plugins =
                 pluginTaskParameters.getProcessingPluginsProvider();
@@ -261,6 +311,7 @@ public class DataStoreService extends AbstractServiceWithLogger<IDataStoreServic
             String userEmailOrNull, boolean archive)
     {
         sessionTokenManager.assertValidSessionToken(sessionToken);
+        injectDefaultShareId(datasets);
 
         String description = archive ? "Archiving" : "Unarchiving";
         ArchiverTaskFactory factory = pluginTaskParameters.getArchiverTaskFactory();
@@ -305,11 +356,28 @@ public class DataStoreService extends AbstractServiceWithLogger<IDataStoreServic
             DatasetDescription dataSet)
     {
         sessionTokenManager.assertValidSessionToken(sessionToken);
+        injectDefaultShareId(dataSet);
 
         PluginTaskProvider<IReportingPluginTask> reportingPlugins =
                 pluginTaskParameters.getReportingPluginsProvider();
         IReportingPluginTask task = reportingPlugins.getPluginInstance(serviceKey);
         return task.createLink(dataSet);
     }
+    
+    private void injectDefaultShareId(List<DatasetDescription> dataSets)
+    {
+        for (DatasetDescription dataSet : dataSets)
+        {
+            injectDefaultShareId(dataSet);
+        }
+    }
+
+    private void injectDefaultShareId(DatasetDescription dataSetOrNull)
+    {
+        if (dataSetOrNull != null && dataSetOrNull.getDataSetShareId() == null)
+        {
+            dataSetOrNull.setDataSetShareId(defaultShareId);
+        }
+    }
 
 }
diff --git a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/DataStoreServiceLogger.java b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/DataStoreServiceLogger.java
index 6ad513f0247..a13f931b506 100644
--- a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/DataStoreServiceLogger.java
+++ b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/DataStoreServiceLogger.java
@@ -78,17 +78,17 @@ class DataStoreServiceLogger implements IDataStoreService
         return 0;
     }
 
-    public List<String> getKnownDataSets(String sessionToken, List<String> dataSetLocations)
+    public List<String> getKnownDataSets(String sessionToken, List<DatasetDescription> dataSetLocations)
             throws InvalidAuthenticationException
     {
-        log("getKnownDataSets", "LOCATIONS(%s)", dataSetLocations);
+        log("getKnownDataSets", "DATA_SETS(%s)", dataSetLocations);
         return null;
     }
 
-    public void deleteDataSets(String sessionToken, List<String> dataSetLocations)
+    public void deleteDataSets(String sessionToken, List<DatasetDescription> dataSets)
             throws InvalidAuthenticationException
     {
-        log("deleteDataSets", "LOCATIONS(%s)", dataSetLocations);
+        log("deleteDataSets", "DATA_SETS(%s)", dataSets);
     }
 
     public void uploadDataSetsToCIFEX(String sessionToken, List<ExternalData> dataSets,
diff --git a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/DeletionCommand.java b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/DeletionCommand.java
index ff4611bd15a..5abeb92395e 100644
--- a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/DeletionCommand.java
+++ b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/DeletionCommand.java
@@ -20,6 +20,7 @@ import java.io.File;
 import java.util.List;
 
 import ch.systemsx.cisd.common.filesystem.QueueingPathRemoverService;
+import ch.systemsx.cisd.openbis.generic.shared.dto.DatasetDescription;
 
 /**
  * A command for deleting data sets, based on their location relative to the data store root.
@@ -30,18 +31,19 @@ class DeletionCommand implements IDataSetCommand
 {
     private static final long serialVersionUID = 1L;
     
-    private final List<String> dataSetLocations;
+    private final List<DatasetDescription> dataSets;
 
-    DeletionCommand(List<String> dataSetLocations)
+    DeletionCommand(List<DatasetDescription> dataSets)
     {
-        this.dataSetLocations = dataSetLocations;
+        this.dataSets = dataSets;
     }
 
     public void execute(File store)
     {
-        for (String location : dataSetLocations)
+        for (DatasetDescription dataSet : dataSets)
         {
-            QueueingPathRemoverService.removeRecursively(new File(store, location));
+            File share = new File(store, dataSet.getDataSetShareId());
+            QueueingPathRemoverService.removeRecursively(new File(share, dataSet.getDataSetLocation()));
         }
     }
 
@@ -49,9 +51,9 @@ class DeletionCommand implements IDataSetCommand
     {
         final StringBuilder b = new StringBuilder();
         b.append("Delete data set paths: ");
-        for (String dataset : dataSetLocations)
+        for (DatasetDescription dataset : dataSets)
         {
-            b.append(dataset);
+            b.append(dataset.getDataSetShareId()).append('/').append(dataset.getDataSetLocation());
             b.append(',');
         }
         b.setLength(b.length() - 1);
diff --git a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/EncapsulatedOpenBISService.java b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/EncapsulatedOpenBISService.java
index a976e50b814..5be821b47f4 100644
--- a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/EncapsulatedOpenBISService.java
+++ b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/EncapsulatedOpenBISService.java
@@ -79,17 +79,21 @@ public final class EncapsulatedOpenBISService implements IEncapsulatedOpenBISSer
     // this session object is automatically kept up-to-date by an aspect
     private OpenBISSessionHolder session;
 
+    private final String defaultShareId;
+
     public static IETLLIMSService createOpenBisService(String openBISURL)
     {
         return new OpenBisServiceFactory(openBISURL, ResourceNames.ETL_SERVICE_URL).createService();
     }
 
-    public EncapsulatedOpenBISService(IETLLIMSService service, OpenBISSessionHolder sessionHolder)
+    public EncapsulatedOpenBISService(IETLLIMSService service, OpenBISSessionHolder sessionHolder, String defaultShareId)
     {
         assert service != null : "Given IETLLIMSService implementation can not be null.";
         assert sessionHolder != null : "Given OpenBISSessionHolder can not be null.";
         this.service = service;
         this.session = sessionHolder;
+        this.defaultShareId =
+                defaultShareId.startsWith("$") ? DataStoreService.DEFAULT_SHARE_ID : defaultShareId;
     }
 
 
@@ -112,7 +116,7 @@ public final class EncapsulatedOpenBISService implements IEncapsulatedOpenBISSer
     //
     // IEncapsulatedOpenBISService
     //
-
+    
     public Experiment tryToGetExperiment(ExperimentIdentifier experimentIdentifier)
     {
         assert experimentIdentifier != null : " Unspecified experiment identifier.";
@@ -164,14 +168,27 @@ public final class EncapsulatedOpenBISService implements IEncapsulatedOpenBISSer
             throws UserFailureException
     {
         TechId id = new TechId(experimentID);
-        return service.listDataSetsByExperimentID(session.getToken(), id);
+        List<ExternalData> result = service.listDataSetsByExperimentID(session.getToken(), id);
+        injectDefaultShareId(result);
+        return result;
     }
-
+    
     public List<ExternalData> listDataSetsBySampleID(long sampleID,
             boolean showOnlyDirectlyConnected)
     {
         TechId id = new TechId(sampleID);
-        return service.listDataSetsBySampleID(session.getToken(), id, showOnlyDirectlyConnected);
+        List<ExternalData> result =
+                service.listDataSetsBySampleID(session.getToken(), id, showOnlyDirectlyConnected);
+        injectDefaultShareId(result);
+        return result;
+    }
+
+    public List<ExternalData> listDataSetsByCode(List<String> dataSetCodes)
+            throws UserFailureException
+    {
+        List<ExternalData> dataSets = service.listDataSetsByCode(session.getToken(), dataSetCodes);
+        injectDefaultShareId(dataSets);
+        return dataSets;
     }
 
     public long registerExperiment(NewExperiment experiment) throws UserFailureException
@@ -309,13 +326,17 @@ public final class EncapsulatedOpenBISService implements IEncapsulatedOpenBISSer
 
     public ExternalData tryGetDataSet(String dataSetCode) throws UserFailureException
     {
-        return service.tryGetDataSet(session.getToken(), dataSetCode);
+        ExternalData dataSet = service.tryGetDataSet(session.getToken(), dataSetCode);
+        injectDefaultShareId(dataSet);
+        return dataSet;
     }
 
     public ExternalData tryGetDataSet(String sToken, String dataSetCode)
             throws UserFailureException
     {
-        return service.tryGetDataSet(sToken, dataSetCode);
+        ExternalData dataSet = service.tryGetDataSet(sToken, dataSetCode);
+        injectDefaultShareId(dataSet);
+        return dataSet;
     }
 
     public void checkInstanceAdminAuthorization(String sToken)
@@ -350,8 +371,11 @@ public final class EncapsulatedOpenBISService implements IEncapsulatedOpenBISSer
     public List<ExternalData> listAvailableDataSets(ArchiverDataSetCriteria criteria)
             throws UserFailureException
     {
-        return service.listAvailableDataSets(session.getToken(), session.getDataStoreCode(),
-                criteria);
+        List<ExternalData> result =
+                service.listAvailableDataSets(session.getToken(), session.getDataStoreCode(),
+                        criteria);
+        injectDefaultShareId(result);
+        return result;
     }
 
     public List<DeletedDataSet> listDeletedDataSets(Long lastSeenDeletionEventIdOrNull)
@@ -376,7 +400,9 @@ public final class EncapsulatedOpenBISService implements IEncapsulatedOpenBISSer
 
     public ExternalData tryGetDataSetForServer(String dataSetCode) throws UserFailureException
     {
-        return service.tryGetDataSetForServer(session.getToken(), dataSetCode);
+        ExternalData dataSet = service.tryGetDataSetForServer(session.getToken(), dataSetCode);
+        injectDefaultShareId(dataSet);
+        return dataSet;
     }
 
     public List<String> generateCodes(String prefix, int size)
@@ -407,4 +433,20 @@ public final class EncapsulatedOpenBISService implements IEncapsulatedOpenBISSer
         return service.updateSampleAndRegisterDataSet(session.getToken(), newSample, externalData);
     }
 
+    private void injectDefaultShareId(List<ExternalData> dataSets)
+    {
+        for (ExternalData dataSet : dataSets)
+        {
+            injectDefaultShareId(dataSet);
+        }
+    }
+
+    private void injectDefaultShareId(ExternalData dataSetOrNull)
+    {
+        if (dataSetOrNull != null && dataSetOrNull.getShareId() == null)
+        {
+            dataSetOrNull.setShareId(defaultShareId);
+        }
+    }
+    
 }
\ No newline at end of file
diff --git a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/IDataSetCommandExecutor.java b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/IDataSetCommandExecutor.java
index ef31862005f..ee1f5954291 100644
--- a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/IDataSetCommandExecutor.java
+++ b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/IDataSetCommandExecutor.java
@@ -41,9 +41,9 @@ interface IDataSetCommandExecutor
     void start();
 
     /**
-     * Schedules deletion of all data sets at specified locations.
+     * Schedules deletion of all specified data sets.
      */
-    void scheduleDeletionOfDataSets(List<String> locations);
+    void scheduleDeletionOfDataSets(List<DatasetDescription> dataSets);
 
     /**
      * Schedules uploading of all data sets to CIFEX using the specified upload context.
diff --git a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/UploadingCommand.java b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/UploadingCommand.java
index 43e7456204e..64edaaa8506 100644
--- a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/UploadingCommand.java
+++ b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/UploadingCommand.java
@@ -397,10 +397,11 @@ class UploadingCommand implements IDataSetCommand
             for (ExternalData dataSet : dataSets)
             {
                 String location = dataSet.getLocation();
-                File dataSetFile = new File(store, location);
+                String path = dataSet.getShareId() + "/" + location;
+                File dataSetFile = new File(new File(store, dataSet.getShareId()), location);
                 if (dataSetFile.exists() == false)
                 {
-                    notificationLog.error("Data set '" + location + "' does not exist.");
+                    notificationLog.error("Data set '" + path + "' does not exist.");
                     return false;
                 }
                 String newRootPath = createRootPath(dataSet);
@@ -421,7 +422,7 @@ class UploadingCommand implements IDataSetCommand
                             dataSetFile);
                 } catch (IOException ex)
                 {
-                    notificationLog.error("Couldn't add data set '" + location + "' to zip file.",
+                    notificationLog.error("Couldn't add data set '" + path + "' to zip file.",
                             ex);
                     return false;
                 }
diff --git a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/IEncapsulatedOpenBISService.java b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/IEncapsulatedOpenBISService.java
index d3e14d58f48..cc079a441fa 100644
--- a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/IEncapsulatedOpenBISService.java
+++ b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/IEncapsulatedOpenBISService.java
@@ -168,6 +168,14 @@ public interface IEncapsulatedOpenBISService
     @ManagedAuthentication
     public List<ExternalData> listDataSetsBySampleID(long sampleID,
             boolean showOnlyDirectlyConnected) throws UserFailureException;
+    
+    /**
+     * Returns all data sets found for specified data set codes.
+     * 
+     * @return plain data sets without properties, samples, and experiments.
+     */
+    @ManagedAuthentication
+    public List<ExternalData> listDataSetsByCode(List<String> dataSetCodes) throws UserFailureException;
 
     /**
      * Registers the specified experiment.
diff --git a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/dto/DataSetInformation.java b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/dto/DataSetInformation.java
index 978d3d3ff11..06b3963273f 100644
--- a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/dto/DataSetInformation.java
+++ b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/dto/DataSetInformation.java
@@ -53,6 +53,8 @@ public class DataSetInformation implements Serializable
     private IEntityProperty[] properties = IEntityProperty.EMPTY_ARRAY;
 
     private DataSetType dataSetType;
+    
+    private String shareId;
 
     /**
      * The database instance <i>UUID</i>.
@@ -96,6 +98,16 @@ public class DataSetInformation implements Serializable
     {
     }
 
+    public String getShareId()
+    {
+        return shareId;
+    }
+
+    public void setShareId(String shareId)
+    {
+        this.shareId = shareId;
+    }
+
     public String tryGetUploadingUserEmail()
     {
         return uploadingUserEmailOrNull;
diff --git a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/utils/DatasetLocationUtil.java b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/utils/DatasetLocationUtil.java
index 068d3a73392..a925b91d989 100644
--- a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/utils/DatasetLocationUtil.java
+++ b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/utils/DatasetLocationUtil.java
@@ -32,13 +32,13 @@ public class DatasetLocationUtil
      * 
      * @throws UserFailureException if the dataset directory does not exist.
      */
-    public static File getDatasetLocationPathCheckingIfExists(String dataSetCode,
+    public static File getDatasetLocationPathCheckingIfExists(String dataSetCode, String shareId, 
             DatabaseInstance databaseInstance, File storeDir)
     {
         String databaseUuid = databaseInstance.getUuid();
 
         File dataSetRootDirectory =
-                DatasetLocationUtil.getDatasetLocationPath(storeDir, dataSetCode, databaseUuid);
+                DatasetLocationUtil.getDatasetLocationPath(storeDir, dataSetCode, shareId, databaseUuid);
         if (dataSetRootDirectory.exists() == false)
         {
             throw new UserFailureException("Data set '" + dataSetCode + "' not found in the store.");
@@ -47,17 +47,17 @@ public class DatasetLocationUtil
     }
 
     /** Creates a location where a dataset can be found in a specified base directory. */
-    public static File getDatasetLocationPath(final File baseDir, String dataSetCode,
+    public static File getDatasetLocationPath(final File baseDir, String dataSetCode, String shareId, 
             final String instanceUUID)
     {
-        return new File(baseDir, getDatasetRelativeLocationPath(dataSetCode, instanceUUID));
+        return new File(baseDir, getDatasetRelativeLocationPath(dataSetCode, shareId, instanceUUID));
     }
 
     /** returns path relative to the store */
-    public static String getDatasetRelativeLocationPath(String dataSetCode,
+    public static String getDatasetRelativeLocationPath(String dataSetCode, String shareId, 
             final String instanceUUID)
     {
-        final File instanceDir = new File(instanceUUID);
+        final File instanceDir = new File(new File(shareId), instanceUUID);
         final File shardingDir = createShardingDir(instanceDir, dataSetCode);
         final File datasetDir = new File(shardingDir, dataSetCode);
         return datasetDir.getPath();
diff --git a/datastore_server/source/java/dssApplicationContext.xml b/datastore_server/source/java/dssApplicationContext.xml
index 3f1e65f2a68..8407ce5ff24 100644
--- a/datastore_server/source/java/dssApplicationContext.xml
+++ b/datastore_server/source/java/dssApplicationContext.xml
@@ -49,6 +49,7 @@
     <bean id="openBIS-service" class="ch.systemsx.cisd.openbis.dss.generic.server.EncapsulatedOpenBISService">
        <constructor-arg ref="etl-lims-service"/>
        <constructor-arg ref="sessionHolder"/>
+       <constructor-arg value="${default-share-id}" />
     </bean>    
     
     <bean id="data-store-server"
@@ -65,6 +66,7 @@
                     </bean>
                 </constructor-arg>
                 <constructor-arg ref="plugin-tasks" />
+                <constructor-arg value="${default-share-id}" />
                 <property name="cifexAdminUserOrNull" value="${cifex-admin-username}" />
                 <property name="cifexAdminPasswordOrNull" value="${cifex-admin-password}" />
                 <property name="commandQueueDir" value="${commandqueue-dir}"/>
diff --git a/datastore_server/sourceTest/java/ch/systemsx/cisd/etlserver/IdentifiedDataStrategyTest.java b/datastore_server/sourceTest/java/ch/systemsx/cisd/etlserver/IdentifiedDataStrategyTest.java
index eebf650342b..f7630fa1ceb 100644
--- a/datastore_server/sourceTest/java/ch/systemsx/cisd/etlserver/IdentifiedDataStrategyTest.java
+++ b/datastore_server/sourceTest/java/ch/systemsx/cisd/etlserver/IdentifiedDataStrategyTest.java
@@ -37,6 +37,8 @@ import ch.systemsx.cisd.openbis.generic.shared.dto.types.DataSetTypeCode;
  */
 public class IdentifiedDataStrategyTest extends AbstractFileSystemTestCase
 {
+    private static final String SHARE_ID = "share-1";
+
     private static final String DATA_SET_CODE = "data-set-code";
 
     private static final String EXAMPLE_PROJECT_CODE = "P";
@@ -64,6 +66,7 @@ public class IdentifiedDataStrategyTest extends AbstractFileSystemTestCase
         dataSetInfo.setInstanceCode("my-instance");
         dataSetInfo.setInstanceUUID("1111-2222");
         dataSetInfo.setDataSetCode(DATA_SET_CODE);
+        dataSetInfo.setShareId(SHARE_ID);
         return dataSetInfo;
     }
 
@@ -92,7 +95,7 @@ public class IdentifiedDataStrategyTest extends AbstractFileSystemTestCase
         assertTrue("Null values not permited here", exceptionThrown);
         final DataSetInformation dataSetInfo = createDataSetInfo();
         File baseDirectory = strategy.getBaseDirectory(workingDirectory, dataSetInfo, dataSetType);
-        final File file = new File(workingDirectory, "1111-2222/27/35/33/data-set-code");
+        final File file = new File(new File(workingDirectory, SHARE_ID), "1111-2222/27/35/33/data-set-code");
         assertEquals(file, baseDirectory);
         assertTrue(baseDirectory.exists() == false);
         // Create a file instead of a directory
diff --git a/datastore_server/sourceTest/java/ch/systemsx/cisd/etlserver/NamedDataStrategyTest.java b/datastore_server/sourceTest/java/ch/systemsx/cisd/etlserver/NamedDataStrategyTest.java
index b30d402ff5f..fe8379f9f8e 100644
--- a/datastore_server/sourceTest/java/ch/systemsx/cisd/etlserver/NamedDataStrategyTest.java
+++ b/datastore_server/sourceTest/java/ch/systemsx/cisd/etlserver/NamedDataStrategyTest.java
@@ -23,6 +23,7 @@ import org.apache.commons.io.FileUtils;
 import org.testng.annotations.Test;
 
 import ch.systemsx.cisd.base.tests.AbstractFileSystemTestCase;
+import ch.systemsx.cisd.openbis.dss.generic.shared.dto.DataSetInformation;
 import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DataSetType;
 
 /**
@@ -32,6 +33,8 @@ import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DataSetType;
  */
 public final class NamedDataStrategyTest extends AbstractFileSystemTestCase
 {
+    private static final String SHARE_ID = "share-1";
+
     private static final DataStoreStrategyKey UNIDENTIFIED = DataStoreStrategyKey.UNIDENTIFIED;
 
     private final static String FILE_NAME = "AX14";
@@ -95,9 +98,11 @@ public final class NamedDataStrategyTest extends AbstractFileSystemTestCase
         }
         assertTrue("Base directory can not be null", exceptionThrown);
         final DataSetType dataSetType = new DataSetType("DataSet");
+        DataSetInformation dataSetInfo = new DataSetInformation();
+        dataSetInfo.setShareId(SHARE_ID);
         final File baseDirectory =
-                strategy.getBaseDirectory(workingDirectory, null, dataSetType);
-        assertEquals(new File(new File(workingDirectory, NamedDataStrategy
+                strategy.getBaseDirectory(workingDirectory, dataSetInfo, dataSetType);
+        assertEquals(new File(new File(new File(workingDirectory, SHARE_ID), NamedDataStrategy
                 .getDirectoryName(UNIDENTIFIED)), IdentifiedDataStrategy
                 .createDataSetTypeDirectory(dataSetType)), baseDirectory);
     }
diff --git a/datastore_server/sourceTest/java/ch/systemsx/cisd/etlserver/TransferredDataSetHandlerTest.java b/datastore_server/sourceTest/java/ch/systemsx/cisd/etlserver/TransferredDataSetHandlerTest.java
index 3774fbd7191..6b6ab2937ed 100644
--- a/datastore_server/sourceTest/java/ch/systemsx/cisd/etlserver/TransferredDataSetHandlerTest.java
+++ b/datastore_server/sourceTest/java/ch/systemsx/cisd/etlserver/TransferredDataSetHandlerTest.java
@@ -52,6 +52,7 @@ import ch.systemsx.cisd.common.mail.IMailClient;
 import ch.systemsx.cisd.common.test.LogMonitoringAppender;
 import ch.systemsx.cisd.etlserver.IStorageProcessor.UnstoreDataAction;
 import ch.systemsx.cisd.etlserver.validation.IDataSetValidator;
+import ch.systemsx.cisd.openbis.dss.generic.server.DataStoreService;
 import ch.systemsx.cisd.openbis.dss.generic.server.EncapsulatedOpenBISService;
 import ch.systemsx.cisd.openbis.dss.generic.server.openbisauth.OpenBISSessionHolder;
 import ch.systemsx.cisd.openbis.dss.generic.server.plugins.tasks.PluginTaskProviders;
@@ -85,6 +86,8 @@ import ch.systemsx.cisd.openbis.generic.shared.dto.identifier.ExperimentIdentifi
 public final class TransferredDataSetHandlerTest extends AbstractFileSystemTestCase
 {
 
+    private static final String SHARE_ID = DataStoreService.DEFAULT_SHARE_ID;
+
     private static final String SAMPLE_CODE = "sample1";
 
     private static final String FOLDER_NAME = "folder";
@@ -135,6 +138,7 @@ public final class TransferredDataSetHandlerTest extends AbstractFileSystemTestC
             assertEquals(expectedData.getCode(), data.getCode());
             assertEquals(expectedData.getDataProducerCode(), data.getDataProducerCode());
             assertEquals(expectedData.getLocation(), data.getLocation());
+            assertEquals(expectedData.getShareId(), data.getShareId());
             assertEquals(expectedData.getLocatorType(), data.getLocatorType());
             assertEquals(expectedData.getFileFormatType(), data.getFileFormatType());
             assertEquals(expectedData.getDataSetType(), data.getDataSetType());
@@ -261,7 +265,7 @@ public final class TransferredDataSetHandlerTest extends AbstractFileSystemTestC
         OpenBISSessionHolder sessionHolder = new OpenBISSessionHolder();
         sessionHolder.setToken(SESSION_TOKEN);
         authorizedLimsService =
- new EncapsulatedOpenBISService(limsService, sessionHolder);
+                new EncapsulatedOpenBISService(limsService, sessionHolder, "share-id");
         dataSetValidator = context.mock(IDataSetValidator.class);
 
         Properties threadProperties = new Properties();
@@ -304,6 +308,7 @@ public final class TransferredDataSetHandlerTest extends AbstractFileSystemTestC
         dataSetInformation.setProductionDate(DATA_PRODUCTION_DATE);
         dataSetInformation.setDataSetCode(DATA_SET_CODE);
         dataSetInformation.setParentDataSetCodes(Collections.singletonList(PARENT_DATA_SET_CODE));
+        dataSetInformation.setShareId(SHARE_ID);
         targetFolder =
                 IdentifiedDataStrategy.createBaseDirectory(workingDirectory, dataSetInformation);
         targetData1 = createTargetData(data1);
@@ -344,6 +349,7 @@ public final class TransferredDataSetHandlerTest extends AbstractFileSystemTestC
         data.setDataProducerCode(DATA_PRODUCER_CODE);
         data.setProductionDate(DATA_PRODUCTION_DATE);
         data.setCode(DATA_SET_CODE);
+        data.setShareId(SHARE_ID);
         data.setParentDataSetCodes(Collections.singletonList(PARENT_DATA_SET_CODE));
         return data;
     }
@@ -351,7 +357,7 @@ public final class TransferredDataSetHandlerTest extends AbstractFileSystemTestC
     private String getRelativeTargetFolder()
     {
         String absoluteTarget = targetFolder.getAbsolutePath();
-        return absoluteTarget.substring(workingDirectory.getAbsolutePath().length() + 1);
+        return absoluteTarget.substring(workingDirectory.getAbsolutePath().length() + 1 + SHARE_ID.length() + 1);
     }
 
     // crates sample connected to an experiment
@@ -624,7 +630,7 @@ public final class TransferredDataSetHandlerTest extends AbstractFileSystemTestC
                 + "but according to the openBIS server there is no such sample for this experiment "
                 + "(it has maybe been invalidated?). We thus consider it invalid."
                 + OSUtilities.LINE_SEPARATOR + "INFO  OPERATION.FileRenamer - "
-                + "Moving file 'data1' from '<wd>' to '<wd>/invalid/DataSetType_O1'.");
+                + "Moving file 'data1' from '<wd>' to '<wd>/1/invalid/DataSetType_O1'.");
 
         context.assertIsSatisfied();
     }
@@ -637,7 +643,7 @@ public final class TransferredDataSetHandlerTest extends AbstractFileSystemTestC
         assert data1.exists() && data2.exists();
         prepareForStrategy(data1, null);
         final File toDir =
-                new File(new File(workingDirectory,
+                new File(new File(new File(workingDirectory, SHARE_ID),
                         NamedDataStrategy.getDirectoryName(DataStoreStrategyKey.UNIDENTIFIED)),
                         IdentifiedDataStrategy.createDataSetTypeDirectory(DATA_SET_TYPE));
 
@@ -702,7 +708,8 @@ public final class TransferredDataSetHandlerTest extends AbstractFileSystemTestC
             final File dataSet)
     {
         final File strategyDirectory =
-                new File(workingDirectory, NamedDataStrategy.getDirectoryName(key));
+                new File(new File(workingDirectory, SHARE_ID),
+                        NamedDataStrategy.getDirectoryName(key));
         assertEquals(true, strategyDirectory.exists());
         final File dataSetTypeDir =
                 new File(strategyDirectory,
diff --git a/datastore_server/sourceTest/java/ch/systemsx/cisd/etlserver/entityregistration/SampleAndDatasetRegistrationHandlerTest.java b/datastore_server/sourceTest/java/ch/systemsx/cisd/etlserver/entityregistration/SampleAndDatasetRegistrationHandlerTest.java
index 105950899be..8fb1ecb334c 100644
--- a/datastore_server/sourceTest/java/ch/systemsx/cisd/etlserver/entityregistration/SampleAndDatasetRegistrationHandlerTest.java
+++ b/datastore_server/sourceTest/java/ch/systemsx/cisd/etlserver/entityregistration/SampleAndDatasetRegistrationHandlerTest.java
@@ -131,8 +131,8 @@ public class SampleAndDatasetRegistrationHandlerTest extends AbstractFileSystemT
 
         String logText =
                 "Global properties extracted from file 'control.tsv': SAMPLE_TYPE(MY_SAMPLE_TYPE) DATA_SET_TYPE(MY_DATA_SET_TYPE) USER(test@test.test)\n"
-                        + "Registered sample/data set pair SampleDataSetPair[sampleIdentifier=/MYSPACE/S1,sampleProperties={prop1: VAL10,prop2: VAL20,prop3: VAL30},dataSetInformation=DataSetInformation{sampleCode=<null>,properties={},dataSetType=MY_DATA_SET_TYPE,instanceUUID=<null>,instanceCode=<null>,spaceCode=<null>,experimentIdentifier=/MYSPACE/MYPROJ/EXP1,isCompleteFlag=U,extractableData=ExtractableData{productionDate=<null>,dataProducerCode=<null>,parentDataSetCodes=[],dataSetProperties=[NewProperty{property=prop1,value=VAL40}, NewProperty{property=prop2,value=VAL50}],code=<null>},uploadingUserEmailOrNull=<null>,uploadingUserIdOrNull=test}]\n"
-                        + "Registered sample/data set pair SampleDataSetPair[sampleIdentifier=/MYSPACE/S3,sampleProperties={prop1: VAL12,prop2: VAL22,prop3: VAL32},dataSetInformation=DataSetInformation{sampleCode=<null>,properties={},dataSetType=MY_DATA_SET_TYPE,instanceUUID=<null>,instanceCode=<null>,spaceCode=<null>,experimentIdentifier=/MYSPACE/MYPROJ/EXP3,isCompleteFlag=U,extractableData=ExtractableData{productionDate=<null>,dataProducerCode=<null>,parentDataSetCodes=[],dataSetProperties=[NewProperty{property=prop1,value=VAL42}, NewProperty{property=prop2,value=VAL52}],code=<null>},uploadingUserEmailOrNull=<null>,uploadingUserIdOrNull=test}]\n"
+                        + "Registered sample/data set pair SampleDataSetPair[sampleIdentifier=/MYSPACE/S1,sampleProperties={prop1: VAL10,prop2: VAL20,prop3: VAL30},dataSetInformation=DataSetInformation{sampleCode=<null>,properties={},dataSetType=MY_DATA_SET_TYPE,shareId=<null>,instanceUUID=<null>,instanceCode=<null>,spaceCode=<null>,experimentIdentifier=/MYSPACE/MYPROJ/EXP1,isCompleteFlag=U,extractableData=ExtractableData{productionDate=<null>,dataProducerCode=<null>,parentDataSetCodes=[],dataSetProperties=[NewProperty{property=prop1,value=VAL40}, NewProperty{property=prop2,value=VAL50}],code=<null>},uploadingUserEmailOrNull=<null>,uploadingUserIdOrNull=test}]\n"
+                        + "Registered sample/data set pair SampleDataSetPair[sampleIdentifier=/MYSPACE/S3,sampleProperties={prop1: VAL12,prop2: VAL22,prop3: VAL32},dataSetInformation=DataSetInformation{sampleCode=<null>,properties={},dataSetType=MY_DATA_SET_TYPE,shareId=<null>,instanceUUID=<null>,instanceCode=<null>,spaceCode=<null>,experimentIdentifier=/MYSPACE/MYPROJ/EXP3,isCompleteFlag=U,extractableData=ExtractableData{productionDate=<null>,dataProducerCode=<null>,parentDataSetCodes=[],dataSetProperties=[NewProperty{property=prop1,value=VAL42}, NewProperty{property=prop2,value=VAL52}],code=<null>},uploadingUserEmailOrNull=<null>,uploadingUserIdOrNull=test}]\n"
                         + "Encountered errors in the following lines:\n"
                         + "# Illegal empty identifier\n"
                         + "\t/MYSPACE/MYPROJ/EXP2\tVAL11\tVAL21\tVAL31\tFILE_TYPE\tVAL41\tVAL51\tds2/\n\n"
@@ -171,7 +171,7 @@ public class SampleAndDatasetRegistrationHandlerTest extends AbstractFileSystemT
 
         String logText =
                 "Global properties extracted from file 'control.tsv': SAMPLE_TYPE(MY_SAMPLE_TYPE) DATA_SET_TYPE(MY_DATA_SET_TYPE) USER(test@test.test)\n"
-                        + "Registered sample/data set pair SampleDataSetPair[sampleIdentifier=/MYSPACE/S1,sampleProperties={prop1: VAL10,prop2: VAL20,prop3: VAL30},dataSetInformation=DataSetInformation{sampleCode=<null>,properties={},dataSetType=MY_DATA_SET_TYPE,instanceUUID=<null>,instanceCode=<null>,spaceCode=<null>,experimentIdentifier=/MYSPACE/MYPROJ/EXP1,isCompleteFlag=U,extractableData=ExtractableData{productionDate=<null>,dataProducerCode=<null>,parentDataSetCodes=[],dataSetProperties=[NewProperty{property=prop1,value=VAL40}, NewProperty{property=prop2,value=VAL50}],code=<null>},uploadingUserEmailOrNull=<null>,uploadingUserIdOrNull=test}]\n"
+                        + "Registered sample/data set pair SampleDataSetPair[sampleIdentifier=/MYSPACE/S1,sampleProperties={prop1: VAL10,prop2: VAL20,prop3: VAL30},dataSetInformation=DataSetInformation{sampleCode=<null>,properties={},dataSetType=MY_DATA_SET_TYPE,shareId=<null>,instanceUUID=<null>,instanceCode=<null>,spaceCode=<null>,experimentIdentifier=/MYSPACE/MYPROJ/EXP1,isCompleteFlag=U,extractableData=ExtractableData{productionDate=<null>,dataProducerCode=<null>,parentDataSetCodes=[],dataSetProperties=[NewProperty{property=prop1,value=VAL40}, NewProperty{property=prop2,value=VAL50}],code=<null>},uploadingUserEmailOrNull=<null>,uploadingUserIdOrNull=test}]\n"
                         + "The following subfolders were in the uploaded folder, but were not mentioned in the control file:\n"
                         + "ds2,ds3\n"
                         + "The following lines were successfully processed:\n"
@@ -209,9 +209,9 @@ public class SampleAndDatasetRegistrationHandlerTest extends AbstractFileSystemT
 
         String logText =
                 "Global properties extracted from file 'control.tsv': SAMPLE_TYPE(MY_SAMPLE_TYPE) DATA_SET_TYPE(MY_DATA_SET_TYPE) USER(test@test.test)\n"
-                        + "Registered sample/data set pair SampleDataSetPair[sampleIdentifier=/MYSPACE/S1,sampleProperties={prop1: VAL10,prop2: VAL20,prop3: VAL30},dataSetInformation=DataSetInformation{sampleCode=<null>,properties={},dataSetType=MY_DATA_SET_TYPE,instanceUUID=<null>,instanceCode=<null>,spaceCode=<null>,experimentIdentifier=/MYSPACE/MYPROJ/EXP1,isCompleteFlag=U,extractableData=ExtractableData{productionDate=<null>,dataProducerCode=<null>,parentDataSetCodes=[],dataSetProperties=[NewProperty{property=prop1,value=VAL40}, NewProperty{property=prop2,value=VAL50}],code=<null>},uploadingUserEmailOrNull=<null>,uploadingUserIdOrNull=test}]\n"
-                        + "Registered sample/data set pair SampleDataSetPair[sampleIdentifier=/MYSPACE/S2,sampleProperties={prop1: VAL11,prop2: VAL21,prop3: VAL31},dataSetInformation=DataSetInformation{sampleCode=<null>,properties={},dataSetType=MY_DATA_SET_TYPE,instanceUUID=<null>,instanceCode=<null>,spaceCode=<null>,experimentIdentifier=/MYSPACE/MYPROJ/EXP2,isCompleteFlag=U,extractableData=ExtractableData{productionDate=<null>,dataProducerCode=<null>,parentDataSetCodes=[],dataSetProperties=[NewProperty{property=prop1,value=VAL41}, NewProperty{property=prop2,value=VAL51}],code=<null>},uploadingUserEmailOrNull=<null>,uploadingUserIdOrNull=test}]\n"
-                        + "Registered sample/data set pair SampleDataSetPair[sampleIdentifier=/MYSPACE/S3,sampleProperties={prop1: VAL12,prop2: VAL22,prop3: VAL32},dataSetInformation=DataSetInformation{sampleCode=<null>,properties={},dataSetType=MY_DATA_SET_TYPE,instanceUUID=<null>,instanceCode=<null>,spaceCode=<null>,experimentIdentifier=/MYSPACE/MYPROJ/EXP3,isCompleteFlag=U,extractableData=ExtractableData{productionDate=<null>,dataProducerCode=<null>,parentDataSetCodes=[],dataSetProperties=[NewProperty{property=prop1,value=VAL42}, NewProperty{property=prop2,value=VAL52}],code=<null>},uploadingUserEmailOrNull=<null>,uploadingUserIdOrNull=test}]";
+                        + "Registered sample/data set pair SampleDataSetPair[sampleIdentifier=/MYSPACE/S1,sampleProperties={prop1: VAL10,prop2: VAL20,prop3: VAL30},dataSetInformation=DataSetInformation{sampleCode=<null>,properties={},dataSetType=MY_DATA_SET_TYPE,shareId=<null>,instanceUUID=<null>,instanceCode=<null>,spaceCode=<null>,experimentIdentifier=/MYSPACE/MYPROJ/EXP1,isCompleteFlag=U,extractableData=ExtractableData{productionDate=<null>,dataProducerCode=<null>,parentDataSetCodes=[],dataSetProperties=[NewProperty{property=prop1,value=VAL40}, NewProperty{property=prop2,value=VAL50}],code=<null>},uploadingUserEmailOrNull=<null>,uploadingUserIdOrNull=test}]\n"
+                        + "Registered sample/data set pair SampleDataSetPair[sampleIdentifier=/MYSPACE/S2,sampleProperties={prop1: VAL11,prop2: VAL21,prop3: VAL31},dataSetInformation=DataSetInformation{sampleCode=<null>,properties={},dataSetType=MY_DATA_SET_TYPE,shareId=<null>,instanceUUID=<null>,instanceCode=<null>,spaceCode=<null>,experimentIdentifier=/MYSPACE/MYPROJ/EXP2,isCompleteFlag=U,extractableData=ExtractableData{productionDate=<null>,dataProducerCode=<null>,parentDataSetCodes=[],dataSetProperties=[NewProperty{property=prop1,value=VAL41}, NewProperty{property=prop2,value=VAL51}],code=<null>},uploadingUserEmailOrNull=<null>,uploadingUserIdOrNull=test}]\n"
+                        + "Registered sample/data set pair SampleDataSetPair[sampleIdentifier=/MYSPACE/S3,sampleProperties={prop1: VAL12,prop2: VAL22,prop3: VAL32},dataSetInformation=DataSetInformation{sampleCode=<null>,properties={},dataSetType=MY_DATA_SET_TYPE,shareId=<null>,instanceUUID=<null>,instanceCode=<null>,spaceCode=<null>,experimentIdentifier=/MYSPACE/MYPROJ/EXP3,isCompleteFlag=U,extractableData=ExtractableData{productionDate=<null>,dataProducerCode=<null>,parentDataSetCodes=[],dataSetProperties=[NewProperty{property=prop1,value=VAL42}, NewProperty{property=prop2,value=VAL52}],code=<null>},uploadingUserEmailOrNull=<null>,uploadingUserIdOrNull=test}]";
         checkAppenderContent(logText, folderName);
 
         context.assertIsSatisfied();
@@ -244,9 +244,9 @@ public class SampleAndDatasetRegistrationHandlerTest extends AbstractFileSystemT
 
         String logText =
                 "Global properties extracted from file 'control.tsv': SAMPLE_TYPE(MY_SAMPLE_TYPE) DATA_SET_TYPE(MY_DATA_SET_TYPE) USER(test@test.test)\n"
-                        + "Registered sample/data set pair SampleDataSetPair[sampleIdentifier=/MYSPACE/S1,sampleProperties={prop1: VAL10,prop2: VAL20,prop3: VAL30},dataSetInformation=DataSetInformation{sampleCode=<null>,properties={},dataSetType=MY_DATA_SET_TYPE,instanceUUID=<null>,instanceCode=<null>,spaceCode=<null>,experimentIdentifier=/MYSPACE/MYPROJ/EXP1,isCompleteFlag=U,extractableData=ExtractableData{productionDate=<null>,dataProducerCode=<null>,parentDataSetCodes=[],dataSetProperties=[NewProperty{property=prop1,value=VAL40}, NewProperty{property=prop2,value=VAL50}],code=<null>},uploadingUserEmailOrNull=<null>,uploadingUserIdOrNull=test}]\n"
-                        + "Registered sample/data set pair SampleDataSetPair[sampleIdentifier=/MYSPACE/S2,sampleProperties={prop1: VAL11,prop2: VAL21,prop3: VAL31},dataSetInformation=DataSetInformation{sampleCode=<null>,properties={},dataSetType=MY_DATA_SET_TYPE,instanceUUID=<null>,instanceCode=<null>,spaceCode=<null>,experimentIdentifier=/MYSPACE/MYPROJ/EXP2,isCompleteFlag=U,extractableData=ExtractableData{productionDate=<null>,dataProducerCode=<null>,parentDataSetCodes=[],dataSetProperties=[NewProperty{property=prop1,value=VAL41}, NewProperty{property=prop2,value=VAL51}],code=<null>},uploadingUserEmailOrNull=<null>,uploadingUserIdOrNull=test}]\n"
-                        + "Registered sample/data set pair SampleDataSetPair[sampleIdentifier=/MYSPACE/S3,sampleProperties={prop1: VAL12,prop2: VAL22,prop3: VAL32},dataSetInformation=DataSetInformation{sampleCode=<null>,properties={},dataSetType=MY_DATA_SET_TYPE,instanceUUID=<null>,instanceCode=<null>,spaceCode=<null>,experimentIdentifier=/MYSPACE/MYPROJ/EXP3,isCompleteFlag=U,extractableData=ExtractableData{productionDate=<null>,dataProducerCode=<null>,parentDataSetCodes=[],dataSetProperties=[NewProperty{property=prop1,value=VAL42}, NewProperty{property=prop2,value=VAL52}],code=<null>},uploadingUserEmailOrNull=<null>,uploadingUserIdOrNull=test}]";
+                        + "Registered sample/data set pair SampleDataSetPair[sampleIdentifier=/MYSPACE/S1,sampleProperties={prop1: VAL10,prop2: VAL20,prop3: VAL30},dataSetInformation=DataSetInformation{sampleCode=<null>,properties={},dataSetType=MY_DATA_SET_TYPE,shareId=<null>,instanceUUID=<null>,instanceCode=<null>,spaceCode=<null>,experimentIdentifier=/MYSPACE/MYPROJ/EXP1,isCompleteFlag=U,extractableData=ExtractableData{productionDate=<null>,dataProducerCode=<null>,parentDataSetCodes=[],dataSetProperties=[NewProperty{property=prop1,value=VAL40}, NewProperty{property=prop2,value=VAL50}],code=<null>},uploadingUserEmailOrNull=<null>,uploadingUserIdOrNull=test}]\n"
+                        + "Registered sample/data set pair SampleDataSetPair[sampleIdentifier=/MYSPACE/S2,sampleProperties={prop1: VAL11,prop2: VAL21,prop3: VAL31},dataSetInformation=DataSetInformation{sampleCode=<null>,properties={},dataSetType=MY_DATA_SET_TYPE,shareId=<null>,instanceUUID=<null>,instanceCode=<null>,spaceCode=<null>,experimentIdentifier=/MYSPACE/MYPROJ/EXP2,isCompleteFlag=U,extractableData=ExtractableData{productionDate=<null>,dataProducerCode=<null>,parentDataSetCodes=[],dataSetProperties=[NewProperty{property=prop1,value=VAL41}, NewProperty{property=prop2,value=VAL51}],code=<null>},uploadingUserEmailOrNull=<null>,uploadingUserIdOrNull=test}]\n"
+                        + "Registered sample/data set pair SampleDataSetPair[sampleIdentifier=/MYSPACE/S3,sampleProperties={prop1: VAL12,prop2: VAL22,prop3: VAL32},dataSetInformation=DataSetInformation{sampleCode=<null>,properties={},dataSetType=MY_DATA_SET_TYPE,shareId=<null>,instanceUUID=<null>,instanceCode=<null>,spaceCode=<null>,experimentIdentifier=/MYSPACE/MYPROJ/EXP3,isCompleteFlag=U,extractableData=ExtractableData{productionDate=<null>,dataProducerCode=<null>,parentDataSetCodes=[],dataSetProperties=[NewProperty{property=prop1,value=VAL42}, NewProperty{property=prop2,value=VAL52}],code=<null>},uploadingUserEmailOrNull=<null>,uploadingUserIdOrNull=test}]";
         checkAppenderContent(logText, folderName);
 
         context.assertIsSatisfied();
@@ -280,9 +280,9 @@ public class SampleAndDatasetRegistrationHandlerTest extends AbstractFileSystemT
 
         String logText =
                 "Global properties extracted from file 'control.tsv': SAMPLE_TYPE(MY_SAMPLE_TYPE) DATA_SET_TYPE(MY_DATA_SET_TYPE) USER(test@test.test)\n"
-                        + "Updated sample, registered data set SampleDataSetPair[sampleIdentifier=/MYSPACE/S1,sampleProperties={prop1: VAL10,prop2: VAL20,prop3: VAL30},dataSetInformation=DataSetInformation{sampleCode=<null>,properties={},dataSetType=MY_DATA_SET_TYPE,instanceUUID=<null>,instanceCode=<null>,spaceCode=<null>,experimentIdentifier=/MYSPACE/MYPROJ/EXP1,isCompleteFlag=U,extractableData=ExtractableData{productionDate=<null>,dataProducerCode=<null>,parentDataSetCodes=[],dataSetProperties=[NewProperty{property=prop1,value=VAL40}, NewProperty{property=prop2,value=VAL50}],code=<null>},uploadingUserEmailOrNull=<null>,uploadingUserIdOrNull=test}]\n"
-                        + "Updated sample, registered data set SampleDataSetPair[sampleIdentifier=/MYSPACE/S2,sampleProperties={prop1: VAL11,prop2: VAL21,prop3: VAL31},dataSetInformation=DataSetInformation{sampleCode=<null>,properties={},dataSetType=MY_DATA_SET_TYPE,instanceUUID=<null>,instanceCode=<null>,spaceCode=<null>,experimentIdentifier=/MYSPACE/MYPROJ/EXP2,isCompleteFlag=U,extractableData=ExtractableData{productionDate=<null>,dataProducerCode=<null>,parentDataSetCodes=[],dataSetProperties=[NewProperty{property=prop1,value=VAL41}, NewProperty{property=prop2,value=VAL51}],code=<null>},uploadingUserEmailOrNull=<null>,uploadingUserIdOrNull=test}]\n"
-                        + "Updated sample, registered data set SampleDataSetPair[sampleIdentifier=/MYSPACE/S3,sampleProperties={prop1: VAL12,prop2: VAL22,prop3: VAL32},dataSetInformation=DataSetInformation{sampleCode=<null>,properties={},dataSetType=MY_DATA_SET_TYPE,instanceUUID=<null>,instanceCode=<null>,spaceCode=<null>,experimentIdentifier=/MYSPACE/MYPROJ/EXP3,isCompleteFlag=U,extractableData=ExtractableData{productionDate=<null>,dataProducerCode=<null>,parentDataSetCodes=[],dataSetProperties=[NewProperty{property=prop1,value=VAL42}, NewProperty{property=prop2,value=VAL52}],code=<null>},uploadingUserEmailOrNull=<null>,uploadingUserIdOrNull=test}]";
+                        + "Updated sample, registered data set SampleDataSetPair[sampleIdentifier=/MYSPACE/S1,sampleProperties={prop1: VAL10,prop2: VAL20,prop3: VAL30},dataSetInformation=DataSetInformation{sampleCode=<null>,properties={},dataSetType=MY_DATA_SET_TYPE,shareId=<null>,instanceUUID=<null>,instanceCode=<null>,spaceCode=<null>,experimentIdentifier=/MYSPACE/MYPROJ/EXP1,isCompleteFlag=U,extractableData=ExtractableData{productionDate=<null>,dataProducerCode=<null>,parentDataSetCodes=[],dataSetProperties=[NewProperty{property=prop1,value=VAL40}, NewProperty{property=prop2,value=VAL50}],code=<null>},uploadingUserEmailOrNull=<null>,uploadingUserIdOrNull=test}]\n"
+                        + "Updated sample, registered data set SampleDataSetPair[sampleIdentifier=/MYSPACE/S2,sampleProperties={prop1: VAL11,prop2: VAL21,prop3: VAL31},dataSetInformation=DataSetInformation{sampleCode=<null>,properties={},dataSetType=MY_DATA_SET_TYPE,shareId=<null>,instanceUUID=<null>,instanceCode=<null>,spaceCode=<null>,experimentIdentifier=/MYSPACE/MYPROJ/EXP2,isCompleteFlag=U,extractableData=ExtractableData{productionDate=<null>,dataProducerCode=<null>,parentDataSetCodes=[],dataSetProperties=[NewProperty{property=prop1,value=VAL41}, NewProperty{property=prop2,value=VAL51}],code=<null>},uploadingUserEmailOrNull=<null>,uploadingUserIdOrNull=test}]\n"
+                        + "Updated sample, registered data set SampleDataSetPair[sampleIdentifier=/MYSPACE/S3,sampleProperties={prop1: VAL12,prop2: VAL22,prop3: VAL32},dataSetInformation=DataSetInformation{sampleCode=<null>,properties={},dataSetType=MY_DATA_SET_TYPE,shareId=<null>,instanceUUID=<null>,instanceCode=<null>,spaceCode=<null>,experimentIdentifier=/MYSPACE/MYPROJ/EXP3,isCompleteFlag=U,extractableData=ExtractableData{productionDate=<null>,dataProducerCode=<null>,parentDataSetCodes=[],dataSetProperties=[NewProperty{property=prop1,value=VAL42}, NewProperty{property=prop2,value=VAL52}],code=<null>},uploadingUserEmailOrNull=<null>,uploadingUserIdOrNull=test}]";
         checkAppenderContent(logText, folderName);
 
         context.assertIsSatisfied();
@@ -319,9 +319,9 @@ public class SampleAndDatasetRegistrationHandlerTest extends AbstractFileSystemT
 
         String logText =
                 "Global properties extracted from file 'control.tsv': SAMPLE_TYPE(MY_SAMPLE_TYPE) DATA_SET_TYPE(MY_DATA_SET_TYPE) USER(test@test.test)\n"
-                        + "Registered sample/data set pair SampleDataSetPair[sampleIdentifier=/MYSPACE/S1,sampleProperties={prop1: VAL10,prop2: VAL20,prop3: VAL30},dataSetInformation=DataSetInformation{sampleCode=<null>,properties={},dataSetType=MY_DATA_SET_TYPE,instanceUUID=<null>,instanceCode=<null>,spaceCode=<null>,experimentIdentifier=/MYSPACE/MYPROJ/EXP1,isCompleteFlag=U,extractableData=ExtractableData{productionDate=<null>,dataProducerCode=<null>,parentDataSetCodes=[],dataSetProperties=[NewProperty{property=prop1,value=VAL40}, NewProperty{property=prop2,value=VAL50}],code=<null>},uploadingUserEmailOrNull=<null>,uploadingUserIdOrNull=test}]\n"
-                        + "Updated sample, registered data set SampleDataSetPair[sampleIdentifier=/MYSPACE/S2,sampleProperties={prop1: VAL11,prop2: VAL21,prop3: VAL31},dataSetInformation=DataSetInformation{sampleCode=<null>,properties={},dataSetType=MY_DATA_SET_TYPE,instanceUUID=<null>,instanceCode=<null>,spaceCode=<null>,experimentIdentifier=/MYSPACE/MYPROJ/EXP2,isCompleteFlag=U,extractableData=ExtractableData{productionDate=<null>,dataProducerCode=<null>,parentDataSetCodes=[],dataSetProperties=[NewProperty{property=prop1,value=VAL41}, NewProperty{property=prop2,value=VAL51}],code=<null>},uploadingUserEmailOrNull=<null>,uploadingUserIdOrNull=test}]\n"
-                        + "Registered sample/data set pair SampleDataSetPair[sampleIdentifier=/MYSPACE/S3,sampleProperties={prop1: VAL12,prop2: VAL22,prop3: VAL32},dataSetInformation=DataSetInformation{sampleCode=<null>,properties={},dataSetType=MY_DATA_SET_TYPE,instanceUUID=<null>,instanceCode=<null>,spaceCode=<null>,experimentIdentifier=/MYSPACE/MYPROJ/EXP3,isCompleteFlag=U,extractableData=ExtractableData{productionDate=<null>,dataProducerCode=<null>,parentDataSetCodes=[],dataSetProperties=[NewProperty{property=prop1,value=VAL42}, NewProperty{property=prop2,value=VAL52}],code=<null>},uploadingUserEmailOrNull=<null>,uploadingUserIdOrNull=test}]";
+                        + "Registered sample/data set pair SampleDataSetPair[sampleIdentifier=/MYSPACE/S1,sampleProperties={prop1: VAL10,prop2: VAL20,prop3: VAL30},dataSetInformation=DataSetInformation{sampleCode=<null>,properties={},dataSetType=MY_DATA_SET_TYPE,shareId=<null>,instanceUUID=<null>,instanceCode=<null>,spaceCode=<null>,experimentIdentifier=/MYSPACE/MYPROJ/EXP1,isCompleteFlag=U,extractableData=ExtractableData{productionDate=<null>,dataProducerCode=<null>,parentDataSetCodes=[],dataSetProperties=[NewProperty{property=prop1,value=VAL40}, NewProperty{property=prop2,value=VAL50}],code=<null>},uploadingUserEmailOrNull=<null>,uploadingUserIdOrNull=test}]\n"
+                        + "Updated sample, registered data set SampleDataSetPair[sampleIdentifier=/MYSPACE/S2,sampleProperties={prop1: VAL11,prop2: VAL21,prop3: VAL31},dataSetInformation=DataSetInformation{sampleCode=<null>,properties={},dataSetType=MY_DATA_SET_TYPE,shareId=<null>,instanceUUID=<null>,instanceCode=<null>,spaceCode=<null>,experimentIdentifier=/MYSPACE/MYPROJ/EXP2,isCompleteFlag=U,extractableData=ExtractableData{productionDate=<null>,dataProducerCode=<null>,parentDataSetCodes=[],dataSetProperties=[NewProperty{property=prop1,value=VAL41}, NewProperty{property=prop2,value=VAL51}],code=<null>},uploadingUserEmailOrNull=<null>,uploadingUserIdOrNull=test}]\n"
+                        + "Registered sample/data set pair SampleDataSetPair[sampleIdentifier=/MYSPACE/S3,sampleProperties={prop1: VAL12,prop2: VAL22,prop3: VAL32},dataSetInformation=DataSetInformation{sampleCode=<null>,properties={},dataSetType=MY_DATA_SET_TYPE,shareId=<null>,instanceUUID=<null>,instanceCode=<null>,spaceCode=<null>,experimentIdentifier=/MYSPACE/MYPROJ/EXP3,isCompleteFlag=U,extractableData=ExtractableData{productionDate=<null>,dataProducerCode=<null>,parentDataSetCodes=[],dataSetProperties=[NewProperty{property=prop1,value=VAL42}, NewProperty{property=prop2,value=VAL52}],code=<null>},uploadingUserEmailOrNull=<null>,uploadingUserIdOrNull=test}]";
         checkAppenderContent(logText, folderName);
 
         context.assertIsSatisfied();
diff --git a/datastore_server/sourceTest/java/ch/systemsx/cisd/etlserver/registrator/JythonTopLevelDataSetRegistratorTest.java b/datastore_server/sourceTest/java/ch/systemsx/cisd/etlserver/registrator/JythonTopLevelDataSetRegistratorTest.java
index 2cf1d798ce7..a9ef583ccae 100644
--- a/datastore_server/sourceTest/java/ch/systemsx/cisd/etlserver/registrator/JythonTopLevelDataSetRegistratorTest.java
+++ b/datastore_server/sourceTest/java/ch/systemsx/cisd/etlserver/registrator/JythonTopLevelDataSetRegistratorTest.java
@@ -53,6 +53,7 @@ import ch.systemsx.cisd.etlserver.ITypeExtractor;
 import ch.systemsx.cisd.etlserver.ThreadParameters;
 import ch.systemsx.cisd.etlserver.TopLevelDataSetRegistratorGlobalState;
 import ch.systemsx.cisd.etlserver.validation.IDataSetValidator;
+import ch.systemsx.cisd.openbis.dss.generic.server.DataStoreService;
 import ch.systemsx.cisd.openbis.dss.generic.shared.IEncapsulatedOpenBISService;
 import ch.systemsx.cisd.openbis.dss.generic.shared.dto.DataSetInformation;
 import ch.systemsx.cisd.openbis.dss.generic.shared.utils.DatasetLocationUtil;
@@ -175,9 +176,11 @@ public class JythonTopLevelDataSetRegistratorTest extends AbstractFileSystemTest
         assertEquals(DATA_SET_TYPE, dataSet.recordedObject().getDataSetType());
         File datasetLocation =
                 DatasetLocationUtil.getDatasetLocationPath(workingDirectory, DATA_SET_CODE,
+                        DataStoreService.DEFAULT_SHARE_ID,
                         DATABASE_INSTANCE_UUID);
-        assertEquals(FileUtilities.getRelativeFile(workingDirectory, datasetLocation), dataSet
-                .recordedObject().getLocation());
+        assertEquals(FileUtilities.getRelativeFile(new File(workingDirectory,
+                DataStoreService.DEFAULT_SHARE_ID), datasetLocation), dataSet.recordedObject()
+                .getLocation());
         assertEquals(1, MockStorageProcessor.instance.calledCommitCount);
         assertEquals(datasetLocation, MockStorageProcessor.instance.rootDirs.get(0));
         File incomingDir = MockStorageProcessor.instance.incomingDirs.get(0);
@@ -288,9 +291,10 @@ public class JythonTopLevelDataSetRegistratorTest extends AbstractFileSystemTest
         assertEquals(DATA_SET_TYPE, dataSet1.recordedObject().getDataSetType());
         File datasetLocation1 =
                 DatasetLocationUtil.getDatasetLocationPath(workingDirectory, DATA_SET_CODE + 1,
-                        DATABASE_INSTANCE_UUID);
-        assertEquals(FileUtilities.getRelativeFile(workingDirectory, datasetLocation1), dataSet1
-                .recordedObject().getLocation());
+                        DataStoreService.DEFAULT_SHARE_ID, DATABASE_INSTANCE_UUID);
+        assertEquals(FileUtilities.getRelativeFile(new File(workingDirectory,
+                DataStoreService.DEFAULT_SHARE_ID), datasetLocation1), dataSet1.recordedObject()
+                .getLocation());
         assertEquals(datasetLocation1, MockStorageProcessor.instance.rootDirs.get(0));
         File incomingDir1 = MockStorageProcessor.instance.incomingDirs.get(0);
         assertEquals(new File(new File(stagingDir, DATA_SET_CODE + 1), "sub_data_set_1"),
@@ -305,9 +309,10 @@ public class JythonTopLevelDataSetRegistratorTest extends AbstractFileSystemTest
         assertEquals(DATA_SET_TYPE, dataSet2.recordedObject().getDataSetType());
         File datasetLocation2 =
                 DatasetLocationUtil.getDatasetLocationPath(workingDirectory, DATA_SET_CODE + 2,
-                        DATABASE_INSTANCE_UUID);
-        assertEquals(FileUtilities.getRelativeFile(workingDirectory, datasetLocation2), dataSet2
-                .recordedObject().getLocation());
+                        DataStoreService.DEFAULT_SHARE_ID, DATABASE_INSTANCE_UUID);
+        assertEquals(FileUtilities.getRelativeFile(new File(workingDirectory,
+                DataStoreService.DEFAULT_SHARE_ID), datasetLocation2), dataSet2.recordedObject()
+                .getLocation());
         assertEquals(datasetLocation2, MockStorageProcessor.instance.rootDirs.get(1));
         File incomingDir2 = MockStorageProcessor.instance.incomingDirs.get(1);
         assertEquals(new File(new File(stagingDir, DATA_SET_CODE + 2), "sub_data_set_2"),
@@ -339,7 +344,7 @@ public class JythonTopLevelDataSetRegistratorTest extends AbstractFileSystemTest
         assertEquals(2, MockStorageProcessor.instance.incomingDirs.size());
         assertEquals(2, MockStorageProcessor.instance.calledCommitCount);
         assertEquals(
-                "DataSetInformation{sampleCode=<null>,properties={},dataSetType=O1,instanceUUID=db-uuid,instanceCode=<null>,spaceCode=<null>,experimentIdentifier=/SPACE/PROJECT/EXP-CODE,isCompleteFlag=U,extractableData=ExtractableData{productionDate=<null>,dataProducerCode=<null>,parentDataSetCodes=[data-set-code1],dataSetProperties=[],code=data-set-code2},uploadingUserEmailOrNull=<null>,uploadingUserIdOrNull=<null>}",
+                "DataSetInformation{sampleCode=<null>,properties={},dataSetType=O1,shareId=1,instanceUUID=db-uuid,instanceCode=<null>,spaceCode=<null>,experimentIdentifier=/SPACE/PROJECT/EXP-CODE,isCompleteFlag=U,extractableData=ExtractableData{productionDate=<null>,dataProducerCode=<null>,parentDataSetCodes=[data-set-code1],dataSetProperties=[],code=data-set-code2},uploadingUserEmailOrNull=<null>,uploadingUserIdOrNull=<null>}",
                 MockStorageProcessor.instance.dataSetInfoString);
     }
 
diff --git a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/DssComponentTest.java b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/DssComponentTest.java
index 62e5510a485..9245dddf263 100644
--- a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/DssComponentTest.java
+++ b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/DssComponentTest.java
@@ -34,6 +34,7 @@ import ch.systemsx.cisd.common.filesystem.FileUtilities;
 import ch.systemsx.cisd.openbis.dss.client.api.v1.DssComponentFactory;
 import ch.systemsx.cisd.openbis.dss.client.api.v1.IDataSetDss;
 import ch.systemsx.cisd.openbis.dss.client.api.v1.IDssComponent;
+import ch.systemsx.cisd.openbis.dss.generic.server.DataStoreService;
 import ch.systemsx.cisd.openbis.dss.generic.shared.IEncapsulatedOpenBISService;
 import ch.systemsx.cisd.openbis.dss.generic.shared.ServiceProvider;
 import ch.systemsx.cisd.openbis.dss.generic.shared.api.v1.FileInfoDssBuilder;
@@ -119,7 +120,9 @@ public class DssComponentTest extends SystemTestCase
     {
         SimpleDataSetInformationDTO dataSetInfo = getCodeOfLatestDataSet();
         String code = dataSetInfo.getDataSetCode();
-        File fileIntoStore = new File(new File(rootDir, "store"), dataSetInfo.getDataSetLocation());
+        File fileIntoStore =
+                new File(new File(new File(rootDir, "store"), DataStoreService.DEFAULT_SHARE_ID),
+                        dataSetInfo.getDataSetLocation());
         
         IDataSetDss ds = dss.getDataSet(code);
         
diff --git a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/dss/generic/server/DataStoreServiceTest.java b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/dss/generic/server/DataStoreServiceTest.java
index 32dc33cc3b4..774beed590a 100644
--- a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/dss/generic/server/DataStoreServiceTest.java
+++ b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/dss/generic/server/DataStoreServiceTest.java
@@ -39,6 +39,8 @@ import ch.systemsx.cisd.openbis.dss.generic.shared.utils.PluginUtilTest;
 import ch.systemsx.cisd.openbis.generic.shared.IDataStoreService;
 import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ExternalData;
 import ch.systemsx.cisd.openbis.generic.shared.dto.DataSetUploadContext;
+import ch.systemsx.cisd.openbis.generic.shared.dto.DatasetDescription;
+import ch.systemsx.cisd.openbis.generic.shared.dto.builders.DatasetDescriptionBuilder;
 
 /**
  * @author Franz-Josef Elmer
@@ -53,6 +55,8 @@ public class DataStoreServiceTest extends AssertJUnit
 
     private static final File TEST_STORE = new File(TEST_FOLDER, "store");
 
+    private static final String SHARE_ID = "share-id";
+    
     private static final class MockDataStoreService extends DataStoreService
     {
         private final ICIFEXRPCServiceFactory cifexServiceFactory;
@@ -66,7 +70,7 @@ public class DataStoreServiceTest extends AssertJUnit
                 PluginTaskProviders pluginTaskParameters)
         {
             super(sessionTokenManager, commandExecutorFactory, mailClientParameters,
-                    pluginTaskParameters);
+                    pluginTaskParameters, SHARE_ID);
             this.cifexServiceFactory = cifexServiceFactory;
             this.expectedCIFEXURL = expectedCIFEXURL;
         }
@@ -164,18 +168,46 @@ public class DataStoreServiceTest extends AssertJUnit
     @Test
     public void testGetKnownDataSets() throws IOException
     {
+        String shareId = "share-1";
         String location = "ds1";
-        new File(TEST_STORE, location).createNewFile();
+        DatasetDescriptionBuilder ds1 =
+                new DatasetDescriptionBuilder("ds1").shareId(shareId).location(location);
+        DatasetDescriptionBuilder ds2 = new DatasetDescriptionBuilder("ds2").location(location);
+        File share = new File(TEST_STORE, shareId);
+        share.mkdirs();
+        new File(share, location).createNewFile();
 
         IDataStoreService service = createService();
         List<String> knownDataSets =
-                service.getKnownDataSets(sessionToken, Arrays.asList(location, "ds2"));
+                service.getKnownDataSets(sessionToken,
+                        Arrays.asList(ds1.getDatasetDescription(), ds2.getDatasetDescription()));
 
         assertEquals(1, knownDataSets.size());
         assertSame(location, knownDataSets.get(0));
         context.assertIsSatisfied();
     }
 
+    @Test
+    public void testGetKnownDataSetsForDefaultShareId() throws IOException
+    {
+        String location = "ds1";
+        DatasetDescriptionBuilder ds1 =
+            new DatasetDescriptionBuilder("ds1").location(location);
+        DatasetDescriptionBuilder ds2 = new DatasetDescriptionBuilder("ds2").location("unknown");
+        File share = new File(TEST_STORE, SHARE_ID);
+        share.mkdirs();
+        new File(share, location).createNewFile();
+        
+        IDataStoreService service = createService();
+        List<String> knownDataSets =
+            service.getKnownDataSets(sessionToken,
+                    Arrays.asList(ds1.getDatasetDescription(), ds2.getDatasetDescription()));
+        
+        assertEquals(1, knownDataSets.size());
+        assertSame(location, knownDataSets.get(0));
+        context.assertIsSatisfied();
+    }
+    
     @Test
     public void testDeleteDataSetsForInvalidSessionToken()
     {
@@ -194,15 +226,17 @@ public class DataStoreServiceTest extends AssertJUnit
     @Test
     public void testDeleteDataSets()
     {
-        final List<String> locations = Arrays.asList("d1", "d2");
+        DatasetDescription d1 = new DatasetDescription();
+        final List<DatasetDescription> dataSets = Arrays.asList(d1);
         context.checking(new Expectations()
             {
                 {
-                    one(commandExecutor).scheduleDeletionOfDataSets(locations);
+                    one(commandExecutor).scheduleDeletionOfDataSets(dataSets);
                 }
             });
-        createService().deleteDataSets(sessionToken, locations);
-
+        
+        createService().deleteDataSets(sessionToken, dataSets);
+        assertEquals(SHARE_ID, d1.getDataSetShareId());
         context.assertIsSatisfied();
     }
 
diff --git a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/dss/generic/server/DatasetDownloadServletTest.java b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/dss/generic/server/DatasetDownloadServletTest.java
index afa5e609507..6b45d0cf571 100644
--- a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/dss/generic/server/DatasetDownloadServletTest.java
+++ b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/dss/generic/server/DatasetDownloadServletTest.java
@@ -29,6 +29,7 @@ import java.io.PrintWriter;
 import java.io.StringWriter;
 import java.io.UnsupportedEncodingException;
 import java.net.URLEncoder;
+import java.util.Arrays;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Properties;
@@ -60,6 +61,7 @@ import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ExternalData;
 import ch.systemsx.cisd.openbis.generic.shared.basic.dto.LocatorType;
 import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Project;
 import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Space;
+import ch.systemsx.cisd.openbis.generic.shared.basic.dto.builders.DataSetBuilder;
 import ch.systemsx.cisd.openbis.generic.shared.dto.ExternalDataPE;
 
 /**
@@ -185,6 +187,7 @@ public class DatasetDownloadServletTest
         prepareForObtainingDataSetFromServer(externalData);
         prepareForGettingDataSetFromSession(externalData, "");
         prepareForCreatingHTML(writer);
+        prepareListDataSetsByCode();
 
         DatasetDownloadServlet servlet = createServlet();
         servlet.doGet(request, response);
@@ -220,7 +223,7 @@ public class DatasetDownloadServletTest
         assertContains(getSessionCreationLogMessage() + OSUtilities.LINE_SEPARATOR + LOG_INFO
                 + "Data set '1234-1' obtained from openBIS server.", normalizedLogContent);
         assertContains(OSUtilities.LINE_SEPARATOR + LOG_INFO
-                + "For data set '1234-1' show directory <wd>/db-uuid/0a/28/59/1234-1",
+                + "For data set '1234-1' show directory <wd>/1/db-uuid/0a/28/59/1234-1",
                 normalizedLogContent);
 
         context.assertIsSatisfied();
@@ -259,6 +262,7 @@ public class DatasetDownloadServletTest
         final ExternalData externalData = createExternalData();
         prepareParseRequestURL();
         prepareCreateSession();
+        prepareListDataSetsByCode();
         context.checking(new Expectations()
             {
                 {
@@ -296,12 +300,13 @@ public class DatasetDownloadServletTest
         prepareParseRequestURL();
         prepareCreateSession();
         prepareTryGetDataset(null);
+        prepareListDataSetsByCode();
         context.checking(new Expectations()
             {
                 {
                     one(request).getRequestURI();
                     will(returnValue(REQUEST_URI_PREFIX + EXAMPLE_DATA_SET_CODE));
-
+                    
                     one(response).setContentType("text/html");
                     one(response).getWriter();
                     will(returnValue(new PrintWriter(writer)));
@@ -332,6 +337,7 @@ public class DatasetDownloadServletTest
     {
         final StringWriter writer = new StringWriter();
         final ExternalData externalData = createExternalData();
+        prepareListDataSetsByCode();
         context.checking(new Expectations()
             {
                 {
@@ -361,7 +367,7 @@ public class DatasetDownloadServletTest
                         + "</table> </div> </body></html>"
                         + OSUtilities.LINE_SEPARATOR, writer.toString());
         assertContains(LOG_INFO
-                + "For data set '1234-1' show directory <wd>/db-uuid/0a/28/59/1234-1/"
+                + "For data set '1234-1' show directory <wd>/1/db-uuid/0a/28/59/1234-1/"
                 + EXAMPLE_DATA_SET_SUB_FOLDER_NAME, getNormalizedLogContent());
 
         context.assertIsSatisfied();
@@ -376,6 +382,7 @@ public class DatasetDownloadServletTest
         prepareCreateSession();
         prepareCheckDatasetAccess();
         prepareParseRequestURL();
+        prepareListDataSetsByCode();
         context.checking(new Expectations()
             {
                 {
@@ -406,7 +413,7 @@ public class DatasetDownloadServletTest
                 + "Check access to the data set '1234-1' at openBIS server.", normalizedLogContent);
         assertContains(OSUtilities.LINE_SEPARATOR + LOG_INFO
                 + "For data set '1234-1' deliver file "
-                + "<wd>/db-uuid/0a/28/59/1234-1/read me @home.txt (12 bytes).",
+                + "<wd>/1/db-uuid/0a/28/59/1234-1/read me @home.txt (12 bytes).",
                 normalizedLogContent);
 
         context.assertIsSatisfied();
@@ -420,6 +427,7 @@ public class DatasetDownloadServletTest
         prepareParseRequestURLForThumbnail(100, 50);
         prepareCreateSession();
         prepareCheckDatasetAccess();
+        prepareListDataSetsByCode();
         final ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
         context.checking(new Expectations()
             {
@@ -457,7 +465,7 @@ public class DatasetDownloadServletTest
         AssertionUtil
                 .assertContains(
                         LOG_INFO
-                                + "For data set '1234-1' deliver file <wd>/db-uuid/0a/28/59/1234-1/read me @home.txt "
+                                + "For data set '1234-1' deliver file <wd>/1/db-uuid/0a/28/59/1234-1/read me @home.txt "
                                 + "(84 bytes) as a thumbnail.", normalizedLogContent);
 
         context.assertIsSatisfied();
@@ -470,6 +478,7 @@ public class DatasetDownloadServletTest
         final ExternalData externalData = createExternalData();
         prepareParseRequestURL();
         prepareCreateSession();
+        prepareListDataSetsByCode();
         context.checking(new Expectations()
             {
                 {
@@ -704,6 +713,18 @@ public class DatasetDownloadServletTest
                 }
             });
     }
+    
+    private void prepareListDataSetsByCode()
+    {
+        context.checking(new Expectations()
+            {
+                {
+                    one(dataSetService).listDataSetsByCode(Arrays.asList(EXAMPLE_DATA_SET_CODE));
+                    will(returnValue(Arrays.asList(new DataSetBuilder().code(EXAMPLE_DATA_SET_CODE)
+                            .shareId(DataStoreService.DEFAULT_SHARE_ID).getDataSet())));
+                }
+            });
+    }
 
     private void prepareCheckDatasetAccess()
     {
@@ -768,14 +789,14 @@ public class DatasetDownloadServletTest
         locatorType.setCode(LocatorType.DEFAULT_LOCATOR_TYPE_CODE);
         externalData.setLocatorType(locatorType);
         externalData.setLocation(DatasetLocationUtil.getDatasetRelativeLocationPath(
-                EXAMPLE_DATA_SET_CODE, DATABASE_INSTANCE_UUID));
+                EXAMPLE_DATA_SET_CODE, DataStoreService.DEFAULT_SHARE_ID, DATABASE_INSTANCE_UUID));
         return externalData;
     }
 
     private static File getDatasetDirectoryLocation(final File baseDir, String dataSetCode)
     {
         return DatasetLocationUtil.getDatasetLocationPath(baseDir, dataSetCode,
-                DATABASE_INSTANCE_UUID);
+                DataStoreService.DEFAULT_SHARE_ID, DATABASE_INSTANCE_UUID);
     }
 
     private DatasetDownloadServlet createServlet()
diff --git a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/dss/generic/server/DssServiceRpcV1Test.java b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/dss/generic/server/DssServiceRpcV1Test.java
index 51d40902d02..cda5e6076e1 100644
--- a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/dss/generic/server/DssServiceRpcV1Test.java
+++ b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/dss/generic/server/DssServiceRpcV1Test.java
@@ -23,6 +23,7 @@ import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.io.PrintWriter;
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.Collections;
 import java.util.List;
 import java.util.Properties;
@@ -74,6 +75,7 @@ import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Person;
 import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Project;
 import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Sample;
 import ch.systemsx.cisd.openbis.generic.shared.basic.dto.Space;
+import ch.systemsx.cisd.openbis.generic.shared.basic.dto.builders.DataSetBuilder;
 import ch.systemsx.cisd.openbis.generic.shared.dto.NewExternalData;
 import ch.systemsx.cisd.openbis.generic.shared.dto.SessionContextDTO;
 import ch.systemsx.cisd.openbis.generic.shared.dto.identifier.DatabaseInstanceIdentifier;
@@ -86,6 +88,8 @@ import ch.systemsx.cisd.openbis.generic.shared.dto.identifier.SpaceIdentifier;
  */
 public class DssServiceRpcV1Test extends AbstractFileSystemTestCase
 {
+    private static final String SHARE_ID = "share-1";
+
     private static final String NEW_DATA_SET_EXP = "E1";
 
     private static final String NEW_DATA_SET_OWNER_ID = "/TEST-SPACE/S1";
@@ -165,7 +169,7 @@ public class DssServiceRpcV1Test extends AbstractFileSystemTestCase
     private void initializeDirectories(File storeDir, File incomingDir) throws IOException
     {
         File location =
-                DatasetLocationUtil.getDatasetLocationPath(storeDir, DATA_SET_CODE,
+                DatasetLocationUtil.getDatasetLocationPath(storeDir, DATA_SET_CODE, SHARE_ID,
                         DB_INSTANCE_UUID);
         if (!location.mkdirs())
             return;
@@ -273,6 +277,7 @@ public class DssServiceRpcV1Test extends AbstractFileSystemTestCase
     @Test
     public void testDataSetListingNonRecursive()
     {
+        prepareListDataSetsByCode();
         FileInfoDssDTO[] fileInfos =
                 rpcService.listFilesForDataSet(SESSION_TOKEN, DATA_SET_CODE, "/", false);
         assertEquals(2, fileInfos.length);
@@ -302,6 +307,7 @@ public class DssServiceRpcV1Test extends AbstractFileSystemTestCase
     @Test
     public void testDataSetListingRecursive()
     {
+        prepareListDataSetsByCode();
         FileInfoDssDTO[] fileInfos =
                 rpcService.listFilesForDataSet(SESSION_TOKEN, DATA_SET_CODE, "/", true);
         assertEquals(3, fileInfos.length);
@@ -344,6 +350,7 @@ public class DssServiceRpcV1Test extends AbstractFileSystemTestCase
     @Test
     public void testDataSetListingOfChild()
     {
+        prepareListDataSetsByCode();
         FileInfoDssDTO[] fileInfos =
                 rpcService.listFilesForDataSet(SESSION_TOKEN, DATA_SET_CODE, "/stuff/", false);
         assertEquals(1, fileInfos.length);
@@ -373,6 +380,7 @@ public class DssServiceRpcV1Test extends AbstractFileSystemTestCase
     @Test
     public void testDataSetListingOfRelativeChild()
     {
+        prepareListDataSetsByCode();
         FileInfoDssDTO[] fileInfos =
                 rpcService.listFilesForDataSet(SESSION_TOKEN, DATA_SET_CODE, "stuff/", false);
         assertEquals(1, fileInfos.length);
@@ -386,6 +394,7 @@ public class DssServiceRpcV1Test extends AbstractFileSystemTestCase
     @Test
     public void testDataSetListingOfFile()
     {
+        prepareListDataSetsByCode();
         FileInfoDssDTO[] fileInfos =
                 rpcService
                         .listFilesForDataSet(SESSION_TOKEN, DATA_SET_CODE, "stuff/bar.txt", false);
@@ -424,6 +433,8 @@ public class DssServiceRpcV1Test extends AbstractFileSystemTestCase
     @Test
     public void testDataSetListingWithSneakyPath()
     {
+        prepareListDataSetsByCode();
+        prepareListDataSetsByCode();
         try
         {
             rpcService.listFilesForDataSet(SESSION_TOKEN, DATA_SET_CODE, "../", true);
@@ -448,6 +459,8 @@ public class DssServiceRpcV1Test extends AbstractFileSystemTestCase
     @Test
     public void testDataSetFileRetrieval() throws IOException
     {
+        prepareListDataSetsByCode();
+        prepareListDataSetsByCode();
         FileInfoDssDTO[] fileInfos =
                 rpcService
                         .listFilesForDataSet(SESSION_TOKEN, DATA_SET_CODE, "stuff/bar.txt", false);
@@ -524,6 +537,7 @@ public class DssServiceRpcV1Test extends AbstractFileSystemTestCase
     @Test
     public void testAuthorizationForStringCode()
     {
+        prepareListDataSetsByCode();
         TestMethodInterceptor testMethodInterceptor = new TestMethodInterceptor();
         IDssServiceRpcGenericInternal service = getAdvisedService(testMethodInterceptor);
         service.listFilesForDataSet(SESSION_TOKEN, DATA_SET_CODE, "/", false);
@@ -533,6 +547,7 @@ public class DssServiceRpcV1Test extends AbstractFileSystemTestCase
     @Test
     public void testAuthorizationDataSetFile()
     {
+        prepareListDataSetsByCode();
         TestMethodInterceptor testMethodInterceptor = new TestMethodInterceptor();
         IDssServiceRpcGenericInternal service = getAdvisedService(testMethodInterceptor);
         DataSetFileDTO dataSetFile = new DataSetFileDTO(DATA_SET_CODE, "/", false);
@@ -605,4 +620,17 @@ public class DssServiceRpcV1Test extends AbstractFileSystemTestCase
         builder.appendFileInfosForFile(file, fileInfos, true);
         return fileInfos;
     }
+    
+    private void prepareListDataSetsByCode()
+    {
+        context.checking(new Expectations()
+            {
+                {
+                    one(openBisService).listDataSetsByCode(Arrays.asList(DATA_SET_CODE));
+                    will(returnValue(Arrays.asList(new DataSetBuilder().code(DATA_SET_CODE)
+                            .shareId(SHARE_ID).getDataSet())));
+                }
+            });
+    }
+
 }
diff --git a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/dss/generic/server/EncapsulatedOpenBISServiceTest.java b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/dss/generic/server/EncapsulatedOpenBISServiceTest.java
index 99de1882078..e255205ddd0 100644
--- a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/dss/generic/server/EncapsulatedOpenBISServiceTest.java
+++ b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/dss/generic/server/EncapsulatedOpenBISServiceTest.java
@@ -35,6 +35,8 @@ import ch.systemsx.cisd.openbis.generic.shared.dto.identifier.SampleIdentifier;
  */
 public class EncapsulatedOpenBISServiceTest
 {
+    private static final String DEFAULT_SHARE_ID = "share-id";
+
     private static final String SESSION_TOKEN = "session-token";
 
     private Mockery context;
@@ -52,7 +54,7 @@ public class EncapsulatedOpenBISServiceTest
         limsService = context.mock(IETLLIMSService.class);
         session = new OpenBISSessionHolder();
         session.setToken(SESSION_TOKEN);
-        encapsulatedLimsService = new EncapsulatedOpenBISService(limsService, session);
+        encapsulatedLimsService = new EncapsulatedOpenBISService(limsService, session, DEFAULT_SHARE_ID);
     }
 
     @AfterMethod
diff --git a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/dss/generic/server/UploadingCommandTest.java b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/dss/generic/server/UploadingCommandTest.java
index c5ce5b43d1a..39e57cde043 100644
--- a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/dss/generic/server/UploadingCommandTest.java
+++ b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/dss/generic/server/UploadingCommandTest.java
@@ -71,6 +71,8 @@ import ch.systemsx.cisd.openbis.generic.shared.translator.ExternalDataTranslator
 @Friend(toClasses = UploadingCommand.class)
 public class UploadingCommandTest extends AssertJUnit
 {
+    private static final String SHARE_ID = "share-id";
+
     private static final String ZIP_FILENAME = "myData";
 
     private static final String INFO_UPLOAD_PREFIX = "INFO  OPERATION.UploadingCommand - ";
@@ -182,6 +184,7 @@ public class UploadingCommandTest extends AssertJUnit
     {
         ExternalDataPE externalData = new ExternalDataPE();
         externalData.setCode(code);
+        externalData.setShareId(SHARE_ID);
         externalData.setLocation(location);
         externalData.setDerived(true); // measured == (derived == false)
         DataSetTypePE dataSetTypePE = new DataSetTypePE();
@@ -233,8 +236,8 @@ public class UploadingCommandTest extends AssertJUnit
 
     private File createTestData(String location)
     {
-        File dataSet = new File(STORE, location);
-        dataSet.mkdir();
+        File dataSet = new File(new File(STORE, SHARE_ID), location);
+        dataSet.mkdirs();
         FileUtilities.writeToFile(new File(dataSet, "README.TXT"), "Data set " + location);
         File dataFolder = new File(dataSet, "data");
         dataFolder.mkdir();
@@ -411,7 +414,7 @@ public class UploadingCommandTest extends AssertJUnit
         command.execute(STORE);
 
         checkEmail("Couldn't create zip file");
-        assertEquals("ERROR NOTIFY.UploadingCommand - Data set 'ds2' does not exist."
+        assertEquals("ERROR NOTIFY.UploadingCommand - Data set 'share-id/ds2' does not exist."
                 + OSUtilities.LINE_SEPARATOR + INFO_MAIL_PREFIX
                 + "Sending message from 'a@bc.de' to recipients '[user@bc.de]'",
                 getNormalizedLogContent());
diff --git a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/dss/generic/server/api/v1/DssServiceRpcGenericTest.java b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/dss/generic/server/api/v1/DssServiceRpcGenericTest.java
index 4cc02c13924..09237fd339b 100644
--- a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/dss/generic/server/api/v1/DssServiceRpcGenericTest.java
+++ b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/dss/generic/server/api/v1/DssServiceRpcGenericTest.java
@@ -17,6 +17,7 @@
 package ch.systemsx.cisd.openbis.dss.generic.server.api.v1;
 
 import java.io.File;
+import java.util.Arrays;
 
 import org.jmock.Expectations;
 import org.jmock.Mockery;
@@ -26,12 +27,14 @@ import org.testng.annotations.BeforeMethod;
 import org.testng.annotations.Test;
 
 import ch.systemsx.cisd.base.tests.AbstractFileSystemTestCase;
+import ch.systemsx.cisd.openbis.dss.generic.server.DataStoreService;
 import ch.systemsx.cisd.openbis.dss.generic.server.DssServiceRpcAuthorizationAdvisor;
 import ch.systemsx.cisd.openbis.dss.generic.shared.IEncapsulatedOpenBISService;
 import ch.systemsx.cisd.openbis.dss.generic.shared.api.v1.FileInfoDssDTO;
 import ch.systemsx.cisd.openbis.dss.generic.shared.api.v1.IDssServiceRpcGeneric;
 import ch.systemsx.cisd.openbis.dss.generic.shared.utils.DatasetLocationUtil;
 import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DatabaseInstance;
+import ch.systemsx.cisd.openbis.generic.shared.basic.dto.builders.DataSetBuilder;
 
 
 /**
@@ -88,7 +91,10 @@ public class DssServiceRpcGenericTest extends AbstractFileSystemTestCase
         final String dataSetCode = "ds-1";
         prepareCheckDataSetAccess(dataSetCode);
         prepareCheckDataSetAccess(dataSetCode);
-        File location = DatasetLocationUtil.getDatasetLocationPath(store, dataSetCode, DB_UUID);
+        prepareListDataSetsByCode(dataSetCode);
+        File location =
+                DatasetLocationUtil.getDatasetLocationPath(store, dataSetCode,
+                        DataStoreService.DEFAULT_SHARE_ID, DB_UUID);
         location.mkdirs();
         
         FileInfoDssDTO[] dataSets = dssService.listFilesForDataSet(SESSION_TOKEN, dataSetCode, "abc/de", true);
@@ -98,6 +104,18 @@ public class DssServiceRpcGenericTest extends AbstractFileSystemTestCase
         context.assertIsSatisfied();
     }
 
+    private void prepareListDataSetsByCode(final String dataSetCode)
+    {
+        context.checking(new Expectations()
+            {
+                {
+                    one(service).listDataSetsByCode(Arrays.asList(dataSetCode));
+                    will(returnValue(Arrays.asList(new DataSetBuilder().code(dataSetCode)
+                            .shareId(DataStoreService.DEFAULT_SHARE_ID).getDataSet())));
+                }
+            });
+    }
+
     private void prepareCheckDataSetAccess(final String dataSetCode)
     {
         context.checking(new Expectations()
diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/ETLService.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/ETLService.java
index 43ef9fe50dd..8e1d24f2cae 100644
--- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/ETLService.java
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/ETLService.java
@@ -485,6 +485,13 @@ public class ETLService extends AbstractCommonServer<IETLService> implements IET
         Collections.sort(datasets);
         return datasets;
     }
+    
+    public List<ExternalData> listDataSetsByCode(String sessionToken, List<String> dataSetCodes)
+    {
+        final Session session = getSession(sessionToken);
+        final IDatasetLister datasetLister = createDatasetLister(session);
+        return datasetLister.listByDatasetCode(dataSetCodes);
+    }
 
     public IEntityProperty[] tryToGetPropertiesOfTopSampleRegisteredFor(String sessionToken,
             SampleIdentifier sampleIdentifier) throws UserFailureException
diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/ETLServiceLogger.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/ETLServiceLogger.java
index fa5be84bea1..23be394552a 100644
--- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/ETLServiceLogger.java
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/ETLServiceLogger.java
@@ -212,6 +212,13 @@ public class ETLServiceLogger extends AbstractServerLogger implements IETLServic
         return null;
     }
 
+    public List<ExternalData> listDataSetsByCode(String sessionToken, List<String> dataSetCodes)
+            throws UserFailureException
+    {
+        logAccess(sessionToken, "listDataSetsByCode", "DATA_SETS(%s)", dataSetCodes);
+        return null;
+    }
+
     public IEntityProperty[] tryToGetPropertiesOfTopSampleRegisteredFor(String sessionToken,
             SampleIdentifier sampleIdentifier) throws UserFailureException
     {
diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/ExternalDataTable.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/ExternalDataTable.java
index 00b7ee038a4..4fb80952c16 100644
--- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/ExternalDataTable.java
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/ExternalDataTable.java
@@ -63,11 +63,11 @@ import ch.systemsx.cisd.openbis.generic.shared.dto.EventPE.EntityType;
 import ch.systemsx.cisd.openbis.generic.shared.dto.EventType;
 import ch.systemsx.cisd.openbis.generic.shared.dto.ExperimentPE;
 import ch.systemsx.cisd.openbis.generic.shared.dto.ExternalDataPE;
-import ch.systemsx.cisd.openbis.generic.shared.dto.SpacePE;
 import ch.systemsx.cisd.openbis.generic.shared.dto.PersonPE;
 import ch.systemsx.cisd.openbis.generic.shared.dto.ProjectPE;
 import ch.systemsx.cisd.openbis.generic.shared.dto.SamplePE;
 import ch.systemsx.cisd.openbis.generic.shared.dto.Session;
+import ch.systemsx.cisd.openbis.generic.shared.dto.SpacePE;
 import ch.systemsx.cisd.openbis.generic.shared.dto.properties.EntityKind;
 import ch.systemsx.cisd.openbis.generic.shared.translator.ExternalDataTranslator;
 import ch.systemsx.cisd.openbis.generic.shared.util.HibernateUtils;
@@ -218,7 +218,7 @@ public final class ExternalDataTable extends AbstractExternalDataBusinessObject
                 deleteDataSetLocally(dataSet, reason);
             }
             // delete remotely from Data Store
-            deleteDataSets(dataStore, getLocations(dataSets));
+            deleteDataSets(dataStore, createDatasetDescriptions(dataSets));
         }
     }
 
@@ -318,8 +318,8 @@ public final class ExternalDataTable extends AbstractExternalDataBusinessObject
         for (Map.Entry<DataStorePE, List<ExternalDataPE>> entry : map.entrySet())
         {
             DataStorePE dataStore = entry.getKey();
-            List<String> locations = getLocations(entry.getValue());
-            knownLocations.addAll(getKnownDataSets(dataStore, locations));
+            List<ExternalDataPE> dataSets = entry.getValue();
+            knownLocations.addAll(getKnownDataSets(dataStore, createDatasetDescriptions(dataSets)));
         }
         List<String> unknownDataSets = new ArrayList<String>();
         for (ExternalDataPE dataSet : externalData)
@@ -356,16 +356,6 @@ public final class ExternalDataTable extends AbstractExternalDataBusinessObject
         return map;
     }
 
-    private List<String> getLocations(List<ExternalDataPE> dataSets)
-    {
-        List<String> locations = new ArrayList<String>();
-        for (ExternalDataPE dataSet : dataSets)
-        {
-            locations.add(dataSet.getLocation());
-        }
-        return locations;
-    }
-
     private void uploadDataSetsToCIFEX(DataStorePE dataStore, List<ExternalDataPE> dataSets,
             DataSetUploadContext context)
     {
@@ -375,7 +365,7 @@ public final class ExternalDataTable extends AbstractExternalDataBusinessObject
         service.uploadDataSetsToCIFEX(sessionToken, cleanDataSets, context);
     }
 
-    private void deleteDataSets(DataStorePE dataStore, List<String> locations)
+    private void deleteDataSets(DataStorePE dataStore, List<DatasetDescription> list)
     {
         IDataStoreService service = tryGetDataStoreService(dataStore);
         if (service == null)
@@ -384,7 +374,7 @@ public final class ExternalDataTable extends AbstractExternalDataBusinessObject
             return;
         }
         String sessionToken = dataStore.getSessionToken();
-        service.deleteDataSets(sessionToken, locations);
+        service.deleteDataSets(sessionToken, list);
     }
 
     // null if DSS URL has not been specified
@@ -398,17 +388,22 @@ public final class ExternalDataTable extends AbstractExternalDataBusinessObject
         return dssFactory.create(remoteURL);
     }
 
-    private List<String> getKnownDataSets(DataStorePE dataStore, List<String> locations)
+    private List<String> getKnownDataSets(DataStorePE dataStore, List<DatasetDescription> dataSets)
     {
         String remoteURL = dataStore.getRemoteUrl();
         if (StringUtils.isBlank(remoteURL))
         {
             // Assuming dummy data store "knows" all locations
+            List<String> locations = new ArrayList<String>();
+            for (DatasetDescription dataSet : dataSets)
+            {
+                locations.add(dataSet.getDataSetLocation());
+            }
             return locations;
         }
         IDataStoreService service = dssFactory.create(remoteURL);
         String sessionToken = dataStore.getSessionToken();
-        return service.getKnownDataSets(sessionToken, locations);
+        return service.getKnownDataSets(sessionToken, dataSets);
     }
 
     public void processDatasets(String datastoreServiceKey, String datastoreCode,
diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/datasetlister/DatasetLister.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/datasetlister/DatasetLister.java
index 36e1c6c7d9e..0d2d597e9b5 100644
--- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/datasetlister/DatasetLister.java
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/datasetlister/DatasetLister.java
@@ -325,7 +325,7 @@ public class DatasetLister extends AbstractLister implements IDatasetLister
         return enrichDatasets(query.getDatasets(new LongOpenHashSet(datasetIds)));
     }
 
-    public List<ExternalData> listByDatasetCodes(Collection<String> datasetCodes)
+    public List<ExternalData> listByDatasetCode(Collection<String> datasetCodes)
     {
         String[] codes = datasetCodes.toArray(new String[datasetCodes.size()]);
         DataIterator<DatasetRecord> datasets = query.getDatasets(codes);
diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/datasetlister/IDatasetLister.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/datasetlister/IDatasetLister.java
index 9a9c2c22aaa..2f760abfbc4 100644
--- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/datasetlister/IDatasetLister.java
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/server/business/bo/datasetlister/IDatasetLister.java
@@ -73,7 +73,7 @@ public interface IDatasetLister
     /** 
      * Lists all data sets with specified codes. Unenriched data sets will be returned. 
      */
-    List<ExternalData> listByDatasetCodes(Collection<String> datasetCodes);
+    List<ExternalData> listByDatasetCode(Collection<String> datasetCodes);
 
     /** @return datasets with given ids */
     List<ExternalData> listByDatasetIds(Collection<Long> datasetIds);
diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/IDataStoreService.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/IDataStoreService.java
index 3e0ce3eefdd..7cefba2da43 100644
--- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/IDataStoreService.java
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/IDataStoreService.java
@@ -49,12 +49,13 @@ public interface IDataStoreService
     public int getVersion(String sessionToken) throws InvalidAuthenticationException;
 
     /**
-     * Returns from the specified data set locations those locations known by the Data Store Server.
+     * Returns from the specified data sets those known by the Data Store Server.
      * 
      * @param sessionToken Valid token to identify authorised access.
+     * @return locations of known data sets
      * @throws InvalidAuthenticationException if <code>sessionToken</code> is invalid.
      */
-    public List<String> getKnownDataSets(String sessionToken, List<String> dataSetLocations)
+    public List<String> getKnownDataSets(String sessionToken, List<DatasetDescription> dataSets)
             throws InvalidAuthenticationException;
 
     /**
@@ -63,7 +64,7 @@ public interface IDataStoreService
      * @param sessionToken Valid token to identify authorised access.
      * @throws InvalidAuthenticationException if <code>sessionToken</code> is invalid.
      */
-    public void deleteDataSets(String sessionToken, List<String> dataSetLocations)
+    public void deleteDataSets(String sessionToken, List<DatasetDescription> dataSets)
             throws InvalidAuthenticationException;
 
     /**
diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/IETLLIMSService.java b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/IETLLIMSService.java
index 8fcb7e8576b..0c7a98577cf 100644
--- a/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/IETLLIMSService.java
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/generic/shared/IETLLIMSService.java
@@ -188,6 +188,18 @@ public interface IETLLIMSService extends IServer, ISessionProvider
             @AuthorizationGuard(guardClass = SampleTechIdPredicate.class) final TechId sampleId,
             final boolean showOnlyDirectlyConnected) throws UserFailureException;
 
+    /**
+     * Returns all data sets found for specified data set codes.
+     * 
+     * @return plain data sets without properties, samples, and experiments.
+     */
+    @Transactional(readOnly = true)
+    @RolesAllowed(RoleWithHierarchy.SPACE_ETL_SERVER)
+    public List<ExternalData> listDataSetsByCode(
+            String sessionToken,
+            @AuthorizationGuard(guardClass = DataSetCodeCollectionPredicate.class) List<String> dataSetCodes)
+            throws UserFailureException;
+    
     /**
      * Lists samples using given configuration.
      * 
diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/business/bo/ExternalDataTableTest.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/business/bo/ExternalDataTableTest.java
index d753de49e72..67d52559776 100644
--- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/business/bo/ExternalDataTableTest.java
+++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/business/bo/ExternalDataTableTest.java
@@ -54,10 +54,10 @@ import ch.systemsx.cisd.openbis.generic.shared.dto.EventPE;
 import ch.systemsx.cisd.openbis.generic.shared.dto.ExperimentPE;
 import ch.systemsx.cisd.openbis.generic.shared.dto.ExperimentTypePE;
 import ch.systemsx.cisd.openbis.generic.shared.dto.ExternalDataPE;
-import ch.systemsx.cisd.openbis.generic.shared.dto.SpacePE;
 import ch.systemsx.cisd.openbis.generic.shared.dto.PersonPE;
 import ch.systemsx.cisd.openbis.generic.shared.dto.ProjectPE;
 import ch.systemsx.cisd.openbis.generic.shared.dto.SamplePE;
+import ch.systemsx.cisd.openbis.generic.shared.dto.SpacePE;
 import ch.systemsx.cisd.openbis.generic.shared.dto.identifier.ExperimentIdentifier;
 import ch.systemsx.cisd.openbis.generic.shared.dto.identifier.ProjectIdentifier;
 
@@ -245,8 +245,8 @@ public final class ExternalDataTableTest extends AbstractBOTest
                     prepareFindFullDatasets(new ExternalDataPE[]
                         { d1, d2 }, false, false);
 
-                    one(dataStoreService2).getKnownDataSets(dss2.getSessionToken(),
-                            Arrays.asList(d2.getLocation()));
+                    one(dataStoreService2).getKnownDataSets(with(dss2.getSessionToken()),
+                            with(createDatasetDescriptionsMatcher(d2)));
                     will(returnValue(Arrays.asList()));
                 }
             });
@@ -316,9 +316,9 @@ public final class ExternalDataTableTest extends AbstractBOTest
                     prepareFindFullDatasets(new ExternalDataPE[]
                         { d1, d2 }, false, false);
 
-                    List<String> d2Locations = Arrays.asList(d2.getLocation());
-                    one(dataStoreService2).getKnownDataSets(dss2.getSessionToken(), d2Locations);
-                    will(returnValue(d2Locations));
+                    BaseMatcher<List<DatasetDescription>> dataSets = createDatasetDescriptionsMatcher(d2);
+                    one(dataStoreService2).getKnownDataSets(with(dss2.getSessionToken()), with(dataSets));
+                    will(returnValue(Arrays.asList(d2.getLocation())));
 
                     PersonPE person = EXAMPLE_SESSION.tryGetPerson();
                     one(eventDAO).persist(createDeletionEvent(d1, person, reason));
@@ -326,7 +326,7 @@ public final class ExternalDataTableTest extends AbstractBOTest
                     one(eventDAO).persist(createDeletionEvent(d2, person, reason));
                     one(externalDataDAO).delete(d2);
 
-                    one(dataStoreService2).deleteDataSets(dss2.getSessionToken(), d2Locations);
+                    one(dataStoreService2).deleteDataSets(with(dss2.getSessionToken()), with(dataSets));
                 }
             });
 
@@ -361,12 +361,12 @@ public final class ExternalDataTableTest extends AbstractBOTest
                     prepareFindFullDatasets(new ExternalDataPE[]
                         { d1PE, d2PE }, true, false);
 
-                    List<String> d2Locations = Arrays.asList(d2PE.getLocation());
-                    one(dataStoreService2).getKnownDataSets(dss2.getSessionToken(), d2Locations);
-                    will(returnValue(d2Locations));
+                    one(dataStoreService2).getKnownDataSets(with(dss2.getSessionToken()),
+                            with(createDatasetDescriptionsMatcher(d2PE)));
+                    will(returnValue(Arrays.asList(d2PE.getLocation())));
 
                     one(dataStoreService2).uploadDataSetsToCIFEX(
-                            with(equal(dss2.getSessionToken())), with(new BaseMatcher<List>()
+                            with(equal(dss2.getSessionToken())), with(new BaseMatcher<List<ExternalData>>()
                                 {
 
                                     public boolean matches(Object item)
@@ -621,7 +621,6 @@ public final class ExternalDataTableTest extends AbstractBOTest
             });
     }
 
-    @SuppressWarnings("unchecked")
     private void prepareArchiving(final IDataStoreService service, final DataStorePE store,
             final ExternalDataPE... dataSets)
     {
@@ -635,7 +634,6 @@ public final class ExternalDataTableTest extends AbstractBOTest
             });
     }
 
-    @SuppressWarnings("unchecked")
     private void prepareUnarchiving(final IDataStoreService service, final DataStorePE store,
             final ExternalDataPE... dataSets)
     {
@@ -650,24 +648,18 @@ public final class ExternalDataTableTest extends AbstractBOTest
     }
 
     @SuppressWarnings("unchecked")
-    private BaseMatcher<List> createDatasetDescriptionsMatcher(final ExternalDataPE... dataSets)
+    private BaseMatcher<List<DatasetDescription>> createDatasetDescriptionsMatcher(final ExternalDataPE... dataSets)
     {
-        return new BaseMatcher<List>()
+        return new BaseMatcher<List<DatasetDescription>>()
             {
 
                 public boolean matches(Object item)
                 {
                     List<DatasetDescription> list = (List<DatasetDescription>) item;
-                    if (list.size() != dataSets.length)
-                    {
-                        return false;
-                    }
+                    assertEquals(dataSets.length, list.size());
                     for (int i = 0; i < list.size(); i++)
                     {
-                        if (false == list.get(i).getDatasetCode().equals(dataSets[i].getCode()))
-                        {
-                            return false;
-                        }
+                        assertEquals("data set " + i, dataSets[i].getCode(), list.get(i).getDatasetCode());
                     }
                     return true;
                 }
diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/business/bo/datasetlister/DatasetListerTest.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/business/bo/datasetlister/DatasetListerTest.java
index 9332ce7a94e..b3083fa9b98 100644
--- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/business/bo/datasetlister/DatasetListerTest.java
+++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/server/business/bo/datasetlister/DatasetListerTest.java
@@ -171,7 +171,7 @@ public class DatasetListerTest extends AbstractDAOTest
     public void testListDataSetsByCode()
     {
         List<ExternalData> dataSets =
-                lister.listByDatasetCodes(Arrays.asList("20081105092158673-1", "blabla",
+                lister.listByDatasetCode(Arrays.asList("20081105092158673-1", "blabla",
                         "20081105092159188-3"));
         
         Collections.sort(dataSets, new Comparator<ExternalData>()
diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/shared/IETLLIMSService.java.expected b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/shared/IETLLIMSService.java.expected
index 8fcb7e8576b..0c7a98577cf 100644
--- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/shared/IETLLIMSService.java.expected
+++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/shared/IETLLIMSService.java.expected
@@ -188,6 +188,18 @@ public interface IETLLIMSService extends IServer, ISessionProvider
             @AuthorizationGuard(guardClass = SampleTechIdPredicate.class) final TechId sampleId,
             final boolean showOnlyDirectlyConnected) throws UserFailureException;
 
+    /**
+     * Returns all data sets found for specified data set codes.
+     * 
+     * @return plain data sets without properties, samples, and experiments.
+     */
+    @Transactional(readOnly = true)
+    @RolesAllowed(RoleWithHierarchy.SPACE_ETL_SERVER)
+    public List<ExternalData> listDataSetsByCode(
+            String sessionToken,
+            @AuthorizationGuard(guardClass = DataSetCodeCollectionPredicate.class) List<String> dataSetCodes)
+            throws UserFailureException;
+    
     /**
      * Lists samples using given configuration.
      * 
diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/builders/DataSetBuilder.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/builders/DataSetBuilder.java
index 4f0b48ad95d..ac6d7e32068 100644
--- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/builders/DataSetBuilder.java
+++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/shared/basic/dto/builders/DataSetBuilder.java
@@ -51,6 +51,12 @@ public class DataSetBuilder
         return this;
     }
     
+    public DataSetBuilder shareId(String shareId)
+    {
+        dataSet.setShareId(shareId);
+        return this;
+    }
+    
     public DataSetBuilder type(String dataSetTypeCode)
     {
         dataSet.setDataSetType(new DataSetType(dataSetTypeCode));
diff --git a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/shared/dto/builders/DatasetDescriptionBuilder.java b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/shared/dto/builders/DatasetDescriptionBuilder.java
index f4db74cad72..9f02cc9ee3b 100644
--- a/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/shared/dto/builders/DatasetDescriptionBuilder.java
+++ b/openbis/sourceTest/java/ch/systemsx/cisd/openbis/generic/shared/dto/builders/DatasetDescriptionBuilder.java
@@ -45,6 +45,12 @@ public class DatasetDescriptionBuilder
         return this;
     }
     
+    public DatasetDescriptionBuilder shareId(String shareId)
+    {
+        datasetDescription.setDataSetShareId(shareId);
+        return this;
+    }
+    
     public DatasetDescriptionBuilder sample(String sampleCode)
     {
         datasetDescription.setSampleCode(sampleCode);
diff --git a/screening/source/java/ch/systemsx/cisd/openbis/dss/etl/dataaccess/migration/MigrationStepFrom003To004.java b/screening/source/java/ch/systemsx/cisd/openbis/dss/etl/dataaccess/migration/MigrationStepFrom003To004.java
index cbf15c27fd2..0e5e35f54f6 100644
--- a/screening/source/java/ch/systemsx/cisd/openbis/dss/etl/dataaccess/migration/MigrationStepFrom003To004.java
+++ b/screening/source/java/ch/systemsx/cisd/openbis/dss/etl/dataaccess/migration/MigrationStepFrom003To004.java
@@ -266,7 +266,7 @@ public class MigrationStepFrom003To004 implements IMigrationStep
         {
             String permId = dataset.getPermId();
             File datasetDir =
-                    DatasetLocationUtil.getDatasetLocationPath(storeRootDir, permId, dbUUID);
+                    DatasetLocationUtil.getDatasetLocationPath(storeRootDir, permId, "1", dbUUID);
             DatasetFileLines featureVectorLines = tryFindFeatureVectorsFile(datasetDir);
             if (featureVectorLines != null)
             {
diff --git a/screening/source/java/ch/systemsx/cisd/openbis/dss/generic/server/AbstractImagesDownloadServlet.java b/screening/source/java/ch/systemsx/cisd/openbis/dss/generic/server/AbstractImagesDownloadServlet.java
index a43036a74fe..6e83afff6d3 100644
--- a/screening/source/java/ch/systemsx/cisd/openbis/dss/generic/server/AbstractImagesDownloadServlet.java
+++ b/screening/source/java/ch/systemsx/cisd/openbis/dss/generic/server/AbstractImagesDownloadServlet.java
@@ -29,8 +29,6 @@ import ch.systemsx.cisd.common.exceptions.EnvironmentFailureException;
 import ch.systemsx.cisd.openbis.dss.generic.server.images.ImageChannelsUtils.IDatasetDirectoryProvider;
 import ch.systemsx.cisd.openbis.dss.generic.server.images.dto.DatasetAcquiredImagesReference;
 import ch.systemsx.cisd.openbis.dss.generic.server.images.dto.ImageGenerationDescription;
-import ch.systemsx.cisd.openbis.dss.generic.shared.utils.DatasetLocationUtil;
-import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DatabaseInstance;
 
 /**
  * ABstract class for servlets which allow to download screening images in a chosen size for a
@@ -100,16 +98,13 @@ abstract class AbstractImagesDownloadServlet extends AbstractDatasetDownloadServ
         writeResponseContent(responseStream, response);
     }
 
-    private IDatasetDirectoryProvider createDatasetDirectoryProvider(HttpSession session)
+    private IDatasetDirectoryProvider createDatasetDirectoryProvider(final HttpSession session)
     {
-        final DatabaseInstance databaseInstance = getDatabaseInstance(session);
-        final File storeRootPath = getStoreRootPath();
         return new IDatasetDirectoryProvider()
             {
                 public File getDatasetRoot(String datasetCode)
                 {
-                    return DatasetLocationUtil.getDatasetLocationPathCheckingIfExists(datasetCode,
-                            databaseInstance, storeRootPath);
+                    return createDataSetRootDirectory(datasetCode, session);
                 }
             };
     }
diff --git a/screening/source/java/ch/systemsx/cisd/openbis/dss/screening/server/DssServiceRpcScreening.java b/screening/source/java/ch/systemsx/cisd/openbis/dss/screening/server/DssServiceRpcScreening.java
index cdb0d996a08..dae229d8667 100644
--- a/screening/source/java/ch/systemsx/cisd/openbis/dss/screening/server/DssServiceRpcScreening.java
+++ b/screening/source/java/ch/systemsx/cisd/openbis/dss/screening/server/DssServiceRpcScreening.java
@@ -640,7 +640,7 @@ public class DssServiceRpcScreening extends AbstractDssServiceRpc<IDssServiceRpc
     private IImagingDatasetLoader createImageLoader(IDatasetIdentifier dataSetIdentifier)
     {
         String datasetCode = dataSetIdentifier.getDatasetCode();
-        File rootDir = getRootDirectoryForDataSet(datasetCode);
+        File rootDir = getRootDirectory(datasetCode);
         IImagingDatasetLoader imageAccessor = createImageLoader(datasetCode, rootDir);
         return imageAccessor;
     }
@@ -965,7 +965,7 @@ public class DssServiceRpcScreening extends AbstractDssServiceRpc<IDssServiceRpc
 
     private IImagingDatasetLoader createImageLoader(String datasetCode)
     {
-        File datasetRoot = getRootDirectoryForDataSet(datasetCode);
+        File datasetRoot = getRootDirectory(datasetCode);
         return createImageLoader(datasetCode, datasetRoot);
     }
 
-- 
GitLab