in client/idrepo/console/src/main/java/org/apache/syncope/client/console/widgets/JobWidget.java [386:518]
protected ActionsPanel<JobTO> getActions(final IModel<JobTO> model) {
final ActionsPanel<JobTO> panel = super.getActions(model);
final JobTO jobTO = model.getObject();
panel.add(new ActionLink<>() {
private static final long serialVersionUID = -7978723352517770644L;
@Override
public void onClick(final AjaxRequestTarget target, final JobTO ignore) {
switch (jobTO.getType()) {
case NOTIFICATION -> {
}
case REPORT -> {
ReportTO reportTO = reportRestClient.read(jobTO.getRefKey());
ReportWizardBuilder rwb = new ReportWizardBuilder(
reportTO,
implementationRestClient,
reportRestClient,
mimeTypesLoader,
pageRef);
rwb.setEventSink(AvailableJobsPanel.this);
target.add(jobModal.setContent(rwb.build(BaseModal.CONTENT_ID, AjaxWizard.Mode.EDIT)));
jobModal.header(new StringResourceModel(
"any.edit",
AvailableJobsPanel.this,
new Model<>(reportTO)));
jobModal.show(true);
}
case TASK -> {
TaskType taskType = null;
if (jobTO.getRefDesc().startsWith("SCHEDULED")) {
taskType = TaskType.SCHEDULED;
} else if (jobTO.getRefDesc().startsWith("PULL")) {
taskType = TaskType.PULL;
} else if (jobTO.getRefDesc().startsWith("PUSH")) {
taskType = TaskType.PUSH;
} else if (jobTO.getRefDesc().startsWith("MACRO")) {
taskType = TaskType.MACRO;
}
if (taskType == null) {
break;
}
TaskTO taskTO = null;
try {
taskTO = taskRestClient.readTask(taskType, jobTO.getRefKey());
} catch (Exception e) {
LOG.debug("Failed to read {} as {}", jobTO.getRefKey(), taskType, e);
}
if (taskTO == null) {
break;
}
if (taskTO instanceof ProvisioningTaskTO provisioningTask) {
SchedTaskWizardBuilder<ProvisioningTaskTO> swb = new SchedTaskWizardBuilder<>(
taskType, provisioningTask, realmRestClient, taskRestClient, pageRef);
swb.setEventSink(AvailableJobsPanel.this);
target.add(jobModal.setContent(swb.build(BaseModal.CONTENT_ID, AjaxWizard.Mode.EDIT)));
jobModal.header(new StringResourceModel(
"any.edit",
AvailableJobsPanel.this,
new Model<>(taskTO)));
jobModal.show(true);
} else {
SyncopeConsoleSession.get().info("Unsupported task type: " + taskType.name());
((BasePage) pageRef.getPage()).getNotificationPanel().refresh(target);
}
}
default -> {
}
}
}
@Override
protected boolean statusCondition(final JobTO modelObject) {
return !(null != jobTO.getType() && JobType.NOTIFICATION.equals(jobTO.getType()));
}
}, ActionType.EDIT, IdRepoEntitlement.TASK_UPDATE);
panel.add(new ActionLink<>() {
private static final long serialVersionUID = -3722207913631435501L;
@Override
public void onClick(final AjaxRequestTarget target, final JobTO ignore) {
try {
if (null != jobTO.getType()) {
switch (jobTO.getType()) {
case NOTIFICATION -> {
}
case REPORT ->
reportRestClient.actionJob(jobTO.getRefKey(), JobAction.DELETE);
case TASK ->
taskRestClient.actionJob(jobTO.getRefKey(), JobAction.DELETE);
default -> {
}
}
SyncopeConsoleSession.get().success(getString(Constants.OPERATION_SUCCEEDED));
target.add(container);
}
} catch (SyncopeClientException e) {
LOG.error("While deleting object {}", jobTO.getRefKey(), e);
SyncopeConsoleSession.get().onException(e);
}
((BasePage) pageRef.getPage()).getNotificationPanel().refresh(target);
}
@Override
protected boolean statusCondition(final JobTO modelObject) {
return (null != jobTO.getType()
&& !JobType.NOTIFICATION.equals(jobTO.getType())
&& (jobTO.isScheduled() && !jobTO.isRunning()));
}
}, ActionLink.ActionType.DELETE, IdRepoEntitlement.TASK_DELETE, true);
return panel;
}