empty payload when receiving HTML mails with image in body and a attachment MULE - mule-esb

I'm using imap connector its working fine in all the scenarios but when an email sent with an image in the body and an attachment I'm getting empty payload from the imap listener.
if I send an email with an image in the body and no attachment the image is saving as separate file and content in the body as a separate file that's okay.
Did anyone faced the same issue or can anyone please provide a fix?
even tried disableTransportTransformer="true in imap connector its not working
<?xml version="1.0" encoding="UTF-8"?>
<mule xmlns:imap="http://www.mulesoft.org/schema/mule/imap"
xmlns:email="http://www.mulesoft.org/schema/mule/email"
xmlns="http://www.mulesoft.org/schema/mule/core"
xmlns:doc="http://www.mulesoft.org/schema/mule/documentation"
xmlns:spring="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-current.xsd
http://www.mulesoft.org/schema/mule/core http://www.mulesoft.org/schema/mule/core/current/mule.xsd
http://www.mulesoft.org/schema/mule/imap http://www.mulesoft.org/schema/mule/imap/current/mule-imap.xsd
http://www.mulesoft.org/schema/mule/email http://www.mulesoft.org/schema/mule/email/current/mule-email.xsd">
<imap:connector name="IMAP_Security"
validateConnections="true" doc:name="IMAP"/>
<email:email-to-string-transformer mimeType="text/html" name="Email_to_String" doc:name="Email to String" encoding="UTF-8"/>
<flow name="emailprocessorFlow">
<imap:inbound-endpoint host="localhost" port="143" connector-ref="IMAP_Security" responseTimeout="10000" disableTransportTransformer="true" doc:name="IMAP" transformer-refs="Email_to_String" encoding="UTF-8"/>
<logger message="initial payload## #[message.payloadAs(String)]" level="INFO" doc:name="Logger"/>
<set-variable variableName="sender" value="${poller}" doc:name="poller"/>
<set-variable variableName="inbox" value="${username}" doc:name="email User Name"/>
<base64-encoder-transformer name="Base64-Encoder-Transformer_Headers"
doc:name="Headers Base64 Encoder" encoding="utf-8">
</base64-encoder-transformer>
</flow>
</mule>
email body should be extracted through

The image is likely another attachement, not the body. Try to iterate over the attachements and log information about the message to confirm it:
<foreach collection="#[message.inboundAttachments]" doc:name="ForEach">
<logger />
</foreach>

Related

Spring mvc multipart file upload

I've seen a lot of answers on stackoverflow about multipart file upload problem in Spring MVC application.
Step by step I've make sure that I don't repeat errors others did.
Here is my form
<form class="form-horizontal" data-toggle="validator"
id="track_existing_repair"
method="post"
action="/euo/testUpload.htm"
enctype="multipart/form-data">
...
<div class="form-group required">
<label class="control-label col-sm-4" for="proofOfPurchaseInput">Select File:</label>
<div class="col-sm-8">
<input name="proofOfPurchase"
id="proofOfPurchaseInput"
type="file"
required/>
</div>
</div>
...
</form>
In pom file I have dependency
<dependency>
<groupId>commons-fileupload</groupId>
<artifactId>commons-fileupload</artifactId>
<version>1.3.2</version>
</dependency>
declared multipartResolver in app-servlet.xml
<bean id="multipartResolver" class="org.springframework.web.multipart.commons.CommonsMultipartResolver">
<!-- max upload size in bytes -->
<property name="maxUploadSize" value="20971520" /> <!-- 20MB -->
<!-- max size of file in memory (in bytes) -->
<property name="maxInMemorySize" value="1048576" /> <!-- 1MB -->
</bean>
Method mapped to request in Controller class
#RequestMapping(value = {"/testUpload"},headers = "Content-Type=multipart/form-data", method = RequestMethod.POST)
public String testUpload(
#RequestPart(value = "proofOfPurchase", required = false) MultipartFile proofOfPurchaseFile
,HttpServletRequest request
) throws InvalidFormatException, IOException {
if(proofOfPurchaseFile != null){
readFile(proofOfPurchaseFile);
}
return NAV_HOME;
}
I tried #RequestParam instead #RequestPart
Without required = false I have "Required request part
'proofOfPurchase' is not present" response, so I made it not required
only to get in to examine request in debugger
So when I stop in debugger I wasn't surprised that request object shows me that file was received and even stored in jBoss temporary folder.
Could you please point out what I could miss that Spring can't see uploaded file?
The problem appears in legacy project where we also use Struts.
It's turn out that struts dispatcher somehow conflicts with spring CommonsMultipartResolver.
Once I've removed all struts servlets and filters from web.xml everything start working.

