Class RemoteResourceManager

  • All Implemented Interfaces:
    java.io.Closeable, java.lang.AutoCloseable, ResourceManager

    public class RemoteResourceManager
    extends AbstractRemoteClient
    implements ResourceManager
    This class provides an API to upload resources (compiled code of a keyword, etc) to the controller
    • Constructor Detail

      • RemoteResourceManager

        public RemoteResourceManager()
    • Method Detail

      • upload

        public ResourceUploadResponse upload​(java.io.File file)
        Upload the local file provided as argument to the controller
        Parameters:
        file - the local file to be uploaded
        Returns:
        the ResourceUploadResponse containing an handle to the uploaded file
      • upload

        public ResourceUploadResponse upload​(java.lang.String filename,
                                             java.io.InputStream stream)
        Upload the local file provided as argument to the controller
        Parameters:
        filename - the path to the local file to be uploaded
        Returns:
        the ResourceUploadResponse containing an handle to the uploaded file
      • upload

        protected ResourceUploadResponse upload​(org.glassfish.jersey.media.multipart.FormDataBodyPart bodyPart)
      • upload

        protected ResourceUploadResponse upload​(org.glassfish.jersey.media.multipart.FormDataBodyPart bodyPart,
                                                java.lang.String type,
                                                boolean checkForDuplicates)
      • download

        public step.grid.io.Attachment download​(java.lang.String resourceId)
        Download a resource based on its id
        Parameters:
        resourceId - the id of the resource to be downloaded
        Returns:
        the Response containing an handle to the uploaded file
      • createResource

        public Resource createResource​(java.lang.String resourceType,
                                       java.io.InputStream resourceStream,
                                       java.lang.String resourceFileName,
                                       boolean checkForDuplicates,
                                       ObjectEnricher objectEnricher)
                                throws java.io.IOException,
                                       SimilarResourceExistingException
        Specified by:
        createResource in interface ResourceManager
        Parameters:
        resourceType - the type of the resource
        resourceStream - the stream of the resource to be saved
        resourceFileName - the name of the resource (filename)
        checkForDuplicates - is duplicate should be checked
        objectEnricher - the ObjectEnricher of the context
        Returns:
        the created Resource
        Throws:
        java.io.IOException - an IOException occurs during the call
        SimilarResourceExistingException - a similar resource exist
      • saveResourceContent

        public Resource saveResourceContent​(java.lang.String resourceId,
                                            java.io.InputStream resourceStream,
                                            java.lang.String resourceFileName)
                                     throws java.io.IOException
        Description copied from interface: ResourceManager
        Save the content provided as stream to an existing resource. This creates a new ResourceRevision for the Resource and saves the content provided as stream under this revision.
        Specified by:
        saveResourceContent in interface ResourceManager
        Parameters:
        resourceId - the id of the resource to be updated
        resourceStream - the stream of the resource to be saved
        resourceFileName - the name of the resource (filename)
        Returns:
        the updated Resource
        Throws:
        java.io.IOException - an IOException occurs during the call
      • deleteResource

        public void deleteResource​(java.lang.String resourceId)
        Description copied from interface: ResourceManager
        Delete the resource and all its revisions
        Specified by:
        deleteResource in interface ResourceManager
        Parameters:
        resourceId - the id of the Resource to be deleted
      • getResourceContent

        public ResourceRevisionContent getResourceContent​(java.lang.String resourceId)
                                                   throws java.io.IOException
        Description copied from interface: ResourceManager
        Get the content of an existing Resource
        Specified by:
        getResourceContent in interface ResourceManager
        Parameters:
        resourceId - the id of the Resource to be deleted
        Returns:
        the content of the resource as stream
        Throws:
        java.io.IOException - an IOException occurs during the call
      • resourceExists

        public boolean resourceExists​(java.lang.String resourceId)
        Description copied from interface: ResourceManager
        Test if a given resource id exists
        Specified by:
        resourceExists in interface ResourceManager
        Parameters:
        resourceId - the id of the resource to test
        Returns:
        true if the resource exists
      • saveResource

        public Resource saveResource​(Resource resource)
                              throws java.io.IOException
        Description copied from interface: ResourceManager
        Saved the resource object only
        Specified by:
        saveResource in interface ResourceManager
        Parameters:
        resource - the resource to be saved
        Returns:
        the updated Resource
        Throws:
        java.io.IOException - an IOException occurs during the call