当前位置: 首页>>代码示例>>Java>>正文


Java DocumentMetadataHandle.withPermission方法代码示例

本文整理汇总了Java中com.marklogic.client.io.DocumentMetadataHandle.withPermission方法的典型用法代码示例。如果您正苦于以下问题:Java DocumentMetadataHandle.withPermission方法的具体用法?Java DocumentMetadataHandle.withPermission怎么用?Java DocumentMetadataHandle.withPermission使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.marklogic.client.io.DocumentMetadataHandle的用法示例。


在下文中一共展示了DocumentMetadataHandle.withPermission方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: process

import com.marklogic.client.io.DocumentMetadataHandle; //导入方法依赖的package包/类
@Override
public DocumentWriteOperation process(Map<String, Object> item) throws Exception {
	String tableName = null;
	if (item.containsKey(tableNameKey)) {
		tableName = (String)item.get(tableNameKey);
		item.remove(tableNameKey);
	}

	String thisRootLocalName = tableName != null ? tableName : rootLocalName;
	String content = columnMapSerializer.serializeColumnMap(item, thisRootLocalName);

	String uuid = UUID.randomUUID().toString();
	String uri = "/" + thisRootLocalName + "/" + uuid + uriSuffix;

	DocumentMetadataHandle metadata = new DocumentMetadataHandle();
	if (collections != null) {
		metadata.withCollections(collections);
	}
	if (tableName != null) {
		metadata.withCollections(tableName);
	}

	if (permissions != null) {
		for (int i = 0; i < permissions.length; i += 2) {
			String role = permissions[i];
			DocumentMetadataHandle.Capability c = DocumentMetadataHandle.Capability.valueOf(permissions[i + 1].toUpperCase());
			metadata.withPermission(role, c);
		}
	}

	return new DocumentWriteOperationImpl(DocumentWriteOperation.OperationType.DOCUMENT_WRITE,
		uri, metadata, new StringHandle(content));
}
 
开发者ID:rjrudin,项目名称:ml-migration-starter,代码行数:34,代码来源:ColumnMapProcessor.java

示例2: getDocumentMetadata

import com.marklogic.client.io.DocumentMetadataHandle; //导入方法依赖的package包/类
protected DocumentMetadataHandle getDocumentMetadata(T item) {
    DocumentMetadataHandle metadata = new DocumentMetadataHandle();
    if (collections != null) {
        metadata.withCollections(collections);
    }
    if (permissions != null) {
        for (int i = 0; i < permissions.length; i += 2) {
            String role = permissions[i];
            DocumentMetadataHandle.Capability c = DocumentMetadataHandle.Capability.valueOf(permissions[i + 1].toUpperCase());
            metadata.withPermission(role, c);
        }
    }
    return metadata;
}
 
开发者ID:marklogic-community,项目名称:marklogic-spring-batch,代码行数:15,代码来源:AbstractMarkLogicItemProcessor.java

示例3: getMetadata

import com.marklogic.client.io.DocumentMetadataHandle; //导入方法依赖的package包/类
@Override
public DocumentMetadataWriteHandle getMetadata() {
	DocumentMetadataHandle h = new DocumentMetadataHandle();
	if (collections != null) {
		h.withCollections(collections);
	}
	if (permissions != null) {
		for (String role : permissions.keySet()) {
			h.withPermission(role, permissions.get(role));
		}
	}
	return h;
}
 
开发者ID:marklogic-community,项目名称:ml-javaclient-util,代码行数:14,代码来源:SimpleDocumentWriteOperation.java

示例4: test

import com.marklogic.client.io.DocumentMetadataHandle; //导入方法依赖的package包/类
@Test
public void test() throws Exception {
	String xml = "<hello>World</hello>";
	String uri = "/test.xml";
	DocumentMetadataHandle metadata = new DocumentMetadataHandle();
	metadata.withCollections("collection1", "collection2");
	metadata.withPermission("role1", DocumentMetadataHandle.Capability.EXECUTE, DocumentMetadataHandle.Capability.READ);
	metadata.withPermission("role2", DocumentMetadataHandle.Capability.UPDATE);
	metadata.withPermission("role3", DocumentMetadataHandle.Capability.INSERT);
	metadata.setFormat(Format.XML);

	DocumentWriteOperation operation = new DocumentWriteOperationImpl(
		DocumentWriteOperation.OperationType.DOCUMENT_WRITE, uri, metadata, new StringHandle(xml));

	Content content = sut.adapt(operation);

	assertEquals(uri, content.getUri());
	String xccXml = new String(FileCopyUtils.copyToByteArray(content.openDataStream()));
	assertEquals(xml, xccXml);

	ContentCreateOptions options = content.getCreateOptions();

	String[] collections = options.getCollections();
	assertEquals("collection1", collections[0]);
	assertEquals("collection2", collections[1]);

	// Permissions are in a set, and thus not ordered, so our assertions a little funky here
	ContentPermission[] permissions = options.getPermissions();
	assertEquals(4, permissions.length);
	for (ContentPermission perm : permissions) {
		String role = perm.getRole();
		ContentCapability capability = perm.getCapability();
		if ("role1".equals(role)) {
			assertTrue(ContentCapability.EXECUTE.equals(capability) || ContentCapability.READ.equals(capability));
		} else if ("role2".equals(role)) {
			assertEquals(ContentCapability.UPDATE, capability);
		} else if ("role3".equals(role)) {
			assertEquals(ContentCapability.INSERT, capability);
		} else {
			fail("Unexpected role: " + role);
		}
	}
}
 
开发者ID:marklogic-community,项目名称:ml-javaclient-util,代码行数:44,代码来源:DefaultDocumentWriteOperationAdapterTest.java


注:本文中的com.marklogic.client.io.DocumentMetadataHandle.withPermission方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。