Package org.apache.jackrabbit.oak.api

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


    private Validator checkPermissions(@Nonnull Tree tree, boolean isBefore,
                                       long defaultPermission) throws CommitFailedException {
        long toTest = getPermission(tree, defaultPermission);
        if (Permissions.isRepositoryPermission(toTest)) {
            if (!permissionProvider.isGranted(toTest)) {
                throw new CommitFailedException(ACCESS, 0, "Access denied");
            }
            return null; // no need for further validation down the subtree
        } else {
            if (!permissionProvider.isGranted(tree, null, toTest)) {
                throw new CommitFailedException(ACCESS, 0, "Access denied");
            }
            if (noTraverse(toTest, defaultPermission)) {
                return null;
            } else {
                return (isBefore) ?
View Full Code Here


            return;
        }
        long toTest = getPermission(parent, property, defaultPermission);
        if (Permissions.isRepositoryPermission(toTest)) {
            if (!permissionProvider.isGranted(toTest)) {
                throw new CommitFailedException(ACCESS, 0, "Access denied");
            }
        } else if (!permissionProvider.isGranted(parent, property, toTest)) {
            throw new CommitFailedException(ACCESS, 0, "Access denied");
        }
    }
View Full Code Here

            if (VersionConstants.NT_VERSIONHISTORY.equals(TreeUtil.getPrimaryTypeName(child))) {
                versionHistory = child;
            } else if (isVersionstorageTree(child)) {
                versionHistory = getVersionHistoryTree(child);
            } else {
                throw new CommitFailedException("Misc", 0, "unexpected node");
            }
        }
        return versionHistory;
    }
View Full Code Here

    protected void checkValidName(String name) throws CommitFailedException {
        int colon = name.indexOf(':');
        if (colon > 0) {
            String prefix = name.substring(0, colon);
            if (prefix.isEmpty() || !prefixes.contains(prefix)) {
                throw new CommitFailedException(
                        CommitFailedException.NAME, 1, "Invalid namespace prefix: " + name);
            }
        }

        String local = name.substring(colon + 1);

        int n = local.length();
        if (n > 3 && local.charAt(n - 1) == ']') {
            int i = n - 2;
            while (i > 1 && Character.isDigit(local.charAt(i))) {
                i--;
            }
            if (local.charAt(i) != '[') {
                throw new CommitFailedException(
                        CommitFailedException.NAME, 2, "Invalid name index " + name);
            } else {
                local = local.substring(0, i);
            }
        }

        if (!Namespaces.isValidLocalName(local)) {
            throw new CommitFailedException(
                    CommitFailedException.NAME, 3, "Invalid name: " + name);
        }
    }
View Full Code Here

        // ignore jcr:primaryType
        if (prefix.equals("jcr:primaryType")) {
            return;
        }
        if (map.containsKey(prefix)) {
            throw new CommitFailedException(
                    CommitFailedException.NAMESPACE, 1,
                    "Namespace mapping already registered: " + prefix);
        } else if (Namespaces.isValidPrefix(prefix)) {
            if (after.isArray() || !STRING.equals(after.getType())) {
                throw new CommitFailedException(
                        CommitFailedException.NAMESPACE, 2,
                        "Invalid namespace mapping: " + prefix);
            } else if (prefix.toLowerCase(Locale.ENGLISH).startsWith("xml")) {
                throw new CommitFailedException(
                        CommitFailedException.NAMESPACE, 3,
                        "XML prefixes are reserved: " + prefix);
            } else if (map.containsValue(after.getValue(STRING))) {
                throw modificationNotAllowed(prefix);
            }
        } else {
            throw new CommitFailedException(
                    CommitFailedException.NAMESPACE, 4,
                    "Not a valid namespace prefix: " + prefix);
        }
    }
View Full Code Here

            // TODO: Check whether this namespace is still used in content
        }
    }

    private static CommitFailedException modificationNotAllowed(String prefix) {
        return new CommitFailedException(
                CommitFailedException.NAMESPACE, 5,
                "Namespace modification not allowed: " + prefix);
    }
View Full Code Here

    public void removeMandatoryProperty() throws CommitFailedException {
        EffectiveType effective = createControl().createMock(EffectiveType.class);
        expect(effective.isMandatoryProperty("mandatory")).andReturn(true);
        expect(effective.constraintViolation(
                22, "/", "Mandatory property mandatory can not be removed"))
                .andReturn(new CommitFailedException("", 0, ""));

        replay(effective);

        TypeEditor editor = new TypeEditor(effective);
        editor.propertyDeleted(PropertyStates.createProperty("mandatory", ""));
View Full Code Here

    public void removeMandatoryChildNode() throws CommitFailedException {
        EffectiveType effective = createControl().createMock(EffectiveType.class);
        expect(effective.isMandatoryChildNode("mandatory")).andReturn(true);
        expect(effective.constraintViolation(
                26, "/", "Mandatory child node mandatory can not be removed"))
                .andReturn(new CommitFailedException("", 0, ""));

        replay(effective);

        TypeEditor editor = new TypeEditor(effective);
        editor.childNodeDeleted("mandatory", EMPTY_NODE);
View Full Code Here

                NodeState newHead = store.commit(diff.toString(), base);
                committed.contentChanged(base, newHead);
                branchState = new Merged(base);
                return newHead;
            } catch (MicroKernelException e) {
                throw new CommitFailedException(
                        "Kernel", 1,
                        "Failed to merge changes to the underlying MicroKernel", e);
            } finally {
                mergeLock.unlock();
            }
View Full Code Here

                    committed.contentChanged(base, newRoot);
                    branchState = new Merged(base);
                    return newRoot;
                }
            } catch (MicroKernelException e) {
                throw new CommitFailedException(
                        "Kernel", 1,
                        "Failed to merge changes to the underlying MicroKernel", e);
            } finally {
                mergeLock.unlock();
            }
View Full Code Here

TOP

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

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.