cancel
Showing results for 
Search instead for 
Did you mean: 

How to trigger a Process from APS when an E-mail comes to ACS ?

amitkulhari26
Confirmed Champ
Confirmed Champ

I have created a Process for Alfresco Process Service and now I want to trigger it from Alfresco Content Service when, an E-mail comes to Alfresco Content Service, how it's possible?

22 REPLIES 22

afaust
Legendary Innovator
Legendary Innovator

I thought I did: Your custom code needs to handle authentication against APS, i.e. manage login / SSO and session. As I mentioned earler, you should use ReST / HTTP client framework (not use the raw Java URL connection handling), which typically already provide some utilities i.e. for HTTP BASIC authentication and session handling, as well as JSON to Java mapping.

as you mentioned I updated my code but after changing I am still facing same errors and I am new to alfresco so I don't know how to manage login/SSO and session through my code against APS. My updated code is below:


try {
DefaultHttpClient httpClient = new DefaultHttpClient();
HttpPost postRequest = new HttpPost(
"http://23.22.110.20:9090/activiti-app/api/enterprise/process-instances");

StringEntity input = new StringEntity("{\"processDefinitionId\":\"adhoctask:1:13\"}");
input.setContentType("application/json");
postRequest.setEntity(input);

HttpResponse response = httpClient.execute(postRequest);

if (response.getStatusLine().getStatusCode() != 201) {
throw new RuntimeException("Failed : HTTP error code : "
+ response.getStatusLine().getStatusCode());
}

BufferedReader br = new BufferedReader(
new InputStreamReader((response.getEntity().getContent())));

String output;
System.out.println("Output from Server .... \n");
while ((output = br.readLine()) != null) {
System.out.println(output);
}


httpClient.getConnectionManager().shutdown();
} catch (MalformedURLException e) {

e.printStackTrace();

} catch (IOException e) {

e.printStackTrace();

}

Could you please address me how to fix those errors?

afaust
Legendary Innovator
Legendary Innovator

You are still not handling any sort of authentication.... Since you are using HttpClient, I'd advise to look into its documentation on authentication. And also check the APS documentation on handling authorisation.