cancel
Showing results for 
Search instead for 
Did you mean: 

activiti rest

jaikrishna
Champ on-the-rise
Champ on-the-rise
I am able to run my JUnit test ..
This is my Junit test ..

package org.activiti.designer.test;
import static org.junit.Assert.*;
import java.io.FileInputStream;
import java.io.IOException;
import java.util.HashMap;
import java.util.Map;

import org.activiti.engine.RepositoryService;
import org.activiti.engine.RuntimeService;
import org.activiti.engine.impl.util.json.JSONArray;
import org.activiti.engine.impl.util.json.JSONException;
import org.activiti.engine.impl.util.json.JSONObject;
import org.activiti.engine.runtime.ProcessInstance;
import org.activiti.engine.test.ActivitiRule;
import org.activiti.engine.test.Deployment;
import org.junit.Rule;
import org.junit.Test;




public class ProcessTestMyProcess {
     private String filename = ".\\src\\main\\resources\\diagrams\\SimpleLeaveProcess.bpmn";
   ;
   
   @Rule
   public ActivitiRule activitiRule = new ActivitiRule("activiti.cfg.xml");
   
   @Test
   @Deployment
   public void startProcess() throws Exception {
      
      RepositoryService repositoryService = activitiRule.getRepositoryService();
      RuntimeService runtimeService = activitiRule.getRuntimeService();
      FileInputStream  fis = new FileInputStream(filename);
      repositoryService.createDeployment().addInputStream("SimpleLeaveProcess.bpmn20.xml",
            fis).deploy();
      Map<String,Object> variableMap = new HashMap<String,Object>();
      variableMap.put("Empname", "J");
      ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("myProcess", variableMap);
     assertNotNull(processInstance.getId());
    
    
    
      System.out.println("id " + processInstance.getId() + " "
            + processInstance.getProcessDefinitionId());
      
      
      
   }
   
      
}

But When I login to localhost:8080/activiti-explorer ,and check the table act_re_deployment , i do not see any entries ..
Is it actually getting deployed ??
I used h2 jar in eclipse project ..
and

entries in act_Re_Deployments is not matching with the entries I am getting when i run the url :

http:localhost:8080/activiti-rest/service/repository/deployments ,

in act_Re_deployments , there are two entries : demo processes with id 23 and demo reports with id 41 .

But when i run the rest service url in rest client ,
i am getting :
{
data: [1]
0:  {
id: "20"
name: "Demo processes"
deploymentTime: "2015-09-02T18:05:43.967+05:30"
category: null
url: "http://localhost:8080/activiti-rest/service/repository/deployments/20"
tenantId: ""
}-
-
total: 1
start: 0
sort: "id"
order: "asc"
size: 1
}
From where is this data coming ? And why I am not getting data which is there in act_Re_deployments
6 REPLIES 6

vasile_dirla
Star Contributor
Star Contributor
Hi,
would be great if you will deliver a zip with your full unit test.
http://forums.activiti.org/content/sticky-how-write-unit-test

Note:
before publishing here please rename it to txt. (in order to be able to upload it)

jaikrishna
Champ on-the-rise
Champ on-the-rise
Hi ,

How to deploy a bpmn file via activiti rest api post ?
how to send the data as multipart/form-data ?
I have a bpmn file in xml format .. Please help ..

trademak
Star Contributor
Star Contributor
We've described this in the Activiti user guide. How you are sending this data depends a lot on the framework/technology/tool you are using and is not Activiti specific.

Best regards,

jaikrishna
Champ on-the-rise
Champ on-the-rise
In activiti user guide , it has been just mentioned like request should be of type multipart/form-data .. but how to give a file in that format has not been mentioned ? can you please help ? which technology should be used ? i am using eclipse ide and trying to post using rest api .. i have a bpmn file .. need to upload it via activiti rest api ..

jaikrishna
Champ on-the-rise
Champ on-the-rise
Hi ,

I have been trying to deploy the file through activiti rest api post ..
But I am not able to do it ..
Please help me ..
I have attached the code ..


public class repo

private static String REST_URI = "http://localhost:8080/activiti-rest/service/repository";

   private static ClientResource getClientResource(String uri)
   {
   ClientResource resource = new ClientResource(uri);
   resource.setChallengeResponse(ChallengeScheme.HTTP_BASIC,"kermit", "kermit");
   return resource;
   }
  
   public static void postDeployments() throws JSONException,IOException {  
   
  
  
   String postdeploymnet = REST_URI+"/deployments";
  
  
  
  
  
  
   Path path = Paths.get(".\\src\\main\\resources\\diagrams\\SimpleLeaveProcess.bpmn");
   String name = "SimpleLeaveProcess.bpmn";
   String originalFileName = "SimpleLeaveProcess.bpmn";
   String contentType = "";
   byte[] content = null;
   try {
       content = Files.readAllBytes(path);
   } catch (final IOException e) {
   }
   MultipartFile result = new MockMultipartFile(name,originalFileName, contentType, content);
  
  
   Representation response1 = getClientResource(postdeploymnet).post(result, MediaType.MULTIPART_FORM_DATA);
}
}

vasile_dirla
Star Contributor
Star Contributor
Hi,
since you created a new entry for this let's follow it here: http://forums.activiti.org/content/unable-deploy-bpmn-file-using-activiti-rest-api-post