Skip to content
Snippets Groups Projects
Commit 1b4c9127 authored by cramakri's avatar cramakri
Browse files

LMS-1503 Work on the put method.

SVN: 16174
parent 11b0df80
No related branches found
No related tags found
No related merge requests found
......@@ -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
*/
......
......@@ -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());
}
}
......@@ -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;
}
......
......@@ -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()
{
......
/*
* 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;
}
}
......@@ -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;
}
/*
* 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;
}
}
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