use of org.activiti.rest.service.api.engine.RestIdentityLink in project Activiti by Activiti.
the class RestResponseFactory method createRestIdentityLinks.
public List<RestIdentityLink> createRestIdentityLinks(List<IdentityLink> links) {
RestUrlBuilder urlBuilder = createUrlBuilder();
List<RestIdentityLink> responseList = new ArrayList<RestIdentityLink>();
for (IdentityLink instance : links) {
responseList.add(createRestIdentityLink(instance, urlBuilder));
}
return responseList;
}
use of org.activiti.rest.service.api.engine.RestIdentityLink 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.rest.service.api.engine.RestIdentityLink 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.rest.service.api.engine.RestIdentityLink 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);
}
use of org.activiti.rest.service.api.engine.RestIdentityLink in project Activiti by Activiti.
the class RestResponseFactory method createRestIdentityLink.
public RestIdentityLink createRestIdentityLink(String type, String userId, String groupId, String taskId, String processDefinitionId, String processInstanceId, RestUrlBuilder urlBuilder) {
RestIdentityLink result = new RestIdentityLink();
result.setUser(userId);
result.setGroup(groupId);
result.setType(type);
String family = null;
if (userId != null) {
family = RestUrls.SEGMENT_IDENTITYLINKS_FAMILY_USERS;
} else {
family = RestUrls.SEGMENT_IDENTITYLINKS_FAMILY_GROUPS;
}
if (processDefinitionId != null) {
result.setUrl(urlBuilder.buildUrl(RestUrls.URL_PROCESS_DEFINITION_IDENTITYLINK, processDefinitionId, family, (userId != null ? userId : groupId)));
} else if (taskId != null) {
result.setUrl(urlBuilder.buildUrl(RestUrls.URL_TASK_IDENTITYLINK, taskId, family, (userId != null ? userId : groupId), type));
} else {
result.setUrl(urlBuilder.buildUrl(RestUrls.URL_PROCESS_INSTANCE_IDENTITYLINK, processInstanceId, (userId != null ? userId : groupId), type));
}
return result;
}
Aggregations