當前位置: 首頁>>代碼示例>>Java>>正文


Java BytesHandle類代碼示例

本文整理匯總了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);
		}
	}
}
 
開發者ID:marklogic-community,項目名稱:ml-javaclient-util,代碼行數:18,代碼來源:WriteToZipConsumer.java

示例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\")"));
}
 
開發者ID:marklogic-community,項目名稱:ml-javaclient-util,代碼行數:29,代碼來源:LoadModulesTest.java

示例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);
}
 
開發者ID:etourdot,項目名稱:vertx-marklogic,代碼行數:9,代碼來源:MarklogicDocumentWriteTest.java

示例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();
	}
}
 
開發者ID:marklogic-community,項目名稱:ml-app-deployer,代碼行數:31,代碼來源:ReplaceTokensTest.java

示例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;
}
 
開發者ID:marklogic-community,項目名稱:ml-javaclient-util,代碼行數:14,代碼來源:EntityServicesManager.java


注:本文中的com.marklogic.client.io.BytesHandle類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。