StringBuffer exceptionBuffer =
new StringBuffer(256)
.append("Malformed destinationURL - Must be of the format '")
.append("db://<data-source>[/<table>[/<repositoryName>]]'. Was passed ")
.append(conf.getAttribute("destinationURL"));
throw new ConfigurationException(exceptionBuffer.toString());
}
if (urlParams.size() >= 1) {
datasourceName = (String)urlParams.get(0);
}
if (urlParams.size() >= 2) {
tableName = (String)urlParams.get(1);
}
if (urlParams.size() >= 3) {
repositoryName = "";
for (int i = 2; i < urlParams.size(); i++) {
if (i >= 3) {
repositoryName += '/';
}
repositoryName += (String)urlParams.get(i);
}
}
if (getLogger().isDebugEnabled()) {
StringBuffer logBuffer =
new StringBuffer(128)
.append("Parsed URL: table = '")
.append(tableName)
.append("', repositoryName = '")
.append(repositoryName)
.append("'");
getLogger().debug(logBuffer.toString());
}
filestore = conf.getChild("filestore").getValue(null);
sqlFileName = conf.getChild("sqlFile").getValue();
if (!sqlFileName.startsWith("file://")) {
throw new ConfigurationException
("Malformed sqlFile - Must be of the format 'file://<filename>'.");
}
try {
if (filestore != null) {
Store store = (Store)componentManager.
lookup("org.apache.avalon.cornerstone.services.store.Store");
//prepare Configurations for stream repositories
DefaultConfiguration streamConfiguration
= new DefaultConfiguration( "repository",
"generated:JDBCMailRepository.configure()" );
streamConfiguration.setAttribute( "destinationURL", filestore );
streamConfiguration.setAttribute( "type", "STREAM" );
streamConfiguration.setAttribute( "model", "SYNCHRONOUS" );
sr = (StreamRepository) store.select(streamConfiguration);
if (getLogger().isDebugEnabled()) {
getLogger().debug("Got filestore for JdbcMailRepository: " + filestore);
}
}
lock = new Lock();
if (getLogger().isDebugEnabled()) {
StringBuffer logBuffer =
new StringBuffer(128)
.append(this.getClass().getName())
.append(" created according to ")
.append(destination);
getLogger().debug(logBuffer.toString());
}
} catch (Exception e) {
final String message = "Failed to retrieve Store component:" + e.getMessage();
getLogger().error(message, e);
e.printStackTrace();
throw new ConfigurationException(message, e);
}
}