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()); } }
private <F extends FocusType> void createDeleteHistoryDeltasIfNeeded(int historyLength, int addedValues, PrismContainer<R> currentCredentialContainer) throws SchemaException { PrismContainer<PasswordHistoryEntryType> historyEntries = currentCredentialContainer.findOrCreateContainer(PasswordType.F_HISTORY_ENTRY); List<PrismContainerValue<PasswordHistoryEntryType>> historyEntryValues = historyEntries.getValues(); if (historyEntries.size() == 0) { return; } // We need to delete one more entry than intuitively expected - because we are computing from the history entries // in the old object. In the new object there will be one new history entry for the changed password. int numberOfHistoryEntriesToDelete = historyEntries.size() - historyLength + addedValues + 1; Iterator<PrismContainerValue<PasswordHistoryEntryType>> historyEntryIterator = historyEntryValues.iterator(); int i = 0; while (historyEntryIterator.hasNext() && i < numberOfHistoryEntriesToDelete) { ContainerDelta<PasswordHistoryEntryType> deleteHistoryDelta = prismContext.deltaFactory().container() .createModificationDelete(SchemaConstants.PATH_CREDENTIALS_PASSWORD_HISTORY_ENTRY, UserType.class, historyEntryIterator.next().clone()); context.getFocusContext().swallowToSecondaryDelta(deleteHistoryDelta); i++; } }
.findOrCreateContainer(LensContextType.F_FOCUS_CONTEXT); focusContext.addToPrismContainer(lensFocusContextTypeContainer, reduced); .findOrCreateContainer(LensContextType.F_PROJECTION_CONTEXT); for (LensProjectionContext lensProjectionContext : projectionContexts) {
@Test public void test990AddResourceWithEmptyConnectorConfiguration() throws Exception { OperationResult result = new OperationResult("test990AddResourceWithEmptyConnectorConfiguration"); PrismObject<ResourceType> prismResource = getPrismContext().getSchemaRegistry().findObjectDefinitionByCompileTimeClass(ResourceType.class).instantiate(); PolyStringType name = new PolyStringType(); name.setOrig("Test Resource"); name.setNorm("test resource"); prismResource.asObjectable().setName(name); prismResource .findOrCreateContainer(ResourceType.F_CONNECTOR_CONFIGURATION) .findOrCreateContainer(SchemaConstants.ICF_CONFIGURATION_PROPERTIES) .createNewValue(); System.out.println("Original data before saving: " + prismResource.debugDump()); String oid = repositoryService.addObject(prismResource, null, result); PrismObject<ResourceType> fetchedResource = repositoryService.getObject(ResourceType.class, oid, null, result); System.out.println("Original data after saving: " + prismResource.debugDump()); System.out.println("Fetched data: " + fetchedResource.debugDump()); AssertJUnit.assertEquals(prismResource, fetchedResource); }