public void setTriggeredResource(ResourceType triggeredResource) { if (triggeredResource != null) { this.triggeredResourceOid = triggeredResource.getOid(); } }
/** * Puts resource in the cache for later use. The resource should be fetched * from provisioning and have pre-parsed schemas. So the next time just * reuse it without the other overhead. */ public void rememberResource(ResourceType resourceType) { getResourceCache().put(resourceType.getOid(), resourceType); }
public SynchronizeAccountResultHandler(ResourceType resource, ObjectClassComplexTypeDefinition objectClassDef, String processShortName, Task coordinatorTask, ResourceObjectChangeListener objectChangeListener, TaskStageType stageType, TaskManager taskManager) { super(coordinatorTask, SynchronizeAccountResultHandler.class.getName(), processShortName, "from "+resource, stageType, taskManager); this.objectChangeListener = objectChangeListener; this.resourceReadOnly = resource; this.resourceOid = resource.getOid(); this.objectClassDef = objectClassDef; forceAdd = false; setRecordIterationStatistics(false); // we do statistics ourselves in handler, because in case of reconciliation // we are not called via AbstractSearchIterativeResultHandler.processRequest }
@Override public ShadowType getLinkedShadow(FocusType focus, ResourceType resource, boolean repositoryObjectOnly) throws SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { return getLinkedShadow(focus, resource.getOid(), repositoryObjectOnly); }
@Override public ShadowType getLinkedShadow(FocusType focus, ResourceType resource) throws SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { return getLinkedShadow(focus, resource.getOid()); }
public String getResourceOid() { if (resource != null) { return resource.getOid(); } else if (resourceShadowDiscriminator != null) { return resourceShadowDiscriminator.getResourceOid(); } else { return null; } }
@Override public Object executeAdHocProvisioningScript(ResourceType resource, String language, String code) throws SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SecurityViolationException, ObjectAlreadyExistsException { return executeAdHocProvisioningScript(resource.getOid(), language, code); }
public static ObjectQuery createAllShadowsQuery(ResourceType resourceType, PrismContext prismContext) throws SchemaException { return prismContext.queryFor(ShadowType.class) .item(ShadowType.F_RESOURCE_REF).ref(resourceType.getOid()) .build(); }
public static <F extends ObjectType> boolean isDependencyTargetContext(LensProjectionContext sourceProjContext, LensProjectionContext targetProjectionContext, ResourceObjectTypeDependencyType dependency) { ResourceShadowDiscriminator refDiscr = new ResourceShadowDiscriminator(dependency, sourceProjContext.getResource().getOid(), sourceProjContext.getKind()); return targetProjectionContext.compareResourceShadowDiscriminator(refDiscr, false); }
public static String determineConstructionResource(AssignmentType assignmentType) { ConstructionType construction = assignmentType.getConstruction(); if (construction != null){ if (construction.getResource() != null){ return construction.getResource().getOid(); } else if (construction.getResourceRef() != null){ return construction.getResourceRef().getOid(); } return null; } return null; }
private <F extends FocusType> ResourceShadowDiscriminator getConstructionMapKey(LensContext<F> context, Construction<F> construction, Task task, OperationResult result) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { String resourceOid = construction.getResource(task, result).getOid(); String intent = construction.getIntent(); ShadowKindType kind = construction.getKind(); ResourceType resource = LensUtil.getResourceReadOnly(context, resourceOid, provisioningService, task, result); intent = LensUtil.refineProjectionIntent(kind, intent, resource, prismContext); ResourceShadowDiscriminator rat = new ResourceShadowDiscriminator(resourceOid, kind, intent); return rat; }
private void validateResourceInShadow(ShadowType shadow, ResourceType resource) { if (shadow.getResource() != null || shadow.getResourceRef() != null) { return; } ObjectReferenceType reference = new ObjectReferenceType(); reference.setOid(resource.getOid()); reference.setType(ObjectTypes.RESOURCE.getTypeQName()); shadow.setResourceRef(reference); }
public static ObjectQuery createAllShadowsQuery(ResourceType resourceType, QName objectClass, PrismContext prismContext) throws SchemaException { return prismContext.queryFor(ShadowType.class) .item(ShadowType.F_RESOURCE_REF).ref(resourceType.getOid()) .and().item(ShadowType.F_OBJECT_CLASS).eq(objectClass) .build(); }
private ObjectDelta createDelta(ResourceType resourceType) throws ScriptExecutionException { PrismContainer<XmlSchemaType> schemaContainer = resourceType.asPrismObject().findContainer(ResourceType.F_SCHEMA); if (schemaContainer == null || schemaContainer.isEmpty()) { return null; } return prismContext.deltaFactory().object().createModificationDeleteContainer( ResourceType.class, resourceType.getOid(), ResourceType.F_SCHEMA, schemaContainer.getValue().clone()); } }
/** * Find context that has the closest order to the dependency. */ private <F extends ObjectType> LensProjectionContext findDependencyTargetContext( LensContext<F> context, LensProjectionContext sourceProjContext, ResourceObjectTypeDependencyType dependency) { ResourceShadowDiscriminator refDiscr = new ResourceShadowDiscriminator(dependency, sourceProjContext.getResource().getOid(), sourceProjContext.getKind()); LensProjectionContext selected = null; for (LensProjectionContext projectionContext: context.getProjectionContexts()) { if (!projectionContext.compareResourceShadowDiscriminator(refDiscr, false)) { continue; } int ctxOrder = projectionContext.getResourceShadowDiscriminator().getOrder(); if (ctxOrder > refDiscr.getOrder()) { continue; } if (selected == null) { selected = projectionContext; } else { if (ctxOrder > selected.getResourceShadowDiscriminator().getOrder()) { selected = projectionContext; } } } return selected; }
private <T> Integer countAccounts(ResourceType resourceType, QName attributeName, T attributeValue, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { RefinedResourceSchema rSchema = RefinedResourceSchemaImpl.getRefinedSchema(resourceType); RefinedObjectClassDefinition rAccountDef = rSchema.getDefaultRefinedDefinition(ShadowKindType.ACCOUNT); RefinedAttributeDefinition attrDef = rAccountDef.findAttributeDefinition(attributeName); ObjectQuery query = prismContext.queryFor(ShadowType.class) .itemWithDef(attrDef, ShadowType.F_ATTRIBUTES, attrDef.getName()).eq(attributeValue) .and().item(ShadowType.F_OBJECT_CLASS).eq(rAccountDef.getObjectClassDefinition().getTypeName()) .and().item(ShadowType.F_RESOURCE_REF).ref(resourceType.getOid()) .build(); return modelObjectResolver.countObjects(ShadowType.class, query, null, task, result); }
private void assumeUserTemplate(String templateOid, ResourceType resource, String syncConfigName, OperationResult result) throws ObjectNotFoundException, SchemaException, ObjectAlreadyExistsException { SynchronizationType resourceSync = resource.getSynchronization(); resourceSync.getObjectSynchronization().get(0).setObjectTemplateRef(ObjectTypeUtil.createObjectRef(templateOid, ObjectTypes.OBJECT_TEMPLATE)); Collection<? extends ItemDelta> refDelta = prismContext.deltaFactory().property() .createModificationReplacePropertyCollection(ResourceType.F_SYNCHRONIZATION, resource.asPrismObject().getDefinition(), resourceSync); repositoryService.modifyObject(ResourceType.class, resource.getOid(), refDelta, result); ResourceType res = repositoryService.getObject(ResourceType.class, resource.getOid(), null, result).asObjectable(); assertNotNull(res); assertNotNull("Synchronization is not specified", res.getSynchronization()); ObjectSynchronizationType ost = determineSynchronization(res, UserType.class, syncConfigName); assertNotNull("object sync type is not specified", ost); assertNotNull("user template not specified", ost.getObjectTemplateRef()); assertEquals("Wrong user template in resource", templateOid, ost.getObjectTemplateRef().getOid()); }
private void assertJackAccountShadow(LensContext<UserType> context) throws ObjectNotFoundException, SchemaException, SecurityViolationException, CommunicationException, ConfigurationException, ExpressionEvaluationException { Collection<LensProjectionContext> accountContexts = context.getProjectionContexts(); assertEquals(1, accountContexts.size()); LensProjectionContext accContext = accountContexts.iterator().next(); String accountOid = accContext.getOid(); assertNotNull("No OID in account context "+accContext); PrismObject<ShadowType> newAccount = getShadowModel(accountOid); assertEquals(DEFAULT_INTENT, newAccount.findProperty(ShadowType.F_INTENT).getRealValue()); assertEquals(new QName(ResourceTypeUtil.getResourceNamespace(getDummyResourceType()), "AccountObjectClass"), newAccount.findProperty(ShadowType.F_OBJECT_CLASS).getRealValue()); PrismReference resourceRef = newAccount.findReference(ShadowType.F_RESOURCE_REF); assertEquals(getDummyResourceType().getOid(), resourceRef.getOid()); PrismContainer<?> attributes = newAccount.findContainer(ShadowType.F_ATTRIBUTES); assertEquals("jack", attributes.findProperty(SchemaTestConstants.ICFS_NAME).getRealValue()); assertEquals("Jack Sparrow", attributes.findProperty(new ItemName(ResourceTypeUtil.getResourceNamespace(getDummyResourceType()), "fullname")).getRealValue()); }
private boolean checkAttributeUniqueness(PrismProperty identifier, RefinedObjectClassDefinition accountDefinition, ResourceType resourceType, String oid, Task task, OperationResult result) throws SchemaException, ObjectNotFoundException, CommunicationException, ConfigurationException, SecurityViolationException, ExpressionEvaluationException { List<PrismPropertyValue<?>> identifierValues = identifier.getValues(); if (identifierValues.isEmpty()) { throw new SchemaException("Empty identifier "+identifier+" while checking uniqueness of "+oid+" ("+resourceType+")"); } //TODO: set matching rule instead of null ObjectQuery query = prismContext.queryFor(ShadowType.class) .itemWithDef(identifier.getDefinition(), ShadowType.F_ATTRIBUTES, identifier.getDefinition().getName()) .eq(PrismValueCollectionsUtil.cloneCollection(identifierValues)) .and().item(ShadowType.F_OBJECT_CLASS).eq(accountDefinition.getObjectClassDefinition().getTypeName()) .and().item(ShadowType.F_RESOURCE_REF).ref(resourceType.getOid()) .and().block() .item(ShadowType.F_DEAD).eq(false) .or().item(ShadowType.F_DEAD).isNull() .endBlock() .build(); boolean unique = checkUniqueness(oid, identifier, query, task, result); return unique; }
@Test public void test010Sanity() throws Exception { final String TEST_NAME = "test010Sanity"; TestUtil.displayTestTitle(TEST_NAME); final OperationResult result = new OperationResult(TestSynchronization.class.getName() + "." + TEST_NAME); // WHEN PrismObject<ResourceType> resource = provisioningService.getObject(ResourceType.class, resourceType.getOid(), null, taskManager.createTaskInstance(), result); // THEN assertNotNull("Resource is null", resource); display("getObject(resource)", resource); result.computeStatus(); display("getObject(resource) result", result); TestUtil.assertSuccess(result); // Make sure these were generated assertNotNull("No resource schema", resource.asObjectable().getSchema()); assertNotNull("No native capabilities", resource.asObjectable().getCapabilities().getNative()); Task syncTask = taskManager.getTask(SYNC_TASK_OID, result); AssertJUnit.assertNotNull(syncTask); assertSyncToken(syncTask, 0, result); }