%line | %branch | |||||||||
---|---|---|---|---|---|---|---|---|---|---|
org.apache.jetspeed.ajax.AJAXValve |
|
|
1 | /* |
|
2 | * Licensed to the Apache Software Foundation (ASF) under one or more |
|
3 | * contributor license agreements. See the NOTICE file distributed with |
|
4 | * this work for additional information regarding copyright ownership. |
|
5 | * The ASF licenses this file to You under the Apache License, Version 2.0 |
|
6 | * (the "License"); you may not use this file except in compliance with |
|
7 | * the License. You may obtain a copy of the License at |
|
8 | * |
|
9 | * 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.ajax; |
|
18 | ||
19 | import javax.servlet.http.HttpServletResponse; |
|
20 | ||
21 | import org.apache.jetspeed.layout.PortletActionSecurityBehavior; |
|
22 | import org.apache.jetspeed.pipeline.PipelineException; |
|
23 | import org.apache.jetspeed.pipeline.valve.AbstractValve; |
|
24 | import org.apache.jetspeed.pipeline.valve.ValveContext; |
|
25 | import org.apache.jetspeed.request.RequestContext; |
|
26 | ||
27 | /** |
|
28 | * This should eventually replace the AJAX ServletFilter. |
|
29 | * |
|
30 | * @author <href a="mailto:weaver@apache.org">Scott T. Weaver </a> |
|
31 | * |
|
32 | */ |
|
33 | public class AJAXValve extends AbstractValve |
|
34 | { |
|
35 | private AJAXService ajaxService; |
|
36 | private PortletActionSecurityBehavior securityBehavior; |
|
37 | ||
38 | public AJAXValve(AJAXService service, PortletActionSecurityBehavior securityBehavior) |
|
39 | { |
|
40 | 0 | super(); |
41 | 0 | this.ajaxService = service; |
42 | 0 | this.securityBehavior = securityBehavior; |
43 | 0 | } |
44 | ||
45 | public void invoke( RequestContext request, ValveContext context ) |
|
46 | throws PipelineException |
|
47 | { |
|
48 | 0 | HttpServletResponse response = request.getResponse(); |
49 | try |
|
50 | { |
|
51 | 0 | response.setContentType("text/xml"); |
52 | 0 | if (!securityBehavior.checkAccess(request, "edit")) |
53 | { |
|
54 | 0 | throw new AJAXException("Access Denied."); |
55 | } |
|
56 | 0 | AJAXRequest ajaxRequest = new AJAXRequestImpl(request.getRequest(), response, request.getConfig().getServletContext()); |
57 | 0 | ajaxService.processRequest(ajaxRequest); |
58 | } |
|
59 | 0 | catch (AJAXException e) |
60 | { |
|
61 | try |
|
62 | { |
|
63 | 0 | response.sendError(500, e.getMessage()); |
64 | } |
|
65 | 0 | catch (Exception e2) |
66 | { |
|
67 | 0 | throw new PipelineException(e2.getMessage(), e2); |
68 | 0 | } |
69 | } |
|
70 | 0 | catch(Exception e) |
71 | { |
|
72 | 0 | throw new PipelineException(e.getMessage(), e); |
73 | 0 | } |
74 | ||
75 | // Pass control to the next Valve in the Pipeline |
|
76 | 0 | context.invokeNext(request); |
77 | 0 | } |
78 | ||
79 | public String toString() |
|
80 | { |
|
81 | 0 | return "AJAXValve"; |
82 | } |
|
83 | ||
84 | ||
85 | ||
86 | } |
This report is generated by jcoverage, Maven and Maven JCoverage Plugin. |