Package org.apache.jackrabbit.oak.api

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


    @CheckForNull
    private ImmutableTree getVersionableTree(@Nonnull ImmutableTree versionStoreTree) {
        String relPath = "";
        String versionablePath = null;
        Tree t = versionStoreTree;
        while (t.exists() && !t.isRoot() && !VersionConstants.VERSION_STORE_ROOT_NAMES.contains(t.getName())) {
            String ntName = TreeUtil.getPrimaryTypeName(t);
            if (VersionConstants.JCR_FROZENNODE.equals(t.getName()) && t != versionStoreTree) {
                relPath = PathUtils.relativize(t.getPath(), versionStoreTree.getPath());
            } else if (JcrConstants.NT_VERSIONHISTORY.equals(ntName)) {
                PropertyState prop = t.getProperty(workspaceName);
                if (prop != null) {
                    versionablePath = PathUtils.concat(prop.getValue(Type.PATH), relPath);
                }
                return (versionablePath == null) ? null : root.getTree(versionablePath);
            } else if (VersionConstants.NT_CONFIGURATION.equals(ntName)) {
                String rootId = TreeUtil.getString(t, VersionConstants.JCR_ROOT);
                if (rootId != null) {
                    versionablePath = new IdentifierManager(root).getPath(rootId);
                    return (versionablePath == null) ? null : root.getTree(versionablePath);
                } else {
                    log.error("Missing mandatory property jcr:root with configuration node.");
                    return null;
                }
            } else if (VersionConstants.NT_ACTIVITY.equals(ntName)) {
                return versionStoreTree;
            }
            t = t.getParent();
        }

        // intermediate node in the version, configuration or activity store that
        // matches none of the special conditions checked above -> regular permission eval.
        return versionStoreTree;
View Full Code Here


    @CheckForNull
    PrivilegeDefinition readDefinition(String privilegeName) {
        if (privilegesTree == null) {
            return null;
        } else {
            Tree definitionTree = privilegesTree.getChild(privilegeName);
            return (isPrivilegeDefinition(definitionTree)) ? PrivilegeUtil.readDefinition(definitionTree) : null;
        }
    }
View Full Code Here

    }

    public static Map<String, String> getNamespaceMap(Tree root) {
        Map<String, String> map = new HashMap<String, String>();

        Tree namespaces = getNamespaceTree(root);
        for (PropertyState property : namespaces.getProperties()) {
            String prefix = property.getName();
            if (STRING.equals(property.getType()) && isValidPrefix(prefix)) {
                map.put(unescapePropertyKey(prefix), property.getValue(STRING));
            }
        }
View Full Code Here

    static Set<String> getNamespacePrefixesAsSet(Tree root) {
        return safeGet(getNamespaceTree(root).getChild(REP_NSDATA), REP_PREFIXES);
    }

    public static String getNamespacePrefix(Tree root, String uri) {
        Tree namespaces = getNamespaceTree(root);
        PropertyState ps = namespaces.getChild(REP_NSDATA)
                .getProperty(encodeUri(escapePropertyKey(uri)));
        if (ps != null) {
            return ps.getValue(STRING);
        }
        return null;
View Full Code Here

@Service(EditorProvider.class)
public class ConflictValidatorProvider extends ValidatorProvider {

    @Override
    public Validator getRootValidator(NodeState before, NodeState after) {
        Tree rootAfter = new ImmutableTree(after);
        return new ConflictValidator(rootAfter);
    }
View Full Code Here

     * @return The path of the tree with the given {@code identifier} or {@code null} if no
     *         such tree exists or if the tree is not accessible.
     */
    @CheckForNull
    public String getPath(String identifier) {
        Tree tree = getTree(identifier);
        return tree != null && tree.exists()
            ? tree.getPath()
            : null;
    }
View Full Code Here

                        }
                    }

                    // skip references from the version storage (OAK-1196)
                    if (!rowPath.startsWith(VersionConstants.VERSION_STORE_PATH)) {
                        Tree tree = root.getTree(rowPath);
                        if (nodeTypeNames.length == 0 || containsNodeType(tree, nodeTypeNames)) {
                            if (propertyName == null) {
                                return filter(
                                        transform(tree.getProperties().iterator(), new PropertyToPath()),
                                        notNull());
                            } else {
                                // for a fixed property name, we don't need to look for it, but just assume that
                                // the search found the correct one
                                return singletonIterator(PathUtils.concat(rowPath, propertyName));
View Full Code Here

                        }
                    }

                    // skip references from the version storage (OAK-1196)
                    if (!rowPath.startsWith(VersionConstants.VERSION_STORE_PATH)) {
                        Tree tree = root.getTree(rowPath);
                        if (nodeTypeNames.length == 0 || containsNodeType(tree, nodeTypeNames)) {
                            if (propertyName == null) {
                                return filter(
                                        transform(tree.getProperties().iterator(), new PropertyToPath()),
                                        notNull());
                            } else {
                                // for a fixed property name, we don't need to look for it, but just assume that
                                // the search found the correct one
                                return singletonIterator(PathUtils.concat(rowPath, propertyName));
View Full Code Here

        if (uri.equals(getNamespaceURI(getReadTree(), prefix))) {
            return; // Namespace already registered, so we do nothing
        }
        try {
            Root root = getWriteRoot();
            Tree namespaces = root.getTree(NAMESPACES_PATH);

            // remove existing mapping to given uri
            String ns = Namespaces.getNamespacePrefix(namespaces, uri);
            if (ns != null) {
                namespaces.removeProperty(ns);
            }
            namespaces.setProperty(prefix, uri);
            root.commit();
            refresh();
        } catch (CommitFailedException e) {
            String message =
                    "Failed to register namespace mapping from "
View Full Code Here

    }

    @Override
    public void unregisterNamespace(String prefix) throws RepositoryException {
        Root root = getWriteRoot();
        Tree namespaces = root.getTree(NAMESPACES_PATH);
        if (!namespaces.exists() || !namespaces.hasProperty(prefix)) {
            throw new NamespaceException(
                    "Namespace mapping from " + prefix + " to "
                            + getURI(prefix) + " can not be unregistered");
        }

        try {
            namespaces.removeProperty(prefix);
            root.commit();
            refresh();
        } catch (CommitFailedException e) {
            String message = "Failed to unregister namespace mapping for prefix " + prefix;
            throw e.asRepositoryException(message);
View Full Code Here

TOP

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

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.