Search in sources :

Example 1 with Report

use of org.apache.syncope.core.persistence.api.entity.Report in project syncope by apache.

the class JPAReportDAO method delete.

@Override
public void delete(final String key) {
    Report report = find(key);
    if (report == null) {
        return;
    }
    delete(report);
}
Also used : Report(org.apache.syncope.core.persistence.api.entity.Report) JPAReport(org.apache.syncope.core.persistence.jpa.entity.JPAReport)

Example 2 with Report

use of org.apache.syncope.core.persistence.api.entity.Report in project syncope by apache.

the class ReportLogic method execute.

@PreAuthorize("hasRole('" + StandardEntitlement.REPORT_EXECUTE + "')")
@Override
public ExecTO execute(final String key, final Date startAt, final boolean dryRun) {
    Report report = reportDAO.find(key);
    if (report == null) {
        throw new NotFoundException("Report " + key);
    }
    if (!report.isActive()) {
        SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.Scheduling);
        sce.getElements().add("Report " + key + " is not active");
        throw sce;
    }
    try {
        jobManager.register(report, startAt, confDAO.find("tasks.interruptMaxRetries", 1L));
        scheduler.getScheduler().triggerJob(JobNamer.getJobKey(report));
    } catch (Exception e) {
        LOG.error("While executing report {}", report, e);
        SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.Scheduling);
        sce.getElements().add(e.getMessage());
        throw sce;
    }
    ExecTO result = new ExecTO();
    result.setJobType(JobType.REPORT);
    result.setRefKey(report.getKey());
    result.setRefDesc(binder.buildRefDesc(report));
    result.setStart(new Date());
    result.setStatus(ReportExecStatus.STARTED.name());
    result.setMessage("Job fired; waiting for results...");
    return result;
}
Also used : ExecTO(org.apache.syncope.common.lib.to.ExecTO) Report(org.apache.syncope.core.persistence.api.entity.Report) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) NotFoundException(org.apache.syncope.core.persistence.api.dao.NotFoundException) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) NotFoundException(org.apache.syncope.core.persistence.api.dao.NotFoundException) SchedulerException(org.quartz.SchedulerException) Date(java.util.Date) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Example 3 with Report

use of org.apache.syncope.core.persistence.api.entity.Report in project syncope by apache.

the class ReportLogic method update.

@PreAuthorize("hasRole('" + StandardEntitlement.REPORT_UPDATE + "')")
public ReportTO update(final ReportTO reportTO) {
    Report report = reportDAO.find(reportTO.getKey());
    if (report == null) {
        throw new NotFoundException("Report " + reportTO.getKey());
    }
    binder.getReport(report, reportTO);
    report = reportDAO.save(report);
    try {
        jobManager.register(report, null, confDAO.find("tasks.interruptMaxRetries", 1L));
    } catch (Exception e) {
        LOG.error("While registering quartz job for report " + report.getKey(), e);
        SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.Scheduling);
        sce.getElements().add(e.getMessage());
        throw sce;
    }
    return binder.getReportTO(report);
}
Also used : Report(org.apache.syncope.core.persistence.api.entity.Report) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) NotFoundException(org.apache.syncope.core.persistence.api.dao.NotFoundException) 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)

Example 4 with Report

use of org.apache.syncope.core.persistence.api.entity.Report in project syncope by apache.

the class ReportLogic method create.

@PreAuthorize("hasRole('" + StandardEntitlement.REPORT_CREATE + "')")
public ReportTO create(final ReportTO reportTO) {
    Report report = entityFactory.newEntity(Report.class);
    binder.getReport(report, reportTO);
    report = reportDAO.save(report);
    try {
        jobManager.register(report, null, confDAO.find("tasks.interruptMaxRetries", 1L));
    } catch (Exception e) {
        LOG.error("While registering quartz job for report " + report.getKey(), e);
        SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.Scheduling);
        sce.getElements().add(e.getMessage());
        throw sce;
    }
    return binder.getReportTO(report);
}
Also used : Report(org.apache.syncope.core.persistence.api.entity.Report) SyncopeClientException(org.apache.syncope.common.lib.SyncopeClientException) 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)

Example 5 with Report

use of org.apache.syncope.core.persistence.api.entity.Report in project syncope by apache.

the class ReportLogic method delete.

@PreAuthorize("hasRole('" + StandardEntitlement.REPORT_DELETE + "')")
public ReportTO delete(final String key) {
    Report report = reportDAO.find(key);
    if (report == null) {
        throw new NotFoundException("Report " + key);
    }
    ReportTO deletedReport = binder.getReportTO(report);
    jobManager.unregister(report);
    reportDAO.delete(report);
    return deletedReport;
}
Also used : Report(org.apache.syncope.core.persistence.api.entity.Report) NotFoundException(org.apache.syncope.core.persistence.api.dao.NotFoundException) ReportTO(org.apache.syncope.common.lib.to.ReportTO) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Aggregations

Report (org.apache.syncope.core.persistence.api.entity.Report)20 NotFoundException (org.apache.syncope.core.persistence.api.dao.NotFoundException)10 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)9 SyncopeClientException (org.apache.syncope.common.lib.SyncopeClientException)7 SchedulerException (org.quartz.SchedulerException)7 AbstractTest (org.apache.syncope.core.persistence.jpa.AbstractTest)6 Test (org.junit.jupiter.api.Test)6 Date (java.util.Date)4 ReportExec (org.apache.syncope.core.persistence.api.entity.ReportExec)4 HashMap (java.util.HashMap)2 BulkActionResult (org.apache.syncope.common.lib.to.BulkActionResult)2 ExecTO (org.apache.syncope.common.lib.to.ExecTO)2 JobTO (org.apache.syncope.common.lib.to.JobTO)2 ReportTO (org.apache.syncope.common.lib.to.ReportTO)2 Transactional (org.springframework.transaction.annotation.Transactional)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 IOException (java.io.IOException)1 OutputStream (java.io.OutputStream)1 Method (java.lang.reflect.Method)1