Package org.apache.axis.attachments
Class AttachmentsImpl
- java.lang.Object
-
- org.apache.axis.attachments.AttachmentsImpl
-
- All Implemented Interfaces:
java.io.Serializable,Attachments
public class AttachmentsImpl extends java.lang.Object implements Attachments
Implements the Attachment interface, via an actual Hashmap of actual AttachmentParts.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected java.lang.StringcontentLocationThis is the content location as specified in SOAP with Attachments.protected static org.apache.commons.logging.Loglogprotected MultiPartInputStreammpartStreamThe actual stream to manage the multi-related input stream.protected intsendtypeThe form of the attachments, whether MIME or DIME.protected SOAPPartsoapPartField soapPart.-
Fields inherited from interface org.apache.axis.attachments.Attachments
CIDprefix, SEND_TYPE_DEFAULT, SEND_TYPE_DIME, SEND_TYPE_MAX, SEND_TYPE_MIME, SEND_TYPE_MTOM, SEND_TYPE_NONE, SEND_TYPE_NOTSET
-
-
Constructor Summary
Constructors Constructor Description AttachmentsImpl(java.lang.Object intialContents, java.lang.String contentType, java.lang.String contentLocation)Construct one of these on a parent Message.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description PartaddAttachmentPart(Part newPart)Adds an existing attachment to this list.PartcreateAttachmentPart()Create a new attachment Part in this Message.PartcreateAttachmentPart(java.lang.Object datahandler)Create a new attachment Part in this Message.protected DimeMultiPartcreateDimeMessage()Creates the DIME messagevoiddispose()dispose of the attachments and their files; do not use the object after making this call.PartgetAttachmentByReference(java.lang.String reference)This method should look at a refernce and determine if it is a CID: or url to look for attachment.intgetAttachmentCount()This is the number of attachments.java.util.CollectiongetAttachments()This method will return all attachments as a collection.java.util.IteratorgetAttachments(MimeHeaders headers)Retrieves all theAttachmentPartobjects that have header entries that match the specified headers.longgetContentLength()Get the content length of the stream.java.lang.StringgetContentType()Gets the content type for the whole stream.IncomingAttachmentStreamsgetIncomingAttachmentStreams()Once this method is called, attachments can only be accessed via the InputStreams.PartgetRootPart()From the complex stream return the root part.intgetSendType()Determine if an object is to be treated as an attchment.static intgetSendType(java.lang.String value)Determine how an object typically sent as attachments are to be represented.static java.lang.StringgetSendTypeString(int value)For a given sendType value, return a string representation.booleanisAttachment(java.lang.Object value)Determine if an object is to be treated as an attchment.voidremoveAllAttachments()Removes allAttachmentPartobjects that have been added to thisSOAPMessageobject.PartremoveAttachmentPart(java.lang.String reference)This method uses getAttacmentByReference() to look for attachment.voidsetAttachmentParts(java.util.Collection parts)Add the collection of parts.voidsetRootPart(Part newRoot)Sets the root part of this multipart blockvoidsetSendType(int sendtype)Set the format for attachments.voidwriteContentToStream(java.io.OutputStream os)Write the content to the stream.
-
-
-
Field Detail
-
log
protected static org.apache.commons.logging.Log log
-
soapPart
protected SOAPPart soapPart
Field soapPart.
-
mpartStream
protected MultiPartInputStream mpartStream
The actual stream to manage the multi-related input stream.
-
sendtype
protected int sendtype
The form of the attachments, whether MIME or DIME.
-
contentLocation
protected java.lang.String contentLocation
This is the content location as specified in SOAP with Attachments. This maybe null if the message had no Content-Location specifed.
-
-
Constructor Detail
-
AttachmentsImpl
public AttachmentsImpl(java.lang.Object intialContents, java.lang.String contentType, java.lang.String contentLocation) throws AxisFaultConstruct one of these on a parent Message. Should only ever be called by Message constructor!- Parameters:
intialContents- should be anything but today only a stream is supported.contentType- The mime content type of the stream for transports that provide it.contentLocation-- Throws:
AxisFault
-
-
Method Detail
-
removeAttachmentPart
public Part removeAttachmentPart(java.lang.String reference) throws AxisFault
This method uses getAttacmentByReference() to look for attachment. If attachment has been found, it will be removed from the list, and returned to the user.- Specified by:
removeAttachmentPartin interfaceAttachments- Parameters:
reference- The reference that referers to an attachment.- Returns:
- The part associated with the removed attachment, or null.
- Throws:
AxisFault
-
addAttachmentPart
public Part addAttachmentPart(Part newPart) throws AxisFault
Adds an existing attachment to this list. Note: Passed part will be bound to this message.- Specified by:
addAttachmentPartin interfaceAttachments- Parameters:
newPart- new part to add- Returns:
- Part old attachment with the same Content-ID, or null.
- Throws:
AxisFault
-
createAttachmentPart
public Part createAttachmentPart(java.lang.Object datahandler) throws AxisFault
Description copied from interface:AttachmentsCreate a new attachment Part in this Message. Will actually, and always, return an AttachmentPart.- Specified by:
createAttachmentPartin interfaceAttachments- Parameters:
datahandler- The part that is referenced- Returns:
- a new attachment part
- Throws:
AxisFault
-
setAttachmentParts
public void setAttachmentParts(java.util.Collection parts) throws AxisFaultAdd the collection of parts.- Specified by:
setAttachmentPartsin interfaceAttachments- Parameters:
parts-- Throws:
AxisFault
-
getAttachmentByReference
public Part getAttachmentByReference(java.lang.String reference) throws AxisFault
This method should look at a refernce and determine if it is a CID: or url to look for attachment.
Note: if Content-Id or Content-Location headers have changed by outside code, lookup will not return proper values. In order to change these values attachment should be removed, then added again.- Specified by:
getAttachmentByReferencein interfaceAttachments- Parameters:
reference- The reference in the xml that referers to an attachment.- Returns:
- The part associated with the attachment.
- Throws:
AxisFault
-
getAttachments
public java.util.Collection getAttachments() throws AxisFaultThis method will return all attachments as a collection.- Specified by:
getAttachmentsin interfaceAttachments- Returns:
- A collection of attachments.
- Throws:
AxisFault
-
getRootPart
public Part getRootPart()
From the complex stream return the root part. Today this is SOAP.- Specified by:
getRootPartin interfaceAttachments- Returns:
- the root
Part
-
setRootPart
public void setRootPart(Part newRoot)
Description copied from interface:AttachmentsSets the root part of this multipart block- Specified by:
setRootPartin interfaceAttachments- Parameters:
newRoot- the new rootPart
-
getContentLength
public long getContentLength() throws AxisFaultGet the content length of the stream.- Specified by:
getContentLengthin interfaceAttachments- Returns:
- the content length of the stream
- Throws:
AxisFault
-
createDimeMessage
protected DimeMultiPart createDimeMessage() throws AxisFault
Creates the DIME message- Returns:
- a DIME part
- Throws:
AxisFault- if the part could not be built
-
writeContentToStream
public void writeContentToStream(java.io.OutputStream os) throws AxisFaultWrite the content to the stream.- Specified by:
writeContentToStreamin interfaceAttachments- Parameters:
os-- Throws:
AxisFault
-
getContentType
public java.lang.String getContentType() throws AxisFaultGets the content type for the whole stream.- Specified by:
getContentTypein interfaceAttachments- Returns:
- the content type for the whole stream
- Throws:
AxisFault
-
getAttachmentCount
public int getAttachmentCount()
This is the number of attachments.- Specified by:
getAttachmentCountin interfaceAttachments- Returns:
- the number of attachments
-
isAttachment
public boolean isAttachment(java.lang.Object value)
Determine if an object is to be treated as an attchment.- Specified by:
isAttachmentin interfaceAttachments- Parameters:
value- the value that is to be determined if its an attachment.- Returns:
- True if value should be treated as an attchment.
-
removeAllAttachments
public void removeAllAttachments()
Removes allAttachmentPartobjects that have been added to thisSOAPMessageobject.This method does not touch the SOAP part.
- Specified by:
removeAllAttachmentsin interfaceAttachments
-
getAttachments
public java.util.Iterator getAttachments(MimeHeaders headers)
Retrieves all theAttachmentPartobjects that have header entries that match the specified headers. Note that a returned attachment could have headers in addition to those specified.- Specified by:
getAttachmentsin interfaceAttachments- Parameters:
headers- aMimeHeadersobject containing the MIME headers for which to search- Returns:
- an iterator over all attachments that have a header that matches one of the given headers
-
createAttachmentPart
public Part createAttachmentPart() throws AxisFault
Create a new attachment Part in this Message. Will actually, and always, return an AttachmentPart.- Specified by:
createAttachmentPartin interfaceAttachments- Returns:
- a new attachment Part
- Throws:
AxisFault
-
setSendType
public void setSendType(int sendtype)
Description copied from interface:AttachmentsSet the format for attachments.- Specified by:
setSendTypein interfaceAttachments- Parameters:
sendtype- the format to send. SEND_TYPE_MIME for Multipart Releated Mail type attachments. SEND_TYPE_DIME for DIME type attachments.
-
getSendType
public int getSendType()
Description copied from interface:AttachmentsDetermine if an object is to be treated as an attchment.- Specified by:
getSendTypein interfaceAttachments- Returns:
- SEND_TYPE_MIME, SEND_TYPE_DIME, SEND_TYPE_NOTSET
-
dispose
public void dispose()
dispose of the attachments and their files; do not use the object after making this call.- Specified by:
disposein interfaceAttachments
-
getSendType
public static int getSendType(java.lang.String value)
Determine how an object typically sent as attachments are to be represented. Currently, MIME DIME and NONE are reccognised.- Parameters:
value- a String representing a sending type, treated in a case-insensetive manner- Returns:
- an
intsend type code
-
getSendTypeString
public static java.lang.String getSendTypeString(int value)
For a given sendType value, return a string representation.- Parameters:
value- a type code integer- Returns:
- a
Stringrepresentation ofvalue
-
getIncomingAttachmentStreams
public IncomingAttachmentStreams getIncomingAttachmentStreams()
Once this method is called, attachments can only be accessed via the InputStreams. Any other access to the attachments collection (e.g. via getAttachments()) is prohibited and will cause a IllegalStateException to be thrown.- Specified by:
getIncomingAttachmentStreamsin interfaceAttachments- Returns:
- All of the attachment streams.
-
-