From 267c7b1af11ec8f306b37c58c7190c57fd906dc5 Mon Sep 17 00:00:00 2001 From: Ludovic Pouzenc Date: Thu, 23 Oct 2014 13:17:16 +0200 Subject: Config : all enum values in CAPS. --- .../JUTests/data/io/sql/SQLRelDataReaderTest.java | 2 +- src/connectors/src/data/io/sql/SQLConnectionWrapper.java | 6 +++--- src/main/JUTests/conf/testConn.yaml | 10 +++++----- src/main/JUTests/conf/testExpectedConn.yaml | 6 +++--- src/main/JUTests/conf/testExpectedMain.yaml | 12 ++++++------ src/main/JUTests/conf/testMain.yaml | 14 +++++++------- src/main/conf/connections.yaml | 6 +++--- src/main/conf/sssync.yaml | 14 +++++++------- src/main/src/conf/ConfigConnectionBean.java | 2 +- src/main/src/conf/ConfigDestBean.java | 8 ++++---- src/main/src/conf/ConfigRootBean.java | 2 ++ src/main/src/conf/ConfigSourceBean.java | 2 +- src/main/src/data/io/SSSyncConnectionsFactory.java | 4 ++-- src/main/src/sync/SSSyncTasksFactory.java | 14 +++++++------- 14 files changed, 52 insertions(+), 50 deletions(-) (limited to 'src') diff --git a/src/connectors/JUTests/data/io/sql/SQLRelDataReaderTest.java b/src/connectors/JUTests/data/io/sql/SQLRelDataReaderTest.java index a97a98d..f22671d 100644 --- a/src/connectors/JUTests/data/io/sql/SQLRelDataReaderTest.java +++ b/src/connectors/JUTests/data/io/sql/SQLRelDataReaderTest.java @@ -67,7 +67,7 @@ public class SQLRelDataReaderTest { File currentFolder = new File(main.getPath()).getParentFile(); // Build a connection and two readers on it - builder = new SQLConnectionWrapper(DBMSType.mysql, "localhost", 3306, null, "root", "secret", "sssync"); + builder = new SQLConnectionWrapper(DBMSType.MYSQL, "localhost", 3306, null, "root", "secret", "sssync"); reader1 = builder.newReader("testMysql1", TEST_REQUEST); reader2 = builder.newReader("testMysql2", new File(currentFolder, "req_test.sql")); } diff --git a/src/connectors/src/data/io/sql/SQLConnectionWrapper.java b/src/connectors/src/data/io/sql/SQLConnectionWrapper.java index e4bbf10..de9b2cc 100644 --- a/src/connectors/src/data/io/sql/SQLConnectionWrapper.java +++ b/src/connectors/src/data/io/sql/SQLConnectionWrapper.java @@ -40,7 +40,7 @@ public class SQLConnectionWrapper implements Closeable { /** * Enumeration of supported DBMS. Each use a particular JDBC driver. */ - public enum DBMSType { oracle, mysql } + public enum DBMSType { ORACLE, MYSQL } private final Connection conn; @@ -60,11 +60,11 @@ public class SQLConnectionWrapper implements Closeable { String url; switch ( dbms ) { - case oracle: + case ORACLE: driverClassName="oracle.jdbc.driver.OracleDriver"; url="jdbc:oracle:thin:@" + host + ":" + port + ":" + ress + "/" + db; break; - case mysql: + case MYSQL: driverClassName="com.mysql.jdbc.Driver"; url="jdbc:mysql://" + host + ":" + port + "/" + db; break; diff --git a/src/main/JUTests/conf/testConn.yaml b/src/main/JUTests/conf/testConn.yaml index c41063c..78a4fa6 100644 --- a/src/main/JUTests/conf/testConn.yaml +++ b/src/main/JUTests/conf/testConn.yaml @@ -1,17 +1,17 @@ # This file contains credentials (should be readable only by SSSync) connections: - id : ora_1 - type: jdbc - dbms: oracle + type: JDBC + dbms: ORACLE ress: gest host: ora.univ-jfc.fr port: 1521 - user: GRHUM + user: grhum pass: secret - db : GHRUM + db : grhum - id : ldap_1 - type: ldap + type: LDAP host: localhost port: 389 bind: uid=ldapadmin,ou=specialUsers,dc=univ-jfc,dc=fr diff --git a/src/main/JUTests/conf/testExpectedConn.yaml b/src/main/JUTests/conf/testExpectedConn.yaml index 4cb3421..17d4f0b 100644 --- a/src/main/JUTests/conf/testExpectedConn.yaml +++ b/src/main/JUTests/conf/testExpectedConn.yaml @@ -2,13 +2,13 @@ connections: - bind: null db: GHRUM - dbms: oracle + dbms: ORACLE host: ora.univ-jfc.fr id: ora_1 pass: secret port: 1521 ress: gest - type: jdbc + type: JDBC user: GRHUM - bind: uid=ldapadmin,ou=specialUsers,dc=univ-jfc,dc=fr db: null @@ -18,5 +18,5 @@ connections: pass: secret port: 389 ress: null - type: ldap + type: LDAP user: null diff --git a/src/main/JUTests/conf/testExpectedMain.yaml b/src/main/JUTests/conf/testExpectedMain.yaml index dd00aef..88bcb32 100644 --- a/src/main/JUTests/conf/testExpectedMain.yaml +++ b/src/main/JUTests/conf/testExpectedMain.yaml @@ -6,7 +6,7 @@ tasks: attr: uid base: ou=people,dc=univ-jfc,dc=fr conn: ldap_1 - kind: ldap + kind: LDAP mode: null name: LDAP de test, ou=people path: null @@ -22,7 +22,7 @@ tasks: - attr: null base: null conn: ora_1 - kind: sql + kind: SQL mode: PRIMARY_SOURCE name: GHRUM, comptes et personnes path: null @@ -30,7 +30,7 @@ tasks: - attr: null base: null conn: null - kind: csv + kind: FIXED_CSV mode: MERGE_APPEND name: CSV personnes additionnelles path: people_append.csv @@ -38,7 +38,7 @@ tasks: - attr: null base: null conn: null - kind: sorted_csv + kind: FIXED_CSV_SORTED mode: MERGE_REPLACE name: CSV correctifs personnes path: people_replace.csv @@ -47,7 +47,7 @@ tasks: attr: supannEntiteAffectation base: ou=structures,dc=univ-jfc,dc=fr conn: ldap_1 - kind: ldap + kind: LDAP mode: null name: LDAP de test, ou=structures path: null @@ -63,7 +63,7 @@ tasks: - attr: null base: null conn: ora_1 - kind: sql + kind: SQL mode: PRIMARY_SOURCE name: GHRUM, structures path: null diff --git a/src/main/JUTests/conf/testMain.yaml b/src/main/JUTests/conf/testMain.yaml index 39350b2..123a8b1 100644 --- a/src/main/JUTests/conf/testMain.yaml +++ b/src/main/JUTests/conf/testMain.yaml @@ -11,24 +11,24 @@ tasks: delete: 10 sources: - name: GHRUM, comptes et personnes - kind: sql + kind: SQL conn: ora_1 mode: PRIMARY_SOURCE query: people.sql - name: CSV personnes additionnelles - kind: csv + kind: FIXED_CSV mode: MERGE_APPEND path: people_append.csv - name: CSV correctifs personnes - kind: sorted_csv + kind: FIXED_CSV_SORTED mode: MERGE_REPLACE path: people_replace.csv destination: name: LDAP de test, ou=people - kind: ldap + kind: LDAP conn: ldap_1 attr: uid base: ou=people,dc=univ-jfc,dc=fr @@ -36,13 +36,13 @@ tasks: - name: Structure sync sources: - name: GHRUM, structures - kind: sql + kind: SQL conn: ora_1 mode: PRIMARY_SOURCE query: structures.sql destination: name: LDAP de test, ou=structures - kind: ldap + kind: LDAP conn: ldap_1 attr: supannEntiteAffectation base: ou=structures,dc=univ-jfc,dc=fr @@ -51,4 +51,4 @@ tasks: opLimits: insert: 10 update: 10 - delete: 10 \ No newline at end of file + delete: 10 diff --git a/src/main/conf/connections.yaml b/src/main/conf/connections.yaml index 1918d02..097117e 100644 --- a/src/main/conf/connections.yaml +++ b/src/main/conf/connections.yaml @@ -1,8 +1,8 @@ # This file contains credentials (should be readable only by SSSync) connections: - id : mysql_1 - type: jdbc - dbms: mysql + type: JDBC + dbms: MYSQL host: localhost port: 3306 user: root @@ -10,7 +10,7 @@ connections: db : sssync - id : ldap_1 - type: ldap + type: LDAP host: localhost port: 389 bind: uid=ldapadmin,ou=specialUsers,dc=univ-jfc,dc=fr diff --git a/src/main/conf/sssync.yaml b/src/main/conf/sssync.yaml index b285a37..068a95b 100644 --- a/src/main/conf/sssync.yaml +++ b/src/main/conf/sssync.yaml @@ -11,24 +11,24 @@ tasks: delete: 300 sources: - name: GHRUM, comptes et personnes - kind: sql + kind: SQL conn: mysql_1 mode: PRIMARY_SOURCE query: conf/queries/people.sql - name: CSV personnes additionnelles - kind: csv + kind: FIXED_CSV mode: MERGE_APPEND path: data/people_append.csv - name: CSV correctifs personnes - kind: csv + kind: FIXED_CSV mode: MERGE_REPLACE path: data/people_replace.csv destination: name: LDAP de test, ou=people - kind: ldap + kind: LDAP conn: ldap_1 attr: uid base: ou=people,dc=univ-jfc,dc=fr @@ -40,17 +40,17 @@ tasks: delete: 10 sources: - name: GHRUM, structures - kind: sql + kind: SQL conn: mysql_1 mode: PRIMARY_SOURCE query: conf/queries/structures.sql destination: name: LDAP de test, ou=structures - kind: ldap + kind: LDAP conn: ldap_1 attr: supannCodeEntite base: ou=structures,dc=univ-jfc,dc=fr skipEntryDelete: true - skipReadErrors: true \ No newline at end of file + skipReadErrors: true diff --git a/src/main/src/conf/ConfigConnectionBean.java b/src/main/src/conf/ConfigConnectionBean.java index b43b56f..0597480 100644 --- a/src/main/src/conf/ConfigConnectionBean.java +++ b/src/main/src/conf/ConfigConnectionBean.java @@ -27,7 +27,7 @@ import data.io.sql.SQLConnectionWrapper.DBMSType; */ public class ConfigConnectionBean { - public enum ConnectionType { jdbc, ldap } + public enum ConnectionType { JDBC, LDAP } private String id; private ConnectionType type; diff --git a/src/main/src/conf/ConfigDestBean.java b/src/main/src/conf/ConfigDestBean.java index 2d9b2f7..d3c12fb 100644 --- a/src/main/src/conf/ConfigDestBean.java +++ b/src/main/src/conf/ConfigDestBean.java @@ -24,10 +24,10 @@ package conf; * Generated Configuration Bean */ public class ConfigDestBean { - public enum DestinationKind { ldap }; + public enum DestKind { LDAP }; private String name; - private DestinationKind kind; + private DestKind kind; private String conn; private String attr; private String base; @@ -39,10 +39,10 @@ public class ConfigDestBean { public void setName(String name) { this.name = name; } - public DestinationKind getKind() { + public DestKind getKind() { return kind; } - public void setKind(DestinationKind kind) { + public void setKind(DestKind kind) { this.kind = kind; } public String getConn() { diff --git a/src/main/src/conf/ConfigRootBean.java b/src/main/src/conf/ConfigRootBean.java index acbbd49..eac7793 100644 --- a/src/main/src/conf/ConfigRootBean.java +++ b/src/main/src/conf/ConfigRootBean.java @@ -51,6 +51,8 @@ public class ConfigRootBean { public static String listDump(List list, int ident) { + if ( list == null ) return "{}"; + StringBuffer buf = new StringBuffer(); buf.append('{'); for (T item : list) { diff --git a/src/main/src/conf/ConfigSourceBean.java b/src/main/src/conf/ConfigSourceBean.java index cf01dce..893d41a 100644 --- a/src/main/src/conf/ConfigSourceBean.java +++ b/src/main/src/conf/ConfigSourceBean.java @@ -28,7 +28,7 @@ import data.filters.MVDataCombiner; public class ConfigSourceBean { //TODO : fixed_csv ? - public enum SourceKind { csv, ldap, sorted_csv, sql }; + public enum SourceKind { FIXED_CSV, FIXED_CSV_SORTED, LDAP, SQL }; private String name; private SourceKind kind; diff --git a/src/main/src/data/io/SSSyncConnectionsFactory.java b/src/main/src/data/io/SSSyncConnectionsFactory.java index 07f19e9..0eab7a2 100644 --- a/src/main/src/data/io/SSSyncConnectionsFactory.java +++ b/src/main/src/data/io/SSSyncConnectionsFactory.java @@ -42,11 +42,11 @@ public class SSSyncConnectionsFactory { for ( ConfigConnectionBean conn : confConn.getConnections() ) { switch (conn.getType()) { - case jdbc: + case JDBC: SQLConnectionWrapper connSQL = new SQLConnectionWrapper(conn.getDbms(), conn.getHost(), conn.getPort(), conn.getRess(), conn.getUser(), conn.getPass(), conn.getDb()); connections.putConnSQL(conn.getId(), connSQL); break; - case ldap: + case LDAP: LDAPConnectionWrapper connLDAP = new LDAPConnectionWrapper(conn.getHost(), conn.getPort(), conn.getBind(), conn.getPass()); connections.putConnLDAP(conn.getId(), connLDAP); break; diff --git a/src/main/src/sync/SSSyncTasksFactory.java b/src/main/src/sync/SSSyncTasksFactory.java index a91b3fa..4f7cfd6 100644 --- a/src/main/src/sync/SSSyncTasksFactory.java +++ b/src/main/src/sync/SSSyncTasksFactory.java @@ -118,18 +118,18 @@ public class SSSyncTasksFactory { private static MVDataReader _makeSrcReader(ConnectionsHolder connections, ConfigSourceBean confSource, String taskName) throws Exception { MVDataReader reader=null; switch (confSource.getKind()) { - case csv: + case FIXED_CSV: reader = new CSVDataReader(confSource.getName(), new FileReader(confSource.getPath()), false); break; - case ldap: + case FIXED_CSV_SORTED: + reader = new CSVDataReader(confSource.getName(), new FileReader(confSource.getPath()), true); + break; + case LDAP: LDAPConnectionWrapper ldapConnBuilder = connections.getLDAPConnectionBuilder(confSource.getConn()); //FIXME if conf error, getLDAPConnectionBuilder could return null reader = ldapConnBuilder.newFlatReader(confSource.getName(), confSource.getBase(), confSource.getAttr(), confSource.getLookahead()); break; - case sorted_csv: - reader = new CSVDataReader(confSource.getName(), new FileReader(confSource.getPath()), true); - break; - case sql: + case SQL: SQLConnectionWrapper sqlConnBuilder = connections.getSQLConnectionBuilder(confSource.getConn()); //FIXME if conf error, getSQLConnectionBuilder could return null //TODO We assume the query config item is a filepath. It isn't checked anywhere. @@ -156,7 +156,7 @@ public class SSSyncTasksFactory { MVDataWriter writer = null; switch ( confDest.getKind() ) { - case ldap: + case LDAP: LDAPConnectionWrapper builder = connections.getLDAPConnectionBuilder(confDest.getConn()); reader = builder.newFlatReader(confDest.getName()+"_reader", confDest.getBase(), confDest.getAttr(), confDest.getLookahead()); writer = builder.newFlatWriter(confDest.getBase(), confDest.getAttr()); -- cgit v1.2.3