Search in sources :

Example 11 with PropertyEntry

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

the class Checkin method persisted.

/**
     * Invalidate the target <code>NodeState</code>.
     *
     * @see Operation#persisted()
     */
public void persisted() {
    assert status == STATUS_PENDING;
    status = STATUS_PERSISTED;
    try {
        NodeEntry vhe = mgr.getVersionHistoryEntry(nodeState);
        if (vhe != null) {
            vhe.invalidate(true);
        }
    } catch (RepositoryException e) {
        log.debug("Failed to access Version history entry -> skip invalidation.", e);
    }
    Iterator<PropertyEntry> entries = ((NodeEntry) nodeState.getHierarchyEntry()).getPropertyEntries();
    while (entries.hasNext()) {
        PropertyEntry pe = entries.next();
        pe.invalidate(false);
    }
    nodeState.getHierarchyEntry().invalidate(false);
}
Also used : NodeEntry(org.apache.jackrabbit.jcr2spi.hierarchy.NodeEntry) PropertyEntry(org.apache.jackrabbit.jcr2spi.hierarchy.PropertyEntry) RepositoryException(javax.jcr.RepositoryException)

Example 12 with PropertyEntry

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

the class Checkout method persisted.

/**
     * Invalidate the target <code>NodeState</code>.
     *
     * @see Operation#persisted()
     */
public void persisted() {
    assert status == STATUS_PENDING;
    status = STATUS_PERSISTED;
    try {
        NodeEntry vhe = mgr.getVersionHistoryEntry(nodeState);
        if (vhe != null) {
            vhe.invalidate(true);
        }
    } catch (RepositoryException e) {
        log.warn("Failed to access Version history entry -> skip invalidation.", e);
    }
    // non-recursive invalidation (but including all properties)
    NodeEntry nodeEntry = (NodeEntry) nodeState.getHierarchyEntry();
    Iterator<PropertyEntry> entries = nodeEntry.getPropertyEntries();
    while (entries.hasNext()) {
        PropertyEntry pe = entries.next();
        pe.invalidate(false);
    }
    nodeEntry.invalidate(false);
}
Also used : NodeEntry(org.apache.jackrabbit.jcr2spi.hierarchy.NodeEntry) PropertyEntry(org.apache.jackrabbit.jcr2spi.hierarchy.PropertyEntry) RepositoryException(javax.jcr.RepositoryException)

Example 13 with PropertyEntry

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

the class Checkpoint method persisted.

/**
     * Invalidate the target <code>NodeState</code>.
     *
     * @see org.apache.jackrabbit.jcr2spi.operation.Operation#persisted()
     */
public void persisted() {
    assert status == STATUS_PENDING;
    status = STATUS_PERSISTED;
    try {
        NodeEntry vhe = mgr.getVersionHistoryEntry(nodeState);
        if (vhe != null) {
            vhe.invalidate(true);
        }
    } catch (RepositoryException e) {
        log.warn("Failed to access Version history entry -> skip invalidation.", e);
    }
    // non-recursive invalidation (but including all properties)
    NodeEntry nodeEntry = (NodeEntry) nodeState.getHierarchyEntry();
    Iterator<PropertyEntry> entries = nodeEntry.getPropertyEntries();
    while (entries.hasNext()) {
        PropertyEntry pe = entries.next();
        pe.invalidate(false);
    }
    nodeEntry.invalidate(false);
}
Also used : NodeEntry(org.apache.jackrabbit.jcr2spi.hierarchy.NodeEntry) PropertyEntry(org.apache.jackrabbit.jcr2spi.hierarchy.PropertyEntry) RepositoryException(javax.jcr.RepositoryException)

Example 14 with PropertyEntry

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

the class LockRelease method persisted.

