Search in sources :

Example 46 with NotExecutableException

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

the class RemoveReferenceableNodeTest method createRemoveItem.

@Override
protected Item createRemoveItem() throws NotExecutableException, RepositoryException {
    Node removeItem = (Node) super.createRemoveItem();
    // assert removeNode is referenceable
    if (!removeItem.isNodeType(mixReferenceable)) {
        if (!removeItem.canAddMixin(mixReferenceable)) {
            throw new NotExecutableException("Cannot make remove-node '" + nodeName1 + "' mix:referenceable.");
        }
        removeItem.addMixin(mixReferenceable);
    }
    // make sure the new node is persisted.
    testRootNode.save();
    uuid = removeItem.getUUID();
    return removeItem;
}
Also used : NotExecutableException(org.apache.jackrabbit.test.NotExecutableException) Node(javax.jcr.Node)

Example 47 with NotExecutableException

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

the class MultiValuedPropertyTest method testGetLongFromMultivalued.

/**
     * Tests if Property.getLong() fails for multivalued properties.
     *
     * @throws RepositoryException
     * @throws NotExecutableException
     */
public void testGetLongFromMultivalued() throws RepositoryException, NotExecutableException {
    Property prop = PropertyUtil.searchMultivalProp(testRootNode);
    if (prop == null) {
        throw new NotExecutableException("No multivalued property found.");
    } else {
        try {
            prop.getLong();
            fail("Property.getLong() must fail with ValueFormatException for any multivalued property.");
        } catch (ValueFormatException vfe) {
        // ok
        }
    }
}
Also used : NotExecutableException(org.apache.jackrabbit.test.NotExecutableException) ValueFormatException(javax.jcr.ValueFormatException) Property(javax.jcr.Property)

Example 48 with NotExecutableException

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

the class MultiValuedPropertyTest method testGetDateFromMultivalued.

/**
     * Tests if Property.getDate() fails multivalued properties.
     *
     * @throws RepositoryException
     * @throws NotExecutableException
     */
public void testGetDateFromMultivalued() throws RepositoryException, NotExecutableException {
    Property prop = PropertyUtil.searchMultivalProp(testRootNode);
    if (prop == null) {
        throw new NotExecutableException("No multivalued property found.");
    } else {
        try {
            prop.getDate();
            fail("Property.getDate() must fail with ValueFormatException for any multivalued property.");
        } catch (ValueFormatException vfe) {
        // ok
        }
    }
}
Also used : NotExecutableException(org.apache.jackrabbit.test.NotExecutableException) ValueFormatException(javax.jcr.ValueFormatException) Property(javax.jcr.Property)

Example 49 with NotExecutableException

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

the class UserImportTest method testExistingPrincipal.

@Test
public void testExistingPrincipal() throws Exception {
    Principal existing = null;
    PrincipalIterator principalIterator = ((JackrabbitSession) getImportSession()).getPrincipalManager().getPrincipals(PrincipalManager.SEARCH_TYPE_ALL);
    while (principalIterator.hasNext()) {
        Principal p = principalIterator.nextPrincipal();
        if (getUserManager().getAuthorizable(p) != null) {
            existing = p;
            break;
        }
    }
    if (existing == null) {
        throw new NotExecutableException();
    }
    String xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<sv:node sv:name=\"t\" xmlns:mix=\"http://www.jcp.org/jcr/mix/1.0\" xmlns:nt=\"http://www.jcp.org/jcr/nt/1.0\" xmlns:fn_old=\"http://www.w3.org/2004/10/xpath-functions\" xmlns:fn=\"http://www.w3.org/2005/xpath-functions\" xmlns:xs=\"http://www.w3.org/2001/XMLSchema\" xmlns:sv=\"http://www.jcp.org/jcr/sv/1.0\" xmlns:rep=\"internal\" xmlns:jcr=\"http://www.jcp.org/jcr/1.0\">" + "   <sv:property sv:name=\"jcr:primaryType\" sv:type=\"Name\"><sv:value>rep:User</sv:value></sv:property>" + "   <sv:property sv:name=\"jcr:uuid\" sv:type=\"String\"><sv:value>e358efa4-89f5-3062-b10d-d7316b65649e</sv:value></sv:property>" + "   <sv:property sv:name=\"rep:password\" sv:type=\"String\"><sv:value>{sha1}8efd86fb78a56a5145ed7739dcb00c78581c5375</sv:value></sv:property>" + "   <sv:property sv:name=\"rep:principalName\" sv:type=\"String\"><sv:value>" + existing.getName() + "</sv:value></sv:property>" + "</sv:node>";
    try {
        doImport(getTargetPath(), xml);
        getImportSession().save();
        fail("Import must detect conflicting principals.");
    } catch (RepositoryException e) {
    // success
    }
}
Also used : NotExecutableException(org.apache.jackrabbit.test.NotExecutableException) PrincipalIterator(org.apache.jackrabbit.api.security.principal.PrincipalIterator) RepositoryException(javax.jcr.RepositoryException) Principal(java.security.Principal) Test(org.junit.Test)

Example 50 with NotExecutableException

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

the class ACLTemplateTest method testMultiplePrincipals.

public void testMultiplePrincipals() throws RepositoryException, NotExecutableException {
    PrincipalManager pMgr = ((JackrabbitSession) superuser).getPrincipalManager();
    Principal everyone = pMgr.getEveryone();
    Principal grPrincipal = null;
    PrincipalIterator it = pMgr.findPrincipals("", PrincipalManager.SEARCH_TYPE_GROUP);
    while (it.hasNext()) {
        Group gr = (Group) it.nextPrincipal();
        if (!everyone.equals(gr)) {
            grPrincipal = gr;
        }
    }
    if (grPrincipal == null || grPrincipal.equals(everyone)) {
        throw new NotExecutableException();
    }
    Privilege[] privs = privilegesFromName(Privilege.JCR_READ);
    JackrabbitAccessControlList pt = createEmptyTemplate(getTestPath());
    pt.addAccessControlEntry(testPrincipal, privs);
    assertFalse(pt.addAccessControlEntry(testPrincipal, privs));
    // add same privileges for another principal -> must modify as well.
    assertTrue(pt.addAccessControlEntry(everyone, privs));
    // .. 2 entries must be present.
    assertTrue(pt.getAccessControlEntries().length == 2);
}
Also used : PrincipalManager(org.apache.jackrabbit.api.security.principal.PrincipalManager) Group(java.security.acl.Group) NotExecutableException(org.apache.jackrabbit.test.NotExecutableException) PrincipalIterator(org.apache.jackrabbit.api.security.principal.PrincipalIterator) JackrabbitSession(org.apache.jackrabbit.api.JackrabbitSession) Privilege(javax.jcr.security.Privilege) JackrabbitAccessControlList(org.apache.jackrabbit.api.security.JackrabbitAccessControlList) Principal(java.security.Principal)

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