/**
* Sets the feed db config details for the given feed as sqlMap resource
*/
private void setFeedDBResourcesToAdapterConfig() {
NamespacedAdapterConfiguration adapterConfig = getConfiguration().getAdapterConfiguration();
// Read the adapter config value. This will be
// <sqlMapConfig>...</sqlMapConfig>
String sqlMapConfig = adapterConfig.getConfigData();
// Get the feed config value to be set as sqlMap resource
String sqlMapFeedUrl = getFeedConfigData();
Document adapterConfigDocument =
FeedServerUtil.parseDocument(sqlMapConfig, new SqlMapClasspathEntityResolver());
if (null == adapterConfigDocument) {
String message = "adapter config document is null";
RuntimeException e = new RuntimeException(message);
logger.log(Level.SEVERE, message, e);
throw e;
}
Element adapterParentNode = adapterConfigDocument.getDocumentElement();
if (!adapterParentNode.getNodeName().equals("sqlMapConfig")) {
String message = "adapter config document element not <sqlMapConfig>";
RuntimeException e = new RuntimeException(message);
logger.log(Level.SEVERE, message, e);
throw e;
}
Element node = adapterConfigDocument.createElement(NODE_SQL_MAP_NAME);
node.setAttribute(ATTRIBUTE_RESOURCE, sqlMapFeedUrl);
adapterParentNode.appendChild(node);
try {
adapterConfig.setConfigData(SQLMAP_DOCTYPE_STRING
+ FeedServerUtil.getDocumentAsXml(adapterConfigDocument));
} catch (TransformerException e) {
logger.log(Level.SEVERE, e.getMessage(), e);
throw new RuntimeException("invalid configuration: " + e.getMessage());
}