Package step.client.resources
Class RemoteResourceManager
- java.lang.Object
-
- step.client.AbstractRemoteClient
-
- step.client.resources.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
-
-
Field Summary
-
Fields inherited from class step.client.AbstractRemoteClient
client, cookies, credentials
-
Fields inherited from interface step.resources.ResourceManager
RESOURCE_TYPE_ATTACHMENT, RESOURCE_TYPE_DATASOURCE, RESOURCE_TYPE_FUNCTIONS, RESOURCE_TYPE_PDF_TEST_SCENARIO_FILE, RESOURCE_TYPE_SECRET, RESOURCE_TYPE_STAGING_CONTEXT_FILES, RESOURCE_TYPE_TEMP
-
-
Constructor Summary
Constructors Constructor Description RemoteResourceManager()RemoteResourceManager(ControllerCredentials credentials)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description ResourcecreateResource(java.lang.String resourceType, java.io.InputStream resourceStream, java.lang.String resourceFileName, boolean checkForDuplicates, ObjectEnricher objectEnricher)ResourceRevisionContainercreateResourceContainer(java.lang.String resourceType, java.lang.String resourceFileName)voiddeleteResource(java.lang.String resourceId)Delete the resource and all its revisionsstep.grid.io.Attachmentdownload(java.lang.String resourceId)Download a resource based on its idResourcegetResource(java.lang.String resourceId)ResourceRevisionContentgetResourceContent(java.lang.String resourceId)Get the content of an existingResourceResourceRevisionFileHandlegetResourceFile(java.lang.String resourceId)ResourceRevisiongetResourceRevisionByResourceId(java.lang.String resourceId)ResourceRevisionContentImplgetResourceRevisionContent(java.lang.String resourceRevisionId)java.lang.StringgetResourcesRootPath()ResourcelookupResourceByName(java.lang.String resourcename)booleanresourceExists(java.lang.String resourceId)Test if a given resource id existsResourcesaveResource(Resource resource)Saved the resource object onlyResourcesaveResourceContent(java.lang.String resourceId, java.io.InputStream resourceStream, java.lang.String resourceFileName)Save the content provided as stream to an existing resource.ResourceRevisionsaveResourceRevision(ResourceRevision resourceRevision)ResourceupdateResourceContent(Resource resource, java.io.InputStream resourceStream, java.lang.String resourceFileName, ResourceRevision revision)ResourceUploadResponseupload(java.io.File file)Upload the local file provided as argument to the controllerResourceUploadResponseupload(java.lang.String filename, java.io.InputStream stream)Upload the local file provided as argument to the controllerprotected ResourceUploadResponseupload(org.glassfish.jersey.media.multipart.FormDataBodyPart bodyPart)protected ResourceUploadResponseupload(org.glassfish.jersey.media.multipart.FormDataBodyPart bodyPart, java.lang.String type, boolean checkForDuplicates)-
Methods inherited from class step.client.AbstractRemoteClient
close, executeRequest, notImplemented, requestBuilder, requestBuilder
-
-
-
-
Constructor Detail
-
RemoteResourceManager
public RemoteResourceManager()
-
RemoteResourceManager
public RemoteResourceManager(ControllerCredentials credentials)
-
-
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
ResourceUploadResponsecontaining 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
ResourceUploadResponsecontaining 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
Responsecontaining 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:
createResourcein interfaceResourceManager- Parameters:
resourceType- the type of the resourceresourceStream- the stream of the resource to be savedresourceFileName- the name of the resource (filename)checkForDuplicates- is duplicate should be checkedobjectEnricher- theObjectEnricherof the context- Returns:
- the created
Resource - Throws:
java.io.IOException- an IOException occurs during the callSimilarResourceExistingException- 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:ResourceManagerSave the content provided as stream to an existing resource. This creates a newResourceRevisionfor theResourceand saves the content provided as stream under this revision.- Specified by:
saveResourceContentin interfaceResourceManager- Parameters:
resourceId- the id of the resource to be updatedresourceStream- the stream of the resource to be savedresourceFileName- 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:ResourceManagerDelete the resource and all its revisions- Specified by:
deleteResourcein interfaceResourceManager- Parameters:
resourceId- the id of theResourceto be deleted
-
getResourceContent
public ResourceRevisionContent getResourceContent(java.lang.String resourceId) throws java.io.IOException
Description copied from interface:ResourceManagerGet the content of an existingResource- Specified by:
getResourceContentin interfaceResourceManager- Parameters:
resourceId- the id of theResourceto be deleted- Returns:
- the content of the resource as stream
- Throws:
java.io.IOException- an IOException occurs during the call
-
getResource
public Resource getResource(java.lang.String resourceId)
- Specified by:
getResourcein interfaceResourceManager
-
getResourceFile
public ResourceRevisionFileHandle getResourceFile(java.lang.String resourceId)
- Specified by:
getResourceFilein interfaceResourceManager
-
getResourceRevisionByResourceId
public ResourceRevision getResourceRevisionByResourceId(java.lang.String resourceId)
- Specified by:
getResourceRevisionByResourceIdin interfaceResourceManager
-
getResourceRevisionContent
public ResourceRevisionContentImpl getResourceRevisionContent(java.lang.String resourceRevisionId) throws java.io.IOException
- Specified by:
getResourceRevisionContentin interfaceResourceManager- Throws:
java.io.IOException
-
createResourceContainer
public ResourceRevisionContainer createResourceContainer(java.lang.String resourceType, java.lang.String resourceFileName) throws java.io.IOException
- Specified by:
createResourceContainerin interfaceResourceManager- Throws:
java.io.IOException
-
lookupResourceByName
public Resource lookupResourceByName(java.lang.String resourcename)
- Specified by:
lookupResourceByNamein interfaceResourceManager
-
resourceExists
public boolean resourceExists(java.lang.String resourceId)
Description copied from interface:ResourceManagerTest if a given resource id exists- Specified by:
resourceExistsin interfaceResourceManager- 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:ResourceManagerSaved the resource object only- Specified by:
saveResourcein interfaceResourceManager- Parameters:
resource- the resource to be saved- Returns:
- the updated
Resource - Throws:
java.io.IOException- an IOException occurs during the call
-
getResourcesRootPath
public java.lang.String getResourcesRootPath()
- Specified by:
getResourcesRootPathin interfaceResourceManager
-
updateResourceContent
public Resource updateResourceContent(Resource resource, java.io.InputStream resourceStream, java.lang.String resourceFileName, ResourceRevision revision) throws java.io.IOException
- Specified by:
updateResourceContentin interfaceResourceManager- Throws:
java.io.IOException
-
saveResourceRevision
public ResourceRevision saveResourceRevision(ResourceRevision resourceRevision) throws java.io.IOException
- Specified by:
saveResourceRevisionin interfaceResourceManager- Throws:
java.io.IOException
-
-