/** * Add PLAIN attribute DELETE patch for those attributes of the input AnyTO without values or containing null value * * @param anyTO User, Group or Any Object to look for attributes with no value * @param patch patch to enrich with DELETE statements */ public static void cleanEmptyAttrs(final AnyTO anyTO, final AnyPatch patch) { patch.getPlainAttrs().addAll(anyTO.getPlainAttrs().stream(). filter(plainAttrTO -> isEmpty(plainAttrTO)). map(plainAttrTO -> new AttrPatch.Builder(). operation(PatchOperation.DELETE). attrTO(new AttrTO.Builder().schema(plainAttrTO.getSchema()).build()). build()).collect(Collectors.toSet())); }
originalAttrs.keySet().stream().filter(attr -> !updatedAttrs.containsKey(attr)). forEach(schema -> { result.getPlainAttrs().add(new AttrPatch.Builder(). operation(PatchOperation.DELETE). attrTO(new AttrTO.Builder().schema(schema).build()). if (isEmpty(attrTO)) { if (!incremental) { result.getPlainAttrs().add(new AttrPatch.Builder(). operation(PatchOperation.DELETE). attrTO(new AttrTO.Builder().schema(attrTO.getSchema()).build()). || !originalAttrs.get(attrTO.getSchema()).getValues().equals(attrTO.getValues())) { AttrPatch patch = new AttrPatch.Builder().operation(PatchOperation.ADD_REPLACE).attrTO(attrTO). build(); if (!patch.isEmpty()) {
anyObject.add(newAttr); AttrPatch patch = new AttrPatch.Builder().attrTO(attrTO).build(); processAttrPatch( anyObject, patch, schema, newAttr, anyUtils,
user.add(attr); AttrPatch patch = new AttrPatch.Builder().attrTO(attrTO).build(); processAttrPatch( user, patch, schema, attr, anyUtils,
private void addUpdateOrReplaceAttr( final String key, final SchemaType schemaType, final AttrTO attrTO, final PatchOperation operation) { if (attrTO.getSchema() == null) { throw new NotFoundException("Must specify schema"); } P patch = newPatch(key); switch (schemaType) { case VIRTUAL: patch.getVirAttrs().add(attrTO); break; case PLAIN: patch.getPlainAttrs().add(new AttrPatch.Builder().operation(operation).attrTO(attrTO).build()); break; case DERIVED: default: } doUpdate(patch); }