Search in sources :

Example 1 with SessionContext

use of org.apache.jackrabbit.oak.jcr.session.SessionContext 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)

Aggregations

AtomicLong (java.util.concurrent.atomic.AtomicLong)1 RepositoryException (javax.jcr.RepositoryException)1 LoginException (javax.security.auth.login.LoginException)1 ContentSession (org.apache.jackrabbit.oak.api.ContentSession)1 SessionDelegate (org.apache.jackrabbit.oak.jcr.delegate.SessionDelegate)1 RefreshStrategy (org.apache.jackrabbit.oak.jcr.session.RefreshStrategy)1 SessionContext (org.apache.jackrabbit.oak.jcr.session.SessionContext)1