use of org.camunda.bpm.engine.rest.dto.VariableValueDto in project camunda-bpm-platform by camunda.
the class AbstractVariablesResource method setBinaryVariable.
public void setBinaryVariable(String variableKey, MultipartFormData payload) {
FormPart dataPart = payload.getNamedPart("data");
FormPart objectTypePart = payload.getNamedPart("type");
FormPart valueTypePart = payload.getNamedPart("valueType");
if (objectTypePart != null) {
Object object = null;
if (dataPart.getContentType() != null && dataPart.getContentType().toLowerCase().contains(MediaType.APPLICATION_JSON)) {
object = deserializeJsonObject(objectTypePart.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());
}
} else {
String valueTypeName = DEFAULT_BINARY_VALUE_TYPE;
if (valueTypePart != null) {
if (valueTypePart.getTextContent() == null) {
throw new InvalidRequestException(Status.BAD_REQUEST, "Form part with name 'valueType' must have a text/plain value");
}
valueTypeName = valueTypePart.getTextContent();
}
VariableValueDto valueDto = VariableValueDto.fromFormPart(valueTypeName, dataPart);
try {
TypedValue typedValue = valueDto.toTypedValue(engine, objectMapper);
setVariableEntity(variableKey, typedValue);
} catch (AuthorizationException e) {
throw e;
} catch (ProcessEngineException e) {
String errorMessage = String.format("Cannot put %s variable %s: %s", getResourceTypeName(), variableKey, e.getMessage());
throw new RestException(Status.INTERNAL_SERVER_ERROR, e, errorMessage);
}
}
}
use of org.camunda.bpm.engine.rest.dto.VariableValueDto in project camunda-bpm-platform by camunda.
the class HalVariableValue method fromVariableInstance.
public static HalVariableValue fromVariableInstance(VariableInstance variableInstance) {
HalVariableValue dto = new HalVariableValue();
VariableValueDto variableValueDto = VariableValueDto.fromTypedValue(variableInstance.getTypedValue());
dto.name = variableInstance.getName();
dto.value = variableValueDto.getValue();
dto.type = variableValueDto.getType();
dto.valueInfo = variableValueDto.getValueInfo();
return dto;
}
Aggregations