ch.systemsx.cisd.openbis.dss.client.api.v1.impl
Class DssComponent

java.lang.Object
  extended by 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
DssComponent(IGeneralInformationService service, IRpcServiceFactory dssServiceFactory, java.lang.String sessionTokenOrNull)
          Constructor for clients that already have an IETLLIMSService; also used for testing.
 
Method Summary
 void checkSession()
          Checks whether the session is alive.
 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.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.
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.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

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 name
password - The user's password
openBISUrl - The URL to openBIS
timeoutInMillis - 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 authentication
openBISUrl - The URL to openBIS
timeoutInMillis - network timeout when connecting to remote services

getSessionToken

public java.lang.String getSessionToken()
Description copied from interface: IDssComponent
Returns the session token.

Specified by:
getSessionToken in interface IDssComponent
Returns:
The session token for an authenticated user.

checkSession

public void checkSession()
                  throws InvalidSessionException
Description copied from interface: IDssComponent
Checks whether the session is alive.

Specified by:
checkSession in interface IDssComponent
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: IDssComponent
Get a proxy to the data set designated by the given data set code.

Specified by:
getDataSet in interface IDssComponent
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: IDssComponent
Logs the current user out.

Specified by:
logout in interface IDssComponent

putDataSet

public IDataSetDss putDataSet(NewDataSetDTO newDataset,
                              java.io.File dataSetFile)
                       throws java.lang.IllegalStateException,
                              EnvironmentFailureException
Description copied from interface: IDssComponent
Upload a new data set to the DSS.

Specified by:
putDataSet in interface IDssComponent
Parameters:
newDataset - The new data set that should be registered
dataSetFile - 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.

validateDataSet

public java.util.List<ValidationError> validateDataSet(NewDataSetDTO newDataset,
                                                       java.io.File dataSetFile)
                                                throws java.lang.IllegalStateException,
                                                       EnvironmentFailureException
Description copied from interface: IDssComponent
Validate a data set.

Specified by:
validateDataSet in interface IDssComponent
Parameters:
newDataset - The new data set that should be registered
dataSetFile - 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: IDssComponent
Tries 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:
extractMetadata in interface IDssComponent
Parameters:
newDataset - The new data set that should be registered
dataSetFile - 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.