diff --git a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/api/v1/DssServiceRpcGenericLogger.java b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/api/v1/DssServiceRpcGenericLogger.java index 5e0f726bc9a3dc99dabdf33129c66adb4fc4a1ac..e3a27c4f2216e0fdf78a9590a9dc236e41bced21 100644 --- a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/api/v1/DssServiceRpcGenericLogger.java +++ b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/api/v1/DssServiceRpcGenericLogger.java @@ -230,7 +230,7 @@ public class DssServiceRpcGenericLogger extends AbstractServerLogger implements throws IOExceptionUnchecked, IllegalArgumentException { logAccess(sessionToken, "get_download_url_for_file_for_data_set", - "DATA_SET(%s) PATH(%s) VALIDITY(%i)", dataSetCode, path, validityDurationInSeconds); + "DATA_SET(%s) PATH(%s) VALIDITY(%s)", dataSetCode, path, validityDurationInSeconds); return null; } @@ -242,7 +242,7 @@ public class DssServiceRpcGenericLogger extends AbstractServerLogger implements long validityDurationInSeconds) throws IOExceptionUnchecked, IllegalArgumentException { logAccess(sessionToken, "get_download_url_for_file_for_data_set", - "DATA_SET(%s) VALIDITY(%i)", fileOrFolder, validityDurationInSeconds); + "DATA_SET(%s) VALIDITY(%s)", fileOrFolder, validityDurationInSeconds); return null; } } diff --git a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/JsonDssServiceRpcGenericTest.java b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/JsonDssServiceRpcGenericTest.java index b7fa01c5a57c5e9ec314e550164efe9a7a894db1..66b43f0364480121c2088ed8a994831618463ca0 100644 --- a/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/JsonDssServiceRpcGenericTest.java +++ b/datastore_server/sourceTest/java/ch/systemsx/cisd/openbis/datastoreserver/systemtests/JsonDssServiceRpcGenericTest.java @@ -17,12 +17,15 @@ package ch.systemsx.cisd.openbis.datastoreserver.systemtests; import java.io.File; +import java.io.FileOutputStream; import java.io.IOException; +import java.io.InputStream; import java.net.MalformedURLException; import java.net.URL; import java.util.HashMap; import org.apache.commons.io.FileUtils; +import org.apache.commons.io.IOUtils; import org.testng.annotations.AfterClass; import org.testng.annotations.BeforeClass; import org.testng.annotations.Test; @@ -30,6 +33,7 @@ import org.testng.annotations.Test; import com.googlecode.jsonrpc4j.JsonRpcHttpClient; import com.googlecode.jsonrpc4j.ProxyUtil; +import ch.systemsx.cisd.openbis.dss.generic.shared.api.v1.DataSetFileDTO; 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.generic.shared.api.json.GenericObjectMapper; @@ -91,7 +95,43 @@ public class JsonDssServiceRpcGenericTest extends SystemTestCase { System.out.println(fileInfo); } + } + + @Test + public void testGetDataSetContentsWithURL() throws MalformedURLException, IOException + { + + FileInfoDssDTO[] result = + dssRpcService.listFilesForDataSet(sessionToken, "20081105092159111-1", "", true); + assertTrue("Did not find any files for the data set 20081105092159111-1", result.length > 0); + + FileInfoDssDTO fileInfoToDownload = null; + for (FileInfoDssDTO fileInfo : result) + { + if (false == fileInfo.isDirectory()) + { + fileInfoToDownload = fileInfo; + break; + } + } + assertNotNull("Could not find a file in the data set 20081105092159111-1 to download", + fileInfoToDownload); + + @SuppressWarnings("null") + DataSetFileDTO fileToDownload = + new DataSetFileDTO("20081105092159111-1", fileInfoToDownload.getPathInDataSet(), + false); + String url = + dssRpcService.getDownloadUrlForFileForDataSetWithTimeout(sessionToken, + fileToDownload, -1); + + // Download the data into a file + InputStream input = new URL(url).openStream(); + File file = new File(workingDirectory, "output"); + FileOutputStream output = new FileOutputStream(file); + IOUtils.copyLarge(input, output); + assertEquals(file.length(), fileInfoToDownload.getFileSize()); } public static IGeneralInformationService createOpenbisService()