本文整理了Java中javax.jcr.Node.isNodeType()
方法的一些代码示例,展示了Node.isNodeType()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Node.isNodeType()
方法的具体详情如下:
包路径:javax.jcr.Node
类名称:Node
方法名:isNodeType
[英]Returns true
if this node is of the specified primary node type or mixin type, or a subtype thereof. Returns false
otherwise.
This method respects the effective node type of the node.
[中]如果此节点属于指定的主节点类型或mixin类型或其子类型,则返回true
。否则返回false
。
此方法考虑节点的有效节点类型。
代码示例来源:origin: info.magnolia/magnolia-core
private boolean isNodeType(Node node, String[] nodeType) throws RepositoryException {
for (String nt : nodeType) {
if (node.isNodeType(nt)) {
return true;
}
}
return false;
}
}
代码示例来源:origin: info.magnolia/magnolia-core
private boolean isAllowedNodeType(Node node) throws RepositoryException {
if (allowedNodeTypes.isEmpty()) {
return true; //allowed node types aren't specified, behave like DefaultACLBasedPermissions
}
for (String nodeType : allowedNodeTypes) {
if (node.isNodeType(nodeType)) {
return true;
}
}
return false;
}
}
代码示例来源:origin: info.magnolia/magnolia-core
@Override
public boolean evaluateTyped(Node t) {
try {
return !(t.getName().startsWith(NodeTypes.JCR_PREFIX) || t.isNodeType(NodeTypes.MetaData.NAME));
} catch (RepositoryException e) {
return false;
}
}
});
代码示例来源:origin: info.magnolia/magnolia-core
protected boolean hasBinaryNode(String name) throws RepositoryException {
return this.node.hasNode(name) && (this.node.getNode(name).isNodeType(ItemType.NT_RESOURCE) ||
(this.node.hasProperty("jcr:frozenPrimaryType") && this.node.getNode(name).getProperty("jcr:frozenPrimaryType").getValue().getString().equals(ItemType.NT_RESOURCE)));
}
}
代码示例来源:origin: info.magnolia/magnolia-core
/**
* Verifies the existence of the mix:versionable and adds it if not.
*/
protected void checkAndAddMixin(Node node) throws RepositoryException {
if (!node.isNodeType("mix:versionable")) {
log.debug("Add mix:versionable");
node.addMixin("mix:versionable");
}
}
代码示例来源:origin: info.magnolia/magnolia-core
public static void checkNodeType(Node node, String nodeType, String... propertyNames) throws RepositoryException {
if (!node.isNodeType(nodeType)) {
log.warn("Trying to set property/ies '{}' although the node '{}' with PrimaryType '{}' is not of type '{}'!", propertyNames, node.getPath(), node.getPrimaryNodeType().getName(), nodeType);
}
}
}
代码示例来源:origin: pentaho/pentaho-platform
public static boolean isSupportedNodeType( final PentahoJcrConstants pentahoJcrConstants, final Node node )
throws RepositoryException {
Assert.notNull( node );
if ( node.isNodeType( pentahoJcrConstants.getNT_FROZENNODE() ) ) {
String nodeTypeName = node.getProperty( pentahoJcrConstants.getJCR_FROZENPRIMARYTYPE() ).getString();
return pentahoJcrConstants.getPHO_NT_PENTAHOFILE().equals( nodeTypeName ) || pentahoJcrConstants
.getPHO_NT_PENTAHOFOLDER().equals( nodeTypeName );
}
return node.isNodeType( pentahoJcrConstants.getPHO_NT_PENTAHOFILE() ) || node.isNodeType( pentahoJcrConstants
.getPHO_NT_PENTAHOFOLDER() );
}
代码示例来源:origin: info.magnolia/magnolia-core
public boolean isEditorBinaryLink() {
try {
return getJCRNode().isNodeType(NodeTypes.Resource.NAME);
} catch (RepositoryException e) {
throw new RuntimeRepositoryException(e);
}
}
代码示例来源:origin: Adobe-Consulting-Services/acs-aem-commons
/**
* Determine if a component has a Classic UI dialog for shared or global configs.
*/
private boolean componentHasClassicDialog(Component component, String dialogName) throws RepositoryException {
Resource dialog = component.getLocalResource(dialogName);
return dialog != null && dialog.adaptTo(Node.class).isNodeType("cq:Dialog");
}
代码示例来源:origin: pentaho/pentaho-platform
public static Serializable getNodeId( final Session session, final PentahoJcrConstants pentahoJcrConstants,
final Node node ) throws RepositoryException {
if ( node.isNodeType( pentahoJcrConstants.getNT_FROZENNODE() ) ) {
return node.getProperty( pentahoJcrConstants.getJCR_FROZENUUID() ).getString();
}
return node.getIdentifier();
}
代码示例来源:origin: info.magnolia/magnolia-core
protected void markAsDeleted(Node node) throws RepositoryException {
// add mixin
node.addMixin(NodeTypes.Deleted.NAME);
// change template
if (node.isNodeType(NodeTypes.Renderable.NAME)) {
NodeTypes.Renderable.set(node, DELETED_NODE_TEMPLATE);
}
}
代码示例来源:origin: info.magnolia/magnolia-core
public String getFileName() {
try {
if (StringUtils.isEmpty(this.fileName) && this.getJCRNode() != null && this.getJCRNode().isNodeType(NodeTypes.Resource.NAME)) {
File binary = new File(jcrNode);
fileName = new URI(null, null, binary.getFileName(), null).toASCIIString();
}
} catch (RepositoryException e) {
//Just return fileName.
} catch (URISyntaxException e) {
}
return fileName;
}
代码示例来源:origin: info.magnolia/magnolia-core
public Link(Node node) {
try {
setJCRNode(node);
setWorkspace(node.getSession().getWorkspace().getName());
if (node.isNodeType(JcrConstants.MIX_REFERENCEABLE)) {
setUUID(node.getIdentifier());
}
} catch (RepositoryException e) {
throw new RuntimeRepositoryException(e);
}
}
代码示例来源:origin: info.magnolia/magnolia-core
@Test
public void restoredFirstVersionHasVersionMixin() throws Exception {
//GIVEN
Node node = websiteSession.getRootNode().addNode("page", NodeTypes.Page.NAME);
//WHEN
versionManager.addVersion(node);
//THEN
Node restored = versionManager.getVersionedNode(node);
assertTrue("Node must have hasVersion mixin", node.isNodeType(NodeTypes.HasVersion.NAME));
assertTrue("Node in mgnlVersion workspace must have hasVersion mixin", restored.isNodeType(NodeTypes.HasVersion.NAME));
}
}
代码示例来源:origin: info.magnolia/magnolia-core
public String getExtension() {
try {
if (StringUtils.isEmpty(this.extension) && this.getJCRNode() != null && this.getJCRNode().isNodeType(NodeTypes.Resource.NAME)) {
File binary = new File(jcrNode);
extension = binary.getExtension();
}
} catch (RepositoryException e) {
//Just return extension if already set, default if not.
}
return StringUtils.defaultIfEmpty(this.extension, Components.getComponent(ServerConfiguration.class).getDefaultExtension());
}
代码示例来源:origin: info.magnolia/magnolia-core
@Test
public void testIsNodeType() throws Exception {
// GIVEN
final String nodeType = NodeTypes.ContentNode.NAME;
final Node newNode = new MockNode("test", nodeType);
// WHEN
final boolean result = newNode.isNodeType(nodeType);
// THEN
assertTrue(result);
}
代码示例来源:origin: info.magnolia/magnolia-core
@Test
public void testIsNodeTypeWithSupertype() throws Exception {
// GIVEN
final Node newNode = new MockNode("test");
// WHEN
final boolean result = newNode.isNodeType(JcrConstants.NT_BASE);
// THEN
assertTrue(result);
}
代码示例来源:origin: info.magnolia/magnolia-core
@Test
public void testIsNodeTypeWithUnsetMixin() throws Exception {
// GIVEN
Node newNode = new MockNode();
// WHEN
final boolean result = newNode.isNodeType(NodeTypes.Activatable.NAME);
// THEN
assertFalse(result);
}
代码示例来源:origin: info.magnolia/magnolia-core
@Test
public void testIsNodeTypeWithSetMixin() throws Exception {
// GIVEN
final Node newNode = new MockNode();
final String mixin = NodeTypes.Activatable.NAME;
newNode.addMixin(mixin);
// WHEN
final boolean result = newNode.isNodeType(mixin);
// THEN
assertTrue(result);
}
代码示例来源:origin: info.magnolia/magnolia-core
@Test
public void testNewlyCreatedUserNodeHasMixinLockable() throws PathNotFoundException, RepositoryException {
// WHEN
um.createUser("peter", "peter");
// THEN
Node userNode = MgnlContext.getJCRSession(RepositoryConstants.USERS).getNode("/admin/peter");
assertNotNull(userNode);
assertTrue(userNode.isNodeType(JcrConstants.MIX_LOCKABLE));
}
内容来源于网络,如有侵权,请联系作者删除!