Changeset 3487


Ignore:
Timestamp:
12/19/07 08:59:50 (12 years ago)
Author:
melissa
Message:

Downloading from OMERO is now much faster. Also, ownership rules are now enforced - a user can only download images that (s)he owns.

Location:
trunk/loci
Files:
2 edited

Legend:

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

    r3431 r3487  
    2222 
    2323import ij.gui.GenericDialog; 
    24 import java.awt.*; 
     24import java.awt.Dimension; 
     25import java.awt.GridBagConstraints; 
     26import java.awt.GridBagLayout; 
     27import java.awt.Panel; 
    2528import java.awt.image.BufferedImage; 
    2629import java.io.*; 
     
    9699  } 
    97100 
     101  private static boolean loggedIn = false; 
     102  private static boolean omePixelsInitialized = false; 
     103  private static boolean omeroPixelsInitialized = false; 
     104 
    98105  // -- Utils API methods -- 
    99106 
     
    146153  public static void login(OMECredentials credentials) throws ReflectException 
    147154  { 
     155    if (loggedIn) return; 
    148156    r.setVar("user", credentials.username); 
    149157    r.setVar("pass", credentials.password); 
     
    155163      r.exec("server = new Server(sname, port)"); 
    156164      r.exec("sf = new ServiceFactory(server, login)"); 
     165      r.exec("thumbs = sf.createThumbnailService()"); 
     166      r.exec("admin = sf.getAdminService()"); 
     167      r.exec("eventContext = admin.getEventContext()"); 
    157168    } 
    158169    else { 
     
    180191      r.exec("pf = rs.getService(pfClass)"); 
    181192    } 
     193    loggedIn = true; 
    182194  } 
    183195 
    184196  /** Log out of OME/OMERO server. */ 
    185   public static void logout() { 
    186  
     197  public static void logout(boolean isOMERO) { 
     198    loggedIn = false; 
     199    omePixelsInitialized = false; 
     200    omeroPixelsInitialized = false; 
     201 
     202    if (!isOMERO) { 
     203      try { 
     204        r.exec("rc.logout()"); 
     205      } 
     206      catch (ReflectException e) { } 
     207    } 
    187208  } 
    188209 
     
    455476 
    456477  private static void getAllImages() throws ReflectException { 
     478    if (omePixelsInitialized) return; 
    457479    r.exec("c = new Criteria()"); 
    458480    setImageCriteria(); 
     
    464486    } 
    465487    r.exec("l = df.retrieveList(imageClass, c)"); 
     488    omePixelsInitialized = true; 
    466489  } 
    467490 
     
    543566 
    544567  private static void getAllPixels() throws ReflectException { 
    545     r.exec("thumbs = sf.createThumbnailService()"); 
    546     r.exec("admin = sf.getAdminService()"); 
    547     r.exec("eventContext = admin.getEventContext()"); 
     568    if (omeroPixelsInitialized) return; 
    548569    r.exec("uid = eventContext.getCurrentUserId()"); 
    549570    r.exec("filter = new Filter()"); 
    550     r.exec("filter.owner(uid)"); 
     571    r.exec("filter = filter.owner(uid)"); 
    551572    r.exec("query = sf.getQueryService()"); 
    552573    r.setVar("q", "select p from Pixels as p " + 
     
    556577      "left outer join fetch p.image"); 
    557578    r.exec("params = new Parameters(filter)"); 
    558     r.exec("params.addId(uid)"); 
    559579    r.exec("results = query.findAllByQuery(q, params)"); 
     580 
     581    List results = (List) r.getVar("results"); 
     582    long uid = ((Long) r.getVar("uid")).longValue(); 
     583    for (int i=0; i<results.size(); i++) { 
     584      r.setVar("i", i); 
     585      r.exec("obj = results.get(i)"); 
     586      r.exec("obj = new PixelsData(obj)"); 
     587      r.exec("owner = obj.getOwner()"); 
     588      r.exec("id = owner.getId()"); 
     589      long testId = ((Long) r.getVar("id")).longValue(); 
     590      if (testId != uid) { 
     591        results.remove(i); 
     592        i--; 
     593      } 
     594    } 
     595 
    560596    r.exec("len = results.size()"); 
     597    omeroPixelsInitialized = true; 
    561598  } 
    562599 
  • trunk/loci/plugins/OMEPlugin.java

    r3459 r3487  
    149149    IJ.showStatus("OME: Logging out..."); 
    150150    IJ.showProgress(.99); 
    151     OMEUtils.logout(); 
     151    OMEUtils.logout(cred.isOMERO); 
    152152    IJ.showStatus("OME: Completed"); 
    153153  } 
Note: See TracChangeset for help on using the changeset viewer.