@Test public void testGetFormDisplayTaskUsesRequestorIdentity() { when(config.getConfigItemValue(eq(KieServerConstants.CFG_BYPASS_AUTH_USER), anyString())).thenReturn("false"); FormServiceBase formServiceBase = new FormServiceBase(definitionService, dataService, userTaskService, formManagerService, kieServerRegistry); String userId = "john"; formServiceBase.getFormDisplayTask(CONTAINER_ID, 1L, userId, "en_US", true, FormServiceBase.FormType.ANY.getName()); verify(kieServerRegistry, times(1)).getIdentityProvider(); ArgumentCaptor<GetUserTaskCommand> argument = ArgumentCaptor.forClass(GetUserTaskCommand.class); verify(userTaskService, times(1)).execute(eq(CONTAINER_ID), argument.capture()); Assert.assertEquals("admin", argument.getValue().getUserId()); }
public String getFormDisplayTask(String containerId, long taskId, String userId, String lang, boolean filterContent, String formType) { containerId = registry.getContainerId(containerId, new ByTaskIdContainerLocator(taskId)); userId = getUser(userId); Task task = userTaskService.execute(containerId, new GetUserTaskCommand(userId, taskId)); if (task == null) { throw new IllegalStateException("No task with id " + taskId + " found"); } String name = task.getName(); ProcessDefinition processDesc = dataService.getProcessesByDeploymentIdProcessId(containerId, task.getTaskData().getProcessId()); Map<String, Object> renderContext = new HashMap<>(); renderContext.put("filterForm", filterContent); Map<String, Object> input = userTaskService.getTaskInputContentByTaskId(containerId, taskId); renderContext.put("inputs", input); for (Map.Entry<String, Object> inputVar : input.entrySet()) { renderContext.put(inputVar.getKey(), inputVar.getValue()); } Map<String, String> outputDef = definitionService.getTaskOutputMappings(containerId, task.getTaskData().getProcessId(), task.getName()); Map<String, Object> output = userTaskService.getTaskOutputContentByTaskId(containerId, taskId); renderContext.put("outputs", output); for (Map.Entry<String, Object> outputVar : output.entrySet()) { renderContext.put(outputVar.getKey(), outputVar.getValue()); } outputDef.forEach((k, v) -> { if (!renderContext.containsKey(k)) { renderContext.put(k, ""); } }); renderContext.put("lang", lang); renderContext.put("task", task); for (UIFormProvider provider : providers) { if (!FormType.ANY.getName().equals(formType) && !provider.getType().equals(formType)) { logger.debug("Provider {} does not support {} form type", provider, formType); continue; } String template = provider.render(name, task, processDesc, renderContext); if (!StringUtils.isEmpty(template)) { return template; } } logger.warn("Unable to find form to render for task '{}' on process '{}'", name, processDesc.getName()); throw new IllegalStateException("No form for task with id " + taskId + " found"); }
FormServiceBase { public String getFormDisplayTask(String containerId, long taskId, String userId, String lang, boolean filterContent, String formType) { containerId = registry.getContainerId(containerId, new ByTaskIdContainerLocator(taskId)); userId = getUser(userId); Task task = userTaskService.execute(containerId, new GetUserTaskCommand(userId, taskId)); if (task == null) { throw new IllegalStateException("No task with id " + taskId + " found"); } String name = task.getName(); ProcessDefinition processDesc = dataService.getProcessesByDeploymentIdProcessId(containerId, task.getTaskData().getProcessId()); Map<String, Object> renderContext = new HashMap<>(); renderContext.put("filterForm", filterContent); Map<String, Object> input = userTaskService.getTaskInputContentByTaskId(containerId, taskId); renderContext.put("inputs", input); for (Map.Entry<String, Object> inputVar : input.entrySet()) { renderContext.put(inputVar.getKey(), inputVar.getValue()); } Map<String, String> outputDef = definitionService.getTaskOutputMappings(containerId, task.getTaskData().getProcessId(), task.getName()); Map<String, Object> output = userTaskService.getTaskOutputContentByTaskId(containerId, taskId); renderContext.put("outputs", output); for (Map.Entry<String, Object> outputVar : output.entrySet()) { renderContext.put(outputVar.getKey(), outputVar.getValue()); } outputDef.forEach((k, v) -> { if (!renderContext.containsKey(k)) { renderContext.put(k, ""); } }); renderContext.put("lang", lang); renderContext.put("task", task); for (UIFormProvider provider : providers) { if (!FormType.ANY.getName().equals(formType) && !provider.getType().equals(formType)) { logger.debug("Provider {} does not support {} form type", provider, formType); continue; } String template = provider.render(name, task, processDesc, renderContext); if (!StringUtils.isEmpty(template)) { return template; } } logger.warn("Unable to find form to render for task '{}' on process '{}'", name, processDesc.getName()); throw new IllegalStateException("No form for task with id " + taskId + " found"); } }
FormServiceBase { public String getFormDisplayTask(String containerId, long taskId, String userId, String lang, boolean filterContent, String formType) { containerId = registry.getContainerId(containerId, new ByTaskIdContainerLocator(taskId)); userId = getUser(userId); Task task = userTaskService.execute(containerId, new GetUserTaskCommand(userId, taskId)); if (task == null) { throw new IllegalStateException("No task with id " + taskId + " found"); } String name = task.getName(); ProcessDefinition processDesc = dataService.getProcessesByDeploymentIdProcessId(containerId, task.getTaskData().getProcessId()); Map<String, Object> renderContext = new HashMap<>(); renderContext.put("filterForm", filterContent); Map<String, Object> input = userTaskService.getTaskInputContentByTaskId(containerId, taskId); renderContext.put("inputs", input); for (Map.Entry<String, Object> inputVar : input.entrySet()) { renderContext.put(inputVar.getKey(), inputVar.getValue()); } Map<String, String> outputDef = definitionService.getTaskOutputMappings(containerId, task.getTaskData().getProcessId(), task.getName()); Map<String, Object> output = userTaskService.getTaskOutputContentByTaskId(containerId, taskId); renderContext.put("outputs", output); for (Map.Entry<String, Object> outputVar : output.entrySet()) { renderContext.put(outputVar.getKey(), outputVar.getValue()); } outputDef.forEach((k, v) -> { if (!renderContext.containsKey(k)) { renderContext.put(k, ""); } }); renderContext.put("lang", lang); renderContext.put("task", task); for (UIFormProvider provider : providers) { if (!FormType.ANY.getName().equals(formType) && !provider.getType().equals(formType)) { logger.debug("Provider {} does not support {} form type", provider, formType); continue; } String template = provider.render(name, task, processDesc, renderContext); if (!StringUtils.isEmpty(template)) { return template; } } logger.warn("Unable to find form to render for task '{}' on process '{}'", name, processDesc.getName()); throw new IllegalStateException("No form for task with id " + taskId + " found"); } FormServiceBase(DefinitionService definitionService, RuntimeDataService dataService, UserTaskService userTaskService, FormManagerService formManagerService, KieServerRegistry registry); }
FormServiceBase { public String getFormDisplayTask(String containerId, long taskId, String userId, String lang, boolean filterContent, String formType) { containerId = registry.getContainerId(containerId, new ByTaskIdContainerLocator(taskId)); userId = getUser(userId); Task task = userTaskService.execute(containerId, new GetUserTaskCommand(userId, taskId)); if (task == null) { throw new IllegalStateException("No task with id " + taskId + " found"); } String name = task.getName(); ProcessDefinition processDesc = dataService.getProcessesByDeploymentIdProcessId(containerId, task.getTaskData().getProcessId()); Map<String, Object> renderContext = new HashMap<>(); renderContext.put("filterForm", filterContent); Map<String, Object> input = userTaskService.getTaskInputContentByTaskId(containerId, taskId); renderContext.put("inputs", input); for (Map.Entry<String, Object> inputVar : input.entrySet()) { renderContext.put(inputVar.getKey(), inputVar.getValue()); } Map<String, String> outputDef = definitionService.getTaskOutputMappings(containerId, task.getTaskData().getProcessId(), task.getName()); Map<String, Object> output = userTaskService.getTaskOutputContentByTaskId(containerId, taskId); renderContext.put("outputs", output); for (Map.Entry<String, Object> outputVar : output.entrySet()) { renderContext.put(outputVar.getKey(), outputVar.getValue()); } outputDef.forEach((k, v) -> { if (!renderContext.containsKey(k)) { renderContext.put(k, ""); } }); renderContext.put("lang", lang); renderContext.put("task", task); for (UIFormProvider provider : providers) { if (!FormType.ANY.getName().equals(formType) && !provider.getType().equals(formType)) { logger.debug("Provider {} does not support {} form type", provider, formType); continue; } String template = provider.render(name, task, processDesc, renderContext); if (!StringUtils.isEmpty(template)) { return template; } } logger.warn("Unable to find form to render for task '{}' on process '{}'", name, processDesc.getName()); throw new IllegalStateException("No form for task with id " + taskId + " found"); } FormServiceBase(DefinitionService definitionService, RuntimeDataService dataService, UserTaskService userTaskService, FormManagerService formManagerService, KieServerRegistry registry); String getFormDisplayProcess(String containerId, String processId, String lang, boolean filterContent, String formType); String getFormDisplayTask(String containerId,
                                     long taskId,
                                     String userId,
                                     String lang,
                                     boolean filterContent,
                                     String formType); }
