My url may or may not have a certain parameter and I set the action class for such a url as follows :
<action name="{paramOne}/{paramTwo:myparam*}/details"
class="myaction"
method="execute">
<result name="success">/mypage.jsp</result>
</action>
So the url something/myparam/details is working but when i try to invoke something/details (which according to struts.xml should work). It shows that there is not action class mapped.
your code '*' only can match between "{paramOne}/" and "/details"
so you must have something between "{paramOne}/" and "/details"
You want to route different URI patterns to the same action, this is exactly the case action mapping is made for.
I think the best solution is to write two separate statements.
If you don't want to repeat the "code" inside the <action> tag you can chain it (it's a kind of internal redirect, a kind of aliasing)
<action name="secondpattern" class="com.opensymphony.xwork2.ActionSupport">
<result type="chain">firstpattern</result>
</action>
https://struts.apache.org/docs/action-chaining.html
Related
I want to check logged in user’s authorization based on ‘groupmembership’ header attribute.
The output of
<logger level="INFO" message="groups are =#[message.inboundProperties['GROUPMEMBERSHIP']]" doc:name="Logger"/> is
[groups are =cn=ZZZ-XXXX-Write-Users,ou= ZZZ-XXXX,ou=1234,ou=Groups,dc=someone,dc=net]
Now a user can have multiple group memberships but all I am interested in checking if user is member of ‘ZZZ-XXXX-Write-Users’?
Is there a way in MEL to check that, something like
<when expression="#[message.inboundProperties.GROUPMEMBERSHIP.cn != ' ZZZ-XXXX-Write-Users ']">
Is this the right approach or am I missing anything here?
The scenario you describe looks more like a flow control stuff.
In that case I would say that you use just that MEL expression inside a choice router:
<choice doc:name="Choice">
<when expression="#[!message.inboundProperties.GROUPMEMBERSHIP.cn.equals('ZZZ-XXXX-Write-Users')]">
<!-- DO SOMETHING -->
</when
<otherwise>
<!-- DO SOMETHING ELSE -->
</otherwise>
</choice>
Just a small change the use of equals to compare strings ;).
The other option, as we are talking flow control here, is a filter.
A expression filter will just ignore the message if the expression doesn't evaluate to true. The catch with this is, it either pass or not you can not have an alternative route not even a log message saying that a message was filtered.
<expression-filter expression="#[!message.inboundProperties.GROUPMEMBERSHIP.cn.equals('ZZZ-XXXX-Write-Users')]" doc:name="Expression"/>
HTH
I'm using IIS 7.5 and UrlRewrite Module 2. I've read the official documentation for the module here, as well as many examples on SO and tested my regex on Regexpal. Somehow the translation into the Web.config file is causing me problems. I've tried escaping the parantheses also.
The regex I'm using is:
^partners/(var|distributors|msp|techpartners)/(na|emea|apac)(|/)(.*)
a few example urls:
partners/var/emea
partners/msp/apac/
partners/var/na/abcdabcdabcd
Here is the web.config I have so far:
<rules>
<rule name="partnersListing" enabled="true" stopProcessing="true">
<match url="^partners/(var|distributors|msp|techpartners)/(na|emea|apac)(|/)(.*)" />
<action type="Rewrite" url="partnersList.aspx?type=${R:1}®ion={R:2}" />
</rule>
</rules>
Not sure if I want the action to be Rewrite or Redirect yet, but the pattern isn't working either way. Any help is greatly appreciated
Per your answer to my question in the comments:
Is this rule in the site root web.config or a subdirectory web.config?
#Kev in a subdirectory: "/partners"
From the docs:
http://www.iis.net/learn/extensions/url-rewrite-module/url-rewrite-module-configuration-reference?amp;clcid=0x409
Quote:
Note that the input URL string passed to a distributed rule is always
relative to the location of the Web.config file where the rule is
defined. For example, if a request is made for
http://www.mysite.com/content/default.aspx?tabid=2&subtabid=3, and a
rewrite rule is defined in the /content directory, then the rule gets
this URL string default.aspx as an input.
Based on this you need to change your url match to:
^(var|distributors|msp|techpartners)/(na|emea|apac)(|/)(.*)
Assuming your re-write rule exists in:
http://example.com/partners/web.config
There is just one other thing which is what appears to be an extraneous $ character in your redirect/rewrite url in front of back reference {R:1}, I'm not sure if you intended that to be there or not.
I am trying to write a general rule in /WEB-INF/urlrewrite.xml that will take in an arbitrary URI and append the identifiers that follow a root identifier as Name Value Pairs.
For Example:
localhost:8084/URLRewrite/Fruits/Yellow/Banana/banana.jsp
to become
localhost:8084/URLRewrite/Fruits/Yellow/Banana/banana.jsp&key0=Fruits&key1=Yellow&key2=Banana
I know that this will involve regular expressions as well as parameter ambiguity.
Something of similar flavor is like:
<rule>
<from>^/world/([a-z]+)/([a-z]+)$</from>
<to>/world.jsp?country=$1&city=$2</to>
</rule>
Examples:
Input:
nyc
Output:
nyc
Any help or suggestions would be greatly appreciated.
Try this:
<rule>
<from>^/world/([a-z]+)/([a-z]+)$</from>
<to type="redirect">/world.jsp?country=$1&city=$2</to>
</rule>
Maybe you're missing the attribute type with value redirect in your configuration file.
I am trying to use UrlRewriteFilter to do a redirect. As we are moving servers and infrastructure all the time to develop our in house cloud solutions we plan to use a lot of this.
My problem is I have a URL like
https:// google.com/web-app/servlet?request-parameters&values
I need to redirect all the URLs which has a value for a particular parameter to a different server.
so a URL like :
https:// google.com/administrator/servlet/ej.processOrder?sec=100&geo=appointment&cus=dubai
If the parameters contain cus=dubai, I need to redirect it to
https://hotmail.com/servlet/ej.processOrder?sec=100&geo=appointment&cus=dubai
I have tried the following but it doesn't seem to work
<urlrewrite use-query-string="true">
<rule match-type="wildcard">
<name>Redirect requests to cases</name>
<description></description>
<from>/administrator/servlet/**?**</from>
<to type="redirect" last="true">http://hotmail.com:8080/servlet/$1?&cus=dubai&$2&$3&</to>
</rule>
</urlrewrite>
Thanks for the help.
You will need to make use of the query-string and make sure it matches a particular condition.
From what I can see you would want something like this :
<condition name="query-string" operator="equal">*cus=dubai*</condition>
You will need a rule for each different parameter. One full rule would look like this :
<urlrewrite use-query-string="true">
<rule match-type="wildcard">
<name>Cus = dubai</name>
<from>/administrator/servlet/*</from>
<condition name="query-string" operator="equal">*cus=dubai*</condition>
<to type="redirect" last="true">https://hotmail.com/servlet/ej.processOrder?sec=100&geo=appointment&cus=dubai</to>
</rule>
<!-- other rules go here -->
</urlrewrite>
The condition shall be "type" instead of "name", as:
<condition type="query-string" operator="equal">*cus=dubai*</condition>
Good question and for a situation that I imagine occurs often it is not very well documented in the manual in my opinion.
The following worked for me -
<rule>
<condition type="query-string">foo=123&bar=456</condition>
<from>/index.jsp</from>
<to type="permanent-redirect" last="true">https://somehwere-else.com/blah/blah/</to>
</rule>
So this should work for you -
<rule>
<name>Redirect requests to cases</name>
<condition type="query-string">sec=100&geo=appointment&cus=dubai</condition>
<from>/administrator/servlet</from>
<to type="permanent-redirect" last="true">http://hotmail.com:8080/servlet/sec=100&geo=appointment&cus=dubai</to>
</rule>
Say I have a given action:
<service category="MyService" name="MyFirstService">
<actions mep="RequestResponse">
<action class="actions.CXFListenerAction" name="CXFServiceListener"/>
<action class="org.jboss.soa.esb.actions.transformation.xslt.XsltAction" name="Transform XML">
<property name="templateFile" value="/stylesheets/transform_response.xslt"/>
<property name="failOnWarning" value="true"/>
</action>
</actions>
I am trying to figure out how to add a property name or parameter that I could then access from within the XSLT. I've tried add additional property names,
<property name="param1" value="Hey!"/>
but I'm not 100% sure if this is correct for adding parameters accessible by the XSLT.
Thanks.
The properties defined for the XsltAction class are properties specific to that action class and are not related to parameters in the template file.
So in short, it's not possible to pass parameters to the xslt from the JBoss ESB action pipeline. However, it would be possible to create a custom action that decorates your ESB message with data you define as a property in your jboss-esb.xml file and insert that before your XsltAction. That may be what you're looking for.