Search in sources :

Example 1 with JobTO

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

the class SchedTaskITCase method issueSYNCOPE660.

@Test
public void issueSYNCOPE660() {
    List<JobTO> jobs = taskService.listJobs();
    int old_size = jobs.size();
    ImplementationTO taskJobDelegate = implementationService.read(ImplementationType.TASKJOB_DELEGATE, TestSampleJobDelegate.class.getSimpleName());
    assertNotNull(taskJobDelegate);
    SchedTaskTO task = new SchedTaskTO();
    task.setName("issueSYNCOPE660");
    task.setDescription("issueSYNCOPE660 Description");
    task.setJobDelegate(taskJobDelegate.getKey());
    Response response = taskService.create(TaskType.SCHEDULED, task);
    task = getObject(response.getLocation(), TaskService.class, SchedTaskTO.class);
    jobs = taskService.listJobs();
    assertEquals(old_size + 1, jobs.size());
    taskService.actionJob(task.getKey(), JobAction.START);
    int i = 0, maxit = 50;
    do {
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
        // ignore
        }
        jobs = taskService.listJobs().stream().filter(job -> job.isRunning()).collect(Collectors.toList());
        i++;
    } while (jobs.size() < 1 && i < maxit);
    assertEquals(1, jobs.size());
    assertEquals(task.getKey(), jobs.get(0).getRefKey());
    taskService.actionJob(task.getKey(), JobAction.STOP);
    i = 0;
    do {
        try {
            Thread.sleep(1000);
        } catch (InterruptedException e) {
        // ignore
        }
        jobs = taskService.listJobs().stream().filter(job -> job.isRunning()).collect(Collectors.toList());
        i++;
    } while (jobs.size() >= 1 && i < maxit);
    assertTrue(jobs.isEmpty());
}
Also used : ImplementationTO(org.apache.syncope.common.lib.to.ImplementationTO) Response(javax.ws.rs.core.Response) SchedTaskTO(org.apache.syncope.common.lib.to.SchedTaskTO) TaskService(org.apache.syncope.common.rest.api.service.TaskService) TestSampleJobDelegate(org.apache.syncope.fit.core.reference.TestSampleJobDelegate) JobTO(org.apache.syncope.common.lib.to.JobTO) Test(org.junit.jupiter.api.Test)

Example 2 with JobTO

use of org.apache.syncope.common.lib.to.JobTO 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 3 with JobTO

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

the class ReportLogic method getJob.

@PreAuthorize("hasRole('" + StandardEntitlement.REPORT_READ + "')")
@Override
public JobTO getJob(final String key) {
    Report report = reportDAO.find(key);
    if (report == null) {
        throw new NotFoundException("Report " + key);
    }
    JobTO jobTO = null;
    try {
        jobTO = getJobTO(JobNamer.getJobKey(report));
    } catch (SchedulerException e) {
        LOG.error("Problems while retrieving scheduled job {}", JobNamer.getJobKey(report), e);
        SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.Scheduling);
        sce.getElements().add(e.getMessage());
        throw sce;
    }
    if (jobTO == null) {
        throw new NotFoundException("Job for report " + key);
    }
    return jobTO;
}
Also used : SchedulerException(org.quartz.SchedulerException) 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) JobTO(org.apache.syncope.common.lib.to.JobTO) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize)

Example 4 with JobTO

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

the class ReportDirectoryPanel method getColumns.

@Override
protected List<IColumn<ReportTO, String>> getColumns() {
    final List<IColumn<ReportTO, String>> columns = new ArrayList<>();
    columns.add(new KeyPropertyColumn<>(new StringResourceModel("key", this), "key"));
    columns.add(new PropertyColumn<>(new StringResourceModel("name", this), "name", "name"));
    columns.add(new DatePropertyColumn<>(new StringResourceModel("lastExec", this), "lastExec", "lastExec"));
    columns.add(new DatePropertyColumn<>(new StringResourceModel("nextExec", this), "nextExec", "nextExec"));
    columns.add(new DatePropertyColumn<>(new StringResourceModel("start", this), "start", "start"));
    columns.add(new DatePropertyColumn<>(new StringResourceModel("end", this), "end", "end"));
    columns.add(new PropertyColumn<>(new StringResourceModel("latestExecStatus", this), "latestExecStatus", "latestExecStatus"));
    columns.add(new BooleanPropertyColumn<>(new StringResourceModel("active", this), "active", "active"));
    columns.add(new AbstractColumn<ReportTO, String>(new Model<>(""), "running") {

        private static final long serialVersionUID = 4209532514416998046L;

        @Override
        public void populateItem(final Item<ICellPopulator<ReportTO>> cellItem, final String componentId, final IModel<ReportTO> rowModel) {
            JobTO jobTO = restClient.getJob(rowModel.getObject().getKey());
            JobActionPanel panel = new JobActionPanel(componentId, jobTO, false, ReportDirectoryPanel.this, pageRef);
            MetaDataRoleAuthorizationStrategy.authorize(panel, WebPage.ENABLE, String.format("%s,%s", StandardEntitlement.TASK_EXECUTE, StandardEntitlement.TASK_UPDATE));
            cellItem.add(panel);
        }

        @Override
        public String getCssClass() {
            return "col-xs-1";
        }
    });
    return columns;
}
Also used : ArrayList(java.util.ArrayList) ReportTO(org.apache.syncope.common.lib.to.ReportTO) ICellPopulator(org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator) JobActionPanel(org.apache.syncope.client.console.widgets.JobActionPanel) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) StringResourceModel(org.apache.wicket.model.StringResourceModel) CompoundPropertyModel(org.apache.wicket.model.CompoundPropertyModel) IModel(org.apache.wicket.model.IModel) Model(org.apache.wicket.model.Model) StringResourceModel(org.apache.wicket.model.StringResourceModel) JobTO(org.apache.syncope.common.lib.to.JobTO)

