Search in sources :

Example 6 with PropertyEntry

use of org.apache.jackrabbit.jcr2spi.hierarchy.PropertyEntry in project jackrabbit by apache.

the class ResolveMergeConflict method persisted.

/**
     * Invalidates the <code>NodeState</code> that had a merge conflict pending
     * and all its child properties.
     *
     * @see Operation#persisted()
     */
public void persisted() {
    assert status == STATUS_PENDING;
    status = STATUS_PERSISTED;
    // non-recursive invalidation BUT including all properties
    Iterator<PropertyEntry> propEntries = ((NodeEntry) nodeState.getHierarchyEntry()).getPropertyEntries();
    while (propEntries.hasNext()) {
        PropertyEntry pe = propEntries.next();
        pe.invalidate(false);
    }
    nodeState.getHierarchyEntry().invalidate(false);
}
Also used : NodeEntry(org.apache.jackrabbit.jcr2spi.hierarchy.NodeEntry) PropertyEntry(org.apache.jackrabbit.jcr2spi.hierarchy.PropertyEntry)

Example 7 with PropertyEntry

use of org.apache.jackrabbit.jcr2spi.hierarchy.PropertyEntry in project jackrabbit by apache.

the class NodeImpl method resolveRelativePropertyPath.

/**
     * Returns the id of the property at <code>relPath</code> or <code>null</code>
     * if no property exists at <code>relPath</code>.
     * <p>
     * Note that access rights are not checked.
     *
     * @param relPath relative path of a (possible) property
     * @return the PropertyEntry of the property at <code>relPath</code> or
     * <code>null</code> if no property exists at <code>relPath</code>
     * @throws RepositoryException if <code>relPath</code> is not a valid
     * relative path
     */
private PropertyEntry resolveRelativePropertyPath(String relPath) throws RepositoryException {
    PropertyEntry targetEntry = null;
    try {
        Path rp = session.getPathResolver().getQPath(relPath);
        if (rp.getLength() == 1 && rp.denotesName()) {
            // a single path element must always denote a name. '.' and '..'
            // will never point to a property. If the NodeEntry does not
            // contain such a property entry, the targetEntry is 'null;
            Name propName = rp.getName();
            // check if property entry exists
            targetEntry = getNodeEntry().getPropertyEntry(propName, true);
        } else {
            // build and resolve absolute path
            Path p = getPath(rp).getCanonicalPath();
            try {
                targetEntry = session.getHierarchyManager().getPropertyEntry(p);
            } catch (PathNotFoundException e) {
            // ignore -> return null;
            }
        }
    } catch (NameException e) {
        String msg = "failed to resolve property path " + relPath + " relative to " + safeGetJCRPath();
        log.debug(msg);
        throw new RepositoryException(msg, e);
    }
    return targetEntry;
}
Also used : Path(org.apache.jackrabbit.spi.Path) NameException(org.apache.jackrabbit.spi.commons.conversion.NameException) PropertyEntry(org.apache.jackrabbit.jcr2spi.hierarchy.PropertyEntry) RepositoryException(javax.jcr.RepositoryException) PathNotFoundException(javax.jcr.PathNotFoundException) Name(org.apache.jackrabbit.spi.Name)

Example 8 with PropertyEntry

use of org.apache.jackrabbit.jcr2spi.hierarchy.PropertyEntry in project jackrabbit by apache.

the class NodeImpl method getProperty.

/**
     * @see Node#getProperty(String)
     */
public Property getProperty(String relPath) throws PathNotFoundException, RepositoryException {
    checkStatus();
    PropertyEntry entry = resolveRelativePropertyPath(relPath);
    if (entry == null) {
        throw new PathNotFoundException(relPath);
    }
    try {
        return (Property) getItemManager().getItem(entry);
    } catch (AccessDeniedException e) {
        throw new PathNotFoundException(relPath);
    } catch (ItemNotFoundException e) {
        throw new PathNotFoundException(relPath);
    }
}
Also used : AccessDeniedException(javax.jcr.AccessDeniedException) PropertyEntry(org.apache.jackrabbit.jcr2spi.hierarchy.PropertyEntry) PathNotFoundException(javax.jcr.PathNotFoundException) Property(javax.jcr.Property) AddProperty(org.apache.jackrabbit.jcr2spi.operation.AddProperty) ItemNotFoundException(javax.jcr.ItemNotFoundException)

