com.evolveum.midpoint.task.api.TaskManager.createTaskInstance()方法的使用及代码示例

x33g5p2x  于2022-01-30 转载在 其他  
字(11.5k)|赞(0)|评价(0)|浏览(103)

本文整理了Java中com.evolveum.midpoint.task.api.TaskManager.createTaskInstance()方法的一些代码示例,展示了TaskManager.createTaskInstance()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。TaskManager.createTaskInstance()方法的具体详情如下:
包路径:com.evolveum.midpoint.task.api.TaskManager
类名称:TaskManager
方法名:createTaskInstance

TaskManager.createTaskInstance介绍

[英]Creates new transient, running task instance. This is fact creates usual "synchronous" task. This is useful for normal day-to-day tasks that are either synchronous or start as a synchronous and are switched to asynchronous task later.
[中]创建新的临时运行任务实例。这就是通常的“同步”任务。这对于正常的日常任务很有用,这些任务要么是同步的,要么作为同步任务启动,然后切换到异步任务。

代码示例

代码示例来源:origin: Evolveum/midpoint

protected Task createTaskInstance(String operationName) {
  // TODO: better task initialization
  Task task = taskManager.createTaskInstance(operationName);
  setTaskOwner(task);
  task.setChannel(SchemaConstants.CHANNEL_WEB_SERVICE_URI);
  return task;
}

代码示例来源:origin: Evolveum/midpoint

protected <F extends FocusType, R extends AbstractRoleType> RoleSelectionSpecification getAssignableRoleSpecification(PrismObject<F> focus, Class<R> targetType, int assignmentOrder) throws ObjectNotFoundException, SchemaException, ConfigurationException, ExpressionEvaluationException, CommunicationException, SecurityViolationException {
  Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class+".getAssignableRoleSpecification");
  OperationResult result = task.getResult();
  RoleSelectionSpecification spec = modelInteractionService.getAssignableRoleSpecification(focus, targetType, assignmentOrder, task, result);
  assertSuccess(result);
  return spec;
}

代码示例来源:origin: Evolveum/midpoint

protected void assignRole(String userOid, String roleOid) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException {
  Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class+".assignRole");
  OperationResult result = task.getResult();
  assignRole(userOid, roleOid, task, result);
  assertSuccess(result);
}

代码示例来源:origin: Evolveum/midpoint

protected <O extends ObjectType> PrismObject<O> getObjectViaRepo(Class<O> type, String oid) throws ObjectNotFoundException, SchemaException {
  Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".getObject");
  OperationResult result = task.getResult();
  PrismObject<O> object = repositoryService.getObject(type, oid, null, result);
  result.computeStatus();
  TestUtil.assertSuccess(result);
  return object;
}

代码示例来源:origin: Evolveum/midpoint

protected <T extends ObjectType> PrismObject<T> searchObjectByName(Class<T> type, String name) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException {
  Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName()+".searchObjectByName");
  OperationResult result = task.getResult();
  PrismObject<T> out = searchObjectByName(type, name, task, result);
  result.computeStatus();
  TestUtil.assertSuccess(result);
  return out;
}

代码示例来源:origin: Evolveum/midpoint

protected void displayAllUsers() throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException {
  Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".displayAllUsers");
  OperationResult result = task.getResult();
  ResultHandler<UserType> handler = (object, parentResult) -> {
    display("User", object);
    return true;
  };
  modelService.searchObjectsIterative(UserType.class, null, handler, null, task, result);
  result.computeStatus();
  TestUtil.assertSuccess(result);
}

代码示例来源:origin: Evolveum/midpoint

protected void assignRole(String userOid, String roleOid, QName relation) throws ObjectNotFoundException,
    SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException,
  PolicyViolationException, SecurityViolationException {
  Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class+".assignRole");
  OperationResult result = task.getResult();
  assignRole(userOid, roleOid, relation, task, result);
  result.computeStatus();
  TestUtil.assertSuccess(result);
}

代码示例来源:origin: Evolveum/midpoint

@Test(expectedExceptions = IllegalArgumentException.class)
public void nullClass() throws Exception {
  Task task = taskManager.createTaskInstance("Get Object");
  controller.getObject(null, "abababab-abab-abab-abab-000000000001", null, task,
      task.getResult());
}

代码示例来源:origin: Evolveum/midpoint

protected <O extends ObjectType> PrismObject<O> assertGetAllow(Class<O> type, String oid, Collection<SelectorOptions<GetOperationOptions>> options) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException {
  Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class.getName() + ".assertGetAllow");
  OperationResult result = task.getResult();
  logAttempt("get", type, oid, null);
  PrismObject<O> object = modelService.getObject(type, oid, options, task, result);
  result.computeStatus();
  TestUtil.assertSuccess(result);
  logAllow("get", type, oid, null);
  return object;
}

代码示例来源:origin: Evolveum/midpoint

public UserType getShadowOwner(String shadowOid) {
  Task task = taskManager.createTaskInstance();
  try {
    PrismObject<UserType> owner = model.findShadowOwner(shadowOid, task, task.getResult());
    return owner.asObjectable();
  } catch (ObjectNotFoundException | SecurityViolationException | SchemaException | ConfigurationException | ExpressionEvaluationException | CommunicationException e) {
    // TODO Auto-generated catch block
    LOGGER.error("Could not find owner for shadow with oid " + shadowOid + ". Reason: " + e.getMessage());
  }
  return null;
}

代码示例来源:origin: Evolveum/midpoint

