You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@syncope.apache.org by an...@apache.org on 2019/12/03 08:08:06 UTC

[syncope] branch 2_1_X updated: improved pull correlation rule generation in core upgrader

This is an automated email from the ASF dual-hosted git repository.

andreapatricelli pushed a commit to branch 2_1_X
in repository https://gitbox.apache.org/repos/asf/syncope.git


The following commit(s) were added to refs/heads/2_1_X by this push:
     new 7e22e67  improved pull correlation rule generation in core upgrader
7e22e67 is described below

commit 7e22e67b573cd51b3567b2644150c95c837127a9
Author: Andrea Patricelli <an...@apache.org>
AuthorDate: Tue Dec 3 09:07:51 2019 +0100

    improved pull correlation rule generation in core upgrader
---
 .../syncope/core/upgrade/GenerateUpgradeSQL.java   | 23 +++++++++++++---------
 .../core/upgrade/GeneratedUpgradeSQLTest.java      |  2 +-
 2 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/core/upgrade/src/main/java/org/apache/syncope/core/upgrade/GenerateUpgradeSQL.java b/core/upgrade/src/main/java/org/apache/syncope/core/upgrade/GenerateUpgradeSQL.java
index 014b6ca..e2fe35d 100644
--- a/core/upgrade/src/main/java/org/apache/syncope/core/upgrade/GenerateUpgradeSQL.java
+++ b/core/upgrade/src/main/java/org/apache/syncope/core/upgrade/GenerateUpgradeSQL.java
@@ -119,16 +119,21 @@ public final class GenerateUpgradeSQL {
                 if (specification.has("correlationRules")) {
                     specification.get("correlationRules").fields().forEachRemaining(entry -> {
                         ObjectNode body = MAPPER.createObjectNode();
-                        if ((entry.getValue().asText().contains("org.apache.syncope"))) {
-                            final String confClassName = entry.getValue().asText() + "Conf";
-                            body.put("@class", confClassName);
-                            body.put("name", confClassName);
-                        } else {
-                            body.put("@class", "org.apache.syncope.common.lib.policy.DefaultPullCorrelationRuleConf");
-                            body.put("name", "org.apache.syncope.common.lib.policy.DefaultPullCorrelationRuleConf");
-                            body.set("schemas", entry.getValue());
-                        }
                         try {
+                            final String pullRuleClass = entry.getValue().asText();
+                            if ((pullRuleClass.contains("org.apache.syncope"))) {
+                                final String confClassName = "org.apache.syncope.common.lib.policy."
+                                        + pullRuleClass.substring(pullRuleClass.lastIndexOf(".")).replace(".", "")
+                                        + "Conf";
+                                body.put("@class", confClassName);
+                                body.put("name", confClassName);
+                            } else {
+                                body.
+                                        put("@class",
+                                                "org.apache.syncope.common.lib.policy.DefaultPullCorrelationRuleConf");
+                                body.put("name", "org.apache.syncope.common.lib.policy.DefaultPullCorrelationRuleConf");
+                                body.set("schemas", entry.getValue());
+                            }
                             String implementationId = "PullCorrelationRule_" + entry.getKey() + "_" + id;
                             OUT.write("INSERT INTO Implementation(id,type,engine,body) VALUES("
                                     + "'" + implementationId + "',"
diff --git a/core/upgrade/src/test/java/org/apache/syncope/core/upgrade/GeneratedUpgradeSQLTest.java b/core/upgrade/src/test/java/org/apache/syncope/core/upgrade/GeneratedUpgradeSQLTest.java
index af16116..ecf87d6 100644
--- a/core/upgrade/src/test/java/org/apache/syncope/core/upgrade/GeneratedUpgradeSQLTest.java
+++ b/core/upgrade/src/test/java/org/apache/syncope/core/upgrade/GeneratedUpgradeSQLTest.java
@@ -60,7 +60,7 @@ public class GeneratedUpgradeSQLTest {
     @Autowired
     private DataSource syncope20DataSource;
 
-    private static final String TEST_PULL_RULE = "org.apache.syncope.fit.core.reference.TestPullRuleConf";
+    private static final String TEST_PULL_RULE = "org.apache.syncope.common.lib.policy.TestPullRuleConf";
 
     @Test
     public void upgradefrom20() throws Exception {