Alfresco share worflow form validation

I have been trying to validate my alfresco share workflow form for several days without success. This is what i have done.
Configured my workflow in the share-config-custom.xml located in %TOMCAT_HOME%tomcat\shared\classes\alfresco\web-extension
set my contraint handler as follows.
<constraint-handlers>
<constraint type="MANDATORY"
validation-handler="Alfresco.forms.validation.examplestaffnumber"
event="keyup" />
</constraint-handlers>
</field>
This field i have set to mandatory
< label-id="Staff Number" id="leave:staffnumber" mandatory="true">
I have created the contraint hanlder javascript and placed it at %ALFRESCO_HOME%\tomcat\webapps\share\js folder. This is both js and min.js
Finaly added the js in form.get.head.ftl located at %ALFRESCO_HOME%tomcat\webapps\share\WEB-INF\classes\alfresco\site-webscripts\org\alfresco\components\form
folder like this
<#script type="text/javascript" src="${page.url.context}/res/js/examplevalidation.js">
When I select my worflow form and key values in the staff number form nothing happens. I have checked in the firebug but there is no any call to the js.
Where could i have gone wrong?
I think you have not added dependencies for your java script. To do that add below code in your share-config-custom.xml located in %ALFRESCO_HOME%tomcat\shared\classes\alfresco\web-extension
<config>
<forms>
<dependencies>
<js src="/js/examplevalidation.js" />
</dependencies>
</forms>
</config>
And your constrains handler should be like
<field id="leave:staffnumber" label-id="Staff Number" mandatory="true">
<control template="/org/alfresco/components/form/controls/textfield.ftl" />
<constraint-handlers>
<constraint type="MANDATORY" validation-handler="Alfresco.forms.validation.examplestaffnumber" event="blur"/>
</constraint-handlers>
</field>
And function in your js should be like this:
Alfresco.forms.validation.examplestaffnumber = function examplestaffnumber(
field, args, event, form, silent, message) {
// your code with return statement
}
Hope this helps!!!

How to set REQUEST HEADER in spring Integration

We have a asp page which reading some information form request like this:
varLogon = Request.ServerVariables("HTTP_logon")
If we want to post something to the asp page using spring integration, we are unable to pass the HTTP_logon to the page,
This is not working
Any idea, what and how we can set the request header information?
<int:header-enricher input-channel="pdfgenheaderchannel" output-channel="pdfgenchannel">
<int:header name="HTTP_ordernumber" method="getOrdernumber" ref="reportbean"/>
<int:header name="reportID" method="getReportID" ref="reportbean"/>
<int:header name="Content-Type" value="text/html"/>
<int:header name="logon" value="orderADCB"/>
<int:header name="HTTP_logon" value="orderADCB"/>
</int:header-enricher>
<int-http:outbound-gateway id="pdfgenerationoutboundgateway"
request-channel="pdfgenchannel"
url="http://x.xy.xx.y/convertHTMLtoPDF.asp"
http-method="POST"
expected-response-type="java.lang.String"
charset="UTF-8"
reply-channel="replyChannel"
request-factory="requestFactory" />
You have to specify a header-mapper for the <int-http:outbound-gateway>. By default it maps only standard HTTP headers:
<beans:bean id="headerMapper" class="org.springframework.integration.http.support.DefaultHttpHeaderMapper"
factory-method="outboundMapper">
<beans:property name="outboundHeaderNames" value="*"/>
<beans:property name="userDefinedHeaderPrefix" value=""/>
</beans:bean>
<int-http:outbound-gateway header-mapper="headerMapper"/>
You can user following routing component to route according to header values.
<int:header-value-router input-channel="routingChannel" header-name="headerObject">
<int:mapping value="value1" channel="channel1" />
<int:mapping value="calue2" channel="channel2" />
</int:header-value-router>

