You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by il...@apache.org on 2021/02/05 11:43:54 UTC
[syncope] branch master updated: [SYNCOPE-1616] Create
SinglePullJobDelegate / SinglePushJobDelegate / StreamPullJobDelegate /
StreamPushJobDelegate upon request
This is an automated email from the ASF dual-hosted git repository.
ilgrosso pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/syncope.git
The following commit(s) were added to refs/heads/master by this push:
new 95b56b8 [SYNCOPE-1616] Create SinglePullJobDelegate / SinglePushJobDelegate / StreamPullJobDelegate / StreamPushJobDelegate upon request
95b56b8 is described below
commit 95b56b8099933f1cf2f0145a33261d7cd10cc1ae
Author: Francesco Chicchiriccò <il...@apache.org>
AuthorDate: Fri Feb 5 12:37:29 2021 +0100
[SYNCOPE-1616] Create SinglePullJobDelegate / SinglePushJobDelegate / StreamPullJobDelegate / StreamPushJobDelegate upon request
---
.../syncope/core/logic/ReconciliationLogic.java | 53 +++++++++++++---------
.../java/pushpull/SinglePullJobDelegate.java | 2 -
.../java/pushpull/SinglePushJobDelegate.java | 2 -
.../pushpull/stream/StreamPullJobDelegate.java | 2 -
.../pushpull/stream/StreamPushJobDelegate.java | 2 -
.../pushpull/stream/StreamPullJobDelegateTest.java | 19 ++++++--
.../pushpull/stream/StreamPushJobDelegateTest.java | 19 ++++++--
7 files changed, 61 insertions(+), 38 deletions(-)
diff --git a/core/idm/logic/src/main/java/org/apache/syncope/core/logic/ReconciliationLogic.java b/core/idm/logic/src/main/java/org/apache/syncope/core/logic/ReconciliationLogic.java
index 68c92f2..8d39b68 100644
--- a/core/idm/logic/src/main/java/org/apache/syncope/core/logic/ReconciliationLogic.java
+++ b/core/idm/logic/src/main/java/org/apache/syncope/core/logic/ReconciliationLogic.java
@@ -73,19 +73,24 @@ import org.apache.syncope.core.persistence.api.entity.VirSchema;
import org.apache.syncope.core.provisioning.api.pushpull.ConstantReconFilterBuilder;
import org.apache.syncope.core.provisioning.api.pushpull.KeyValueReconFilterBuilder;
import org.apache.syncope.core.provisioning.api.pushpull.ReconFilterBuilder;
-import org.apache.syncope.core.provisioning.java.pushpull.stream.CSVStreamConnector;
import org.apache.syncope.core.provisioning.api.pushpull.SyncopeSinglePullExecutor;
+import org.apache.syncope.core.provisioning.java.pushpull.stream.CSVStreamConnector;
import org.apache.syncope.core.provisioning.api.pushpull.SyncopeSinglePushExecutor;
import org.apache.syncope.core.provisioning.api.pushpull.stream.SyncopeStreamPullExecutor;
-import org.apache.syncope.core.provisioning.api.pushpull.stream.SyncopeStreamPushExecutor;
-import org.apache.syncope.core.provisioning.api.utils.RealmUtils;
import org.apache.syncope.core.provisioning.java.pushpull.InboundMatcher;
import org.apache.syncope.core.provisioning.java.pushpull.OutboundMatcher;
import org.apache.syncope.core.provisioning.java.utils.ConnObjectUtils;
import org.apache.syncope.core.provisioning.java.utils.MappingUtils;
-import org.apache.syncope.core.spring.security.AuthContextUtils;
import org.identityconnectors.framework.common.objects.Attribute;
import org.identityconnectors.framework.common.objects.ConnectorObject;
+import org.apache.syncope.core.provisioning.api.pushpull.stream.SyncopeStreamPushExecutor;
+import org.apache.syncope.core.provisioning.api.utils.RealmUtils;
+import org.apache.syncope.core.provisioning.java.pushpull.SinglePullJobDelegate;
+import org.apache.syncope.core.provisioning.java.pushpull.SinglePushJobDelegate;
+import org.apache.syncope.core.provisioning.java.pushpull.stream.StreamPullJobDelegate;
+import org.apache.syncope.core.provisioning.java.pushpull.stream.StreamPushJobDelegate;
+import org.apache.syncope.core.spring.ApplicationContextProvider;
+import org.apache.syncope.core.spring.security.AuthContextUtils;
import org.identityconnectors.framework.common.objects.OperationOptions;
import org.identityconnectors.framework.common.objects.SearchResult;
import org.identityconnectors.framework.common.objects.SyncDeltaBuilder;
@@ -98,6 +103,7 @@ import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Component;
+import org.springframework.beans.factory.support.AbstractBeanDefinition;
@Component
public class ReconciliationLogic extends AbstractTransactionalLogic<EntityTO> {
@@ -141,18 +147,6 @@ public class ReconciliationLogic extends AbstractTransactionalLogic<EntityTO> {
@Autowired
private ConnectorFactory connFactory;
- @Autowired
- private SyncopeSinglePullExecutor singlePullExecutor;
-
- @Autowired
- private SyncopeSinglePushExecutor singlePushExecutor;
-
- @Autowired
- private SyncopeStreamPushExecutor streamPushExecutor;
-
- @Autowired
- private SyncopeStreamPullExecutor streamPullExecutor;
-
private Provision getProvision(final String anyTypeKey, final String resourceKey) {
AnyType anyType = anyTypeDAO.find(anyTypeKey);
if (anyType == null) {
@@ -335,6 +329,11 @@ public class ReconciliationLogic extends AbstractTransactionalLogic<EntityTO> {
return status;
}
+ private SyncopeSinglePushExecutor singlePushExecutor() {
+ return (SyncopeSinglePushExecutor) ApplicationContextProvider.getBeanFactory().
+ createBean(SinglePushJobDelegate.class, AbstractBeanDefinition.AUTOWIRE_BY_NAME, false);
+ }
+
@PreAuthorize("hasRole('" + IdRepoEntitlement.TASK_EXECUTE + "')")
public List<ProvisioningReport> push(
final String anyTypeKey,
@@ -347,7 +346,7 @@ public class ReconciliationLogic extends AbstractTransactionalLogic<EntityTO> {
SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.Reconciliation);
List<ProvisioningReport> results = new ArrayList<>();
try {
- results.addAll(singlePushExecutor.push(
+ results.addAll(singlePushExecutor().push(
provision,
connFactory.getConnector(provision.getResource()),
getAny(provision, anyKey),
@@ -385,7 +384,7 @@ public class ReconciliationLogic extends AbstractTransactionalLogic<EntityTO> {
inboundMatcher.match(syncDeltaBuilder.build(), provision).stream().findFirst().ifPresent(match -> {
try {
if (match.getMatchTarget() == MatchType.ANY) {
- results.addAll(singlePushExecutor.push(
+ results.addAll(singlePushExecutor().push(
provision,
connFactory.getConnector(provision.getResource()),
match.getAny(),
@@ -394,7 +393,7 @@ public class ReconciliationLogic extends AbstractTransactionalLogic<EntityTO> {
sce.getElements().add(results.get(0).getMessage());
}
} else {
- ProvisioningReport result = singlePushExecutor.push(
+ ProvisioningReport result = singlePushExecutor().push(
provision,
connFactory.getConnector(provision.getResource()),
match.getLinkedAccount(),
@@ -431,7 +430,11 @@ public class ReconciliationLogic extends AbstractTransactionalLogic<EntityTO> {
SyncopeClientException sce = SyncopeClientException.build(ClientExceptionType.Reconciliation);
List<ProvisioningReport> results = new ArrayList<>();
try {
- results.addAll(singlePullExecutor.pull(
+ SyncopeSinglePullExecutor executor =
+ (SyncopeSinglePullExecutor) ApplicationContextProvider.getBeanFactory().
+ createBean(SinglePullJobDelegate.class, AbstractBeanDefinition.AUTOWIRE_BY_NAME, false);
+
+ results.addAll(executor.pull(
provision,
connFactory.getConnector(provision.getResource()),
reconFilterBuilder,
@@ -605,7 +608,10 @@ public class ReconciliationLogic extends AbstractTransactionalLogic<EntityTO> {
os,
columns.toArray(new String[columns.size()]))) {
- return streamPushExecutor.push(
+ SyncopeStreamPushExecutor executor =
+ (SyncopeStreamPushExecutor) ApplicationContextProvider.getBeanFactory().
+ createBean(StreamPushJobDelegate.class, AbstractBeanDefinition.AUTOWIRE_BY_NAME, false);
+ return executor.push(
anyType,
matching,
columns,
@@ -651,7 +657,10 @@ public class ReconciliationLogic extends AbstractTransactionalLogic<EntityTO> {
throw new NotFoundException("Key column '" + spec.getKeyColumn() + "'");
}
- return streamPullExecutor.pull(anyType,
+ SyncopeStreamPullExecutor executor =
+ (SyncopeStreamPullExecutor) ApplicationContextProvider.getBeanFactory().
+ createBean(StreamPullJobDelegate.class, AbstractBeanDefinition.AUTOWIRE_BY_NAME, false);
+ return executor.pull(anyType,
spec.getKeyColumn(),
columns,
spec.getConflictResolutionAction(),
diff --git a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/pushpull/SinglePullJobDelegate.java b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/pushpull/SinglePullJobDelegate.java
index 34d0b75..0b89fad 100644
--- a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/pushpull/SinglePullJobDelegate.java
+++ b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/pushpull/SinglePullJobDelegate.java
@@ -52,9 +52,7 @@ import org.apache.syncope.core.provisioning.java.utils.TemplateUtils;
import org.apache.syncope.core.spring.ImplementationManager;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-@Component
public class SinglePullJobDelegate extends PullJobDelegate implements SyncopeSinglePullExecutor {
@Autowired
diff --git a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/pushpull/SinglePushJobDelegate.java b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/pushpull/SinglePushJobDelegate.java
index f0c4258..8a7f00d 100644
--- a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/pushpull/SinglePushJobDelegate.java
+++ b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/pushpull/SinglePushJobDelegate.java
@@ -41,9 +41,7 @@ import org.apache.syncope.core.provisioning.api.pushpull.UserPushResultHandler;
import org.apache.syncope.core.spring.ImplementationManager;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
-@Component
public class SinglePushJobDelegate extends PushJobDelegate implements SyncopeSinglePushExecutor {
@Autowired
diff --git a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/pushpull/stream/StreamPullJobDelegate.java b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/pushpull/stream/StreamPullJobDelegate.java
index b43a1aa..54e89fb 100644
--- a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/pushpull/stream/StreamPullJobDelegate.java
+++ b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/pushpull/stream/StreamPullJobDelegate.java
@@ -53,14 +53,12 @@ import org.apache.syncope.core.provisioning.api.pushpull.SyncopePullResultHandle
import org.apache.syncope.core.spring.ImplementationManager;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;
-import org.springframework.stereotype.Component;
import org.apache.syncope.core.provisioning.api.pushpull.stream.SyncopeStreamPullExecutor;
import org.apache.syncope.core.provisioning.java.pushpull.PullJobDelegate;
import org.apache.syncope.core.provisioning.java.utils.MappingUtils;
import org.apache.syncope.core.spring.security.SecureRandomUtils;
import org.identityconnectors.framework.common.objects.ObjectClass;
-@Component
public class StreamPullJobDelegate extends PullJobDelegate implements SyncopeStreamPullExecutor {
@Autowired
diff --git a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/pushpull/stream/StreamPushJobDelegate.java b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/pushpull/stream/StreamPushJobDelegate.java
index cf18b9f..79fa6e4 100644
--- a/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/pushpull/stream/StreamPushJobDelegate.java
+++ b/core/provisioning-java/src/main/java/org/apache/syncope/core/provisioning/java/pushpull/stream/StreamPushJobDelegate.java
@@ -50,9 +50,7 @@ import org.identityconnectors.framework.common.objects.ObjectClass;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.support.AbstractBeanDefinition;
-import org.springframework.stereotype.Component;
-@Component
public class StreamPushJobDelegate extends PushJobDelegate implements SyncopeStreamPushExecutor {
@Autowired
diff --git a/core/provisioning-java/src/test/java/org/apache/syncope/core/provisioning/java/pushpull/stream/StreamPullJobDelegateTest.java b/core/provisioning-java/src/test/java/org/apache/syncope/core/provisioning/java/pushpull/stream/StreamPullJobDelegateTest.java
index bb57c94..a47bb75 100644
--- a/core/provisioning-java/src/test/java/org/apache/syncope/core/provisioning/java/pushpull/stream/StreamPullJobDelegateTest.java
+++ b/core/provisioning-java/src/test/java/org/apache/syncope/core/provisioning/java/pushpull/stream/StreamPullJobDelegateTest.java
@@ -40,24 +40,35 @@ import org.apache.syncope.common.lib.to.ProvisioningReport;
import org.apache.syncope.common.rest.api.beans.CSVPullSpec;
import org.apache.syncope.core.provisioning.api.pushpull.stream.SyncopeStreamPullExecutor;
import org.apache.syncope.core.provisioning.java.AbstractTest;
+import org.apache.syncope.core.spring.ApplicationContextProvider;
import org.apache.syncope.core.spring.security.AuthContextUtils;
import org.junit.jupiter.api.Test;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.support.AbstractBeanDefinition;
import org.springframework.transaction.annotation.Transactional;
@Transactional("Master")
public class StreamPullJobDelegateTest extends AbstractTest {
@Autowired
- private SyncopeStreamPullExecutor streamPullExecutor;
-
- @Autowired
private AnyTypeDAO anyTypeDAO;
@Autowired
private UserDAO userDAO;
+ private SyncopeStreamPullExecutor executor;
+
+ private SyncopeStreamPullExecutor executor() {
+ synchronized (this) {
+ if (executor == null) {
+ executor = (SyncopeStreamPullExecutor) ApplicationContextProvider.getBeanFactory().
+ createBean(StreamPullJobDelegate.class, AbstractBeanDefinition.AUTOWIRE_BY_NAME, false);
+ }
+ }
+ return executor;
+ }
+
@Test
public void pull() throws JobExecutionException, IOException {
List<String> columns = List.of(
@@ -96,7 +107,7 @@ public class StreamPullJobDelegateTest extends AbstractTest {
List<String> csvColumns = connector.getColumns(new CSVPullSpec());
assertEquals(columns, csvColumns);
- return streamPullExecutor.pull(
+ return executor().pull(
anyTypeDAO.findUser(),
"username",
columns,
diff --git a/core/provisioning-java/src/test/java/org/apache/syncope/core/provisioning/java/pushpull/stream/StreamPushJobDelegateTest.java b/core/provisioning-java/src/test/java/org/apache/syncope/core/provisioning/java/pushpull/stream/StreamPushJobDelegateTest.java
index 7742760..e127460 100644
--- a/core/provisioning-java/src/test/java/org/apache/syncope/core/provisioning/java/pushpull/stream/StreamPushJobDelegateTest.java
+++ b/core/provisioning-java/src/test/java/org/apache/syncope/core/provisioning/java/pushpull/stream/StreamPushJobDelegateTest.java
@@ -40,23 +40,34 @@ import org.apache.syncope.core.persistence.api.dao.AnyTypeDAO;
import org.apache.syncope.core.persistence.api.dao.UserDAO;
import org.apache.syncope.core.provisioning.api.pushpull.stream.SyncopeStreamPushExecutor;
import org.apache.syncope.core.provisioning.java.AbstractTest;
+import org.apache.syncope.core.spring.ApplicationContextProvider;
import org.apache.syncope.core.spring.security.AuthContextUtils;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.support.AbstractBeanDefinition;
import org.springframework.transaction.annotation.Transactional;
@Transactional("Master")
public class StreamPushJobDelegateTest extends AbstractTest {
@Autowired
- private SyncopeStreamPushExecutor streamPushExecutor;
-
- @Autowired
private AnyTypeDAO anyTypeDAO;
@Autowired
private UserDAO userDAO;
+ private SyncopeStreamPushExecutor executor;
+
+ private SyncopeStreamPushExecutor executor() {
+ synchronized (this) {
+ if (executor == null) {
+ executor = (SyncopeStreamPushExecutor) ApplicationContextProvider.getBeanFactory().
+ createBean(StreamPushJobDelegate.class, AbstractBeanDefinition.AUTOWIRE_BY_NAME, false);
+ }
+ }
+ return executor;
+ }
+
@Test
public void push() throws IOException {
PipedInputStream in = new PipedInputStream();
@@ -74,7 +85,7 @@ public class StreamPushJobDelegateTest extends AbstractTest {
null,
os)) {
- return streamPushExecutor.push(
+ return executor().push(
anyTypeDAO.findUser(),
userDAO.findAll(1, 100),
List.of("username", "firstname", "surname", "email", "status", "loginDate"),