Package step.client.resources
Class RemoteResourceManager
- java.lang.Object
-
- step.client.AbstractRemoteClient
-
- step.client.resources.RemoteResourceManager
-
- All Implemented Interfaces:
Closeable,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(String resourceType, InputStream resourceStream, String resourceFileName, boolean checkForDuplicates, ObjectEnricher objectEnricher)ResourceRevisionContainercreateResourceContainer(String resourceType, String resourceFileName)voiddeleteResource(String resourceId)Delete the resource and all its revisionsstep.grid.io.Attachmentdownload(String resourceId)Download a resource based on its idResourcegetResource(String resourceId)ResourceRevisionContentgetResourceContent(String resourceId)Get the content of an existingResourceResourceRevisionFileHandlegetResourceFile(String resourceId)ResourceRevisiongetResourceRevisionByResourceId(String resourceId)ResourceRevisionContentImplgetResourceRevisionContent(String resourceRevisionId)ResourcelookupResourceByName(String resourcename)booleanresourceExists(String resourceId)Test if a given resource id existsResourcesaveResource(Resource resource)Saved the resource object onlyResourcesaveResourceContent(String resourceId, InputStream resourceStream, String resourceFileName)Save the content provided as stream to an existing resource.ResourceUploadResponseupload(File file)Upload the local file provided as argument to the controllerResourceUploadResponseupload(String filename, 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, 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(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(String filename, 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, String type, boolean checkForDuplicates)
-
download
public step.grid.io.Attachment download(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(String resourceType, InputStream resourceStream, String resourceFileName, boolean checkForDuplicates, ObjectEnricher objectEnricher) throws 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:
IOException- an IOException occurs during the callSimilarResourceExistingException- a similar resource exist
-
saveResourceContent
public Resource saveResourceContent(String resourceId, InputStream resourceStream, String resourceFileName) throws 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:
IOException- an IOException occurs during the call
-
deleteResource
public void deleteResource(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(String resourceId) throws 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:
IOException- an IOException occurs during the call
-
getResource
public Resource getResource(String resourceId)
- Specified by:
getResourcein interfaceResourceManager
-
getResourceFile
public ResourceRevisionFileHandle getResourceFile(String resourceId)
- Specified by:
getResourceFilein interfaceResourceManager
-
getResourceRevisionByResourceId
public ResourceRevision getResourceRevisionByResourceId(String resourceId)
- Specified by:
getResourceRevisionByResourceIdin interfaceResourceManager
-
getResourceRevisionContent
public ResourceRevisionContentImpl getResourceRevisionContent(String resourceRevisionId) throws IOException
- Specified by:
getResourceRevisionContentin interfaceResourceManager- Throws:
IOException
-
createResourceContainer
public ResourceRevisionContainer createResourceContainer(String resourceType, String resourceFileName) throws IOException
- Specified by:
createResourceContainerin interfaceResourceManager- Throws:
IOException
-
lookupResourceByName
public Resource lookupResourceByName(String resourcename)
- Specified by:
lookupResourceByNamein interfaceResourceManager
-
resourceExists
public boolean resourceExists(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 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:
IOException- an IOException occurs during the call
-
-