Search in sources :

Example 11 with PropagationTaskTO

use of org.apache.syncope.common.lib.to.PropagationTaskTO in project syncope by apache.

the class PropagationManagerImpl method createTasks.

@Override
public List<PropagationTaskTO> createTasks(final Realm realm, final PropagationByResource propByRes, final Collection<String> noPropResourceKeys) {
    if (noPropResourceKeys != null) {
        propByRes.removeAll(noPropResourceKeys);
    }
    LOG.debug("Provisioning {}:\n{}", realm, propByRes);
    // Avoid duplicates - see javadoc
    propByRes.purge();
    LOG.debug("After purge {}:\n{}", realm, propByRes);
    List<PropagationTaskTO> tasks = new ArrayList<>();
    propByRes.asMap().forEach((resourceKey, operation) -> {
        ExternalResource resource = resourceDAO.find(resourceKey);
        OrgUnit orgUnit = resource == null ? null : resource.getOrgUnit();
        if (resource == null) {
            LOG.error("Invalid resource name specified: {}, ignoring...", resourceKey);
        } else if (orgUnit == null) {
            LOG.error("No orgUnit specified on resource {}, ignoring...", resource);
        } else if (StringUtils.isBlank(orgUnit.getConnObjectLink())) {
            LOG.warn("Requesting propagation for {} but no ConnObjectLink provided for {}", realm.getFullPath(), resource);
        } else {
            PropagationTaskTO task = new PropagationTaskTO();
            task.setResource(resource.getKey());
            task.setObjectClassName(orgUnit.getObjectClass().getObjectClassValue());
            task.setEntityKey(realm.getKey());
            task.setOperation(operation);
            task.setOldConnObjectKey(propByRes.getOldConnObjectKey(resource.getKey()));
            Pair<String, Set<Attribute>> preparedAttrs = mappingManager.prepareAttrs(realm, orgUnit);
            task.setConnObjectKey(preparedAttrs.getKey());
            task.setAttributes(POJOHelper.serialize(preparedAttrs.getValue()));
            tasks.add(task);
            LOG.debug("PropagationTask created: {}", task);
        }
    });
    return tasks;
}
Also used : OrgUnit(org.apache.syncope.core.persistence.api.entity.resource.OrgUnit) HashSet(java.util.HashSet) Set(java.util.Set) PropagationTaskTO(org.apache.syncope.common.lib.to.PropagationTaskTO) ArrayList(java.util.ArrayList) ExternalResource(org.apache.syncope.core.persistence.api.entity.resource.ExternalResource)

Example 12 with PropagationTaskTO

use of org.apache.syncope.common.lib.to.PropagationTaskTO in project syncope by apache.

the class TaskDetails method details.

