Search in sources :

Example 6 with ProvisioningReport

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

the class DefaultRealmPullResultHandler method link.

private List<ProvisioningReport> link(final SyncDelta delta, final List<String> keys, final boolean unlink) throws JobExecutionException {
    if (!profile.getTask().isPerformUpdate()) {
        LOG.debug("PullTask not configured for update");
        finalize(unlink ? MatchingRule.toEventName(MatchingRule.UNLINK) : MatchingRule.toEventName(MatchingRule.LINK), Result.SUCCESS, null, null, delta);
        return Collections.<ProvisioningReport>emptyList();
    }
    LOG.debug("About to link {}", keys);
    final List<ProvisioningReport> results = new ArrayList<>();
    for (String key : keys) {
        LOG.debug("About to unassign resource {}", key);
        ProvisioningReport result = new ProvisioningReport();
        result.setOperation(ResourceOperation.NONE);
        result.setAnyType(REALM_TYPE);
        result.setStatus(ProvisioningReport.Status.SUCCESS);
        result.setKey(key);
        Realm realm = realmDAO.find(key);
        RealmTO before = binder.getRealmTO(realm, true);
        if (before == null) {
            result.setStatus(ProvisioningReport.Status.FAILURE);
            result.setMessage(String.format("Realm '%s' not found", key));
        } else {
            result.setName(before.getFullPath());
        }
        Object output;
        Result resultStatus;
        if (!profile.isDryRun()) {
            if (before == null) {
                resultStatus = Result.FAILURE;
                output = null;
            } else {
                try {
                    if (unlink) {
                        for (PullActions action : profile.getActions()) {
                            action.beforeUnlink(profile, delta, before);
                        }
                    } else {
                        for (PullActions action : profile.getActions()) {
                            action.beforeLink(profile, delta, before);
                        }
                    }
                    if (unlink) {
                        realm.getResources().remove(profile.getTask().getResource());
                    } else {
                        realm.add(profile.getTask().getResource());
                    }
                    output = update(delta, Collections.singletonList(key));
                    for (PullActions action : profile.getActions()) {
                        action.after(profile, delta, RealmTO.class.cast(output), result);
                    }
                    resultStatus = Result.SUCCESS;
                    LOG.debug("{} successfully updated", realm);
                } catch (PropagationException e) {
                    // A propagation failure doesn't imply a pull failure.
                    // The propagation exception status will be reported into the propagation task execution.
                    LOG.error("Could not propagate Realm {}", delta.getUid().getUidValue(), e);
                    output = e;
                    resultStatus = Result.FAILURE;
                } catch (Exception e) {
                    throwIgnoreProvisionException(delta, e);
                    result.setStatus(ProvisioningReport.Status.FAILURE);
                    result.setMessage(ExceptionUtils.getRootCauseMessage(e));
                    LOG.error("Could not update Realm {}", delta.getUid().getUidValue(), e);
                    output = e;
                    resultStatus = Result.FAILURE;
                }
            }
            finalize(unlink ? MatchingRule.toEventName(MatchingRule.UNLINK) : MatchingRule.toEventName(MatchingRule.LINK), resultStatus, before, output, delta);
        }
        results.add(result);
    }
    return results;
}
Also used : PropagationException(org.apache.syncope.core.provisioning.api.propagation.PropagationException) PullActions(org.apache.syncope.core.provisioning.api.pushpull.PullActions) ArrayList(java.util.ArrayList) RealmTO(org.apache.syncope.common.lib.to.RealmTO) ProvisioningReport(org.apache.syncope.core.provisioning.api.pushpull.ProvisioningReport) Realm(org.apache.syncope.core.persistence.api.entity.Realm) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) DelegatedAdministrationException(org.apache.syncope.core.spring.security.DelegatedAdministrationException) IgnoreProvisionException(org.apache.syncope.core.provisioning.api.pushpull.IgnoreProvisionException) PropagationException(org.apache.syncope.core.provisioning.api.propagation.PropagationException) JobExecutionException(org.quartz.JobExecutionException) Result(org.apache.syncope.common.lib.types.AuditElements.Result)

