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.PullTask;
23 import org.apache.syncope.core.provisioning.api.pushpull.ProvisioningProfile;
24 import org.apache.syncope.core.provisioning.api.pushpull.PullActions;
25 import org.apache.syncope.core.provisioning.api.pushpull.SyncopePullExecutor;
26 import org.apache.syncope.core.provisioning.api.pushpull.SyncopePullResultHandler;
27 import org.identityconnectors.framework.common.objects.SyncDelta;
28 import org.identityconnectors.framework.common.objects.SyncResultsHandler;
29 import org.springframework.transaction.annotation.Transactional;
30
31 public class PullResultHandlerDispatcher
32 extends SyncopeResultHandlerDispatcher<PullTask, PullActions, SyncopePullResultHandler>
33 implements SyncResultsHandler {
34
35 protected final SyncopePullExecutor executor;
36
37 public PullResultHandlerDispatcher(
38 final ProvisioningProfile<PullTask, PullActions> profile,
39 final SyncopePullExecutor executor) {
40
41 super(profile);
42 this.executor = executor;
43 }
44
45 @Transactional
46 @Override
47 public boolean handle(final SyncDelta delta) {
48 if (executor.wasInterruptRequested()) {
49 LOG.debug("Pull interrupted");
50 executor.setInterrupted();
51 return false;
52 }
53
54 if (tpte.isEmpty()) {
55 boolean result = nonConcurrentHandler(delta.getObjectClass().getObjectClassValue()).handle(delta);
56
57 executor.reportHandled(delta.getObjectClass().getObjectClassValue(), delta.getObject().getName());
58 if (result) {
59 executor.setLatestSyncToken(delta.getObjectClass().getObjectClassValue(), delta.getToken());
60 }
61
62 return result;
63 }
64
65 try {
66 submit(() -> {
67 executor.setLatestSyncToken(delta.getObjectClass().getObjectClassValue(), delta.getToken());
68
69 suppliers.get(delta.getObjectClass().getObjectClassValue()).get().handle(delta);
70
71 executor.reportHandled(delta.getObjectClass().getObjectClassValue(), delta.getObject().getName());
72 });
73 return true;
74 } catch (RejectedExecutionException e) {
75 LOG.error("Could not submit pull handler for {} {}",
76 delta.getObjectClass().getObjectClassValue(), delta.getObject().getName());
77 return false;
78 }
79 }
80 }