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 2018/11/16 11:13:14 UTC

[syncope] branch 2_1_X updated (4ee463d -> 804c64c)

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

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


    from 4ee463d  Upgrading Elasticsearch and CodeMirror
     new 62102ef  [SYNCOPE-1392] Small reflection avoidance
     new 804c64c  [SYNCOPE-1395] Adding docs

The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 core/persistence-jpa-pgjsonb/pom.xml               |  2 +-
 .../src/main/resources/persistence-enhance.xml     |  2 +-
 .../persistence/jpa/dao/AbstractAnySearchDAO.java  | 20 ++---
 .../core/persistence/jpa/dao/JPAAnySearchDAO.java  |  2 -
 .../systemadministration/dbms.adoc                 | 91 +++++++++++++++++++---
 5 files changed, 88 insertions(+), 29 deletions(-)
 copy core/{persistence-jpa => persistence-jpa-pgjsonb}/src/main/resources/persistence-enhance.xml (95%)


[syncope] 01/02: [SYNCOPE-1392] Small reflection avoidance

Posted by il...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 62102ef4b777e1bc7df6def6c701d8d77a196f8a
Author: Francesco Chicchiriccò <il...@apache.org>
AuthorDate: Fri Nov 16 08:43:31 2018 +0100

    [SYNCOPE-1392] Small reflection avoidance
---
 .../persistence/jpa/dao/AbstractAnySearchDAO.java    | 20 +++++---------------
 .../core/persistence/jpa/dao/JPAAnySearchDAO.java    |  2 --
 2 files changed, 5 insertions(+), 17 deletions(-)

diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/AbstractAnySearchDAO.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/AbstractAnySearchDAO.java
index e09ff63..43800e2 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/AbstractAnySearchDAO.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/AbstractAnySearchDAO.java
@@ -20,7 +20,6 @@ package org.apache.syncope.core.persistence.jpa.dao;
 
 import java.lang.annotation.Annotation;
 import java.lang.reflect.Field;
-import java.lang.reflect.Method;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
@@ -30,7 +29,6 @@ import javax.validation.ValidationException;
 import javax.validation.constraints.Max;
 import javax.validation.constraints.Min;
 import org.apache.commons.lang3.ArrayUtils;
-import org.apache.commons.lang3.ClassUtils;
 import org.apache.commons.lang3.tuple.Pair;
 import org.apache.commons.lang3.tuple.Triple;
 import org.apache.syncope.common.lib.SyncopeConstants;
@@ -55,7 +53,6 @@ import org.apache.syncope.core.persistence.api.dao.search.SearchCond;
 import org.apache.syncope.core.persistence.api.entity.Any;
 import org.apache.syncope.core.persistence.api.entity.AnyUtils;
 import org.apache.syncope.core.persistence.api.entity.AnyUtilsFactory;
-import org.apache.syncope.core.persistence.api.entity.Entity;
 import org.apache.syncope.core.persistence.api.entity.EntityFactory;
 import org.apache.syncope.core.persistence.api.entity.PlainAttrValue;
 import org.apache.syncope.core.persistence.api.entity.PlainSchema;
@@ -71,6 +68,8 @@ public abstract class AbstractAnySearchDAO extends AbstractDAO<Any<?>> implement
         "serialVersionUID", "password", "securityQuestion", "securityAnswer", "token", "tokenExpireTime"
     };
 
+    protected static final String[] RELATIONSHIP_FIELDS = new String[] { "realm", "userOwner", "groupOwner" };
+
     @Autowired
     protected RealmDAO realmDAO;
 
@@ -214,18 +213,9 @@ public abstract class AbstractAnySearchDAO extends AbstractDAO<Any<?>> implement
         }
 
         // Deal with any fields representing relationships to other entities
