Package org.camunda.bpm.engine.rest.exception

Examples of org.camunda.bpm.engine.rest.exception.InvalidRequestException


               + (processDefinitionId != null ? 1 : 0)
               + (processDefinitionKey != null ? 1 : 0);

    if (params > 1) {
      String message = "Only one of jobDefinitionId, processDefinitionId or processDefinitionKey should be set to update the suspension state.";
      throw new InvalidRequestException(Status.BAD_REQUEST, message);
    }

    ManagementService managementService = engine.getManagementService();

    Date delayedExecutionDate = null;
    if (executionDate != null && !executionDate.equals("")) {
      delayedExecutionDate = DateTimeUtil.parseDate(executionDate);
    }

    if (jobDefinitionId != null) {
      // activate/suspend job definition by id
      if (getSuspended()) {
        managementService.suspendJobDefinitionById(jobDefinitionId, includeJobs, delayedExecutionDate);
      } else {
        managementService.activateJobDefinitionById(jobDefinitionId, includeJobs, delayedExecutionDate);
      }
    } else

    if (processDefinitionId != null) {
      // activate/suspend job definition by process definition id
      if (getSuspended()) {
        managementService.suspendJobDefinitionByProcessDefinitionId(processDefinitionId, includeJobs, delayedExecutionDate);
      } else {
        managementService.activateJobDefinitionByProcessDefinitionId(processDefinitionId, includeJobs, delayedExecutionDate);
      }
    } else

    if (processDefinitionKey != null) {
      // activate/suspend job definition by process definition key
      if (getSuspended()) {
        managementService.suspendJobDefinitionByProcessDefinitionKey(processDefinitionKey, includeJobs, delayedExecutionDate);
      } else {
        managementService.activateJobDefinitionByProcessDefinitionKey(processDefinitionKey, includeJobs, delayedExecutionDate);
      }
    } else {
      String message = "Either jobDefinitionId, processDefinitionId or processDefinitionKey should be set to update the suspension state.";
      throw new InvalidRequestException(Status.BAD_REQUEST, message);
    }
  }
View Full Code Here


  public JobDefinitionDto getJobDefinition() {
    ManagementService managementService = engine.getManagementService();
    JobDefinition jobDefinition = managementService.createJobDefinitionQuery().jobDefinitionId(jobDefinitionId).singleResult();

    if (jobDefinition == null) {
      throw new InvalidRequestException(Status.NOT_FOUND, "Job Definition with id " + jobDefinitionId + " does not exist");
    }

    return JobDefinitionDto.fromJobDefinition(jobDefinition);
  }
View Full Code Here

      dto.setJobDefinitionId(jobDefinitionId);
      dto.updateSuspensionState(engine);

    } catch (IllegalArgumentException e) {
      String message = String.format("The suspension state of Job Definition with id %s could not be updated due to: %s", jobDefinitionId, e.getMessage());
      throw new InvalidRequestException(Status.BAD_REQUEST, e, message);
    }

  }
View Full Code Here

  public void setJobRetries(JobRetriesDto dto) {
    try {
      ManagementService managementService = engine.getManagementService();
      managementService.setJobRetriesByJobDefinitionId(jobDefinitionId, dto.getRetries());
    } catch (ProcessEngineException e) {
      throw new InvalidRequestException(Status.INTERNAL_SERVER_ERROR, e.getMessage());
    }
  }
View Full Code Here

    Authorization dbAuthorization = authorizationService.createAuthorizationQuery()
      .authorizationId(resourceId)
      .singleResult();

    if (dbAuthorization == null) {
      throw new InvalidRequestException(Status.NOT_FOUND, "Authorization with id " + resourceId + " does not exist.");

    } else {
      return dbAuthorization;

    }
View Full Code Here

      throw new RestException(Status.INTERNAL_SERVER_ERROR, e, errorMessage);
    }

    if (value == null) {
      String errorMessage = String.format("%s variable with name %s does not exist", getResourceTypeName(), variableName);
      throw new InvalidRequestException(Status.NOT_FOUND, errorMessage);
    }
    return value;
  }
View Full Code Here

      }

      return new ByteArrayInputStream(valueBytes);
    }
    else {
      throw new InvalidRequestException(Status.BAD_REQUEST, "Variable '"+variableName+"' is not of type 'Bytes' but of type '"+typedValue.getType()+"'.");
    }
  }
View Full Code Here

    try {
      TypedValue typedValue = variable.toTypedValue(engine, objectMapper);
      setVariableEntity(variableName, typedValue);

    } catch (RestException e) {
      throw new InvalidRequestException(e.getStatus(), e,
        String.format("Cannot put %s variable %s: %s", getResourceTypeName(), variableName, e.getMessage()));
    } catch (BadUserRequestException e) {
      throw new RestException(Status.BAD_REQUEST, e,
        String.format("Cannot put %s variable %s: %s", getResourceTypeName(), variableName, e.getMessage()));
View Full Code Here

          && 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());
      }

      if(object != null) {
        setVariableEntity(variableKey, Variables.objectValue(object).create());
      }
View Full Code Here

      JavaType type = TypeFactory.fromCanonical(className);

      return objectMapper.readValue(new String(data, Charset.forName("UTF-8")), type);

    } catch(Exception e) {
      throw new InvalidRequestException(Status.INTERNAL_SERVER_ERROR, "Could not deserialize JSON object: "+e.getMessage());

    }
  }
View Full Code Here

TOP

Related Classes of org.camunda.bpm.engine.rest.exception.InvalidRequestException

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.