try {
stream = new FileInputStream(propertiesFileName);
prop.load(stream);
}
catch (IOException exc) {
throw new UpdateException("Loading properties file failed: "
+ propertiesFileName, exc);
}
finally {
if (stream != null) {
try { stream.close(); } catch (IOException exc) {}
}
}
// Init the data source
try {
String type = getProperty(prop, "dataSource.type", "http");
if (type.equals("http")) {
String url = getProperty(prop, "dataSource.url", getPrimaryServerUrl());
mDataSource = new HttpDataSource(url);
} else if (type.equals("file")) {
String dir = getProperty(prop, "dataSource.dir");
mDataSource = new FileDataSource(new File(dir));
} else {
throw new UpdateException("dataSource.type must be either 'http' or 'file'");
}
}
catch (Exception exc) {
throw new UpdateException("Error initializing data source from "
+ "properties file: " + propertiesFileName, exc);
}
// Init the data target
try {
String type = getProperty(prop, "dataTarget.type", "ftp");
if (type.equals("ftp")) {
String url = getProperty(prop, "dataTarget.url");
String path = getProperty(prop, "dataTarget.path", "tvdata");
int port = getIntProperty(prop, "dataTarget.port", 21);
String user = getProperty(prop, "dataTarget.user");
String password = getProperty(prop, "dataTarget.password");
mDataTarget = new FtpDataTarget(url, path, port, user, password);
} else if (type.equals("file")) {
String dir = getProperty(prop, "dataTarget.dir");
mDataTarget = new FileDataTarget(new File(dir));
} else {
throw new UpdateException("dataTarget.type must be either 'ftp' or 'file'");
}
}
catch (Exception exc) {
throw new UpdateException("Error initializing data target from "
+ "properties file: " + propertiesFileName, exc);
}
// Get the channel groups