diff --git a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/client/api/cli/CommandGet.java b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/client/api/cli/CommandGet.java index c121be4bae4fd44b376cfa0cb5a73972a45ea95b..0bb5ad827ac6c641055306d7712c3e7f84619cae 100644 --- a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/client/api/cli/CommandGet.java +++ b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/client/api/cli/CommandGet.java @@ -33,7 +33,7 @@ import ch.systemsx.cisd.openbis.dss.client.api.v1.IDssComponent; import ch.systemsx.cisd.openbis.dss.generic.shared.api.v1.FileInfoDssDTO; /** - * Comand that lists files in the data set. + * Command that lists files in the data set. * * @author Chandrasekhar Ramakrishnan */ 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 d6aa583b5ee38e0fbd6b0e97d6b22f3f4d923a12..14da6f0f72f17151b71b9d909ee585a488b97d7f 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 @@ -25,9 +25,10 @@ import java.util.ArrayList; import ch.systemsx.cisd.base.exceptions.IOExceptionUnchecked; import ch.systemsx.cisd.openbis.dss.generic.server.AbstractDssServiceRpc; import ch.systemsx.cisd.openbis.dss.generic.shared.IEncapsulatedOpenBISService; -import ch.systemsx.cisd.openbis.dss.generic.shared.api.v1.FileInfoDssBuilder; import ch.systemsx.cisd.openbis.dss.generic.shared.api.v1.FileInfoDssDTO; +import ch.systemsx.cisd.openbis.dss.generic.shared.api.v1.FileReferenceDTO; import ch.systemsx.cisd.openbis.dss.generic.shared.api.v1.IDssServiceRpcGeneric; +import ch.systemsx.cisd.openbis.dss.generic.shared.api.v1.NewDatasetDTO; /** * Implementation of the generic RPC interface. @@ -85,6 +86,12 @@ public class DssServiceRpcGeneric extends AbstractDssServiceRpc implements IDssS } } + public void putDataSet(String sessionToken, NewDatasetDTO newDataSet) + throws IOExceptionUnchecked, IllegalArgumentException + { + + } + public int getMajorVersion() { return 1; @@ -113,4 +120,18 @@ public class DssServiceRpcGeneric extends AbstractDssServiceRpc implements IDssS FileInfoDssBuilder factory = new FileInfoDssBuilder(dataSetRoot, listingRoot); factory.appendFileInfosForFile(requestedFile, list, isRecursive); } + + public InputStream getFileForDataSet(String sessionToken, FileReferenceDTO fileOrFolder) + throws IOExceptionUnchecked, IllegalArgumentException + { + return this.getFileForDataSet(sessionToken, fileOrFolder.getDataSetCode(), fileOrFolder + .getPath()); + } + + public FileInfoDssDTO[] listFilesForDataSet(String sessionToken, FileReferenceDTO fileOrFolder) + throws IOExceptionUnchecked, IllegalArgumentException + { + return this.listFilesForDataSet(sessionToken, fileOrFolder.getDataSetCode(), fileOrFolder + .getPath(), fileOrFolder.isRecursive()); + } } diff --git a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/api/v1/FileInfoDssBuilder.java b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/api/v1/FileInfoDssBuilder.java similarity index 88% rename from datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/api/v1/FileInfoDssBuilder.java rename to datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/api/v1/FileInfoDssBuilder.java index c8205f8bb1e870829280ec29ccca4bd6c54a83b7..c0f46154c3eeaadf479fd6951b8b9b70821ad975 100644 --- a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/api/v1/FileInfoDssBuilder.java +++ b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/server/api/v1/FileInfoDssBuilder.java @@ -14,12 +14,14 @@ * limitations under the License. */ -package ch.systemsx.cisd.openbis.dss.generic.shared.api.v1; +package ch.systemsx.cisd.openbis.dss.generic.server.api.v1; import java.io.File; import java.io.IOException; import java.util.ArrayList; +import ch.systemsx.cisd.openbis.dss.generic.shared.api.v1.FileInfoDssDTO; + /** * Helper Class for creating FileInfoDss objects * @@ -87,19 +89,10 @@ public class FileInfoDssBuilder private FileInfoDssDTO fileInfoForFile(File file) throws IOException { - FileInfoDssDTO fileInfo = new FileInfoDssDTO(); - - fileInfo.setPathInDataSet(pathRelativeToDataSetRoot(file)); - fileInfo.setPathInListing(pathRelativeToListingRoot(file)); - fileInfo.setDirectory(file.isDirectory()); - if (fileInfo.isDirectory()) - { - fileInfo.setFileSize(-1); - } else - { - fileInfo.setFileSize(file.length()); - } - + FileInfoDssDTO fileInfo = + new FileInfoDssDTO(pathRelativeToDataSetRoot(file), + pathRelativeToListingRoot(file), file.isDirectory(), + (file.isDirectory()) ? -1 : file.length()); return fileInfo; } diff --git a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/api/v1/FileInfoDssDTO.java b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/api/v1/FileInfoDssDTO.java index 20c10bb6de6825db09b94269408796a78171fac0..dfcf1ead8dd890effade729305f02d93d850aad2 100644 --- a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/api/v1/FileInfoDssDTO.java +++ b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/api/v1/FileInfoDssDTO.java @@ -27,17 +27,21 @@ public class FileInfoDssDTO implements Serializable { private static final long serialVersionUID = 1L; - private String pathInDataSet; + private final String pathInDataSet; - private String pathInListing; + private final String pathInListing; - private boolean isDirectory; + private final boolean isDirectory; - private long fileSize; + private final long fileSize; - FileInfoDssDTO() + public FileInfoDssDTO(String pathInDataSet, String pathInListing, boolean isDirectory, + long fileSize) { - + this.pathInDataSet = pathInDataSet; + this.pathInListing = pathInListing; + this.isDirectory = isDirectory; + this.fileSize = fileSize; } /** @@ -73,38 +77,6 @@ public class FileInfoDssDTO implements Serializable return fileSize; } - /** - * Package-visible method for configuring instances. - */ - void setPathInDataSet(String pathInDataSet) - { - this.pathInDataSet = pathInDataSet; - } - - /** - * Package-visible method for configuring instances. - */ - void setPathInListing(String relativePath) - { - this.pathInListing = relativePath; - } - - /** - * Package-visible method for configuring instances. - */ - void setDirectory(boolean isDirectory) - { - this.isDirectory = isDirectory; - } - - /** - * Package-visible method for configuring instances. - */ - void setFileSize(long fileSize) - { - this.fileSize = fileSize; - } - @Override public String toString() { diff --git a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/api/v1/FileReferenceDTO.java b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/api/v1/FileReferenceDTO.java new file mode 100644 index 0000000000000000000000000000000000000000..85e6c2852463eed386f45b304f6e82489856b614 --- /dev/null +++ b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/api/v1/FileReferenceDTO.java @@ -0,0 +1,58 @@ +/* + * Copyright 2010 ETH Zuerich, CISD + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ch.systemsx.cisd.openbis.dss.generic.shared.api.v1; + +import java.io.Serializable; + +/** + * Represents a reference to a file/path within a data set. + * + * @author Chandrasekhar Ramakrishnan + */ +public class FileReferenceDTO implements Serializable +{ + private static final long serialVersionUID = 1L; + + private final String dataSetCode; + + private final String path; + + private final boolean isRecursive; + + public FileReferenceDTO(String dataSetCode, String path, boolean isRecursive) + { + this.dataSetCode = dataSetCode; + this.path = path; + this.isRecursive = isRecursive; + } + + public String getDataSetCode() + { + return dataSetCode; + } + + public String getPath() + { + return path; + } + + public boolean isRecursive() + { + return isRecursive; + } + +} diff --git a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/api/v1/IDssServiceRpcGeneric.java b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/api/v1/IDssServiceRpcGeneric.java index 51bdc10b2151378336e8d742011078392eb1ec81..5557b9245ecd1dc891584423489ae02abcd7fea7 100644 --- a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/api/v1/IDssServiceRpcGeneric.java +++ b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/api/v1/IDssServiceRpcGeneric.java @@ -33,19 +33,58 @@ public interface IDssServiceRpcGeneric extends IRpcService /** * Get an array of FileInfoDss objects that describe the file-system structure of the data set. * + * @param sessionToken The session token + * @param fileOrFolder The file or folder to get information on + * @throws IOExceptionUnchecked Thrown if an IOException occurs when listing the files + * @throws IllegalArgumentException Thrown if the dataSetCode or startPath are not valid + */ + public FileInfoDssDTO[] listFilesForDataSet(String sessionToken, FileReferenceDTO fileOrFolder) + throws IOExceptionUnchecked, IllegalArgumentException; + + /** + * Get an array of FileInfoDss objects that describe the file-system structure of the data set. + * + * @param sessionToken The session token + * @param fileOrFolder The file or folder to retrieve + * @throws IOExceptionUnchecked Thrown if an IOException occurs when listing the files + * @throws IllegalArgumentException Thrown if the dataSetCode or startPath are not valid + */ + public InputStream getFileForDataSet(String sessionToken, FileReferenceDTO fileOrFolder) + throws IOExceptionUnchecked, IllegalArgumentException; + + /** + * Get an array of FileInfoDss objects that describe the file-system structure of the data set. + * + * @param sessionToken The session token + * @param dataSetCode The data set to retrieve file information about + * @param path The path within the data set to retrieve file information about + * @param isRecursive Should the result include information for sub folders? * @throws IOExceptionUnchecked Thrown if an IOException occurs when listing the files * @throws IllegalArgumentException Thrown if the dataSetCode or startPath are not valid */ public FileInfoDssDTO[] listFilesForDataSet(String sessionToken, String dataSetCode, - String startPath, boolean isRecursive) throws IOExceptionUnchecked, - IllegalArgumentException; + String path, boolean isRecursive) throws IOExceptionUnchecked, IllegalArgumentException; /** * Get an array of FileInfoDss objects that describe the file-system structure of the data set. * + * @param sessionToken The session token + * @param dataSetCode The data set to retrieve file from + * @param path The path within the data set to retrieve file information about + * @throws IOExceptionUnchecked Thrown if an IOException occurs when listing the files + * @throws IllegalArgumentException Thrown if the dataSetCode or startPath are not valid + */ + public InputStream getFileForDataSet(String sessionToken, String dataSetCode, String path) + throws IOExceptionUnchecked, IllegalArgumentException; + + /** + * Upload a new data set to the DSS. + * + * @param sessionToken The session token + * @param newDataset The new data set that should be registered * @throws IOExceptionUnchecked Thrown if an IOException occurs when listing the files * @throws IllegalArgumentException Thrown if the dataSetCode or startPath are not valid */ - public InputStream getFileForDataSet(String sessionToken, String dataSetCode, String startPath) + public void putDataSet(String sessionToken, NewDatasetDTO newDataset) throws IOExceptionUnchecked, IllegalArgumentException; } diff --git a/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/api/v1/NewDatasetDTO.java b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/api/v1/NewDatasetDTO.java new file mode 100644 index 0000000000000000000000000000000000000000..6f392c51570b63cd0f2e59f47fb00093cd7c1a5f --- /dev/null +++ b/datastore_server/source/java/ch/systemsx/cisd/openbis/dss/generic/shared/api/v1/NewDatasetDTO.java @@ -0,0 +1,62 @@ +/* + * Copyright 2010 ETH Zuerich, CISD + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package ch.systemsx.cisd.openbis.dss.generic.shared.api.v1; + +import java.io.InputStream; +import java.io.Serializable; + +import ch.systemsx.cisd.common.io.ConcatenatedFileInputStream; + +/** + * Represents a new data set that the DSS should register. + * <p> + * The information required to register a new data set are the path of the data set and the name of + * the storage process that should handle registering it. + * + * @author Chandrasekhar Ramakrishnan + */ +public class NewDatasetDTO implements Serializable +{ + private static final long serialVersionUID = 1L; + + private final String storageProcessName; + + private final InputStream inputStream; + + /** + * Constructor + * + * @param storageProcessName The storage process that should handle this data set + * @param inputStream An input stream on the file or folder to register. If a folder is to be + * registered, the input stream must be a {@link ConcatenatedFileInputStream}. + */ + public NewDatasetDTO(String storageProcessName, InputStream inputStream) + { + this.storageProcessName = storageProcessName; + this.inputStream = inputStream; + } + + public String getStorageProcessName() + { + return storageProcessName; + } + + public InputStream getInputStream() + { + return inputStream; + } +}