Examples of SessionDelegate


Examples of org.apache.jackrabbit.oak.jcr.SessionDelegate

    }

    @Override
    public Node storeAsNode(String absPath) throws RepositoryException {
        manager.ensureIsAlive();
        SessionDelegate sessionDelegate = manager.getSessionDelegate();
        String oakPath = sessionDelegate.getOakPathOrThrow(absPath);
        // TODO query nodes should be of type nt:query
        String parent = PathUtils.getParentPath(oakPath);
        String nodeName = PathUtils.getName(oakPath);
        NodeDelegate parentNode = sessionDelegate.getNode(parent);
        ValueFactoryImpl vf = sessionDelegate.getValueFactory();
        if (parentNode == null) {
            throw new PathNotFoundException("The specified path does not exist: " + parent);
        }
        NodeDelegate node = parentNode.addChild(nodeName);
        if (node == null) {
View Full Code Here

Examples of org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate

                throw new RepositoryException("Duplicate attribute '" + REFRESH_INTERVAL + "'.");
            }

            RefreshStrategy refreshStrategy = createRefreshStrategy(refreshInterval);
            ContentSession contentSession = contentRepository.login(credentials, workspaceName);
            SessionDelegate sessionDelegate = createSessionDelegate(refreshStrategy, contentSession);
            SessionContext context = createSessionContext(
                    securityProvider, createAttributes(refreshInterval), sessionDelegate);
            return context.getSession();
        } catch (LoginException e) {
            throw new javax.jcr.LoginException(e.getMessage(), e);
View Full Code Here

Examples of org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate

    }

    private SessionDelegate createSessionDelegate(
            final RefreshStrategy refreshStrategy,
            final ContentSession contentSession) {
        return new SessionDelegate(contentSession, refreshStrategy) {
            // Defer session MBean registration to avoid cluttering the
            // JMX name space with short lived sessions
            ListenableScheduledFuture<Registration> registration = scheduledExecutor.schedule(
                    new RegistrationCallable(getSessionStats(), whiteboard), 1, TimeUnit.MINUTES);
View Full Code Here

Examples of org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate

                throw new RepositoryException("Duplicate attribute '" + REFRESH_INTERVAL + "'.");
            }

            RefreshStrategy refreshStrategy = createRefreshStrategy(refreshInterval);
            ContentSession contentSession = contentRepository.login(credentials, workspaceName);
            SessionDelegate sessionDelegate = new SessionDelegate(contentSession, refreshStrategy);
            SessionContext context = createSessionContext(
                    securityProvider, createAttributes(refreshInterval), sessionDelegate);
            return context.getSession();
        } catch (LoginException e) {
            throw new javax.jcr.LoginException(e.getMessage(), e);
View Full Code Here

Examples of org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate

    @Override
    public void restore(final String absPath,
                        final Version version,
                        final boolean removeExisting)
            throws RepositoryException {
        final SessionDelegate sessionDelegate = sessionContext.getSessionDelegate();
        sessionDelegate.perform(new SessionOperation<Void>(true) {
            @Override
            public Void perform() throws RepositoryException {
                String oakPath = getOakPathOrThrowNotFound(absPath);
                NodeDelegate nodeDelegate = sessionDelegate.getNode(oakPath);
                if (nodeDelegate != null) {
                    throw new VersionException(
                            "VersionManager.restore(String, Version, boolean)"
                                    + " not allowed on existing nodes; use"
                                    + " VersionManager.restore(Version, boolean) instead: "
                                    + absPath);
                }
                // check if parent exists
                NodeDelegate parent = ensureParentExists(sessionDelegate, absPath);
                // check for pending changes
                checkPendingChangesForRestore(sessionDelegate);
                // check lock status
                checkNotLocked(parent.getPath());
                // check for existing nodes
                List<NodeDelegate> existing = getExisting(version,
                        Collections.<String>emptySet());
                boolean success = false;
                try {
                    if (!existing.isEmpty()) {
                        if (removeExisting) {
                            removeExistingNodes(existing);
                        } else {
                            List<String> paths = new ArrayList<String>();
                            for (NodeDelegate nd : existing) {
                                paths.add(nd.getPath());
                            }
                            throw new ItemExistsException("Unable to restore with " +
                                    "removeExisting=false. Existing nodes in " +
                                    "workspace: " + paths);
                        }
                    }
                    // ready for restore
                    VersionDelegate vd = versionManagerDelegate.getVersionByIdentifier(
                            version.getIdentifier());
                    versionManagerDelegate.restore(
                            parent, PathUtils.getName(oakPath), vd);
                    sessionDelegate.getRoot().commit();
                    success = true;
                } catch (CommitFailedException e) {
                    throw e.asRepositoryException();
                } finally {
                    if (!success) {
                        // refresh if one of the modifying operations fail
                        sessionDelegate.refresh(false);
                    }
                }
                return null;
            }
        });
View Full Code Here

Examples of org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate

        VersionHistory history = (VersionHistory) version.getParent();
        final String versionableId = history.getVersionableIdentifier();
        if (history.getRootVersion().isSame(version)) {
            throw new VersionException("Restore of root version not possible");
        }
        final SessionDelegate sessionDelegate = sessionContext.getSessionDelegate();
        sessionDelegate.perform(new SessionOperation<Void>(true) {
            @Override
            public Void perform() throws RepositoryException {
                // check for pending changes
                checkPendingChangesForRestore(sessionDelegate);
                NodeDelegate n = sessionDelegate.getNodeByIdentifier(versionableId);
                if (n == null) {
                    throw new VersionException("Unable to restore version. " +
                            "No versionable node with identifier: " + versionableId);
                }
                // check lock status
                checkNotLocked(n.getPath());
                // check for existing nodes
                List<NodeDelegate> existing = getExisting(version,
                        Collections.singleton(n.getPath()));
                boolean success = false;
                try {
                    if (!existing.isEmpty()) {
                        if (removeExisting) {
                            removeExistingNodes(existing);
                        } else {
                            List<String> paths = new ArrayList<String>();
                            for (NodeDelegate nd : existing) {
                                paths.add(nd.getPath());
                            }
                            throw new ItemExistsException("Unable to restore with " +
                                    "removeExisting=false. Existing nodes in " +
                                    "workspace: " + paths);
                        }
                    }
                    // ready for restore
                    VersionDelegate vd = versionManagerDelegate.getVersionByIdentifier(
                            version.getIdentifier());
                    versionManagerDelegate.restore(
                            n.getParent(), n.getName(), vd);
                    sessionDelegate.getRoot().commit();
                    success = true;
                } catch (CommitFailedException e) {
                    throw new RepositoryException(e);
                } finally {
                    if (!success) {
                        // refresh if one of the modifying operations fail
                        sessionDelegate.refresh(false);
                    }
                }
                return null;
            }
        });
View Full Code Here

Examples of org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate

        return sessionContext.getOakPathOrThrowNotFound(absPath);
    }

    @Override
    public boolean isCheckedOut(final String absPath) throws RepositoryException {
        final SessionDelegate sessionDelegate = sessionContext.getSessionDelegate();
        return sessionDelegate.perform(new SessionOperation<Boolean>() {
            @Override
            public Boolean perform() throws RepositoryException {
                String oakPath = getOakPathOrThrowNotFound(absPath);
                NodeDelegate nodeDelegate = sessionDelegate.getNode(oakPath);
                if (nodeDelegate == null) {
                    throw new PathNotFoundException(absPath);
                }
                return versionManagerDelegate.isCheckedOut(nodeDelegate);
            }
View Full Code Here

Examples of org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate

    }

    @Override
    public VersionHistory getVersionHistory(final String absPath)
            throws RepositoryException {
        final SessionDelegate sessionDelegate = sessionContext.getSessionDelegate();
        return sessionDelegate.perform(new SessionOperation<VersionHistory>() {
            @Override
            public VersionHistory perform() throws RepositoryException {
                return new VersionHistoryImpl(
                        internalGetVersionHistory(absPath), sessionContext);
            }
View Full Code Here

Examples of org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate

        });
    }

    @Override
    public Version getBaseVersion(final String absPath) throws RepositoryException {
        final SessionDelegate sessionDelegate = sessionContext.getSessionDelegate();
        return sessionDelegate.perform(new SessionOperation<Version>() {
            @Override
            public Version perform() throws RepositoryException {
                String oakPath = getOakPathOrThrowNotFound(absPath);
                NodeDelegate nodeDelegate = sessionDelegate.getNode(oakPath);
                if (nodeDelegate == null) {
                    throw new PathNotFoundException(absPath);
                }
                return new VersionImpl(
                        versionManagerDelegate.getBaseVersion(nodeDelegate), sessionContext);
View Full Code Here

Examples of org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate

        return v;
    }

    @Override
    public void checkout(final String absPath) throws RepositoryException {
        final SessionDelegate sessionDelegate = sessionContext.getSessionDelegate();
        sessionDelegate.perform(new SessionOperation<Void>(true) {
            @Override
            public Void perform() throws RepositoryException {
                String oakPath = getOakPathOrThrowNotFound(absPath);
                NodeDelegate nodeDelegate = sessionDelegate.getNode(oakPath);
                if (nodeDelegate == null) {
                    throw new PathNotFoundException(absPath);
                }
                checkNotLocked(absPath);
                versionManagerDelegate.checkout(nodeDelegate);
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.