try {
LOGGER.logp(Level.CONFIG, CLASS_NAME, METHOD,
"Loading configuration from system setup document.");
NotesView vw = db.getView(NCCONST.VIEWSYSTEMSETUP);
NotesDocument systemDoc = vw.getFirstDocument();
if (null == systemDoc) {
LOGGER.logp(Level.SEVERE, CLASS_NAME, METHOD,
"System configuration document not found.");
return false;
}
// "." means no file extension. Replace with an empty string if it exists.
ExcludedExtns = (Vector<String>)
systemDoc.getItemValue(NCCONST.SITM_EXCLUDEDEXTENSIONS);
for (int i = 0; i < ExcludedExtns.size(); i++ ) {
LOGGER.logp(Level.CONFIG, CLASS_NAME, METHOD,
"The following file extensions will be excluded " +
ExcludedExtns.elementAt(i).toString());
if (ExcludedExtns.elementAt(i).equals(".")) {
ExcludedExtns.set(i, "");
}
}
MaxFileSize = 1024 * 1024 *
systemDoc.getItemValueInteger(NCCONST.SITM_MAXFILESIZE);
LOGGER.logp(Level.CONFIG, CLASS_NAME, METHOD,
"Maximum attachment size is " + MaxFileSize);
// If 0, use the default value
if (0 == MaxFileSize)
MaxFileSize = 1024 * 1024 * NCCONST.DEFAULT_MAX_FILE_LIMIT;
// Get the spool directory for processing attachments
SpoolDir = systemDoc.getItemValueString(NCCONST.SITM_SPOOLDIR);
if ((null == SpoolDir) || (0 == SpoolDir.length())) {
SpoolDir = String.format("%s/%s",
ns.getEnvironmentString(NCCONST.INIDIRECTORY, true),
NCCONST.DEFAULT_ATTACHMENT_DIR);;
}
java.io.File sdir = new java.io.File(SpoolDir);
// Make the directory and make sure we can write to it
sdir.mkdirs();
if (!sdir.isDirectory() || !sdir.canWrite()) {
LOGGER.logp(Level.SEVERE, CLASS_NAME, METHOD,
"Can't write to spool directory " + SpoolDir);
return false;
}
LOGGER.logp(Level.CONFIG, CLASS_NAME, METHOD,
"Attachment spool directory is set to " + SpoolDir);
// Threshhold for polling
maxCrawlQDepth = systemDoc.getItemValueInteger(
NCCONST.SITM_MAXCRAWLQDEPTH);
if (maxCrawlQDepth < 1) {
LOGGER.logp(Level.SEVERE, CLASS_NAME, METHOD,
"Invalid setting for maxCrawlQDepth: " + maxCrawlQDepth);
return false;
}
LOGGER.logp(Level.CONFIG, CLASS_NAME, METHOD,
"maxCrawlQDepth is " + maxCrawlQDepth);
// Time between user/group cache updates
cacheUpdateInterval = systemDoc.getItemValueInteger(
NCCONST.SITM_CACHEUPDATEINTERVAL);
if (cacheUpdateInterval < 1) {
LOGGER.logp(Level.SEVERE, CLASS_NAME, METHOD,
"Invalid setting for cache update interval: "
+ cacheUpdateInterval);
return false;
}
LOGGER.logp(Level.CONFIG, CLASS_NAME, METHOD,
"cacheUpdateInterval is " + cacheUpdateInterval);
// Get the directory and see if we can open it
directory = systemDoc.getItemValueString(
NCCONST.SITM_DIRECTORY);
LOGGER.logp(Level.CONFIG, CLASS_NAME, METHOD,
"Path to Domino directory: " + directory);
NotesDatabase dirDb = ns.getDatabase(this.getServer(), directory);
dirDb.recycle();
userNameFormula = systemDoc.getItemValueString(
NCCONST.SITM_USERNAMEFORMULA);
if (0 == userNameFormula.length()) {
LOGGER.logp(Level.CONFIG, CLASS_NAME, METHOD,
"User Name formula is empty - using default");
userNameFormula = NCCONST.DEFAULT_USERNAMEFORMULA;
}
LOGGER.logp(Level.CONFIG, CLASS_NAME, METHOD,
"User Name formula: " + userNameFormula);
String usernameTypeConfig = systemDoc.getItemValueString(
NCCONST.SITM_USERNAMETYPE);
if (usernameTypeConfig != null && usernameTypeConfig.length() > 0) {
usernameType = NotesUsernameType.findUsernameType(
usernameTypeConfig.toUpperCase());
}
LOGGER.log(Level.CONFIG, "Notes username type: " + usernameType.name());
userSelectionFormula = systemDoc.getItemValueString(
NCCONST.SITM_USERSELECTIONFORMULA);
if (0 == userSelectionFormula.length()) {
LOGGER.logp(Level.CONFIG, CLASS_NAME, METHOD,
"User Selection formula is empty - using default");
userSelectionFormula = NCCONST.DEFAULT_USERSELECTIONFORMULA;
}
LOGGER.logp(Level.CONFIG, CLASS_NAME, METHOD,
"User Selection formula: " + userSelectionFormula);
gsaGroupPrefix =
systemDoc.getItemValueString(NCCONST.SITM_GSAGROUPPREFIX);
if (null != gsaGroupPrefix) {
gsaGroupPrefix = gsaGroupPrefix.trim();
}
LOGGER.logp(Level.CONFIG, CLASS_NAME, METHOD,
"Group prefix: " + gsaGroupPrefix);
// Number of docs to check when deleting
deletionBatchSize = systemDoc.getItemValueInteger(
NCCONST.SITM_DELETIONBATCHSIZE);
if (deletionBatchSize < 1) {
LOGGER.logp(Level.SEVERE, CLASS_NAME, METHOD,
"Invalid setting for deletionBatchSize: " + deletionBatchSize);
return false;
}
LOGGER.logp(Level.CONFIG, CLASS_NAME, METHOD,
"deletionBatchSize is " + deletionBatchSize);
// Number of crawler threads to spawn
numCrawlerThreads = systemDoc.getItemValueInteger(
NCCONST.SITM_NUMCRAWLERTHREADS);
if ((numCrawlerThreads < 0) || (numCrawlerThreads > 5)) {
LOGGER.logp(Level.SEVERE, CLASS_NAME, METHOD,
"Invalid setting for numCrawlerThreads: " + numCrawlerThreads);
return false;
}
LOGGER.logp(Level.CONFIG, CLASS_NAME, METHOD,
"numCrawlerThreads is " + numCrawlerThreads);
// Load server regions
LOGGER.logp(Level.CONFIG, CLASS_NAME, METHOD, "Loading server domains.");
NotesView serversView = db.getView(NCCONST.VIEWSERVERS);
serversView.refresh();
NotesViewNavigator svn = serversView.createViewNav();
NotesViewEntry sve = svn.getFirst();
while (null != sve) {
Vector<?> columnVals = sve.getColumnValues();
String domain = columnVals.elementAt(2).toString().toLowerCase();
if (!Strings.isNullOrEmpty(domain)) {
if (!domain.trim().startsWith(".")) {
domain = "." + domain.trim();
}
}
// This is a problem with the Notes Java API. When the
// server field for a given region has 1 element we get a
// String in the server column of the ViewEntry. When
// the server field has more than 1 element we get one
// ViewEntry for each server value, but the value
// returned in the getColumnValues Vector is a Vector
// with one element.
String server;
Object serverObject = columnVals.elementAt(0);
if (serverObject instanceof String) {
server = ((String) serverObject).toLowerCase();
} else if (serverObject instanceof Vector) {
Vector serverVector = (Vector) serverObject;
if (serverVector.size() == 0) {
LOGGER.logp(Level.CONFIG, CLASS_NAME, METHOD, "Empty server value");
continue;
}
server = ((String) serverVector.elementAt(0)).toLowerCase();
} else {
LOGGER.logp(Level.CONFIG, CLASS_NAME, METHOD,
"Unknown server value " + serverObject);
continue;
}
LOGGER.logp(Level.CONFIG, CLASS_NAME, METHOD,
"Server {0} is in domain {1}", new Object[] { server, domain });
serverDomainMap.put(server, domain);
NotesViewEntry tmpsve = svn.getNext();
sve.recycle();
sve = tmpsve;
}
svn.recycle();
serversView.recycle();
if (0 == serverDomainMap.size()) {
LOGGER.logp(Level.SEVERE, CLASS_NAME, METHOD,
"No regions have been configured for this connector.");
return false;
}