use of org.wso2.carbon.bpmn.rest.common.exception.BPMNRestException in project carbon-business-process by wso2.
the class ProcessInstanceService method createBinaryExecutionVariable.
@POST
@Path("/{processInstanceId}/variables")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@Consumes(MediaType.MULTIPART_FORM_DATA)
public Response createBinaryExecutionVariable(@PathParam("processInstanceId") String processInstanceId, @Context HttpServletRequest httpServletRequest, MultipartBody multipartBody) {
Execution execution = getExecutionInstanceFromRequest(processInstanceId);
Response response;
try {
response = createBinaryExecutionVariable(execution, false, RestResponseFactory.VARIABLE_PROCESS, multipartBody);
} catch (IOException | ServletException e) {
throw new BPMNRestException("Exception occured during creating binary execution variable", e);
}
return response;
}
use of org.wso2.carbon.bpmn.rest.common.exception.BPMNRestException in project carbon-business-process by wso2.
the class ProcessInstanceService method createOrUpdateExecutionVariable.
@PUT
@Path("/{processInstanceId}/variables")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response createOrUpdateExecutionVariable(@PathParam("processInstanceId") String processInstanceId, @Context HttpServletRequest httpServletRequest) {
Execution execution = getExecutionInstanceFromRequest(processInstanceId);
Response result;
try {
result = createExecutionVariable(execution, true, RestResponseFactory.VARIABLE_PROCESS, httpServletRequest);
} catch (IOException | ServletException e) {
throw new BPMNRestException("Exception occured during creating execution variable", e);
}
return result;
}
use of org.wso2.carbon.bpmn.rest.common.exception.BPMNRestException in project carbon-business-process by wso2.
the class AnalyticsConfigurationService method configureProcessLevelEvents.
@PUT
@Path("/processes/{process_id}")
@Consumes({ MediaType.APPLICATION_JSON })
public void configureProcessLevelEvents(@PathParam("process_id") String processDefinitionId, DataPublisherConfig dataPublisherConfig) {
try {
RepositoryService repositoryService = BPMNOSGIService.getRepositoryService();
ProcessDefinition process = repositoryService.getProcessDefinition(processDefinitionId);
if (process != null && process instanceof ProcessDefinitionEntity) {
ProcessDefinitionEntity processDefinitionEntity = (ProcessDefinitionEntity) process;
if (dataPublisherConfig.isEnabled()) {
List<ExecutionListener> endListeners = processDefinitionEntity.getExecutionListeners(PvmEvent.EVENTNAME_END);
ExecutionListener processTerminationListener = null;
for (ExecutionListener listener : endListeners) {
if (listener instanceof ProcessTerminationListener) {
processTerminationListener = listener;
break;
}
}
if (processTerminationListener == null) {
if (log.isDebugEnabled()) {
log.debug("Adding process termination listener to process: " + processDefinitionId);
}
processDefinitionEntity.addExecutionListener(PvmEvent.EVENTNAME_END, new ProcessTerminationListener());
}
} else {
List<ExecutionListener> endListeners = processDefinitionEntity.getExecutionListeners(PvmEvent.EVENTNAME_END);
ExecutionListener processTerminationListener = null;
for (ExecutionListener listener : endListeners) {
if (listener instanceof ProcessTerminationListener) {
processTerminationListener = listener;
break;
}
}
if (processTerminationListener != null) {
if (log.isDebugEnabled()) {
log.debug("Removing process termination listener from process: " + processDefinitionId);
}
endListeners.remove(processTerminationListener);
}
}
}
} catch (Exception e) {
String msg = "Failed to configure events for process: " + processDefinitionId;
log.error(msg, e);
throw new BPMNRestException(msg, e);
}
}
use of org.wso2.carbon.bpmn.rest.common.exception.BPMNRestException in project carbon-business-process by wso2.
the class AnalyticsConfigurationService method configureTaskLevelEvents.
@PUT
@Path("/processes/{process_id}/tasks/{task_id}")
@Consumes({ MediaType.APPLICATION_JSON })
public void configureTaskLevelEvents(@PathParam("process_id") String processDefinitionId, @PathParam("task_id") String taskId, DataPublisherConfig dataPublisherConfig) {
try {
RepositoryService repositoryService = BPMNOSGIService.getRepositoryService();
ProcessDefinition process = repositoryService.getProcessDefinition(processDefinitionId);
if (process != null && process instanceof ProcessDefinitionEntity) {
ProcessDefinitionEntity processDefinitionEntity = (ProcessDefinitionEntity) process;
Map<String, TaskDefinition> taskDefinitions = processDefinitionEntity.getTaskDefinitions();
TaskDefinition taskDefinition = taskDefinitions.get(taskId);
if (taskDefinition != null) {
if (dataPublisherConfig.isEnabled()) {
List<TaskListener> completionListeners = taskDefinition.getTaskListener(TaskListener.EVENTNAME_COMPLETE);
TaskListener taskCompletionListener = null;
for (TaskListener listener : completionListeners) {
if (listener instanceof TaskCompletionListener) {
taskCompletionListener = listener;
break;
}
}
if (taskCompletionListener == null) {
if (log.isDebugEnabled()) {
log.debug("Adding task completion listener to task: " + taskId + " of process: " + processDefinitionId);
}
taskDefinition.addTaskListener(TaskListener.EVENTNAME_COMPLETE, new TaskCompletionListener());
}
} else {
List<TaskListener> completionListeners = taskDefinition.getTaskListener(TaskListener.EVENTNAME_COMPLETE);
TaskListener taskCompletionListener = null;
for (TaskListener listener : completionListeners) {
if (listener instanceof TaskCompletionListener) {
taskCompletionListener = listener;
break;
}
}
if (taskCompletionListener != null) {
if (log.isDebugEnabled()) {
log.debug("Removing task completion listener from task: " + taskId + " of process: " + processDefinitionId);
}
completionListeners.remove(taskCompletionListener);
}
}
}
}
} catch (Exception e) {
String msg = "Failed to configure events for task: " + taskId + " of process: " + processDefinitionId;
log.error(msg, e);
throw new BPMNRestException(msg, e);
}
}
use of org.wso2.carbon.bpmn.rest.common.exception.BPMNRestException in project carbon-business-process by wso2.
the class ProcessInstanceService method createOrUpdateBinaryExecutionVariable.
@PUT
@Path("/{processInstanceId}/variables")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@Consumes(MediaType.MULTIPART_FORM_DATA)
public Response createOrUpdateBinaryExecutionVariable(@PathParam("processInstanceId") String processInstanceId, MultipartBody multipartBody) {
Execution execution = getExecutionInstanceFromRequest(processInstanceId);
Response response;
try {
response = createBinaryExecutionVariable(execution, true, RestResponseFactory.VARIABLE_PROCESS, multipartBody);
} catch (IOException | ServletException e) {
throw new BPMNRestException("Exception occured during creating execution variable", e);
}
return response;
}
Aggregations