01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one or more
03: * contributor license agreements. See the NOTICE file distributed with
04: * this work for additional information regarding copyright ownership.
05: * The ASF licenses this file to You under the Apache License, Version 2.0
06: * (the "License"); you may not use this file except in compliance with
07: * the License. You may obtain a copy of the License at
08: *
09: * http://www.apache.org/licenses/LICENSE-2.0
10: *
11: * Unless required by applicable law or agreed to in writing, software
12: * distributed under the License is distributed on an "AS IS" BASIS,
13: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14: * See the License for the specific language governing permissions and
15: * limitations under the License.
16: */
17: package org.apache.cocoon.webapps.portal.generation;
18:
19: import java.io.IOException;
20:
21: import org.apache.avalon.framework.service.ServiceException;
22: import org.apache.cocoon.ProcessingException;
23: import org.apache.cocoon.environment.ObjectModelHelper;
24: import org.apache.cocoon.environment.Request;
25: import org.apache.cocoon.generation.ServiceableGenerator;
26: import org.apache.cocoon.webapps.portal.components.PortalManager;
27: import org.xml.sax.SAXException;
28:
29: /**
30: * This generator generates the configuration of the portal
31: * for the current user.
32: *
33: * @author <a href="mailto:cziegeler@s-und-n.de">Carsten Ziegeler</a>
34: * @version CVS $Id: ConfigurationGenerator.java 433543 2006-08-22 06:22:54Z crossley $
35: */
36: public final class ConfigurationGenerator extends ServiceableGenerator {
37:
38: public void generate() throws IOException, SAXException,
39: ProcessingException {
40:
41: PortalManager portal = null;
42: try {
43: portal = (PortalManager) this .manager
44: .lookup(PortalManager.ROLE);
45: this .xmlConsumer.startDocument();
46:
47: Request request = ObjectModelHelper
48: .getRequest(this .objectModel);
49: if (request.getSession(false) != null) {
50: if (this .source == null || this .source.length() == 0
51: || this .source.equals("user")) {
52: portal.showPortal(this .xmlConsumer, true, false);
53: } else {
54: portal.showAdminConf(this .xmlConsumer);
55: }
56: }
57:
58: this .xmlConsumer.endDocument();
59: } catch (ServiceException ce) {
60: throw new ProcessingException("Lookup of portal failed.",
61: ce);
62: } finally {
63: this.manager.release(portal);
64: }
65: }
66:
67: }
|