Search in sources :

Example 6 with SessionDelegate

use of org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate in project jackrabbit-oak by apache.

the class SessionStatsTest method getInitStackTrace.

private String getInitStackTrace(Session session) throws IllegalAccessException {
    SessionDelegate sessionDelegate = (SessionDelegate) FieldUtils.readDeclaredField(session, "sd", true);
    SessionStats sessionStats = sessionDelegate.getSessionStats();
    return sessionStats.getInitStackTrace();
}
Also used : SessionDelegate(org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate)

Example 7 with SessionDelegate

use of org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate in project jackrabbit-oak by apache.

the class RepositoryImpl method login.

// ------------------------------------------------------------< JackrabbitRepository >---
@Override
public Session login(@CheckForNull Credentials credentials, @CheckForNull String workspaceName, @CheckForNull Map<String, Object> attributes) throws RepositoryException {
    try {
        if (attributes == null) {
            attributes = emptyMap();
        }
        Long refreshInterval = getRefreshInterval(credentials);
        if (refreshInterval == null) {
            refreshInterval = getRefreshInterval(attributes);
        } else if (attributes.containsKey(REFRESH_INTERVAL)) {
            throw new RepositoryException("Duplicate attribute '" + REFRESH_INTERVAL + "'.");
        }
        boolean relaxedLocking = getRelaxedLocking(attributes);
        RefreshPredicate predicate = new RefreshPredicate();
        RefreshStrategy refreshStrategy = refreshInterval == null ? new RefreshStrategy.ConditionalRefreshStrategy(new RefreshStrategy.LogOnce(60), predicate) : new RefreshStrategy.Timed(refreshInterval);
        ContentSession contentSession = contentRepository.login(credentials, workspaceName);
        SessionDelegate sessionDelegate = createSessionDelegate(refreshStrategy, contentSession);
        SessionContext context = createSessionContext(statisticManager, securityProvider, createAttributes(refreshInterval, relaxedLocking), sessionDelegate, observationQueueLength, commitRateLimiter);
        predicate.setSessionContext(context);
        return context.getSession();
    } catch (LoginException e) {
        throw new javax.jcr.LoginException(e.getMessage(), e);
    }
}
Also used : RefreshStrategy(org.apache.jackrabbit.oak.jcr.session.RefreshStrategy) RepositoryException(javax.jcr.RepositoryException) SessionDelegate(org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate) AtomicLong(java.util.concurrent.atomic.AtomicLong) ContentSession(org.apache.jackrabbit.oak.api.ContentSession) SessionContext(org.apache.jackrabbit.oak.jcr.session.SessionContext) LoginException(javax.security.auth.login.LoginException)

Example 8 with SessionDelegate

use of org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate in project jackrabbit-oak by apache.

the class VersionManagerImpl method getExisting.

/**
 * Returns referenceable nodes outside of the versionable sub-graphs
 * identified by <code>versionablePaths</code>, which are also present
 * in the versionable state captured by <code>version</code>.
 *
 * @param version the version.
 * @param versionablePaths identifies the starting points of the versionable
 *                         sub-graphs.
 * @return existing nodes in this workspace.
 */
private List<NodeDelegate> getExisting(@Nonnull Version version, @Nonnull Set<String> versionablePaths) throws RepositoryException {
    // collect uuids
    final List<String> uuids = new ArrayList<String>();
    version.getFrozenNode().accept(new TraversingItemVisitor.Default() {

        @Override
        protected void entering(Node node, int level) throws RepositoryException {
            if (node.isNodeType(NodeType.NT_FROZEN_NODE)) {
                String id = node.getProperty(Property.JCR_FROZEN_UUID).getString();
                if (id.length() > 0) {
                    uuids.add(id);
                }
            } else if (node.isNodeType(NodeType.NT_VERSIONED_CHILD)) {
                Node history = node.getProperty(Property.JCR_CHILD_VERSION_HISTORY).getNode();
                uuids.add(history.getProperty(Property.JCR_VERSIONABLE_UUID).getString());
            // TODO: further traverse versioned children with some selector (date?)
            }
        }
    });
    SessionDelegate delegate = sessionContext.getSessionDelegate();
    if (uuids.isEmpty()) {
        return Collections.emptyList();
    }
    List<NodeDelegate> existing = new ArrayList<NodeDelegate>();
    for (String uuid : uuids) {
        NodeDelegate node = delegate.getNodeByIdentifier(uuid);
        if (node != null) {
            boolean inSubGraph = false;
            for (String versionablePath : versionablePaths) {
                if (node.getPath().startsWith(versionablePath)) {
                    inSubGraph = true;
                    break;
                }
            }
            if (!inSubGraph) {
                existing.add(node);
            }
        }
    }
    return existing;
}
Also used : Node(javax.jcr.Node) ArrayList(java.util.ArrayList) RepositoryException(javax.jcr.RepositoryException) TraversingItemVisitor(javax.jcr.util.TraversingItemVisitor) NodeDelegate(org.apache.jackrabbit.oak.jcr.delegate.NodeDelegate) SessionDelegate(org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate)

Aggregations

SessionDelegate (org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate)8 RepositoryException (javax.jcr.RepositoryException)6 NodeDelegate (org.apache.jackrabbit.oak.jcr.delegate.NodeDelegate)5 ArrayList (java.util.ArrayList)3 List (java.util.List)2 ItemExistsException (javax.jcr.ItemExistsException)2 PathNotFoundException (javax.jcr.PathNotFoundException)2 VersionException (javax.jcr.version.VersionException)2 CommitFailedException (org.apache.jackrabbit.oak.api.CommitFailedException)2 VersionDelegate (org.apache.jackrabbit.oak.jcr.delegate.VersionDelegate)2 AtomicLong (java.util.concurrent.atomic.AtomicLong)1 Nonnull (javax.annotation.Nonnull)1 Node (javax.jcr.Node)1 UnsupportedRepositoryOperationException (javax.jcr.UnsupportedRepositoryOperationException)1 TraversingItemVisitor (javax.jcr.util.TraversingItemVisitor)1 Version (javax.jcr.version.Version)1 VersionHistory (javax.jcr.version.VersionHistory)1 LoginException (javax.security.auth.login.LoginException)1 ContentSession (org.apache.jackrabbit.oak.api.ContentSession)1 RefreshStrategy (org.apache.jackrabbit.oak.jcr.session.RefreshStrategy)1