Skip to content

Commit 74d1fb7

Browse files
authored
Merge pull request #1465 from marklogic/feature/1036-mimetypes
#1036: Deprecated unused mimetypes argument in ResourcesServices
2 parents 7f96ae4 + d9aa09c commit 74d1fb7

File tree

9 files changed

+42
-68
lines changed

9 files changed

+42
-68
lines changed

marklogic-client-api-functionaltests/src/test/java/com/marklogic/client/fastfunctest/TestJSResourceExtensions.java

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,8 @@ public String getJSON(String docUri) {
5656
params.add("arg1", docUri);
5757
params.add("arg2", "Earth");
5858

59-
// specify the mime type for each expected document returned
60-
String[] mimetypes = new String[] { "text/plain" };
61-
6259
// call the service
63-
ServiceResultIterator resultItr = getServices().get(params, mimetypes);
60+
ServiceResultIterator resultItr = getServices().get(params);
6461

6562
// iterate over the results
6663
List<String> responses = new ArrayList<>();
@@ -81,12 +78,10 @@ public String getJSON(String docUri) {
8178
public String postJSON(String docUri) {
8279
RequestParameters params = new RequestParameters();
8380
params.add("uri", docUri);
84-
// specify the mime type for each expected document returned
85-
String[] mimetypes = new String[] { "text/plain" };
86-
81+
8782
String input = "{\"array\" : [1,2,3]}";
8883
// call the service
89-
ServiceResultIterator resultItr = getServices().post(params, new StringHandle(input).withFormat(Format.JSON), mimetypes);
84+
ServiceResultIterator resultItr = getServices().post(params, new StringHandle(input).withFormat(Format.JSON));
9085
// iterate over the results
9186
List<String> responses = new ArrayList<>();
9287
StringHandle readHandle = new StringHandle();

marklogic-client-api/src/main/java/com/marklogic/client/example/cookbook/JavascriptResourceExtension.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -92,11 +92,8 @@ public String sayHello() {
9292
params.add("service", "hello");
9393
params.add("planet", "Earth");
9494

95-
// specify the mime type for each expected document returned
96-
String[] mimetypes = new String[] {"text/plain"};
97-
9895
// call the service
99-
ServiceResultIterator resultItr = getServices().get(params, mimetypes);
96+
ServiceResultIterator resultItr = getServices().get(params);
10097

10198
// iterate over the results
10299
List<String> responses = new ArrayList<>();

marklogic-client-api/src/main/java/com/marklogic/client/example/cookbook/ResourceExtension.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -119,14 +119,8 @@ public Document[] checkDictionaries(String... uris) {
119119
params.add("service", "check-dictionary");
120120
params.add("uris", uris);
121121

122-
// specify the mime type for each expected document returned
123-
String[] mimetypes = new String[uris.length];
124-
for (int i=0; i < uris.length; i++) {
125-
mimetypes[i] = "application/xml";
126-
}
127-
128122
// call the service
129-
ServiceResultIterator resultItr = getServices().get(params, mimetypes);
123+
ServiceResultIterator resultItr = getServices().get(params);
130124

131125
// iterate over the results
132126
List<Document> documents = new ArrayList<>();

marklogic-client-api/src/main/java/com/marklogic/client/example/extension/BatchManager.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -330,9 +330,6 @@ public BatchResponse apply(BatchRequest request) {
330330
manifestBuilder.append("<?xml version='1.0' encoding='UTF-8'?>\n");
331331
manifestBuilder.append("<rapi:batch-requests xmlns:rapi='http://marklogic.com/rest-api'>\n");
332332

333-
List<String> readMimetypes = new ArrayList<>();
334-
// read the response manifest first
335-
readMimetypes.add("application/xml");
336333
for (Map.Entry<String,InputItem> entry: request.items.entrySet()) {
337334
String uri = entry.getKey();
338335
InputItem item = entry.getValue();
@@ -369,8 +366,6 @@ public BatchResponse apply(BatchRequest request) {
369366
}
370367

371368
if (ritem.mimetype != null) {
372-
readMimetypes.add(ritem.mimetype);
373-
374369
manifestBuilder.append("<rapi:content-mimetype>");
375370
manifestBuilder.append(ritem.mimetype);
376371
manifestBuilder.append("</rapi:content-mimetype>\n");
@@ -401,12 +396,9 @@ public BatchResponse apply(BatchRequest request) {
401396
requestManifest.set(manifestBuilder.toString());
402397
requestManifest.setFormat(Format.XML);
403398

404-
String[] requestMimetypes = new String[readMimetypes.size()];
405-
406399
ServiceResultIterator resultItr = getServices().post(
407400
new RequestParameters(),
408-
requestHandles.toArray(new AbstractWriteHandle[requestHandles.size()]),
409-
requestMimetypes
401+
requestHandles.toArray(new AbstractWriteHandle[requestHandles.size()])
410402
);
411403

412404
if (!resultItr.hasNext())

marklogic-client-api/src/main/java/com/marklogic/client/extensions/ResourceServices.java

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -61,18 +61,18 @@ public interface ResourceServices {
6161
/**
6262
* Reads multiple resource content by calling a GET service.
6363
* @param params the parameters for the call
64-
* @param mimetypes the mimetypes for the requested content
64+
* @param mimetypes the mimetypes for the requested content; deprecated since 6.0.0, has always been ignored by implementation
6565
* @return an iterator over the requested content
6666
*/
67-
ServiceResultIterator get(RequestParameters params, String... mimetypes);
67+
ServiceResultIterator get(RequestParameters params, @Deprecated String... mimetypes);
6868
/**
6969
* Reads multiple resource content by calling a GET service.
7070
* @param params the parameters for the call
7171
* @param transaction the transaction for reading content
72-
* @param mimetypes the mimetypes for the requested content
72+
* @param mimetypes the mimetypes for the requested content; deprecated since 6.0.0, has always been ignored by implementation
7373
* @return an iterator over the requested content
7474
*/
75-
ServiceResultIterator get(RequestParameters params, Transaction transaction, String... mimetypes);
75+
ServiceResultIterator get(RequestParameters params, Transaction transaction, @Deprecated String... mimetypes);
7676

7777
/**
7878
* Writes content by calling a PUT service.
@@ -160,38 +160,38 @@ public interface ResourceServices {
160160
* Applies multiple content by calling a POST service.
161161
* @param params the parameters for the call
162162
* @param input the content passed with the call
163-
* @param mimetypes the mimetypes for the requested content
163+
* @param mimetypes the mimetypes for the requested content; deprecated since 6.0.0, has always been ignored by implementation
164164
* @return an iterator over the requested content
165165
*/
166-
ServiceResultIterator post(RequestParameters params, AbstractWriteHandle input, String... mimetypes);
166+
ServiceResultIterator post(RequestParameters params, AbstractWriteHandle input, @Deprecated String... mimetypes);
167167
/**
168168
* Applies multiple content by calling a POST service.
169169
* @param params the parameters for the call
170170
* @param input the content passed with the call
171171
* @param transaction the transaction for applying content
172-
* @param mimetypes the mimetypes for the requested content
172+
* @param mimetypes the mimetypes for the requested content; deprecated since 6.0.0, has always been ignored by implementation
173173
* @return an iterator over the requested content
174174
*/
175-
ServiceResultIterator post(RequestParameters params, AbstractWriteHandle input, Transaction transaction, String... mimetypes);
175+
ServiceResultIterator post(RequestParameters params, AbstractWriteHandle input, Transaction transaction, @Deprecated String... mimetypes);
176176
/**
177177
* Applies multiple content by calling a POST service.
178178
* @param params the parameters for the call
179179
* @param input an array of content passed with the call
180-
* @param mimetypes the mimetypes for the requested content
180+
* @param mimetypes the mimetypes for the requested content; deprecated since 6.0.0, has always been ignored by implementation
181181
* @param <W> the type of AbstractWriteHandle's with content to send
182182
* @return an iterator over the requested content
183183
*/
184-
<W extends AbstractWriteHandle> ServiceResultIterator post(RequestParameters params, W[] input, String... mimetypes);
184+
<W extends AbstractWriteHandle> ServiceResultIterator post(RequestParameters params, W[] input, @Deprecated String... mimetypes);
185185
/**
186186
* Applies multiple content by calling a POST service.
187187
* @param params the parameters for the call
188188
* @param input an array of content passed with the call
189189
* @param transaction the transaction for applying content
190-
* @param mimetypes the mimetypes for the requested content
190+
* @param mimetypes the mimetypes for the requested content; deprecated since 6.0.0, has always been ignored by implementation
191191
* @param <W> the type of AbstractWriteHandle's with content to send
192192
* @return an iterator over the requested content
193193
*/
194-
<W extends AbstractWriteHandle> ServiceResultIterator post(RequestParameters params, W[] input, Transaction transaction, String... mimetypes);
194+
<W extends AbstractWriteHandle> ServiceResultIterator post(RequestParameters params, W[] input, Transaction transaction, @Deprecated String... mimetypes);
195195

196196
/**
197197
* Deletes content by calling a DELETE service.

marklogic-client-api/src/main/java/com/marklogic/client/impl/OkHttpServices.java

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -994,7 +994,7 @@ private OkHttpResultIterator getBulkDocumentsImpl(RequestLogger reqlog, long ser
994994
}
995995

996996
OkHttpResultIterator iterator = getIteratedResourceImpl(DefaultOkHttpResultIterator::new,
997-
reqlog, path, transaction, params, MIMETYPE_MULTIPART_MIXED);
997+
reqlog, path, transaction, params);
998998
if ( iterator != null ) {
999999
if ( iterator.getStart() == -1 ) iterator.setStart(1);
10001000
if ( iterator.getSize() != -1 ) {
@@ -3222,14 +3222,14 @@ public Response apply(Request.Builder funcBuilder) {
32223222

32233223
@Override
32243224
public RESTServiceResultIterator getIteratedResource(RequestLogger reqlog,
3225-
String path, Transaction transaction, RequestParameters params, String... mimetypes)
3225+
String path, Transaction transaction, RequestParameters params)
32263226
throws ResourceNotFoundException, ForbiddenUserException, FailedRequestException
32273227
{
3228-
return getIteratedResourceImpl(OkHttpServiceResultIterator::new, reqlog, path, transaction, params, mimetypes);
3228+
return getIteratedResourceImpl(OkHttpServiceResultIterator::new, reqlog, path, transaction, params);
32293229
}
32303230

32313231
private <U extends OkHttpResultIterator> U getIteratedResourceImpl(ResultIteratorConstructor<U> constructor,
3232-
RequestLogger reqlog, String path, Transaction transaction, RequestParameters params, String... mimetypes)
3232+
RequestLogger reqlog, String path, Transaction transaction, RequestParameters params)
32333233
throws ResourceNotFoundException, ForbiddenUserException, FailedRequestException
32343234
{
32353235
if ( params == null ) params = new RequestParameters();
@@ -3950,12 +3950,11 @@ private String getJsonType(JsonNode jsonNode) {
39503950

39513951
@Override
39523952
public RESTServiceResultIterator postIteratedResource(RequestLogger reqlog,
3953-
String path, Transaction transaction, RequestParameters params, AbstractWriteHandle input,
3954-
String... outputMimetypes)
3953+
String path, Transaction transaction, RequestParameters params, AbstractWriteHandle input)
39553954
throws ResourceNotFoundException, ResourceNotResendableException, ForbiddenUserException, FailedRequestException
39563955
{
39573956
return postIteratedResourceImpl(OkHttpServiceResultIterator::new,
3958-
reqlog, path, transaction, params, input, outputMimetypes);
3957+
reqlog, path, transaction, params, input);
39593958
}
39603959

39613960
public RESTServiceResultIterator postMultipartForm(
@@ -4040,7 +4039,7 @@ private void addContentParamAttachments(MultipartBody.Builder multiBuilder, List
40404039
private <U extends OkHttpResultIterator> U postIteratedResourceImpl(
40414040
ResultIteratorConstructor<U> constructor, final RequestLogger reqlog,
40424041
final String path, Transaction transaction, RequestParameters params,
4043-
AbstractWriteHandle input, String... outputMimetypes)
4042+
AbstractWriteHandle input)
40444043
throws ResourceNotFoundException, ResourceNotResendableException, ForbiddenUserException, FailedRequestException
40454044
{
40464045
if ( params == null ) params = new RequestParameters();
@@ -4087,16 +4086,16 @@ public Response apply(Request.Builder funcBuilder) {
40874086
@Override
40884087
public <W extends AbstractWriteHandle> RESTServiceResultIterator postIteratedResource(
40894088
RequestLogger reqlog, String path, Transaction transaction, RequestParameters params,
4090-
W[] input, String... outputMimetypes)
4089+
W[] input)
40914090
throws ResourceNotFoundException, ResourceNotResendableException, ForbiddenUserException, FailedRequestException
40924091
{
40934092
return postIteratedResourceImpl(OkHttpServiceResultIterator::new,
4094-
reqlog, path, transaction, params, input, outputMimetypes);
4093+
reqlog, path, transaction, params, input);
40954094
}
40964095

40974096
private <W extends AbstractWriteHandle, U extends OkHttpResultIterator> U postIteratedResourceImpl(
40984097
ResultIteratorConstructor<U> constructor, RequestLogger reqlog, String path, Transaction transaction,
4099-
RequestParameters params, W[] input, String... outputMimetypes)
4098+
RequestParameters params, W[] input)
41004099
throws ResourceNotFoundException, ResourceNotResendableException, ForbiddenUserException, FailedRequestException
41014100
{
41024101
if ( params == null ) params = new RequestParameters();

marklogic-client-api/src/main/java/com/marklogic/client/impl/RESTServices.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,7 @@ <R extends AbstractReadHandle> R getResource(RequestLogger reqlog, String path,
231231
Transaction transaction, RequestParameters params, R output)
232232
throws ResourceNotFoundException, ForbiddenUserException, FailedRequestException;
233233
RESTServiceResultIterator getIteratedResource(
234-
RequestLogger reqlog, String path, Transaction transaction, RequestParameters params, String... mimetypes)
234+
RequestLogger reqlog, String path, Transaction transaction, RequestParameters params)
235235
throws ResourceNotFoundException, ForbiddenUserException, FailedRequestException;
236236

237237
<R extends AbstractReadHandle> R putResource(
@@ -262,7 +262,7 @@ <R extends AbstractReadHandle, W extends AbstractWriteHandle> R postResource(
262262
ForbiddenUserException, FailedRequestException;
263263
RESTServiceResultIterator postIteratedResource(
264264
RequestLogger reqlog, String path, Transaction transaction, RequestParameters params,
265-
AbstractWriteHandle input, String... outputMimetypes)
265+
AbstractWriteHandle input)
266266
throws ResourceNotFoundException, ResourceNotResendableException, ForbiddenUserException,
267267
FailedRequestException;
268268
RESTServiceResultIterator postMultipartForm(
@@ -271,7 +271,7 @@ RESTServiceResultIterator postMultipartForm(
271271
FailedRequestException;
272272
<W extends AbstractWriteHandle> RESTServiceResultIterator postIteratedResource(
273273
RequestLogger reqlog, String path, Transaction transaction, RequestParameters params,
274-
W[] input, String... outputMimetypes)
274+
W[] input)
275275
throws ResourceNotFoundException, ResourceNotResendableException, ForbiddenUserException,
276276
FailedRequestException;
277277
EvalResultIterator postEvalInvoke(RequestLogger reqlog, String code, String modulePath,

marklogic-client-api/src/main/java/com/marklogic/client/impl/ResourceServicesImpl.java

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,12 @@ public <R extends AbstractReadHandle> R get(RequestParameters params, Transactio
5353
transaction, prepareParams(params), output);
5454
}
5555
@Override
56-
public ServiceResultIterator get(RequestParameters params, String... outputMimetypes) {
56+
public ServiceResultIterator get(RequestParameters params, @Deprecated String... outputMimetypes) {
5757
return get(params, null, outputMimetypes);
5858
}
5959
@Override
60-
public ServiceResultIterator get(RequestParameters params, Transaction transaction, String... outputMimetypes) {
61-
return services.getIteratedResource(requestLogger, getResourcePath(),
62-
transaction, prepareParams(params), outputMimetypes);
60+
public ServiceResultIterator get(RequestParameters params, Transaction transaction, @Deprecated String... outputMimetypes) {
61+
return services.getIteratedResource(requestLogger, getResourcePath(), transaction, prepareParams(params));
6362
}
6463

6564
@Override
@@ -91,13 +90,13 @@ public <R extends AbstractReadHandle> R post(RequestParameters params, AbstractW
9190
requestLogger, getResourcePath(), transaction, prepareParams(params), input, output);
9291
}
9392
@Override
94-
public ServiceResultIterator post(RequestParameters params, AbstractWriteHandle input, String... outputMimetypes) {
93+
public ServiceResultIterator post(RequestParameters params, AbstractWriteHandle input, @Deprecated String... outputMimetypes) {
9594
return post(params, input, null, outputMimetypes);
9695
}
9796
@Override
98-
public ServiceResultIterator post(RequestParameters params, AbstractWriteHandle input, Transaction transaction, String... outputMimetypes) {
97+
public ServiceResultIterator post(RequestParameters params, AbstractWriteHandle input, Transaction transaction, @Deprecated String... outputMimetypes) {
9998
return services.postIteratedResource(
100-
requestLogger, getResourcePath(), transaction, prepareParams(params), input, outputMimetypes);
99+
requestLogger, getResourcePath(), transaction, prepareParams(params), input);
101100
}
102101
@Override
103102
public <R extends AbstractReadHandle, W extends AbstractWriteHandle> R post(RequestParameters params, W[] input, R output) {
@@ -109,13 +108,13 @@ public <R extends AbstractReadHandle, W extends AbstractWriteHandle> R post(Requ
109108
requestLogger, getResourcePath(), transaction, prepareParams(params), input, output);
110109
}
111110
@Override
112-
public <W extends AbstractWriteHandle> ServiceResultIterator post(RequestParameters params, W[] input, String... outputMimetypes) {
111+
public <W extends AbstractWriteHandle> ServiceResultIterator post(RequestParameters params, W[] input, @Deprecated String... outputMimetypes) {
113112
return post(params, input, null, outputMimetypes);
114113
}
115114
@Override
116-
public <W extends AbstractWriteHandle> ServiceResultIterator post(RequestParameters params, W[] input, Transaction transaction, String... outputMimetypes) {
115+
public <W extends AbstractWriteHandle> ServiceResultIterator post(RequestParameters params, W[] input, Transaction transaction, @Deprecated String... outputMimetypes) {
117116
return services.postIteratedResource(
118-
requestLogger, getResourcePath(), transaction, prepareParams(params), input, outputMimetypes);
117+
requestLogger, getResourcePath(), transaction, prepareParams(params), input);
119118
}
120119

121120
@Override

marklogic-client-api/src/test/java/com/marklogic/client/test/ResourceServicesTest.java

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,9 +73,7 @@ public void testResourceServices() throws XpathException {
7373
assertNotNull("Failed to get resource service with single document", result);
7474
assertXpathEvaluatesTo("true", "/read-doc/param", result);
7575

76-
String[] mimetypes = {"application/xml", "application/xml"};
77-
78-
ServiceResultIterator resultItr = resourceMgr.getResourceServices().get(params, mimetypes);
76+
ServiceResultIterator resultItr = resourceMgr.getResourceServices().get(params);
7977

8078
List<Document> resultDocuments = new ArrayList<>();
8179
DOMHandle readHandle = new DOMHandle();
@@ -119,7 +117,7 @@ public void testResourceServices() throws XpathException {
119117
assertXpathEvaluatesTo("true", "/applied-doc/param", result);
120118
assertXpathEvaluatesTo("true", "/applied-doc/input-doc", result);
121119

122-
resultItr = resourceMgr.getResourceServices().post(params, writeHandles, mimetypes);
120+
resultItr = resourceMgr.getResourceServices().post(params, writeHandles);
123121

124122
resultDocuments = new ArrayList<>();
125123
readHandle = new DOMHandle();

0 commit comments

Comments
 (0)