private <T> T getTaskPropertyValue(QName propertyName) { PrismProperty<T> prop = task.getExtensionProperty(propertyName); if (prop == null || prop.isEmpty()) { return null; } return prop.getRealValue(); }
@Override public <T> T getExtensionPropertyRealValue(QName propertyName) { PrismProperty<T> property = getExtensionProperty(propertyName); if (property == null || property.isEmpty()) { return null; } else { return property.getRealValue(); } }
static Boolean findItemValue(Task task, QName path) throws SchemaException{ Validate.notNull(task, "Task must not be null."); if (task.getExtension() == null) { return null; } PrismProperty<Boolean> item = task.getExtensionProperty(path); if (item == null || item.isEmpty()) { return null; } if (item.getValues().size() > 1) { throw new SchemaException("Unexpected number of values for option 'dry run'."); } return item.getValues().iterator().next().getValue(); }
private <F extends ObjectType> boolean checkWeakSkip(MappingImpl<?,?> inbound, PrismObject<F> newUser) throws SchemaException { if (inbound.getStrength() != MappingStrengthType.WEAK) { return false; } if (newUser == null) { return false; } PrismProperty<?> property = newUser.findProperty(inbound.getOutputPath()); if (property != null && !property.isEmpty()) { return true; } return false; }
/** * Returns true if the projection has any value for specified attribute. */ public boolean hasValueForAttribute(QName attributeName) { ItemPath attrPath = ItemPath.create(ShadowType.F_ATTRIBUTES, attributeName); if (getObjectNew() != null) { PrismProperty<?> attrNew = getObjectNew().findProperty(attrPath); if (attrNew != null && !attrNew.isEmpty()) { return true; } } return false; }
public static ModelExecuteOptions getModelExecuteOptions(Task task) throws SchemaException { Validate.notNull(task, "Task must not be null."); if (task.getExtension() == null) { return null; } //LOGGER.info("Task:\n{}",task.debugDump(1)); PrismProperty<ModelExecuteOptionsType> item = task.getExtensionProperty(SchemaConstants.C_MODEL_EXECUTE_OPTIONS); if (item == null || item.isEmpty()) { return null; } //LOGGER.info("Item:\n{}",item.debugDump(1)); if (item.getValues().size() > 1) { throw new SchemaException("Unexpected number of values for option 'modelExecuteOptions'."); } ModelExecuteOptionsType modelExecuteOptionsType = item.getValues().iterator().next().getValue(); if (modelExecuteOptionsType == null) { return null; } //LOGGER.info("modelExecuteOptionsType: {}",modelExecuteOptionsType); ModelExecuteOptions modelExecuteOptions = ModelExecuteOptions.fromModelExecutionOptionsType(modelExecuteOptionsType); //LOGGER.info("modelExecuteOptions: {}",modelExecuteOptions); return modelExecuteOptions; }
public static void deleteSchema(PrismObject<ResourceType> resource, ModelService modelService, PrismContext prismContext, Task task, OperationResult parentResult) throws ObjectAlreadyExistsException, ObjectNotFoundException, SchemaException, ExpressionEvaluationException, CommunicationException, ConfigurationException, PolicyViolationException, SecurityViolationException { PrismProperty<SchemaDefinitionType> definition = resource.findProperty(SCHEMA_PATH); if (definition != null && !definition.isEmpty()) { ObjectDelta<ResourceType> delta = prismContext.deltaFor(ResourceType.class) .item(SCHEMA_PATH).replace() .asObjectDelta(resource.getOid()); modelService.executeChanges(singleton(delta), null, task, parentResult); } } }
@Override public List<ShadowType> getShadowsToActivate(Collection<? extends ModelElementContext> projectionContexts) { List<ShadowType> shadows = new ArrayList<>(); for (ModelElementContext<ShadowType> projectionCtx : projectionContexts) { List<? extends ObjectDeltaOperation> executedShadowDelas = projectionCtx.getExecutedDeltas(); for (ObjectDeltaOperation<ShadowType> shadowDelta : executedShadowDelas) { if (shadowDelta.getExecutionResult().getStatus() == OperationResultStatus.SUCCESS && shadowDelta.getObjectDelta().getChangeType() == ChangeType.ADD) { PrismObject<ShadowType> shadow = shadowDelta.getObjectDelta().getObjectToAdd(); PrismProperty<String> pLifecycleState = shadow.findProperty(ShadowType.F_LIFECYCLE_STATE); if (pLifecycleState != null && !pLifecycleState.isEmpty() && SchemaConstants.LIFECYCLE_PROPOSED .equals(pLifecycleState.getRealValue())) { shadows.add(shadow.asObjectable()); } } } } return shadows; }
private static boolean isDryRun(Task task){ Validate.notNull(task, "Task must not be null."); if (task.getExtension() == null){ return false; } PrismProperty<Boolean> item = task.getExtensionProperty(SchemaConstants.MODEL_EXTENSION_DRY_RUN); if (item == null || item.isEmpty()){ return false; } if (item.getValues().size() > 1){ return false; // throw new SchemaException("Unexpected number of values for option 'dry run'."); } Boolean dryRun = item.getValues().iterator().next().getValue(); if (dryRun == null){ return false; } return dryRun.booleanValue(); }
private <T> boolean checkPropertyUniqueness(PrismObject<AH> objectNew, ItemPath propPath, LensContext<AH> context, OperationResult result) throws SchemaException { if (property == null || property.isEmpty()) { throw new SchemaException("No property "+propPath+" in new object "+objectNew+", cannot check uniqueness");
private void checkOrFixActivationItem(ShadowCheckResult checkResult, PrismObject<ShadowType> shadow, PrismContainerValue<ActivationType> activation, ItemName itemName) { PrismProperty property = activation.findProperty(itemName); if (property == null || property.isEmpty()) { return; } checkResult.recordWarning(ShadowStatistics.EXTRA_ACTIVATION_DATA, "Unexpected activation item: " + property); if (fixExtraData) { PropertyDelta delta = prismContext.deltaFactory().property().createReplaceEmptyDelta(shadow.getDefinition(), ItemPath.create(ShadowType.F_ACTIVATION, itemName)); checkResult.addFixDelta(delta, ShadowStatistics.EXTRA_ACTIVATION_DATA); } }
if (deltasProperty == null || deltasProperty.isEmpty()) { PrismProperty<ObjectDeltaType> deltaProperty = task.getExtensionProperty(SchemaConstants.MODEL_EXTENSION_OBJECT_DELTA); if (deltaProperty == null || deltaProperty.isEmpty()) { throw new IllegalArgumentException("No deltas to execute"); } else {
protected void collectPassword(PropertyDelta<ProtectedStringType> passwordDelta) throws SchemaException { PrismProperty<ProtectedStringType> newPassword = passwordDelta.getPropertyNewMatchingPath(); if (newPassword == null || newPassword.isEmpty()) { // This is the case of setting no password. E.g. removing existing password LOGGER.debug("Setting null password."); collectReplace(OperationalAttributes.PASSWORD_NAME, null); } else if (newPassword.getRealValue().canGetCleartext()) { // We have password and we can get a cleartext value of the passowrd. This is normal case GuardedString guardedPassword = passwordToGuardedString(newPassword.getRealValue(), "new password"); collectReplace(OperationalAttributes.PASSWORD_NAME, guardedPassword); } else { // We have password, but we cannot get a cleartext value. Just to nothing. LOGGER.debug("We would like to set password, but we do not have cleartext value. Skipping the opearation."); } }
if (property == null || property.isEmpty()) { LOGGER.error("Attribute {} has no value. Nothing to validate.", property); parentResult.recordFatalError("Attribute " + property + " has no value. Nothing to validate");
if (BooleanUtils.isTrue(propertyConstraintType.isOidBound())) { PrismProperty<Object> prop = focusNew.findProperty(itemPath); if (prop == null || prop.isEmpty()) { String newValue = focusNew.getOid(); if (newValue == null) {