diff --git a/symmetric/src/main/java/org/jumpmind/symmetric/db/hsqldb/HsqlDbTrigger.java b/symmetric/src/main/java/org/jumpmind/symmetric/db/hsqldb/HsqlDbTrigger.java index 29f0500b25..e9abdec118 100644 --- a/symmetric/src/main/java/org/jumpmind/symmetric/db/hsqldb/HsqlDbTrigger.java +++ b/symmetric/src/main/java/org/jumpmind/symmetric/db/hsqldb/HsqlDbTrigger.java @@ -27,6 +27,8 @@ import org.apache.commons.lang.StringUtils; import org.hsqldb.Token; import org.hsqldb.types.Binary; +import org.jumpmind.symmetric.common.logging.Log; +import org.jumpmind.symmetric.common.logging.LogFactory; import org.jumpmind.symmetric.model.Data; import org.jumpmind.symmetric.model.DataEventType; @@ -93,9 +95,7 @@ private void init(int type, String triggerName, String tableName) { if (initialize(getDataEventType(type), tableName)) { buildDataSelectSql(); buildTransactionIdSql(); - if (logger.isDebugEnabled()) { - logger.debug("TriggerInitializing", triggerName, triggerType); - } + logger.debug("TriggerInitializing", triggerName, triggerType); initialized = true; } } diff --git a/symmetric/src/main/java/org/jumpmind/symmetric/db/mssql/MsSqlDbDialect.java b/symmetric/src/main/java/org/jumpmind/symmetric/db/mssql/MsSqlDbDialect.java index 241c3c069f..7040c3ed71 100644 --- a/symmetric/src/main/java/org/jumpmind/symmetric/db/mssql/MsSqlDbDialect.java +++ b/symmetric/src/main/java/org/jumpmind/symmetric/db/mssql/MsSqlDbDialect.java @@ -29,11 +29,11 @@ import org.apache.commons.collections.CollectionUtils; import org.apache.commons.lang.StringUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.apache.ddlutils.model.Column; import org.apache.ddlutils.model.Table; import org.jumpmind.symmetric.common.ParameterConstants; +import org.jumpmind.symmetric.common.logging.Log; +import org.jumpmind.symmetric.common.logging.LogFactory; import org.jumpmind.symmetric.db.AbstractDbDialect; import org.jumpmind.symmetric.db.BinaryEncoding; import org.jumpmind.symmetric.db.IDbDialect; @@ -116,10 +116,10 @@ public boolean isAutoRegister() { }; } - + @Override - public void removeTrigger(StringBuilder sqlBuffer, final String catalogName, String schemaName, final String triggerName, - String tableName, TriggerHistory oldHistory) { + public void removeTrigger(StringBuilder sqlBuffer, final String catalogName, String schemaName, + final String triggerName, String tableName, TriggerHistory oldHistory) { schemaName = schemaName == null ? "" : (schemaName + "."); final String sql = "drop trigger " + schemaName + triggerName; logSql(sql, sqlBuffer); @@ -134,24 +134,23 @@ public Object doInConnection(Connection con) throws SQLException, DataAccessExce } stmt = con.createStatement(); stmt.execute(sql); - } - catch (Exception e) { - logger.warn("Could not drop trigger " + triggerName); - } - finally { + } catch (Exception e) { + logger.warn("TriggerDropError", triggerName); + } finally { if (catalogName != null) { con.setCatalog(previousCatalog); } try { stmt.close(); - } catch (Exception e) { } + } catch (Exception e) { + } } return Boolean.FALSE; } }); } } - + @Override protected String switchCatalogForTriggerInstall(String catalog, Connection c) throws SQLException { if (catalog != null) { @@ -161,7 +160,7 @@ protected String switchCatalogForTriggerInstall(String catalog, Connection c) th } else { return null; } - } + } @Override public void prepareTableForDataLoad(Table table) { @@ -183,18 +182,20 @@ public BinaryEncoding getBinaryEncoding() { } @Override - protected boolean doesTriggerExistOnPlatform(final String catalogName, String schema, String tableName, final String triggerName) { + protected boolean doesTriggerExistOnPlatform(final String catalogName, String schema, String tableName, + final String triggerName) { return (Boolean) jdbcTemplate.execute(new ConnectionCallback() { public Object doInConnection(Connection con) throws SQLException, DataAccessException { String previousCatalog = con.getCatalog(); - PreparedStatement stmt = con.prepareStatement("select count(*) from sysobjects where type = 'TR' AND name = ?"); + PreparedStatement stmt = con + .prepareStatement("select count(*) from sysobjects where type = 'TR' AND name = ?"); try { if (catalogName != null) { con.setCatalog(catalogName); } stmt.setString(1, triggerName); ResultSet rs = stmt.executeQuery(); - if (rs.next()){ + if (rs.next()) { int count = rs.getInt(1); return count > 0; } @@ -213,8 +214,8 @@ public void disableSyncTriggers(String nodeId) { if (nodeId == null) { nodeId = ""; } - jdbcTemplate.update("DECLARE @CI VarBinary(128);" + "SET @CI=cast ('1" + nodeId - + "' as varbinary(128));" + "SET context_info @CI;"); + jdbcTemplate.update("DECLARE @CI VarBinary(128);" + "SET @CI=cast ('1" + nodeId + "' as varbinary(128));" + + "SET context_info @CI;"); } public void enableSyncTriggers() { diff --git a/symmetric/src/main/java/org/jumpmind/symmetric/db/mysql/MySqlDbDialect.java b/symmetric/src/main/java/org/jumpmind/symmetric/db/mysql/MySqlDbDialect.java index b7c3148c9b..97ed44ee5f 100644 --- a/symmetric/src/main/java/org/jumpmind/symmetric/db/mysql/MySqlDbDialect.java +++ b/symmetric/src/main/java/org/jumpmind/symmetric/db/mysql/MySqlDbDialect.java @@ -24,11 +24,11 @@ import java.sql.SQLException; import org.apache.commons.lang.StringUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.apache.ddlutils.model.Table; import org.jumpmind.symmetric.Version; import org.jumpmind.symmetric.common.ParameterConstants; +import org.jumpmind.symmetric.common.logging.Log; +import org.jumpmind.symmetric.common.logging.LogFactory; import org.jumpmind.symmetric.db.AbstractDbDialect; import org.jumpmind.symmetric.db.BinaryEncoding; import org.jumpmind.symmetric.db.IDbDialect; @@ -42,7 +42,7 @@ public class MySqlDbDialect extends AbstractDbDialect implements IDbDialect { static final String TRANSACTION_ID_FUNCTION_NAME = "fn_transaction_id"; static final String SYNC_TRIGGERS_DISABLED_USER_VARIABLE = "@sync_triggers_disabled"; - + static final String SYNC_TRIGGERS_DISABLED_NODE_VARIABLE = "@sync_node_disabled"; private boolean supportsTransactionId = false; @@ -50,17 +50,16 @@ public class MySqlDbDialect extends AbstractDbDialect implements IDbDialect { @Override protected void initForSpecificDialect() { int[] versions = Version.parseVersion(getProductVersion()); - if (getMajorVersion() == 5 - && (getMinorVersion() == 0 || (getMinorVersion() == 1 && versions[2] < 23))) { - logger.info("Enabling transaction ID support"); + if (getMajorVersion() == 5 && (getMinorVersion() == 0 || (getMinorVersion() == 1 && versions[2] < 23))) { + logger.info("TransactionIDSupportEnabling"); supportsTransactionId = true; } } - + @Override - public Table findTable(String catalogName, String schemaName, String tblName) - throws Exception { - catalogName = StringUtils.isBlank(catalogName) ? StringUtils.isBlank(schemaName) ? getDefaultCatalog() :schemaName : catalogName; + public Table findTable(String catalogName, String schemaName, String tblName) throws Exception { + catalogName = StringUtils.isBlank(catalogName) ? StringUtils.isBlank(schemaName) ? getDefaultCatalog() + : schemaName : catalogName; return super.findTable(catalogName, schemaName, tblName); } @@ -69,10 +68,10 @@ protected void createRequiredFunctions() { String[] functions = sqlTemplate.getFunctionsToInstall(); for (String funcKey : functions) { String funcName = tablePrefix + "_" + funcKey; - if (! funcName.equals("fn_transaction_id") || supportsTransactionId) { + if (!funcName.equals("fn_transaction_id") || supportsTransactionId) { if (jdbcTemplate.queryForInt(sqlTemplate.getFunctionInstalledSql(funcKey, defaultSchema)) == 0) { jdbcTemplate.update(sqlTemplate.getFunctionSql(funcKey, funcName, defaultSchema)); - logger.info("Just installed " + funcName); + logger.info("FunctionInstalled", funcName); } } } @@ -98,7 +97,7 @@ public void removeTrigger(StringBuilder sqlBuffer, String catalogName, String sc try { jdbcTemplate.update(sql); } catch (Exception e) { - logger.warn("Trigger does not exist"); + logger.warn("TriggerDoesNotExist"); } } } @@ -185,10 +184,9 @@ public int getStreamingResultsFetchSize() { public BinaryEncoding getBinaryEncoding() { return BinaryEncoding.HEX; } - + @Override - public String getIdentifierQuoteString() - { + public String getIdentifierQuoteString() { return "`"; } diff --git a/symmetric/src/main/java/org/jumpmind/symmetric/db/oracle/OracleDbDialect.java b/symmetric/src/main/java/org/jumpmind/symmetric/db/oracle/OracleDbDialect.java index ef241613e7..230b9da809 100644 --- a/symmetric/src/main/java/org/jumpmind/symmetric/db/oracle/OracleDbDialect.java +++ b/symmetric/src/main/java/org/jumpmind/symmetric/db/oracle/OracleDbDialect.java @@ -24,9 +24,9 @@ import java.util.Map; import org.apache.commons.lang.StringUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.apache.ddlutils.model.Table; +import org.jumpmind.symmetric.common.logging.Log; +import org.jumpmind.symmetric.common.logging.LogFactory; import org.jumpmind.symmetric.db.AbstractDbDialect; import org.jumpmind.symmetric.db.BinaryEncoding; import org.jumpmind.symmetric.db.IDbDialect; @@ -71,9 +71,9 @@ public void initTrigger(StringBuilder sqlBuffer, DataEventType dml, Trigger trig if (ex.getSQLException().getErrorCode() == 4095) { try { // a trigger of the same name must already exist on a table - logger.warn("A trigger already exists for that name. Details are as follows: " - + jdbcTemplate.queryForMap("select * from user_triggers where trigger_name like upper(?)", - new Object[] { hist.getTriggerNameForDmlType(dml) })); + logger.warn("TriggerAlreadyExists", jdbcTemplate.queryForMap( + "select * from user_triggers where trigger_name like upper(?)", new Object[] { hist + .getTriggerNameForDmlType(dml) })); } catch (DataAccessException e) { } } @@ -151,7 +151,7 @@ public boolean storesUpperCaseNamesInCatalog() { public void purge() { jdbcTemplate.update("purge recyclebin"); } - + protected String getSymmetricPackageName() { return tablePrefix + "_pkg"; } diff --git a/symmetric/src/main/java/org/jumpmind/symmetric/db/postgresql/PostgreSqlDbDialect.java b/symmetric/src/main/java/org/jumpmind/symmetric/db/postgresql/PostgreSqlDbDialect.java index e240b2ab82..1489b14c2d 100644 --- a/symmetric/src/main/java/org/jumpmind/symmetric/db/postgresql/PostgreSqlDbDialect.java +++ b/symmetric/src/main/java/org/jumpmind/symmetric/db/postgresql/PostgreSqlDbDialect.java @@ -24,9 +24,9 @@ import java.util.Map; import org.apache.commons.lang.StringUtils; -import org.apache.commons.logging.Log; -import org.apache.commons.logging.LogFactory; import org.jumpmind.symmetric.common.ParameterConstants; +import org.jumpmind.symmetric.common.logging.Log; +import org.jumpmind.symmetric.common.logging.LogFactory; import org.jumpmind.symmetric.db.AbstractDbDialect; import org.jumpmind.symmetric.db.BinaryEncoding; import org.jumpmind.symmetric.db.IDbDialect; @@ -42,7 +42,7 @@ public class PostgreSqlDbDialect extends AbstractDbDialect implements IDbDialect static final String TRANSACTION_ID_EXPRESSION = "txid_current()"; static final String SYNC_TRIGGERS_DISABLED_VARIABLE = "symmetric.triggers_disabled"; - + static final String SYNC_NODE_DISABLED_VARIABLE = "symmetric.node_disabled"; private boolean supportsTransactionId = false; @@ -52,17 +52,17 @@ public class PostgreSqlDbDialect extends AbstractDbDialect implements IDbDialect @Override protected void initForSpecificDialect() { if (getMajorVersion() >= 8 && getMinorVersion() >= 3) { - logger.info("Enabling transaction ID support"); + logger.info("TransactionIDSupportEnabling"); supportsTransactionId = true; transactionIdExpression = TRANSACTION_ID_EXPRESSION; } try { enableSyncTriggers(); } catch (Exception e) { - logger.error("Please add \"custom_variable_classes = 'symmetric'\" to your postgresql.conf file"); - throw new RuntimeException("Missing custom variable class 'symmetric'", e); + logger.error("PostgreSqlCustomVariableMissing"); + throw new RuntimeException("PostgreSqlCustomVariableMissing", e); } - + } @SuppressWarnings("unchecked") @@ -71,18 +71,16 @@ protected Integer overrideJdbcTypeForColumn(Map values) { String typeName = (String) values.get("TYPE_NAME"); if (typeName != null && typeName.equalsIgnoreCase("ABSTIME")) { return Types.TIMESTAMP; - } - else { + } else { return super.overrideJdbcTypeForColumn(values); } } @Override protected boolean doesTriggerExistOnPlatform(String catalogName, String schema, String tableName, String triggerName) { - return jdbcTemplate.queryForInt( - "select count(*) from information_schema.triggers where trigger_name = ? " + - "and event_object_table = ? and trigger_schema = ?", - new Object[] { triggerName.toLowerCase(), tableName.toLowerCase(), schema == null ? defaultSchema : schema }) > 0; + return jdbcTemplate.queryForInt("select count(*) from information_schema.triggers where trigger_name = ? " + + "and event_object_table = ? and trigger_schema = ?", new Object[] { triggerName.toLowerCase(), + tableName.toLowerCase(), schema == null ? defaultSchema : schema }) > 0; } @Override @@ -98,7 +96,7 @@ public void removeTrigger(StringBuilder sqlBuffer, String catalogName, String sc jdbcTemplate.update(dropSql); jdbcTemplate.update(dropFunction); } catch (Exception e) { - logger.warn("Trigger does not exist"); + logger.warn("TriggerDoesNotExist"); } } } @@ -114,8 +112,9 @@ public void disableSyncTriggers(String nodeId) { public void enableSyncTriggers() { transactionTemplate.execute(new TransactionCallbackWithoutResult() { protected void doInTransactionWithoutResult(TransactionStatus transactionstatus) { - if (! transactionstatus.isRollbackOnly()) { - jdbcTemplate.queryForList("select set_config('" + SYNC_TRIGGERS_DISABLED_VARIABLE + "', '', false)"); + if (!transactionstatus.isRollbackOnly()) { + jdbcTemplate + .queryForList("select set_config('" + SYNC_TRIGGERS_DISABLED_VARIABLE + "', '', false)"); jdbcTemplate.queryForList("select set_config('" + SYNC_NODE_DISABLED_VARIABLE + "', '', false)"); } } diff --git a/symmetric/src/main/resources/logMessages_en_US.properties b/symmetric/src/main/resources/logMessages_en_US.properties index dc0454f295..49e77ed907 100644 --- a/symmetric/src/main/resources/logMessages_en_US.properties +++ b/symmetric/src/main/resources/logMessages_en_US.properties @@ -8,13 +8,13 @@ EnvironmentVariablesCreating=Creating environment variables %s and %s FirebirdSymUdfMissing=Please install the sym_udf.so/dll to your {firebird_home}/UDF folder FirebirdSymEscapeMissing=Function SYM_ESCAPE is not installed FunctionInstalled=Just installed %s -MySqlTransactionIDSupportEnabling=Enabling transaction ID support PostgreSqlCustomVariableMissing=Please add "custom_variable_classes = 'symmetric'" to your postgresql.conf file PostTriggerCreateFailed=Failed to create post trigger: %s Sql=SQL: %s TableDropped=Just dropped table %s_CONFIG TablesCreating=About to create SymmetricDS tables TablesCreatingSkipped=No need to create SymmetricDS tables. They already exist. +TransactionIDSupportEnabling=Enabling transaction ID support TriggerCreateFailed=Failed to create trigger: %s TriggerCreating=Creating %s trigger for %s %s TriggerDropped=Just dropped trigger %s