/**
* Initialize the mailet
*/
public void init() throws MessagingException {
if (getInitParameter("data_source") == null) {
throw new MailetException("data_source not specified for JDBCListserv");
}
if (getInitParameter("listserv_id") == null) {
throw new MailetException("listserv_id not specified for JDBCListserv");
}
if (getInitParameter("listserv_table") == null) {
throw new MailetException("listserv_table not specified for JDBCListserv");
}
if (getInitParameter("members_table") == null) {
throw new MailetException("members_table not specified for JDBCListserv");
}
String datasourceName = getInitParameter("data_source");
listservID = getInitParameter("listserv_id");
listservTable = getInitParameter("listserv_table");
membersTable = getInitParameter("members_table");
if (getInitParameter("cache_settings") != null) {
try {
cacheSettings = new Boolean(getInitParameter("cache_settings")).booleanValue();
} catch (Exception e) {
//ignore error
}
}
Connection conn = null;
try {
ServiceManager componentManager = (ServiceManager)getMailetContext().getAttribute(Constants.AVALON_COMPONENT_MANAGER);
// Get the DataSourceSelector service
DataSourceSelector datasources = (DataSourceSelector)componentManager.lookup(DataSourceSelector.ROLE);
// Get the data-source required.
datasource = (DataSourceComponent)datasources.select(datasourceName);
conn = datasource.getConnection();
// Check if the required listserv table exists. If not, complain.
DatabaseMetaData dbMetaData = conn.getMetaData();
// Need to ask in the case that identifiers are stored, ask the DatabaseMetaInfo.
// Try UPPER, lower, and MixedCase, to see if the table is there.
if (!(theJDBCUtil.tableExists(dbMetaData, listservTable))) {
StringBuffer exceptionBuffer =
new StringBuffer(128)
.append("Could not find table '")
.append(listservTable)
.append("' in datasource '")
.append(datasourceName)
.append("'");
throw new MailetException(exceptionBuffer.toString());
}
// Check if the required members table exists. If not, complain.
// Need to ask in the case that identifiers are stored, ask the DatabaseMetaInfo.
// Try UPPER, lower, and MixedCase, to see if the table is there.
if (!( theJDBCUtil.tableExists(dbMetaData, membersTable))) {
StringBuffer exceptionBuffer =
new StringBuffer(128)
.append("Could not find table '")
.append(membersTable)
.append("' in datasource '")
.append(datasourceName)
.append("'");
throw new MailetException(exceptionBuffer.toString());
}
StringBuffer queryBuffer =
new StringBuffer(256)
.append("SELECT members_only, attachments_allowed, reply_to_list, subject_prefix, list_address FROM ")