public static ObjectClassComplexTypeDefinition getObjectClassDefinition(ShadowType shadow) { // TODO: maybe we can do something more intelligent here ResourceAttributeContainer attributesContainer = getAttributesContainer(shadow); return attributesContainer.getDefinition().getComplexTypeDefinition(); }
public static ObjectClassComplexTypeDefinition getObjectClassDefinition(PrismObject<? extends ShadowType> shadow) { // TODO: maybe we can do something more intelligent here ResourceAttributeContainer attributesContainer = getAttributesContainer(shadow); return attributesContainer.getDefinition().getComplexTypeDefinition(); }
public ObjectClass objectClassToConnId(PrismObject<? extends ShadowType> shadow, String schemaNamespace, ConnectorType connectorType, boolean legacySchema) { ShadowType shadowType = shadow.asObjectable(); QName qnameObjectClass = shadowType.getObjectClass(); if (qnameObjectClass == null) { ResourceAttributeContainer attrContainer = ShadowUtil.getAttributesContainer(shadowType); if (attrContainer == null) { return null; } ResourceAttributeContainerDefinition objectClassDefinition = attrContainer.getDefinition(); qnameObjectClass = objectClassDefinition.getTypeName(); } return objectClassToConnId(qnameObjectClass, schemaNamespace, connectorType, legacySchema); }
protected <T> void addAttributeToShadow(PrismObject<ShadowType> shadow, PrismObject<ResourceType> resource, String attrName, T attrValue) throws SchemaException { ResourceAttributeContainer attrs = ShadowUtil.getAttributesContainer(shadow); ResourceAttributeDefinition attrSnDef = attrs.getDefinition().findAttributeDefinition( new ItemName(ResourceTypeUtil.getResourceNamespace(resource), attrName)); ResourceAttribute<T> attr = attrSnDef.instantiate(); attr.setRealValue(attrValue); attrs.add(attr); }
List<ItemDelta<?, ?>> rv = new ArrayList<>(); ResourceAttributeContainer attributes = ShadowUtil.getAttributesContainer(sourceShadow); ResourceAttributeContainerDefinition attributesDefinition = attributes.getDefinition(); if (attributesDefinition == null) { throw new IllegalStateException("No definition for " + attributes);
@Test public void test500FetchObject() throws Exception { final String TEST_NAME = "test500FetchObject"; TestUtil.displayTestTitle(this, TEST_NAME); // GIVEN ResourceAttributeContainer resourceObject = createResourceObject( "uid=Teell,ou=People,dc=example,dc=com", "Teell William", "Teell"); OperationResult addResult = new OperationResult(this.getClass().getName() + "." + TEST_NAME); PrismObject<ShadowType> shadow = wrapInShadow(ShadowType.class, resourceObject); // Add a testing object cc.addObject(shadow, null, null, addResult); ObjectClassComplexTypeDefinition accountDefinition = resourceObject.getDefinition().getComplexTypeDefinition(); Collection<ResourceAttribute<?>> identifiers = resourceObject.getPrimaryIdentifiers(); // Determine object class from the schema ResourceObjectIdentification identification = new ResourceObjectIdentification(accountDefinition, identifiers, null); OperationResult result = new OperationResult(this.getClass().getName() + "." + TEST_NAME); // WHEN PrismObject<ShadowType> ro = cc.fetchObject(identification, null, null, result); // THEN AssertJUnit.assertNotNull(ro); System.out.println("Fetched object " + ro); System.out.println("Result:"); System.out.println(result.debugDump()); }
private void transplantIdentifiers(PrismContainerValue<ShadowAssociationType> association, PrismObject<ShadowType> repoShadow) throws SchemaException { PrismContainer<Containerable> identifiersContainer = association .findContainer(ShadowAssociationType.F_IDENTIFIERS); if (identifiersContainer == null) { ResourceAttributeContainer origContainer = ShadowUtil.getAttributesContainer(repoShadow); identifiersContainer = ObjectFactory.createResourceAttributeContainer(ShadowAssociationType.F_IDENTIFIERS, origContainer.getDefinition(), prismContext); association.add(identifiersContainer); } Collection<ResourceAttribute<?>> identifiers = ShadowUtil.getPrimaryIdentifiers(repoShadow); for (ResourceAttribute<?> identifier : identifiers) { identifiersContainer.add(identifier.clone()); } Collection<ResourceAttribute<?>> secondaryIdentifiers = ShadowUtil .getSecondaryIdentifiers(repoShadow); for (ResourceAttribute<?> identifier : secondaryIdentifiers) { identifiersContainer.add(identifier.clone()); } }
private void toAssociation(PrismObject<ShadowType> shadow, ShadowAssociationType shadowAssociationType) { shadowAssociationType.setShadowRef(new ObjectReferenceType().oid(shadow.getOid()).type(ShadowType.COMPLEX_TYPE)); // We also need to add identifiers here. Otherwise the delta won't match the shadow association. // And therefore new values won't be computed correctly (MID-4948) // This is not a clean systemic solution. But there was no time for a better solution before 3.9 release. try { ResourceAttributeContainer shadowAttributesContainer = ShadowUtil.getAttributesContainer(shadow); ResourceAttributeContainer identifiersContainer = ObjectFactory.createResourceAttributeContainer( ShadowAssociationType.F_IDENTIFIERS, shadowAttributesContainer.getDefinition(), prismContext); shadowAssociationType.asPrismContainerValue().add(identifiersContainer); Collection<ResourceAttribute<?>> shadowIdentifiers = ShadowUtil.getAllIdentifiers(shadow); for (ResourceAttribute<?> shadowIdentifier : shadowIdentifiers) { identifiersContainer.add(shadowIdentifier.clone()); } } catch (SchemaException e) { // Should not happen throw new SystemException(e.getMessage(), e); } }
ResourceAttributeContainerDefinition attrContDef = attributesContainer.getDefinition(); if (attrContDef != null) { ocDef = attrContDef.getComplexTypeDefinition(); attributesContainer.getDefinition().getComplexTypeDefinition(), resourceSchema); for (ResourceAttribute<?> identifier: identifiers) { attributesContainer.getValue().addReplaceExisting(identifier);
protected void checkUniqueness(PrismObject<? extends ShadowType> object) throws SchemaException { OperationResult result = new OperationResult(TestDummyNegative.class.getName() + ".checkConsistency"); PrismPropertyDefinition itemDef = ShadowUtil.getAttributesContainer(object).getDefinition().findAttributeDefinition(SchemaConstants.ICFS_NAME); LOGGER.info("item definition: {}", itemDef.debugDump()); //TODO: matching rule ObjectQuery query = prismContext.queryFor(ShadowType.class) .itemWithDef(itemDef, ShadowType.F_ATTRIBUTES, itemDef.getName()).eq(getWillRepoIcfName()) .build(); System.out.println("Looking for shadows of \"" + getWillRepoIcfName() + "\" with filter " + query.debugDump()); display("Looking for shadows of \"" + getWillRepoIcfName() + "\" with filter " + query.debugDump()); List<PrismObject<ShadowType>> objects = repositoryService.searchObjects(ShadowType.class, query, null, result); assertEquals("Wrong number of repo shadows for ICF NAME \"" + getWillRepoIcfName() + "\"", 1, objects.size()); }
ObjectClassComplexTypeDefinition accountDefinition = resourceObject.getDefinition().getComplexTypeDefinition();
ResourceAttributeContainer attributesContainer = (ResourceAttributeContainer) shadowPrism .findOrCreateContainer(ShadowType.F_ATTRIBUTES); ResourceAttributeContainerDefinition attributesContainerDefinition = attributesContainer.getDefinition(); shadow.setObjectClass(attributesContainerDefinition.getTypeName());
resultShadowType.setObjectClass(resourceAttributesContainer.getDefinition().getTypeName());
repoShadowType.setObjectClass(attributesContainer.getDefinition().getTypeName());