KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > webapps > portal > generation > PortalGenerator


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 package org.apache.cocoon.webapps.portal.generation;
17
18 import java.io.IOException JavaDoc;
19
20 import org.apache.avalon.framework.service.ServiceException;
21 import org.apache.cocoon.ProcessingException;
22 import org.apache.cocoon.environment.ObjectModelHelper;
23 import org.apache.cocoon.environment.Request;
24 import org.apache.cocoon.generation.ServiceableGenerator;
25 import org.apache.cocoon.webapps.portal.components.PortalManager;
26 import org.apache.cocoon.webapps.session.FormManager;
27 import org.xml.sax.SAXException JavaDoc;
28
29 /**
30  * This generator generates the portal for the current user.
31  *
32  * @author <a HREF="mailto:cziegeler@s-und-n.de">Carsten Ziegeler</a>
33  * @version CVS $Id: PortalGenerator.java 30932 2004-07-29 17:35:38Z vgritsenko $
34 */

35 public final class PortalGenerator
36 extends ServiceableGenerator {
37
38     public void generate()
39     throws IOException JavaDoc, SAXException JavaDoc, ProcessingException {
40
41         PortalManager portal = null;
42         FormManager formManager = null;
43         try {
44             formManager = (FormManager)this.manager.lookup(FormManager.ROLE);
45             formManager.processInputFields();
46
47             portal = (PortalManager) this.manager.lookup(PortalManager.ROLE);
48             this.xmlConsumer.startDocument();
49
50             final Request request = ObjectModelHelper.getRequest(this.objectModel);
51             if (request.getSession(false) != null) {
52
53                 portal.showPortal(this.xmlConsumer, false, false);
54
55             }
56             this.xmlConsumer.endDocument();
57         } catch (ServiceException ce) {
58             throw new ProcessingException("Lookup of PortalManager failed.", ce);
59         } finally {
60             this.manager.release( formManager);
61             this.manager.release(portal);
62         }
63     }
64
65 }
66
Popular Tags