use of org.wso2.carbon.bpmn.rest.model.common.RestIdentityLink 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();
}
Aggregations