diff --git a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/DssServiceRpcV1.java b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/DssServiceRpcV1.java index afed1b3757854728dae24620dbbcbd0275e3061e..7ed056635e19992724c16d2c17dc6ded36d6c1a2 100644 --- a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/DssServiceRpcV1.java +++ b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/DssServiceRpcV1.java @@ -91,7 +91,7 @@ public class DssServiceRpcV1 extends AbstractDssServiceRpc implements IDssServic * @param isRecursive If true, directories will be recursively appended to the list */ private void appendFileInfosForFile(File requestedFile, String hierarchyRoot, - ArrayList<FileInfoDss> list, boolean isRecursive) + ArrayList<FileInfoDss> list, boolean isRecursive) throws IOException { FileInfoDssBuilder factory = new FileInfoDssBuilder(hierarchyRoot); factory.appendFileInfosForFile(requestedFile, list, isRecursive); diff --git a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/rpc/shared/FileInfoDssBuilder.java b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/rpc/shared/FileInfoDssBuilder.java index e3976a9e2f523570c7dc515f4a4e5883064404c3..95db120cded3fd24340c69925a166d3295c99089 100644 --- a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/rpc/shared/FileInfoDssBuilder.java +++ b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/rpc/shared/FileInfoDssBuilder.java @@ -50,7 +50,7 @@ public class FileInfoDssBuilder * @param isRecursive If true, directories will be recursively appended to the list */ public void appendFileInfosForFile(File requestedFile, ArrayList<FileInfoDss> list, - boolean isRecursive) + boolean isRecursive) throws IOException { // at the top level, we should list the contents of directories, but only recurse if the // search is recursive @@ -58,7 +58,7 @@ public class FileInfoDssBuilder } private void appendFileInfosForFile(File requestedFile, ArrayList<FileInfoDss> list, - int maxDepth) + int maxDepth) throws IOException { FileInfoDss fileInfo = fileInfoForFile(requestedFile); list.add(fileInfo); @@ -76,7 +76,7 @@ public class FileInfoDssBuilder } } - private FileInfoDss fileInfoForFile(File file) + private FileInfoDss fileInfoForFile(File file) throws IOException { FileInfoDss fileInfo = new FileInfoDss(); @@ -96,17 +96,12 @@ public class FileInfoDssBuilder /** * Convert the path for file to a path relative to the root of the data set */ - private String pathRelativeToRoot(File file) + private String pathRelativeToRoot(File file) throws IOException { String path; - try - { - path = file.getCanonicalPath(); - path = path.substring(hierarchyRoot.length()); - return (path.length() > 0) ? path : "/"; - } catch (IOException ex) - { - return "UNKNOWN"; - } + path = file.getCanonicalPath(); + path = path.substring(hierarchyRoot.length()); + return (path.length() > 0) ? path : "/"; + } } 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 46bcc12956707d2d243bf409bd08407eae9886e4..40ece93c6cd569f1b540d273354e780bfec67b21 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 @@ -167,13 +167,20 @@ public class DssServiceRpcV1Test extends AbstractFileSystemTestCase ++i; } assertEquals(2, dirCount); - FileInfoDss fileInfo = fileInfos[fileIndices[0]]; - assertEquals("/foo.txt", fileInfo.getPath()); - assertEquals(100, fileInfo.getFileSize()); - - fileInfo = fileInfos[fileIndices[1]]; - assertEquals("/stuff/bar.txt", fileInfo.getPath()); - assertEquals(110, fileInfo.getFileSize()); + for (i = 0; i < 2; ++i) + { + FileInfoDss fileInfo = fileInfos[fileIndices[i]]; + if ("/foo.txt".equals(fileInfo.getPath())) + { + assertEquals(100, fileInfo.getFileSize()); + } else if ("/stuff/bar.txt".equals(fileInfo.getPath())) + { + assertEquals(110, fileInfo.getFileSize()); + } else + { + fail("Received unexpected file."); + } + } context.assertIsSatisfied(); }