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

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

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

And can you provide more details to your error, i.e. the original exception stacktrace / response?

Highlighted
Active Member II

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

It shows: package(com.activiti.alfresco.service) does not exist, which I have used in my package. 

Highlighted
Master

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

Don't use it then. It sounds like a package that would only be available within APS itself, but now your are writing code inside ACS.

Active Member II

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

Could you please provide me some guidance or some example, like how I supposed to do this in ACS?

Highlighted
Master

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

I haven't accessed APS from ACS myself, so don't have any ready-to-use code samples. But just use any Java-based tooling for doing REST calls and use the APS ReST API. Don't rely on any APS-internal APIs which are not available in ACS. Build your own little REST client abstraction, i.e. backed by libraries like resteasy, jackson or any other in that domain.

Highlighted
Active Member II

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

Hi again,

now I am trying to start the process by the following code but getting: Caused by: java.lang.RuntimeException: Failed  : HTTP error code : 401

 

private Behaviour onCreateNode;

public void init() {
this.onCreateNode = new JavaBehaviour(this, "onCreateNode", NotificationFrequency.TRANSACTION_COMMIT);

this.policyComponent.bindClassBehaviour(QName.createQName(NamespaceService.ALFRESCO_URI, "onCreateNode"), ContentModel.TYPE_CONTENT, this.onCreateNode);
}

@Override
public void onCreateNode(ChildAssociationRef childasso) {

NodeRef node=childasso.getChildRef();

System.out.println(node);

System.out.println(childasso.getQName());


try {
URL url = new URL("localhost:9090/activiti-app/api/enterprise/process-instances");

HttpURLConnection conn = (HttpURLConnection) url.openConnection();

conn.setDoOutput(true);
conn.setRequestMethod("POST");
conn.setRequestProperty("Accept", "application/json");

String input = "{\"processDefinitionId\":\"adhoctask:1:13\"}";
OutputStream os = conn.getOutputStream();
os.write(input.getBytes());
os.flush();

if (conn.getResponseCode() != 200) {
throw new RuntimeException("Failed : HTTP error code : "
+ conn.getResponseCode());
}
BufferedReader br = new BufferedReader(new InputStreamReader(
(conn.getInputStream())));

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


conn.disconnect();

}catch (MalformedURLException e) {

e.printStackTrace();

}catch (IOException e) {

e.printStackTrace();

}

could you please correct me?

Highlighted
Master

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

Could you please provide the real error? I.e. look into alfresco.log for the details, because the screenshot only shows a wrapped message...

Highlighted
Active Member II

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

Actually, I am getting two errors in the log while compiling, which are in the following screenshot.

Highlighted
Master

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

So there you have it - you are throwing that error yourself because you get a 401 response code... Your custom code isn't handling authentication.

Highlighted
Active Member II

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

So could you please pointer me where should I suppose to change in my code to trigger the process?