summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMelek Zribi2013-09-06 06:50:49 (EDT)
committer Stephan Born2013-09-06 06:50:49 (EDT)
commit64a72097a9932e8c195128e6250920b1aa1f4f0a (patch)
treebe788c1d0d1cd965a11debfd1207a62030a8eeb5
parenta34e181db0fcef03b28ee924965bae1448237776 (diff)
downloadorg.eclipse.stardust.engine-64a72097a9932e8c195128e6250920b1aa1f4f0a.zip
org.eclipse.stardust.engine-64a72097a9932e8c195128e6250920b1aa1f4f0a.tar.gz
org.eclipse.stardust.engine-64a72097a9932e8c195128e6250920b1aa1f4f0a.tar.bz2
Jira-ID: CRNT-30292
Camel Mail Trigger: "NullPointerException" is thrown if mail is having attachment to it git-svn-id: https://svn.csa.sungard.com/repos/ipp2/product/trunk/stardust/engine@67137 8100b5e0-4d52-466c-ae9c-bdeccbdeaf6b Signed-off-by: Melek Zribi <Melek.Zribi@sungard.com>
-rw-r--r--stardust-engine-camel/src/main/java/org/eclipse/stardust/engine/extensions/camel/converter/DocumentDataConverter.java32
1 files changed, 24 insertions, 8 deletions
diff --git a/stardust-engine-camel/src/main/java/org/eclipse/stardust/engine/extensions/camel/converter/DocumentDataConverter.java b/stardust-engine-camel/src/main/java/org/eclipse/stardust/engine/extensions/camel/converter/DocumentDataConverter.java
index 2d36f4c..adba0a7 100644
--- a/stardust-engine-camel/src/main/java/org/eclipse/stardust/engine/extensions/camel/converter/DocumentDataConverter.java
+++ b/stardust-engine-camel/src/main/java/org/eclipse/stardust/engine/extensions/camel/converter/DocumentDataConverter.java
@@ -1,28 +1,27 @@
package org.eclipse.stardust.engine.extensions.camel.converter;
import java.io.IOException;
-import java.io.Serializable;
import java.text.SimpleDateFormat;
import java.util.Date;
-import java.util.HashMap;
-import java.util.Map;
+
+import javax.mail.MessagingException;
+import javax.mail.internet.MimeMultipart;
import org.apache.camel.Converter;
import org.apache.camel.Exchange;
import org.apache.camel.Handler;
import org.apache.camel.component.file.GenericFile;
-import org.eclipse.stardust.engine.api.runtime.DmsUtils;
+import org.apache.log4j.LogManager;
+import org.apache.log4j.Logger;
import org.eclipse.stardust.engine.api.runtime.Document;
-import org.eclipse.stardust.engine.core.compatibility.extensions.dms.data.DocumentStorageBean;
-import org.eclipse.stardust.engine.core.struct.sxml.DocumentBuilder;
+import org.eclipse.stardust.engine.extensions.camel.CamelConstants.MessageProperty;
import org.eclipse.stardust.engine.extensions.camel.util.DmsFileArchiver;
import org.eclipse.stardust.engine.extensions.camel.util.client.ClientEnvironment;
-import org.eclipse.stardust.engine.extensions.camel.CamelConstants.MessageProperty;
-import org.eclipse.stardust.engine.extensions.dms.data.DmsDocumentBean;
@Converter
public class DocumentDataConverter implements DataConverter
{
+ private static final Logger logger = LogManager.getLogger(DocumentDataConverter.class);
private String fromEndpoint;
private String targetType;
@@ -68,6 +67,7 @@ public class DocumentDataConverter implements DataConverter
* Camel exchange
* @return document from the input file
* @throws IOException
+ * @throws MessagingException
*/
@Converter
@Handler
@@ -103,6 +103,22 @@ public class DocumentDataConverter implements DataConverter
+ "_"+df.format(new Date());
}
+ MimeMultipart mimeMultipart = null;
+ if (jcrDocumentContent == null){
+ mimeMultipart = (MimeMultipart) exchange.getIn().getBody();
+ if (mimeMultipart != null){
+ try {
+ jcrDocumentContent = (String) mimeMultipart.getBodyPart(1).getContent();
+ } catch (Exception e) {
+ e.printStackTrace();
+ jcrDocumentContent = "";
+ }
+ }
+ else {
+ jcrDocumentContent = "";
+ }
+ }
+ logger.debug("*** jcrDocumentContent = "+jcrDocumentContent);
Document newDocument = dmsFileArchiver.archiveFile(jcrDocumentContent.getBytes(), path, folder);
newDocument.setProperties(null);