1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 package org.apache.syncope.core.provisioning.java.pushpull;
20
21 import java.util.concurrent.RejectedExecutionException;
22 import org.apache.syncope.core.persistence.api.entity.task.PushTask;
23 import org.apache.syncope.core.provisioning.api.pushpull.ProvisioningProfile;
24 import org.apache.syncope.core.provisioning.api.pushpull.PushActions;
25 import org.apache.syncope.core.provisioning.api.pushpull.SyncopePushExecutor;
26 import org.apache.syncope.core.provisioning.api.pushpull.SyncopePushResultHandler;
27
28 public class PushResultHandlerDispatcher
29 extends SyncopeResultHandlerDispatcher<PushTask, PushActions, SyncopePushResultHandler> {
30
31 protected final SyncopePushExecutor executor;
32
33 public PushResultHandlerDispatcher(
34 final ProvisioningProfile<PushTask, PushActions> profile,
35 final SyncopePushExecutor executor) {
36
37 super(profile);
38 this.executor = executor;
39 }
40
41 public boolean handle(final String anyType, final String anyKey) {
42 if (executor.wasInterruptRequested()) {
43 LOG.debug("Push interrupted");
44 executor.setInterrupted();
45 return false;
46 }
47
48 if (tpte.isEmpty()) {
49 boolean result = nonConcurrentHandler(anyType).handle(anyKey);
50
51 executor.reportHandled(anyType, anyKey);
52
53 return result;
54 }
55
56 try {
57 submit(() -> {
58 suppliers.get(anyType).get().handle(anyKey);
59
60 executor.reportHandled(anyType, anyKey);
61 });
62 return true;
63 } catch (RejectedExecutionException e) {
64 LOG.error("Could not submit push handler for {} {}", anyType, anyKey);
65 return false;
66 }
67 }
68 }