public void details() {
    if (input.parameterNumber() == 0) {
        try {
            final Map<String, String> details = new LinkedHashMap<>();
            final List<TaskTO> notificationTaskTOs = taskSyncopeOperations.list(TaskType.NOTIFICATION.name());
            final List<TaskTO> propagationTaskTOs = taskSyncopeOperations.list(TaskType.PROPAGATION.name());
            final List<TaskTO> pushTaskTOs = taskSyncopeOperations.list(TaskType.PUSH.name());
            final List<TaskTO> scheduledTaskTOs = taskSyncopeOperations.list(TaskType.SCHEDULED.name());
            final List<TaskTO> pullTaskTOs = taskSyncopeOperations.list(TaskType.PULL.name());
            final List<JobTO> jobTOs = taskSyncopeOperations.listJobs();
            final int notificationTaskSize = notificationTaskTOs.size();
            final int propagationTaskSize = propagationTaskTOs.size();
            final int pushTaskSize = pushTaskTOs.size();
            final int scheduledTaskSize = scheduledTaskTOs.size();
            final int pullTaskSize = pullTaskTOs.size();
            final int jobsSize = jobTOs.size();
            long notificationNotExecuted = notificationTaskTOs.stream().filter(notificationTaskTO -> !((NotificationTaskTO) notificationTaskTO).isExecuted()).count();
            long propagationNotExecuted = propagationTaskTOs.stream().filter(propagationTaskTO -> ((PropagationTaskTO) propagationTaskTO).getExecutions().isEmpty()).count();
            long pushNotExecuted = pushTaskTOs.stream().filter(pushTaskTO -> ((PushTaskTO) pushTaskTO).getExecutions().isEmpty()).count();
            long scheduledNotExecuted = scheduledTaskTOs.stream().filter(scheduledTaskTO -> ((SchedTaskTO) scheduledTaskTO).getExecutions().isEmpty()).count();
            int pullNotExecuted = 0;
            int pullFull = 0;
            for (final TaskTO pullTaskTO : pullTaskTOs) {
                if (((PullTaskTO) pullTaskTO).getExecutions().isEmpty()) {
                    pullNotExecuted++;
                }
                if (((PullTaskTO) pullTaskTO).getPullMode() == PullMode.FULL_RECONCILIATION) {
                    pullFull++;
                }
            }
            details.put("total number", String.valueOf(notificationTaskSize + propagationTaskSize + pushTaskSize + scheduledTaskSize + pullTaskSize));
            details.put("notification tasks", String.valueOf(notificationTaskSize));
            details.put("notification tasks not executed", String.valueOf(notificationNotExecuted));
            details.put("propagation tasks", String.valueOf(propagationTaskSize));
            details.put("propagation tasks not executed", String.valueOf(propagationNotExecuted));
            details.put("push tasks", String.valueOf(pushTaskSize));
            details.put("push tasks not executed", String.valueOf(pushNotExecuted));
            details.put("scheduled tasks", String.valueOf(scheduledTaskSize));
            details.put("scheduled tasks not executed", String.valueOf(scheduledNotExecuted));
            details.put("pull tasks", String.valueOf(pullTaskSize));
            details.put("pull tasks not executed", String.valueOf(pullNotExecuted));
            details.put("pull tasks with full reconciliation", String.valueOf(pullFull));
            details.put("jobs", String.valueOf(jobsSize));
            taskResultManager.printDetails(details);
        } catch (final SyncopeClientException ex) {
            LOG.error("Error reading details about task", ex);
            taskResultManager.genericError(ex.getMessage());
        } catch (final IllegalArgumentException ex) {
            LOG.error("Error reading details about task", ex);
            taskResultManager.typeNotValidError("task", input.firstParameter(), CommandUtils.fromEnumToArray(TaskType.class));
        }
    } else {
        taskResultManager.commandOptionError(DETAILS_HELP_MESSAGE);
    }
}
Also used : NotificationTaskTO(org.apache.syncope.common.lib.to.NotificationTaskTO) CommandUtils(org.apache.syncope.client.cli.util.CommandUtils) PushTaskTO(org.apache.syncope.common.lib.to.PushTaskTO) Logger(org.slf4j.Logger) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) TaskTO(org.apache.syncope.common.lib.to.TaskTO) PullMode(org.apache.syncope.common.lib.types.PullMode) LoggerFactory(org.slf4j.LoggerFactory) LinkedHashMap(java.util.LinkedHashMap) List(java.util.List) PropagationTaskTO(org.apache.syncope.common.lib.to.PropagationTaskTO) SchedTaskTO(org.apache.syncope.common.lib.to.SchedTaskTO) Input(org.apache.syncope.client.cli.Input) Map(java.util.Map) PullTaskTO(org.apache.syncope.common.lib.to.PullTaskTO) JobTO(org.apache.syncope.common.lib.to.JobTO) TaskType(org.apache.syncope.common.lib.types.TaskType) NotificationTaskTO(org.apache.syncope.common.lib.to.NotificationTaskTO) PushTaskTO(org.apache.syncope.common.lib.to.PushTaskTO) TaskTO(org.apache.syncope.common.lib.to.TaskTO) PropagationTaskTO(org.apache.syncope.common.lib.to.PropagationTaskTO) SchedTaskTO(org.apache.syncope.common.lib.to.SchedTaskTO) PullTaskTO(org.apache.syncope.common.lib.to.PullTaskTO) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) JobTO(org.apache.syncope.common.lib.to.JobTO) LinkedHashMap(java.util.LinkedHashMap)

Example 13 with PropagationTaskTO

use of org.apache.syncope.common.lib.to.PropagationTaskTO in project syncope by apache.

the class DefaultAnyObjectProvisioningManager method deprovision.

@Override
public List<PropagationStatus> deprovision(final String key, final Collection<String> resources, final boolean nullPriorityAsync) {
    PropagationByResource propByRes = new PropagationByResource();
    propByRes.addAll(ResourceOperation.DELETE, resources);
    List<PropagationTaskTO> tasks = propagationManager.getDeleteTasks(AnyTypeKind.ANY_OBJECT, key, propByRes, anyObjectDAO.findAllResourceKeys(key).stream().filter(resource -> !resources.contains(resource)).collect(Collectors.toList()));
    PropagationReporter propagationReporter = taskExecutor.execute(tasks, nullPriorityAsync);
    return propagationReporter.getStatuses();
}
Also used : PropagationTaskTO(org.apache.syncope.common.lib.to.PropagationTaskTO) PropagationByResource(org.apache.syncope.core.provisioning.api.PropagationByResource) PropagationReporter(org.apache.syncope.core.provisioning.api.propagation.PropagationReporter)

