private <C extends Containerable, O extends ObjectType> Collection<PrismContainerValue<C>> determineContainerValuesFromCurrentObject( ItemPath path, PrismObject<O> currentObject) { PrismContainer<C> container = currentObject.findContainer(path); if (container == null) { return null; } return container.getValues(); }
private PrismContainer<?> getIcfConfigurationProperties(ResourceType resource) { if (resource == null) { return null; } PrismContainer<?> connectorConfiguration = resource.asPrismObject().findContainer(ResourceType.F_CONNECTOR_CONFIGURATION); if (connectorConfiguration == null) { return null; } return connectorConfiguration.findContainer(SchemaConstants.ICF_CONFIGURATION_PROPERTIES); }
public static PrismSchema parseReportConfigurationSchema(PrismObject<ReportType> report, PrismContext context) throws SchemaException { PrismContainer xmlSchema = report.findContainer(ReportType.F_CONFIGURATION_SCHEMA); Element xmlSchemaElement = ObjectTypeUtil.findXsdElement(xmlSchema); if (xmlSchemaElement == null) { //no schema definition available return null; } return PrismSchemaImpl.parse(xmlSchemaElement, true, "schema for " + report, context); }
private <F extends FocusType, T extends ObjectType> void applyAssignmentMetadataObject(LensContext<F> context, PrismObject<T> objectToAdd, XMLGregorianCalendar now, Task task, OperationResult result) throws SchemaException { PrismContainer<AssignmentType> assignmentContainer = objectToAdd.findContainer(FocusType.F_ASSIGNMENT); if (assignmentContainer != null) { for (PrismContainerValue<AssignmentType> assignmentContainerValue: assignmentContainer.getValues()) { applyAssignmentValueMetadataAdd(context, assignmentContainerValue, "ADD", now, task, result); } } }
protected void assertNumberOfAttributes(PrismObject<ShadowType> shadow, Integer expectedNumberOfAttributes) { PrismContainer<Containerable> attributesContainer = shadow.findContainer(ShadowType.F_ATTRIBUTES); assertNotNull("No attributes in repo shadow "+shadow, attributesContainer); List<Item<?,?>> attributes = attributesContainer.getValue().getItems(); assertFalse("Empty attributes in repo shadow "+shadow, attributes.isEmpty()); if (expectedNumberOfAttributes != null) { assertEquals("Unexpected number of attributes in repo shadow "+shadow, (int)expectedNumberOfAttributes, attributes.size()); } }
@Deprecated protected void assertPasswordMetadata(PrismObject<UserType> user, boolean create, XMLGregorianCalendar start, XMLGregorianCalendar end, String actorOid, String channel) { PrismContainer<MetadataType> metadataContainer = user.findContainer(PATH_CREDENTIALS_PASSWORD_METADATA); assertNotNull("No password metadata in "+user, metadataContainer); MetadataType metadataType = metadataContainer.getValue().asContainerable(); assertMetadata("password metadata in "+user, metadataType, create, false, start, end, actorOid, channel); }
public static String getSingleStringAttributeValue(PrismObject<ShadowType> shadow, QName attrName) { PrismContainer<?> attributesContainer = shadow.findContainer(ShadowType.F_ATTRIBUTES); if (attributesContainer == null) { return null; } PrismProperty<String> attribute = attributesContainer.findProperty(ItemName.fromQName(attrName)); if (attribute == null) { return null; } return attribute.getRealValue(); }
protected PrismContainer<R> getOldCredentialContainer() { PrismObject<UserType> objectOld = context.getFocusContext().getObjectOld(); if (objectOld == null) { return null; } return objectOld.findContainer(getCredentialsContainerPath()); }
private PrismValue fixEmptyContainerValue(PrismContainerValue pcv, ItemPath path, PrismObject objectOld) { if (pcv.getId() == null || CollectionUtils.isNotEmpty(pcv.getItems())) { return pcv; } PrismContainer oldContainer = objectOld.findContainer(path); if (oldContainer == null) { return pcv; } PrismContainerValue oldValue = oldContainer.getValue(pcv.getId()); return oldValue != null ? oldValue : pcv; }
protected void assertNumberOfAttributes(PrismObject<ShadowType> shadow, Integer expectedNumberOfAttributes) { PrismContainer<Containerable> attributesContainer = shadow.findContainer(ShadowType.F_ATTRIBUTES); assertNotNull("No attributes in repo shadow "+shadow, attributesContainer); List<Item<?,?>> attributes = attributesContainer.getValue().getItems(); assertFalse("Empty attributes in repo shadow "+shadow, attributes.isEmpty()); if (expectedNumberOfAttributes != null) { assertEquals("Unexpected number of attributes in repo shadow "+shadow, (int)expectedNumberOfAttributes, attributes.size()); } }
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); }
public void processEntitlementsAdd(ProvisioningContext ctx, PrismObject<ShadowType> shadow) throws SchemaException, ConfigurationException, ObjectNotFoundException, CommunicationException, ExpressionEvaluationException { PrismContainer<ShadowAssociationType> associationContainer = shadow.findContainer(ShadowType.F_ASSOCIATION); if (associationContainer == null || associationContainer.isEmpty()) { return; } Map<QName, PropertyModificationOperation> operationMap = new HashMap<>(); collectEntitlementToAttrsDelta(ctx, operationMap, associationContainer.getValues(), ModificationType.ADD); for (PropertyModificationOperation operation : operationMap.values()) { operation.getPropertyDelta().applyTo(shadow); } }
private static <O extends ObjectType> void mergeExtension(ItemDeltaItem<PrismContainerValue<AssignmentType>,PrismContainerDefinition<AssignmentType>> destIdi, PrismObject<O> srcObject) throws SchemaException { if (srcObject == null) { return; } PrismContainer<Containerable> srcExtension = srcObject.findContainer(ObjectType.F_EXTENSION); mergeExtensionContainers(destIdi.getItemNew(), srcExtension); mergeExtensionContainers(destIdi.getItemOld(), srcExtension); }
public static void setAttribute(PrismObject<ShadowType> account, QName attrName, QName typeName, PrismContext prismContext, String value) throws SchemaException { PrismContainer<Containerable> attributesContainer = account.findContainer(ShadowType.F_ATTRIBUTES); ResourceAttributeDefinition attrDef = ObjectFactory.createResourceAttributeDefinition(attrName, typeName, prismContext); ResourceAttribute attribute = attrDef.instantiate(); attribute.setRealValue(value); attributesContainer.add(attribute); }
protected void assertNoAttribute(PrismObject<ResourceType> resource, ShadowType shadow, QName attrQname) { PrismContainer<?> attributesContainer = shadow.asPrismObject().findContainer(ShadowType.F_ATTRIBUTES); if (attributesContainer == null || attributesContainer.isEmpty()) { return; } PrismProperty attribute = attributesContainer.findProperty(ItemName.fromQName(attrQname)); assertNull("Unexpected attribute "+attrQname+" in "+shadow+": "+attribute, attribute); }
private PrismContainer<AssignmentType> parseUserAssignmentContainer() throws SchemaException, IOException { PrismContext prismContext = getPrismContext(); PrismObject<UserType> user = prismContext.parseObject(USER_FILE); System.out.println("Parsed user:"); System.out.println(user.debugDump()); return user.findContainer(ItemPath.create(UserType.F_ASSIGNMENT, USER_ASSIGNMENT_1_ID, AssignmentType.F_EXTENSION)); }
protected String getIcfUid(PrismObject<ShadowType> shadow) { PrismContainer<Containerable> attributesContainer = shadow.findContainer(ShadowType.F_ATTRIBUTES); assertNotNull("Null attributes in "+shadow, attributesContainer); assertFalse("Empty attributes in "+shadow, attributesContainer.isEmpty()); PrismProperty<String> icfUidProp = attributesContainer.findProperty(new ItemName(SchemaConstants.NS_ICF_SCHEMA, "uid")); assertNotNull("No ICF name attribute in "+shadow, icfUidProp); return icfUidProp.getRealValue(); }
private ObjectDelta createDelta(ResourceType resourceType) throws ScriptExecutionException { PrismContainer<XmlSchemaType> schemaContainer = resourceType.asPrismObject().findContainer(ResourceType.F_SCHEMA); if (schemaContainer == null || schemaContainer.isEmpty()) { return null; } return prismContext.deltaFactory().object().createModificationDeleteContainer( ResourceType.class, resourceType.getOid(), ResourceType.F_SCHEMA, schemaContainer.getValue().clone()); } }
@Test public void testReplaceModelOperationContext() throws Exception { PrismObject prismObject = PrismTestUtil.parseObject(new File(TEST_DIR, "task-modelOperationContext-before.xml")); ObjectDelta delta = getPrismContext().deltaFactory().object().createEmptyModifyDelta(TaskType.class, prismObject.getOid() ); delta.addModificationReplaceContainer(TaskType.F_MODEL_OPERATION_CONTEXT); PrismObject changed = prismObject.clone(); ItemDeltaCollectionsUtil.applyTo(delta.getModifications(), changed); Collection<? extends ItemDelta> processedModifications = prismObject.diffModifications(changed, EquivalenceStrategy.LITERAL_IGNORE_METADATA); ItemDeltaCollectionsUtil.applyTo(processedModifications, prismObject); assertNull(prismObject.findContainer(TaskType.F_MODEL_OPERATION_CONTEXT)); }
private void checkLookupResult(PrismObject<LookupTableType> lookup, String[]... tuples) { IntegrationTestTools.display("Languages", lookup); assertEquals("Wrong lang lookup name", LOOKUP_LANGUAGES_NAME, lookup.asObjectable().getName().getOrig()); PrismContainer<LookupTableRowType> tableContainer = lookup.findContainer(LookupTableType.F_ROW); assertNotNull("Table container missing", tableContainer); assertEquals("Unexpected table container size", tuples.length, tableContainer.size()); for (String[] tuple : tuples) { assertLookupRow(tableContainer, tuple[0], tuple[1], tuple[2]); } assertSteadyResources(); }