Skip to content
Snippets Groups Projects
Commit f02adfc9 authored by felmer's avatar felmer
Browse files

SP-387, BIS-255: refactoring: Using ISessionTokenProvider instead of

SVN: 28037
parent 913dc936
No related branches found
No related tags found
No related merge requests found
......@@ -27,8 +27,10 @@ import org.apache.log4j.Logger;
import ch.rinn.restrictions.Private;
import ch.systemsx.cisd.common.action.IDelegatedAction;
import ch.systemsx.cisd.common.filesystem.FileOperations;
import ch.systemsx.cisd.common.filesystem.IFileOperations;
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.spring.ExposablePropertyPlaceholderConfigurer;
import ch.systemsx.cisd.common.spring.HttpInvokerUtils;
import ch.systemsx.cisd.common.ssl.SslCertificateHelper;
......@@ -43,7 +45,6 @@ import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ExternalData;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.ExternalDataLocationNode;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.IDatasetLocation;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.IDatasetLocationNode;
import ch.systemsx.cisd.openbis.generic.shared.dto.OpenBISSessionHolder;
/**
* The default implementation of {@link IHierarchicalContentProvider}.
......@@ -63,7 +64,7 @@ public class HierarchicalContentProvider implements IHierarchicalContentProvider
private IHierarchicalContentFactory hierarchicalContentFactory;
private OpenBISSessionHolder session;
private ISessionTokenProvider sessionTokenProvider;
private String dataStoreCode;
......@@ -73,21 +74,22 @@ public class HierarchicalContentProvider implements IHierarchicalContentProvider
public HierarchicalContentProvider(IEncapsulatedOpenBISService openbisService,
IShareIdManager shareIdManager, IConfigProvider configProvider,
OpenBISSessionHolder session,
ISessionTokenProvider sessionTokenProvider,
ExposablePropertyPlaceholderConfigurer infoProvider)
{
this(openbisService, new DataSetDirectoryProvider(configProvider.getStoreRoot(),
shareIdManager), null, session, configProvider.getDataStoreCode(),
shareIdManager), null, sessionTokenProvider, configProvider.getDataStoreCode(),
infoProvider);
}
public HierarchicalContentProvider(IEncapsulatedOpenBISService openbisService,
IShareIdManager shareIdManager, IConfigProvider configProvider,
IHierarchicalContentFactory hierarchicalContentFactory, OpenBISSessionHolder session,
IHierarchicalContentFactory hierarchicalContentFactory,
ISessionTokenProvider sessionTokenProvider,
ExposablePropertyPlaceholderConfigurer infoProvider)
{
this(openbisService, new DataSetDirectoryProvider(configProvider.getStoreRoot(),
shareIdManager), hierarchicalContentFactory, session, configProvider
shareIdManager), hierarchicalContentFactory, sessionTokenProvider, configProvider
.getDataStoreCode(), infoProvider);
}
......@@ -95,14 +97,14 @@ public class HierarchicalContentProvider implements IHierarchicalContentProvider
public HierarchicalContentProvider(IEncapsulatedOpenBISService openbisService,
IDataSetDirectoryProvider directoryProvider,
IHierarchicalContentFactory hierarchicalContentFactory,
OpenBISSessionHolder session,
ISessionTokenProvider session,
String dataStoreCode,
ExposablePropertyPlaceholderConfigurer infoProvider)
{
this.openbisService = openbisService;
this.directoryProvider = directoryProvider;
this.hierarchicalContentFactory = hierarchicalContentFactory;
this.session = session;
this.sessionTokenProvider = session;
this.dataStoreCode = dataStoreCode;
this.trustAllCertificates = false;
if (infoProvider != null)
......@@ -182,21 +184,24 @@ public class HierarchicalContentProvider implements IHierarchicalContentProvider
.getDataStoreUrl());
}
ContentCache cache = getCache(locationNode);
return new RemoteHierarchicalContent(locationNode, provider, session, cache);
return new RemoteHierarchicalContent(locationNode, provider, sessionTokenProvider,
cache);
}
}
private ContentCache getCache(IDatasetLocationNode locationNode)
{
String remoteDataStoreCode = locationNode.getLocation().getDataStoreCode();
IDatasetLocation location = locationNode.getLocation();
String remoteDataStoreCode = location.getDataStoreCode();
ContentCache cache = cacheMap.get(remoteDataStoreCode);
if (cache == null)
{
String serviceURL = location.getDataStoreUrl() + "/datastore_server/rmi-dss-api-v1";
IDssServiceRpcGeneric remote =
HttpInvokerUtils.createServiceStub(IDssServiceRpcGeneric.class, locationNode
.getLocation().getDataStoreUrl() + "/datastore_server/rmi-dss-api-v1",
HttpInvokerUtils.createServiceStub(IDssServiceRpcGeneric.class, serviceURL,
300000);
cache = new ContentCache(remote, session, cacheWorkspace, FileOperations.getInstance());
IFileOperations fileOperations = FileOperations.getInstance();
cache = new ContentCache(remote, sessionTokenProvider, cacheWorkspace, fileOperations);
cacheMap.put(remoteDataStoreCode, cache);
}
return cache;
......
......@@ -35,9 +35,9 @@ import ch.systemsx.cisd.base.exceptions.CheckedExceptionTunnel;
import ch.systemsx.cisd.common.exceptions.ConfigurationFailureException;
import ch.systemsx.cisd.common.exceptions.EnvironmentFailureException;
import ch.systemsx.cisd.common.filesystem.IFileOperations;
import ch.systemsx.cisd.common.server.ISessionTokenProvider;
import ch.systemsx.cisd.openbis.dss.generic.shared.api.v1.IDssServiceRpcGeneric;
import ch.systemsx.cisd.openbis.dss.generic.shared.dto.DataSetPathInfo;
import ch.systemsx.cisd.openbis.generic.shared.dto.OpenBISSessionHolder;
/**
* Cache for files remotely retrieved from a DSS.
......@@ -52,7 +52,7 @@ public class ContentCache
private final IDssServiceRpcGeneric remoteDss;
private final OpenBISSessionHolder sessionHolder;
private final ISessionTokenProvider sessionTokenProvider;
private final File cachedFiles;
......@@ -60,11 +60,11 @@ public class ContentCache
private Map<String, Lock> locks;
public ContentCache(IDssServiceRpcGeneric remoteDss, OpenBISSessionHolder sessionHolder,
public ContentCache(IDssServiceRpcGeneric remoteDss, ISessionTokenProvider sessionTokenProvider,
File cacheWorkSpace, IFileOperations fileOperations)
{
this.remoteDss = remoteDss;
this.sessionHolder = sessionHolder;
this.sessionTokenProvider = sessionTokenProvider;
cachedFiles = new File(cacheWorkSpace, CHACHED_FOLDER);
creatFolder(cachedFiles);
downloadingFolder = new File(cacheWorkSpace, DOWNLOADING_FOLDER);
......@@ -106,8 +106,9 @@ public class ContentCache
try
{
String url =
remoteDss.getDownloadUrlForFileForDataSet(sessionHolder.getSessionToken(),
dataSetCode, path.getRelativePath());
remoteDss.getDownloadUrlForFileForDataSet(
sessionTokenProvider.getSessionToken(), dataSetCode,
path.getRelativePath());
input = createURL(url).openStream();
File downloadedFile = createFileFromInputStream(pathInCache, input);
File file = new File(cachedFiles, pathInCache);
......
......@@ -19,13 +19,13 @@ package ch.systemsx.cisd.openbis.dss.generic.shared.content;
import java.util.ArrayList;
import java.util.List;
import ch.systemsx.cisd.common.server.ISessionTokenProvider;
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.ISingleDataSetPathInfoProvider;
import ch.systemsx.cisd.openbis.dss.generic.shared.api.v1.IDssServiceRpcGeneric;
import ch.systemsx.cisd.openbis.dss.generic.shared.dto.DataSetPathInfo;
import ch.systemsx.cisd.openbis.generic.shared.basic.dto.IDatasetLocationNode;
import ch.systemsx.cisd.openbis.generic.shared.dto.OpenBISSessionHolder;
/**
* Implementation of HierchicalContent that is stored on remote datastore server.
......@@ -39,19 +39,19 @@ public class RemoteHierarchicalContent implements IHierarchicalContent
private final ISingleDataSetPathInfoProvider provider;
private final OpenBISSessionHolder sessionHolder;
private final ISessionTokenProvider sessionTokenProvider;
private final IDssServiceRpcGeneric remote;
private final ContentCache cache;
public RemoteHierarchicalContent(IDatasetLocationNode location,
ISingleDataSetPathInfoProvider pathInfoProvider, OpenBISSessionHolder sessionHolder,
ISingleDataSetPathInfoProvider pathInfoProvider, ISessionTokenProvider sessionTokenProvider,
ContentCache cache)
{
this.location = location;
this.provider = pathInfoProvider;
this.sessionHolder = sessionHolder;
this.sessionTokenProvider = sessionTokenProvider;
this.remote = cache.getRemoteDss();
this.cache = cache;
......@@ -150,7 +150,7 @@ public class RemoteHierarchicalContent implements IHierarchicalContent
private IHierarchicalContentNode createNode(DataSetPathInfo info)
{
return new RemoteHierarchicalContentNode(location.getLocation().getDataSetCode(), info,
provider, remote, sessionHolder, cache);
provider, remote, sessionTokenProvider, cache);
}
private List<IHierarchicalContentNode> createNodes(List<DataSetPathInfo> paths)
......
......@@ -27,12 +27,12 @@ import java.util.List;
import ch.systemsx.cisd.base.exceptions.IOExceptionUnchecked;
import ch.systemsx.cisd.base.io.IRandomAccessFile;
import ch.systemsx.cisd.base.io.RandomAccessFileImpl;
import ch.systemsx.cisd.common.server.ISessionTokenProvider;
import ch.systemsx.cisd.openbis.common.io.hierarchical_content.api.IHierarchicalContentNode;
import ch.systemsx.cisd.openbis.dss.generic.shared.ISingleDataSetPathInfoProvider;
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.dto.DataSetPathInfo;
import ch.systemsx.cisd.openbis.generic.shared.dto.OpenBISSessionHolder;
/**
* A node of hierarchical content that stored on a remote datastore server. If file content is
......@@ -49,7 +49,7 @@ public class RemoteHierarchicalContentNode implements IHierarchicalContentNode
private IDssServiceRpcGeneric remoteDss;
private OpenBISSessionHolder sessionHolder;
private ISessionTokenProvider sessionTokenProvider;
private DataSetPathInfo path;
......@@ -59,16 +59,16 @@ public class RemoteHierarchicalContentNode implements IHierarchicalContentNode
public RemoteHierarchicalContentNode(String dataSetCode, DataSetPathInfo path,
ISingleDataSetPathInfoProvider provider, IDssServiceRpcGeneric remote,
OpenBISSessionHolder sessionHolder, ContentCache contentCache)
ISessionTokenProvider sessionTokenProvider, ContentCache contentCache)
{
this(dataSetCode, path, provider, remote, sessionHolder, contentCache, null);
this(dataSetCode, path, provider, remote, sessionTokenProvider, contentCache, null);
}
private RemoteHierarchicalContentNode(String dataSetCode,
DataSetPathInfo path,
ISingleDataSetPathInfoProvider provider,
IDssServiceRpcGeneric remote,
OpenBISSessionHolder sessionHolder,
ISessionTokenProvider sessionTokenProvider,
ContentCache contentCache,
String parentRelativePath)
{
......@@ -76,7 +76,7 @@ public class RemoteHierarchicalContentNode implements IHierarchicalContentNode
this.path = path;
this.provider = provider;
this.remoteDss = remote;
this.sessionHolder = sessionHolder;
this.sessionTokenProvider = sessionTokenProvider;
this.cache = contentCache;
this.parentRelativePath = parentRelativePath;
}
......@@ -152,12 +152,12 @@ public class RemoteHierarchicalContentNode implements IHierarchicalContentNode
for (DataSetPathInfo childPath : provider.listChildrenPathInfos(path))
{
children.add(new RemoteHierarchicalContentNode(dataSetCode, childPath, provider,
remoteDss, sessionHolder, cache, path.getRelativePath()));
remoteDss, sessionTokenProvider, cache, path.getRelativePath()));
}
} else
{
for (FileInfoDssDTO file : remoteDss.listFilesForDataSet(
sessionHolder.getSessionToken(), dataSetCode,
sessionTokenProvider.getSessionToken(), dataSetCode,
path.getRelativePath(), false))
{
DataSetPathInfo info = new DataSetPathInfo();
......@@ -168,7 +168,7 @@ public class RemoteHierarchicalContentNode implements IHierarchicalContentNode
info.setSizeInBytes(file.getFileSize());
info.setLastModified(new Date(0L));
children.add(new RemoteHierarchicalContentNode(dataSetCode, info, provider,
remoteDss, sessionHolder, cache, path.getRelativePath()));
remoteDss, sessionTokenProvider, cache, path.getRelativePath()));
}
}
return children;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment