Update of /cvsroot/babeldoc/babeldoc/modules/scanner/src/com/babeldoc/scanner/worker
In directory sc8-pr-cvs1:/tmp/cvs-serv17646/modules/scanner/src/com/babeldoc/scanner/worker
Modified Files:
DirectoryScanner.java ExternalApplicationScanner.java
FtpScanner.java HttpScanner.java MailboxScanner.java
SqlScanner.java
Log Message:
Updates to the scanner code - added the count down option. Updated the I/ConfigInfo object for the getStrValue, getIntValue and the getValue methods for quick and easy access to the option values.
Index: DirectoryScanner.java
===================================================================
RCS file: /cvsroot/babeldoc/babeldoc/modules/scanner/src/com/babeldoc/scanner/worker/DirectoryScanner.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -d -r1.17 -r1.18
*** DirectoryScanner.java 14 Aug 2003 02:34:21 -0000 1.17
--- DirectoryScanner.java 17 Aug 2003 04:12:29 -0000 1.18
***************
*** 148,152 ****
}
! setDoneDirectory((String)this.getInfo().getOption(DONE_DIR).getValue());
//if the done directory does not end with '/' then add one.
--- 148,152 ----
}
! setDoneDirectory(this.getInfo().getStrValue(DONE_DIR));
//if the done directory does not end with '/' then add one.
***************
*** 163,167 ****
try {
! setIncludeSubDirs("true".equals(this.getInfo().getOption(INCLUDE_SUB_DIRS).getClass()));
} catch (Exception e) {
// Dont catch or do anything here - this means that the default is accepted.
--- 163,167 ----
try {
! setIncludeSubDirs("true".equals(this.getInfo().getStrValue(INCLUDE_SUB_DIRS)));
} catch (Exception e) {
// Dont catch or do anything here - this means that the default is accepted.
***************
*** 212,217 ****
file.renameTo(outfile);
} catch (Exception e) {
! throw new ScannerException(I18n.get(
! "scanner.DirectoryScanner.error.finishing"), e);
}
}
--- 212,216 ----
file.renameTo(outfile);
} catch (Exception e) {
! throw new ScannerException(I18n.get("scanner.DirectoryScanner.error.finishing"), e);
}
}
Index: ExternalApplicationScanner.java
===================================================================
RCS file: /cvsroot/babeldoc/babeldoc/modules/scanner/src/com/babeldoc/scanner/worker/ExternalApplicationScanner.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** ExternalApplicationScanner.java 14 Aug 2003 02:34:21 -0000 1.4
--- ExternalApplicationScanner.java 17 Aug 2003 04:12:29 -0000 1.5
***************
*** 146,150 ****
public void initialize() throws ScannerConfigurationException {
// getLog().info("initialize");
! application = (String)this.getInfo().getOption(APPLICATION).getValue();
if ((application == null) || !(new File(application).isFile())) {
--- 146,150 ----
public void initialize() throws ScannerConfigurationException {
// getLog().info("initialize");
! application = this.getInfo().getStrValue(APPLICATION);
if ((application == null) || !(new File(application).isFile())) {
Index: FtpScanner.java
===================================================================
RCS file: /cvsroot/babeldoc/babeldoc/modules/scanner/src/com/babeldoc/scanner/worker/FtpScanner.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -C2 -d -r1.17 -r1.18
*** FtpScanner.java 14 Aug 2003 02:34:21 -0000 1.17
--- FtpScanner.java 17 Aug 2003 04:12:29 -0000 1.18
***************
*** 177,187 ****
public void initialize() throws ScannerConfigurationException {
// LogService.getInstance().logInfo("initialize");
! ftpHost = (String)this.getInfo().getOption(FTP_HOST).getValue();
! ftpUsername = (String)this.getInfo().getOption(FTP_USERNAME).getValue();
! ftpFolder = (String)this.getInfo().getOption(FTP_FOLDER).getValue();
! ftpOutFolder = (String)this.getInfo().getOption(FTP_OUT_FOLDER).getValue();
! localBackupFolder = (String)this.getInfo().getOption(LOCAL_BK_FOLDER).getValue();
! if (("true".equalsIgnoreCase((String)this.getInfo().getOption(SCAN_SUBFOLDERS).getValue()))) {
scanSubfolders = true;
}
--- 177,187 ----
public void initialize() throws ScannerConfigurationException {
// LogService.getInstance().logInfo("initialize");
! ftpHost = this.getInfo().getStrValue(FTP_HOST);
! ftpUsername = this.getInfo().getStrValue(FTP_USERNAME);
! ftpFolder = this.getInfo().getStrValue(FTP_FOLDER);
! ftpOutFolder = this.getInfo().getStrValue(FTP_OUT_FOLDER);
! localBackupFolder = this.getInfo().getStrValue(LOCAL_BK_FOLDER);
! if (("true".equalsIgnoreCase(this.getInfo().getStrValue(SCAN_SUBFOLDERS)))) {
scanSubfolders = true;
}
***************
*** 195,200 ****
connectToHost();
} catch (ScannerException se) {
! throw new ScannerConfigurationException(I18n.get(
! "scanner.FtpScanner.error.init"), se);
}
}
--- 195,199 ----
connectToHost();
} catch (ScannerException se) {
! throw new ScannerConfigurationException(I18n.get("scanner.FtpScanner.error.init"), se);
}
}
***************
*** 229,234 ****
if (!ftpClient.changeWorkingDirectory(ftpFolder)) {
ftpClient.disconnect();
! throw new ScannerException(I18n.get(
! "scanner.FtpScanner.error.notReachable"));
}
} else {
--- 228,232 ----
if (!ftpClient.changeWorkingDirectory(ftpFolder)) {
ftpClient.disconnect();
! throw new ScannerException(I18n.get("scanner.FtpScanner.error.notReachable"));
}
} else {
***************
*** 238,243 ****
} else {
ftpClient.disconnect();
! throw new ScannerException(I18n.get(
! "scanner.FtpScanner.error.connection"));
}
--- 236,240 ----
} else {
ftpClient.disconnect();
! throw new ScannerException(I18n.get("scanner.FtpScanner.error.connection"));
}
Index: HttpScanner.java
===================================================================
RCS file: /cvsroot/babeldoc/babeldoc/modules/scanner/src/com/babeldoc/scanner/worker/HttpScanner.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** HttpScanner.java 14 Aug 2003 02:34:21 -0000 1.4
--- HttpScanner.java 17 Aug 2003 04:12:29 -0000 1.5
***************
*** 76,80 ****
import org.apache.commons.httpclient.*;
import org.apache.commons.httpclient.methods.GetMethod;
- import org.apache.commons.lang.NumberUtils;
import java.io.IOException;
--- 76,79 ----
***************
*** 108,111 ****
--- 107,115 ----
public static final String PROXY_PORT = "proxyPort";
+ /** Default values for the configuration options */
+ public static final int DEFAULT_ATTEMPTS = 1;
+ public static final int DEFAULT_PROXYPORT = 80;
+ public static final int DEFAULT_TIMEOUT = 15000;
+
// Instance fields
HttpClient httpClient = null;
***************
*** 163,174 ****
*/
public void initialize() throws ScannerConfigurationException {
! url = (String)this.getInfo().getOption(URI).getValue();
! attempts = NumberUtils.stringToInt((String)this.getInfo().getOption(ATTEMPTS).getValue(), attempts);
! proxyHost = (String)this.getInfo().getOption(PROXY_HOST).getValue();
! proxyPort = NumberUtils.stringToInt((String)this.getInfo().getOption(PROXY_PORT).getValue(), proxyPort);
! timeout = NumberUtils.stringToInt((String)this.getInfo().getOption(TIMEOUT).getValue(), timeout);
! realm = (String)this.getInfo().getOption(REALM).getValue();
! user = (String)this.getInfo().getOption(USER).getValue();
! password = (String)this.getInfo().getOption(PASSWORD).getValue();
HostConfiguration httpConfig = new HostConfiguration();
--- 167,178 ----
*/
public void initialize() throws ScannerConfigurationException {
! url = this.getInfo().getStrValue(URI);
! attempts = this.getInfo().getIntValue(ATTEMPTS);
! proxyHost = this.getInfo().getStrValue(PROXY_HOST);
! proxyPort = this.getInfo().getIntValue(PROXY_PORT);
! timeout = this.getInfo().getIntValue(TIMEOUT);
! realm = this.getInfo().getStrValue(REALM);
! user = this.getInfo().getStrValue(USER);
! password = this.getInfo().getStrValue(PASSWORD);
HostConfiguration httpConfig = new HostConfiguration();
***************
*** 230,235 ****
// Check that we didn't run out of retries.
if (statusCode == -1) {
! LogService.getInstance().logError(I18n.get(
! "scanner.HttpScanner.error.failed", url), null);
return null;
--- 234,238 ----
// Check that we didn't run out of retries.
if (statusCode == -1) {
! LogService.getInstance().logError(I18n.get("scanner.HttpScanner.error.failed", url), null);
return null;
***************
*** 242,246 ****
/**
! * TODO: DOCUMENT ME!
*
* @author $author$
--- 245,249 ----
/**
! * HttpScanner configuration info
*
* @author $author$
***************
*** 249,253 ****
class HttpScannerInfo extends ScannerWorkerInfo {
/**
! * TODO: DOCUMENT ME!
*
* @return DOCUMENT ME!
--- 252,256 ----
class HttpScannerInfo extends ScannerWorkerInfo {
/**
! * Get the description
*
* @return DOCUMENT ME!
***************
*** 258,262 ****
/**
! * TODO: DOCUMENT ME!
*
* @return DOCUMENT ME!
--- 261,265 ----
/**
! * Get the name of this scanner worker
*
* @return DOCUMENT ME!
***************
*** 267,271 ****
/**
! * TODO: DOCUMENT ME!
*
* @return DOCUMENT ME!
--- 270,274 ----
/**
! * Get the configuration options.
*
* @return DOCUMENT ME!
***************
*** 275,280 ****
//add specific options
! options.add(new ConfigOption(HttpScanner.URI, IConfigOptionType.STRING,
null, true, "URI to getChild the document from"));
return options;
--- 278,298 ----
//add specific options
! options.add(new ConfigOption(HttpScanner.URI, IConfigOptionType.URL,
null, true, "URI to getChild the document from"));
+ options.add(new ConfigOption(HttpScanner.ATTEMPTS, IConfigOptionType.INTEGER,
+ Integer.toString(HttpScanner.DEFAULT_ATTEMPTS), false,
+ "Number of times to attempt to get the document"));
+ options.add(new ConfigOption(HttpScanner.USER, IConfigOptionType.STRING,
+ null, false, "Authenticate with this user name"));
+ options.add(new ConfigOption(HttpScanner.PASSWORD, IConfigOptionType.STRING,
+ null, false, "Authenticate with this password"));
+ options.add(new ConfigOption(HttpScanner.REALM, IConfigOptionType.STRING,
+ null, false, "Authenticate with this realm"));
+ options.add(new ConfigOption(HttpScanner.PROXY_HOST, IConfigOptionType.URL,
+ null, false, "URL of the proxy host"));
+ options.add(new ConfigOption(HttpScanner.PROXY_PORT, IConfigOptionType.INTEGER,
+ Integer.toString(HttpScanner.DEFAULT_PROXYPORT), false, "proxy port"));
+ options.add(new ConfigOption(HttpScanner.TIMEOUT, IConfigOptionType.INTEGER,
+ Integer.toString(HttpScanner.DEFAULT_TIMEOUT), false, "retry timeout"));
return options;
Index: MailboxScanner.java
===================================================================
RCS file: /cvsroot/babeldoc/babeldoc/modules/scanner/src/com/babeldoc/scanner/worker/MailboxScanner.java,v
retrieving revision 1.21
retrieving revision 1.22
diff -C2 -d -r1.21 -r1.22
*** MailboxScanner.java 14 Aug 2003 02:34:21 -0000 1.21
--- MailboxScanner.java 17 Aug 2003 04:12:29 -0000 1.22
***************
*** 118,121 ****
--- 118,123 ----
public static String DEFAULT_PROTOCOL = "pop3";
public static String DEFAULT_FOLDER = "INBOX";
+
+ /** Instance variables */
Folder folder;
Session session;
***************
*** 190,201 ****
*/
public void initialize() throws ScannerConfigurationException {
! host = (String)this.getInfo().getOption(HOST).getValue();
! protocol = (String)this.getInfo().getOption(PROTOCOL).getValue();
! folder_ = (String)this.getInfo().getOption(FOLDER).getValue();
! username = (String)this.getInfo().getOption(USERNAME).getValue();
! password = (String)this.getInfo().getOption(PASSWORD).getValue();
//Dejan 03.10.2002.
! getFrom = (String)this.getInfo().getOption(GET_FROM).getValue();
if (getFrom == null) {
--- 192,203 ----
*/
public void initialize() throws ScannerConfigurationException {
! host = this.getInfo().getStrValue(HOST);
! protocol = this.getInfo().getStrValue(PROTOCOL);
! folder_ = this.getInfo().getStrValue(FOLDER);
! username = this.getInfo().getStrValue(USERNAME);
! password = this.getInfo().getStrValue(PASSWORD);
//Dejan 03.10.2002.
! getFrom = this.getInfo().getStrValue(GET_FROM);
if (getFrom == null) {
***************
*** 215,220 ****
store.connect(host, username, password);
} catch (Exception x) {
! throw new ScannerConfigurationException(I18n.get(
! "scanner.MailboxScanner.error.initialize"), x);
}
}
--- 217,221 ----
store.connect(host, username, password);
} catch (Exception x) {
! throw new ScannerConfigurationException(I18n.get("scanner.MailboxScanner.error.initialize"), x);
}
}
***************
*** 371,375 ****
/**
! * TODO: DOCUMENT ME!
*
* @author $author$
--- 372,376 ----
/**
! * The configuration options for the mailbox scanner.
*
* @author $author$
***************
*** 377,403 ****
*/
class MailboxScannerInfo extends ScannerWorkerInfo {
- /**
- * TODO: DOCUMENT ME!
- *
- * @return DOCUMENT ME!
- */
public String getDescription() {
return com.babeldoc.core.I18n.get("scanner.MailboxScannerInfo.description");
}
- /**
- * TODO: DOCUMENT ME!
- *
- * @return DOCUMENT ME!
- */
public String getName() {
return "MailboxScanner";
}
- /**
- * TODO: DOCUMENT ME!
- *
- * @return DOCUMENT ME!
- */
public Collection getTypeSpecificOptions() {
ArrayList options = new ArrayList();
--- 378,389 ----
Index: SqlScanner.java
===================================================================
RCS file: /cvsroot/babeldoc/babeldoc/modules/scanner/src/com/babeldoc/scanner/worker/SqlScanner.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** SqlScanner.java 14 Aug 2003 02:34:21 -0000 1.9
--- SqlScanner.java 17 Aug 2003 04:12:29 -0000 1.10
***************
*** 221,225 ****
*/
public void initialize() throws ScannerConfigurationException {
! resourceName = (String)this.getInfo().getOption(RESOURCE_NAME).getValue();
if (resourceName.equals("")) {
--- 221,225 ----
*/
public void initialize() throws ScannerConfigurationException {
! resourceName = this.getInfo().getStrValue(RESOURCE_NAME);
if (resourceName.equals("")) {
***************
*** 227,231 ****
}
! sqlStatement = (String)this.getInfo().getOption(SQL_STATEMENT).getValue();
if (sqlStatement.equals("")) {
--- 227,231 ----
}
! sqlStatement = this.getInfo().getStrValue(SQL_STATEMENT);
if (sqlStatement.equals("")) {
***************
*** 233,246 ****
}
! documentType = (String)this.getInfo().getOption(DOCUMENT_TYPE).getValue();
if (DOC_TYPE_CSV.equalsIgnoreCase(documentType)) {
//getChild cvs options
! fieldSeparator = (String)this.getInfo().getOption(FIELD_SEPARATOR).getValue();
! rowSeparator = (String)this.getInfo().getOption(ROW_SEPARATOR).getValue();
} else if (DOC_TYPE_XML.equalsIgnoreCase(documentType)) {
//getChild xml options
! headingTag = (String)this.getInfo().getOption(XML_HEADING_TAG).getValue();
! rowTag = (String)this.getInfo().getOption(XML_ROW_TAG).getValue();
}
}
--- 233,246 ----
}
! documentType = this.getInfo().getStrValue(DOCUMENT_TYPE);
if (DOC_TYPE_CSV.equalsIgnoreCase(documentType)) {
//getChild cvs options
! fieldSeparator = this.getInfo().getStrValue(FIELD_SEPARATOR);
! rowSeparator = this.getInfo().getStrValue(ROW_SEPARATOR);
} else if (DOC_TYPE_XML.equalsIgnoreCase(documentType)) {
//getChild xml options
! headingTag = this.getInfo().getStrValue(XML_HEADING_TAG);
! rowTag = this.getInfo().getStrValue(XML_ROW_TAG);
}
}
|