Example 7 with ProvisioningReport

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

the class DefaultRealmPullResultHandler method ignore.

private ProvisioningReport ignore(final SyncDelta delta, final boolean matching) throws JobExecutionException {
    LOG.debug("Any to ignore {}", delta.getObject().getUid().getUidValue());
    ProvisioningReport result = new ProvisioningReport();
    result.setKey(null);
    result.setName(delta.getObject().getUid().getUidValue());
    result.setOperation(ResourceOperation.NONE);
    result.setAnyType(REALM_TYPE);
    result.setStatus(ProvisioningReport.Status.SUCCESS);
    if (!profile.isDryRun()) {
        finalize(matching ? MatchingRule.toEventName(MatchingRule.IGNORE) : UnmatchingRule.toEventName(UnmatchingRule.IGNORE), Result.SUCCESS, null, null, delta);
    }
    return result;
}
Also used : ProvisioningReport(org.apache.syncope.core.provisioning.api.pushpull.ProvisioningReport)

Example 8 with ProvisioningReport

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

the class DefaultRealmPushResultHandler method handle.

@Transactional(propagation = Propagation.REQUIRES_NEW)
@Override
public boolean handle(final String realmKey) {
    Realm realm = null;
    try {
        realm = realmDAO.find(realmKey);
        doHandle(realm);
        return true;
    } catch (IgnoreProvisionException e) {
        ProvisioningReport result = new ProvisioningReport();
        result.setOperation(ResourceOperation.NONE);
        result.setAnyType(realm == null ? null : REALM_TYPE);
        result.setStatus(ProvisioningReport.Status.IGNORE);
        result.setKey(realmKey);
        profile.getResults().add(result);
        LOG.warn("Ignoring during push", e);
        return true;
    } catch (JobExecutionException e) {
        LOG.error("Push failed", e);
        return false;
    }
}
Also used : JobExecutionException(org.quartz.JobExecutionException) Realm(org.apache.syncope.core.persistence.api.entity.Realm) IgnoreProvisionException(org.apache.syncope.core.provisioning.api.pushpull.IgnoreProvisionException) ProvisioningReport(org.apache.syncope.core.provisioning.api.pushpull.ProvisioningReport) Transactional(org.springframework.transaction.annotation.Transactional)

Example 9 with ProvisioningReport

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

the class DefaultRealmPushResultHandler method doHandle.

