KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > lenya > cms > cocoon > acting > URIParametrizerAction


1 /*
2  * Copyright 1999-2004 The Apache Software Foundation
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */

17
18 /* $Id: URIParametrizerAction.java 42598 2004-03-01 16:18:28Z gregor $ */
19
20 package org.apache.lenya.cms.cocoon.acting;
21
22 import java.util.Map JavaDoc;
23
24 import org.apache.avalon.framework.parameters.Parameters;
25 import org.apache.cocoon.acting.ConfigurableServiceableAction;
26 import org.apache.cocoon.environment.ObjectModelHelper;
27 import org.apache.cocoon.environment.Redirector;
28 import org.apache.cocoon.environment.Request;
29 import org.apache.cocoon.environment.SourceResolver;
30 import org.apache.lenya.cms.cocoon.uriparameterizer.URIParameterizer;
31
32 /**
33  * Action to access the URI parameterizer.
34  * The map returned by this action is the map returned by the
35  * {@link org.apache.lenya.cms.cocoon.uriparameterizer.URIParameterizer}.
36  * The <code>src</code> attribute is the URI to parameterize.
37  */

38 public class URIParametrizerAction extends ConfigurableServiceableAction {
39
40     /**
41      * @see org.apache.cocoon.acting.Action#act(org.apache.cocoon.environment.Redirector, org.apache.cocoon.environment.SourceResolver, java.util.Map, java.lang.String, org.apache.avalon.framework.parameters.Parameters)
42      */

43     public Map JavaDoc act(
44         Redirector redirector,
45         SourceResolver resolver,
46         Map JavaDoc objectModel,
47         String JavaDoc src,
48         Parameters parameters)
49         throws Exception JavaDoc {
50
51         Request request = ObjectModelHelper.getRequest(objectModel);
52         String JavaDoc uri = request.getRequestURI();
53
54         URIParameterizer parameterizer = null;
55         Map JavaDoc map = null;
56         try {
57             parameterizer = (URIParameterizer) manager.lookup(URIParameterizer.ROLE);
58             map = parameterizer.parameterize(uri, src, parameters);
59         } finally {
60             if (parameterizer != null) {
61                 manager.release(parameterizer);
62             }
63         }
64
65         return map;
66
67     }
68
69 }
70
Popular Tags