Author: supun
Date: Thu May 12 09:17:42 2011
New Revision: 1102213
URL: http://svn.apache.org/viewvc?rev=1102213&view=rev
Log:
applying patch SYNAPSE-763, thanks ratha for the contribution
Modified:
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/URLRewriteMediatorFactory.java
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/URLRewriteMediatorSerializer.java
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/transform/url/URLRewriteMediator.java
synapse/trunk/java/repository/conf/sample/synapse_sample_450.xml
synapse/trunk/java/repository/conf/sample/synapse_sample_451.xml
synapse/trunk/java/repository/conf/sample/synapse_sample_452.xml
synapse/trunk/java/repository/schema/mediators/transformation/rewrite.xsd
synapse/trunk/java/src/site/xdoc/Synapse_Configuration_Language.xml
synapse/trunk/java/src/site/xdoc/Synapse_Samples.xml
Modified:
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/URLRewriteMediatorFactory.java
URL:
http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/URLRewriteMediatorFactory.java?rev=1102213&r1=1102212&r2=1102213&view=diff
==============================================================================
---
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/URLRewriteMediatorFactory.java
(original)
+++
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/URLRewriteMediatorFactory.java
Thu May 12 09:17:42 2011
@@ -41,7 +41,7 @@ import java.util.Properties;
*
* <pre>
* <rewrite [inProperty="inputURL"] [outProperty="outputURL"]>
- * <rule>
+ * <rewriterule>
* <condition>
* evaluator configuration
* </condition> ?
@@ -51,7 +51,7 @@ import java.util.Properties;
* [type="set | append | prepend | replace | remove"]
* [fragment="protocol | user | host | port | path | query | ref
| full"]
* [regex="regex"] /> +
- * </rule> *
+ * </rewriterule> *
* </rewrite>
* </pre>
*/
@@ -59,7 +59,7 @@ public class URLRewriteMediatorFactory e
private static final QName REWRITE_Q = new
QName(XMLConfigConstants.SYNAPSE_NAMESPACE, "rewrite");
- private static final QName RULE_Q = new
QName(XMLConfigConstants.SYNAPSE_NAMESPACE, "rule");
+ private static final QName RULE_Q = new
QName(XMLConfigConstants.SYNAPSE_NAMESPACE, "rewriterule");
private static final QName CONDITION_Q = new
QName(XMLConfigConstants.SYNAPSE_NAMESPACE, "condition");
private static final QName ACTION_Q = new
QName(XMLConfigConstants.SYNAPSE_NAMESPACE, "action");
@@ -100,6 +100,7 @@ public class URLRewriteMediatorFactory e
mediator.addRule(parseRule((OMElement) rules.next()));
}
processAuditStatus(mediator, element);
+
return mediator;
}
Modified:
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/URLRewriteMediatorSerializer.java
URL:
http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/URLRewriteMediatorSerializer.java?rev=1102213&r1=1102212&r2=1102213&view=diff
==============================================================================
---
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/URLRewriteMediatorSerializer.java
(original)
+++
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/config/xml/URLRewriteMediatorSerializer.java
Thu May 12 09:17:42 2011
@@ -41,9 +41,22 @@ public class URLRewriteMediatorSerialize
}
URLRewriteMediator mediator = (URLRewriteMediator) m;
- OMElement rewrite = fac.createOMElement("rewrite", synNS);
- saveTracingState(rewrite, mediator);
+ OMElement rewrite = fac.createOMElement("rewrite", synNS);
+
+ String inProperty = mediator.getInputProperty();
+ String outProperty = mediator.getOutputProperty();
+
+ if (inProperty != null) {
+ rewrite.addAttribute(fac.createOMAttribute("inProperty", nullNS,
+ inProperty));
+ }
+ if (outProperty != null) {
+ rewrite.addAttribute(fac.createOMAttribute("outProperty",
nullNS,
+ outProperty));
+ }
+ saveTracingState(rewrite, mediator);
+
List<RewriteRule> rules = mediator.getRules();
try {
for (RewriteRule r : rules) {
@@ -58,7 +71,7 @@ public class URLRewriteMediatorSerialize
}
private OMElement serializeRule(RewriteRule r) throws EvaluatorException {
- OMElement rule = fac.createOMElement("rule", synNS);
+ OMElement rule = fac.createOMElement("rewriterule", synNS);
Evaluator condition = r.getCondition();
if (condition != null) {
OMElement conditionElt = fac.createOMElement("condition", synNS);
Modified:
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/transform/url/URLRewriteMediator.java
URL:
http://svn.apache.org/viewvc/synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/transform/url/URLRewriteMediator.java?rev=1102213&r1=1102212&r2=1102213&view=diff
==============================================================================
---
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/transform/url/URLRewriteMediator.java
(original)
+++
synapse/trunk/java/modules/core/src/main/java/org/apache/synapse/mediators/transform/url/URLRewriteMediator.java
Thu May 12 09:17:42 2011
@@ -60,6 +60,11 @@ public class URLRewriteMediator extends
} else {
messageContext.setTo(new
EndpointReference(fragments.toURIString()));
}
+
+ if(log.isDebugEnabled()) {
+ log.debug("URL Rewrite Mediator has rewritten the address url
: \n " + messageContext.getEnvelope());
+ }
+
} catch (URISyntaxException e) {
handleException("Error while constructing a URI from the
fragments", e, messageContext);
}
Modified: synapse/trunk/java/repository/conf/sample/synapse_sample_450.xml
URL:
http://svn.apache.org/viewvc/synapse/trunk/java/repository/conf/sample/synapse_sample_450.xml?rev=1102213&r1=1102212&r2=1102213&view=diff
==============================================================================
--- synapse/trunk/java/repository/conf/sample/synapse_sample_450.xml (original)
+++ synapse/trunk/java/repository/conf/sample/synapse_sample_450.xml Thu May 12
09:17:42 2011
@@ -24,9 +24,9 @@
<sequence name="main">
<in>
<rewrite>
- <rule>
+ <rewriterule>
<action type="replace" regex="soap" value="services"
fragment="path"/>
- </rule>
+ </rewriterule>
</rewrite>
<send/>
</in>
Modified: synapse/trunk/java/repository/conf/sample/synapse_sample_451.xml
URL:
http://svn.apache.org/viewvc/synapse/trunk/java/repository/conf/sample/synapse_sample_451.xml?rev=1102213&r1=1102212&r2=1102213&view=diff
==============================================================================
--- synapse/trunk/java/repository/conf/sample/synapse_sample_451.xml (original)
+++ synapse/trunk/java/repository/conf/sample/synapse_sample_451.xml Thu May 12
09:17:42 2011
@@ -24,7 +24,7 @@
<sequence name="main">
<in>
<rewrite>
- <rule>
+ <rewriterule>
<condition>
<and>
<equal type="url" source="host" value="localhost"/>
@@ -35,7 +35,7 @@
</condition>
<action fragment="protocol" value="https"/>
<action fragment="port" value="9002"/>
- </rule>
+ </rewriterule>
</rewrite>
<send/>
</in>
Modified: synapse/trunk/java/repository/conf/sample/synapse_sample_452.xml
URL:
http://svn.apache.org/viewvc/synapse/trunk/java/repository/conf/sample/synapse_sample_452.xml?rev=1102213&r1=1102212&r2=1102213&view=diff
==============================================================================
--- synapse/trunk/java/repository/conf/sample/synapse_sample_452.xml (original)
+++ synapse/trunk/java/repository/conf/sample/synapse_sample_452.xml Thu May 12
09:17:42 2011
@@ -26,22 +26,22 @@
<property name="http.port" value="9000"/>
<property name="https.port" value="9002"/>
<rewrite>
- <rule>
+ <rewriterule>
<action fragment="host" value="localhost"/>
<action fragment="path" type="prepend" value="/services"/>
- </rule>
- <rule>
+ </rewriterule>
+ <rewriterule>
<condition>
<equal type="url" source="protocol" value="http"/>
</condition>
<action fragment="port" xpath="get-property('http.port')"/>
- </rule>
- <rule>
+ </rewriterule>
+ <rewriterule>
<condition>
<equal type="url" source="protocol" value="https"/>
</condition>
<action fragment="port"
xpath="get-property('https.port')"/>
- </rule>
+ </rewriterule>
</rewrite>
<log level="full"/>
<send/>
Modified:
synapse/trunk/java/repository/schema/mediators/transformation/rewrite.xsd
URL:
http://svn.apache.org/viewvc/synapse/trunk/java/repository/schema/mediators/transformation/rewrite.xsd?rev=1102213&r1=1102212&r2=1102213&view=diff
==============================================================================
--- synapse/trunk/java/repository/schema/mediators/transformation/rewrite.xsd
(original)
+++ synapse/trunk/java/repository/schema/mediators/transformation/rewrite.xsd
Thu May 12 09:17:42 2011
@@ -32,7 +32,7 @@
</xs:annotation>
<xs:complexType>
<xs:sequence>
- <xs:element name="rule" minOccurs="1" maxOccurs="unbounded">
+ <xs:element name="rewriterule" minOccurs="1"
maxOccurs="unbounded">
<xs:complexType>
<xs:choice maxOccurs="unbounded">
<xs:element name="condition" minOccurs="0"
maxOccurs="1">
Modified: synapse/trunk/java/src/site/xdoc/Synapse_Configuration_Language.xml
URL:
http://svn.apache.org/viewvc/synapse/trunk/java/src/site/xdoc/Synapse_Configuration_Language.xml?rev=1102213&r1=1102212&r2=1102213&view=diff
==============================================================================
--- synapse/trunk/java/src/site/xdoc/Synapse_Configuration_Language.xml
(original)
+++ synapse/trunk/java/src/site/xdoc/Synapse_Configuration_Language.xml Thu May
12 09:17:42 2011
@@ -1590,13 +1590,13 @@ where "sequence/dynamic_seq_1.xml" refer
<a name="rewrite" id="rewrite">URLRewrite</a>
</h4>
<pre xml:space="preserve"><rewrite [inProperty="string"]
[outProperty="string"]>
- <rule>
+ <rewriterule>
<condition>
...
</condition>?
<action [type="append|prepend|replace|remove|set"] [value="string"]
[xpath="xpath"]
[fragment="protocol|host|port|path|query|ref|user|full"] [regex="regex"]>+
- </rule>+
+ </rewriterule>+
</rewrite></pre>
<p/>
<p>
@@ -1610,13 +1610,13 @@ where "sequence/dynamic_seq_1.xml" refer
</p>
<p>
The rewrite mediator applies URL transformations by evaluating a set of
rules on
- the message. Rules are specified using the 'rule' element. Rules are
evaluated in the
+ the message. Rules are specified using the 'rewriterule' element. Rules
are evaluated in the
order they are specified. A rule can consist of an optional condition
and one or more
rewrite actions. If the condition is provided it will be evaluated
first. If it evaluates
to 'true' all the specified rewrite actions will be executed. Otherwise
the set of
actions will be skipped. If no condition is specified, the provided
rewrite actions
will be always executed. The condition should be wrapped in a
'condition' element within
- the 'rule' element. Rewrite actions are specified using 'action'
elements.
+ the 'rewriterule' element. Rewrite actions are specified using 'action'
elements.
</p>
<p>
The 'type' attribute on the 'action' element states which type of action
should be
Modified: synapse/trunk/java/src/site/xdoc/Synapse_Samples.xml
URL:
http://svn.apache.org/viewvc/synapse/trunk/java/src/site/xdoc/Synapse_Samples.xml?rev=1102213&r1=1102212&r2=1102213&view=diff
==============================================================================
--- synapse/trunk/java/src/site/xdoc/Synapse_Samples.xml (original)
+++ synapse/trunk/java/src/site/xdoc/Synapse_Samples.xml Thu May 12 09:17:42
2011
@@ -4755,9 +4755,9 @@ will be converted into a JSON message an
<sequence xmlns="http://ws.apache.org/ns/synapse" name="main">
<in>
<rewrite>
- <rule>
+ <rewriterule>
<action type="replace" regex="soap" value="services"
fragment="path"/>
- </rule>
+ </rewriterule>
</rewrite>
<send/>
</in>
@@ -4787,7 +4787,7 @@ Axis2 client will receive a valid respon
<sequence xmlns="http://ws.apache.org/ns/synapse" name="main">
<in>
<rewrite>
- <rule>
+ <rewriterule>
<condition>
<and>
<equal type="url" source="host"
value="localhost"/>
@@ -4798,7 +4798,7 @@ Axis2 client will receive a valid respon
</condition>
<action fragment="protocol" value="https"/>
<action fragment="port" value="9002"/>
- </rule>
+ </rewriterule>
</rewrite>
<log level="full"/>
<send/>
@@ -4834,22 +4834,22 @@ framework. Hence URL rewriting can be do
<property name="http.port" value="9000"/>
<property name="https.port" value="9002"/>
<rewrite>
- <rule>
+ <rewriterule>
<action fragment="host" value="localhost"/>
<action fragment="path" type="prepend"
value="/services"/>
- </rule>
- <rule>
+ </rewriterule>
+ <rewriterule>
<condition>
<equal type="url" source="protocol"
value="http"/>
</condition>
<action fragment="port"
xpath="get-property('http.port')"/>
- </rule>
- <rule>
+ </rewriterule>
+ <rewriterule>
<condition>
<equal type="url" source="protocol"
value="https"/>
</condition>
<action fragment="port"
xpath="get-property('https.port')"/>
- </rule>
+ </rewriterule>
</rewrite>
<log level="full"/>
<send/>