Skip to content

Commit fcc8459

Browse files
rjrudinMarkLogic Builder
authored andcommitted
DHFPROD-4483: Fixing custom rewriter for ML 10
The HEAD/PUT/DELETE dispatchers were referring to non-existent modules. They now refer to the OOTB ML modules.
1 parent a59309a commit fcc8459

File tree

2 files changed

+48
-3
lines changed

2 files changed

+48
-3
lines changed

marklogic-data-hub/src/main/resources/ml-modules/root/data-hub/5/rest-api/rewriter/10-rewriter.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@
333333
<match-header name="range">
334334
<dispatch>/data-hub/5/rest-api/endpoints/document-item-query.xqy</dispatch>
335335
</match-header>
336-
<dispatch>/data-hub/5/rest-api/endpoints/document-item-query-head.xqy</dispatch>
336+
<dispatch>/MarkLogic/rest-api/endpoints/document-item-query-head.xqy</dispatch>
337337
</match-method>
338338
<match-method any-of="OPTIONS">
339339
<match-query-param name="txid">
@@ -374,7 +374,7 @@
374374
<match-query-param name="transform">
375375
<dispatch>/data-hub/5/rest-api/endpoints/document-item-update.xqy</dispatch>
376376
</match-query-param>
377-
<dispatch>/data-hub/5/rest-api/endpoints/document-item-update-put.xqy</dispatch>
377+
<dispatch>/MarkLogic/rest-api/endpoints/document-item-update-put.xqy</dispatch>
378378
</match-method>
379379
<match-method any-of="DELETE">
380380
<match-query-param name="txid">
@@ -390,7 +390,7 @@
390390
<match-query-param name="category" repeated="true">
391391
<dispatch>/data-hub/5/rest-api/endpoints/document-item-update.xqy</dispatch>
392392
</match-query-param>
393-
<dispatch>/data-hub/5/rest-api/endpoints/document-item-update-delete.xqy</dispatch>
393+
<dispatch>/MarkLogic/rest-api/endpoints/document-item-update-delete.xqy</dispatch>
394394
</match-method>
395395
<match-method any-of="POST">
396396
<match-query-param name="txid">
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
package com.marklogic.hub.rewriter;
2+
3+
import com.fasterxml.jackson.databind.ObjectMapper;
4+
import com.fasterxml.jackson.databind.node.ObjectNode;
5+
import com.marklogic.client.DatabaseClient;
6+
import com.marklogic.client.document.JSONDocumentManager;
7+
import com.marklogic.client.io.DocumentMetadataHandle;
8+
import com.marklogic.client.io.JacksonHandle;
9+
import com.marklogic.hub.ApplicationConfig;
10+
import com.marklogic.hub.HubTestBase;
11+
import org.junit.jupiter.api.Test;
12+
import org.junit.jupiter.api.extension.ExtendWith;
13+
import org.springframework.test.context.ContextConfiguration;
14+
import org.springframework.test.context.junit.jupiter.SpringExtension;
15+
16+
import static org.junit.jupiter.api.Assertions.*;
17+
18+
@ExtendWith(SpringExtension.class)
19+
@ContextConfiguration(classes = ApplicationConfig.class)
20+
public class StagingRewriterTest extends HubTestBase {
21+
22+
/**
23+
* This is simply to verify that the custom rewriter for ML doesn't cause basic functions to fail. This was the
24+
* case prior to 5.2.0, as 10-rewriter.xml referred to some non-existent modules.
25+
*/
26+
@Test
27+
void test() {
28+
DatabaseClient client = adminHubConfig.newStagingClient();
29+
JSONDocumentManager mgr = client.newJSONDocumentManager();
30+
31+
final String uri = "/test.json";
32+
ObjectNode node = new ObjectMapper().createObjectNode();
33+
node.put("hello", "world");
34+
35+
DocumentMetadataHandle metadata = new DocumentMetadataHandle();
36+
metadata.getPermissions().add("data-hub-operator", DocumentMetadataHandle.Capability.READ, DocumentMetadataHandle.Capability.UPDATE);
37+
mgr.write(uri, metadata, new JacksonHandle(node));
38+
39+
assertEquals(uri, mgr.exists(uri).getUri());
40+
assertNotNull(mgr.read(uri, new JacksonHandle()).get());
41+
42+
mgr.delete(uri);
43+
assertNull(mgr.exists(uri));
44+
}
45+
}

0 commit comments

Comments
 (0)