public static ResourceAttributeContainer getAttributesContainer(PrismObject<? extends ShadowType> shadow) { return getAttributesContainer(shadow, ShadowType.F_ATTRIBUTES); }
public static Collection<ResourceAttribute<?>> getAllIdentifiers(PrismObject<? extends ShadowType> shadow) { ResourceAttributeContainer attributesContainer = getAttributesContainer(shadow); if (attributesContainer == null) { return null; } return attributesContainer.getAllIdentifiers(); }
public static Collection<ResourceAttribute<?>> getPrimaryIdentifiers(PrismObject<? extends ShadowType> shadow) { ResourceAttributeContainer attributesContainer = getAttributesContainer(shadow); if (attributesContainer == null) { return null; } return attributesContainer.getPrimaryIdentifiers(); }
public static Collection<ResourceAttribute<?>> getSecondaryIdentifiers(PrismObject<? extends ShadowType> shadow) { ResourceAttributeContainer attributesContainer = getAttributesContainer(shadow); if (attributesContainer == null) { return null; } return attributesContainer.getSecondaryIdentifiers(); }
public static ResourceAttribute<String> getNamingAttribute(PrismObject<? extends ShadowType> shadow) { ResourceAttributeContainer attributesContainer = getAttributesContainer(shadow); if (attributesContainer == null) { return null; } return attributesContainer.getNamingAttribute(); }
public static <T> ResourceAttribute<T> getAttribute(PrismObject<? extends ShadowType> shadow, QName attrName) { return getAttributesContainer(shadow).findAttribute(attrName); }
public static ResourceAttributeContainer getAttributesContainer(ShadowType shadowType) { return getAttributesContainer(shadowType.asPrismObject()); }
public static ResourceAttributeContainer getAttributesContainer(PrismObject<? extends ShadowType> shadow, QName containerName) { return getAttributesContainer(shadow.getValue(), containerName); }
public static Collection<ResourceAttribute<?>> getAttributes(PrismObject<? extends ShadowType> shadow) { return getAttributesContainer(shadow).getAttributes(); }
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 <T> Collection<T> getAttributeValues(ShadowType shadow, QName attributeQname, Class<T> type) { ResourceAttributeContainer attributesContainer = getAttributesContainer(shadow); if (attributesContainer == null) { return null; } ResourceAttribute<T> attribute = attributesContainer.findAttribute(attributeQname); if (attribute == null) { return null; } return attribute.getRealValues(type); }
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 static void validateAttributeSchema(PrismObject<ShadowType> shadow, ObjectClassComplexTypeDefinition objectClassDefinition) throws SchemaException { ResourceAttributeContainer attributesContainer = getAttributesContainer(shadow); for (ResourceAttribute<?> attribute: attributesContainer.getAttributes()) { validateAttribute(attribute, objectClassDefinition); } }
public static ResourceAttributeContainer getOrCreateAttributesContainer(PrismObject<? extends ShadowType> shadow, ObjectClassComplexTypeDefinition objectClassDefinition) { ResourceAttributeContainer attributesContainer = getAttributesContainer(shadow); if (attributesContainer != null) { return attributesContainer; } ResourceAttributeContainer emptyContainer = ResourceAttributeContainer.createEmptyContainer(ShadowType.F_ATTRIBUTES, objectClassDefinition); try { shadow.add(emptyContainer); } catch (SchemaException e) { throw new SystemException("Unexpected schema error: "+e.getMessage(), e); } return emptyContainer; }
public boolean matches(PrismObject<ShadowType> shadowToMatch, MatchingRuleRegistry matchingRuleRegistry, RelationRegistry relationRegistry) throws SchemaException { if (objectFilter != null) { ObjectTypeUtil.normalizeFilter(objectFilter, relationRegistry); // we suppose references in shadowToMatch are normalized (on return from repo) return ObjectQuery.match(shadowToMatch, objectFilter, matchingRuleRegistry); } else { // Deprecated method ResourceAttributeContainer attributesContainer = ShadowUtil.getAttributesContainer(shadowToMatch); if (attributesContainer == null) { return false; } Collection<ResourceAttribute<?>> attributesToMatch = attributesContainer.getAttributes(); for (ResourceAttribute<?> identifier: identifiers) { if (!matches(identifier, attributesToMatch, matchingRuleRegistry)) { return false; } } return true; } }
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); }
@SuppressWarnings({ "rawtypes", "unchecked" }) private void applyAfterOperationAttributes(PrismObject<ShadowType> shadow, Collection<ResourceAttribute<?>> resourceAttributesAfterAdd) throws SchemaException { if (resourceAttributesAfterAdd == null) { return; } ResourceAttributeContainer attributesContainer = ShadowUtil.getAttributesContainer(shadow); for (ResourceAttribute attributeAfter : resourceAttributesAfterAdd) { ResourceAttribute attributeBefore = attributesContainer.findAttribute(attributeAfter.getElementName()); if (attributeBefore != null) { attributesContainer.remove(attributeBefore); } if (!attributesContainer.contains(attributeAfter)) { attributesContainer.add(attributeAfter.clone()); } } }
protected void assertSyncOldShadow(PrismObject<? extends ShadowType> oldShadow, String repoName, Integer expectedNumberOfAttributes) { assertNotNull("Old shadow missing", oldShadow); assertNotNull("Old shadow does not have an OID", oldShadow.getOid()); PrismAsserts.assertClass("old shadow", ShadowType.class, oldShadow); ShadowType oldShadowType = oldShadow.asObjectable(); ResourceAttributeContainer attributesContainer = ShadowUtil .getAttributesContainer(oldShadowType); assertNotNull("No attributes container in old shadow", attributesContainer); Collection<ResourceAttribute<?>> attributes = attributesContainer.getAttributes(); assertFalse("Attributes container is empty", attributes.isEmpty()); if (expectedNumberOfAttributes != null) { assertEquals("Unexpected number of attributes", (int)expectedNumberOfAttributes, attributes.size()); } ResourceAttribute<?> icfsNameAttribute = attributesContainer.findAttribute(SchemaConstants.ICFS_NAME); assertNotNull("No ICF name attribute in old shadow", icfsNameAttribute); assertEquals("Wrong value of ICF name attribute in old shadow", repoName, icfsNameAttribute.getRealValue()); }
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()); }