Search in sources :

Example 36 with PropertyId

use of org.apache.jackrabbit.core.id.PropertyId in project jackrabbit by apache.

the class NodeImpl method removeChildProperty.

protected void removeChildProperty(Name propName) throws RepositoryException {
    // modify the state of 'this', i.e. the parent node
    NodeState thisState = (NodeState) getOrCreateTransientItemState();
    // remove the property entry
    if (!thisState.removePropertyName(propName)) {
        String msg = "failed to remove property " + propName + " of " + this;
        log.debug(msg);
        throw new RepositoryException(msg);
    }
    // remove property
    PropertyId propId = new PropertyId(thisState.getNodeId(), propName);
    itemMgr.getItem(propId).setRemoved();
}
Also used : NodeState(org.apache.jackrabbit.core.state.NodeState) RepositoryException(javax.jcr.RepositoryException) PropertyId(org.apache.jackrabbit.core.id.PropertyId)

Example 37 with PropertyId

use of org.apache.jackrabbit.core.id.PropertyId in project jackrabbit by apache.

the class NodeImpl method isCheckedOut.

// ------------------------------< versioning support: public Node methods >
/**
 * {@inheritDoc}
 */
public boolean isCheckedOut() throws RepositoryException {
    // check state of this instance
    sanityCheck();
    // otherwise it would had been impossible to add it in the first place
    if (isNew()) {
        return true;
    }
    // this would have a negative impact on performance though...
    try {
        NodeState state = getNodeState();
        while (!state.hasPropertyName(JCR_ISCHECKEDOUT)) {
            ItemId parentId = state.getParentId();
            if (parentId == null) {
                // root reached or out of hierarchy
                return true;
            }
            state = (NodeState) sessionContext.getItemStateManager().getItemState(parentId);
        }
        PropertyId id = new PropertyId(state.getNodeId(), JCR_ISCHECKEDOUT);
        PropertyState ps = (PropertyState) sessionContext.getItemStateManager().getItemState(id);
        InternalValue[] values = ps.getValues();
        if (values == null || values.length != 1) {
            // in which case it's probably not mix:versionable
            return true;
        }
        return values[0].getBoolean();
    } catch (ItemStateException e) {
        throw new RepositoryException(e);
    }
}
Also used : NodeState(org.apache.jackrabbit.core.state.NodeState) RepositoryException(javax.jcr.RepositoryException) InternalValue(org.apache.jackrabbit.core.value.InternalValue) ItemId(org.apache.jackrabbit.core.id.ItemId) PropertyId(org.apache.jackrabbit.core.id.PropertyId) PropertyState(org.apache.jackrabbit.core.state.PropertyState) InvalidItemStateException(javax.jcr.InvalidItemStateException) ItemStateException(org.apache.jackrabbit.core.state.ItemStateException)

Example 38 with PropertyId

use of org.apache.jackrabbit.core.id.PropertyId in project jackrabbit by apache.

the class ItemManager method propertyExists.

/**
 * Checks whether a property exists at the specified path.
 *
 * @param path path to the property to be checked
 * @return true if a property exists at the specified path
 */
public boolean propertyExists(Path path) {
    try {
        sanityCheck();
        PropertyId id = hierMgr.resolvePropertyPath(path);
        return (id != null) && itemExists(id, path);
    } catch (RepositoryException re) {
        return false;
    }
}
Also used : RepositoryException(javax.jcr.RepositoryException) PropertyId(org.apache.jackrabbit.core.id.PropertyId)

Example 39 with PropertyId

use of org.apache.jackrabbit.core.id.PropertyId in project jackrabbit by apache.

the class ItemManager method hasChildProperties.

/**
 * @param parentId
 * @return
 * @throws ItemNotFoundException
 * @throws AccessDeniedException
 * @throws RepositoryException
 */
synchronized boolean hasChildProperties(NodeId parentId) throws ItemNotFoundException, AccessDeniedException, RepositoryException {
    sanityCheck();
    ItemData data = getItemData(parentId);
    if (!data.isNode()) {
        String msg = "can't list child properties of property " + parentId;
        log.debug(msg);
        throw new RepositoryException(msg);
    }
    Iterator<Name> iter = ((NodeState) data.getState()).getPropertyNames().iterator();
    while (iter.hasNext()) {
        Name propName = iter.next();
        // make sure any of the properties can be read.
        if (canRead(data, new PropertyId(parentId, propName))) {
            return true;
        }
    }
    return false;
}
Also used : RepositoryException(javax.jcr.RepositoryException) Name(org.apache.jackrabbit.spi.Name) PropertyId(org.apache.jackrabbit.core.id.PropertyId)

