Commits

Anonymous committed 12b1331

Checkpoint

  • Participants
  • Parent commits aa5bd47

Comments (0)

Files changed (3)

Source/org/xnat/xnatfs/webdav/xnatfs.java

-/**
- * 
- */
-package org.xnat.xnatfs.webdav;
-
-import java.io.File;
-import java.net.URL;
-import java.util.concurrent.ExecutorService;
-import java.util.concurrent.Executors;
-
-import net.sf.ehcache.Cache;
-import net.sf.ehcache.CacheManager;
-import net.sf.ehcache.Element;
-
-import org.apache.log4j.BasicConfigurator;
-import org.apache.log4j.Level;
-import org.apache.log4j.Logger;
-import org.apache.log4j.PropertyConfigurator;
-
-import com.bradmcevoy.http.Auth;
-import com.bradmcevoy.http.HttpManager;
-import com.bradmcevoy.http.Request;
-import com.bradmcevoy.http.Resource;
-import com.bradmcevoy.http.ResourceFactory;
-import com.bradmcevoy.http.SecurityManager;
-import com.bradmcevoy.http.Request.Method;
-
-/**
- * Main xnatfs-webdav class
- * 
- * @author blezek
- * 
- */
-public class XNATFS implements ResourceFactory, SecurityManager {
-  private static final Logger logger = Logger.getLogger ( XNATFS.class );
-
-  /** Cache services from ehcache */
-  public static Cache sContentCache;
-  public static Cache sResourceCache;
-  public static CacheManager mMemoryCacheManager;
-
-  /** Thread pool for background downloads of files */
-  public static ExecutorService sExecutor = Executors.newCachedThreadPool ();
-  public static File sTemporaryDirectory;
-
-  SecurityManager securityManager;
-  LockManager mLockManager;
-  boolean mUseVerboseFolders = true;
-  HttpManager httpManager = null;
-
-  public XNATFS () {
-    // Configure log4j
-    // First try to configure from local directory, then from application
-    // support directory
-    File props;
-    props = new File ( System.getProperty ( "user.dir", "." ), "log4j.properties" );
-    props = new File ( "/Users/blezek/Source/xnatfs-webapp/log4j.properties" );
-    if ( props.exists () && props.canRead () ) {
-      System.out.println ( "Found props file: " + props.getAbsoluteFile () );
-      PropertyConfigurator.configure ( props.getAbsolutePath () );
-    } else {
-      props = new File ( getApplicationResourceDirectory ( "xnatfs" ), "log4j.properties" );
-      if ( props.exists () && props.canRead () ) {
-        System.out.println ( "Found props file: " + props.getAbsoluteFile () );
-        PropertyConfigurator.configure ( props.getAbsolutePath () );
-      } else {
-        URL url = xnatfsServlet.class.getResource ( "/log4j.properties" );
-        if ( url != null ) {
-          System.out.println ( "Found props url: " + url );
-          PropertyConfigurator.configure ( url );
-        } else {
-          System.out.println ( "No props file found falling back to defaults" );
-          BasicConfigurator.configure ();
-        }
-      }
-    }
-    Logger.getRootLogger ().setLevel ( Level.WARN );
-    Logger.getLogger ( "org.apache.commons" ).setLevel ( Level.WARN );
-    Logger.getLogger ( "httpclient.wire" ).setLevel ( Level.WARN );
-    Logger.getLogger ( "org.xnat.xnatfs.webdav." ).setLevel ( Level.DEBUG );
-    Logger.getLogger ( "com.bradmcevoy.http" ).setLevel ( Level.DEBUG );
-    configureCache ();
-    configureConnection ();
-    sTemporaryDirectory = new File ( System.getProperty ( "java.io.tmpdir" ) );
-    if ( mMemoryCacheManager.getDiskStorePath () != null ) {
-      sTemporaryDirectory = new File ( mMemoryCacheManager.getDiskStorePath () );
-    }
-    sTemporaryDirectory = new File ( sTemporaryDirectory, "FileCache" );
-    sTemporaryDirectory.mkdirs ();
-
-    securityManager = this;
-    mLockManager = new LockManager ();
-  }
-
-  public void setHttpManager ( HttpManager h ) {
-    httpManager = h;
-  }
-
-  /*
-   * Configure the cache by looking up the ehcache.xml file in the system
-   * classpath. Expects to have a "Node", "Content" and "FileHandle" cache. If
-   * any cache does not exist, it is created on the fly.
-   * 
-   * First checks the local directory, then the application directory, and
-   * finally falls back on the embedded file.
-   * 
-   * Register a caches listener for the content cache to close and delete files.
-   */
-  static public void configureCache () {
-    URL url = ClassLoader.getSystemResource ( "ehcache.xml" );
-    logger.info ( "Found configuration URL: " + url );
-    File SystemConfig = new File ( getApplicationResourceDirectory ( "xnatfs" ), "ehcache.xml" );
-    File LocalConfig = new File ( System.getProperty ( "user.dir", "." ), "ehcache.xml" );
-    if ( LocalConfig.exists () && LocalConfig.canRead () ) {
-      mMemoryCacheManager = CacheManager.create ( LocalConfig.getAbsolutePath () );
-    } else if ( SystemConfig.exists () && SystemConfig.canRead () ) {
-      mMemoryCacheManager = CacheManager.create ( SystemConfig.getAbsolutePath () );
-    } else if ( url != null ) {
-      mMemoryCacheManager = CacheManager.create ( url );
-    } else {
-      mMemoryCacheManager = CacheManager.create ();
-    }
-
-    if ( mMemoryCacheManager.getCache ( "Resource" ) == null ) {
-      mMemoryCacheManager.addCache ( "Resource" );
-    }
-    if ( mMemoryCacheManager.getCache ( "Content" ) == null ) {
-      mMemoryCacheManager.addCache ( "Content" );
-    }
-    sContentCache = mMemoryCacheManager.getCache ( "Content" );
-    sResourceCache = mMemoryCacheManager.getCache ( "Resource" );
-    // sContentCache.getCacheEventNotificationService ().registerListener ( new
-    // CacheFileCleanup () );
-
-  }
-
-  /*
-   * Configure the connection. Hard coded username and password for now. NB:
-   * username and password need to be set before the first
-   */
-  static public void configureConnection () {
-    Connection.getInstance ().setUsername ( "blezek" );
-    Connection.getInstance ().setPassword ( "throwaway" );
-  }
-
-  /**
-   * Do we use verbose folders or not. If true, setup folders like Projects,
-   * etc.
-   */
-  boolean useVerboseFolders () {
-    return mUseVerboseFolders;
-  }
-
-  static public VirtualResource findInCache ( String absolutePath, Auth auth ) {
-    if ( auth == null ) {
-      logger.debug ( "Not authorized, returning resource" );
-      return null;
-    }
-    String key = auth.user + "::" + auth.password + "::Resource::" + absolutePath;
-    Element e = XNATFS.sResourceCache.get ( key );
-    if ( e != null ) {
-      logger.debug ( "Returning cached resource: " + absolutePath );
-      return (VirtualResource) e.getObjectValue ();
-    }
-    return null;
-  }
-
-  static public VirtualResource findInCache ( VirtualResource resource, Auth auth ) {
-    if ( auth == null ) {
-      logger.debug ( "Not authorized, returning resource" );
-      return resource;
-    }
-    String key = auth.user + "::" + auth.password + "::Resource::" + resource.getAbsolutePath ();
-    Element e = XNATFS.sResourceCache.get ( key );
-    if ( e != null ) {
-      logger.debug ( "Returning cached resource: " + resource.getAbsolutePath () );
-      return (VirtualResource) e.getObjectValue ();
-    }
-    // Insert the new resource
-    XNATFS.sResourceCache.put ( new Element ( key, resource ) );
-    return resource;
-  }
-
-  /**
-   * Returns the Node indicated by the path argument. If the note is not in the
-   * xnatfs.sNodeCache, call createChild to try to create the parent and this
-   * child within it.
-   * 
-   * @see com.bradmcevoy.http.ResourceFactory#getResource(java.lang.String,
-   *      java.lang.String)
-   */
-  public Resource getResource ( String host, String path ) {
-    if ( path.startsWith ( "/xnatfs" ) ) {
-      path = path.replaceFirst ( "/xnatfs", "" );
-    }
-    // logger.debug ( "Couldn't find node '" + path +
-    // "', trying to create the file in the parent" );
-    Auth auth = HttpManager.request ().getAuthorization ();
-    if ( auth == null ) {
-      logger.error ( "user is not authorized for this " + path );
-      auth = httpManager.getSessionAuthentication ( HttpManager.request () );
-      if ( auth == null ) {
-        logger.error ( "Still not authorized!" );
-      }
-    }
-
-    // If we are authorized, let's look for a cached resource, before trying to
-    // create one.
-    if ( auth != null ) {
-      String key = auth.user + "::" + auth.password + "::Resource::" + path;
-      Element e = XNATFS.sResourceCache.get ( key );
-      if ( e != null ) {
-        logger.debug ( "Returning cached resource: " + path );
-        return (Resource) e.getObjectValue ();
-      }
-    }
-    String areAuthorized = " authorized ";
-    if ( auth == null ) {
-      areAuthorized = " not authorized ";
-    }
-    logger.debug ( "getResource: " + host + " path: " + path + " and we are" + areAuthorized );
-
-    VirtualResource child;
-    child = findInCache ( path, auth );
-    if ( child == null ) {
-      child = createChild ( path, auth );
-    }
-    if ( auth != null && child != null ) {
-      findInCache ( child, auth );
-    }
-    return child;
-  }
-
-  /**
-   * Lookup the path, if it exists, try to create the child. If the Node
-   * indicated by the path is not in the cache, try to create it by looking up
-   * the parent by calling this function recursively.
-   * 
-   * @param path
-   *          Path to the node in which to create child
-   * @param child
-   *          Name of the Node to create
-   * @return The new Node. Should never return null.
-   */
-  synchronized VirtualResource createChild ( String path, Auth auth ) {
-    // logger.debug ( "createChild: " + path );
-    if ( path == null || path.equals ( "" ) ) {
-      logger.error ( "createChild: Null path" );
-      return null;
-    }
-    // End the recursion
-    if ( path.equals ( "/" ) ) {
-      // logger.error ( "createChild: Should have found root, creating new" );
-      // logger.warn ( "Reminder: returning UploadDirectory" );
-      // UploadDirectory d = new UploadDirectory ( this, null, "/", "/" );
-      // return d;
-
-      Root root = new Root ( this, null, "/", "/" );
-      root.setCredentials ( auth );
-      return root;
-    }
-    VirtualDirectory parent = null;
-    Resource r = null;
-    r = createChild ( VirtualResource.dirname ( path ), auth );
-
-    if ( r != null && r instanceof VirtualResource ) {
-      parent = (VirtualDirectory) r;
-      parent.setCredentials ( auth );
-    }
-    if ( parent == null ) {
-      logger.error ( "Couldn't find parent of " + path );
-      return null;
-    }
-    try {
-      // logger.debug ( "createChild: having parent " + VirtualResource.dirname
-      // ( path ) + " create child " + VirtualResource.tail ( path ) );
-      return (VirtualResource) parent.child ( VirtualResource.tail ( path ) );
-    } catch ( Exception e ) {
-      logger.error ( "Falied to create child: " + VirtualResource.tail ( path ), e );
-    }
-    return null;
-  }
-
-  /*
-   * (non-Javadoc)
-   * 
-   * @see com.bradmcevoy.http.ResourceFactory#getSupportedLevels()
-   */
-  // Note that supported levels of 1,2 is required for mac os write operations,
-  // but might interfere with MS office editing operations
-  public String getSupportedLevels () {
-    return "1,2";
-  }
-
-  /**
-   * @return
-   */
-  public SecurityManager getSecurityManager () {
-    return securityManager;
-  }
-
-  /**
-   * Returns the appropriate working directory for storing application data. The
-   * result of this method is platform dependant: On linux, it will return
-   * ~/applicationName, on windows, the working directory will be located in the
-   * user's application data folder. For Mac OS systems, the working directory
-   * will be placed in the proper location in "Library/Application Support".
-   * <p/>
-   * This method will also make sure that the working directory exists. When
-   * invoked, the directory and all required subfolders will be created.
-   * 
-   * @param applicationName
-   *          Name of the application, used to determine the working directory.
-   * @return the appropriate working directory for storing application data.
-   */
-  public static File getApplicationResourceDirectory ( final String applicationName ) {
-    final String userHome = System.getProperty ( "user.home", "." );
-    final File workingDirectory;
-    switch ( getOS () ) {
-    case UNIX:
-      workingDirectory = new File ( userHome, '.' + applicationName + '/' );
-      break;
-    case WINDOWS:
-      final String applicationData = System.getenv ( "APPDATA" );
-      if ( applicationData != null )
-        workingDirectory = new File ( applicationData, "." + applicationName + '/' );
-      else
-        workingDirectory = new File ( userHome, '.' + applicationName + '/' );
-      break;
-    case MACINTOSH:
-      workingDirectory = new File ( userHome, "Library/Application Support/" + applicationName );
-      break;
-    default:
-      return new File ( "." );
-    }
-    if ( !workingDirectory.exists () && !workingDirectory.mkdirs () ) {
-      throw new RuntimeException ( "The working directory could not be created: " + workingDirectory );
-
-    }
-    return workingDirectory;
-  }
-
-  public enum OSType {
-    WINDOWS, MACINTOSH, UNIX
-  }
-
-  static OSType getOS () {
-    String sysName = System.getProperty ( "os.name" ).toLowerCase ();
-    if ( sysName.contains ( "windows" ) ) {
-      return OSType.WINDOWS;
-    } else if ( sysName.contains ( "mac" ) ) {
-      return OSType.MACINTOSH;
-    } else {
-      return OSType.UNIX;
-    }
-  }
-
-  public Object authenticate ( String user, String password ) {
-    logger.debug ( "authenticate: " + user + "/****** (password removed)" );
-    return user;
-  }
-
-  public boolean authorise ( Request request, Method method, Auth auth, Resource resource ) {
-    logger.debug ( "authorise: " + request + "/" + method + "/" + auth + "/" + resource );
-    if ( auth == null ) {
-      return false;
-    }
-    logger.debug ( "authorise: " + auth.user + "/" + auth.password );
-    if ( resource instanceof VirtualResource ) {
-      VirtualResource r = (VirtualResource) resource;
-      r.authenticate ( auth.user, auth.password );
-    }
-    return true;
-  }
-
-  public String getRealm () {
-    logger.debug ( "getRealm" );
-    return new String ( "xnatfs" );
-  }
-
-  public LockManager getLockManager () {
-    return mLockManager;
-  }
-}

