And can you provide more details to your error, i.e. the original exception stacktrace / response?
It shows: package(com.activiti.alfresco.service) does not exist, which I have used in my package.
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.
Could you please provide me some guidance or some example, like how I supposed to do this in 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.
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?
Could you please provide the real error? I.e. look into alfresco.log for the details, because the screenshot only shows a wrapped message...
Actually, I am getting two errors in the log while compiling, which are in the following screenshot.
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.
So could you please pointer me where should I suppose to change in my code to trigger the process?
Ask for and offer help to other Alfresco Content Services Users and members of the Alfresco team.
Related links:
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.