Example 40 with PropertyId

use of org.apache.jackrabbit.core.id.PropertyId in project jackrabbit by apache.

the class GarbageCollector method scanPersistenceManagersByNodeInfos.

private void scanPersistenceManagersByNodeInfos() throws RepositoryException, ItemStateException {
    int pmCount = 0;
    for (IterablePersistenceManager pm : pmList) {
        pmCount++;
        int count = 0;
        Map<NodeId, NodeInfo> batch = pm.getAllNodeInfos(null, NODESATONCE);
        while (!batch.isEmpty()) {
            NodeId lastId = null;
            for (NodeInfo info : batch.values()) {
                count++;
                if (count % 1000 == 0) {
                    LOG.debug(pm.toString() + " (" + pmCount + "/" + pmList.length + "): analyzed " + count + " nodes...");
                }
                lastId = info.getId();
                if (callback != null) {
                    callback.beforeScanning(null);
                }
                if (info.hasBlobsInDataStore()) {
                    try {
                        NodeState state = pm.load(info.getId());
                        Set<Name> propertyNames = state.getPropertyNames();
                        for (Name name : propertyNames) {
                            PropertyId pid = new PropertyId(info.getId(), name);
                            PropertyState ps = pm.load(pid);
                            if (ps.getType() == PropertyType.BINARY) {
                                for (InternalValue v : ps.getValues()) {
                                    // getLength will update the last modified date
                                    // if the persistence manager scan is running
                                    v.getLength();
                                }
                            }
                        }
                    } catch (NoSuchItemStateException ignored) {
                    // the node may have been deleted in the meantime
                    }
                }
            }
            batch = pm.getAllNodeInfos(lastId, NODESATONCE);
        }
    }
    NodeInfo.clearPool();
}
Also used : IterablePersistenceManager(org.apache.jackrabbit.core.persistence.IterablePersistenceManager) NodeState(org.apache.jackrabbit.core.state.NodeState) NoSuchItemStateException(org.apache.jackrabbit.core.state.NoSuchItemStateException) NodeInfo(org.apache.jackrabbit.core.persistence.util.NodeInfo) NodeId(org.apache.jackrabbit.core.id.NodeId) InternalValue(org.apache.jackrabbit.core.value.InternalValue) Name(org.apache.jackrabbit.spi.Name) PropertyId(org.apache.jackrabbit.core.id.PropertyId) PropertyState(org.apache.jackrabbit.core.state.PropertyState)

Aggregations

PropertyId (org.apache.jackrabbit.core.id.PropertyId)59 Name (org.apache.jackrabbit.spi.Name)29 PropertyState (org.apache.jackrabbit.core.state.PropertyState)25 NodeState (org.apache.jackrabbit.core.state.NodeState)23 RepositoryException (javax.jcr.RepositoryException)22 ItemStateException (org.apache.jackrabbit.core.state.ItemStateException)22 NodeId (org.apache.jackrabbit.core.id.NodeId)16 InternalValue (org.apache.jackrabbit.core.value.InternalValue)14 NoSuchItemStateException (org.apache.jackrabbit.core.state.NoSuchItemStateException)12 ChildNodeEntry (org.apache.jackrabbit.core.state.ChildNodeEntry)11 HashSet (java.util.HashSet)10 InvalidItemStateException (javax.jcr.InvalidItemStateException)9 ArrayList (java.util.ArrayList)7 EffectiveNodeType (org.apache.jackrabbit.core.nodetype.EffectiveNodeType)6 ConstraintViolationException (javax.jcr.nodetype.ConstraintViolationException)5 NodeReferences (org.apache.jackrabbit.core.state.NodeReferences)5 PropertyDefinitionImpl (org.apache.jackrabbit.spi.commons.nodetype.PropertyDefinitionImpl)5 ItemId (org.apache.jackrabbit.core.id.ItemId)4 NodeTypeManagerImpl (org.apache.jackrabbit.core.nodetype.NodeTypeManagerImpl)4 PropertyEntry (org.apache.jackrabbit.core.persistence.util.NodePropBundle.PropertyEntry)4