Test/org/xnat/xnatfs/test/FilenameManipulationTest.java

-/**
- * 
- */
-package org.xnat.xnatfs.test;
-import junit.framework.TestCase;
-import org.xnat.xnatfs.Node;
-
-
-/**
- * @author blezek
- *
- */
-public class FilenameManipulationTest extends TestCase {
-	public void testExtention () {
-		assertEquals ( ".txt", Node.extention( "/foo/bar/test.txt"));
-		assertEquals ( "", Node.extention("/foo/bar"));
-		assertEquals ( "", Node.extention("/"));
-	}
-	public void testRoot() {
-		assertEquals ( "/foo/bar", Node.root("/foo/bar.txt"));
-		assertEquals ( "/foo/bar", Node.root("/foo/bar"));
-		assertEquals ( "/", Node.root("/"));
-	}
-	public void testTail() {
-		assertEquals ( "bar.txt", Node.tail("/foo/bar.txt"));
-		assertEquals ( "bar.txt", Node.tail ("/bar.txt") );
-		assertEquals ( "bar.txt", Node.tail ("bar.txt"));
-		assertEquals ( "foo", Node.tail("/foo/"));
-		assertEquals ( "foo2", Node.tail("foo2/"));
-		assertEquals ( "._.", Node.tail("/._."));
-	}
-	public void testDirname() {
-		assertEquals ( "/", Node.dirname("/foo"));
-		assertEquals ("/bar", Node.dirname("/bar/foo"));
-		assertEquals ( "/bar2", Node.dirname("/bar2/foo/"));
-		assertEquals ( "/", Node.dirname("/._."));
-	}
-}

