public static Collection<ResourceAttribute<?>> getPrimaryIdentifiers(ShadowType shadowType) { return getPrimaryIdentifiers(shadowType.asPrismObject()); }
public <T> T getIdentifierValue(ShadowType shadow) throws SchemaException { if (shadow == null) { return null; } Collection<ResourceAttribute<?>> identifiers = ShadowUtil.getPrimaryIdentifiers(shadow); if (identifiers.size() == 0) { return null; } if (identifiers.size() > 1) { throw new SchemaException("More than one 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 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> assertHasPrimaryIdentifier() { Collection<ResourceAttribute<?>> primaryIdentifiers = ShadowUtil.getPrimaryIdentifiers(getShadow()); assertFalse("No primary identifiers in "+desc(), primaryIdentifiers.isEmpty()); return this; }
public boolean matches(PrismObject<ShadowType> shadow) { ShadowType shadowType = shadow.asObjectable(); if (!objectClass.equals(shadowType.getObjectClass())) { return false; } Collection<ResourceAttribute<?>> shadowIdentifiers = ShadowUtil.getPrimaryIdentifiers(shadow); return ItemCollectionsUtil.compareCollectionRealValues(primaryIdentifiers, shadowIdentifiers); }
public ShadowAttributesAsserter<R> assertNoPrimaryIdentifier() { Collection<ResourceAttribute<?>> primaryIdentifiers = ShadowUtil.getPrimaryIdentifiers(getShadow()); assertTrue("Unexpected primary identifiers in "+desc()+": "+primaryIdentifiers, primaryIdentifiers.isEmpty()); return this; }
public static String getHumanReadableName(PrismObject<? extends ShadowType> shadow) { if (shadow == null) { return "null"; } StringBuilder sb = new StringBuilder(); ShadowType shadowType = shadow.asObjectable(); ShadowKindType kind = shadowType.getKind(); if (kind != null) { sb.append(kind).append(" "); } sb.append("shadow "); boolean first = true; for(ResourceAttribute iattr: getPrimaryIdentifiers(shadow)) { if (first) { sb.append("["); first = false; } else { sb.append(","); } sb.append(iattr.getElementName().getLocalPart()); sb.append("="); sb.append(iattr.getRealValue()); } if (first) { sb.append("["); } sb.append("]"); return shadow.toString(); }
Collection<ResourceAttribute<?>> identifiers = ShadowUtil.getPrimaryIdentifiers(shadow); if (identifiers == null) { return null;
sb.append(name); } else { Collection<ResourceAttribute<?>> primaryIdentifiers = getPrimaryIdentifiers(shadow); if (primaryIdentifiers != null && !primaryIdentifiers.isEmpty()) { shortDumpShadowIdentifiers(sb, shadow, primaryIdentifiers);
@Override public void notifyEvent(ResourceEventDescription eventDescription, Task task, OperationResult parentResult) throws SchemaException, CommunicationException, ConfigurationException, SecurityViolationException, ObjectNotFoundException, GenericConnectorException, ObjectAlreadyExistsException, ExpressionEvaluationException { Validate.notNull(eventDescription, "Event description must not be null."); Validate.notNull(task, "Task must not be null."); Validate.notNull(parentResult, "Operation result must not be null"); LOGGER.trace("Received event notification with the description: {}", eventDescription.debugDump()); if (eventDescription.getCurrentShadow() == null && eventDescription.getDelta() == null){ throw new IllegalStateException("Neither current shadow, nor delta specified. It is required to have at least one of them specified."); } applyDefinitions(eventDescription, parentResult); PrismObject<ShadowType> shadow = null; shadow = eventDescription.getShadow(); ProvisioningContext ctx = provisioningContextFactory.create(shadow, task, parentResult); ctx.assertDefinition(); Collection<ResourceAttribute<?>> identifiers = ShadowUtil.getPrimaryIdentifiers(shadow); Change change = new Change(identifiers, eventDescription.getCurrentShadow(), eventDescription.getOldShadow(), eventDescription.getDelta()); ObjectClassComplexTypeDefinition objectClassDefinition = ShadowUtil.getObjectClassDefinition(shadow); change.setObjectClassDefinition(objectClassDefinition); LOGGER.trace("Start to precess change: {}", change.toString()); try { shadowCache.processChange(ctx, change, null, parentResult); } catch (EncryptionException e) { // TODO: better handling throw new SystemException(e.getMessage(), e); } LOGGER.trace("Change after processing {} . Start synchronizing.", change.toString()); shadowCache.processSynchronization(ctx, change, parentResult); }
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()); } }
@Override protected String createTicketAdd(PrismObject<? extends ShadowType> object, Collection<Operation> additionalOperations, OperationResult result) throws CommunicationException, GenericFrameworkException, SchemaException, ObjectAlreadyExistsException, ConfigurationException { LOGGER.debug("Creating case to add account\n{}", object.debugDump(1)); ObjectDelta<? extends ShadowType> objectDelta = DeltaFactory.Object.createAddDelta(object); ObjectDeltaType objectDeltaType = DeltaConvertor.toObjectDeltaType(objectDelta); String shadowName; if (object.getName() != null) { shadowName = object.getName().toString(); } else { shadowName = getShadowIdentifier(ShadowUtil.getPrimaryIdentifiers(object)); } String description = "Please create resource account: "+shadowName; PrismObject<CaseType> acase = addCase(description, ShadowUtil.getResourceOid(object.asObjectable()), shadowName, objectDeltaType, result); return acase.getOid(); }
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(); }
@Override public boolean handle(PrismObject<ShadowType> entitlementShadow) { Collection<? extends ResourceAttribute<?>> primaryIdentifiers = ShadowUtil.getPrimaryIdentifiers(entitlementShadow); ResourceObjectDiscriminator disc = new ResourceObjectDiscriminator(entitlementOcDef.getTypeName(), primaryIdentifiers); ResourceObjectOperations operations = roMap.get(disc);
Collection<ResourceAttribute<?>> identifiers = ShadowUtil.getPrimaryIdentifiers(account); assertNotNull("Identifiers must not be null", identifiers); assertEquals("Expected one identifier", 1, identifiers.size());
Collection<? extends ResourceAttribute<?>> primaryIdentifiers = ShadowUtil.getPrimaryIdentifiers(repoShadow);
Collection<? extends ResourceAttribute<?>> primaryIdentifiers = ShadowUtil.getPrimaryIdentifiers(repositoryShadow); if (primaryIdentifiers == null || primaryIdentifiers.isEmpty()) { if (ProvisioningUtil.hasPendingAddOperation(repositoryShadow) || ShadowUtil.isDead(repositoryShadow.asObjectable())) {