cancel
Showing results for 
Search instead for 
Did you mean: 

Process Instance Diagram through Restful API

pneudecorb
Champ in-the-making
Champ in-the-making
I am trying to retrieve the process instance (not definition) diagram using the restful API, but I am not getting all the byte data back from the activiti calls.

My initial definition deployment consisted only of the definition (bpmn 2.0 xml) with no process definition image data.

I assume (please correct me) that all that is required to generate the process "Instance" diagram is the actual xml definition along with the current runtime state which is found using the passed in process instance id.

If I generate a process "definition" diagram using the activiti services (not restful), I get back roughly 12k bytes which I then render as an image.

When I try to generate a process "instance" diagram over the provided restful API, the resultant response stream (InputStream) contains only 92 bytes of data (garbage?).  I would expect at least 12k bytes and most likely more because of the additional decoration it does to the image for the process runtime state.

Not sure what I am doing wrong here and hoped someone else has exercised the process definition/instance diagram generation over the restful api.

Pneu
4 REPLIES 4

pneudecorb
Champ in-the-making
Champ in-the-making
One additional piece of information is that these bpmn 2.0 xml definitions are generated by Joram's kickstart code, so they may not have enough  or even valid "diagram interchange" information that would allow activiti to generate the diagrams at deployment if they are not provided.

potgieterde
Champ in-the-making
Champ in-the-making
Any luck with this?

As far as i can see i get the image back calling uri :



        String subUrl = "/process-instance/" + processInstanceId + "/diagram";
        Reference reference = new Reference(Play.configuration.getProperty("activiti.rest.url") + subUrl);
        Client client = new Client(Protocol.HTTP);
        Request request = new Request(Method.GET, reference);
        request.setChallengeResponse(new ChallengeResponse(ChallengeScheme.HTTP_BASIC, "kermit", "kermit"));

        Response response = client.handle(request);
        Logger.debug("type : " + response.getEntity().getMediaType().getName());

but i cant seem to figure out how to read the image in byte[] form.
the debug statement returns "image/png" and calling response.getEntityAsText() returns a whole lot of printed binary.

Any help would be appreciated.

potgieterde
Champ in-the-making
Champ in-the-making
Any luck with this?

As far as i can see i get the image back calling uri :



        String subUrl = "/process-instance/" + processInstanceId + "/diagram";
        Reference reference = new Reference(Play.configuration.getProperty("activiti.rest.url") + subUrl);
        Client client = new Client(Protocol.HTTP);
        Request request = new Request(Method.GET, reference);
        request.setChallengeResponse(new ChallengeResponse(ChallengeScheme.HTTP_BASIC, "kermit", "kermit"));

        Response response = client.handle(request);
        Logger.debug("type : " + response.getEntity().getMediaType().getName());

but i cant seem to figure out how to read the image in byte[] form.
the debug statement returns "image/png" and calling response.getEntityAsText() returns a whole lot of printed binary.

Any help would be appreciated.

frederikherema1
Star Contributor
Star Contributor
Don't read it as text, just read the response-entity stream. Use the getEntity().getContent() inputsream. Make sure you sue the right encoding…