{
UnifiedNodeReference nodeReference = new UnifiedNodeReference(url);
// First try use user specified session provider, e.g.
// ThreadLocalSessionProvider or System SessionProvider
SessionProvider sessionProvider = threadLocalSessionProviderService.getSessionProvider(null);
boolean closeSessionProvider = false;
if (sessionProvider == null && ConversationState.getCurrent() != null)
{
sessionProvider =
(SessionProvider)ConversationState.getCurrent().getAttribute(SessionProvider.SESSION_PROVIDER);
}
if (sessionProvider == null)
{
sessionProvider = SessionProvider.createAnonimProvider();
closeSessionProvider = true;
}
String repositoryName = nodeReference.getRepository();
if (repositoryName != null && repositoryName.length() > 0)
{
ManageableRepository repository = repositoryService.getRepository(repositoryName);
sessionProvider.setCurrentRepository(repository);
}
String workspaceName = nodeReference.getWorkspace();
if (workspaceName != null && workspaceName.length() > 0)
{
sessionProvider.setCurrentWorkspace(workspaceName);
}
JcrURLConnection conn =
new JcrURLConnection(nodeReference, sessionProvider, nodeRepresentationService, closeSessionProvider);
return conn;