[Yanel-dev] Patch for Redirect Resource
Balz Schreier
balz.schreier at gmail.com
Mon Sep 20 10:22:43 CEST 2010
Hi Michael,
yes it works like that, except that the parameter is different in my case:
"zg.redirect=3D<gotoUrl>"
Cheers
balz
On Sun, Sep 19, 2010 at 11:56 PM, Michael Wechner <michael.wechner at wyona.com
> wrote:
> Balz Schreier wrote:
>
>> Hi Michael,
>>
>> the enhanced version is stored in our project's SVN, you should have
>> access:
>>
>> /zwischengas/src/java/com/zwischengas/resource/redirect/LoginRedirect.ja=
va
>>
>> What the extension does is:
>> - if a config property is retrieved, the extension verifies whether the
>> key matches the "href" parameter, now available as
>> RedirectResource.RESOURCE_CONFIG_PARAM_HREF
>> - if this parameter is retrieved, the extension returns the value
>> retrieved from the request's parameter instead of the configured value f=
rom
>> the resource config.
>>
>
> what I mean re an example how does the URL look like? Does it look like
> something
>
> http://127.0.0.1:8080/yanel/MY_REALM/en/login?href=3D/en/hello-world.html
>
> ?
>
> Thanks
>
> Michael
>
>>
>> he code is very simple but does its job for me.
>>
>> Cheers
>> Balz
>>
>> On Sat, Sep 18, 2010 at 10:26 PM, Michael Wechner <
>> michael.wechner at wyona.com <mailto:michael.wechner at wyona.com>> wrote:
>>
>> Balz Schreier wrote:
>>
>> Hi Michael,
>>
>> I would like to reuse 98% of the redirect resource.
>> My local redirect resource which extends the yanel redirect
>> resource is not expecting a URL from the resource config
>> (where to redirect) but rather from the URL.
>> To do so, I would like to extend it, so that the resource does
>> not expect a hardcoded redirect URL anymore.
>>
>> For that, I would like to overwrite
>> Resource.getResourceConfigProperty():
>> if the passed key is "href", then I will return my own value
>> instead of the resource config property.
>>
>> As the parameter name "href" is hardcoded in the
>> RedirectResource, I introduced a public constant, so that I
>> can reuse that key in my extended class.
>>
>>
>> Can you send me a "configuration/URL" example how you are using
>> this enhanced version?
>> I am asking because I would like to write a test for it ;-)
>>
>> Thanks
>>
>> Michael
>>
>>
>> The patch for the RedirectResource is here:
>>
>> Index:
>>
>> src/contributions/resources/redirect/src/java/org/wyona/yanel/impl/reso=
urces/redirect/RedirectResource.java
>> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
>> ---
>>
>> src/contributions/resources/redirect/src/java/org/wyona/yanel/impl/reso=
urces/redirect/RedirectResource.java
>> (revision 53304)
>> +++
>>
>> src/contributions/resources/redirect/src/java/org/wyona/yanel/impl/reso=
urces/redirect/RedirectResource.java
>> (working copy)
>> @@ -41,6 +41,7 @@
>> private static Category log =3D
>> Category.getInstance(RedirectResource.class);
>> public static String IDENTITY_MAP_KEY =3D "identity-map";
>> + public static final String RESOURCE_CONFIG_PARAM_HREF =3D
>> "href";
>> // Only a temporary variable needed during creation
>> (roundtrip)
>> private String defaultHrefSetByCreator;
>> @@ -72,7 +73,7 @@
>> HttpServletResponse response =3D getResponse();
>> - String defaultHref =3D getResourceConfigProperty("href"=
);
>> + String defaultHref =3D
>> getResourceConfigProperty(RESOURCE_CONFIG_PARAM_HREF);
>> if (defaultHref =3D=3D null) throw new Exception("No
>> default redirect has been set!");
>> @@ -96,7 +97,7 @@
>> try {
>> if
>>
>> (languageRedirectConfigs[i].getAttribute("code").equals(localizationLan=
guage))
>> {
>> response.setStatus(307);
>> - response.setHeader("Location",
>> languageRedirectConfigs[i].getAttribute("href"));
>> + response.setHeader("Location",
>>
>> languageRedirectConfigs[i].getAttribute(RESOURCE_CONFIG_PARAM_HREF));
>> }
>> } catch (Exception e) {
>> log.error(e.getMessage(), e);
>> @@ -117,7 +118,7 @@
>> try {
>> if
>> (userRedirectConfigs[i].getAttribute("name") =3D=3D currentUser ||
>> (currentUser).equals(userRedirectConfigs[i].getAttribute("name")))
>> {
>> response.setStatus(307);
>> - response.setHeader("Location",
>> userRedirectConfigs[i].getAttribute("href"));
>> + response.setHeader("Location",
>> userRedirectConfigs[i].getAttribute(RESOURCE_CONFIG_PARAM_HREF));
>> }
>> } catch (Exception e) {
>> log.error(e.getMessage(), e);
>> @@ -188,7 +189,7 @@
>> */
>> public HashMap createRTIProperties(HttpServletRequest
>> request) {
>> HashMap map =3D new HashMap();
>> - map.put("href", request.getParameter("rp." +
>> REDIRECT_URL));
>> + map.put(RESOURCE_CONFIG_PARAM_HREF,
>> request.getParameter("rp." + REDIRECT_URL));
>> return map;
>> }
>>
>> Cheers
>> Balz
>>
>>
>> -- Yanel-development mailing list Yanel-development at wyona.com
>> <mailto:Yanel-development at wyona.com>
>>
>> http://lists.wyona.org/cgi-bin/mailman/listinfo/yanel-development
>>
>>
>>
> --
> Yanel-development mailing list Yanel-development at wyona.com
> http://lists.wyona.org/cgi-bin/mailman/listinfo/yanel-development
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.wyona.org/pipermail/yanel-development/attachments/2010092=
0/d03ca6ce/attachment-0001.htm
More information about the Yanel-development
mailing list