|
From: <cy...@us...> - 2003-07-31 06:56:02
|
Update of /cvsroot/ebxmlms/ebxmlms/src/hk/hku/cecid/phoenix/message/packaging
In directory sc8-pr-cvs1:/tmp/cvs-serv11313
Modified Files:
EbxmlMessage.java PayloadContainer.java
Log Message:
Remove SAAJ's AttachmentPart from PayloadContainer. Now, PayloadContainer
encapsulates a DataHandler directly and it also supports MIME headers
other than Content-Type and Content-ID.
Index: EbxmlMessage.java
===================================================================
RCS file: /cvsroot/ebxmlms/ebxmlms/src/hk/hku/cecid/phoenix/message/packaging/EbxmlMessage.java,v
retrieving revision 1.34
retrieving revision 1.35
diff -C2 -d -r1.34 -r1.35
*** EbxmlMessage.java 31 Jul 2003 05:58:54 -0000 1.34
--- EbxmlMessage.java 31 Jul 2003 06:55:59 -0000 1.35
***************
*** 265,269 ****
if (cidMap.containsKey(contentId)) {
payloadContainers.add(new PayloadContainer
! (attachment, attachment.getContentId(),
(Reference) cidMap.get(contentId)));
}
--- 265,269 ----
if (cidMap.containsKey(contentId)) {
payloadContainers.add(new PayloadContainer
! (attachment.getDataHandler(), contentId,
(Reference) cidMap.get(contentId)));
}
***************
*** 1007,1013 ****
}
- final AttachmentPart attachment = soapMessage.
- createAttachmentPart(dataHandler);
-
Manifest manifest = headerContainer.getManifest();
if (manifest == null) {
--- 1007,1010 ----
***************
*** 1022,1029 ****
if (needPatch) {
payload = new PayloadContainer
! (attachment, "<" + contentId + ">", reference);
}
else {
! payload = new PayloadContainer(attachment, contentId, reference);
}
payloadContainers.add(payload);
--- 1019,1026 ----
if (needPatch) {
payload = new PayloadContainer
! (dataHandler, "<" + contentId + ">", reference);
}
else {
! payload = new PayloadContainer(dataHandler, contentId, reference);
}
payloadContainers.add(payload);
Index: PayloadContainer.java
===================================================================
RCS file: /cvsroot/ebxmlms/ebxmlms/src/hk/hku/cecid/phoenix/message/packaging/PayloadContainer.java,v
retrieving revision 1.10
retrieving revision 1.11
diff -C2 -d -r1.10 -r1.11
*** PayloadContainer.java 13 Jun 2003 06:49:25 -0000 1.10
--- PayloadContainer.java 31 Jul 2003 06:55:59 -0000 1.11
***************
*** 69,74 ****
package hk.hku.cecid.phoenix.message.packaging;
! import javax.xml.soap.AttachmentPart;
! import javax.xml.soap.SOAPException;
import javax.activation.DataHandler;
import javax.activation.DataSource;
--- 69,75 ----
package hk.hku.cecid.phoenix.message.packaging;
! import hk.hku.cecid.phoenix.message.handler.Constants;
! import java.util.HashMap;
! import java.util.Map;
import javax.activation.DataHandler;
import javax.activation.DataSource;
***************
*** 109,116 ****
/**
! * SOAP <code>AttachmentPart</code> representing this
* <code>PayloadContainer</code>.
*/
! private final AttachmentPart attachmentPart;
/**
--- 110,117 ----
/**
! * <code>DataHandler</code> representing this
* <code>PayloadContainer</code>.
*/
! private final DataHandler dataHandler;
/**
***************
*** 120,156 ****
private final Reference reference;
! /**
! * Content-Id of this <code>PayloadContainer</code>.
*/
! private String contentId;
/**
* Create a <code>PayloadContainer</code> from the specified
! * <code>AttachmentPart</code>.
! */
! public PayloadContainer(AttachmentPart attachmentPart, String contentId,
! Reference reference) {
! this.attachmentPart = attachmentPart;
! this.attachmentPart.setContentId(contentId);
this.reference = reference;
! this.contentId = contentId;
! if (this.contentId.startsWith("<") && EbxmlMessage.needPatch) {
! this.contentId = this.contentId.substring(1);
! if (this.contentId.endsWith(">")) {
! this.contentId = this.contentId.substring
! (0, this.contentId.length() - 1);
}
}
! }
!
! /**
! * Return the <code>AttachmentPart</code> that this
! * <code>PayloadContainer</code> encapsulates.
! *
! * @deprecated use other methods such as getDataHandler(), etc. to
! * get information of this <code>PayloadContainer</code>.
! */
! public AttachmentPart getAttachmentPart() {
! return attachmentPart;
}
--- 121,147 ----
private final Reference reference;
! /*
! * MIME headers of this <code>PayloadContainer</code>.
*/
! private final HashMap mimeHeaders;
/**
* Create a <code>PayloadContainer</code> from the specified
! * <code>DataHandler</code>.
! */
! public PayloadContainer(DataHandler dataHandler, String contentId,
! Reference reference) {
! this.dataHandler = dataHandler;
this.reference = reference;
! this.mimeHeaders = new HashMap();
! String id = contentId;
! if (id != null && id.startsWith("<") && EbxmlMessage.needPatch) {
! id = id.substring(1);
! if (id.endsWith(">")) {
! id = id.substring(0, id.length() - 1);
}
}
! mimeHeaders.put(Constants.CONTENT_TYPE, dataHandler.getContentType());
! mimeHeaders.put(Constants.CONTENT_ID, id);
}
***************
*** 159,163 ****
*/
public String getContentId() {
! return contentId;
}
--- 150,154 ----
*/
public String getContentId() {
! return (String) mimeHeaders.get(Constants.CONTENT_ID);
}
***************
*** 166,170 ****
*/
public String getHref() {
! return HREF_PREFIX + contentId;
}
--- 157,161 ----
*/
public String getHref() {
! return HREF_PREFIX + getContentId();
}
***************
*** 173,186 ****
*/
public String getContentType() {
! return attachmentPart.getContentType();
}
/**
* Get <code>javax.activation.DataHandler</code> of this attachment.
- *
- * @exception SOAPException
*/
! public DataHandler getDataHandler() throws SOAPException {
! return attachmentPart.getDataHandler();
}
--- 164,191 ----
*/
public String getContentType() {
! return dataHandler.getContentType();
! }
!
! /*
! * Get all MIME headers of this attachment.
! */
! public Map getMimeHeaders() {
! return mimeHeaders;
! }
!
! /*
! * Set a MIME header of this attachment.
! */
! public void setMimeHeader(String name, String value) {
! if (name != null) {
! mimeHeaders.put(name, value);
! }
}
/**
* Get <code>javax.activation.DataHandler</code> of this attachment.
*/
! public DataHandler getDataHandler() {
! return dataHandler;
}
***************
*** 202,216 ****
*/
public long getContentLength() {
! try {
! DataSource source = attachmentPart.getDataHandler().getDataSource();
! if (source instanceof AttachmentDataSource) {
! AttachmentDataSource ads = (AttachmentDataSource) source;
! return ads.getLength();
! }
! else {
! return -1;
! }
}
! catch (SOAPException e) {
return -1;
}
--- 207,216 ----
*/
public long getContentLength() {
! DataSource source = dataHandler.getDataSource();
! if (source instanceof AttachmentDataSource) {
! AttachmentDataSource ads = (AttachmentDataSource) source;
! return ads.getLength();
}
! else {
return -1;
}
|