final ValueFactories factories() { return context().getValueFactories(); }
final ValueFactories factories() { return context().getValueFactories(); }
final JcrValue[] valuesFrom( int propertyType, Object[] values ) { /* * Null values in the array are "compacted" (read: ignored) as per section 7.1.6 in the JCR 1.0.1 specification. */ int len = values.length; ValueFactories factories = context().getValueFactories(); List<JcrValue> results = new ArrayList<JcrValue>(len); for (int i = 0; i != len; ++i) { if (values[i] != null) results.add(new JcrValue(factories, propertyType, values[i])); } return results.toArray(new JcrValue[results.size()]); }
final JcrValue[] valuesFrom( int propertyType, Object[] values ) { /* * Null values in the array are "compacted" (read: ignored) as per section 7.1.6 in the JCR 1.0.1 specification. */ int len = values.length; ValueFactories factories = context().getValueFactories(); List<JcrValue> results = new ArrayList<JcrValue>(len); for (int i = 0; i != len; ++i) { if (values[i] != null) results.add(new JcrValue(factories, propertyType, values[i])); } return results.toArray(new JcrValue[results.size()]); }
final JcrValue valueFrom( int propertyType, Object value ) { return new JcrValue(context().getValueFactories(), propertyType, value); }
final JcrValue valueFrom( int propertyType, Object value ) { return new JcrValue(context().getValueFactories(), propertyType, value); }
protected final Path absolutePathFor( Path parentPath, Segment childSegment ) { return context().getValueFactories().getPathFactory().create(parentPath, childSegment); }
protected final Path absolutePathFor( Path parentPath, Segment childSegment ) { return context().getValueFactories().getPathFactory().create(parentPath, childSegment); }
final JcrValue valueFrom( Calendar value ) { DateTime dateTime = context().getValueFactories().getDateFactory().create(value); return valueFrom(PropertyType.DATE, dateTime); }
final JcrValue valueFrom( InputStream value ) { org.modeshape.jcr.value.BinaryValue binary = context().getValueFactories().getBinaryFactory().create(value); return valueFrom(PropertyType.BINARY, binary); }
final JcrValue valueFrom( InputStream value ) { org.modeshape.jcr.value.BinaryValue binary = context().getValueFactories().getBinaryFactory().create(value); return valueFrom(PropertyType.BINARY, binary); }
final JcrValue valueFrom( Calendar value ) { DateTime dateTime = context().getValueFactories().getDateFactory().create(value); return valueFrom(PropertyType.DATE, dateTime); }
@Override public String getCorrespondingNodePath( String workspaceName ) throws ItemNotFoundException, NoSuchWorkspaceException, AccessDeniedException, RepositoryException { CheckArg.isNotNull(workspaceName, "workspaceName"); checkSession(); NamespaceRegistry namespaces = this.context().getNamespaceRegistry(); return correspondingNodePath(workspaceName).getString(namespaces); }
@Override public String getCorrespondingNodePath( String workspaceName ) throws ItemNotFoundException, NoSuchWorkspaceException, AccessDeniedException, RepositoryException { CheckArg.isNotNull(workspaceName, "workspaceName"); checkSession(); NamespaceRegistry namespaces = this.context().getNamespaceRegistry(); return correspondingNodePath(workspaceName).getString(namespaces); }
protected final Path correspondingNodePath( String workspaceName ) throws NoSuchWorkspaceException, ItemNotFoundException, RepositoryException { assert workspaceName != null; NamespaceRegistry namespaces = this.context().getNamespaceRegistry(); // Find the closest ancestor (including this node) that is referenceable ... AbstractJcrNode referenceableRoot = this; while (!referenceableRoot.isNodeType(JcrMixLexicon.REFERENCEABLE.getString(namespaces))) { referenceableRoot = referenceableRoot.getParent(); } // Find the relative path from the nearest referenceable node to this node (or null if this node is referenceable) ... Path relativePath = path().equals(referenceableRoot.path()) ? null : path().relativeTo(referenceableRoot.path()); NodeKey key = referenceableRoot.key(); // if the we're looking for a system node, we need to use the system ws name, which is repository-wide String systemWsKey = session.getRepository().systemWorkspaceKey(); String workspaceKey = systemWsKey.equals(key.getWorkspaceKey()) ? systemWsKey : NodeKey.keyForWorkspaceName(workspaceName); NodeKey nodeKey = new NodeKey(key.getSourceKey(), workspaceKey, key.getIdentifier()); return session.getPathForCorrespondingNode(workspaceName, nodeKey, relativePath); }
protected final Path correspondingNodePath( String workspaceName ) throws NoSuchWorkspaceException, ItemNotFoundException, RepositoryException { assert workspaceName != null; NamespaceRegistry namespaces = this.context().getNamespaceRegistry(); // Find the closest ancestor (including this node) that is referenceable ... AbstractJcrNode referenceableRoot = this; while (!referenceableRoot.isNodeType(JcrMixLexicon.REFERENCEABLE.getString(namespaces))) { referenceableRoot = referenceableRoot.getParent(); } // Find the relative path from the nearest referenceable node to this node (or null if this node is referenceable) ... Path relativePath = path().equals(referenceableRoot.path()) ? null : path().relativeTo(referenceableRoot.path()); NodeKey key = referenceableRoot.key(); // if the we're looking for a system node, we need to use the system ws name, which is repository-wide String systemWsKey = session.getRepository().systemWorkspaceKey(); String workspaceKey = systemWsKey.equals(key.getWorkspaceKey()) ? systemWsKey : NodeKey.keyForWorkspaceName(workspaceName); NodeKey nodeKey = new NodeKey(key.getSourceKey(), workspaceKey, key.getIdentifier()); return session.getPathForCorrespondingNode(workspaceName, nodeKey, relativePath); }
ValueFactories factories = context().getValueFactories(); if (isSingle) {
ValueFactories factories = context().getValueFactories(); if (isSingle) {
@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())); } }