private static void mergeExtensionContainers(Item<PrismContainerValue<AssignmentType>,PrismContainerDefinition<AssignmentType>> dstItem, PrismContainer<Containerable> srcExtension) throws SchemaException { if (dstItem == null) { return; } PrismContainer<AssignmentType> dstContainer = (PrismContainer<AssignmentType>) dstItem; if (srcExtension != null && !srcExtension.isEmpty()) { PrismContainer<?> dstExtensionContainer = dstContainer.findOrCreateContainer(AssignmentType.F_EXTENSION); PrismContainerValue<?> dstExtensionContainerValue = dstExtensionContainer.getValues().isEmpty() ? dstExtensionContainer.createNewValue() : dstExtensionContainer.getValue(); ObjectTypeUtil.mergeExtension(dstExtensionContainerValue, srcExtension.getValue()); } }
@Override public <C extends Containerable> void setExtensionContainer(PrismContainer<C> container) throws SchemaException { processModificationBatched(setExtensionContainerAndPrepareDelta(container.getElementName(), container.getDefinition(), PrismValueCollectionsUtil.cloneCollection(container.getValues()))); }
public static <T> Collection<T> getAttributeValues(PrismObject<? extends ShadowType> shadow, QName name) { if (shadow == null) { throw new IllegalArgumentException("No shadow"); } PrismContainer<?> attrCont = shadow.findContainer(ShadowType.F_ATTRIBUTES); if (attrCont == null) { return null; } PrismProperty<T> attrProp = attrCont.findProperty(ItemName.fromQName(name)); if (attrProp == null) { return null; } return attrProp.getRealValues(); }
private <O extends ObjectType> AccessDecision determineObjectDecision(PrismContainer<O> object, ItemDecisionFunction itemDecitionFunction) { AccessDecision containerDecision = determineContainerDecision(object.getValue(), itemDecitionFunction, false, "object"); if (containerDecision == null && object.isEmpty()) { // There are no items in the object. Therefore there is no item that is allowed. Therefore decision is DEFAULT. // But also there is no item that is denied or not allowed. // This is a corner case. But this approach is often used by GUI to determine if // a specific class of object is allowed, e.g. if it is allowed to create (some) roles. This is used to // determine whether to display a particular menu item. // Therefore we should allow such cases. return AccessDecision.ALLOW; } return containerDecision; }
PrismContainerDefinition confContDef = configurationContainer.getDefinition(); assertNotNull("No configuration container definition", confContDef); PrismContainer confingurationPropertiesContainer = configurationContainer .findContainer(SchemaConstants.CONNECTOR_SCHEMA_CONFIGURATION_PROPERTIES_ELEMENT_QNAME); assertNotNull("No configuration properties container", confingurationPropertiesContainer); PrismContainerDefinition confPropsDef = confingurationPropertiesContainer.getDefinition(); assertNotNull("No configuration properties container definition", confPropsDef); List<PrismProperty<?>> configurationProperties = confingurationPropertiesContainer.getValue().getItems(); assertFalse("No configuration properties", configurationProperties.isEmpty()); for (PrismProperty<?> confProp : configurationProperties) {
public static <T extends Containerable> PrismContainerValue<T> getFieldContainerValue(PrismContainerValue<?> parent, QName fieldName) { Validate.notNull(parent, "Container value must not be null."); Validate.notNull(fieldName, "Field QName must not be null."); PrismContainer<T> container = parent.findItem(ItemName.fromQName(fieldName), PrismContainer.class); return container != null ? container.getValue() : null; }
PrismContainerValue<?> extensionValue = extension.getValue(); assertTrue("Extension parent", extensionValue.getParent() == extension); assertNull("Extension ID", extensionValue.getId()); PrismProperty<String> stringType = extension.findProperty(EXTENSION_STRING_TYPE_ELEMENT); PrismAsserts.assertPropertyValue(stringType, "BARbar", "FOObar"); PrismPropertyDefinition stringTypePropertyDef = stringType.getDefinition(); PrismProperty<String> singleStringType = extension.findProperty(EXTENSION_SINGLE_STRING_TYPE_ELEMENT); PrismAsserts.assertPropertyValue(singleStringType, "foobar"); PrismPropertyDefinition singleStringTypePropertyDef = singleStringType.getDefinition(); PrismProperty<Double> doubleType = extension.findProperty(EXTENSION_DOUBLE_TYPE_ELEMENT); PrismAsserts.assertPropertyValue(doubleType, 3.1415926535); PrismPropertyDefinition doubleTypePropertyDef = doubleType.getDefinition(); PrismProperty<Integer> intType = extension.findProperty(EXTENSION_INT_TYPE_ELEMENT); PrismAsserts.assertPropertyValue(intType, 42); PrismPropertyDefinition intTypePropertyDef = intType.getDefinition(); PrismProperty<BigInteger> integerType = extension.findProperty(EXTENSION_INTEGER_TYPE_ELEMENT); PrismAsserts.assertPropertyValue(integerType, new BigInteger("19134702400093278081449423917")); PrismPropertyDefinition integerTypePropertyDef = integerType.getDefinition(); PrismProperty<Long> longType = extension.findProperty(EXTENSION_LONG_TYPE_ELEMENT); PrismAsserts.assertPropertyValue(longType, 299792458L); PrismPropertyDefinition longTypePropertyDef = longType.getDefinition(); PrismProperty<XMLGregorianCalendar> dateType = extension.findProperty(EXTENSION_DATE_TYPE_ELEMENT);
private boolean containsItem(PrismContainer container, ItemPath itemPath) { if (container.size() == 0) { return false; // there is a container, but no values } if (itemPath.isEmpty()) { return true; } for (Object o : container.getValues()) { if (containsItem((PrismContainerValue) o, itemPath)) { return true; } } return false; }
protected void assertNoAttribute(PrismObject<ResourceType> resource, ShadowType shadow, ItemName attrQname) { PrismContainer<?> attributesContainer = shadow.asPrismObject().findContainer(ShadowType.F_ATTRIBUTES); if (attributesContainer == null || attributesContainer.isEmpty()) { return; } PrismProperty attribute = attributesContainer.findProperty(attrQname); assertNull("Unexpected attribute "+attrQname+" in "+shadow+": "+attribute, attribute); }
PrismContainer<Containerable> configurationContainer = resource.findContainer(ResourceType.F_CONNECTOR_CONFIGURATION); assertNotNull("No configuration container in "+resource+" from "+source, configurationContainer); PrismContainer<Containerable> configPropsContainer = configurationContainer.findContainer(SchemaTestConstants.ICFC_CONFIGURATION_PROPERTIES); assertNotNull("No configuration properties container in "+resource+" from "+source, configPropsContainer); List<? extends Item<?,?>> configProps = configPropsContainer.getValue().getItems(); assertEquals("Wrong number of config properties in "+resource+" from "+source, numConfigProps, configProps.size()); PrismProperty<Object> credentialsProp = configPropsContainer.findProperty(new ItemName(connectorNamespace,credentialsPropertyName)); if (credentialsProp == null) { display("Configuration with the heisenbug", configurationContainer.debugDump());
public static AssignmentType getAssignmentToBeModified(PrismContainer<AssignmentType> assignmentsOld, Long id) { if (id == null && assignmentsOld.size() == 1) { return assignmentsOld.getValue().asContainerable(); } PrismContainerValue<AssignmentType> value = assignmentsOld.getValue(id); if (value == null) { throw new IllegalStateException("No assignment value with id " + id + " in user old"); } return value.asContainerable(); }
private List<PrismContainerValue<T>> getValues() { return container.getValues(); }
private List<PrismContainer<?>> listAllPrismContainers(Visitable object) { List<PrismContainer<?>> values = new ArrayList<>(); object.accept(visitable -> { if (!(visitable instanceof PrismContainer)) { return; } if (visitable instanceof PrismObject) { return; } PrismContainer container = (PrismContainer) visitable; PrismContainerDefinition def = container.getDefinition(); if (def.isSingleValue()) { return; } values.add((PrismContainer) visitable); }); return values; }
public <I extends Item> void addExtensionItem(I item) throws SchemaException { PrismContainer<?> extension = getExtension(); if (extension == null) { extension = createExtension(); } extension.add(item); }
private void assertConfigurationPropertyDefinition(PrismContainer container, String propertyLocalName, QName expectedType, int expectedMinOccurs, int expectedMaxOccurs, String expectedDisplayName, String expectedHelp) { QName propName = new QName(container.getDefinition().getTypeName().getNamespaceURI(),propertyLocalName); PrismProperty prop = container.findProperty(ItemName.fromQName(propName)); assertNotNull("No property "+propName, prop); PrismPropertyDefinition propDef = prop.getDefinition(); assertNotNull("No definition for property "+prop, propDef); assertConfigurationPropertyDefinition(propDef, expectedType, expectedMinOccurs, expectedMaxOccurs, expectedDisplayName, expectedHelp); }
public void setExtensionRealValues(PrismContainerValue<?> containerValue, Map<String, Object> map) throws SchemaException { PrismContainer<Containerable> ext = containerValue.findOrCreateContainer(ObjectType.F_EXTENSION); Map<QName, Object> qnameKeyedMap = new HashMap<>(); map.forEach((uri, value) -> qnameKeyedMap.put(QNameUtil.uriToQName(uri, true), value)); List<Item<?, ?>> items = ObjectTypeUtil.mapToExtensionItems(qnameKeyedMap, ext.getDefinition(), prismContext); for (Item<?, ?> item : items) { ext.getValue().addReplaceExisting(item); } }
public <T> PrismObject<ShadowType> collectEntitlementsAsObjectOperationInShadowAdd(ProvisioningContext ctx, Map<ResourceObjectDiscriminator, ResourceObjectOperations> roMap, PrismObject<ShadowType> shadow, OperationResult result) throws SchemaException, ObjectNotFoundException, CommunicationException, SecurityViolationException, ConfigurationException, ExpressionEvaluationException { PrismContainer<ShadowAssociationType> associationContainer = shadow.findContainer(ShadowType.F_ASSOCIATION); if (associationContainer == null || associationContainer.isEmpty()) { return shadow; } return collectEntitlementsAsObjectOperation(ctx, roMap, associationContainer.getValues(), null, shadow, ModificationType.ADD, result); }
@Test public void test004Configuration() throws Exception { final String TEST_NAME = "test004Configuration"; TestUtil.displayTestTitle(TEST_NAME); // GIVEN Task task = createTask(TEST_NAME); OperationResult result = task.getResult(); // WHEN resource = provisioningService.getObject(ResourceType.class, getResourceOid(), null, task, result); resourceType = resource.asObjectable(); PrismContainer<Containerable> configurationContainer = resource.findContainer(ResourceType.F_CONNECTOR_CONFIGURATION); assertNotNull("No configuration container", configurationContainer); PrismContainerDefinition confContDef = configurationContainer.getDefinition(); assertNotNull("No configuration container definition", confContDef); PrismContainer confingurationPropertiesContainer = configurationContainer.findContainer(SchemaConstants.CONNECTOR_SCHEMA_CONFIGURATION_PROPERTIES_ELEMENT_QNAME); assertNotNull("No configuration properties container", confingurationPropertiesContainer); PrismContainerDefinition confPropDef = confingurationPropertiesContainer.getDefinition(); assertNotNull("No configuration properties container definition", confPropDef); }
private <C extends Containerable> void parseContainerValueToContainer(PrismContainer<C> container, XNodeImpl node, @NotNull ParsingContext pc) throws SchemaException { container.add(parseContainerValue(node, container.getDefinition(), pc)); if (node instanceof MapXNodeImpl && container instanceof PrismObject) { MapXNodeImpl map = (MapXNodeImpl) node; PrismObject object = (PrismObject) container; object.setOid(getOid(map)); object.setVersion(getVersion(map)); } }