KickJava   Java API By Example, From Geeks To Geeks.

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


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.xml.sax.SAXException JavaDoc;
27
28 /**
29  * This generator generates the configuration of the portal
30  * for the current user.
31  *
32  * @author <a HREF="mailto:cziegeler@s-und-n.de">Carsten Ziegeler</a>
33  * @version CVS $Id: ConfigurationGenerator.java 30932 2004-07-29 17:35:38Z vgritsenko $
34 */

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