KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > portal > acting > PreparePortalAction


1 /*
2  * Copyright 2005 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 package org.apache.cocoon.portal.acting;
17
18 import java.util.Map JavaDoc;
19
20 import org.apache.avalon.framework.parameters.Parameters;
21 import org.apache.avalon.framework.service.ServiceException;
22 import org.apache.cocoon.ProcessingException;
23 import org.apache.cocoon.acting.ServiceableAction;
24 import org.apache.cocoon.environment.Redirector;
25 import org.apache.cocoon.environment.SourceResolver;
26 import org.apache.cocoon.portal.Constants;
27 import org.apache.cocoon.portal.PortalService;
28
29 /**
30  * Prepare the portal by setting the portal name.
31  *
32  * @author <a HREF="mailto:cziegeler@apache.org">Carsten Ziegeler</a>
33  * @version CVS $Id: PreparePortalAction.java 219049 2005-07-14 15:11:52Z cziegeler $
34  */

35 public class PreparePortalAction
36 extends ServiceableAction {
37
38     /* (non-Javadoc)
39      * @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)
40      */

41     public Map JavaDoc act(Redirector redirector, SourceResolver resolver, Map JavaDoc objectModel, String JavaDoc source, Parameters parameters)
42     throws Exception JavaDoc {
43         PortalService portalService = null;
44         try {
45
46             portalService = (PortalService)this.manager.lookup(PortalService.ROLE);
47
48             if ( portalService.getPortalName() == null ) {
49                 final String JavaDoc portalName = parameters.getParameter("portal-name",
50                                               (String JavaDoc)objectModel.get(Constants.PORTAL_NAME_KEY));
51                 portalService.setPortalName(portalName);
52             }
53             return EMPTY_MAP;
54
55         } catch (ServiceException e) {
56             throw new ProcessingException("Unable to lookup portal service.", e);
57         } finally {
58             this.manager.release(portalService);
59         }
60     }
61 }
62
Popular Tags