private void doHandle(final Realm realm) throws JobExecutionException {
    ProvisioningReport result = new ProvisioningReport();
    profile.getResults().add(result);
    result.setKey(realm.getKey());
    result.setAnyType(REALM_TYPE);
    result.setName(realm.getFullPath());
    LOG.debug("Propagating Realm with key {} towards {}", realm.getKey(), profile.getTask().getResource());
    Object output = null;
    Result resultStatus = null;
    // Try to read remote object BEFORE any actual operation
    OrgUnit orgUnit = profile.getTask().getResource().getOrgUnit();
    Optional<? extends OrgUnitItem> connObjectKey = orgUnit.getConnObjectKeyItem();
    Optional<String> connObjecKeyValue = mappingManager.getConnObjectKeyValue(realm, orgUnit);
    ConnectorObject beforeObj = null;
    if (connObjectKey.isPresent() && connObjecKeyValue.isPresent()) {
        beforeObj = getRemoteObject(orgUnit.getObjectClass(), connObjectKey.get().getExtAttrName(), connObjecKeyValue.get(), orgUnit.getItems().iterator());
    } else {
        LOG.debug("OrgUnitItem {} or its value {} are null", connObjectKey, connObjecKeyValue);
    }
    if (profile.isDryRun()) {
        if (beforeObj == null) {
            result.setOperation(toResourceOperation(profile.getTask().getUnmatchingRule()));
        } else {
            result.setOperation(toResourceOperation(profile.getTask().getMatchingRule()));
        }
        result.setStatus(ProvisioningReport.Status.SUCCESS);
    } else {
        String operation = beforeObj == null ? UnmatchingRule.toEventName(profile.getTask().getUnmatchingRule()) : MatchingRule.toEventName(profile.getTask().getMatchingRule());
        boolean notificationsAvailable = notificationManager.notificationsAvailable(AuditElements.EventCategoryType.PUSH, REALM_TYPE.toLowerCase(), profile.getTask().getResource().getKey(), operation);
        boolean auditRequested = auditManager.auditRequested(AuditElements.EventCategoryType.PUSH, REALM_TYPE.toLowerCase(), profile.getTask().getResource().getKey(), operation);
        try {
            if (beforeObj == null) {
                result.setOperation(toResourceOperation(profile.getTask().getUnmatchingRule()));
                switch(profile.getTask().getUnmatchingRule()) {
                    case ASSIGN:
                        for (PushActions action : profile.getActions()) {
                            action.beforeAssign(profile, realm);
                        }
                        if (!profile.getTask().isPerformCreate()) {
                            LOG.debug("PushTask not configured for create");
                            result.setStatus(ProvisioningReport.Status.IGNORE);
                        } else {
                            assign(realm, result);
                        }
                        break;
                    case PROVISION:
                        for (PushActions action : profile.getActions()) {
                            action.beforeProvision(profile, realm);
                        }
                        if (!profile.getTask().isPerformCreate()) {
                            LOG.debug("PushTask not configured for create");
                            result.setStatus(ProvisioningReport.Status.IGNORE);
                        } else {
                            provision(realm, result);
                        }
                        break;
                    case UNLINK:
                        for (PushActions action : profile.getActions()) {
                            action.beforeUnlink(profile, realm);
                        }
                        if (!profile.getTask().isPerformUpdate()) {
                            LOG.debug("PushTask not configured for update");
                            result.setStatus(ProvisioningReport.Status.IGNORE);
                        } else {
                            link(realm, true, result);
                        }
                        break;
                    case IGNORE:
                        LOG.debug("Ignored any: {}", realm);
                        result.setStatus(ProvisioningReport.Status.IGNORE);
                        break;
                    default:
                }
            } else {
                result.setOperation(toResourceOperation(profile.getTask().getMatchingRule()));
                switch(profile.getTask().getMatchingRule()) {
                    case UPDATE:
                        for (PushActions action : profile.getActions()) {
                            action.beforeUpdate(profile, realm);
                        }
                        if (!profile.getTask().isPerformUpdate()) {
                            LOG.debug("PushTask not configured for update");
                            result.setStatus(ProvisioningReport.Status.IGNORE);
                        } else {
                            update(binder.getRealmTO(realm, true), result);
                        }
                        break;
                    case DEPROVISION:
                        for (PushActions action : profile.getActions()) {
                            action.beforeDeprovision(profile, realm);
                        }
                        if (!profile.getTask().isPerformDelete()) {
                            LOG.debug("PushTask not configured for delete");
                            result.setStatus(ProvisioningReport.Status.IGNORE);
                        } else {
                            deprovision(realm, result);
                        }
                        break;
                    case UNASSIGN:
                        for (PushActions action : profile.getActions()) {
                            action.beforeUnassign(profile, realm);
                        }
                        if (!profile.getTask().isPerformDelete()) {
                            LOG.debug("PushTask not configured for delete");
                            result.setStatus(ProvisioningReport.Status.IGNORE);
                        } else {
                            unassign(realm, result);
                        }
                        break;
                    case LINK:
                        for (PushActions action : profile.getActions()) {
                            action.beforeLink(profile, realm);
                        }
                        if (!profile.getTask().isPerformUpdate()) {
                            LOG.debug("PushTask not configured for update");
                            result.setStatus(ProvisioningReport.Status.IGNORE);
                        } else {
                            link(realm, false, result);
                        }
                        break;
                    case UNLINK:
                        for (PushActions action : profile.getActions()) {
                            action.beforeUnlink(profile, realm);
                        }
                        if (!profile.getTask().isPerformUpdate()) {
                            LOG.debug("PushTask not configured for update");
                            result.setStatus(ProvisioningReport.Status.IGNORE);
                        } else {
                            link(realm, true, result);
                        }
                        break;
                    case IGNORE:
                        LOG.debug("Ignored any: {}", realm);
                        result.setStatus(ProvisioningReport.Status.IGNORE);
                        break;
                    default:
                }
            }
            for (PushActions action : profile.getActions()) {
                action.after(profile, realm, result);
            }
            if (result.getStatus() == null) {
                result.setStatus(ProvisioningReport.Status.SUCCESS);
            }
            resultStatus = AuditElements.Result.SUCCESS;
            if (connObjectKey.isPresent() && connObjecKeyValue.isPresent()) {
                output = getRemoteObject(orgUnit.getObjectClass(), connObjectKey.get().getExtAttrName(), connObjecKeyValue.get(), orgUnit.getItems().iterator());
            }
        } catch (IgnoreProvisionException e) {
            throw e;
        } catch (Exception e) {
            result.setStatus(ProvisioningReport.Status.FAILURE);
            result.setMessage(ExceptionUtils.getRootCauseMessage(e));
            resultStatus = AuditElements.Result.FAILURE;
            output = e;
            LOG.warn("Error pushing {} towards {}", realm, profile.getTask().getResource(), e);
            for (PushActions action : profile.getActions()) {
                action.onError(profile, realm, result, e);
            }
            throw new JobExecutionException(e);
        } finally {
            if (notificationsAvailable || auditRequested) {
                Map<String, Object> jobMap = new HashMap<>();
                jobMap.put(AfterHandlingEvent.JOBMAP_KEY, new AfterHandlingEvent(AuditElements.EventCategoryType.PUSH, REALM_TYPE.toLowerCase(), profile.getTask().getResource().getKey(), operation, resultStatus, beforeObj, output, realm));
                AfterHandlingJob.schedule(scheduler, jobMap);
            }
        }
    }
}
Also used : OrgUnit(org.apache.syncope.core.persistence.api.entity.resource.OrgUnit) HashMap(java.util.HashMap) ConnectorObject(org.identityconnectors.framework.common.objects.ConnectorObject) AfterHandlingEvent(org.apache.syncope.core.provisioning.api.event.AfterHandlingEvent) ProvisioningReport(org.apache.syncope.core.provisioning.api.pushpull.ProvisioningReport) IgnoreProvisionException(org.apache.syncope.core.provisioning.api.pushpull.IgnoreProvisionException) IgnoreProvisionException(org.apache.syncope.core.provisioning.api.pushpull.IgnoreProvisionException) TimeoutException(org.apache.syncope.core.provisioning.api.TimeoutException) JobExecutionException(org.quartz.JobExecutionException) Result(org.apache.syncope.common.lib.types.AuditElements.Result) JobExecutionException(org.quartz.JobExecutionException) ConnectorObject(org.identityconnectors.framework.common.objects.ConnectorObject) PushActions(org.apache.syncope.core.provisioning.api.pushpull.PushActions)

