Class 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.

    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method 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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, 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.
      • 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.
      • putFileToSessionWorkspace

        public void putFileToSessionWorkspace​(java.lang.String filePath,
                                              java.io.InputStream inputStream)
                                       throws ch.systemsx.cisd.base.exceptions.IOExceptionUnchecked
        Description copied from interface: IDssComponent
        Uploads a file to the session workspace.
        Specified by:
        putFileToSessionWorkspace in interface IDssComponent
        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.IOExceptionUnchecked
        Description copied from interface: IDssComponent
        Uploads a file to the session workspace.
        Specified by:
        putFileToSessionWorkspace in interface IDssComponent
        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.IOExceptionUnchecked
        Description copied from interface: IDssComponent
        Downloads a file from the session workspace.
        Specified by:
        getFileFromSessionWorkspace in interface IDssComponent
        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.IOExceptionUnchecked
        Description copied from interface: IDssComponent
        Downloads a file from the session workspace.
        Specified by:
        getFileFromSessionWorkspace in interface IDssComponent
        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: IDssComponent
        Delete a file or directory in the session workspace.
        Specified by:
        deleteSessionWorkspaceFile in interface IDssComponent
        Returns:
        true if 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: 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.