return identification; if (identification.hasPrimaryIdentifiers()) { return identification; Collection<ResourceAttribute<?>> secondaryIdentifiers = (Collection<ResourceAttribute<?>>) identification.getSecondaryIdentifiers(); PrismObject<ShadowType> repoShadow = shadowManager.lookupShadowBySecondaryIdentifiers(ctx, secondaryIdentifiers, result); if (repoShadow == null) { return new ResourceObjectIdentification(identification.getObjectClassDefinition(), primaryIdentifiers, identification.getSecondaryIdentifiers());
public static ResourceObjectIdentification createFromShadow(ObjectClassComplexTypeDefinition objectClassDefinition, ShadowType shadowType) throws SchemaException { return createFromAttributes(objectClassDefinition, ShadowUtil.getAttributes(shadowType)); }
private ResourceAttributeDefinition getUidDefinition(ResourceObjectIdentification identification) throws SchemaException { ResourceAttribute<String> primaryIdentifier = identification.getPrimaryIdentifier(); if (primaryIdentifier == null) { // fallback, compatibility for (ResourceAttribute<?> attr : identification.getAllIdentifiers()) { if (attr.getElementName().equals(SchemaConstants.ICFS_UID)) { return attr.getDefinition(); } } return null; } return primaryIdentifier.getDefinition(); }
private ResourceAttributeDefinition getNameDefinition(ResourceObjectIdentification identification) throws SchemaException { ResourceAttribute<String> secondaryIdentifier = identification.getSecondaryIdentifier(); if (secondaryIdentifier == null) { // fallback, compatibility for (ResourceAttribute<?> attr : identification.getAllIdentifiers()) { if (attr.getElementName().equals(SchemaConstants.ICFS_NAME)) { return attr.getDefinition(); } } return null; } return secondaryIdentifier.getDefinition(); }
public static ResourceObjectIdentification getResourceObjectIdentification( PrismObject<ShadowType> shadow, ObjectClassComplexTypeDefinition objectClassDefinition) { return new ResourceObjectIdentification(objectClassDefinition, ShadowUtil.getPrimaryIdentifiers(shadow), ShadowUtil.getSecondaryIdentifiers(shadow)); }
ObjectClass objClass = connIdNameMapper.objectClassToConnId(identification.getObjectClassDefinition(), getSchemaNamespace(), connectorType, legacySchema);
@Override public AsynchronousOperationReturnValue<Collection<PropertyModificationOperation>> modifyObject( ResourceObjectIdentification identification, PrismObject<ShadowType> shadow, Collection<Operation> changes, ConnectorOperationOptions options, StateReporter reporter, OperationResult parentResult) throws ObjectNotFoundException, CommunicationException, GenericFrameworkException, SchemaException, SecurityViolationException, ObjectAlreadyExistsException, ConfigurationException { OperationResult result = parentResult.createSubresult(OPERATION_MODIFY); InternalMonitor.recordConnectorOperation("modify"); InternalMonitor.recordConnectorModification("modify"); String ticketIdentifier = null; try { ticketIdentifier = createTicketModify(identification.getObjectClassDefinition(), shadow, identification.getAllIdentifiers(), reporter.getResourceOid(), changes, result); } catch (ObjectNotFoundException | CommunicationException | GenericFrameworkException | SchemaException | ObjectAlreadyExistsException | ConfigurationException | RuntimeException | Error e) { result.recordFatalError(e); throw e; } result.recordInProgress(); result.setAsynchronousOperationReference(ticketIdentifier); AsynchronousOperationReturnValue<Collection<PropertyModificationOperation>> ret = new AsynchronousOperationReturnValue<>(); ret.setOperationType(PendingOperationTypeType.MANUAL); ret.setOperationResult(result); return ret; }
ResourceAttribute<?> secondaryIdentifier = baseContextIdentification.getSecondaryIdentifier(); if (secondaryIdentifier == null) { SchemaException e = new SchemaException("No secondary identifier in base context identification "+baseContextIdentification); ObjectClass baseContextIcfObjectClass = connIdNameMapper.objectClassToConnId(baseContextIdentification.getObjectClassDefinition(), getSchemaNamespace(), connectorType, legacySchema); QualifiedUid containerQualifiedUid = new QualifiedUid(baseContextIcfObjectClass, new Uid(secondaryIdentifierValue)); optionsBuilder.setContainer(containerQualifiedUid);
ResourceObjectIdentification identification = ResourceObjectIdentification.create(objectClassDefinition, identifiers); identification = resolvePrimaryIdentifiers(ctx, identification, parentResult); identification.validatePrimaryIdenfiers(); return connector.fetchObject(identification, attributesToReturn, ctx, parentResult);
public void validatePrimaryIdenfiers() { if (!hasPrimaryIdentifiers()) { throw new IllegalStateException("No primary identifiers in " + this); } }
private String getNameValue(ResourceObjectIdentification resourceObjectIdentification) throws SchemaException { Collection<? extends ResourceAttribute<?>> secondaryIdentifiers = resourceObjectIdentification.getSecondaryIdentifiers(); if (secondaryIdentifiers == null) { return null; } if (secondaryIdentifiers.size() == 1) { return (String) secondaryIdentifiers.iterator().next().getRealValue(); } else if (secondaryIdentifiers.size() > 1) { for (ResourceAttribute<?> secondaryIdentifier : secondaryIdentifiers) { ResourceAttributeDefinition<?> definition = secondaryIdentifier.getDefinition(); if (definition != null) { if (Name.NAME.equals(definition.getFrameworkAttributeName())) { return (String) secondaryIdentifier.getRealValue(); } } } throw new SchemaException("More than one secondary indentifier in "+resourceObjectIdentification+", cannot detemine ConnId __NAME__"); } return null; }
private ConnectorOperationOptions createConnectorOperationOptions(ProvisioningContext ctx, ProvisioningOperationOptions options, OperationResult result) throws SchemaException, ConfigurationException, ObjectNotFoundException, CommunicationException, ExpressionEvaluationException { if (options == null) { return null; } String runAsAccountOid = options.getRunAsAccountOid(); if (runAsAccountOid == null) { return null; } RunAsCapabilityType capRunAs = ctx.getResourceEffectiveCapability(RunAsCapabilityType.class); if (capRunAs == null) { LOGGER.trace("Operation runAs requested, but resource does not have the capability. Ignoring runAs"); return null; } PrismObject<ShadowType> runAsShadow; try { runAsShadow = shadowManager.getRepoShadow(runAsAccountOid, result); } catch (ObjectNotFoundException e) { throw new ConfigurationException("Requested non-existing 'runAs' shadow", e); } ProvisioningContext runAsCtx = ctxFactory.create(runAsShadow, null, ctx.getTask(), result); shadowCaretaker.applyAttributesDefinition(runAsCtx, runAsShadow); ResourceObjectIdentification runAsIdentification = ResourceObjectIdentification.createFromShadow(runAsCtx.getObjectClassDefinition(), runAsShadow.asObjectable()); ConnectorOperationOptions connOptions = new ConnectorOperationOptions(); LOGGER.trace("RunAs identification: {}", runAsIdentification); connOptions.setRunAsIdentification(runAsIdentification); return connOptions; }
private Uid getUid(ResourceObjectIdentification resourceObjectIdentification) throws SchemaException { ResourceAttribute<String> primaryIdentifier = resourceObjectIdentification.getPrimaryIdentifier(); if (primaryIdentifier == null) { return null; } String uidValue = primaryIdentifier.getRealValue(); String nameValue = getNameValue(resourceObjectIdentification); if (uidValue != null) { if (nameValue == null) { return new Uid(uidValue); } else { return new Uid(uidValue, new Name(nameValue)); } } return null; }
ResourceObjectIdentification identification = ResourceObjectIdentification.create(objectClassDefinition, identifiersWorkingCopy); connectorAsyncOpRet = connector.modifyObject(identification, currentShadow, operationsWave, connOptions, ctx, parentResult); Collection<PropertyModificationOperation> sideEffects = connectorAsyncOpRet.getReturnValue();
public static ResourceObjectIdentification createFromAttributes(ObjectClassComplexTypeDefinition objectClassDefinition, Collection<? extends ResourceAttribute<?>> attributes) throws SchemaException { Collection<? extends ResourceAttribute<?>> primaryIdentifiers = null; Collection<? extends ResourceAttribute<?>> secondaryIdentifiers = null; for (ResourceAttribute<?> identifier: attributes) { if (objectClassDefinition.isPrimaryIdentifier(identifier.getElementName())) { if (primaryIdentifiers == null) { primaryIdentifiers = new ArrayList<>(); } ((Collection)primaryIdentifiers).add(identifier); } else if (objectClassDefinition.isSecondaryIdentifier(identifier.getElementName())) { if (secondaryIdentifiers == null) { secondaryIdentifiers = new ArrayList<>(); } ((Collection)secondaryIdentifiers).add(identifier); } } return new ResourceObjectIdentification(objectClassDefinition, primaryIdentifiers, secondaryIdentifiers); }
GenericFrameworkException, SchemaException, SecurityViolationException, PolicyViolationException, ObjectAlreadyExistsException { ObjectClassComplexTypeDefinition objectClassDef = identification.getObjectClassDefinition(); Set<AttributeDelta> sideEffect = new HashSet<>(); String originalUid = uid.getUidValue();
private void replaceNameValue(ResourceObjectIdentification identification, Name newName) throws SchemaException { ResourceAttribute<String> secondaryIdentifier = identification.getSecondaryIdentifier(); if (secondaryIdentifier == null) { // fallback, compatibility for (ResourceAttribute<?> attr : identification.getAllIdentifiers()) { if (attr.getElementName().equals(SchemaConstants.ICFS_NAME)) { // expecting the NAME property is of type String //noinspection unchecked ((ResourceAttribute<String>) attr).setRealValue(newName.getNameValue()); return; } } throw new IllegalStateException("No identifiers"); } secondaryIdentifier.setRealValue(newName.getNameValue()); }
if (!MiscUtil.equals(shadowAttrsToReturn, attrsToReturn)) { ResourceObjectIdentification identification = ResourceObjectIdentification.create(shadowCtx.getObjectClassDefinition(), change.getIdentifiers()); identification.validatePrimaryIdenfiers(); LOGGER.trace("Re-fetching object {} because of attrsToReturn", identification); currentShadow = connector.fetchObject(identification, shadowAttrsToReturn, ctx, parentResult);
ResourceObjectIdentification identification = ResourceObjectIdentification.createFromShadow(ctx.getObjectClassDefinition(), shadow.asObjectable());
public static ResourceObjectIdentification create(ObjectClassComplexTypeDefinition objectClassDefinition, Collection<? extends ResourceAttribute<?>> allIdentifiers) throws SchemaException { if (allIdentifiers == null) { throw new IllegalArgumentException("Cannot create ResourceObjectIdentification with null identifiers"); } Collection<? extends ResourceAttribute<?>> primaryIdentifiers = null; Collection<? extends ResourceAttribute<?>> secondaryIdentifiers = null; for (ResourceAttribute<?> identifier: allIdentifiers) { if (objectClassDefinition.isPrimaryIdentifier(identifier.getElementName())) { if (primaryIdentifiers == null) { primaryIdentifiers = new ArrayList<>(); } ((Collection)primaryIdentifiers).add(identifier); } else if (objectClassDefinition.isSecondaryIdentifier(identifier.getElementName())) { if (secondaryIdentifiers == null) { secondaryIdentifiers = new ArrayList<>(); } ((Collection)secondaryIdentifiers).add(identifier); } else { throw new SchemaException("Attribute "+identifier+" is neither primary not secondary identifier in object class "+objectClassDefinition); } } return new ResourceObjectIdentification(objectClassDefinition, primaryIdentifiers, secondaryIdentifiers); }