@Override public org.modeshape.jcr.api.query.Query getQuery( Node node ) throws InvalidQueryException, RepositoryException { AbstractJcrNode jcrNode = CheckArg.getInstanceOf(node, AbstractJcrNode.class, "node"); // Check the type of the node ... JcrNodeType nodeType = jcrNode.getPrimaryNodeType(); if (!nodeType.getInternalName().equals(JcrNtLexicon.QUERY)) { NamespaceRegistry registry = session.context().getNamespaceRegistry(); throw new InvalidQueryException(JcrI18n.notStoredQuery.text(jcrNode.path().getString(registry))); } // These are both mandatory properties for nodes of nt:query String statement = jcrNode.getProperty(JcrLexicon.STATEMENT).getString(); String language = jcrNode.getProperty(JcrLexicon.LANGUAGE).getString(); return createQuery(statement, language, jcrNode.path(), null); }
@Override public org.modeshape.jcr.api.query.Query getQuery( Node node ) throws InvalidQueryException, RepositoryException { AbstractJcrNode jcrNode = CheckArg.getInstanceOf(node, AbstractJcrNode.class, "node"); // Check the type of the node ... JcrNodeType nodeType = jcrNode.getPrimaryNodeType(); if (!nodeType.getInternalName().equals(JcrNtLexicon.QUERY)) { NamespaceRegistry registry = session.context().getNamespaceRegistry(); throw new InvalidQueryException(JcrI18n.notStoredQuery.text(jcrNode.path().getString(registry))); } // These are both mandatory properties for nodes of nt:query String statement = jcrNode.getProperty(JcrLexicon.STATEMENT).getString(); String language = jcrNode.getProperty(JcrLexicon.LANGUAGE).getString(); return createQuery(statement, language, jcrNode.path(), null); }
private void validateNodesWithCustomTypes() throws RepositoryException { JcrRootNode rootNode = session.getRootNode(); rootNode.addNode("car", "car:Car"); rootNode.addNode("aircraft", "air:Aircraft"); session.save(); assertEquals("car:Car", session.getNode("/car").getPrimaryNodeType().getName()); assertEquals("air:Aircraft", session.getNode("/aircraft").getPrimaryNodeType().getName()); }
NodeDefinitionSet childDefns = nodeTypes.findChildNodeDefinitions(primaryTypeName, newMixinNames); JcrNodeDefinition match = childDefns.findBestDefinitionForChild(JcrNodeType.RESIDUAL_NAME, child.getPrimaryNodeType().getInternalName(), skipProtected, siblingCounter); if (match == null) {
NodeDefinitionSet childDefns = nodeTypes.findChildNodeDefinitions(primaryTypeName, newMixinNames); JcrNodeDefinition match = childDefns.findBestDefinitionForChild(JcrNodeType.RESIDUAL_NAME, child.getPrimaryNodeType().getInternalName(), skipProtected, siblingCounter); if (match == null) {
primaryType = selectedNode.getPrimaryNodeType().getName(); } else { if (selectedNode == outputNode && !selectedNode.getPrimaryNodeType().getName().equals(primaryType)) { String msg = RepositoryI18n.sequencersMayNotChangeThePrimaryTypeOfTheSelectedNode.text(); throw new RepositoryException(msg);
primaryType = selectedNode.getPrimaryNodeType().getName(); } else { if (selectedNode == outputNode && !selectedNode.getPrimaryNodeType().getName().equals(primaryType)) { String msg = RepositoryI18n.sequencersMayNotChangeThePrimaryTypeOfTheSelectedNode.text(); throw new RepositoryException(msg);
if (!getPrimaryNodeType().hasOrderableChildNodes()) { String msg = JcrI18n.notOrderable.text(getPrimaryNodeType().getName(), location()); throw new UnsupportedRepositoryOperationException(msg);
if (!getPrimaryNodeType().hasOrderableChildNodes()) { String msg = JcrI18n.notOrderable.text(getPrimaryNodeType().getName(), location()); throw new UnsupportedRepositoryOperationException(msg);
@Override public Item getPrimaryItem() throws ItemNotFoundException, RepositoryException { checkSession(); // Get the primary item name from this node's type ... NodeType primaryType = getPrimaryNodeType(); String primaryItemNameString = primaryType.getPrimaryItemName(); if (primaryItemNameString == null) { I18n msg = JcrI18n.noPrimaryItemNameDefinedOnPrimaryType; throw new ItemNotFoundException(msg.text(primaryType.getName(), location(), workspaceName())); } try { Path primaryItemPath = context().getValueFactories().getPathFactory().create(primaryItemNameString); if (primaryItemPath.size() == 1 && !primaryItemPath.isAbsolute()) { try { return session.node(node(), primaryItemPath); } catch (PathNotFoundException e) { // Must not be any child by that name, so now look for a property on the parent node ... return getProperty(primaryItemPath.getLastSegment().getName()); } } I18n msg = JcrI18n.primaryItemNameForPrimaryTypeIsNotValid; throw new ItemNotFoundException(msg.text(primaryType.getName(), primaryItemNameString, location(), workspaceName())); } catch (ValueFormatException error) { I18n msg = JcrI18n.primaryItemNameForPrimaryTypeIsNotValid; throw new ItemNotFoundException(msg.text(primaryType.getName(), primaryItemNameString, location(), workspaceName())); } catch (PathNotFoundException error) { I18n msg = JcrI18n.primaryItemDoesNotExist; throw new ItemNotFoundException(msg.text(primaryType.getName(), primaryItemNameString, location(), workspaceName())); } }
@Override public Item getPrimaryItem() throws ItemNotFoundException, RepositoryException { checkSession(); // Get the primary item name from this node's type ... NodeType primaryType = getPrimaryNodeType(); String primaryItemNameString = primaryType.getPrimaryItemName(); if (primaryItemNameString == null) { I18n msg = JcrI18n.noPrimaryItemNameDefinedOnPrimaryType; throw new ItemNotFoundException(msg.text(primaryType.getName(), location(), workspaceName())); } try { Path primaryItemPath = context().getValueFactories().getPathFactory().create(primaryItemNameString); if (primaryItemPath.size() == 1 && !primaryItemPath.isAbsolute()) { try { return session.node(node(), primaryItemPath); } catch (PathNotFoundException e) { // Must not be any child by that name, so now look for a property on the parent node ... return getProperty(primaryItemPath.getLastSegment().getName()); } } I18n msg = JcrI18n.primaryItemNameForPrimaryTypeIsNotValid; throw new ItemNotFoundException(msg.text(primaryType.getName(), primaryItemNameString, location(), workspaceName())); } catch (ValueFormatException error) { I18n msg = JcrI18n.primaryItemNameForPrimaryTypeIsNotValid; throw new ItemNotFoundException(msg.text(primaryType.getName(), primaryItemNameString, location(), workspaceName())); } catch (PathNotFoundException error) { I18n msg = JcrI18n.primaryItemDoesNotExist; throw new ItemNotFoundException(msg.text(primaryType.getName(), primaryItemNameString, location(), workspaceName())); } }