Removed SLF4J from manifest template, added ignoreNotFound convenience property for turning off 404 error messages in RestTemplate.

This commit is contained in:
J. Brisbin
2011-01-07 14:28:55 -06:00
parent d5ece8ee81
commit a471f8b409
4 changed files with 18 additions and 5 deletions

View File

@@ -30,6 +30,7 @@ import org.springframework.core.convert.ConversionService;
import org.springframework.core.convert.support.ConversionServiceFactory;
import org.springframework.data.keyvalue.riak.DataStoreOperationException;
import org.springframework.data.keyvalue.riak.convert.KeyValueStoreMetaData;
import org.springframework.data.keyvalue.riak.util.Ignore404sErrorHandler;
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpInputMessage;
import org.springframework.http.MediaType;
@@ -40,6 +41,7 @@ import org.springframework.http.converter.json.MappingJacksonHttpMessageConverte
import org.springframework.util.Assert;
import org.springframework.util.ClassUtils;
import org.springframework.util.StringUtils;
import org.springframework.web.client.DefaultResponseErrorHandler;
import org.springframework.web.client.ResourceAccessException;
import org.springframework.web.client.RestTemplate;
import org.springframework.web.client.support.RestGatewaySupport;
@@ -205,6 +207,19 @@ public abstract class AbstractRiakTemplate extends RestGatewaySupport implements
this.workerPool = workerPool;
}
public void setIgnoreNotFound(boolean b) {
if (b) {
getRestTemplate().setErrorHandler(new Ignore404sErrorHandler());
} else {
if (getRestTemplate().getErrorHandler() instanceof Ignore404sErrorHandler) {
getRestTemplate().setErrorHandler(new DefaultResponseErrorHandler());
}
}
}
public boolean getIgnoreNotFound() {
return (getRestTemplate().getErrorHandler() instanceof Ignore404sErrorHandler);
}
/**
* Get the default type to use if none can be inferred.

View File

@@ -22,7 +22,6 @@ import org.springframework.data.keyvalue.riak.mapreduce.JavascriptMapReduceOpera
import org.springframework.data.keyvalue.riak.mapreduce.MapReduceJob
import org.springframework.data.keyvalue.riak.mapreduce.RiakMapReduceJob
import org.springframework.data.keyvalue.riak.mapreduce.RiakMapReducePhase
import org.springframework.data.keyvalue.riak.util.Ignore404sErrorHandler
import spock.lang.Shared
import spock.lang.Specification
@@ -42,7 +41,7 @@ class RiakTemplateSpec extends Specification {
RiakQosParameters qos = new RiakQosParameters()
qos.setDurableWriteThreshold("all")
riak.setDefaultQosParameters(qos)
riak.getRestTemplate().setErrorHandler(new Ignore404sErrorHandler())
riak.ignoreNotFound = true
if (!riak.get("status", "")) {
p = "$riakBin start".execute()

View File

@@ -27,8 +27,8 @@
<bean id="qos" class="org.springframework.data.keyvalue.riak.core.RiakQosParameters"
p:durableWriteThreshold="all"
p:writeThreshold="all"/>
<bean id="riakTemplate"
class="org.springframework.data.keyvalue.riak.core.AsyncRiakTemplate"
<bean id="riakTemplate" class="org.springframework.data.keyvalue.riak.core.AsyncRiakTemplate"
p:ignoreNotFound="true"
p:defaultQosParameters-ref="qos"/>
</beans>

View File

@@ -20,7 +20,6 @@ Import-Template:
org.springframework.data.document.*;version="[1.0.0, 2.0.0)",
org.aopalliance.*;version="[1.0.0, 2.0.0)";resolution:=optional,
org.apache.commons.logging.*;version="[1.1.1, 2.0.0)",
org.slf4j.*;version="[1.5.10, 2.0.0)",
org.w3c.dom.*;version="0",
org.codehaus.jackson.*;version="[1.5.6, 1.5.6)",
org.codehaus.jackson.map.*;version="[1.5.6, 1.5.6)",