public class FileSystemAttachmentService extends java.lang.Object implements AttachmentService
Constructor and Description |
---|
FileSystemAttachmentService(java.lang.String attachmentsDirectory)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
copy(java.lang.String jobId,
java.io.File destination)
Copy all the attachments for a job into the specified directory.
|
void |
copyAll(java.lang.String id,
java.nio.file.Path destination)
Copy all attachments associated with the given id into the provided destination.
|
void |
delete(java.lang.String jobId)
Delete the attachments for the given job.
|
void |
deleteAll(java.lang.String id)
Delete all the attachments that were associated with the given id.
|
void |
deleteAttachments(java.lang.String jobId)
Given the id of a job delete all the attachments that were saved for it.
|
void |
save(java.lang.String jobId,
java.lang.String filename,
java.io.InputStream content)
Save a given attachment for a job for later retrieval.
|
java.lang.String |
saveAll(java.util.Map<java.lang.String,java.io.InputStream> attachments)
Save all attachments for a given request.
|
java.util.Set<java.net.URI> |
saveAttachments(java.lang.String jobId,
java.util.Set<org.springframework.core.io.Resource> attachments)
Given the id of a job and the set of attachments associated with that job this API should save the attachments
somewhere that the agent can access as job dependencies once the job runs.
|
public FileSystemAttachmentService(java.lang.String attachmentsDirectory)
attachmentsDirectory
- The directory to use or null if want to default to system temp directorypublic void save(java.lang.String jobId, java.lang.String filename, java.io.InputStream content) throws GenieException
save
in interface AttachmentService
jobId
- The id of the job to save the attachment forfilename
- The name of the attachmentcontent
- A stream to access the contents of the attachmentGenieException
- For any error during the save processpublic void copy(java.lang.String jobId, java.io.File destination) throws GenieException
copy
in interface AttachmentService
jobId
- The id of the job to get the attachments for.destination
- The directory to copy the attachments intoGenieException
- For any error during the copy processpublic void delete(java.lang.String jobId) throws GenieException
delete
in interface AttachmentService
jobId
- The id of the job to delete the attachments forGenieException
- For any error during the delete processpublic java.lang.String saveAll(java.util.Map<java.lang.String,java.io.InputStream> attachments) throws java.io.IOException
saveAll
in interface AttachmentService
attachments
- The map of filename to contents for all attachments. All input streams will be closed after
this method returnsjava.io.IOException
- If unable to save any of the attachmentspublic void copyAll(java.lang.String id, java.nio.file.Path destination) throws java.io.IOException
copyAll
in interface AttachmentService
id
- The id that was returned from the original call to AttachmentService.saveAll(Map)
destination
- The destination where the attachments should be copied. Must be a directory if it already
exists. If it doesn't exist it will be created.java.io.IOException
- If the copy fails for any reasonpublic void deleteAll(java.lang.String id) throws java.io.IOException
deleteAll
in interface AttachmentService
id
- The id that was returned from the original call to AttachmentService.saveAll(Map)
java.io.IOException
- On error during deletionpublic java.util.Set<java.net.URI> saveAttachments(java.lang.String jobId, java.util.Set<org.springframework.core.io.Resource> attachments) throws SaveAttachmentException
saveAttachments
in interface AttachmentService
jobId
- The id of the job these attachments are forattachments
- The attachments sent by the userURI
where the attachments were savedSaveAttachmentException
- on error when an attachment is attempted to be saved to the underlying storagepublic void deleteAttachments(java.lang.String jobId) throws java.io.IOException
deleteAttachments
in interface AttachmentService
jobId
- The id of the job to delete attachments forjava.io.IOException
- on error while deleting the attachments