Example 9 with PropertyEntry

use of org.apache.jackrabbit.jcr2spi.hierarchy.PropertyEntry in project jackrabbit by apache.

the class NodeImpl method getMixinTypes.

/**
     * Retrieves the value of the jcr:mixinTypes property present with this
     * Node including those that have been transiently added and excluding
     * those, that have been transiently removed.<br>
     * NOTE, that the result of this method, does NOT represent the list of
     * mixin-types that currently affect this node.
     *
     * @return mixin names present with the jcr:mixinTypes property.
     */
private List<Name> getMixinTypes() {
    Name[] mixinValue;
    if (getNodeState().getStatus() == Status.EXISTING) {
        // jcr:mixinTypes must correspond to the mixins present on the nodestate.
        mixinValue = getNodeState().getMixinTypeNames();
    } else {
        try {
            PropertyEntry pe = getNodeEntry().getPropertyEntry(NameConstants.JCR_MIXINTYPES);
            if (pe != null) {
                // prop entry exists (and ev. has been transiently mod.)
                // -> retrieve mixin types from prop
                mixinValue = StateUtility.getMixinNames(pe.getPropertyState());
            } else {
                // prop entry has not been loaded yet -> not modified
                mixinValue = getNodeState().getMixinTypeNames();
            }
        } catch (RepositoryException e) {
            // should never occur
            log.warn("Internal error", e);
            mixinValue = Name.EMPTY_ARRAY;
        }
    }
    List<Name> l = new ArrayList<Name>();
    l.addAll(Arrays.asList(mixinValue));
    return l;
}
Also used : PropertyEntry(org.apache.jackrabbit.jcr2spi.hierarchy.PropertyEntry) ArrayList(java.util.ArrayList) RepositoryException(javax.jcr.RepositoryException) Name(org.apache.jackrabbit.spi.Name)

Example 10 with PropertyEntry

use of org.apache.jackrabbit.jcr2spi.hierarchy.PropertyEntry in project jackrabbit by apache.

the class ItemManagerImpl method hasChildProperties.

/**
     * @see ItemManager#hasChildProperties(NodeEntry)
     */
public synchronized boolean hasChildProperties(NodeEntry parentEntry) throws ItemNotFoundException, RepositoryException {
    // check sanity of session
    session.checkIsAlive();
    Iterator<PropertyEntry> iter = parentEntry.getPropertyEntries();
    while (iter.hasNext()) {
        try {
            PropertyEntry entry = iter.next();
            // check read access by accessing the propState (also implicit validation).
            entry.getPropertyState();
            return true;
        } catch (ItemNotFoundException e) {
            // should not occur. ignore
            log.debug("Failed to access node state.", e);
        }
    }
    return false;
}
Also used : PropertyEntry(org.apache.jackrabbit.jcr2spi.hierarchy.PropertyEntry) ItemNotFoundException(javax.jcr.ItemNotFoundException)

Aggregations

PropertyEntry (org.apache.jackrabbit.jcr2spi.hierarchy.PropertyEntry)19 NodeEntry (org.apache.jackrabbit.jcr2spi.hierarchy.NodeEntry)10 RepositoryException (javax.jcr.RepositoryException)7 Name (org.apache.jackrabbit.spi.Name)7 ItemNotFoundException (javax.jcr.ItemNotFoundException)4 ArrayList (java.util.ArrayList)3 QValue (org.apache.jackrabbit.spi.QValue)3 ItemExistsException (javax.jcr.ItemExistsException)2 PathNotFoundException (javax.jcr.PathNotFoundException)2 Property (javax.jcr.Property)2 QPropertyDefinition (org.apache.jackrabbit.spi.QPropertyDefinition)2 AccessDeniedException (javax.jcr.AccessDeniedException)1 Node (javax.jcr.Node)1 Version (javax.jcr.version.Version)1 VersionException (javax.jcr.version.VersionException)1 EffectiveNodeTypeProvider (org.apache.jackrabbit.jcr2spi.nodetype.EffectiveNodeTypeProvider)1 ItemDefinitionProvider (org.apache.jackrabbit.jcr2spi.nodetype.ItemDefinitionProvider)1 AddProperty (org.apache.jackrabbit.jcr2spi.operation.AddProperty)1 Operation (org.apache.jackrabbit.jcr2spi.operation.Operation)1 PropertyState (org.apache.jackrabbit.jcr2spi.state.PropertyState)1