Search in sources :

Example 36 with UnsupportedRepositoryOperationException

use of javax.jcr.UnsupportedRepositoryOperationException in project jackrabbit by apache.

the class AuthorizableActionTest method testAccessControlAction.

public void testAccessControlAction() throws Exception {
    AccessControlAction action = new AccessControlAction();
    action.setUserPrivilegeNames("jcr:all");
    action.setGroupPrivilegeNames("jcr:read");
    User u = null;
    Group gr = null;
    try {
        setActions(action);
        String uid = getTestPrincipal().getName();
        u = impl.createUser(uid, buildPassword(uid));
        save(superuser);
        assertAcAction(u, impl);
        String grId = getTestPrincipal().getName();
        gr = impl.createGroup(grId);
        save(superuser);
        assertAcAction(gr, impl);
    } catch (UnsupportedRepositoryOperationException e) {
        throw new NotExecutableException(e.getMessage());
    } finally {
        if (u != null) {
            u.remove();
        }
        if (gr != null) {
            gr.remove();
        }
        save(superuser);
    }
}
Also used : Group(org.apache.jackrabbit.api.security.user.Group) UnsupportedRepositoryOperationException(javax.jcr.UnsupportedRepositoryOperationException) User(org.apache.jackrabbit.api.security.user.User) AccessControlAction(org.apache.jackrabbit.core.security.user.action.AccessControlAction) NotExecutableException(org.apache.jackrabbit.test.NotExecutableException)

Example 37 with UnsupportedRepositoryOperationException

use of javax.jcr.UnsupportedRepositoryOperationException in project jackrabbit by apache.

the class ValueFactoryTest method setUp.

public void setUp() throws Exception {
    super.setUp();
    session = getHelper().getReadWriteSession();
    try {
        valueFactory = session.getValueFactory();
    } catch (UnsupportedRepositoryOperationException e) {
        String message = "ValueFactory Test not executable: " + e.getMessage();
        throw new NotExecutableException(message);
    }
    //notReferenceableNode = getProperty(not_ReferenceableNode);
    nameValue = testRootNode.getName();
    pathValue = testRootNode.getPath();
    dateValue = Calendar.getInstance();
    binaryValue = createRandomString(10).getBytes();
    referenceNode = createReferenceableNode(nodeName1);
}
Also used : UnsupportedRepositoryOperationException(javax.jcr.UnsupportedRepositoryOperationException) NotExecutableException(org.apache.jackrabbit.test.NotExecutableException)

Example 38 with UnsupportedRepositoryOperationException

use of javax.jcr.UnsupportedRepositoryOperationException in project jackrabbit by apache.

the class ShareableNodeTest method testRemoveMixin.

/**
     * Remove mix:shareable from a shareable node.
     */
public void testRemoveMixin() throws Exception {
    // setup parent node and first child
    Node a = testRootNode.addNode("a");
    Node b = a.addNode("b");
    testRootNode.getSession().save();
    // add mixin
    ensureMixinType(b, mixShareable);
    b.getSession().save();
    // (per Section 14.15 of JSR-283 specification)
    try {
        // remove mixin
        b.removeMixin(mixShareable);
        b.getSession().save();
        // If this happens, then b shouldn't be shareable anymore ...
        assertFalse(b.isNodeType(mixShareable));
    } catch (ConstraintViolationException e) {
    // one possible outcome if removing 'mix:shareable' isn't supported
    } catch (UnsupportedRepositoryOperationException e) {
    // also possible if the implementation doesn't support this
    // capability
    }
}
Also used : UnsupportedRepositoryOperationException(javax.jcr.UnsupportedRepositoryOperationException) Node(javax.jcr.Node) ConstraintViolationException(javax.jcr.nodetype.ConstraintViolationException)

Example 39 with UnsupportedRepositoryOperationException

use of javax.jcr.UnsupportedRepositoryOperationException in project jackrabbit by apache.

the class LuceneQueryFactory method create.

