Skip to content

Commit

Permalink
ninja add remove attribute processor fix
Browse files Browse the repository at this point in the history
  • Loading branch information
1azyman committed Oct 4, 2023
1 parent 3478655 commit dd42aa6
Showing 1 changed file with 2 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@

package com.evolveum.midpoint.schema.validator.processor;

import java.util.Arrays;
import java.util.List;

import com.evolveum.midpoint.prism.PrismObject;
import com.evolveum.midpoint.prism.path.ItemPath;
import com.evolveum.midpoint.schema.validator.UpgradeObjectProcessor;
Expand All @@ -25,14 +22,6 @@
@SuppressWarnings("unused")
public class AddRemoveAttributeValuesProcessor implements UpgradeObjectProcessor<ResourceType> {

private static final ItemPath PATH_NATIVE = ItemPath.create(
ResourceType.F_CAPABILITIES, CapabilitiesType.F_NATIVE, CapabilityCollectionType.F_ADD_REMOVE_ATTRIBUTE_VALUES);

private static final ItemPath PATH_CONFIGURED = ItemPath.create(
ResourceType.F_CAPABILITIES, CapabilitiesType.F_CONFIGURED, CapabilityCollectionType.F_ADD_REMOVE_ATTRIBUTE_VALUES);

private static final List<ItemPath> PATHS = Arrays.asList(PATH_NATIVE, PATH_CONFIGURED);

@Override
public UpgradePhase getPhase() {
return UpgradePhase.BEFORE;
Expand All @@ -50,17 +39,12 @@ public UpgradeType getType() {

@Override
public boolean isApplicable(PrismObject<?> object, ItemPath path) {
if (!ResourceType.class.equals(object.getCompileTimeClass())) {
return false;
}

return PATHS.stream().anyMatch(p -> p.equivalent(path));
return matchParentTypeAndItemName(object, path, CapabilityCollectionType.class, CapabilityCollectionType.F_ADD_REMOVE_ATTRIBUTE_VALUES);
}

@Override
public boolean process(PrismObject<ResourceType> object, ItemPath path) {
ItemPath collectionPath = path.allExceptLast();
CapabilityCollectionType collection = object.findContainer(collectionPath).getRealValue(CapabilityCollectionType.class);
CapabilityCollectionType collection = getItemParent(object, path);

AddRemoveAttributeValuesCapabilityType addRemoveValues = collection.getAddRemoveAttributeValues();
collection.setAddRemoveAttributeValues(null);
Expand Down

0 comments on commit dd42aa6

Please sign in to comment.