Coder Social home page Coder Social logo

marklogic / java-client-api Goto Github PK

View Code? Open in Web Editor NEW
56.0 38.0 75.0 39.3 MB

Java client for the MarkLogic enterprise NoSQL database

Home Page: https://docs.marklogic.com/guide/java

License: Apache License 2.0

Java 97.18% XSLT 0.13% Shell 0.02% XQuery 0.56% JavaScript 0.63% HTML 0.01% Kotlin 1.48%
marklogic java database nosql sparql xquery javascript json xml

java-client-api's Introduction

GitHub release GitHub last commit License Known Vulnerabilities

The MarkLogic Java Client

The MarkLogic Java Client makes it easy to write, read, delete, and find documents in a MarkLogic database. The client requires connecting to a MarkLogic REST API app server and is ideal for applications wishing to build upon the MarkLogic REST API.

The client supports the following core features of the MarkLogic database:

  • Write and read binary, JSON, text, and XML documents.
  • Query data structure trees, marked-up text, and all the hybrids in between those extremes.
  • Project values, tuples, and triples from hierarchical documents and aggregate over them.
  • Patch documents with partial updates.
  • Use Optimistic Locking to detect contention without creating locks on the server.
  • Execute ACID modifications so the change either succeeds or throws an exception.
  • Execute multi-statement transactions so changes to multiple documents succeed or fail together.
  • Call Data Services by means of a Java interface on the client for data functionality implemented by an endpoint on the server.

The client can be used in applications running on Java 8, 11, and 17. If you are using Java 11 or higher and intend to use JAXB, please see the section below for ensuring that the necessary dependencies are available in your application's classpath.

QuickStart

To use the client in your Maven project, include the following in your pom.xml file:

<dependency>
    <groupId>com.marklogic</groupId>
    <artifactId>marklogic-client-api</artifactId>
    <version>6.4.1</version>
</dependency>

To use the client in your Gradle project, include the following in your build.gradle file:

dependencies {
    implementation "com.marklogic:marklogic-client-api:6.4.1"
}

Next, read The Java API in Five Minutes to get started.

Full documentation is available at:

Including JAXB support

If you are using Java 11 or higher (including Java 17) and you wish to use JAXB with the client, you'll need to include JAXB API and implementation dependencies as those are no longer included in Java 11 and higher.

For Maven, include the following in your pom.xml file:

<dependency>
    <groupId>javax.xml.bind</groupId>
    <artifactId>jaxb-api</artifactId>
    <version>2.3.1</version>
</dependency>
<dependency>
    <groupId>org.glassfish.jaxb</groupId>
    <artifactId>jaxb-runtime</artifactId>
    <version>2.3.2</version>
</dependency>
<dependency>
    <groupId>org.glassfish.jaxb</groupId>
    <artifactId>jaxb-core</artifactId>
    <version>2.3.0.1</version>
</dependency>

For Gradle, include the following in your build.gradle file (this can be included in the same dependencies block as the one that includes the marklogic-client-api dependency):

dependencies {
    implementation "javax.xml.bind:jaxb-api:2.3.1"
    implementation "org.glassfish.jaxb:jaxb-runtime:2.3.2"
    implementation "org.glassfish.jaxb:jaxb-core:2.3.0.1"
}

You are free to use any implementation of JAXB that you wish, but you need to ensure that you're using a JAXB implementation that corresponds to the javax.xml.bind interfaces. JAXB 3.0 and 4.0 interfaces are packaged under jakarta.xml.bind, and the Java API does not yet depend on those interfaces.

Thus, you are free to include an implementation of JAXB 3.0 or 4.0 in your project for your own use; it will not affect the Java API. A caveat though is if you are trying to use different major versions of the same JAXB implementation library - such as org.glassfish.jaxb:jaxb-runtime - then you will run into an expected dependency conflict between the two versions of the library. This can be worked around by using a different implementation of JAXB 3.0 or JAXB 4.0 - for example:

dependencies {
    // JAXB 2 dependencies required by Java Client
    implementation "javax.xml.bind:jaxb-api:2.3.1"
    implementation "org.glassfish.jaxb:jaxb-runtime:2.3.2"
    implementation "org.glassfish.jaxb:jaxb-core:2.3.0.1"
    
    // JAXB 4 dependencies required by other application code
    implementation "jakarta.xml.bind:jakarta.xml.bind-api:4.0.0"
    implementation "com.sun.xml.bind:jaxb-impl:4.0.1"
}

The client will soon be updated to use the newer jakarta.xml.bind interfaces. Until then, the above approach or one similar to it will allow for both the old and new JAXB interfaces and implementations to exist together in the same classpath.

Support

The MarkLogic Java Client is maintained by MarkLogic Engineering and is made available under the Apache 2.0 license. It is designed for use in production applications with MarkLogic Server. Everyone is encouraged to file bug reports, feature requests, and pull requests through GitHub. This input is critical and will be carefully considered. However, we can’t promise a specific resolution or timeframe for any request. In addition, MarkLogic provides technical support for release tags of the Java Client to licensed customers under the terms outlined in the MarkLogic Technical Support Handbook. Customers with an active maintenance contract can sign up for MarkLogic Technical Support on our support portal.

java-client-api's People

Contributors

anu3990 avatar billfarber avatar dmcassel avatar ehennum avatar georgeajit avatar gvaidees avatar hansenmc avatar itsshivaverma avatar jmakeig avatar kcoleman-marklogic avatar kkanthet avatar kshitizmittal avatar llinggit avatar ndw avatar nikos avatar rjrudin avatar robsman avatar ryanjdew avatar sameerapriyathamtadikonda avatar sammefford avatar sravanr avatar srinathgit avatar vivekmuniyandi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

java-client-api's Issues

TestBulkWriteWithTransactions.java not reading docs from transaction

140 @test
141 public void testBulkWritewithTransactions() throws Exception {
142
143 int count=1;
144 Transaction t1 = client.openTransaction();
145 XMLDocumentManager docMgr = client.newXMLDocumentManager();
146 HashMap<String,String> map= new HashMap<String,String>();
147 DocumentWriteSet writeset =docMgr.newWriteSet();
148 for(int i =0;i<102;i++){
149
150 writeset.add(DIRECTORY+"foo"+i+".xml", new DOMHandle(getDocumentContent("This is so foo"+i)));
151 map.put(DIRECTORY+"foo"+i+".xml", convertXMLDocumentToString(getDocumentContent("This is so foo"+i)));
152 if(count%BATCH_SIZE == 0){
153 docMgr.write(writeset,t1);
154 writeset = docMgr.newWriteSet();
155 }
156 count++;
157 }
158 if(count%BATCH_SIZE > 0){
159 docMgr.write(writeset,t1);
160 }
161 String uris[] = new String[102];
162 for(int i =0;i<102;i++){
163 uris[i]=DIRECTORY+"foo"+i+".xml";
164 }
165
166 count=0;
167 DocumentPage page = docMgr.read(t1,uris);
168 DOMHandle dh = new DOMHandle();
169 while(page.hasNext()){
170 DocumentRecord rec = page.next();
171 validateRecord(rec,Format.XML);
172 rec.getContent(dh);
173 assertEquals("Comparing the content :",map.get(rec.getUri()),convertXMLDocumentToString(dh.get()));
174 count++;
175 }
176
177 assertEquals("document count", 102,count);
178 t1.rollback();
179 }

<failure message="java.lang.AssertionError: document count expected:&lt;102&gt; but was:&lt;0&gt;" type="java.lang.AssertionError">java.lang.AssertionError: document count expected:&lt;102&gt; but was:&lt;0&gt;
at org.junit.Assert.fail(Assert.java:88)
at org.junit.Assert.failNotEquals(Assert.java:743)
at org.junit.Assert.assertEquals(Assert.java:118)
at org.junit.Assert.assertEquals(Assert.java:555)
at com.marklogic.javaclient.TestBulkWriteWithTransactions.testBulkWritewithTransactions(TestBulkWriteWithTransactions.java:177)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.runTestClass(JUnitTestClassExecuter.java:86)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassExecuter.execute(JUnitTestClassExecuter.java:49)
at org.gradle.api.internal.tasks.testing.junit.JUnitTestClassProcessor.processTestClass(JUnitTestClassProcessor.java:69)
at org.gradle.api.internal.tasks.testing.SuiteTestClassProcessor.processTestClass(SuiteTestClassProcessor.java:48)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
at org.gradle.messaging.dispatch.ContextClassLoaderDispatch.dispatch(ContextClassLoaderDispatch.java:32)
at org.gradle.messaging.dispatch.ProxyDispatchAdapter$DispatchingInvocationHandler.invoke(ProxyDispatchAdapter.java:93)
at com.sun.proxy.$Proxy2.processTestClass(Unknown Source)
at org.gradle.api.internal.tasks.testing.worker.TestWorker.processTestClass(TestWorker.java:105)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:35)
at org.gradle.messaging.dispatch.ReflectionDispatch.dispatch(ReflectionDispatch.java:24)
at org.gradle.messaging.remote.internal.hub.MessageHub$Handler.run(MessageHub.java:355)
at org.gradle.internal.concurrent.DefaultExecutorFactory$StoppableExecutorImpl$1.run(DefaultExecutorFactory.java:64)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:744)

Show getServices() in javadocs

While the protected method getServices() is mentioned in the class-level javadoc, the method should ideally be visible in the table of methods. It is a key method for using and extending the ResourceManager. I'm not sure if we have any limitation here as we generate our javadoc with maven, but I'll look into it.

Bulkload with transactions hangs (throws SVC-EXTIME in server)

Here is the test case
@test
public void testBulkWritewithTransactions() throws Exception {

    int count=1;
    Transaction t1 = client.openTransaction();
    XMLDocumentManager docMgr = client.newXMLDocumentManager();
    HashMap<String,String> map= new HashMap<String,String>();
    DocumentWriteSet writeset =docMgr.newWriteSet();
    for(int i =0;i<12;i++){

        writeset.add(DIRECTORY+"foo"+i+".xml", new DOMHandle(getDocumentContent("This is so foo"+i)));
        map.put(DIRECTORY+"foo"+i+".xml", convertXMLDocumentToString(getDocumentContent("This is so foo"+i)));
        if(count%BATCH_SIZE == 0){
              docMgr.write(writeset,t1);
              writeset = docMgr.newWriteSet();
            }
          count++;
    }
    if(count%BATCH_SIZE > 0){
        docMgr.write(writeset,t1);
     }
     String uris[] = new String[12];
     for(int i =0;i<12;i++){
        uris[i]=DIRECTORY+"foo"+i+".xml";
      }
    // t1.commit();
      count=0;
      DocumentPage page = docMgr.read(t1,uris);
      DOMHandle dh = new DOMHandle();
      while(page.hasNext()){
            DocumentRecord rec = page.next();
            validateRecord(rec,Format.XML);
            rec.getContent(dh);
            assertEquals("Comparing the content :",map.get(rec.getUri()),convertXMLDocumentToString(dh.get()));
            count++;
      }

     assertEquals("document count", 102,count); 
}

I see the following when I enable Http wire logging

