Package org.camunda.bpm.engine.rest.mapper.MultipartFormData

Examples of org.camunda.bpm.engine.rest.mapper.MultipartFormData.FormPart


  protected void parseRequest(MultipartFormData multipartFormData, FileUpload fileUpload, RestMultipartRequestContext requestContext) {
    try {
      FileItemIterator itemIterator = fileUpload.getItemIterator(requestContext);
      while (itemIterator.hasNext()) {
        FileItemStream stream = itemIterator.next();
        multipartFormData.addPart(new FormPart(stream));
      }
    } catch (Exception e) {
      throw new RestException(Status.BAD_REQUEST, e, "multipart/form-data cannot be processed");

    }
View Full Code Here


          String.format("Cannot put %s variable %s: %s", getResourceTypeName(), variableName, e.getMessage()));
    }
  }

  public void setBinaryVariable(String variableKey, MultipartFormData payload) {
    FormPart dataPart = payload.getNamedPart("data");
    FormPart valueTypePart = payload.getNamedPart("type");

    if(valueTypePart != null) {
      Object object = null;

      if(dataPart.getContentType()!=null
          && dataPart.getContentType().toLowerCase().contains(MediaType.APPLICATION_JSON)) {

        object = deserializeJsonObject(valueTypePart.getTextContent(), dataPart.getBinaryContent());

      } else {
        throw new InvalidRequestException(Status.BAD_REQUEST, "Unrecognized content type for serialized java type: "+dataPart.getContentType());
      }
View Full Code Here

  @Override
  public AttachmentDto addAttachment(UriInfo uriInfo, MultipartFormData payload) {
    ensureHistoryEnabled(Status.FORBIDDEN);
    ensureTaskExists(Status.BAD_REQUEST);

    FormPart attachmentNamePart = payload.getNamedPart("attachment-name");
    FormPart attachmentTypePart = payload.getNamedPart("attachment-type");
    FormPart attachmentDescriptionPart = payload.getNamedPart("attachment-description");
    FormPart contentPart = payload.getNamedPart("content");
    FormPart urlPart = payload.getNamedPart("url");

    if (urlPart == null && contentPart == null) {
      throw new InvalidRequestException(Status.BAD_REQUEST, "No content or url to remote content exists to create the task attachment.");
    }

    String attachmentName = null;
    String attachmentDescription = null;
    String attachmentType = null;
    if (attachmentNamePart != null) {
      attachmentName = attachmentNamePart.getTextContent();
    }
    if (attachmentDescriptionPart != null) {
      attachmentDescription = attachmentDescriptionPart.getTextContent();
    }
    if (attachmentTypePart != null) {
      attachmentType = attachmentTypePart.getTextContent();
    }

    Attachment attachment = null;
    try {
      if (contentPart != null) {
        ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(contentPart.getBinaryContent());
        attachment = engine.getTaskService().createAttachment(attachmentType, taskId, null, attachmentName, attachmentDescription, byteArrayInputStream);
      } else if (urlPart != null) {
        attachment = engine.getTaskService().createAttachment(attachmentType, taskId, null, attachmentName, attachmentDescription, urlPart.getTextContent());
      }
    } catch (ProcessEngineException e) {
      throw new InvalidRequestException(Status.BAD_REQUEST, e, "Task id is null");
    }
View Full Code Here

    DeploymentBuilder deploymentBuilder = getProcessEngine().getRepositoryService().createDeployment();

    Set<String> partNames = payload.getPartNames();

    for (String name : partNames) {
      FormPart part = payload.getNamedPart(name);

      if (!RESERVED_KEYWORDS.contains(name)) {
        deploymentBuilder.addInputStream(part.getFileName(), new ByteArrayInputStream(part.getBinaryContent()));
      }
    }

    if (payload.getNamedPart(DEPLOYMENT_NAME) != null) {
      FormPart part = payload.getNamedPart(DEPLOYMENT_NAME);
      deploymentBuilder.name(part.getTextContent());
    }

    boolean enableDuplicateFiltering = false;
    boolean deployChangedOnly = false;

    if (payload.getNamedPart(ENABLE_DUPLICATE_FILTERING) != null) {
      FormPart part = payload.getNamedPart(ENABLE_DUPLICATE_FILTERING);
      enableDuplicateFiltering = Boolean.parseBoolean(part.getTextContent());
    }

    if (payload.getNamedPart(DEPLOY_CHANGED_ONLY) != null) {
      FormPart part = payload.getNamedPart(DEPLOY_CHANGED_ONLY);
      deployChangedOnly = Boolean.parseBoolean(part.getTextContent());
    }

    // deployChangedOnly overrides the enableDuplicateFiltering setting
    if (deployChangedOnly) {
      deploymentBuilder.enableDuplicateFiltering(true);
View Full Code Here

TOP

Related Classes of org.camunda.bpm.engine.rest.mapper.MultipartFormData.FormPart

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.