use of org.wso2.carbon.bpmn.rest.common.RestResponseFactory in project carbon-business-process by wso2.
the class WorkflowTaskService method getIdentityLinksForFamily.
@GET
@Path("/{taskId}/identitylinks/{family}")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getIdentityLinksForFamily(@PathParam("taskId") String taskId, @PathParam("family") String family) {
Task task = getTaskFromRequest(taskId);
TaskService taskService = BPMNOSGIService.getTaskService();
if (family == null || (!RestUrls.SEGMENT_IDENTITYLINKS_FAMILY_GROUPS.equals(family) && !RestUrls.SEGMENT_IDENTITYLINKS_FAMILY_USERS.equals(family))) {
throw new ActivitiIllegalArgumentException("Identity link family should be 'users' or 'groups'.");
}
boolean isUser = family.equals(RestUrls.SEGMENT_IDENTITYLINKS_FAMILY_USERS);
List<RestIdentityLink> results = new ArrayList<RestIdentityLink>();
List<IdentityLink> allLinks = taskService.getIdentityLinksForTask(task.getId());
for (IdentityLink link : allLinks) {
boolean match = false;
if (isUser) {
match = link.getUserId() != null;
} else {
match = link.getGroupId() != null;
}
if (match) {
results.add(new RestResponseFactory().createRestIdentityLink(link, uriInfo.getBaseUri().toString()));
}
}
RestIdentityLinkCollection restIdentityLinkCollection = new RestIdentityLinkCollection();
restIdentityLinkCollection.setRestIdentityLinks(results);
return Response.ok().entity(restIdentityLinkCollection).build();
}
use of org.wso2.carbon.bpmn.rest.common.RestResponseFactory in project carbon-business-process by wso2.
the class WorkflowTaskService method getComment.
@GET
@Path("/{taskId}/comments/{commentId}")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getComment(@PathParam("taskId") String taskId, @PathParam("commentId") String commentId) {
HistoricTaskInstance task = getHistoricTaskFromRequest(taskId);
TaskService taskService = BPMNOSGIService.getTaskService();
Comment comment = taskService.getComment(commentId);
if (comment == null || !task.getId().equals(comment.getTaskId())) {
throw new ActivitiObjectNotFoundException("Task '" + task.getId() + "' doesn't have a comment with id '" + commentId + "'.", Comment.class);
}
return Response.ok().entity(new RestResponseFactory().createRestComment(comment, uriInfo.getBaseUri().toString())).build();
}
use of org.wso2.carbon.bpmn.rest.common.RestResponseFactory in project carbon-business-process by wso2.
the class WorkflowTaskService method createSimpleAttachment.
protected AttachmentResponse createSimpleAttachment(AttachmentRequest attachmentRequest, Task task) {
if (attachmentRequest.getName() == null) {
throw new ActivitiIllegalArgumentException("Attachment name is required.");
}
TaskService taskService = BPMNOSGIService.getTaskService();
Attachment createdAttachment = taskService.createAttachment(attachmentRequest.getType(), task.getId(), task.getProcessInstanceId(), attachmentRequest.getName(), attachmentRequest.getDescription(), attachmentRequest.getExternalUrl());
return new RestResponseFactory().createAttachmentResponse(createdAttachment, uriInfo.getBaseUri().toString());
}
use of org.wso2.carbon.bpmn.rest.common.RestResponseFactory in project carbon-business-process by wso2.
the class WorkflowTaskService method getAttachments.
@GET
@Path("/{taskId}/attachments")
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response getAttachments(@PathParam("taskId") String taskId) {
List<AttachmentResponse> result = new ArrayList<AttachmentResponse>();
HistoricTaskInstance task = getHistoricTaskFromRequest(taskId);
TaskService taskService = BPMNOSGIService.getTaskService();
RestResponseFactory restResponseFactory = new RestResponseFactory();
String baseUri = uriInfo.getBaseUri().toString();
for (Attachment attachment : taskService.getProcessInstanceAttachments(task.getProcessInstanceId())) {
result.add(restResponseFactory.createAttachmentResponse(attachment, baseUri));
}
AttachmentResponseCollection attachmentResponseCollection = new AttachmentResponseCollection();
attachmentResponseCollection.setAttachmentResponseList(result);
return Response.ok().entity(attachmentResponseCollection).build();
}
use of org.wso2.carbon.bpmn.rest.common.RestResponseFactory in project carbon-business-process by wso2.
the class WorkflowTaskService method createTask.
/**
* Create a new task instance for a process instance.
* @param taskRequest
* @return
*/
@POST
@Path("/")
@Consumes({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
@Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML })
public Response createTask(TaskRequest taskRequest) {
TaskService taskService = BPMNOSGIService.getTaskService();
Task task = taskService.newTask();
// Populate the task properties based on the request
populateTaskFromRequest(task, taskRequest);
if (taskRequest.isTenantIdSet()) {
((TaskEntity) task).setTenantId(taskRequest.getTenantId());
}
taskService.saveTask(task);
return Response.ok().entity(new RestResponseFactory().createTaskResponse(task, uriInfo.getBaseUri().toString())).build();
}
Aggregations