Search in sources :

Example 76 with Name

use of org.apache.jackrabbit.spi.Name in project jackrabbit by apache.

the class ChildNodeEntriesImpl method reorderAfter.

/**
     *
     * @param insertLN
     * @param afterLN
     */
private void reorderAfter(LinkedEntries.LinkNode insertLN, LinkedEntries.LinkNode afterLN) {
    // the link node to move
    if (insertLN == null) {
        throw new NoSuchElementException();
    }
    // the link node where insertLN is ordered after
    if (afterLN == null) {
        // move to first position
        afterLN = entries.getHeader();
    }
    LinkedEntries.LinkNode currentAfter = afterLN.getNextLinkNode();
    if (currentAfter == insertLN) {
        log.debug("Already ordered behind 'afterEntry'.");
        // nothing to do
        return;
    } else {
        // reorder named map
        Name insertName = insertLN.qName;
        if (entriesByName.containsSiblings(insertName)) {
            // default: reorder to the end.
            int position = -1;
            if (afterLN == entries.getHeader()) {
                // move to the beginning
                position = 0;
            } else {
                // count all SNS-entries that are before 'afterLN' in order to
                // determine the new position of the reordered node regarding
                // his siblings.
                position = 0;
                for (Iterator<LinkedEntries.LinkNode> it = entries.linkNodeIterator(); it.hasNext(); ) {
                    LinkedEntries.LinkNode ln = it.next();
                    if (insertName.equals(ln.qName) && (ln != insertLN)) {
                        position++;
                    }
                    if (ln == afterLN) {
                        break;
                    }
                }
            }
            entriesByName.reorder(insertName, insertLN, position);
        }
        // reorder in linked list
        entries.reorderNode(insertLN, currentAfter);
    }
}
Also used : NoSuchElementException(java.util.NoSuchElementException) Name(org.apache.jackrabbit.spi.Name)

Example 77 with Name

use of org.apache.jackrabbit.spi.Name in project jackrabbit by apache.

the class ChildNodeEntriesImpl method internalAdd.

/**
     *
     * @param entry
     * @param index
     * @return the <code>LinkNode</code> belonging to the added entry.
     */
private LinkedEntries.LinkNode internalAdd(NodeEntry entry, int index) {
    Name nodeName = entry.getName();
    // retrieve ev. sibling node with same index. if index is 'undefined'
    // the existing entry is always null and no reordering occurs.
    LinkedEntries.LinkNode existing = null;
    if (index >= Path.INDEX_DEFAULT) {
        existing = entriesByName.getLinkNode(nodeName, index);
    }
    // TODO: TOBEFIXED in case of orderable node the order in the 'linked-entries' must be respected.
    for (int i = Path.INDEX_DEFAULT; i < index; i++) {
        LinkedEntries.LinkNode previous = entriesByName.getLinkNode(nodeName, i);
        if (previous == null) {
            NodeEntry sibling = factory.createNodeEntry(parent, nodeName, null);
            internalAdd(sibling, i);
        }
    }
    // add new entry
    LinkedEntries.LinkNode ln = entries.add(entry, index);
    entriesByName.put(nodeName, index, ln);
    // than appended at the end of the list.
    if (existing != null) {
        reorder(nodeName, ln, existing);
    }
    return ln;
}
Also used : Name(org.apache.jackrabbit.spi.Name)

Example 78 with Name

use of org.apache.jackrabbit.spi.Name in project jackrabbit by apache.

the class ChildPropertyEntriesImpl method remove.

/**
     * @see ChildPropertyEntries#remove(PropertyEntry)
     */
public boolean remove(PropertyEntry propertyEntry) {
    synchronized (properties) {
        Name pName = propertyEntry.getName();
        PropertyEntry pe = get(pName);
        if (pe == propertyEntry) {
            properties.remove(pName);
            return true;
        } else {
            return false;
        }
    }
}
Also used : Name(org.apache.jackrabbit.spi.Name)

Example 79 with Name

use of org.apache.jackrabbit.spi.Name in project jackrabbit by apache.

the class PropertyImpl method getName.

//-----------------------------------------------------< Item interface >---
/**
     * @see Item#getName()
     */
@Override
public String getName() throws RepositoryException {
    checkStatus();
    Name name = getQName();
    return session.getNameResolver().getJCRName(name);
}
Also used : Name(org.apache.jackrabbit.spi.Name)

Example 80 with Name

use of org.apache.jackrabbit.spi.Name 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)

Aggregations

Name (org.apache.jackrabbit.spi.Name)382 RepositoryException (javax.jcr.RepositoryException)101 ArrayList (java.util.ArrayList)57 QValue (org.apache.jackrabbit.spi.QValue)42 NameException (org.apache.jackrabbit.spi.commons.conversion.NameException)39 HashSet (java.util.HashSet)38 Path (org.apache.jackrabbit.spi.Path)38 NodeId (org.apache.jackrabbit.core.id.NodeId)37 QPropertyDefinition (org.apache.jackrabbit.spi.QPropertyDefinition)33 ConstraintViolationException (javax.jcr.nodetype.ConstraintViolationException)32 NodeId (org.apache.jackrabbit.spi.NodeId)32 PropertyId (org.apache.jackrabbit.core.id.PropertyId)29 HashMap (java.util.HashMap)28 NamespaceException (javax.jcr.NamespaceException)28 NodeState (org.apache.jackrabbit.core.state.NodeState)28 Value (javax.jcr.Value)25 QNodeDefinition (org.apache.jackrabbit.spi.QNodeDefinition)25 InternalValue (org.apache.jackrabbit.core.value.InternalValue)23 ChildNodeEntry (org.apache.jackrabbit.core.state.ChildNodeEntry)22 PropertyState (org.apache.jackrabbit.core.state.PropertyState)22