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

cancel
Showing results for 
Search instead for 
Did you mean: 
afaust
Master

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

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.

amitkulhari26
Active Member II

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

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
Master

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

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.