FormServiceBase { public String getFormDisplayTask(String containerId, long taskId, String userId, String lang, boolean filterContent, String formType) { containerId = registry.getContainerId(containerId, new ByTaskIdContainerLocator(taskId)); userId = getUser(userId); Task task = userTaskService.execute(containerId, new GetUserTaskCommand(userId, taskId)); if (task == null) { throw new IllegalStateException("No task with id " + taskId + " found"); } String name = task.getName(); ProcessDefinition processDesc = dataService.getProcessesByDeploymentIdProcessId(containerId, task.getTaskData().getProcessId()); Map<String, Object> renderContext = new HashMap<>(); renderContext.put("filterForm", filterContent); Map<String, Object> input = userTaskService.getTaskInputContentByTaskId(containerId, taskId); renderContext.put("inputs", input); for (Map.Entry<String, Object> inputVar : input.entrySet()) { renderContext.put(inputVar.getKey(), inputVar.getValue()); } Map<String, String> outputDef = definitionService.getTaskOutputMappings(containerId, task.getTaskData().getProcessId(), task.getName()); Map<String, Object> output = userTaskService.getTaskOutputContentByTaskId(containerId, taskId); renderContext.put("outputs", output); for (Map.Entry<String, Object> outputVar : output.entrySet()) { renderContext.put(outputVar.getKey(), outputVar.getValue()); } outputDef.forEach((k, v) -> { if (!renderContext.containsKey(k)) { renderContext.put(k, ""); } }); renderContext.put("lang", lang); renderContext.put("task", task); for (UIFormProvider provider : providers) { if (!FormType.ANY.getName().equals(formType) && !provider.getType().equals(formType)) { logger.debug("Provider {} does not support {} form type", provider, formType); continue; } String template = provider.render(name, task, processDesc, renderContext); if (!StringUtils.isEmpty(template)) { return template; } } logger.warn("Unable to find form to render for task '{}' on process '{}'", name, processDesc.getName()); throw new IllegalStateException("No form for task with id " + taskId + " found"); } FormServiceBase(DefinitionService definitionService, RuntimeDataService dataService, UserTaskService userTaskService, FormManagerService formManagerService, KieServerRegistry registry); String getFormDisplayProcess(String containerId, String processId, String lang, boolean filterContent, String formType); String getFormDisplayTask(String containerId,
                                     long taskId,
                                     String userId,
                                     String lang,
                                     boolean filterContent,
                                     String formType); static final Logger logger; }