diff --git a/examples/src/main/java/com/marklogic/client/example/cookbook/datamovement/BulkExportToJdbc.java b/examples/src/main/java/com/marklogic/client/example/cookbook/datamovement/BulkExportToJdbc.java index 6d62d64d5..ea0c19121 100644 --- a/examples/src/main/java/com/marklogic/client/example/cookbook/datamovement/BulkExportToJdbc.java +++ b/examples/src/main/java/com/marklogic/client/example/cookbook/datamovement/BulkExportToJdbc.java @@ -142,7 +142,7 @@ public void run() throws IOException, SQLException { // in a production application we could have more elaborate error // handling here - .onBatchFailure((failedBatch,exception) -> exception.printStackTrace()) + .onFailure((failedBatch,exception) -> exception.printStackTrace()) ) // another onUrisReady listener, this one custom, and just for logging diff --git a/examples/src/main/java/com/marklogic/client/example/cookbook/datamovement/BulkLoadFromJdbcRaw.java b/examples/src/main/java/com/marklogic/client/example/cookbook/datamovement/BulkLoadFromJdbcRaw.java index e187031c8..63b2cd944 100644 --- a/examples/src/main/java/com/marklogic/client/example/cookbook/datamovement/BulkLoadFromJdbcRaw.java +++ b/examples/src/main/java/com/marklogic/client/example/cookbook/datamovement/BulkLoadFromJdbcRaw.java @@ -207,7 +207,7 @@ public void transform() throws IOException, SQLException { ApplyTransformListener transformListener = new ApplyTransformListener() .withTransform(new ServerTransform("BulkLoadFromJdbcRaw")) .withApplyResult(ApplyTransformListener.ApplyResult.REPLACE) - .onBatchFailure((batch, throwable) -> throwable.printStackTrace()); + .onFailure((batch, throwable) -> throwable.printStackTrace()); // add the ApplyTransformListener to the QueryBatcher qb.onUrisReady(transformListener); diff --git a/marklogic-client-api-functionaltests/src/test/java/com/marklogic/client/fastfunctest/TestNamespaces.java b/marklogic-client-api-functionaltests/src/test/java/com/marklogic/client/fastfunctest/TestNamespaces.java deleted file mode 100644 index 5e6621100..000000000 --- a/marklogic-client-api-functionaltests/src/test/java/com/marklogic/client/fastfunctest/TestNamespaces.java +++ /dev/null @@ -1,167 +0,0 @@ -/* - * Copyright (c) 2023 MarkLogic Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - - -// This test needs to be removed/deleted when NamespaceManager Class is taken out of Java Client API package. -package com.marklogic.client.fastfunctest; - -import com.marklogic.client.DatabaseClient; -import com.marklogic.client.admin.NamespacesManager; -import com.marklogic.client.document.DocumentPatchBuilder; -import com.marklogic.client.document.XMLDocumentManager; -import com.marklogic.client.io.StringHandle; -import com.marklogic.client.util.EditableNamespaceContext; -import com.marklogic.client.util.RequestLogger; -import org.junit.jupiter.api.Test; - -import javax.xml.namespace.NamespaceContext; -import java.io.IOException; -import java.security.KeyManagementException; -import java.security.NoSuchAlgorithmException; -import java.util.Collection; - -import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.assertTrue; - -public class TestNamespaces extends AbstractFunctionalTest { - - @Test - public void testNamespaces() throws KeyManagementException, NoSuchAlgorithmException, IOException - { - System.out.println("Running testNamespaces"); - - // connect the client - DatabaseClient client = getDatabaseClient("rest-admin", "x", getConnType()); - - // create namespaces manager - NamespacesManager nsMgr = client.newServerConfigManager().newNamespacesManager(); - - // create logger - RequestLogger logger = client.newLogger(System.out); - logger.setContentMax(RequestLogger.ALL_CONTENT); - - // start logging - nsMgr.startLogging(logger); - - // add prefix - nsMgr.addPrefix("foo", "http://example.com"); - - NamespaceContext nsContext = nsMgr.readAll(); - - assertEquals( "foo", nsContext.getPrefix("http://example.com")); - assertEquals( "http://example.com", nsContext.getNamespaceURI("foo")); - - // update prefix - nsMgr.updatePrefix("foo", "http://exampleupdated.com"); - nsContext = nsMgr.readAll(); - assertEquals( "http://exampleupdated.com", nsContext.getNamespaceURI("foo")); - - // stop logging - nsMgr.stopLogging(); - - String expectedLogContentMax = "9223372036854775807"; - assertEquals( expectedLogContentMax, Long.toString(logger.getContentMax())); - - // delete prefix - nsMgr.deletePrefix("foo"); - assertTrue( nsMgr.readPrefix("foo") == null); - - nsMgr.deleteAll(); - assertTrue( nsMgr.readPrefix("foo") == null); - - // release client - client.release(); - } - - @Test - public void testDefaultNamespaces() throws KeyManagementException, NoSuchAlgorithmException, IOException - { - System.out.println("Running testDefaultNamespaces"); - - // connect the client - DatabaseClient client = getDatabaseClient("rest-admin", "x", getConnType()); - - // create namespaces manager - NamespacesManager nsMgr = client.newServerConfigManager().newNamespacesManager(); - - // add namespaces - nsMgr.addPrefix("ns1", "http://foo.com"); - nsMgr.addPrefix("ns2", "http://bar.com"); - nsMgr.addPrefix("ns3", "http://baz.com"); - - nsMgr.readAll(); - - // set default namespace - nsMgr.updatePrefix("defaultns", "http://baz.com"); - String defaultNsUri = nsMgr.readPrefix("defaultns"); - assertEquals( "http://baz.com", defaultNsUri); - - // delete namespace - nsMgr.deletePrefix("baz"); - nsMgr.readAll(); - - // get default namespace - assertEquals( "http://baz.com", nsMgr.readPrefix("defaultns")); - - nsMgr.deleteAll(); - nsMgr.readAll(); - assertTrue( nsMgr.readPrefix("ns1") == null); - assertTrue( nsMgr.readPrefix("ns2") == null); - assertTrue( nsMgr.readPrefix("ns3") == null); - assertTrue( nsMgr.readPrefix("defaultns") == null); - - // release client - client.release(); - } - - @Test - public void testBug22396() throws KeyManagementException, NoSuchAlgorithmException, IOException { - - System.out.println("Runing testBug22396"); - - DatabaseClient client = getDatabaseClient("rest-writer", "x", getConnType()); - - // write docs - writeDocumentUsingInputStreamHandle(client, "constraint1.xml", "/testBug22396/", "XML"); - - String docId = "/testBug22396/constraint1.xml"; - - // create document manager - XMLDocumentManager docMgr = client.newXMLDocumentManager(); - DocumentPatchBuilder patchBldr = docMgr.newPatchBuilder(); - - // get namespaces - Collection nameSpaceCollection = patchBldr.getNamespaces().getAllPrefixes(); - assertEquals(false, nameSpaceCollection.isEmpty()); - for (String prefix : nameSpaceCollection) { - System.out.println("Prefixes : " + prefix); - System.out.println(patchBldr.getNamespaces().getNamespaceURI(prefix)); - } - // set namespace - EditableNamespaceContext namespaces = new EditableNamespaceContext(); - namespaces.put("new", "http://www.marklogic.com"); - patchBldr.setNamespaces(namespaces); - System.out.println("\n Namespace Output : " + patchBldr.getNamespaces().getNamespaceURI("xmlns") + "\n Next xml : " + patchBldr.getNamespaces().getNamespaceURI("xml") - + "\n Next xs : " + patchBldr.getNamespaces().getNamespaceURI("xs") + "\n Next xsi : " + patchBldr.getNamespaces().getNamespaceURI("xsi") + "\n Next rapi : " - + patchBldr.getNamespaces().getNamespaceURI("rapi") + "\n Next new : " + patchBldr.getNamespaces().getNamespaceURI("new")); - String content = docMgr.read(docId, new StringHandle()).get(); - assertTrue(patchBldr.getNamespaces().getNamespaceURI("new").contains("www.marklogic.com")); - System.out.println(content); - - // release client - client.release(); - } -} diff --git a/marklogic-client-api/src/main/java/com/marklogic/client/admin/NamespacesManager.java b/marklogic-client-api/src/main/java/com/marklogic/client/admin/NamespacesManager.java deleted file mode 100644 index b702065fb..000000000 --- a/marklogic-client-api/src/main/java/com/marklogic/client/admin/NamespacesManager.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright (c) 2022 MarkLogic Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.marklogic.client.admin; - -import com.marklogic.client.FailedRequestException; -import com.marklogic.client.ForbiddenUserException; -import com.marklogic.client.util.RequestLogger; -import com.marklogic.client.ResourceNotFoundException; - -import javax.xml.namespace.NamespaceContext; - -/** - * Deprecated. To configure namespaces on a MarkLogic server, use Management REST API. - * - * See Management REST API - */ -@Deprecated -public interface NamespacesManager { - /** - * Returns the namespace URI bound to the specified prefix on the server. - * @param prefix the prefix for the binding - * @return the namespace URI - */ - @Deprecated - String readPrefix(String prefix) throws ForbiddenUserException, FailedRequestException; - /** - * Reads all of the namespace bindings from the server. - * @return a namespace context with the bindings - */ - @Deprecated - NamespaceContext readAll() throws ForbiddenUserException, FailedRequestException; - /** - * Creates a namespace binding on the server. - * @param prefix the prefix bound to the URI - * @param namespaceURI the URI bound to the prefix - */ - @Deprecated - void addPrefix(String prefix, String namespaceURI) throws ForbiddenUserException, FailedRequestException; - /** - * Writes a namespace binding on the server. - * @param prefix the prefix bound to the URI - * @param namespaceURI the URI bound to the prefix - */ - @Deprecated - void updatePrefix(String prefix, String namespaceURI) throws ResourceNotFoundException, ForbiddenUserException, FailedRequestException; - /** - * Deletes a namespace binding on the server. - * @param prefix the prefix bound to the URI - */ - @Deprecated - void deletePrefix(String prefix) throws ResourceNotFoundException, ForbiddenUserException, FailedRequestException; - /** - * Deletes all namespace bindings on the server. - */ - @Deprecated - void deleteAll() throws ForbiddenUserException, FailedRequestException; - /** - * Starts debugging client requests. You can suspend and resume debugging output - * using the methods of the logger. - * - * @param logger the logger that receives debugging output - */ - @Deprecated - void startLogging(RequestLogger logger); - /** - * Stops debugging client requests. - */ - @Deprecated - void stopLogging(); -} diff --git a/marklogic-client-api/src/main/java/com/marklogic/client/admin/ServerConfigurationManager.java b/marklogic-client-api/src/main/java/com/marklogic/client/admin/ServerConfigurationManager.java index 91178441b..d75e8aba2 100644 --- a/marklogic-client-api/src/main/java/com/marklogic/client/admin/ServerConfigurationManager.java +++ b/marklogic-client-api/src/main/java/com/marklogic/client/admin/ServerConfigurationManager.java @@ -160,14 +160,6 @@ void writeConfiguration() * @return a new manager for query options */ QueryOptionsManager newQueryOptionsManager(); - /** - * Deprecated. To configure namespaces on a MarkLogic server, use Management REST API. - * @return a new manager for namespace bindings - * - * See Management REST API - */ - @Deprecated - NamespacesManager newNamespacesManager(); /** * Creates a manager for listing, reading, writing, and deleting * resource service extensions. diff --git a/marklogic-client-api/src/main/java/com/marklogic/client/datamovement/ApplyTransformListener.java b/marklogic-client-api/src/main/java/com/marklogic/client/datamovement/ApplyTransformListener.java index 606eaba05..9eb752348 100644 --- a/marklogic-client-api/src/main/java/com/marklogic/client/datamovement/ApplyTransformListener.java +++ b/marklogic-client-api/src/main/java/com/marklogic/client/datamovement/ApplyTransformListener.java @@ -15,19 +15,21 @@ */ package com.marklogic.client.datamovement; -import com.marklogic.client.impl.DatabaseClientImpl; +import com.marklogic.client.datamovement.impl.QueryBatchImpl; import com.marklogic.client.document.ServerTransform; +import com.marklogic.client.impl.DatabaseClientImpl; import com.marklogic.client.impl.RESTServices; import com.marklogic.client.io.ReaderHandle; import com.marklogic.client.io.StringHandle; import com.marklogic.client.util.RequestParameters; -import com.marklogic.client.datamovement.impl.QueryBatchImpl; - import org.slf4j.Logger; import org.slf4j.LoggerFactory; import java.io.BufferedReader; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Iterator; +import java.util.List; import java.util.stream.Collectors; /** @@ -93,7 +95,7 @@ *

In order to handle such scenarios where we get an empty response, it is * recommended to add a BatchFailureListener which would take care of apply * transform failures and retry only for those URIs for which the apply - * transform has failed. If the transform is idempotent, we can just initialize + * transform has failed. If the transform is idempotent, we can just initialize * the RetryListener of the NoResponseListener by calling * NoResponseListener.initializeRetryListener(this) and add it to the * BatchFailureListeners similar to what we have in the other listeners.

@@ -104,7 +106,6 @@ public class ApplyTransformListener implements QueryBatchListener { private ApplyResult applyResult = ApplyResult.REPLACE; private List successListeners = new ArrayList<>(); private List skippedListeners = new ArrayList<>(); - private List>> failureListeners = new ArrayList<>(); private List> queryBatchFailureListeners = new ArrayList<>(); public ApplyTransformListener() { @@ -176,13 +177,6 @@ public void processEvent(QueryBatch batch) { } } } catch (Throwable t) { - for ( BatchFailureListener> listener : failureListeners ) { - try { - listener.processFailure(batch, t); - } catch (Throwable t2) { - logger.error("Exception thrown by an onBatchFailure listener", t2); - } - } for ( BatchFailureListener queryBatchFailureListener : queryBatchFailureListeners ) { try { queryBatchFailureListener.processFailure(batch, t); @@ -221,21 +215,6 @@ public ApplyTransformListener onSkipped(QueryBatchListener listener) { return this; } - /** - * When a batch fails or a callback throws an Exception, run this listener - * code. Multiple listeners can be registered with this method. - * - * @param listener the code to run when a failure occurs - * - * @return this instance for method chaining - * @deprecated use {@link #onFailure(BatchFailureListener)} - */ - @Deprecated - public ApplyTransformListener onBatchFailure(BatchFailureListener> listener) { - failureListeners.add(listener); - return this; - } - /** * When a batch fails or a callback throws an Exception, run this listener * code. Multiple listeners can be registered with this method. diff --git a/marklogic-client-api/src/main/java/com/marklogic/client/datamovement/DeleteListener.java b/marklogic-client-api/src/main/java/com/marklogic/client/datamovement/DeleteListener.java index 0e32dbe09..bdd8b790a 100644 --- a/marklogic-client-api/src/main/java/com/marklogic/client/datamovement/DeleteListener.java +++ b/marklogic-client-api/src/main/java/com/marklogic/client/datamovement/DeleteListener.java @@ -65,7 +65,6 @@ */ public class DeleteListener implements QueryBatchListener { private static Logger logger = LoggerFactory.getLogger(DeleteListener.class); - private List>> failureListeners = new ArrayList<>(); private List> queryBatchFailureListeners = new ArrayList<>(); public DeleteListener() { @@ -103,13 +102,6 @@ public void processEvent(QueryBatch batch) { } batch.getClient().newDocumentManager().delete( batch.getItems() ); } catch (Throwable t) { - for ( BatchFailureListener> listener : failureListeners ) { - try { - listener.processFailure(batch, t); - } catch (Throwable t2) { - logger.error("Exception thrown by an onBatchFailure listener", t2); - } - } for ( BatchFailureListener queryBatchFailureListener : queryBatchFailureListeners ) { try { queryBatchFailureListener.processFailure(batch, t); @@ -120,21 +112,6 @@ public void processEvent(QueryBatch batch) { } } - /** - * When a batch fails or a callback throws an Exception, run this listener - * code. Multiple listeners can be registered with this method. - * - * @param listener the code to run when a failure occurs - * - * @return this instance for method chaining - * @deprecated use {@link #onFailure(BatchFailureListener)} - */ - @Deprecated - public DeleteListener onBatchFailure(BatchFailureListener> listener) { - failureListeners.add(listener); - return this; - } - /** * When a batch fails or a callback throws an Exception, run this listener * code. Multiple listeners can be registered with this method. diff --git a/marklogic-client-api/src/main/java/com/marklogic/client/datamovement/ExportListener.java b/marklogic-client-api/src/main/java/com/marklogic/client/datamovement/ExportListener.java index d336d3bd9..1caf52396 100644 --- a/marklogic-client-api/src/main/java/com/marklogic/client/datamovement/ExportListener.java +++ b/marklogic-client-api/src/main/java/com/marklogic/client/datamovement/ExportListener.java @@ -15,15 +15,10 @@ */ package com.marklogic.client.datamovement; -import com.marklogic.client.document.DocumentManager; -import com.marklogic.client.document.DocumentPage; -import com.marklogic.client.document.DocumentRecord; -import com.marklogic.client.document.GenericDocumentManager; +import com.marklogic.client.document.*; import com.marklogic.client.impl.GenericDocumentImpl; -import com.marklogic.client.document.ServerTransform; import com.marklogic.client.io.Format; import com.marklogic.client.query.QueryManager; - import com.marklogic.client.query.StructuredQueryDefinition; import org.slf4j.Logger; import org.slf4j.LoggerFactory; @@ -77,7 +72,6 @@ public class ExportListener implements QueryBatchListener { private List> documentListeners = new ArrayList<>(); private Consumer documentPageListener; private boolean consistentSnapshot = false; - private List>> failureListeners = new ArrayList<>(); private List> queryBatchFailureListeners = new ArrayList<>(); public ExportListener() { @@ -142,13 +136,6 @@ public void processEvent(QueryBatch batch) { } } } catch (Throwable t) { - for ( BatchFailureListener> listener : failureListeners ) { - try { - listener.processFailure(batch, t); - } catch (Throwable t2) { - logger.error("Exception thrown by an onBatchFailure listener", t2); - } - } for ( BatchFailureListener queryBatchFailureListener : queryBatchFailureListeners ) { try { queryBatchFailureListener.processFailure(batch, t); @@ -272,21 +259,6 @@ public ExportListener onDocumentPageReady(Consumer listener) { return this; } - /** - * When a batch fails or a callback throws an Exception, run this listener - * code. Multiple listeners can be registered with this method. - * - * @param listener the code to run when a failure occurs - * - * @return this instance for method chaining - * @deprecated use {@link #onFailure(BatchFailureListener)} - */ - @Deprecated - public ExportListener onBatchFailure(BatchFailureListener> listener) { - failureListeners.add(listener); - return this; - } - /** * When a batch fails or a callback throws an Exception, run this listener * code. Multiple listeners can be registered with this method. @@ -300,11 +272,6 @@ public ExportListener onFailure(BatchFailureListener listener) { return this; } - @Deprecated - protected List>> getFailureListeners() { - return failureListeners; - } - protected List> getBatchFailureListeners() { return queryBatchFailureListeners; } diff --git a/marklogic-client-api/src/main/java/com/marklogic/client/datamovement/ExportToWriterListener.java b/marklogic-client-api/src/main/java/com/marklogic/client/datamovement/ExportToWriterListener.java index 9bb129225..b8d66a0a8 100644 --- a/marklogic-client-api/src/main/java/com/marklogic/client/datamovement/ExportToWriterListener.java +++ b/marklogic-client-api/src/main/java/com/marklogic/client/datamovement/ExportToWriterListener.java @@ -116,13 +116,6 @@ public void processEvent(QueryBatch batch) { } } } catch (Throwable t) { - for ( BatchFailureListener> listener : getFailureListeners() ) { - try { - listener.processFailure(batch, t); - } catch (Throwable t2) { - logger.error("Exception thrown by an onBatchFailure listener", t2); - } - } for ( BatchFailureListener queryBatchFailureListener : getBatchFailureListeners() ) { try { queryBatchFailureListener.processFailure(batch, t); diff --git a/marklogic-client-api/src/main/java/com/marklogic/client/datamovement/QueryBatcher.java b/marklogic-client-api/src/main/java/com/marklogic/client/datamovement/QueryBatcher.java index d273b9db7..da3bb9573 100644 --- a/marklogic-client-api/src/main/java/com/marklogic/client/datamovement/QueryBatcher.java +++ b/marklogic-client-api/src/main/java/com/marklogic/client/datamovement/QueryBatcher.java @@ -157,18 +157,6 @@ public interface QueryBatcher extends Batcher { */ public void retry(QueryEvent queryEvent); - /** - * Get the array of QueryBatchListener instances registered via - * onUrisReady. - * - * @return the QueryBatchListener instances this batcher - * is using - * - * @deprecated (as of 4.0.4) this should have been called getUrisReadyListeners - */ - @Deprecated - QueryBatchListener[] getQuerySuccessListeners(); - /** * Get the array of QueryBatchListener instances registered via * onUrisReady. diff --git a/marklogic-client-api/src/main/java/com/marklogic/client/datamovement/UrisToWriterListener.java b/marklogic-client-api/src/main/java/com/marklogic/client/datamovement/UrisToWriterListener.java index 5705d8a1b..42cff6c71 100644 --- a/marklogic-client-api/src/main/java/com/marklogic/client/datamovement/UrisToWriterListener.java +++ b/marklogic-client-api/src/main/java/com/marklogic/client/datamovement/UrisToWriterListener.java @@ -67,7 +67,6 @@ public class UrisToWriterListener implements QueryBatchListener { private String suffix = "\n"; private String prefix; private List outputListeners = new ArrayList<>(); - private List>> failureListeners = new ArrayList<>(); private List> queryBatchFailureListeners = new ArrayList<>(); public UrisToWriterListener(Writer writer) { @@ -124,13 +123,6 @@ public void processEvent(QueryBatch batch) { } } } catch (Throwable t) { - for ( BatchFailureListener> listener : failureListeners ) { - try { - listener.processFailure(batch, t); - } catch (Throwable t2) { - logger.error("Exception thrown by an onBatchFailure listener", t2); - } - } for ( BatchFailureListener queryBatchFailureListener : queryBatchFailureListeners ) { try { queryBatchFailureListener.processFailure(batch, t); @@ -156,21 +148,6 @@ public UrisToWriterListener onGenerateOutput(OutputListener listener) { return this; } - /** - * When a batch fails or a callback throws an Exception, run this listener - * code. Multiple listeners can be registered with this method. - * - * @param listener the code to run when a failure occurs - * - * @return this instance for method chaining - * @deprecated use {@link #onFailure(BatchFailureListener)} - */ - @Deprecated - public UrisToWriterListener onBatchFailure(BatchFailureListener> listener) { - failureListeners.add(listener); - return this; - } - /** * When a batch fails or a callback throws an Exception, run this listener * code. Multiple listeners can be registered with this method. diff --git a/marklogic-client-api/src/main/java/com/marklogic/client/datamovement/impl/JobReportImpl.java b/marklogic-client-api/src/main/java/com/marklogic/client/datamovement/impl/JobReportImpl.java index 7c4e7d87c..39562ac73 100644 --- a/marklogic-client-api/src/main/java/com/marklogic/client/datamovement/impl/JobReportImpl.java +++ b/marklogic-client-api/src/main/java/com/marklogic/client/datamovement/impl/JobReportImpl.java @@ -84,15 +84,13 @@ public JobReportImpl(WriteBatcher batcher) { public JobReportImpl(QueryBatcher batcher) { QueryJobReportListener queryJobSuccessListener = null; QueryJobReportListener queryJobFailureListener = null; - QueryBatchListener[] batchListeners = batcher.getQuerySuccessListeners(); - for(QueryBatchListener batchListener : batchListeners) { + for(QueryBatchListener batchListener : batcher.getUrisReadyListeners()) { if(batchListener instanceof QueryJobReportListener) { queryJobSuccessListener = (QueryJobReportListener) batchListener; break; } } - QueryFailureListener[] failureListeners = batcher.getQueryFailureListeners(); - for(QueryFailureListener failureListener : failureListeners) { + for(QueryFailureListener failureListener : batcher.getQueryFailureListeners()) { if(failureListener instanceof QueryJobReportListener) { queryJobFailureListener = (QueryJobReportListener) failureListener; break; diff --git a/marklogic-client-api/src/main/java/com/marklogic/client/datamovement/impl/QueryBatcherImpl.java b/marklogic-client-api/src/main/java/com/marklogic/client/datamovement/impl/QueryBatcherImpl.java index fdbd9cea2..a5ef71bd8 100644 --- a/marklogic-client-api/src/main/java/com/marklogic/client/datamovement/impl/QueryBatcherImpl.java +++ b/marklogic-client-api/src/main/java/com/marklogic/client/datamovement/impl/QueryBatcherImpl.java @@ -258,11 +258,6 @@ public void retryListener(QueryBatch batch, QueryBatchListener queryBatchListene queryBatchListener.processEvent(retryBatch); } - @Override - public QueryBatchListener[] getQuerySuccessListeners() { - return getUrisReadyListeners(); - } - @Override public QueryBatchListener[] getUrisReadyListeners() { return urisReadyListeners.toArray(new QueryBatchListener[urisReadyListeners.size()]); diff --git a/marklogic-client-api/src/main/java/com/marklogic/client/extensions/ResourceServices.java b/marklogic-client-api/src/main/java/com/marklogic/client/extensions/ResourceServices.java index edd455712..6c7305ae1 100644 --- a/marklogic-client-api/src/main/java/com/marklogic/client/extensions/ResourceServices.java +++ b/marklogic-client-api/src/main/java/com/marklogic/client/extensions/ResourceServices.java @@ -27,7 +27,7 @@ /** * A ResourceServices object supports calling the services for a resource. * The Resource Services extension must have been installed on the server - * previously, which can be done with + * previously, which can be done with * {@link com.marklogic.client.admin.ResourceExtensionsManager}. * A {@link ResourceManager} object * receives a ResourceServices object when it is initialized by the @@ -61,18 +61,16 @@ public interface ResourceServices { /** * Reads multiple resource content by calling a GET service. * @param params the parameters for the call - * @param mimetypes the mimetypes for the requested content; deprecated since 6.0.0, has always been ignored by implementation * @return an iterator over the requested content */ - ServiceResultIterator get(RequestParameters params, @Deprecated String... mimetypes); + ServiceResultIterator get(RequestParameters params); /** * Reads multiple resource content by calling a GET service. * @param params the parameters for the call * @param transaction the transaction for reading content - * @param mimetypes the mimetypes for the requested content; deprecated since 6.0.0, has always been ignored by implementation * @return an iterator over the requested content */ - ServiceResultIterator get(RequestParameters params, Transaction transaction, @Deprecated String... mimetypes); + ServiceResultIterator get(RequestParameters params, Transaction transaction); /** * Writes content by calling a PUT service. @@ -160,38 +158,34 @@ public interface ResourceServices { * Applies multiple content by calling a POST service. * @param params the parameters for the call * @param input the content passed with the call - * @param mimetypes the mimetypes for the requested content; deprecated since 6.0.0, has always been ignored by implementation * @return an iterator over the requested content */ - ServiceResultIterator post(RequestParameters params, AbstractWriteHandle input, @Deprecated String... mimetypes); + ServiceResultIterator post(RequestParameters params, AbstractWriteHandle input); /** * Applies multiple content by calling a POST service. * @param params the parameters for the call * @param input the content passed with the call * @param transaction the transaction for applying content - * @param mimetypes the mimetypes for the requested content; deprecated since 6.0.0, has always been ignored by implementation * @return an iterator over the requested content */ - ServiceResultIterator post(RequestParameters params, AbstractWriteHandle input, Transaction transaction, @Deprecated String... mimetypes); + ServiceResultIterator post(RequestParameters params, AbstractWriteHandle input, Transaction transaction); /** * Applies multiple content by calling a POST service. * @param params the parameters for the call * @param input an array of content passed with the call - * @param mimetypes the mimetypes for the requested content; deprecated since 6.0.0, has always been ignored by implementation * @param the type of AbstractWriteHandle's with content to send * @return an iterator over the requested content */ - ServiceResultIterator post(RequestParameters params, W[] input, @Deprecated String... mimetypes); + ServiceResultIterator post(RequestParameters params, W[] input); /** * Applies multiple content by calling a POST service. * @param params the parameters for the call * @param input an array of content passed with the call * @param transaction the transaction for applying content - * @param mimetypes the mimetypes for the requested content; deprecated since 6.0.0, has always been ignored by implementation * @param the type of AbstractWriteHandle's with content to send * @return an iterator over the requested content */ - ServiceResultIterator post(RequestParameters params, W[] input, Transaction transaction, @Deprecated String... mimetypes); + ServiceResultIterator post(RequestParameters params, W[] input, Transaction transaction); /** * Deletes content by calling a DELETE service. diff --git a/marklogic-client-api/src/main/java/com/marklogic/client/impl/NamespacesManagerImpl.java b/marklogic-client-api/src/main/java/com/marklogic/client/impl/NamespacesManagerImpl.java deleted file mode 100644 index 4ad277274..000000000 --- a/marklogic-client-api/src/main/java/com/marklogic/client/impl/NamespacesManagerImpl.java +++ /dev/null @@ -1,192 +0,0 @@ -/* - * Copyright (c) 2022 MarkLogic Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.marklogic.client.impl; - -import java.io.IOException; -import java.io.InputStream; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -import javax.xml.namespace.NamespaceContext; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.xml.sax.SAXException; - -import com.marklogic.client.util.EditableNamespaceContext; -import com.marklogic.client.FailedRequestException; -import com.marklogic.client.ForbiddenUserException; -import com.marklogic.client.MarkLogicInternalException; -import com.marklogic.client.admin.NamespacesManager; -import com.marklogic.client.ResourceNotFoundException; - -class NamespacesManagerImpl - extends AbstractLoggingManager - implements NamespacesManager -{ - static final private Logger logger = LoggerFactory.getLogger(NamespacesManagerImpl.class); - - static final private Pattern NAMESPACE_PATTERN = Pattern.compile( - "<([^: >]+:)?uri(\\s[^>]+)?>([^<>]+)]+:)?uri>" - ); - - private RESTServices services; - - NamespacesManagerImpl(RESTServices services) { - super(); - this.services = services; - } - - @Override - public String readPrefix(String prefix) throws ForbiddenUserException, FailedRequestException { - if (prefix == null) - throw new IllegalArgumentException("Cannot read namespace for null prefix"); - if (prefix.length() == 0) - throw new IllegalArgumentException("Server does not maintain a default namespace"); - - String binding = services.getValue( - requestLogger, "config/namespaces", prefix, true, "application/xml", String.class); - if (binding == null) - return null; - - Matcher matcher = NAMESPACE_PATTERN.matcher(binding); - if (!matcher.find()) { - if (logger.isWarnEnabled()) - logger.warn("Failed to extract namespace from {}", binding); - return null; - } - - return matcher.toMatchResult().group(3); - } - @Override - public NamespaceContext readAll() throws ForbiddenUserException, FailedRequestException { - EditableNamespaceContext context = new EditableNamespaceContext(); - - try { - InputStream stream = services.getValues(requestLogger, "config/namespaces", "application/xml", InputStream.class); - if (stream == null) - return null; - - DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance(); - factory.setNamespaceAware(true); - factory.setValidating(false); - - Document document = factory.newDocumentBuilder().parse(stream); - NodeList bindings = - document.getElementsByTagNameNS("http://marklogic.com/rest-api", "namespace"); - if (bindings == null) - return null; - - int bindingsCount = bindings.getLength(); - if (bindingsCount < 1) - return null; - - for (int i=0; i < bindingsCount; i++) { - Node binding = bindings.item(i); - - NodeList children = binding.getChildNodes(); - if (children == null) - continue; - - String prefix = null; - String namespaceUri = null; - for (int j=0; j < children.getLength(); j++) { - Node child = children.item(j); - if (child.getNodeType() != Node.ELEMENT_NODE) - continue; - - Element element = (Element) child; - if ("prefix".equals(element.getLocalName())) - prefix = element.getTextContent(); - else if ("uri".equals(element.getLocalName())) - namespaceUri = element.getTextContent(); - } - if (prefix == null || namespaceUri == null) - continue; - - context.put(prefix, namespaceUri); - } - } catch (SAXException e) { - logger.error("Failed to parse DOM document for namespace bindings",e); - throw new MarkLogicInternalException(e); - } catch (IOException e) { - logger.error("Failed to parse DOM document for namespace bindings",e); - throw new MarkLogicInternalException(e); - } catch (ParserConfigurationException e) { - logger.error("Failed to parse DOM document for namespace bindings",e); - throw new MarkLogicInternalException(e); - } - - return context; - } - @Override - public void addPrefix(String prefix, String namespaceUri) throws ForbiddenUserException, FailedRequestException { - if (prefix == null) - throw new IllegalArgumentException("Cannot write binding for null prefix"); - if (prefix.length() == 0) - throw new IllegalArgumentException("Cannot specify a default namespace"); - if (namespaceUri == null) - throw new IllegalArgumentException("Cannot write binding for null namespaceUri"); - - String structure = - "\n"+ - "" + - "\n"+ - " "+prefix+"\n"+ - " "+namespaceUri+"\n"+ - "\n"+ - ""; - - services.postValue(requestLogger, "config/namespaces", prefix, "application/xml", structure); - } - @Override - public void updatePrefix(String prefix, String namespaceUri) throws ResourceNotFoundException, ForbiddenUserException, FailedRequestException { - if (prefix == null) - throw new IllegalArgumentException("Cannot write binding for null prefix"); - if (prefix.length() == 0) - throw new IllegalArgumentException("Cannot specify a default namespace"); - if (namespaceUri == null) - throw new IllegalArgumentException("Cannot write binding for null namespaceUri"); - - String structure = - "\n"+ - "\n"+ - " "+prefix+"\n"+ - " "+namespaceUri+"\n"+ - "\n"; - - services.putValue(requestLogger, "config/namespaces", prefix, "application/xml", structure); - } - @Override - public void deletePrefix(String prefix) throws ResourceNotFoundException, ForbiddenUserException, FailedRequestException { - if (prefix == null) - throw new IllegalArgumentException("Cannot delete binding for null prefix"); - if (prefix.length() == 0) - throw new IllegalArgumentException("Server does not maintain a default namespace"); - - services.deleteValue(requestLogger, "config/namespaces", prefix); - } - @Override - public void deleteAll() throws ForbiddenUserException, FailedRequestException { - services.deleteValues(requestLogger, "config/namespaces"); - } -} diff --git a/marklogic-client-api/src/main/java/com/marklogic/client/impl/ResourceServicesImpl.java b/marklogic-client-api/src/main/java/com/marklogic/client/impl/ResourceServicesImpl.java index 005500177..946e26782 100644 --- a/marklogic-client-api/src/main/java/com/marklogic/client/impl/ResourceServicesImpl.java +++ b/marklogic-client-api/src/main/java/com/marklogic/client/impl/ResourceServicesImpl.java @@ -53,11 +53,11 @@ public R get(RequestParameters params, Transactio transaction, prepareParams(params), output); } @Override - public ServiceResultIterator get(RequestParameters params, @Deprecated String... outputMimetypes) { - return get(params, null, outputMimetypes); + public ServiceResultIterator get(RequestParameters params) { + return get(params, (Transaction)null); } @Override - public ServiceResultIterator get(RequestParameters params, Transaction transaction, @Deprecated String... outputMimetypes) { + public ServiceResultIterator get(RequestParameters params, Transaction transaction) { return services.getIteratedResource(requestLogger, getResourcePath(), transaction, prepareParams(params)); } @@ -90,11 +90,11 @@ public R post(RequestParameters params, AbstractW requestLogger, getResourcePath(), transaction, prepareParams(params), input, output); } @Override - public ServiceResultIterator post(RequestParameters params, AbstractWriteHandle input, @Deprecated String... outputMimetypes) { - return post(params, input, null, outputMimetypes); + public ServiceResultIterator post(RequestParameters params, AbstractWriteHandle input) { + return post(params, input, (Transaction)null); } @Override - public ServiceResultIterator post(RequestParameters params, AbstractWriteHandle input, Transaction transaction, @Deprecated String... outputMimetypes) { + public ServiceResultIterator post(RequestParameters params, AbstractWriteHandle input, Transaction transaction) { return services.postIteratedResource( requestLogger, getResourcePath(), transaction, prepareParams(params), input); } @@ -108,11 +108,11 @@ public R post(Requ requestLogger, getResourcePath(), transaction, prepareParams(params), input, output); } @Override - public ServiceResultIterator post(RequestParameters params, W[] input, @Deprecated String... outputMimetypes) { - return post(params, input, null, outputMimetypes); + public ServiceResultIterator post(RequestParameters params, W[] input) { + return post(params, input, (Transaction) null); } @Override - public ServiceResultIterator post(RequestParameters params, W[] input, Transaction transaction, @Deprecated String... outputMimetypes) { + public ServiceResultIterator post(RequestParameters params, W[] input, Transaction transaction) { return services.postIteratedResource( requestLogger, getResourcePath(), transaction, prepareParams(params), input); } diff --git a/marklogic-client-api/src/main/java/com/marklogic/client/impl/ServerConfigurationManagerImpl.java b/marklogic-client-api/src/main/java/com/marklogic/client/impl/ServerConfigurationManagerImpl.java index f49d4cd5c..d2d259b5d 100644 --- a/marklogic-client-api/src/main/java/com/marklogic/client/impl/ServerConfigurationManagerImpl.java +++ b/marklogic-client-api/src/main/java/com/marklogic/client/impl/ServerConfigurationManagerImpl.java @@ -15,33 +15,18 @@ */ package com.marklogic.client.impl; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; - -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLOutputFactory; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamReader; -import javax.xml.stream.XMLStreamWriter; - -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - import com.marklogic.client.DatabaseClientFactory.HandleFactoryRegistry; -import com.marklogic.client.FailedRequestException; -import com.marklogic.client.ForbiddenUserException; -import com.marklogic.client.MarkLogicInternalException; -import com.marklogic.client.ResourceNotFoundException; -import com.marklogic.client.ResourceNotResendableException; -import com.marklogic.client.admin.ExtensionLibrariesManager; -import com.marklogic.client.admin.NamespacesManager; -import com.marklogic.client.admin.QueryOptionsManager; -import com.marklogic.client.admin.ResourceExtensionsManager; -import com.marklogic.client.admin.ServerConfigurationManager; -import com.marklogic.client.admin.TransformExtensionsManager; +import com.marklogic.client.*; +import com.marklogic.client.admin.*; import com.marklogic.client.io.OutputStreamHandle; import com.marklogic.client.io.OutputStreamSender; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import javax.xml.stream.*; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; class ServerConfigurationManagerImpl implements ServerConfigurationManager, OutputStreamSender @@ -284,10 +269,6 @@ public ExtensionLibrariesManager newExtensionLibrariesManager() { return extensionMgr; } @Override - public NamespacesManager newNamespacesManager() { - return new NamespacesManagerImpl(services); - } - @Override public QueryOptionsManager newQueryOptionsManager() { QueryOptionsManagerImpl optMgr = new QueryOptionsManagerImpl(services); optMgr.setHandleRegistry(getHandleRegistry()); diff --git a/marklogic-client-api/src/main/java/com/marklogic/client/io/SearchHandle.java b/marklogic-client-api/src/main/java/com/marklogic/client/io/SearchHandle.java index 1bdd1d3e8..c44ae6fc5 100644 --- a/marklogic-client-api/src/main/java/com/marklogic/client/io/SearchHandle.java +++ b/marklogic-client-api/src/main/java/com/marklogic/client/io/SearchHandle.java @@ -442,15 +442,13 @@ static private class SearchMetricsImpl implements SearchMetrics { long qrTime = -1; long frTime = -1; long srTime = -1; - long mrTime = -1; long erTime = -1; long totalTime = -1; - public SearchMetricsImpl(long qrTime, long frTime, long srTime, long mrTime, long erTime, long totalTime) { + public SearchMetricsImpl(long qrTime, long frTime, long srTime, long erTime, long totalTime) { this.qrTime = qrTime; this.frTime = frTime; this.srTime = srTime; - this.mrTime = mrTime; this.erTime = erTime; this.totalTime = totalTime; } @@ -470,11 +468,6 @@ public long getSnippetResolutionTime() { return srTime; } - @Override - public long getMetadataResolutionTime() { - return mrTime; - } - @Override public long getExtractResolutionTime() { return erTime; @@ -1519,7 +1512,6 @@ private void handleMetrics(XMLEventReader reader, StartElement element) long qrTime = -1; long frTime = -1; long srTime = -1; - long mrTime = -1; long erTime = -1; long tTime = -1; @@ -1540,9 +1532,7 @@ private void handleMetrics(XMLEventReader reader, StartElement element) frTime = parseTime(dtFactory, now, readerValue); } else if (snippetName.equals(startName)) { srTime = parseTime(dtFactory, now, readerValue); - } else if (metadataName.equals(startName)) { - mrTime = parseTime(dtFactory, now, readerValue); - } else if (extractName.equals(startName)) { + }else if (extractName.equals(startName)) { erTime = parseTime(dtFactory, now, readerValue); } else if (totalName.equals(startName)) { tTime = parseTime(dtFactory, now, readerValue); @@ -1559,7 +1549,7 @@ private void handleMetrics(XMLEventReader reader, StartElement element) } } - tempMetrics = new SearchMetricsImpl(qrTime, frTime, srTime, mrTime, erTime, tTime); + tempMetrics = new SearchMetricsImpl(qrTime, frTime, srTime, erTime, tTime); } private void handleConstraint(XMLEventReader reader, StartElement element) throws XMLStreamException diff --git a/marklogic-client-api/src/main/java/com/marklogic/client/query/SearchMetrics.java b/marklogic-client-api/src/main/java/com/marklogic/client/query/SearchMetrics.java index f300db253..6ec972a26 100644 --- a/marklogic-client-api/src/main/java/com/marklogic/client/query/SearchMetrics.java +++ b/marklogic-client-api/src/main/java/com/marklogic/client/query/SearchMetrics.java @@ -37,14 +37,6 @@ public interface SearchMetrics { */ long getSnippetResolutionTime(); - /** - * Returns the metadata resolution time in milliseconds. - * @return The metadata resolution time. - * @deprecated (as of 4.0.1) this is only populated when using the deprecated option extract-metadata - */ - @Deprecated - long getMetadataResolutionTime(); - /** * Returns the extract resolution time in milliseconds. * @return The extract resolution time. diff --git a/marklogic-client-api/src/main/java/com/marklogic/client/query/StructuredQueryBuilder.java b/marklogic-client-api/src/main/java/com/marklogic/client/query/StructuredQueryBuilder.java index 08018a685..db9128a95 100644 --- a/marklogic-client-api/src/main/java/com/marklogic/client/query/StructuredQueryBuilder.java +++ b/marklogic-client-api/src/main/java/com/marklogic/client/query/StructuredQueryBuilder.java @@ -15,24 +15,6 @@ */ package com.marklogic.client.query; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.OutputStream; -import java.util.Calendar; -import java.util.Date; -import java.util.HashMap; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentMap; - -import javax.xml.XMLConstants; -import jakarta.xml.bind.DatatypeConverter; -import javax.xml.namespace.QName; -import javax.xml.stream.XMLOutputFactory; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.XMLStreamWriter; -import javax.xml.transform.Templates; - import com.marklogic.client.MarkLogicIOException; import com.marklogic.client.impl.AbstractQueryDefinition; import com.marklogic.client.impl.RawQueryDefinitionImpl; @@ -46,6 +28,23 @@ import com.marklogic.client.io.marker.XMLWriteHandle; import com.marklogic.client.util.EditableNamespaceContext; import com.marklogic.client.util.IterableNamespaceContext; +import jakarta.xml.bind.DatatypeConverter; + +import javax.xml.XMLConstants; +import javax.xml.namespace.QName; +import javax.xml.stream.XMLOutputFactory; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.XMLStreamWriter; +import javax.xml.transform.Templates; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.util.Calendar; +import java.util.Date; +import java.util.HashMap; +import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; +import java.util.concurrent.ConcurrentMap; /** * StructuredQueryBuilder builds a query for documents in the database. @@ -462,22 +461,6 @@ public StructuredQueryDefinition directory(boolean isInfinite, String... uris) { return new DirectoryQuery(isInfinite, uris); } - /** - * Matches documents at the specified depth within at least one - * of the criteria directories. - * @param depth specifies how many subdirectories deep to traverse - * A value of 1 means to exclude subdirectories. - * @param uris the identifiers for the criteria directories - * @return the StructuredQueryDefinition for the directory query - * @deprecated since 6.4.0; a directory query in MarkLogic does not support custom depths; it is either limited - * to the given directory or it is "infinite". For that reason, prefer the {@code directory} method that accepts a - * boolean indicating whether the directory query is infinite. - */ - @Deprecated - public StructuredQueryDefinition directory(int depth, String... uris) { - return new DirectoryQuery(depth, uris); - } - /** * Matches the specified documents. * @param uris the identifiers for the documents diff --git a/marklogic-client-api/src/test/java/com/marklogic/client/test/NamespacesManagerTest.java b/marklogic-client-api/src/test/java/com/marklogic/client/test/NamespacesManagerTest.java deleted file mode 100644 index bb9e5eb0f..000000000 --- a/marklogic-client-api/src/test/java/com/marklogic/client/test/NamespacesManagerTest.java +++ /dev/null @@ -1,106 +0,0 @@ -/* - * Copyright (c) 2023 MarkLogic Corporation - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.marklogic.client.test; - -import com.marklogic.client.FailedRequestException; -import com.marklogic.client.ForbiddenUserException; -import com.marklogic.client.ResourceNotFoundException; -import com.marklogic.client.admin.NamespacesManager; -import com.marklogic.client.util.EditableNamespaceContext; -import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.BeforeAll; -import org.junit.jupiter.api.Test; - -import static org.junit.jupiter.api.Assertions.*; - -public class NamespacesManagerTest { - @BeforeAll - public static void beforeClass() { - Common.connectRestAdmin(); - } - @AfterAll - public static void afterClass() { - } - - @Test - public void testWriteReadPrefix() - throws ForbiddenUserException, FailedRequestException, ResourceNotFoundException - { - NamespacesManager nsMgr = - Common.restAdminClient.newServerConfigManager().newNamespacesManager(); - - nsMgr.updatePrefix("dc", "http://purl.org/dc/terms/"); - - String nsUri = nsMgr.readPrefix("dc"); - assertEquals( nsUri, "http://purl.org/dc/terms/"); - - nsMgr.updatePrefix("rdf", "http://www.w3.org/1999/02/22-rdf-syntax-ns#"); - nsMgr.updatePrefix("skos", "http://www.w3.org/2004/02/skos/core#"); - - EditableNamespaceContext context = (EditableNamespaceContext) nsMgr.readAll(); - - int initialSize = context.size(); - assertTrue( initialSize >= 3); - assertEquals( - "http://purl.org/dc/terms/", - context.get("dc")); - assertEquals( - "http://www.w3.org/1999/02/22-rdf-syntax-ns#", - context.get("rdf")); - assertEquals( - "http://www.w3.org/2004/02/skos/core#", - context.get("skos")); - - nsMgr.updatePrefix("dc", "http://diverted/category/"); - - nsUri = nsMgr.readPrefix("dc"); - assertEquals( nsUri, "http://diverted/category/"); - - nsMgr.deletePrefix("dc"); - context = (EditableNamespaceContext) nsMgr.readAll(); - // assumes no concurrent deletes - assertEquals( initialSize - 1, context.size()); - - nsMgr.deleteAll(); - context = (EditableNamespaceContext) nsMgr.readAll(); - assertTrue( - context == null || context.size() == 0); - } - - @Test - public void testExceptions() - throws ForbiddenUserException, FailedRequestException, ResourceNotFoundException - { - NamespacesManager nsMgr = - Common.restAdminClient.newServerConfigManager().newNamespacesManager(); - - boolean illegalArgument = false; - try { - nsMgr.updatePrefix(javax.xml.XMLConstants.DEFAULT_NS_PREFIX, "http://invalid"); - } catch (IllegalArgumentException e) { - illegalArgument = true; - } - assertTrue( illegalArgument); - - illegalArgument = false; - try { - nsMgr.addPrefix(javax.xml.XMLConstants.DEFAULT_NS_PREFIX, "http://invalid"); - } catch (IllegalArgumentException e) { - illegalArgument = true; - } - assertTrue( illegalArgument); - } -} diff --git a/marklogic-client-api/src/test/java/com/marklogic/client/test/StringSearchTest.java b/marklogic-client-api/src/test/java/com/marklogic/client/test/StringSearchTest.java index b37c469b3..56721c6e6 100644 --- a/marklogic-client-api/src/test/java/com/marklogic/client/test/StringSearchTest.java +++ b/marklogic-client-api/src/test/java/com/marklogic/client/test/StringSearchTest.java @@ -189,7 +189,6 @@ public void testSearchHandle() throws Exception { assertTrue(metrics.getFacetResolutionTime() >= 0); assertTrue(metrics.getQueryResolutionTime() >= 0); assertTrue(metrics.getSnippetResolutionTime() >= 0); - assertTrue(metrics.getMetadataResolutionTime() >= 0); assertTrue(metrics.getExtractResolutionTime() >= 0); assertTrue(metrics.getTotalTime() >= 0); assertTrue(results.getPlan(new StringHandle()).get().startsWith("/dir1dir2false", q); } - t = qb.directory(4, "/dir1", "dir2"); - for (String q: new String[]{t.serialize(), qb.build(t).toString()}) { - xml = new StringInputStream(q); - parser.parse(xml, handler); - assertXMLEqual("" - + "/dir1dir2false", q); - } - t = qb.locks(qb.term("one")); for (String q: new String[]{t.serialize(), qb.build(t).toString()}) { xml = new StringInputStream(q); diff --git a/marklogic-client-api/src/test/java/com/marklogic/client/test/datamovement/ApplyTransformTest.java b/marklogic-client-api/src/test/java/com/marklogic/client/test/datamovement/ApplyTransformTest.java index b471d405c..6cdd85d96 100644 --- a/marklogic-client-api/src/test/java/com/marklogic/client/test/datamovement/ApplyTransformTest.java +++ b/marklogic-client-api/src/test/java/com/marklogic/client/test/datamovement/ApplyTransformTest.java @@ -142,7 +142,7 @@ public void testManyDocs() throws Exception { .withTransform(transform) .withApplyResult(ApplyResult.REPLACE) .onSuccess(batch -> count2.addAndGet(batch.getItems().length)) - .onBatchFailure((batch, throwable) -> throwable.printStackTrace()); + .onFailure((batch, throwable) -> throwable.printStackTrace()); QueryBatcher batcher = moveMgr.newQueryBatcher(query2) .onUrisReady(listener) .withConsistentSnapshot(); @@ -192,7 +192,7 @@ public void testOnSkipped() throws Exception { skippedUris.add(uri); } }) - .onBatchFailure((batch, throwable) -> throwable.printStackTrace()) + .onFailure((batch, throwable) -> throwable.printStackTrace()) ) .onQueryFailure(throwable -> throwable.printStackTrace()); JobTicket ticket = moveMgr.startJob( batcher ); diff --git a/marklogic-client-api/src/test/java/com/marklogic/client/test/datamovement/QueryBatcherTest.java b/marklogic-client-api/src/test/java/com/marklogic/client/test/datamovement/QueryBatcherTest.java index 68b30875f..80d4b417d 100644 --- a/marklogic-client-api/src/test/java/com/marklogic/client/test/datamovement/QueryBatcherTest.java +++ b/marklogic-client-api/src/test/java/com/marklogic/client/test/datamovement/QueryBatcherTest.java @@ -518,10 +518,10 @@ public void testApplyTransformListenerException() { testListenerException( new ApplyTransformListener() .withTransform(new ServerTransform("thisTransformDoesntExist")) - .onBatchFailure( (batch, throwable) -> failureBatchCount.incrementAndGet() ) + .onFailure( (batch, throwable) -> failureBatchCount.incrementAndGet() ) ); // there should be one failure sent to the ApplyTransformListener - // onBatchFailure listener since the transform is invalid + // onFailure listener since the transform is invalid assertEquals(1, failureBatchCount.get()); } @@ -651,10 +651,10 @@ public void testExportListenerException() { testListenerException( new ExportListener() .withTransform(new ServerTransform("thisTransformDoesntExist")) - .onBatchFailure( (batch, throwable) -> failureBatchCount.incrementAndGet() ) + .onFailure( (batch, throwable) -> failureBatchCount.incrementAndGet() ) ); // there should be one failure sent to the ExportListener - // onBatchFailure listener since the transform is invalid + // onFailure listener since the transform is invalid assertEquals(1, failureBatchCount.get()); } @@ -665,10 +665,10 @@ public void testExportToWriterListenerException() { testListenerException( new ExportToWriterListener(new StringWriter()) .withTransform(new ServerTransform("thisTransformDoesntExist")) - .onBatchFailure( (batch, throwable) -> failureBatchCount.incrementAndGet() ) + .onFailure( (batch, throwable) -> failureBatchCount.incrementAndGet() ) ); // there should be one failure sent to the ExportToWriterListener - // onBatchFailure listener since the transform is invalid + // onFailure listener since the transform is invalid assertEquals(1, failureBatchCount.get()); } @@ -682,10 +682,10 @@ public void write(String str) { }; testListenerException( new UrisToWriterListener(badWriter) - .onBatchFailure( (batch, throwable) -> failureBatchCount.incrementAndGet() ) + .onFailure( (batch, throwable) -> failureBatchCount.incrementAndGet() ) ); // there should be one failure sent to the UrisToWriterListener - // onBatchFailure listener since the writer is invalid + // onFailure listener since the writer is invalid assertEquals(1, failureBatchCount.get()); } @@ -694,7 +694,7 @@ public void testDeleteListenerException() { final AtomicInteger failureBatchCount = new AtomicInteger(); testListenerException( batch -> { DeleteListener listener = new DeleteListener() - .onBatchFailure( (batch2, throwable) -> failureBatchCount.incrementAndGet() ); + .onFailure( (batch2, throwable) -> failureBatchCount.incrementAndGet() ); QueryBatch mockQueryBatch = new QueryBatchImpl() { public DatabaseClient getClient() { throw new InternalError(errorMessage); @@ -708,7 +708,7 @@ public QueryBatcher getBatcher() { } ); // there should be one failure sent to the DeleteListener - // onBatchFailure listener since getClient in mockQueryBatch throws InternalError + // onFailure listener since getClient in mockQueryBatch throws InternalError assertEquals(1, failureBatchCount.get()); }