You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by di...@apache.org on 2006/12/14 03:21:23 UTC
svn commit: r486934 -
/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/Builder.java
Author: dims
Date: Wed Dec 13 18:21:22 2006
New Revision: 486934
URL: http://svn.apache.org/viewvc?view=rev&rev=486934
Log:
split out creation of an attachment object into separate method
Modified:
webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/Builder.java
Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/Builder.java
URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/Builder.java?view=diff&rev=486934&r1=486933&r2=486934
==============================================================================
--- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/Builder.java (original)
+++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/util/Builder.java Wed Dec 13 18:21:22 2006
@@ -161,62 +161,10 @@
throws OMException, XMLStreamException, FactoryConfigurationError {
StAXBuilder builder = null;
- Object cacheAttachmentProperty = msgContext
- .getProperty(Constants.Configuration.CACHE_ATTACHMENTS);
- String cacheAttachmentString = null;
- boolean fileCacheForAttachments;
-
- if (cacheAttachmentProperty != null
- && cacheAttachmentProperty instanceof String) {
- cacheAttachmentString = (String) cacheAttachmentProperty;
- fileCacheForAttachments = (Constants.VALUE_TRUE
- .equals(cacheAttachmentString));
- } else {
- Parameter parameter_cache_attachment = msgContext
- .getParameter(Constants.Configuration.CACHE_ATTACHMENTS);
- cacheAttachmentString = (parameter_cache_attachment != null) ? (String) parameter_cache_attachment
- .getValue()
- : null;
- }
- fileCacheForAttachments = (Constants.VALUE_TRUE
- .equals(cacheAttachmentString));
-
- String attachmentRepoDir = null;
- String attachmentSizeThreshold = null;
-
- if (fileCacheForAttachments) {
- Object attachmentRepoDirProperty = msgContext
- .getProperty(Constants.Configuration.ATTACHMENT_TEMP_DIR);
-
- if (attachmentRepoDirProperty != null) {
- attachmentRepoDir = (String) attachmentRepoDirProperty;
- } else {
- Parameter attachmentRepoDirParameter = msgContext
- .getParameter(Constants.Configuration.ATTACHMENT_TEMP_DIR);
- attachmentRepoDir = (attachmentRepoDirParameter != null) ? (String) attachmentRepoDirParameter
- .getValue()
- : null;
- }
+ Attachments attachments = createAttachment(msgContext, inStream, contentTypeString);
+ String charSetEncoding = getCharSetEncoding(attachments.getSOAPPartContentType());
- Object attachmentSizeThresholdProperty = msgContext
- .getProperty(Constants.Configuration.FILE_SIZE_THRESHOLD);
- if (attachmentSizeThresholdProperty != null
- && attachmentSizeThresholdProperty instanceof String) {
- attachmentSizeThreshold = (String) attachmentSizeThresholdProperty;
- } else {
- Parameter attachmentSizeThresholdParameter = msgContext
- .getParameter(Constants.Configuration.FILE_SIZE_THRESHOLD);
- attachmentSizeThreshold = attachmentSizeThresholdParameter
- .getValue().toString();
- }
- }
-
- Attachments attachments = new Attachments(inStream, contentTypeString,
- fileCacheForAttachments, attachmentRepoDir,
- attachmentSizeThreshold);
- String charSetEncoding = getCharSetEncoding(attachments
- .getSOAPPartContentType());
- XMLStreamReader streamReader;
+ XMLStreamReader streamReader;
if ((charSetEncoding == null)
|| "null".equalsIgnoreCase(charSetEncoding)) {
@@ -286,6 +234,63 @@
return builder;
}
+
+ private static Attachments createAttachment(MessageContext msgContext, InputStream inStream, String contentTypeString) {
+ Object cacheAttachmentProperty = msgContext
+ .getProperty(Constants.Configuration.CACHE_ATTACHMENTS);
+ String cacheAttachmentString = null;
+ boolean fileCacheForAttachments;
+
+ if (cacheAttachmentProperty != null
+ && cacheAttachmentProperty instanceof String) {
+ cacheAttachmentString = (String) cacheAttachmentProperty;
+ fileCacheForAttachments = (Constants.VALUE_TRUE
+ .equals(cacheAttachmentString));
+ } else {
+ Parameter parameter_cache_attachment = msgContext
+ .getParameter(Constants.Configuration.CACHE_ATTACHMENTS);
+ cacheAttachmentString = (parameter_cache_attachment != null) ? (String) parameter_cache_attachment
+ .getValue()
+ : null;
+ }
+ fileCacheForAttachments = (Constants.VALUE_TRUE
+ .equals(cacheAttachmentString));
+
+ String attachmentRepoDir = null;
+ String attachmentSizeThreshold = null;
+
+ if (fileCacheForAttachments) {
+ Object attachmentRepoDirProperty = msgContext
+ .getProperty(Constants.Configuration.ATTACHMENT_TEMP_DIR);
+
+ if (attachmentRepoDirProperty != null) {
+ attachmentRepoDir = (String) attachmentRepoDirProperty;
+ } else {
+ Parameter attachmentRepoDirParameter = msgContext
+ .getParameter(Constants.Configuration.ATTACHMENT_TEMP_DIR);
+ attachmentRepoDir = (attachmentRepoDirParameter != null) ? (String) attachmentRepoDirParameter
+ .getValue()
+ : null;
+ }
+
+ Object attachmentSizeThresholdProperty = msgContext
+ .getProperty(Constants.Configuration.FILE_SIZE_THRESHOLD);
+ if (attachmentSizeThresholdProperty != null
+ && attachmentSizeThresholdProperty instanceof String) {
+ attachmentSizeThreshold = (String) attachmentSizeThresholdProperty;
+ } else {
+ Parameter attachmentSizeThresholdParameter = msgContext
+ .getParameter(Constants.Configuration.FILE_SIZE_THRESHOLD);
+ attachmentSizeThreshold = attachmentSizeThresholdParameter
+ .getValue().toString();
+ }
+ }
+
+ Attachments attachments = new Attachments(inStream, contentTypeString,
+ fileCacheForAttachments, attachmentRepoDir,
+ attachmentSizeThreshold);
+ return attachments;
+ }
public static StAXBuilder getBuilder(Reader in) throws XMLStreamException {
XMLStreamReader xmlreader = StAXUtils.createXMLStreamReader(in);
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-cvs-help@ws.apache.org