Changeset 2457


Ignore:
Timestamp:
03/15/07 09:36:18 (13 years ago)
Author:
curtis
Message:

Add status reporting to OME uploader. But uploader is broken right now.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/loci/formats/ome/OMEUploader.java

    r2455 r2457  
    8282 
    8383  /** Construct a new OMEUploader for the specified server. */ 
    84   public OMEUploader(String server) { 
    85     this.server = server; 
     84  public OMEUploader() { 
    8685    files = new Vector(); 
    8786  } 
     
    123122  { 
    124123    this.server = server + "/shoola"; 
    125     omeis = server + "/cgi-bin/omeis"; 
    126  
    127     if (!omeis.startsWith("http://")) omeis = "http://" + omeis; 
    128124    if (!this.server.startsWith("http://")) { 
    129125      this.server = "http://" + this.server; 
    130126    } 
     127    omeis = this.server + "/cgi-bin/omeis"; 
     128    this.user = user; 
     129    this.pass = pass; 
     130 
     131    status("Logging in to " + server); 
    131132 
    132133    Vector v = new Vector(); 
     
    155156  /** Log all users out of the current server. */ 
    156157  public void logout() { 
     158    status("Logging out"); 
     159 
    157160    Vector v = new Vector(); 
    158161    v.add(sessionKey); 
    159162    try { sendRequest(buildXML("closeSession", v)); } 
    160     catch (Exception e) { /* do nothing; we don't care if this fails */ } 
     163    catch (UploadException e) { 
     164      // do nothing; we don't care if this fails 
     165    } 
    161166    validLogin = false; 
    162167  } 
     
    635640    throws UploadException 
    636641  { 
     642    status("Creating pixels file"); 
     643 
    637644    Vector keys = new Vector(); 
    638645    Vector values = new Vector(); 
     
    651658  /** Close the given pixels file. */ 
    652659  private String closePixels(String id) throws UploadException { 
     660    status("Closing pixels file"); 
     661 
    653662    Vector keys = new Vector(); 
    654663    Vector values = new Vector(); 
     
    669678    boolean bigEndian) throws UploadException 
    670679  { 
     680    status("Uploading plane: Z=" + z + ", C=" + c + ", T=" + t); 
     681 
    671682    Vector keys = new Vector(); 
    672683    Vector values = new Vector(); 
     
    700711   */ 
    701712  private void setupImport(long size) throws UploadException { 
     713    status("Preparing to upload"); 
     714 
    702715    if (files != null) files.clear(); 
    703716 
     
    747760    throws UploadException 
    748761  { 
     762    status("Uploading metadata"); 
     763 
    749764    OMEXMLMetadataStore xml = (OMEXMLMetadataStore) store; 
    750765 
     
    811826    try { 
    812827      for (int i=0; i<files.size(); i++) { 
    813         OriginalFile f = pf.uploadFile(r, of, new File((String) files.get(i))); 
    814         f.setPath((String) files.get(i)); 
     828        String filename = (String) files.get(i); 
     829        status("Uploading file " + filename); 
     830        OriginalFile f = pf.uploadFile(r, of, new File(filename)); 
     831        f.setPath(filename); 
    815832        df.markForUpdate(f); 
    816833      } 
     
    820837    of.setStatus("FINISHED"); 
    821838    df.update(of); 
     839 
     840    status("Linking pixels"); 
    822841 
    823842    ModuleExecution ii = im.getImageImportMEX(image); 
     
    954973 
    955974    // create image uploader 
    956     OMEUploader uploader = new OMEUploader(server, user, pass); 
    957 //    uploader.addUploadListener(new UploadListener() { 
    958 //      public void taskUpdated(UploadEvent e) { 
    959 //        System.out.println(e.getStatusMessage()); 
    960 //      } 
    961 //    }); 
     975    OMEUploader uploader = new OMEUploader(); 
     976    uploader.addStatusListener(new StatusListener() { 
     977      public void statusUpdated(StatusEvent e) { 
     978        System.out.println(e.getStatusMessage()); 
     979      } 
     980    }); 
     981    uploader.login(server, user, pass); 
    962982    uploader.uploadFile(id, true); 
    963983  } 
Note: See TracChangeset for help on using the changeset viewer.