public static RefinedResourceSchema getRefinedSchema(ResourceType resourceType) throws SchemaException, ConfigurationException { RefinedResourceSchema refinedSchema = RefinedResourceSchemaImpl.getRefinedSchema(resourceType); if (refinedSchema == null) { throw new ConfigurationException("No schema for "+resourceType); } return refinedSchema; }
public static RefinedResourceSchema getRefinedSchema(PrismObject<ResourceType> resource) throws SchemaException, ConfigurationException { RefinedResourceSchema refinedSchema = RefinedResourceSchemaImpl.getRefinedSchema(resource); if (refinedSchema == null) { throw new ConfigurationException("No schema for "+resource); } return refinedSchema; }
@Override protected void throwException(Exception cause, ProvisioningOperationState<? extends AsynchronousOperationResult> opState, OperationResult result) throws ConfigurationException { recordCompletionError(cause, opState, result); if (cause instanceof ConfigurationException) { throw (ConfigurationException)cause; } else { throw new ConfigurationException(cause.getMessage(), cause); } }
public PrismObject<ShadowType> lookupShadowBySecondaryIdentifiers( ProvisioningContext ctx, Collection<ResourceAttribute<?>> secondaryIdentifiers, OperationResult parentResult) throws SchemaException, ConfigurationException, ObjectNotFoundException, CommunicationException, ExpressionEvaluationException { List<PrismObject<ShadowType>> shadows = lookupShadowsBySecondaryIdentifiers(ctx, secondaryIdentifiers, parentResult); if (shadows == null || shadows.isEmpty()) { return null; } if (shadows.size() > 1) { LOGGER.error("Too many shadows ({}) for secondary identifiers {}: {}", shadows.size(), secondaryIdentifiers, shadows); throw new ConfigurationException("Too many shadows ("+shadows.size()+") for secondary identifiers "+secondaryIdentifiers); } return shadows.get(0); }
private MergeConfigurationType selectConfiguration( PrismObject<SystemConfigurationType> systemConfiguration, String mergeConfigurationName) throws ConfigurationException { if (StringUtils.isBlank(mergeConfigurationName)) { throw new IllegalArgumentException("Merge configuration name not specified"); } for (MergeConfigurationType mergeConfiguration: systemConfiguration.asObjectable().getMergeConfiguration()) { if (mergeConfigurationName.equals(mergeConfiguration.getName())) { return mergeConfiguration; } } throw new ConfigurationException("Merge configuration with name '"+mergeConfigurationName+"' was not found"); }
private <O extends ObjectType, I extends Item> Collection<PrismValue> getValuesToTake(PrismObject<O> objectLeft, PrismObject<O> objectRight, String side, I origItem, MergeStrategyType strategy, Expression<PrismValue, ItemDefinition> valueExpression, Task task, OperationResult result) throws ConfigurationException, SchemaException, ExpressionEvaluationException, ObjectNotFoundException, CommunicationException, SecurityViolationException { if (origItem == null) { return new ArrayList<>(0); } if (strategy == MergeStrategyType.TAKE) { return cleanContainerIds(origItem.getClonedValues()); } else if (strategy == MergeStrategyType.EXPRESSION) { if (valueExpression == null) { throw new ConfigurationException("Expression strategy specified but no expression present"); } List<PrismValue> origValues = origItem.getValues(); Collection<PrismValue> valuesToTake = new ArrayList<>(origValues.size()); for (PrismValue origValue: origValues) { Collection<PrismValue> expressionOutput = evaluateValueExpression(objectLeft, objectRight, side, origValue, valueExpression, task, result); if (expressionOutput != null) { valuesToTake.addAll(expressionOutput); } } return cleanContainerIds(valuesToTake); } else { throw new ConfigurationException("Unknown strategy "+strategy); } }
private void applyConfigurationToConfigurationClass(PrismContainerValue<?> configurationContainer) throws ConfigurationException { BeanWrapper connectorBean = new BeanWrapperImpl(this); PropertyDescriptor connectorConfigurationProp = UcfUtil.findAnnotatedProperty(connectorBean, ManagedConnectorConfiguration.class); if (connectorConfigurationProp == null) { return; } Class<?> configurationClass = connectorConfigurationProp.getPropertyType(); Object configurationObject; try { configurationObject = configurationClass.newInstance(); } catch (InstantiationException | IllegalAccessException e) { throw new ConfigurationException("Cannot instantiate configuration "+configurationClass); } BeanWrapper configurationClassBean = new BeanWrapperImpl(configurationObject); for (Item<?, ?> configurationItem: configurationContainer.getItems()) { if (! (configurationItem instanceof PrismProperty<?>)) { throw new ConfigurationException("Only properties are supported for now"); } PrismProperty<?> configurationProperty = (PrismProperty<?>)configurationItem; Object realValue = configurationProperty.getRealValue(); configurationClassBean.setPropertyValue(configurationProperty.getElementName().getLocalPart(), realValue); } connectorBean.setPropertyValue(connectorConfigurationProp.getName(), configurationObject); } }
throw new ConfigurationException("Unknown configuration property "+propertyName);
return ConnIdUtil.toGuardedString(ps, pval.getParent().getElementName().getLocalPart(), protector); } else { throw new ConfigurationException( "Expected protected string as value of configuration property " + pval.getParent().getElementName().getLocalPart() + " but got " return protector.decryptString((ProtectedStringType)midPointRealValue); } catch (EncryptionException e) { throw new ConfigurationException(e);
SynchronizationSituationType reactionSituation = syncReaction.getSituation(); if (reactionSituation == null) { throw new ConfigurationException("No situation defined for a reaction in " + resource);
private <T extends CapabilityType> ConnectorInstance getConnectorInstance(Class<T> operationCapabilityClass, OperationResult parentResult) throws ObjectNotFoundException, SchemaException, CommunicationException, ConfigurationException, ExpressionEvaluationException { OperationResult connectorResult = parentResult.createMinorSubresult(ProvisioningContext.class.getName() + ".getConnectorInstance"); try { ConnectorInstance connector = resourceManager.getConfiguredConnectorInstance(getResource().asPrismObject(), operationCapabilityClass, false, parentResult); connectorResult.recordSuccess(); return connector; } catch (ObjectNotFoundException | SchemaException e){ connectorResult.recordPartialError("Could not get connector instance " + getDesc() + ": " + e.getMessage(), e); // Wrap those exceptions to a configuration exception. In the context of the provisioning operation we really cannot throw // ObjectNotFoundException exception. If we do that then the consistency code will interpret that as if the resource object // (shadow) is missing. But that's wrong. We do not have connector therefore we do not know anything about the shadow. We cannot // throw ObjectNotFoundException here. throw new ConfigurationException(e.getMessage(), e); } catch (CommunicationException | ConfigurationException | SystemException e){ connectorResult.recordPartialError("Could not get connector instance " + getDesc() + ": " + e.getMessage(), e); throw e; } }
private boolean isCachedShadowValid(Collection<SelectorOptions<GetOperationOptions>> options, PrismObject<ShadowType> repositoryShadow, ResourceType resource) throws ConfigurationException { long stalenessOption = GetOperationOptions.getStaleness(SelectorOptions.findRootOptions(options)); if (stalenessOption == 0L) { return false; } CachingMetadataType cachingMetadata = repositoryShadow.asObjectable().getCachingMetadata(); if (cachingMetadata == null) { if (stalenessOption == Long.MAX_VALUE) { // We must return cached version but there is no cached version. throw new ConfigurationException("Cached version of "+repositoryShadow+" requested, but there is no cached value"); } return false; } if (stalenessOption == Long.MAX_VALUE) { return true; } XMLGregorianCalendar retrievalTimestamp = cachingMetadata.getRetrievalTimestamp(); if (retrievalTimestamp == null) { return false; } long retrievalTimestampMillis = XmlTypeConverter.toMillis(retrievalTimestamp); return (clock.currentTimeMillis() - retrievalTimestampMillis < stalenessOption); }
public <O extends ObjectType> MergeDeltas<O> computeMergeDeltas(Class<O> type, String leftOid, String rightOid, final String mergeConfigurationName, final Task task, final OperationResult result) throws ObjectNotFoundException, SchemaException, ConfigurationException, ExpressionEvaluationException, CommunicationException, SecurityViolationException { final PrismObject<O> objectLeft = (PrismObject<O>) objectResolver.getObjectSimple(type, leftOid, null, task, result).asPrismObject(); final PrismObject<O> objectRight = (PrismObject<O>) objectResolver.getObjectSimple(type, rightOid, null, task, result).asPrismObject(); PrismObject<SystemConfigurationType> systemConfiguration = systemObjectCache.getSystemConfiguration(result); MergeConfigurationType mergeConfiguration = selectConfiguration(systemConfiguration, mergeConfigurationName); if (mergeConfiguration == null) { throw new ConfigurationException("No merge configuration defined"); } // The "left" object is always the one that will be the result. We will use its OID. final ObjectDelta<O> leftObjectDelta = objectLeft.createModifyDelta(); final ObjectDelta<O> leftLinkDelta = objectLeft.createModifyDelta(); final ObjectDelta<O> rightLinkDelta = objectRight.createModifyDelta(); final List<ItemPath> processedPaths = new ArrayList<>(); computeItemDeltas(leftObjectDelta, objectLeft, objectRight, processedPaths, mergeConfiguration, mergeConfigurationName, task, result); computeDefaultDeltas(leftObjectDelta, objectLeft, objectRight, processedPaths, mergeConfiguration, mergeConfigurationName, task, result); computeProjectionDeltas(leftLinkDelta, rightLinkDelta, objectLeft, objectRight, mergeConfiguration, mergeConfigurationName, task, result); return new MergeDeltas<>(leftObjectDelta, leftLinkDelta, rightLinkDelta); }
public static boolean shouldStoreAtributeInShadow(RefinedObjectClassDefinition objectClassDefinition, QName attributeName, CachingStategyType cachingStrategy) throws ConfigurationException { if (cachingStrategy == null || cachingStrategy == CachingStategyType.NONE) { if (objectClassDefinition.isPrimaryIdentifier(attributeName) || objectClassDefinition.isSecondaryIdentifier(attributeName)) { return true; } for (RefinedAssociationDefinition associationDef: objectClassDefinition.getAssociationDefinitions()) { if (associationDef.getResourceObjectAssociationType().getDirection() == ResourceObjectAssociationDirectionType.OBJECT_TO_SUBJECT) { QName valueAttributeName = associationDef.getResourceObjectAssociationType().getValueAttribute(); if (QNameUtil.match(attributeName, valueAttributeName)) { return true; } } } return false; } else if (cachingStrategy == CachingStategyType.PASSIVE) { RefinedAttributeDefinition<Object> attrDef = objectClassDefinition.findAttributeDefinition(attributeName); return attrDef != null; } else { throw new ConfigurationException("Unknown caching strategy "+cachingStrategy); } }
private RefinedObjectClassDefinition determineObjectClassDefinition(PrismObject<ShadowType> shadow, ResourceType resource) throws SchemaException, ConfigurationException { ShadowType shadowType = shadow.asObjectable(); RefinedResourceSchema refinedSchema = RefinedResourceSchemaImpl.getRefinedSchema(resource, prismContext); if (refinedSchema == null) { throw new ConfigurationException("No schema definied for "+resource); } RefinedObjectClassDefinition objectClassDefinition = null; ShadowKindType kind = shadowType.getKind(); String intent = shadowType.getIntent(); QName objectClass = shadow.asObjectable().getObjectClass(); if (kind != null) { objectClassDefinition = refinedSchema.getRefinedDefinition(kind, intent); } else { // Fallback to objectclass only if (objectClass == null) { throw new SchemaException("No kind nor objectclass definied in "+shadow); } objectClassDefinition = refinedSchema.findRefinedDefinitionByObjectClassQName(null, objectClass); } if (objectClassDefinition == null) { throw new SchemaException("Definition for "+shadow+" not found (objectClass=" + PrettyPrinter.prettyPrint(objectClass) + ", kind="+kind+", intent='"+intent+"') in schema of " + resource); } return objectClassDefinition; }
+ " resolution in " + contextDescription + ": " + e.getMessage(), e); } catch (ConfigurationException e) { throw new ConfigurationException("Configuration error during variable " + varDesc + " resolution in " + contextDescription + ": " + e.getMessage(), e); } catch (SecurityViolationException e) {
throw new ConfigurationException( "Action definition in resource " + syncCtx.getResource() + " doesn't contain handler URI");
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; }
} catch (ConfigurationException ex) { LoggingUtils.logException(LOGGER, "Couldn't confirm user {}", ex, user.getElementName()); throw new ConfigurationException("Couldn't confirm user " + user.getElementName(), ex); } catch (SecurityViolationException ex) { LoggingUtils.logException(LOGGER, "Couldn't confirm user {}", ex, user.getElementName());
private static Exception processConnectorException(ConnectorException connIdException, OperationResult connIdResult) { if (connIdException instanceof ConfigurationException) { Exception newEx = new com.evolveum.midpoint.util.exception.ConfigurationException(createMessageFromInnermostException("Configuration error", connIdException)); connIdResult.recordFatalError("Configuration error: " + connIdException.getMessage(), newEx); return newEx;