[Mondrian] Eigenbase perforce change 14566 for review
Julian Hyde
jhyde at pentaho.com
Thu Aug 25 15:29:22 EDT 2011
Michele,
Congratulations on your first check in.
However, it had 17 checkFile exceptions. Can you fix today please.
Julian
On Aug 25, 2011, at 12:44 AM, Michele Rossi wrote:
> http://p4web.eigenbase.org/@md=d&c=6PU@/14566?ac=10
>
> Change 14566 by mrossi at michele_mondrian on 2011/08/25 00:43:32
>
> MONDRIAN: fixes to xmla servlet
>
> Affected files ...
>
> ... //open/mondrian/src/main/mondrian/xmla/XmlaHandler.java#80 edit
> ... //open/mondrian/src/main/mondrian/xmla/impl/DefaultXmlaServlet.java#33 edit
> ... //open/mondrian/src/main/mondrian/xmla/impl/Olap4jXmlaServlet.java#4 edit
>
> Differences ...
>
> ==== //open/mondrian/src/main/mondrian/xmla/XmlaHandler.java#80 (ktext) ====
>
> 2c2
> < // $Id: //open/mondrian/src/main/mondrian/xmla/XmlaHandler.java#79 $
> ---
>> // $Id: //open/mondrian/src/main/mondrian/xmla/XmlaHandler.java#80 $
> 27a28,29
>> import java.lang.reflect.InvocationTargetException;
>> import java.lang.reflect.UndeclaredThrowableException;
> 41c43
> < * @version $Id: //open/mondrian/src/main/mondrian/xmla/XmlaHandler.java#79 $
> ---
>> * @version $Id: //open/mondrian/src/main/mondrian/xmla/XmlaHandler.java#80 $
> 75a78,102
>> } catch (UndeclaredThrowableException ute) {
>> //
>> // Note: this is necessary because we use a dynamic proxy for the
>> // connection.
>> // I could not catch and un-wrap the Undeclared Throwable within
>> // the proxy.
>> // The exception comes out here and I couldn't find any better
>> // ways to deal with it.
>> //
>> // The undeclared throwable contains an Invocation Target Exception
>> // which in turns contains the real exception thrown by the "unwrap"
>> // method, for example OlapException.
>> //
>>
>> Throwable cause = ute.getCause();
>> if (cause instanceof InvocationTargetException) {
>> cause = cause.getCause();
>> }
>>
>> // this maintains the original behaviour: don't catch exceptions
>> // that are not subclasses of SQLException
>>
>> if (! (cause instanceof SQLException)) {
>> throw ute;
>> }
>
> ==== //open/mondrian/src/main/mondrian/xmla/impl/DefaultXmlaServlet.java#33 (ktext) ====
>
> 2c2
> < // $Id: //open/mondrian/src/main/mondrian/xmla/impl/DefaultXmlaServlet.java#32 $
> ---
>> // $Id: //open/mondrian/src/main/mondrian/xmla/impl/DefaultXmlaServlet.java#33 $
> 12c12,18
> < import java.io.*;
> ---
>> import java.io.ByteArrayInputStream;
>> import java.io.ByteArrayOutputStream;
>> import java.io.IOException;
>> import java.io.InputStream;
>> import java.io.OutputStream;
>> import java.io.StringWriter;
>> import java.io.UnsupportedEncodingException;
> 14,15c20,24
> < import java.nio.channels.*;
> < import java.util.*;
> ---
>> import java.nio.channels.Channels;
>> import java.nio.channels.ReadableByteChannel;
>> import java.nio.channels.WritableByteChannel;
>> import java.util.HashMap;
>> import java.util.Map;
> 17,19c26,32
> < import javax.servlet.*;
> < import javax.servlet.http.*;
> < import javax.xml.parsers.*;
> ---
>> import javax.servlet.ServletConfig;
>> import javax.servlet.ServletException;
>> import javax.servlet.http.HttpServletRequest;
>> import javax.servlet.http.HttpServletResponse;
>> import javax.xml.parsers.DocumentBuilder;
>> import javax.xml.parsers.DocumentBuilderFactory;
>> import javax.xml.parsers.ParserConfigurationException;
> 21d33
> < import mondrian.xmla.*;
> 22a35,42
>> import mondrian.xmla.SaxWriter;
>> import mondrian.xmla.XmlaConstants;
>> import mondrian.xmla.XmlaException;
>> import mondrian.xmla.XmlaRequest;
>> import mondrian.xmla.XmlaRequestCallback;
>> import mondrian.xmla.XmlaResponse;
>> import mondrian.xmla.XmlaServlet;
>> import mondrian.xmla.XmlaUtil;
> 25,26c45,51
> < import org.w3c.dom.*;
> < import org.xml.sax.*;
> ---
>> import org.w3c.dom.Attr;
>> import org.w3c.dom.Document;
>> import org.w3c.dom.Element;
>> import org.w3c.dom.Node;
>> import org.w3c.dom.NodeList;
>> import org.xml.sax.InputSource;
>> import org.xml.sax.SAXException;
> 32c57
> < * @version $Id: //open/mondrian/src/main/mondrian/xmla/impl/DefaultXmlaServlet.java#32 $
> ---
>> * @version $Id: //open/mondrian/src/main/mondrian/xmla/impl/DefaultXmlaServlet.java#33 $
> 45,52d69
> < /**
> < * Simba O2X for some reason attempts to create many new xmla sessions
> < * during the same user interactions. We can mitigate that by creating a
> < * session id which is a direct hash function of the credentials supplied
> < * and the remote host IP.
> < */
> < private static final String REUSE_SESSION_IDS = "reuseSessionIds";
> <
> 56d72
> < private boolean reuseSessionIds = false;
> 61,63d76
> < *
> < * <p>NOTE: There is no mechanism to remove entries from this map,
> < * so it will get larger if the server is up for a long time.</p>
> 74,76d86
> < this.reuseSessionIds =
> < Boolean.parseBoolean(
> < servletConfig.getInitParameter(REUSE_SESSION_IDS));
> 79c89
> < protected DocumentBuilderFactory getDocumentBuilderFactory() {
> ---
>> protected static DocumentBuilderFactory getDocumentBuilderFactory() {
> 239a250
>>
> 277a289
>>
> 281d292
> < context.put(CONTEXT_XMLA_PASSWORD, passwordStr);
> 283,285c294,296
> < // [MROSSI] TODO we'd need to inject the HttpServletRequest
> < // into this method context.put("remote_host",
> < // request.getRemoteHost());
> ---
>>
>> context.put(CONTEXT_XMLA_PASSWORD, passwordStr);
>>
> 287c298
> < LOGGER.error(
> ---
>> LOGGER.warn(
> 319d329
> < // generate SessionId
> 328,330c338,347
> < // extract the SessionId attrs value and put into
> < // context
> < sessionIdStr = getSessionId(e, context);
> ---
>> sessionIdStr = getSessionIdFromRequest(e, context);
>>
>> SessionInfo sessionInfo = getSessionInfo(sessionIdStr);
>>
>> if (sessionInfo != null) {
>> context.put(CONTEXT_XMLA_USERNAME, sessionInfo.user);
>> context.put(
>> CONTEXT_XMLA_PASSWORD,
>> sessionInfo.password);
>> }
> 338,349c355
> < // extract the SessionId attrs value and put into
> < // context
> < sessionIdStr = getSessionId(e, context);
> <
> < SessionInfo sessionInfo =
> < getSessionInfo(sessionIdStr);
> < if (sessionInfo != null) {
> < context.put(CONTEXT_XMLA_USERNAME, sessionInfo.user);
> < context.put(
> < CONTEXT_XMLA_PASSWORD, sessionInfo.password);
> < }
> < context.put(CONTEXT_XMLA_SESSION_ID, sessionIdStr);
> ---
>> sessionIdStr = getSessionIdFromRequest(e, context);
> 354,355d359
> < // remove session info
> < removeSessionInfo(sessionIdStr);
> 392a397
>>
> 419,423d423
> < private void removeSessionInfo(String sessionIdStr) {
> < synchronized (sessionInfos) {
> < sessionInfos.remove(sessionIdStr);
> < }
> < }
> 425a426
>>
> 432,469c433,438
> < /*
> < * Fallback to the default session ID generation algorithm.
> < */
> < if (reuseSessionIds) {
> < // This is how we use the same session id (key to retrieve a
> < // connection) for requests with the same username coming from
> < // the same remote host. The password can't be part of the
> < // string because if you use Simba and you don't tick "save
> < // password" in the login dialog then Simba only sends the
> < // password with the first session that it opens - after which
> < // it sends something like the following:
> < //
> < // <Header>
> < // <Security xmlns="http://schemas.xmlsoap.org/ws/2002/04/secext">
> < // <UsernameToken>
> < // <Username>michele</Username>
> < // <Password Type="PasswordText"/>
> < // </UsernameToken>
> < // </Security>
> < // <BeginSession
> < // xmlns="urn:schemas-microsoft-com:xml-analysis"
> < // mustUnderstand="1"/>
> < // </Header>
> < //
> < // Note the Password element with no value in it.
> < String sessionString =
> < "session_"
> < + context.get(CONTEXT_XMLA_USERNAME)
> < + "_"
> < + "_"
> < + context.get("remote_host");
> < return Long.toString(sessionString.hashCode(), 35);
> < } else {
> < // Generate a semi-random new session ID.
> < return Long.toString(
> < -17L * System.nanoTime() + 11L * System.currentTimeMillis(),
> < 35);
> < }
> ---
>>
>>
>> // Generate a pseudo-random new session ID.
>> return Long.toString(17L * System.nanoTime()
>> +
>> 3L * System.currentTimeMillis(), 35);
> 472c441,443
> < protected String getSessionId(Element e, Map<String, Object> context)
> ---
>>
>> private static String getSessionIdFromRequest(Element e,
>> Map<String, Object> context)
> 485,486c456,458
> < String value = attr.getValue();
> < if (value == null) {
> ---
>>
>> String sessionId = attr.getValue();
>> if (sessionId == null) {
> 494c466
> < return value;
> ---
>> return sessionId;
> 845c817,822
> < SessionInfo sessionInfo;
> ---
>> if (sessionId == null) {
>> return null;
>> }
>>
>> SessionInfo sessionInfo = null;
>>
> 848a826
>>
> 851,852c829,831
> < "No login credentials for found for session [" + sessionId
> < + "]");
> ---
>> "No login credentials for found for session ["
>> +
>> sessionId + "]");
> 855,856c834,837
> < "Found existing credentials for session id ["
> < + sessionId + "], username=[" + sessionInfo.user + "]");
> ---
>> "Found credentials for session id ["
>> + sessionId
>> + "], username=[" + sessionInfo.user
>> + "] in servlet cache");
> 876c857
> < new SessionInfo(sessionId, username, password);
> ---
>> new SessionInfo(username, password);
> 882c863
> < sessionInfo = new SessionInfo(sessionId, username, password);
> ---
>> sessionInfo = new SessionInfo(username, password);
> 888c869,871
> <
> ---
>> /**
>> * Holds authentication credentials of a XMLA session.
>> */
> 890d872
> < final String id;
> 894,895c876,877
> < public SessionInfo(String id, String user, String password) {
> < this.id = id;
> ---
>> public SessionInfo(String user, String password)
>> {
> 901d882
> <
>
> ==== //open/mondrian/src/main/mondrian/xmla/impl/Olap4jXmlaServlet.java#4 (ktext) ====
>
> 2c2
> < // $Id: //open/mondrian/src/main/mondrian/xmla/impl/Olap4jXmlaServlet.java#3 $
> ---
>> // $Id: //open/mondrian/src/main/mondrian/xmla/impl/Olap4jXmlaServlet.java#4 $
> 28a29
>> import java.lang.reflect.UndeclaredThrowableException;
> 36c37
> < * @version $Id: //open/mondrian/src/main/mondrian/xmla/impl/Olap4jXmlaServlet.java#3 $
> ---
>> * @version $Id: //open/mondrian/src/main/mondrian/xmla/impl/Olap4jXmlaServlet.java#4 $
> 415a417
>>
> 422,423c424,427
> < if (OlapConnection.class.isAssignableFrom(
> < method.getClass()))
> ---
>> if ("unwrap".equals(method.getName())
>> ||
>> OlapConnection.class.isAssignableFrom(
>> method.getDeclaringClass()))
>
More information about the Mondrian
mailing list