Example 10 with ProvisioningReport

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

the class AbstractProvisioningJobDelegate method createReport.

/**
 * Create a textual report of the provisionig operation, based on the trace level.
 *
 * @param provResults Provisioning results
 * @param resource Provisioning resource
 * @param dryRun dry run?
 * @return report as string
 */
protected String createReport(final Collection<ProvisioningReport> provResults, final ExternalResource resource, final boolean dryRun) {
    TraceLevel traceLevel = resource.getProvisioningTraceLevel();
    if (traceLevel == TraceLevel.NONE) {
        return null;
    }
    StringBuilder report = new StringBuilder();
    if (dryRun) {
        report.append("==> Dry run only, no modifications were made <==\n\n");
    }
    if (interrupted) {
        report.append("==> Execution was interrupted <==\n\n");
    }
    List<ProvisioningReport> rSuccCreate = new ArrayList<>();
    List<ProvisioningReport> rFailCreate = new ArrayList<>();
    List<ProvisioningReport> rSuccUpdate = new ArrayList<>();
    List<ProvisioningReport> rFailUpdate = new ArrayList<>();
    List<ProvisioningReport> rSuccDelete = new ArrayList<>();
    List<ProvisioningReport> rFailDelete = new ArrayList<>();
    List<ProvisioningReport> rSuccNone = new ArrayList<>();
    List<ProvisioningReport> rIgnore = new ArrayList<>();
    List<ProvisioningReport> uSuccCreate = new ArrayList<>();
    List<ProvisioningReport> uFailCreate = new ArrayList<>();
    List<ProvisioningReport> uSuccUpdate = new ArrayList<>();
    List<ProvisioningReport> uFailUpdate = new ArrayList<>();
    List<ProvisioningReport> uSuccDelete = new ArrayList<>();
    List<ProvisioningReport> uFailDelete = new ArrayList<>();
    List<ProvisioningReport> uSuccNone = new ArrayList<>();
    List<ProvisioningReport> uIgnore = new ArrayList<>();
    List<ProvisioningReport> gSuccCreate = new ArrayList<>();
    List<ProvisioningReport> gFailCreate = new ArrayList<>();
    List<ProvisioningReport> gSuccUpdate = new ArrayList<>();
    List<ProvisioningReport> gFailUpdate = new ArrayList<>();
    List<ProvisioningReport> gSuccDelete = new ArrayList<>();
    List<ProvisioningReport> gFailDelete = new ArrayList<>();
    List<ProvisioningReport> gSuccNone = new ArrayList<>();
    List<ProvisioningReport> gIgnore = new ArrayList<>();
    List<ProvisioningReport> aSuccCreate = new ArrayList<>();
    List<ProvisioningReport> aFailCreate = new ArrayList<>();
    List<ProvisioningReport> aSuccUpdate = new ArrayList<>();
    List<ProvisioningReport> aFailUpdate = new ArrayList<>();
    List<ProvisioningReport> aSuccDelete = new ArrayList<>();
    List<ProvisioningReport> aFailDelete = new ArrayList<>();
    List<ProvisioningReport> aSuccNone = new ArrayList<>();
    List<ProvisioningReport> aIgnore = new ArrayList<>();
    for (ProvisioningReport provResult : provResults) {
        AnyType anyType = anyTypeDAO.find(provResult.getAnyType());
        switch(provResult.getStatus()) {
            case SUCCESS:
                switch(provResult.getOperation()) {
                    case CREATE:
                        if (anyType == null) {
                            rSuccCreate.add(provResult);
                        } else {
                            switch(anyType.getKind()) {
                                case USER:
                                    uSuccCreate.add(provResult);
                                    break;
                                case GROUP:
                                    gSuccCreate.add(provResult);
                                    break;
                                case ANY_OBJECT:
                                default:
                                    aSuccCreate.add(provResult);
                            }
                        }
                        break;
                    case UPDATE:
                        if (anyType == null) {
                            rSuccUpdate.add(provResult);
                        } else {
                            switch(anyType.getKind()) {
                                case USER:
                                    uSuccUpdate.add(provResult);
                                    break;
                                case GROUP:
                                    gSuccUpdate.add(provResult);
                                    break;
                                case ANY_OBJECT:
                                default:
                                    aSuccUpdate.add(provResult);
                            }
                        }
                        break;
                    case DELETE:
                        if (anyType == null) {
                            rSuccDelete.add(provResult);
                        } else {
                            switch(anyType.getKind()) {
                                case USER:
                                    uSuccDelete.add(provResult);
                                    break;
                                case GROUP:
                                    gSuccDelete.add(provResult);
                                    break;
                                case ANY_OBJECT:
                                default:
                                    aSuccDelete.add(provResult);
                            }
                        }
                        break;
                    case NONE:
                        if (anyType == null) {
                            rSuccNone.add(provResult);
                        } else {
                            switch(anyType.getKind()) {
                                case USER:
                                    uSuccNone.add(provResult);
                                    break;
                                case GROUP:
                                    gSuccNone.add(provResult);
                                    break;
                                case ANY_OBJECT:
                                default:
                                    aSuccNone.add(provResult);
                            }
                        }
                        break;
                    default:
                }
                break;
            case FAILURE:
                switch(provResult.getOperation()) {
                    case CREATE:
                        if (anyType == null) {
                            rFailCreate.add(provResult);
                        } else {
                            switch(anyType.getKind()) {
                                case USER:
                                    uFailCreate.add(provResult);
                                    break;
                                case GROUP:
                                    gFailCreate.add(provResult);
                                    break;
                                case ANY_OBJECT:
                                default:
                                    aFailCreate.add(provResult);
                            }
                        }
                        break;
                    case UPDATE:
                        if (anyType == null) {
                            rFailUpdate.add(provResult);
                        } else {
                            switch(anyType.getKind()) {
                                case USER:
                                    uFailUpdate.add(provResult);
                                    break;
                                case GROUP:
                                    gFailUpdate.add(provResult);
                                    break;
                                case ANY_OBJECT:
                                default:
                                    aFailUpdate.add(provResult);
                            }
                        }
                        break;
                    case DELETE:
                        if (anyType == null) {
                            rFailDelete.add(provResult);
                        } else {
                            switch(anyType.getKind()) {
                                case USER:
                                    uFailDelete.add(provResult);
                                    break;
                                case GROUP:
                                    gFailDelete.add(provResult);
                                    break;
                                case ANY_OBJECT:
                                default:
                                    aFailDelete.add(provResult);
                            }
                        }
                        break;
                    default:
                }
                break;
            case IGNORE:
                if (anyType == null) {
                    rIgnore.add(provResult);
                } else {
                    switch(anyType.getKind()) {
                        case USER:
                            uIgnore.add(provResult);
                            break;
                        case GROUP:
                            gIgnore.add(provResult);
                            break;
                        case ANY_OBJECT:
                        default:
                            aIgnore.add(provResult);
                    }
                }
                break;
            default:
        }
    }
    // Summary, also to be included for FAILURE and ALL, so create it anyway.
    boolean includeUser = resource.getProvision(anyTypeDAO.findUser()) != null;
    boolean includeGroup = resource.getProvision(anyTypeDAO.findGroup()) != null;
    boolean includeAnyObject = resource.getProvisions().stream().anyMatch(provision -> provision.getAnyType().getKind() == AnyTypeKind.ANY_OBJECT);
    boolean includeRealm = resource.getOrgUnit() != null;
    if (includeUser) {
        report.append("Users ").append("[created/failures]: ").append(uSuccCreate.size()).append('/').append(uFailCreate.size()).append(' ').append("[updated/failures]: ").append(uSuccUpdate.size()).append('/').append(uFailUpdate.size()).append(' ').append("[deleted/failures]: ").append(uSuccDelete.size()).append('/').append(uFailDelete.size()).append(' ').append("[no operation/ignored]: ").append(uSuccNone.size()).append('/').append(uIgnore.size()).append('\n');
    }
    if (includeGroup) {
        report.append("Groups ").append("[created/failures]: ").append(gSuccCreate.size()).append('/').append(gFailCreate.size()).append(' ').append("[updated/failures]: ").append(gSuccUpdate.size()).append('/').append(gFailUpdate.size()).append(' ').append("[deleted/failures]: ").append(gSuccDelete.size()).append('/').append(gFailDelete.size()).append(' ').append("[no operation/ignored]: ").append(gSuccNone.size()).append('/').append(gIgnore.size()).append('\n');
    }
    if (includeAnyObject) {
        report.append("Any objects ").append("[created/failures]: ").append(aSuccCreate.size()).append('/').append(aFailCreate.size()).append(' ').append("[updated/failures]: ").append(aSuccUpdate.size()).append('/').append(aFailUpdate.size()).append(' ').append("[deleted/failures]: ").append(aSuccDelete.size()).append('/').append(aFailDelete.size()).append(' ').append("[no operation/ignored]: ").append(aSuccNone.size()).append('/').append(aIgnore.size());
    }
    if (includeRealm) {
        report.append("Realms ").append("[created/failures]: ").append(rSuccCreate.size()).append('/').append(rFailCreate.size()).append(' ').append("[updated/failures]: ").append(rSuccUpdate.size()).append('/').append(rFailUpdate.size()).append(' ').append("[deleted/failures]: ").append(rSuccDelete.size()).append('/').append(rFailDelete.size()).append(' ').append("[no operation/ignored]: ").append(rSuccNone.size()).append('/').append(rIgnore.size());
    }
    // Failures
    if (traceLevel == TraceLevel.FAILURES || traceLevel == TraceLevel.ALL) {
        if (includeUser) {
            if (!uFailCreate.isEmpty()) {
                report.append("\n\nUsers failed to create: ");
                report.append(ProvisioningReport.generate(uFailCreate, traceLevel));
            }
            if (!uFailUpdate.isEmpty()) {
                report.append("\nUsers failed to update: ");
                report.append(ProvisioningReport.generate(uFailUpdate, traceLevel));
            }
            if (!uFailDelete.isEmpty()) {
                report.append("\nUsers failed to delete: ");
                report.append(ProvisioningReport.generate(uFailDelete, traceLevel));
            }
        }
        if (includeGroup) {
            if (!gFailCreate.isEmpty()) {
                report.append("\n\nGroups failed to create: ");
                report.append(ProvisioningReport.generate(gFailCreate, traceLevel));
            }
            if (!gFailUpdate.isEmpty()) {
                report.append("\nGroups failed to update: ");
                report.append(ProvisioningReport.generate(gFailUpdate, traceLevel));
            }
            if (!gFailDelete.isEmpty()) {
                report.append("\nGroups failed to delete: ");
                report.append(ProvisioningReport.generate(gFailDelete, traceLevel));
            }
        }
        if (includeAnyObject && !aFailCreate.isEmpty()) {
            report.append("\nAny objects failed to create: ");
            report.append(ProvisioningReport.generate(aFailCreate, traceLevel));
        }
        if (includeAnyObject && !aFailUpdate.isEmpty()) {
            report.append("\nAny objects failed to update: ");
            report.append(ProvisioningReport.generate(aFailUpdate, traceLevel));
        }
        if (includeAnyObject && !aFailDelete.isEmpty()) {
            report.append("\nAny objects failed to delete: ");
            report.append(ProvisioningReport.generate(aFailDelete, traceLevel));
        }
        if (includeRealm) {
            if (!rFailCreate.isEmpty()) {
                report.append("\nRealms failed to create: ");
                report.append(ProvisioningReport.generate(rFailCreate, traceLevel));
            }
            if (!rFailUpdate.isEmpty()) {
                report.append("\nRealms failed to update: ");
                report.append(ProvisioningReport.generate(rFailUpdate, traceLevel));
            }
            if (!rFailDelete.isEmpty()) {
                report.append("\nRealms failed to delete: ");
                report.append(ProvisioningReport.generate(rFailDelete, traceLevel));
            }
        }
    }
    // Succeeded, only if on 'ALL' level
    if (traceLevel == TraceLevel.ALL) {
        if (includeUser) {
            if (!uSuccCreate.isEmpty()) {
                report.append("\n\nUsers created:\n").append(ProvisioningReport.generate(uSuccCreate, traceLevel));
            }
            if (!uSuccUpdate.isEmpty()) {
                report.append("\nUsers updated:\n").append(ProvisioningReport.generate(uSuccUpdate, traceLevel));
            }
            if (!uSuccDelete.isEmpty()) {
                report.append("\nUsers deleted:\n").append(ProvisioningReport.generate(uSuccDelete, traceLevel));
            }
            if (!uSuccNone.isEmpty()) {
                report.append("\nUsers no operation:\n").append(ProvisioningReport.generate(uSuccNone, traceLevel));
            }
            if (!uIgnore.isEmpty()) {
                report.append("\nUsers ignored:\n").append(ProvisioningReport.generate(uIgnore, traceLevel));
            }
        }
        if (includeGroup) {
            if (!gSuccCreate.isEmpty()) {
                report.append("\n\nGroups created:\n").append(ProvisioningReport.generate(gSuccCreate, traceLevel));
            }
            if (!gSuccUpdate.isEmpty()) {
                report.append("\nGroups updated:\n").append(ProvisioningReport.generate(gSuccUpdate, traceLevel));
            }
            if (!gSuccDelete.isEmpty()) {
                report.append("\nGroups deleted:\n").append(ProvisioningReport.generate(gSuccDelete, traceLevel));
            }
            if (!gSuccNone.isEmpty()) {
                report.append("\nGroups no operation:\n").append(ProvisioningReport.generate(gSuccNone, traceLevel));
            }
            if (!gIgnore.isEmpty()) {
                report.append("\nGroups ignored:\n").append(ProvisioningReport.generate(gIgnore, traceLevel));
            }
        }
        if (includeAnyObject) {
            if (!aSuccCreate.isEmpty()) {
                report.append("\n\nAny objects created:\n").append(ProvisioningReport.generate(aSuccCreate, traceLevel));
            }
            if (!aSuccUpdate.isEmpty()) {
                report.append("\nAny objects updated:\n").append(ProvisioningReport.generate(aSuccUpdate, traceLevel));
            }
            if (!aSuccDelete.isEmpty()) {
                report.append("\nAny objects deleted:\n").append(ProvisioningReport.generate(aSuccDelete, traceLevel));
            }
            if (!aSuccNone.isEmpty()) {
                report.append("\nAny objects no operation:\n").append(ProvisioningReport.generate(aSuccNone, traceLevel));
            }
            if (!aIgnore.isEmpty()) {
                report.append("\nAny objects ignored:\n").append(ProvisioningReport.generate(aIgnore, traceLevel));
            }
        }
        if (includeRealm) {
            if (!rSuccCreate.isEmpty()) {
                report.append("\n\nRealms created:\n").append(ProvisioningReport.generate(rSuccCreate, traceLevel));
            }
            if (!rSuccUpdate.isEmpty()) {
                report.append("\nRealms updated:\n").append(ProvisioningReport.generate(rSuccUpdate, traceLevel));
            }
            if (!rSuccDelete.isEmpty()) {
                report.append("\nRealms deleted:\n").append(ProvisioningReport.generate(rSuccDelete, traceLevel));
            }
            if (!rSuccNone.isEmpty()) {
                report.append("\nRealms no operation:\n").append(ProvisioningReport.generate(rSuccNone, traceLevel));
            }
            if (!rIgnore.isEmpty()) {
                report.append("\nRealms ignored:\n").append(ProvisioningReport.generate(rIgnore, traceLevel));
            }
        }
    }
    return report.toString();
}
Also used : ArrayList(java.util.ArrayList) TraceLevel(org.apache.syncope.common.lib.types.TraceLevel) ProvisioningReport(org.apache.syncope.core.provisioning.api.pushpull.ProvisioningReport) AnyType(org.apache.syncope.core.persistence.api.entity.AnyType)

