Package org.apache.jackrabbit.oak.api

Examples of org.apache.jackrabbit.oak.api.PropertyState


            ids.add(writeNode(state.getChildNode(template.getChildName())).getRecordId());
        }

        for (PropertyTemplate pt : template.getPropertyTemplates()) {
            String name = pt.getName();
            PropertyState property = state.getProperty(name);

            if (store.isInstance(property, SegmentPropertyState.class)) {
                ids.add(((SegmentPropertyState) property).getRecordId());
            } else {
                Map<String, RecordId> previousValues = emptyMap();
                if (before != null) {
                    // reuse previously stored property values, if possible
                    PropertyState beforeProperty = before.getProperty(name);
                    if (store.isInstance(beforeProperty, SegmentPropertyState.class)
                            && beforeProperty.isArray()
                            && beforeProperty.getType() != Type.BINARIES) {
                        SegmentPropertyState segmentProperty =
                                (SegmentPropertyState) beforeProperty;
                        previousValues = segmentProperty.getValueRecords();
                    }
                }
View Full Code Here


    }

    static PropertyState getProperty(
            NodeState base, Map<String, PropertyState> properties,
            String name) {
        PropertyState property = properties.get(name);
        if (property == null && !properties.containsKey(name)) {
            property = base.getProperty(name);
        }
        return property;
    }
View Full Code Here

        if (this == base) {
            return true; // no differences
        }

        for (Map.Entry<String, PropertyState> entry : properties.entrySet()) {
            PropertyState before = base.getProperty(entry.getKey());
            PropertyState after = entry.getValue();
            if (after == null) {
                if (before != null && !diff.propertyDeleted(before)) {
                    return false;
                }
            } else if (before == null) {
                if (!diff.propertyAdded(after)) {
                    return false;
                }
            } else if (!before.equals(after)
                    && !diff.propertyChanged(before, after)) {
                return false;
            }
        }

        for (Map.Entry<String, NodeState> entry : nodes.entrySet()) {
            String name = entry.getKey();
            NodeState before = base.getChildNode(name);
            NodeState after = entry.getValue();
            if (!after.exists()) {
                if (before.exists() && !diff.childNodeDeleted(name, before)) {
                    return false;
                }
            } else if (!before.exists()) {
                if (!diff.childNodeAdded(name, after)) {
                    return false;
                }
            } else if (before != after // TODO: fastEquals?
                    && !diff.childNodeChanged(name, before, after)) {
                return false;
            }
        }

        return this.base.compareAgainstBaseState(base, new NodeStateDiff() {
            @Override
            public boolean propertyAdded(PropertyState after) {
                return properties.containsKey(after.getName())
                        || diff.propertyAdded(after);
            }
            @Override
            public boolean propertyChanged(
                    PropertyState before, PropertyState after) {
View Full Code Here

    @Override
    public Value[] getProperty(String relPath) throws RepositoryException {
        String oakPath = getOakPath(relPath);
        Tree tree = getTree();
        Value[] values = null;
        PropertyState property = getAuthorizableProperty(tree, getLocation(tree, oakPath), true);
        if (property != null) {
            if (property.isArray()) {
                List<Value> vs = ValueFactoryImpl.createValues(property, namePathMapper);
                values = vs.toArray(new Value[vs.size()]);
            } else {
                values = new Value[]{ValueFactoryImpl.createValue(property, namePathMapper)};
            }
View Full Code Here

        if (value == null) {
            removeProperty(relPath);
        } else {
            String oakPath = getOakPath(relPath);
            String name = Text.getName(oakPath);
            PropertyState propertyState = PropertyStates.createProperty(name, value);

            String intermediate = (oakPath.equals(name)) ? null : Text.getRelativeParent(oakPath, 1);
            Tree parent = getOrCreateTargetTree(intermediate);
            checkProtectedProperty(parent, propertyState);
View Full Code Here

    private String getOakName() {
        return getOakName(definition);
    }

    private String getOakName(Tree tree) {
        PropertyState property = tree.getProperty(JCR_NODETYPENAME);
        if (property != null) {
            return property.getValue(Type.NAME);
        } else {
            return tree.getName();
        }
    }
View Full Code Here

        if (values == null) {
            removeProperty(relPath);
        } else {
            String oakPath = getOakPath(relPath);
            String name = Text.getName(oakPath);
            PropertyState propertyState =
                    PropertyStates.createProperty(name, Arrays.asList(values));

            String intermediate = (oakPath.equals(name)) ? null : Text.getRelativeParent(oakPath, 1);
            Tree parent = getOrCreateTargetTree(intermediate);
            checkProtectedProperty(parent, propertyState);
View Full Code Here

        addSupertypes(definition, supertypes);
        return supertypes.values().toArray(NO_NODE_TYPES);
    }

    private void addSupertypes(Tree type, Map<String, NodeType> supertypes) {
        PropertyState property = type.getProperty(JCR_SUPERTYPES);
        if (property != null) {
            Tree root = definition.getParent();
            for (String oakName : property.getValue(Type.NAMES)) {
                if (!supertypes.containsKey(oakName)) {
                    Tree supertype = root.getChild(oakName);
                    checkState(supertype.exists());
                    supertypes.put(
                            oakName, new NodeTypeImpl(supertype, mapper));
View Full Code Here

    @CheckForNull
    private PropertyState getAuthorizableProperty(Tree authorizableTree, TreeLocation propertyLocation, boolean verifyAncestor) throws RepositoryException {
        if (propertyLocation == null) {
            return null;
        }
        PropertyState property = propertyLocation.getProperty();
        if (property == null) {
            return null;
        }

        String authorizablePath = authorizableTree.getPath();
View Full Code Here

* alternatives.
*/
public abstract class AbstractNodeState implements NodeState {

    public static boolean getBoolean(NodeState state, String name) {
        PropertyState property = state.getProperty(name);
        return property != null
                && property.getType() == BOOLEAN
                && property.getValue(BOOLEAN);
    }
View Full Code Here

TOP

Related Classes of org.apache.jackrabbit.oak.api.PropertyState

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.