[DEBUG] ThreadSafeClientConnManager - Get connection: HttpRoute[{}->http://localhost:8011], timeout = 0
[DEBUG] ConnPoolByRoute - [HttpRoute[{}->http://localhost:8011]] total kept alive: 0, total issued: 0, total allocated: 0 out of 200
[DEBUG] ConnPoolByRoute - No free connections [HttpRoute[{}->http://localhost:8011]][null]
[DEBUG] ConnPoolByRoute - Available capacity: 100 out of 100 [HttpRoute[{}->http://localhost:8011]][null]
[DEBUG] ConnPoolByRoute - Creating new connection [HttpRoute[{}->http://localhost:8011]]
[DEBUG] DefaultClientConnectionOperator - Connecting to localhost/127.0.0.1:8011
[DEBUG] RequestAddCookies - CookieSpec selected: best-match
[DEBUG] RequestAuthCache - Auth cache not set in the context
[DEBUG] DefaultHttpClient - Attempt 1 to execute request
[DEBUG] DefaultClientConnection - Sending request: POST /v1/transactions HTTP/1.1
[DEBUG] wire - >> "POST /v1/transactions HTTP/1.1[\r][\n]"
[DEBUG] wire - >> "Content-Length: 0[\r][\n]"
[DEBUG] wire - >> "Host: localhost:8011[\r][\n]"
[DEBUG] wire - >> "Connection: Keep-Alive[\r][\n]"
[DEBUG] wire - >> "[\r][\n]"
[DEBUG] headers - >> POST /v1/transactions HTTP/1.1
[DEBUG] headers - >> Content-Length: 0
[DEBUG] headers - >> Host: localhost:8011
[DEBUG] headers - >> Connection: Keep-Alive
[DEBUG] wire - << "HTTP/1.1 401 Unauthorized[\r][\n]"
[DEBUG] wire - << "WWW-Authenticate: Digest realm="public", qop="auth", nonce="50d5b60b853b0bd2cd594ed63a6df144", opaque="a356e486d94715d7"[\r][\n]"
[DEBUG] wire - << "Content-type: application/json[\r][\n]"
[DEBUG] wire - << "Server: MarkLogic[\r][\n]"
[DEBUG] wire - << "Content-Length: 103[\r][\n]"
[DEBUG] wire - << "Connection: Keep-Alive[\r][\n]"
[DEBUG] wire - << "Keep-Alive: timeout=5[\r][\n]"
[DEBUG] wire - << "[\r][\n]"
[DEBUG] DefaultClientConnection - Receiving response: HTTP/1.1 401 Unauthorized
[DEBUG] headers - << HTTP/1.1 401 Unauthorized
[DEBUG] headers - << WWW-Authenticate: Digest realm="public", qop="auth", nonce="50d5b60b853b0bd2cd594ed63a6df144", opaque="a356e486d94715d7"
[DEBUG] headers - << Content-type: application/json
[DEBUG] headers - << Server: MarkLogic
[DEBUG] headers - << Content-Length: 103
[DEBUG] headers - << Connection: Keep-Alive
[DEBUG] headers - << Keep-Alive: timeout=5
[DEBUG] DefaultHttpClient - Connection can be kept alive for 5000 MILLISECONDS
[DEBUG] DefaultHttpClient - Target requested authentication
[DEBUG] DefaultTargetAuthenticationHandler - Authentication schemes in the order of preference: [negotiate, NTLM, Digest, Basic]
[DEBUG] DefaultTargetAuthenticationHandler - Challenge for negotiate authentication scheme not available
[DEBUG] DefaultTargetAuthenticationHandler - Challenge for NTLM authentication scheme not available
[DEBUG] DefaultTargetAuthenticationHandler - Digest authentication scheme selected
[DEBUG] DefaultHttpClient - Authorization challenge processed
[DEBUG] DefaultHttpClient - Authentication scope: DIGEST 'public'@localhost:8011
[DEBUG] DefaultHttpClient - Credentials not found
[DEBUG] wire - << "{"error":{"status-code":"401", "status":"Failed Auth", "message-code":"", "message":"Unauthenticated"}}"
[DEBUG] ThreadSafeClientConnManager - Released connection is reusable.
[DEBUG] ConnPoolByRoute - Releasing connection [HttpRoute[{}->http://localhost:8011]][null]
[DEBUG] ConnPoolByRoute - Pooling connection [HttpRoute[{}->http://localhost:8011]][null]; keep alive for 5000 MILLISECONDS
[DEBUG] ConnPoolByRoute - Notifying no-one, there are no waiting threads
[DEBUG] ThreadSafeClientConnManager - Get connection: HttpRoute[{}->http://localhost:8011], timeout = 0
[DEBUG] ConnPoolByRoute - [HttpRoute[{}->http://localhost:8011]] total kept alive: 1, total issued: 0, total allocated: 1 out of 200
[DEBUG] ConnPoolByRoute - Getting free connection [HttpRoute[{}->http://localhost:8011]][null]
[DEBUG] DefaultHttpClient - Stale connection check
[DEBUG] RequestAddCookies - CookieSpec selected: best-match
[DEBUG] RequestAuthCache - Auth cache not set in the context
[DEBUG] DefaultHttpClient - Attempt 1 to execute request
[DEBUG] DefaultClientConnection - Sending request: POST /v1/transactions HTTP/1.1
[DEBUG] wire - >> "POST /v1/transactions HTTP/1.1[\r][\n]"
[DEBUG] wire - >> "Authorization: Digest username="usr1",realm="public",nonce="50d5b60b853b0bd2cd594ed63a6df144",opaque="a356e486d94715d7",qop=auth,uri="/v1/transactions",cnonce="a65dfbd6",nc=00000001,response="506dc2990d3be9b67c374580cde31d4b"[\r][\n]"
[DEBUG] wire - >> "Content-Length: 0[\r][\n]"
[DEBUG] wire - >> "Host: localhost:8011[\r][\n]"
[DEBUG] wire - >> "Connection: Keep-Alive[\r][\n]"
[DEBUG] wire - >> "[\r][\n]"
[DEBUG] headers - >> POST /v1/transactions HTTP/1.1
[DEBUG] headers - >> Authorization: Digest username="usr1",realm="public",nonce="50d5b60b853b0bd2cd594ed63a6df144",opaque="a356e486d94715d7",qop=auth,uri="/v1/transactions",cnonce="a65dfbd6",nc=00000001,response="506dc2990d3be9b67c374580cde31d4b"
[DEBUG] headers - >> Content-Length: 0
[DEBUG] headers - >> Host: localhost:8011
[DEBUG] headers - >> Connection: Keep-Alive
[DEBUG] wire - << "HTTP/1.1 303 See Created Transaction[\r][\n]"
[DEBUG] wire - << "Set-Cookie: HostId=18106243054103630114[\r][\n]"
[DEBUG] wire - << "Location: /v1/transactions/18106243054103630114_15536520426208774143[\r][\n]"
[DEBUG] wire - << "Server: MarkLogic[\r][\n]"
[DEBUG] wire - << "Content-Length: 0[\r][\n]"
[DEBUG] wire - << "Connection: Keep-Alive[\r][\n]"
[DEBUG] wire - << "Keep-Alive: timeout=5[\r][\n]"
[DEBUG] wire - << "[\r][\n]"
[DEBUG] DefaultClientConnection - Receiving response: HTTP/1.1 303 See Created Transaction
[DEBUG] headers - << HTTP/1.1 303 See Created Transaction
[DEBUG] headers - << Set-Cookie: HostId=18106243054103630114
[DEBUG] headers - << Location: /v1/transactions/18106243054103630114_15536520426208774143
[DEBUG] headers - << Server: MarkLogic
[DEBUG] headers - << Content-Length: 0
[DEBUG] headers - << Connection: Keep-Alive
[DEBUG] headers - << Keep-Alive: timeout=5
[DEBUG] ResponseProcessCookies - Cookie accepted: "[version: 0][name: HostId][value: 18106243054103630114][domain: localhost][path: /v1][expiry: null]".
[DEBUG] DefaultHttpClient - Connection can be kept alive for 5000 MILLISECONDS
[DEBUG] ThreadSafeClientConnManager - Released connection is reusable.
[DEBUG] ConnPoolByRoute - Releasing connection [HttpRoute[{}->http://localhost:8011]][null]
[DEBUG] ConnPoolByRoute - Pooling connection [HttpRoute[{}->http://localhost:8011]][null]; keep alive for 5000 MILLISECONDS
[DEBUG] ConnPoolByRoute - Notifying no-one, there are no waiting threads
[DEBUG] ThreadSafeClientConnManager - Get connection: HttpRoute[{}->http://localhost:8011], timeout = 0
[DEBUG] ConnPoolByRoute - [HttpRoute[{}->http://localhost:8011]] total kept alive: 1, total issued: 0, total allocated: 1 out of 200
[DEBUG] ConnPoolByRoute - Getting free connection [HttpRoute[{}->http://localhost:8011]][null]
[DEBUG] DefaultHttpClient - Stale connection check
[DEBUG] RequestAddCookies - CookieSpec selected: best-match
[DEBUG] RequestAddCookies - Cookie [version: 0][name: HostId][value: 18106243054103630114][domain: localhost][path: /v1][expiry: null] match [localhost:8011/v1/documents]
[DEBUG] RequestAuthCache - Auth cache not set in the context
[DEBUG] DefaultHttpClient - Attempt 1 to execute request
[DEBUG] DefaultClientConnection - Sending request: POST /v1/documents?txid=18106243054103630114_15536520426208774143 HTTP/1.1
[DEBUG] wire - >> "POST /v1/documents?txid=18106243054103630114_15536520426208774143 HTTP/1.1[\r][\n]"
[DEBUG] wire - >> "Content-Type: multipart/mixed; boundary=Boundary_1_1078351181_1406165984811[\r][\n]"
[DEBUG] wire - >> "Authorization: Digest username="usr1",realm="public",nonce="50d5b60b853b0bd2cd594ed63a6df144",opaque="a356e486d94715d7",qop=auth,uri="/v1/documents",cnonce="913ca9a3",nc=00000002,response="7a88727f8b4aa140395b4f39d4ee7e4a"[\r][\n]"
[DEBUG] wire - >> "Transfer-Encoding: chunked[\r][\n]"
[DEBUG] wire - >> "Host: localhost:8011[\r][\n]"
[DEBUG] wire - >> "Connection: Keep-Alive[\r][\n]"
[DEBUG] wire - >> "Cookie: HostId=18106243054103630114[\r][\n]"
[DEBUG] wire - >> "Cookie2: $Version=1[\r][\n]"
[DEBUG] wire - >> "[\r][\n]"
[DEBUG] headers - >> POST /v1/documents?txid=18106243054103630114_15536520426208774143 HTTP/1.1
[DEBUG] headers - >> Content-Type: multipart/mixed; boundary=Boundary_1_1078351181_1406165984811
[DEBUG] headers - >> Authorization: Digest username="usr1",realm="public",nonce="50d5b60b853b0bd2cd594ed63a6df144",opaque="a356e486d94715d7",qop=auth,uri="/v1/documents",cnonce="913ca9a3",nc=00000002,response="7a88727f8b4aa140395b4f39d4ee7e4a"
[DEBUG] headers - >> Transfer-Encoding: chunked
[DEBUG] headers - >> Host: localhost:8011
[DEBUG] headers - >> Connection: Keep-Alive
[DEBUG] headers - >> Cookie: HostId=18106243054103630114
[DEBUG] headers - >> Cookie2: $Version=1
[DEBUG] wire - >> "8e[\r][\n]"
[DEBUG] wire - >> "--Boundary_1_1078351181_1406165984811[\r][\n]"
[DEBUG] wire - >> "Content-Disposition: attachment; filename="/bulkTransacton/foo0.xml"[\r][\n]"
[DEBUG] wire - >> "Content-Type: application/xml[\r][\n]"
[DEBUG] wire - >> "[\r][\n]"
[DEBUG] wire - >> "[\r][\n]"
[DEBUG] wire - >> "41[\r][\n]"
[DEBUG] wire - >> "[\n]"
[DEBUG] wire - >> "This is so foo0"
[DEBUG] wire - >> "[\r][\n]"
[DEBUG] wire - >> "90[\r][\n]"
[DEBUG] wire - >> "[\r][\n]"
[DEBUG] wire - >> "--Boundary_1_1078351181_1406165984811[\r][\n]"
[DEBUG] wire - >> "Content-Disposition: attachment; filename="/bulkTransacton/foo1.xml"[\r][\n]"
[DEBUG] wire - >> "Content-Type: application/xml[\r][\n]"
[DEBUG] wire - >> "[\r][\n]"
[DEBUG] wire - >> "[\r][\n]"
[DEBUG] wire - >> "41[\r][\n]"
[DEBUG] wire - >> "[\n]"
[DEBUG] wire - >> "This is so foo1"
[DEBUG] wire - >> "[\r][\n]"
[DEBUG] wire - >> "90[\r][\n]"
[DEBUG] wire - >> "[\r][\n]"
[DEBUG] wire - >> "--Boundary_1_1078351181_1406165984811[\r][\n]"
[DEBUG] wire - >> "Content-Disposition: attachment; filename="/bulkTransacton/foo2.xml"[\r][\n]"
[DEBUG] wire - >> "Content-Type: application/xml[\r][\n]"
[DEBUG] wire - >> "[\r][\n]"
[DEBUG] wire - >> "[\r][\n]"
[DEBUG] wire - >> "41[\r][\n]"
[DEBUG] wire - >> "[\n]"
[DEBUG] wire - >> "This is so foo2"
[DEBUG] wire - >> "[\r][\n]"
[DEBUG] wire - >> "90[\r][\n]"
[DEBUG] wire - >> "[\r][\n]"
[DEBUG] wire - >> "--Boundary_1_1078351181_1406165984811[\r][\n]"
[DEBUG] wire - >> "Content-Disposition: attachment; filename="/bulkTransacton/foo3.xml"[\r][\n]"
[DEBUG] wire - >> "Content-Type: application/xml[\r][\n]"
[DEBUG] wire - >> "[\r][\n]"
[DEBUG] wire - >> "[\r][\n]"
[DEBUG] wire - >> "41[\r][\n]"
[DEBUG] wire - >> "[\n]"
[DEBUG] wire - >> "This is so foo3"
[DEBUG] wire - >> "[\r][\n]"
[DEBUG] wire - >> "90[\r][\n]"
[DEBUG] wire - >> "[\r][\n]"
[DEBUG] wire - >> "--Boundary_1_1078351181_1406165984811[\r][\n]"
[DEBUG] wire - >> "Content-Disposition: attachment; filename="/bulkTransacton/foo4.xml"[\r][\n]"
[DEBUG] wire - >> "Content-Type: application/xml[\r][\n]"
[DEBUG] wire - >> "[\r][\n]"
[DEBUG] wire - >> "[\r][\n]"
[DEBUG] wire - >> "41[\r][\n]"
[DEBUG] wire - >> "[\n]"
[DEBUG] wire - >> "This is so foo4"
[DEBUG] wire - >> "[\r][\n]"
[DEBUG] wire - >> "90[\r][\n]"
[DEBUG] wire - >> "[\r][\n]"
[DEBUG] wire - >> "--Boundary_1_1078351181_1406165984811[\r][\n]"
[DEBUG] wire - >> "Content-Disposition: attachment; filename="/bulkTransacton/foo5.xml"[\r][\n]"
[DEBUG] wire - >> "Content-Type: application/xml[\r][\n]"
[DEBUG] wire - >> "[\r][\n]"
[DEBUG] wire - >> "[\r][\n]"
[DEBUG] wire - >> "41[\r][\n]"
[DEBUG] wire - >> "[\n]"
[DEBUG] wire - >> "This is so foo5"
[DEBUG] wire - >> "[\r][\n]"
[DEBUG] wire - >> "90[\r][\n]"
[DEBUG] wire - >> "[\r][\n]"
[DEBUG] wire - >> "--Boundary_1_1078351181_1406165984811[\r][\n]"
[DEBUG] wire - >> "Content-Disposition: attachment; filename="/bulkTransacton/foo6.xml"[\r][\n]"
[DEBUG] wire - >> "Content-Type: application/xml[\r][\n]"
[DEBUG] wire - >> "[\r][\n]"
[DEBUG] wire - >> "[\r][\n]"
[DEBUG] wire - >> "41[\r][\n]"
[DEBUG] wire - >> "[\n]"
[DEBUG] wire - >> "This is so foo6"
[DEBUG] wire - >> "[\r][\n]"
[DEBUG] wire - >> "90[\r][\n]"
[DEBUG] wire - >> "[\r][\n]"
[DEBUG] wire - >> "--Boundary_1_1078351181_1406165984811[\r][\n]"
[DEBUG] wire - >> "Content-Disposition: attachment; filename="/bulkTransacton/foo7.xml"[\r][\n]"
[DEBUG] wire - >> "Content-Type: application/xml[\r][\n]"
[DEBUG] wire - >> "[\r][\n]"
[DEBUG] wire - >> "[\r][\n]"
[DEBUG] wire - >> "41[\r][\n]"
[DEBUG] wire - >> "[\n]"
[DEBUG] wire - >> "This is so foo7"
[DEBUG] wire - >> "[\r][\n]"
[DEBUG] wire - >> "90[\r][\n]"
[DEBUG] wire - >> "[\r][\n]"
[DEBUG] wire - >> "--Boundary_1_1078351181_1406165984811[\r][\n]"
[DEBUG] wire - >> "Content-Disposition: attachment; filename="/bulkTransacton/foo8.xml"[\r][\n]"
[DEBUG] wire - >> "Content-Type: application/xml[\r][\n]"
[DEBUG] wire - >> "[\r][\n]"
[DEBUG] wire - >> "[\r][\n]"
[DEBUG] wire - >> "41[\r][\n]"
[DEBUG] wire - >> "[\n]"
[DEBUG] wire - >> "This is so foo8"
[DEBUG] wire - >> "[\r][\n]"
[DEBUG] wire - >> "90[\r][\n]"
[DEBUG] wire - >> "[\r][\n]"
[DEBUG] wire - >> "--Boundary_1_1078351181_1406165984811[\r][\n]"
[DEBUG] wire - >> "Content-Disposition: attachment; filename="/bulkTransacton/foo9.xml"[\r][\n]"
[DEBUG] wire - >> "Content-Type: application/xml[\r][\n]"
[DEBUG] wire - >> "[\r][\n]"
[DEBUG] wire - >> "[\r][\n]"
[DEBUG] wire - >> "41[\r][\n]"
[DEBUG] wire - >> "[\n]"
[DEBUG] wire - >> "This is so foo9"
[DEBUG] wire - >> "[\r][\n]"
[DEBUG] wire - >> "2b[\r][\n]"
[DEBUG] wire - >> "[\r][\n]"
[DEBUG] wire - >> "--Boundary_1_1078351181_1406165984811--[\r][\n]"
[DEBUG] wire - >> "[\r][\n]"
[DEBUG] wire - >> "0[\r][\n]"
[DEBUG] wire - >> "[\r][\n]"
[DEBUG] wire - << "HTTP/1.1 200 Bulk Change Written[\r][\n]"
[DEBUG] wire - << "Set-Cookie: HostId=18106243054103630114[\r][\n]"
[DEBUG] wire - << "vnd.marklogic.document-format: xml[\r][\n]"
[DEBUG] wire - << "Content-type: application/xml; charset=utf-8[\r][\n]"
[DEBUG] wire - << "Server: MarkLogic[\r][\n]"
[DEBUG] wire - << "Content-Length: 2087[\r][\n]"
[DEBUG] wire - << "Connection: Keep-Alive[\r][\n]"
[DEBUG] wire - << "Keep-Alive: timeout=5[\r][\n]"
[DEBUG] wire - << "[\r][\n]"
[DEBUG] DefaultClientConnection - Receiving response: HTTP/1.1 200 Bulk Change Written
[DEBUG] headers - << HTTP/1.1 200 Bulk Change Written
[DEBUG] headers - << Set-Cookie: HostId=18106243054103630114
[DEBUG] headers - << vnd.marklogic.document-format: xml
[DEBUG] headers - << Content-type: application/xml; charset=utf-8
[DEBUG] headers - << Server: MarkLogic
[DEBUG] headers - << Content-Length: 2087
[DEBUG] headers - << Connection: Keep-Alive
[DEBUG] headers - << Keep-Alive: timeout=5
[DEBUG] ResponseProcessCookies - Cookie accepted: "[version: 0][name: HostId][value: 18106243054103630114][domain: localhost][path: /v1][expiry: null]".
[DEBUG] DefaultHttpClient - Connection can be kept alive for 5000 MILLISECONDS
[DEBUG] wire - << "<rapi:documents xmlns:rapi="http://marklogic.com/rest-api">rapi:documentrapi:uri/bulkTransacton/foo0.xml/rapi:urirapi:categorymetadata/rapi:categoryrapi:categorycontent/rapi:categoryrapi:mime-typeapplication/xml/rapi:mime-type/rapi:documentrapi:documentrapi:uri/bulkTransacton/foo1.xml/rapi:urirapi:categorymetadata/rapi:categoryrapi:categorycontent/rapi:categoryrapi:mime-typeapplication/xml/rapi:mime-type/rapi:documentrapi:documentrapi:uri/bulkTransacton/foo2.xml/rapi:urirapi:categorymetadata/rapi:categoryrapi:categorycontent/rapi:categoryrapi:mime-typeapplication/xml/rapi:mime-type/rapi:documentrapi:documentrapi:uri/bulkTransacton/foo3.xml/rapi:urirapi:categorymetadata/rapi:categoryrapi:categorycontent/rapi:categoryrapi:mime-typeapplication/xml/rapi:mime-type/rapi:documentrapi:documentrapi:uri/bulkTransacton/foo4.xml/rapi:urirapi:categorymetadata/rapi:categoryrapi:categorycontent/rapi:categoryrapi:mime-typeapplication/xml/rapi:mime-type/rapi:documentrapi:documentrapi:uri/bulkTransacton/foo5.xml/rapi:urirapi:categorymetadata/rapi:categoryrapi:categorycontent/rapi:categoryrapi:mime-typeapplication/xml/rapi:mime-type/rapi:documentrapi:documentrapi:uri/bulkTransacton/foo6.xml/rapi:urirapi:categorymetadata/rapi:categoryrapi:categorycontent/rapi:categoryrapi:mime-typeapplication/xml/rapi:mime-type/rapi:documentrapi:documentrapi:uri/bulkTransacton/foo7.xml/rapi:urirapi:categorymetadata/rapi:categoryrapi:categorycontent/rapi:categoryrapi:mime-typeapplication/xml/rapi:mime-type/rapi:documentrapi:documentrapi:uri/bulkTransacton/foo8.xml/rapi:urirapi:categorymetadata/rapi:categoryrapi:categorycontent/rapi:categoryrapi:mime-typeapplication/xml/rapi:mime-type/rapi:documentrapi:documentrapi:uri/bulkTransacton/foo9.xml/rapi:urirapi:categorymetadata/rapi:categoryrapi:categorycontent/rapi:categoryrapi:mime-typeapplication/xml/rapi:mime-type/rapi:document/rapi:documents[\n]"
[DEBUG] ThreadSafeClientConnManager - Released connection is reusable.
[DEBUG] ConnPoolByRoute - Releasing connection [HttpRoute[{}->http://localhost:8011]][null]
[DEBUG] ConnPoolByRoute - Pooling connection [HttpRoute[{}->http://localhost:8011]][null]; keep alive for 5000 MILLISECONDS
[DEBUG] ConnPoolByRoute - Notifying no-one, there are no waiting threads
[DEBUG] ThreadSafeClientConnManager - Get connection: HttpRoute[{}->http://localhost:8011], timeout = 0
[DEBUG] ConnPoolByRoute - [HttpRoute[{}->http://localhost:8011]] total kept alive: 1, total issued: 0, total allocated: 1 out of 200
[DEBUG] ConnPoolByRoute - Getting free connection [HttpRoute[{}->http://localhost:8011]][null]
[DEBUG] DefaultHttpClient - Stale connection check
[DEBUG] RequestAddCookies - CookieSpec selected: best-match
[DEBUG] RequestAddCookies - Cookie [version: 0][name: HostId][value: 18106243054103630114][domain: localhost][path: /v1][expiry: null] match [localhost:8011/v1/documents]
[DEBUG] RequestAuthCache - Auth cache not set in the context
[DEBUG] DefaultHttpClient - Attempt 1 to execute request
[DEBUG] DefaultClientConnection - Sending request: POST /v1/documents?txid=18106243054103630114_15536520426208774143 HTTP/1.1
[DEBUG] wire - >> "POST /v1/documents?txid=18106243054103630114_15536520426208774143 HTTP/1.1[\r][\n]"
[DEBUG] wire - >> "Content-Type: multipart/mixed; boundary=Boundary_2_232517457_1406165986549[\r][\n]"
[DEBUG] wire - >> "Authorization: Digest username="usr1",realm="public",nonce="50d5b60b853b0bd2cd594ed63a6df144",opaque="a356e486d94715d7",qop=auth,uri="/v1/documents",cnonce="ddbf4f09",nc=00000003,response="897d3c3cf7f277d8bd6a80f4f3eace8b"[\r][\n]"
[DEBUG] wire - >> "Transfer-Encoding: chunked[\r][\n]"
[DEBUG] wire - >> "Host: localhost:8011[\r][\n]"
[DEBUG] wire - >> "Connection: Keep-Alive[\r][\n]"
[DEBUG] wire - >> "Cookie: HostId=18106243054103630114[\r][\n]"
[DEBUG] wire - >> "Cookie2: $Version=1[\r][\n]"
[DEBUG] wire - >> "[\r][\n]"
[DEBUG] headers - >> POST /v1/documents?txid=18106243054103630114_15536520426208774143 HTTP/1.1
[DEBUG] headers - >> Content-Type: multipart/mixed; boundary=Boundary_2_232517457_1406165986549
[DEBUG] headers - >> Authorization: Digest username="usr1",realm="public",nonce="50d5b60b853b0bd2cd594ed63a6df144",opaque="a356e486d94715d7",qop=auth,uri="/v1/documents",cnonce="ddbf4f09",nc=00000003,response="897d3c3cf7f277d8bd6a80f4f3eace8b"
[DEBUG] headers - >> Transfer-Encoding: chunked
[DEBUG] headers - >> Host: localhost:8011
[DEBUG] headers - >> Connection: Keep-Alive
[DEBUG] headers - >> Cookie: HostId=18106243054103630114
[DEBUG] headers - >> Cookie2: $Version=1
[DEBUG] wire - >> "8e[\r][\n]"
[DEBUG] wire - >> "--Boundary_2_232517457_1406165986549[\r][\n]"
[DEBUG] wire - >> "Content-Disposition: attachment; filename="/bulkTransacton/foo10.xml"[\r][\n]"
[DEBUG] wire - >> "Content-Type: application/xml[\r][\n]"
[DEBUG] wire - >> "[\r][\n]"
[DEBUG] wire - >> "[\r][\n]"
[DEBUG] wire - >> "42[\r][\n]"
[DEBUG] wire - >> "[\n]"
[DEBUG] wire - >> "This is so foo10"
[DEBUG] wire - >> "[\r][\n]"
[DEBUG] wire - >> "90[\r][\n]"
[DEBUG] wire - >> "[\r][\n]"
[DEBUG] wire - >> "--Boundary_2_232517457_1406165986549[\r][\n]"
[DEBUG] wire - >> "Content-Disposition: attachment; filename="/bulkTransacton/foo11.xml"[\r][\n]"
[DEBUG] wire - >> "Content-Type: application/xml[\r][\n]"
[DEBUG] wire - >> "[\r][\n]"
[DEBUG] wire - >> "[\r][\n]"
[DEBUG] wire - >> "42[\r][\n]"
[DEBUG] wire - >> "[\n]"
[DEBUG] wire - >> "This is so foo11"
[DEBUG] wire - >> "[\r][\n]"
[DEBUG] wire - >> "2a[\r][\n]"
[DEBUG] wire - >> "[\r][\n]"
[DEBUG] wire - >> "--Boundary_2_232517457_1406165986549--[\r][\n]"
[DEBUG] wire - >> "[\r][\n]"
[DEBUG] wire - >> "0[\r][\n]"
[DEBUG] wire - >> "[\r][\n]"
[DEBUG] wire - << "HTTP/1.1 200 Bulk Change Written[\r][\n]"
[DEBUG] wire - << "Set-Cookie: HostId=18106243054103630114[\r][\n]"
[DEBUG] wire - << "vnd.marklogic.document-format: xml[\r][\n]"
[DEBUG] wire - << "Content-type: application/xml; charset=utf-8[\r][\n]"
[DEBUG] wire - << "Server: MarkLogic[\r][\n]"
[DEBUG] wire - << "Content-Length: 481[\r][\n]"
[DEBUG] wire - << "Connection: Keep-Alive[\r][\n]"
[DEBUG] wire - << "Keep-Alive: timeout=5[\r][\n]"
[DEBUG] wire - << "[\r][\n]"
[DEBUG] DefaultClientConnection - Receiving response: HTTP/1.1 200 Bulk Change Written
[DEBUG] headers - << HTTP/1.1 200 Bulk Change Written
[DEBUG] headers - << Set-Cookie: HostId=18106243054103630114
[DEBUG] headers - << vnd.marklogic.document-format: xml
[DEBUG] headers - << Content-type: application/xml; charset=utf-8
[DEBUG] headers - << Server: MarkLogic
[DEBUG] headers - << Content-Length: 481
[DEBUG] headers - << Connection: Keep-Alive
[DEBUG] headers - << Keep-Alive: timeout=5
[DEBUG] ResponseProcessCookies - Cookie accepted: "[version: 0][name: HostId][value: 18106243054103630114][domain: localhost][path: /v1][expiry: null]".
[DEBUG] DefaultHttpClient - Connection can be kept alive for 5000 MILLISECONDS
[DEBUG] wire - << "<rapi:documents xmlns:rapi="http://marklogic.com/rest-api">rapi:documentrapi:uri/bulkTransacton/foo10.xml/rapi:urirapi:categorymetadata/rapi:categoryrapi:categorycontent/rapi:categoryrapi:mime-typeapplication/xml/rapi:mime-type/rapi:documentrapi:documentrapi:uri/bulkTransacton/foo11.xml/rapi:urirapi:categorymetadata/rapi:categoryrapi:categorycontent/rapi:categoryrapi:mime-typeapplication/xml/rapi:mime-type/rapi:document/rapi:documents[\n]"
[DEBUG] ThreadSafeClientConnManager - Released connection is reusable.
[DEBUG] ConnPoolByRoute - Releasing connection [HttpRoute[{}->http://localhost:8011]][null]
[DEBUG] ConnPoolByRoute - Pooling connection [HttpRoute[{}->http://localhost:8011]][null]; keep alive for 5000 MILLISECONDS
[DEBUG] ConnPoolByRoute - Notifying no-one, there are no waiting threads
[DEBUG] ThreadSafeClientConnManager - Get connection: HttpRoute[{}->http://localhost:8011], timeout = 0
[DEBUG] ConnPoolByRoute - [HttpRoute[{}->http://localhost:8011]] total kept alive: 1, total issued: 0, total allocated: 1 out of 200
[DEBUG] ConnPoolByRoute - Getting free connection [HttpRoute[{}->http://localhost:8011]][null]
[DEBUG] DefaultHttpClient - Stale connection check
[DEBUG] RequestAddCookies - CookieSpec selected: best-match
[DEBUG] RequestAddCookies - Cookie [version: 0][name: HostId][value: 18106243054103630114][domain: localhost][path: /v1][expiry: null] match [localhost:8011/v1/documents]
[DEBUG] RequestAuthCache - Auth cache not set in the context
[DEBUG] DefaultHttpClient - Attempt 1 to execute request
[DEBUG] DefaultClientConnection - Sending request: GET /v1/documents?category=content&format=xml&uri=/bulkTransacton/foo0.xml&uri=/bulkTransacton/foo1.xml&uri=/bulkTransacton/foo2.xml&uri=/bulkTransacton/foo3.xml&uri=/bulkTransacton/foo4.xml&uri=/bulkTransacton/foo5.xml&uri=/bulkTransacton/foo6.xml&uri=/bulkTransacton/foo7.xml&uri=/bulkTransacton/foo8.xml&uri=/bulkTransacton/foo9.xml&uri=/bulkTransacton/foo10.xml&uri=/bulkTransacton/foo11.xml HTTP/1.1
[DEBUG] wire - >> "GET /v1/documents?category=content&format=xml&uri=/bulkTransacton/foo0.xml&uri=/bulkTransacton/foo1.xml&uri=/bulkTransacton/foo2.xml&uri=/bulkTransacton/foo3.xml&uri=/bulkTransacton/foo4.xml&uri=/bulkTransacton/foo5.xml&uri=/bulkTransacton/foo6.xml&uri=/bulkTransacton/foo7.xml&uri=/bulkTransacton/foo8.xml&uri=/bulkTransacton/foo9.xml&uri=/bulkTransacton/foo10.xml&uri=/bulkTransacton/foo11.xml HTTP/1.1[\r][\n]"
[DEBUG] wire - >> "Accept: multipart/mixed; boundary=Boundary_3_187965576_1406165986593[\r][\n]"
[DEBUG] wire - >> "Authorization: Digest username="usr1",realm="public",nonce="50d5b60b853b0bd2cd594ed63a6df144",opaque="a356e486d94715d7",qop=auth,uri="/v1/documents",cnonce="d226a6da",nc=00000004,response="79f7381d4bedecf1c05e1119f231c6a1"[\r][\n]"
[DEBUG] wire - >> "Host: localhost:8011[\r][\n]"
[DEBUG] wire - >> "Connection: Keep-Alive[\r][\n]"
[DEBUG] wire - >> "Cookie: HostId=18106243054103630114[\r][\n]"
[DEBUG] wire - >> "Cookie2: $Version=1[\r][\n]"
[DEBUG] wire - >> "[\r][\n]"
[DEBUG] headers - >> GET /v1/documents?category=content&format=xml&uri=/bulkTransacton/foo0.xml&uri=/bulkTransacton/foo1.xml&uri=/bulkTransacton/foo2.xml&uri=/bulkTransacton/foo3.xml&uri=/bulkTransacton/foo4.xml&uri=/bulkTransacton/foo5.xml&uri=/bulkTransacton/foo6.xml&uri=/bulkTransacton/foo7.xml&uri=/bulkTransacton/foo8.xml&uri=/bulkTransacton/foo9.xml&uri=/bulkTransacton/foo10.xml&uri=/bulkTransacton/foo11.xml HTTP/1.1
[DEBUG] headers - >> Accept: multipart/mixed; boundary=Boundary_3_187965576_1406165986593
[DEBUG] headers - >> Authorization: Digest username="usr1",realm="public",nonce="50d5b60b853b0bd2cd594ed63a6df144",opaque="a356e486d94715d7",qop=auth,uri="/v1/documents",cnonce="d226a6da",nc=00000004,response="79f7381d4bedecf1c05e1119f231c6a1"
[DEBUG] headers - >> Host: localhost:8011
[DEBUG] headers - >> Connection: Keep-Alive
[DEBUG] headers - >> Cookie: HostId=18106243054103630114
[DEBUG] headers - >> Cookie2: $Version=1
[DEBUG] wire - << "HTTP/1.1 200 OK[\r][\n]"
[DEBUG] wire - << "Content-type: multipart/mixed; boundary=Boundary_3_187965576_1406165986593[\r][\n]"
[DEBUG] wire - << "Server: MarkLogic[\r][\n]"
[DEBUG] wire - << "Content-Length: 0[\r][\n]"
[DEBUG] wire - << "Connection: Keep-Alive[\r][\n]"
[DEBUG] wire - << "Keep-Alive: timeout=5[\r][\n]"
[DEBUG] wire - << "[\r][\n]"
[DEBUG] DefaultClientConnection - Receiving response: HTTP/1.1 200 OK
[DEBUG] headers - << HTTP/1.1 200 OK
[DEBUG] headers - << Content-type: multipart/mixed; boundary=Boundary_3_187965576_1406165986593
[DEBUG] headers - << Server: MarkLogic
[DEBUG] headers - << Content-Length: 0
[DEBUG] headers - << Connection: Keep-Alive
[DEBUG] headers - << Keep-Alive: timeout=5
[DEBUG] DefaultHttpClient - Connection can be kept alive for 5000 MILLISECONDS
[DEBUG] ThreadSafeClientConnManager - Released connection is reusable.
[DEBUG] ConnPoolByRoute - Releasing connection [HttpRoute[{}->http://localhost:8011]][null]
[DEBUG] ConnPoolByRoute - Pooling connection [HttpRoute[{}->http://localhost:8011]][null]; keep alive for 5000 MILLISECONDS
[DEBUG] ConnPoolByRoute - Notifying no-one, there are no waiting threads

Adding metadata to a single document in bulk writes is adding it to every document.

I am expecting the below method will add metadata to only to the specified uri that is provided in first argument
public DocumentWriteSet add(String uri, DocumentMetadataWriteHandle metadataHandle, W contentHandle);
but it seems like it is adding the metadata info to every document which is part of that batch.

here is my example which is failing in my case
String docId[] = {"/foo/test/myFoo1.txt","/foo/test/myFoo2.txt","/foo/test/myFoo3.txt"};

    TextDocumentManager docMgr = client.newTextDocumentManager();

    DocumentWriteSet writeset =docMgr.newWriteSet();
 // put metadata
    DocumentMetadataHandle mh = setMetadata();

    writeset.add(docId[0],mh, new StringHandle().with("This is so foo1"));
    writeset.add(docId[1], new StringHandle().with("This is so foo2"));
    writeset.add(docId[2], new StringHandle().with("This is so foo3"));
    docMgr.write(writeset);
    DocumentPage page = docMgr.read(docId);

    while(page.hasNext()){
        DocumentRecord rec = page.next();
        docMgr.readMetadata(rec.getUri(), mh);
        validateMetadata(mh);
    }

Explicit order by

Changes as necessary to accommodate ability to define explicit ordering by range index.

JSON QBE search broken

If I try to perform a search with a QBE expressed as JSON, the Java API chokes on the search results, saying "Could not construct search results: parser error". Poking at it using XML and using string results, I think the problem is the results are coming back as JSON and the client lib doesn't know what to do with them.

In the past, search results always came back as XML, regardless of the query format. Currently, the results seem to come back as JSON if the quer is JSON, but you cannot set the SearchHandle format to JSON. If you try, withFormat() yells at you that search results are always in XML.

All this might be expected, given the current state of things, so I'm not sure it is a bug rather than just something no one has gotten around to yet, but I figured I might as well file it.

Error below, sample code in next comment.

Exception in thread "main" com.marklogic.client.MarkLogicIOException: Could not construct search results: parser error
at com.marklogic.client.io.SearchHandle.receiveContent(SearchHandle.java:183)
at com.marklogic.client.io.SearchHandle.receiveContent(SearchHandle.java:1)
at com.marklogic.client.impl.QueryManagerImpl.search(QueryManagerImpl.java:199)
at com.marklogic.client.impl.QueryManagerImpl.search(QueryManagerImpl.java:162)
at examples.bug.jsonQBE(bug.java:50)
at examples.bug.main(bug.java:59)
Caused by: javax.xml.stream.XMLStreamException: ParseError at [row,col]:[1,1]
Message: Content is not allowed in prolog.
at com.sun.org.apache.xerces.internal.impl.XMLStreamReaderImpl.next(Unknown Source)
at com.sun.xml.internal.stream.XMLEventReaderImpl.nextEvent(Unknown Source)
at com.marklogic.client.io.SearchHandle$SearchResponseImpl.parse(SearchHandle.java:982)
at com.marklogic.client.io.SearchHandle$SearchResponseImpl.access$1(SearchHandle.java:978)
at com.marklogic.client.io.SearchHandle.receiveContent(SearchHandle.java:158)
... 5 more

RawQueryDefinitionTest not getting summaries

Line with error is 167:
165 MatchDocumentSummary[] summaries = results.getMatchResults();
166 assertNotNull(summaries);
167 assertTrue(summaries.length > 0);

Full stack trace:

java.lang.AssertionError
at org.junit.Assert.fail(Assert.java:86)
at org.junit.Assert.assertTrue(Assert.java:41)
at org.junit.Assert.assertTrue(Assert.java:52)
at com.marklogic.client.test.RawQueryDefinitionTest.checkResults(RawQueryDefinitionTest.java:167)
at com.marklogic.client.test.RawQueryDefinitionTest.testByExampleSearch(RawQueryDefinitionTest.java:257)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

Bulk Read: Unable to read just metadata

I can’t figure out how to retrieve just metadata in Java with bulk read. It feels like this might be a gap in the API. Apologies if I'm just overlooking the intended method.

With the REST API, I can retrieve just metadata or both content and metadata in a bulk read, thusly:

only document quality
GET /v1/documents?uri=…&uri=…&category=quality
document quality and document contnet
GET /v1/documents?uri=…&uri=…&category=quality&category=content

In the single document case, I believe you use DocumentManager.readMetadata to fetch just metadata, but I don’t see an analog for this in bulk read. It seems that category=content is always implied. That is, there is no way in the Java API to explicitly include/exclude content because there hasn't been a need in the past.

I'll tag this as a task for now, Sam, and you can decide if its a bug or an RFE (or just WAI) at your leisure.

Bulk RW: XDMP-CONFLICTINGUPDATES on bulk write that includes metadata

The following logged by Kim Coleman:

The example program below attempts to add 2 JSON documents to the database, one with no included metadata (sys default), one using document-specific metadata that specifies a quality value. The bulk write returns XDMP-CONFLICTINGUPDATES for the document that has its own metadata:

Exception in thread "main" com.marklogic.client.FailedRequestException: Local message: failed to apply resource at documents: Bad Request. Server Message: XDMP-CONFLICTINGUPDATES: xdmp:document-insert("doc2.json", document{object-node{"animal": text{"cat"}, "says": text{"meow"}}}, (<sec:permission xmlns:sec="http://marklogic.com/xdmp/security">sec:capabilityread/sec:capabilitysec:role-id70893385306317.../sec:permission, <sec:permission xmlns:sec="http://marklogic.com/xdmp/security">sec:capabilityupdate/sec:capabilitysec:role-id155206546613.../sec:permission), (), 0, ()) -- Conflicting updates xdmp:document-insert("doc2.json", document{object-node{"animal": text{"cat"}, "says": text{"meow"}}}, (<sec:permission xmlns:sec="http://marklogic.com/xdmp/security">sec:capabilityread/sec:capabilitysec:role-id7089338530631756591/sec:role-id/sec:permission, <sec:permission xmlns:sec="http://marklogic.com/xdmp/security">sec:capabilityupdate/sec:capabilitysec:role-id15520654661378671735/sec:role-id/sec:permission), (), 0) and xdmp:document-insert("doc2.json", document{object-node{"quality": number-node{2}}}, (<sec:permission xmlns:sec="http://marklogic.com/xdmp/security">sec:capabilityupdate/sec:capabilitysec:role-id15520654661378671735/sec:role-id/sec:permission, <sec:permission xmlns:sec="http://marklogic.com/xdmp/security">sec:capabilityread/sec:capabilitysec:role-id7089338530631756591/sec:role-id/sec:permission), (), 0)
at com.marklogic.client.impl.JerseyServices.checkStatus(JerseyServices.java:4028)
at com.marklogic.client.impl.JerseyServices.postResource(JerseyServices.java:3358)
at com.marklogic.client.impl.JerseyServices.postBulkDocuments(JerseyServices.java:3425)
at com.marklogic.client.impl.DocumentManagerImpl.write(DocumentManagerImpl.java:421)
at com.marklogic.client.impl.JSONDocumentImpl.write(JSONDocumentImpl.java:1)
at com.marklogic.client.impl.DocumentManagerImpl.write(DocumentManagerImpl.java:408)
at com.marklogic.client.impl.JSONDocumentImpl.write(JSONDocumentImpl.java:1)
at sandbox.BulkTest.main(BulkTest.java:36)

I confirmed that what should be the equivalent direct REST call doesn't cause a problem, so I don't believe the server is at fault. Sample code is included below.

package sandbox;

import com.marklogic.client.io.*;
import com.marklogic.client.document.JSONDocumentManager;
import com.marklogic.client.document.DocumentWriteSet;
import com.marklogic.client.DatabaseClientFactory;
import com.marklogic.client.DatabaseClient;

public class BulkTest {

public static void main(String[] args) {
StringHandle doc1 =
new StringHandle("{"animal": "dog", "says": "woof"}").withFormat(Format.JSON);
StringHandle doc2 =
new StringHandle("{"animal": "cat", "says": "meow"}").withFormat(Format.JSON);
StringHandle doc2Metadata =
new StringHandle("{"quality" : 2.0}").withFormat(Format.JSON);

DatabaseClient client = DatabaseClientFactory.newClient(
"kim-3.marklogic.com", 8003,
"admin", "adm1n",
DatabaseClientFactory.Authentication.DIGEST);
JSONDocumentManager jdm = client.newJSONDocumentManager();
DocumentWriteSet batch = jdm.newWriteSet();

batch.add("doc1.json", doc1);

// throws XDMP-CONFLICTINGUPDATES on write
batch.add("doc2.json", doc2Metadata, doc2);

// this doesn't work any better
// DocumentMetadataHandle mh = new DocumentMetadataHandle();
// mh.setQuality(2);
// batch.add("doc2.json", mh, doc2);

jdm.write(batch);
}

}

Here is the equivalent POST /v1/documents payload I tried, in case it helps to have something to compare to:

--BOUNDARY
Content-Type: application/json
Content-Disposition: attachment; filename="doc1.json"
Content-Length: 35

{ "animal": "dog", "says": "woof" }
--BOUNDARY
Content-Type: application/json
Content-Disposition: attachment; filename="doc2.json"; category=metadata
Content-Length: 16

{"quality" : 2 }
--BOUNDARY
Content-Type: application/json
Content-Disposition: attachment; filename="doc2.json"
Content-Length: 35

{ "animal": "cat", "says": "meow" }
--BOUNDARY--

After inserting couple of binaries using bulkwrite , reading the length of a binary document using file handle always gives me last file length

Here is my test

String docId[] = {"Pandakarlino.jpg","mlfavicon.png"};

           BinaryDocumentManager docMgr = client.newBinaryDocumentManager();
          DocumentWriteSet writeset =docMgr.newWriteSet();
          File file1= null,file2=null;
          file1 = new File("src/junit/com/marklogic/javaclient/data/" + docId[0]);
          FileHandle handle1 = new FileHandle(file1);
          writeset.add("/1/"+docId[0],handle1.withFormat(Format.BINARY));

          file2 = new File("src/junit/com/marklogic/javaclient/data/" + docId[1]);
          FileHandle handle2 = new FileHandle(file2);
          writeset.add("/1/"+docId[1],handle1.withFormat(Format.BINARY));


           docMgr.write(writeset);
          long fsize1 = file1.length(),fsize2 = file2.length();


           FileHandle readHandle1 = new FileHandle();
          docMgr.read("/1/"+docId[0],readHandle1);

           FileHandle readHandle2 = new FileHandle();
          docMgr.read("/1/"+docId[1],readHandle2);
          System.out.println(file1.getName()+":"+fsize1+" "+readHandle1.get().getName()+":"+readHandle1.get().length());
          System.out.println(file2.getName()+":"+fsize2+" "+readHandle2.get().getName()+":"+readHandle2.get().length());

Output:
Pandakarlino.jpg:17154 rep8758160148785271849tmp:17154
mlfavicon.png:3322 rep2111885764668130719tmp:17154

Turn off default metadata with null

The following submitted by Kim Coleman:

What is the proper way to “turn off” default metadata for a batch? Is it by passing a null in to DocumentWriteSet.addDefaultMetadata, or by passing in a handle with no values set? That is, which of these:

batch.addDefaultMetadata(null);

DocumentMetadataHandle handle = new DocumentMetadataHandle();
batch.addDefaultMetadata(handle);

The first of these does not work, atm. The second does, but is that intentional or accidental? By which I mean, the default values in a handle with no explicit values set happen to correspond to system defaults, since, for example, the default document quality is 0.

That may be by design, which is fine. I just like to make sure such behaviors are intentional.

-Kim

DocumentBuilderPatch fails if permissions included.

DocumentBuilderPatch internally uses JSON path when you give it permissions (and probably metadata). It needs to either specify the path language in these particular paths, or use XPath, since that's what the new native JSON implementation expects.

Here's Java, A log of the offending patch, and the server error:

try {
        patchBuilder
                .replaceInsertFragment("acceptedAnswerId", "/node()",
                        Position.LAST_CHILD,
                        mapper.writeValueAsString(acceptNode));
        Iterator<JsonNode> answerIterator = answers.iterator();
        while (answerIterator.hasNext()) {
            JsonNode answer = answerIterator.next();
            String thisId = answer.get("id").asText();
            if (thisId.equals(answerId)) {
                patchBuilder.replaceValue("node()/node('answers')/node()[id='"+thisId+"']/accepted", true);
            }
            else {
                patchBuilder.replaceValue("node()/node('answers')/node()[id='"+thisId+"']/accepted", false);

            }
        }
        patchBuilder.addPermission("samplestack-guest", Capability.READ);
        DocumentPatchHandle patch = patchBuilder.build();
        logger.debug(patch.toString());
        jsonDocumentManager(ClientRole.SAMPLESTACK_CONTRIBUTOR).patch(
                documentUri, patch);

13:46:48.504 [main] DEBUG c.m.samplestack.impl.QnAServiceImpl - {"patch":[{"replace-insert":{"select":"acceptedAnswerId", "context":"/node()", "position":"last-child", "content":{"acceptedAnswerId":"/answers/6c8d7d22-54f6-4288-aec3-98b102c15695"}}}, {"replace":{"select":"node()/node('answers')/node()[id='/answers/6c8d7d22-54f6-4288-aec3-98b102c15695']/accepted", "content":"true"}}, {"insert":{"context":"$.permissions", "position":"last-child", "content":{"role-name":"samplestack-guest", "capabilities":["read"]}}}]}

org.springframework.web.util.NestedServletException: Request processing failed; nested exception is com.marklogic.client.FailedRequestException: Local message: write failed: Internal Server Error. Server Message: XDMP-UNEXPECTED: (err:XPST0003) Unexpected token syntax error, unexpected Dot_. See the MarkLogic server error log for further detail.
at
... at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Caused by: com.marklogic.client.FailedRequestException: Local message: write failed: Internal Server Error. Server Message: XDMP-UNEXPECTED: (err:XPST0003) Unexpected token syntax error, unexpected Dot_. See the MarkLogic server error log for further detail.
at com.marklogic.client.impl.JerseyServices.putPostDocumentImpl(JerseyServices.java:1271)
at com.marklogic.client.impl.JerseyServices.patchDocument(JerseyServices.java:1443)
at com.marklogic.client.impl.DocumentManagerImpl.patch(DocumentManagerImpl.java:797)
at com.marklogic.client.impl.JSONDocumentImpl.patch(JSONDocumentImpl.java:25)
at com.marklogic.client.impl.DocumentManagerImpl.patch(DocumentManagerImpl.java:781)
at com.marklogic.client.impl.JSONDocumentImpl.patch(JSONDocumentImpl.java:25)
at com.marklogic.client.impl.DocumentManagerImpl.patch(DocumentManagerImpl.java:776)
at com.marklogic.client.impl.JSONDocumentImpl.patch(JSONDocumentImpl.java:25)
at com.marklogic.samplestack.impl.QnAServiceImpl.accept(QnAServiceImpl.java:170)
at com.marklogic.samplestack.web.QnADocumentController.accept(QnADocumentController.java:109)
at

Promote selected options

Expand StructuredQueryBuilder to build more parameters of the search (promoting options into search specification). Scope TBD.

StructuredSearchTest using cts:geospatial-query

com.marklogic.client.FailedRequestException: Local message: search failed: Bad Request. Server Message: XDMP-UNDFUN: (err:XPST0017) Undefined function cts:geospatial-query()
at com.marklogic.client.impl.JerseyServices$JerseySearchRequest.getResponse(JerseyServices.java:2118)
at com.marklogic.client.impl.JerseyServices.search(JerseyServices.java:1909)
at com.marklogic.client.impl.JerseyServices.search(JerseyServices.java:1882)
at com.marklogic.client.impl.QueryManagerImpl.search(QueryManagerImpl.java:199)
at com.marklogic.client.impl.QueryManagerImpl.search(QueryManagerImpl.java:162)
at com.marklogic.client.test.StructuredSearchTest.testStructuredSearch2(StructuredSearchTest.java:112)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

DocumentBuilderPatch fails if permissions included.

I thought I'd just created this bug, but I can't find it now.

try {
        patchBuilder
                .replaceInsertFragment("acceptedAnswerId", "/node()",
                        Position.LAST_CHILD,
                        mapper.writeValueAsString(acceptNode));
        Iterator<JsonNode> answerIterator = answers.iterator();
        while (answerIterator.hasNext()) {
            JsonNode answer = answerIterator.next();
            String thisId = answer.get("id").asText();
            if (thisId.equals(answerId)) {
                patchBuilder.replaceValue("node()/node('answers')/node()[id='"+thisId+"']/accepted", true);
            }
            else {
                patchBuilder.replaceValue("node()/node('answers')/node()[id='"+thisId+"']/accepted", false);

            }
        }
        patchBuilder.addPermission("samplestack-guest", Capability.READ);
        DocumentPatchHandle patch = patchBuilder.build();
        logger.debug(patch.toString());
        jsonDocumentManager(ClientRole.SAMPLESTACK_CONTRIBUTOR).patch(
                documentUri, patch);

13:46:48.504 [main] DEBUG c.m.samplestack.impl.QnAServiceImpl - {"patch":[{"replace-insert":{"select":"acceptedAnswerId", "context":"/node()", "position":"last-child", "content":{"acceptedAnswerId":"/answers/6c8d7d22-54f6-4288-aec3-98b102c15695"}}}, {"replace":{"select":"node()/node('answers')/node()[id='/answers/6c8d7d22-54f6-4288-aec3-98b102c15695']/accepted", "content":"true"}}, {"insert":{"context":"$.permissions", "position":"last-child", "content":{"role-name":"samplestack-guest", "capabilities":["read"]}}}]}

org.springframework.web.util.NestedServletException: Request processing failed; nested exception is com.marklogic.client.FailedRequestException: Local message: write failed: Internal Server Error. Server Message: XDMP-UNEXPECTED: (err:XPST0003) Unexpected token syntax error, unexpected Dot_. See the MarkLogic server error log for further detail.
at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:973)
at org.springframework.web.servlet.FrameworkServlet.doPost(FrameworkServlet.java:863)
at

.....

org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:675)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:382)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:192)
Caused by: com.marklogic.client.FailedRequestException: Local message: write failed: Internal Server Error. Server Message: XDMP-UNEXPECTED: (err:XPST0003) Unexpected token syntax error, unexpected Dot_. See the MarkLogic server error log for further detail.
at com.marklogic.client.impl.JerseyServices.putPostDocumentImpl(JerseyServices.java:1271)
at com.marklogic.client.impl.JerseyServices.patchDocument(JerseyServices.java:1443)
at com.marklogic.client.impl.DocumentManagerImpl.patch(DocumentManagerImpl.java:797)
at com.marklogic.client.impl.JSONDocumentImpl.patch(JSONDocumentImpl.java:25)
at com.marklogic.client.impl.DocumentManagerImpl.patch(DocumentManagerImpl.java:781)
at com.marklogic.client.impl.JSONDocumentImpl.patch(JSONDocumentImpl.java:25)
at com.marklogic.client.impl.DocumentManagerImpl.patch(DocumentManagerImpl.java:776)
at com.marklogic.client.impl.JSONDocumentImpl.patch(JSONDocumentImpl.java:25)
at com.marklogic.samplestack.impl.QnAServiceImpl.accept(QnAServiceImpl.java:170)
at

Updating only 1(quality) metadata is not resetting the collections to system default

As per the Rest documentation

The metadata in scope is determined as described in Understanding Metadata Scoping.
Any metadata category that has a value in the in-scope metadata completely replaces that category.

Any metadata category other than properties that is missing or empty in the in-scope metadata is completely replaced by the system default value.

If the in-scope metadata does not include properties, then existing properties are preserved.
If the in-scope metadata does not include collections, then collections are reset to the default. There is no system default for collections, so this results in a document being removed from all collections if no default collections are specified for the user role performining the update.

I have user with default permissions and collection uri and I see the following behavior

Add default metadata,
add document1 to the batch,
add document2 with only quality metadata
If I check the collections on document2, I see no collection where as I am expecting the system default collection
here is my functional test
public void testWriteGenericDocMgrWithDefaultMetadata() throws Exception
{
String docId[] = {"Sega-4MB.jpg"};

    GenericDocumentManager docMgr = client.newDocumentManager();
    DocumentWriteSet writeset =docMgr.newWriteSet();
     // put metadata
     DocumentMetadataHandle mh = setMetadata();

     writeset.addDefault(mh); // Adding default metadata to the entire batch
     File file1= null;
     file1 = new File("src/test/java/com/marklogic/javaclient/data/" + docId[0]);
     FileInputStream fis = new FileInputStream(file1);
     InputStreamHandle handle1 = new InputStreamHandle(fis);
     handle1.setFormat(Format.BINARY);

     writeset.add("/generic/Pandakarlino.jpg",handle1); // This document implicitly gets the default metadata that we added in the begining

     JacksonHandle jh = new JacksonHandle();
     ObjectMapper objM = new ObjectMapper();
     JsonNode jn = objM.readTree(new String("{\"animal\":\"dog\", \"says\":\"woof\"}"));
     jh.set(jn);
     jh.setFormat(Format.JSON);

     writeset.add("/generic/dog.json",new DocumentMetadataHandle().withQuality(10),jh); //This document suppose to get the in scope metadata quality and should set collections to system default

     String foo1 = "This is foo1 of byte Array";
     byte[] ba = foo1.getBytes();
     BytesHandle bh = new BytesHandle(ba);
     bh.setFormat(Format.TEXT);

     writeset.add("/generic/foo1.txt",bh);

     DOMSource ds = new DOMSource(getDocumentContent("This is so foo1"));
     SourceHandle sh = new SourceHandle();
     sh.set(ds);
     sh.setFormat(Format.XML);
     DocumentMetadataHandle mh2 = new DocumentMetadataHandle();
     writeset.add("/generic/foo.xml", mh2.withCollections("genericCollection"), sh); //This document should over write the system default and default collection list and get document specific collection

     docMgr.write(writeset);

     DocumentPage page = docMgr.read("/generic/Pandakarlino.jpg","/generic/foo1.txt");

        while(page.hasNext()){
            DocumentRecord rec = page.next();
            docMgr.readMetadata(rec.getUri(), mh);
            System.out.println(rec.getUri());
            validateMetadata(mh);
        }
        validateMetadata(mh);

page = docMgr.read("/generic/dog.json");
DocumentRecord rec = page.next();
docMgr.readMetadata(rec.getUri(), mh);
assertEquals("default quality",10,mh.getQuality());
assertTrue("default collections missing",mh.getCollections().isEmpty()); // problem appears to be here

         page = docMgr.read("/generic/foo.xml");
         rec = page.next();
         docMgr.readMetadata(rec.getUri(), mh);
         assertEquals("default quality",0,mh.getQuality());
         assertEquals("default collection must change","[genericCollection]",mh.getCollections().toString());

    }

Default connections to 8000

Consider defaulting to port 8000 for connection() and samples, to take advantage of out of the box REST services.

dev branch: batch default metadata resetting

Batch default metadata does not seem to propagate to all the documents that should inherit it. In the sample code that I'll paste in the next post, 5 documents are inserted into the database:

doc1.json - system default metadata (quality 0)
doc2.json - batch default metadata, setting quality to 1
doc3.json - document specific metadata, involving collections only (quality 0)
doc4.json - batch default metadata, same as doc2 (quality = 1)
doc5.json - new batch default metadata, setting quality to 2

What I observe is that doc2.json gets the specified default quality of 1, but doc4.json does not. It seems to revert to the system default (0).

When document-specific metadata was not working properly yesterday, I had the doc3. insert commented out, and at that point, doc2 and doc4 were getting the correct quality, so it might be that the presence of document-specific metadata is somehow messing up the default.

If you leave ".json" off of the document uri, JacksonHandle doesn't work

There's a unit test for JacksonHandle

com.marklogic.client.test.JacksonHandleTest

If you strip the .json from the test URI, you'll get a format failure. There is something that prefers the extension format over the fact that its a JacksonHandle, and setting the format on JacksonHandle explicitly does not help. Here's the stack trace.

java.lang.IllegalArgumentException: JacksonHandle supports the JSON format only
at com.marklogic.client.io.JacksonHandle.setFormat(JacksonHandle.java:140)
at com.marklogic.client.impl.JerseyServices.updateFormat(JerseyServices.java:1682)
at com.marklogic.client.impl.JerseyServices.updateFormat(JerseyServices.java:1677)
at com.marklogic.client.impl.JerseyServices.updateDescriptor(JerseyServices.java:1660)
at com.marklogic.client.impl.JerseyServices.getDocumentImpl(JerseyServices.java:677)
at com.marklogic.client.impl.JerseyServices.getDocument(JerseyServices.java:576)
at com.marklogic.client.impl.DocumentManagerImpl.read(DocumentManagerImpl.java:294)
at com.marklogic.client.impl.JSONDocumentImpl.read(JSONDocumentImpl.java:1)
at

BinaryDocumentTest read wrong number of bytes

java.lang.AssertionError: Binary range read wrong number of bytes expected:<10> but was:<11>
at org.junit.Assert.fail(Assert.java:88)
at org.junit.Assert.failNotEquals(Assert.java:743)
at org.junit.Assert.assertEquals(Assert.java:118)
at org.junit.Assert.assertEquals(Assert.java:555)
at com.marklogic.client.test.BinaryDocumentTest.testReadWrite(BinaryDocumentTest.java:77)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

dev branch: bulk read: Unable to retrieve metadata by uri

When I try to fetch just metadata or both content and metadata using a bulk read by URI, I get a MarkLogicInternalException telling me that "Metadata and content parts should always come in pairs!"

Exception in thread "main" com.marklogic.client.MarkLogicInternalException: Metadata and content parts should always come in pairs!
at com.marklogic.client.impl.JerseyServices.convertToDocumentPage(JerseyServices.java:730)
at com.marklogic.client.impl.JerseyServices.getBulkDocuments(JerseyServices.java:702)
at com.marklogic.client.impl.DocumentManagerImpl.read(DocumentManagerImpl.java:331)
at com.marklogic.client.impl.JSONDocumentImpl.read(JSONDocumentImpl.java:1)
at com.marklogic.client.impl.DocumentManagerImpl.read(DocumentManagerImpl.java:313)
at com.marklogic.client.impl.JSONDocumentImpl.read(JSONDocumentImpl.java:1)
at examples.ReadExamples.example2(ReadExamples.java:47)
at examples.ReadExamples.main(ReadExamples.java:60)

I'll paste my example function in the next comment, but I was basically attempting to do the moral equivalent of this REST request:

curl --anyauth --user admin:adm1n -X GET 'http://localhost:8003/v1/documents?uri=doc1.json&uri=doc2.json&uri=doc3.json&category=quality'

I tried with and without also fetching content. I tried both a JSON and an XML DocumentManager. All give the same result.

Running the same test second time fails in case of adding metadata to bulk documents

Run the below test twice without cleanup i.e. without clearing the database.

public void testWriteMultipleTextDocWithDefaultMetadata() 
      {
        DocumentMetadataHandle mh1,mh2;
         String docId[] = {"/foo/test/myFoo1.txt","/foo/test/myFoo2.txt","/foo/test/myFoo3.txt",
                            "/foo/test/myFoo4.txt","/foo/test/myFoo5.txt","/foo/test/myFoo6.txt",
                            "/foo/test/myFoo7.txt","/foo/test/myFoo8.txt","/foo/test/myFoo9.txt"};

        TextDocumentManager docMgr = client.newTextDocumentManager();

        DocumentWriteSet writeset =docMgr.newWriteSet();

        writeset.add(docId[0], new StringHandle().with("This is so foo1"));
        writeset.add(docId[1], new StringHandle().with("This is so foo2"));
        writeset.add(docId[2], new StringHandle().with("This is so foo3"));
        docMgr.write(writeset);
       //Default system property document set
        System.out.println("Assert if document set doesnt show default properties");
        DocumentPage page = docMgr.read(docId);
        mh1=new DocumentMetadataHandle();
        while(page.hasNext()){
            DocumentRecord rec = page.next();
            docMgr.readMetadata(rec.getUri(), mh1);
            validateDefaultMetadata(mh1);
        }
        validateDefaultMetadata(mh1);

        //Adding document specific properties in document set2

        System.out.println("Assert if document 5 show default properties");

            writeset =docMgr.newWriteSet();
         // put metadata
            mh2 = setMetadata();

            writeset.add(docId[3], new StringHandle().with("This is so foo4"));
            writeset.add(docId[4],mh2, new StringHandle().with("This is so foo5"));
            writeset.add(docId[5], new StringHandle().with("This is so foo6"));
            docMgr.write(writeset);


            page = docMgr.read(docId[4]);
            mh2=new DocumentMetadataHandle();
            DocumentRecord rec = page.next();
            docMgr.readMetadata(rec.getUri(), mh2);
            validateMetadata(mh2);
            page = docMgr.read(docId[3]);
            rec = page.next();
            docMgr.readMetadata(rec.getUri(), mh2);
            validateDefaultMetadata(mh2);
            page = docMgr.read(docId[5]);
            rec = page.next();
            docMgr.readMetadata(rec.getUri(), mh2);
            validateDefaultMetadata(mh2);

            System.out.println("Assert if documents 8 and 9 show default properties and if 7 doesnt show default");

            writeset =docMgr.newWriteSet();
            // put metadata
            mh2 = setMetadata();

            writeset.add(docId[6], new StringHandle().with("This is so foo4"));
            writeset.addDefault(mh2);
            writeset.add(docId[7], new StringHandle().with("This is so foo5"));
            writeset.add(docId[8], new StringHandle().with("This is so foo6"));
            docMgr.write(writeset);

            page = docMgr.read(docId[6]);
            mh2=new DocumentMetadataHandle();
            rec = page.next();
            docMgr.readMetadata(rec.getUri(), mh2);
            validateDefaultMetadata(mh2);

            page = docMgr.read(docId[7]);
            rec = page.next();
            docMgr.readMetadata(rec.getUri(), mh2);
            validateMetadata(mh2);

             page = docMgr.read(docId[8]);
             rec = page.next();
             docMgr.readMetadata(rec.getUri(), mh2);
             validateMetadata(mh2);

      }

public DocumentMetadataHandle setMetadata(){
          // create and initialize a handle on the metadata
        DocumentMetadataHandle metadataHandle = new DocumentMetadataHandle();
        metadataHandle.getCollections().addAll("my-collection1","my-collection2");
        metadataHandle.getPermissions().add("app-user", Capability.UPDATE, Capability.READ);
        metadataHandle.getProperties().put("reviewed", true);
        metadataHandle.getProperties().put("myString", "foo");
        metadataHandle.getProperties().put("myInteger", 10);
        metadataHandle.getProperties().put("myDecimal", 34.56678);
        metadataHandle.getProperties().put("myCalendar", Calendar.getInstance().get(Calendar.YEAR));
        metadataHandle.setQuality(23);
        return  metadataHandle;
    }
public void validateMetadata(DocumentMetadataHandle mh){

        // get metadata values
        DocumentProperties properties = mh.getProperties();
        DocumentPermissions permissions = mh.getPermissions();
        DocumentCollections collections = mh.getCollections();

        // Properties
       // String expectedProperties = "size:5|reviewed:true|myInteger:10|myDecimal:34.56678|myCalendar:2014|myString:foo|";
        String actualProperties = getDocumentPropertiesString(properties);
        boolean result = actualProperties.contains("size:6|");
        assertTrue("Document properties count", result);

        // Permissions
        String expectedPermissions1 = "size:4|rest-reader:[READ]|eval:[UPDATE, READ]|app-user:[UPDATE, READ]|rest-writer:[UPDATE]|";
        String expectedPermissions2 = "size:4|rest-reader:[READ]|eval:[READ, UPDATE]|app-user:[READ, UPDATE]|rest-writer:[UPDATE]|";
        String actualPermissions = getDocumentPermissionsString(permissions);
        System.out.println(actualPermissions);
        if(actualPermissions.contains("[UPDATE, READ]"))
            assertEquals("Document permissions difference", expectedPermissions1, actualPermissions);
        else if(actualPermissions.contains("[READ, UPDATE]"))
            assertEquals("Document permissions difference", expectedPermissions2, actualPermissions);
        else
            assertEquals("Document permissions difference", "wrong", actualPermissions);

        // Collections 
        String expectedCollections = "size:2|my-collection1|my-collection2|";
        String actualCollections = getDocumentCollectionsString(collections);
        assertEquals("Document collections difference", expectedCollections, actualCollections);

    }
public void validateDefaultMetadata(DocumentMetadataHandle mh){

        // get metadata values
        DocumentProperties properties = mh.getProperties();
        DocumentPermissions permissions = mh.getPermissions();
        DocumentCollections collections = mh.getCollections();

        // Properties
        String actualProperties = getDocumentPropertiesString(properties);
        boolean result =actualProperties.contains("size:1|");
        System.out.println(actualProperties +result);
        assertTrue("Document default last modified properties count1?", result);
       // assertFalse("Document default last modified properties count2?", result);

        // Permissions

        String expectedPermissions1 = "size:3|rest-reader:[READ]|eval:[UPDATE, READ]|rest-writer:[UPDATE]|";
        String expectedPermissions2 = "size:3|rest-reader:[READ]|eval:[READ, UPDATE]|rest-writer:[UPDATE]|";
        String actualPermissions = getDocumentPermissionsString(permissions);

        if(actualPermissions.contains("[UPDATE, READ]"))
            assertEquals("Document permissions difference", expectedPermissions1, actualPermissions);
        else if(actualPermissions.contains("[READ, UPDATE]"))
            assertEquals("Document permissions difference", expectedPermissions2, actualPermissions);
        else
            assertEquals("Document permissions difference", "wrong", actualPermissions);

        // Collections 
        String expectedCollections = "size:1|http://permission-collections/|";
        String actualCollections = getDocumentCollectionsString(collections);

        assertEquals("Document collections difference", expectedCollections, actualCollections);
        System.out.println(actualPermissions);
    }

Include method and parameter descriptions in resource metadata

As a developer using the REST API
I want to include method and parameter descriptions in resource metadata
So that clients of the resources I provide can look at /v1/config/resources (or perhaps an HTML view of this content) and get information not just about the resource itself, but also about each method and each parameter, thereby making it easier for the developer to invoke the resource correctly.

Notes:

  • In theory this can be done by describing each of the methods and parameters in the resource description, but that becomes very unwieldy for resources with multiple methods and parameters.
  • This is an enhancement to the REST API itself; the Java API would then to expose this capability in ResourceExtensionsManager::writeServices. A new data structure would be needed instead of the simple map that MethodParameters currently is, as each method and parameter would need something like a "setDescription(String)" method.

BulkLoad using GenericDocumentManager is throwing ClientHandlerException

String docId[] = {"Pandakarlino.jpg","mlfavicon.png"};

          GenericDocumentManager docMgr = client.newDocumentManager();
          DocumentWriteSet writeset =docMgr.newWriteSet();

           File file1= null;
          file1 = new File("src/junit/com/marklogic/javaclient/data/" + docId[0]);
          FileInputStream fis = new FileInputStream(file1);
          InputStreamHandle handle1 = new InputStreamHandle(fis);
          handle1.setFormat(Format.BINARY);

           writeset.add("/generic/"+docId[0],handle1);

        JacksonHandle jh = new JacksonHandle();
        ObjectMapper objM = new ObjectMapper();
        JsonNode jn = objM.readTree(new String("{\"animal\":\"dog\", \"says\":\"woof\"}"));
        jh.set(jn);
        jh.setFormat(Format.JSON);

        writeset.add("/generic/dog.json",jh);

        String foo1 = "This is foo1 of byte Array";
        byte[] ba = foo1.getBytes();
        BytesHandle bh = new BytesHandle(ba);
        bh.setFormat(Format.TEXT);

        writeset.add("/generic/foo1.txt",bh);

        DOMSource ds = new DOMSource(getDocumentContent("This is so foo1"));
        SourceHandle sh = new SourceHandle();
        sh.set(ds);
        sh.setFormat(Format.XML);

        writeset.add("/generic/foo.xml",sh);

           docMgr.write(writeset);


        FileHandle readHandle1 = new FileHandle();
          docMgr.read("/generic/"+docId[0],readHandle1);
           System.out.println(readHandle1.get().getName()+":"+readHandle1.get().length()+"\n");
          fis.close();

Actual:
com.sun.jersey.api.client.ClientHandlerException: org.apache.http.client.ClientProtocolException
at com.sun.jersey.client.apache4.ApacheHttpClient4Handler.handle(ApacheHttpClient4Handler.java:184)
at com.marklogic.client.impl.DigestChallengeFilter.handle(DigestChallengeFilter.java:34)
at com.sun.jersey.api.client.filter.HTTPDigestAuthFilter.handle(HTTPDigestAuthFilter.java:418)
at com.sun.jersey.api.client.Client.handle(Client.java:648)
at com.sun.jersey.api.client.WebResource.handle(WebResource.java:680)
at com.sun.jersey.api.client.WebResource.access$200(WebResource.java:74)
at com.sun.jersey.api.client.WebResource$Builder.post(WebResource.java:568)
at com.marklogic.client.impl.JerseyServices.doPost(JerseyServices.java:3810)
at com.marklogic.client.impl.JerseyServices.postResource(JerseyServices.java:3328)
at com.marklogic.client.impl.JerseyServices.postBulkDocuments(JerseyServices.java:3429)
at com.marklogic.client.impl.DocumentManagerImpl.write(DocumentManagerImpl.java:421)
at com.marklogic.client.impl.GenericDocumentImpl.write(GenericDocumentImpl.java:23)
at com.marklogic.client.impl.DocumentManagerImpl.write(DocumentManagerImpl.java:408)
at com.marklogic.client.impl.GenericDocumentImpl.write(GenericDocumentImpl.java:23)
at com.marklogic.javaclient.TestBulkWriteSample1.testWriteGenericDocMgr(TestBulkWriteSample1.java:280)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: org.apache.http.client.ClientProtocolException
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:822)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:776)
at com.sun.jersey.client.apache4.ApacheHttpClient4Handler.handle(ApacheHttpClient4Handler.java:170)
... 40 more
Caused by: org.apache.http.client.NonRepeatableRequestException: Cannot retry request with a non-repeatable request entity. The cause lists the reason the original request failed.
at org.apache.http.impl.client.DefaultRequestDirector.tryExecute(DefaultRequestDirector.java:607)
at org.apache.http.impl.client.DefaultRequestDirector.execute(DefaultRequestDirector.java:454)
at org.apache.http.impl.client.AbstractHttpClient.execute(AbstractHttpClient.java:820)
... 42 more
Caused by: java.io.IOException: Attempted write to closed stream.
at org.apache.http.impl.io.ChunkedOutputStream.write(ChunkedOutputStream.java:157)
at sun.nio.cs.StreamEncoder.writeBytes(StreamEncoder.java:221)
at sun.nio.cs.StreamEncoder.implFlushBuffer(StreamEncoder.java:291)
at sun.nio.cs.StreamEncoder.implFlush(StreamEncoder.java:295)
at sun.nio.cs.StreamEncoder.flush(StreamEncoder.java:141)
at java.io.OutputStreamWriter.flush(OutputStreamWriter.java:229)
at java.io.BufferedWriter.flush(BufferedWriter.java:254)
at com.sun.jersey.multipart.impl.MultiPartWriter.writeTo(MultiPartWriter.java:195)
at com.sun.jersey.multipart.impl.MultiPartWriter.writeTo(MultiPartWriter.java:71)
at com.sun.jersey.api.client.RequestWriter$RequestEntityWriterImpl.writeRequestEntity(RequestWriter.java:231)
at com.sun.jersey.client.apache4.ApacheHttpClient4Handler$2.writeTo(ApacheHttpClient4Handler.java:262)
at org.apache.http.entity.HttpEntityWrapper.writeTo(HttpEntityWrapper.java:96)
at org.apache.http.impl.client.EntityEnclosingRequestWrapper$EntityWrapper.writeTo(EntityEnclosingRequestWrapper.java:108)
at org.apache.http.impl.entity.EntitySerializer.serialize(EntitySerializer.java:120)
at org.apache.http.impl.AbstractHttpClientConnection.sendRequestEntity(AbstractHttpClientConnection.java:263)
at org.apache.http.impl.conn.AbstractClientConnAdapter.sendRequestEntity(AbstractClientConnAdapter.java:227)
at org.apache.http.protocol.HttpRequestExecutor.doSendRequest(HttpRequestExecutor.java:255)
at org.apache.http.protocol.HttpRequestExecutor.execute(HttpRequestExecutor.java:123)
at org.apache.http.impl.client.DefaultRequestDirector.tryExecute(DefaultRequestDirector.java:633)
... 44 more

Support combined query POST with QueryManager.suggest

The REST API now supports sending a combined query payload to /v1/suggest, which enables dynamic creation of suggestion sources.

So there's a gap for this support in the Java API. Nobody has asked for this feature though. Setting for EA-3, but that's up to PM and Sam.

Moving bugtrack 25333 here to create this issue.

Data binding facade

Add higher-level conveniences to enable Java developers to work with services on domain models instead of having to think about documents and document operations.

ConditionalDocumenTest facing different error message

It was expecting "Local message: Content version must match to write document. Server Message: RESTAPI-CONTENTWRONGVERSION: (err:FOER0000) Content version mismatch: uri: /test/conditional1.xml" but apparently got something different

java.lang.AssertionError: Write with no version had misleading message
at org.junit.Assert.fail(Assert.java:88)
at org.junit.Assert.assertTrue(Assert.java:41)
at com.marklogic.client.test.ConditionalDocumentTest.testConditional(ConditionalDocumentTest.java:99)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

Bulk Read: Unable to use a JSON QBE

If I try to perform a bulk read using a JSON QBE, the server returns REST-REPEATEDPARAM. Seems like the request is not being properly constructed. An equivalent read using an XML QBE works as expected. See next comment for sample code.

Exception in thread "main" com.marklogic.client.FailedRequestException: Local message: search failed: Bad Request. Server Message: REST-REPEATEDPARAM: (rest:REPEATEDPARAM) Endpoint does not support repeated parameter: format can only appear once
at com.marklogic.client.impl.JerseyServices$JerseySearchRequest.getResponse(JerseyServices.java:2074)
at com.marklogic.client.impl.JerseyServices.getBulkDocumentsImpl(JerseyServices.java:775)
at com.marklogic.client.impl.JerseyServices.getBulkDocuments(JerseyServices.java:715)
at com.marklogic.client.impl.DocumentManagerImpl.search(DocumentManagerImpl.java:371)
at com.marklogic.client.impl.JSONDocumentImpl.search(JSONDocumentImpl.java:1)
at com.marklogic.client.impl.DocumentManagerImpl.search(DocumentManagerImpl.java:342)
at com.marklogic.client.impl.JSONDocumentImpl.search(JSONDocumentImpl.java:1)
at examples.ReadExamples.qbeExample(ReadExamples.java:64)
at examples.ReadExamples.main(ReadExamples.java:101)

ExtensionLibrariesTest failed to install module

It has the arguments backwards in the assertEquals call, so the error should say "expected: <1> but was: <0>"

java.lang.AssertionError: number of modules installed expected:<0> but was:<1>
at org.junit.Assert.fail(Assert.java:88)
at org.junit.Assert.failNotEquals(Assert.java:743)
at org.junit.Assert.assertEquals(Assert.java:118)
at org.junit.Assert.assertEquals(Assert.java:555)
at com.marklogic.client.test.ExtensionLibrariesTest.testXQueryModuleCRUD(ExtensionLibrariesTest.java:52)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

JAVA BULK WRITE: Writing bulk text documents in to the server is thorwing 'Internal Server Error'

Logged by Sravan Kottam:

My test

String docId[] = {"/foo/test/myFoo1.txt","/foo/test/myFoo2.txt","/foo/test/myFoo3.txt"};

 TextDocumentManager docMgr = client.newTextDocumentManager();
 DocumentWriteSet writeset =docMgr.newWriteSet();

 writeset.add(docId[0], new StringHandle().with("This is so foo1"));
 writeset.add(docId[1], new StringHandle().with("This is so foo2"));
 writeset.add(docId[2], new StringHandle().with("This is so foo3"));

 docMgr.write(writeset);

 assertEquals("Text document write difference", "This is so foo1", docMgr.read(docId[0], new StringHandle()).get());
 assertEquals("Text document write difference", "This is so foo2", docMgr.read(docId[1], new StringHandle()).get());
 assertEquals("Text document write difference", "This is so foo3", docMgr.read(docId[2], new StringHandle()).get());

Actual:
com.marklogic.client.FailedRequestException: Local message: failed to apply resource at documents: Internal Server Error. Server Message: XDMP-AS: (err:XPTY0004) $mimetype as xs:string -- Invalid coercion: () as xs:string. See the MarkLogic server error log for further detail.
at com.marklogic.client.impl.JerseyServices.checkStatus(JerseyServices.java:4028)
at com.marklogic.client.impl.JerseyServices.postResource(JerseyServices.java:3358)
at com.marklogic.client.impl.JerseyServices.postBulkDocuments(JerseyServices.java:3425)
at com.marklogic.client.impl.DocumentManagerImpl.write(DocumentManagerImpl.java:421)
at com.marklogic.client.impl.DocumentManagerImpl.write(DocumentManagerImpl.java:408)
at com.marklogic.javaclient.TestBulkWriteSample1.testWriteMultipleTextDoc(TestBulkWriteSample1.java:78)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:44)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:41)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:76)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:193)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:52)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:191)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:42)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:184)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:31)
at org.junit.runners.ParentRunner.run(ParentRunner.java:236)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

I see the following logging from client side

In setup
[DEBUG] ThreadSafeClientConnManager - Get connection: HttpRoute[{}->http://localhost:8011], timeout = 0
[DEBUG] ConnPoolByRoute - [HttpRoute[{}->http://localhost:8011]] total kept alive: 0, total issued: 0, total allocated: 0 out of 200
[DEBUG] ConnPoolByRoute - No free connections [HttpRoute[{}->http://localhost:8011]][null]
[DEBUG] ConnPoolByRoute - Available capacity: 100 out of 100 [HttpRoute[{}->http://localhost:8011]][null]
[DEBUG] ConnPoolByRoute - Creating new connection [HttpRoute[{}->http://localhost:8011]]
[DEBUG] DefaultClientConnectionOperator - Connecting to localhost/127.0.0.1:8011
[DEBUG] RequestAddCookies - CookieSpec selected: best-match
[DEBUG] RequestAuthCache - Auth cache not set in the context
[DEBUG] DefaultHttpClient - Attempt 1 to execute request
[DEBUG] DefaultClientConnection - Sending request: POST /v1/documents HTTP/1.1
[DEBUG] wire - >> "POST /v1/documents HTTP/1.1[\r][\n]"
[DEBUG] wire - >> "Content-Type: multipart/mixed; boundary=Boundary_1_1299150774_1403115952401[\r][\n]"
[DEBUG] wire - >> "Accept: application/json[\r][\n]"
[DEBUG] wire - >> "Transfer-Encoding: chunked[\r][\n]"
[DEBUG] wire - >> "Host: localhost:8011[\r][\n]"
[DEBUG] wire - >> "Connection: Keep-Alive[\r][\n]"
[DEBUG] wire - >> "[\r][\n]"
[DEBUG] headers - >> POST /v1/documents HTTP/1.1
[DEBUG] headers - >> Content-Type: multipart/mixed; boundary=Boundary_1_1299150774_1403115952401
[DEBUG] headers - >> Accept: application/json
[DEBUG] headers - >> Transfer-Encoding: chunked
[DEBUG] headers - >> Host: localhost:8011
[DEBUG] headers - >> Connection: Keep-Alive
[DEBUG] wire - >> "7e[\r][\n]"
[DEBUG] wire - >> "--Boundary_1_1299150774_1403115952401[\r][\n]"
[DEBUG] wire - >> "Content-Disposition: attachment; filename="/foo/test/myFoo1.txt"[\r][\n]"
[DEBUG] wire - >> "Content-Type: /[\r][\n]"
[DEBUG] wire - >> "[\r][\n]"
[DEBUG] wire - >> "[\r][\n]"
[DEBUG] wire - >> "8f[\r][\n]"
[DEBUG] wire - >> "This is so foo1[\r][\n]"
[DEBUG] wire - >> "--Boundary_1_1299150774_1403115952401[\r][\n]"
[DEBUG] wire - >> "Content-Disposition: attachment; filename="/foo/test/myFoo2.txt"[\r][\n]"
[DEBUG] wire - >> "Content-Type: /[\r][\n]"
[DEBUG] wire - >> "[\r][\n]"
[DEBUG] wire - >> "[\r][\n]"
[DEBUG] wire - >> "8f[\r][\n]"
[DEBUG] wire - >> "This is so foo2[\r][\n]"
[DEBUG] wire - >> "--Boundary_1_1299150774_1403115952401[\r][\n]"
[DEBUG] wire - >> "Content-Disposition: attachment; filename="/foo/test/myFoo3.txt"[\r][\n]"
[DEBUG] wire - >> "Content-Type: /[\r][\n]"
[DEBUG] wire - >> "[\r][\n]"
[DEBUG] wire - >> "[\r][\n]"
[DEBUG] wire - >> "3a[\r][\n]"
[DEBUG] wire - >> "This is so foo3[\r][\n]"
[DEBUG] wire - >> "--Boundary_1_1299150774_1403115952401--[\r][\n]"
[DEBUG] wire - >> "[\r][\n]"
[DEBUG] wire - >> "0[\r][\n]"
[DEBUG] wire - >> "[\r][\n]"
[DEBUG] wire - << "HTTP/1.1 401 Unauthorized[\r][\n]"
[DEBUG] wire - << "WWW-Authenticate: Digest realm="public", qop="auth", nonce="443b7b7b0beff466f3c3fd8bace3c6a1", opaque="d47d20a7d7dd7b57"[\r][\n]"
[DEBUG] wire - << "Content-type: application/xml[\r][\n]"
[DEBUG] wire - << "Server: MarkLogic[\r][\n]"
[DEBUG] wire - << "Content-Length: 211[\r][\n]"
[DEBUG] wire - << "Connection: Keep-Alive[\r][\n]"
[DEBUG] wire - << "Keep-Alive: timeout=5[\r][\n]"
[DEBUG] wire - << "[\r][\n]"
[DEBUG] DefaultClientConnection - Receiving response: HTTP/1.1 401 Unauthorized
[DEBUG] headers - << HTTP/1.1 401 Unauthorized
[DEBUG] headers - << WWW-Authenticate: Digest realm="public", qop="auth", nonce="443b7b7b0beff466f3c3fd8bace3c6a1", opaque="d47d20a7d7dd7b57"
[DEBUG] headers - << Content-type: application/xml
[DEBUG] headers - << Server: MarkLogic
[DEBUG] headers - << Content-Length: 211
[DEBUG] headers - << Connection: Keep-Alive
[DEBUG] headers - << Keep-Alive: timeout=5
[DEBUG] DefaultHttpClient - Connection can be kept alive for 5000 MILLISECONDS
[DEBUG] DefaultHttpClient - Target requested authentication
[DEBUG] DefaultTargetAuthenticationHandler - Authentication schemes in the order of preference: [negotiate, NTLM, Digest, Basic]
[DEBUG] DefaultTargetAuthenticationHandler - Challenge for negotiate authentication scheme not available
[DEBUG] DefaultTargetAuthenticationHandler - Challenge for NTLM authentication scheme not available
[DEBUG] DefaultTargetAuthenticationHandler - Digest authentication scheme selected
[DEBUG] DefaultHttpClient - Authorization challenge processed
[DEBUG] DefaultHttpClient - Authentication scope: DIGEST 'public'@localhost:8011
[DEBUG] DefaultHttpClient - Credentials not found
[DEBUG] wire - << "<rapi:error xmlns:rapi="http://marklogic.com/rest-api">rapi:status-code401/rapi:status-coderapi:statusFailed Auth/rapi:statusrapi:message-code/rapi:messageUnauthenticated/rapi:message/rapi:error[\n]"
[DEBUG] ThreadSafeClientConnManager - Released connection is reusable.
[DEBUG] ConnPoolByRoute - Releasing connection [HttpRoute[{}->http://localhost:8011]][null]
[DEBUG] ConnPoolByRoute - Pooling connection [HttpRoute[{}->http://localhost:8011]][null]; keep alive for 5000 MILLISECONDS
[DEBUG] ConnPoolByRoute - Notifying no-one, there are no waiting threads
[DEBUG] ThreadSafeClientConnManager - Get connection: HttpRoute[{}->http://localhost:8011], timeout = 0
[DEBUG] ConnPoolByRoute - [HttpRoute[{}->http://localhost:8011]] total kept alive: 1, total issued: 0, total allocated: 1 out of 200
[DEBUG] ConnPoolByRoute - Getting free connection [HttpRoute[{}->http://localhost:8011]][null]
[DEBUG] DefaultHttpClient - Stale connection check
[DEBUG] RequestAddCookies - CookieSpec selected: best-match
[DEBUG] RequestAuthCache - Auth cache not set in the context
[DEBUG] DefaultHttpClient - Attempt 1 to execute request
[DEBUG] DefaultClientConnection - Sending request: POST /v1/documents HTTP/1.1
[DEBUG] wire - >> "POST /v1/documents HTTP/1.1[\r][\n]"
[DEBUG] wire - >> "Content-Type: multipart/mixed; boundary=Boundary_1_1299150774_1403115952401[\r][\n]"
[DEBUG] wire - >> "Accept: application/json[\r][\n]"
[DEBUG] wire - >> "MIME-Version: 1.0[\r][\n]"
[DEBUG] wire - >> "Authorization: Digest username="admin",realm="public",nonce="443b7b7b0beff466f3c3fd8bace3c6a1",opaque="d47d20a7d7dd7b57",qop=auth,uri="/v1/documents",cnonce="46062b78",nc=00000001,response="97226cf4e65296733f2f38891f96b9f2"[\r][\n]"
[DEBUG] wire - >> "Transfer-Encoding: chunked[\r][\n]"
[DEBUG] wire - >> "Host: localhost:8011[\r][\n]"
[DEBUG] wire - >> "Connection: Keep-Alive[\r][\n]"
[DEBUG] wire - >> "[\r][\n]"
[DEBUG] headers - >> POST /v1/documents HTTP/1.1
[DEBUG] headers - >> Content-Type: multipart/mixed; boundary=Boundary_1_1299150774_1403115952401
[DEBUG] headers - >> Accept: application/json
[DEBUG] headers - >> MIME-Version: 1.0
[DEBUG] headers - >> Authorization: Digest username="admin",realm="public",nonce="443b7b7b0beff466f3c3fd8bace3c6a1",opaque="d47d20a7d7dd7b57",qop=auth,uri="/v1/documents",cnonce="46062b78",nc=00000001,response="97226cf4e65296733f2f38891f96b9f2"
[DEBUG] headers - >> Transfer-Encoding: chunked
[DEBUG] headers - >> Host: localhost:8011
[DEBUG] headers - >> Connection: Keep-Alive
[DEBUG] wire - >> "7e[\r][\n]"
[DEBUG] wire - >> "--Boundary_1_1299150774_1403115952401[\r][\n]"
[DEBUG] wire - >> "Content-Disposition: attachment; filename="/foo/test/myFoo1.txt"[\r][\n]"
[DEBUG] wire - >> "Content-Type: /[\r][\n]"
[DEBUG] wire - >> "[\r][\n]"
[DEBUG] wire - >> "[\r][\n]"
[DEBUG] wire - >> "8f[\r][\n]"
[DEBUG] wire - >> "This is so foo1[\r][\n]"
[DEBUG] wire - >> "--Boundary_1_1299150774_1403115952401[\r][\n]"
[DEBUG] wire - >> "Content-Disposition: attachment; filename="/foo/test/myFoo2.txt"[\r][\n]"
[DEBUG] wire - >> "Content-Type: /[\r][\n]"
[DEBUG] wire - >> "[\r][\n]"
[DEBUG] wire - >> "[\r][\n]"
[DEBUG] wire - >> "8f[\r][\n]"
[DEBUG] wire - >> "This is so foo2[\r][\n]"
[DEBUG] wire - >> "--Boundary_1_1299150774_1403115952401[\r][\n]"
[DEBUG] wire - >> "Content-Disposition: attachment; filename="/foo/test/myFoo3.txt"[\r][\n]"
[DEBUG] wire - >> "Content-Type: /[\r][\n]"
[DEBUG] wire - >> "[\r][\n]"
[DEBUG] wire - >> "[\r][\n]"
[DEBUG] wire - >> "3a[\r][\n]"
[DEBUG] wire - >> "This is so foo3[\r][\n]"
[DEBUG] wire - >> "--Boundary_1_1299150774_1403115952401--[\r][\n]"
[DEBUG] wire - >> "[\r][\n]"
[DEBUG] wire - >> "0[\r][\n]"
[DEBUG] wire - >> "[\r][\n]"
[DEBUG] wire - << "HTTP/1.1 500 Internal Server Error[\r][\n]"
[DEBUG] wire - << "Content-type: application/xml[\r][\n]"
[DEBUG] wire - << "Server: MarkLogic[\r][\n]"
[DEBUG] wire - << "Content-Length: 365[\r][\n]"
[DEBUG] wire - << "Connection: Keep-Alive[\r][\n]"
[DEBUG] wire - << "Keep-Alive: timeout=5[\r][\n]"
[DEBUG] wire - << "[\r][\n]"
[DEBUG] DefaultClientConnection - Receiving response: HTTP/1.1 500 Internal Server Error
[DEBUG] headers - << HTTP/1.1 500 Internal Server Error
[DEBUG] headers - << Content-type: application/xml
[DEBUG] headers - << Server: MarkLogic
[DEBUG] headers - << Content-Length: 365
[DEBUG] headers - << Connection: Keep-Alive
[DEBUG] headers - << Keep-Alive: timeout=5
[DEBUG] DefaultHttpClient - Connection can be kept alive for 5000 MILLISECONDS
[DEBUG] wire - << "<rapi:error xmlns:rapi="http://marklogic.com/rest-api">rapi:status-code500/rapi:status-coderapi:statusINTERNAL ERROR/rapi:statusrapi:message-codeXDMP-AS/rapi:message-coderapi:messageXDMP-AS: (err:XPTY0004) $mimetype as xs:string -- Invalid coercion: () as xs:string. See the MarkLogic server error log for further detail./rapi:message/rapi:error[\n]"
[DEBUG] ThreadSafeClientConnManager - Released connection is reusable.
[DEBUG] ConnPoolByRoute - Releasing connection [HttpRoute[{}->http://localhost:8011]][null]
[DEBUG] ConnPoolByRoute - Pooling connection [HttpRoute[{}->http://localhost:8011]][null]; keep alive for 5000 MILLISECONDS
[DEBUG] ConnPoolByRoute - Notifying no-one, there are no waiting threads

Better Eclipse support

The project must not require Eclipse to build/run/test. However, there should be an easy way for a developer using Eclipse to easily set up her environment. This likely includes, but isn’t limited to, .project, .classpath, and perhaps, .settings/.

The resulting configuration should compile and build with zero warnings.

Should we require the m2e plugin? egit.

GenericDocumentTest possibly facing JSONPath issue

Hoping this is fixed when Charles addresses #39 so we're correctly sending over jsonpaths

com.marklogic.client.FailedRequestException: Local message: write failed: Internal Server Error. Server Message: XDMP-UNEXPECTED: (err:XPST0003) Unexpected token syntax error, unexpected Dot_. See the MarkLogic server error log for further detail.
at com.marklogic.client.impl.JerseyServices.putPostDocumentImpl(JerseyServices.java:1278)
at com.marklogic.client.impl.JerseyServices.patchDocument(JerseyServices.java:1450)
at com.marklogic.client.impl.DocumentManagerImpl.patch(DocumentManagerImpl.java:819)
at com.marklogic.client.impl.GenericDocumentImpl.patch(GenericDocumentImpl.java:1)
at com.marklogic.client.impl.DocumentManagerImpl.patch(DocumentManagerImpl.java:803)
at com.marklogic.client.impl.GenericDocumentImpl.patch(GenericDocumentImpl.java:1)
at com.marklogic.client.impl.DocumentManagerImpl.patch(DocumentManagerImpl.java:798)
at com.marklogic.client.impl.GenericDocumentImpl.patch(GenericDocumentImpl.java:1)
at com.marklogic.client.test.GenericDocumentTest.testPatch(GenericDocumentTest.java:408)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

Changes for native JSON

Switch Jackson from provided to compile in the POM
Move the JacksonHandle from extra to io
Make sure we expose the Jackson capabilities for JSON databinding, DOM, and streaming

JavaScript extensions

Modifications to ResourceManager base class to support JavaScript extensions, as needed.

JSONDocumentTest failing, maybe missing pathlang property

com.marklogic.client.FailedRequestException: Local message: write failed: Bad Request. Server Message: RESTAPI-INVALIDCONTENT: (err:FOER0000) Invalid content: Invalid patch (maybe missing pathlang property?)
at com.marklogic.client.impl.JerseyServices.putPostDocumentImpl(JerseyServices.java:1278)
at com.marklogic.client.impl.JerseyServices.patchDocument(JerseyServices.java:1450)
at com.marklogic.client.impl.DocumentManagerImpl.patch(DocumentManagerImpl.java:819)
at com.marklogic.client.impl.JSONDocumentImpl.patch(JSONDocumentImpl.java:1)
at com.marklogic.client.impl.DocumentManagerImpl.patch(DocumentManagerImpl.java:803)
at com.marklogic.client.impl.JSONDocumentImpl.patch(JSONDocumentImpl.java:1)
at com.marklogic.client.impl.DocumentManagerImpl.patch(DocumentManagerImpl.java:798)
at com.marklogic.client.impl.JSONDocumentImpl.patch(JSONDocumentImpl.java:1)
at com.marklogic.client.test.JSONDocumentTest.testPatch(JSONDocumentTest.java:130)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:483)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:47)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:44)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:271)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:70)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:50)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:238)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:63)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:236)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:53)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:229)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
at org.junit.runners.ParentRunner.run(ParentRunner.java:309)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)

ClientResponse.Status is null after SSL auth with invalid user

When running a negative test attempting to authenticate over SSL with an invalid user, JerseyServices has a null status, and thus cannot throw the expected "Unauthorized" FailedRequestException.

SSLTest.java demonstrates the error. If I can figure out how to attach in github, I will.

DocumentPage.size() always returns -1

(I'm assuming the purpose of this method is to return the actual number of documents in a given page vs. the configured page size returned by DocumentPage.getPageSize()).

For example, this code:
Java DocumentPage documents = jdm.search(query, 1); System.out.println("Total matching documents: " + documents.getTotalSize()); System.out.println("Number of documents in current page: " + documents.size());

Prints out the following:
Total matching documents: 6
Number of documents in current page: -1

It is not a function of whether there are > 1 pages as size() behaves the same way with multi-page results.

Add shortcut methods to bulk API

DocumentRecord:

public <T> T getContentAs(Class<T> as);

DocumentPage:

public <T> T nextContentAs(Class<T> as);

DocumentWriteSet:

public DocumentWriteSet addAs(String uri, Format format, Object content);
public DocumentWriteSet addAs(String uri, DocumentMetadataWriteHandle metadataHandle, Format format, Object content);
public DocumentWriteSet addAs(DocumentDescriptor desc, Format format, Object content);
public DocumentWriteSet addAs(DocumentDescriptor desc, DocumentMetadataWriteHandle metadataHandle, Format format, Object content);

The implementations would just wrap calls to the equivalent handle methods.

Fix language on StructuredQueryBuilder.value javadoc

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.