@Override
protected URLConnection openConnection(URL url) throws IOException
{
try
{
UnifiedNodeReference nodeReference = new UnifiedNodeReference(url);
// First try use user specified session provider, e.g.
// ThreadLocalSessionProvider or System SessionProvider
SessionProvider sessionProvider = threadLocalSessionProviderService.getSessionProvider(null);
if (sessionProvider == null && ConversationState.getCurrent() != null)
sessionProvider =
(SessionProvider)ConversationState.getCurrent().getAttribute(SessionProvider.SESSION_PROVIDER);
// if still not set use anonymous session provider
if (sessionProvider == null)
sessionProvider = SessionProvider.createAnonimProvider();
ManageableRepository repository;
String repositoryName = nodeReference.getRepository();
if (repositoryName == null || repositoryName.length() == 0)
repository = sessionProvider.getCurrentRepository();
else
repository = repositoryService.getRepository(repositoryName);
String workspaceName = nodeReference.getWorkspace();
if (workspaceName == null || workspaceName.length() == 0)
workspaceName = sessionProvider.getCurrentWorkspace();
Session ses = sessionProvider.getSession(workspaceName, repository);
JcrURLConnection conn = new JcrURLConnection(nodeReference, ses, nodeRepresentationService);