Commits

ble...@numbers.local  committed a3e7f08

More search support

  • Participants
  • Parent commits 72d5c1e

Comments (0)

Files changed (4)

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

   public HttpClient getClient ( Auth credentials ) {
     DefaultHttpClient mClient;
     mClient = new DefaultHttpClient ( cm, params );
-    logger.debug ( "getClient: credentials are " + credentials.user + "/" + credentials.password );
+    logger.debug ( "getClient: credentials are " + credentials.user + "/********" );
     mClient.getCredentialsProvider ().setCredentials ( new AuthScope ( AuthScope.ANY_HOST, AuthScope.ANY_PORT ), new UsernamePasswordCredentials ( credentials.user, credentials.password ) );
     /*
      * BasicHttpContext localcontext = new BasicHttpContext ();

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

    * @see com.bradmcevoy.http.CollectionResource#child(java.lang.String)
    */
   public Resource child ( String childName ) {
-    logger.debug ( "child: Creating child " + childName );
+    logger.debug ( "child: Creating child " + childName + " with credentials " + mCredentials );
 
     if ( xnatfs.useVerboseFolders () & !mVerboseDirectory ) {
       // this object is not the verbose folder, but we must create one.

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

 import java.util.HashMap;
 import java.util.List;
 
+import net.sf.ehcache.Element;
+
 import org.apache.http.HttpEntity;
 import org.apache.log4j.Logger;
 import org.json.JSONArray;
 
   @Override
   public Resource child ( String childName ) {
+    if ( mChildren.get ( childName ) == null ) {
+      logger.debug ( "null child: " + childName );
+    }
+    logger.debug ( "Looking up " + childName + " returning " + mChildren.get ( childName ) );
     return mChildren.get ( childName );
   }
 
      * :0.708,"quarantine_status"
      * :"active","xnat_mrsessiondata_cnda_clinicalassessmentdata_diff":""}
      */
+    String url = mURL + "/results?format=json";
+    String key = mCredentials.user + "::" + mCredentials.password + "::ElementList::" + url;
+    ArrayList<Resource> list = new ArrayList<Resource> ();
+    Element e = XNATFS.sContentCache.get ( key );
+    if ( e != null ) {
+      mChildren = (HashMap<String, VirtualDirectory>) e.getObjectValue ();
+      list.addAll ( mChildren.values () );
+    }
 
-    ArrayList<Resource> list = new ArrayList<Resource> ();
-
-    String url = mURL + "/results?format=json";
     if ( mCredentials == null ) {
+      logger.error ( "getChildren: called without credentials" );
       return list;
     }
+    mChildren.clear ();
+    if ( true || false ) {
+      String eURL = "/projects/NAMIC_TEST/subjects/1/experiments/MR1/";
+      eURL = "/projects/NAMIC_TEST/";
+      logger.debug ( "getChildren: creating new Experiment for " + eURL );
+      Project P = new Project ( xnatfs, mAbsolutePath, "NAMIC_TEST", eURL );
+      setChildAuthorization ( P );
+      mChildren.put ( "NAMIC_TEST", P );
+      eURL = "/projects/NAMIC_TEST/subjects/1/";
+      logger.debug ( "getChildren: creating new Subject for " + eURL );
+      Subject S = new Subject ( xnatfs, mAbsolutePath, "NAMIC_TEST-1", eURL );
+      setChildAuthorization ( S );
+      mChildren.put ( "NAMIC_TEST-1", S );
+
+      eURL = "/projects/NAMIC_TEST/subjects/1/experiments/MR1/";
+      Experiment E = new Experiment ( xnatfs, mAbsolutePath, "NAMIC_TEST-1-MR1", eURL );
+      setChildAuthorization ( E );
+      mChildren.put ( "NAMIC_TEST-1-MR1", E );
+
+      eURL = "/projects/CENTRAL_OASIS_CS/subjects/OAS1_0002/experiments/OAS1_0002_MR1/";
+      E = new Experiment ( xnatfs, mAbsolutePath, "OASIS_TEST", eURL );
+      setChildAuthorization ( E );
+      mChildren.put ( "OASIS_TEST", E );
+    }
+
     // Get the subjects code
     HttpEntity entity = null;
     try {
           continue;
         }
 
-        // If we have the keys session_id, project, xnat_subjectdata_subjectid,
+        // If we have the keys session_id, project,
+        // xnat_subjectdata_subjectid,
         // then we are a session
         if ( item.has ( "session_id" ) && item.has ( "project" ) && item.has ( "xnat_subjectdata_subjectid" ) ) {
           // Construct and add a child
           String sessionID = item.getString ( "session_id" );
           String name = projectName + "-" + subjectID + "-" + sessionID;
           // Need to construct the URL properly
-          String experimentURL = "/projects/" + projectName + "/subjects/" + subjectID + "/experiments/" + sessionID;
+          // "/projects/NAMIC_TEST/subjects/1/experiments/MR1/";
+
+          String experimentURL;
+          experimentURL = "/projects/" + projectName + "/subjects/" + subjectID + "/experiments/" + sessionID + "/";
+          experimentURL = "/projects/CENTRAL_OASIS_CS/subjects/OAS1_0044/experiments/OAS1_0044_MR1/";
+          experimentURL = "/projects/" + projectName + "/subjects/" + subjectID + "/experiments/" + sessionID + "/";
+          // logger.debug ( "getChildren: created Experiment with URL: " +
+          // experimentURL );
           Experiment exp = new Experiment ( xnatfs, mAbsolutePath, name, experimentURL );
           setChildAuthorization ( exp );
           mChildren.put ( name, exp );
       if ( entity != null ) {
         try {
           entity.consumeContent ();
-        } catch ( IOException e ) {
-          logger.error ( "error consuming all content", e );
+        } catch ( IOException e1 ) {
+          logger.error ( "error consuming all content", e1 );
         }
       }
     }
 
-    for ( String child : mChildren.keySet () ) {
-      // logger.debug ( "got Child " + child );
-      list.add ( child ( child ) );
-    }
+    list.addAll ( mChildren.values () );
     Collections.sort ( list, new Comparator<Resource> () {
       public int compare ( Resource o1, Resource o2 ) {
         return o1.getName ().compareTo ( o2.getName () );
       }
     } );
+    // Cache for later
+    XNATFS.sContentCache.put ( new Element ( key, mChildren ) );
     return list;
   }
 }

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

 
   @Override
   public Resource child ( String childName ) {
+    logger.debug ( "child: creating child: " + childName + " with credentials: " + mCredentials );
     Search search = new Search ( xnatfs, mAbsolutePath, childName, "/search/saved/" + childName );
     setChildAuthorization ( search );
     return search;