Changeset 3510


Ignore:
Timestamp:
Jun 19, 2007, 8:56:23 AM (16 years ago)
Author:
Nicklas Nordborg
Message:

Fixes #470

Location:
trunk
Files:
5 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/bin/set_classpath.bat

    r3476 r3510  
    8686REM Affymetrix Fusion SDK
    8787SET CP=%CP%;%WEBINF%/lib/AffxFusion.jar
     88
     89REM TAR and BZIP
     90SET CP=%CP%;%WEBINF%/lib/tar.jar
     91SET CP=%CP%;%WEBINF%/lib/bzip2.jar
  • trunk/bin/set_classpath.sh

    r3476 r3510  
    8585# Affymetrix Fusion SDK
    8686CP=$CP:$WEBINF/lib/AffxFusion.jar
     87
     88# TAR and BZIP
     89CP=$CP:$WEBINF/lib/tar.jar
     90CP=$CP:$WEBINF/lib/bzip2.jar
  • trunk/doc/3rd-party-components.txt

    r3476 r3510  
    238238Files    : AffxFusion.jar
    239239
     240TAR file support
     241----------------
     242Package for reading and writing TAR files.
     243
     244More info: http://www.trustice.com/java/tar/
     245Version  : 2.5
     246License  : tar.license.txt
     247Files    : tar.jar
     248
     249BZIP file support
     250-----------------
     251Package for reading and writing BZIP files.
     252
     253More info: http://www.kohsuke.org/bzip2/
     254Version  : unknown
     255License  : Apache software license (apache.license.txt)
     256Files    : bzip2.jar
     257
     258
     259
  • trunk/src/core/net/sf/basedb/core/Install.java

    r3503 r3510  
    602602      createPluginDefinition("net.sf.basedb.plugins.SpotImageCreator", null, keyEveryoneUse, true, null, false);
    603603      createPluginDefinition("net.sf.basedb.plugins.ZipFileUnpacker", null, keyEveryoneUse, true, null, true);
     604      createPluginDefinition("net.sf.basedb.plugins.TarFileUnpacker", null, keyEveryoneUse, true, null, true);
    604605      createPluginDefinition("net.sf.basedb.plugins.PluginConfigurationExporter", null, keyEveryoneUse, true, null, true);
    605606      createPluginDefinition("net.sf.basedb.plugins.PluginConfigurationImporter", null, null, true, null, false);
  • trunk/src/core/net/sf/basedb/util/FileUtil.java

    r2304 r3510  
    3636import net.sf.basedb.core.query.Orders;
    3737
     38import java.util.Arrays;
    3839import java.util.List;
    3940import java.util.LinkedList;
     
    4950import java.io.FileInputStream;
    5051import java.io.BufferedInputStream;
     52import java.io.PushbackInputStream;
    5153
    5254/**
     
    118120 
    119121  /**
     122    Take a peek at an input stream and check if the first few bytes
     123    matches the bCheck parameter. After the check the bytes are
     124    pushed back to the stream again. This method is useful to check
     125    the file format of a file, which can often be done by checing
     126    the first few bytes at the start of the file. For example
     127    to check if the file is gzip file:
     128    <p>
     129    <code>bCheck = new byte[] { 0x1f, (byte)0x8b };</code>
     130   
     131    @param pin The input stream to read from which must have
     132      large enough buffer to be able to unread the bytes
     133    @param bCheck The byte values to use for comparison
     134    @return TRUE if the file matches the specified bytes,
     135      FALSE otherwise
     136    @throws IOException If there is an error reading or unreading
     137      the bytes
     138    @throws NullPointerException If pin or bCheck is null
     139    @throws IllegalArgumentException If bCheck is zero length
     140    @since 2.4
     141  */
     142  public static boolean checkMagicNumber(PushbackInputStream pin, byte[] bCheck)
     143    throws IOException
     144  {
     145    if (pin == null) throw new NullPointerException("pin");
     146    if (bCheck == null) throw new NullPointerException("bCheck");
     147    if (bCheck.length == 0) throw new IllegalArgumentException("bCheck has zero length");
     148    byte[] b = new byte[bCheck.length];
     149    pin.read(b);
     150    boolean match = Arrays.equals(b, bCheck);
     151    pin.unread(b);
     152    return match;
     153  }
     154 
     155  /**
    120156    Get the complete tree of subdirectories from a given directory.
    121157    @param directory The directory to start with
  • trunk/src/core/net/sf/basedb/util/zip/AbstractFileUnpacker.java

    r2981 r3510  
    198198      if (!getMimeTypes().contains(mimeType))
    199199      {
    200         int dotIndex = name.lastIndexOf('.');
    201         String extension = name.substring(dotIndex + 1);
    202         if (dotIndex ==  -1 || !getExtensions().contains(extension))
     200        for (String extension : getExtensions())
    203201        {
    204           message = "Unsupported file: " + f.getPath().toString();
     202          if (name.endsWith(extension)) return null;
    205203        }
     204        message = "Unsupported file: " + f.getPath().toString();
    206205      }
    207206    }
     
    277276    @return The packed file or null
    278277    @see #getZipFileParameter(String, String)
     278    @see #getCurrentFile(DbControl)
    279279  */
    280280  protected File getZipFile(DbControl dc)
     
    304304    if (label == null) label = "Save in";
    305305    if (description == null) description = "The directory where the unpacked files should be saved.";
    306     return new PluginParameter<String>(UNPACK_DIRECTORY, label, description , unpackType);
    307   }
     306    DbControl dc = sc.newDbControl();
     307    String defaultDir = null;
     308    try
     309    {
     310      Directory dir = getCurrentDirectory(dc);
     311      if (dir != null) defaultDir = dir.getPath().toString();
     312    }
     313    finally
     314    {
     315      if (dc != null) dc.close();
     316    }
     317    return new PluginParameter<String>(UNPACK_DIRECTORY, label, description , defaultDir, unpackType);
     318  }
     319 
     320  /**
     321    Get the current directory or null there is no current or it can't be loaded.
     322    This method will first try to load the current file and use the file's
     323    directory as the current. If there is no current file, the current directory
     324    is loaded from the session context.
     325    The current directory is only available in the configuration phase.
     326   
     327    @param dc A DbControl to use for database access
     328    @return A directory or null
     329    @since 2.4
     330    @see #getUnpackDirectory(DbControl)
     331  */
     332  protected Directory getCurrentDirectory(DbControl dc)
     333  {
     334    File currentFile = getCurrentFile(dc);
     335    if (currentFile != null) return currentFile.getDirectory();
     336    int directoryId = sc.getCurrentContext(Item.DIRECTORY).getId();
     337    if (directoryId != 0)
     338    {
     339      try
     340      {
     341        return Directory.getById(dc, directoryId);
     342      }
     343      catch (Throwable t)
     344      {}
     345    }
     346    return null;
     347  }
     348 
     349  /**
     350    Get the current file or null there is no current or it can't be loaded.
     351    The current file is only available in the configuration phase.
     352    @param dc A DbControl to use for database access
     353    @return A file or null
     354    @since 2.4
     355    @see #getZipFile(DbControl)
     356  */
     357  protected File getCurrentFile(DbControl dc)
     358  {
     359    int fileId = sc.getCurrentContext(Item.FILE).getId();
     360    if (fileId != 0)
     361    {
     362      try
     363      {
     364        return File.getById(dc, fileId);
     365      }
     366      catch (Throwable t)
     367      {}
     368    }
     369    return null;
     370  }
    308371 
    309372  /**
     
    314377    @return The directory or null
    315378    @see #getDirectoryParameter(String, String)
     379    @see #getCurrentDirectory(DbControl)
    316380  */
    317381  protected Directory getUnpackDirectory(DbControl dc)
  • trunk/src/test/set_classpath.bat

    r3476 r3510  
    8181REM Affymetrix Fusion SDK
    8282SET CP=%CP%;../../lib/dist/AffxFusion.jar
     83
     84REM TAR and BZIP
     85SET CP=%CP%;../../lib/dist/tar.jar
     86SET CP=%CP%;../../lib/dist/bzip2.jar
     87
  • trunk/src/test/set_classpath.sh

    r3476 r3510  
    8282# Affymetrix Fusion SDK
    8383CP=$CP:$LIB/AffxFusion.jar
     84
     85# TAR and BZIP
     86CP=$CP:$LIB/tar.jar
     87CP=$CP:$LIB/bzip2.jar
Note: See TracChangeset for help on using the changeset viewer.