cancel
Showing results for 
Search instead for 
Did you mean: 

how to create deployment with tenantId using cxf ?

kafeitu
Champ on-the-rise
Champ on-the-rise

WebClient client = createClient("repository/deployments");

InputStream resourceAsStream = RestRequestTandem.class.getClassLoader().getResourceAsStream("diagrams/leave.bpmn");
client.type("multipart/form-data");
ContentDisposition cd = new ContentDisposition("form-data;name=bpmn;filename=leave.bpmn;");
Attachment att = new Attachment("leave.bpmn", resourceAsStream, cd);
MultipartBody body = new MultipartBody(att);
Response response = client.post(body);


response:
<javascript>
{
  "id" : "905",
  "name" : "leave.bpmn",
  "deploymentTime" : "2014-06-14T07:30:27.441+0000",
  "category" : null,
  "url" : "http://localhost:8089/activiti-rest/service/repository/deployments/905",
  "tenantId" : ""
}
</javascript>

—-

How to set parameter tenantId using cxf ?
5 REPLIES 5

trademak
Star Contributor
Star Contributor
The tenantId can be provided as part of the multipart field items.

Best regards,

kafeitu
Champ on-the-rise
Champ on-the-rise
Can you show me the code ? I tried many times but still failed.

jbarrez
Star Contributor
Star Contributor
See DeploymentCollectionResource

The tenantId is parsed from the multipart content:

<code>

      String tenantId = null;
     
      FileItem uploadItem = null;
      for (FileItem fileItem : items) {
       if(fileItem.isFormField()) {
        if("tenantId".equals(fileItem.getFieldName())) {
         tenantId = fileItem.getString("UTF-8");
        }
       } else if(fileItem.getName() != null) {
          uploadItem = fileItem;
        }
      }
</code>

However, I dont see any tests that actually build this data and test it with a post :s

kafeitu
Champ on-the-rise
Champ on-the-rise
Yes @jbarrez, I viewed the source code about that, but I have not found how to use CXF to submit form with file and form properties. So I replaced CXF to RestTemplate support by Spring MVC.

I hope others can provide sample codes, thanks.

jbarrez
Star Contributor
Star Contributor
Does it work with restTemplate though?