protected void handleNonEquivalence(String message, Object pk, DBRow entity) { errorHandler.handleError(message); }
protected void handleNKNotFound(String naturalKey, String tableName, String sourceDbId, String targetDbId) { String message = "Missing entry: " + sourceDbId + '.' + tableName + "[" + naturalKey + "]" + " does not appear in " + targetDbId; errorHandler.handleError(message); }
@Override public void fatalError(SAXParseException e) { errorHandler.handleError(e.getMessage(), e); }
@Override public void warning(SAXParseException e) { errorHandler.handleError(e.getMessage(), e); }
@Override public void error(SAXParseException e) { errorHandler.handleError(e.getMessage(), e); }
public static int runShellCommand(String command, Writer outputWriter, File directory, ErrorHandler errorHandler) { logger.debug(command); try { Process process = Runtime.getRuntime().exec(command, null, directory); return execute(process, command, outputWriter, errorHandler); } catch (FileNotFoundException e) { errorHandler.handleError("Error in shell invocation: " + command, e); return 2; } catch (Exception e) { errorHandler.handleError("Error in shell invocation: " + command, e); return 1; } }
public static int runShellCommand(String[] cmdArray, Writer outputWriter, File directory, ErrorHandler errorHandler) { String description = renderCmdArray(cmdArray); if (logger.isDebugEnabled()) logger.debug(description); try { Process process = Runtime.getRuntime().exec(cmdArray, null, directory); return execute(process, description, outputWriter, errorHandler); } catch (Exception e) { errorHandler.handleError("Error in shell invocation: " + description, e); return -1; } }
public void handleError(String message, Throwable t) { if (loggingStackTrace) { switch (level) { // yes, this could be more efficient, but it's just for error handling // and you're not supposed to have a number of errors that impacts performance case trace : logger.trace(message); break; case debug : logger.debug(message); break; case info : logger.info( message); break; case warn : logger.warn( message); break; case error : logger.error(message, t); break; case fatal : if (t instanceof RuntimeException) throw (RuntimeException) t; else throw new RuntimeException(t); case ignore: break; // ignore } } else handleError(message + SystemInfo.getLineSeparator() + t.toString()); }
public static void say(String text, ErrorHandler errorHandler) { if (!speechSupported()) errorHandler.handleError("Speech is not supported on this system"); ShellUtil.runShellCommand("say -v Alex \"" + text + "\"", new OutputStreamWriter(System.out), errorHandler); }
private static int execute(Process process, String description, Writer outputWriter, ErrorHandler errorHandler) throws IOException, InterruptedException { String lf = SystemInfo.getLineSeparator(); BufferedReader stdIn = new BufferedReader(new InputStreamReader(process.getInputStream())); BufferedReader stdErr = new BufferedReader(new InputStreamReader(process.getErrorStream())); // read the output from the command boolean firstLine = true; String s; while ((s = stdIn.readLine()) != null) { if (outputWriter != null) { if (firstLine) firstLine = false; else outputWriter.write(lf); outputWriter.write(s); } } if (outputWriter != null) outputWriter.flush(); // read any errors from the attempted command while ((s = stdErr.readLine()) != null) { errorHandler.handleError(s); } process.waitFor(); int exitValue = process.exitValue(); if (exitValue != 0) errorHandler.handleError("Process (" + description + ") did not terminate normally: Return code " + exitValue); return exitValue; }
protected void handleMissingOwner(String ownedTableName, DBRow ownedEntity, String ownerTableName, Object ownerId, String sourceDbId) { String message = "Owner of " + sourceDbId + '.' + ownedTableName + '[' + ArrayFormat.format(ownedEntity.getPKValues()) + "] was dropped. " + "Missing: " + sourceDbId + '.' + ownerTableName + '[' + ownerId + "]. " + "Possibly it was rejected or it was missing in the NK query"; errorHandler.handleError(message); }
public void importPrimaryKeyOfTable(DBTable table, PKReceiver receiver) { LOGGER.debug("Importing primary keys for table '{}'", table); StopWatch watch = new StopWatch("importPrimaryKeyOfTable"); ResultSet pkset = null; try { pkset = metaData.getPrimaryKeys(catalogName, schemaName, table.getName()); TreeMap<Short, String> pkComponents = new TreeMap<Short, String>(); String pkName = null; while (pkset.next()) { String tableName = pkset.getString(3); if (!tableName.equals(table.getName())) // Bug fix for Firebird: continue; // When querying X, it returns the pks of XY too String columnName = pkset.getString(4); short keySeq = pkset.getShort(5); pkComponents.put(keySeq, columnName); pkName = pkset.getString(6); LOGGER.debug("found pk column {}, {}, {}", new Object[] { columnName, keySeq, pkName }); } if (pkComponents.size() > 0) { String[] columnNames = pkComponents.values().toArray(new String[pkComponents.size()]); receiver.receivePK(pkName, dialect.isDeterministicPKName(pkName), columnNames, table); } } catch (SQLException e) { errorHandler.handleError("Error importing primary key of table " + table.getName()); } finally { DBUtil.close(pkset); } watch.stop(); }
if (errorHandler == null) errorHandler = new ErrorHandler(DBUtil.class); errorHandler.handleError("Error in executing SQL: " + SystemInfo.getLineSeparator() + cmd, e);
errorHandler.handleError("Error importing index " + indexName);
errorHandler.handleError("Error in parsing columns for table pattern " + tablePattern, e); } finally { DBUtil.close(columnSet);
public void importRefererTables(DBTable table, ReferrerReceiver receiver) { StopWatch watch = new StopWatch("importRefererTables"); LOGGER.debug("Importing exported keys for table '{}'", table); DBCatalog catalog = table.getCatalog(); DBSchema schema = table.getSchema(); String catalogName = (catalog != null ? catalog.getName() : null); String tableName = table.getName(); String schemaName = (schema != null ? schema.getName() : null); ResultSet resultSet = null; try { resultSet = metaData.getExportedKeys(catalogName, schemaName, tableName); while (resultSet.next()) { String fktable_cat = resultSet.getString(5); String fktable_schem = resultSet.getString(6); String fktable_name = resultSet.getString(7); if (tableSupported(fktable_name)) { LOGGER.debug("Importing referrer: {}", fktable_name); receiver.receiveReferrer(fktable_name, table); } } } catch (SQLException e) { errorHandler.handleError("Error importing foreign key constraints for table " + table, e); } finally { DBUtil.close(resultSet); } watch.stop(); }
public ResultSet importIndexesOfTable(DBTable table, boolean uniquesOnly, IndexReceiver receiver) { StopWatch watch = new StopWatch("importIndexesOfTable"); if (table.getTableType() == TableType.TABLE) LOGGER.debug("Importing indexes of table '{}'", table.getName()); else LOGGER.debug("Skipping indexes of table '{}' with type '{}'", table.getName(), table.getTableType()); ResultSet indexSet = null; try { indexSet = metaData.getIndexInfo(table.getCatalog().getName(), table.getSchema().getName(), table.getName(), uniquesOnly, true); parseIndexSet(indexSet, table.getSchema(), table, receiver); } catch (SQLException e) { // possibly we try to query a catalog to which we do not have access rights errorHandler.handleError("Error parsing index data of table " + table.getName(), e); } finally { DBUtil.close(indexSet); } watch.stop(); return indexSet; }
errorHandler.handleError("Error importing foreign key constraints", e); } finally { DBUtil.close(resultSet);