use of org.activiti.engine.RuntimeService in project carbon-business-process by wso2.
the class ProcessInstanceService method deleteVariable.
@DELETE
@Path("/{processInstanceId}/variables/{variableName}")
public Response deleteVariable(@PathParam("processInstanceId") String processInstanceId, @PathParam("variableName") String variableName) {
String scope = uriInfo.getQueryParameters().getFirst("scope");
Execution execution = getExecutionInstanceFromRequest(processInstanceId);
// Determine scope
RestVariable.RestVariableScope variableScope = RestVariable.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);
}
RuntimeService runtimeService = BPMNOSGIService.getRuntimeService();
if (variableScope == RestVariable.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);
}
return Response.ok().status(Response.Status.NO_CONTENT).build();
}
use of org.activiti.engine.RuntimeService in project carbon-business-process by wso2.
the class ProcessInstanceService method setVariable.
protected void setVariable(Execution execution, String name, Object value, RestVariable.RestVariableScope scope, boolean isNew) {
// Create can only be done on new variables. Existing variables should be updated using PUT
if (log.isDebugEnabled()) {
log.debug("Going to invoke has variable from set binary variable");
}
boolean hasVariable = hasVariableOnScope(execution, name, scope);
if (isNew && hasVariable) {
throw new ActivitiException("Variable '" + name + "' is already present on execution '" + execution.getId() + "'.");
}
if (!isNew && !hasVariable) {
throw new ActivitiObjectNotFoundException("Execution '" + execution.getId() + "' doesn't have a variable with name: '" + name + "'.", null);
}
RuntimeService runtimeService = BPMNOSGIService.getRuntimeService();
if (scope == RestVariable.RestVariableScope.LOCAL) {
runtimeService.setVariableLocal(execution.getId(), name, value);
} else {
if (execution.getParentId() != null) {
runtimeService.setVariable(execution.getParentId(), name, value);
} else {
runtimeService.setVariable(execution.getId(), name, value);
}
}
}
use of org.activiti.engine.RuntimeService in project carbon-business-process by wso2.
the class ProcessInstanceService method deleteIdentityLink.
@DELETE
@Path("/{processInstanceId}/identitylinks/users/{identityId}/{type}")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response deleteIdentityLink(@PathParam("processInstanceId") String processInstanceId, @PathParam("identityId") String identityId, @PathParam("type") String type) {
ProcessInstance processInstance = getProcessInstanceFromRequest(processInstanceId);
validateIdentityLinkArguments(identityId, type);
getIdentityLink(identityId, type, processInstance.getId());
RuntimeService runtimeService = BPMNOSGIService.getRuntimeService();
runtimeService.deleteUserIdentityLink(processInstance.getId(), identityId, type);
return Response.ok().status(Response.Status.NO_CONTENT).build();
}
use of org.activiti.engine.RuntimeService in project carbon-business-process by wso2.
the class ProcessInstanceService method createIdentityLink.
@POST
@Path("/{processInstanceId}/identitylinks")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response createIdentityLink(@PathParam("processInstanceId") String processInstanceId, RestIdentityLink identityLink) {
ProcessInstance processInstance = getProcessInstanceFromRequest(processInstanceId);
if (identityLink.getGroup() != null) {
throw new ActivitiIllegalArgumentException("Only user identity links are supported on a process instance.");
}
if (identityLink.getUser() == null) {
throw new ActivitiIllegalArgumentException("The user is required.");
}
if (identityLink.getType() == null) {
throw new ActivitiIllegalArgumentException("The identity link type is required.");
}
RuntimeService runtimeService = BPMNOSGIService.getRuntimeService();
runtimeService.addUserIdentityLink(processInstance.getId(), identityLink.getUser(), identityLink.getType());
RestIdentityLink restIdentityLink = new RestResponseFactory().createRestIdentityLink(identityLink.getType(), identityLink.getUser(), identityLink.getGroup(), null, null, processInstance.getId(), uriInfo.getBaseUri().toString());
return Response.ok().status(Response.Status.CREATED).entity(restIdentityLink).build();
}
use of org.activiti.engine.RuntimeService in project carbon-business-process by wso2.
the class ProcessInstanceService method deleteProcessInstance.
@DELETE
@Path("/{processInstanceId}")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response deleteProcessInstance(@PathParam("processInstanceId") String processInstanceId) {
RuntimeService runtimeService = BPMNOSGIService.getRuntimeService();
String deleteReason = uriInfo.getQueryParameters().getFirst("deleteReason");
if (deleteReason == null) {
deleteReason = "";
}
ProcessInstance processInstance = getProcessInstanceFromRequest(processInstanceId);
runtimeService.deleteProcessInstance(processInstance.getId(), deleteReason);
return Response.ok().status(Response.Status.NO_CONTENT).build();
}
Aggregations