Search in sources :

Example 16 with NotExecutableException

use of org.apache.jackrabbit.test.NotExecutableException in project jackrabbit by apache.

the class AbstractWorkspaceReferenceableTest method setUp.

protected void setUp() throws Exception {
    super.setUp();
    // we assume referencing is supported by repository
    NodeTypeManager ntMgr = superuser.getWorkspace().getNodeTypeManager();
    // assert that this repository supports references
    try {
        NodeType referenceableNt = ntMgr.getNodeType(mixReferenceable);
        if (referenceableNt == null) {
            throw new NotExecutableException("Repository does not support Referencing: mixin nodetype '" + mixReferenceable + "' is missing.");
        }
    } catch (NoSuchNodeTypeException e) {
        throw new NotExecutableException("Repository does not support Referencing: mixin nodetype '" + mixReferenceable + "' is missing.");
    }
}
Also used : NodeTypeManager(javax.jcr.nodetype.NodeTypeManager) NotExecutableException(org.apache.jackrabbit.test.NotExecutableException) NodeType(javax.jcr.nodetype.NodeType) NoSuchNodeTypeException(javax.jcr.nodetype.NoSuchNodeTypeException)

Example 17 with NotExecutableException

use of org.apache.jackrabbit.test.NotExecutableException in project jackrabbit by apache.

the class AbstractWorkspaceSameNameSibsTest method setUp.

protected void setUp() throws Exception {
    super.setUp();
    // we assume sameNameSibs is supported by repository
    NodeTypeManager ntMgr = superuser.getWorkspace().getNodeTypeManager();
    // make sure 'sameNameSibsTrue' nodetype is properly defined
    try {
        sameNameSibsTrueNodeType = ntMgr.getNodeType(getProperty(PROP_SAME_NAME_SIBS_TRUE_NODE_TYPE));
        NodeDefinition[] childNodeDefs = sameNameSibsTrueNodeType.getDeclaredChildNodeDefinitions();
        boolean isSameNameSibs = false;
        for (int i = 0; i < childNodeDefs.length; i++) {
            if (childNodeDefs[i].allowsSameNameSiblings()) {
                isSameNameSibs = true;
                break;
            }
        }
        if (!isSameNameSibs) {
            throw new NotExecutableException("Property 'sameNameSibsTrueNodeType' does not define a nodetype where sameNameSibs are allowed: '" + sameNameSibsTrueNodeType.getName() + "'");
        }
    } catch (NoSuchNodeTypeException e) {
        fail("Property 'sameNameSibsTrueNodeType' does not define an existing nodetype: '" + sameNameSibsTrueNodeType + "'");
    }
    // make sure 'sameNameSibsFalse' nodetype is properly defined
    try {
        sameNameSibsFalseNodeType = ntMgr.getNodeType(getProperty(PROP_SAME_NAME_SIBS_FALSE_NODE_TYPE));
        NodeDefinition[] childNodeDefs = sameNameSibsFalseNodeType.getDeclaredChildNodeDefinitions();
        boolean isSameNameSibs = true;
        for (int i = 0; i < childNodeDefs.length; i++) {
            if (!childNodeDefs[i].allowsSameNameSiblings()) {
                isSameNameSibs = false;
                break;
            }
        }
        if (isSameNameSibs) {
            fail("Property 'sameNameSibsFalseNodeType' does define a nodetype where sameNameSibs are not allowed: '" + sameNameSibsFalseNodeType.getName() + "'");
        }
    } catch (NoSuchNodeTypeException e) {
        fail("Property 'sameNameSibsFalseNodeType' does not define an existing nodetype: '" + sameNameSibsFalseNodeType + "'");
    }
}
Also used : NodeTypeManager(javax.jcr.nodetype.NodeTypeManager) NotExecutableException(org.apache.jackrabbit.test.NotExecutableException) NodeDefinition(javax.jcr.nodetype.NodeDefinition) NoSuchNodeTypeException(javax.jcr.nodetype.NoSuchNodeTypeException)

Example 18 with NotExecutableException

use of org.apache.jackrabbit.test.NotExecutableException in project jackrabbit by apache.

the class AbstractWorkspaceVersionableTest method setUp.