XML Work FLow Deployment in Alfresco

Hi Guyz,
I am trying to deploy the following test workflow definition in alfresco, since from 2 dayz :(
<?xml version="1.0" encoding="UTF-8"?>
<process-definition xmlns="urn:jbpm.org:jpdl-3.1" name="helloWorld">
<start-state name="start">
<transition name="" to="hello"></transition>
</start-state>
<node name="hello">
<transition name="" to="end1">
<action class="org.alfresco.repo.workflow.jbpm.AlfrescoJavaScript">
<script>
logger.log("Hello World!");
</script>
</action>
</transition>
</node>
<end-state name="end1"></end-state>
</process-definition>"
But when im going to deploy the above workflow definition in alfresco community 4.2 through "work-flow.jsp, it gives me following error message.
"org.alfresco.service.cmr.workflow.WorkflowException: 03200027 Workflow Component for engine id 'jbpm' is not registered"
Please Help !
JBPM is disabled by default!
Onine docs: http://docs.alfresco.com/4.1/topic/com.alfresco.enterprise.doc/tasks/adminconsole-workflow.html
Snippet:
set the following properties in your alfresco-global.properties.
system.workflow.engine.jbpm.enabled=true
system.workflow.engine.jbpm.definitions.visible=true

Voicexml how to store input into a global variable

I'm creating a voicexml appliacation.
I want to store an user input into a global variable.
I wondered, the input should be stored in the fieldvar. shouldn't it? After I tried it with this, i tried to store it in an global variable:
<assign name="myvar" expr="'myinput'"/>
but somehow it didn't work. I used value expr="var" as expr.
<?xml version="1.0" encoding="UTF-8"?>
<vxml xmlns="http://www.w3.org/2001/vxml"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.w3.org/2001/vxml
http://www.w3.org/TR/voicexml20/vxml.xsd"
version="2.0">
<var name="myProdukt" />
<form id="test">
<field name="var">
<prompt bargein="true" bargeintype="hotword" >Sagen Sie ein Produkt</prompt>
<grammar root="main" version="1.0" xml:lang="de-DE">
<rule id="main" scope="public">
<one-of>
<item> p1 </item>
<item> p2 </item>
<item> p3 </item>
<item> p4 </item>
</one-of>
</rule>
</grammar>
<filled>
<assign name="myProdukt" expr="<value expr="var"/>"/>
</filled>
</field>
</form>
<<!--[...] Here i want to use the input.-->
</vxml>
thanks in advance
---------------EDIT:
now i used this:
<filled>
test
<assign name="myProdukt" expr="var" />
</filled>
I only changed that. The Applications says "test" but then there is an error.
It isn'T allowed to use "var" instead I used an other name :-)
Did you try a simple assignment of field var to the variable myProdukt like so ?
<filled>
<assign name="myProdukt" expr="var"/>
</filled>
Which would be fine except that according to Section 5.1, Variables and Expressions of the Voice XML specification:
VoiceXML variables, including form
item variables, must not contain
ECMAScript reserved words.
So, you'll need to rename the field var to something that is not a reserved word in ECMAscript, say productSelection:
<field name="productSelection">
<!-- .. prompt, grammar as before .. -->
<filled>
<assign name="myProdukt" expr="productSelection"/>
</filled>
</field>

Resources