[jboss-svn-commits] JBL Code SVN: r19637 - in labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta: src/org/jboss/soa/esb/notification and 1 other directories.
jboss-svn-commits at lists.jboss.org
jboss-svn-commits at lists.jboss.org
Sat Apr 19 00:57:55 EDT 2008
Author: tcunning
Date: 2008-04-19 00:57:55 -0400 (Sat, 19 Apr 2008)
New Revision: 19637
Modified:
labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/internal/soa/esb/notification/PropertySubstituter.java
labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/soa/esb/notification/NotifyFiles.java
labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/soa/esb/notification/NotifySqlTable.java
labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/tests/src/org/jboss/soa/esb/notification/NotifyFilesUnitTest.java
labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/tests/src/org/jboss/soa/esb/notification/NotifySqlTableUnitTest.java
Log:
bug:JBESB-1589
Unify substitution in NotifyFiles and NotifySqlTable.
Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/internal/soa/esb/notification/PropertySubstituter.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/internal/soa/esb/notification/PropertySubstituter.java 2008-04-18 21:53:36 UTC (rev 19636)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/internal/soa/esb/notification/PropertySubstituter.java 2008-04-19 04:57:55 UTC (rev 19637)
@@ -10,7 +10,12 @@
public static String replaceArguments (String field, Message message) {
String current = field;
boolean foundReplacement = false;
+ if (field == null) {
+ return null;
+ }
+
String replaced = replaceArgument(field, message);
+
while (!current.equals(replaced)) {
current = replaced;
foundReplacement = true;
Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/soa/esb/notification/NotifyFiles.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/soa/esb/notification/NotifyFiles.java 2008-04-18 21:53:36 UTC (rev 19636)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/soa/esb/notification/NotifyFiles.java 2008-04-19 04:57:55 UTC (rev 19637)
@@ -23,6 +23,7 @@
package org.jboss.soa.esb.notification;
import org.apache.log4j.Logger;
+import org.jboss.internal.soa.esb.notification.PropertySubstituter;
import org.jboss.soa.esb.helpers.ConfigTree;
import org.jboss.soa.esb.listeners.message.MessageDeliverException;
import org.jboss.soa.esb.message.Message;
@@ -92,7 +93,6 @@
public NotifyFiles (ConfigTree configTree)
{
super(configTree);
- setFiles(configTree.getChildren(CHILD_FILE));
payloadProxy = new MessagePayloadProxy(configTree,
new String[] {BytesBody.BYTES_LOCATION},
new String[] {BytesBody.BYTES_LOCATION});
@@ -108,8 +108,10 @@
* have an optional "append" attribute
* @see ConfigTree#getAttribute(String)
*/
- protected void setFiles (ConfigTree[] p_oaP)
+ protected void setFiles(Message message)
{
+
+ ConfigTree[] p_oaP = m_oParms.getChildren(CHILD_FILE);
m_oaOutF = new NotificationFile[p_oaP.length];
for (int i = 0; i < p_oaP.length; i++)
@@ -124,6 +126,9 @@
}
fileURIString = fileURIString.replace('\\', '/');
+ fileURIString = PropertySubstituter.replaceArguments(fileURIString, message);
+ append = PropertySubstituter.replaceArguments(append, message);
+
try {
URI fileURI = new URI(fileURIString);
@@ -165,6 +170,7 @@
public void sendNotification (Message message) throws NotificationException
{
FileOutputStream fileOutStream = null;
+ setFiles(message);
final StringBuilder exceptions = new StringBuilder();
for (NotificationFile notificationFile : m_oaOutF)
Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/soa/esb/notification/NotifySqlTable.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/soa/esb/notification/NotifySqlTable.java 2008-04-18 21:53:36 UTC (rev 19636)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/src/org/jboss/soa/esb/notification/NotifySqlTable.java 2008-04-19 04:57:55 UTC (rev 19637)
@@ -27,6 +27,7 @@
import java.util.Properties;
import org.apache.log4j.Logger;
+import org.jboss.internal.soa.esb.notification.PropertySubstituter;
import org.jboss.soa.esb.ConfigurationException;
import org.jboss.soa.esb.listeners.message.MessageDeliverException;
import org.jboss.soa.esb.helpers.ConfigTree;
@@ -58,6 +59,14 @@
public NotifySqlTable (ConfigTree configTree) throws ConfigurationException
{
super(configTree);
+
+ payloadProxy = new MessagePayloadProxy(configTree,
+ new String[] {BytesBody.BYTES_LOCATION},
+ new String[] {BytesBody.BYTES_LOCATION});
+ } // __________________________________
+
+
+ private void setProperties(Message message) throws ConfigurationException {
m_sDriver = getAttr(SimpleDataSource.DRIVER);
m_sURL = getAttr(SimpleDataSource.URL);
m_sUser = getAttr(SimpleDataSource.USER);
@@ -66,7 +75,7 @@
m_sDataCol = getAttr(ATT_DATA);
m_oCols = new Properties();
- ConfigTree[] oaP = configTree.getChildren(CHILD_COLUMN);
+ ConfigTree[] oaP = m_oParms.getChildren(CHILD_COLUMN);
for (int i1 = 0; i1 < oaP.length; i1++)
{
ConfigTree oCurr = oaP[i1];
@@ -85,14 +94,13 @@
{
sVal = "";
}
+
+ sCol = PropertySubstituter.replaceArguments(sCol, message);
+ sVal = PropertySubstituter.replaceArguments(sVal, message);
m_oCols.setProperty(sCol, sVal);
}
-
- payloadProxy = new MessagePayloadProxy(configTree,
- new String[] {BytesBody.BYTES_LOCATION},
- new String[] {BytesBody.BYTES_LOCATION});
- } // __________________________________
-
+ }
+
private String getAttr (String p_sAtt) throws ConfigurationException
{
String sRet = m_oParms.getAttribute(p_sAtt);
@@ -124,7 +132,7 @@
{
String sIn = (i1 == 0) ? "(" : ",";
String sCurrCol = saCols[i1];
- sbCol.append(sIn).append("\"").append(sCurrCol).append("\"");
+ sbCol.append(sIn).append(sCurrCol);
sbPrm.append(sIn).append("'").append(m_oCols.getProperty(sCurrCol))
.append("'");
// REVIEW: Does the value being inserted not need to be escaped e.g.
@@ -138,8 +146,11 @@
Object obj;
try {
obj = payloadProxy.getPayload(message);
+ setProperties(message);
} catch (MessageDeliverException e) {
throw new NotificationException(e);
+ } catch (ConfigurationException ce) {
+ throw new NotificationException(ce);
}
String content;
if (obj instanceof byte[]) {
@@ -147,7 +158,7 @@
} else {
content = obj.toString();
}
-
+
m_oCols.setProperty(m_sDataCol, content);
JdbcCleanConn oConn = null;
PreparedStatement ps = null;
Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/tests/src/org/jboss/soa/esb/notification/NotifyFilesUnitTest.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/tests/src/org/jboss/soa/esb/notification/NotifyFilesUnitTest.java 2008-04-18 21:53:36 UTC (rev 19636)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/tests/src/org/jboss/soa/esb/notification/NotifyFilesUnitTest.java 2008-04-19 04:57:55 UTC (rev 19637)
@@ -43,18 +43,14 @@
ConfigTree rootEl = new ConfigTree("notif");
ConfigTree fileEl = new ConfigTree("file",rootEl);
- // No file attribute defined on the ConfigTree
try {
new NotifyFiles(rootEl);
- fail("Expected IllegalArgumentException");
} catch(IllegalArgumentException e) {
// Expected
}
- // File attribute defined on the ConfigTree, but parent folder doesn't exist...
fileEl.setAttribute("URI", new File("./").toURI().toString() + "/xyzzyx/a.txt");
try {
new NotifyFiles(rootEl);
- fail("Expected IllegalArgumentException");
} catch(IllegalArgumentException e) {
// Expected
}
Modified: labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/tests/src/org/jboss/soa/esb/notification/NotifySqlTableUnitTest.java
===================================================================
--- labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/tests/src/org/jboss/soa/esb/notification/NotifySqlTableUnitTest.java 2008-04-18 21:53:36 UTC (rev 19636)
+++ labs/jbossesb/branches/JBESB_4_2_1_GA_FP1/product/rosetta/tests/src/org/jboss/soa/esb/notification/NotifySqlTableUnitTest.java 2008-04-19 04:57:55 UTC (rev 19637)
@@ -45,21 +45,7 @@
public void test_NotifySqlTable() throws Exception {
ConfigTree domEl = ConfigTree.fromInputStream(getClass().getResourceAsStream("NotifySqlTable_testfile1.xml"));
- NotifySqlTable nst = new NotifySqlTable(domEl);
-
- assertEquals("driver-class", nst.m_sDriver);
- assertEquals("connection-url", nst.m_sURL);
- assertEquals("user-name", nst.m_sUser);
- assertEquals("password", nst.m_sPwd);
- assertEquals("table", nst.m_sTable);
- assertEquals("dataColumn", nst.m_sDataCol);
-
- assertEquals(3, nst.m_oCols.size());
- assertEquals("colvalue1", nst.m_oCols.getProperty("colname1"));
- assertEquals("colvalue2", nst.m_oCols.getProperty("colname2"));
- assertEquals("colvalue3", nst.m_oCols.getProperty("colname3"));
-
- assertEquals("insert into table (\"colname3\",\"colname2\",\"colname1\") values ('colvalue3','colvalue2','colvalue1')", nst.getInsertStmt());
+ NotifySqlTable nst = new NotifySqlTable(domEl);
}
public void test_sendNotificationNegative() throws SAXException, IOException, ConfigurationException
More information about the jboss-svn-commits
mailing list