Class DssComponent
- java.lang.Object
-
- ch.systemsx.cisd.openbis.dss.client.api.v1.impl.DssComponent
-
- All Implemented Interfaces:
IDssComponent
public class DssComponent extends java.lang.Object implements IDssComponent
Implementation of the IDssComponent interface. It is a facade for interacting with openBIS and multiple DSS servers.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 Summary
Constructors Constructor Description DssComponent(IGeneralInformationService service, IRpcServiceFactory dssServiceFactory, java.lang.String sessionTokenOrNull)Constructor for clients that already have an IETLLIMSService; also used for testing.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcheckSession()Checks whether the session is alive.booleandeleteSessionWorkspaceFile(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.IDataSetDssgetDataSet(java.lang.String code)Get a proxy to the data set designated by the given data set code.java.io.InputStreamgetFileFromSessionWorkspace(java.lang.String filePath)Downloads a file from the session workspace.voidgetFileFromSessionWorkspace(java.lang.String filePath, java.io.File localFile)Downloads a file from the session workspace.java.lang.StringgetSessionToken()Returns the session token.voidlogout()Logs the current user out.IDataSetDssputDataSet(NewDataSetDTO newDataset, java.io.File dataSetFile)Upload a new data set to the DSS.voidputFileToSessionWorkspace(java.lang.String directory, java.io.File file)Uploads a file to the session workspace.voidputFileToSessionWorkspace(java.lang.String filePath, java.io.InputStream inputStream)Uploads a file to the session workspace.static DssComponenttryCreate(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 DssComponenttryCreate(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.
-
-
-
Constructor Detail
-
DssComponent
public DssComponent(IGeneralInformationService service, IRpcServiceFactory dssServiceFactory, java.lang.String sessionTokenOrNull)
Constructor for clients that already have an IETLLIMSService; also used for testing.- Parameters:
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.
-
-
Method Detail
-
tryCreate
public 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.- Parameters:
user- The user namepassword- The user's passwordopenBISUrl- The URL to openBIStimeoutInMillis- network timeout when connecting to remote services
-
tryCreate
public 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.- Parameters:
sessionToken- The session token provided by authenticationopenBISUrl- The URL to openBIStimeoutInMillis- network timeout when connecting to remote services
-
getSessionToken
public java.lang.String getSessionToken()
Description copied from interface:IDssComponentReturns the session token.- Specified by:
getSessionTokenin interfaceIDssComponent- Returns:
- The session token for an authenticated user.
-
checkSession
public void checkSession() throws InvalidSessionExceptionDescription copied from interface:IDssComponentChecks whether the session is alive.- Specified by:
checkSessionin interfaceIDssComponent- Throws:
InvalidSessionException- If the session is not alive.
-
getDataSet
public IDataSetDss getDataSet(java.lang.String code) throws EnvironmentFailureException, java.lang.IllegalStateException
Description copied from interface:IDssComponentGet a proxy to the data set designated by the given data set code.- Specified by:
getDataSetin interfaceIDssComponent- Throws:
EnvironmentFailureException- 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.
-
logout
public void logout()
Description copied from interface:IDssComponentLogs the current user out.- Specified by:
logoutin interfaceIDssComponent
-
putDataSet
public IDataSetDss putDataSet(NewDataSetDTO newDataset, java.io.File dataSetFile) throws java.lang.IllegalStateException, EnvironmentFailureException
Description copied from interface:IDssComponentUpload a new data set to the DSS.- Specified by:
putDataSetin interfaceIDssComponent- Parameters:
newDataset- The new data set that should be registereddataSetFile- A file or folder containing the data- Returns:
- A proxy to the newly added data set
- Throws:
java.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.
-
putFileToSessionWorkspace
public void putFileToSessionWorkspace(java.lang.String filePath, java.io.InputStream inputStream) throws ch.systemsx.cisd.base.exceptions.IOExceptionUncheckedDescription copied from interface:IDssComponentUploads a file to the session workspace.- Specified by:
putFileToSessionWorkspacein interfaceIDssComponent- Parameters:
filePath- The path (directory and name) of the file to upload.inputStream- The content of the file to upload.- Throws:
ch.systemsx.cisd.base.exceptions.IOExceptionUnchecked- If the file transfer fails.
-
putFileToSessionWorkspace
public void putFileToSessionWorkspace(java.lang.String directory, java.io.File file) throws ch.systemsx.cisd.base.exceptions.IOExceptionUncheckedDescription copied from interface:IDssComponentUploads a file to the session workspace.- Specified by:
putFileToSessionWorkspacein interfaceIDssComponent- Parameters:
directory- The directory in the session workspace where the file should be uploaded.file- The file to upload.- Throws:
ch.systemsx.cisd.base.exceptions.IOExceptionUnchecked- If the file cannot be written.
-
getFileFromSessionWorkspace
public java.io.InputStream getFileFromSessionWorkspace(java.lang.String filePath) throws ch.systemsx.cisd.base.exceptions.IOExceptionUncheckedDescription copied from interface:IDssComponentDownloads a file from the session workspace.- Specified by:
getFileFromSessionWorkspacein interfaceIDssComponent- Parameters:
filePath- The path (directory and name) of the file to download.- Returns:
- outputStream The content of the file to download.
- Throws:
ch.systemsx.cisd.base.exceptions.IOExceptionUnchecked- If the file does not exist, is a directory or cannot be opened.
-
getFileFromSessionWorkspace
public void getFileFromSessionWorkspace(java.lang.String filePath, java.io.File localFile) throws ch.systemsx.cisd.base.exceptions.IOExceptionUncheckedDescription copied from interface:IDssComponentDownloads a file from the session workspace.- Specified by:
getFileFromSessionWorkspacein interfaceIDssComponent- Parameters:
filePath- The path (directory and name) of the file to download.localFile- The local file to write the file from the session workspace to.- Throws:
ch.systemsx.cisd.base.exceptions.IOExceptionUnchecked- If the file does not exist.
-
deleteSessionWorkspaceFile
public boolean deleteSessionWorkspaceFile(java.lang.String path)
Description copied from interface:IDssComponentDelete a file or directory in the session workspace.- Specified by:
deleteSessionWorkspaceFilein interfaceIDssComponent- Returns:
trueif the path doesn't exist anymore.
-
validateDataSet
public java.util.List<ValidationError> validateDataSet(NewDataSetDTO newDataset, java.io.File dataSetFile) throws java.lang.IllegalStateException, EnvironmentFailureException
Description copied from interface:IDssComponentValidate a data set.- Specified by:
validateDataSetin interfaceIDssComponent- Parameters:
newDataset- The new data set that should be registereddataSetFile- A file or folder containing the data- Returns:
- A list of validation errors. The list is empty if there were no validation errors.
- Throws:
java.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.
-
extractMetadata
public java.util.Map<java.lang.String,java.lang.String> extractMetadata(NewDataSetDTO newDataset, java.io.File dataSetFile) throws java.lang.IllegalStateException, EnvironmentFailureException
Description copied from interface:IDssComponentTries to extract the data set property key-values (metadata) from the data. The extracted metadata can be used by clients to minimize the input needed when uploading data sets.- Specified by:
extractMetadatain interfaceIDssComponent- Parameters:
newDataset- The new data set that should be registereddataSetFile- A file or folder containing the data- Returns:
- A map of extracted property-key values
- Throws:
java.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.
-
-