public static String getSecondaryIdentifier(PrismObject<ShadowType> shadow) { Collection<ResourceAttribute<?>> secondaryIdentifiers = ShadowUtil.getSecondaryIdentifiers(shadow); if (secondaryIdentifiers == null || secondaryIdentifiers.isEmpty()) { return null; } if (secondaryIdentifiers.size() > 1) { throw new IllegalArgumentException("Too many secondary indentifiers in "+shadow); } return (String) secondaryIdentifiers.iterator().next().getRealValue(); }
public static ResourceAttribute<String> getSecondaryIdentifier(PrismObject<? extends ShadowType> shadow) throws SchemaException { Collection<ResourceAttribute<?>> secondaryIdentifiers = getSecondaryIdentifiers(shadow); if (secondaryIdentifiers == null || secondaryIdentifiers.isEmpty()) { return null; } if (secondaryIdentifiers.size() > 1) { throw new SchemaException("Too many secondary identifiers in "+shadow+": "+secondaryIdentifiers); } return (ResourceAttribute<String>) secondaryIdentifiers.iterator().next(); }
public static Collection<ResourceAttribute<?>> getSecondaryIdentifiers(ShadowType shadowType) { return getSecondaryIdentifiers(shadowType.asPrismObject()); }
public <T> T getSecondaryIdentifierValue(ShadowType shadow) throws SchemaException { if (shadow == null) { return null; } Collection<ResourceAttribute<?>> identifiers = ShadowUtil.getSecondaryIdentifiers(shadow); if (identifiers.size() == 0) { return null; } if (identifiers.size() > 1) { throw new SchemaException("More than one secondary idenfier in " + shadow); } Collection<T> realValues = (Collection<T>) identifiers.iterator().next().getRealValues(); if (realValues.size() == 0) { return null; } if (realValues.size() > 1) { throw new SchemaException("More than one secondary idenfier value in " + shadow); } return realValues.iterator().next(); }
public static ResourceObjectIdentification getResourceObjectIdentification( PrismObject<ShadowType> shadow, ObjectClassComplexTypeDefinition objectClassDefinition) { return new ResourceObjectIdentification(objectClassDefinition, ShadowUtil.getPrimaryIdentifiers(shadow), ShadowUtil.getSecondaryIdentifiers(shadow)); }
public ShadowAttributesAsserter<R> assertHasSecondaryIdentifier() { Collection<ResourceAttribute<?>> secondaryIdentifiers = ShadowUtil.getSecondaryIdentifiers(getShadow()); assertFalse("No secondary identifiers in "+desc(), secondaryIdentifiers.isEmpty()); return this; }
public ShadowAttributesAsserter<R> assertNoSecondaryIdentifier() { Collection<ResourceAttribute<?>> secondaryIdentifiers = ShadowUtil.getSecondaryIdentifiers(getShadow()); assertTrue("Unexpected secondary identifiers in "+desc()+": "+secondaryIdentifiers, secondaryIdentifiers.isEmpty()); return this; }
shortDumpShadowIdentifiers(sb, shadow, primaryIdentifiers); } else { Collection<ResourceAttribute<?>> secondaryIdentifiers = getSecondaryIdentifiers(shadow); if (secondaryIdentifiers != null && !secondaryIdentifiers.isEmpty()) { shortDumpShadowIdentifiers(sb, shadow, secondaryIdentifiers);
@Override public String getShadowName(PrismObject<? extends ShadowType> shadow) { if (shadow == null) { return null; } else if (shadow.asObjectable().getName() != null) { return shadow.asObjectable().getName().getOrig(); } else { Collection<ResourceAttribute<?>> secondaryIdentifiers = ShadowUtil.getSecondaryIdentifiers(shadow); LOGGER.trace("secondary identifiers: {}", secondaryIdentifiers); // first phase = looking for "name" identifier for (ResourceAttribute ra : secondaryIdentifiers) { if (ra.getElementName() != null && ra.getElementName().getLocalPart().contains("name")) { LOGGER.trace("Considering {} as a name", ra); return String.valueOf(ra.getAnyRealValue()); } } // second phase = returning any value ;) if (!secondaryIdentifiers.isEmpty()) { return String.valueOf(secondaryIdentifiers.iterator().next().getAnyRealValue()); } else { return null; } } }
throws SchemaException, ConfigurationException, ObjectNotFoundException, CommunicationException, ExpressionEvaluationException { Collection<ResourceAttribute<?>> secondaryIdentifiers = ShadowUtil.getSecondaryIdentifiers(resourceShadow); List<PrismObject<ShadowType>> results = lookupShadowsBySecondaryIdentifiers(ctx, secondaryIdentifiers, parentResult);
return null; Collection<ResourceAttribute<?>> secondaryIdentifiers = ShadowUtil.getSecondaryIdentifiers(identifiers, ctx.getObjectClassDefinition()); PrismObject<ShadowType> repoShadow = shadowManager.lookupShadowBySecondaryIdentifiers(ctx, secondaryIdentifiers, result); if (repoShadow == null) {
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 ObjectQuery createQueryBySecondaryIdentifier(ShadowType shadow) throws SchemaException { // TODO TODO TODO set matching rule instead of null in equlas filter Collection<ResourceAttribute<?>> secondaryIdentifiers = ShadowUtil.getSecondaryIdentifiers(shadow); S_AtomicFilterEntry q = prismContext.queryFor(ShadowType.class); q = q.block(); if (secondaryIdentifiers.isEmpty()) { for (ResourceAttribute<?> primaryIdentifier: ShadowUtil.getPrimaryIdentifiers(shadow)) { q = q.itemAs(primaryIdentifier).or(); } } else { // secondary identifiers connected by 'or' clause for (ResourceAttribute<?> secondaryIdentifier : secondaryIdentifiers) { q = q.itemAs(secondaryIdentifier).or(); } } q = q.none().endBlock().and(); // resource + object class q = q.item(ShadowType.F_RESOURCE_REF).ref(shadow.getResourceRef().getOid()).and(); return q.item(ShadowType.F_OBJECT_CLASS).eq(shadow.getObjectClass()).build(); }