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();
}
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);
}
}
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;
}
Aggregations