Return-Path: X-Original-To: apmail-syncope-commits-archive@www.apache.org Delivered-To: apmail-syncope-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id DF52018028 for ; Fri, 21 Aug 2015 14:04:19 +0000 (UTC) Received: (qmail 82114 invoked by uid 500); 21 Aug 2015 14:04:19 -0000 Delivered-To: apmail-syncope-commits-archive@syncope.apache.org Received: (qmail 82043 invoked by uid 500); 21 Aug 2015 14:04:19 -0000 Mailing-List: contact commits-help@syncope.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@syncope.apache.org Delivered-To: mailing list commits@syncope.apache.org Received: (qmail 82028 invoked by uid 99); 21 Aug 2015 14:04:19 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 21 Aug 2015 14:04:19 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 9A707E10B1; Fri, 21 Aug 2015 14:04:19 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: ilgrosso@apache.org To: commits@syncope.apache.org Date: Fri, 21 Aug 2015 14:04:20 -0000 Message-Id: <822efc1bbc2242518804658f9eac321a@git.apache.org> In-Reply-To: <37ddfa2322bc4a628fb83c70d189edeb@git.apache.org> References: <37ddfa2322bc4a628fb83c70d189edeb@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [2/3] syncope git commit: Fixing archetype AND standalone after SYNCOPE-620 Fixing archetype AND standalone after SYNCOPE-620 Project: http://git-wip-us.apache.org/repos/asf/syncope/repo Commit: http://git-wip-us.apache.org/repos/asf/syncope/commit/ec6bcf2f Tree: http://git-wip-us.apache.org/repos/asf/syncope/tree/ec6bcf2f Diff: http://git-wip-us.apache.org/repos/asf/syncope/diff/ec6bcf2f Branch: refs/heads/master Commit: ec6bcf2f8979b76c7708f9590c786422bad56255 Parents: 213fbc6 Author: Francesco Chicchiriccò Authored: Fri Aug 21 15:19:12 2015 +0200 Committer: Francesco Chicchiriccò Committed: Fri Aug 21 15:19:12 2015 +0200 ---------------------------------------------------------------------- archetype/pom.xml | 4 +- .../archetype-resources/console/pom.xml | 3 +- .../test/resources/domains/MasterContent.xml | 2 +- .../src/test/resources/domains/Two.properties | 2 +- .../resources/scriptedsql/CreateScript.groovy | 52 ----------- .../resources/scriptedsql/DeleteScript.groovy | 43 --------- .../resources/scriptedsql/SchemaScript.groovy | 50 ---------- .../resources/scriptedsql/SearchScript.groovy | 94 ------------------- .../resources/scriptedsql/SyncScript.groovy | 98 -------------------- .../resources/scriptedsql/TestScript.groovy | 31 ------- .../resources/scriptedsql/UpdateScript.groovy | 67 ------------- .../resources/scriptedsql/CreateScript.groovy | 52 +++++++++++ .../resources/scriptedsql/DeleteScript.groovy | 43 +++++++++ .../resources/scriptedsql/SchemaScript.groovy | 50 ++++++++++ .../resources/scriptedsql/SearchScript.groovy | 94 +++++++++++++++++++ .../resources/scriptedsql/SyncScript.groovy | 98 ++++++++++++++++++++ .../resources/scriptedsql/TestScript.groovy | 31 +++++++ .../resources/scriptedsql/UpdateScript.groovy | 67 +++++++++++++ pom.xml | 2 +- standalone/pom.xml | 16 +++- standalone/src/main/resources/setenv.bat | 2 +- standalone/src/main/resources/setenv.sh | 2 +- 22 files changed, 457 insertions(+), 446 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/syncope/blob/ec6bcf2f/archetype/pom.xml ---------------------------------------------------------------------- diff --git a/archetype/pom.xml b/archetype/pom.xml index f22303b..a921a3c 100644 --- a/archetype/pom.xml +++ b/archetype/pom.xml @@ -175,8 +175,8 @@ under the License. - ../fit/core-reference/src/main/resources/scriptedsql - ${project.build.outputDirectory}/archetype-resources/core/src/main/resources/scriptedsql + ../fit/core-reference/src/test/resources/scriptedsql + ${project.build.outputDirectory}/archetype-resources/core/src/test/resources/scriptedsql ../fit/core-reference/src/main/resources http://git-wip-us.apache.org/repos/asf/syncope/blob/ec6bcf2f/archetype/src/main/resources/archetype-resources/console/pom.xml ---------------------------------------------------------------------- diff --git a/archetype/src/main/resources/archetype-resources/console/pom.xml b/archetype/src/main/resources/archetype-resources/console/pom.xml index 2a4ad8f..53bd556 100644 --- a/archetype/src/main/resources/archetype-resources/console/pom.xml +++ b/archetype/src/main/resources/archetype-resources/console/pom.xml @@ -231,7 +231,8 @@ ORYX.Editor.createByUrl = function(modelUrl){"/> package - + + + jsonConf='[{"schema":{"name":"updateScriptFileName","displayName":"updateScriptFileName","helpMessage":"updateScriptFileName","type":"java.lang.String","required":false,"order":0,"confidential":false,"defaultValues":[]},"overridable":false,"values":["${conf.directory}/scriptedsql/UpdateScript.groovy"]},{"schema":{"name":"testScript","displayName":"testScript","helpMessage":"testScript","type":"java.lang.String","required":false,"order":0,"confidential":false,"defaultValues":[""]},"overridable":false,"values":[]},{"schema":{"name":"host","displayName":"Host","helpMessage":"<b>Host< /b><br/>Enter the name of the host where the database is running.","type":"java.lang.String","required":false,"order":2,"confidential":false,"defaultValues":["localhost"]},"overridable":false},{"schema":{"name":"port","displayName":"Port","helpMessage":"<b>TCP Port</b><br/>Enter the port number the database server is listening on.","type":"java.lang.String","required":false,"order":3,"confidential":false,"defaultValues":["3306"]},"overridable":false},{"schema":{"name":"database","displayName":"Database","helpMessage":"<b>Database</b><br/>Enter the name of the database on the database server that contains the table.","type":" java.lang.String","required":false,"order":6,"confidential":false,"defaultValues":[""]},"overridable":false},{"schema":{"name":"createScript","displayName":"createScript","helpMessage":"createScript","type":"java.lang.String","required":false,"order":0,"confidential":false,"defaultValues":[""]},"overridable":false,"values":[]},{"schema":{"name":"jdbcUrlTemplate","displayName":"JDBC Connection URL","helpMessage":"<b>JDBC Connection URL</b><br/>Specify the JDBC Driver Connection URL.<br/> Oracle template is jdbc:oracle:thin:@[host]:[port(1521)]:[DB].<br/> MySQL template is jdbc:mysql://[host]:[port(3306)]/[db], for more info, read the JDBC driver documentation.<br/&g t;Could be empty if datasource is provided.","type":"java.lang.String","required":false,"order":11,"confidential":false,"defaultValues":["jdbc:mysql://%h:%p/%d"]},"overridable":false,"values":["${testdb.url}"]},{"schema":{"name":"jndiProperties","displayName":"Initial JNDI Properties","helpMessage":"<b>Initial JNDI Properties</b><br/>Could be empty or enter the JDBC JNDI Initial context factory, context provider in a format: key = value.","type":"[Ljava.lang.String;","required":false,"order":21,"confidential":false,"defaultValues":[]},"overridable":false,"values":[]},{"schema":{"name":"enableEmptyString","displayName":"Enable writing empty string","helpMessage& quot;:"<b>Enable writing empty string</b><br/>Select to enable support for writing an empty strings, instead of a NULL value, in character based columns defined as not-null in the table schema. This option does not influence the way strings are written for Oracle based tables. By default empty strings are written as a NULL value.","type":"boolean","required":false,"order":12,"confidential":false,"defaultValues":[false]},"overridable":false,"values":["false"]},{"schema":{"name":"allNative","displayName":"All native","helpMessage":"<b>All native</b><br/>Select to retrieve all data type of the columns in a native format from the database table.","type":"boolean","required":false,"order":16,"confidential":false,"defaultValues" ;:[false]},"overridable":false,"values":[false]},{"schema":{"name":"password","displayName":"User Password","helpMessage":"<b>User Password</b><br/>Enter a user account that has permission to access accounts table.","type":"org.identityconnectors.common.security.GuardedString","required":false,"order":5,"confidential":true,"defaultValues":[]},"overridable":false,"values":["${testdb.password}"]},{"schema":{"name":"validConnectionQuery","displayName":"Validate Connection Query","helpMessage":"<b>Validate Connection Query</b><br/>There can be specified the check connection alive query. If empty, default implementation will test it using the switch on/off the autocommit. Some select 1 from dummy table could be more efficient.","type":"java.lang.String","required":false,"order":17,"confidential":false,"defaultValues":[]},"overridable":false,"values":[]},{"schema":{"name":"reloadScriptOnExecution","displayName":"reloadScriptOnExecution","helpMessage":"reloadScriptOnExecution","type":"boolean","required":false,"order":0,"confidential":false,"defaultValues":[false]},"overridable":false,"values":["true"]},{"schema":{"name":"schemaScriptFileName","displayName":"schemaScriptFileName","helpMessage":"schemaScriptFileName","type":"java.lang.String","required":false,"order":0,"confidential":false,"defaultValues":[]},"overridab le":true,"values":["${conf.directory}/scriptedsql/SchemaScript.groovy"]},{"schema":{"name":"jdbcDriver","displayName":"JDBC Driver","helpMessage":"<b>JDBC Driver</b><br/>Specify the JDBC Driver class name. Oracle is oracle.jdbc.driver.OracleDriver. MySQL is org.gjt.mm.mysql.Driver.<br/>Could be empty if datasource is provided.","type":"java.lang.String","required":false,"order":10,"confidential":false,"defaultValues":["com.mysql.jdbc.Driver"]},"overridable":false,"values":["${testdb.driver}"]},{"schema":{"name":"testScriptFileName","displayName":"testScriptFileName","helpMessage":"testScriptFileName","type":"java.lang.String","required":false,"order":0,"c onfidential":false,"defaultValues":[]},"overridable":true,"values":["${conf.directory}/scriptedsql/TestScript.groovy"]},{"schema":{"name":"quoting","displayName":"Name Quoting","helpMessage":"<b>Name Quoting</b><br/>Select whether database column names for this resource should be quoted, and the quoting characters. By default, database column names are not quoted (None). For other selections (Single, Double, Back, or Brackets), column names will appear between single quotes, double quotes, back quotes, or brackets in the SQL generated to access the database.","type":"java.lang.String","required":false,"order":-1,"confidential":false,"defaultValues":[""]},"overridable":false,"values":[]},{"schema":{"name":"createScriptFileName","d isplayName":"createScriptFileName","helpMessage":"createScriptFileName","type":"java.lang.String","required":false,"order":0,"confidential":false,"defaultValues":[]},"overridable":false,"values":["${conf.directory}/scriptedsql/CreateScript.groovy"]},{"schema":{"name":"clearTextPasswordToScript","displayName":"clearTextPasswordToScript","helpMessage":"clearTextPasswordToScript","type":"boolean","required":false,"order":0,"confidential":false,"defaultValues":[true]},"overridable":false,"values":["false"]},{"schema":{"name":"nativeTimestamps","displayName":"Native Timestamps","helpMessage":"<b>Native Timestamps</b><br/>Selec t to retrieve Timestamp data type of the columns in java.sql.Timestamp format from the database table.","type":"boolean","required":false,"order":15,"confidential":false,"defaultValues":[false]},"overridable":false,"values":[false]},{"schema":{"name":"syncScript","displayName":"syncScript","helpMessage":"syncScript","type":"java.lang.String","required":false,"order":0,"confidential":false,"defaultValues":[""]},"overridable":false,"values":[]},{"schema":{"name":"autoCommit","displayName":"autoCommit","helpMessage":"autoCommit","type":"boolean","required":false,"order":0,"confidential":false,"defaultValues":[true]},& quot;overridable":false,"values":[true]},{"schema":{"name":"scriptingLanguage","displayName":"scriptingLanguage","helpMessage":"scriptingLanguage","type":"java.lang.String","required":false,"order":0,"confidential":false,"defaultValues":["GROOVY"]},"overridable":false,"values":["GROOVY"]},{"schema":{"name":"datasource","displayName":"Datasource Path","helpMessage":"<b>JDBC Data Source Name/Path</b><br/>Enter the JDBC Data Source Name/Path to connect to the Oracle server. If specified, connector will only try to connect using Datasource and ignore other resource parameters specified.<br/>the example value is: <CODE>jdbc/SampleDataSourceName</CODE>","type":"java.lang.String",&quo t;required":false,"order":20,"confidential":false,"defaultValues":[""]},"overridable":false,"values":[]},{"schema":{"name":"deleteScript","displayName":"deleteScript","helpMessage":"deleteScript","type":"java.lang.String","required":false,"order":0,"confidential":false,"defaultValues":[""]},"overridable":false,"values":[]},{"schema":{"name":"rethrowAllSQLExceptions","displayName":"Rethrow all SQLExceptions","helpMessage":"If this is not checked, SQL statements which throw SQLExceptions with a 0 ErrorCode will be have the exception caught and suppressed. Check it to have exceptions with 0 ErrorCodes rethrown.","type":"boolean","required":false,"order":14, "confidential":false,"defaultValues":[true]},"overridable":false,"values":[true]},{"schema":{"name":"syncScriptFileName","displayName":"syncScriptFileName","helpMessage":"syncScriptFileName","type":"java.lang.String","required":false,"order":0,"confidential":false,"defaultValues":[]},"overridable":true,"values":["${conf.directory}/scriptedsql/SyncScript.groovy"]},{"schema":{"name":"updateScript","displayName":"updateScript","helpMessage":"updateScript","type":"java.lang.String","required":false,"order":0,"confidential":false,"defaultValues":[""]},"overridable":false,"values":[]},{"schema":{"name":"user&qu ot;,"displayName":"User","helpMessage":"<b>User</b><br/>Enter the name of the mandatory Database user with permission to account table.","type":"java.lang.String","required":false,"order":4,"confidential":false,"defaultValues":[""]},"overridable":false,"values":["${testdb.username}"]},{"schema":{"name":"deleteScriptFileName","displayName":"deleteScriptFileName","helpMessage":"deleteScriptFileName","type":"java.lang.String","required":false,"order":0,"confidential":false,"defaultValues":[]},"overridable":false,"values":["${conf.directory}/scriptedsql/DeleteScript.groovy"]},{"schema":{"name":"searchScriptFileName","displayName":" ;searchScriptFileName","helpMessage":"searchScriptFileName","type":"java.lang.String","required":false,"order":0,"confidential":false,"defaultValues":[]},"overridable":true,"values":["${conf.directory}/scriptedsql/SearchScript.groovy"]},{"schema":{"name":"searchScript","displayName":"searchScript","helpMessage":"searchScript","type":"java.lang.String","required":false,"order":0,"confidential":false,"defaultValues":[""]},"overridable":false,"values":[]}]'/> http://git-wip-us.apache.org/repos/asf/syncope/blob/ec6bcf2f/core/persistence-jpa/src/test/resources/domains/Two.properties ---------------------------------------------------------------------- diff --git a/core/persistence-jpa/src/test/resources/domains/Two.properties b/core/persistence-jpa/src/test/resources/domains/Two.properties index b37a969..479b223 100644 --- a/core/persistence-jpa/src/test/resources/domains/Two.properties +++ b/core/persistence-jpa/src/test/resources/domains/Two.properties @@ -15,7 +15,7 @@ # specific language governing permissions and limitations # under the License. Two.driverClassName=org.h2.Driver -Two.url=jdbc:h2:file:${project.build.directory}/test-classes/syncopetwo.db;DB_CLOSE_DELAY=-1 +Two.url=jdbc:h2:file:${conf.directory}/syncopetwo.db Two.schema= Two.username=sa Two.password= http://git-wip-us.apache.org/repos/asf/syncope/blob/ec6bcf2f/fit/core-reference/src/main/resources/scriptedsql/CreateScript.groovy ---------------------------------------------------------------------- diff --git a/fit/core-reference/src/main/resources/scriptedsql/CreateScript.groovy b/fit/core-reference/src/main/resources/scriptedsql/CreateScript.groovy deleted file mode 100644 index 52c10f9..0000000 --- a/fit/core-reference/src/main/resources/scriptedsql/CreateScript.groovy +++ /dev/null @@ -1,52 +0,0 @@ -/* - * 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. - */ -import groovy.sql.Sql; -import groovy.sql.DataSet; - -// Parameters: -// The connector sends us the following: -// connection : SQL connection -// action: String correponding to the action ("CREATE" here) -// log: a handler to the Log facility -// objectClass: a String describing the Object class (__ACCOUNT__ / __GROUP__ / other) -// id: The entry identifier (OpenICF "Name" atribute. (most often matches the uid) -// attributes: an Attribute Map, containg the attribute name as a key -// and the attribute value(s) as value. -// password: password string, clear text -// options: a handler to the OperationOptions Map - -log.info("Entering " + action + " Script"); - -def sql = new Sql(connection); - -switch ( objectClass ) { -case "__PRINTER__": - sql.execute("INSERT INTO TESTPRINTER (id, location, lastmodification) values (?,?,?)", - [ - id, - attributes.get("location").get(0), - new Date() - ]) - break - -default: - id; -} - -return id; http://git-wip-us.apache.org/repos/asf/syncope/blob/ec6bcf2f/fit/core-reference/src/main/resources/scriptedsql/DeleteScript.groovy ---------------------------------------------------------------------- diff --git a/fit/core-reference/src/main/resources/scriptedsql/DeleteScript.groovy b/fit/core-reference/src/main/resources/scriptedsql/DeleteScript.groovy deleted file mode 100644 index cdd7f5b..0000000 --- a/fit/core-reference/src/main/resources/scriptedsql/DeleteScript.groovy +++ /dev/null @@ -1,43 +0,0 @@ -/* - * 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. - */ -import groovy.sql.Sql; -import groovy.sql.DataSet; - -// Parameters: -// The connector sends the following: -// connection: handler to the SQL connection -// action: a string describing the action ("DELETE" here) -// log: a handler to the Log facility -// objectClass: a String describing the Object class (__ACCOUNT__ / __GROUP__ / other) -// options: a handler to the OperationOptions Map -// uid: String for the unique id that specifies the object to delete - -log.info("Entering " + action + " Script"); -def sql = new Sql(connection); - -assert uid != null - -switch ( objectClass ) { -case "__PRINTER__": - sql.execute("DELETE FROM TESTPRINTER where id= ?",[uid]) - break - -default: - uid; -} http://git-wip-us.apache.org/repos/asf/syncope/blob/ec6bcf2f/fit/core-reference/src/main/resources/scriptedsql/SchemaScript.groovy ---------------------------------------------------------------------- diff --git a/fit/core-reference/src/main/resources/scriptedsql/SchemaScript.groovy b/fit/core-reference/src/main/resources/scriptedsql/SchemaScript.groovy deleted file mode 100644 index 50f8a8a..0000000 --- a/fit/core-reference/src/main/resources/scriptedsql/SchemaScript.groovy +++ /dev/null @@ -1,50 +0,0 @@ -/* - * 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. - */ -import org.identityconnectors.framework.common.objects.AttributeInfo; -import org.identityconnectors.framework.common.objects.AttributeInfo.Flags; -import org.identityconnectors.framework.common.objects.AttributeInfoBuilder; -import org.identityconnectors.framework.common.objects.ObjectClassInfo; -import org.identityconnectors.framework.common.objects.ObjectClassInfoBuilder; - -// Parameters: -// The connector sends the following: -// action: a string describing the action ("SCHEMA" here) -// log: a handler to the Log facility -// builder: SchemaBuilder instance for the connector -// -// The connector will make the final call to builder.build() -// so the scipt just need to declare the different object types. - -// This sample shows how to create 3 basic ObjectTypes: __ACCOUNT__, __GROUP__ and organization. -// Each of them contains one required attribute and normal String attributes - - -log.info("Entering " + action + " Script"); - -idAIB = new AttributeInfoBuilder("id", String.class); -idAIB.setRequired(true); - -orgAttrsInfo = new HashSet(); -orgAttrsInfo.add(idAIB.build()); -orgAttrsInfo.add(AttributeInfoBuilder.build("location", String.class)); -// Create the organization Object class -ObjectClassInfo ociOrg = new ObjectClassInfoBuilder().setType("__PRINTER__").addAllAttributeInfo(orgAttrsInfo).build(); -builder.defineObjectClass(ociOrg); - -log.info("Schema script done"); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/syncope/blob/ec6bcf2f/fit/core-reference/src/main/resources/scriptedsql/SearchScript.groovy ---------------------------------------------------------------------- diff --git a/fit/core-reference/src/main/resources/scriptedsql/SearchScript.groovy b/fit/core-reference/src/main/resources/scriptedsql/SearchScript.groovy deleted file mode 100644 index cc0dd65..0000000 --- a/fit/core-reference/src/main/resources/scriptedsql/SearchScript.groovy +++ /dev/null @@ -1,94 +0,0 @@ -/* - * 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. - */ -import groovy.sql.Sql; -import groovy.sql.DataSet; - -// Parameters: -// The connector sends the following: -// connection: handler to the SQL connection -// objectClass: a String describing the Object class (__ACCOUNT__ / __GROUP__ / other) -// action: a string describing the action ("SEARCH" here) -// log: a handler to the Log facility -// options: a handler to the OperationOptions Map -// query: a handler to the Query Map -// -// The Query map describes the filter used. -// -// query = [ operation: "CONTAINS", left: attribute, right: "value", not: true/false ] -// query = [ operation: "ENDSWITH", left: attribute, right: "value", not: true/false ] -// query = [ operation: "STARTSWITH", left: attribute, right: "value", not: true/false ] -// query = [ operation: "EQUALS", left: attribute, right: "value", not: true/false ] -// query = [ operation: "GREATERTHAN", left: attribute, right: "value", not: true/false ] -// query = [ operation: "GREATERTHANOREQUAL", left: attribute, right: "value", not: true/false ] -// query = [ operation: "LESSTHAN", left: attribute, right: "value", not: true/false ] -// query = [ operation: "LESSTHANOREQUAL", left: attribute, right: "value", not: true/false ] -// query = null : then we assume we fetch everything -// -// AND and OR filter just embed a left/right couple of queries. -// query = [ operation: "AND", left: query1, right: query2 ] -// query = [ operation: "OR", left: query1, right: query2 ] -// -// Returns: A list of Maps. Each map describing one row. -// !!!! Each Map must contain a '__UID__' and '__NAME__' attribute. -// This is required to build a ConnectorObject. - -log.info("Entering " + action + " Script"); - -def sql = new Sql(connection); -def result = [] -def where = ""; - -if (query != null) { - // Need to handle the __UID__ in queries - if (query.get("left").equalsIgnoreCase("__UID__") && objectClass.equalsIgnoreCase("__PRINTER__")) { - query.put("left","id") - } - - // We can use Groovy template engine to generate our custom SQL queries - def engine = new groovy.text.SimpleTemplateEngine(); - - def whereTemplates = [ - CONTAINS:' WHERE $left ${not ? "NOT " : ""}LIKE "%$right%"', - ENDSWITH:' WHERE $left ${not ? "NOT " : ""}LIKE "%$right"', - STARTSWITH:' WHERE $left ${not ? "NOT " : ""}LIKE "$right%"', - EQUALS:' WHERE $left ${not ? "<>" : "="} \'$right\'', - GREATERTHAN:' WHERE $left ${not ? "<=" : ">"} "$right"', - GREATERTHANOREQUAL:' WHERE $left ${not ? "<" : ">="} "$right"', - LESSTHAN:' WHERE $left ${not ? ">=" : "<"} "$right"', - LESSTHANOREQUAL:' WHERE $left ${not ? ">" : "<="} "$right"' - ] - - def wt = whereTemplates.get(query.get("operation")); - def binding = [left:query.get("left"),right:query.get("right"),not:query.get("not")]; - def template = engine.createTemplate(wt).make(binding); - where = template.toString(); - log.ok("Search WHERE clause is: "+ where) -} - -switch ( objectClass ) { -case "__PRINTER__": - sql.eachRow("SELECT * FROM TESTPRINTER " + where, - {result.add([__UID__:it.id, __NAME__:it.id, location:it.location])} ); - break - -default: - result; -} - -return result; http://git-wip-us.apache.org/repos/asf/syncope/blob/ec6bcf2f/fit/core-reference/src/main/resources/scriptedsql/SyncScript.groovy ---------------------------------------------------------------------- diff --git a/fit/core-reference/src/main/resources/scriptedsql/SyncScript.groovy b/fit/core-reference/src/main/resources/scriptedsql/SyncScript.groovy deleted file mode 100644 index 6060870..0000000 --- a/fit/core-reference/src/main/resources/scriptedsql/SyncScript.groovy +++ /dev/null @@ -1,98 +0,0 @@ -/* - * 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. - */ -import groovy.sql.Sql; -import groovy.sql.DataSet; - -// Parameters: -// The connector sends the following: -// connection: handler to the SQL connection -// objectClass: a String describing the Object class (__ACCOUNT__ / __GROUP__ / other) -// action: a string describing the action ("SYNC" or "GET_LATEST_SYNC_TOKEN" here) -// log: a handler to the Log facility -// options: a handler to the OperationOptions Map (null if action = "GET_LATEST_SYNC_TOKEN") -// token: a handler to an Object representing the sync token (null if action = "GET_LATEST_SYNC_TOKEN") -// -// -// Returns: -// if action = "GET_LATEST_SYNC_TOKEN", it must return an object representing the last known -// sync token for the corresponding ObjectClass -// -// if action = "SYNC": -// A list of Maps . Each map describing one update: -// Map should look like the following: -// -// [ -// "token": token object (could be Integer, Date, String) , [!! could be null] -// "operation": ("CREATE_OR_UPDATE"|"DELETE") will always default to CREATE_OR_DELETE , -// "uid": uid (uid of the entry) , -// "previousUid": prevuid (This is for rename ops) , -// "password": password (optional... allows to pass clear text password if needed), -// "attributes":Map of attributes name/values -// ] - -log.info("Entering " + action + " Script"); -def sql = new Sql(connection); - -if (action.equalsIgnoreCase("GET_LATEST_SYNC_TOKEN")) { - switch (objectClass) { - case "__PRINTER__": - row = sql.firstRow("SELECT lastmodification FROM TESTPRINTER ORDER BY lastmodification DESC"); - log.ok("Get Latest Sync Token script: last token is: " + row["lastmodification"]) - break; - - default: - row = null; - } - - return row == null ? null : row["lastmodification"].getTime(); -} else if (action.equalsIgnoreCase("SYNC")) { - def result = []; - def lastmodification = null; - if (token != null) { - lastmodification = new Date(token); - } else { - lastmodification = new Date(0); - } - - switch (objectClass) { - case "__PRINTER__": - sql.eachRow("SELECT * FROM TESTPRINTER WHERE lastmodification > ${lastmodification}", - { - result.add([ - operation:"CREATE_OR_UPDATE", - uid:it.id.toString(), - token:it.lastmodification.getTime(), - attributes:[ - __UID__:it.id.toString(), - __NAME__:it.id.toString(), - id:it.id.toString(), - location:it.location - ] - ]); - } - ) - break; - } - - log.ok("Sync script: found " + result.size() + " events to sync"); - return result; -} else { - log.error("Sync script: action '" + action + "' is not implemented in this script"); - return null; -} http://git-wip-us.apache.org/repos/asf/syncope/blob/ec6bcf2f/fit/core-reference/src/main/resources/scriptedsql/TestScript.groovy ---------------------------------------------------------------------- diff --git a/fit/core-reference/src/main/resources/scriptedsql/TestScript.groovy b/fit/core-reference/src/main/resources/scriptedsql/TestScript.groovy deleted file mode 100644 index 5b8f4b5..0000000 --- a/fit/core-reference/src/main/resources/scriptedsql/TestScript.groovy +++ /dev/null @@ -1,31 +0,0 @@ -/* - * 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. - */ -import groovy.sql.Sql; -import groovy.sql.DataSet; - -// Parameters: -// The connector sends the following: -// connection: handler to the SQL connection -// action: a string describing the action ("TEST" here) -// log: a handler to the Log facility - -log.info("Entering " + action + " Script"); -def sql = new Sql(connection); - -sql.eachRow("select * from TESTPRINTER", { println it.uid} ); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/syncope/blob/ec6bcf2f/fit/core-reference/src/main/resources/scriptedsql/UpdateScript.groovy ---------------------------------------------------------------------- diff --git a/fit/core-reference/src/main/resources/scriptedsql/UpdateScript.groovy b/fit/core-reference/src/main/resources/scriptedsql/UpdateScript.groovy deleted file mode 100644 index f3155cb..0000000 --- a/fit/core-reference/src/main/resources/scriptedsql/UpdateScript.groovy +++ /dev/null @@ -1,67 +0,0 @@ -/* - * 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. - */ -import groovy.sql.Sql; -import groovy.sql.DataSet; - -// Parameters: -// The connector sends us the following: -// connection : SQL connection -// -// action: String correponding to the action (UPDATE/ADD_ATTRIBUTE_VALUES/REMOVE_ATTRIBUTE_VALUES) -// - UPDATE : For each input attribute, replace all of the current values of that attribute -// in the target object with the values of that attribute. -// - ADD_ATTRIBUTE_VALUES: For each attribute that the input set contains, add to the current values -// of that attribute in the target object all of the values of that attribute in the input set. -// - REMOVE_ATTRIBUTE_VALUES: For each attribute that the input set contains, remove from the current values -// of that attribute in the target object any value that matches one of the values of the attribute from the input set. - -// log: a handler to the Log facility -// -// objectClass: a String describing the Object class (__ACCOUNT__ / __GROUP__ / other) -// -// uid: a String representing the entry uid -// -// attributes: an Attribute Map, containg the attribute name as a key -// and the attribute value(s) as value. -// -// password: password string, clear text (only for UPDATE) -// -// options: a handler to the OperationOptions Map - -log.info("Entering " + action + " Script"); -def sql = new Sql(connection); - - -switch (action) { -case "UPDATE": - if (attributes.get("location").get(0) != null) { - sql.executeUpdate("UPDATE TESTPRINTER SET location = ?, lastmodification = ? where id = ?", - [attributes.get("location").get(0), new Date(), attributes.get("__NAME__").get(0)]) - - return attributes.get("__NAME__").get(0); - } - break - -case "ADD_ATTRIBUTE_VALUES": - break - - -default: - sql -} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/syncope/blob/ec6bcf2f/fit/core-reference/src/test/resources/scriptedsql/CreateScript.groovy ---------------------------------------------------------------------- diff --git a/fit/core-reference/src/test/resources/scriptedsql/CreateScript.groovy b/fit/core-reference/src/test/resources/scriptedsql/CreateScript.groovy new file mode 100644 index 0000000..52c10f9 --- /dev/null +++ b/fit/core-reference/src/test/resources/scriptedsql/CreateScript.groovy @@ -0,0 +1,52 @@ +/* + * 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. + */ +import groovy.sql.Sql; +import groovy.sql.DataSet; + +// Parameters: +// The connector sends us the following: +// connection : SQL connection +// action: String correponding to the action ("CREATE" here) +// log: a handler to the Log facility +// objectClass: a String describing the Object class (__ACCOUNT__ / __GROUP__ / other) +// id: The entry identifier (OpenICF "Name" atribute. (most often matches the uid) +// attributes: an Attribute Map, containg the attribute name as a key +// and the attribute value(s) as value. +// password: password string, clear text +// options: a handler to the OperationOptions Map + +log.info("Entering " + action + " Script"); + +def sql = new Sql(connection); + +switch ( objectClass ) { +case "__PRINTER__": + sql.execute("INSERT INTO TESTPRINTER (id, location, lastmodification) values (?,?,?)", + [ + id, + attributes.get("location").get(0), + new Date() + ]) + break + +default: + id; +} + +return id; http://git-wip-us.apache.org/repos/asf/syncope/blob/ec6bcf2f/fit/core-reference/src/test/resources/scriptedsql/DeleteScript.groovy ---------------------------------------------------------------------- diff --git a/fit/core-reference/src/test/resources/scriptedsql/DeleteScript.groovy b/fit/core-reference/src/test/resources/scriptedsql/DeleteScript.groovy new file mode 100644 index 0000000..cdd7f5b --- /dev/null +++ b/fit/core-reference/src/test/resources/scriptedsql/DeleteScript.groovy @@ -0,0 +1,43 @@ +/* + * 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. + */ +import groovy.sql.Sql; +import groovy.sql.DataSet; + +// Parameters: +// The connector sends the following: +// connection: handler to the SQL connection +// action: a string describing the action ("DELETE" here) +// log: a handler to the Log facility +// objectClass: a String describing the Object class (__ACCOUNT__ / __GROUP__ / other) +// options: a handler to the OperationOptions Map +// uid: String for the unique id that specifies the object to delete + +log.info("Entering " + action + " Script"); +def sql = new Sql(connection); + +assert uid != null + +switch ( objectClass ) { +case "__PRINTER__": + sql.execute("DELETE FROM TESTPRINTER where id= ?",[uid]) + break + +default: + uid; +} http://git-wip-us.apache.org/repos/asf/syncope/blob/ec6bcf2f/fit/core-reference/src/test/resources/scriptedsql/SchemaScript.groovy ---------------------------------------------------------------------- diff --git a/fit/core-reference/src/test/resources/scriptedsql/SchemaScript.groovy b/fit/core-reference/src/test/resources/scriptedsql/SchemaScript.groovy new file mode 100644 index 0000000..50f8a8a --- /dev/null +++ b/fit/core-reference/src/test/resources/scriptedsql/SchemaScript.groovy @@ -0,0 +1,50 @@ +/* + * 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. + */ +import org.identityconnectors.framework.common.objects.AttributeInfo; +import org.identityconnectors.framework.common.objects.AttributeInfo.Flags; +import org.identityconnectors.framework.common.objects.AttributeInfoBuilder; +import org.identityconnectors.framework.common.objects.ObjectClassInfo; +import org.identityconnectors.framework.common.objects.ObjectClassInfoBuilder; + +// Parameters: +// The connector sends the following: +// action: a string describing the action ("SCHEMA" here) +// log: a handler to the Log facility +// builder: SchemaBuilder instance for the connector +// +// The connector will make the final call to builder.build() +// so the scipt just need to declare the different object types. + +// This sample shows how to create 3 basic ObjectTypes: __ACCOUNT__, __GROUP__ and organization. +// Each of them contains one required attribute and normal String attributes + + +log.info("Entering " + action + " Script"); + +idAIB = new AttributeInfoBuilder("id", String.class); +idAIB.setRequired(true); + +orgAttrsInfo = new HashSet(); +orgAttrsInfo.add(idAIB.build()); +orgAttrsInfo.add(AttributeInfoBuilder.build("location", String.class)); +// Create the organization Object class +ObjectClassInfo ociOrg = new ObjectClassInfoBuilder().setType("__PRINTER__").addAllAttributeInfo(orgAttrsInfo).build(); +builder.defineObjectClass(ociOrg); + +log.info("Schema script done"); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/syncope/blob/ec6bcf2f/fit/core-reference/src/test/resources/scriptedsql/SearchScript.groovy ---------------------------------------------------------------------- diff --git a/fit/core-reference/src/test/resources/scriptedsql/SearchScript.groovy b/fit/core-reference/src/test/resources/scriptedsql/SearchScript.groovy new file mode 100644 index 0000000..cc0dd65 --- /dev/null +++ b/fit/core-reference/src/test/resources/scriptedsql/SearchScript.groovy @@ -0,0 +1,94 @@ +/* + * 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. + */ +import groovy.sql.Sql; +import groovy.sql.DataSet; + +// Parameters: +// The connector sends the following: +// connection: handler to the SQL connection +// objectClass: a String describing the Object class (__ACCOUNT__ / __GROUP__ / other) +// action: a string describing the action ("SEARCH" here) +// log: a handler to the Log facility +// options: a handler to the OperationOptions Map +// query: a handler to the Query Map +// +// The Query map describes the filter used. +// +// query = [ operation: "CONTAINS", left: attribute, right: "value", not: true/false ] +// query = [ operation: "ENDSWITH", left: attribute, right: "value", not: true/false ] +// query = [ operation: "STARTSWITH", left: attribute, right: "value", not: true/false ] +// query = [ operation: "EQUALS", left: attribute, right: "value", not: true/false ] +// query = [ operation: "GREATERTHAN", left: attribute, right: "value", not: true/false ] +// query = [ operation: "GREATERTHANOREQUAL", left: attribute, right: "value", not: true/false ] +// query = [ operation: "LESSTHAN", left: attribute, right: "value", not: true/false ] +// query = [ operation: "LESSTHANOREQUAL", left: attribute, right: "value", not: true/false ] +// query = null : then we assume we fetch everything +// +// AND and OR filter just embed a left/right couple of queries. +// query = [ operation: "AND", left: query1, right: query2 ] +// query = [ operation: "OR", left: query1, right: query2 ] +// +// Returns: A list of Maps. Each map describing one row. +// !!!! Each Map must contain a '__UID__' and '__NAME__' attribute. +// This is required to build a ConnectorObject. + +log.info("Entering " + action + " Script"); + +def sql = new Sql(connection); +def result = [] +def where = ""; + +if (query != null) { + // Need to handle the __UID__ in queries + if (query.get("left").equalsIgnoreCase("__UID__") && objectClass.equalsIgnoreCase("__PRINTER__")) { + query.put("left","id") + } + + // We can use Groovy template engine to generate our custom SQL queries + def engine = new groovy.text.SimpleTemplateEngine(); + + def whereTemplates = [ + CONTAINS:' WHERE $left ${not ? "NOT " : ""}LIKE "%$right%"', + ENDSWITH:' WHERE $left ${not ? "NOT " : ""}LIKE "%$right"', + STARTSWITH:' WHERE $left ${not ? "NOT " : ""}LIKE "$right%"', + EQUALS:' WHERE $left ${not ? "<>" : "="} \'$right\'', + GREATERTHAN:' WHERE $left ${not ? "<=" : ">"} "$right"', + GREATERTHANOREQUAL:' WHERE $left ${not ? "<" : ">="} "$right"', + LESSTHAN:' WHERE $left ${not ? ">=" : "<"} "$right"', + LESSTHANOREQUAL:' WHERE $left ${not ? ">" : "<="} "$right"' + ] + + def wt = whereTemplates.get(query.get("operation")); + def binding = [left:query.get("left"),right:query.get("right"),not:query.get("not")]; + def template = engine.createTemplate(wt).make(binding); + where = template.toString(); + log.ok("Search WHERE clause is: "+ where) +} + +switch ( objectClass ) { +case "__PRINTER__": + sql.eachRow("SELECT * FROM TESTPRINTER " + where, + {result.add([__UID__:it.id, __NAME__:it.id, location:it.location])} ); + break + +default: + result; +} + +return result; http://git-wip-us.apache.org/repos/asf/syncope/blob/ec6bcf2f/fit/core-reference/src/test/resources/scriptedsql/SyncScript.groovy ---------------------------------------------------------------------- diff --git a/fit/core-reference/src/test/resources/scriptedsql/SyncScript.groovy b/fit/core-reference/src/test/resources/scriptedsql/SyncScript.groovy new file mode 100644 index 0000000..6060870 --- /dev/null +++ b/fit/core-reference/src/test/resources/scriptedsql/SyncScript.groovy @@ -0,0 +1,98 @@ +/* + * 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. + */ +import groovy.sql.Sql; +import groovy.sql.DataSet; + +// Parameters: +// The connector sends the following: +// connection: handler to the SQL connection +// objectClass: a String describing the Object class (__ACCOUNT__ / __GROUP__ / other) +// action: a string describing the action ("SYNC" or "GET_LATEST_SYNC_TOKEN" here) +// log: a handler to the Log facility +// options: a handler to the OperationOptions Map (null if action = "GET_LATEST_SYNC_TOKEN") +// token: a handler to an Object representing the sync token (null if action = "GET_LATEST_SYNC_TOKEN") +// +// +// Returns: +// if action = "GET_LATEST_SYNC_TOKEN", it must return an object representing the last known +// sync token for the corresponding ObjectClass +// +// if action = "SYNC": +// A list of Maps . Each map describing one update: +// Map should look like the following: +// +// [ +// "token": token object (could be Integer, Date, String) , [!! could be null] +// "operation": ("CREATE_OR_UPDATE"|"DELETE") will always default to CREATE_OR_DELETE , +// "uid": uid (uid of the entry) , +// "previousUid": prevuid (This is for rename ops) , +// "password": password (optional... allows to pass clear text password if needed), +// "attributes":Map of attributes name/values +// ] + +log.info("Entering " + action + " Script"); +def sql = new Sql(connection); + +if (action.equalsIgnoreCase("GET_LATEST_SYNC_TOKEN")) { + switch (objectClass) { + case "__PRINTER__": + row = sql.firstRow("SELECT lastmodification FROM TESTPRINTER ORDER BY lastmodification DESC"); + log.ok("Get Latest Sync Token script: last token is: " + row["lastmodification"]) + break; + + default: + row = null; + } + + return row == null ? null : row["lastmodification"].getTime(); +} else if (action.equalsIgnoreCase("SYNC")) { + def result = []; + def lastmodification = null; + if (token != null) { + lastmodification = new Date(token); + } else { + lastmodification = new Date(0); + } + + switch (objectClass) { + case "__PRINTER__": + sql.eachRow("SELECT * FROM TESTPRINTER WHERE lastmodification > ${lastmodification}", + { + result.add([ + operation:"CREATE_OR_UPDATE", + uid:it.id.toString(), + token:it.lastmodification.getTime(), + attributes:[ + __UID__:it.id.toString(), + __NAME__:it.id.toString(), + id:it.id.toString(), + location:it.location + ] + ]); + } + ) + break; + } + + log.ok("Sync script: found " + result.size() + " events to sync"); + return result; +} else { + log.error("Sync script: action '" + action + "' is not implemented in this script"); + return null; +} http://git-wip-us.apache.org/repos/asf/syncope/blob/ec6bcf2f/fit/core-reference/src/test/resources/scriptedsql/TestScript.groovy ---------------------------------------------------------------------- diff --git a/fit/core-reference/src/test/resources/scriptedsql/TestScript.groovy b/fit/core-reference/src/test/resources/scriptedsql/TestScript.groovy new file mode 100644 index 0000000..5b8f4b5 --- /dev/null +++ b/fit/core-reference/src/test/resources/scriptedsql/TestScript.groovy @@ -0,0 +1,31 @@ +/* + * 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. + */ +import groovy.sql.Sql; +import groovy.sql.DataSet; + +// Parameters: +// The connector sends the following: +// connection: handler to the SQL connection +// action: a string describing the action ("TEST" here) +// log: a handler to the Log facility + +log.info("Entering " + action + " Script"); +def sql = new Sql(connection); + +sql.eachRow("select * from TESTPRINTER", { println it.uid} ); \ No newline at end of file http://git-wip-us.apache.org/repos/asf/syncope/blob/ec6bcf2f/fit/core-reference/src/test/resources/scriptedsql/UpdateScript.groovy ---------------------------------------------------------------------- diff --git a/fit/core-reference/src/test/resources/scriptedsql/UpdateScript.groovy b/fit/core-reference/src/test/resources/scriptedsql/UpdateScript.groovy new file mode 100644 index 0000000..f3155cb --- /dev/null +++ b/fit/core-reference/src/test/resources/scriptedsql/UpdateScript.groovy @@ -0,0 +1,67 @@ +/* + * 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. + */ +import groovy.sql.Sql; +import groovy.sql.DataSet; + +// Parameters: +// The connector sends us the following: +// connection : SQL connection +// +// action: String correponding to the action (UPDATE/ADD_ATTRIBUTE_VALUES/REMOVE_ATTRIBUTE_VALUES) +// - UPDATE : For each input attribute, replace all of the current values of that attribute +// in the target object with the values of that attribute. +// - ADD_ATTRIBUTE_VALUES: For each attribute that the input set contains, add to the current values +// of that attribute in the target object all of the values of that attribute in the input set. +// - REMOVE_ATTRIBUTE_VALUES: For each attribute that the input set contains, remove from the current values +// of that attribute in the target object any value that matches one of the values of the attribute from the input set. + +// log: a handler to the Log facility +// +// objectClass: a String describing the Object class (__ACCOUNT__ / __GROUP__ / other) +// +// uid: a String representing the entry uid +// +// attributes: an Attribute Map, containg the attribute name as a key +// and the attribute value(s) as value. +// +// password: password string, clear text (only for UPDATE) +// +// options: a handler to the OperationOptions Map + +log.info("Entering " + action + " Script"); +def sql = new Sql(connection); + + +switch (action) { +case "UPDATE": + if (attributes.get("location").get(0) != null) { + sql.executeUpdate("UPDATE TESTPRINTER SET location = ?, lastmodification = ? where id = ?", + [attributes.get("location").get(0), new Date(), attributes.get("__NAME__").get(0)]) + + return attributes.get("__NAME__").get(0); + } + break + +case "ADD_ATTRIBUTE_VALUES": + break + + +default: + sql +} \ No newline at end of file http://git-wip-us.apache.org/repos/asf/syncope/blob/ec6bcf2f/pom.xml ---------------------------------------------------------------------- diff --git a/pom.xml b/pom.xml index d50da6b..a4df5a5 100644 --- a/pom.xml +++ b/pom.xml @@ -321,7 +321,7 @@ under the License. 1.4.1.0 1.3.0 - 2.2.2 + 2.2.3-SNAPSHOT 0.8.2 1.4.0 1.2.3 http://git-wip-us.apache.org/repos/asf/syncope/blob/ec6bcf2f/standalone/pom.xml ---------------------------------------------------------------------- diff --git a/standalone/pom.xml b/standalone/pom.xml index 8976467..a23b810 100644 --- a/standalone/pom.xml +++ b/standalone/pom.xml @@ -36,6 +36,7 @@ under the License. ${basedir}/.. + ${CATALINA_HOME}/webapps/syncope/WEB-INF/classes connid://${testconnectorserver.key}@localhost:${testconnectorserver.port} ./logs ./test-csvdir @@ -94,7 +95,7 @@ under the License. ${project.build.directory}/classes/core - content.xml + domains/MasterContent.xml ${project.build.directory}/classes/core ${basedir}/../fit/core-reference/src/test/resources/addActivitiToContent.xsl @@ -214,15 +215,19 @@ under the License. - ../core/persistence-jpa/src/test/resources + ../core/persistence-jpa/src/main/resources - content.xml persistence.properties core true + ../core/persistence-jpa/src/test/resources/domains + core/domains + true + + ../fit/core-reference/src/main/resources *.xml @@ -240,6 +245,11 @@ under the License. core true + + ../fit/core-reference/src/test/resources/scriptedsql + core/scriptedsql + true + ../fit/console-reference/src/main/resources http://git-wip-us.apache.org/repos/asf/syncope/blob/ec6bcf2f/standalone/src/main/resources/setenv.bat ---------------------------------------------------------------------- diff --git a/standalone/src/main/resources/setenv.bat b/standalone/src/main/resources/setenv.bat index 2267b8b..9dc2c67 100644 --- a/standalone/src/main/resources/setenv.bat +++ b/standalone/src/main/resources/setenv.bat @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -set JAVA_OPTS=-Djava.awt.headless=true -Dfile.encoding=UTF-8 -server -Xms2048m -Xmx2048m -XX:NewSize=256m -XX:MaxNewSize=256m -XX:PermSize=256m -XX:MaxPermSize=256m -XX:+DisableExplicitGC +set JAVA_OPTS=-Djava.awt.headless=true -Dfile.encoding=UTF-8 -server -Xms2048m -Xmx2048m -XX:NewSize=256m -XX:MaxNewSize=256m -XX:PermSize=256m -XX:MaxPermSize=256m -XX:+DisableExplicitGC -DCATALINA_HOME=%CATALINA_HOME% http://git-wip-us.apache.org/repos/asf/syncope/blob/ec6bcf2f/standalone/src/main/resources/setenv.sh ---------------------------------------------------------------------- diff --git a/standalone/src/main/resources/setenv.sh b/standalone/src/main/resources/setenv.sh index 22cff49..fbc725b 100755 --- a/standalone/src/main/resources/setenv.sh +++ b/standalone/src/main/resources/setenv.sh @@ -13,4 +13,4 @@ # See the License for the specific language governing permissions and # limitations under the License. -JAVA_OPTS="-Djava.awt.headless=true -Dfile.encoding=UTF-8 -server -Xms2048m -Xmx2048m -XX:NewSize=256m -XX:MaxNewSize=256m -XX:PermSize=256m -XX:MaxPermSize=256m -XX:+DisableExplicitGC" +JAVA_OPTS="-Djava.awt.headless=true -Dfile.encoding=UTF-8 -server -Xms2048m -Xmx2048m -XX:NewSize=256m -XX:MaxNewSize=256m -XX:PermSize=256m -XX:MaxPermSize=256m -XX:+DisableExplicitGC -DCATALINA_HOME=$CATALINA_HOME"