protected void setUp() throws Exception {
    super.setUp();
    // we assume versioning is supported by repository
    NodeTypeManager ntMgr = superuser.getWorkspace().getNodeTypeManager();
    // assert that this repository supports versioning
    try {
        NodeType versionableNt = ntMgr.getNodeType(mixVersionable);
        if (versionableNt == null) {
            throw new NotExecutableException("Repository does not support versioning: mixin nodetype '" + mixVersionable + "' is missing.");
        }
    } catch (NoSuchNodeTypeException e) {
        throw new NotExecutableException("Repository does not support versioning: mixin nodetype '" + mixVersionable + "' is missing.");
    }
}
Also used : NodeTypeManager(javax.jcr.nodetype.NodeTypeManager) NotExecutableException(org.apache.jackrabbit.test.NotExecutableException) NodeType(javax.jcr.nodetype.NodeType) NoSuchNodeTypeException(javax.jcr.nodetype.NoSuchNodeTypeException)

Example 19 with NotExecutableException

use of org.apache.jackrabbit.test.NotExecutableException in project jackrabbit by apache.

the class DerefQueryLevel1Test method testDerefMultiPropWithNodeTest.

/**
     * Test a deref query on a multi valued reference property with a node test.
     * @throws NotExecutableException if the workspace does not have sufficient
     *  content.
     */
public void testDerefMultiPropWithNodeTest() throws RepositoryException, NotExecutableException {
    Property refProp = PropertyUtil.searchMultivalProp(testRootNode, PropertyType.REFERENCE);
    if (refProp == null) {
        throw new NotExecutableException("Workspace does not contain a node with a multivalue reference property.");
    }
    Value[] targets = refProp.getValues();
    Node[] targetNodes = new Node[targets.length];
    for (int i = 0; i < targets.length; i++) {
        targetNodes[i] = session.getNodeByUUID(targets[i].getString());
    }
    if (targetNodes.length == 0) {
        throw new NotExecutableException("Reference property does not contain a value");
    }
    String nodeName = targetNodes[0].getName();
    List<Node> resultNodes = new ArrayList<Node>();
    for (int i = 0; i < targetNodes.length; i++) {
        if (targetNodes[i].getName().equals(nodeName)) {
            resultNodes.add(targetNodes[i]);
        }
    }
    targetNodes = resultNodes.toArray(new Node[resultNodes.size()]);
    String xpath = createStatement(refProp, nodeName);
    executeDerefQuery(session, xpath, targetNodes);
}
Also used : NotExecutableException(org.apache.jackrabbit.test.NotExecutableException) Node(javax.jcr.Node) Value(javax.jcr.Value) ArrayList(java.util.ArrayList) Property(javax.jcr.Property)

Example 20 with NotExecutableException

use of org.apache.jackrabbit.test.NotExecutableException in project jackrabbit by apache.

the class DerefQueryLevel1Test method testDerefSinglePropWithNodeTest.

/**
     * Test a deref query on a single valued reference property with a node test.
     * @throws NotExecutableException if the workspace does not have sufficient
     *  content.
     */
public void testDerefSinglePropWithNodeTest() throws RepositoryException, NotExecutableException {
    Property refProp = PropertyUtil.searchProp(session, testRootNode, PropertyType.REFERENCE, Boolean.FALSE);
    if (refProp == null) {
        throw new NotExecutableException("Workspace does not contain a node with a reference property.");
    }
    Node target = refProp.getNode();
    String xpath = createStatement(refProp, target.getName());
    executeDerefQuery(session, xpath, new Node[] { target });
}
Also used : NotExecutableException(org.apache.jackrabbit.test.NotExecutableException) Node(javax.jcr.Node) Property(javax.jcr.Property)

Aggregations

NotExecutableException (org.apache.jackrabbit.test.NotExecutableException)381 Node (javax.jcr.Node)149 NodeType (javax.jcr.nodetype.NodeType)84 Value (javax.jcr.Value)81 RepositoryException (javax.jcr.RepositoryException)64 PropertyDefinition (javax.jcr.nodetype.PropertyDefinition)61 Session (javax.jcr.Session)59 Property (javax.jcr.Property)47 NodeDefinition (javax.jcr.nodetype.NodeDefinition)29 ConstraintViolationException (javax.jcr.nodetype.ConstraintViolationException)28 JackrabbitSession (org.apache.jackrabbit.api.JackrabbitSession)25 Authorizable (org.apache.jackrabbit.api.security.user.Authorizable)23 AccessControlPolicyIterator (javax.jcr.security.AccessControlPolicyIterator)22 Test (org.junit.Test)22 AccessControlPolicy (javax.jcr.security.AccessControlPolicy)21 User (org.apache.jackrabbit.api.security.user.User)19 Principal (java.security.Principal)18 NodeIterator (javax.jcr.NodeIterator)18 UserManager (org.apache.jackrabbit.api.security.user.UserManager)17 ItemExistsException (javax.jcr.ItemExistsException)16