70 Logger.getLogger(LogDomainConstants.SOAP_DOMAIN,
71 "com.sun.xml.internal.messaging.saaj.soap.LocalStrings");
72
73 protected static final int PLAIN_XML_FLAG = 1; // 00001
74 protected static final int MIME_MULTIPART_FLAG = 2; // 00010
75 protected static final int SOAP1_1_FLAG = 4; // 00100
76 protected static final int SOAP1_2_FLAG = 8; // 01000
77 //protected static final int MIME_MULTIPART_XOP_FLAG = 14; // 01110
78 protected static final int MIME_MULTIPART_XOP_SOAP1_1_FLAG = 6; // 00110
79 protected static final int MIME_MULTIPART_XOP_SOAP1_2_FLAG = 10; // 01010
80 protected static final int XOP_FLAG = 13; // 01101
81 protected static final int FI_ENCODED_FLAG = 16; // 10000
82
83 protected MimeHeaders headers;
84 protected ContentType contentType;
85 protected SOAPPartImpl soapPartImpl;
86 protected FinalArrayList<AttachmentPart> attachments;
87 protected boolean saved = false;
88 protected byte[] messageBytes;
89 protected int messageByteCount;
90 protected HashMap properties = new HashMap();
91
92 // used for lazy attachment initialization
93 protected MimeMultipart multiPart = null;
94 protected boolean attachmentsInitialized = false;
95
96 /**
97 * True if this part is encoded using Fast Infoset.
98 * MIME -> application/fastinfoset
99 */
100 protected boolean isFastInfoset = false;
101
102 /**
103 * True if the Accept header of this message includes
104 * application/fastinfoset
105 */
106 protected boolean acceptFastInfoset = false;
107
108 protected MimeMultipart mmp = null;
109
110 // if attachments are present, don't read the entire message in byte stream in saveTo()
866 public int countAttachments() {
867 try {
868 initializeAllAttachments();
869 } catch (Exception e) {
870 throw new RuntimeException(e);
871 }
872 if (attachments != null)
873 return attachments.size();
874 return 0;
875 }
876
877 @Override
878 public void addAttachmentPart(AttachmentPart attachment) {
879 try {
880 initializeAllAttachments();
881 this.optimizeAttachmentProcessing = true;
882 } catch (Exception e) {
883 throw new RuntimeException(e);
884 }
885 if (attachments == null)
886 attachments = new FinalArrayList<AttachmentPart>();
887
888 attachments.add(attachment);
889
890 needsSave();
891 }
892
893 static private final Iterator nullIter = Collections.EMPTY_LIST.iterator();
894
895 @Override
896 public Iterator getAttachments() {
897 try {
898 initializeAllAttachments();
899 } catch (Exception e) {
900 throw new RuntimeException(e);
901 }
902 if (attachments == null)
903 return nullIter;
904 return attachments.iterator();
905 }
906
907 private void setFinalContentType(String charset) {
908 ContentType ct = contentType();
909 if (ct == null) {
910 ct = new ContentType();
911 }
912 String[] split = getExpectedContentType().split("/");
913 ct.setPrimaryType(split[0]);
914 ct.setSubType(split[1]);
915 ct.setParameter("charset", charset);
916 headers.setHeader("Content-Type", ct.toString());
946
947 return null;
948 }
949
950 AttachmentPart nextMatch() {
951 while (iter.hasNext()) {
952 AttachmentPartImpl ap = (AttachmentPartImpl) iter.next();
953 if (ap.hasAllHeaders(headers))
954 return ap;
955 }
956 return null;
957 }
958
959 @Override
960 public void remove() {
961 iter.remove();
962 }
963 }
964
965 @Override
966 public Iterator getAttachments(MimeHeaders headers) {
967 try {
968 initializeAllAttachments();
969 } catch (Exception e) {
970 throw new RuntimeException(e);
971 }
972 if (attachments == null)
973 return nullIter;
974
975 return new MimeMatchingIterator(headers);
976 }
977
978 @Override
979 public void removeAttachments(MimeHeaders headers) {
980 try {
981 initializeAllAttachments();
982 } catch (Exception e) {
983 throw new RuntimeException(e);
984 }
985 if (attachments == null)
986 return ;
|
70 Logger.getLogger(LogDomainConstants.SOAP_DOMAIN,
71 "com.sun.xml.internal.messaging.saaj.soap.LocalStrings");
72
73 protected static final int PLAIN_XML_FLAG = 1; // 00001
74 protected static final int MIME_MULTIPART_FLAG = 2; // 00010
75 protected static final int SOAP1_1_FLAG = 4; // 00100
76 protected static final int SOAP1_2_FLAG = 8; // 01000
77 //protected static final int MIME_MULTIPART_XOP_FLAG = 14; // 01110
78 protected static final int MIME_MULTIPART_XOP_SOAP1_1_FLAG = 6; // 00110
79 protected static final int MIME_MULTIPART_XOP_SOAP1_2_FLAG = 10; // 01010
80 protected static final int XOP_FLAG = 13; // 01101
81 protected static final int FI_ENCODED_FLAG = 16; // 10000
82
83 protected MimeHeaders headers;
84 protected ContentType contentType;
85 protected SOAPPartImpl soapPartImpl;
86 protected FinalArrayList<AttachmentPart> attachments;
87 protected boolean saved = false;
88 protected byte[] messageBytes;
89 protected int messageByteCount;
90 protected Map<String, Object> properties = new HashMap<>();
91
92 // used for lazy attachment initialization
93 protected MimeMultipart multiPart = null;
94 protected boolean attachmentsInitialized = false;
95
96 /**
97 * True if this part is encoded using Fast Infoset.
98 * MIME -> application/fastinfoset
99 */
100 protected boolean isFastInfoset = false;
101
102 /**
103 * True if the Accept header of this message includes
104 * application/fastinfoset
105 */
106 protected boolean acceptFastInfoset = false;
107
108 protected MimeMultipart mmp = null;
109
110 // if attachments are present, don't read the entire message in byte stream in saveTo()
866 public int countAttachments() {
867 try {
868 initializeAllAttachments();
869 } catch (Exception e) {
870 throw new RuntimeException(e);
871 }
872 if (attachments != null)
873 return attachments.size();
874 return 0;
875 }
876
877 @Override
878 public void addAttachmentPart(AttachmentPart attachment) {
879 try {
880 initializeAllAttachments();
881 this.optimizeAttachmentProcessing = true;
882 } catch (Exception e) {
883 throw new RuntimeException(e);
884 }
885 if (attachments == null)
886 attachments = new FinalArrayList<>();
887
888 attachments.add(attachment);
889
890 needsSave();
891 }
892
893 static private final Iterator<AttachmentPart> nullIter = Collections.<AttachmentPart>EMPTY_LIST.iterator();
894
895 @Override
896 public Iterator<AttachmentPart> getAttachments() {
897 try {
898 initializeAllAttachments();
899 } catch (Exception e) {
900 throw new RuntimeException(e);
901 }
902 if (attachments == null)
903 return nullIter;
904 return attachments.iterator();
905 }
906
907 private void setFinalContentType(String charset) {
908 ContentType ct = contentType();
909 if (ct == null) {
910 ct = new ContentType();
911 }
912 String[] split = getExpectedContentType().split("/");
913 ct.setPrimaryType(split[0]);
914 ct.setSubType(split[1]);
915 ct.setParameter("charset", charset);
916 headers.setHeader("Content-Type", ct.toString());
946
947 return null;
948 }
949
950 AttachmentPart nextMatch() {
951 while (iter.hasNext()) {
952 AttachmentPartImpl ap = (AttachmentPartImpl) iter.next();
953 if (ap.hasAllHeaders(headers))
954 return ap;
955 }
956 return null;
957 }
958
959 @Override
960 public void remove() {
961 iter.remove();
962 }
963 }
964
965 @Override
966 public Iterator<AttachmentPart> getAttachments(MimeHeaders headers) {
967 try {
968 initializeAllAttachments();
969 } catch (Exception e) {
970 throw new RuntimeException(e);
971 }
972 if (attachments == null)
973 return nullIter;
974
975 return new MimeMatchingIterator(headers);
976 }
977
978 @Override
979 public void removeAttachments(MimeHeaders headers) {
980 try {
981 initializeAllAttachments();
982 } catch (Exception e) {
983 throw new RuntimeException(e);
984 }
985 if (attachments == null)
986 return ;
|