-        if (Entity.class.isAssignableFrom(anyField.getType())) {
-            Method relMethod = null;
-            try {
-                relMethod = ClassUtils.getPublicMethod(anyField.getType(), "getKey", new Class<?>[0]);
-            } catch (Exception e) {
-                LOG.error("Could not find {}#getKey", anyField.getType(), e);
-            }
-
-            if (relMethod != null && String.class.isAssignableFrom(relMethod.getReturnType())) {
-                computed.setSchema(computed.getSchema() + "_id");
-                schema.setType(AttrSchemaType.String);
-            }
+        if (ArrayUtils.contains(RELATIONSHIP_FIELDS, computed.getSchema())) {
+            computed.setSchema(computed.getSchema() + "_id");
+            schema.setType(AttrSchemaType.String);
         }
 
         PlainAttrValue attrValue = anyUtils.newPlainAttrValue();
diff --git a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAAnySearchDAO.java b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAAnySearchDAO.java
index 5810207..02e2535 100644
--- a/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAAnySearchDAO.java
+++ b/core/persistence-jpa/src/main/java/org/apache/syncope/core/persistence/jpa/dao/JPAAnySearchDAO.java
@@ -65,8 +65,6 @@ public class JPAAnySearchDAO extends AbstractAnySearchDAO {
 
     protected static final String EMPTY_QUERY = "SELECT any_id FROM user_search WHERE 1=2";
 
-    protected static final String[] RELATIONSHIP_FIELDS = new String[] { "realm", "userOwner", "groupOwner" };
-
     private Pair<String, Set<String>> getAdminRealmsFilter(
             final Set<String> adminRealms,
             final SearchSupport svs,


[syncope] 02/02: [SYNCOPE-1395] Adding docs

Posted by il...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

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

commit 804c64c87e997639cc90a1a11e7e1b1c5668d67c
Author: Francesco Chicchiriccò <il...@apache.org>
AuthorDate: Fri Nov 16 12:12:32 2018 +0100

    [SYNCOPE-1395] Adding docs
---
 core/persistence-jpa-pgjsonb/pom.xml               |  2 +-
 .../src/main/resources/persistence-enhance.xml     | 31 ++++++++
 .../systemadministration/dbms.adoc                 | 91 +++++++++++++++++++---
 3 files changed, 113 insertions(+), 11 deletions(-)

diff --git a/core/persistence-jpa-pgjsonb/pom.xml b/core/persistence-jpa-pgjsonb/pom.xml
index 831f9fb..0fe11d7 100644
--- a/core/persistence-jpa-pgjsonb/pom.xml
+++ b/core/persistence-jpa-pgjsonb/pom.xml
@@ -92,7 +92,7 @@ under the License.
           </dependency>
         </dependencies>
         <configuration>
-          <persistenceXmlFile>${project.basedir}/../persistence-jpa/src/main/resources/persistence-enhance.xml</persistenceXmlFile> 
+          <persistenceXmlFile>src/main/resources/persistence-enhance.xml</persistenceXmlFile> 
           <includes>org/apache/syncope/core/persistence/jpa/entity/**/*.class</includes>
           <connectionDriverName>org.springframework.jdbc.datasource.DriverManagerDataSource</connectionDriverName>
           <connectionProperties>
diff --git a/core/persistence-jpa-pgjsonb/src/main/resources/persistence-enhance.xml b/core/persistence-jpa-pgjsonb/src/main/resources/persistence-enhance.xml
new file mode 100644
index 0000000..718f229
--- /dev/null
+++ b/core/persistence-jpa-pgjsonb/src/main/resources/persistence-enhance.xml
@@ -0,0 +1,31 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+Licensed to the Apache Software Foundation (ASF) under one
+or more contributor license agreements.  See the NOTICE file
+distributed with this work for additional information
+regarding copyright ownership.  The ASF licenses this file
+to you under the Apache License, Version 2.0 (the
+"License"); you may not use this file except in compliance
+with the License.  You may obtain a copy of the License at
+
+  http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing,
+software distributed under the License is distributed on an
+"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+KIND, either express or implied.  See the License for the
+specific language governing permissions and limitations
+under the License.
+-->
+<persistence xmlns="http://java.sun.com/xml/ns/persistence"
+             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+             xsi:schemaLocation="http://java.sun.com/xml/ns/persistence
+                                 http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd"
+             version="2.0">
+  
+  <persistence-unit name="Master">
+    <mapping-file>META-INF/spring-orm-pgjsonb.xml</mapping-file>
+    <validation-mode>NONE</validation-mode>
+  </persistence-unit>
+  
+</persistence>
diff --git a/src/main/asciidoc/reference-guide/workingwithapachesyncope/systemadministration/dbms.adoc b/src/main/asciidoc/reference-guide/workingwithapachesyncope/systemadministration/dbms.adoc
index 038870b..f30c541 100644
--- a/src/main/asciidoc/reference-guide/workingwithapachesyncope/systemadministration/dbms.adoc
+++ b/src/main/asciidoc/reference-guide/workingwithapachesyncope/systemadministration/dbms.adoc
@@ -27,14 +27,14 @@ updated.
 [NOTE]
 Apache Syncope {docVersion} is verified with PostgreSQL server >= 10.3 and JDBC driver >= {postgresqlJDBC}.
 
-In `provisioning.properties`:
+In `provisioning.properties`, replace as follows:
 
 ....
 quartz.jobstore=org.quartz.impl.jdbcjobstore.PostgreSQLDelegate
 quartz.sql=tables_postgres.sql
 ....
 
-In `domains/Master.properties` (for the `Master` domain):
+In `domains/Master.properties` (for the `Master` domain), replace as follows:
 
 ....
 Master.driverClassName=org.postgresql.Driver
@@ -59,12 +59,83 @@ https://github.com/apache/syncope/tree/2_1_X/fit/core-reference/src/main/resourc
 endif::[]
 and save it under `core/src/main/resources/`.
 
+===== PostgreSQL (JSONB)
+
+[NOTE]
+With the configurations reported below, Apache Syncope will leverage the
+https://www.postgresql.org/docs/current/datatype-json.html[JSONB^] column type for attribute storage.
+
+[NOTE]
+Apache Syncope {docVersion} is verified with PostgreSQL server >= 10.3 and JDBC driver >= {postgresqlJDBC}.
+
+In `persistence.properties`, replace as follows:
+
+....
+entity.factory=org.apache.syncope.core.persistence.jpa.entity.PGJPAEntityFactory
+plainSchema.dao=org.apache.syncope.core.persistence.jpa.dao.PGJPAPlainSchemaDAO
+plainAttr.dao=org.apache.syncope.core.persistence.jpa.dao.PGJPAPlainAttrDAO
+plainAttrValue.dao=org.apache.syncope.core.persistence.jpa.dao.PGJPAPlainAttrValueDAO
+any.search.dao=org.apache.syncope.core.persistence.jpa.dao.PGJPAAnySearchDAO
+user.dao=org.apache.syncope.core.persistence.jpa.dao.PGJPAUserDAO
+group.dao=org.apache.syncope.core.persistence.jpa.dao.PGJPAGroupDAO
+anyObject.dao=org.apache.syncope.core.persistence.jpa.dao.PGJPAAnyObjectDAO
+conf.dao=org.apache.syncope.core.persistence.jpa.dao.PGJPAConfDAO
+....
+
+In `provisioning.properties`, replace as follows:
+
+....
+quartz.jobstore=org.quartz.impl.jdbcjobstore.PostgreSQLDelegate
+quartz.sql=tables_postgres.sql
+....
+
+In `domains/Master.properties` (for the `Master` domain), replace as follows:
+
+....
+Master.driverClassName=org.postgresql.Driver
+Master.url=jdbc:postgresql://localhost:5432/syncope?stringtype=unspecified
+Master.schema=
+Master.username=syncope
+Master.password=syncope
+Master.databasePlatform=org.apache.openjpa.jdbc.sql.PostgresDictionary
+Master.orm=META-INF/spring-orm-pgjsonb.xml
+....
+
+[WARNING]
+This assumes that you have a PostgreSQL instance running on localhost, listening on its default port 5432 with a
+database `syncope` fully accessible by user `syncope` with password `syncope`.
+
+Download
+ifeval::["{snapshotOrRelease}" == "release"]
+https://github.com/apache/syncope/blob/syncope-{docVersion}/fit/core-reference/src/main/resources/pgjsonb/indexes.xml[indexes.xml^]
+endif::[]
+ifeval::["{snapshotOrRelease}" == "snapshot"]
+https://github.com/apache/syncope/tree/2_1_X/fit/core-reference/src/main/resources/pgjsonb/indexes.xml[indexes.xml^]
+endif::[]
+and
+ifeval::["{snapshotOrRelease}" == "release"]
+https://github.com/apache/syncope/blob/syncope-{docVersion}/fit/core-reference/src/main/resources/pgjsonb/views.xml[views.xml^]
+endif::[]
+ifeval::["{snapshotOrRelease}" == "snapshot"]
+https://github.com/apache/syncope/tree/2_1_X/fit/core-reference/src/main/resources/pgjsonb/views.xml[views.xml^]
+endif::[]
+then save both under `core/src/main/resources/`.
+
+Download
+ifeval::["{snapshotOrRelease}" == "release"]
+https://github.com/apache/syncope/blob/syncope-{docVersion/core/persistence-jpa-pgjsonb/src/test/resources/domains/MasterContent.xml[MasterContent.xml^]
+endif::[]
+ifeval::["{snapshotOrRelease}" == "snapshot"]
+https://github.com/apache/syncope/blob/2_1_X/core/persistence-jpa-pgjsonb/src/test/resources/domains/MasterContent.xml[MasterContent.xml^]
+endif::[]
+and save it under `core/src/test/resources/`.
+
 ===== MySQL
 
 [NOTE]
 Apache Syncope {docVersion} is verified with MySQL server >= 5.7 and JDBC driver >= {mysqlJDBC}.
 
-In `provisioning.properties`:
+In `provisioning.properties`, replace as follows:
 
 ....
 quartz.jobstore=org.quartz.impl.jdbcjobstore.StdJDBCDelegate
@@ -75,7 +146,7 @@ quartz.sql=tables_mysql_innodb.sql
 This assumes that the InnoDB engine is enabled in your MySQL instance - if this is not the case, then change the value
 for `quartz.sql` to `tables_mysql.sql`.
 
-In `domains/Master.properties` (for the `Master` domain):
+In `domains/Master.properties` (for the `Master` domain), replace as follows:
 
 ....
 Master.driverClassName=com.mysql.jdbc.Driver
@@ -104,7 +175,7 @@ This assumes that you have a MySQL instance running on localhost, listening on i
 [NOTE]
 Apache Syncope {docVersion} is verified with MariaDB server >= 10.3.7 and JDBC driver >= {mariadbJDBC}.
 
-In `provisioning.properties`:
+In `provisioning.properties`, replace as follows:
 
 ....
 quartz.jobstore=org.quartz.impl.jdbcjobstore.StdJDBCDelegate
@@ -115,7 +186,7 @@ quartz.sql=tables_mariadb.sql
 This assumes that the InnoDB engine is enabled in your MariaDB instance - if this is not the case, then change the value
 for `quartz.sql` to `tables_mariadb.sql`.
 
-In `domains/Master.properties` (for the `Master` domain):
+In `domains/Master.properties` (for the `Master` domain), replace as follows:
 
 ....
 Master.driverClassName=org.mariadb.jdbc.Driver
@@ -139,14 +210,14 @@ This assumes that you have a MariaDB instance running on localhost, listening on
 [NOTE]
 Apache Syncope {docVersion} is verified with Oracle database >= 11g and JDBC driver >= ojdbc8 12.2.0.1.
 
-In `provisioning.properties`:
+In `provisioning.properties`, replace as follows:
 
 ....
 quartz.jobstore=org.quartz.impl.jdbcjobstore.oracle.OracleDelegate
 quartz.sql=tables_oracle.sql
 ....
 
-In `domains/Master.properties` (for the `Master` domain):
+In `domains/Master.properties` (for the `Master` domain), replace as follows:
 
 ....
 Master.driverClassName=oracle.jdbc.OracleDriver
@@ -168,14 +239,14 @@ This assumes that you have an Oracle instance running on localhost, listening on
 [NOTE]
 Apache Syncope {docVersion} is verified with MS SQL server >= 2017 and JDBC driver >= {sqlserverJDBC}8.
 
-In `provisioning.properties`:
+In `provisioning.properties`, replace as follows:
 
 ....
 quartz.jobstore=org.quartz.impl.jdbcjobstore.MSSQLDelegate
 quartz.sql=tables_sqlServer.sql
 ....
 
-In `domains/Master.properties` (for the `Master` domain):
+In `domains/Master.properties` (for the `Master` domain), replace as follows:
 
 ....
 Master.driverClassName=com.microsoft.sqlserver.jdbc.SQLServerDriver