@Override public int size() { return property.getValues().size(); }
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 PrismPropertyValue<Object> getPropertyValue(int index) { if (index < 0 || index >= size()) { throw new IndexOutOfBoundsException("Can't get object on position '" + index + "', list size is '" + size() + "'."); } //at least we try to get object on index defined by parameter Iterator<PrismPropertyValue<Object>> iterator = property.getValues().iterator(); for (int i = 0; i < index; i++) { iterator.next(); } return iterator.next(); }
private void checkProperty(PrismProperty<String> property) { for (PrismPropertyValue<String> value : property.getValues()) { if (!KNOWN_KEYS.contains(value.getValue())) { throw new IllegalArgumentException("Unknown diagnose/fix keyword: " + value.getValue() + ". Known keys are: " + KNOWN_KEYS); } } }
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); }
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 void formatPrismProperty(StringBuilder sb, String prefix, Item item) { sb.append(prefix); sb.append(" - "); sb.append(getItemLabel(item)); sb.append(": "); if (item.size() > 1) { for (PrismPropertyValue propertyValue : ((PrismProperty<?>) item).getValues()) { sb.append("\n"); sb.append(prefix).append(" - "); sb.append(ValueDisplayUtil.toStringValue(propertyValue)); } } else if (item.size() == 1) { sb.append(ValueDisplayUtil.toStringValue(((PrismProperty<?>) item).getAnyValue())); } sb.append("\n"); }
private SceneItemImpl createSceneItem(PrismProperty<?> property, boolean descriptive) { SceneItemImpl si = createSceneItemCommon(property); si.setNewValues(toSceneItemValues(property.getValues())); si.setDescriptive(descriptive); return si; }
protected void validateCredentialContainerValues(PrismContainerValue<R> cVal) throws PolicyViolationException, SchemaException, ObjectNotFoundException, ExpressionEvaluationException, CommunicationException, ConfigurationException, SecurityViolationException { PrismProperty<ProtectedStringType> credentialValueProperty = cVal.findProperty(getCredentialRelativeValuePath()); if (credentialValueProperty != null) { for (PrismPropertyValue<ProtectedStringType> credentialValuePropertyValue : credentialValueProperty.getValues()) { validateProtectedStringValue(credentialValuePropertyValue.getValue()); } } }
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); } }
@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 <T> List<PrismPropertyValue<T>> getNormalizedValue(PrismProperty<T> attr, RefinedObjectClassDefinition rObjClassDef) throws SchemaException { RefinedAttributeDefinition<T> refinedAttributeDefinition = rObjClassDef.findAttributeDefinition(attr.getElementName()); QName matchingRuleQName = refinedAttributeDefinition.getMatchingRuleQName(); MatchingRule<T> matchingRule = matchingRuleRegistry.getMatchingRule(matchingRuleQName, refinedAttributeDefinition.getTypeName()); List<PrismPropertyValue<T>> normalized = new ArrayList<>(); for (PrismPropertyValue<T> origPValue : attr.getValues()){ T normalizedValue = matchingRule.normalize(origPValue.getValue()); PrismPropertyValue<T> normalizedPValue = origPValue.clone(); normalizedPValue.setValue(normalizedValue); normalized.add(normalizedPValue); } return normalized; }
@Override public void setExtensionProperty(PrismProperty<?> property) throws SchemaException { processModificationBatched(setExtensionPropertyAndPrepareDelta(property.getElementName(), property.getDefinition(), PrismValueCollectionsUtil.cloneCollection(property.getValues()))); }
@Override public void addExtensionProperty(PrismProperty<?> property) throws SchemaException { processModificationBatched(addExtensionPropertyAndPrepareDelta(property.getElementName(), property.getDefinition(), PrismValueCollectionsUtil.cloneCollection(property.getValues()))); }
@Override public void deleteExtensionProperty(PrismProperty<?> property) throws SchemaException { processModificationBatched(deleteExtensionPropertyAndPrepareDelta(property.getElementName(), property.getDefinition(), PrismValueCollectionsUtil.cloneCollection(property.getValues()))); }
@Override public void setExtensionPropertyImmediate(PrismProperty<?> property, OperationResult parentResult) throws ObjectNotFoundException, SchemaException { try { processModificationNow(setExtensionPropertyAndPrepareDelta(property.getElementName(), property.getDefinition(), PrismValueCollectionsUtil.cloneCollection(property.getValues())), parentResult); } catch (ObjectAlreadyExistsException ex) { throw new SystemException(ex); } }
public static <T,X> PrismProperty<X> convertProperty(PrismProperty<T> srcProp, PrismPropertyDefinition<X> targetDef, PrismContext prismContext) throws SchemaException { if (targetDef.getTypeName().equals(srcProp.getDefinition().getTypeName())) { return (PrismProperty<X>) srcProp; } else { PrismProperty<X> targetProp = targetDef.instantiate(); Class<X> expectedJavaType = XsdTypeMapper.toJavaType(targetDef.getTypeName()); for (PrismPropertyValue<T> srcPVal: srcProp.getValues()) { X convertedRealValue = JavaTypeConverter.convert(expectedJavaType, srcPVal.getValue()); targetProp.add(prismContext.itemFactory().createPropertyValue(convertedRealValue)); } return targetProp; } }
@SuppressWarnings({ "unused", "unchecked" }) private SceneDeltaItemImpl createSceneDeltaItem(PropertyDelta<?> delta, SceneImpl owningScene, VisualizationContext context, Task task, OperationResult result) throws SchemaException { SceneDeltaItemImpl si = createSceneDeltaItemCommon(delta, owningScene); si.setOldValues(toSceneItemValues(delta.getEstimatedOldValues())); PrismProperty property = prismContext.itemFactory().createProperty(delta.getElementName()); if (delta.getEstimatedOldValues() != null) { property.addValues(CloneUtil.cloneCollectionMembers(delta.getEstimatedOldValues())); } try { delta.applyToMatchingPath(property, ParameterizedEquivalenceStrategy.DEFAULT_FOR_DELTA_APPLICATION); } catch (SchemaException e) { throw new SystemException("Couldn't visualize property delta: " + delta + ": " + e.getMessage(), e); } computeAddedDeletedUnchanged(si, delta.getEstimatedOldValues(), property.getValues()); si.setNewValues(toSceneItemValues(property.getValues())); return si; }
private <O extends ObjectType, T> void assertExtension(PrismObject<O> object, QName propName, T... expectedValues) { PrismContainer<Containerable> extensionContainer = object.findContainer(ObjectType.F_EXTENSION); assertNotNull("No extension container in "+object, extensionContainer); PrismProperty<T> extensionProperty = extensionContainer.findProperty(ItemName.fromQName(propName)); assertNotNull("No extension property "+propName+" in "+object, extensionProperty); PrismAsserts.assertPropertyValues("Values of extension property "+propName, extensionProperty.getValues(), expectedValues); }
@Override protected void checkAccountWill(PrismObject<ShadowType> shadow, OperationResult result, XMLGregorianCalendar startTs, XMLGregorianCalendar endTs) throws SchemaException, EncryptionException { super.checkAccountWill(shadow, result, startTs, endTs); CredentialsType credentials = shadow.asObjectable().getCredentials(); assertNotNull("No credentials in "+shadow, credentials); PasswordType password = credentials.getPassword(); assertNotNull("No password in "+shadow, password); PrismContainerValue<PasswordType> passwordContainerValue = password.asPrismContainerValue(); PrismProperty<ProtectedStringType> valueProperty = passwordContainerValue.findProperty(PasswordType.F_VALUE); assertTrue("Unexpected password value in "+shadow+": "+valueProperty, valueProperty.getValues().isEmpty()); assertTrue("No incompleteness in password value in "+shadow+": "+valueProperty, valueProperty.isIncomplete()); }