Example 14 with PropagationTaskTO

use of org.apache.syncope.common.lib.to.PropagationTaskTO in project syncope by apache.

the class DefaultAnyObjectProvisioningManager method provision.

@Override
public List<PropagationStatus> provision(final String key, final Collection<String> resources, final boolean nullPriorityAsync) {
    PropagationByResource propByRes = new PropagationByResource();
    propByRes.addAll(ResourceOperation.UPDATE, resources);
    List<PropagationTaskTO> tasks = propagationManager.getUpdateTasks(AnyTypeKind.ANY_OBJECT, key, false, null, propByRes, null, null);
    PropagationReporter propagationReporter = taskExecutor.execute(tasks, nullPriorityAsync);
    return propagationReporter.getStatuses();
}
Also used : PropagationTaskTO(org.apache.syncope.common.lib.to.PropagationTaskTO) PropagationByResource(org.apache.syncope.core.provisioning.api.PropagationByResource) PropagationReporter(org.apache.syncope.core.provisioning.api.propagation.PropagationReporter)

Example 15 with PropagationTaskTO

use of org.apache.syncope.common.lib.to.PropagationTaskTO in project syncope by apache.

the class DefaultUserProvisioningManager method delete.

@Transactional(propagation = Propagation.REQUIRES_NEW)
@Override
public List<PropagationStatus> delete(final String key, final Set<String> excludedResources, final boolean nullPriorityAsync) {
    PropagationByResource propByRes = new PropagationByResource();
    propByRes.set(ResourceOperation.DELETE, userDAO.findAllResourceKeys(key));
    // Note here that we can only notify about "delete", not any other
    // task defined in workflow process definition: this because this
    // information could only be available after uwfAdapter.delete(), which
    // will also effectively remove user from db, thus making virtually
    // impossible by NotificationManager to fetch required user information
    List<PropagationTaskTO> tasks = propagationManager.getDeleteTasks(AnyTypeKind.USER, key, propByRes, excludedResources);
    PropagationReporter propagationReporter = taskExecutor.execute(tasks, nullPriorityAsync);
    try {
        uwfAdapter.delete(key);
    } catch (PropagationException e) {
        throw e;
    }
    return propagationReporter.getStatuses();
}
Also used : PropagationException(org.apache.syncope.core.provisioning.api.propagation.PropagationException) PropagationTaskTO(org.apache.syncope.common.lib.to.PropagationTaskTO) PropagationByResource(org.apache.syncope.core.provisioning.api.PropagationByResource) PropagationReporter(org.apache.syncope.core.provisioning.api.propagation.PropagationReporter) Transactional(org.springframework.transaction.annotation.Transactional)

Aggregations

PropagationTaskTO (org.apache.syncope.common.lib.to.PropagationTaskTO)48 PropagationReporter (org.apache.syncope.core.provisioning.api.propagation.PropagationReporter)29 PropagationByResource (org.apache.syncope.core.provisioning.api.PropagationByResource)21 Transactional (org.springframework.transaction.annotation.Transactional)11 Pair (org.apache.commons.lang3.tuple.Pair)10 ArrayList (java.util.ArrayList)9 SyncopeClientException (org.apache.syncope.common.lib.SyncopeClientException)9 UserPatch (org.apache.syncope.common.lib.patch.UserPatch)9 WorkflowResult (org.apache.syncope.core.provisioning.api.WorkflowResult)9 List (java.util.List)8 PropagationException (org.apache.syncope.core.provisioning.api.propagation.PropagationException)8 Map (java.util.Map)7 Test (org.junit.jupiter.api.Test)7 RealmTO (org.apache.syncope.common.lib.to.RealmTO)6 Realm (org.apache.syncope.core.persistence.api.entity.Realm)6 HashSet (java.util.HashSet)5 Collectors (java.util.stream.Collectors)5 UserTO (org.apache.syncope.common.lib.to.UserTO)5 TaskQuery (org.apache.syncope.common.rest.api.beans.TaskQuery)5 ExternalResource (org.apache.syncope.core.persistence.api.entity.resource.ExternalResource)5