Unable to deploy the bpmn file using activiti rest api post
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-03-2015 03:26 AM
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);
}
}
- Labels:
-
Archive
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-03-2015 04:17 AM
Do you have a error in the log or any other relevant information which can help us understand what's happening?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-04-2015 09:49 AM
Am I doing the file conversion to multipart format right ? the way I am calling the rest api post , arguments is that all right ?
I don't know where I am making mistake .. Please help me .
If you have the code for file deploy through activiti post , please share that as well..
Please guide
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-05-2015 04:38 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-06-2015 06:59 AM
Can you please tell me how to do that in the same link which you had posted
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-07-2015 04:22 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-08-2015 07:27 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-13-2015 12:53 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-13-2015 08:06 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎05-10-2016 11:13 AM
import org.apache.commons.codec.binary.Base64;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.core.io.FileSystemResource;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.MediaType;
import org.springframework.http.ResponseEntity;
import org.springframework.http.converter.FormHttpMessageConverter;
import org.springframework.http.converter.ResourceHttpMessageConverter;
import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestTemplate;
import java.util.Arrays;
import java.util.Collections;
import java.util.Map;
public class DeployBarUtility2 {
public static final String BAR_FILE_PATH = "/Users/paravena/dev/workspace/activiti-examples/add-sales-opportunity-process/target/add-sales-opportunity-process-1.0-SNAPSHOT.bar";
public static final String DEPLOY_URL = "http://localhost:8080/activiti-rest/service/repository/deployments";
public static void main(String[] args) throws Exception {
new DeployBarUtility2().deploy(BAR_FILE_PATH);
}
public void deploy(String barFilePath) {
RestTemplate restTemplate = getRestTemplate();
MultiValueMap<String, Object> multipartDataMap = new LinkedMultiValueMap<String, Object>();
FileSystemResource barFileResource = new FileSystemResource(barFilePath);
multipartDataMap.add("file", barFileResource);
HttpEntity<MultiValueMap<String, Object>> requestEntity = new HttpEntity<MultiValueMap<String, Object>>(multipartDataMap, getHttpHeaders());
ResponseEntity<Map<String, String>> response = restTemplate.exchange(DEPLOY_URL,
HttpMethod.POST, requestEntity, new ParameterizedTypeReference<Map<String, String>>() {
});
System.out.println("Status: " + response.getStatusCode());
System.out.println("Name: " + response.getBody().get("name"));
}
private RestTemplate getRestTemplate() {
RestTemplate restTemplate = new RestTemplate();
restTemplate.setMessageConverters(Arrays.asList(new FormHttpMessageConverter(),
new ResourceHttpMessageConverter(),
new MappingJackson2HttpMessageConverter()));
return restTemplate;
}
private HttpHeaders getHttpHeaders() {
HttpHeaders headers = new HttpHeaders();
String token="kermit".concat(":").concat("kermit");
headers.add("Authorization", "Basic " + new String(Base64.encodeBase64(token.getBytes())));
headers.setContentType(MediaType.MULTIPART_FORM_DATA);
headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON));
return headers;
}
}
