@RequestMapping(value="/runtime/process-instances/{processInstanceId}/variables/{variableName}", method = RequestMethod.DELETE)
public void deleteVariable(@PathVariable("processInstanceId") String processInstanceId,
@PathVariable("variableName") String variableName, @RequestParam(value="scope", required=false) String scope,
HttpServletResponse response) {
Execution execution = getProcessInstanceFromRequest(processInstanceId);
// Determine scope
RestVariableScope variableScope = RestVariableScope.LOCAL;
if (scope != null) {
variableScope = RestVariable.getScopeFromString(scope);
}
if (!hasVariableOnScope(execution, variableName, variableScope)) {
throw new ActivitiObjectNotFoundException("Execution '" + execution.getId() + "' doesn't have a variable '" +
variableName + "' in scope " + variableScope.name().toLowerCase(), VariableInstanceEntity.class);
}
if (variableScope == RestVariableScope.LOCAL) {
runtimeService.removeVariableLocal(execution.getId(), variableName);
} else {
// Safe to use parentId, as the hasVariableOnScope would have stopped a global-var update on a root-execution
runtimeService.removeVariable(execution.getParentId(), variableName);
}
response.setStatus(HttpStatus.NO_CONTENT.value());
}