public <T> T getPropertyRealValue(ItemPath propertyPath, Class<T> type) { PrismProperty<T> property = findProperty(propertyPath); if (property == null) { return null; } return property.getRealValue(type); }
@Override public void setExtensionProperty(PrismProperty<?> property) throws SchemaException { processModificationBatched(setExtensionPropertyAndPrepareDelta(property.getElementName(), property.getDefinition(), PrismValueCollectionsUtil.cloneCollection(property.getValues()))); }
public static void setXsdSchemaDefinition(PrismProperty<SchemaDefinitionType> definitionProperty, Element xsdElement) { // Document document = xsdElement.getOwnerDocument(); // Element definitionElement = document.createElementNS(XmlSchemaType.F_DEFINITION.getNamespaceURI(), // XmlSchemaType.F_DEFINITION.getLocalPart()); // definitionElement.appendChild(xsdElement); // SchemaDefinitionType schemaDefinition = definitionProperty.getValue().getValue(); // schemaDefinition.setSchema(definitionElement); SchemaDefinitionType schemaDefinition = new SchemaDefinitionType(); schemaDefinition.setSchema(xsdElement); definitionProperty.setRealValue(schemaDefinition); }
private String determinePasswordValue(PrismProperty<ProtectedStringType> password) { if (password == null || password.getValue(ProtectedStringType.class) == null) { return null; } ProtectedStringType passValue = password.getRealValue(); return determinePasswordValue(passValue); }
public static <T> void assertPropertyValueDesc(PrismProperty<T> property, MatchingRule<T> matchingRule, String contextDescrition, T... expectedPropValues) throws SchemaException { Collection<PrismPropertyValue<T>> pvals = property.getValues(); QName propQName = property.getElementName(); assert pvals != null && !pvals.isEmpty() : "Empty property "+propQName; assertSet("property "+propQName + (contextDescrition == null ? "" : " in " + contextDescrition), "value", matchingRule, pvals, expectedPropValues); }
public static <T> PropertyDelta<T> diff(PrismProperty<T> a, PrismProperty<T> b) { if (a == null) { if (b == null) { return null; } PropertyDelta<T> delta = b.createDelta(); delta.addValuesToAdd(PrismValueCollectionsUtil.cloneCollection(b.getValues())); return delta; } else { return a.diff(b); } }
public static void assertPropertyDefinition(PrismContainer<?> container, QName propertyName, QName type, int minOccurs, int maxOccurs) { PrismProperty<?> findProperty = container.findProperty(ItemName.fromQName(propertyName)); PrismPropertyDefinition<?> definition = findProperty.getDefinition(); assertDefinition(definition, propertyName, type, minOccurs, maxOccurs); }
/** * Always returns collection, even for single-valued results. */ public static <X> Collection<X> getPropertyStaticRealValues(ExpressionType expressionType, PrismPropertyDefinition outputDefinition, String contextDescription, PrismContext prismContext) throws SchemaException { PrismProperty<X> output = getPropertyStatic(expressionType, outputDefinition, contextDescription, prismContext); return output.getRealValues(); }
displayNamePP.setRealValue("Big red ball"); displayNamePP.setImmutable(true); displayNamePP.setRealValue("Small black cube"); AssertJUnit.fail("Value was changed when immutable!"); } catch (RuntimeException e) { displayNamePP.getValue().setValue("Green point"); AssertJUnit.fail("Value was changed when immutable!"); } catch (RuntimeException e) { displayNamePP.setImmutable(false); displayNamePP.setRealValue("Small black cube"); assertEquals("Real value was not changed", "Small black cube", displayNamePP.getAnyRealValue()); displayNamePP.getAnyValue().setValue("Green point"); assertEquals("Real value was not changed", "Green point", displayNamePP.getAnyRealValue());
@Override protected <T> void assertConfigurationProperty(PrismProperty<T> confProp) { T val = confProp.getRealValue(); switch (confProp.getElementName().getLocalPart()) { case "instanceId": assertEquals("Wrong value for "+confProp, "", val); break; case "uselessString": assertEquals("Wrong value for "+confProp, "Shiver me timbers!", val); assertExpression(confProp, "value"); break; default: break; } }
@Override public <T> S_MatchingRuleEntry eq(PrismProperty<T> property) { List<PrismPropertyValue<T>> clonedValues = (List<PrismPropertyValue<T>>) PrismValueCollectionsUtil.cloneCollection(property.getValues()); //noinspection unchecked PrismPropertyDefinition<T> definition = this.propertyDefinition != null ? this.propertyDefinition : property.getDefinition(); return new R_AtomicFilter(this, EqualFilterImpl .createEqual(itemPath, definition, null, owner.getPrismContext(), clonedValues)); }
private Object[] convertToConnIdfArray(PrismProperty prismProperty, Class<?> componentType) throws ConfigurationException { List<PrismPropertyValue> values = prismProperty.getValues(); Object valuesArrary = Array.newInstance(componentType, values.size()); for (int j = 0; j < values.size(); ++j) { Object icfValue = convertToIcf(values.get(j), componentType); Array.set(valuesArrary, j, icfValue); } return (Object[]) valuesArrary; }
private Object convertToConnIdSingle(PrismProperty<?> configProperty, Class<?> expectedType) throws ConfigurationException { if (configProperty == null) { return null; } PrismPropertyValue<?> pval = configProperty.getValue(); return convertToIcf(pval, expectedType); }
public static boolean compareCollectionRealValues(Collection<? extends PrismProperty> col1, Collection<? extends PrismProperty> col2) { return MiscUtil.unorderedCollectionEquals(col1, col2, (p1, p2) -> { if (!p1.getElementName().equals(p2.getElementName())) { return false; } Collection p1RealVals = p1.getRealValues(); Collection p2RealVals = p2.getRealValues(); return MiscUtil.unorderedCollectionEquals(p1RealVals, p2RealVals); }); } }
@Override public PrismValueDeltaSetTriple<V> evaluate(ExpressionEvaluationContext context) throws SchemaException, ExpressionEvaluationException, ObjectNotFoundException { String constName = constEvaluatorType.getValue(); String stringValue = constantsManager.getConstantValue(constName); Item<V, D> output = outputDefinition.instantiate(); Object value = ExpressionUtil.convertToOutputValue(stringValue, outputDefinition, protector); if (output instanceof PrismProperty) { ((PrismProperty<Object>) output).addRealValue(value); } else { throw new UnsupportedOperationException( "Can only generate values of property, not " + output.getClass()); } return ItemDeltaUtil.toDeltaSetTriple(output, null, prismContext); }
private void checkExtension(ExtensionType extension, String sourceDescription) throws SchemaException { PrismContainerValue<ExtensionType> extensionValueFromJaxb = extension.asPrismContainerValue(); assertNotNull("No extension container in "+sourceDescription+" (jaxb)", extensionValueFromJaxb); assertNotNull("No extension definition in "+sourceDescription+" (jaxb)", extensionValueFromJaxb.getParent().getDefinition()); assertTrue("Not runtime in definition in "+sourceDescription+" (jaxb)", extensionValueFromJaxb.getParent().getDefinition().isRuntimeSchema()); PrismProperty<Integer> intProperty = extensionValueFromJaxb.findOrCreateProperty(EXTENSION_INT_TYPE_ELEMENT); PrismAsserts.assertDefinition(intProperty.getDefinition(), EXTENSION_INT_TYPE_ELEMENT, DOMUtil.XSD_INT, 0, -1); intProperty.setRealValue(15); PrismProperty<String> stringProperty = extensionValueFromJaxb.findOrCreateItem(EXTENSION_STRING_TYPE_ELEMENT, PrismProperty.class); PrismAsserts.assertDefinition(stringProperty.getDefinition(), EXTENSION_STRING_TYPE_ELEMENT, DOMUtil.XSD_STRING, 0, -1); stringProperty.setRealValue("fifteen men on a dead man chest"); }
private SyncToken getSyncToken(PrismProperty tokenProperty) throws SchemaException { if (tokenProperty == null){ return null; } if (tokenProperty.getValues() == null) { return null; } if (tokenProperty.getValues().isEmpty()) { return null; } if (tokenProperty.getValues().size() > 1) { throw new SchemaException("Unexpected number of attributes in SyncToken. SyncToken is single-value attribute and can contain only one value."); } Object tokenValue = tokenProperty.getAnyRealValue(); if (tokenValue == null) { return null; } SyncToken syncToken = new SyncToken(tokenValue); return syncToken; }
private <X> PrismProperty<X> resolveStructuredPropertyItem(PrismProperty<Structured> sourceProperty, ItemPath resolvePath, PrismPropertyDefinition outputDefinition) { if (sourceProperty == null) { return null; } PrismProperty<X> outputProperty = outputDefinition.instantiate(); for (Structured sourceRealValue: sourceProperty.getRealValues()) { X outputRealValue = (X) sourceRealValue.resolve(resolvePath); outputProperty.addRealValue(outputRealValue); } return outputProperty; }
public static ItemDelta<?, ?> createExtensionDelta(PrismPropertyDefinition definition, Object realValue, PrismContext prismContext) { PrismProperty<Object> property = (PrismProperty<Object>) definition.instantiate(); property.setRealValue(realValue); return prismContext.deltaFactory().property() .createModificationReplaceProperty(ItemPath.create(TaskType.F_EXTENSION, property.getElementName()), definition, realValue); }
@SuppressWarnings("rawtypes") private PrismProperty getTokenProperty(ResourceShadowDiscriminator shadowCoordinates, Task task, OperationResult result) throws ObjectNotFoundException, CommunicationException, SchemaException, ConfigurationException, ExpressionEvaluationException { PrismProperty tokenProperty = null; if (task.getExtension() != null) { tokenProperty = task.getExtensionProperty(SchemaConstants.SYNC_TOKEN); } if (tokenProperty != null && (tokenProperty.getAnyRealValue() == null)) { LOGGER.warn("Sync token exists, but it is empty (null value). Ignoring it."); if (LOGGER.isTraceEnabled()) { LOGGER.trace("Empty sync token property:\n{}", tokenProperty.debugDump()); } tokenProperty = null; } // if the token is not specified in the task, get the latest token if (tokenProperty == null) { tokenProperty = shadowCache.fetchCurrentToken(shadowCoordinates, result); if (tokenProperty == null || tokenProperty.getValue() == null || tokenProperty.getValue().getValue() == null) { LOGGER.warn("Empty current sync token provided by {}", shadowCoordinates); if (LOGGER.isTraceEnabled()) { LOGGER.trace("Empty current sync token property."); } return null; } } return tokenProperty; }