use of org.activiti.engine.task.IdentityLink in project Activiti by Activiti.
the class ProcessDefinitionIdentityLinkResource method getIdentityLink.
@RequestMapping(value = "/repository/process-definitions/{processDefinitionId}/identitylinks/{family}/{identityId}", method = RequestMethod.GET, produces = "application/json")
public RestIdentityLink getIdentityLink(@PathVariable("processDefinitionId") String processDefinitionId, @PathVariable("family") String family, @PathVariable("identityId") String identityId, HttpServletRequest request) {
ProcessDefinition processDefinition = getProcessDefinitionFromRequest(processDefinitionId);
validateIdentityLinkArguments(family, identityId);
// Check if identitylink to get exists
IdentityLink link = getIdentityLink(family, identityId, processDefinition.getId());
return restResponseFactory.createRestIdentityLink(link);
}
use of org.activiti.engine.task.IdentityLink in project Activiti by Activiti.
the class ProcessDefinitionIdentityLinkResource method getIdentityLink.
protected IdentityLink getIdentityLink(String family, String identityId, String processDefinitionId) {
boolean isUser = family.equals(RestUrls.SEGMENT_IDENTITYLINKS_FAMILY_USERS);
// Perhaps it would be better to offer getting a single identitylink from
// the API
List<IdentityLink> allLinks = repositoryService.getIdentityLinksForProcessDefinition(processDefinitionId);
for (IdentityLink link : allLinks) {
boolean rightIdentity = false;
if (isUser) {
rightIdentity = identityId.equals(link.getUserId());
} else {
rightIdentity = identityId.equals(link.getGroupId());
}
if (rightIdentity && link.getType().equals(IdentityLinkType.CANDIDATE)) {
return link;
}
}
throw new ActivitiObjectNotFoundException("Could not find the requested identity link.", IdentityLink.class);
}
use of org.activiti.engine.task.IdentityLink in project Activiti by Activiti.
the class TaskIdentityLinkFamilyResource method getIdentityLinksForFamily.
@RequestMapping(value = "/runtime/tasks/{taskId}/identitylinks/{family}", method = RequestMethod.GET, produces = "application/json")
public List<RestIdentityLink> getIdentityLinksForFamily(@PathVariable("taskId") String taskId, @PathVariable("family") String family, HttpServletRequest request) {
Task task = getTaskFromRequest(taskId);
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(restResponseFactory.createRestIdentityLink(link));
}
}
return results;
}
use of org.activiti.engine.task.IdentityLink in project Activiti by Activiti.
the class TaskIdentityLinkResource method getIdentityLink.
protected IdentityLink getIdentityLink(String family, String identityId, String type, String taskId) {
boolean isUser = family.equals(RestUrls.SEGMENT_IDENTITYLINKS_FAMILY_USERS);
// Perhaps it would be better to offer getting a single identitylink from the API
List<IdentityLink> allLinks = taskService.getIdentityLinksForTask(taskId);
for (IdentityLink link : allLinks) {
boolean rightIdentity = false;
if (isUser) {
rightIdentity = identityId.equals(link.getUserId());
} else {
rightIdentity = identityId.equals(link.getGroupId());
}
if (rightIdentity && link.getType().equals(type)) {
return link;
}
}
throw new ActivitiObjectNotFoundException("Could not find the requested identity link.", IdentityLink.class);
}
use of org.activiti.engine.task.IdentityLink in project Activiti by Activiti.
the class ProcessInstanceIdentityLinkResource method getIdentityLink.
@RequestMapping(value = "/runtime/process-instances/{processInstanceId}/identitylinks/users/{identityId}/{type}", method = RequestMethod.GET, produces = "application/json")
public RestIdentityLink getIdentityLink(@PathVariable("processInstanceId") String processInstanceId, @PathVariable("identityId") String identityId, @PathVariable("type") String type, HttpServletRequest request) {
ProcessInstance processInstance = getProcessInstanceFromRequest(processInstanceId);
validateIdentityLinkArguments(identityId, type);
IdentityLink link = getIdentityLink(identityId, type, processInstance.getId());
return restResponseFactory.createRestIdentityLink(link);
}
Aggregations