Skip to content

Commit 991b8c9

Browse files
Ajit GeorgeAjit George
authored andcommitted
Merge branch 'release-3.0.3' into 3.0-master
2 parents f76692e + bb2a50e commit 991b8c9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

45 files changed

+2097
-798
lines changed

.classpath

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<classpath>
3+
<classpathentry kind="src" output="target/classes" path="src/main/java">
4+
<attributes>
5+
<attribute name="optional" value="true"/>
6+
<attribute name="maven.pomderived" value="true"/>
7+
</attributes>
8+
</classpathentry>
9+
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
10+
<attributes>
11+
<attribute name="optional" value="true"/>
12+
<attribute name="maven.pomderived" value="true"/>
13+
</attributes>
14+
</classpathentry>
15+
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
16+
<attributes>
17+
<attribute name="maven.pomderived" value="true"/>
18+
</attributes>
19+
</classpathentry>
20+
<classpathentry excluding="**" kind="src" output="target/test-classes" path="src/test/resources">
21+
<attributes>
22+
<attribute name="maven.pomderived" value="true"/>
23+
</attributes>
24+
</classpathentry>
25+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6">
26+
<attributes>
27+
<attribute name="maven.pomderived" value="true"/>
28+
</attributes>
29+
</classpathentry>
30+
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
31+
<attributes>
32+
<attribute name="maven.pomderived" value="true"/>
33+
</attributes>
34+
</classpathentry>
35+
<classpathentry kind="output" path="target/classes"/>
36+
</classpath>

.gitignore

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
target/
2-
.classpath
3-
.project
42
.gradle
5-
.settings/
63
*.class
74
test-complete/build/
85

.project

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>java-client-api-develop</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
<buildCommand>
14+
<name>org.eclipse.m2e.core.maven2Builder</name>
15+
<arguments>
16+
</arguments>
17+
</buildCommand>
18+
</buildSpec>
19+
<natures>
20+
<nature>org.eclipse.m2e.core.maven2Nature</nature>
21+
<nature>org.eclipse.jdt.core.javanature</nature>
22+
</natures>
23+
</projectDescription>
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
eclipse.preferences.version=1
2+
encoding//src/main/java=UTF-8
3+
encoding//src/main/resources=UTF-8
4+
encoding//src/test/java=UTF-8
5+
encoding//src/test/resources=UTF-8
6+
encoding/<project>=UTF-8

.settings/org.eclipse.jdt.core.prefs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
eclipse.preferences.version=1
2+
org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
3+
org.eclipse.jdt.core.compiler.compliance=1.6
4+
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
5+
org.eclipse.jdt.core.compiler.source=1.6

.settings/org.eclipse.m2e.core.prefs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
activeProfiles=
2+
eclipse.preferences.version=1
3+
resolveWorkspaceProjects=true
4+
version=1

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
<groupId>com.marklogic</groupId>
55
<artifactId>java-client-api</artifactId>
66
<packaging>jar</packaging>
7-
<version>3.0.2</version>
7+
<version>3.0.3</version>
88
<name>MarkLogic Java Client API</name>
99
<description>The official MarkLogic Java client API.</description>
1010
<url>https://github.com/marklogic/java-client-api</url>

