T
- the type of ERAttachment that this processor processespublic abstract class ERAttachmentProcessor<T extends ERAttachment> extends Object
ERAttachmentProcessors provide the implementation of the communication with the attachment storage method, including import, URL generation, and stream generation.
ERAttachmentProcessors also provide support for path template variables. Read the er.attachment package.html for more information.
Name | Description |
---|---|
er.attachment.maxSize | the maximum size of an uploaded attachment |
er.attachment.[configurationName].maxSize | the maximum size of an uploaded attachment |
er.attachment.[configurationName].storageType | er.attachment.[configurationName].storageType |
er.attachment.storageType | er.attachment.storageType |
er.attachment.[configurationName].proxyAsAttachment | er.attachment.[configurationName].proxyAsAttachment |
er.attachment.proxyAsAttachment | er.attachment.proxyAsAttachment |
Modifier and Type | Class and Description |
---|---|
static class |
ERAttachmentProcessor.ERXAttachmentExceedsLengthException
ERXAttachmentExceedsLengthException thrown when an attachment exceeds the maximum attachment size.
|
Constructor and Description |
---|
ERAttachmentProcessor() |
Modifier and Type | Method and Description |
---|---|
protected static String |
_parsePathTemplate(ERAttachment attachment,
String templatePath,
String recommendedFileName)
Parses a path template with ${ext}, ${fileName}, ${hash}, ${uuid}, and ${pk} variables in it.
|
abstract T |
_process(com.webobjects.eocontrol.EOEditingContext editingContext,
File uploadedFile,
String recommendedFileName,
String mimeType,
String configurationName,
String ownerID,
boolean pendingDelete)
Processes an uploaded file, imports it into the appropriate data store, and returns an ERAttachment that
represents it.
|
static void |
addAttachmentProcessorForType(ERAttachmentProcessor<?> processor,
String storageType)
Adds a new attachment processor for the given storage type.
|
abstract InputStream |
attachmentInputStream(T attachment)
Returns an InputStream to the data of the given attachment.
|
void |
attachmentInserted(T attachment)
Called after an attachment has been inserted (from didInsert).
|
abstract String |
attachmentUrl(T attachment,
com.webobjects.appserver.WORequest request,
com.webobjects.appserver.WOContext context)
Returns a URL to the attachment's data.
|
IERAttachmentProcessorDelegate |
delegate()
Returns the attachment processor delegate for this processor.
|
abstract void |
deleteAttachment(T attachment)
Deletes the attachment from the data store.
|
T |
process(com.webobjects.eocontrol.EOEditingContext editingContext,
ERPendingAttachment pendingAttachment)
Processes an uploaded file, imports it into the appropriate data store, and returns an ERAttachment that
represents it.
|
T |
process(com.webobjects.eocontrol.EOEditingContext editingContext,
File uploadedFile)
Processes an uploaded file, imports it into the appropriate data store, and returns an ERAttachment that
represents it.
|
T |
process(com.webobjects.eocontrol.EOEditingContext editingContext,
File uploadedFile,
String recommendedFilePath)
Processes an uploaded file, imports it into the appropriate data store, and returns an ERAttachment that
represents it.
|
T |
process(com.webobjects.eocontrol.EOEditingContext editingContext,
File uploadedFile,
String recommendedFilePath,
String mimeType)
Processes an uploaded file, imports it into the appropriate data store, and returns an ERAttachment that
represents it.
|
T |
process(com.webobjects.eocontrol.EOEditingContext editingContext,
File uploadedFile,
String recommendedFilePath,
String mimeType,
int width,
int height,
String configurationName,
String ownerID)
Processes an uploaded file, imports it into the appropriate data store, and returns an ERAttachment that
represents it.
|
T |
process(com.webobjects.eocontrol.EOEditingContext editingContext,
File uploadedFile,
String recommendedFilePath,
String mimeType,
String configurationName,
String ownerID)
Processes an uploaded file, imports it into the appropriate data store, and returns an ERAttachment that
represents it.
|
static <P extends ERAttachmentProcessor<T>,T extends ERAttachment> |
processorForConfigurationName(String configurationName)
Returns the processor that corresponds to the given configuration name ("s3", "db", "file", etc).
|
static <P extends ERAttachmentProcessor<T>,T extends ERAttachment> |
processorForType(String storageType)
Returns the processor that corresponds to the given storage type ("s3", "db", "file", etc).
|
static <P extends ERAttachmentProcessor<T>,T extends ERAttachment> |
processorForType(T attachment)
Returns the processor that corresponds to the given attachment.
|
static NSMutableDictionary<String,ERAttachmentProcessor<?>> |
processors()
Returns all of the processors mapped by storageType.
|
protected String |
proxiedUrl(T attachment,
com.webobjects.appserver.WOContext context)
Returns a URL to the given attachment that routes via the ERAttachmentRequestHandler.
|
boolean |
proxyAsAttachment(T attachment)
Returns whether or not the proxy request handler should return this as an attachment
with a Content-Disposition.
|
void |
setDelegate(IERAttachmentProcessorDelegate delegate)
Sets the attachment processor delegate for this processor.
|
public static final Logger log
public static NSMutableDictionary<String,ERAttachmentProcessor<?>> processors()
public static <P extends ERAttachmentProcessor<T>,T extends ERAttachment> P processorForType(T attachment)
T
- the attachment typeattachment
- the attachment to lookup a processor forpublic static <P extends ERAttachmentProcessor<T>,T extends ERAttachment> P processorForType(String storageType)
T
- the attachment typestorageType
- the type of processor to lookuppublic static <P extends ERAttachmentProcessor<T>,T extends ERAttachment> P processorForConfigurationName(String configurationName)
T
- the attachment typeconfigurationName
- the configuration name to use to lookup the default storage typepublic static void addAttachmentProcessorForType(ERAttachmentProcessor<?> processor, String storageType)
processor
- the processorstorageType
- the storage type that corresponds to the processorprotected static String _parsePathTemplate(ERAttachment attachment, String templatePath, String recommendedFileName)
attachment
- the attachment being processedtemplatePath
- the template path definitionrecommendedFileName
- the original file name recommended by the uploading userpublic void setDelegate(IERAttachmentProcessorDelegate delegate)
delegate
- the attachment processor delegate for this processorpublic IERAttachmentProcessorDelegate delegate()
protected String proxiedUrl(T attachment, com.webobjects.appserver.WOContext context)
attachment
- the attachment to proxycontext
- the contextpublic T process(com.webobjects.eocontrol.EOEditingContext editingContext, File uploadedFile) throws IOException
editingContext
- the EOEditingContext to create the ERAttachment inuploadedFile
- the file to attach (which will NOT be deleted at the end)IOException
- if the processing failspublic T process(com.webobjects.eocontrol.EOEditingContext editingContext, File uploadedFile, String recommendedFilePath) throws IOException
editingContext
- the EOEditingContext to create the ERAttachment inuploadedFile
- the uploaded temporary file (which will be deleted at the end)recommendedFilePath
- the filename recommended by the user during importIOException
- if the processing failspublic T process(com.webobjects.eocontrol.EOEditingContext editingContext, File uploadedFile, String recommendedFilePath, String mimeType) throws IOException
editingContext
- the EOEditingContext to create the ERAttachment inuploadedFile
- the uploaded temporary file (which will be deleted at the end)recommendedFilePath
- the filename recommended by the user during importmimeType
- the mimeType to use (null = guess based on file extension)IOException
- if the processing failspublic T process(com.webobjects.eocontrol.EOEditingContext editingContext, File uploadedFile, String recommendedFilePath, String mimeType, String configurationName, String ownerID) throws IOException
editingContext
- the EOEditingContext to create the ERAttachment inuploadedFile
- the uploaded temporary file (which will be deleted at the end)recommendedFilePath
- the filename recommended by the user during importmimeType
- the mimeType to use (null = guess based on file extension)configurationName
- the name of the configuration settings to use for this processor (see top level docs)ownerID
- an arbitrary string that represents the ID of the "owner" of this thumbnail (Person.primaryKey, for instance)IOException
- if the processing failspublic T process(com.webobjects.eocontrol.EOEditingContext editingContext, File uploadedFile, String recommendedFilePath, String mimeType, int width, int height, String configurationName, String ownerID) throws IOException
editingContext
- the EOEditingContext to create the ERAttachment inuploadedFile
- the uploaded temporary file (which will be deleted at the end)recommendedFilePath
- the filename recommended by the user during importmimeType
- the mimeType to use (null = guess based on file extension)configurationName
- the name of the configuration settings to use for this processor (see top level docs)ownerID
- an arbitrary string that represents the ID of the "owner" of this thumbnail (Person.primaryKey, for instance)width
- the desired width of the attachmentheight
- the desired height of the attachmentIOException
- if the processing failspublic T process(com.webobjects.eocontrol.EOEditingContext editingContext, ERPendingAttachment pendingAttachment) throws IOException
editingContext
- the EOEditingContext to create the ERAttachment inpendingAttachment
- the ERPendingAttachment that encapsulates the import informationIOException
- if the processing failspublic void attachmentInserted(T attachment)
attachment
- the inserted attachmentpublic boolean proxyAsAttachment(T attachment)
public abstract T _process(com.webobjects.eocontrol.EOEditingContext editingContext, File uploadedFile, String recommendedFileName, String mimeType, String configurationName, String ownerID, boolean pendingDelete) throws IOException
editingContext
- the EOEditingContext to create the ERAttachment inuploadedFile
- the uploaded temporary file (which will be deleted at the end)recommendedFileName
- the filename recommended by the user during importmimeType
- the mimeType to use (null = guess based on file extension)configurationName
- the name of the configuration settings to use for this processor (see top level docs)ownerID
- an arbitrary string that represents the ID of the "owner" of this thumbnail (Person.primaryKey, for instance)pendingDelete
- if true, the uploadedFile will be deleted after import; if false, it will be left aloneIOException
- if the processing failspublic abstract InputStream attachmentInputStream(T attachment) throws IOException
attachment
- the attachment to retrieve the data forIOException
- if the stream cannot be createdpublic abstract String attachmentUrl(T attachment, com.webobjects.appserver.WORequest request, com.webobjects.appserver.WOContext context)
attachment
- the attachment to generate a URL forrequest
- the current requestcontext
- the current contextpublic abstract void deleteAttachment(T attachment) throws IOException
attachment
- the attachment to deleteIOException
- if the delete failsCopyright © 2002 – 2020 Project Wonder.