Skip to content

Commit

Permalink
ISPN-8113 Querying via Rest endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
Gustavo Fernandes committed Nov 6, 2017
1 parent 6674ad7 commit 77c2129
Show file tree
Hide file tree
Showing 48 changed files with 1,436 additions and 134 deletions.
Expand Up @@ -170,7 +170,9 @@ private void lookupTranscoder(EncoderRegistry encoderRegistry) {
} }
} }
if (directTranscoder != null) { if (directTranscoder != null) {
encoder = IdentityEncoder.INSTANCE; if (encoder.getStorageFormat().equals(MediaType.APPLICATION_OBJECT)) {
encoder = IdentityEncoder.INSTANCE;
}
transcoder = directTranscoder; transcoder = directTranscoder;
} else { } else {
transcoder = encoderRegistry.getTranscoder(requestMediaType, storageMediaType); transcoder = encoderRegistry.getTranscoder(requestMediaType, storageMediaType);
Expand Down
5 changes: 5 additions & 0 deletions integrationtests/compatibility-mode-it/pom.xml
Expand Up @@ -97,6 +97,11 @@
<artifactId>testng</artifactId> <artifactId>testng</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<scope>test</scope>
</dependency>
</dependencies> </dependencies>


</project> </project>
Expand Up @@ -3,6 +3,7 @@


import static org.infinispan.client.hotrod.test.HotRodClientTestingUtil.killServers; import static org.infinispan.client.hotrod.test.HotRodClientTestingUtil.killServers;
import static org.infinispan.client.hotrod.test.HotRodClientTestingUtil.startHotRodServer; import static org.infinispan.client.hotrod.test.HotRodClientTestingUtil.startHotRodServer;
import static org.infinispan.rest.JSONConstants.TYPE;
import static org.infinispan.server.core.test.ServerTestingUtil.findFreePort; import static org.infinispan.server.core.test.ServerTestingUtil.findFreePort;
import static org.infinispan.test.TestingUtil.killCacheManagers; import static org.infinispan.test.TestingUtil.killCacheManagers;
import static org.testng.Assert.assertEquals; import static org.testng.Assert.assertEquals;
Expand All @@ -20,6 +21,7 @@
import org.apache.commons.httpclient.methods.StringRequestEntity; import org.apache.commons.httpclient.methods.StringRequestEntity;
import org.codehaus.jackson.JsonNode; import org.codehaus.jackson.JsonNode;
import org.codehaus.jackson.map.ObjectMapper; import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.node.ObjectNode;
import org.infinispan.client.hotrod.RemoteCache; import org.infinispan.client.hotrod.RemoteCache;
import org.infinispan.client.hotrod.RemoteCacheManager; import org.infinispan.client.hotrod.RemoteCacheManager;
import org.infinispan.client.hotrod.Search; import org.infinispan.client.hotrod.Search;
Expand All @@ -43,11 +45,12 @@
@Test(groups = "functional") @Test(groups = "functional")
public abstract class BaseJsonTest extends AbstractInfinispanTest { public abstract class BaseJsonTest extends AbstractInfinispanTest {


protected RestServer restServer; RestServer restServer;
protected HttpClient restClient; HttpClient restClient;
private EmbeddedCacheManager cacheManager; private EmbeddedCacheManager cacheManager;
private RemoteCacheManager remoteCacheManager; private RemoteCacheManager remoteCacheManager;
private RemoteCache<String, CryptoCurrency> remoteCache; private RemoteCache<String, CryptoCurrency> remoteCache;
private static final ObjectMapper MAPPER = new ObjectMapper();


private static final String CACHE_NAME = "indexed"; private static final String CACHE_NAME = "indexed";


Expand Down Expand Up @@ -85,8 +88,11 @@ protected void setup() throws Exception {


private void writeCurrencyViaJson(String key, String description, int rank) throws IOException { private void writeCurrencyViaJson(String key, String description, int rank) throws IOException {
EntityEnclosingMethod put = new PutMethod(restEndpoint + "/" + key); EntityEnclosingMethod put = new PutMethod(restEndpoint + "/" + key);
String json = String.format("{\"_type\":\"%s\",\"description\":\"%s\",\"rank\":%d}", getEntityName(), description, rank); ObjectNode currency = MAPPER.createObjectNode();
put.setRequestEntity(new StringRequestEntity(json, "application/json", "UTF-8")); currency.put(TYPE, getEntityName());
currency.put("description", description);
currency.put("rank", rank);
put.setRequestEntity(new StringRequestEntity(currency.toString(), "application/json", "UTF-8"));


restClient.executeMethod(put); restClient.executeMethod(put);
System.out.println(put.getResponseBodyAsString()); System.out.println(put.getResponseBodyAsString());
Expand Down
@@ -1,5 +1,6 @@
package org.infinispan.it.compatibility; package org.infinispan.it.compatibility;


import static org.infinispan.rest.JSONConstants.TYPE;
import static org.testng.AssertJUnit.assertArrayEquals; import static org.testng.AssertJUnit.assertArrayEquals;
import static org.testng.AssertJUnit.assertEquals; import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.assertNotNull; import static org.testng.AssertJUnit.assertNotNull;
Expand Down Expand Up @@ -28,6 +29,8 @@
import org.apache.commons.httpclient.methods.HeadMethod; import org.apache.commons.httpclient.methods.HeadMethod;
import org.apache.commons.httpclient.methods.InputStreamRequestEntity; import org.apache.commons.httpclient.methods.InputStreamRequestEntity;
import org.apache.commons.httpclient.methods.PutMethod; import org.apache.commons.httpclient.methods.PutMethod;
import org.codehaus.jackson.map.ObjectMapper;
import org.codehaus.jackson.node.ObjectNode;
import org.infinispan.client.hotrod.Flag; import org.infinispan.client.hotrod.Flag;
import org.infinispan.client.hotrod.RemoteCache; import org.infinispan.client.hotrod.RemoteCache;
import org.infinispan.commons.dataconversion.IdentityEncoder; import org.infinispan.commons.dataconversion.IdentityEncoder;
Expand All @@ -49,6 +52,8 @@ public class EmbeddedRestHotRodTest extends AbstractInfinispanTest {


private static final DateFormat dateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.US); private static final DateFormat dateFormat = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss zzz", Locale.US);


private static final ObjectMapper MAPPER = new ObjectMapper();

CompatibilityCacheFactory<String, Object> cacheFactory; CompatibilityCacheFactory<String, Object> cacheFactory;


@BeforeClass @BeforeClass
Expand Down Expand Up @@ -170,7 +175,7 @@ public void testCustomObjectEmbeddedPutRestGetAcceptJSONAndXML() throws Exceptio
getJson.setRequestHeader("Accept", "application/json"); getJson.setRequestHeader("Accept", "application/json");
cacheFactory.getRestClient().executeMethod(getJson); cacheFactory.getRestClient().executeMethod(getJson);
assertEquals(getJson.getStatusText(), HttpStatus.SC_OK, getJson.getStatusCode()); assertEquals(getJson.getStatusText(), HttpStatus.SC_OK, getJson.getStatusCode());
assertEquals("{\"_type\":\"" + Person.class.getName() + "\",\"name\":\"Anna\"}", getJson.getResponseBodyAsString()); assertEquals(asJson(p), getJson.getResponseBodyAsString());


// 3. Get with REST (accept application/xml) // 3. Get with REST (accept application/xml)
HttpMethod getXml = new GetMethod(cacheFactory.getRestUrl() + "/" + key); HttpMethod getXml = new GetMethod(cacheFactory.getRestUrl() + "/" + key);
Expand All @@ -193,7 +198,7 @@ public void testCustomObjectHotRodPutRestGetAcceptJSONAndXML() throws Exception
getJson.setRequestHeader("Accept", "application/json"); getJson.setRequestHeader("Accept", "application/json");
cacheFactory.getRestClient().executeMethod(getJson); cacheFactory.getRestClient().executeMethod(getJson);
assertEquals(getJson.getStatusText(), HttpStatus.SC_OK, getJson.getStatusCode()); assertEquals(getJson.getStatusText(), HttpStatus.SC_OK, getJson.getStatusCode());
assertEquals("{\"_type\":\"" + Person.class.getName() + "\",\"name\":\"Jakub\"}", getJson.getResponseBodyAsString()); assertEquals(asJson(p), getJson.getResponseBodyAsString());


// 3. Get with REST (accept application/xml) // 3. Get with REST (accept application/xml)
HttpMethod getXml = new GetMethod(cacheFactory.getRestUrl() + "/" + key); HttpMethod getXml = new GetMethod(cacheFactory.getRestUrl() + "/" + key);
Expand Down Expand Up @@ -397,6 +402,13 @@ public void testHotRodEmbeddedPutRestGetCacheControlHeader() throws Exception {
assertEquals("v2", getKey2.getResponseBodyAsString()); assertEquals("v2", getKey2.getResponseBodyAsString());
} }


private String asJson(Person p) {
ObjectNode person = MAPPER.createObjectNode();
person.put(TYPE, p.getClass().getName());
person.put("name", p.name);
return person.toString();
}

/** /**
* The class needs a getter for the attribute "name" so that it can be converted to JSON format * The class needs a getter for the attribute "name" so that it can be converted to JSON format
* internally by the REST server. * internally by the REST server.
Expand Down
Expand Up @@ -6,6 +6,7 @@
import org.infinispan.commons.dataconversion.Encoder; import org.infinispan.commons.dataconversion.Encoder;
import org.infinispan.configuration.cache.Configuration; import org.infinispan.configuration.cache.Configuration;
import org.infinispan.factories.ComponentRegistry; import org.infinispan.factories.ComponentRegistry;
import org.infinispan.marshall.core.EncoderRegistry;
import org.infinispan.objectfilter.Matcher; import org.infinispan.objectfilter.Matcher;
import org.infinispan.objectfilter.impl.syntax.parser.EntityNameResolver; import org.infinispan.objectfilter.impl.syntax.parser.EntityNameResolver;
import org.infinispan.protostream.SerializationContext; import org.infinispan.protostream.SerializationContext;
Expand All @@ -26,8 +27,10 @@ abstract class AbstractCompatRemoteQueryManager implements RemoteQueryManager {


protected final SerializationContext ctx; protected final SerializationContext ctx;
protected final boolean isIndexed; protected final boolean isIndexed;
final EncoderRegistry encoderRegistry;


AbstractCompatRemoteQueryManager(ComponentRegistry cr) { AbstractCompatRemoteQueryManager(ComponentRegistry cr) {
this.encoderRegistry = cr.getGlobalComponentRegistry().getComponent(EncoderRegistry.class);
SearchIntegrator searchIntegrator = cr.getComponent(SearchIntegrator.class); SearchIntegrator searchIntegrator = cr.getComponent(SearchIntegrator.class);
AdvancedCache<?, ?> cache = cr.getComponent(Cache.class).getAdvancedCache(); AdvancedCache<?, ?> cache = cr.getComponent(Cache.class).getAdvancedCache();
Configuration cfg = cr.getComponent(Configuration.class); Configuration cfg = cr.getComponent(Configuration.class);
Expand Down
@@ -1,15 +1,22 @@
package org.infinispan.query.remote.impl; package org.infinispan.query.remote.impl;


import static java.util.stream.Collectors.toList;
import static org.infinispan.commons.dataconversion.MediaType.APPLICATION_JSON;
import static org.infinispan.commons.dataconversion.MediaType.APPLICATION_OBJECT;

import java.util.List;
import java.util.Set; import java.util.Set;


import org.hibernate.search.spi.SearchIntegrator; import org.hibernate.search.spi.SearchIntegrator;
import org.infinispan.commons.dataconversion.Transcoder;
import org.infinispan.factories.ComponentRegistry; import org.infinispan.factories.ComponentRegistry;
import org.infinispan.objectfilter.impl.syntax.parser.EntityNameResolver; import org.infinispan.objectfilter.impl.syntax.parser.EntityNameResolver;
import org.infinispan.objectfilter.impl.syntax.parser.ReflectionEntityNamesResolver; import org.infinispan.objectfilter.impl.syntax.parser.ReflectionEntityNamesResolver;
import org.infinispan.protostream.SerializationContext; import org.infinispan.protostream.SerializationContext;
import org.infinispan.query.backend.QueryInterceptor; import org.infinispan.query.backend.QueryInterceptor;
import org.infinispan.query.remote.client.QueryRequest; import org.infinispan.query.remote.client.QueryRequest;
import org.infinispan.query.remote.client.QueryResponse; import org.infinispan.query.remote.client.QueryResponse;
import org.infinispan.query.remote.impl.util.LazyRef;


/** /**
* Handle remote queries with deserialized object storage using the configured compat mode marshaller. * Handle remote queries with deserialized object storage using the configured compat mode marshaller.
Expand All @@ -18,6 +25,9 @@
*/ */
class GenericCompatRemoteQueryManager extends AbstractCompatRemoteQueryManager { class GenericCompatRemoteQueryManager extends AbstractCompatRemoteQueryManager {


private LazyRef<Transcoder> transcoder =
new LazyRef<>(() -> encoderRegistry.getTranscoder(APPLICATION_OBJECT, APPLICATION_JSON));

GenericCompatRemoteQueryManager(ComponentRegistry cr) { GenericCompatRemoteQueryManager(ComponentRegistry cr) {
super(cr); super(cr);
} }
Expand Down Expand Up @@ -55,6 +65,12 @@ public QueryRequest decodeQueryRequest(byte[] queryRequest) {
return (QueryRequest) getValueEncoder().toStorage(queryRequest); return (QueryRequest) getValueEncoder().toStorage(queryRequest);
} }


@Override
public List<Object> encodeQueryResults(List<Object> results) {
return results.stream()
.map(o -> transcoder.get().transcode(o, APPLICATION_OBJECT, APPLICATION_JSON)).collect(toList());
}

@Override @Override
public byte[] encodeQueryResponse(QueryResponse queryResponse) { public byte[] encodeQueryResponse(QueryResponse queryResponse) {
Object o = this.getValueEncoder().fromStorage(queryResponse); Object o = this.getValueEncoder().fromStorage(queryResponse);
Expand Down
@@ -1,15 +1,22 @@
package org.infinispan.query.remote.impl; package org.infinispan.query.remote.impl;


import static java.util.stream.Collectors.toList;
import static org.infinispan.commons.dataconversion.MediaType.APPLICATION_JSON;
import static org.infinispan.commons.dataconversion.MediaType.APPLICATION_OBJECT;

import java.io.IOException; import java.io.IOException;
import java.util.List;


import org.hibernate.search.spi.SearchIntegrator; import org.hibernate.search.spi.SearchIntegrator;
import org.infinispan.commons.CacheException; import org.infinispan.commons.CacheException;
import org.infinispan.commons.dataconversion.Transcoder;
import org.infinispan.factories.ComponentRegistry; import org.infinispan.factories.ComponentRegistry;
import org.infinispan.objectfilter.impl.syntax.parser.EntityNameResolver; import org.infinispan.objectfilter.impl.syntax.parser.EntityNameResolver;
import org.infinispan.protostream.ProtobufUtil; import org.infinispan.protostream.ProtobufUtil;
import org.infinispan.protostream.SerializationContext; import org.infinispan.protostream.SerializationContext;
import org.infinispan.query.remote.client.QueryRequest; import org.infinispan.query.remote.client.QueryRequest;
import org.infinispan.query.remote.client.QueryResponse; import org.infinispan.query.remote.client.QueryResponse;
import org.infinispan.query.remote.impl.util.LazyRef;


/** /**
* Handle remote queries with deserialized object storage using the protostream marshaller. * Handle remote queries with deserialized object storage using the protostream marshaller.
Expand All @@ -18,6 +25,9 @@
*/ */
class ProtostreamCompatRemoteQueryManager extends AbstractCompatRemoteQueryManager { class ProtostreamCompatRemoteQueryManager extends AbstractCompatRemoteQueryManager {


private LazyRef<Transcoder> transcoder =
new LazyRef<>(() -> encoderRegistry.getTranscoder(APPLICATION_OBJECT, APPLICATION_JSON));

ProtostreamCompatRemoteQueryManager(ComponentRegistry cr) { ProtostreamCompatRemoteQueryManager(ComponentRegistry cr) {
super(cr); super(cr);
} }
Expand Down Expand Up @@ -45,6 +55,12 @@ public QueryRequest decodeQueryRequest(byte[] queryRequest) {
} }
} }


@Override
public List<Object> encodeQueryResults(List<Object> results) {
return results.stream()
.map(o -> transcoder.get().transcode(o, APPLICATION_OBJECT, APPLICATION_JSON)).collect(toList());
}

@Override @Override
public byte[] encodeQueryResponse(QueryResponse queryResponse) { public byte[] encodeQueryResponse(QueryResponse queryResponse) {
try { try {
Expand Down
Expand Up @@ -7,7 +7,7 @@ public class RemoteQueryResult {
private final int totalResults; private final int totalResults;
private final List<Object> results; private final List<Object> results;


public RemoteQueryResult(String[] projections, int totalResults, List<Object> results) { RemoteQueryResult(String[] projections, int totalResults, List<Object> results) {
this.projections = projections; this.projections = projections;
this.totalResults = totalResults; this.totalResults = totalResults;
this.results = results; this.results = results;
Expand Down
@@ -0,0 +1,30 @@
package org.infinispan.query.remote.impl.util;

import java.util.function.Supplier;

/**
* @since 9.2
*/
public class LazyRef<R> implements Supplier<R> {

private final Supplier<R> supplier;
private R supplied;
private volatile boolean available;

public LazyRef(Supplier<R> supplier) {
this.supplier = supplier;
}

@Override
public R get() {
if (!available) {
synchronized (this) {
if (!available) {
supplied = supplier.get();
available = true;
}
}
}
return supplied;
}
}
Expand Up @@ -8,7 +8,6 @@
import org.infinispan.rest.context.WrongContextException; import org.infinispan.rest.context.WrongContextException;
import org.infinispan.rest.logging.Log; import org.infinispan.rest.logging.Log;
import org.infinispan.rest.logging.RestAccessLoggingHandler; import org.infinispan.rest.logging.RestAccessLoggingHandler;
import org.infinispan.rest.operations.CacheOperations;
import org.infinispan.util.logging.LogFactory; import org.infinispan.util.logging.LogFactory;


import io.netty.channel.ChannelFutureListener; import io.netty.channel.ChannelFutureListener;
Expand All @@ -28,7 +27,6 @@ public class Http20RequestHandler extends SimpleChannelInboundHandler<FullHttpRe


protected final static Log logger = LogFactory.getLog(Http20RequestHandler.class, Log.class); protected final static Log logger = LogFactory.getLog(Http20RequestHandler.class, Log.class);


private final CacheOperations cacheOperations;
private final Authenticator authenticator; private final Authenticator authenticator;
final RestAccessLoggingHandler restAccessLoggingHandler = new RestAccessLoggingHandler(); final RestAccessLoggingHandler restAccessLoggingHandler = new RestAccessLoggingHandler();
protected final RestServer restServer; protected final RestServer restServer;
Expand All @@ -42,18 +40,18 @@ public class Http20RequestHandler extends SimpleChannelInboundHandler<FullHttpRe
Http20RequestHandler(RestServer restServer) { Http20RequestHandler(RestServer restServer) {
this.restServer = restServer; this.restServer = restServer;
this.configuration = restServer.getConfiguration(); this.configuration = restServer.getConfiguration();
this.cacheOperations = restServer.getCacheOperations();
this.authenticator = restServer.getAuthenticator(); this.authenticator = restServer.getAuthenticator();
} }


@Override @Override
public void channelRead0(ChannelHandlerContext ctx, FullHttpRequest request) throws Exception { public void channelRead0(ChannelHandlerContext ctx, FullHttpRequest request) throws Exception {
InfinispanRequest infinispanRequest = InfinispanRequestCreator.createRequest(request, ctx);
InfinispanResponse response; InfinispanResponse response;
InfinispanRequest infinispanRequest = null;
try { try {
infinispanRequest = InfinispanRequestFactory.createRequest(restServer, request, ctx);
this.checkContext(infinispanRequest); this.checkContext(infinispanRequest);
authenticator.challenge(infinispanRequest); authenticator.challenge(infinispanRequest);
response = infinispanRequest.execute(cacheOperations); response = infinispanRequest.execute();
} catch (RestResponseException responseException) { } catch (RestResponseException responseException) {
logger.errorWhileResponding(responseException); logger.errorWhileResponding(responseException);
response = responseException.toResponse(infinispanRequest); response = responseException.toResponse(infinispanRequest);
Expand Down
Expand Up @@ -3,6 +3,7 @@
import static io.netty.handler.codec.http.HttpResponseStatus.NOT_IMPLEMENTED; import static io.netty.handler.codec.http.HttpResponseStatus.NOT_IMPLEMENTED;


import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Optional; import java.util.Optional;


import org.infinispan.rest.operations.CacheOperations; import org.infinispan.rest.operations.CacheOperations;
Expand All @@ -14,16 +15,18 @@
import io.netty.handler.codec.http.HttpMethod; import io.netty.handler.codec.http.HttpMethod;


/** /**
* Representation of a HTTP request related to Cache API operations. * Representation of a HTTP request related to Cache API operations.
* *
* @since 9.2 * @since 9.2
*/ */
public class InfinispanCacheAPIRequest extends InfinispanRequest { public class InfinispanCacheAPIRequest extends InfinispanRequest {


private final Optional<String> key; private final Optional<String> key;
private final CacheOperations cacheOperations;


InfinispanCacheAPIRequest(FullHttpRequest request, ChannelHandlerContext ctx, Optional<String> cacheName, Optional<String> key, String context) { InfinispanCacheAPIRequest(CacheOperations operations, FullHttpRequest request, ChannelHandlerContext ctx, Optional<String> cacheName, Optional<String> key, String context, Map<String, List<String>> parameters) {
super(request, ctx, cacheName.orElse(null), context); super(request, ctx, cacheName.orElse(null), context, parameters);
this.cacheOperations = operations;
this.key = key; this.key = key;
} }


Expand All @@ -35,7 +38,7 @@ public Optional<String> getKey() {
} }


@Override @Override
protected InfinispanResponse execute(CacheOperations cacheOperations) { protected InfinispanResponse execute() {
InfinispanResponse response = InfinispanErrorResponse.asError(this, NOT_IMPLEMENTED, null); InfinispanResponse response = InfinispanErrorResponse.asError(this, NOT_IMPLEMENTED, null);


if (request.method() == HttpMethod.GET) { if (request.method() == HttpMethod.GET) {
Expand Down Expand Up @@ -73,7 +76,7 @@ public Optional<Long> getTimeToLiveSeconds() {
if (timeToLiveSeconds != null) { if (timeToLiveSeconds != null) {
try { try {
return Optional.of(Long.valueOf(timeToLiveSeconds)); return Optional.of(Long.valueOf(timeToLiveSeconds));
} catch (NumberFormatException nfe) { } catch (NumberFormatException ignored) {
} }
} }
return Optional.empty(); return Optional.empty();
Expand All @@ -89,7 +92,7 @@ public Optional<Long> getMaxIdleTimeSeconds() {
if (maxIdleTimeSeconds != null) { if (maxIdleTimeSeconds != null) {
try { try {
return Optional.of(Long.valueOf(maxIdleTimeSeconds)); return Optional.of(Long.valueOf(maxIdleTimeSeconds));
} catch (NumberFormatException nfe) { } catch (NumberFormatException ignored) {
} }
} }
return Optional.empty(); return Optional.empty();
Expand Down Expand Up @@ -145,7 +148,7 @@ public Optional<String> getCacheControl() {
* @return <code>true</code> if client wishes to return 'Extended Headers'. * @return <code>true</code> if client wishes to return 'Extended Headers'.
*/ */
public Optional<String> getExtended() { public Optional<String> getExtended() {
List<String> extendedParameters = queryStringDecoder.parameters().get("extended"); List<String> extendedParameters = parameters.get("extended");
if (extendedParameters != null && extendedParameters.size() > 0) { if (extendedParameters != null && extendedParameters.size() > 0) {
return Optional.ofNullable(extendedParameters.get(0)); return Optional.ofNullable(extendedParameters.get(0));
} }
Expand Down
Expand Up @@ -9,12 +9,12 @@
*/ */
public class InfinispanErrorResponse extends InfinispanResponse { public class InfinispanErrorResponse extends InfinispanResponse {


protected InfinispanErrorResponse(Optional<InfinispanRequest> request) { private InfinispanErrorResponse(Optional<InfinispanRequest> request) {
super(request); super(request);
} }


public static InfinispanErrorResponse asError(InfinispanRequest request, HttpResponseStatus status, String description) { public static InfinispanErrorResponse asError(InfinispanRequest request, HttpResponseStatus status, String description) {
InfinispanErrorResponse infinispanResponse = new InfinispanErrorResponse(Optional.of(request)); InfinispanErrorResponse infinispanResponse = new InfinispanErrorResponse(Optional.ofNullable(request));
infinispanResponse.status(status); infinispanResponse.status(status);
if (description != null) { if (description != null) {
infinispanResponse.contentAsText(description); infinispanResponse.contentAsText(description);
Expand Down

0 comments on commit 77c2129

Please sign in to comment.