From 65a7c4347aa8e936f4fe22f682438a49ba62f174 Mon Sep 17 00:00:00 2001 From: felmer <felmer> Date: Mon, 14 Jan 2013 14:48:06 +0000 Subject: [PATCH] SP-439 BIS-255: Add method cloneFor(ISessionTokenProvider sessionTokenProvider) to IHierarchicalContentProvider in order to allow creating a content provider for a user different then etlserver. This should help to solve a bug that file from a remote DSS are stored in session workspace of etlserver instead of the user. SVN: 28082 --- .../generic/server/AbstractDssServiceRpc.java | 11 ++++--- .../generic/server/ApplicationContext.java | 11 +++++-- .../server/DatasetDownloadServlet.java | 7 ++-- .../server/DatasetImageOverviewServlet.java | 7 ++-- .../server/api/v1/DssServiceRpcGeneric.java | 4 +-- .../server/ftp/FtpPathResolverContext.java | 4 ++- .../TemplateBasedDataSetResourceResolver.java | 30 +++++++++-------- .../shared/DataSetProcessingContext.java | 11 ++++++- .../shared/HierarchicalContentProvider.java | 32 +++++++++++++------ .../shared/IHierarchicalContentProvider.java | 7 +++- .../generic/server/UploadingCommandTest.java | 8 +++++ ...plateBasedDataSetResourceResolverTest.java | 7 ++++ .../standard/TSVViewReportingPluginTest.java | 8 +++++ .../tasks/PluginTaskParametersTest.java | 8 +++++ .../server/AbstractImagesDownloadServlet.java | 6 ++-- .../server/DssServiceRpcScreening.java | 32 +++++++++---------- 16 files changed, 136 insertions(+), 57 deletions(-) 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 316500c96f8..7200100dd06 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 @@ -30,6 +30,7 @@ import ch.systemsx.cisd.openbis.dss.generic.shared.ServiceProvider; import ch.systemsx.cisd.openbis.dss.generic.shared.api.v1.DataStoreApiUrlUtilities; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.DatabaseInstance; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ExternalData; +import ch.systemsx.cisd.openbis.generic.shared.dto.OpenBISSessionHolder; /** * Abstract superclass of DssServiceRpc implementations. @@ -84,13 +85,15 @@ public abstract class AbstractDssServiceRpc<T> extends AbstractServiceWithLogger this.contentProvider = contentProvider; } - protected IHierarchicalContentProvider getHierarchicalContentProvider() + protected IHierarchicalContentProvider getHierarchicalContentProvider(String sessionToken) { if (contentProvider == null) { contentProvider = ServiceProvider.getHierarchicalContentProvider(); } - return contentProvider; + OpenBISSessionHolder sessionTokenHolder = new OpenBISSessionHolder(); + sessionTokenHolder.setSessionToken(sessionToken); + return contentProvider.cloneFor(sessionTokenHolder); } protected IShareIdManager getShareIdManager() @@ -128,9 +131,9 @@ public abstract class AbstractDssServiceRpc<T> extends AbstractServiceWithLogger return homeDatabaseInstance; } - protected IHierarchicalContent getHierarchicalContent(String dataSetCode) + protected IHierarchicalContent getHierarchicalContent(String sessionToken, String dataSetCode) { - return getHierarchicalContentProvider().asContent(dataSetCode); + return getHierarchicalContentProvider(sessionToken).asContent(dataSetCode); } protected ExternalData tryGetDataSet(String sessionToken, String dataSetCode) diff --git a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/ApplicationContext.java b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/ApplicationContext.java index 2ab1363a7d7..c874a4e70b7 100644 --- a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/ApplicationContext.java +++ b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/ApplicationContext.java @@ -19,6 +19,7 @@ package ch.systemsx.cisd.openbis.dss.generic.server; import ch.systemsx.cisd.openbis.dss.generic.shared.IEncapsulatedOpenBISService; import ch.systemsx.cisd.openbis.dss.generic.shared.IHierarchicalContentProvider; import ch.systemsx.cisd.openbis.dss.generic.shared.IShareIdManager; +import ch.systemsx.cisd.openbis.generic.shared.dto.OpenBISSessionHolder; /** * Application context. It contains the object accessing the openBIS for retrieving the data set, @@ -61,9 +62,15 @@ class ApplicationContext return configParameters; } - public IHierarchicalContentProvider getHierarchicalContentProvider() + public IHierarchicalContentProvider getHierarchicalContentProvider(String sessionTokenOrNull) { - return hierarchicalContentProvider; + if (sessionTokenOrNull == null) + { + return hierarchicalContentProvider; + } + OpenBISSessionHolder sessionHolder = new OpenBISSessionHolder(); + sessionHolder.setSessionToken(sessionTokenOrNull); + return hierarchicalContentProvider.cloneFor(sessionHolder); } } diff --git a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/DatasetDownloadServlet.java b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/DatasetDownloadServlet.java index f300d402a45..1067e552492 100644 --- a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/DatasetDownloadServlet.java +++ b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/DatasetDownloadServlet.java @@ -40,6 +40,7 @@ import ch.systemsx.cisd.common.exceptions.UserFailureException; import ch.systemsx.cisd.openbis.common.io.hierarchical_content.HierarchicalContentUtils; import ch.systemsx.cisd.openbis.common.io.hierarchical_content.api.IHierarchicalContent; import ch.systemsx.cisd.openbis.common.io.hierarchical_content.api.IHierarchicalContentNode; +import ch.systemsx.cisd.openbis.dss.generic.shared.IHierarchicalContentProvider; import ch.systemsx.cisd.openbis.dss.generic.shared.dto.Size; import ch.systemsx.cisd.openbis.generic.shared.util.HttpRequestUtils; @@ -223,8 +224,10 @@ public class DatasetDownloadServlet extends AbstractDatasetDownloadServlet IHierarchicalContent rootContent = null; try { - rootContent = - applicationContext.getHierarchicalContentProvider().asContent(dataSetCode); + String sessionTokenOrNull = requestParams.tryGetSessionId(); + IHierarchicalContentProvider contentProvider = + applicationContext.getHierarchicalContentProvider(sessionTokenOrNull); + rootContent = contentProvider.asContent(dataSetCode); } catch (IllegalArgumentException ex) { throw new UserFailureException(ex.getMessage()); diff --git a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/DatasetImageOverviewServlet.java b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/DatasetImageOverviewServlet.java index f0d32b0cd8e..3931cd85bab 100644 --- a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/DatasetImageOverviewServlet.java +++ b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/DatasetImageOverviewServlet.java @@ -112,7 +112,8 @@ public class DatasetImageOverviewServlet extends AbstractDatasetDownloadServlet ensureDatasetAccessible(datasetCode, session, sessionId); ResponseContentStream responseStream = - createImageResponse(session, datasetCode, datasetTypeCode, resolution); + createImageResponse(session, sessionId, datasetCode, datasetTypeCode, + resolution); if (responseStream != null && operationLog.isDebugEnabled()) { @@ -128,11 +129,11 @@ public class DatasetImageOverviewServlet extends AbstractDatasetDownloadServlet } } - private ResponseContentStream createImageResponse(HttpSession session, String dataSetCode, + private ResponseContentStream createImageResponse(HttpSession session, String sessionToken, String dataSetCode, String dataSetTypeCode, ImageResolutionKind resolution) { IHierarchicalContent content = - applicationContext.getHierarchicalContentProvider().asContent(dataSetCode); + applicationContext.getHierarchicalContentProvider(sessionToken).asContent(dataSetCode); IDatasetImageOverviewPlugin plugin = configuration.getDatasetImageOverviewPlugin(dataSetTypeCode); return plugin.createImageOverview(dataSetCode, dataSetTypeCode, content, resolution); diff --git a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/api/v1/DssServiceRpcGeneric.java b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/api/v1/DssServiceRpcGeneric.java index 8df26f4ae41..9f00a3d8fe7 100644 --- a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/api/v1/DssServiceRpcGeneric.java +++ b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/api/v1/DssServiceRpcGeneric.java @@ -135,7 +135,7 @@ public class DssServiceRpcGeneric extends AbstractDssServiceRpc<IDssServiceRpcGe IHierarchicalContent content = null; try { - content = getHierarchicalContent(dataSetCode); + content = getHierarchicalContent(sessionToken, dataSetCode); IHierarchicalContentNode startPathNode = getContentNode(content, startPath); ArrayList<FileInfoDssDTO> list = new ArrayList<FileInfoDssDTO>(); if (startPathNode.isDirectory()) @@ -173,7 +173,7 @@ public class DssServiceRpcGeneric extends AbstractDssServiceRpc<IDssServiceRpcGe IHierarchicalContent content = null; try { - content = getHierarchicalContent(dataSetCode); + content = getHierarchicalContent(sessionToken, dataSetCode); IHierarchicalContentNode contentNode = getContentNode(content, path); return HierarchicalContentUtils.getInputStreamAutoClosingContent(contentNode, content); } catch (RuntimeException ex) diff --git a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/ftp/FtpPathResolverContext.java b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/ftp/FtpPathResolverContext.java index 965589004ac..fc1a5c18913 100644 --- a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/ftp/FtpPathResolverContext.java +++ b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/ftp/FtpPathResolverContext.java @@ -22,6 +22,7 @@ import java.util.Collections; import java.util.EnumSet; import java.util.List; +import ch.systemsx.cisd.common.server.ISessionTokenProvider; import ch.systemsx.cisd.openbis.generic.shared.IETLLIMSService; import ch.systemsx.cisd.openbis.generic.shared.api.v1.IGeneralInformationService; import ch.systemsx.cisd.openbis.generic.shared.api.v1.dto.DataSet; @@ -37,7 +38,7 @@ import ch.systemsx.cisd.openbis.generic.shared.dto.identifier.ExperimentIdentifi * * @author Kaloyan Enimanev */ -public class FtpPathResolverContext +public class FtpPathResolverContext implements ISessionTokenProvider { private final String sessionToken; @@ -61,6 +62,7 @@ public class FtpPathResolverContext this.cache = cache; } + @Override public String getSessionToken() { return sessionToken; diff --git a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/ftp/resolver/TemplateBasedDataSetResourceResolver.java b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/ftp/resolver/TemplateBasedDataSetResourceResolver.java index 5aed27c597f..25af80ade76 100644 --- a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/ftp/resolver/TemplateBasedDataSetResourceResolver.java +++ b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/ftp/resolver/TemplateBasedDataSetResourceResolver.java @@ -34,6 +34,7 @@ import ch.rinn.restrictions.Private; import ch.systemsx.cisd.common.exceptions.ConfigurationFailureException; import ch.systemsx.cisd.common.logging.LogCategory; import ch.systemsx.cisd.common.logging.LogFactory; +import ch.systemsx.cisd.common.server.ISessionTokenProvider; import ch.systemsx.cisd.common.string.Template; import ch.systemsx.cisd.openbis.common.io.hierarchical_content.IHierarchicalContentNodeFilter; import ch.systemsx.cisd.openbis.common.io.hierarchical_content.api.IHierarchicalContent; @@ -113,7 +114,7 @@ public class TemplateBasedDataSetResourceResolver implements IFtpPathResolver, addNodesOfType(PARENT_PREFIX, result, dataSetWithMetaData.getParentCodes()); addNodesOfType(CHILD_PREFIX, result, dataSetWithMetaData.getChildrenCodes()); } - FtpFileEvaluationContext evalContext = createFtpFileEvaluationContext(); + FtpFileEvaluationContext evalContext = createFtpFileEvaluationContext(resolverContext); try { IHierarchicalContent hierarchicalContent = @@ -246,7 +247,7 @@ public class TemplateBasedDataSetResourceResolver implements IFtpPathResolver, service.listDataSetsByExperimentID(sessionToken, new TechId(experiment)); if (fileNamePresent) { - FtpFileEvaluationContext evalContext = evaluateDataSetPaths(dataSets); + FtpFileEvaluationContext evalContext = evaluateDataSetPaths(resolverContext, dataSets); try { @@ -425,18 +426,18 @@ public class TemplateBasedDataSetResourceResolver implements IFtpPathResolver, List<ExternalData> dataSets = service.listDataSetsByExperimentID(sessionToken, new TechId(experiment)); - FtpFileEvaluationContext evalContext = evaluateDataSetPaths(dataSets); + FtpFileEvaluationContext evalContext = evaluateDataSetPaths(context, dataSets); try { - return createFtpFilesFromEvaluationResult(parentPath, evalContext); + return createFtpFilesFromEvaluationResult(context, parentPath, evalContext); } finally { evalContext.close(); } } - private List<FtpFile> createFtpFilesFromEvaluationResult(final String parentPath, - FtpFileEvaluationContext evalResult) + private List<FtpFile> createFtpFilesFromEvaluationResult(ISessionTokenProvider sessionTokenProvider, + final String parentPath, FtpFileEvaluationContext evalResult) { ArrayList<FtpFile> result = new ArrayList<FtpFile>(); for (EvaluatedElement evalElement : evalResult.getEvalElements()) @@ -447,7 +448,7 @@ public class TemplateBasedDataSetResourceResolver implements IFtpPathResolver, String childPath = parentPath + FtpConstants.FILE_SEPARATOR + evalElement.evaluatedTemplate; String dataSetCode = evalElement.dataSet.getCode(); - IHierarchicalContentProvider getContentProvider = getContentProvider(); + IHierarchicalContentProvider getContentProvider = getContentProvider(sessionTokenProvider); FtpFile childFtpFile = FtpFileFactory.createFtpFile(dataSetCode, childPath, @@ -460,9 +461,10 @@ public class TemplateBasedDataSetResourceResolver implements IFtpPathResolver, return result; } - private FtpFileEvaluationContext evaluateDataSetPaths(List<ExternalData> dataSets) + private FtpFileEvaluationContext evaluateDataSetPaths(ISessionTokenProvider sessionTokenProvider, + List<ExternalData> dataSets) { - FtpFileEvaluationContext evalContext = createFtpFileEvaluationContext(); + FtpFileEvaluationContext evalContext = createFtpFileEvaluationContext(sessionTokenProvider); for (int disambiguationIdx = 0; disambiguationIdx < dataSets.size(); disambiguationIdx++) { @@ -664,18 +666,20 @@ public class TemplateBasedDataSetResourceResolver implements IFtpPathResolver, return getDataSetTypeConfig(dataSet).fileListSubPath; } - private FtpFileEvaluationContext createFtpFileEvaluationContext() + private FtpFileEvaluationContext createFtpFileEvaluationContext( + ISessionTokenProvider sessionTokenProvider) { - return new FtpFileEvaluationContext(getContentProvider()); + return new FtpFileEvaluationContext(getContentProvider(sessionTokenProvider)); } - private IHierarchicalContentProvider getContentProvider() + private IHierarchicalContentProvider getContentProvider( + ISessionTokenProvider sessionTokenProvider) { if (contentProvider == null) { contentProvider = ServiceProvider.getHierarchicalContentProvider(); } - return contentProvider; + return contentProvider.cloneFor(sessionTokenProvider); } } diff --git a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/DataSetProcessingContext.java b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/DataSetProcessingContext.java index b0a4a9c337a..07a8c834ecd 100644 --- a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/DataSetProcessingContext.java +++ b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/DataSetProcessingContext.java @@ -24,6 +24,7 @@ import org.apache.log4j.Logger; import ch.systemsx.cisd.common.logging.LogCategory; import ch.systemsx.cisd.common.logging.LogFactory; import ch.systemsx.cisd.common.mail.IMailClient; +import ch.systemsx.cisd.common.server.ISessionTokenProvider; import ch.systemsx.cisd.openbis.common.io.hierarchical_content.api.IHierarchicalContent; import ch.systemsx.cisd.openbis.dss.generic.server.plugins.tasks.IProcessingPluginTask; import ch.systemsx.cisd.openbis.dss.generic.shared.api.internal.ISessionWorkspaceProvider; @@ -105,7 +106,7 @@ public class DataSetProcessingContext * Creates an instance for specified service, directory provider, workspace provider, parameter * bindings, e-mail client, and optional user e-mail address and sessionToken. */ - public DataSetProcessingContext(IEncapsulatedOpenBISService service, + private DataSetProcessingContext(IEncapsulatedOpenBISService service, IHierarchicalContentProvider contentProvider, IDataSetDirectoryProvider directoryProvider, ISessionWorkspaceProvider sessionWorkspaceProviderOrNull, @@ -195,6 +196,14 @@ public class DataSetProcessingContext { return hierarchicalContentProvider.asContent(datasetLocation); } + + @Override + public IHierarchicalContentProvider cloneFor( + ISessionTokenProvider sessionTokenProvider) + { + return hierarchicalContentProvider.cloneFor(sessionTokenProvider); + } + }; } diff --git a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/HierarchicalContentProvider.java b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/HierarchicalContentProvider.java index 47bd1f3a9e2..62a62a24397 100644 --- a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/HierarchicalContentProvider.java +++ b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/HierarchicalContentProvider.java @@ -19,7 +19,6 @@ package ch.systemsx.cisd.openbis.dss.generic.shared; import java.io.File; import java.util.ArrayList; import java.util.List; -import java.util.Properties; import org.apache.log4j.Logger; @@ -99,6 +98,18 @@ public class HierarchicalContentProvider implements IHierarchicalContentProvider IDssServiceRpcGenericFactory serviceFactory, IContentCache contentCache, ISessionTokenProvider sessionTokenProvider, String dataStoreCode, ExposablePropertyPlaceholderConfigurer infoProvider) + { + this(openbisService, directoryProvider, hierarchicalContentFactory, serviceFactory, + contentCache, sessionTokenProvider, dataStoreCode, infoProvider != null + && "true".equalsIgnoreCase(infoProvider.getResolvedProps().getProperty( + "trust-all-certificates"))); + } + + private HierarchicalContentProvider(IEncapsulatedOpenBISService openbisService, + IDataSetDirectoryProvider directoryProvider, + IHierarchicalContentFactory hierarchicalContentFactory, + IDssServiceRpcGenericFactory serviceFactory, IContentCache contentCache, + ISessionTokenProvider sessionTokenProvider, String dataStoreCode, boolean trustAllCertificates) { this.openbisService = openbisService; this.directoryProvider = directoryProvider; @@ -107,15 +118,16 @@ public class HierarchicalContentProvider implements IHierarchicalContentProvider this.cache = contentCache; this.sessionTokenProvider = sessionTokenProvider; this.dataStoreCode = dataStoreCode; - if (infoProvider != null) - { - Properties properties = infoProvider.getResolvedProps(); - String trust = properties.getProperty("trust-all-certificates"); - trustAllCertificates = (trust != null && trust.equalsIgnoreCase("true")); - } else - { - trustAllCertificates = false; - } + this.trustAllCertificates = trustAllCertificates; + + } + + @Override + public IHierarchicalContentProvider cloneFor(ISessionTokenProvider anotherSessionTokenProvider) + { + return new HierarchicalContentProvider(openbisService, directoryProvider, + hierarchicalContentFactory, serviceFactory, cache, anotherSessionTokenProvider, + dataStoreCode, trustAllCertificates); } @Override diff --git a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/IHierarchicalContentProvider.java b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/IHierarchicalContentProvider.java index 2a6d2fe9877..441f50e04d3 100644 --- a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/IHierarchicalContentProvider.java +++ b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/IHierarchicalContentProvider.java @@ -18,6 +18,7 @@ package ch.systemsx.cisd.openbis.dss.generic.shared; import java.io.File; +import ch.systemsx.cisd.common.server.ISessionTokenProvider; import ch.systemsx.cisd.openbis.common.io.hierarchical_content.api.IHierarchicalContent; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ExternalData; import ch.systemsx.cisd.openbis.generic.shared.basic.dto.IDatasetLocation; @@ -69,5 +70,9 @@ public interface IHierarchicalContentProvider */ @Deprecated IHierarchicalContent asContent(File datasetDirectory); - + + /** + * Creates a clone of this provider for the specified session token provider. + */ + IHierarchicalContentProvider cloneFor(ISessionTokenProvider sessionTokenProvider); } 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 bee8a16dfb7..592f0bc147a 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 @@ -51,6 +51,7 @@ import ch.systemsx.cisd.common.exceptions.AuthorizationFailureException; import ch.systemsx.cisd.common.filesystem.FileUtilities; import ch.systemsx.cisd.common.logging.BufferedAppender; import ch.systemsx.cisd.common.mail.MailClientParameters; +import ch.systemsx.cisd.common.server.ISessionTokenProvider; import ch.systemsx.cisd.openbis.common.io.hierarchical_content.DefaultFileBasedHierarchicalContentFactory; import ch.systemsx.cisd.openbis.common.io.hierarchical_content.api.IHierarchicalContent; import ch.systemsx.cisd.openbis.dss.generic.shared.IDataSetDirectoryProvider; @@ -126,6 +127,13 @@ public class UploadingCommandTest extends AssertJUnit { return getContent(LOCATION_PREFIX + dataSetCode); } + + @Override + public IHierarchicalContentProvider cloneFor( + ISessionTokenProvider sessionTokenProvider) + { + return null; + } }; private static final class MockDataSetDirectoryProvider implements IDataSetDirectoryProvider diff --git a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/dss/generic/server/ftp/resolver/TemplateBasedDataSetResourceResolverTest.java b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/dss/generic/server/ftp/resolver/TemplateBasedDataSetResourceResolverTest.java index 57953fab7c6..3e071d35405 100644 --- a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/dss/generic/server/ftp/resolver/TemplateBasedDataSetResourceResolverTest.java +++ b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/dss/generic/server/ftp/resolver/TemplateBasedDataSetResourceResolverTest.java @@ -40,6 +40,7 @@ import ch.systemsx.cisd.base.tests.AbstractFileSystemTestCase; import ch.systemsx.cisd.common.action.IDelegatedAction; import ch.systemsx.cisd.common.exceptions.ConfigurationFailureException; import ch.systemsx.cisd.common.filesystem.FileUtilities; +import ch.systemsx.cisd.common.server.ISessionTokenProvider; import ch.systemsx.cisd.common.test.TrackingMockery; import ch.systemsx.cisd.common.utilities.ITimeProvider; import ch.systemsx.cisd.openbis.common.io.hierarchical_content.DefaultFileBasedHierarchicalContentFactory; @@ -106,6 +107,12 @@ public class TemplateBasedDataSetResourceResolverTest extends AbstractFileSystem return new DefaultFileBasedHierarchicalContentFactory().asHierarchicalContent( datasetDirectory, IDelegatedAction.DO_NOTHING); } + + @Override + public IHierarchicalContentProvider cloneFor(ISessionTokenProvider sessionTokenProvider) + { + return null; + } } private static final Date REGISTRATION_DATE = new Date(42); diff --git a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/dss/generic/server/plugins/standard/TSVViewReportingPluginTest.java b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/dss/generic/server/plugins/standard/TSVViewReportingPluginTest.java index fac4d390249..58edb1adad9 100644 --- a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/dss/generic/server/plugins/standard/TSVViewReportingPluginTest.java +++ b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/dss/generic/server/plugins/standard/TSVViewReportingPluginTest.java @@ -31,6 +31,7 @@ import ch.systemsx.cisd.base.tests.AbstractFileSystemTestCase; import ch.systemsx.cisd.common.action.IDelegatedAction; import ch.systemsx.cisd.common.exceptions.UserFailureException; import ch.systemsx.cisd.common.filesystem.FileUtilities; +import ch.systemsx.cisd.common.server.ISessionTokenProvider; import ch.systemsx.cisd.openbis.common.io.hierarchical_content.DefaultFileBasedHierarchicalContentFactory; import ch.systemsx.cisd.openbis.common.io.hierarchical_content.api.IHierarchicalContent; import ch.systemsx.cisd.openbis.dss.generic.shared.DataSetProcessingContext; @@ -114,6 +115,13 @@ public class TSVViewReportingPluginTest extends AbstractFileSystemTestCase { return getContent("dataset-" + dataSetCode); } + + @Override + public IHierarchicalContentProvider cloneFor( + ISessionTokenProvider sessionTokenProvider) + { + return null; + } }; } diff --git a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/dss/generic/server/plugins/tasks/PluginTaskParametersTest.java b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/dss/generic/server/plugins/tasks/PluginTaskParametersTest.java index 68f458b79fd..166f66cf809 100644 --- a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/dss/generic/server/plugins/tasks/PluginTaskParametersTest.java +++ b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/dss/generic/server/plugins/tasks/PluginTaskParametersTest.java @@ -39,6 +39,7 @@ import ch.systemsx.cisd.base.tests.AbstractFileSystemTestCase; import ch.systemsx.cisd.common.action.IDelegatedAction; import ch.systemsx.cisd.common.exceptions.ConfigurationFailureException; import ch.systemsx.cisd.common.properties.PropertyParametersUtil.SectionProperties; +import ch.systemsx.cisd.common.server.ISessionTokenProvider; import ch.systemsx.cisd.common.test.RecordingMatcher; import ch.systemsx.cisd.openbis.common.io.hierarchical_content.DefaultFileBasedHierarchicalContentFactory; import ch.systemsx.cisd.openbis.common.io.hierarchical_content.api.IHierarchicalContent; @@ -105,6 +106,13 @@ public class PluginTaskParametersTest extends AbstractFileSystemTestCase { return null; } + + @Override + public IHierarchicalContentProvider cloneFor( + ISessionTokenProvider sessionTokenProvider) + { + return null; + } }; final BeanFactory beanFactory = context.mock(BeanFactory.class); ServiceProviderTestWrapper.setApplicationContext(beanFactory); 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 120eb0d8701..b5915c54bbe 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 @@ -81,14 +81,16 @@ abstract class AbstractImagesDownloadServlet extends AbstractDatasetDownloadServ protected void deliverFile(HttpServletResponse response, ImageGenerationDescription params, HttpSession session) throws IOException { - ensureDatasetsAccessible(params, session, params.getSessionId()); + String sessionId = params.getSessionId(); + ensureDatasetsAccessible(params, session, sessionId); long start = System.currentTimeMillis(); ResponseContentStream responseStream; try { responseStream = - createImageResponse(params, applicationContext.getHierarchicalContentProvider()); + createImageResponse(params, + applicationContext.getHierarchicalContentProvider(sessionId)); } catch (HighLevelException e) { operationLog.warn(e.getMessage()); 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 b925397281e..9aa9509ff89 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 @@ -248,7 +248,7 @@ public class DssServiceRpcScreening extends AbstractDssServiceRpc<IDssServiceRpc for (IImageDatasetIdentifier dataset : imageDatasets) { final IHierarchicalContent content = - getHierarchicalContent(dataset.getDatasetCode()); + getHierarchicalContent(sessionToken, dataset.getDatasetCode()); try { result.add(extractImageMetadata(dataset, content)); @@ -828,7 +828,7 @@ public class DssServiceRpcScreening extends AbstractDssServiceRpc<IDssServiceRpc public InputStream loadImages(String sessionToken, IDatasetIdentifier dataSetIdentifier, List<WellPosition> wellPositions, String channel, ImageSize thumbnailSizeOrNull) { - final IImagingDatasetLoader imageAccessor = createImageLoader(dataSetIdentifier); + final IImagingDatasetLoader imageAccessor = createImageLoader(sessionToken, dataSetIdentifier); final List<PlateImageReference> imageReferences = createPlateImageReferences(imageAccessor, dataSetIdentifier, wellPositions, channel); @@ -870,7 +870,7 @@ public class DssServiceRpcScreening extends AbstractDssServiceRpc<IDssServiceRpc public InputStream loadImages(String sessionToken, IDatasetIdentifier dataSetIdentifier, String channel, ImageSize thumbnailSizeOrNull) { - final IImagingDatasetLoader imageAccessor = createImageLoader(dataSetIdentifier); + final IImagingDatasetLoader imageAccessor = createImageLoader(sessionToken, dataSetIdentifier); List<MicroscopyImageReference> imageReferences = listImageReferences(dataSetIdentifier, channel, imageAccessor); final Size sizeOrNull = tryAsSize(thumbnailSizeOrNull); @@ -903,7 +903,7 @@ public class DssServiceRpcScreening extends AbstractDssServiceRpc<IDssServiceRpc public InputStream loadThumbnailImages(String sessionToken, IDatasetIdentifier dataSetIdentifier, List<String> channels) { - final IImagingDatasetLoader imageAccessor = createImageLoader(dataSetIdentifier); + final IImagingDatasetLoader imageAccessor = createImageLoader(sessionToken, dataSetIdentifier); assert imageAccessor != null : "imageAccessor not found for: " + dataSetIdentifier; final List<MicroscopyImageReference> imageReferences = listImageReferences(dataSetIdentifier, channels, imageAccessor); @@ -936,7 +936,7 @@ public class DssServiceRpcScreening extends AbstractDssServiceRpc<IDssServiceRpc public List<MicroscopyImageReference> listImageReferences(String sessionToken, IDatasetIdentifier dataSetIdentifier, String channel) { - IImagingDatasetLoader imageAccessor = createImageLoader(dataSetIdentifier); + IImagingDatasetLoader imageAccessor = createImageLoader(sessionToken, dataSetIdentifier); return listImageReferences(dataSetIdentifier, channel, imageAccessor); } @@ -944,7 +944,7 @@ public class DssServiceRpcScreening extends AbstractDssServiceRpc<IDssServiceRpc public List<MicroscopyImageReference> listImageReferences(String sessionToken, IDatasetIdentifier dataSetIdentifier, List<String> channels) { - IImagingDatasetLoader imageAccessor = createImageLoader(dataSetIdentifier); + IImagingDatasetLoader imageAccessor = createImageLoader(sessionToken, dataSetIdentifier); return listImageReferences(dataSetIdentifier, channels, imageAccessor); } @@ -982,7 +982,7 @@ public class DssServiceRpcScreening extends AbstractDssServiceRpc<IDssServiceRpc public List<PlateImageReference> listPlateImageReferences(String sessionToken, IDatasetIdentifier dataSetIdentifier, List<WellPosition> wellPositions, String channel) { - IImagingDatasetLoader imageAccessor = createImageLoader(dataSetIdentifier); + IImagingDatasetLoader imageAccessor = createImageLoader(sessionToken, dataSetIdentifier); return createPlateImageReferences(imageAccessor, dataSetIdentifier, wellPositions, channel); } @@ -991,7 +991,7 @@ public class DssServiceRpcScreening extends AbstractDssServiceRpc<IDssServiceRpc IDatasetIdentifier dataSetIdentifier, List<WellPosition> wellPositions, List<String> channels) { - IImagingDatasetLoader imageAccessor = createImageLoader(dataSetIdentifier); + IImagingDatasetLoader imageAccessor = createImageLoader(sessionToken, dataSetIdentifier); return createPlateImageReferences(imageAccessor, dataSetIdentifier, wellPositions, channels); } @@ -1107,10 +1107,10 @@ public class DssServiceRpcScreening extends AbstractDssServiceRpc<IDssServiceRpc return transformations; } - private IImagingDatasetLoader createImageLoader(IDatasetIdentifier dataSetIdentifier) + private IImagingDatasetLoader createImageLoader(String sessionToken, IDatasetIdentifier dataSetIdentifier) { final String datasetCode = dataSetIdentifier.getDatasetCode(); - return createImageLoader(datasetCode); + return createImageLoader(sessionToken, datasetCode); } @Override @@ -1442,7 +1442,7 @@ public class DssServiceRpcScreening extends AbstractDssServiceRpc<IDssServiceRpc if (imageDatasetsMap.containsKey(imageReference.getDatasetCode()) == false) { IImagingDatasetLoader imageAccessor = - tryCreateImageLoader(imageReference.getDatasetCode()); + tryCreateImageLoader(sessionToken, imageReference.getDatasetCode()); if (imageAccessor == null) // Check whether this is a feature vector data set { final ExternalData imageDataset = @@ -1450,7 +1450,7 @@ public class DssServiceRpcScreening extends AbstractDssServiceRpc<IDssServiceRpc if (imageDataset != null) { imageAccessor = - createImageLoader(imageDataset.getCode()); + createImageLoader(sessionToken, imageDataset.getCode()); } else { throw UserFailureException.fromTemplate( @@ -1536,15 +1536,15 @@ public class DssServiceRpcScreening extends AbstractDssServiceRpc<IDssServiceRpc return new Size(thumbnailSizeOrNull.getWidth(), thumbnailSizeOrNull.getHeight()); } - private IImagingDatasetLoader tryCreateImageLoader(String datasetCode) + private IImagingDatasetLoader tryCreateImageLoader(String sessionToken, String datasetCode) { - final IHierarchicalContent content = getHierarchicalContent(datasetCode); + final IHierarchicalContent content = getHierarchicalContent(sessionToken, datasetCode); return tryCreateImageLoader(datasetCode, content, false); } - private IImagingDatasetLoader createImageLoader(String datasetCode) + private IImagingDatasetLoader createImageLoader(String sessionToken, String datasetCode) { - final IHierarchicalContent content = getHierarchicalContent(datasetCode); + final IHierarchicalContent content = getHierarchicalContent(sessionToken, datasetCode); return createImageLoader(datasetCode, content); } -- GitLab