use of org.wso2.carbon.bpmn.rest.common.RestResponseFactory in project carbon-business-process by wso2.
the class WorkflowTaskService method getAttachment.
@GET
@Path("/{taskId}/attachments/{attachmentId}")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getAttachment(@PathParam("taskId") String taskId, @PathParam("attachmentId") String attachmentId) {
HistoricTaskInstance task = getHistoricTaskFromRequest(taskId);
TaskService taskService = BPMNOSGIService.getTaskService();
Attachment attachment = taskService.getAttachment(attachmentId);
if (attachment == null) {
throw new ActivitiObjectNotFoundException("Task '" + task.getId() + "' doesn't have an attachment with id '" + attachmentId + "'.", Comment.class);
}
return Response.ok().entity(new RestResponseFactory().createAttachmentResponse(attachment, uriInfo.getBaseUri().toString())).build();
}
use of org.wso2.carbon.bpmn.rest.common.RestResponseFactory in project carbon-business-process by wso2.
the class HistoricProcessInstanceQueryService method addVariables.
protected void addVariables(org.activiti.engine.history.HistoricProcessInstanceQuery processInstanceQuery, List<QueryVariable> variables) {
for (QueryVariable variable : variables) {
if (variable.getVariableOperation() == null) {
throw new ActivitiIllegalArgumentException("Variable operation is missing for variable: " + variable.getName());
}
if (variable.getValue() == null) {
throw new ActivitiIllegalArgumentException("Variable value is missing for variable: " + variable.getName());
}
boolean nameLess = variable.getName() == null;
Object actualValue = new RestResponseFactory().getVariableValue(variable);
// A value-only query is only possible using equals-operator
if (nameLess && variable.getVariableOperation() != QueryVariable.QueryVariableOperation.EQUALS) {
throw new ActivitiIllegalArgumentException("Value-only query (without a variable-name) is only supported when using 'equals' operation.");
}
switch(variable.getVariableOperation()) {
case EQUALS:
if (nameLess) {
processInstanceQuery.variableValueEquals(actualValue);
} else {
processInstanceQuery.variableValueEquals(variable.getName(), actualValue);
}
break;
case EQUALS_IGNORE_CASE:
if (actualValue instanceof String) {
processInstanceQuery.variableValueEqualsIgnoreCase(variable.getName(), (String) actualValue);
} else {
throw new ActivitiIllegalArgumentException("Only string variable values are supported when ignoring casing, but was: " + actualValue.getClass().getName());
}
break;
case NOT_EQUALS:
processInstanceQuery.variableValueNotEquals(variable.getName(), actualValue);
break;
case LIKE:
if (actualValue instanceof String) {
processInstanceQuery.variableValueLike(variable.getName(), (String) actualValue);
} else {
throw new ActivitiIllegalArgumentException("Only string variable values are supported for like, but was: " + actualValue.getClass().getName());
}
break;
case GREATER_THAN:
processInstanceQuery.variableValueGreaterThan(variable.getName(), actualValue);
break;
case GREATER_THAN_OR_EQUALS:
processInstanceQuery.variableValueGreaterThanOrEqual(variable.getName(), actualValue);
break;
case LESS_THAN:
processInstanceQuery.variableValueLessThan(variable.getName(), actualValue);
break;
case LESS_THAN_OR_EQUALS:
processInstanceQuery.variableValueLessThanOrEqual(variable.getName(), actualValue);
break;
default:
throw new ActivitiIllegalArgumentException("Unsupported variable query operation: " + variable.getVariableOperation());
}
}
}
use of org.wso2.carbon.bpmn.rest.common.RestResponseFactory in project carbon-business-process by wso2.
the class DeploymentService method getDeploymentResources.
@GET
@Path("/{deploymentId}/resources")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getDeploymentResources(@PathParam("deploymentId") String deploymentId) {
RepositoryService repositoryService = BPMNOSGIService.getRepositoryService();
// Check if deployment exists
Deployment deployment = repositoryService.createDeploymentQuery().deploymentId(deploymentId).singleResult();
if (deployment == null) {
throw new ActivitiObjectNotFoundException("Could not find a deployment with id '" + deploymentId + "'.", Deployment.class);
}
List<String> resourceList = repositoryService.getDeploymentResourceNames(deploymentId);
DeploymentResourceResponseCollection deploymentResourceResponseCollection = new RestResponseFactory().createDeploymentResourceResponseList(deploymentId, resourceList, uriInfo.getBaseUri().toString());
return Response.ok().entity(deploymentResourceResponseCollection).build();
}
use of org.wso2.carbon.bpmn.rest.common.RestResponseFactory in project carbon-business-process by wso2.
the class DeploymentService method getDeploymentResourceForDifferentUrl.
@GET
@Path("/{deploymentId}/resources/{resourcePath:.*}")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getDeploymentResourceForDifferentUrl(@PathParam("deploymentId") String deploymentId, @PathParam("resourcePath") String resourcePath) {
if (log.isDebugEnabled()) {
log.debug("deploymentId:" + deploymentId + " resourcePath:" + resourcePath);
}
RepositoryService repositoryService = BPMNOSGIService.getRepositoryService();
// Check if deployment exists
Deployment deployment = repositoryService.createDeploymentQuery().deploymentId(deploymentId).singleResult();
if (deployment == null) {
throw new ActivitiObjectNotFoundException("Could not find a deployment with id '" + deploymentId + "'.", Deployment.class);
}
List<String> resourceList = repositoryService.getDeploymentResourceNames(deploymentId);
if (resourceList.contains(resourcePath)) {
// Build resource representation
DeploymentResourceResponse deploymentResourceResponse = new RestResponseFactory().createDeploymentResourceResponse(deploymentId, resourcePath, Utils.resolveContentType(resourcePath), uriInfo.getBaseUri().toString());
return Response.ok().entity(deploymentResourceResponse).build();
} else {
// Resource not found in deployment
throw new ActivitiObjectNotFoundException("Could not find a resource with id '" + resourcePath + "' in deployment '" + deploymentId + "'.", Deployment.class);
}
}
use of org.wso2.carbon.bpmn.rest.common.RestResponseFactory in project carbon-business-process by wso2.
the class ProcessDefinitionService method getIdentityLinks.
@GET
@Path("/{processDefinitionId}/identitylinks")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getIdentityLinks(@PathParam("processDefinitionId") String processDefinitionId) {
RepositoryService repositoryService = BPMNOSGIService.getRepositoryService();
ProcessDefinition processDefinition = getProcessDefinitionFromRequest(processDefinitionId);
return Response.ok().entity(new RestResponseFactory().createRestIdentityLinks(repositoryService.getIdentityLinksForProcessDefinition(processDefinition.getId()), uriInfo.getBaseUri().toString())).build();
}
Aggregations