http://git-wip-us.apache.org/repos/asf/syncope/blob/9f73fa43/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/CamelUserProvisioningManager.java ---------------------------------------------------------------------- diff --git a/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/CamelUserProvisioningManager.java b/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/CamelUserProvisioningManager.java index fa0b84b..436d80d 100644 --- a/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/CamelUserProvisioningManager.java +++ b/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/CamelUserProvisioningManager.java @@ -29,8 +29,8 @@ import org.apache.camel.Exchange; import org.apache.camel.PollingConsumer; import org.apache.commons.lang3.tuple.ImmutablePair; import org.apache.commons.lang3.tuple.Pair; -import org.apache.syncope.common.lib.mod.StatusMod; -import org.apache.syncope.common.lib.mod.UserMod; +import org.apache.syncope.common.lib.patch.StatusPatch; +import org.apache.syncope.common.lib.patch.UserPatch; import org.apache.syncope.common.lib.to.PropagationStatus; import org.apache.syncope.common.lib.to.UserTO; import org.apache.syncope.common.lib.types.PropagationByResource; @@ -85,10 +85,10 @@ public class CamelUserProvisioningManager extends AbstractCamelProvisioningManag @Override @SuppressWarnings("unchecked") - public Pair<Long, List<PropagationStatus>> update(final UserMod userMod) { + public Pair<Long, List<PropagationStatus>> update(final UserPatch userPatch) { PollingConsumer pollingConsumer = getConsumer("direct:updatePort"); - sendMessage("direct:updateUser", userMod); + sendMessage("direct:updateUser", userPatch); Exchange exchange = pollingConsumer.receive(); @@ -100,8 +100,8 @@ public class CamelUserProvisioningManager extends AbstractCamelProvisioningManag } @Override - public Pair<Long, List<PropagationStatus>> update(final UserMod anyMod, final Set<String> excludedResources) { - return update(anyMod, anyMod.getKey(), new ProvisioningResult(), null, excludedResources); + public Pair<Long, List<PropagationStatus>> update(final UserPatch anyPatch, final Set<String> excludedResources) { + return update(anyPatch, anyPatch.getKey(), new ProvisioningResult(), null, excludedResources); } @Override @@ -129,10 +129,10 @@ public class CamelUserProvisioningManager extends AbstractCamelProvisioningManag } @Override - public Long unlink(final UserMod userMod) { + public Long unlink(final UserPatch userPatch) { PollingConsumer pollingConsumer = getConsumer("direct:unlinkPort"); - sendMessage("direct:unlinkUser", userMod); + sendMessage("direct:unlinkUser", userPatch); Exchange exchange = pollingConsumer.receive(); @@ -140,25 +140,25 @@ public class CamelUserProvisioningManager extends AbstractCamelProvisioningManag throw (RuntimeException) exchange.getProperty(Exchange.EXCEPTION_CAUGHT); } - exchange.getIn().setBody((exchange.getIn().getBody(UserMod.class).getKey())); + exchange.getIn().setBody((exchange.getIn().getBody(UserPatch.class).getKey())); return exchange.getIn().getBody(Long.class); } @Override @SuppressWarnings("unchecked") - public Pair<Long, List<PropagationStatus>> activate(final StatusMod statusMod) { + public Pair<Long, List<PropagationStatus>> activate(final StatusPatch statusPatch) { PollingConsumer pollingConsumer = getConsumer("direct:statusPort"); Map<String, Object> props = new HashMap<>(); - props.put("token", statusMod.getToken()); - props.put("userKey", statusMod.getKey()); - props.put("statusMod", statusMod); + props.put("token", statusPatch.getToken()); + props.put("userKey", statusPatch.getKey()); + props.put("statusPatch", statusPatch); - if (statusMod.isOnSyncope()) { - sendMessage("direct:activateUser", statusMod.getKey(), props); + if (statusPatch.isOnSyncope()) { + sendMessage("direct:activateUser", statusPatch.getKey(), props); } else { WorkflowResult<Long> updated = - new WorkflowResult<>(statusMod.getKey(), null, statusMod.getType().name().toLowerCase()); + new WorkflowResult<>(statusPatch.getKey(), null, statusPatch.getType().name().toLowerCase()); sendMessage("direct:userStatusPropagation", updated, props); } @@ -173,18 +173,18 @@ public class CamelUserProvisioningManager extends AbstractCamelProvisioningManag @Override @SuppressWarnings("unchecked") - public Pair<Long, List<PropagationStatus>> reactivate(final StatusMod statusMod) { + public Pair<Long, List<PropagationStatus>> reactivate(final StatusPatch statusPatch) { PollingConsumer pollingConsumer = getConsumer("direct:statusPort"); Map<String, Object> props = new HashMap<>(); - props.put("userKey", statusMod.getKey()); - props.put("statusMod", statusMod); + props.put("userKey", statusPatch.getKey()); + props.put("statusPatch", statusPatch); - if (statusMod.isOnSyncope()) { - sendMessage("direct:reactivateUser", statusMod.getKey(), props); + if (statusPatch.isOnSyncope()) { + sendMessage("direct:reactivateUser", statusPatch.getKey(), props); } else { WorkflowResult<Long> updated = - new WorkflowResult<>(statusMod.getKey(), null, statusMod.getType().name().toLowerCase()); + new WorkflowResult<>(statusPatch.getKey(), null, statusPatch.getType().name().toLowerCase()); sendMessage("direct:userStatusPropagation", updated, props); } @@ -199,18 +199,18 @@ public class CamelUserProvisioningManager extends AbstractCamelProvisioningManag @Override @SuppressWarnings("unchecked") - public Pair<Long, List<PropagationStatus>> suspend(final StatusMod statusMod) { + public Pair<Long, List<PropagationStatus>> suspend(final StatusPatch statusPatch) { PollingConsumer pollingConsumer = getConsumer("direct:statusPort"); Map<String, Object> props = new HashMap<>(); - props.put("userKey", statusMod.getKey()); - props.put("statusMod", statusMod); + props.put("userKey", statusPatch.getKey()); + props.put("statusPatch", statusPatch); - if (statusMod.isOnSyncope()) { - sendMessage("direct:suspendUser", statusMod.getKey(), props); + if (statusPatch.isOnSyncope()) { + sendMessage("direct:suspendUser", statusPatch.getKey(), props); } else { WorkflowResult<Long> updated = - new WorkflowResult<>(statusMod.getKey(), null, statusMod.getType().name().toLowerCase()); + new WorkflowResult<>(statusPatch.getKey(), null, statusPatch.getType().name().toLowerCase()); sendMessage("direct:userStatusPropagation", updated, props); } @@ -224,10 +224,10 @@ public class CamelUserProvisioningManager extends AbstractCamelProvisioningManag } @Override - public Long link(final UserMod anyMod) { + public Long link(final UserPatch anyPatch) { PollingConsumer pollingConsumer = getConsumer("direct:linkPort"); - sendMessage("direct:linkUser", anyMod); + sendMessage("direct:linkUser", anyPatch); Exchange exchange = pollingConsumer.receive(); @@ -235,7 +235,7 @@ public class CamelUserProvisioningManager extends AbstractCamelProvisioningManag throw (RuntimeException) exchange.getProperty(Exchange.EXCEPTION_CAUGHT); } - exchange.getIn().setBody((exchange.getIn().getBody(UserMod.class).getKey())); + exchange.getIn().setBody((exchange.getIn().getBody(UserPatch.class).getKey())); return exchange.getIn().getBody(Long.class); } @@ -285,7 +285,7 @@ public class CamelUserProvisioningManager extends AbstractCamelProvisioningManag @Override @SuppressWarnings("unchecked") public Pair<Long, List<PropagationStatus>> update( - final UserMod userMod, final Long key, final ProvisioningResult result, + final UserPatch userPatch, final Long key, final ProvisioningResult result, final Boolean enabled, final Set<String> excludedResources) { PollingConsumer pollingConsumer = getConsumer("direct:updateInSyncPort"); @@ -296,7 +296,7 @@ public class CamelUserProvisioningManager extends AbstractCamelProvisioningManag props.put("enabled", enabled); props.put("excludedResources", excludedResources); - sendMessage("direct:updateUserInSync", userMod, props); + sendMessage("direct:updateUserInSync", userPatch, props); Exchange exchange = pollingConsumer.receive(); @@ -307,8 +307,8 @@ public class CamelUserProvisioningManager extends AbstractCamelProvisioningManag result.setStatus(ProvisioningResult.Status.FAILURE); result.setMessage("Update failed, trying to sync status anyway (if configured)\n" + ex.getMessage()); - WorkflowResult<Pair<UserMod, Boolean>> updated = new WorkflowResult<Pair<UserMod, Boolean>>( - new ImmutablePair<>(userMod, false), new PropagationByResource(), + WorkflowResult<Pair<UserPatch, Boolean>> updated = new WorkflowResult<Pair<UserPatch, Boolean>>( + new ImmutablePair<>(userPatch, false), new PropagationByResource(), new HashSet<String>()); sendMessage("direct:userInSync", updated, props); exchange = pollingConsumer.receive();
http://git-wip-us.apache.org/repos/asf/syncope/blob/9f73fa43/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/AnyObjectProvisionProcessor.java ---------------------------------------------------------------------- diff --git a/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/AnyObjectProvisionProcessor.java b/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/AnyObjectProvisionProcessor.java index ff9466d..1c1f24d 100644 --- a/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/AnyObjectProvisionProcessor.java +++ b/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/AnyObjectProvisionProcessor.java @@ -61,7 +61,7 @@ public class AnyObjectProvisionProcessor implements Processor { WorkflowResult<Long> wfResult = new WorkflowResult<>(key, propByRes, "update"); - List<PropagationTask> tasks = propagationManager.getAnyObjectUpdateTasks(wfResult, null, null, null); + List<PropagationTask> tasks = propagationManager.getAnyObjectUpdateTasks(wfResult, null, null); PropagationReporter propagationReporter = ApplicationContextProvider.getBeanFactory().getBean(PropagationReporter.class); try { http://git-wip-us.apache.org/repos/asf/syncope/blob/9f73fa43/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/AnyObjectUpdateProcessor.java ---------------------------------------------------------------------- diff --git a/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/AnyObjectUpdateProcessor.java b/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/AnyObjectUpdateProcessor.java index 04009ef..7243f8c 100644 --- a/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/AnyObjectUpdateProcessor.java +++ b/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/AnyObjectUpdateProcessor.java @@ -24,7 +24,7 @@ import java.util.Set; import org.apache.camel.Exchange; import org.apache.camel.Processor; import org.apache.commons.lang3.tuple.ImmutablePair; -import org.apache.syncope.common.lib.mod.AnyObjectMod; +import org.apache.syncope.common.lib.patch.AnyObjectPatch; import org.apache.syncope.common.lib.types.AnyTypeKind; import org.apache.syncope.common.lib.types.PropagationByResource; import org.apache.syncope.core.misc.spring.ApplicationContextProvider; @@ -58,20 +58,19 @@ public class AnyObjectUpdateProcessor implements Processor { @Override public void process(final Exchange exchange) { WorkflowResult<Long> updated = (WorkflowResult) exchange.getIn().getBody(); - AnyObjectMod anyObjectMod = exchange.getProperty("anyMod", AnyObjectMod.class); + AnyObjectPatch anyObjectPatch = exchange.getProperty("anyPatch", AnyObjectPatch.class); Set<String> excludedResources = exchange.getProperty("excludedResources", Set.class); - List<PropagationTask> tasks = propagationManager.getAnyObjectUpdateTasks(updated, - anyObjectMod.getVirAttrsToRemove(), anyObjectMod.getVirAttrsToUpdate(), excludedResources); + List<PropagationTask> tasks = propagationManager.getAnyObjectUpdateTasks( + updated, anyObjectPatch.getVirAttrs(), excludedResources); if (tasks.isEmpty()) { // SYNCOPE-459: take care of user virtual attributes ... PropagationByResource propByResVirAttr = virtAttrHandler.fillVirtual( updated.getResult(), - AnyTypeKind.GROUP, - anyObjectMod.getVirAttrsToRemove(), - anyObjectMod.getVirAttrsToUpdate()); + AnyTypeKind.ANY_OBJECT, + anyObjectPatch.getVirAttrs()); tasks.addAll(!propByResVirAttr.isEmpty() - ? propagationManager.getAnyObjectUpdateTasks(updated, null, null, null) + ? propagationManager.getAnyObjectUpdateTasks(updated, null, null) : Collections.<PropagationTask>emptyList()); } http://git-wip-us.apache.org/repos/asf/syncope/blob/9f73fa43/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/GroupProvisionProcessor.java ---------------------------------------------------------------------- diff --git a/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/GroupProvisionProcessor.java b/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/GroupProvisionProcessor.java index 23f47a7..4c7af59 100644 --- a/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/GroupProvisionProcessor.java +++ b/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/GroupProvisionProcessor.java @@ -61,7 +61,7 @@ public class GroupProvisionProcessor implements Processor { WorkflowResult<Long> wfResult = new WorkflowResult<>(key, propByRes, "update"); - List<PropagationTask> tasks = propagationManager.getGroupUpdateTasks(wfResult, null, null, null); + List<PropagationTask> tasks = propagationManager.getGroupUpdateTasks(wfResult, null, null); PropagationReporter propagationReporter = ApplicationContextProvider.getBeanFactory().getBean(PropagationReporter.class); try { http://git-wip-us.apache.org/repos/asf/syncope/blob/9f73fa43/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/GroupUpdateProcessor.java ---------------------------------------------------------------------- diff --git a/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/GroupUpdateProcessor.java b/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/GroupUpdateProcessor.java index 1bdbb6c..22c5f3d 100644 --- a/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/GroupUpdateProcessor.java +++ b/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/GroupUpdateProcessor.java @@ -24,7 +24,7 @@ import java.util.Set; import org.apache.camel.Exchange; import org.apache.camel.Processor; import org.apache.commons.lang3.tuple.ImmutablePair; -import org.apache.syncope.common.lib.mod.GroupMod; +import org.apache.syncope.common.lib.patch.GroupPatch; import org.apache.syncope.common.lib.types.AnyTypeKind; import org.apache.syncope.common.lib.types.PropagationByResource; import org.apache.syncope.core.misc.spring.ApplicationContextProvider; @@ -58,20 +58,19 @@ public class GroupUpdateProcessor implements Processor { @Override public void process(final Exchange exchange) { WorkflowResult<Long> updated = (WorkflowResult) exchange.getIn().getBody(); - GroupMod groupMod = exchange.getProperty("anyMod", GroupMod.class); + GroupPatch groupPatch = exchange.getProperty("anyPatch", GroupPatch.class); Set<String> excludedResources = exchange.getProperty("excludedResources", Set.class); - List<PropagationTask> tasks = propagationManager.getGroupUpdateTasks(updated, - groupMod.getVirAttrsToRemove(), groupMod.getVirAttrsToUpdate(), excludedResources); + List<PropagationTask> tasks = propagationManager.getGroupUpdateTasks( + updated, groupPatch.getVirAttrs(), excludedResources); if (tasks.isEmpty()) { // SYNCOPE-459: take care of user virtual attributes ... PropagationByResource propByResVirAttr = virtAttrHandler.fillVirtual( updated.getResult(), AnyTypeKind.GROUP, - groupMod.getVirAttrsToRemove(), - groupMod.getVirAttrsToUpdate()); + groupPatch.getVirAttrs()); tasks.addAll(!propByResVirAttr.isEmpty() - ? propagationManager.getGroupUpdateTasks(updated, null, null, null) + ? propagationManager.getGroupUpdateTasks(updated, null, null) : Collections.<PropagationTask>emptyList()); } http://git-wip-us.apache.org/repos/asf/syncope/blob/9f73fa43/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/UserConfirmPwdResetProcessor.java ---------------------------------------------------------------------- diff --git a/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/UserConfirmPwdResetProcessor.java b/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/UserConfirmPwdResetProcessor.java index a586f09..1e02187 100644 --- a/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/UserConfirmPwdResetProcessor.java +++ b/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/UserConfirmPwdResetProcessor.java @@ -23,7 +23,8 @@ import org.apache.camel.Exchange; import org.apache.camel.Processor; import org.apache.commons.lang3.tuple.ImmutablePair; import org.apache.commons.lang3.tuple.Pair; -import org.apache.syncope.common.lib.mod.UserMod; +import org.apache.syncope.common.lib.patch.PasswordPatch; +import org.apache.syncope.common.lib.patch.UserPatch; import org.apache.syncope.core.misc.spring.ApplicationContextProvider; import org.apache.syncope.core.persistence.api.entity.task.PropagationTask; import org.apache.syncope.core.provisioning.api.WorkflowResult; @@ -51,13 +52,14 @@ public class UserConfirmPwdResetProcessor implements Processor { public void process(final Exchange exchange) { Long key = exchange.getProperty("userKey", Long.class); - UserMod userMod = new UserMod(); - userMod.setKey(key); - userMod.setPassword(exchange.getProperty("password", String.class)); + UserPatch userPatch = new UserPatch(); + userPatch.setKey(key); + userPatch.setPassword(new PasswordPatch.Builder(). + value(exchange.getProperty("password", String.class)).build()); List<PropagationTask> tasks = propagationManager.getUserUpdateTasks( - new WorkflowResult<Pair<UserMod, Boolean>>( - new ImmutablePair<UserMod, Boolean>(userMod, null), null, "confirmPasswordReset"), + new WorkflowResult<Pair<UserPatch, Boolean>>( + new ImmutablePair<UserPatch, Boolean>(userPatch, null), null, "confirmPasswordReset"), true, null); PropagationReporter propReporter = ApplicationContextProvider.getBeanFactory().getBean(PropagationReporter.class); http://git-wip-us.apache.org/repos/asf/syncope/blob/9f73fa43/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/UserInternalSuspendProcessor.java ---------------------------------------------------------------------- diff --git a/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/UserInternalSuspendProcessor.java b/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/UserInternalSuspendProcessor.java index 73e63ad..e565872 100644 --- a/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/UserInternalSuspendProcessor.java +++ b/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/UserInternalSuspendProcessor.java @@ -23,7 +23,7 @@ import org.apache.camel.Exchange; import org.apache.camel.Processor; import org.apache.commons.lang3.tuple.ImmutablePair; import org.apache.commons.lang3.tuple.Pair; -import org.apache.syncope.common.lib.mod.UserMod; +import org.apache.syncope.common.lib.patch.UserPatch; import org.apache.syncope.core.persistence.api.entity.task.PropagationTask; import org.apache.syncope.core.provisioning.api.WorkflowResult; import org.apache.syncope.core.provisioning.api.propagation.PropagationManager; @@ -47,12 +47,12 @@ public class UserInternalSuspendProcessor implements Processor { // propagate suspension if and only if it is required by policy if (updated != null && updated.getValue()) { - UserMod userMod = new UserMod(); - userMod.setKey(updated.getKey().getResult()); + UserPatch userPatch = new UserPatch(); + userPatch.setKey(updated.getKey().getResult()); List<PropagationTask> tasks = propagationManager.getUserUpdateTasks( - new WorkflowResult<Pair<UserMod, Boolean>>( - new ImmutablePair<>(userMod, Boolean.FALSE), + new WorkflowResult<Pair<UserPatch, Boolean>>( + new ImmutablePair<>(userPatch, Boolean.FALSE), updated.getKey().getPropByRes(), updated.getKey().getPerformedTasks())); taskExecutor.execute(tasks); } http://git-wip-us.apache.org/repos/asf/syncope/blob/9f73fa43/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/UserProvisionProcessor.java ---------------------------------------------------------------------- diff --git a/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/UserProvisionProcessor.java b/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/UserProvisionProcessor.java index b77b61f..04c9ac9 100644 --- a/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/UserProvisionProcessor.java +++ b/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/UserProvisionProcessor.java @@ -21,10 +21,14 @@ package org.apache.syncope.core.provisioning.camel.processor; import java.util.List; import org.apache.camel.Exchange; import org.apache.camel.Processor; +import org.apache.commons.collections4.CollectionUtils; +import org.apache.commons.collections4.Transformer; import org.apache.commons.lang3.tuple.ImmutablePair; import org.apache.commons.lang3.tuple.Pair; -import org.apache.syncope.common.lib.mod.StatusMod; -import org.apache.syncope.common.lib.mod.UserMod; +import org.apache.syncope.common.lib.patch.PasswordPatch; +import org.apache.syncope.common.lib.patch.StringPatchItem; +import org.apache.syncope.common.lib.patch.UserPatch; +import org.apache.syncope.common.lib.types.PatchOperation; import org.apache.syncope.common.lib.types.PropagationByResource; import org.apache.syncope.common.lib.types.ResourceOperation; import org.apache.syncope.core.misc.spring.ApplicationContextProvider; @@ -62,16 +66,19 @@ public class UserProvisionProcessor implements Processor { @SuppressWarnings("unchecked") List<String> resources = exchange.getProperty("resources", List.class); - UserMod userMod = new UserMod(); - userMod.setKey(key); - userMod.getResourcesToAdd().addAll(resources); + UserPatch userPatch = new UserPatch(); + userPatch.setKey(key); + userPatch.getResources().addAll(CollectionUtils.collect(resources, new Transformer<String, StringPatchItem>() { + + @Override + public StringPatchItem transform(final String resource) { + return new StringPatchItem.Builder().operation(PatchOperation.ADD_REPLACE).value(resource).build(); + } + })); if (changePwd) { - StatusMod statusMod = new StatusMod(); - statusMod.setOnSyncope(false); - statusMod.getResources().addAll(resources); - userMod.setPwdPropRequest(statusMod); - userMod.setPassword(password); + userPatch.setPassword( + new PasswordPatch.Builder().onSyncope(true).value(password).resources(resources).build()); } PropagationByResource propByRes = new PropagationByResource(); @@ -79,8 +86,8 @@ public class UserProvisionProcessor implements Processor { propByRes.add(ResourceOperation.UPDATE, resource); } - WorkflowResult<Pair<UserMod, Boolean>> wfResult = new WorkflowResult<Pair<UserMod, Boolean>>( - ImmutablePair.of(userMod, (Boolean) null), propByRes, "update"); + WorkflowResult<Pair<UserPatch, Boolean>> wfResult = new WorkflowResult<Pair<UserPatch, Boolean>>( + ImmutablePair.of(userPatch, (Boolean) null), propByRes, "update"); List<PropagationTask> tasks = propagationManager.getUserUpdateTasks(wfResult, changePwd, null); PropagationReporter propagationReporter = http://git-wip-us.apache.org/repos/asf/syncope/blob/9f73fa43/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/UserSetStatusInSyncProcessor.java ---------------------------------------------------------------------- diff --git a/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/UserSetStatusInSyncProcessor.java b/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/UserSetStatusInSyncProcessor.java index 75ab027..fbe4c20 100644 --- a/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/UserSetStatusInSyncProcessor.java +++ b/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/UserSetStatusInSyncProcessor.java @@ -21,7 +21,7 @@ package org.apache.syncope.core.provisioning.camel.processor; import java.util.Map; import org.apache.camel.Processor; import org.apache.camel.Exchange; -import org.apache.syncope.common.lib.mod.UserMod; +import org.apache.syncope.common.lib.patch.UserPatch; import org.apache.syncope.core.persistence.api.dao.UserDAO; import org.apache.syncope.core.persistence.api.entity.user.User; import org.apache.syncope.core.provisioning.api.WorkflowResult; @@ -41,7 +41,7 @@ public class UserSetStatusInSyncProcessor implements Processor { @SuppressWarnings("unchecked") @Override public void process(final Exchange exchange) { - WorkflowResult<Map.Entry<UserMod, Boolean>> updated = (WorkflowResult) exchange.getIn().getBody(); + WorkflowResult<Map.Entry<UserPatch, Boolean>> updated = (WorkflowResult) exchange.getIn().getBody(); Boolean enabled = exchange.getProperty("enabled", Boolean.class); Long key = exchange.getProperty("userKey", Long.class); http://git-wip-us.apache.org/repos/asf/syncope/blob/9f73fa43/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/UserStatusPropagationProcessor.java ---------------------------------------------------------------------- diff --git a/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/UserStatusPropagationProcessor.java b/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/UserStatusPropagationProcessor.java index 41af6eb..f05a95a 100644 --- a/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/UserStatusPropagationProcessor.java +++ b/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/UserStatusPropagationProcessor.java @@ -24,7 +24,8 @@ import org.apache.camel.Exchange; import org.apache.camel.Processor; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.tuple.ImmutablePair; -import org.apache.syncope.common.lib.mod.StatusMod; +import org.apache.syncope.common.lib.patch.StatusPatch; +import org.apache.syncope.common.lib.types.StatusPatchType; import org.apache.syncope.core.misc.spring.ApplicationContextProvider; import org.apache.syncope.core.persistence.api.dao.UserDAO; import org.apache.syncope.core.persistence.api.entity.task.PropagationTask; @@ -58,13 +59,13 @@ public class UserStatusPropagationProcessor implements Processor { WorkflowResult<Long> updated = (WorkflowResult) exchange.getIn().getBody(); Long key = exchange.getProperty("userKey", Long.class); - StatusMod statusMod = exchange.getProperty("statusMod", StatusMod.class); + StatusPatch statusPatch = exchange.getProperty("statusPatch", StatusPatch.class); Collection<String> resourcesToBeExcluded = CollectionUtils.removeAll( - userDAO.findAllResourceNames(userDAO.find(key)), statusMod.getResources()); + userDAO.findAllResourceNames(userDAO.find(key)), statusPatch.getResources()); List<PropagationTask> tasks = propagationManager.getUserUpdateTasks( - key, statusMod.getType() != StatusMod.ModType.SUSPEND, resourcesToBeExcluded); + key, statusPatch.getType() != StatusPatchType.SUSPEND, resourcesToBeExcluded); PropagationReporter propReporter = ApplicationContextProvider.getBeanFactory().getBean(PropagationReporter.class); try { http://git-wip-us.apache.org/repos/asf/syncope/blob/9f73fa43/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/UserUpdateInSyncProcessor.java ---------------------------------------------------------------------- diff --git a/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/UserUpdateInSyncProcessor.java b/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/UserUpdateInSyncProcessor.java index dcd271d..ffdd5d2 100644 --- a/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/UserUpdateInSyncProcessor.java +++ b/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/UserUpdateInSyncProcessor.java @@ -24,7 +24,7 @@ import org.apache.camel.Exchange; import org.apache.camel.Processor; import org.apache.commons.lang3.tuple.ImmutablePair; import org.apache.commons.lang3.tuple.Pair; -import org.apache.syncope.common.lib.mod.UserMod; +import org.apache.syncope.common.lib.patch.UserPatch; import org.apache.syncope.core.misc.spring.ApplicationContextProvider; import org.apache.syncope.core.persistence.api.entity.task.PropagationTask; import org.apache.syncope.core.provisioning.api.WorkflowResult; @@ -51,14 +51,14 @@ public class UserUpdateInSyncProcessor implements Processor { @SuppressWarnings("unchecked") @Override public void process(final Exchange exchange) { - WorkflowResult<Pair<UserMod, Boolean>> updated = (WorkflowResult) exchange.getIn().getBody(); + WorkflowResult<Pair<UserPatch, Boolean>> updated = (WorkflowResult) exchange.getIn().getBody(); Set<String> excludedResources = exchange.getProperty("excludedResources", Set.class); PropagationReporter propagationReporter = ApplicationContextProvider.getBeanFactory().getBean(PropagationReporter.class); - List<PropagationTask> tasks = propagationManager.getUserUpdateTasks(updated, updated.getResult().getKey(). - getPassword() != null, excludedResources); + List<PropagationTask> tasks = propagationManager.getUserUpdateTasks( + updated, updated.getResult().getKey().getPassword() != null, excludedResources); try { taskExecutor.execute(tasks, propagationReporter); http://git-wip-us.apache.org/repos/asf/syncope/blob/9f73fa43/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/UserUpdateProcessor.java ---------------------------------------------------------------------- diff --git a/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/UserUpdateProcessor.java b/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/UserUpdateProcessor.java index 1dc19f5..8023264 100644 --- a/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/UserUpdateProcessor.java +++ b/ext/camel/provisioning-camel/src/main/java/org/apache/syncope/core/provisioning/camel/processor/UserUpdateProcessor.java @@ -18,13 +18,12 @@ */ package org.apache.syncope.core.provisioning.camel.processor; -import java.util.Collections; import java.util.List; import org.apache.camel.Exchange; import org.apache.camel.Processor; import org.apache.commons.lang3.tuple.ImmutablePair; import org.apache.commons.lang3.tuple.Pair; -import org.apache.syncope.common.lib.mod.UserMod; +import org.apache.syncope.common.lib.patch.UserPatch; import org.apache.syncope.common.lib.types.AnyTypeKind; import org.apache.syncope.common.lib.types.PropagationByResource; import org.apache.syncope.core.misc.spring.ApplicationContextProvider; @@ -57,8 +56,8 @@ public class UserUpdateProcessor implements Processor { @Override @SuppressWarnings("unchecked") public void process(final Exchange exchange) { - WorkflowResult<Pair<UserMod, Boolean>> updated = (WorkflowResult) exchange.getIn().getBody(); - UserMod userMod = exchange.getProperty("actual", UserMod.class); + WorkflowResult<Pair<UserPatch, Boolean>> updated = (WorkflowResult) exchange.getIn().getBody(); + UserPatch userPatch = exchange.getProperty("actual", UserPatch.class); List<PropagationTask> tasks = propagationManager.getUserUpdateTasks(updated); if (tasks.isEmpty()) { @@ -66,11 +65,10 @@ public class UserUpdateProcessor implements Processor { PropagationByResource propByResVirAttr = virtAttrHandler.fillVirtual( updated.getResult().getKey().getKey(), AnyTypeKind.USER, - userMod.getVirAttrsToRemove(), - userMod.getVirAttrsToUpdate()); - tasks.addAll(!propByResVirAttr.isEmpty() - ? propagationManager.getUserUpdateTasks(updated, false, null) - : Collections.<PropagationTask>emptyList()); + userPatch.getVirAttrs()); + if (!propByResVirAttr.isEmpty()) { + tasks.addAll(propagationManager.getUserUpdateTasks(updated, false, null)); + } } PropagationReporter propagationReporter = http://git-wip-us.apache.org/repos/asf/syncope/blob/9f73fa43/ext/camel/provisioning-camel/src/main/resources/anyObjectRoutes.xml ---------------------------------------------------------------------- diff --git a/ext/camel/provisioning-camel/src/main/resources/anyObjectRoutes.xml b/ext/camel/provisioning-camel/src/main/resources/anyObjectRoutes.xml index 9cbde16..c0b1fe5 100644 --- a/ext/camel/provisioning-camel/src/main/resources/anyObjectRoutes.xml +++ b/ext/camel/provisioning-camel/src/main/resources/anyObjectRoutes.xml @@ -40,7 +40,7 @@ under the License. <route id="updateAnyObject"> <from uri="direct:updateAnyObject"/> - <setProperty propertyName="anyMod"> + <setProperty propertyName="anyPatch"> <simple>${body}</simple> </setProperty> <doTry> http://git-wip-us.apache.org/repos/asf/syncope/blob/9f73fa43/ext/camel/provisioning-camel/src/main/resources/groupRoutes.xml ---------------------------------------------------------------------- diff --git a/ext/camel/provisioning-camel/src/main/resources/groupRoutes.xml b/ext/camel/provisioning-camel/src/main/resources/groupRoutes.xml index ac64345..8e1b914 100644 --- a/ext/camel/provisioning-camel/src/main/resources/groupRoutes.xml +++ b/ext/camel/provisioning-camel/src/main/resources/groupRoutes.xml @@ -59,7 +59,7 @@ under the License. <route id="updateGroup"> <from uri="direct:updateGroup"/> - <setProperty propertyName="anyMod"> + <setProperty propertyName="anyPatch"> <simple>${body}</simple> </setProperty> <doTry> http://git-wip-us.apache.org/repos/asf/syncope/blob/9f73fa43/fit/console-reference/src/test/java/org/apache/syncope/fit/console/reference/AbstractITCase.java ---------------------------------------------------------------------- diff --git a/fit/console-reference/src/test/java/org/apache/syncope/fit/console/reference/AbstractITCase.java b/fit/console-reference/src/test/java/org/apache/syncope/fit/console/reference/AbstractITCase.java index 1bd2027..1fdc90e 100644 --- a/fit/console-reference/src/test/java/org/apache/syncope/fit/console/reference/AbstractITCase.java +++ b/fit/console-reference/src/test/java/org/apache/syncope/fit/console/reference/AbstractITCase.java @@ -31,9 +31,6 @@ import org.slf4j.LoggerFactory; public abstract class AbstractITCase { - /** - * Logger. - */ protected static final Logger LOG = LoggerFactory.getLogger(AbstractITCase.class); public static final String ADMIN = "admin"; http://git-wip-us.apache.org/repos/asf/syncope/blob/9f73fa43/fit/core-reference/src/main/java/org/apache/syncope/fit/core/reference/DoubleValueLogicActions.java ---------------------------------------------------------------------- diff --git a/fit/core-reference/src/main/java/org/apache/syncope/fit/core/reference/DoubleValueLogicActions.java b/fit/core-reference/src/main/java/org/apache/syncope/fit/core/reference/DoubleValueLogicActions.java index 1544969..4e416df 100644 --- a/fit/core-reference/src/main/java/org/apache/syncope/fit/core/reference/DoubleValueLogicActions.java +++ b/fit/core-reference/src/main/java/org/apache/syncope/fit/core/reference/DoubleValueLogicActions.java @@ -20,8 +20,8 @@ package org.apache.syncope.fit.core.reference; import java.util.ArrayList; import java.util.List; -import org.apache.syncope.common.lib.mod.AnyMod; -import org.apache.syncope.common.lib.mod.AttrMod; +import org.apache.syncope.common.lib.patch.AnyPatch; +import org.apache.syncope.common.lib.patch.AttrPatch; import org.apache.syncope.common.lib.to.AnyTO; import org.apache.syncope.common.lib.to.AttrTO; import org.apache.syncope.core.provisioning.java.DefaultLogicActions; @@ -54,19 +54,19 @@ public class DoubleValueLogicActions extends DefaultLogicActions { } @Override - public <M extends AnyMod> M beforeUpdate(final M input) { - for (AttrMod attr : input.getPlainAttrsToUpdate()) { - if (NAME.equals(attr.getSchema())) { - List<String> values = new ArrayList<>(attr.getValuesToBeAdded().size()); - for (String value : attr.getValuesToBeAdded()) { + public <M extends AnyPatch> M beforeUpdate(final M input) { + for (AttrPatch patch : input.getPlainAttrs()) { + if (NAME.equals(patch.getAttrTO().getSchema())) { + List<String> values = new ArrayList<>(patch.getAttrTO().getValues().size()); + for (String value : patch.getAttrTO().getValues()) { try { values.add(String.valueOf(2 * Long.valueOf(value))); } catch (NumberFormatException e) { // ignore } } - attr.getValuesToBeAdded().clear(); - attr.getValuesToBeAdded().addAll(values); + patch.getAttrTO().getValues().clear(); + patch.getAttrTO().getValues().addAll(values); } } http://git-wip-us.apache.org/repos/asf/syncope/blob/9f73fa43/fit/core-reference/src/main/java/org/apache/syncope/fit/core/reference/TestSyncActions.java ---------------------------------------------------------------------- diff --git a/fit/core-reference/src/main/java/org/apache/syncope/fit/core/reference/TestSyncActions.java b/fit/core-reference/src/main/java/org/apache/syncope/fit/core/reference/TestSyncActions.java index 9852612..de2b417 100644 --- a/fit/core-reference/src/main/java/org/apache/syncope/fit/core/reference/TestSyncActions.java +++ b/fit/core-reference/src/main/java/org/apache/syncope/fit/core/reference/TestSyncActions.java @@ -19,11 +19,12 @@ package org.apache.syncope.fit.core.reference; import org.apache.commons.collections4.CollectionUtils; -import org.apache.syncope.common.lib.mod.AnyMod; -import org.apache.syncope.common.lib.mod.AttrMod; +import org.apache.syncope.common.lib.patch.AnyPatch; +import org.apache.syncope.common.lib.patch.AttrPatch; import org.apache.syncope.common.lib.to.AnyTO; import org.apache.syncope.common.lib.to.AttrTO; import org.apache.syncope.common.lib.to.UserTO; +import org.apache.syncope.common.lib.types.PatchOperation; import org.apache.syncope.core.provisioning.api.sync.IgnoreProvisionException; import org.apache.syncope.core.provisioning.api.sync.ProvisioningProfile; import org.apache.syncope.core.provisioning.java.sync.DefaultSyncActions; @@ -73,28 +74,27 @@ public class TestSyncActions extends DefaultSyncActions { } @Override - public <A extends AnyTO, M extends AnyMod> SyncDelta beforeUpdate( + public <A extends AnyTO, M extends AnyPatch> SyncDelta beforeUpdate( final ProvisioningProfile<?, ?> profile, final SyncDelta delta, final A any, - final M anyMod) throws JobExecutionException { + final M anyPatch) throws JobExecutionException { - anyMod.getPlainAttrsToRemove().add("fullname"); - - AttrMod fullnameMod = null; - for (AttrMod attrMod : anyMod.getPlainAttrsToUpdate()) { - if ("fullname".equals(attrMod.getSchema())) { - fullnameMod = attrMod; + AttrPatch fullnamePatch = null; + for (AttrPatch attrPatch : anyPatch.getPlainAttrs()) { + if ("fullname".equals(attrPatch.getAttrTO().getSchema())) { + fullnamePatch = attrPatch; } } - if (fullnameMod == null) { - fullnameMod = new AttrMod(); - fullnameMod.setSchema("fullname"); - anyMod.getPlainAttrsToUpdate().add(fullnameMod); + if (fullnamePatch == null) { + fullnamePatch = new AttrPatch.Builder(). + operation(PatchOperation.ADD_REPLACE). + attrTO(new AttrTO.Builder().schema("fullname").build()). + build(); } - fullnameMod.getValuesToBeAdded().clear(); - fullnameMod.getValuesToBeAdded().add(String.valueOf(counter++)); + fullnamePatch.getAttrTO().getValues().clear(); + fullnamePatch.getAttrTO().getValues().add(String.valueOf(counter++)); return delta; } http://git-wip-us.apache.org/repos/asf/syncope/blob/9f73fa43/fit/core-reference/src/main/resources/userWorkflow.bpmn20.xml ---------------------------------------------------------------------- diff --git a/fit/core-reference/src/main/resources/userWorkflow.bpmn20.xml b/fit/core-reference/src/main/resources/userWorkflow.bpmn20.xml index df292b8..0b05bef 100644 --- a/fit/core-reference/src/main/resources/userWorkflow.bpmn20.xml +++ b/fit/core-reference/src/main/resources/userWorkflow.bpmn20.xml @@ -97,7 +97,7 @@ under the License. <exclusiveGateway id="activeGw"/> <sequenceFlow id="active2UpdateApproval" sourceRef="activeGw" targetRef="updateApproval"> <conditionExpression xsi:type="tFormalExpression"><![CDATA[${wfExecutor == user.getUsername() and task == 'update' - and (!userMod.getMembershipsToAdd().isEmpty() or !userMod.getMembershipsToRemove().isEmpty())}]]></conditionExpression> + and (!userPatch.getMemberships().isEmpty())}]]></conditionExpression> </sequenceFlow> <sequenceFlow id="active2DeleteApproval" sourceRef="activeGw" targetRef="deleteApproval"> <conditionExpression xsi:type="tFormalExpression"><![CDATA[${wfExecutor == user.getUsername() and task == 'delete'}]]></conditionExpression> http://git-wip-us.apache.org/repos/asf/syncope/blob/9f73fa43/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/AbstractITCase.java ---------------------------------------------------------------------- diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/AbstractITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/AbstractITCase.java index 4e5d5e9..b30c962 100644 --- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/AbstractITCase.java +++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/AbstractITCase.java @@ -36,10 +36,10 @@ import org.apache.commons.lang3.StringUtils; import org.apache.cxf.jaxrs.client.WebClient; import org.apache.syncope.client.lib.SyncopeClient; import org.apache.syncope.client.lib.SyncopeClientFactoryBean; -import org.apache.syncope.common.lib.mod.AnyObjectMod; -import org.apache.syncope.common.lib.mod.AttrMod; -import org.apache.syncope.common.lib.mod.GroupMod; -import org.apache.syncope.common.lib.mod.UserMod; +import org.apache.syncope.common.lib.patch.AnyObjectPatch; +import org.apache.syncope.common.lib.patch.AttrPatch; +import org.apache.syncope.common.lib.patch.GroupPatch; +import org.apache.syncope.common.lib.patch.UserPatch; import org.apache.syncope.common.lib.policy.AbstractPolicyTO; import org.apache.syncope.common.lib.to.AbstractSchemaTO; import org.apache.syncope.common.lib.to.AnyObjectTO; @@ -49,6 +49,7 @@ import org.apache.syncope.common.lib.to.GroupTO; import org.apache.syncope.common.lib.to.RoleTO; import org.apache.syncope.common.lib.to.UserTO; import org.apache.syncope.common.lib.types.ConnConfProperty; +import org.apache.syncope.common.lib.types.PatchOperation; import org.apache.syncope.common.lib.types.SchemaType; import org.apache.syncope.common.rest.api.RESTHeaders; import org.apache.syncope.common.rest.api.service.AnyObjectService; @@ -266,17 +267,11 @@ public abstract class AbstractITCase { } protected static AttrTO attrTO(final String schema, final String value) { - AttrTO attr = new AttrTO(); - attr.setSchema(schema); - attr.getValues().add(value); - return attr; + return new AttrTO.Builder().schema(schema).value(value).build(); } - protected static AttrMod attrMod(final String schema, final String valueToBeAdded) { - AttrMod attr = new AttrMod(); - attr.setSchema(schema); - attr.getValuesToBeAdded().add(valueToBeAdded); - return attr; + protected static AttrPatch attrAddReplacePatch(final String schema, final String value) { + return new AttrPatch.Builder().operation(PatchOperation.ADD_REPLACE).attrTO(attrTO(schema, value)).build(); } protected UserTO createUser(final UserTO userTO) { @@ -299,8 +294,8 @@ public abstract class AbstractITCase { userService.getUserKey(username).getHeaderString(RESTHeaders.USER_KEY))); } - protected UserTO updateUser(final UserMod userMod) { - return userService.update(userMod).readEntity(UserTO.class); + protected UserTO updateUser(final UserPatch userPatch) { + return userService.update(userPatch).readEntity(UserTO.class); } protected UserTO deleteUser(final Long key) { @@ -349,8 +344,8 @@ public abstract class AbstractITCase { return getObject(response.getLocation(), AnyObjectService.class, AnyObjectTO.class); } - protected AnyObjectTO updateAnyObject(final AnyObjectMod anyObjectMod) { - return anyObjectService.update(anyObjectMod).readEntity(AnyObjectTO.class); + protected AnyObjectTO updateAnyObject(final AnyObjectPatch anyObjectPatch) { + return anyObjectService.update(anyObjectPatch).readEntity(AnyObjectTO.class); } protected AnyObjectTO deleteAnyObject(final Long key) { @@ -368,8 +363,8 @@ public abstract class AbstractITCase { return getObject(response.getLocation(), GroupService.class, GroupTO.class); } - protected GroupTO updateGroup(final GroupMod groupMod) { - return groupService.update(groupMod).readEntity(GroupTO.class); + protected GroupTO updateGroup(final GroupPatch groupPatch) { + return groupService.update(groupPatch).readEntity(GroupTO.class); } protected GroupTO deleteGroup(final Long key) { http://git-wip-us.apache.org/repos/asf/syncope/blob/9f73fa43/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/AnyObjectITCase.java ---------------------------------------------------------------------- diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/AnyObjectITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/AnyObjectITCase.java index e2b339a..94716e7 100644 --- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/AnyObjectITCase.java +++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/AnyObjectITCase.java @@ -27,7 +27,7 @@ import javax.ws.rs.core.Response; import org.apache.syncope.client.lib.SyncopeClient; import org.apache.syncope.common.lib.SyncopeClientException; import org.apache.syncope.common.lib.SyncopeConstants; -import org.apache.syncope.common.lib.mod.AnyObjectMod; +import org.apache.syncope.common.lib.patch.AnyObjectPatch; import org.apache.syncope.common.lib.to.ConnObjectTO; import org.apache.syncope.common.lib.to.AnyObjectTO; import org.apache.syncope.common.lib.to.PagedResult; @@ -113,12 +113,12 @@ public class AnyObjectITCase extends AbstractITCase { assertEquals(1, anyObjectTO.getPlainAttrs().size()); - AnyObjectMod anyObjectMod = new AnyObjectMod(); - anyObjectMod.setKey(anyObjectTO.getKey()); + AnyObjectPatch anyObjectPatch = new AnyObjectPatch(); + anyObjectPatch.setKey(anyObjectTO.getKey()); String newLocation = "new" + getUUIDString(); - anyObjectMod.getPlainAttrsToUpdate().add(attrMod("location", newLocation)); + anyObjectPatch.getPlainAttrs().add(attrAddReplacePatch("location", newLocation)); - anyObjectTO = updateAnyObject(anyObjectMod); + anyObjectTO = updateAnyObject(anyObjectPatch); assertEquals(newLocation, anyObjectTO.getPlainAttrMap().get("location").getValues().get(0)); } http://git-wip-us.apache.org/repos/asf/syncope/blob/9f73fa43/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/AuthenticationITCase.java ---------------------------------------------------------------------- diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/AuthenticationITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/AuthenticationITCase.java index 79ec47a..3f82edf 100644 --- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/AuthenticationITCase.java +++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/AuthenticationITCase.java @@ -36,8 +36,11 @@ import org.apache.commons.lang3.tuple.Pair; import org.apache.syncope.client.lib.SyncopeClient; import org.apache.syncope.common.lib.SyncopeClientException; import org.apache.syncope.common.lib.SyncopeConstants; -import org.apache.syncope.common.lib.mod.StatusMod; -import org.apache.syncope.common.lib.mod.UserMod; +import org.apache.syncope.common.lib.patch.DeassociationPatch; +import org.apache.syncope.common.lib.patch.PasswordPatch; +import org.apache.syncope.common.lib.patch.StatusPatch; +import org.apache.syncope.common.lib.patch.StringReplacePatchItem; +import org.apache.syncope.common.lib.patch.UserPatch; import org.apache.syncope.common.lib.to.BulkActionResult; import org.apache.syncope.common.lib.to.MembershipTO; import org.apache.syncope.common.lib.to.PagedResult; @@ -50,10 +53,9 @@ import org.apache.syncope.common.lib.types.AttrSchemaType; import org.apache.syncope.common.lib.types.CipherAlgorithm; import org.apache.syncope.common.lib.types.ClientExceptionType; import org.apache.syncope.common.lib.types.Entitlement; -import org.apache.syncope.common.lib.types.ResourceDeassociationActionType; +import org.apache.syncope.common.lib.types.ResourceDeassociationAction; import org.apache.syncope.common.lib.types.SchemaType; -import org.apache.syncope.common.lib.wrap.ResourceKey; -import org.apache.syncope.common.rest.api.CollectionWrapper; +import org.apache.syncope.common.lib.types.StatusPatchType; import org.apache.syncope.common.rest.api.RESTHeaders; import org.apache.syncope.common.rest.api.service.SchemaService; import org.apache.syncope.common.rest.api.service.UserService; @@ -281,23 +283,22 @@ public class AuthenticationITCase extends AbstractITCase { assertEquals("surname", user.getPlainAttrMap().get("surname").getValues().get(0)); // 5. as delegated, update user attempting to move under realm / -> fail - UserMod userMod = new UserMod(); - userMod.setKey(user.getKey()); - userMod.setRealm("/odd"); - userMod.getPlainAttrsToRemove().add("surname"); - userMod.getPlainAttrsToUpdate().add(attrMod("surname", "surname2")); + UserPatch userPatch = new UserPatch(); + userPatch.setKey(user.getKey()); + userPatch.setRealm(new StringReplacePatchItem.Builder().value("/odd").build()); + userPatch.getPlainAttrs().add(attrAddReplacePatch("surname", "surname2")); try { - delegatedUserService.update(userMod); + delegatedUserService.update(userPatch); fail(); } catch (SyncopeClientException e) { assertEquals(ClientExceptionType.DelegatedAdministration, e.getType()); } // 6. revert realm change -> succeed - userMod.setRealm(null); + userPatch.setRealm(null); - response = delegatedUserService.update(userMod); + response = delegatedUserService.update(userPatch); assertEquals(Response.Status.OK.getStatusCode(), response.getStatus()); user = response.readEntity(UserTO.class); @@ -380,9 +381,9 @@ public class AuthenticationITCase extends AbstractITCase { SyncopeClient goodPwdClient = clientFactory.create(userTO.getUsername(), "password123"); assertReadFails(goodPwdClient); - StatusMod reactivate = new StatusMod(); + StatusPatch reactivate = new StatusPatch(); reactivate.setKey(userTO.getKey()); - reactivate.setType(StatusMod.ModType.REACTIVATE); + reactivate.setType(StatusPatchType.REACTIVATE); userTO = userService.status(reactivate).readEntity(UserTO.class); assertNotNull(userTO); assertEquals("active", userTO.getStatus()); @@ -396,9 +397,7 @@ public class AuthenticationITCase extends AbstractITCase { // 1. create user with group 9 (users with group 9 are defined in workflow as subject to approval) UserTO userTO = UserITCase.getUniqueSampleTO("[email protected]"); - MembershipTO membershipTO = new MembershipTO(); - membershipTO.setRightKey(9L); - userTO.getMemberships().add(membershipTO); + userTO.getMemberships().add(new MembershipTO.Builder().group(9L).build()); userTO = createUser(userTO); assertNotNull(userTO); @@ -442,16 +441,17 @@ public class AuthenticationITCase extends AbstractITCase { assertNotNull(user); // 2. unlink the resource from the created user - assertNotNull(userService.deassociate(user.getKey(), - ResourceDeassociationActionType.UNLINK, - CollectionWrapper.wrap(RESOURCE_NAME_TESTDB, ResourceKey.class)). - readEntity(BulkActionResult.class)); + DeassociationPatch deassociationPatch = new DeassociationPatch(); + deassociationPatch.setKey(user.getKey()); + deassociationPatch.setAction(ResourceDeassociationAction.UNLINK); + deassociationPatch.getResources().add(RESOURCE_NAME_TESTDB); + assertNotNull(userService.deassociate(deassociationPatch).readEntity(BulkActionResult.class)); // 3. change password on Syncope - UserMod userMod = new UserMod(); - userMod.setKey(user.getKey()); - userMod.setPassword("password234"); - user = updateUser(userMod); + UserPatch userPatch = new UserPatch(); + userPatch.setKey(user.getKey()); + userPatch.setPassword(new PasswordPatch.Builder().value("password234").build()); + user = updateUser(userPatch); assertNotNull(user); // 4. check that the db resource has still the initial password value http://git-wip-us.apache.org/repos/asf/syncope/blob/9f73fa43/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/ConnectorITCase.java ---------------------------------------------------------------------- diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/ConnectorITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/ConnectorITCase.java index 52ee2ac..194de73 100644 --- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/ConnectorITCase.java +++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/ConnectorITCase.java @@ -38,6 +38,7 @@ import java.util.Properties; import java.util.Set; import javax.ws.rs.core.Response; import org.apache.commons.io.IOUtils; +import org.apache.commons.lang3.exception.ExceptionUtils; import org.apache.syncope.common.lib.SyncopeClientException; import org.apache.syncope.common.lib.to.BulkAction; import org.apache.syncope.common.lib.to.ConnBundleTO; @@ -519,14 +520,23 @@ public class ConnectorITCase extends AbstractITCase { // set connector configuration connectorTO.getConfiguration().addAll(conf); - assertTrue(connectorService.check(connectorTO).getElement()); + try { + connectorService.check(connectorTO); + } catch (Exception e) { + fail(ExceptionUtils.getStackTrace(e)); + } conf.remove(password); password.getValues().clear(); password.getValues().add("password"); conf.add(password); - assertFalse(connectorService.check(connectorTO).getElement()); + try { + connectorService.check(connectorTO); + fail(); + } catch (Exception e) { + assertNotNull(e); + } } @Test @@ -626,7 +636,12 @@ public class ConnectorITCase extends AbstractITCase { connectorTO.getConfiguration().addAll(conf); try { - assertFalse(connectorService.check(connectorTO).getElement()); + try { + connectorService.check(connectorTO); + fail(); + } catch (Exception e) { + assertNotNull(e); + } Response response = connectorService.create(connectorTO); if (response.getStatusInfo().getStatusCode() != Response.Status.CREATED.getStatusCode()) { @@ -672,7 +687,11 @@ public class ConnectorITCase extends AbstractITCase { // ---------------------------------------- // Check connection without saving the resource .... // ---------------------------------------- - assertTrue(resourceService.check(resourceTO).getElement()); + try { + resourceService.check(resourceTO); + } catch (Exception e) { + fail(ExceptionUtils.getStackTrace(e)); + } // ---------------------------------------- } finally { // Remove connector from db to make test re-runnable http://git-wip-us.apache.org/repos/asf/syncope/blob/9f73fa43/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/GroupITCase.java ---------------------------------------------------------------------- diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/GroupITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/GroupITCase.java index 6ad53c7..f1cc587 100644 --- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/GroupITCase.java +++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/GroupITCase.java @@ -42,11 +42,15 @@ import org.apache.commons.lang3.StringUtils; import org.apache.syncope.client.lib.SyncopeClient; import org.apache.syncope.common.lib.SyncopeClientException; import org.apache.syncope.common.lib.SyncopeConstants; -import org.apache.syncope.common.lib.mod.ReferenceMod; -import org.apache.syncope.common.lib.mod.GroupMod; -import org.apache.syncope.common.lib.mod.ResourceAssociationMod; +import org.apache.syncope.common.lib.patch.AssociationPatch; +import org.apache.syncope.common.lib.patch.AttrPatch; +import org.apache.syncope.common.lib.patch.DeassociationPatch; +import org.apache.syncope.common.lib.patch.GroupPatch; +import org.apache.syncope.common.lib.patch.LongReplacePatchItem; +import org.apache.syncope.common.lib.patch.StringReplacePatchItem; import org.apache.syncope.common.lib.to.AnyTypeClassTO; import org.apache.syncope.common.lib.to.AnyTypeTO; +import org.apache.syncope.common.lib.to.AttrTO; import org.apache.syncope.common.lib.to.BulkActionResult; import org.apache.syncope.common.lib.to.ConnObjectTO; import org.apache.syncope.common.lib.to.MappingItemTO; @@ -60,11 +64,10 @@ import org.apache.syncope.common.lib.types.AnyTypeKind; import org.apache.syncope.common.lib.types.ClientExceptionType; import org.apache.syncope.common.lib.types.IntMappingType; import org.apache.syncope.common.lib.types.MappingPurpose; +import org.apache.syncope.common.lib.types.PatchOperation; import org.apache.syncope.common.lib.types.ResourceAssociationAction; -import org.apache.syncope.common.lib.types.ResourceDeassociationActionType; +import org.apache.syncope.common.lib.types.ResourceDeassociationAction; import org.apache.syncope.common.lib.types.SchemaType; -import org.apache.syncope.common.lib.wrap.ResourceKey; -import org.apache.syncope.common.rest.api.CollectionWrapper; import org.apache.syncope.common.rest.api.Preference; import org.apache.syncope.common.rest.api.RESTHeaders; import org.apache.syncope.common.rest.api.service.GroupService; @@ -113,11 +116,11 @@ public class GroupITCase extends AbstractITCase { assertNotNull(connObjectTO.getPlainAttrMap().get("owner")); // SYNCOPE-515: remove ownership - final GroupMod groupMod = new GroupMod(); - groupMod.setKey(groupTO.getKey()); - groupMod.setGroupOwner(new ReferenceMod()); + GroupPatch groupPatch = new GroupPatch(); + groupPatch.setKey(groupTO.getKey()); + groupPatch.setGroupOwner(new LongReplacePatchItem()); - assertNull(updateGroup(groupMod).getGroupOwner()); + assertNull(updateGroup(groupPatch).getGroupOwner()); } @Test @@ -202,13 +205,13 @@ public class GroupITCase extends AbstractITCase { assertEquals(1, groupTO.getPlainAttrs().size()); - GroupMod groupMod = new GroupMod(); - groupMod.setKey(groupTO.getKey()); + GroupPatch groupPatch = new GroupPatch(); + groupPatch.setKey(groupTO.getKey()); String modName = "finalGroup" + getUUIDString(); - groupMod.setName(modName); - groupMod.getPlainAttrsToUpdate().add(attrMod("show", "FALSE")); + groupPatch.setName(new StringReplacePatchItem.Builder().value(modName).build()); + groupPatch.getPlainAttrs().add(attrAddReplacePatch("show", "FALSE")); - groupTO = updateGroup(groupMod); + groupTO = updateGroup(groupPatch); assertEquals(modName, groupTO.getName()); assertEquals(2, groupTO.getPlainAttrs().size()); @@ -224,11 +227,13 @@ public class GroupITCase extends AbstractITCase { assertNotNull(groupTO); assertEquals(1, groupTO.getVirAttrs().size()); - final GroupMod groupMod = new GroupMod(); - groupMod.setKey(groupTO.getKey()); - groupMod.getVirAttrsToRemove().add("rvirtualdata"); + GroupPatch groupPatch = new GroupPatch(); + groupPatch.setKey(groupTO.getKey()); + groupPatch.getVirAttrs().add(new AttrPatch.Builder().operation(PatchOperation.DELETE). + attrTO(new AttrTO.Builder().schema("rvirtualdata").build()). + build()); - groupTO = updateGroup(groupMod); + groupTO = updateGroup(groupPatch); assertNotNull(groupTO); assertTrue(groupTO.getVirAttrs().isEmpty()); } @@ -243,11 +248,13 @@ public class GroupITCase extends AbstractITCase { assertNotNull(groupTO); assertEquals(1, groupTO.getDerAttrs().size()); - final GroupMod groupMod = new GroupMod(); - groupMod.setKey(groupTO.getKey()); - groupMod.getDerAttrsToRemove().add("rderivedschema"); + GroupPatch groupPatch = new GroupPatch(); + groupPatch.setKey(groupTO.getKey()); + groupPatch.getDerAttrs().add(new AttrPatch.Builder().operation(PatchOperation.DELETE). + attrTO(new AttrTO.Builder().schema("rderivedschema").build()). + build()); - groupTO = updateGroup(groupMod); + groupTO = updateGroup(groupPatch); assertNotNull(groupTO); assertTrue(groupTO.getDerAttrs().isEmpty()); } @@ -264,15 +271,15 @@ public class GroupITCase extends AbstractITCase { assertEquals("admin", groupTO.getLastModifier()); // 2. prepare update - GroupMod groupMod = new GroupMod(); - groupMod.setKey(groupTO.getKey()); - groupMod.setName("Director"); + GroupPatch groupPatch = new GroupPatch(); + groupPatch.setKey(groupTO.getKey()); + groupPatch.setName(new StringReplacePatchItem.Builder().value("Director").build()); // 3. try to update as verdi, not owner of group 6 - fail GroupService groupService2 = clientFactory.create("verdi", ADMIN_PWD).getService(GroupService.class); try { - groupService2.update(groupMod); + groupService2.update(groupPatch); fail(); } catch (SyncopeClientException e) { assertEquals(Response.Status.UNAUTHORIZED, e.getType().getResponseStatus()); @@ -283,7 +290,7 @@ public class GroupITCase extends AbstractITCase { // 4. update as puccini, owner of group 6 - success GroupService groupService3 = clientFactory.create("puccini", ADMIN_PWD).getService(GroupService.class); - groupTO = groupService3.update(groupMod).readEntity(GroupTO.class); + groupTO = groupService3.update(groupPatch).readEntity(GroupTO.class); assertEquals("Director", groupTO.getName()); // issue SYNCOPE-15 @@ -306,12 +313,12 @@ public class GroupITCase extends AbstractITCase { assertNotNull(actual); assertEquals(groupName, actual.getName()); - GroupMod groupMod = new GroupMod(); - groupMod.setKey(actual.getKey()); + GroupPatch groupPatch = new GroupPatch(); + groupPatch.setKey(actual.getKey()); String renamedGroup = "renamed" + getUUIDString(); - groupMod.setName(renamedGroup); + groupPatch.setName(new StringReplacePatchItem.Builder().value(renamedGroup).build()); - actual = updateGroup(groupMod); + actual = updateGroup(groupPatch); assertNotNull(actual); assertEquals(renamedGroup, actual.getName()); } @@ -323,10 +330,12 @@ public class GroupITCase extends AbstractITCase { assertNotNull(resourceService.readConnObject(RESOURCE_NAME_LDAP, AnyTypeKind.GROUP.name(), actual.getKey())); - assertNotNull(groupService.deassociate(actual.getKey(), - ResourceDeassociationActionType.UNLINK, - CollectionWrapper.wrap(RESOURCE_NAME_LDAP, ResourceKey.class)). - readEntity(BulkActionResult.class)); + DeassociationPatch deassociationPatch = new DeassociationPatch(); + deassociationPatch.setKey(actual.getKey()); + deassociationPatch.setAction(ResourceDeassociationAction.UNLINK); + deassociationPatch.getResources().add(RESOURCE_NAME_LDAP); + + assertNotNull(groupService.deassociate(deassociationPatch).readEntity(BulkActionResult.class)); actual = groupService.read(actual.getKey()); assertNotNull(actual); @@ -350,10 +359,12 @@ public class GroupITCase extends AbstractITCase { assertNotNull(e); } - ResourceAssociationMod associationMod = new ResourceAssociationMod(); - associationMod.getTargetResources().addAll(CollectionWrapper.wrap(RESOURCE_NAME_LDAP, ResourceKey.class)); - assertNotNull(groupService.associate(actual.getKey(), ResourceAssociationAction.LINK, associationMod). - readEntity(BulkActionResult.class)); + AssociationPatch associationPatch = new AssociationPatch(); + associationPatch.setKey(actual.getKey()); + associationPatch.setAction(ResourceAssociationAction.LINK); + associationPatch.getResources().add(RESOURCE_NAME_LDAP); + + assertNotNull(groupService.associate(associationPatch).readEntity(BulkActionResult.class)); actual = groupService.read(actual.getKey()); assertFalse(actual.getResources().isEmpty()); @@ -373,10 +384,12 @@ public class GroupITCase extends AbstractITCase { assertNotNull(resourceService.readConnObject(RESOURCE_NAME_LDAP, AnyTypeKind.GROUP.name(), actual.getKey())); - assertNotNull(groupService.deassociate(actual.getKey(), - ResourceDeassociationActionType.UNASSIGN, - CollectionWrapper.wrap(RESOURCE_NAME_LDAP, ResourceKey.class)). - readEntity(BulkActionResult.class)); + DeassociationPatch deassociationPatch = new DeassociationPatch(); + deassociationPatch.setKey(actual.getKey()); + deassociationPatch.setAction(ResourceDeassociationAction.UNASSIGN); + deassociationPatch.getResources().add(RESOURCE_NAME_LDAP); + + assertNotNull(groupService.deassociate(deassociationPatch).readEntity(BulkActionResult.class)); actual = groupService.read(actual.getKey()); assertNotNull(actual); @@ -405,11 +418,12 @@ public class GroupITCase extends AbstractITCase { assertNotNull(e); } - ResourceAssociationMod associationMod = new ResourceAssociationMod(); - associationMod.getTargetResources().addAll(CollectionWrapper.wrap(RESOURCE_NAME_LDAP, ResourceKey.class)); - assertNotNull(groupService.associate(actual.getKey(), - ResourceAssociationAction.ASSIGN, associationMod). - readEntity(BulkActionResult.class)); + AssociationPatch associationPatch = new AssociationPatch(); + associationPatch.setKey(actual.getKey()); + associationPatch.setAction(ResourceAssociationAction.ASSIGN); + associationPatch.getResources().add(RESOURCE_NAME_LDAP); + + assertNotNull(groupService.associate(associationPatch).readEntity(BulkActionResult.class)); actual = groupService.read(actual.getKey()); assertFalse(actual.getResources().isEmpty()); @@ -424,10 +438,12 @@ public class GroupITCase extends AbstractITCase { assertNotNull(resourceService.readConnObject(RESOURCE_NAME_LDAP, AnyTypeKind.GROUP.name(), actual.getKey())); - assertNotNull(groupService.deassociate(actual.getKey(), - ResourceDeassociationActionType.DEPROVISION, - CollectionWrapper.wrap(RESOURCE_NAME_LDAP, ResourceKey.class)). - readEntity(BulkActionResult.class)); + DeassociationPatch deassociationPatch = new DeassociationPatch(); + deassociationPatch.setKey(actual.getKey()); + deassociationPatch.setAction(ResourceDeassociationAction.DEPROVISION); + deassociationPatch.getResources().add(RESOURCE_NAME_LDAP); + + assertNotNull(groupService.deassociate(deassociationPatch).readEntity(BulkActionResult.class)); actual = groupService.read(actual.getKey()); assertNotNull(actual); @@ -456,11 +472,12 @@ public class GroupITCase extends AbstractITCase { assertNotNull(e); } - ResourceAssociationMod associationMod = new ResourceAssociationMod(); - associationMod.getTargetResources().addAll(CollectionWrapper.wrap(RESOURCE_NAME_LDAP, ResourceKey.class)); - assertNotNull(groupService.associate(actual.getKey(), - ResourceAssociationAction.PROVISION, associationMod). - readEntity(BulkActionResult.class)); + AssociationPatch associationPatch = new AssociationPatch(); + associationPatch.setKey(actual.getKey()); + associationPatch.setAction(ResourceAssociationAction.PROVISION); + associationPatch.getResources().add(RESOURCE_NAME_LDAP); + + assertNotNull(groupService.associate(associationPatch).readEntity(BulkActionResult.class)); actual = groupService.read(actual.getKey()); assertTrue(actual.getResources().isEmpty()); @@ -483,21 +500,24 @@ public class GroupITCase extends AbstractITCase { assertNotNull(e); } - ResourceAssociationMod associationMod = new ResourceAssociationMod(); - associationMod.getTargetResources().addAll(CollectionWrapper.wrap(RESOURCE_NAME_LDAP, ResourceKey.class)); - assertNotNull(groupService.associate(actual.getKey(), - ResourceAssociationAction.PROVISION, associationMod). - readEntity(BulkActionResult.class)); + AssociationPatch associationPatch = new AssociationPatch(); + associationPatch.setKey(actual.getKey()); + associationPatch.setAction(ResourceAssociationAction.PROVISION); + associationPatch.getResources().add(RESOURCE_NAME_LDAP); + + assertNotNull(groupService.associate(associationPatch).readEntity(BulkActionResult.class)); actual = groupService.read(actual.getKey()); assertTrue(actual.getResources().isEmpty()); assertNotNull(resourceService.readConnObject(RESOURCE_NAME_LDAP, AnyTypeKind.GROUP.name(), actual.getKey())); - assertNotNull(groupService.deassociate(actual.getKey(), - ResourceDeassociationActionType.DEPROVISION, - CollectionWrapper.wrap(RESOURCE_NAME_LDAP, ResourceKey.class)). - readEntity(BulkActionResult.class)); + DeassociationPatch deassociationPatch = new DeassociationPatch(); + deassociationPatch.setKey(actual.getKey()); + deassociationPatch.setAction(ResourceDeassociationAction.DEPROVISION); + deassociationPatch.getResources().add(RESOURCE_NAME_LDAP); + + assertNotNull(groupService.deassociate(deassociationPatch).readEntity(BulkActionResult.class)); actual = groupService.read(actual.getKey()); assertNotNull(actual); @@ -537,20 +557,20 @@ public class GroupITCase extends AbstractITCase { try { // 4. update group: failure since no values are provided and it is mandatory - GroupMod groupMod = new GroupMod(); - groupMod.setKey(groupTO.getKey()); + GroupPatch groupPatch = new GroupPatch(); + groupPatch.setKey(groupTO.getKey()); try { - updateGroup(groupMod); + updateGroup(groupPatch); fail(); } catch (SyncopeClientException e) { assertEquals(ClientExceptionType.RequiredValuesMissing, e.getType()); } // 5. also add an actual attribute for badge - it will work - groupMod.getPlainAttrsToUpdate().add(attrMod(badge.getKey(), "xxxxxxxxxx")); + groupPatch.getPlainAttrs().add(attrAddReplacePatch(badge.getKey(), "xxxxxxxxxx")); - groupTO = updateGroup(groupMod); + groupTO = updateGroup(groupPatch); assertNotNull(groupTO); assertTrue(groupTO.getPlainAttrMap().containsKey(badge.getKey())); } finally { @@ -594,11 +614,11 @@ public class GroupITCase extends AbstractITCase { group = getObject(response.getLocation(), GroupService.class, GroupTO.class); assertNotNull(group); - GroupMod groupMod = new GroupMod(); - groupMod.setKey(group.getKey()); - groupMod.getPlainAttrsToUpdate().add(attrMod("badge", "xxxxxxxxxx")); + GroupPatch groupPatch = new GroupPatch(); + groupPatch.setKey(group.getKey()); + groupPatch.getPlainAttrs().add(attrAddReplacePatch("badge", "xxxxxxxxxx")); - response = noContentService.update(groupMod); + response = noContentService.update(groupPatch); assertEquals(Response.Status.NO_CONTENT.getStatusCode(), response.getStatus()); assertEquals(Preference.RETURN_NO_CONTENT.toString(), response.getHeaderString(RESTHeaders.PREFERENCE_APPLIED)); assertEquals(StringUtils.EMPTY, IOUtils.toString((InputStream) response.getEntity())); @@ -647,12 +667,11 @@ public class GroupITCase extends AbstractITCase { assertNotNull(groupTO); // 3. update the group - GroupMod groupMod = new GroupMod(); - groupMod.setKey(groupTO.getKey()); - groupMod.getPlainAttrsToRemove().add("icon"); - groupMod.getPlainAttrsToUpdate().add(attrMod("icon", "anotherIcon")); + GroupPatch groupPatch = new GroupPatch(); + groupPatch.setKey(groupTO.getKey()); + groupPatch.getPlainAttrs().add(attrAddReplacePatch("icon", "anotherIcon")); - groupTO = updateGroup(groupMod); + groupTO = updateGroup(groupPatch); assertNotNull(groupTO); // 4. check that a single group exists in LDAP for the group created and updated above @@ -703,9 +722,9 @@ public class GroupITCase extends AbstractITCase { assertTrue(userService.read(4L).getDynGroups().contains(group.getKey())); - GroupMod mod = new GroupMod(); + GroupPatch mod = new GroupPatch(); mod.setKey(group.getKey()); - mod.setUDynMembershipCond("cool==false"); + mod.setUDynMembershipCond(new StringReplacePatchItem.Builder().value("cool==false").build()); groupService.update(mod); assertTrue(userService.read(4L).getDynGroups().isEmpty()); http://git-wip-us.apache.org/repos/asf/syncope/blob/9f73fa43/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/NotificationTaskITCase.java ---------------------------------------------------------------------- diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/NotificationTaskITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/NotificationTaskITCase.java index 02c4299..f494e85 100644 --- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/NotificationTaskITCase.java +++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/NotificationTaskITCase.java @@ -383,9 +383,7 @@ public class NotificationTaskITCase extends AbstractTaskITCase { // 2. create user UserTO userTO = UserITCase.getUniqueSampleTO(MAIL_ADDRESS); - MembershipTO membershipTO = new MembershipTO(); - membershipTO.setRightKey(7); - userTO.getMemberships().add(membershipTO); + userTO.getMemberships().add(new MembershipTO.Builder().group(7L).build()); userTO = createUser(userTO); assertNotNull(userTO); http://git-wip-us.apache.org/repos/asf/syncope/blob/9f73fa43/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/PlainSchemaITCase.java ---------------------------------------------------------------------- diff --git a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/PlainSchemaITCase.java b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/PlainSchemaITCase.java index feb041a..679288c 100644 --- a/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/PlainSchemaITCase.java +++ b/fit/core-reference/src/test/java/org/apache/syncope/fit/core/reference/PlainSchemaITCase.java @@ -29,9 +29,7 @@ import java.security.AccessControlException; import java.util.List; import javax.ws.rs.core.Response; import org.apache.commons.lang3.SerializationUtils; -import org.apache.syncope.common.lib.AnyOperations; import org.apache.syncope.common.lib.SyncopeClientException; -import org.apache.syncope.common.lib.mod.UserMod; import org.apache.syncope.common.lib.to.AnyTypeClassTO; import org.apache.syncope.common.lib.to.MembershipTO; import org.apache.syncope.common.lib.to.PlainSchemaTO; @@ -247,13 +245,9 @@ public class PlainSchemaITCase extends AbstractITCase { assertNotNull(userTO); UserTO newUserTO = SerializationUtils.clone(userTO); - MembershipTO membership = new MembershipTO(); - membership.setRightKey(2L); - newUserTO.getMemberships().add(membership); + newUserTO.getMemberships().add(new MembershipTO.Builder().group(2L).build()); - UserMod userMod = AnyOperations.diff(newUserTO, userTO); - - userTO = userService.update(userMod).readEntity(UserTO.class); + userTO = userService.update(newUserTO).readEntity(UserTO.class); assertNotNull(userTO); }