Aggregations

ProvisioningReport (org.apache.syncope.core.provisioning.api.pushpull.ProvisioningReport)21 IgnoreProvisionException (org.apache.syncope.core.provisioning.api.pushpull.IgnoreProvisionException)14 JobExecutionException (org.quartz.JobExecutionException)14 PullActions (org.apache.syncope.core.provisioning.api.pushpull.PullActions)12 ArrayList (java.util.ArrayList)10 Result (org.apache.syncope.common.lib.types.AuditElements.Result)10 PropagationException (org.apache.syncope.core.provisioning.api.propagation.PropagationException)8 DelegatedAdministrationException (org.apache.syncope.core.spring.security.DelegatedAdministrationException)8 AnyTO (org.apache.syncope.common.lib.to.AnyTO)6 RealmTO (org.apache.syncope.common.lib.to.RealmTO)6 Realm (org.apache.syncope.core.persistence.api.entity.Realm)5 SyncopeClientException (org.apache.syncope.common.lib.SyncopeClientException)4 NotFoundException (org.apache.syncope.core.persistence.api.dao.NotFoundException)4 PropagationByResource (org.apache.syncope.core.provisioning.api.PropagationByResource)4 AnyPatch (org.apache.syncope.common.lib.patch.AnyPatch)3 Date (java.util.Date)2 HashMap (java.util.HashMap)2 PropagationTaskTO (org.apache.syncope.common.lib.to.PropagationTaskTO)2 Remediation (org.apache.syncope.core.persistence.api.entity.Remediation)2 OrgUnit (org.apache.syncope.core.persistence.api.entity.resource.OrgUnit)2