• Views
  • Iteration Report
  • My Iteration Report
  •  
OMERO.server
  • Login
  • Help/Guide
  • About Trac
  • Preferences
  • Wiki
  • Timeline
  • Roadmap
  • Browse Source
  • View Tickets
  • Search

Context Navigation

  • ← Previous Changeset
  • Next Changeset →

Changeset 1744

Show
Ignore:
Timestamp:
08/14/07 14:25:55 (15 months ago)
Author:
Aleksandra Tarkowska
Message:

changing logic to modularize compression library (#6)

Location:
trunk/components
Files:
7 modified

  • common/src/ome/system/ServiceFactory.java (modified) (2 diffs)
  • server/resources/ome/services/service-ome.api.IThumb.xml (modified) (1 diff)
  • server/src/ome/logic/LdapImpl.java (modified) (2 diffs)
  • server/src/ome/security/LdapUtil.java (modified) (1 diff)
  • server/src/ome/services/ThumbnailBean.java (modified) (8 diffs)
  • server/test/ome/server/itests/ThumbnailServiceTest.java (modified) (1 diff)
  • server/test/ome/server/itests/sec/LdapTest.java (modified) (9 diffs)

Legend:

Unmodified
Added
Removed
  • trunk/components/common/src/ome/system/ServiceFactory.java

    r1715 r1744  
    1616import ome.api.IAdmin; 
    1717import ome.api.IAnalysis; 
     18import ome.api.ICompress; 
    1819import ome.api.IConfig; 
    1920import ome.api.ILdap; 
    … …  
    179180    } 
    180181 
     182    public ICompress getCompresService() { 
     183        return getServiceByClass(ICompress.class); 
     184    } 
     185     
    181186    public IConfig getConfigService() { 
    182187        return getServiceByClass(IConfig.class); 
  • trunk/components/server/resources/ome/services/service-ome.api.IThumb.xml

    r1670 r1744  
    2929    <property name="scaleService" ref="internal:ome.api.IScale"/> 
    3030    <property name="IRepositoryInfo" ref="internal:ome.api.IRepositoryInfo"/> 
     31    <property name="ICompress" ref="internal:ome.api.ICompress"/> 
    3132  </bean> 
    3233   
  • trunk/components/server/src/ome/logic/LdapImpl.java

    r1719 r1744  
    179179        @RolesAllowed("system") 
    180180        public Experimenter searchByDN(DistinguishedName dn) { 
    181                 Experimenter exp = new Experimenter(); 
    182181                return (Experimenter) ldapTemplate 
    183182                                .lookup(dn, new PersonContextMapper()); 
    … …  
    446445                                        .getEnvironment(); 
    447446 
    448                         if (username != "" && username != null) { 
     447                        if (!username.equals("") && username != null) { 
    449448                                env.put(Context.SECURITY_PRINCIPAL, username); 
    450449                                if (password != null) 
  • trunk/components/server/src/ome/security/LdapUtil.java

    r1717 r1744  
    99 
    1010// Java imports 
    11 import java.util.ArrayList; 
    12 import java.util.Hashtable; 
    13 import java.util.List; 
    14  
    15 import javax.naming.AuthenticationException; 
    16 import javax.naming.Context; 
    17 import javax.naming.NamingException; 
    18 import javax.naming.ldap.InitialLdapContext; 
    19 import javax.naming.ldap.LdapContext; 
    20  
    21 // Third-party libraries 
    2211import org.springframework.jdbc.core.simple.SimpleJdbcOperations; 
    23 import net.sf.ldaptemplate.support.DistinguishedName; 
    24  
    25 // Application-internal dependencies 
    26 import ome.api.IAdmin; 
    27 import ome.api.ILdap; 
    28 import ome.api.local.LocalAdmin; 
    29 import ome.api.local.LocalLdap; 
    30 import ome.model.meta.Experimenter; 
    31 import ome.system.OmeroContext; 
    32 import ome.system.Principal; 
    33 import ome.system.Roles; 
    34 import ome.system.ServiceFactory; 
    3512 
    3613/** 
  • trunk/components/server/src/ome/services/ThumbnailBean.java

    r1640 r1744  
    2020import java.io.FileOutputStream; 
    2121import java.io.IOException; 
    22 import java.io.OutputStream; 
    2322import java.io.Serializable; 
    2423import java.util.List; 
    … …  
    3534import javax.ejb.TransactionManagement; 
    3635import javax.ejb.TransactionManagementType; 
    37 import javax.imageio.IIOImage; 
    38 import javax.imageio.ImageIO; 
    39 import javax.imageio.ImageWriteParam; 
    40 import javax.imageio.ImageWriter; 
    41 import javax.imageio.stream.ImageOutputStream; 
    4236import javax.interceptor.Interceptors; 
    43 // Third-party libraries 
    44 import org.springframework.transaction.annotation.Transactional; 
    45  
    46 import org.apache.commons.logging.Log; 
    47 import org.apache.commons.logging.LogFactory; 
    48 import org.jboss.annotation.ejb.LocalBinding; 
    49 import org.jboss.annotation.ejb.RemoteBinding; 
    50 import org.jboss.annotation.security.SecurityDomain; 
    51  
     37 
     38import ome.api.ICompress; 
    5239import ome.api.IRepositoryInfo; 
    5340import ome.api.IScale; 
     41import ome.api.ServiceInterface; 
    5442import ome.api.ThumbnailStore; 
    55 import ome.api.ServiceInterface; 
    5643import ome.conditions.ApiUsageException; 
    5744import ome.conditions.ResourceError; 
    5845import ome.io.nio.ThumbnailService; 
    5946import ome.logic.AbstractLevel2Service; 
    60 import ome.logic.SimpleLifecycle; 
    6147import ome.model.core.Pixels; 
    6248import ome.model.display.Thumbnail; 
    … …  
    6753import omeis.providers.re.RenderingEngine; 
    6854import omeis.providers.re.data.PlaneDef; 
     55 
     56import org.apache.commons.logging.Log; 
     57import org.apache.commons.logging.LogFactory; 
     58import org.jboss.annotation.ejb.LocalBinding; 
     59import org.jboss.annotation.ejb.RemoteBinding; 
     60import org.jboss.annotation.security.SecurityDomain; 
     61import org.springframework.transaction.annotation.Transactional; 
     62 
    6963import sun.awt.image.IntegerInterleavedRaster; 
    7064 
    … …  
    110104    /** the disk space checking service */ 
    111105    private transient IRepositoryInfo iRepositoryInfo; 
     106     
     107    /** the disk space checking service */ 
     108    private transient ICompress iCompress; 
    112109 
    113110    /** is file service checking for disk overflow */ 
    … …  
    275272        this.iRepositoryInfo = iRepositoryInfo; 
    276273    } 
     274     
     275    /** 
     276     * Scale service Bean injector. 
     277     *  
     278     * @param iCompress 
     279     *            an <code>ICompress</code>. 
     280     */ 
     281    public void setICompress(ICompress iCompress) { 
     282        getBeanHelper().throwIfAlreadySet(this.iCompress, iCompress); 
     283        this.iCompress = iCompress; 
     284    } 
     285     
    277286    /** 
    278287     * Creates a buffered image from a rendering engine RGB buffer without data 
    … …  
    320329 
    321330    /** 
    322      * Compresses a buffered image thumbnail to an output stream. 
    323      *  
    324      * @param image 
    325      *            the thumbnail's buffered image. 
    326      * @param outputStream 
    327      *            the stream to write to. 
    328      * @throws IOException 
    329      *             if there is a problem when writing to <i>stream<i>. 
    330      */ 
    331     private void compressThumbnailToStream(BufferedImage image, 
    332             OutputStream outputStream) throws IOException { 
    333         // Get a JPEG image writer 
    334         ImageWriter jpegWriter = 
    335                 ImageIO.getImageWritersByFormatName("jpeg").next(); 
    336  
    337         // Setup the compression value from (0.05, 0.75 and 0.95) 
    338         ImageWriteParam iwp = jpegWriter.getDefaultWriteParam(); 
    339         iwp.setCompressionMode(ImageWriteParam.MODE_EXPLICIT); 
    340         iwp.setCompressionQuality(DEFAULT_COMPRESSION_QUALITY); 
    341  
    342         // Write the JPEG to our ByteArray stream 
    343         ImageOutputStream imageOutputStream = null; 
    344         try { 
    345                 imageOutputStream = ImageIO.createImageOutputStream(outputStream); 
    346                 jpegWriter.setOutput(imageOutputStream); 
    347                 jpegWriter.write(null, new IIOImage(image, null, null), iwp); 
    348         } finally { 
    349                 if (imageOutputStream != null) 
    350                         imageOutputStream.close(); 
    351         } 
    352     } 
    353  
    354     /** 
    355331     * Compresses a buffered image thumbnail to disk. 
    356332     *  
    … …  
    370346 
    371347        FileOutputStream stream = ioService.getThumbnailOutputStream(thumb); 
    372         compressThumbnailToStream(image, stream); 
     348        iCompress.compressThumbnailToStream(image, stream); 
    373349        stream.close(); 
    374350    } 
    … …  
    632608        ByteArrayOutputStream byteStream = new ByteArrayOutputStream(); 
    633609        try { 
    634             compressThumbnailToStream(image, byteStream); 
     610            iCompress.compressThumbnailToStream(image, byteStream); 
    635611            byte[] thumbnail = byteStream.toByteArray(); 
    636612            return thumbnail; 
  • trunk/components/server/test/ome/server/itests/ThumbnailServiceTest.java

    r1167 r1744  
    6060    public void testThumbnailsDirect() throws Exception { 
    6161 
     62         
    6263        RenderingDef def = (RenderingDef) qs 
    6364                .findAllByQuery( 
  • trunk/components/server/test/ome/server/itests/sec/LdapTest.java

    r1717 r1744  
    3232 
    3333                List<String> l = iLdap.searchDnInGroups("member", 
    34                                 "cn=jburel, ou=edir, ou=people, ou=lifesci, o=dundee"); 
     34                                "cn=jsmith, ou=example, ou=domain, o=com"); 
    3535                for (String s : l) { 
    3636                        System.out.println(s); 
    … …  
    4444 
    4545                List<Experimenter> exps = iLdap.searchByAttribute( 
    46                                 DistinguishedName.EMPTY_PATH, "sn", "Tarkowska"); 
     46                                DistinguishedName.EMPTY_PATH, "sn", "Smith"); 
    4747                for (Experimenter e : exps) { 
    4848                        System.out.println(e.getOmeName()); 
    … …  
    6060                String[] vals = new String[2]; 
    6161                vals[0] = "person"; 
    62                 vals[1] = "1614"; 
     62                vals[1] = "1111"; 
    6363 
    6464                List<Experimenter> exps = iLdap.searchByAttributes( 
    … …  
    7070 
    7171                DistinguishedName dn = new DistinguishedName( 
    72                                 "cn=atarkowska,ou=edir,ou=people"); 
     72                                "cn=jsmith,ou=example"); 
    7373                List<Experimenter> exps1 = iLdap.searchByAttributes(dn, attrs, vals); 
    7474                System.out.println("size " + exps1.size()); 
    … …  
    8484 
    8585                DistinguishedName dn = new DistinguishedName( 
    86                                 "cn=atarkowska,ou=edir,ou=people"); 
     86                                "cn=atarkowska,ou=example"); 
    8787                Experimenter exp = iLdap.searchByDN(dn); 
    8888                System.out.println("Experimenter: " + exp.getFirstName() + " " 
    … …  
    9696                loginRoot(); 
    9797 
    98                 DistinguishedName dn = iLdap.findDN("akrasowski"); 
     98                DistinguishedName dn = iLdap.findDN("jsmith"); 
    9999                System.out.println("DN: " + dn.toString()); 
    100100 
    … …  
    102102                // should catch an exception 
    103103                try { 
    104                         iLdap.findDN("atarkowska"); 
     104                        iLdap.findDN("jsmith"); 
    105105                } catch (Exception e) { 
    106106                        e.printStackTrace(); 
    … …  
    123123        public void testValidatePassword() throws Exception { 
    124124                loginRoot(); 
    125                 System.out.println(iLdap.validatePassword("cn=atarkowska,ou=edir,ou=people,ou=lifesci,o=dundee", "123")); 
     125                System.out.println(iLdap.validatePassword("cn=jsmith,ou=example,ou=domain,o=com", "passwod")); 
    126126                 
    127127        } 
    … …  
    130130        public void testCreateUserFromLdap() throws Exception { 
    131131                loginRoot(); 
    132                 System.out.println(iLdap.createUserFromLdap("atarkowska", "123")); 
     132                System.out.println(iLdap.createUserFromLdap("jsmith", "passwd")); 
    133133                 
    134134        } 

Download in other formats:

  • Unified Diff
  • Zip Archive

Trac Powered

Powered by Trac 0.11
By Edgewall Software.

Visit the Trac open source project at
http://trac.edgewall.org/