protected String dumpOrgTree(String topOrgOid, boolean dumpUsers) throws SchemaException, ObjectNotFoundException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException {
  Task task = taskManager.createTaskInstance(AbstractModelIntegrationTest.class+".assertSubOrgs");
  OperationResult result = task.getResult();
  PrismObject<OrgType> topOrg = modelService.getObject(OrgType.class, topOrgOid, null, task, result);
  String dump = dumpOrgTree(topOrg, dumpUsers, task, result);
  result.computeStatus();
  TestUtil.assertSuccess(result);
  return dump;
}

代码示例来源:origin: Evolveum/midpoint

protected void assertImportStreamAllow(File file) throws FileNotFoundException {
  Task task = taskManager.createTaskInstance(AbstractSecurityTest.class.getName() + ".assertImportStreamAllow");
  OperationResult result = task.getResult();
  InputStream stream = new FileInputStream(file);
  modelService.importObjectsFromStream(stream, null, task, result);
  result.computeStatus();
  TestUtil.assertSuccess(result);
}

代码示例来源:origin: Evolveum/midpoint

@Test
public void test110EvaluateExpressionEmployeeTypeNoneFilter() throws Exception {
  final String TEST_NAME = "testEvaluateExpressionEmployeeTypeNoneFilter";
  TestUtil.displayTestTitle(TEST_NAME);
  // GIVEN
  OperationResult result = new OperationResult(TestFilterExpression.class.getName() + "." + TEST_NAME);
  Task task = taskManager.createTaskInstance(TEST_NAME);
  ObjectFilter filter = evaluateExpressionAssertFilter("expression-employeeType-none-filter.xml",
      null, NoneFilter.class, task, result);
  executeFilter(filter, 0, task, result);
}

代码示例来源:origin: Evolveum/midpoint

@Test
public void test310TestResourceNoJars() throws Exception {
  TestUtil.displayTestTitle(this, "test310TestResourceNoJars");
  // GIVEN
  Task task = taskManager.createTaskInstance(TestBrokenResources.class.getName() + ".test310TestResourceNoJars");
  // WHEN
  OperationResult testResult = modelService.testResource(RESOURCE_DUMMY_NOJARS_OID, task);
  // THEN
  display("testResource result", testResult);
  TestUtil.assertFailure("testResource result", testResult);
}

代码示例来源:origin: Evolveum/midpoint

@Test(expectedExceptions = IllegalArgumentException.class)
public void nullResult() throws Exception {
  TestUtil.displayTestTitle("nullResult");
  controller.addObject(new UserType().asPrismObject(), null, taskManager.createTaskInstance(), null);
}

代码示例来源:origin: Evolveum/midpoint

protected <O extends ObjectType, T extends ObjectType> void assertIsAuthorized(String operationUrl, AuthorizationPhaseType phase, AuthorizationParameters<O,T> params, OwnerResolver ownerResolver) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SecurityViolationException {
  Task task = taskManager.createTaskInstance(AbstractSecurityTest.class.getName() + ".assertIsAuthorized");
  OperationResult result = task.getResult();
  boolean authorized = securityEnforcer.isAuthorized(operationUrl, phase, params, ownerResolver, task, result);
  assertTrue("Expected isAuthorized for "+QNameUtil.uriToQName(operationUrl).getLocalPart()+" with "+params+", but we are not authorized", authorized);
  result.computeStatus();
  TestUtil.assertSuccess(result);
}

代码示例来源:origin: Evolveum/midpoint

private String addAccount(File file) throws SchemaException, ObjectAlreadyExistsException, CommunicationException, ObjectNotFoundException, ConfigurationException, SecurityViolationException, IOException, ExpressionEvaluationException, PolicyViolationException {
  Task task = taskManager.createTaskInstance(TestDummyResourceAndSchemaCaching.class.getName()
      + ".addAccount");
  OperationResult result = task.getResult();
  PrismObject<ShadowType> account = PrismTestUtil.parseObject(file);
  String oid = provisioningService.addObject(account, null, null, task, result);
  result.computeStatus();
  TestUtil.assertSuccess(result);
  return oid;
}

代码示例来源:origin: Evolveum/midpoint

@Override
public void initSystem(Task initTask, OperationResult initResult) throws Exception {
  super.initSystem(initTask, initResult);
  InternalMonitor.setTrace(InternalOperationClasses.CONNECTOR_OPERATIONS, true);
  // in order to have schema available here
  resourceType = provisioningService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null, taskManager.createTaskInstance(), initResult).asObjectable();
}

代码示例来源:origin: Evolveum/midpoint

@Override
protected void cleanupAutzTest(String userOid, int expectedAssignments) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException, IOException {
  super.cleanupAutzTest(userOid, expectedAssignments);
  Task task = taskManager.createTaskInstance(TestSecurityAdvanced.class.getName() + ".cleanupAutzTest");
  OperationResult result = task.getResult();
  assignRole(userRumRogersOid, ROLE_ORDINARY_OID, task, result);
  assignRole(userRumRogersOid, ROLE_UNINTERESTING_OID, task, result);
  assignRole(userCobbOid, ROLE_ORDINARY_OID, task, result);
  assignRole(userCobbOid, ROLE_UNINTERESTING_OID, task, result);
}

代码示例来源:origin: Evolveum/midpoint

@Test
public void test200LegacyIntegrity() throws Exception {
  final String TEST_NAME = "test200LegacyIntegrity";
  TestUtil.displayTestTitle(TEST_NAME);
  display("Dummy resource instance", dummyResourceLegacy.toString());
  assertNotNull("Resource is null", resourceLegacy);
  assertNotNull("ResourceType is null", resourceTypeLegacy);
  Task task = taskManager.createTaskInstance(TestDummyLegacy.class.getName() + "." + TEST_NAME);
  OperationResult result = task.getResult();
  ResourceType resource = repositoryService.getObject(ResourceType.class, RESOURCE_DUMMY_LEGACY_OID, null, result)
      .asObjectable();
}

相关文章