You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by il...@apache.org on 2016/03/09 12:52:44 UTC
[08/17] syncope git commit: Further refactoring as per SYNCOPE-620
http://git-wip-us.apache.org/repos/asf/syncope/blob/28569df5/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/AbstractSyncResultHandler.java
----------------------------------------------------------------------
diff --git a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/AbstractSyncResultHandler.java b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/AbstractSyncResultHandler.java
deleted file mode 100644
index 2c5bbb9..0000000
--- a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/AbstractSyncResultHandler.java
+++ /dev/null
@@ -1,797 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.core.provisioning.java.sync;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import org.apache.commons.lang3.exception.ExceptionUtils;
-import org.apache.syncope.common.lib.patch.AnyPatch;
-import org.apache.syncope.common.lib.patch.StringPatchItem;
-import org.apache.syncope.common.lib.to.AnyTO;
-import org.apache.syncope.common.lib.types.AnyTypeKind;
-import org.apache.syncope.common.lib.types.AuditElements;
-import org.apache.syncope.common.lib.types.AuditElements.Result;
-import org.apache.syncope.common.lib.types.MatchingRule;
-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.common.lib.types.UnmatchingRule;
-import org.apache.syncope.core.persistence.api.dao.NotFoundException;
-import org.apache.syncope.core.persistence.api.entity.task.SyncTask;
-import org.apache.syncope.core.provisioning.api.propagation.PropagationException;
-import org.apache.syncope.core.provisioning.api.sync.SyncActions;
-import org.apache.syncope.core.misc.security.DelegatedAdministrationException;
-import org.apache.syncope.core.persistence.api.dao.VirSchemaDAO;
-import org.apache.syncope.core.persistence.api.entity.AnyUtils;
-import org.apache.syncope.core.persistence.api.entity.VirSchema;
-import org.apache.syncope.core.persistence.api.entity.resource.Provision;
-import org.apache.syncope.core.provisioning.api.ProvisioningManager;
-import org.apache.syncope.core.provisioning.api.cache.VirAttrCache;
-import org.apache.syncope.core.provisioning.api.cache.VirAttrCacheValue;
-import org.apache.syncope.core.provisioning.api.sync.IgnoreProvisionException;
-import org.apache.syncope.core.provisioning.api.sync.ProvisioningReport;
-import org.apache.syncope.core.provisioning.api.sync.SyncopeSyncResultHandler;
-import org.identityconnectors.framework.common.objects.Attribute;
-import org.identityconnectors.framework.common.objects.SyncDelta;
-import org.identityconnectors.framework.common.objects.SyncDeltaType;
-import org.quartz.JobExecutionException;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.transaction.annotation.Transactional;
-
-@Transactional(rollbackFor = Throwable.class)
-public abstract class AbstractSyncResultHandler extends AbstractSyncopeResultHandler<SyncTask, SyncActions>
- implements SyncopeSyncResultHandler {
-
- @Autowired
- protected SyncUtils syncUtilities;
-
- @Autowired
- protected VirSchemaDAO virSchemaDAO;
-
- @Autowired
- protected VirAttrCache virAttrCache;
-
- protected abstract String getName(AnyTO anyTO);
-
- protected abstract ProvisioningManager<?, ?> getProvisioningManager();
-
- protected abstract AnyTO doCreate(AnyTO anyTO, SyncDelta delta, ProvisioningReport result);
-
- protected AnyTO doLink(final AnyTO before, final boolean unlink) {
- AnyPatch patch = newPatch(before.getKey());
- patch.setKey(before.getKey());
- patch.getResources().add(new StringPatchItem.Builder().
- operation(unlink ? PatchOperation.DELETE : PatchOperation.ADD_REPLACE).
- value(profile.getTask().getResource().getKey()).build());
-
- return getAnyTO(update(patch).getResult());
- }
-
- protected abstract AnyTO doUpdate(AnyTO before, AnyPatch anyPatch, SyncDelta delta, ProvisioningReport result);
-
- protected void doDeprovision(final AnyTypeKind kind, final Long key, final boolean unlink) {
- PropagationByResource propByRes = new PropagationByResource();
- propByRes.add(ResourceOperation.DELETE, profile.getTask().getResource().getKey());
- taskExecutor.execute(propagationManager.getDeleteTasks(
- kind,
- key,
- propByRes,
- null));
-
- if (unlink) {
- AnyPatch anyObjectPatch = newPatch(key);
- anyObjectPatch.getResources().add(new StringPatchItem.Builder().
- operation(PatchOperation.DELETE).
- value(profile.getTask().getResource().getKey()).build());
- }
- }
-
- protected void doDelete(final AnyTypeKind kind, final Long key) {
- PropagationByResource propByRes = new PropagationByResource();
- propByRes.add(ResourceOperation.DELETE, profile.getTask().getResource().getKey());
- try {
- taskExecutor.execute(propagationManager.getDeleteTasks(
- kind,
- key,
- propByRes,
- null));
- } catch (Exception e) {
- // A propagation failure doesn't imply a synchronization failure.
- // The propagation exception status will be reported into the propagation task execution.
- LOG.error("Could not propagate anyObject " + key, e);
- }
-
- getProvisioningManager().delete(key, true);
- }
-
- @Override
- public boolean handle(final SyncDelta delta) {
- Provision provision = null;
- try {
- provision = profile.getTask().getResource().getProvision(delta.getObject().getObjectClass());
- if (provision == null) {
- throw new JobExecutionException("No provision found on " + profile.getTask().getResource() + " for "
- + delta.getObject().getObjectClass());
- }
-
- doHandle(delta, provision);
- return true;
- } catch (IgnoreProvisionException e) {
- ProvisioningReport result = new ProvisioningReport();
- result.setOperation(ResourceOperation.NONE);
- result.setAnyType(provision == null
- ? getAnyUtils().getAnyTypeKind().name() : provision.getAnyType().getKey());
- result.setStatus(ProvisioningReport.Status.IGNORE);
- result.setKey(0L);
- result.setName(delta.getObject().getName().getNameValue());
- profile.getResults().add(result);
-
- LOG.warn("Ignoring during synchronization", e);
- return true;
- } catch (JobExecutionException e) {
- LOG.error("Synchronization failed", e);
- return false;
- }
- }
-
- protected List<ProvisioningReport> assign(
- final SyncDelta delta, final Provision provision, final AnyUtils anyUtils)
- throws JobExecutionException {
-
- if (!profile.getTask().isPerformCreate()) {
- LOG.debug("SyncTask not configured for create");
- return Collections.<ProvisioningReport>emptyList();
- }
-
- AnyTO anyTO = connObjectUtils.getAnyTO(delta.getObject(), profile.getTask(), provision, anyUtils);
-
- anyTO.getResources().add(profile.getTask().getResource().getKey());
-
- ProvisioningReport result = new ProvisioningReport();
- result.setOperation(ResourceOperation.CREATE);
- result.setAnyType(provision.getAnyType().getKey());
- result.setStatus(ProvisioningReport.Status.SUCCESS);
- result.setName(getName(anyTO));
-
- if (profile.isDryRun()) {
- result.setKey(0L);
- } else {
- SyncDelta actionedDelta = delta;
- for (SyncActions action : profile.getActions()) {
- actionedDelta = action.beforeAssign(this.getProfile(), actionedDelta, anyTO);
- }
-
- create(anyTO, actionedDelta, UnmatchingRule.toEventName(UnmatchingRule.ASSIGN), result);
- }
-
- return Collections.singletonList(result);
- }
-
- protected List<ProvisioningReport> provision(
- final SyncDelta delta, final Provision provision, final AnyUtils anyUtils)
- throws JobExecutionException {
-
- if (!profile.getTask().isPerformCreate()) {
- LOG.debug("SyncTask not configured for create");
- return Collections.<ProvisioningReport>emptyList();
- }
-
- AnyTO anyTO = connObjectUtils.getAnyTO(delta.getObject(), profile.getTask(), provision, anyUtils);
-
- ProvisioningReport result = new ProvisioningReport();
- result.setOperation(ResourceOperation.CREATE);
- result.setAnyType(provision.getAnyType().getKey());
- result.setStatus(ProvisioningReport.Status.SUCCESS);
- result.setName(getName(anyTO));
-
- if (profile.isDryRun()) {
- result.setKey(0L);
- } else {
- SyncDelta actionedDelta = delta;
- for (SyncActions action : profile.getActions()) {
- actionedDelta = action.beforeProvision(this.getProfile(), actionedDelta, anyTO);
- }
-
- create(anyTO, actionedDelta, UnmatchingRule.toEventName(UnmatchingRule.PROVISION), result);
- }
-
- return Collections.singletonList(result);
- }
-
- private void create(
- final AnyTO anyTO,
- final SyncDelta delta,
- final String operation,
- final ProvisioningReport result)
- throws JobExecutionException {
-
- Object output;
- Result resultStatus;
-
- try {
- AnyTO actual = doCreate(anyTO, delta, result);
- result.setName(getName(actual));
- output = actual;
- resultStatus = Result.SUCCESS;
-
- for (SyncActions action : profile.getActions()) {
- action.after(this.getProfile(), delta, actual, result);
- }
- } catch (IgnoreProvisionException e) {
- throw e;
- } catch (PropagationException e) {
- // A propagation failure doesn't imply a synchronization failure.
- // The propagation exception status will be reported into the propagation task execution.
- LOG.error("Could not propagate {} {}", anyTO.getType(), delta.getUid().getUidValue(), e);
- output = e;
- resultStatus = Result.FAILURE;
-
- for (SyncActions action : profile.getActions()) {
- action.onError(this.getProfile(), delta, result, e);
- }
- } catch (Exception e) {
- result.setStatus(ProvisioningReport.Status.FAILURE);
- result.setMessage(ExceptionUtils.getRootCauseMessage(e));
- LOG.error("Could not create {} {} ", anyTO.getType(), delta.getUid().getUidValue(), e);
- output = e;
- resultStatus = Result.FAILURE;
-
- for (SyncActions action : profile.getActions()) {
- action.onError(this.getProfile(), delta, result, e);
- }
- }
-
- audit(operation, resultStatus, null, output, delta);
- }
-
- protected List<ProvisioningReport> update(final SyncDelta delta, final List<Long> anys,
- final Provision provision) throws JobExecutionException {
-
- if (!profile.getTask().isPerformUpdate()) {
- LOG.debug("SyncTask not configured for update");
- return Collections.<ProvisioningReport>emptyList();
- }
-
- LOG.debug("About to update {}", anys);
-
- List<ProvisioningReport> results = new ArrayList<>();
-
- SyncDelta workingDelta = delta;
- for (Long key : anys) {
- LOG.debug("About to update {}", key);
-
- ProvisioningReport result = new ProvisioningReport();
- result.setOperation(ResourceOperation.UPDATE);
- result.setAnyType(provision.getAnyType().getKey());
- result.setStatus(ProvisioningReport.Status.SUCCESS);
- result.setKey(key);
-
- AnyTO before = getAnyTO(key);
- if (before == null) {
- result.setStatus(ProvisioningReport.Status.FAILURE);
- result.setMessage(String.format("Any '%s(%d)' not found", provision.getAnyType().getKey(), key));
- } else {
- result.setName(getName(before));
- }
-
- Result resultStatus;
- Object output;
- if (!profile.isDryRun()) {
- if (before == null) {
- resultStatus = Result.FAILURE;
- output = null;
- } else {
- try {
- AnyPatch anyPatch = connObjectUtils.getAnyPatch(
- before.getKey(),
- workingDelta.getObject(),
- before,
- profile.getTask(),
- provision,
- getAnyUtils());
-
- for (SyncActions action : profile.getActions()) {
- workingDelta = action.beforeUpdate(this.getProfile(), workingDelta, before, anyPatch);
- }
-
- AnyTO updated = doUpdate(before, anyPatch, workingDelta, result);
-
- for (SyncActions action : profile.getActions()) {
- action.after(this.getProfile(), workingDelta, updated, result);
- }
-
- output = updated;
- resultStatus = Result.SUCCESS;
- result.setName(getName(updated));
- LOG.debug("{} {} successfully updated", provision.getAnyType().getKey(), key);
- } catch (IgnoreProvisionException e) {
- throw e;
- } catch (PropagationException e) {
- // A propagation failure doesn't imply a synchronization failure.
- // The propagation exception status will be reported into the propagation task execution.
- LOG.error("Could not propagate {} {}",
- provision.getAnyType().getKey(), workingDelta.getUid().getUidValue(), e);
- output = e;
- resultStatus = Result.FAILURE;
-
- for (SyncActions action : profile.getActions()) {
- action.onError(this.getProfile(), workingDelta, result, e);
- }
- } catch (Exception e) {
- result.setStatus(ProvisioningReport.Status.FAILURE);
- result.setMessage(ExceptionUtils.getRootCauseMessage(e));
- LOG.error("Could not update {} {}",
- provision.getAnyType().getKey(), workingDelta.getUid().getUidValue(), e);
- output = e;
- resultStatus = Result.FAILURE;
-
- for (SyncActions action : profile.getActions()) {
- action.onError(this.getProfile(), workingDelta, result, e);
- }
- }
- }
- audit(MatchingRule.toEventName(MatchingRule.UPDATE), resultStatus, before, output, workingDelta);
- }
- results.add(result);
- }
- return results;
- }
-
- protected List<ProvisioningReport> deprovision(
- final SyncDelta delta,
- final List<Long> anys,
- final Provision provision,
- final boolean unlink)
- throws JobExecutionException {
-
- if (!profile.getTask().isPerformUpdate()) {
- LOG.debug("SyncTask not configured for update");
- return Collections.<ProvisioningReport>emptyList();
- }
-
- LOG.debug("About to update {}", anys);
-
- final List<ProvisioningReport> updResults = new ArrayList<>();
-
- for (Long key : anys) {
- LOG.debug("About to unassign resource {}", key);
-
- Object output;
- Result resultStatus;
-
- ProvisioningReport result = new ProvisioningReport();
- result.setOperation(ResourceOperation.DELETE);
- result.setAnyType(provision.getAnyType().getKey());
- result.setStatus(ProvisioningReport.Status.SUCCESS);
- result.setKey(key);
-
- AnyTO before = getAnyTO(key);
-
- if (before == null) {
- result.setStatus(ProvisioningReport.Status.FAILURE);
- result.setMessage(String.format("Any '%s(%d)' not found", provision.getAnyType().getKey(), key));
- }
-
- if (!profile.isDryRun()) {
- if (before == null) {
- resultStatus = Result.FAILURE;
- output = null;
- } else {
- result.setName(getName(before));
-
- try {
- if (unlink) {
- for (SyncActions action : profile.getActions()) {
- action.beforeUnassign(this.getProfile(), delta, before);
- }
- } else {
- for (SyncActions action : profile.getActions()) {
- action.beforeDeprovision(this.getProfile(), delta, before);
- }
- }
-
- doDeprovision(provision.getAnyType().getKind(), key, unlink);
- output = getAnyTO(key);
-
- for (SyncActions action : profile.getActions()) {
- action.after(this.getProfile(), delta, AnyTO.class.cast(output), result);
- }
-
- resultStatus = Result.SUCCESS;
- LOG.debug("{} {} successfully updated", provision.getAnyType().getKey(), key);
- } catch (IgnoreProvisionException e) {
- throw e;
- } catch (PropagationException e) {
- // A propagation failure doesn't imply a synchronization failure.
- // The propagation exception status will be reported into the propagation task execution.
- LOG.error("Could not propagate {} {}",
- provision.getAnyType().getKey(), delta.getUid().getUidValue(), e);
- output = e;
- resultStatus = Result.FAILURE;
-
- for (SyncActions action : profile.getActions()) {
- action.onError(this.getProfile(), delta, result, e);
- }
- } catch (Exception e) {
- result.setStatus(ProvisioningReport.Status.FAILURE);
- result.setMessage(ExceptionUtils.getRootCauseMessage(e));
- LOG.error("Could not update {} {}",
- provision.getAnyType().getKey(), delta.getUid().getUidValue(), e);
- output = e;
- resultStatus = Result.FAILURE;
-
- for (SyncActions action : profile.getActions()) {
- action.onError(this.getProfile(), delta, result, e);
- }
- }
- }
- audit(unlink
- ? MatchingRule.toEventName(MatchingRule.UNASSIGN)
- : MatchingRule.toEventName(MatchingRule.DEPROVISION), resultStatus, before, output, delta);
- }
- updResults.add(result);
- }
-
- return updResults;
- }
-
- protected List<ProvisioningReport> link(
- final SyncDelta delta,
- final List<Long> anys,
- final Provision provision,
- final boolean unlink)
- throws JobExecutionException {
-
- if (!profile.getTask().isPerformUpdate()) {
- LOG.debug("SyncTask not configured for update");
- return Collections.<ProvisioningReport>emptyList();
- }
-
- LOG.debug("About to update {}", anys);
-
- final List<ProvisioningReport> updResults = new ArrayList<>();
-
- for (Long key : anys) {
- LOG.debug("About to unassign resource {}", key);
-
- Object output;
- Result resultStatus;
-
- ProvisioningReport result = new ProvisioningReport();
- result.setOperation(ResourceOperation.NONE);
- result.setAnyType(provision.getAnyType().getKey());
- result.setStatus(ProvisioningReport.Status.SUCCESS);
- result.setKey(key);
-
- AnyTO before = getAnyTO(key);
-
- if (before == null) {
- result.setStatus(ProvisioningReport.Status.FAILURE);
- result.setMessage(String.format("Any '%s(%d)' not found", provision.getAnyType().getKey(), key));
- }
-
- if (!profile.isDryRun()) {
- if (before == null) {
- resultStatus = Result.FAILURE;
- output = null;
- } else {
- result.setName(getName(before));
-
- try {
- if (unlink) {
- for (SyncActions action : profile.getActions()) {
- action.beforeUnlink(this.getProfile(), delta, before);
- }
- } else {
- for (SyncActions action : profile.getActions()) {
- action.beforeLink(this.getProfile(), delta, before);
- }
- }
-
- output = doLink(before, unlink);
-
- for (SyncActions action : profile.getActions()) {
- action.after(this.getProfile(), delta, AnyTO.class.cast(output), result);
- }
-
- resultStatus = Result.SUCCESS;
- LOG.debug("{} {} successfully updated", provision.getAnyType().getKey(), key);
- } catch (IgnoreProvisionException e) {
- throw e;
- } catch (PropagationException e) {
- // A propagation failure doesn't imply a synchronization failure.
- // The propagation exception status will be reported into the propagation task execution.
- LOG.error("Could not propagate {} {}",
- provision.getAnyType().getKey(), delta.getUid().getUidValue(), e);
- output = e;
- resultStatus = Result.FAILURE;
-
- for (SyncActions action : profile.getActions()) {
- action.onError(this.getProfile(), delta, result, e);
- }
- } catch (Exception e) {
- result.setStatus(ProvisioningReport.Status.FAILURE);
- result.setMessage(ExceptionUtils.getRootCauseMessage(e));
- LOG.error("Could not update {} {}",
- provision.getAnyType().getKey(), delta.getUid().getUidValue(), e);
- output = e;
- resultStatus = Result.FAILURE;
-
- for (SyncActions action : profile.getActions()) {
- action.onError(this.getProfile(), delta, result, e);
- }
- }
- }
- audit(unlink ? MatchingRule.toEventName(MatchingRule.UNLINK)
- : MatchingRule.toEventName(MatchingRule.LINK), resultStatus, before, output, delta);
- }
- updResults.add(result);
- }
-
- return updResults;
- }
-
- protected List<ProvisioningReport> delete(
- final SyncDelta delta,
- final List<Long> anys,
- final Provision provision)
- throws JobExecutionException {
-
- if (!profile.getTask().isPerformDelete()) {
- LOG.debug("SyncTask not configured for delete");
- return Collections.<ProvisioningReport>emptyList();
- }
-
- LOG.debug("About to delete {}", anys);
-
- List<ProvisioningReport> delResults = new ArrayList<>();
-
- SyncDelta workingDelta = delta;
- for (Long key : anys) {
- Object output;
- Result resultStatus = Result.FAILURE;
-
- ProvisioningReport result = new ProvisioningReport();
-
- try {
- AnyTO before = getAnyTO(key);
-
- result.setKey(key);
- result.setName(getName(before));
- result.setOperation(ResourceOperation.DELETE);
- result.setAnyType(provision.getAnyType().getKey());
- result.setStatus(ProvisioningReport.Status.SUCCESS);
-
- if (!profile.isDryRun()) {
- for (SyncActions action : profile.getActions()) {
- workingDelta = action.beforeDelete(this.getProfile(), workingDelta, before);
- }
-
- try {
- doDelete(provision.getAnyType().getKind(), key);
- output = null;
- resultStatus = Result.SUCCESS;
-
- for (SyncActions action : profile.getActions()) {
- action.after(this.getProfile(), workingDelta, before, result);
- }
- } catch (IgnoreProvisionException e) {
- throw e;
- } catch (Exception e) {
- result.setStatus(ProvisioningReport.Status.FAILURE);
- result.setMessage(ExceptionUtils.getRootCauseMessage(e));
- LOG.error("Could not delete {} {}", provision.getAnyType().getKey(), key, e);
- output = e;
-
- for (SyncActions action : profile.getActions()) {
- action.onError(this.getProfile(), workingDelta, result, e);
- }
- }
-
- audit(ResourceOperation.DELETE.name().toLowerCase(), resultStatus, before, output, workingDelta);
- }
-
- delResults.add(result);
- } catch (NotFoundException e) {
- LOG.error("Could not find {} {}", provision.getAnyType().getKey(), key, e);
- } catch (DelegatedAdministrationException e) {
- LOG.error("Not allowed to read {} {}", provision.getAnyType().getKey(), key, e);
- } catch (Exception e) {
- LOG.error("Could not delete {} {}", provision.getAnyType().getKey(), key, e);
- }
- }
-
- return delResults;
- }
-
- private List<ProvisioningReport> ignore(
- final SyncDelta delta,
- final Provision provision,
- final boolean matching)
- throws JobExecutionException {
-
- LOG.debug("Any to ignore {}", delta.getObject().getUid().getUidValue());
-
- final List<ProvisioningReport> ignoreResults = new ArrayList<>();
- ProvisioningReport result = new ProvisioningReport();
-
- result.setKey(null);
- result.setName(delta.getObject().getUid().getUidValue());
- result.setOperation(ResourceOperation.NONE);
- result.setAnyType(provision.getAnyType().getKey());
- result.setStatus(ProvisioningReport.Status.SUCCESS);
- ignoreResults.add(result);
-
- if (!profile.isDryRun()) {
- audit(matching
- ? MatchingRule.toEventName(MatchingRule.IGNORE)
- : UnmatchingRule.toEventName(UnmatchingRule.IGNORE), Result.SUCCESS, null, null, delta);
- }
-
- return ignoreResults;
- }
-
- /**
- * Look into SyncDelta and take necessary profile.getActions() (create / update / delete) on any object(s).
- *
- * @param delta returned by the underlying profile.getConnector()
- * @param provision provisioning info
- * @throws JobExecutionException in case of synchronization failure.
- */
- protected void doHandle(final SyncDelta delta, final Provision provision) throws JobExecutionException {
- AnyUtils anyUtils = getAnyUtils();
-
- LOG.debug("Process {} for {} as {}",
- delta.getDeltaType(), delta.getUid().getUidValue(), delta.getObject().getObjectClass());
-
- String uid = delta.getPreviousUid() == null
- ? delta.getUid().getUidValue()
- : delta.getPreviousUid().getUidValue();
-
- try {
- List<Long> anyKeys = syncUtilities.findExisting(uid, delta.getObject(), provision, anyUtils);
- LOG.debug("Match(es) found for {} as {}: {}",
- delta.getUid().getUidValue(), delta.getObject().getObjectClass(), anyKeys);
-
- if (anyKeys.size() > 1) {
- switch (profile.getResAct()) {
- case IGNORE:
- throw new IllegalStateException("More than one match " + anyKeys);
-
- case FIRSTMATCH:
- anyKeys = anyKeys.subList(0, 1);
- break;
-
- case LASTMATCH:
- anyKeys = anyKeys.subList(anyKeys.size() - 1, anyKeys.size());
- break;
-
- default:
- // keep anyKeys unmodified
- }
- }
-
- if (SyncDeltaType.CREATE_OR_UPDATE == delta.getDeltaType()) {
- if (anyKeys.isEmpty()) {
- switch (profile.getTask().getUnmatchingRule()) {
- case ASSIGN:
- profile.getResults().addAll(assign(delta, provision, anyUtils));
- break;
-
- case PROVISION:
- profile.getResults().addAll(provision(delta, provision, anyUtils));
- break;
-
- case IGNORE:
- profile.getResults().addAll(ignore(delta, provision, false));
- break;
-
- default:
- // do nothing
- }
- } else {
- // update VirAttrCache
- for (VirSchema virSchema : virSchemaDAO.findByProvision(provision)) {
- Attribute attr = delta.getObject().getAttributeByName(virSchema.getExtAttrName());
- for (Long anyKey : anyKeys) {
- if (attr == null) {
- virAttrCache.expire(
- provision.getAnyType().getKey(),
- anyKey,
- virSchema.getKey());
- } else {
- VirAttrCacheValue cacheValue = new VirAttrCacheValue();
- cacheValue.setValues(attr.getValue());
- virAttrCache.put(
- provision.getAnyType().getKey(),
- anyKey,
- virSchema.getKey(),
- cacheValue);
- }
- }
- }
-
- switch (profile.getTask().getMatchingRule()) {
- case UPDATE:
- profile.getResults().addAll(update(delta, anyKeys, provision));
- break;
-
- case DEPROVISION:
- profile.getResults().addAll(deprovision(delta, anyKeys, provision, false));
- break;
-
- case UNASSIGN:
- profile.getResults().addAll(deprovision(delta, anyKeys, provision, true));
- break;
-
- case LINK:
- profile.getResults().addAll(link(delta, anyKeys, provision, false));
- break;
-
- case UNLINK:
- profile.getResults().addAll(link(delta, anyKeys, provision, true));
- break;
-
- case IGNORE:
- profile.getResults().addAll(ignore(delta, provision, true));
- break;
-
- default:
- // do nothing
- }
- }
- } else if (SyncDeltaType.DELETE == delta.getDeltaType()) {
- if (anyKeys.isEmpty()) {
- LOG.debug("No match found for deletion");
- } else {
- profile.getResults().addAll(delete(delta, anyKeys, provision));
- }
- }
- } catch (IllegalStateException | IllegalArgumentException e) {
- LOG.warn(e.getMessage());
- }
- }
-
- private void audit(
- final String event,
- final Result result,
- final Object before,
- final Object output,
- final Object... input) {
-
- notificationManager.createTasks(AuditElements.EventCategoryType.SYNCHRONIZATION,
- getAnyUtils().getAnyTypeKind().name().toLowerCase(),
- profile.getTask().getResource().getKey(),
- event,
- result,
- before,
- output,
- input);
-
- auditManager.audit(AuditElements.EventCategoryType.SYNCHRONIZATION,
- getAnyUtils().getAnyTypeKind().name().toLowerCase(),
- profile.getTask().getResource().getKey(),
- event,
- result,
- before,
- output,
- input);
- }
-}
http://git-wip-us.apache.org/repos/asf/syncope/blob/28569df5/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/AbstractSyncopeResultHandler.java
----------------------------------------------------------------------
diff --git a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/AbstractSyncopeResultHandler.java b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/AbstractSyncopeResultHandler.java
deleted file mode 100644
index 4e6f2eb..0000000
--- a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/AbstractSyncopeResultHandler.java
+++ /dev/null
@@ -1,155 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.core.provisioning.java.sync;
-
-import org.apache.syncope.common.lib.patch.AnyPatch;
-import org.apache.syncope.common.lib.to.AnyTO;
-import org.apache.syncope.core.persistence.api.dao.GroupDAO;
-import org.apache.syncope.core.persistence.api.dao.UserDAO;
-import org.apache.syncope.core.persistence.api.entity.task.ProvisioningTask;
-import org.apache.syncope.core.provisioning.api.GroupProvisioningManager;
-import org.apache.syncope.core.provisioning.api.data.GroupDataBinder;
-import org.apache.syncope.core.provisioning.api.UserProvisioningManager;
-import org.apache.syncope.core.provisioning.api.data.UserDataBinder;
-import org.apache.syncope.core.provisioning.api.propagation.PropagationManager;
-import org.apache.syncope.core.provisioning.api.propagation.PropagationTaskExecutor;
-import org.apache.syncope.core.provisioning.api.sync.ProvisioningProfile;
-import org.apache.syncope.core.provisioning.api.sync.SyncopeResultHandler;
-import org.apache.syncope.core.misc.AuditManager;
-import org.apache.syncope.core.misc.utils.ConnObjectUtils;
-import org.apache.syncope.core.persistence.api.dao.AnyObjectDAO;
-import org.apache.syncope.core.persistence.api.entity.Any;
-import org.apache.syncope.core.persistence.api.entity.AnyUtils;
-import org.apache.syncope.core.persistence.api.entity.AnyUtilsFactory;
-import org.apache.syncope.core.provisioning.api.AnyObjectProvisioningManager;
-import org.apache.syncope.core.provisioning.api.WorkflowResult;
-import org.apache.syncope.core.provisioning.api.data.AnyObjectDataBinder;
-import org.apache.syncope.core.provisioning.api.notification.NotificationManager;
-import org.apache.syncope.core.provisioning.api.sync.ProvisioningActions;
-import org.apache.syncope.core.workflow.api.AnyObjectWorkflowAdapter;
-import org.apache.syncope.core.workflow.api.GroupWorkflowAdapter;
-import org.apache.syncope.core.workflow.api.UserWorkflowAdapter;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-
-public abstract class AbstractSyncopeResultHandler<T extends ProvisioningTask, A extends ProvisioningActions>
- implements SyncopeResultHandler<T, A> {
-
- protected static final Logger LOG = LoggerFactory.getLogger(SyncopeResultHandler.class);
-
- @Autowired
- protected AnyObjectDAO anyObjectDAO;
-
- @Autowired
- protected UserDAO userDAO;
-
- @Autowired
- protected GroupDAO groupDAO;
-
- /**
- * ConnectorObject utils.
- */
- @Autowired
- protected ConnObjectUtils connObjectUtils;
-
- /**
- * Notification Manager.
- */
- @Autowired
- protected NotificationManager notificationManager;
-
- /**
- * Audit Manager.
- */
- @Autowired
- protected AuditManager auditManager;
-
- /**
- * Propagation manager.
- */
- @Autowired
- protected PropagationManager propagationManager;
-
- /**
- * Task executor.
- */
- @Autowired
- protected PropagationTaskExecutor taskExecutor;
-
- protected AnyObjectWorkflowAdapter awfAdapter;
-
- /**
- * User workflow adapter.
- */
- @Autowired
- protected UserWorkflowAdapter uwfAdapter;
-
- /**
- * Group workflow adapter.
- */
- @Autowired
- protected GroupWorkflowAdapter gwfAdapter;
-
- @Autowired
- protected AnyObjectDataBinder anyObjectDataBinder;
-
- @Autowired
- protected UserDataBinder userDataBinder;
-
- @Autowired
- protected GroupDataBinder groupDataBinder;
-
- @Autowired
- protected AnyObjectProvisioningManager anyObjectProvisioningManager;
-
- @Autowired
- protected UserProvisioningManager userProvisioningManager;
-
- @Autowired
- protected GroupProvisioningManager groupProvisioningManager;
-
- @Autowired
- protected AnyUtilsFactory anyUtilsFactory;
-
- /**
- * Sync profile.
- */
- protected ProvisioningProfile<T, A> profile;
-
- protected abstract AnyUtils getAnyUtils();
-
- protected abstract AnyTO getAnyTO(long key);
-
- protected abstract Any<?> getAny(long key);
-
- protected abstract AnyPatch newPatch(final long key);
-
- protected abstract WorkflowResult<Long> update(AnyPatch patch);
-
- @Override
- public void setProfile(final ProvisioningProfile<T, A> profile) {
- this.profile = profile;
- }
-
- @Override
- public ProvisioningProfile<T, A> getProfile() {
- return profile;
- }
-}
http://git-wip-us.apache.org/repos/asf/syncope/blob/28569df5/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/AnyObjectPushResultHandlerImpl.java
----------------------------------------------------------------------
diff --git a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/AnyObjectPushResultHandlerImpl.java b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/AnyObjectPushResultHandlerImpl.java
deleted file mode 100644
index f9546cc..0000000
--- a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/AnyObjectPushResultHandlerImpl.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.core.provisioning.java.sync;
-
-import org.apache.commons.lang3.StringUtils;
-import org.apache.syncope.common.lib.patch.AnyObjectPatch;
-import org.apache.syncope.common.lib.patch.AnyPatch;
-import org.apache.syncope.common.lib.to.AnyTO;
-import org.apache.syncope.common.lib.types.AnyTypeKind;
-import org.apache.syncope.core.persistence.api.entity.Any;
-import org.apache.syncope.core.persistence.api.entity.AnyUtils;
-import org.apache.syncope.core.provisioning.api.WorkflowResult;
-import org.apache.syncope.core.provisioning.api.sync.AnyObjectPushResultHandler;
-
-public class AnyObjectPushResultHandlerImpl extends AbstractPushResultHandler implements AnyObjectPushResultHandler {
-
- @Override
- protected AnyUtils getAnyUtils() {
- return anyUtilsFactory.getInstance(AnyTypeKind.ANY_OBJECT);
- }
-
- @Override
- protected String getName(final Any<?> any) {
- return StringUtils.EMPTY;
- }
-
- @Override
- protected Any<?> getAny(final long key) {
- try {
- return anyObjectDAO.authFind(key);
- } catch (Exception e) {
- LOG.warn("Error retrieving anyObject {}", key, e);
- return null;
- }
- }
-
- @Override
- protected AnyTO getAnyTO(final long key) {
- return anyObjectDataBinder.getAnyObjectTO(key);
- }
-
- @Override
- protected AnyPatch newPatch(final long key) {
- AnyObjectPatch patch = new AnyObjectPatch();
- patch.setKey(key);
- return patch;
- }
-
- @Override
- protected WorkflowResult<Long> update(final AnyPatch patch) {
- return awfAdapter.update((AnyObjectPatch) patch);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/syncope/blob/28569df5/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/AnyObjectSyncResultHandlerImpl.java
----------------------------------------------------------------------
diff --git a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/AnyObjectSyncResultHandlerImpl.java b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/AnyObjectSyncResultHandlerImpl.java
deleted file mode 100644
index d194a25..0000000
--- a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/AnyObjectSyncResultHandlerImpl.java
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.core.provisioning.java.sync;
-
-import java.util.Collections;
-import java.util.List;
-import java.util.Map;
-import org.apache.commons.lang3.StringUtils;
-import org.apache.syncope.common.lib.patch.AnyObjectPatch;
-import org.apache.syncope.common.lib.patch.AnyPatch;
-import org.apache.syncope.common.lib.to.AnyTO;
-import org.apache.syncope.common.lib.to.PropagationStatus;
-import org.apache.syncope.common.lib.to.AnyObjectTO;
-import org.apache.syncope.common.lib.types.AnyTypeKind;
-import org.apache.syncope.core.persistence.api.entity.Any;
-import org.apache.syncope.core.persistence.api.entity.AnyUtils;
-import org.apache.syncope.core.provisioning.api.ProvisioningManager;
-import org.apache.syncope.core.provisioning.api.WorkflowResult;
-import org.apache.syncope.core.provisioning.api.sync.ProvisioningReport;
-import org.apache.syncope.core.provisioning.api.sync.AnyObjectSyncResultHandler;
-import org.identityconnectors.framework.common.objects.SyncDelta;
-
-public class AnyObjectSyncResultHandlerImpl extends AbstractSyncResultHandler implements AnyObjectSyncResultHandler {
-
- @Override
- protected AnyUtils getAnyUtils() {
- return anyUtilsFactory.getInstance(AnyTypeKind.ANY_OBJECT);
- }
-
- @Override
- protected String getName(final AnyTO anyTO) {
- return StringUtils.EMPTY;
- }
-
- @Override
- protected ProvisioningManager<?, ?> getProvisioningManager() {
- return anyObjectProvisioningManager;
- }
-
- @Override
- protected Any<?> getAny(final long key) {
- try {
- return anyObjectDAO.authFind(key);
- } catch (Exception e) {
- LOG.warn("Error retrieving anyObject {}", key, e);
- return null;
- }
- }
-
- @Override
- protected AnyTO getAnyTO(final long key) {
- return anyObjectDataBinder.getAnyObjectTO(key);
- }
-
- @Override
- protected AnyPatch newPatch(final long key) {
- AnyObjectPatch patch = new AnyObjectPatch();
- patch.setKey(key);
- return patch;
- }
-
- @Override
- protected WorkflowResult<Long> update(final AnyPatch patch) {
- return awfAdapter.update((AnyObjectPatch) patch);
- }
-
- @Override
- protected AnyTO doCreate(final AnyTO anyTO, final SyncDelta delta, final ProvisioningReport result) {
- AnyObjectTO anyObjectTO = AnyObjectTO.class.cast(anyTO);
-
- Map.Entry<Long, List<PropagationStatus>> created = anyObjectProvisioningManager.create(
- anyObjectTO, Collections.singleton(profile.getTask().getResource().getKey()), true);
-
- result.setKey(created.getKey());
- result.setName(getName(anyTO));
-
- return getAnyTO(created.getKey());
- }
-
- @Override
- protected AnyTO doUpdate(
- final AnyTO before,
- final AnyPatch anyPatch,
- final SyncDelta delta,
- final ProvisioningReport result) {
-
- AnyObjectPatch anyObjectPatch = AnyObjectPatch.class.cast(anyPatch);
-
- Map.Entry<Long, List<PropagationStatus>> updated =
- anyObjectProvisioningManager.update(anyObjectPatch, true);
-
- AnyObjectTO after = anyObjectDataBinder.getAnyObjectTO(updated.getKey());
- result.setName(getName(after));
- return after;
- }
-}
http://git-wip-us.apache.org/repos/asf/syncope/blob/28569df5/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/DBPasswordSyncActions.java
----------------------------------------------------------------------
diff --git a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/DBPasswordSyncActions.java b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/DBPasswordSyncActions.java
deleted file mode 100644
index 6e8af59..0000000
--- a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/DBPasswordSyncActions.java
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.core.provisioning.java.sync;
-
-import org.apache.commons.collections4.IterableUtils;
-import org.apache.commons.collections4.Predicate;
-import org.apache.syncope.common.lib.patch.AnyPatch;
-import org.apache.syncope.common.lib.patch.PasswordPatch;
-import org.apache.syncope.common.lib.patch.UserPatch;
-import org.apache.syncope.common.lib.to.AnyTO;
-import org.apache.syncope.common.lib.to.UserTO;
-import org.apache.syncope.common.lib.types.CipherAlgorithm;
-import org.apache.syncope.common.lib.types.ConnConfProperty;
-import org.apache.syncope.core.persistence.api.dao.UserDAO;
-import org.apache.syncope.core.persistence.api.entity.ConnInstance;
-import org.apache.syncope.core.persistence.api.entity.user.User;
-import org.apache.syncope.core.provisioning.api.Connector;
-import org.apache.syncope.core.provisioning.api.sync.ProvisioningProfile;
-import org.apache.syncope.core.provisioning.api.sync.ProvisioningReport;
-import org.identityconnectors.framework.common.objects.SyncDelta;
-import org.quartz.JobExecutionException;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.transaction.annotation.Transactional;
-
-/**
- * A SyncActions implementation which allows the ability to import passwords from a Database
- * backend, where the passwords are hashed according to the password cipher algorithm property
- * of the (DB) Connector and HEX-encoded.
- */
-public class DBPasswordSyncActions extends DefaultSyncActions {
-
- private static final Logger LOG = LoggerFactory.getLogger(DBPasswordSyncActions.class);
-
- private static final String CLEARTEXT = "CLEARTEXT";
-
- @Autowired
- private UserDAO userDAO;
-
- private String encodedPassword;
-
- private CipherAlgorithm cipher;
-
- @Transactional(readOnly = true)
- @Override
- public <A extends AnyTO> SyncDelta beforeProvision(
- final ProvisioningProfile<?, ?> profile,
- final SyncDelta delta,
- final A any) throws JobExecutionException {
-
- if (any instanceof UserTO) {
- String password = ((UserTO) any).getPassword();
- parseEncodedPassword(password, profile.getConnector());
- }
-
- return delta;
- }
-
- @Transactional(readOnly = true)
- @Override
- public <A extends AnyTO, M extends AnyPatch> SyncDelta beforeUpdate(
- final ProvisioningProfile<?, ?> profile,
- final SyncDelta delta,
- final A any,
- final M anyPatch) throws JobExecutionException {
-
- if (anyPatch instanceof UserPatch) {
- PasswordPatch modPassword = ((UserPatch) anyPatch).getPassword();
- parseEncodedPassword(modPassword == null ? null : modPassword.getValue(), profile.getConnector());
- }
-
- return delta;
- }
-
- private void parseEncodedPassword(final String password, final Connector connector) {
- if (password != null) {
- ConnInstance connInstance = connector.getConnInstance();
-
- String cipherAlgorithm = getCipherAlgorithm(connInstance);
- if (!CLEARTEXT.equals(cipherAlgorithm)) {
- try {
- encodedPassword = password;
- cipher = CipherAlgorithm.valueOf(cipherAlgorithm);
- } catch (IllegalArgumentException e) {
- LOG.error("Cipher algorithm not allowed: {}", cipherAlgorithm, e);
- encodedPassword = null;
- }
- }
- }
- }
-
- private String getCipherAlgorithm(final ConnInstance connInstance) {
- ConnConfProperty cipherAlgorithm =
- IterableUtils.find(connInstance.getConf(), new Predicate<ConnConfProperty>() {
-
- @Override
- public boolean evaluate(final ConnConfProperty property) {
- return "cipherAlgorithm".equals(property.getSchema().getName())
- && property.getValues() != null && !property.getValues().isEmpty();
- }
- });
-
- return cipherAlgorithm == null
- ? CLEARTEXT
- : (String) cipherAlgorithm.getValues().get(0);
- }
-
- @Transactional(readOnly = true)
- @Override
- public <A extends AnyTO> void after(
- final ProvisioningProfile<?, ?> profile,
- final SyncDelta delta,
- final A any,
- final ProvisioningReport result) throws JobExecutionException {
-
- if (any instanceof UserTO && encodedPassword != null && cipher != null) {
- User syncopeUser = userDAO.find(any.getKey());
- if (syncopeUser != null) {
- syncopeUser.setEncodedPassword(encodedPassword.toUpperCase(), cipher);
- }
- encodedPassword = null;
- cipher = null;
- }
- }
-}
http://git-wip-us.apache.org/repos/asf/syncope/blob/28569df5/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/DefaultPushActions.java
----------------------------------------------------------------------
diff --git a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/DefaultPushActions.java b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/DefaultPushActions.java
deleted file mode 100644
index a005493..0000000
--- a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/DefaultPushActions.java
+++ /dev/null
@@ -1,100 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.core.provisioning.java.sync;
-
-import org.apache.syncope.core.persistence.api.entity.Any;
-import org.apache.syncope.core.provisioning.api.sync.PushActions;
-import org.apache.syncope.core.provisioning.api.sync.ProvisioningProfile;
-import org.apache.syncope.core.provisioning.api.sync.ProvisioningReport;
-import org.quartz.JobExecutionException;
-
-/**
- * Default (empty) implementation of PushActions.
- */
-public abstract class DefaultPushActions implements PushActions {
-
- @Override
- public void beforeAll(final ProvisioningProfile<?, ?> profile) throws JobExecutionException {
- }
-
- @Override
- public <A extends Any<?>> A beforeAssign(final ProvisioningProfile<?, ?> profile, final A any)
- throws JobExecutionException {
-
- return any;
- }
-
- @Override
- public <A extends Any<?>> A beforeProvision(final ProvisioningProfile<?, ?> profile, final A any)
- throws JobExecutionException {
-
- return any;
- }
-
- @Override
- public <A extends Any<?>> A beforeLink(final ProvisioningProfile<?, ?> profile, final A any)
- throws JobExecutionException {
-
- return any;
- }
-
- @Override
- public <A extends Any<?>> A beforeUnassign(final ProvisioningProfile<?, ?> profile, final A any)
- throws JobExecutionException {
-
- return any;
- }
-
- @Override
- public <A extends Any<?>> A beforeDeprovision(final ProvisioningProfile<?, ?> profile, final A any)
- throws JobExecutionException {
-
- return any;
- }
-
- @Override
- public <A extends Any<?>> A beforeUnlink(final ProvisioningProfile<?, ?> profile, final A any)
- throws JobExecutionException {
-
- return any;
- }
-
- @Override
- public <A extends Any<?>> void onError(
- final ProvisioningProfile<?, ?> profile, final A any, final ProvisioningReport result,
- final Exception error) throws JobExecutionException {
-
- // do nothing
- }
-
- @Override
- public <A extends Any<?>> void after(
- final ProvisioningProfile<?, ?> profile, final A any, final ProvisioningReport result)
- throws JobExecutionException {
-
- // do nothing
- }
-
- @Override
- public void afterAll(final ProvisioningProfile<?, ?> profile)
- throws JobExecutionException {
-
- // do nothing
- }
-}
http://git-wip-us.apache.org/repos/asf/syncope/blob/28569df5/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/DefaultReconciliationFilterBuilder.java
----------------------------------------------------------------------
diff --git a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/DefaultReconciliationFilterBuilder.java b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/DefaultReconciliationFilterBuilder.java
deleted file mode 100644
index 2c75928..0000000
--- a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/DefaultReconciliationFilterBuilder.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.core.provisioning.java.sync;
-
-import static org.identityconnectors.framework.impl.api.local.operations.FilteredResultsHandler.PassThroughFilter;
-
-import org.identityconnectors.framework.common.objects.filter.Filter;
-import org.apache.syncope.core.provisioning.api.sync.ReconciliationFilterBuilder;
-
-/**
- * Default (pass-through) implementation of {@link ReconciliationFilterBuilder}.
- */
-public abstract class DefaultReconciliationFilterBuilder implements ReconciliationFilterBuilder {
-
- private static final PassThroughFilter PASS_THROUGH = new PassThroughFilter();
-
- @Override
- public Filter build() {
- return PASS_THROUGH;
- }
-
-}
http://git-wip-us.apache.org/repos/asf/syncope/blob/28569df5/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/DefaultSyncActions.java
----------------------------------------------------------------------
diff --git a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/DefaultSyncActions.java b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/DefaultSyncActions.java
deleted file mode 100644
index 9045e2a..0000000
--- a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/DefaultSyncActions.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.core.provisioning.java.sync;
-
-import org.apache.syncope.common.lib.patch.AnyPatch;
-import org.apache.syncope.common.lib.to.AnyTO;
-import org.apache.syncope.core.provisioning.api.sync.SyncActions;
-import org.apache.syncope.core.provisioning.api.sync.ProvisioningProfile;
-import org.apache.syncope.core.provisioning.api.sync.ProvisioningReport;
-import org.identityconnectors.framework.common.objects.SyncDelta;
-import org.quartz.JobExecutionException;
-
-/**
- * Default (empty) implementation of {@link SyncActions}.
- */
-public abstract class DefaultSyncActions implements SyncActions {
-
- @Override
- public void beforeAll(final ProvisioningProfile<?, ?> profile) throws JobExecutionException {
- }
-
- @Override
- public <A extends AnyTO, P extends AnyPatch> SyncDelta beforeUpdate(
- final ProvisioningProfile<?, ?> profile,
- final SyncDelta delta,
- final A any,
- final P anyMod) throws JobExecutionException {
-
- return delta;
- }
-
- @Override
- public <A extends AnyTO> SyncDelta beforeDelete(
- final ProvisioningProfile<?, ?> profile, final SyncDelta delta, final A any)
- throws JobExecutionException {
-
- return delta;
- }
-
- @Override
- public <A extends AnyTO> SyncDelta beforeAssign(
- final ProvisioningProfile<?, ?> profile, final SyncDelta delta, final A any)
- throws JobExecutionException {
-
- return delta;
- }
-
- @Override
- public <A extends AnyTO> SyncDelta beforeProvision(
- final ProvisioningProfile<?, ?> profile, final SyncDelta delta, final A any)
- throws JobExecutionException {
-
- return delta;
- }
-
- @Override
- public <A extends AnyTO> SyncDelta beforeLink(
- final ProvisioningProfile<?, ?> profile, final SyncDelta delta, final A any)
- throws JobExecutionException {
-
- return delta;
- }
-
- @Override
- public <A extends AnyTO> SyncDelta beforeUnassign(
- final ProvisioningProfile<?, ?> profile, final SyncDelta delta, final A any)
- throws JobExecutionException {
-
- return delta;
- }
-
- @Override
- public <A extends AnyTO> SyncDelta beforeDeprovision(
- final ProvisioningProfile<?, ?> profile, final SyncDelta delta, final A any)
- throws JobExecutionException {
-
- return delta;
- }
-
- @Override
- public <A extends AnyTO> SyncDelta beforeUnlink(
- final ProvisioningProfile<?, ?> profile, final SyncDelta delta, final A any)
- throws JobExecutionException {
-
- return delta;
- }
-
- @Override
- public void onError(
- final ProvisioningProfile<?, ?> profile, final SyncDelta delta, final ProvisioningReport result,
- final Exception error) throws JobExecutionException {
- }
-
- @Override
- public <A extends AnyTO> void after(
- final ProvisioningProfile<?, ?> profile, final SyncDelta delta, final A any,
- final ProvisioningReport result)
- throws JobExecutionException {
- }
-
- @Override
- public void afterAll(final ProvisioningProfile<?, ?> profile)
- throws JobExecutionException {
- }
-}
http://git-wip-us.apache.org/repos/asf/syncope/blob/28569df5/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/GroupPushResultHandlerImpl.java
----------------------------------------------------------------------
diff --git a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/GroupPushResultHandlerImpl.java b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/GroupPushResultHandlerImpl.java
deleted file mode 100644
index 571fc47..0000000
--- a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/GroupPushResultHandlerImpl.java
+++ /dev/null
@@ -1,70 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.core.provisioning.java.sync;
-
-import org.apache.syncope.common.lib.patch.GroupPatch;
-import org.apache.syncope.common.lib.patch.AnyPatch;
-import org.apache.syncope.common.lib.to.AnyTO;
-import org.apache.syncope.common.lib.types.AnyTypeKind;
-import org.apache.syncope.core.persistence.api.entity.Any;
-import org.apache.syncope.core.persistence.api.entity.AnyUtils;
-import org.apache.syncope.core.persistence.api.entity.group.Group;
-import org.apache.syncope.core.provisioning.api.WorkflowResult;
-import org.apache.syncope.core.provisioning.api.sync.GroupPushResultHandler;
-
-public class GroupPushResultHandlerImpl extends AbstractPushResultHandler implements GroupPushResultHandler {
-
- @Override
- protected AnyUtils getAnyUtils() {
- return anyUtilsFactory.getInstance(AnyTypeKind.GROUP);
- }
-
- @Override
- protected String getName(final Any<?> any) {
- return Group.class.cast(any).getName();
- }
-
- @Override
- protected Any<?> getAny(final long key) {
- try {
- return groupDAO.authFind(key);
- } catch (Exception e) {
- LOG.warn("Error retrieving group {}", key, e);
- return null;
- }
- }
-
- @Override
- protected AnyTO getAnyTO(final long key) {
- return groupDataBinder.getGroupTO(key);
- }
-
- @Override
- protected AnyPatch newPatch(final long key) {
- GroupPatch patch = new GroupPatch();
- patch.setKey(key);
- return patch;
- }
-
- @Override
- protected WorkflowResult<Long> update(final AnyPatch patch) {
- return gwfAdapter.update((GroupPatch) patch);
- }
-
-}
http://git-wip-us.apache.org/repos/asf/syncope/blob/28569df5/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/GroupSyncResultHandlerImpl.java
----------------------------------------------------------------------
diff --git a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/GroupSyncResultHandlerImpl.java b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/GroupSyncResultHandlerImpl.java
deleted file mode 100644
index c3c63fb..0000000
--- a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/sync/GroupSyncResultHandlerImpl.java
+++ /dev/null
@@ -1,138 +0,0 @@
-/*
- * Licensed to the Apache Software Foundation (ASF) under one
- * or more contributor license agreements. See the NOTICE file
- * distributed with this work for additional information
- * regarding copyright ownership. The ASF licenses this file
- * to you under the Apache License, Version 2.0 (the
- * "License"); you may not use this file except in compliance
- * with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing,
- * software distributed under the License is distributed on an
- * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the
- * specific language governing permissions and limitations
- * under the License.
- */
-package org.apache.syncope.core.provisioning.java.sync;
-
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import org.apache.syncope.common.lib.patch.AnyPatch;
-import org.apache.syncope.common.lib.patch.AttrPatch;
-import org.apache.syncope.common.lib.patch.GroupPatch;
-import org.apache.syncope.common.lib.to.AnyTO;
-import org.apache.syncope.common.lib.to.PropagationStatus;
-import org.apache.syncope.common.lib.to.GroupTO;
-import org.apache.syncope.common.lib.types.AnyTypeKind;
-import org.apache.syncope.common.lib.types.PatchOperation;
-import org.apache.syncope.core.persistence.api.entity.Any;
-import org.apache.syncope.core.persistence.api.entity.AnyUtils;
-import org.apache.syncope.core.provisioning.api.ProvisioningManager;
-import org.apache.syncope.core.provisioning.api.WorkflowResult;
-import org.apache.syncope.core.provisioning.api.sync.ProvisioningReport;
-import org.apache.syncope.core.provisioning.api.sync.GroupSyncResultHandler;
-import org.identityconnectors.framework.common.objects.SyncDelta;
-
-public class GroupSyncResultHandlerImpl extends AbstractSyncResultHandler implements GroupSyncResultHandler {
-
- protected final Map<Long, String> groupOwnerMap = new HashMap<>();
-
- @Override
- public Map<Long, String> getGroupOwnerMap() {
- return this.groupOwnerMap;
- }
-
- @Override
- protected AnyUtils getAnyUtils() {
- return anyUtilsFactory.getInstance(AnyTypeKind.GROUP);
- }
-
- @Override
- protected String getName(final AnyTO anyTO) {
- return GroupTO.class.cast(anyTO).getName();
- }
-
- @Override
- protected ProvisioningManager<?, ?> getProvisioningManager() {
- return groupProvisioningManager;
- }
-
- @Override
- protected Any<?> getAny(final long key) {
- try {
- return groupDAO.authFind(key);
- } catch (Exception e) {
- LOG.warn("Error retrieving group {}", key, e);
- return null;
- }
- }
-
- @Override
- protected AnyTO getAnyTO(final long key) {
- return groupDataBinder.getGroupTO(key);
- }
-
- @Override
- protected AnyPatch newPatch(final long key) {
- GroupPatch patch = new GroupPatch();
- patch.setKey(key);
- return patch;
- }
-
- @Override
- protected WorkflowResult<Long> update(final AnyPatch patch) {
- return gwfAdapter.update((GroupPatch) patch);
- }
-
- @Override
- protected AnyTO doCreate(final AnyTO anyTO, final SyncDelta delta, final ProvisioningReport result) {
- GroupTO groupTO = GroupTO.class.cast(anyTO);
-
- Map.Entry<Long, List<PropagationStatus>> created = groupProvisioningManager.create(
- groupTO,
- groupOwnerMap,
- Collections.singleton(profile.getTask().getResource().getKey()),
- true);
-
- result.setKey(created.getKey());
- result.setName(getName(anyTO));
-
- return getAnyTO(created.getKey());
- }
-
- @Override
- protected AnyTO doUpdate(
- final AnyTO before,
- final AnyPatch anyPatch,
- final SyncDelta delta,
- final ProvisioningReport result) {
-
- GroupPatch groupPatch = GroupPatch.class.cast(anyPatch);
-
- Map.Entry<Long, List<PropagationStatus>> updated = groupProvisioningManager.update(groupPatch, true);
-
- String groupOwner = null;
- for (AttrPatch attrPatch : groupPatch.getPlainAttrs()) {
- if (attrPatch.getOperation() == PatchOperation.ADD_REPLACE && attrPatch.getAttrTO() != null
- && attrPatch.getAttrTO().getSchema().isEmpty() && !attrPatch.getAttrTO().getValues().isEmpty()) {
-
- groupOwner = attrPatch.getAttrTO().getValues().get(0);
- }
- }
- if (groupOwner != null) {
- groupOwnerMap.put(updated.getKey(), groupOwner);
- }
-
- GroupTO after = groupDataBinder.getGroupTO(updated.getKey());
-
- result.setName(getName(after));
-
- return after;
- }
-
-}