public class DssComponent extends java.lang.Object implements IDssComponent
The DssComponent manages a connection to openBIS (IETLLIMSService) as well as connections to data store servers (IDssServiceRpc) to present a simplified interface to downloading datasets.
| Constructor and Description |
|---|
DssComponent(IGeneralInformationService service,
IRpcServiceFactory dssServiceFactory,
java.lang.String sessionTokenOrNull)
Constructor for clients that already have an IETLLIMSService; also used for testing.
|
| Modifier and Type | Method and Description |
|---|---|
void |
checkSession()
Checks whether the session is alive.
|
boolean |
deleteSessionWorkspaceFile(java.lang.String path)
Delete a file or directory in the session workspace.
|
java.util.Map<java.lang.String,java.lang.String> |
extractMetadata(NewDataSetDTO newDataset,
java.io.File dataSetFile)
Tries to extract the data set property key-values (metadata) from the data.
|
IDataSetDss |
getDataSet(java.lang.String code)
Get a proxy to the data set designated by the given data set code.
|
java.io.InputStream |
getFileFromSessionWorkspace(java.lang.String filePath)
Downloads a file from the session workspace.
|
void |
getFileFromSessionWorkspace(java.lang.String filePath,
java.io.File localFile)
Downloads a file from the session workspace.
|
java.lang.String |
getSessionToken()
Returns the session token.
|
void |
logout()
Logs the current user out.
|
IDataSetDss |
putDataSet(NewDataSetDTO newDataset,
java.io.File dataSetFile)
Upload a new data set to the DSS.
|
void |
putFileToSessionWorkspace(java.lang.String directory,
java.io.File file)
Uploads a file to the session workspace.
|
void |
putFileToSessionWorkspace(java.lang.String filePath,
java.io.InputStream inputStream)
Uploads a file to the session workspace.
|
static DssComponent |
tryCreate(java.lang.String sessionToken,
java.lang.String openBISUrl,
long timeoutInMillis)
Public factory method for creating a DssComponent for a user that has already been authenticated.
|
static DssComponent |
tryCreate(java.lang.String user,
java.lang.String password,
java.lang.String openBISUrl,
long timeoutInMillis)
Public factory method for creating a DssComponent with a username and password.
|
java.util.List<ValidationError> |
validateDataSet(NewDataSetDTO newDataset,
java.io.File dataSetFile)
Validate a data set.
|
public DssComponent(IGeneralInformationService service, IRpcServiceFactory dssServiceFactory, java.lang.String sessionTokenOrNull)
service - A proxy to the openBIS application server.dssServiceFactory - A proxy to the DSS server.sessionTokenOrNull - A session token, if the user has already logged in, or null otherwise.public static DssComponent tryCreate(java.lang.String user, java.lang.String password, java.lang.String openBISUrl, long timeoutInMillis)
user - The user namepassword - The user's passwordopenBISUrl - The URL to openBIStimeoutInMillis - network timeout when connecting to remote servicespublic static DssComponent tryCreate(java.lang.String sessionToken, java.lang.String openBISUrl, long timeoutInMillis)
sessionToken - The session token provided by authenticationopenBISUrl - The URL to openBIStimeoutInMillis - network timeout when connecting to remote servicespublic java.lang.String getSessionToken()
IDssComponentgetSessionToken in interface IDssComponentpublic void checkSession()
throws InvalidSessionException
IDssComponentcheckSession in interface IDssComponentInvalidSessionException - If the session is not alive.public IDataSetDss getDataSet(java.lang.String code) throws EnvironmentFailureException, java.lang.IllegalStateException
IDssComponentgetDataSet in interface IDssComponentEnvironmentFailureException - Thrown in cases where it is not possible to connect to
the server.java.lang.IllegalStateException - Thrown if the user has not yet been authenticated.public void logout()
IDssComponentlogout in interface IDssComponentpublic IDataSetDss putDataSet(NewDataSetDTO newDataset, java.io.File dataSetFile) throws java.lang.IllegalStateException, EnvironmentFailureException
IDssComponentputDataSet in interface IDssComponentnewDataset - The new data set that should be registereddataSetFile - A file or folder containing the datajava.lang.IllegalStateException - Thrown if the user has not yet been authenticated.EnvironmentFailureException - Thrown in cases where it is not possible to connect to
the server.public void putFileToSessionWorkspace(java.lang.String filePath,
java.io.InputStream inputStream)
throws ch.systemsx.cisd.base.exceptions.IOExceptionUnchecked
IDssComponentputFileToSessionWorkspace in interface IDssComponentfilePath - The path (directory and name) of the file to upload.inputStream - The content of the file to upload.ch.systemsx.cisd.base.exceptions.IOExceptionUnchecked - If the file transfer fails.public void putFileToSessionWorkspace(java.lang.String directory,
java.io.File file)
throws ch.systemsx.cisd.base.exceptions.IOExceptionUnchecked
IDssComponentputFileToSessionWorkspace in interface IDssComponentdirectory - The directory in the session workspace where the file should be uploaded.file - The file to upload.ch.systemsx.cisd.base.exceptions.IOExceptionUnchecked - If the file cannot be written.public java.io.InputStream getFileFromSessionWorkspace(java.lang.String filePath)
throws ch.systemsx.cisd.base.exceptions.IOExceptionUnchecked
IDssComponentgetFileFromSessionWorkspace in interface IDssComponentfilePath - The path (directory and name) of the file to download.ch.systemsx.cisd.base.exceptions.IOExceptionUnchecked - If the file does not exist, is a directory or cannot be opened.public void getFileFromSessionWorkspace(java.lang.String filePath,
java.io.File localFile)
throws ch.systemsx.cisd.base.exceptions.IOExceptionUnchecked
IDssComponentgetFileFromSessionWorkspace in interface IDssComponentfilePath - The path (directory and name) of the file to download.localFile - The local file to write the file from the session workspace to.ch.systemsx.cisd.base.exceptions.IOExceptionUnchecked - If the file does not exist.public boolean deleteSessionWorkspaceFile(java.lang.String path)
IDssComponentdeleteSessionWorkspaceFile in interface IDssComponenttrue if the path doesn't exist anymore.public java.util.List<ValidationError> validateDataSet(NewDataSetDTO newDataset, java.io.File dataSetFile) throws java.lang.IllegalStateException, EnvironmentFailureException
IDssComponentvalidateDataSet in interface IDssComponentnewDataset - The new data set that should be registereddataSetFile - A file or folder containing the datajava.lang.IllegalStateException - Thrown if the user has not yet been authenticated.EnvironmentFailureException - Thrown in cases where it is not possible to connect to
the server.public java.util.Map<java.lang.String,java.lang.String> extractMetadata(NewDataSetDTO newDataset, java.io.File dataSetFile) throws java.lang.IllegalStateException, EnvironmentFailureException
IDssComponentextractMetadata in interface IDssComponentnewDataset - The new data set that should be registereddataSetFile - A file or folder containing the datajava.lang.IllegalStateException - Thrown if the user has not yet been authenticated.EnvironmentFailureException - Thrown in cases where it is not possible to connect to
the server.