@BeforeClass public static void beforeClass() { libMgr = adminClient.newServerConfigManager().newExtensionLibrariesManager(); Common.connectEval(); septFirst.set(2014, Calendar.SEPTEMBER, 1, 0, 0, 0); septFirst.set(Calendar.MILLISECOND, 0); } @AfterClass
private static void installModule() throws Exception { // get a modules manager ExtensionLibrariesManager libsMgr = adminClient.newServerConfigManager().newExtensionLibrariesManager(); // write server-side javascript module file to the modules database libsMgr.write("/ext" + directory + "filterUrisReferencedByHolds.sjs", new FileHandle(new File("src/test/resources/legal_holds/filterUrisReferencedByHolds.sjs")) .withFormat(Format.TEXT)); }
@BeforeClass public static void beforeClass() { Common.connectAdmin(); // get a manager libsMgr = Common.adminClient .newServerConfigManager().newExtensionLibrariesManager(); // write XQuery file to the modules database libsMgr.write("/ext/my-lib.xqy", new FileHandle( new File("src/test/resources/my-lib.xqy")).withFormat(Format.TEXT)); Common.connect(); }
@BeforeClass public static void beforeClass() { Common.connectAdmin(); // get a manager libsMgr = Common.adminClient .newServerConfigManager().newExtensionLibrariesManager(); // write XQuery file to the modules database libsMgr.write("/ext/my-lib.xqy", new FileHandle( new File("src/test/resources/my-lib.xqy")).withFormat(Format.TEXT)); Common.connect(); } @AfterClass
@Test public void testXQueryModuleCRUDXmlFileNegative() throws KeyManagementException, NoSuchAlgorithmException, IOException { DatabaseClient client = getDatabaseClient("rest-admin", "x", getConnType()); // get a manager ExtensionLibrariesManager libsMgr = client.newServerConfigManager().newExtensionLibrariesManager(); String Path = "/foo/my/path/to/my/module.xqy"; FileHandle f = new FileHandle(new File("src/test/java/com/marklogic/client/functionaltest/data/all_well.xml")).withFormat(Format.XML); // write XQuery file to the modules database try { libsMgr.write(Path, f); Assert.assertTrue("Exception was not thrown", false); } catch (IllegalArgumentException e) { // Issue 210 logged for meaningful error assertEquals("libraryPath (the modules database path under which you install an asset) must begin with /ext/", e.getMessage()); } // delete it try { libsMgr.delete(Path); Assert.assertTrue("Exception was not thrown", false); } catch (IllegalArgumentException e) { assertEquals("libraryPath (the modules database path under which you install an asset) must begin with /ext/", e.getMessage()); } }
ExtensionLibrariesManager libsMgr = Common.adminClient.newServerConfigManager().newExtensionLibrariesManager();
ExtensionLibrariesManager libsMgr = client.newServerConfigManager().newExtensionLibrariesManager();
ExtensionLibrariesManager libsMgr = client.newServerConfigManager().newExtensionLibrariesManager();
@Test public void testXQueryModuleCRUDBinaryFile() throws KeyManagementException, NoSuchAlgorithmException, IOException { DatabaseClient client = getDatabaseClient("rest-admin", "x", getConnType()); // get a manager ExtensionLibrariesManager libsMgr = client.newServerConfigManager().newExtensionLibrariesManager(); String Path = "/ext/my/path/to/my/module.xqy"; // write XQuery file to the modules database libsMgr.write(Path, new FileHandle(new File("src/test/java/com/marklogic/client/functionaltest/data/binary.jpg")).withFormat(Format.BINARY)); // read it back File f = new File("src/test/java/com/marklogic/client/functionaltest/data/binary.jpg"); assertEquals(f.length(), libsMgr.read(Path, new StringHandle()).getByteLength()); // get the list of descriptors ExtensionLibraryDescriptor[] descriptors = libsMgr.list(); assertEquals("number of modules installed", descriptors.length, 1); for (ExtensionLibraryDescriptor descriptor : descriptors) { assertEquals(descriptor.getPath(), Path); } // delete it libsMgr.delete(Path); try { // read deleted module libsMgr.read(Path, new StringHandle()).get(); } catch (ResourceNotFoundException e) { // pass; } }
ExtensionLibrariesManager libsMgr = client.newServerConfigManager().newExtensionLibrariesManager();
@Test public void testXQueryModuleCRUDTextFile() throws KeyManagementException, NoSuchAlgorithmException, IOException { DatabaseClient client = getDatabaseClient("rest-admin", "x", getConnType()); // get a manager ExtensionLibrariesManager libsMgr = client.newServerConfigManager().newExtensionLibrariesManager(); String Path = "/ext/my/path/to/my/module.xqy"; // write XQuery file to the modules database libsMgr.write(Path, new FileHandle(new File("src/test/java/com/marklogic/client/functionaltest/data/readme.txt")).withFormat(Format.TEXT)); // read it back String xqueryModuleAsString = libsMgr.read(Path, new StringHandle()).get(); assertTrue("module read and read back", xqueryModuleAsString.startsWith("Copyright 2017 MarkLogic Corporation")); // get the list of descriptors ExtensionLibraryDescriptor[] descriptors = libsMgr.list(); assertEquals("number of modules installed", descriptors.length, 1); for (ExtensionLibraryDescriptor descriptor : descriptors) { assertEquals(descriptor.getPath(), Path); } // delete it libsMgr.delete(Path); try { // read deleted module xqueryModuleAsString = libsMgr.read(Path, new StringHandle()).get(); } catch (ResourceNotFoundException e) { // pass; } }
.newServerConfigManager().newExtensionLibrariesManager();
@Test public void testXQueryModuleCRUDXmlFile() throws KeyManagementException, NoSuchAlgorithmException, IOException { DatabaseClient client = getDatabaseClient("rest-admin", "x", getConnType()); // get a manager ExtensionLibrariesManager libsMgr = client.newServerConfigManager().newExtensionLibrariesManager(); String Path = "/ext/my/path/to/my/module.xqy"; FileHandle f = new FileHandle(new File("src/test/java/com/marklogic/client/functionaltest/data/all_well.xml")).withFormat(Format.XML); // write XQuery file to the modules database libsMgr.write(Path, f); // read it back assertEquals(209745, libsMgr.read(Path, new StringHandle()).getByteLength()); // get the list of descriptors ExtensionLibraryDescriptor[] descriptors = libsMgr.list(); assertEquals("number of modules installed", descriptors.length, 1); for (ExtensionLibraryDescriptor descriptor : descriptors) { assertEquals(descriptor.getPath(), Path); } // delete it libsMgr.delete(Path); try { // read deleted module libsMgr.read(Path, new StringHandle()).get(); } catch (ResourceNotFoundException e) { // pass; } }
ExtensionLibrariesManager libsMgr = client.newServerConfigManager().newExtensionLibrariesManager(); String firstPath = "/ext/my/path/to/my/module.xqy"; String secondPath = "/ext/my/path/to/my/other/module.xqy";
SecurityContext secContext = new DatabaseClientFactory.DigestAuthContext("rest-admin", "x"); DatabaseClient client = DatabaseClientFactory.newClient(appServerHostname, 8000, secContext, getConnType()); ExtensionLibrariesManager libsMgr = client.newServerConfigManager().newExtensionLibrariesManager();
libMgr = confMgr.newExtensionLibrariesManager();