Example 5 with JobTO

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

the class ProvisioningTaskDirectoryPanel method getFieldColumns.

@Override
protected List<IColumn<T, String>> getFieldColumns() {
    List<IColumn<T, String>> columns = new ArrayList<>();
    columns.add(new KeyPropertyColumn<>(new StringResourceModel("key", this), "key"));
    columns.add(new PropertyColumn<>(new StringResourceModel("name", this), "name", "name"));
    columns.add(new PropertyColumn<>(new StringResourceModel("description", this), "description", "description"));
    if (reference == PullTaskTO.class) {
        columns.add(new PropertyColumn<>(new StringResourceModel("destinationRealm", this), "destinationRealm", "destinationRealm"));
    } else if (reference == PushTaskTO.class) {
        columns.add(new PropertyColumn<>(new StringResourceModel("sourceRealm", this), "sourceRealm", "sourceRealm"));
    }
    columns.add(new DatePropertyColumn<>(new StringResourceModel("lastExec", this), "lastExec", "lastExec"));
    columns.add(new DatePropertyColumn<>(new StringResourceModel("nextExec", this), "nextExec", "nextExec"));
    columns.add(new PropertyColumn<>(new StringResourceModel("latestExecStatus", this), "latestExecStatus", "latestExecStatus"));
    columns.add(new BooleanPropertyColumn<>(new StringResourceModel("active", this), "active", "active"));
    columns.add(new AbstractColumn<T, String>(new Model<>(""), "running") {

        private static final long serialVersionUID = -4008579357070833846L;

        @Override
        public void populateItem(final Item<ICellPopulator<T>> cellItem, final String componentId, final IModel<T> rowModel) {
            JobTO jobTO = restClient.getJob(rowModel.getObject().getKey());
            JobActionPanel panel = new JobActionPanel(componentId, jobTO, false, ProvisioningTaskDirectoryPanel.this, pageRef);
            MetaDataRoleAuthorizationStrategy.authorize(panel, WebPage.ENABLE, String.format("%s,%s", StandardEntitlement.TASK_EXECUTE, StandardEntitlement.TASK_UPDATE));
            cellItem.add(panel);
        }

        @Override
        public String getCssClass() {
            return "col-xs-1";
        }
    });
    return columns;
}
Also used : DatePropertyColumn(org.apache.syncope.client.console.wicket.extensions.markup.html.repeater.data.table.DatePropertyColumn) KeyPropertyColumn(org.apache.syncope.client.console.wicket.extensions.markup.html.repeater.data.table.KeyPropertyColumn) BooleanPropertyColumn(org.apache.syncope.client.console.wicket.extensions.markup.html.repeater.data.table.BooleanPropertyColumn) PropertyColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.PropertyColumn) ArrayList(java.util.ArrayList) ICellPopulator(org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator) JobActionPanel(org.apache.syncope.client.console.widgets.JobActionPanel) IColumn(org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn) PushTaskTO(org.apache.syncope.common.lib.to.PushTaskTO) StringResourceModel(org.apache.wicket.model.StringResourceModel) IModel(org.apache.wicket.model.IModel) Model(org.apache.wicket.model.Model) StringResourceModel(org.apache.wicket.model.StringResourceModel) JobTO(org.apache.syncope.common.lib.to.JobTO)

Aggregations

JobTO (org.apache.syncope.common.lib.to.JobTO)7 SyncopeClientException (org.apache.syncope.common.lib.SyncopeClientException)3 ArrayList (java.util.ArrayList)2 JobActionPanel (org.apache.syncope.client.console.widgets.JobActionPanel)2 PushTaskTO (org.apache.syncope.common.lib.to.PushTaskTO)2 SchedTaskTO (org.apache.syncope.common.lib.to.SchedTaskTO)2 NotFoundException (org.apache.syncope.core.persistence.api.dao.NotFoundException)2 ICellPopulator (org.apache.wicket.extensions.markup.html.repeater.data.grid.ICellPopulator)2 IColumn (org.apache.wicket.extensions.markup.html.repeater.data.table.IColumn)2 IModel (org.apache.wicket.model.IModel)2 Model (org.apache.wicket.model.Model)2 StringResourceModel (org.apache.wicket.model.StringResourceModel)2 SchedulerException (org.quartz.SchedulerException)2 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)2 LinkedHashMap (java.util.LinkedHashMap)1 List (java.util.List)1 Map (java.util.Map)1 Response (javax.ws.rs.core.Response)1 Input (org.apache.syncope.client.cli.Input)1 CommandUtils (org.apache.syncope.client.cli.util.CommandUtils)1