Search in sources :

Example 6 with IgnoreProvisionException

use of org.apache.syncope.core.provisioning.api.pushpull.IgnoreProvisionException in project syncope by apache.

the class AbstractPullResultHandler method handle.

@Override
public boolean handle(final SyncDelta delta) {
    Provision provision = null;
    try {
        provision = profile.getTask().getResource().getProvision(delta.getObject().getObjectClass()).orElse(null);
        if (provision == null) {
            throw new JobExecutionException("No provision found on " + profile.getTask().getResource() + " for " + delta.getObject().getObjectClass());
        }
        doHandle(delta, provision);
        executor.reportHandled(delta.getObjectClass(), delta.getObject().getName());
        LOG.debug("Successfully handled {}", delta);
        if (profile.getTask().getPullMode() != PullMode.INCREMENTAL) {
            if (executor.wasInterruptRequested()) {
                LOG.debug("Pull interrupted");
                executor.setInterrupted();
                return false;
            }
            return true;
        }
        boolean shouldContinue;
        synchronized (this) {
            shouldContinue = latestResult == Result.SUCCESS;
            this.latestResult = null;
        }
        if (shouldContinue) {
            executor.setLatestSyncToken(delta.getObjectClass(), delta.getToken());
        }
        if (executor.wasInterruptRequested()) {
            LOG.debug("Pull interrupted");
            executor.setInterrupted();
            return false;
        }
        return shouldContinue;
    } catch (IgnoreProvisionException e) {
        ProvisioningReport ignoreResult = new ProvisioningReport();
        ignoreResult.setOperation(ResourceOperation.NONE);
        ignoreResult.setAnyType(provision == null ? getAnyUtils().getAnyTypeKind().name() : provision.getAnyType().getKey());
        ignoreResult.setStatus(ProvisioningReport.Status.IGNORE);
        ignoreResult.setKey(null);
        ignoreResult.setName(delta.getObject().getName().getNameValue());
        profile.getResults().add(ignoreResult);
        LOG.warn("Ignoring during pull", e);
        executor.setLatestSyncToken(delta.getObjectClass(), delta.getToken());
        executor.reportHandled(delta.getObjectClass(), delta.getObject().getName());
        return true;
    } catch (JobExecutionException e) {
        LOG.error("Pull failed", e);
        return false;
    }
}
Also used : Provision(org.apache.syncope.core.persistence.api.entity.resource.Provision) JobExecutionException(org.quartz.JobExecutionException) IgnoreProvisionException(org.apache.syncope.core.provisioning.api.pushpull.IgnoreProvisionException) ProvisioningReport(org.apache.syncope.core.provisioning.api.pushpull.ProvisioningReport)

Aggregations

IgnoreProvisionException (org.apache.syncope.core.provisioning.api.pushpull.IgnoreProvisionException)6 ProvisioningReport (org.apache.syncope.core.provisioning.api.pushpull.ProvisioningReport)6 JobExecutionException (org.quartz.JobExecutionException)6 HashMap (java.util.HashMap)2 Result (org.apache.syncope.common.lib.types.AuditElements.Result)2 OrgUnit (org.apache.syncope.core.persistence.api.entity.resource.OrgUnit)2 TimeoutException (org.apache.syncope.core.provisioning.api.TimeoutException)2 AfterHandlingEvent (org.apache.syncope.core.provisioning.api.event.AfterHandlingEvent)2 PushActions (org.apache.syncope.core.provisioning.api.pushpull.PushActions)2 ConnectorObject (org.identityconnectors.framework.common.objects.ConnectorObject)2 Transactional (org.springframework.transaction.annotation.Transactional)2 AnyUtils (org.apache.syncope.core.persistence.api.entity.AnyUtils)1 Realm (org.apache.syncope.core.persistence.api.entity.Realm)1 AnyObject (org.apache.syncope.core.persistence.api.entity.anyobject.AnyObject)1 MappingItem (org.apache.syncope.core.persistence.api.entity.resource.MappingItem)1 Provision (org.apache.syncope.core.persistence.api.entity.resource.Provision)1 User (org.apache.syncope.core.persistence.api.entity.user.User)1