Search in sources :

Example 1 with NameException

use of org.apache.jackrabbit.spi.commons.conversion.NameException in project jackrabbit by apache.

the class SessionImpl method getImportContentHandler.

/**
     * {@inheritDoc}
     */
public ContentHandler getImportContentHandler(String parentAbsPath, int uuidBehavior) throws PathNotFoundException, ConstraintViolationException, VersionException, LockException, RepositoryException {
    // check sanity of this session
    sanityCheck();
    NodeImpl parent;
    try {
        Path p = getQPath(parentAbsPath).getNormalizedPath();
        if (!p.isAbsolute()) {
            throw new RepositoryException("not an absolute path: " + parentAbsPath);
        }
        parent = getItemManager().getNode(p);
    } catch (NameException e) {
        String msg = parentAbsPath + ": invalid path";
        log.debug(msg);
        throw new RepositoryException(msg, e);
    } catch (AccessDeniedException ade) {
        throw new PathNotFoundException(parentAbsPath);
    }
    // verify that parent node is checked-out, not locked and not protected
    // by either node type constraints nor by some retention or hold.
    int options = ItemValidator.CHECK_LOCK | ItemValidator.CHECK_CHECKED_OUT | ItemValidator.CHECK_CONSTRAINTS | ItemValidator.CHECK_HOLD | ItemValidator.CHECK_RETENTION;
    context.getItemValidator().checkModify(parent, options, Permission.NONE);
    SessionImporter importer = new SessionImporter(parent, this, uuidBehavior, context.getWorkspace().getConfig().getImportConfig());
    return new ImportHandler(importer, this);
}
Also used : Path(org.apache.jackrabbit.spi.Path) AccessDeniedException(javax.jcr.AccessDeniedException) NameException(org.apache.jackrabbit.spi.commons.conversion.NameException) IllegalNameException(org.apache.jackrabbit.spi.commons.conversion.IllegalNameException) ImportHandler(org.apache.jackrabbit.core.xml.ImportHandler) RepositoryException(javax.jcr.RepositoryException) PathNotFoundException(javax.jcr.PathNotFoundException) SessionImporter(org.apache.jackrabbit.core.xml.SessionImporter)

Example 2 with NameException

use of org.apache.jackrabbit.spi.commons.conversion.NameException in project jackrabbit by apache.

the class QueryImpl method storeAsNode.

/**
     * {@inheritDoc}
     */
public Node storeAsNode(String absPath) throws ItemExistsException, PathNotFoundException, VersionException, ConstraintViolationException, LockException, UnsupportedRepositoryOperationException, RepositoryException {
    checkInitialized();
    try {
        Path p = sessionContext.getQPath(absPath).getNormalizedPath();
        if (!p.isAbsolute()) {
            throw new RepositoryException(absPath + " is not an absolute path");
        }
        String relPath = sessionContext.getJCRPath(p).substring(1);
        Node queryNode = sessionContext.getSessionImpl().getRootNode().addNode(relPath, sessionContext.getJCRName(NT_QUERY));
        // set properties
        queryNode.setProperty(sessionContext.getJCRName(JCR_LANGUAGE), language);
        queryNode.setProperty(sessionContext.getJCRName(JCR_STATEMENT), statement);
        node = queryNode;
        return node;
    } catch (NameException e) {
        throw new RepositoryException(e.getMessage(), e);
    }
}
Also used : Path(org.apache.jackrabbit.spi.Path) NameException(org.apache.jackrabbit.spi.commons.conversion.NameException) Node(javax.jcr.Node) RepositoryException(javax.jcr.RepositoryException)

Example 3 with NameException

use of org.apache.jackrabbit.spi.commons.conversion.NameException in project jackrabbit by apache.

the class VersionHistoryImpl method removeVersion.

/**
     * @see javax.jcr.version.VersionHistory#removeVersion(String)
     */
public void removeVersion(String versionName) throws UnsupportedRepositoryOperationException, VersionException, RepositoryException {
    try {
        // check permissions
        checkVersionManagementPermission();
        sessionContext.getSessionImpl().getInternalVersionManager().removeVersion(getSession(), getInternalVersionHistory(), sessionContext.getQName(versionName));
    } catch (NameException e) {
        throw new RepositoryException(e);
    }
}
Also used : NameException(org.apache.jackrabbit.spi.commons.conversion.NameException) RepositoryException(javax.jcr.RepositoryException)

Example 4 with NameException

use of org.apache.jackrabbit.spi.commons.conversion.NameException in project jackrabbit by apache.

the class WorkspaceImpl method internalClone.

/**
     * Handles a clone inside the same workspace, which is supported with
     * shareable nodes.
     *
     * @see {@link #clone()}
     *
     * @param srcAbsPath source path
     * @param destAbsPath destination path
     * @return the path of the node at its new position
     * @throws ConstraintViolationException
     * @throws AccessDeniedException
     * @throws VersionException
     * @throws PathNotFoundException
     * @throws ItemExistsException
     * @throws LockException
     * @throws RepositoryException
     */
