1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.syncope.client.console.tasks;
20
21 import org.apache.syncope.client.console.SyncopeConsoleSession;
22 import org.apache.syncope.client.console.pages.BasePage;
23 import org.apache.syncope.client.console.panels.StartAtTogglePanel;
24 import org.apache.syncope.client.console.rest.TaskRestClient;
25 import org.apache.syncope.client.ui.commons.Constants;
26 import org.apache.syncope.common.lib.SyncopeClientException;
27 import org.apache.wicket.PageReference;
28 import org.apache.wicket.ajax.AjaxRequestTarget;
29 import org.apache.wicket.ajax.markup.html.form.AjaxSubmitLink;
30 import org.apache.wicket.markup.html.WebMarkupContainer;
31 import org.apache.wicket.spring.injection.annot.SpringBean;
32
33 public class TaskStartAtTogglePanel extends StartAtTogglePanel {
34
35 private static final long serialVersionUID = -3195479265440591519L;
36
37 @SpringBean
38 protected TaskRestClient taskRestClient;
39
40 public TaskStartAtTogglePanel(final WebMarkupContainer container, final PageReference pageRef) {
41 super(container, pageRef);
42
43 form.add(new AjaxSubmitLink("dryRun", form) {
44
45 private static final long serialVersionUID = -7978723352517770644L;
46
47 @Override
48 protected void onSubmit(final AjaxRequestTarget target) {
49 try {
50 taskRestClient.startExecution(key, startAtDateModel.getObject(), true);
51 SyncopeConsoleSession.get().success(getString(Constants.OPERATION_SUCCEEDED));
52 toggle(target, false);
53 target.add(container);
54 } catch (SyncopeClientException e) {
55 SyncopeConsoleSession.get().onException(e);
56 LOG.error("While running task {}", key, e);
57 }
58 ((BasePage) pageRef.getPage()).getNotificationPanel().refresh(target);
59 }
60
61 @Override
62 protected void onError(final AjaxRequestTarget target) {
63 ((BasePage) pageRef.getPage()).getNotificationPanel().refresh(target);
64 }
65 });
66 }
67
68 @Override
69 protected TaskRestClient getRestClient() {
70 return taskRestClient;
71 }
72 }