本文整理匯總了Java中com.marklogic.client.io.BytesHandle類的典型用法代碼示例。如果您正苦於以下問題:Java BytesHandle類的具體用法?Java BytesHandle怎麽用?Java BytesHandle使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
BytesHandle類屬於com.marklogic.client.io包,在下文中一共展示了BytesHandle類的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: accept
import com.marklogic.client.io.BytesHandle; //導入依賴的package包/類
@Override
public void accept(DocumentRecord documentRecord) {
String uri = documentRecord.getUri();
ZipEntry zipEntry = buildZipEntry(documentRecord);
synchronized (this.zipOutputStream) {
try {
zipOutputStream.putNextEntry(zipEntry);
if (logger.isDebugEnabled()) {
logger.debug("Writing zip entry, name: " + zipEntry.getName());
}
zipOutputStream.write(documentRecord.getContent(new BytesHandle()).get());
zipOutputStream.closeEntry();
} catch (IOException e) {
throw new RuntimeException("Unable to write zip entry for URI: " + uri + "; cause: " + e.getMessage(), e);
}
}
}
示例2: replaceTokens
import com.marklogic.client.io.BytesHandle; //導入依賴的package包/類
/**
* This test is a little brittle because it assumes the URI of options/services/transforms that are loaded
* into the Modules database.
*/
@Test
public void replaceTokens() {
String dir = Paths.get("src", "test", "resources", "token-replace").toString();
DefaultTokenReplacer tokenReplacer = new DefaultTokenReplacer();
Properties props = new Properties();
props.setProperty("%%REPLACEME%%", "hello-world");
tokenReplacer.setProperties(props);
modulesLoader.setTokenReplacer(tokenReplacer);
modulesLoader.loadModules(dir, new DefaultModulesFinder(), client);
String optionsXml = modulesClient.newXMLDocumentManager().read(
"/Default/App-Services/rest-api/options/sample-options.xml", new StringHandle()).get();
assertTrue(optionsXml.contains("fn:collection('hello-world')"));
String serviceText = new String(modulesClient.newDocumentManager().read(
"/marklogic.rest.resource/sample/assets/resource.xqy", new BytesHandle()).get());
assertTrue(serviceText.contains("xdmp:log(\"hello-world called\")"));
String transformText = new String(modulesClient.newDocumentManager().read(
"/marklogic.rest.transform/xquery-transform/assets/transform.xqy", new BytesHandle()).get());
assertTrue(transformText.contains("xdmp:log(\"hello-world\")"));
}
示例3: retrieveBinaryDocument
import com.marklogic.client.io.BytesHandle; //導入依賴的package包/類
private void retrieveBinaryDocument(String id, Handler<AsyncResult<Buffer>> resultHandler) {
vertx.executeBlocking(future -> {
BinaryDocumentManager documentManager = databaseClient.newBinaryDocumentManager();
BytesHandle bytesHandle = new BytesHandle();
documentManager.read(id, bytesHandle);
future.complete(Buffer.buffer(bytesHandle.get()));
}, resultHandler);
}
示例4: test
import com.marklogic.client.io.BytesHandle; //導入依賴的package包/類
@Test
public void test() {
appConfig.setContentForestsPerHost(1);
appConfig.setConfigDir(new ConfigDir(new File("src/test/resources/token-test/ml-config")));
appConfig.setModulePaths(Arrays.asList("src/test/resources/token-test/ml-modules"));
Properties props = new Properties();
props.setProperty("xdbcEnabled", "true");
props.setProperty("sample-token", "replaced!");
appConfig.populateCustomTokens(new SimplePropertiesSource(props));
LoadModulesCommand loadModulesCommand = new LoadModulesCommand();
loadModulesCommand.initializeDefaultModulesLoader(new CommandContext(appConfig, manageClient, adminManager));
((DefaultModulesLoader) loadModulesCommand.getModulesLoader()).setModulesManager(null);
initializeAppDeployer(new DeployRestApiServersCommand(), loadModulesCommand);
deploySampleApp();
// We know xdbcEnabled was replaced, otherwise the deployment of the REST API server would have failed
// Gotta verify the text in the module was replaced
DatabaseClient modulesClient = appConfig.newAppServicesDatabaseClient(appConfig.getModulesDatabaseName());
try {
String moduleText = new String(modulesClient.newDocumentManager().read("/hello.xqy", new BytesHandle()).get());
assertTrue("Did not find replaced text in module: " + moduleText, moduleText.contains("replaced!"));
} finally {
modulesClient.release();
undeploySampleApp();
}
}
示例5: loadModel
import com.marklogic.client.io.BytesHandle; //導入依賴的package包/類
/**
* @param moduleName appended to the baseUri to determine the model definition URI
* @param modelDefinition JSON or XML
* @return
*/
public String loadModel(String moduleName, String modelDefinition) {
GenericDocumentManager mgr = client.newDocumentManager();
DocumentMetadataHandle dmh = new DocumentMetadataHandle();
dmh.getCollections().add(modelCollection);
String modelUri = baseUri + moduleName;
mgr.write(modelUri, dmh, new BytesHandle(modelDefinition.getBytes()));
return modelUri;
}