src/main/java/com/marklogic/client/Transaction.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,15 @@ public interface Transaction {
3131
*/
3232
public String getTransactionId();
3333

34+
/**
35+
* Returns the host identifier for the transaction that binds this
36+
* transaction with the host e-node for the transaction. Ordinarily, you
37+
* will not need to do anything with the host id. Instead, you pass the
38+
* Transaction object to methods.
39+
* @return the host identifier
40+
*/
41+
public String getHostId();
42+
3443
/**
3544
* Reads the status for the transaction including whether the transaction
3645
* has timed out.

src/main/java/com/marklogic/client/document/DocumentManager.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -852,6 +852,25 @@ public void delete(String docId)
852852
*/
853853
public void delete(String docId, Transaction transaction)
854854
throws ResourceNotFoundException, ForbiddenUserException, FailedRequestException;
855+
/**
856+
* Deletes the documents' metadata and content
857+
*
858+
* To call delete(), an application must authenticate as rest-writer or rest-admin.
859+
*
860+
* @param uris the identifiers for the documents to delete
861+
*/
862+
public void delete(String... uris)
863+
throws ResourceNotFoundException, ForbiddenUserException, FailedRequestException;
864+
/**
865+
* Deletes the documents' metadata and content from an open database transaction
866+
*
867+
* To call delete(), an application must authenticate as rest-writer or rest-admin.
868+
*
869+
* @param transaction an open transaction
870+
* @param uris the identifiers for the documents to delete
871+
*/
872+
public void delete(Transaction transaction, String... uris)
873+
throws ResourceNotFoundException, ForbiddenUserException, FailedRequestException;
855874
/**
856875
* Deletes the document metadata and content from the database
857876
*

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,17 +61,17 @@ public void setHandleRegistry(HandleFactoryRegistry handleRegistry) {
6161

6262
@Override
6363
public Transaction openTransaction() throws ForbiddenUserException, FailedRequestException {
64-
return new TransactionImpl(services, services.openTransaction(null, TransactionImpl.DEFAULT_TIMELIMIT));
64+
return services.openTransaction(null, TransactionImpl.DEFAULT_TIMELIMIT);
6565
}
6666

6767
@Override
6868
public Transaction openTransaction(String name) throws ForbiddenUserException, FailedRequestException {
69-
return new TransactionImpl(services, services.openTransaction(name, TransactionImpl.DEFAULT_TIMELIMIT));
69+
return services.openTransaction(name, TransactionImpl.DEFAULT_TIMELIMIT);
7070
}
7171

7272
@Override
7373
public Transaction openTransaction(String name, int timeLimit) throws ForbiddenUserException, FailedRequestException{
74-
return new TransactionImpl(services, services.openTransaction(name, timeLimit));
74+
return services.openTransaction(name, timeLimit);
7575
}
7676

7777
@Override

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

Lines changed: 27 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,7 @@ public DocumentDescriptor exists(String uri) throws ForbiddenUserException,
153153
@Override
154154
public DocumentDescriptor exists(String uri, Transaction transaction)
155155
throws ForbiddenUserException, FailedRequestException {
156-
return services.head(requestLogger, uri, (transaction == null) ? null
157-
: transaction.getTransactionId());
156+
return services.head(requestLogger, uri, transaction);
158157
}
159158

160159
// shortcut readers
@@ -386,7 +385,7 @@ public <T extends R> T read(DocumentDescriptor desc,
386385
boolean wasModified = services.getDocument(
387386
requestLogger,
388387
desc,
389-
(transaction != null) ? transaction.getTransactionId() : null,
388+
transaction,
390389
(metadataHandle != null) ? processedMetadata : null,
391390
mergeTransformParameters((transform != null) ? transform
392391
: getReadTransform(), extraParams), metadataHandle, contentHandle);
@@ -439,7 +438,7 @@ public DocumentPage read(ServerTransform transform, Transaction transaction,
439438

440439
return services.getBulkDocuments(
441440
requestLogger,
442-
(transaction == null) ? null : transaction.getTransactionId(),
441+
transaction,
443442
// the default for bulk is no metadata, which differs from the normal
444443
// default of ALL
445444
isProcessedMetadataModified ? processedMetadata : null,
@@ -498,7 +497,7 @@ public DocumentPage search(QueryDefinition querydef, long start,
498497
Set<Metadata> metadata = isProcessedMetadataModified ? processedMetadata
499498
: null;
500499
return services.getBulkDocuments(requestLogger, querydef, start,
501-
getPageLength(), tid, searchHandle, searchView, metadata,
500+
getPageLength(), transaction, searchHandle, searchView, metadata,
502501
nonDocumentFormat, null);
503502
}
504503

@@ -552,7 +551,7 @@ public void write(DocumentWriteSet writeSet, ServerTransform transform,
552551
Format defaultFormat = contentFormat;
553552
services.postBulkDocuments(requestLogger, writeSet,
554553
(transform != null) ? transform : getWriteTransform(),
555-
(transaction == null) ? null : transaction.getTransactionId(),
554+
transaction,
556555
defaultFormat, null);
557556
}
558557

@@ -825,7 +824,7 @@ public void write(DocumentDescriptor desc,
825824
services.putDocument(
826825
requestLogger,
827826
desc,
828-
(transaction == null) ? null : transaction.getTransactionId(),
827+
transaction,
829828
(metadataHandle != null) ? processedMetadata : null,
830829
mergeTransformParameters((transform != null) ? transform
831830
: getWriteTransform(), extraParams), metadataHandle, contentHandle);
@@ -844,6 +843,22 @@ public void delete(String uri, Transaction transaction)
844843
delete(new DocumentDescriptorImpl(uri, true), transaction);
845844
}
846845

846+
@Override
847+
public void delete(String... uris)
848+
throws ResourceNotFoundException, ForbiddenUserException,
849+
FailedRequestException
850+
{
851+
services.delete(requestLogger, null, uris);
852+
}
853+
854+
@Override
855+
public void delete(Transaction transaction, String... uris)
856+
throws ResourceNotFoundException, ForbiddenUserException,
857+
FailedRequestException
858+
{
859+
services.delete(requestLogger, transaction, uris);
860+
}
861+
847862
@Override
848863
public void delete(DocumentDescriptor desc) throws ResourceNotFoundException,
849864
ForbiddenUserException, FailedRequestException {
@@ -896,8 +911,7 @@ public void delete(DocumentDescriptor desc, Transaction transaction,
896911
RequestParameters extraParams = addTemporalParams(new RequestParameters(),
897912
temporalCollection, systemTime);
898913

899-
services.deleteDocument(requestLogger, desc, (transaction == null) ? null
900-
: transaction.getTransactionId(), null, extraParams);
914+
services.deleteDocument(requestLogger, desc, transaction, null, extraParams);
901915
}
902916

903917
// shortcut creators
@@ -1049,7 +1063,7 @@ public DocumentDescriptor create(DocumentUriTemplate template,
10491063
return services.postDocument(
10501064
requestLogger,
10511065
template,
1052-
(transaction == null) ? null : transaction.getTransactionId(),
1066+
transaction,
10531067
(metadataHandle != null) ? processedMetadata : null,
10541068
mergeTransformParameters((transform != null) ? transform
10551069
: getWriteTransform(), extraParams), metadataHandle, contentHandle);
@@ -1109,9 +1123,8 @@ public void patch(DocumentDescriptor desc, DocumentPatchHandle patch,
11091123

11101124
DocumentPatchHandleImpl builtPatch = (patch instanceof DocumentPatchHandleImpl) ? (DocumentPatchHandleImpl) patch
11111125
: null;
1112-
services.patchDocument(requestLogger, desc, (transaction == null) ? null
1113-
: transaction.getTransactionId(),
1114-
(builtPatch != null) ? builtPatch.getMetadata() : processedMetadata,
1126+
services.patchDocument(requestLogger, desc, transaction,
1127+
(builtPatch != null) ? builtPatch.getMetadata() : processedMetadata,
11151128
(builtPatch != null) ? builtPatch.isOnContent() : true, patch);
11161129
}
11171130

@@ -1167,8 +1180,7 @@ public void writeDefaultMetadata(String uri, Transaction transaction)
11671180
logger.info("Resetting metadata for {}", uri);
11681181

11691182
services.deleteDocument(requestLogger,
1170-
new DocumentDescriptorImpl(uri, true), (transaction == null) ? null
1171-
: transaction.getTransactionId(), processedMetadata,
1183+
new DocumentDescriptorImpl(uri, true), transaction, processedMetadata,
11721184
getWriteParams());
11731185
}
11741186

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

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -86,23 +86,32 @@ static class ContentReplaceOperation extends PatchOperation {
8686
String selectPath;
8787
Cardinality cardinality;
8888
boolean isFragment = true;
89-
String input;
89+
Object input;
90+
String inputAsString;
9091
ContentReplaceOperation(String selectPath, Cardinality cardinality, boolean isFragment,
9192
Object input
9293
) {
9394
super();
9495
this.selectPath = selectPath;
9596
this.cardinality = cardinality;
9697
this.isFragment = isFragment;
97-
this.input = (input instanceof String) ?
98-
(String) input : input.toString();
98+
this.input = input;
99+
this.inputAsString = null;
100+
if (input != null) {
101+
inputAsString = (input instanceof String) ? (String) input : input.toString();
102+
}
99103
}
100104
@Override
101105
public void write(JSONStringWriter serializer) {
102106
writeStartReplace(serializer, selectPath, cardinality);
103107
serializer.writeStartEntry("content");
104108
if (isFragment) {
105-
serializer.writeFragment(input);
109+
serializer.writeFragment(inputAsString);
110+
} else if (input instanceof Boolean) {
111+
serializer.writeBooleanValue(input);
112+
}
113+
else if (input instanceof Number) {
114+
serializer.writeNumberValue(input);
106115
} else {
107116
serializer.writeStringValue(input);
108117
}
@@ -115,9 +124,9 @@ public void write(XMLOutputSerializer out) throws Exception {
115124
writeStartReplace(out, selectPath, cardinality);
116125
if (isFragment) {
117126
serializer.writeCharacters(""); // force the tag close
118-
out.getWriter().write(input);
127+
out.getWriter().write(inputAsString);
119128
} else {
120-
serializer.writeCharacters(input);
129+
serializer.writeCharacters(inputAsString);
121130
}
122131
serializer.writeEndElement();
123132
}

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public ExtensionLibraryDescriptor[] list()
5050
public ExtensionLibraryDescriptor[] list(String directory)
5151
throws ResourceNotFoundException, ForbiddenUserException, FailedRequestException {
5252

53-
XMLEventReaderHandle handle = services.getResource(requestLogger, directory, null, new XMLEventReaderHandle());
53+
XMLEventReaderHandle handle = services.getResource(requestLogger, directory, null, null, new XMLEventReaderHandle());
5454

5555
XMLEventReader reader = handle.get();
5656
List<ExtensionLibraryDescriptor> modules = new ArrayList<ExtensionLibraryDescriptor>();
@@ -89,7 +89,7 @@ public <T> T read(ExtensionLibraryDescriptor modulesDescriptor, Class<T> as)
8989
@Override
9090
public <T extends AbstractReadHandle> T read(String modulePath, T readHandle)
9191
throws ResourceNotFoundException, ForbiddenUserException, FailedRequestException {
92-
return services.getResource(requestLogger, modulePath, null, readHandle);
92+
return services.getResource(requestLogger, modulePath, null, null, readHandle);
9393
}
9494
@Override
9595
public <T extends AbstractReadHandle> T read(ExtensionLibraryDescriptor modulesDescriptor, T readHandle)
@@ -129,7 +129,7 @@ private AbstractWriteHandle getContentHandle(Object content) {
129129
@Override
130130
public void write(String modulePath, AbstractWriteHandle contentHandle)
131131
throws ResourceNotFoundException, ResourceNotResendableException, ForbiddenUserException, FailedRequestException {
132-
services.putResource(requestLogger, modulePath, null, contentHandle, null);
132+
services.putResource(requestLogger, modulePath, null, null, contentHandle, null);
133133
}
134134
@Override
135135
public void write(ExtensionLibraryDescriptor modulesDescriptor, AbstractWriteHandle contentHandle)
@@ -138,13 +138,13 @@ public void write(ExtensionLibraryDescriptor modulesDescriptor, AbstractWriteHan
138138
for (Permission perm : modulesDescriptor.getPermissions()) {
139139
requestParams.add("perm:" + perm.getRoleName(), perm.getCapability());
140140
}
141-
services.putResource(requestLogger, modulesDescriptor.getPath(), requestParams, contentHandle, null);
141+
services.putResource(requestLogger, modulesDescriptor.getPath(), null, requestParams, contentHandle, null);
142142
}
143143

144144
@Override
145145
public void delete(String modulePath)
146146
throws ResourceNotFoundException, ForbiddenUserException, FailedRequestException {
147-
services.deleteResource(requestLogger, modulePath, null, null);
147+
services.deleteResource(requestLogger, modulePath, null, null, null);
148148
}
149149
@Override
150150
public void delete(ExtensionLibraryDescriptor modulesDescriptor)

0 commit comments

Comments
 (0)