Skip to content

Commit 11abaee

Browse files
committed
revert changes for #610 since keyvalue endpoint isn't removed yet for 3.x branch (and ML8)
1 parent 1ac6bcd commit 11abaee

File tree

1 file changed

+28
-1
lines changed

1 file changed

+28
-1
lines changed

src/main/java/com/marklogic/client/impl/JerseyServices.java

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,10 @@
5252
import javax.xml.bind.DatatypeConverter;
5353

5454
import com.marklogic.client.extensions.ResourceServices;
55+
import com.marklogic.client.query.ElementLocator;
56+
import com.marklogic.client.query.KeyLocator;
57+
import com.marklogic.client.query.KeyValueQueryDefinition;
58+
import com.marklogic.client.query.ValueLocator;
5559
import org.apache.http.HttpHost;
5660
import org.apache.http.HttpVersion;
5761
import org.apache.http.auth.params.AuthPNames;
@@ -2078,6 +2082,27 @@ void init() {
20782082
builder = (payloadMimetype != null) ?
20792083
webResource.type(payloadMimetype).accept(mimetype) :
20802084
webResource.accept(mimetype);
2085+
} else if (queryDef instanceof KeyValueQueryDefinition ) {
2086+
if (logger.isDebugEnabled())
2087+
logger.debug("Searching for keys/values");
2088+
2089+
Map<ValueLocator, String> pairs = ((KeyValueQueryDefinition) queryDef);
2090+
for (Map.Entry<ValueLocator, String> entry: pairs.entrySet()) {
2091+
ValueLocator loc = entry.getKey();
2092+
if (loc instanceof KeyLocator ) {
2093+
addEncodedParam(params, "key", ((KeyLocator) loc).getKey());
2094+
} else {
2095+
ElementLocator eloc = (ElementLocator) loc;
2096+
params.add("element", eloc.getElement().toString());
2097+
if (eloc.getAttribute() != null) {
2098+
params.add("attribute", eloc.getAttribute().toString());
2099+
}
2100+
}
2101+
addEncodedParam(params, "value", entry.getValue());
2102+
}
2103+
2104+
webResource = getConnection().path("keyvalue").queryParams(params);
2105+
builder = webResource.accept(mimetype);
20812106
} else if (queryDef instanceof CombinedQueryDefinition) {
20822107
structure = ((CombinedQueryDefinition) queryDef).serialize();
20832108

@@ -2121,7 +2146,9 @@ ClientResponse getResponse() {
21212146
}
21222147
}
21232148

2124-
if (queryDef instanceof StructuredQueryDefinition && ! (queryDef instanceof RawQueryDefinition)) {
2149+
if (queryDef instanceof KeyValueQueryDefinition) {
2150+
response = doGet(builder);
2151+
} else if (queryDef instanceof StructuredQueryDefinition && ! (queryDef instanceof RawQueryDefinition)) {
21252152
response = doPost(reqlog, builder, structure, true);
21262153
} else if (queryDef instanceof CombinedQueryDefinition) {
21272154
response = doPost(reqlog, builder, structure, true);

0 commit comments

Comments
 (0)