@Override
public void initModule() throws ModuleInitializationException {
// pidNamespace (required, 1-17 chars, a-z, A-Z, 0-9 '-' '.')
m_pidNamespace = getParameter("pidNamespace");
if (m_pidNamespace == null) {
throw new ModuleInitializationException(
"pidNamespace parameter must be specified.", getRole());
}
if (m_pidNamespace.length() > 17 || m_pidNamespace.length() < 1) {
throw new ModuleInitializationException(
"pidNamespace parameter must be 1-17 chars long", getRole());
}
StringBuffer badChars = new StringBuffer();
for (int i = 0; i < m_pidNamespace.length(); i++) {
char c = m_pidNamespace.charAt(i);
boolean invalid = true;
if (c >= '0' && c <= '9') {
invalid = false;
} else if (c >= 'a' && c <= 'z') {
invalid = false;
} else if (c >= 'A' && c <= 'Z') {
invalid = false;
} else if (c == '-') {
invalid = false;
} else if (c == '.') {
invalid = false;
}
if (invalid) {
badChars.append(c);
}
}
if (badChars.toString().length() > 0) {
throw new ModuleInitializationException("pidNamespace contains " +
"invalid character(s) '" + badChars.toString() + "'",
getRole());
}
// storagePool (optional, default=ConnectionPoolManager's default pool)
m_storagePool = getParameter("storagePool");
if (m_storagePool == null) {
logger.debug("Parameter storagePool "
+ "not given, will defer to ConnectionPoolManager's "
+ "default pool.");
}
// internal storage format (required)
logger.debug("Server property format.storage= " + Server.STORAGE_FORMAT);
m_defaultStorageFormat = Server.STORAGE_FORMAT;
if (m_defaultStorageFormat == null) {
throw new ModuleInitializationException(
"System property format.storage "
+ "not given, but it's required.", getRole());
}
// default export format (required)
m_defaultExportFormat = getParameter("defaultExportFormat");
if (m_defaultExportFormat == null) {
throw new ModuleInitializationException(
"Parameter defaultExportFormat "
+ "not given, but it's required.", getRole());
}
// storageCharacterEncoding (optional, default=UTF-8)
m_storageCharacterEncoding = getParameter("storageCharacterEncoding");
if (m_storageCharacterEncoding == null) {
logger.debug("Parameter storage_character_encoding "
+ "not given, using UTF-8");
m_storageCharacterEncoding = "UTF-8";
}
initRetainPID();
// readerCacheSize and readerCacheSeconds (optional, defaults = 20, 5)
String rcSize = getParameter("readerCacheSize");
if (rcSize == null) {
logger.debug("Parameter readerCacheSize not given, using 20");
rcSize = "20";
}
int readerCacheSize;
try {
readerCacheSize = Integer.parseInt(rcSize);
if (readerCacheSize < 0) {
throw new Exception("Cannot be less than zero");
}
} catch (Exception e) {
throw new ModuleInitializationException(
"Bad value for readerCacheSize parameter: " +
e.getMessage(), getRole());
}
String rcSeconds = getParameter("readerCacheSeconds");
if (rcSeconds == null) {
logger.debug("Parameter readerCacheSeconds not given, using 5");
rcSeconds = "5";
}
int readerCacheSeconds;
try {
readerCacheSeconds = Integer.parseInt(rcSeconds);
if (readerCacheSeconds < 1) {
throw new Exception("Cannot be less than one");
}
} catch (Exception e) {
throw new ModuleInitializationException(
"Bad value for readerCacheSeconds parameter: " +
e.getMessage(), getRole());
}
// configuration of ingest validation
String ingestValidationLevel = getParameter("ingestValidationLevel");
if (ingestValidationLevel == null) {
logger.debug("Ingest validation level not specified, using default of all");
m_ingestValidationLevel = DOValidator.VALIDATE_ALL;
} else {
m_ingestValidationLevel = Integer.parseInt(ingestValidationLevel);
// check the values. better to declare the levels as enums, but this
// would require DOValidator interface change
if (m_ingestValidationLevel < -1 || m_ingestValidationLevel > 2) {
throw new ModuleInitializationException(
"Bad value for ingestValidationLevel", getRole());
}
}
}