You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@knox.apache.org by Kristopher Kane <kk...@hortonworks.com> on 2014/10/17 22:15:20 UTC
Derive template from rule
Hello,
In Contributor tests I'd like to derive the rewrite template from the
rule rather than hard coding.
Consider this:
WebHCatDeploymentContributor contributor = new WebHCatDeploymentContributor();
UrlRewriteRulesDescriptor webhcatRules = contributor.loadRulesFromTemplate()
webhcatRules.getRule("WEBHCAT/webhcat/root/inbound").pattern().toString()
webhcatRules.getRule("WEBHCAT/webhcat/root/inbound").template().toString()
Both template and pattern methods return the pattern. At the end of
the day, I'd like to only have to know the rewrite rule name and then
derive both from the contributor. Is there a way to get the template
as well?
These come from UrlRewriteRuleDescriptorImpl.
Thanks,
Kris
--
CONFIDENTIALITY NOTICE
NOTICE: This message is intended for the use of the individual or entity to
which it is addressed and may contain information that is confidential,
privileged and exempt from disclosure under applicable law. If the reader
of this message is not the intended recipient, you are hereby notified that
any printing, copying, dissemination, distribution, disclosure or
forwarding of this communication is strictly prohibited. If you have
received this communication in error, please contact the sender immediately
and delete it from your system. Thank You.
Re: Derive template from rule
Posted by Kevin Minder <ke...@hortonworks.com>.
Kris,
This isn't as simple as it seems. The <rule/> element can contain a
rather complex set of nested elements. Consider a rule like this from
gateway-provider-rewrite/src/test/resources/org/apache/hadoop/gateway/filter/rewrite/api/UrlRewriteProcessorTest/rewrite.xml
<rule name="test-rule-with-complex-flow" flow="OR">
<match pattern="*://*:*/~/{path=**}?{**}">
<rewrite
template="test-scheme-output://test-host-output:777/test-path-output/test-home/{path}?{**}"/>
</match>
<match pattern="*://*:*/{path=**}?{**}">
<rewrite
template="test-scheme-output://test-host-output:42/test-path-output/{path}?{**}"/>
</match>
</rule>
So the .pattern() and .template() are really the same thing. The
.pattern() is just the string version and the .template() is the
"complied" version. Note that .pattern() is already a String so
.pattern().toString() is redundant.
Kevin.
On 10/17/14, 4:15 PM, Kristopher Kane wrote:
> Hello,
>
> In Contributor tests I'd like to derive the rewrite template from the
> rule rather than hard coding.
>
> Consider this:
>
> WebHCatDeploymentContributor contributor = new WebHCatDeploymentContributor();
> UrlRewriteRulesDescriptor webhcatRules = contributor.loadRulesFromTemplate()
>
> webhcatRules.getRule("WEBHCAT/webhcat/root/inbound").pattern().toString()
> webhcatRules.getRule("WEBHCAT/webhcat/root/inbound").template().toString()
>
> Both template and pattern methods return the pattern. At the end of
> the day, I'd like to only have to know the rewrite rule name and then
> derive both from the contributor. Is there a way to get the template
> as well?
>
> These come from UrlRewriteRuleDescriptorImpl.
>
> Thanks,
>
> Kris
>
--
CONFIDENTIALITY NOTICE
NOTICE: This message is intended for the use of the individual or entity to
which it is addressed and may contain information that is confidential,
privileged and exempt from disclosure under applicable law. If the reader
of this message is not the intended recipient, you are hereby notified that
any printing, copying, dissemination, distribution, disclosure or
forwarding of this communication is strictly prohibited. If you have
received this communication in error, please contact the sender immediately
and delete it from your system. Thank You.