protected Query create(Constraint constraint, Map<String, NodeType> selectorMap, JackrabbitIndexSearcher searcher) throws RepositoryException, IOException {
    if (constraint instanceof And) {
        return getAndQuery((And) constraint, selectorMap, searcher);
    } else if (constraint instanceof Or) {
        return getOrQuery((Or) constraint, selectorMap, searcher);
    } else if (constraint instanceof Not) {
        return getNotQuery((Not) constraint, selectorMap, searcher);
    } else if (constraint instanceof PropertyExistence) {
        return getPropertyExistenceQuery((PropertyExistence) constraint);
    } else if (constraint instanceof Comparison) {
        Comparison c = (Comparison) constraint;
        Transform left = new Transform(c.getOperand1());
        return getComparisonQuery(left.operand, left.transform, c.getOperator(), c.getOperand2(), selectorMap);
    } else if (constraint instanceof FullTextSearch) {
        return getFullTextSearchQuery((FullTextSearch) constraint);
    } else if (constraint instanceof SameNode) {
        SameNode sn = (SameNode) constraint;
        return getNodeIdQuery(UUID, sn.getPath());
    } else if (constraint instanceof ChildNode) {
        ChildNode cn = (ChildNode) constraint;
        return getNodeIdQuery(PARENT, cn.getParentPath());
    } else if (constraint instanceof DescendantNode) {
        DescendantNode dn = (DescendantNode) constraint;
        return getDescendantNodeQuery(dn, searcher);
    } else {
        throw new UnsupportedRepositoryOperationException("Unknown constraint type: " + constraint);
    }
}
Also used : UnsupportedRepositoryOperationException(javax.jcr.UnsupportedRepositoryOperationException) Not(javax.jcr.query.qom.Not) Or(javax.jcr.query.qom.Or) Comparison(javax.jcr.query.qom.Comparison) And(javax.jcr.query.qom.And) DescendantNode(javax.jcr.query.qom.DescendantNode) FullTextSearch(javax.jcr.query.qom.FullTextSearch) SameNode(javax.jcr.query.qom.SameNode) PropertyExistence(javax.jcr.query.qom.PropertyExistence) ChildNode(javax.jcr.query.qom.ChildNode)

Example 40 with UnsupportedRepositoryOperationException

use of javax.jcr.UnsupportedRepositoryOperationException in project jackrabbit by apache.

the class VersionManagerImplConfig method restore.

/**
     * Restores the versions recorded in the given baseline below the specified
     * path.
     * @param parent the parent state
     * @param name the name of the new node (tree)
     * @param baseline the baseline that recorded the versions
     * @return the node id of the configuration
     * @throws RepositoryException if an error occurs
     */
protected NodeId restore(NodeStateEx parent, Name name, InternalBaseline baseline) throws RepositoryException {
    // check if nt:configuration exists
    NodeId configId = baseline.getConfigurationId();
    NodeId rootId = baseline.getConfigurationRootId();
    if (stateMgr.hasItemState(rootId)) {
        NodeStateEx existing = parent.getNode(rootId);
        String msg = "Configuration for the given baseline already exists at: " + safeGetJCRPath(existing);
        log.error(msg);
        throw new UnsupportedRepositoryOperationException(msg);
    }
    // find version for configuration root
    VersionSet versions = baseline.getBaseVersions();
    InternalVersion rootVersion = null;
    for (InternalVersion v : versions.versions().values()) {
        if (v.getVersionHistory().getVersionableId().equals(rootId)) {
            rootVersion = v;
            break;
        }
    }
    if (rootVersion == null) {
        String msg = "Internal error: supplied baseline has no version for its configuration root.";
        log.error(msg);
        throw new RepositoryException(msg);
    }
    // create new node below parent
    WriteOperation ops = startWriteOperation();
    try {
        if (!stateMgr.hasItemState(configId)) {
            // create if nt:configuration node is not exists
            internalCreateConfiguration(rootId, configId, baseline.getId());
        }
        NodeStateEx config = parent.getNode(configId);
        // create the root node so that the restore works
        InternalFrozenNode fn = rootVersion.getFrozenNode();
        NodeStateEx state = parent.addNode(name, fn.getFrozenPrimaryType(), fn.getFrozenId());
        state.setMixins(fn.getFrozenMixinTypes());
        parent.store();
        // and finally restore the config and root
        internalRestore(config, baseline, null, false);
        ops.save();
        return configId;
    } catch (ItemStateException e) {
        throw new RepositoryException(e);
    } finally {
        ops.close();
    }
}
Also used : UnsupportedRepositoryOperationException(javax.jcr.UnsupportedRepositoryOperationException) NodeId(org.apache.jackrabbit.core.id.NodeId) RepositoryException(javax.jcr.RepositoryException) ItemStateException(org.apache.jackrabbit.core.state.ItemStateException)

Aggregations

UnsupportedRepositoryOperationException (javax.jcr.UnsupportedRepositoryOperationException)57 RepositoryException (javax.jcr.RepositoryException)17 Node (javax.jcr.Node)14 NotExecutableException (org.apache.jackrabbit.test.NotExecutableException)12 NodeId (org.apache.jackrabbit.core.id.NodeId)8 ArrayList (java.util.ArrayList)7 Workspace (javax.jcr.Workspace)5 ConstraintViolationException (javax.jcr.nodetype.ConstraintViolationException)5 Session (javax.jcr.Session)4 VersionManager (javax.jcr.version.VersionManager)4 NodeState (org.apache.jackrabbit.core.state.NodeState)4 Name (org.apache.jackrabbit.spi.Name)4 Path (org.apache.jackrabbit.spi.Path)4 IOException (java.io.IOException)3 ItemExistsException (javax.jcr.ItemExistsException)3 ItemNotFoundException (javax.jcr.ItemNotFoundException)3 NodeType (javax.jcr.nodetype.NodeType)3 HashMap (java.util.HashMap)2 Map (java.util.Map)2 AccessDeniedException (javax.jcr.AccessDeniedException)2