@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);

         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;

      }
      catch (RepositoryException e)
      {
         //e.printStackTrace();
         throw new IOException("Open connection to URL '" + url.toString() + "' failed!", e);
      }
      catch (URISyntaxException e)
      {
         //e.printStackTrace();
         throw new IOException("Open connection to URL '" + url.toString() + "' failed!", e);
      }
      catch (RepositoryConfigurationException e)
      {
         //e.printStackTrace();
         throw new IOException("Open connection to URL '" + url.toString() + "' failed!", e);
      }
   }
@ Override protected URLConnection openConnection ( URL url ) throws IOException { try { UnifiedNodeReference nodeReference = new UnifiedNodeReference ( url ) ; 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 ; } catch ( RepositoryException e ) { throw new IOException ( "Open connection to URL '" + url . toString ( ) + "' failed!" , e ) ; } catch ( URISyntaxException e ) { throw new IOException ( "Open connection to URL '" + url . toString ( ) + "' failed!" , e ) ; } catch ( RepositoryConfigurationException e ) { throw new IOException ( "Open connection to URL '" + url . toString ( ) + "' failed!" , e ) ; } }
{@inheritDoc}