Skip to content

Commit

Permalink
Cleanup of the XmlaProxyCache prior to 1.0.0. Was throwing a Runtime …
Browse files Browse the repository at this point in the history
…Exception for no good reason. Downgrading it to OlapException. They get handled anyways by the XmlaProxy contract.

git-svn-id: https://olap4j.svn.sourceforge.net/svnroot/olap4j/trunk@426 c6a108a4-781c-0410-a6c6-c2d559e19af0
  • Loading branch information
lucboudreau committed Mar 23, 2011
1 parent fd44edb commit 0a2e5c6
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 24 deletions.
22 changes: 12 additions & 10 deletions src/org/olap4j/driver/xmla/cache/XmlaOlap4jCache.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
import java.net.URL;
import java.util.Map;

import org.olap4j.OlapException;

/**
* XMLA driver cache. Implementations will have to declare those methods.
*
Expand All @@ -37,9 +39,9 @@ public interface XmlaOlap4jCache {
* @param url The URL where the SOAP message was sent.
* @param request The SOAP complete message.
*
* @throws XmlaOlap4jInvalidStateException when
* operations to the cache are performed but it hasn't been initialized.
* Make sure you call the setParameters method.
* @throws OlapException when operations to the cache are
* performed but it hasn't been initialized. Make sure you
* call the setParameters(Map, Map) method.
*
* @return The SOAP response, null if there are no corresponding
* response in the cache.
Expand All @@ -48,7 +50,7 @@ public byte[] get(
String id,
URL url,
byte[] request)
throws XmlaOlap4jInvalidStateException;
throws OlapException;

/**
* Adds a SOAP response to the cache. It has to be relative to the
Expand All @@ -60,16 +62,16 @@ public byte[] get(
* response.
* @param response The response to cache.
*
* @throws XmlaOlap4jInvalidStateException when
* operations to the cache are performed but it hasn't been initialized.
* Make sure you call the setParameters method.
* @throws OlapException when operations to the cache are
* performed but it hasn't been initialized. Make sure you
* call the setParameters(Map, Map) method.
*/
public void put(
String id,
URL url,
byte[] request,
byte[] response)
throws XmlaOlap4jInvalidStateException;
throws OlapException;

/**
* Tells the cache to flush all cached entries.
Expand All @@ -82,9 +84,9 @@ public void put(
* <p>The XMLA driver takes cache properties as
* "<code>Cache.[property name]=[value]</code>" in its JDBC url. All those
* properties should be striped of their "<code>Cache.</code>" prefix and
* sent to this method as the properties parameter.
* sent to this method as the props parameter.
*
* <p>Also, the complete config map of the current connection
* <p>Also, the complete map of the current connection
* should be passed as the config parameter.
*
* @param config The complete configuration parameters which were used to
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,16 @@
*/
package org.olap4j.driver.xmla.cache;

import org.olap4j.OlapException;

/**
* <p>Internal exception which gets thrown when operations to the cache
* are performed but it hasn't been initialized.
*
* <p>It extends RuntimeException so it cannot be catched by the
* regular catch(Exception) mechanism. Those exceptions should get right
* to the system level since it's a programming error.
*
* @author Luc Boudreau
* @version $Id$
*/
class XmlaOlap4jInvalidStateException extends RuntimeException {
public class XmlaOlap4jInvalidStateException extends OlapException {
private static final long serialVersionUID = 7265273715459263740L;
}

Expand Down
22 changes: 13 additions & 9 deletions src/org/olap4j/driver/xmla/proxy/XmlaOlap4jAbstractHttpProxy.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,14 @@
*/
package org.olap4j.driver.xmla.proxy;

import java.io.*;
import java.net.*;
import java.util.*;
import java.util.concurrent.*;
import java.net.URL;
import java.net.URLConnection;
import java.util.Map;
import java.util.concurrent.Future;

import org.olap4j.OlapException;
import org.olap4j.driver.xmla.XmlaOlap4jDriver;
import org.olap4j.driver.xmla.XmlaHelper;
import org.olap4j.driver.xmla.XmlaOlap4jDriver;
import org.olap4j.driver.xmla.cache.XmlaOlap4jCache;

/**
Expand Down Expand Up @@ -159,7 +159,7 @@ public byte[] get(URL url, String request) throws XmlaOlap4jProxyException {
if (response != null) {
return response;
}
} catch (IOException e) {
} catch (Exception e) {
throw new XmlaOlap4jProxyException(
"An exception was encountered while browsing the proxy cache.",
e);
Expand All @@ -176,7 +176,7 @@ public byte[] get(URL url, String request) throws XmlaOlap4jProxyException {
response);
// Returns result
return response;
} catch (IOException e) {
} catch (Exception e) {
throw new XmlaOlap4jProxyException(
"An exception was encountered while saving a response in the proxy cache.",
e);
Expand All @@ -194,7 +194,9 @@ public byte[] get(URL url, String request) throws XmlaOlap4jProxyException {
* @return either a response in a byte array or null
* if the response is not in cache
*/
private byte[] getFromCache(final URL url, final byte[] request) {
private byte[] getFromCache(final URL url, final byte[] request)
throws OlapException
{
return (this.cache != null)
? this.cache.get(this.cacheId, url, request)
: null;
Expand All @@ -207,7 +209,9 @@ private byte[] getFromCache(final URL url, final byte[] request) {
* @param request The SOAP request to cache
* @param response The SOAP response to cache
*/
private void addToCache(URL url, byte[] request, byte[] response) {
private void addToCache(URL url, byte[] request, byte[] response)
throws OlapException
{
if (this.cache != null) {
this.cache.put(this.cacheId, url, request, response);
}
Expand Down

0 comments on commit 0a2e5c6

Please sign in to comment.