private PrismObject<ShadowType> fetchShadow(ShadowCheckResult checkResult, PrismObject<ShadowType> shadow, Task task, OperationResult result) { try { return provisioningService.getObject(ShadowType.class, shadow.getOid(), SelectorOptions.createCollection(GetOperationOptions.createDoNotDiscovery()), task, result); } catch (ObjectNotFoundException | CommunicationException | SchemaException | ConfigurationException | SecurityViolationException | ExpressionEvaluationException | RuntimeException | Error e) { checkResult.recordError(ShadowStatistics.CANNOT_FETCH_RESOURCE_OBJECT, new SystemException("The resource object couldn't be fetched", e)); return null; } }
public static <F extends ObjectType> ResourceType getResourceReadOnly(LensContext<F> context, String resourceOid, ProvisioningService provisioningService, Task task, OperationResult result) throws ObjectNotFoundException, CommunicationException, SchemaException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { ResourceType resourceType = context.getResource(resourceOid); if (resourceType == null) { // Fetching from provisioning to take advantage of caching and // pre-parsed schema Collection<SelectorOptions<GetOperationOptions>> options = SelectorOptions.createCollection(GetOperationOptions.createReadOnly()); resourceType = provisioningService.getObject(ResourceType.class, resourceOid, options, task, result) .asObjectable(); context.rememberResource(resourceType); } return resourceType; }
private PrismObject<ShadowType> getAccount(String oid) throws ObjectNotFoundException, CommunicationException, SchemaException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { OperationResult result = new OperationResult(TestDummyResourceAndSchemaCaching.class.getName() + ".getAccount"); PrismObject<ShadowType> account = provisioningService.getObject(ShadowType.class, oid, null, null, result); result.computeStatus(); TestUtil.assertSuccess(result); return account; }
@Test public void test701ConfiguredCapabilityNoRead() throws Exception{ final String TEST_NAME = "test701ConfiguredCapabilityNoRead"; Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); addResourceFromFile(new File(TEST_DIR, "resource-opendj-no-read.xml"), IntegrationTestTools.CONNECTOR_LDAP_TYPE, true, result); try { provisioningService.getObject(ShadowType.class, ACCOUNT_WILL_OID, null, task, result); AssertJUnit .fail("Expected unsupported operation exception, but haven't got one."); } catch (UnsupportedOperationException ex) { // this is expected.. } }
private void assertGetUncreatedShadow(String oid) throws ObjectNotFoundException, CommunicationException, SchemaException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { Task task = createTask("assertGetUncreatedShadow"); OperationResult result = task.getResult(); try { PrismObject<ShadowType> shadow = provisioningService.getObject(ShadowType.class, oid, null, task, result); fail("Expected that get of uncreated shadow fails, but it was successful: "+shadow); } catch (GenericConnectorException e) { // Expected } }
protected void modifyAccountShadowReplace(String accountOid, ItemPath propertyPath, Task task, OperationResult result, Object... newRealValue) throws ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, ObjectAlreadyExistsException, PolicyViolationException, SecurityViolationException { PrismObject<ShadowType> shadow = repositoryService.getObject(ShadowType.class, accountOid, null, result); String resourceOid = shadow.asObjectable().getResourceRef().getOid(); PrismObject<ResourceType> resource = provisioningService.getObject(ResourceType.class, resourceOid, null, task, result); ObjectDelta<ShadowType> objectDelta = createModifyAccountShadowReplaceDelta(accountOid, resource, propertyPath, newRealValue); Collection<ObjectDelta<? extends ObjectType>> deltas = MiscSchemaUtil.createCollection(objectDelta); modelService.executeChanges(deltas, null, task, result); }
@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(); }
protected void assertProvisioningNotFound(String oid) throws CommunicationException, SchemaException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { Task task = createTask("assertProvisioningNotFound"); OperationResult result = task.getResult(); try { provisioningService.getObject(ShadowType.class, oid, null, task, result); assertNotReached(); } catch (ObjectNotFoundException e) { // expected } assertFailure(result); }
@Test public void test006GetObjectSchemaless() throws Exception { final String TEST_NAME = "test006GetObjectSchemaless"; TestUtil.displayTestTitle(TEST_NAME); // GIVEN OperationResult result = new OperationResult(TestDummySchemaless.class.getName() + "." + TEST_NAME); PrismObject<ResourceType> resource = provisioningService.getObject(ResourceType.class, RESOURCE_DUMMY_NO_SCHEMA_OID, null, null, result); assertNotNull("Resource is null", resource); ResourceType resourceType = resource.asObjectable(); assertNotNull("No connector ref", resourceType.getConnectorRef()); assertNotNull("No connector ref OID", resourceType.getConnectorRef().getOid()); }
private PrismObject<ShadowType> getShadowFuture(String oid) throws ObjectNotFoundException, CommunicationException, SchemaException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { Task task = createTask("getShadowFuture"); OperationResult result = task.getResult(); Collection<SelectorOptions<GetOperationOptions>> options = SelectorOptions.createCollection(GetOperationOptions.createPointInTimeType(PointInTimeType.FUTURE)); PrismObject<ShadowType> shadow = provisioningService.getObject(ShadowType.class, oid, options, task, result); assertSuccess(result); return shadow; }
private PrismObject<ShadowType> getShadowFuturePartialError(String oid) throws ObjectNotFoundException, CommunicationException, SchemaException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { Task task = createTask("getShadowFuture"); OperationResult result = task.getResult(); Collection<SelectorOptions<GetOperationOptions>> options = SelectorOptions.createCollection(GetOperationOptions.createPointInTimeType(PointInTimeType.FUTURE)); PrismObject<ShadowType> shadow = provisioningService.getObject(ShadowType.class, oid, options, task, result); assertPartialError(result); return shadow; }
@Test public void test180GetUnlockedAccount() throws Exception { final String TEST_NAME = "test180GetUnlockedAccount"; displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); // WHEN PrismObject<ShadowType> shadow = provisioningService.getObject(ShadowType.class, ACCOUNT_WILL_OID, null, task, result); // THEN result.computeStatus(); assertSuccess(result); PrismAsserts.assertPropertyValue(shadow, SchemaConstants.PATH_ACTIVATION_LOCKOUT_STATUS, LockoutStatusType.NORMAL); }
protected ShadowAsserter<Void> assertShadowProvisioning(String oid) throws ObjectNotFoundException, CommunicationException, SchemaException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { Task task = createTask("assertShadowProvisioning"); OperationResult result = task.getResult(); PrismObject<ShadowType> shadow = provisioningService.getObject(ShadowType.class, oid, null, task, result); assertSuccess(result); ShadowAsserter<Void> asserter = ShadowAsserter.forShadow(shadow, "provisioning"); asserter .display(); return asserter; }
private PrismObject<ShadowType> getShadowNoFetch(String oid) throws ObjectNotFoundException, CommunicationException, SchemaException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { Task task = createTask("getShadowNoFetch"); OperationResult result = task.getResult(); Collection<SelectorOptions<GetOperationOptions>> options = SelectorOptions.createCollection(GetOperationOptions.createNoFetch()); PrismObject<ShadowType> shadow = provisioningService.getObject(ShadowType.class, oid, options, task, result); assertSuccess(result); return shadow; }
protected void assertProvisioningFutureNotFound(String oid) throws CommunicationException, SchemaException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { Task task = createTask("assertProvisioningFutureNotFound"); OperationResult result = task.getResult(); Collection<SelectorOptions<GetOperationOptions>> options = SelectorOptions.createCollection(GetOperationOptions.createPointInTimeType(PointInTimeType.FUTURE)); try { provisioningService.getObject(ShadowType.class, oid, options, task, result); assertNotReached(); } catch (ObjectNotFoundException e) { // expected } assertFailure(result); }
protected ShadowAsserter<Void> assertShadowNoFetch(String oid) throws ObjectNotFoundException, CommunicationException, SchemaException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { Task task = createTask("assertShadowProvisioning"); OperationResult result = task.getResult(); Collection<SelectorOptions<GetOperationOptions>> options = SelectorOptions.createCollection(GetOperationOptions.createNoFetch()); PrismObject<ShadowType> shadow = provisioningService.getObject(ShadowType.class, oid, options, task, result); assertSuccess(result); ShadowAsserter<Void> asserter = ShadowAsserter.forShadow(shadow, "noFetch"); asserter .display(); return asserter; }
protected ShadowAsserter<Void> assertShadowFuture(String oid) throws ObjectNotFoundException, CommunicationException, SchemaException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { Task task = createTask("assertShadowFuture"); OperationResult result = task.getResult(); Collection<SelectorOptions<GetOperationOptions>> options = SelectorOptions.createCollection(GetOperationOptions.createPointInTimeType(PointInTimeType.FUTURE)); PrismObject<ShadowType> shadow = provisioningService.getObject(ShadowType.class, oid, options, task, result); assertSuccess(result); ShadowAsserter<Void> asserter = ShadowAsserter.forShadow(shadow, "future"); asserter .display(); return asserter; }
@Test public void test000Integrity() throws Exception { final String TEST_NAME = "test000Integrity"; displayTestTitle(TEST_NAME); Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); display("Dummy resource instance", dummyResource.toString()); OperationResult testResult = provisioningService.testResource(RESOURCE_DUMMY_OID, task); assertSuccess(testResult); resource = provisioningService.getObject(ResourceType.class, RESOURCE_DUMMY_OID, null, null, result); resourceType = resource.asObjectable(); assertSuccess(result); rememberSteadyResources(); }
protected ShadowAsserter<Void> assertShadowFutureNoFetch(String oid) throws ObjectNotFoundException, CommunicationException, SchemaException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { Task task = createTask("assertShadowFutureNoFetch"); OperationResult result = task.getResult(); GetOperationOptions rootOptions = GetOperationOptions.createPointInTimeType(PointInTimeType.FUTURE); rootOptions.setNoFetch(true); Collection<SelectorOptions<GetOperationOptions>> options = SelectorOptions.createCollection(rootOptions); PrismObject<ShadowType> shadow = provisioningService.getObject(ShadowType.class, oid, options, task, result); assertSuccess(result); ShadowAsserter<Void> asserter = ShadowAsserter.forShadow(shadow, "future,noFetch"); asserter .display(); return asserter; } }
protected LensProjectionContext fillContextWithAccount(LensContext<UserType> context, PrismObject<ShadowType> account, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { ShadowType accountType = account.asObjectable(); String resourceOid = accountType.getResourceRef().getOid(); ResourceType resourceType = provisioningService.getObject(ResourceType.class, resourceOid, null, task, result).asObjectable(); applyResourceSchema(accountType, resourceType); ResourceShadowDiscriminator rat = new ResourceShadowDiscriminator(resourceOid, ShadowKindType.ACCOUNT, ShadowUtil.getIntent(accountType)); LensProjectionContext accountSyncContext = context.findOrCreateProjectionContext(rat); accountSyncContext.setOid(account.getOid()); accountSyncContext.setLoadedObject(account); accountSyncContext.setResource(resourceType); accountSyncContext.setExists(true); context.rememberResource(resourceType); return accountSyncContext; }