if (connection == null) {
connection = this.dataSource.getConnection();
}
RssItem item = (RssItem)entry.getValue();
// Strip tags before passing guid to stored function.
String guid = strings.strip( "</?guid[^>]*>", item.getGuid() );
// Strip tags and escape apostrophes before passing title to stored function.
String title = strings.strip( "</?title>", item.getTitle() );
title = strings.substitute("'", "''", title);
// Escape dollar signs in title before using in substitution.
title = title.replace("\\$", "\\\\$");
// Fill in placeholder parameters from stored function node in config file.
boolean deepCopy = true;
Node functionNode = this.dbFunctionNode.cloneNode(deepCopy);
NodeList functionParameters = ((Element)functionNode).getElementsByTagName(DBXmlConfig.DB_PARAM);
for (int i = 0; i < functionParameters.getLength(); i++) {
// Each parameter node contains a text node whose value is the actual parameter value.
Node parameter = functionParameters.item(i);
String parameterValue = parameter.getFirstChild().getNodeValue();
parameterValue = parameterValue.replace(XmultraConfig.RSS_ITEM_GUID_SYMBOL, guid);
parameterValue = parameterValue.replace(XmultraConfig.RSS_ITEM_TITLE_SYMBOL, title);
parameter.getFirstChild().setNodeValue(parameterValue);
}
String fileName = (String)dataSource.callStoredFunction(connection, functionNode);
String fileContents = "";
if (fileName != null) {
fileContents = fileUtils.readFile( fileUtils.addRoot(fileName) );
}
if ( !fileContents.equals("") ) {
RssItem fullTextItem = null;
try {
boolean keepCDataSections = true;
fullTextItem = new RssItem(fileContents, keepCDataSections);
String fullText = fullTextItem.getContentEncoded();
item.setContentEncoded(fullText, updateText);
// Retrieve byline and credit line from full-text item if necessary,
// as when a Daylife feed is being processed.
String itemCreator = item.getCreator();
if ( itemCreator == null || itemCreator.equals("") ) {
String fullTextItemCreator = fullTextItem.getCreator();
if ( fullTextItemCreator != null && !fullTextItemCreator.equals("") ) {
item.setCreator(fullTextItemCreator, updateText);
}
}