private String internalClone(String srcAbsPath, String destAbsPath) throws ConstraintViolationException, AccessDeniedException, VersionException, PathNotFoundException, ItemExistsException, LockException, RepositoryException {
    Path srcPath;
    try {
        srcPath = context.getQPath(srcAbsPath).getNormalizedPath();
    } catch (NameException e) {
        String msg = "invalid path: " + srcAbsPath;
        log.debug(msg);
        throw new RepositoryException(msg, e);
    }
    if (!srcPath.isAbsolute()) {
        throw new RepositoryException("not an absolute path: " + srcAbsPath);
    }
    Path destPath;
    try {
        destPath = context.getQPath(destAbsPath).getNormalizedPath();
    } catch (NameException e) {
        String msg = "invalid path: " + destAbsPath;
        log.debug(msg);
        throw new RepositoryException(msg, e);
    }
    if (!destPath.isAbsolute()) {
        throw new RepositoryException("not an absolute path: " + destAbsPath);
    }
    BatchedItemOperations ops = new BatchedItemOperations(stateMgr, context);
    try {
        ops.edit();
    } catch (IllegalStateException e) {
        String msg = "unable to start edit operation";
        log.debug(msg);
        throw new RepositoryException(msg, e);
    }
    boolean succeeded = false;
    try {
        ItemId id = ops.clone(srcPath, destPath);
        ops.update();
        succeeded = true;
        return context.getJCRPath(hierMgr.getPath(id));
    } finally {
        if (!succeeded) {
            // update operation failed, cancel all modifications
            ops.cancel();
        }
    }
}
Also used : Path(org.apache.jackrabbit.spi.Path) NameException(org.apache.jackrabbit.spi.commons.conversion.NameException) RepositoryException(javax.jcr.RepositoryException) ItemId(org.apache.jackrabbit.core.id.ItemId)

Example 5 with NameException

use of org.apache.jackrabbit.spi.commons.conversion.NameException in project jackrabbit by apache.

the class WorkspaceImpl method move.

/**
     * {@inheritDoc}
     */
public void move(String srcAbsPath, String destAbsPath) throws ConstraintViolationException, VersionException, AccessDeniedException, PathNotFoundException, ItemExistsException, LockException, RepositoryException {
    // check state of this instance
    sanityCheck();
    // intra-workspace move...
    Path srcPath;
    try {
        srcPath = context.getQPath(srcAbsPath).getNormalizedPath();
    } catch (NameException e) {
        String msg = "invalid path: " + srcAbsPath;
        log.debug(msg);
        throw new RepositoryException(msg, e);
    }
    if (!srcPath.isAbsolute()) {
        throw new RepositoryException("not an absolute path: " + srcAbsPath);
    }
    Path destPath;
    try {
        destPath = context.getQPath(destAbsPath).getNormalizedPath();
    } catch (NameException e) {
        String msg = "invalid path: " + destAbsPath;
        log.debug(msg);
        throw new RepositoryException(msg, e);
    }
    if (!destPath.isAbsolute()) {
        throw new RepositoryException("not an absolute path: " + destAbsPath);
    }
    BatchedItemOperations ops = new BatchedItemOperations(stateMgr, context);
    try {
        ops.edit();
    } catch (IllegalStateException e) {
        String msg = "unable to start edit operation";
        log.debug(msg);
        throw new RepositoryException(msg, e);
    }
    boolean succeeded = false;
    try {
        ops.move(srcPath, destPath);
        ops.update();
        succeeded = true;
    } finally {
        if (!succeeded) {
            // update operation failed, cancel all modifications
            ops.cancel();
        }
    }
}
Also used : Path(org.apache.jackrabbit.spi.Path) NameException(org.apache.jackrabbit.spi.commons.conversion.NameException) RepositoryException(javax.jcr.RepositoryException)

Aggregations

NameException (org.apache.jackrabbit.spi.commons.conversion.NameException)65 RepositoryException (javax.jcr.RepositoryException)44 Name (org.apache.jackrabbit.spi.Name)38 Path (org.apache.jackrabbit.spi.Path)20 NamespaceException (javax.jcr.NamespaceException)17 ArrayList (java.util.ArrayList)16 IllegalNameException (org.apache.jackrabbit.spi.commons.conversion.IllegalNameException)9 SAXException (org.xml.sax.SAXException)8 Node (javax.jcr.Node)6 ConstraintViolationException (javax.jcr.nodetype.ConstraintViolationException)6 InvalidQueryException (javax.jcr.query.InvalidQueryException)6 NodeId (org.apache.jackrabbit.core.id.NodeId)6 IOException (java.io.IOException)5 ItemNotFoundException (javax.jcr.ItemNotFoundException)5 PathNotFoundException (javax.jcr.PathNotFoundException)5 Value (javax.jcr.Value)5 LocationStepQueryNode (org.apache.jackrabbit.spi.commons.query.LocationStepQueryNode)5 AccessDeniedException (javax.jcr.AccessDeniedException)4 NodeType (javax.jcr.nodetype.NodeType)4 VersionException (javax.jcr.version.VersionException)4