Skip to content
Snippets Groups Projects
Commit 8fa3c91f authored by buczekp's avatar buczekp
Browse files

[LMS-2172] basic retrieve of file based content;

minor: changed logging level

SVN: 20984
parent 32f34a36
No related branches found
No related tags found
No related merge requests found
...@@ -31,7 +31,7 @@ public class PathInfoDBAwareHierarchicalContentFactory extends ...@@ -31,7 +31,7 @@ public class PathInfoDBAwareHierarchicalContentFactory extends
{ {
if (DatabaseBasedDataSetPathInfoProvider.isDataSourceDefined()) if (DatabaseBasedDataSetPathInfoProvider.isDataSourceDefined())
{ {
operationLog.debug("Path Info DB is properly configured"); operationLog.info("Path Info DB is properly configured");
return new PathInfoDBAwareHierarchicalContentFactory( return new PathInfoDBAwareHierarchicalContentFactory(
new DatabaseBasedDataSetPathInfoProvider()); new DatabaseBasedDataSetPathInfoProvider());
} else } else
...@@ -57,7 +57,7 @@ public class PathInfoDBAwareHierarchicalContentFactory extends ...@@ -57,7 +57,7 @@ public class PathInfoDBAwareHierarchicalContentFactory extends
DataSetPathInfo rootPathInfo = pathInfoProvider.tryGetDataSetRootPathInfo(dataSetCode); DataSetPathInfo rootPathInfo = pathInfoProvider.tryGetDataSetRootPathInfo(dataSetCode);
if (rootPathInfo != null) // exists in DB if (rootPathInfo != null) // exists in DB
{ {
operationLog.info("Data set " + dataSetCode + " was found in Path Info DB."); operationLog.debug("Data set " + dataSetCode + " was found in Path Info DB.");
return new SimplePathInfoBasedHierarchicalContent(rootPathInfo, file, onCloseAction); return new SimplePathInfoBasedHierarchicalContent(rootPathInfo, file, onCloseAction);
} else } else
{ {
......
...@@ -17,12 +17,16 @@ ...@@ -17,12 +17,16 @@
package ch.systemsx.cisd.openbis.dss.generic.shared.content; package ch.systemsx.cisd.openbis.dss.generic.shared.content;
import java.io.File; import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.InputStream; import java.io.InputStream;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import ch.systemsx.cisd.base.exceptions.CheckedExceptionTunnel;
import ch.systemsx.cisd.base.io.IRandomAccessFile; import ch.systemsx.cisd.base.io.IRandomAccessFile;
import ch.systemsx.cisd.base.io.RandomAccessFileImpl;
import ch.systemsx.cisd.common.io.AbstractHierarchicalContentNode; import ch.systemsx.cisd.common.io.AbstractHierarchicalContentNode;
import ch.systemsx.cisd.common.io.IHierarchicalContent; import ch.systemsx.cisd.common.io.IHierarchicalContent;
import ch.systemsx.cisd.common.io.IHierarchicalContentNode; import ch.systemsx.cisd.common.io.IHierarchicalContentNode;
...@@ -68,7 +72,7 @@ class SimplePathInfoBasedHierarchicalContent implements IHierarchicalContent ...@@ -68,7 +72,7 @@ class SimplePathInfoBasedHierarchicalContent implements IHierarchicalContent
{ {
if (rootNode == null) if (rootNode == null)
{ {
rootNode = new SimplePathInfoNode(rootPathInfo); rootNode = new SimplePathInfoNode(root, rootPathInfo);
} }
return rootNode; return rootNode;
} }
...@@ -87,7 +91,7 @@ class SimplePathInfoBasedHierarchicalContent implements IHierarchicalContent ...@@ -87,7 +91,7 @@ class SimplePathInfoBasedHierarchicalContent implements IHierarchicalContent
private IHierarchicalContentNode createNode(String relativePath) private IHierarchicalContentNode createNode(String relativePath)
{ {
DataSetPathInfo pathInfo = findPathInfo(rootPathInfo, relativePath); DataSetPathInfo pathInfo = findPathInfo(rootPathInfo, relativePath);
return new SimplePathInfoNode(pathInfo); return new SimplePathInfoNode(root, pathInfo);
} }
/** /**
...@@ -123,7 +127,7 @@ class SimplePathInfoBasedHierarchicalContent implements IHierarchicalContent ...@@ -123,7 +127,7 @@ class SimplePathInfoBasedHierarchicalContent implements IHierarchicalContent
throw new IllegalArgumentException("Resource '" + relativePath + "' does not exist."); throw new IllegalArgumentException("Resource '" + relativePath + "' does not exist.");
} }
// TODO remove repetition // TODO 2011-04-19, Piotr Buczek: remove repetition
public List<IHierarchicalContentNode> listMatchingNodes(final String relativePathPattern) public List<IHierarchicalContentNode> listMatchingNodes(final String relativePathPattern)
{ {
final IHierarchicalContentNode startingNode = getRootNode(); final IHierarchicalContentNode startingNode = getRootNode();
...@@ -241,8 +245,11 @@ class SimplePathInfoBasedHierarchicalContent implements IHierarchicalContent ...@@ -241,8 +245,11 @@ class SimplePathInfoBasedHierarchicalContent implements IHierarchicalContent
private final DataSetPathInfo pathInfo; private final DataSetPathInfo pathInfo;
SimplePathInfoNode(DataSetPathInfo pathInfo) private final File root;
SimplePathInfoNode(File root, DataSetPathInfo pathInfo)
{ {
this.root = root;
this.pathInfo = pathInfo; this.pathInfo = pathInfo;
} }
...@@ -273,7 +280,7 @@ class SimplePathInfoBasedHierarchicalContent implements IHierarchicalContent ...@@ -273,7 +280,7 @@ class SimplePathInfoBasedHierarchicalContent implements IHierarchicalContent
List<IHierarchicalContentNode> result = new ArrayList<IHierarchicalContentNode>(); List<IHierarchicalContentNode> result = new ArrayList<IHierarchicalContentNode>();
for (DataSetPathInfo child : pathInfo.getChildren()) for (DataSetPathInfo child : pathInfo.getChildren())
{ {
result.add(new SimplePathInfoNode(child)); result.add(new SimplePathInfoNode(root, child));
} }
return result; return result;
} }
...@@ -284,23 +291,35 @@ class SimplePathInfoBasedHierarchicalContent implements IHierarchicalContent ...@@ -284,23 +291,35 @@ class SimplePathInfoBasedHierarchicalContent implements IHierarchicalContent
return pathInfo.getSizeInBytes(); return pathInfo.getSizeInBytes();
} }
// TODO // TODO 2011-04-19, Piotr Buczek: use abstraction to get file content
public File getFile() throws UnsupportedOperationException public File getFile() throws UnsupportedOperationException
{ {
throw null; if (StringUtils.isBlank(getRelativePath()))
{
return root;
} else
{
return new File(root, getRelativePath());
}
} }
@Override @Override
protected IRandomAccessFile doGetFileContent() protected IRandomAccessFile doGetFileContent()
{ {
return null; return new RandomAccessFileImpl(getFile(), "r");
} }
@Override @Override
protected InputStream doGetInputStream() protected InputStream doGetInputStream()
{ {
return null; try
{
return new FileInputStream(getFile());
} catch (FileNotFoundException ex)
{
throw CheckedExceptionTunnel.wrapIfNecessary(ex);
}
} }
} }
......
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