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.jetspeed.aggregator;
18:
19: import org.apache.jetspeed.PortalReservedParameters;
20: import org.apache.jetspeed.pipeline.PipelineException;
21: import org.apache.jetspeed.pipeline.valve.AbstractValve;
22: import org.apache.jetspeed.pipeline.valve.ValveContext;
23: import org.apache.jetspeed.request.RequestContext;
24:
25: /**
26: * FileServerValve
27: *
28: * @author <a href="mailto:taylor@apache.org">David Sean Taylor</a>
29: * @version $Id: $
30: */
31: public class FileServerValve extends AbstractValve {
32: private String portletName;
33: private String portletEntity;
34:
35: public FileServerValve(String portletName, String portletEntity) {
36: this .portletName = portletName;
37: this .portletEntity = portletEntity;
38: }
39:
40: public void invoke(RequestContext request, ValveContext context)
41: throws PipelineException {
42: try {
43: String entity = request
44: .getRequestParameter(PortalReservedParameters.PORTLET_ENTITY);
45: if (entity == null) {
46: entity = (String) request
47: .getAttribute(PortalReservedParameters.PORTLET_ENTITY);
48: }
49: if (entity == null) {
50: request.setAttribute(
51: PortalReservedParameters.PORTLET_ENTITY,
52: portletEntity);
53: }
54:
55: String name = request
56: .getRequestParameter(PortalReservedParameters.PORTLET);
57: if (name == null) {
58: name = (String) request
59: .getAttribute(PortalReservedParameters.PORTLET);
60: }
61: if (name == null) {
62: request.setAttribute(PortalReservedParameters.PORTLET,
63: portletName);
64: }
65: } catch (Exception e) {
66: throw new PipelineException(e);
67: }
68: // Pass control to the next Valve in the Pipeline
69: context.invokeNext(request);
70: }
71:
72: public String toString() {
73: return "FileServerValve";
74: }
75: }
|