/**
     * Invalidates the <code>NodeState</code> that has been unlocked 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
    NodeEntry nodeEntry = nodeState.getNodeEntry();
    Iterator<PropertyEntry> entries = nodeEntry.getPropertyEntries();
    while (entries.hasNext()) {
        PropertyEntry pe = entries.next();
        pe.invalidate(false);
    }
    nodeEntry.invalidate(false);
}
Also used : NodeEntry(org.apache.jackrabbit.jcr2spi.hierarchy.NodeEntry) PropertyEntry(org.apache.jackrabbit.jcr2spi.hierarchy.PropertyEntry)

Example 15 with PropertyEntry

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

the class SessionImporter method importProperty.

/**
     *
     * @param pi
     * @param parentState
     * @param resolver
     * @throws RepositoryException
     * @throws ConstraintViolationException
     */
private void importProperty(PropInfo pi, NodeState parentState, NamePathResolver resolver) throws RepositoryException, ConstraintViolationException {
    Name propName = pi.getName();
    TextValue[] tva = pi.getValues();
    int infoType = pi.getType();
    PropertyState propState = null;
    QPropertyDefinition def = null;
    NodeEntry parentEntry = (NodeEntry) parentState.getHierarchyEntry();
    PropertyEntry pEntry = parentEntry.getPropertyEntry(propName);
    if (pEntry != null) {
        // a property with that name already exists...
        try {
            PropertyState existing = pEntry.getPropertyState();
            def = existing.getDefinition();
            if (def.isProtected()) {
                // skip protected property
                log.debug("skipping protected property " + LogUtil.safeGetJCRPath(existing, session.getPathResolver()));
                return;
            }
            if (def.isAutoCreated() && (existing.getType() == infoType || infoType == PropertyType.UNDEFINED) && def.isMultiple() == existing.isMultiValued()) {
                // this property has already been auto-created, no need to create it
                propState = existing;
            } else {
                throw new ItemExistsException(LogUtil.safeGetJCRPath(existing, session.getPathResolver()));
            }
        } catch (ItemNotFoundException e) {
        // property doesn't exist any more
        // -> ignore
        }
    }
    Name[] parentNtNames = parentState.getAllNodeTypeNames();
    if (def == null) {
        // there's no property with that name, find applicable definition
        if (tva.length == 1) {
            // could be single- or multi-valued (n == 1)
            def = session.getItemDefinitionProvider().getQPropertyDefinition(parentNtNames, propName, infoType);
        } else {
            // can only be multi-valued (n == 0 || n > 1)
            def = session.getItemDefinitionProvider().getQPropertyDefinition(parentNtNames, propName, infoType, true);
        }
        if (def.isProtected()) {
            // skip protected property
            log.debug("skipping protected property " + propName);
            return;
        }
    }
    // retrieve the target property type needed for creation of QValue(s)
    // including an eventual conversion. the targetType is then needed for
    // setting/updating the type of the property-state.
    int targetType = def.getRequiredType();
    if (targetType == PropertyType.UNDEFINED) {
        if (infoType == PropertyType.UNDEFINED) {
            targetType = PropertyType.STRING;
        } else {
            targetType = infoType;
        }
    }
    QValue[] values = getPropertyValues(pi, targetType, def.isMultiple(), resolver);
    if (propState == null) {
        // create new property
        Operation ap = AddProperty.create(parentState, propName, targetType, def, values);
        stateMgr.execute(ap);
        propState = parentEntry.getPropertyEntry(propName).getPropertyState();
    } else {
        // modify value of existing property
        Operation sp = SetPropertyValue.create(propState, values, targetType);
        stateMgr.execute(sp);
    }
    // store reference for later resolution
    if (propState.getType() == PropertyType.REFERENCE) {
        refTracker.processedReference(propState);
    }
}
Also used : QValue(org.apache.jackrabbit.spi.QValue) Operation(org.apache.jackrabbit.jcr2spi.operation.Operation) Name(org.apache.jackrabbit.spi.Name) PropertyState(org.apache.jackrabbit.jcr2spi.state.PropertyState) NodeEntry(org.apache.jackrabbit.jcr2spi.hierarchy.NodeEntry) PropertyEntry(org.apache.jackrabbit.jcr2spi.hierarchy.PropertyEntry) ItemExistsException(javax.jcr.ItemExistsException) QPropertyDefinition(org.apache.jackrabbit.spi.QPropertyDefinition) 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