private List<ReferenceDelta> filterParentRefDeltas(Collection<? extends ItemDelta> modifications) { boolean containsAdd = false, containsDelete = false, containsReplace = false; List<ReferenceDelta> deltas = new ArrayList<>(); if (modifications == null) { return deltas; } for (ItemDelta delta : modifications) { if (!QNameUtil.match(ObjectType.F_PARENT_ORG_REF, delta.getElementName())) { // TODO is this OK? continue; } if (delta.isAdd()) { containsAdd = true; } if (delta.isDelete()) { containsDelete = true; } if (delta.isReplace()) { if (containsReplace) { throw new IllegalStateException("Unsupported combination of parentOrgRef operations: more REPLACE ItemDeltas"); } containsReplace = true; } deltas.add((ReferenceDelta) delta); } if (containsReplace && (containsAdd || containsDelete)) { throw new IllegalStateException("Unsupported combination of parentOrgRef operations: REPLACE with either ADD or DELETE"); } return deltas; }
if (itemDelta.isDelete()) { for (PrismValue prismValue : itemDelta.getValuesToDelete()) { body.append(" --- DELETE: ");
Set<RFocusPhoto> photos = focus.getJpegPhoto(); if (delta.isDelete()) { photos.clear(); return;
private ItemPath getPathToExplain(ItemDelta itemDelta) { ItemPath path = itemDelta.getPath(); for (int i = 0; i < path.size(); i++) { Object segment = path.getSegment(i); if (ItemPath.isId(segment)) { if (i < path.size()-1 || itemDelta.isDelete()) { return path.allUpToIncluding(i); } else { // this means that the path ends with [id] segment *and* the value(s) are // only added and deleted, i.e. they are shown in the delta anyway // (actually it is questionable whether path in delta can end with [id] segment, // but we test for this case just to be sure) return null; } } } return null; }
private void handleObjectExtensionWholeContainer(RObject object, ItemDelta delta, PrismIdentifierGenerator idGenerator) { RObjectExtensionType extType = computeObjectExtensionType(delta); if (!delta.isAdd()) { clearExtension(object, extType); } if (delta.isDelete()) { return; } PrismContainerValue extension = (PrismContainerValue) delta.getAnyValue(); for (Item item : (List<Item>) extension.getItems()) { ItemDelta itemDelta = item.createDelta(); itemDelta.setValuesToReplace(item.getClonedValues()); processAnyExtensionDeltaValues(itemDelta, object, extType, null, null, idGenerator); } }
private void handleBasicOrEmbedded(Object bean, ItemDelta delta, Attribute attribute) { Class outputType = getRealOutputType(attribute); PrismValue anyPrismValue = delta.getAnyValue(); Object value; if (delta.isDelete() || (delta.isReplace() && (anyPrismValue == null || anyPrismValue.isEmpty()))) { value = null; } else { value = anyPrismValue.getRealValue(); } value = prismEntityMapper.map(value, outputType); try { PropertyUtils.setSimpleProperty(bean, attribute.getName(), value); } catch (Exception ex) { throw new SystemException("Couldn't set simple property for '" + attribute.getName() + "'", ex); } }
private void handleOneToMany(Collection collection, ItemDelta delta, Attribute attribute, Object bean, PrismObject prismObject, PrismIdentifierGenerator idGenerator) { Class outputType = getRealOutputType(attribute); Item item = prismObject.findItem(delta.getPath()); // handle replace if (delta.isReplace()) { Collection<PrismEntityPair<?>> valuesToReplace = processDeltaValues(delta.getValuesToReplace(), outputType, delta, bean); replaceValues(collection, valuesToReplace, item, idGenerator); return; } // handle add if (delta.isAdd()) { Collection<PrismEntityPair<?>> valuesToAdd = processDeltaValues(delta.getValuesToAdd(), outputType, delta, bean); addValues(collection, valuesToAdd, idGenerator); } // handle delete if (delta.isDelete()) { Collection<PrismEntityPair<?>> valuesToDelete = processDeltaValues(delta.getValuesToDelete(), outputType, delta, bean); valuesToDelete.stream().forEach(pair -> { if (pair.getRepository() instanceof EntityState) { ((EntityState) pair.getRepository()).setTransient(false); } }); deleteValues(collection, valuesToDelete, item); } }
private void handleMetadata(Object bean, ItemDelta delta) { if (!(bean instanceof Metadata)) { throw new SystemException("Bean is not instance of " + Metadata.class + ", shouldn't happen"); } PrismValue value = null; if (!delta.isDelete()) { value = delta.getAnyValue(); } MapperContext context = new MapperContext(); context.setRepositoryContext(new RepositoryContext(repositoryService, prismContext, relationRegistry, extItemDictionary)); context.setDelta(delta); context.setOwner(bean); if (value != null) { prismEntityMapper.mapPrismValue(value, Metadata.class, context); } else { // todo clean this up // we know that mapper supports mapping null value, but still this code smells Mapper mapper = prismEntityMapper.getMapper(MetadataType.class, Metadata.class); mapper.map(null, context); } }
private void handleOperationResult(Object bean, ItemDelta delta) { if (!(bean instanceof OperationResult)) { throw new SystemException("Bean is not instance of " + OperationResult.class + ", shouldn't happen"); } PrismValue value = null; if (!delta.isDelete()) { value = delta.getAnyValue(); } MapperContext context = new MapperContext(); context.setRepositoryContext(new RepositoryContext(repositoryService, prismContext, relationRegistry, extItemDictionary)); context.setDelta(delta); context.setOwner(bean); if (value != null) { prismEntityMapper.mapPrismValue(value, OperationResult.class, context); } else { // todo clean this up // we know that mapper supports mapping null value, but still this code smells Mapper mapper = prismEntityMapper.getMapper(OperationResultType.class, OperationResult.class); mapper.map(null, context); } }
private void handleAssignmentExtensionWholeContainer(RAssignment assignment, ItemDelta delta, PrismIdentifierGenerator idGenerator) { RAssignmentExtension ext = assignment.getExtension(); if (!delta.isAdd()) { if (ext != null) { clearExtension(ext); } } if (delta.isDelete()) { return; } if (ext == null) { ext = new RAssignmentExtension(); ext.setOwner(assignment); assignment.setExtension(ext); } PrismContainerValue extension = (PrismContainerValue) delta.getAnyValue(); for (Item item : (List<Item>) extension.getItems()) { ItemDelta itemDelta = item.createDelta(); itemDelta.setValuesToReplace(item.getClonedValues()); processAnyExtensionDeltaValues(itemDelta, null, null, ext, RAssignmentExtensionType.EXTENSION, idGenerator); } }
private void takePasswordsFromItemDelta(List<ProtectedStringType> passwords, ItemDelta itemDelta) { if (itemDelta.isDelete()) { return;
if (itemDelta.isDelete()) { LOGGER.trace("Non-tolerant item with values to DELETE => removing them");