KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > mondrian > xmla > XmlaRequestCallback


1 /*
2 // $Id: //open/mondrian/src/main/mondrian/xmla/XmlaRequestCallback.java#8 $
3 // This software is subject to the terms of the Common Public License
4 // Agreement, available at the following URL:
5 // http://www.opensource.org/licenses/cpl.html.
6 // Copyright (C) 2005-2006 Julian Hyde
7 // All Rights Reserved.
8 // You must accept the terms of that agreement to use this software.
9 */

10 package mondrian.xmla;
11
12 import java.util.Map JavaDoc;
13
14 import javax.servlet.ServletConfig JavaDoc;
15 import javax.servlet.ServletException JavaDoc;
16 import javax.servlet.http.HttpServletRequest JavaDoc;
17 import javax.servlet.http.HttpServletResponse JavaDoc;
18
19 import org.w3c.dom.Element JavaDoc;
20
21
22 /**
23  * Extract data from HTTP request, SOAP header for following XML/A request.<p/>
24  *
25  * Fill context binding with whatever data you want, then use them in
26  * {@link XmlaServlet#handleSoapHeader} and {@link XmlaServlet#handleSoapBody}.
27  *
28  * @author Gang Chen
29  * @version $Id: //open/mondrian/src/main/mondrian/xmla/XmlaRequestCallback.java#8 $
30  */

31 public interface XmlaRequestCallback {
32     String JavaDoc AUTHORIZATION = "Authorization";
33     String JavaDoc EXPECT = "Expect";
34     String JavaDoc EXPECT_100_CONTINUE = "100-continue";
35
36     public class Helper {
37         public static XmlaException authorizationException(Exception JavaDoc ex) {
38             return new XmlaException(
39                 XmlaConstants.CLIENT_FAULT_FC,
40                 XmlaConstants.CHH_AUTHORIZATION_CODE,
41                 XmlaConstants.CHH_AUTHORIZATION_FAULT_FS,
42                 ex);
43         }
44
45         /*
46     HTTP/1.1 100 Continue
47     Server: Microsoft-IIS/5.0
48     Date: Tue, 21 Feb 2006 21:07:57 GMT
49     X-Powered-By: ASP.NET
50         */

51         public static void generatedExpectResponse(
52             HttpServletRequest JavaDoc request,
53             HttpServletResponse JavaDoc response,
54             Map JavaDoc<String JavaDoc, String JavaDoc> context) throws Exception JavaDoc
55         {
56             response.reset();
57             response.setStatus(HttpServletResponse.SC_CONTINUE);
58         }
59     }
60
61     void init(ServletConfig JavaDoc servletConfig) throws ServletException JavaDoc;
62
63     /**
64      * Process the request header items. Specifically if present the
65      * Authorization and Expect headers. If the Authorization header is
66      * present, then the callback can validate the user/password. If
67      * authentication fails, the callback should throw an XmlaException
68      * with the correct XmlaConstants values. The XmlaRequestCallback.Helper
69      * class contains the authorizationException method that can be used
70      * by a callback to generate the XmlaException with the correct values.
71      * If the Expect header is set with "100-continue", then it is
72      * upto the callback to create the appropriate response and return false.
73      * In this case, the XmlaServlet stops processing and returns the
74      * response to the client application. To facilitate the generation of
75      * the response, the XmlaRequestCallback.Helper has the method
76      * generatedExpectResponse that can be called by the callback.
77      * <p>
78      * Note that it is upto the XMLA client to determine whether or not
79      * there is an Expect header entry (ADOMD.NET seems to like to do this).
80      *
81      * @return true if XmlaServlet handling is to continue and false if
82      * there was an Expect header "100-continue".
83      */

84     boolean processHttpHeader(
85         HttpServletRequest JavaDoc request,
86         HttpServletResponse JavaDoc response,
87         Map JavaDoc<String JavaDoc, String JavaDoc> context) throws Exception JavaDoc;
88
89     /**
90      * This is called after the headers have been process but before the
91      * body (DISCOVER/EXECUTE) has been processed.
92      *
93      */

94     void preAction(
95         HttpServletRequest JavaDoc request,
96         Element JavaDoc[] requestSoapParts,
97         Map JavaDoc<String JavaDoc, String JavaDoc> context) throws Exception JavaDoc;
98
99     /**
100      * The Callback is requested to generate a sequence id string. This
101      * sequence id was requested by the XMLA client and will be used
102      * for all subsequent communications in the Soap Header block.
103      *
104      */

105     String JavaDoc generateSessionId(Map JavaDoc<String JavaDoc, String JavaDoc> context);
106
107     /**
108      * This is called after all Mondrian processing (DISCOVER/EXECUTE) has
109      * occurred.
110      *
111      */

112     void postAction(HttpServletRequest JavaDoc request,
113                 HttpServletResponse JavaDoc response,
114                 byte[][] responseSoapParts,
115                 Map JavaDoc<String JavaDoc, String JavaDoc> context) throws Exception JavaDoc;
116 }
117
118 // End XmlaRequestCallback.java
119
Popular Tags