private List<PrismContainer> getChildrenContainers(PrismObject parent) { List<PrismContainer> containers = new ArrayList<>(); if (ObjectType.class.isAssignableFrom(parent.getCompileTimeClass())) { containers.add(parent.findContainer(ObjectType.F_TRIGGER)); } if (LookupTableType.class.isAssignableFrom(parent.getCompileTimeClass())) { containers.add(parent.findContainer(LookupTableType.F_ROW)); } if (FocusType.class.isAssignableFrom(parent.getCompileTimeClass())) { containers.add(parent.findContainer(FocusType.F_ASSIGNMENT)); } if (AbstractRoleType.class.isAssignableFrom(parent.getCompileTimeClass())) { containers.add(parent.findContainer(AbstractRoleType.F_INDUCEMENT)); containers.add(parent.findContainer(AbstractRoleType.F_EXCLUSION)); containers.add(parent.findContainer(AbstractRoleType.F_AUTHORIZATION)); PrismContainer policyConstraints = parent.findContainer(AbstractRoleType.F_POLICY_CONSTRAINTS); if (policyConstraints != null) { containers.add(policyConstraints.findContainer(PolicyConstraintsType.F_MAX_ASSIGNEES)); containers.add(policyConstraints.findContainer(PolicyConstraintsType.F_MIN_ASSIGNEES)); } } return containers; }
private void cleanupEmptyContainers(PrismContainer container) { List<PrismContainerValue> values = container.getValues(); List<PrismContainerValue> valuesToBeRemoved = new ArrayList<PrismContainerValue>(); for (PrismContainerValue value : values) { List<? extends Item> items = value.getItems(); if (items != null) { Iterator<? extends Item> iterator = items.iterator(); while (iterator.hasNext()) { Item item = iterator.next(); if (item instanceof PrismContainer) { cleanupEmptyContainers((PrismContainer) item); if (item.isEmpty()) { iterator.remove(); } } } } if (items == null || value.isEmpty()) { valuesToBeRemoved.add(value); } } container.removeAll(valuesToBeRemoved); }
private void transformConnectorTimeoutsConfiguration( APIConfiguration apiConfig, PrismContainer<?> connectorTimeoutsContainer) throws SchemaException { if (connectorTimeoutsContainer == null || connectorTimeoutsContainer.getValue() == null) { return; } for (PrismProperty prismProperty : connectorTimeoutsContainer.getValue().getProperties()) { QName propertQName = prismProperty.getElementName(); if (ConnectorFactoryIcfImpl.NS_ICF_CONFIGURATION.equals(propertQName.getNamespaceURI())) { String opName = propertQName.getLocalPart(); Class<? extends APIOperation> apiOpClass = ConnectorFactoryIcfImpl.resolveApiOpClass(opName); if (apiOpClass != null) { apiConfig.setTimeout(apiOpClass, parseInt(prismProperty)); } else { throw new SchemaException( "Unknown operation name " + opName + " in " + ConnectorFactoryIcfImpl.CONNECTOR_SCHEMA_TIMEOUTS_XML_ELEMENT_NAME); } } } }
private CallableResult<List<AssignmentItemDto>> loadAssignments() throws Exception { LOGGER.debug("Loading assignments."); CallableResult callableResult = new CallableResult(); List<AssignmentItemDto> list = new ArrayList<AssignmentItemDto>(); callableResult.setValue(list); PrismObject<UserType> user = principalModel.getObject(); if (user == null || user.findContainer(UserType.F_ASSIGNMENT) == null) { return callableResult; } Task task = createSimpleTask(OPERATION_LOAD_ASSIGNMENTS); OperationResult result = task.getResult(); callableResult.setResult(result); PrismContainer assignments = user.findContainer(UserType.F_ASSIGNMENT); List<PrismContainerValue> values = assignments.getValues(); for (PrismContainerValue assignment : values) { AssignmentItemDto item = createAssignmentItem(user, assignment, task, result); if (item != null) { list.add(item); } } result.recordSuccessIfUnknown(); result.recomputeStatus(); Collections.sort(list); LOGGER.debug("Finished assignments loading."); return callableResult; }
private void transformResultsHandlerConfiguration( ResultsHandlerConfiguration resultsHandlerConfiguration, PrismContainer<?> resultsHandlerConfigurationContainer) throws SchemaException { if (resultsHandlerConfigurationContainer == null || resultsHandlerConfigurationContainer.getValue() == null) { return; } for (PrismProperty prismProperty : resultsHandlerConfigurationContainer.getValue().getProperties()) { QName propertyQName = prismProperty.getElementName(); if (propertyQName.getNamespaceURI().equals(ConnectorFactoryIcfImpl.NS_ICF_CONFIGURATION)) { String subelementName = propertyQName.getLocalPart(); if (ConnectorFactoryIcfImpl .CONNECTOR_SCHEMA_RESULTS_HANDLER_CONFIGURATION_ENABLE_NORMALIZING_RESULTS_HANDLER .equals(subelementName)) { resultsHandlerConfiguration.setEnableNormalizingResultsHandler( parseBoolean(prismProperty)); } else if (ConnectorFactoryIcfImpl .CONNECTOR_SCHEMA_RESULTS_HANDLER_CONFIGURATION_ENABLE_FILTERED_RESULTS_HANDLER.equals( subelementName)) { resultsHandlerConfiguration.setEnableFilteredResultsHandler(parseBoolean(prismProperty)); } else if (ConnectorFactoryIcfImpl .CONNECTOR_SCHEMA_RESULTS_HANDLER_CONFIGURATION_FILTERED_RESULTS_HANDLER_IN_VALIDATION_MODE .equals(subelementName)) { resultsHandlerConfiguration.setFilteredResultsHandlerInValidationMode( parseBoolean(prismProperty)); } else if (ConnectorFactoryIcfImpl .CONNECTOR_SCHEMA_RESULTS_HANDLER_CONFIGURATION_ENABLE_CASE_INSENSITIVE_HANDLER.equals( subelementName)) { resultsHandlerConfiguration.setEnableCaseInsensitiveFilter(parseBoolean(prismProperty)); } else if (ConnectorFactoryIcfImpl .CONNECTOR_SCHEMA_RESULTS_HANDLER_CONFIGURATION_ENABLE_ATTRIBUTES_TO_GET_SEARCH_RESULTS_HANDLER .equals(subelementName)) { resultsHandlerConfiguration.setEnableAttributesToGetSearchResultsHandler( parseBoolean(prismProperty)); } else { throw new SchemaException( "Unexpected element " + propertyQName + " in " + ConnectorFactoryIcfImpl .CONNECTOR_SCHEMA_RESULTS_HANDLER_CONFIGURATION_ELEMENT_LOCAL_NAME); } } else { throw new SchemaException( "Unexpected element " + propertyQName + " in " + ConnectorFactoryIcfImpl .CONNECTOR_SCHEMA_RESULTS_HANDLER_CONFIGURATION_ELEMENT_LOCAL_NAME); } } }
public static <T> T deserializeValue( String value, Class clazz, QName itemName, ItemDefinition itemDef, PrismContext prismContext, String language) throws SchemaException { // System.out.println("item value deserialization"); XNode xnode = prismContext.getParserDom().parse(value); // System.out.println("xnode: " + xnode.debugDump()); XNode xmap = null; if (xnode instanceof RootXNode) { xmap = ((RootXNode) xnode).getSubnode(); } // System.out.println("xmap: " + xmap); // else if (xnode instanceof MapXNode){ // xmap = (MapXNode) xnode; // } else if (xnode instanceof PrimitiveXNode){ // xmap = new MapXNode(); // xmap.put(itemName, xnode); // } Item item = prismContext.getXnodeProcessor().parseItem(xmap, itemName, itemDef); // System.out.println("item: " + item.debugDump()); if (item instanceof PrismProperty) { PrismProperty prop = (PrismProperty) item; if (prop.isSingleValue()) { return (T) prop.getRealValue(); } return (T) prop.getRealValues(); } else if (item instanceof PrismContainer) { PrismContainer cont = (PrismContainer) item; return (T) cont.getValue().asContainerable(); } else if (item instanceof PrismReference) { PrismReference ref = (PrismReference) item; return (T) ref.getValue(); } if (item != null) { return (T) item.getValue(0); } // if (prismContext.getBeanConverter().canConvert(clazz)){ // prismContext.getBeanConverter().unmarshall(xmap, clazz); // } else{ // prismContext.getXnodeProcessor().parseContainer(xnode, clazz); // } throw new UnsupportedOperationException("need to be implemented"); }
private AssignmentItemDto createAssignmentItem( PrismObject<UserType> user, PrismContainerValue assignment, Task task, OperationResult result) { PrismReference targetRef = assignment.findReference(AssignmentType.F_TARGET_REF); if (targetRef == null || targetRef.isEmpty()) { // account construction PrismContainer construction = assignment.findContainer(AssignmentType.F_CONSTRUCTION); String name = null; String description = null; if (construction.getValue().asContainerable() != null && !construction.isEmpty()) { ConstructionType constr = (ConstructionType) construction.getValue().asContainerable(); description = (String) construction.getPropertyRealValue(ConstructionType.F_DESCRIPTION, String.class); if (constr.getResourceRef() != null) { ObjectReferenceType resourceRef = constr.getResourceRef(); PrismObject resource = WebModelUtils.loadObject( ResourceType.class, resourceRef.getOid(), this, task, result); name = WebMiscUtil.getName(resource); } } return new AssignmentItemDto( AssignmentEditorDtoType.ACCOUNT_CONSTRUCTION, name, description, null); } PrismReferenceValue refValue = targetRef.getValue(); PrismObject value = refValue.getObject(); if (value == null) { // resolve reference value = WebModelUtils.loadObject(ObjectType.class, refValue.getOid(), this, task, result); } if (value == null) { // we couldn't resolve assignment details return new AssignmentItemDto(null, null, null, null); } String name = WebMiscUtil.getName(value); AssignmentEditorDtoType type = AssignmentEditorDtoType.getType(value.getCompileTimeClass()); String relation = refValue.getRelation() != null ? refValue.getRelation().getLocalPart() : null; String description = null; if (RoleType.class.isAssignableFrom(value.getCompileTimeClass())) { description = (String) value.getPropertyRealValue(RoleType.F_DESCRIPTION, String.class); } return new AssignmentItemDto(type, name, description, relation); }
@Test public void testParseModelContextPrism() throws Exception { System.out.println("===[ testParseModelContextPrism ]==="); // GIVEN PrismContext prismContext = PrismTestUtil.getPrismContext(); // WHEN PrismContainer<LensContextType> lensContextType = prismContext.parseContainer( MODEL_CONTEXT_FILE, LensContextType.class, PrismContext.LANG_XML); // THEN System.out.println("Parsed LensContextType: " + lensContextType.getValue().asContainerable()); }
private void transformConnectorPoolConfiguration( ObjectPoolConfiguration connectorPoolConfiguration, PrismContainer<?> connectorPoolContainer) throws SchemaException { if (connectorPoolContainer == null || connectorPoolContainer.getValue() == null) { return; } for (PrismProperty prismProperty : connectorPoolContainer.getValue().getProperties()) { QName propertyQName = prismProperty.getElementName(); if (propertyQName.getNamespaceURI().equals(ConnectorFactoryIcfImpl.NS_ICF_CONFIGURATION)) { String subelementName = propertyQName.getLocalPart(); if (ConnectorFactoryIcfImpl .CONNECTOR_SCHEMA_CONNECTOR_POOL_CONFIGURATION_MIN_EVICTABLE_IDLE_TIME_MILLIS.equals( subelementName)) { connectorPoolConfiguration.setMinEvictableIdleTimeMillis(parseLong(prismProperty)); } else if (ConnectorFactoryIcfImpl.CONNECTOR_SCHEMA_CONNECTOR_POOL_CONFIGURATION_MIN_IDLE .equals(subelementName)) { connectorPoolConfiguration.setMinIdle(parseInt(prismProperty)); } else if (ConnectorFactoryIcfImpl.CONNECTOR_SCHEMA_CONNECTOR_POOL_CONFIGURATION_MAX_IDLE .equals(subelementName)) { connectorPoolConfiguration.setMaxIdle(parseInt(prismProperty)); } else if (ConnectorFactoryIcfImpl.CONNECTOR_SCHEMA_CONNECTOR_POOL_CONFIGURATION_MAX_OBJECTS .equals(subelementName)) { connectorPoolConfiguration.setMaxObjects(parseInt(prismProperty)); } else if (ConnectorFactoryIcfImpl.CONNECTOR_SCHEMA_CONNECTOR_POOL_CONFIGURATION_MAX_WAIT .equals(subelementName)) { connectorPoolConfiguration.setMaxWait(parseLong(prismProperty)); } else { throw new SchemaException( "Unexpected element " + propertyQName + " in " + ConnectorFactoryIcfImpl .CONNECTOR_SCHEMA_CONNECTOR_POOL_CONFIGURATION_XML_ELEMENT_NAME); } } else { throw new SchemaException( "Unexpected element " + propertyQName + " in " + ConnectorFactoryIcfImpl .CONNECTOR_SCHEMA_CONNECTOR_POOL_CONFIGURATION_XML_ELEMENT_NAME); } } }
private void assertTask(PrismObject<TaskType> task) { task.checkConsistence(); assertEquals("Wrong oid", "44444444-4444-4444-4444-000000001111", task.getOid()); PrismObjectDefinition<TaskType> usedDefinition = task.getDefinition(); assertNotNull("No task definition", usedDefinition); PrismAsserts.assertObjectDefinition( usedDefinition, new QName(SchemaConstantsGenerated.NS_COMMON, "task"), TaskType.COMPLEX_TYPE, TaskType.class); assertEquals("Wrong class in task", TaskType.class, task.getCompileTimeClass()); TaskType taskType = task.asObjectable(); assertNotNull("asObjectable resulted in null", taskType); assertPropertyValue(task, "name", PrismTestUtil.createPolyString("Task2")); assertPropertyDefinition(task, "name", PolyStringType.COMPLEX_TYPE, 0, 1); assertPropertyValue(task, "taskIdentifier", "44444444-4444-4444-4444-000000001111"); assertPropertyDefinition(task, "taskIdentifier", DOMUtil.XSD_STRING, 0, 1); assertPropertyDefinition( task, "executionStatus", JAXBUtil.getTypeQName(TaskExecutionStatusType.class), 1, 1); PrismProperty<TaskExecutionStatusType> executionStatusProperty = task.findProperty(TaskType.F_EXECUTION_STATUS); PrismPropertyValue<TaskExecutionStatusType> executionStatusValue = executionStatusProperty.getValue(); TaskExecutionStatusType executionStatus = executionStatusValue.getValue(); assertEquals("Wrong execution status", TaskExecutionStatusType.RUNNABLE, executionStatus); PrismContainer extension = task.getExtension(); PrismContainerValue extensionValue = extension.getValue(); assertTrue("Extension parent", extensionValue.getParent() == extension); assertNull("Extension ID", extensionValue.getId()); }
private void generateIdForObject( PrismObject object, IdGeneratorResult result, Operation operation) { if (object == null) { return; } List<PrismContainer> containers = getChildrenContainers(object); Set<Long> usedIds = new HashSet<>(); for (PrismContainer c : containers) { if (c == null || c.getValues() == null) { continue; } for (PrismContainerValue val : (List<PrismContainerValue>) c.getValues()) { if (val.getId() != null) { usedIds.add(val.getId()); } } } Long nextId = 1L; for (PrismContainer c : containers) { if (c == null || c.getValues() == null) { continue; } for (PrismContainerValue val : (List<PrismContainerValue>) c.getValues()) { if (val.getId() != null) { if (Operation.ADD.equals(operation)) { result.getValues().add(val); } continue; } while (usedIds.contains(nextId)) { nextId++; } val.setId(nextId); usedIds.add(nextId); if (!Operation.ADD_WITH_OVERWRITE.equals(operation) && !Operation.MODIFY.equals(operation)) { result.getValues().add(val); } } } }
// normally this method returns an InputPanel; // however, for some special readonly types (like ObjectDeltaType) it will return a Panel private Panel createTypedInputComponent(String id) { // ValueWrapper valueWrapper = model.getObject(); // ItemWrapper itemWrapper = final Item item = valueWrapperModel.getObject().getItem().getItem(); Panel panel = null; if (item instanceof PrismProperty) { final PrismProperty property = (PrismProperty) item; PrismPropertyDefinition definition = property.getDefinition(); final QName valueType = definition.getTypeName(); final String baseExpression = "value.value"; // pointing to prism property real value // fixing MID-1230, will be improved with some kind of annotation or something like that // now it works only in description if (ObjectType.F_DESCRIPTION.equals(definition.getName())) { return new TextAreaPanel(id, new PropertyModel(valueWrapperModel, baseExpression), null); } if (ActivationType.F_ADMINISTRATIVE_STATUS.equals(definition.getName())) { return WebComponentUtil.createEnumPanel( ActivationStatusType.class, id, new PropertyModel<ActivationStatusType>(valueWrapperModel, baseExpression), this); } else if (ActivationType.F_LOCKOUT_STATUS.equals(definition.getName())) { return new LockoutStatusPanel( id, new PropertyModel<LockoutStatusType>(valueWrapperModel, baseExpression)); } else { // nothing to do } if (DOMUtil.XSD_DATETIME.equals(valueType)) { panel = new DatePanel( id, new PropertyModel<XMLGregorianCalendar>(valueWrapperModel, baseExpression)); } else if (ProtectedStringType.COMPLEX_TYPE.equals(valueType)) { boolean showRemovePasswordButton = true; if (pageBase instanceof PageUser && ((PageUser) pageBase).getObjectWrapper().getObject() != null && ((PageUser) pageBase).getObjectWrapper().getObject().getOid() != null && ((PageUser) pageBase) .getObjectWrapper() .getObject() .getOid() .equals(SecurityUtils.getPrincipalUser().getOid())) { showRemovePasswordButton = false; } panel = new PasswordPanel( id, new PropertyModel<ProtectedStringType>(valueWrapperModel, baseExpression), valueWrapperModel.getObject().isReadonly(), showRemovePasswordButton); } else if (DOMUtil.XSD_BOOLEAN.equals(valueType)) { panel = new TriStateComboPanel( id, new PropertyModel<Boolean>(valueWrapperModel, baseExpression)); } else if (SchemaConstants.T_POLY_STRING_TYPE.equals(valueType)) { InputPanel inputPanel; PrismPropertyDefinition def = property.getDefinition(); if (def.getValueEnumerationRef() != null) { PrismReferenceValue valueEnumerationRef = def.getValueEnumerationRef(); String lookupTableUid = valueEnumerationRef.getOid(); Task task = pageBase.createSimpleTask("loadLookupTable"); OperationResult result = task.getResult(); Collection<SelectorOptions<GetOperationOptions>> options = SelectorOptions.createCollection( LookupTableType.F_ROW, GetOperationOptions.createRetrieve(RetrieveOption.INCLUDE)); final PrismObject<LookupTableType> lookupTable = WebModelServiceUtils.loadObject( LookupTableType.class, lookupTableUid, options, pageBase, task, result); if (lookupTable != null) { inputPanel = new AutoCompleteTextPanel<String>( id, new LookupPropertyModel<String>( valueWrapperModel, baseExpression + ".orig", lookupTable.asObjectable()), String.class) { @Override public Iterator<String> getIterator(String input) { return prepareAutoCompleteList(input, lookupTable).iterator(); } }; } else { inputPanel = new TextPanel<>( id, new PropertyModel<String>(valueWrapperModel, baseExpression + ".orig"), String.class); } } else { inputPanel = new TextPanel<>( id, new PropertyModel<String>(valueWrapperModel, baseExpression + ".orig"), String.class); } if (ObjectType.F_NAME.equals(def.getName()) || UserType.F_FULL_NAME.equals(def.getName())) { inputPanel.getBaseFormComponent().setRequired(true); } panel = inputPanel; } else if (DOMUtil.XSD_BASE64BINARY.equals(valueType)) { panel = new UploadDownloadPanel(id, valueWrapperModel.getObject().isReadonly()) { @Override public InputStream getStream() { Object object = ((PrismPropertyValue) valueWrapperModel.getObject().getValue()).getValue(); return object != null ? new ByteArrayInputStream((byte[]) object) : new ByteArrayInputStream(new byte[0]); // return super.getStream(); } @Override public void updateValue(byte[] file) { ((PrismPropertyValue) valueWrapperModel.getObject().getValue()).setValue(file); } @Override public void uploadFilePerformed(AjaxRequestTarget target) { super.uploadFilePerformed(target); target.add(PrismValuePanel.this.get(ID_FEEDBACK)); } @Override public void removeFilePerformed(AjaxRequestTarget target) { super.removeFilePerformed(target); target.add(PrismValuePanel.this.get(ID_FEEDBACK)); } @Override public void uploadFileFailed(AjaxRequestTarget target) { super.uploadFileFailed(target); target.add(PrismValuePanel.this.get(ID_FEEDBACK)); target.add(((PageBase) getPage()).getFeedbackPanel()); } }; } else if (ObjectDeltaType.COMPLEX_TYPE.equals(valueType)) { panel = new ModificationsPanel( id, new AbstractReadOnlyModel<DeltaDto>() { @Override public DeltaDto getObject() { if (valueWrapperModel.getObject() == null || valueWrapperModel.getObject().getValue() == null || ((PrismPropertyValue) valueWrapperModel.getObject().getValue()) .getValue() == null) { return null; } PrismContext prismContext = ((PageBase) getPage()).getPrismContext(); ObjectDeltaType objectDeltaType = (ObjectDeltaType) ((PrismPropertyValue) valueWrapperModel.getObject().getValue()) .getValue(); try { ObjectDelta delta = DeltaConvertor.createObjectDelta(objectDeltaType, prismContext); return new DeltaDto(delta); } catch (SchemaException e) { throw new IllegalStateException( "Couldn't convert object delta: " + objectDeltaType); } } }); } else if (QueryType.COMPLEX_TYPE.equals(valueType) || CleanupPoliciesType.COMPLEX_TYPE.equals(valueType)) { return new TextAreaPanel( id, new AbstractReadOnlyModel() { @Override public Object getObject() { if (valueWrapperModel.getObject() == null || valueWrapperModel.getObject().getValue() == null) { return null; } PrismPropertyValue ppv = (PrismPropertyValue) valueWrapperModel.getObject().getValue(); if (ppv == null || ppv.getValue() == null) { return null; } QName name = property.getElementName(); if (name == null && property.getDefinition() != null) { name = property.getDefinition().getName(); } if (name == null) { name = SchemaConstants.C_VALUE; } PrismContext prismContext = ((PageBase) getPage()).getPrismContext(); try { return prismContext.serializeAnyData(ppv.getValue(), name, PrismContext.LANG_XML); } catch (SchemaException e) { throw new SystemException( "Couldn't serialize property value of type: " + valueType + ": " + e.getMessage(), e); } } }, 10); } else { Class type = XsdTypeMapper.getXsdToJavaMapping(valueType); if (type != null && type.isPrimitive()) { type = ClassUtils.primitiveToWrapper(type); } if (isEnum(property)) { return WebComponentUtil.createEnumPanel( definition, id, new PropertyModel<>(valueWrapperModel, baseExpression), this); } // // default QName validation is a bit weird, so let's treat QNames as // strings [TODO finish this - at the parsing side] // if (type == QName.class) { // type = String.class; // } PrismPropertyDefinition def = property.getDefinition(); if (def.getValueEnumerationRef() != null) { PrismReferenceValue valueEnumerationRef = def.getValueEnumerationRef(); String lookupTableUid = valueEnumerationRef.getOid(); Task task = pageBase.createSimpleTask("loadLookupTable"); OperationResult result = task.getResult(); Collection<SelectorOptions<GetOperationOptions>> options = SelectorOptions.createCollection( LookupTableType.F_ROW, GetOperationOptions.createRetrieve(RetrieveOption.INCLUDE)); final PrismObject<LookupTableType> lookupTable = WebModelServiceUtils.loadObject( LookupTableType.class, lookupTableUid, options, pageBase, task, result); if (lookupTable != null) { panel = new AutoCompleteTextPanel<String>( id, new LookupPropertyModel<String>( valueWrapperModel, baseExpression, lookupTable == null ? null : lookupTable.asObjectable()), type) { @Override public Iterator<String> getIterator(String input) { return prepareAutoCompleteList(input, lookupTable).iterator(); } @Override public void checkInputValue( AutoCompleteTextField input, AjaxRequestTarget target, LookupPropertyModel model) { Iterator<String> lookupTableValuesIterator = prepareAutoCompleteList("", lookupTable).iterator(); String value = input.getInput(); boolean isValueExist = false; if (value != null) { if (value.trim().equals("")) { isValueExist = true; } else { while (lookupTableValuesIterator.hasNext()) { String lookupTableValue = lookupTableValuesIterator.next(); if (value.trim().equals(lookupTableValue)) { isValueExist = true; break; } } } } if (isValueExist) { input.setModelValue(new String[] {value}); target.add(PrismValuePanel.this.get(ID_FEEDBACK)); } else { input.error( "Entered value doesn't match any of available values and will not be saved."); target.add(PrismValuePanel.this.get(ID_FEEDBACK)); } } }; } else { panel = new TextPanel<>( id, new PropertyModel<String>(valueWrapperModel, baseExpression), type); } } else { panel = new TextPanel<>( id, new PropertyModel<String>(valueWrapperModel, baseExpression), type); } } } else if (item instanceof PrismReference) { PrismContext prismContext = item.getPrismContext(); if (prismContext == null) { prismContext = pageBase.getPrismContext(); } QName targetTypeName = ((PrismReferenceDefinition) item.getDefinition()).getTargetTypeName(); Class targetClass = null; if (targetTypeName != null && prismContext != null) { targetClass = prismContext.getSchemaRegistry().determineCompileTimeClass(targetTypeName); } final Class typeClass = targetClass != null ? targetClass : (item.getDefinition().getTypeClassIfKnown() != null ? item.getDefinition().getTypeClassIfKnown() : FocusType.class); Collection typeClasses = new ArrayList(); // HACK HACK MID-3201 MID-3231 if (isUserOrgItem(item, typeClass)) { typeClasses.add(UserType.class); typeClasses.add(OrgType.class); } else { typeClasses.add(typeClass); } panel = new ValueChoosePanel( id, new PropertyModel<>(valueWrapperModel, "value"), item.getValues(), false, typeClasses); } else if (item instanceof PrismContainer<?>) { AssociationWrapper itemWrapper = (AssociationWrapper) valueWrapperModel.getObject().getItem(); final PrismContainer container = (PrismContainer) item; PrismContainerDefinition definition = container.getDefinition(); QName valueType = definition.getTypeName(); if (ShadowAssociationType.COMPLEX_TYPE.equals(valueType)) { PrismContext prismContext = item.getPrismContext(); if (prismContext == null) { prismContext = pageBase.getPrismContext(); } ShadowType shadowType = ((ShadowType) itemWrapper.getContainer().getObject().getObject().asObjectable()); PrismObject<ResourceType> resource = shadowType.getResource().asPrismObject(); // HACK. The revive should not be here. Revive is no good. The next use of the resource will // cause parsing of resource schema. We need some centralized place to maintain live cached // copies // of resources. try { resource.revive(prismContext); } catch (SchemaException e) { throw new SystemException(e.getMessage(), e); } RefinedResourceSchema refinedSchema; CompositeRefinedObjectClassDefinition rOcDef; try { refinedSchema = RefinedResourceSchema.getRefinedSchema(resource); rOcDef = refinedSchema.determineCompositeObjectClassDefinition(shadowType.asPrismObject()); } catch (SchemaException e) { throw new SystemException(e.getMessage(), e); } RefinedAssociationDefinition assocDef = itemWrapper.getRefinedAssociationDefinition(); RefinedObjectClassDefinition assocTargetDef = assocDef.getAssociationTarget(); ObjectQuery query = getAssociationsSearchQuery( prismContext, resource, assocTargetDef.getTypeName(), assocTargetDef.getKind(), assocTargetDef.getIntent()); List values = item.getValues(); return new AssociationValueChoicePanel( id, valueWrapperModel, values, false, ShadowType.class, query, assocTargetDef); } } return panel; }
private void transformConnectorConfiguration( ConfigurationProperties configProps, PrismContainer<?> configurationPropertiesContainer, String connectorConfNs) throws ConfigurationException, SchemaException { if (configurationPropertiesContainer == null || configurationPropertiesContainer.getValue() == null) { throw new SchemaException("No configuration properties container in " + connectorType); } int numConfingProperties = 0; List<QName> wrongNamespaceProperties = new ArrayList<>(); for (PrismProperty prismProperty : configurationPropertiesContainer.getValue().getProperties()) { QName propertyQName = prismProperty.getElementName(); // All the elements must be in a connector instance // namespace. if (propertyQName.getNamespaceURI() == null || !propertyQName.getNamespaceURI().equals(connectorConfNs)) { LOGGER.warn( "Found element with a wrong namespace ({}) in {}", propertyQName.getNamespaceURI(), connectorType); wrongNamespaceProperties.add(propertyQName); } else { numConfingProperties++; // Local name of the element is the same as the name // of ICF configuration property String propertyName = propertyQName.getLocalPart(); ConfigurationProperty property = configProps.getProperty(propertyName); if (property == null) { throw new ConfigurationException("Unknown configuration property " + propertyName); } // Check (java) type of ICF configuration property, // behave accordingly Class<?> type = property.getType(); if (type.isArray()) { property.setValue(convertToIcfArray(prismProperty, type.getComponentType())); // property.setValue(prismProperty.getRealValuesArray(type.getComponentType())); } else { // Single-valued property are easy to convert property.setValue(convertToIcfSingle(prismProperty, type)); // property.setValue(prismProperty.getRealValue(type)); } } } // empty configuration is OK e.g. when creating a new resource using wizard if (numConfingProperties == 0 && !wrongNamespaceProperties.isEmpty()) { throw new SchemaException( "No configuration properties found. Wrong namespace? (expected: " + connectorConfNs + ", present e.g. " + wrongNamespaceProperties.get(0) + ")"); } }
public static <T> String serializeValue( T value, ItemDefinition def, QName itemName, QName parentName, PrismContext prismContext, String language) throws SchemaException { // System.out.println("value serialization"); if (value == null) { return null; } XNodeSerializer serializer = prismContext.getXnodeProcessor().createSerializer(); if (value instanceof List) { List<T> values = (List<T>) value; if (values.isEmpty()) { return null; } if (def instanceof PrismPropertyDefinition) { PrismProperty prop = (PrismProperty) def.instantiate(itemName); for (T val : values) { PrismPropertyValue<T> pValue = new PrismPropertyValue<T>(val); prop.add(pValue); } XNode node = serializer.serializeItem(prop); if (node instanceof ListXNode) { ListXNode xList = (ListXNode) node; if (xList.size() == 1) { XNode sub = xList.iterator().next(); if (!(sub instanceof MapXNode)) { throw new IllegalArgumentException("must be a map"); } String s = prismContext.getParserDom().serializeToString(sub, parentName); // System.out.println("serialized: " + s); return s; } else { MapXNode xmap = new MapXNode(); xmap.put(itemName, xList); String s = prismContext.getParserDom().serializeToString(xmap, parentName); // System.out.println("serialized: " + s); return s; // throw new IllegalArgumentException("Check your data."); } // MapXNode xmap = xList.new MapXNode(); // xmap.put(def.getName(), xList); } String s = prismContext.getParserDom().serializeToString(node, def.getName()); // System.out.println("serialized: " + s); return s; } else if (def instanceof PrismContainerDefinition) { PrismContainer pc = (PrismContainer) def.instantiate(); for (T val : values) { // PrismContainerValue pcVal = new PrismContainerValue<Containerable>((Containerable) // val); PrismContainerValue pcVal = ((Containerable) val).asPrismContainerValue(); pc.add(pcVal.clone()); } XNode node = serializer.serializeItem(pc); if (node instanceof ListXNode) { ListXNode xList = (ListXNode) node; MapXNode xmap = new MapXNode(); xmap.put(def.getName(), xList); String s = prismContext.getParserDom().serializeToString(xmap, parentName); // System.out.println("serialized: " + s); return s; } String s = prismContext.getParserDom().serializeToString(node, def.getName()); // System.out.println("serialized: " + s); return s; } } PrismValue pVal = null; if (value instanceof Containerable) { pVal = ((Containerable) value).asPrismContainerValue(); } else if (value instanceof Referencable) { pVal = ((Referencable) value).asReferenceValue(); } else { pVal = new PrismPropertyValue<T>(value); } // Class clazz = prismContext.getSchemaRegistry().determineCompileTimeClass(itemName); // PrismContainerDefinition def = // prismContext.getSchemaRegistry().determineDefinitionFromClass(clazz); // // ItemDefinition def = // prismContext.getSchemaRegistry().findItemDefinitionByElementName(itemName); // QName itemName = null; if (def != null) { itemName = def.getName(); } XNode node = serializer.serializeItemValue(pVal, def); String s = prismContext.getParserDom().serializeToString(node, itemName); // System.out.println("serialized: " + s); return s; // throw new UnsupportedOperationException("need to be implemented"); }
@Override public String getCaseInfoButtonTitle( IModel<? extends CertCaseOrDecisionDto> rowModel, PageBase page) { CertCaseOrDecisionDto dto = rowModel.getObject(); AccessCertificationCaseType _case = dto.getCertCase(); if (!(_case instanceof AccessCertificationAssignmentCaseType)) { return null; // should not occur, TODO treat gracefully } AccessCertificationAssignmentCaseType assignmentCase = (AccessCertificationAssignmentCaseType) _case; AssignmentType assignment = assignmentCase.getAssignment(); List<String> infoList = new ArrayList<>(); String assignmentOrInducement; if (Boolean.TRUE.equals(assignmentCase.isIsInducement())) { assignmentOrInducement = page.createStringResource("PageCert.message.textInducement").getString(); } else { assignmentOrInducement = page.createStringResource("PageCert.message.textAssignment").getString(); } String targetType = getLocalizedTypeName(_case.getTargetRef().getType(), page); String targetName = dto.getTargetName(); String objectType = getLocalizedTypeName(_case.getObjectRef().getType(), page); String objectName = dto.getObjectName(); infoList.add( page.createStringResource( "PageCert.message.assignment", assignmentOrInducement, emptyToDash(targetType), emptyToDash(targetName), emptyToDash(objectType), emptyToDash(objectName)) .getString()); if (StringUtils.isNotEmpty(assignment.getDescription())) { infoList.add( page.createStringResource("PageCert.message.textDescription", assignment.getDescription()) .getString()); } if (assignment.getOrder() != null) { infoList.add( page.createStringResource("PageCert.message.textOrder", assignment.getOrder()) .getString()); } if (assignment.getConstruction() != null) { if (assignment.getConstruction().getKind() != null) { infoList.add( page.createStringResource( "PageCert.message.textKind", page.createStringResource(assignment.getConstruction().getKind()).getString()) .getString()); } if (assignment.getConstruction().getIntent() != null) { infoList.add( page.createStringResource( "PageCert.message.textIntent", assignment.getConstruction().getIntent()) .getString()); } } if (_case.getTargetRef().getRelation() != null) { infoList.add( page.createStringResource( "PageCert.message.textRelation", _case.getTargetRef().getRelation().getLocalPart()) .getString()); } Task task = page.createSimpleTask("dummy"); if (assignment.getOrgRef() != null) { String orgName = WebModelServiceUtils.resolveReferenceName( assignment.getOrgRef(), page, task, task.getResult()); infoList.add(page.createStringResource("PageCert.message.textOrg", orgName).getString()); } if (assignment.getTenantRef() != null) { String tenantName = WebModelServiceUtils.resolveReferenceName( assignment.getTenantRef(), page, task, task.getResult()); infoList.add( page.createStringResource("PageCert.message.textTenant", tenantName).getString()); } PrismContainer<? extends Containerable> extensionContainer = assignment.asPrismContainerValue().findContainer(AssignmentType.F_EXTENSION); if (extensionContainer != null && !extensionContainer.isEmpty()) { List<String> extensionItemNameList = new ArrayList<>(); for (Item extensionItem : extensionContainer.getValue().getItems()) { extensionItemNameList.add(extensionItem.getElementName().getLocalPart()); } infoList.add( page.createStringResource( "PageCert.message.textExtensions", StringUtils.join(extensionItemNameList, ", ")) .getString()); } if (assignment.getActivation() != null) { String validFrom = WebComponentUtil.formatDate(assignment.getActivation().getValidFrom()); if (validFrom != null) { infoList.add( page.createStringResource("PageCert.message.textValidFrom", validFrom).getString()); } String validTo = WebComponentUtil.formatDate(assignment.getActivation().getValidTo()); if (validTo != null) { infoList.add( page.createStringResource("PageCert.message.textValidTo", validTo).getString()); } if (assignment.getActivation().getAdministrativeStatus() != null) { infoList.add( page.createStringResource( "PageCert.message.textAdministrativeState", page.createStringResource(assignment.getActivation().getAdministrativeStatus()) .getString()) .getString()); } } String rv = StringUtils.join(infoList, "<br/>"); return rv; }
private List<ItemWrapper> createProperties(PageBase pageBase) { result = new OperationResult(CREATE_PROPERTIES); List<ItemWrapper> properties = new ArrayList<ItemWrapper>(); PrismContainerDefinition definition = null; PrismObject parent = getObject().getObject(); Class clazz = parent.getCompileTimeClass(); if (ShadowType.class.isAssignableFrom(clazz)) { QName name = containerDefinition.getName(); if (ShadowType.F_ATTRIBUTES.equals(name)) { try { definition = objectWrapper.getRefinedAttributeDefinition(); if (definition == null) { PrismReference resourceRef = parent.findReference(ShadowType.F_RESOURCE_REF); PrismObject<ResourceType> resource = resourceRef.getValue().getObject(); definition = pageBase .getModelInteractionService() .getEditObjectClassDefinition( (PrismObject<ShadowType>) objectWrapper.getObject(), resource, AuthorizationPhaseType.REQUEST) .toResourceAttributeContainerDefinition(); if (LOGGER.isTraceEnabled()) { LOGGER.trace("Refined account def:\n{}", definition.debugDump()); } } } catch (Exception ex) { LoggingUtils.logException( LOGGER, "Couldn't load definitions from refined schema for shadow", ex); result.recordFatalError( "Couldn't load definitions from refined schema for shadow, reason: " + ex.getMessage(), ex); return properties; } } else { definition = containerDefinition; } } else if (ResourceType.class.isAssignableFrom(clazz)) { if (containerDefinition != null) { definition = containerDefinition; } else { definition = container.getDefinition(); } } else { definition = containerDefinition; } if (definition == null) { LOGGER.error( "Couldn't get property list from null definition {}", new Object[] {container.getElementName()}); return properties; } // assignments are treated in a special way -- we display names of // org.units and roles // (but only if ObjectWrapper.isShowAssignments() is true; otherwise // they are filtered out by ObjectWrapper) if (container.getCompileTimeClass() != null && AssignmentType.class.isAssignableFrom(container.getCompileTimeClass())) { for (Object o : container.getValues()) { PrismContainerValue<AssignmentType> pcv = (PrismContainerValue<AssignmentType>) o; AssignmentType assignmentType = pcv.asContainerable(); if (assignmentType.getTargetRef() == null) { continue; } // hack... we want to create a definition for Name // PrismPropertyDefinition def = ((PrismContainerValue) // pcv.getContainer().getParent()).getContainer().findProperty(ObjectType.F_NAME).getDefinition(); PrismPropertyDefinition def = new PrismPropertyDefinition( ObjectType.F_NAME, DOMUtil.XSD_STRING, pcv.getPrismContext()); if (OrgType.COMPLEX_TYPE.equals(assignmentType.getTargetRef().getType())) { def.setDisplayName("Org.Unit"); def.setDisplayOrder(100); } else if (RoleType.COMPLEX_TYPE.equals(assignmentType.getTargetRef().getType())) { def.setDisplayName("Role"); def.setDisplayOrder(200); } else { continue; } PrismProperty<Object> temp = def.instantiate(); String value = formatAssignmentBrief(assignmentType); temp.setValue(new PrismPropertyValue<Object>(value)); // TODO: do this.isReadOnly() - is that OK? (originally it was the default behavior for all // cases) properties.add(new PropertyWrapper(this, temp, this.isReadonly(), ValueStatus.NOT_CHANGED)); } } else if (isShadowAssociation()) { PrismContext prismContext = objectWrapper.getObject().getPrismContext(); Map<QName, PrismContainer<ShadowAssociationType>> assocMap = new HashMap<>(); if (objectWrapper.getAssociations() != null) { for (PrismContainerValue<ShadowAssociationType> cval : objectWrapper.getAssociations()) { ShadowAssociationType associationType = cval.asContainerable(); QName assocName = associationType.getName(); PrismContainer<ShadowAssociationType> fractionalContainer = assocMap.get(assocName); if (fractionalContainer == null) { fractionalContainer = new PrismContainer<>( ShadowType.F_ASSOCIATION, ShadowAssociationType.class, cval.getPrismContext()); fractionalContainer.setDefinition(cval.getParent().getDefinition()); // HACK: set the name of the association as the element name so wrapper.getName() will // return correct data. fractionalContainer.setElementName(assocName); assocMap.put(assocName, fractionalContainer); } try { fractionalContainer.add(cval.clone()); } catch (SchemaException e) { // Should not happen throw new SystemException("Unexpected error: " + e.getMessage(), e); } } } PrismReference resourceRef = parent.findReference(ShadowType.F_RESOURCE_REF); PrismObject<ResourceType> resource = resourceRef.getValue().getObject(); // HACK. The revive should not be here. Revive is no good. The next use of the resource will // cause parsing of resource schema. We need some centralized place to maintain live cached // copies // of resources. try { resource.revive(prismContext); } catch (SchemaException e) { throw new SystemException(e.getMessage(), e); } RefinedResourceSchema refinedSchema; CompositeRefinedObjectClassDefinition rOcDef; try { refinedSchema = RefinedResourceSchema.getRefinedSchema(resource); rOcDef = refinedSchema.determineCompositeObjectClassDefinition(parent); } catch (SchemaException e) { throw new SystemException(e.getMessage(), e); } // Make sure even empty associations have their wrappers so they can be displayed and edited for (RefinedAssociationDefinition assocDef : rOcDef.getAssociations()) { QName name = assocDef.getName(); if (!assocMap.containsKey(name)) { PrismContainer<ShadowAssociationType> fractionalContainer = new PrismContainer<>( ShadowType.F_ASSOCIATION, ShadowAssociationType.class, prismContext); fractionalContainer.setDefinition(getItemDefinition()); // HACK: set the name of the association as the element name so wrapper.getName() will // return correct data. fractionalContainer.setElementName(name); assocMap.put(name, fractionalContainer); } } for (Entry<QName, PrismContainer<ShadowAssociationType>> assocEntry : assocMap.entrySet()) { // HACK HACK HACK, the container wrapper should not parse itself. This code should not be // here. AssociationWrapper assocWrapper = new AssociationWrapper( this, assocEntry.getValue(), this.isReadonly(), ValueStatus.NOT_CHANGED); properties.add(assocWrapper); } } else { // if not an assignment if ((container.getValues().size() == 1 || container.getValues().isEmpty()) && (containerDefinition == null || containerDefinition.isSingleValue())) { // there's no point in showing properties for non-single-valued // parent containers, // so we continue only if the parent is single-valued Collection<ItemDefinition> propertyDefinitions = definition.getDefinitions(); for (ItemDefinition itemDef : propertyDefinitions) { if (itemDef instanceof PrismPropertyDefinition) { PrismPropertyDefinition def = (PrismPropertyDefinition) itemDef; if (def.isIgnored() || skipProperty(def)) { continue; } if (!showInheritedObjectAttributes && INHERITED_OBJECT_ATTRIBUTES.contains(def.getName())) { continue; } // capability handling for activation properties if (isShadowActivation() && !hasCapability(def)) { continue; } if (isShadowAssociation()) { continue; } PrismProperty property = container.findProperty(def.getName()); boolean propertyIsReadOnly; // decision is based on parent object status, not this // container's one (because container can be added also // to an existing object) if (objectWrapper.getStatus() == ContainerStatus.MODIFYING) { propertyIsReadOnly = !def.canModify(); } else { propertyIsReadOnly = !def.canAdd(); } if (property == null) { properties.add( new PropertyWrapper( this, def.instantiate(), propertyIsReadOnly, ValueStatus.ADDED)); } else { properties.add( new PropertyWrapper(this, property, propertyIsReadOnly, ValueStatus.NOT_CHANGED)); } } else if (itemDef instanceof PrismReferenceDefinition) { PrismReferenceDefinition def = (PrismReferenceDefinition) itemDef; if (INHERITED_OBJECT_ATTRIBUTES.contains(def.getName())) { continue; } PrismReference reference = container.findReference(def.getName()); boolean propertyIsReadOnly; // decision is based on parent object status, not this // container's one (because container can be added also // to an existing object) if (objectWrapper.getStatus() == ContainerStatus.MODIFYING) { propertyIsReadOnly = !def.canModify(); } else { propertyIsReadOnly = !def.canAdd(); } if (reference == null) { properties.add( new ReferenceWrapper( this, def.instantiate(), propertyIsReadOnly, ValueStatus.ADDED)); } else { properties.add( new ReferenceWrapper( this, reference, propertyIsReadOnly, ValueStatus.NOT_CHANGED)); } } } } } Collections.sort(properties, new ItemWrapperComparator()); result.recomputeStatus(); return properties; }
private List<ContainerWrapper> createContainerWrapper( PrismContainer parent, ItemPath path, PageBase pageBase) { PrismContainerDefinition definition = parent.getDefinition(); List<ContainerWrapper> wrappers = new ArrayList<ContainerWrapper>(); List<ItemPathSegment> segments = new ArrayList<ItemPathSegment>(); if (path != null) { segments.addAll(path.getSegments()); } ItemPath parentPath = new ItemPath(segments); for (ItemDefinition def : (Collection<ItemDefinition>) definition.getDefinitions()) { if (!(def instanceof PrismContainerDefinition)) { continue; } if (ObjectSpecificationType.COMPLEX_TYPE.equals(def.getTypeName())) { continue; // TEMPORARY FIX } if (TriggerType.COMPLEX_TYPE.equals(def.getTypeName())) { continue; // TEMPORARY FIX TODO: remove after getEditSchema // (authorization) will be fixed. } if (ApprovalSchemaType.COMPLEX_TYPE.equals(def.getTypeName())) { continue; } LOGGER.trace("ObjectWrapper.createContainerWrapper processing definition: {}", def); PrismContainerDefinition containerDef = (PrismContainerDefinition) def; if (!showAssignments && AssignmentType.COMPLEX_TYPE.equals(containerDef.getTypeName())) { continue; } if (!showInheritedObjectAttributes) { boolean result = INHERITED_OBJECT_SUBCONTAINERS.contains(containerDef.getName()); LOGGER.info("checking " + containerDef.getName() + ", result = " + result); if (result) { continue; } } ItemPath newPath = createPropertyPath(parentPath, containerDef.getName()); // [med] // The following code fails to work when parent is multivalued or // potentially multivalued. // Therefore (as a brutal hack), for multivalued parents we simply // skip it. if (parent.size() <= 1) { // the same check as in getValue() implementation boolean isMultiValued = parent.getDefinition() != null && !parent.getDefinition().isDynamic() && !parent.getDefinition().isSingleValue(); if (!isMultiValued) { PrismContainer prismContainer = parent.findContainer(def.getName()); ContainerWrapper container; if (prismContainer != null) { container = new ContainerWrapper( this, prismContainer, ContainerStatus.MODIFYING, newPath, pageBase); } else { prismContainer = containerDef.instantiate(); container = new ContainerWrapper( this, prismContainer, ContainerStatus.ADDING, newPath, pageBase); } addSubresult(container.getResult()); wrappers.add(container); if (!AssignmentType.COMPLEX_TYPE.equals(containerDef.getTypeName()) || !ShadowType.F_ASSOCIATION.equals(parent.getElementName())) { // do // not // show // internals // of // Assignments // (e.g. // activation) wrappers.addAll(createContainerWrapper(prismContainer, newPath, pageBase)); } } } } return wrappers; }
private ObjectDelta createAddingObjectDelta() throws SchemaException { PrismObject object = this.object.clone(); List<ContainerWrapper> containers = getContainers(); // sort containers by path size Collections.sort(containers, new PathSizeComparator()); for (ContainerWrapper containerWrapper : getContainers()) { if (containerWrapper.getItemDefinition().getName().equals(ShadowType.F_ASSOCIATION)) { PrismContainer associationContainer = object.findOrCreateContainer(ShadowType.F_ASSOCIATION); List<AssociationWrapper> associationItemWrappers = (List<AssociationWrapper>) containerWrapper.getItems(); for (AssociationWrapper associationItemWrapper : associationItemWrappers) { List<ValueWrapper> assocValueWrappers = associationItemWrapper.getValues(); for (ValueWrapper assocValueWrapper : assocValueWrappers) { PrismContainerValue<ShadowAssociationType> assocValue = (PrismContainerValue<ShadowAssociationType>) assocValueWrapper.getValue(); associationContainer.add(assocValue.clone()); } } continue; } if (!containerWrapper.hasChanged()) { continue; } PrismContainer container = containerWrapper.getItem(); ItemPath path = containerWrapper.getPath(); if (containerWrapper.getPath() != null) { container = container.clone(); if (path.size() > 1) { ItemPath parentPath = path.allExceptLast(); PrismContainer parent = object.findOrCreateContainer(parentPath); parent.add(container); } else { PrismContainer existing = object.findContainer(container.getElementName()); if (existing == null) { object.add(container); } else { continue; } } } else { container = object; } for (ItemWrapper propertyWrapper : (List<ItemWrapper>) containerWrapper.getItems()) { if (!propertyWrapper.hasChanged()) { continue; } Item property = propertyWrapper.getItem().clone(); if (container.findProperty(property.getElementName()) != null) { continue; } for (ValueWrapper valueWrapper : propertyWrapper.getValues()) { valueWrapper.normalize(object.getPrismContext()); if (!valueWrapper.hasValueChanged() || ValueStatus.DELETED.equals(valueWrapper.getStatus())) { continue; } if (property.hasRealValue(valueWrapper.getValue())) { continue; } PrismValue cloned = clone(valueWrapper.getValue()); if (cloned != null) { property.add(cloned); } } if (!property.isEmpty()) { container.add(property); } } } // cleanup empty containers cleanupEmptyContainers(object); ObjectDelta delta = ObjectDelta.createAddDelta(object); // returning container to previous order Collections.sort(containers, new ItemWrapperComparator()); if (InternalsConfig.consistencyChecks) { delta.checkConsistence(true, true, true, ConsistencyCheckScope.THOROUGH); } return delta; }