Test/org/xnat/xnatfs/test/RemoteFileHandleTest.java

-package org.xnat.xnatfs.test;
-
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
-
-import java.io.FileInputStream;
-import java.io.IOException;
-import java.io.InputStreamReader;
-import java.nio.ByteBuffer;
-import java.util.HashSet;
-
-import org.apache.log4j.BasicConfigurator;
-import org.apache.log4j.Level;
-import org.apache.log4j.Logger;
-import org.jdom.Document;
-import org.jdom.input.SAXBuilder;
-import org.junit.BeforeClass;
-import org.junit.Ignore;
-import org.junit.Test;
-import org.xnat.xnatfs.FileHandle;
-import org.xnat.xnatfs.RemoteFileHandle;
-import org.xnat.xnatfs.XNATConnection;
-import org.xnat.xnatfs.xnatfs;
-import org.apache.http.HttpEntity;
-import org.apache.http.HttpException;
-import org.apache.http.HttpHost;
-import org.apache.http.HttpRequest;
-import org.apache.http.HttpRequestInterceptor;
-import org.apache.http.HttpResponse;
-import org.apache.http.auth.*;
-import org.apache.http.client.CredentialsProvider;
-import org.apache.http.client.methods.HttpGet;
-import org.apache.http.client.protocol.ClientContext;
-import org.apache.http.impl.auth.BasicScheme;
-import org.apache.http.impl.auth.BasicSchemeFactory;
-import org.apache.http.impl.client.DefaultHttpClient;
-import org.apache.http.protocol.BasicHttpContext;
-import org.apache.http.protocol.ExecutionContext;
-import org.apache.http.protocol.HttpContext;
-
-import fuse.FuseOpen;
-import fuse.FuseOpenSetter;
-
-public class RemoteFileHandleTest {
-  static Logger logger = Logger.getLogger ( RemoteFileHandleTest.class );
-  static xnatfs x = new xnatfs ();
-
-  @BeforeClass
-  public static void configure () {
-    BasicConfigurator.configure ();
-    xnatfs.configureCache ();
-    xnatfs.configureConnection ();
-  }
-
-  @Test
-  public void testLargeFile () throws Exception {
-    Logger.getLogger ( "org.xnat.xnatfs" ).setLevel ( Level.DEBUG );
-    Logger.getLogger ( "org.apache" ).setLevel ( Level.WARN );
-    Logger.getLogger ( "org.apache" ).setLevel ( Level.WARN );
-    try {
-      RemoteFileHandle files = new RemoteFileHandle ( "http://central.xnat.org/REST/projects/CENTRAL_OASIS_CS/subjects/OAS1_0456/experiments/OAS1_0456_MR1/scans/mpr-1/files", "files" );
-      assertTrue ( files.getCachedFile () != null );
-    } catch ( Exception e1 ) {
-      fail ( "Failed to get remote file: " + e1 );
-    }
-  }
-
-  @Test
-  public void testJDOM () throws Exception {
-    RemoteFileHandle fh = XNATConnection.getInstance ().get ( "http://central.xnat.org/REST/projects/NAMIC_TEST/subjects/1/experiments/MR1/scans/4/resources/SNAPSHOTS?format=json", "resources" );
-    HashSet<String> list = new HashSet<String> ();
-    fh.waitForDownload ();
-    InputStreamReader reader = new InputStreamReader ( new FileInputStream ( fh.getCachedFile () ) );
-    SAXBuilder builder = new SAXBuilder ();
-    Document doc = builder.build ( reader );
-    org.jdom.Element root = doc.getRootElement ();
-  }
-
-  @Test
-  public void testFileHandle () throws Exception {
-    FileHandle fh = null;
-    try {
-      fh = new FileHandle ( "http://central.xnat.org/REST/projects/CENTRAL_OASIS_CS/subjects?format=xml", "foo" );
-      fh.open ();
-      assertTrue ( fh.waitForDownload () != 0 );
-    } catch ( Exception e2 ) {
-      logger.error ( "Error", e2 );
-      fail ( "Failed to get remote file through FileHandle: " + e2 );
-    } finally {
-      fh.release ();
-    }
-  }
-
-  @Test
-  public void readFileHandle () throws Exception {
-    FileHandle fh = null;
-    try {
-      fh = new FileHandle ( "http://central.xnat.org/REST/projects/CENTRAL_OASIS_CS/subjects?format=json", "foobar" );
-      fh.open ();
-      ByteBuffer b = ByteBuffer.allocate ( 1000000 );
-      int offset = 0;
-      while ( !fh.isDownloadComplete () ) {
-        fh.read ( b, offset );
-        offset += b.position ();
-        logger.debug ( "Buffer position: " + b.position () );
-      }
-    } catch ( Exception e2 ) {
-      logger.error ( "Error", e2 );
-      fail ( "Failed to get remote file through FileHandle: " + e2 );
-    } finally {
-      fh.release ();
-    }
-
-    // try {
-    // RemoteFileHandle bigFile = new RemoteFileHandle (
-    // "http://central.xnat.org/REST/projects/CENTRAL_OASIS_CS/subjects/OAS1_0456/experiments/OAS1_0456_MR1/scans/mpr-1/resources/308/files/OAS1_0456_MR1_mpr-1_anon.img",
-    // "bigfile" );
-    // assertTrue ( bigFile.getCachedFile () != null );
-    // } catch ( Exception e2 ) {
-    // fail ( "Failed to get large remote file: " + e2 );
-    // }
-
-  }
-
-  @Test
-  public void testCommons () throws Exception {
-    DefaultHttpClient httpclient = new DefaultHttpClient ();
-
-    httpclient.getCredentialsProvider ().setCredentials ( new AuthScope ( AuthScope.ANY_HOST, AuthScope.ANY_PORT ), new UsernamePasswordCredentials ( "blezek", "throwaway " ) ); // .setCredentials
-    // (
-    // new
-    // AuthScope
-    // (
-    // "localhost",
-    // 443
-    // ),
-    // new
-    // UsernamePasswordCredentials
-    // (
-    // "username",
-    // "password"
-    // )
-    // );
-
-    // httpclient.getAuthSchemes ().register ( "basic", new BasicSchemeFactory
-    // () );
-
-    logger.debug ( httpclient.getAuthSchemes ().getSchemeNames () );
-
-    logger.debug ( httpclient.getTargetAuthenticationHandler () );
-    HttpGet httpget = new HttpGet ( "http://central.xnat.org/REST/projects/CENTRAL_OASIS_CS/subjects/OAS1_0456/experiments/OAS1_0456_MR1/scans/mpr-1/files" );
-
-    // BasicHttpContext localcontext = new BasicHttpContext ();
-
-    // Generate BASIC scheme object and stick it to the local
-    // execution context
-    // BasicScheme basicAuth = new BasicScheme ();
-    // localcontext.setAttribute ( "preemptive-auth", basicAuth );
-
-    // Add as the first request interceptor
-    // httpclient.addRequestInterceptor ( new PreemptiveAuth (), 0 );
-
-    System.out.println ( "executing request " + httpget.getRequestLine () );
-    HttpResponse response = httpclient.execute ( httpget );
-    HttpEntity entity = response.getEntity ();
-
-    System.out.println ( "----------------------------------------" );
-    System.out.println ( response.getStatusLine () );
-    if ( entity != null ) {
-      System.out.println ( "Response content length: " + entity.getContentLength () );
-    }
-    if ( entity != null ) {
-      entity.consumeContent ();
-    }
-
-    // When HttpClient instance is no longer needed,
-    // shut down the connection manager to ensure
-    // immediate deallocation of all system resources
-    httpclient.getConnectionManager ().shutdown ();
-
-  }
-
-  @Test
-  public void Interceptor () throws Exception {
-    DefaultHttpClient httpclient = new DefaultHttpClient ();
-
-    httpclient.getCredentialsProvider ().setCredentials ( new AuthScope ( AuthScope.ANY_HOST, AuthScope.ANY_PORT ), new UsernamePasswordCredentials ( "blezek", "throwaway" ) );
-
-    BasicHttpContext localcontext = new BasicHttpContext ();
-
-    // Generate BASIC scheme object and stick it to the local
-    // execution context
-    BasicScheme basicAuth = new BasicScheme ();
-    localcontext.setAttribute ( "preemptive-auth", basicAuth );
-
-    // Add as the first request interceptor
-    httpclient.addRequestInterceptor ( new PreemptiveAuth (), 0 );
-
-    HttpHost targetHost = new HttpHost ( "central.xnat.org", 80, "http" );
-
-    HttpGet httpget = new HttpGet ( "/REST/projects/CENTRAL_OASIS_CS/subjects/OAS1_0456/experiments/OAS1_0456_MR1/scans/mpr-1/files" );
-
-    logger.debug ( "executing request: " + httpget.getRequestLine () );
-    logger.debug ( "to target: " + targetHost );
-
-    for ( int i = 0; i < 3; i++ ) {
-      logger.debug ( "Starting loop: " + i );
-      HttpResponse response = httpclient.execute ( targetHost, httpget, localcontext );
-      logger.debug ( "Got response: " + response );
-      HttpEntity entity = response.getEntity ();
-
-      System.out.println ( "----------------------------------------" );
-      System.out.println ( response.getStatusLine () );
-      if ( entity != null ) {
-        System.out.println ( "Response content length: " + entity.getContentLength () );
-        entity.consumeContent ();
-      }
-    }
-    // When HttpClient instance is no longer needed,
-    // shut down the connection manager to ensure
-    // immediate deallocation of all system resources
-    httpclient.getConnectionManager ().shutdown ();
-
-  }
-
-  @Ignore
-  public void testOpen () throws Exception {
-    String path = "/projects/CENTRAL_OASIS_CS/subjects/OAS1_0457/experiments/OAS1_0457_MR1/scans/mpr-1/files/OAS1_0457_MR1_mpr-1_anon.img";
-    FuseOpenSetter openSetter = new FuseOpen ();
-    x.open ( path, 0, openSetter );
-  }
-
-  static class PreemptiveAuth implements HttpRequestInterceptor {
-
-    public void process ( final HttpRequest request, final HttpContext context ) throws HttpException, IOException {
-
-      AuthState authState = (AuthState) context.getAttribute ( ClientContext.TARGET_AUTH_STATE );
-
-      // If no auth scheme avaialble yet, try to initialize it preemptively
-      if ( authState.getAuthScheme () == null ) {
-        AuthScheme authScheme = (AuthScheme) context.getAttribute ( "preemptive-auth" );
-        CredentialsProvider credsProvider = (CredentialsProvider) context.getAttribute ( ClientContext.CREDS_PROVIDER );
-        HttpHost targetHost = (HttpHost) context.getAttribute ( ExecutionContext.HTTP_TARGET_HOST );
-        if ( authScheme != null ) {
-          Credentials creds = credsProvider.getCredentials ( new AuthScope ( targetHost.getHostName (), targetHost.getPort () ) );
-          if ( creds == null ) {
-            throw new HttpException ( "No credentials for preemptive authentication" );
-          }
-          authState.setAuthScheme ( authScheme );
-          authState.setCredentials ( creds );
-        }
-      }
-
-    }
-  }
-
-}