public static ResourceAttributeContainer getAttributesContainer(PrismContainerValue<?> cval, QName containerName) { PrismContainer attributesContainer = cval.findContainer(containerName); if (attributesContainer == null) { return null; } if (attributesContainer instanceof ResourceAttributeContainer) { return (ResourceAttributeContainer)attributesContainer; } else { throw new SystemException("Expected that <"+containerName.getLocalPart()+"> will be ResourceAttributeContainer but it is "+attributesContainer.getClass()); } }
private <CC extends Containerable> PrismContainer<CC> findContainer(QName attrName) { return getPrismValue().findContainer(ItemName.fromQName(attrName)); }
public static <T extends PrismContainer<?>> T getContainer(PrismContainerValue parentValue, QName name) { Validate.notNull(parentValue, "Parent container value must not be null."); Validate.notNull(name, "QName must not be null."); try { PrismContainer container = parentValue.findContainer(name); if (container != null) { return (T) container; } else { return (T) parentValue.createDetachedSubItem(name, PrismContainerImpl.class, null, parentValue.isImmutable()); } } catch (SchemaException ex) { throw new SystemException(ex.getMessage(), ex); } }
private ConnectorSpec getConnectorSpec(PrismObject<ResourceType> resource, ConnectorInstanceSpecificationType additionalConnectorType) throws SchemaException { String connectorOid = additionalConnectorType.getConnectorRef().getOid(); if (StringUtils.isBlank(connectorOid)) { throw new SchemaException("No connector OID in additional connector in "+resource); } PrismContainer<ConnectorConfigurationType> connectorConfiguration = additionalConnectorType.asPrismContainerValue().findContainer(ConnectorInstanceSpecificationType.F_CONNECTOR_CONFIGURATION); String connectorName = additionalConnectorType.getName(); if (StringUtils.isBlank(connectorName)) { throw new SchemaException("No connector name in additional connector in "+resource); } return new ConnectorSpec(resource, connectorName, connectorOid, connectorConfiguration); }
public static boolean limitationsAllow(List<OtherPrivilegesLimitationType> limitations, QName itemName) { for (OtherPrivilegesLimitationType limitation : limitations) { @SuppressWarnings({ "unchecked", "raw" }) PrismContainer<WorkItemSelectorType> selector = limitation.asPrismContainerValue().findContainer(itemName); if (selector == null || selector.isEmpty() || !selector.getRealValue().isAll()) { return false; } } return true; }
.findContainer(SchemaConstants.CONNECTOR_SCHEMA_CONFIGURATION_PROPERTIES_ELEMENT_QNAME); if (configurationPropertiesContainer == null) { configurationPropertiesContainer = configuration.findContainer(new QName(connectorConfNs, SchemaConstants.CONNECTOR_SCHEMA_CONFIGURATION_PROPERTIES_ELEMENT_LOCAL_NAME)); PrismContainer connectorPoolContainer = configuration.findContainer(new QName( SchemaConstants.NS_ICF_CONFIGURATION, ConnectorFactoryConnIdImpl.CONNECTOR_SCHEMA_CONNECTOR_POOL_CONFIGURATION_XML_ELEMENT_NAME)); PrismContainer connectorTimeoutsContainer = configuration.findContainer(new QName( SchemaConstants.NS_ICF_CONFIGURATION, ConnectorFactoryConnIdImpl.CONNECTOR_SCHEMA_TIMEOUTS_XML_ELEMENT_NAME)); transformConnectorTimeoutsConfiguration(apiConfig, connectorTimeoutsContainer); PrismContainer resultsHandlerConfigurationContainer = configuration.findContainer(new QName( SchemaConstants.NS_ICF_CONFIGURATION, ConnectorFactoryConnIdImpl.CONNECTOR_SCHEMA_RESULTS_HANDLER_CONFIGURATION_ELEMENT_LOCAL_NAME));
public static void setEnableExperimentalCode(SystemConfigurationType s, Boolean enableExperimentalCode) { if (enableExperimentalCode == null) { if (s.getInternals() != null) { s.getInternals().setEnableExperimentalCode(null); s.asPrismContainerValue().findContainer(SystemConfigurationType.F_INTERNALS).normalize(); } } else { if (s.getInternals() == null) { s.setInternals(new InternalsConfigurationType()); // hopefully prismContext etc is correctly set } s.getInternals().setEnableExperimentalCode(enableExperimentalCode); } }
private void transplantIdentifiers(PrismContainerValue<ShadowAssociationType> association, PrismObject<ShadowType> repoShadow) throws SchemaException { PrismContainer<Containerable> identifiersContainer = association .findContainer(ShadowAssociationType.F_IDENTIFIERS); if (identifiersContainer == null) { ResourceAttributeContainer origContainer = ShadowUtil.getAttributesContainer(repoShadow); identifiersContainer = ObjectFactory.createResourceAttributeContainer(ShadowAssociationType.F_IDENTIFIERS, origContainer.getDefinition(), prismContext); association.add(identifiersContainer); } Collection<ResourceAttribute<?>> identifiers = ShadowUtil.getPrimaryIdentifiers(repoShadow); for (ResourceAttribute<?> identifier : identifiers) { identifiersContainer.add(identifier.clone()); } Collection<ResourceAttribute<?>> secondaryIdentifiers = ShadowUtil .getSecondaryIdentifiers(repoShadow); for (ResourceAttribute<?> identifier : secondaryIdentifiers) { identifiersContainer.add(identifier.clone()); } }
private void preprocessEntitlement(ProvisioningContext ctx, PrismContainerValue<ShadowAssociationType> association, String desc, OperationResult result) throws SchemaException, ObjectNotFoundException, ConfigurationException, CommunicationException, ExpressionEvaluationException { PrismContainer<Containerable> identifiersContainer = association .findContainer(ShadowAssociationType.F_IDENTIFIERS); if (identifiersContainer != null && !identifiersContainer.isEmpty()) { // We already have identifiers here return; } ShadowAssociationType associationType = association.asContainerable(); if (associationType.getShadowRef() == null || StringUtils.isEmpty(associationType.getShadowRef().getOid())) { throw new SchemaException( "No identifiers and no OID specified in entitlements association " + association); } PrismObject<ShadowType> repoShadow; try { repoShadow = repositoryService.getObject(ShadowType.class, associationType.getShadowRef().getOid(), null, result); } catch (ObjectNotFoundException e) { throw new ObjectNotFoundException(e.getMessage() + " while resolving entitlement association OID in " + association + " in " + desc, e); } shadowCaretaker.applyAttributesDefinition(ctx, repoShadow); transplantIdentifiers(association, repoShadow); }
private void checkContainerValuesSize(QName parentName, PrismContainerValue newValue, PrismContainerValue oldValue) { LOGGER.info("Checking: " + parentName); AssertJUnit.assertEquals("Count doesn't match for '" + parentName + "' id="+newValue.getId(), size(oldValue), size(newValue)); List<QName> checked = new ArrayList<>(); for (Item item : (List<Item>) newValue.getItems()) { if (!(item instanceof PrismContainer)) { continue; } PrismContainer newContainer = (PrismContainer) item; PrismContainer oldContainer = oldValue.findContainer(newContainer.getElementName()); AssertJUnit.assertNotNull("Container '" + newContainer.getElementName() + "' doesn't exist.", oldContainer); checkContainersSize(newContainer, oldContainer); checked.add(oldContainer.getElementName()); } for (Item item : (List<Item>) oldValue.getItems()) { if (!(item instanceof PrismContainer) || checked.contains(item.getElementName())) { continue; } PrismContainer oldContainer = (PrismContainer) item; PrismContainer newContainer = newValue.findContainer(oldContainer.getElementName()); checkContainersSize(newContainer, oldContainer); } }
private void checkSchema(AssignmentPathSegmentImpl segment, EvaluationContext ctx) throws SchemaException { AssignmentType assignmentType = getAssignmentType(segment, ctx); PrismContainerValue<AssignmentType> assignmentContainerValue = assignmentType.asPrismContainerValue(); PrismContainerable<AssignmentType> assignmentContainer = assignmentContainerValue.getParent(); if (assignmentContainer == null) { throw new SchemaException("The assignment "+assignmentType+" does not have a parent in "+segment.sourceDescription); } if (assignmentContainer.getDefinition() == null) { throw new SchemaException("The assignment "+assignmentType+" does not have definition in "+segment.sourceDescription); } PrismContainer<Containerable> extensionContainer = assignmentContainerValue.findContainer(AssignmentType.F_EXTENSION); if (extensionContainer != null) { if (extensionContainer.getDefinition() == null) { throw new SchemaException("Extension does not have a definition in assignment "+assignmentType+" in "+segment.sourceDescription); } for (Item<?,?> item: extensionContainer.getValue().getItems()) { if (item == null) { throw new SchemaException("Null item in extension in assignment "+assignmentType+" in "+segment.sourceDescription); } if (item.getDefinition() == null) { throw new SchemaException("Item "+item+" has no definition in extension in assignment "+assignmentType+" in "+segment.sourceDescription); } } } }
PrismContainer<ConstructionType> accConstruction = value5.findContainer(AssignmentType.F_CONSTRUCTION); assertNotNull(accConstruction); assertEquals(1, accConstruction.getValues().size());
currentPasswordType.asPrismContainerValue().findContainer(PasswordType.F_HISTORY_ENTRY), false); int i = 1; for (PasswordHistoryEntryType historyEntry: sortedHistoryList) {
PrismContainer<?> nextContainer = containerValue.findContainer(nextName); if (nextContainer != null) { for (PrismContainerValue<?> pcv : nextContainer.getValues()) {
PrismContainerValue<AssignmentType> firstAssignmentValue = assignmentContainer.getValues().iterator().next(); PrismContainer<Containerable> assignmentExtensionContainer = firstAssignmentValue.findContainer(AssignmentType.F_EXTENSION); PrismAsserts.assertDefinition(assignmentExtensionContainer.getDefinition(), AssignmentType.F_EXTENSION, ExtensionType.COMPLEX_TYPE, 0, 1); List<Item<?,?>> assignmentExtensionItems = assignmentExtensionContainer.getValue().getItems(); assertEquals("Wrong value of "+EXTENSION_INT_TYPE_ELEMENT+" in assignment extension", 42, firstValueOfFirstAssignmentExtensionItem.getValue()); PrismContainer<Containerable> constructionContainer = firstAssignmentValue.findContainer(AssignmentType.F_CONSTRUCTION); PrismAsserts.assertDefinition(constructionContainer.getDefinition(), AssignmentType.F_CONSTRUCTION, ConstructionType.COMPLEX_TYPE, 0, 1); List<Item<?,?>> constructionItems = constructionContainer.getValue().getItems();