Search in sources :

Example 16 with BulkActionResult

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

the class UserRestClient method reactivate.

public BulkActionResult reactivate(final String etag, final String userKey, final List<StatusBean> statuses) {
    StatusPatch statusPatch = StatusUtils.buildStatusPatch(statuses, true);
    statusPatch.setKey(userKey);
    statusPatch.setType(StatusPatchType.REACTIVATE);
    BulkActionResult result;
    synchronized (this) {
        result = new BulkActionResult();
        Map<String, BulkActionResult.Status> res = result.getResults();
        UserService service = getService(etag, UserService.class);
        @SuppressWarnings("unchecked") ProvisioningResult<UserTO> provisions = (ProvisioningResult<UserTO>) service.status(statusPatch).readEntity(ProvisioningResult.class);
        if (statusPatch.isOnSyncope()) {
            res.put(StringUtils.capitalize(Constants.SYNCOPE), "active".equalsIgnoreCase(provisions.getEntity().getStatus()) ? BulkActionResult.Status.SUCCESS : BulkActionResult.Status.FAILURE);
        }
        for (PropagationStatus status : provisions.getPropagationStatuses()) {
            res.put(status.getResource(), BulkActionResult.Status.valueOf(status.getStatus().name()));
        }
        resetClient(UserService.class);
    }
    return result;
}
Also used : PropagationStatus(org.apache.syncope.common.lib.to.PropagationStatus) UserService(org.apache.syncope.common.rest.api.service.UserService) UserTO(org.apache.syncope.common.lib.to.UserTO) ProvisioningResult(org.apache.syncope.common.lib.to.ProvisioningResult) StatusPatch(org.apache.syncope.common.lib.patch.StatusPatch) PropagationStatus(org.apache.syncope.common.lib.to.PropagationStatus) BulkActionResult(org.apache.syncope.common.lib.to.BulkActionResult)

Example 17 with BulkActionResult

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

the class TaskLogic method deleteExecutions.

@PreAuthorize("hasRole('" + StandardEntitlement.TASK_DELETE + "')")
@Override
public BulkActionResult deleteExecutions(final String key, final Date startedBefore, final Date startedAfter, final Date endedBefore, final Date endedAfter) {
    Task task = taskDAO.find(key);
    if (task == null) {
        throw new NotFoundException("Task " + key);
    }
    BulkActionResult result = new BulkActionResult();
    taskExecDAO.findAll(task, startedBefore, startedAfter, endedBefore, endedAfter).forEach(exec -> {
        try {
            taskExecDAO.delete(exec);
            result.getResults().put(String.valueOf(exec.getKey()), BulkActionResult.Status.SUCCESS);
        } catch (Exception e) {
            LOG.error("Error deleting execution {} of task {}", exec.getKey(), key, e);
            result.getResults().put(String.valueOf(exec.getKey()), BulkActionResult.Status.FAILURE);
        }
    });
    return result;
}
Also used : NotificationTask(org.apache.syncope.core.persistence.api.entity.task.NotificationTask) SchedTask(org.apache.syncope.core.persistence.api.entity.task.SchedTask) Task(org.apache.syncope.core.persistence.api.entity.task.Task) NotFoundException(org.apache.syncope.core.persistence.api.dao.NotFoundException) BulkActionResult(org.apache.syncope.common.lib.to.BulkActionResult) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) SchedulerException(org.quartz.SchedulerException) NotFoundException(org.apache.syncope.core.persistence.api.dao.NotFoundException) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Example 18 with BulkActionResult

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

the class ReportLogic method deleteExecutions.

@PreAuthorize("hasRole('" + StandardEntitlement.REPORT_DELETE + "')")
@Override
public BulkActionResult deleteExecutions(final String key, final Date startedBefore, final Date startedAfter, final Date endedBefore, final Date endedAfter) {
    Report report = reportDAO.find(key);
    if (report == null) {
        throw new NotFoundException("Report " + key);
    }
    BulkActionResult result = new BulkActionResult();
    reportExecDAO.findAll(report, startedBefore, startedAfter, endedBefore, endedAfter).forEach(exec -> {
        try {
            reportExecDAO.delete(exec);
            result.getResults().put(String.valueOf(exec.getKey()), BulkActionResult.Status.SUCCESS);
        } catch (Exception e) {
            LOG.error("Error deleting execution {} of report {}", exec.getKey(), key, e);
            result.getResults().put(String.valueOf(exec.getKey()), BulkActionResult.Status.FAILURE);
        }
    });
    return result;
}
Also used : Report(org.apache.syncope.core.persistence.api.entity.Report) NotFoundException(org.apache.syncope.core.persistence.api.dao.NotFoundException) BulkActionResult(org.apache.syncope.common.lib.to.BulkActionResult) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) NotFoundException(org.apache.syncope.core.persistence.api.dao.NotFoundException) SchedulerException(org.quartz.SchedulerException) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Aggregations

BulkActionResult (org.apache.syncope.common.lib.to.BulkActionResult)18 StatusPatch (org.apache.syncope.common.lib.patch.StatusPatch)6 Date (java.util.Date)3 AssociationPatch (org.apache.syncope.common.lib.patch.AssociationPatch)3 DeassociationPatch (org.apache.syncope.common.lib.patch.DeassociationPatch)3 AnyTO (org.apache.syncope.common.lib.to.AnyTO)3 AttrTO (org.apache.syncope.common.lib.to.AttrTO)3 UserTO (org.apache.syncope.common.lib.to.UserTO)3 NotFoundException (org.apache.syncope.core.persistence.api.dao.NotFoundException)3 BadRequestException (javax.ws.rs.BadRequestException)2 SyncopeClientException (org.apache.syncope.common.lib.SyncopeClientException)2 PropagationStatus (org.apache.syncope.common.lib.to.PropagationStatus)2 ProvisioningResult (org.apache.syncope.common.lib.to.ProvisioningResult)2 UserService (org.apache.syncope.common.rest.api.service.UserService)2 Test (org.junit.jupiter.api.Test)2 SchedulerException (org.quartz.SchedulerException)2 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)2 NotSupportedException (javax.ws.rs.NotSupportedException)1 BooleanReplacePatchItem (org.apache.syncope.common.lib.patch.BooleanReplacePatchItem)1 UserPatch (org.apache.syncope.common.lib.patch.UserPatch)1