|
From: <kc...@us...> - 2003-06-13 06:44:41
|
Update of /cvsroot/ebxmlms/ebxmlms/src/hk/hku/cecid/phoenix/message/packaging
In directory sc8-pr-cvs1:/tmp/cvs-serv7418/packaging
Modified Files:
PayloadContainer.java
Log Message:
1. make the constructor public, so that it is callable from MessageServer
2. add a method to get the content length of the payload size if the payload
container is created from an AttachmentDataSource. Please note that the
content length is raw size, which does not take the content transfer
encoding into account, if any.
Index: PayloadContainer.java
===================================================================
RCS file: /cvsroot/ebxmlms/ebxmlms/src/hk/hku/cecid/phoenix/message/packaging/PayloadContainer.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -C2 -d -r1.8 -r1.9
*** PayloadContainer.java 10 Jun 2003 02:22:49 -0000 1.8
--- PayloadContainer.java 13 Jun 2003 06:44:37 -0000 1.9
***************
*** 72,75 ****
--- 72,76 ----
import javax.xml.soap.SOAPException;
import javax.activation.DataHandler;
+ import javax.activation.DataSource;
/**
***************
*** 128,132 ****
* <code>AttachmentPart</code>.
*/
! PayloadContainer(AttachmentPart attachmentPart, String contentId,
Reference reference) {
this.attachmentPart = attachmentPart;
--- 129,133 ----
* <code>AttachmentPart</code>.
*/
! public PayloadContainer(AttachmentPart attachmentPart, String contentId,
Reference reference) {
this.attachmentPart = attachmentPart;
***************
*** 190,193 ****
--- 191,214 ----
public Reference getReference() {
return reference;
+ }
+
+ /**
+ * Get the content length of this payload
+ * @return content length of this payload
+ */
+ 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;
+ }
}
}
|