use of com.iplanet.log.NullLocationException in project OpenAM by OpenRock.
the class DBHandler method configure.
private void configure() throws NullLocationException, FormatterInitException {
setFilter(null);
try {
setEncoding("UTF-8");
} catch (UnsupportedEncodingException e) {
Debug.error(tableName + ":DBHandler: unsupportedEncodingException ", e);
}
String bufferSize = lmanager.getProperty(LogConstants.BUFFER_SIZE);
if (bufferSize != null && bufferSize.length() > 0) {
try {
recCountLimit = Integer.parseInt(bufferSize);
} catch (NumberFormatException nfe) {
Debug.warning(tableName + ":DBHandler: NumberFormatException ", nfe);
if (Debug.messageEnabled()) {
Debug.message(tableName + ":DBHandler: Setting buffer size to 1");
}
recCountLimit = 1;
}
} else {
Debug.warning(tableName + ":DBHandler: Invalid buffer size: " + bufferSize);
if (Debug.messageEnabled()) {
Debug.message(tableName + ":DBHandler: Setting buffer size to 1");
}
recCountLimit = 1;
}
String recMaxDBMemStr = lmanager.getProperty(LogConstants.DB_MEM_MAX_RECS);
if (recMaxDBMemStr != null && recMaxDBMemStr.length() > 0) {
try {
recMaxDBMem = Integer.parseInt(recMaxDBMemStr);
} catch (NumberFormatException nfe) {
Debug.warning(tableName + ":DBHandler:recMaxDBMem (" + recMaxDBMemStr + "): NumberFormatException ", nfe);
if (Debug.messageEnabled()) {
Debug.message(tableName + ":DBHandler: Setting Max DB Mem Buffer Size to 2x (" + 2 * recCountLimit + ") the Buffer Size (" + recCountLimit + ")");
}
recMaxDBMem = 2 * recCountLimit;
}
} else {
Debug.warning(tableName + ":DBHandler: Invalid buffer size: " + bufferSize);
if (Debug.messageEnabled()) {
Debug.message(tableName + ":DBHandler: Defaulting Max DB Mem Buffer Size to 2x Buffer Size");
}
recMaxDBMem = 2 * recCountLimit;
}
if (recMaxDBMem < recCountLimit) {
Debug.warning(tableName + ":DBHandler:Maximum DB memory buffer size < Buffer Size, " + "setting to buffer size (" + recCountLimit + ")");
recMaxDBMem = recCountLimit;
}
String status = lmanager.getProperty(LogConstants.TIME_BUFFERING_STATUS);
if (status != null && status.equalsIgnoreCase("ON")) {
timeBufferingEnabled = true;
}
oraDataType = lmanager.getProperty(LogConstants.ORA_DBDATA_FIELDTYPE);
mysqlDataType = lmanager.getProperty(LogConstants.MYSQL_DBDATA_FIELDTYPE);
databaseURL = lmanager.getProperty(LogConstants.LOG_LOCATION);
if ((databaseURL == null) || (databaseURL.length() == 0)) {
throw new NullLocationException("Database URL location is null");
}
String strFormatter = com.sun.identity.log.LogManager.FORMATTER;
if ((strFormatter == null) || (strFormatter.length() == 0)) {
throw new FormatterInitException("Unable To Initialize DBFormatter");
}
userName = lmanager.getProperty(LogConstants.DB_USER);
if ((userName == null) || (userName.length() == 0)) {
throw new NullLocationException("userName is null");
}
password = lmanager.getProperty(LogConstants.DB_PASSWORD);
if ((password == null) || (password.length() == 0)) {
throw new NullLocationException("password not provided");
}
driver = lmanager.getProperty(LogConstants.DB_DRIVER);
if ((driver == null) || (driver.length() == 0)) {
throw new NullLocationException("driver not provided");
}
//
if (driver.toLowerCase().indexOf("oracle") != -1) {
isMySQL = false;
} else if (driver.toLowerCase().indexOf("mysql") != -1) {
isMySQL = true;
} else {
isMySQL = false;
Debug.warning(tableName + ":DBHandler:configure:assuming driver: '" + driver + "' is Oracle-compatible.");
}
try {
Class clz = Class.forName(strFormatter);
Formatter formatter = (Formatter) clz.newInstance();
setFormatter(formatter);
} catch (Exception e) {
// should be Invalid Formatter Exception
Debug.error(tableName + ":DBHandler: Could not load Formatter", e);
throw new FormatterInitException("Unable To Initialize DBFormatter " + e.getMessage());
}
}
Aggregations