se.gawell.fakeriak.servlet.InMemoryGetHandler Maven / Gradle / Ivy
The newest version!
package se.gawell.fakeriak.servlet;
import java.io.IOException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import se.gawell.fakeriak.buckets.Buckets;
import se.gawell.fakeriak.index.Indexes;
public class InMemoryGetHandler extends InMemoryHandler implements GetHandler {
public InMemoryGetHandler(Buckets buckets, Indexes indexes) {
super(buckets, indexes);
}
@Override
public void handle(HttpServletRequest request, HttpServletResponse response) throws IOException {
String bucketName = getBucketName(request);
String key = getKey(request);
String result;
if (key.equals("index")) {
String indexName = getPathElement(request.getPathInfo(), 3);
String indexValueA = getPathElement(request.getPathInfo(), 4);
String indexValueB = getPathElement(request.getPathInfo(), 5);
result = indexes.getKeysAsJsonString(bucketName, indexName, indexValueA, indexValueB);
} else {
result = getBucket(bucketName).get(key);
}
writeResultToResponse(response, result);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy