com.arsdigita.acs.acsAdmin
Class ApmFileUtilities

java.lang.Object
  |
  +--com.arsdigita.acs.acsAdmin.ApmFileUtilities

public class ApmFileUtilities
extends java.lang.Object

Since:
ACS 4.0

Field Summary
static java.lang.String cvsId
           
protected static org.apache.oro.text.perl.Perl5Util re
           
 
Constructor Summary
ApmFileUtilities()
           
 
Method Summary
static java.math.BigDecimal addFile(java.math.BigDecimal version_id, java.lang.String path, java.lang.String file_type)
          Adds one file into the specified version.
static java.math.BigDecimal addFile(java.math.BigDecimal version_id, java.lang.String path, java.lang.String file_type, java.math.BigDecimal file_id)
           
static java.lang.String getFileExtension(java.lang.String filename)
          Gets the extension of a filename.
static java.util.Enumeration getVersionFileList(java.lang.String type, java.math.BigDecimal versionId)
          Returns a list of files of a given type (or all files, if type is not specified) in a version.
static java.lang.String guessFileType(java.lang.String package_key, java.lang.String path)
          Guesses and returns the file type key corresponding to a particular path (or an empty string if none is known).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cvsId

public static final java.lang.String cvsId

re

protected static final org.apache.oro.text.perl.Perl5Util re
Constructor Detail

ApmFileUtilities

public ApmFileUtilities()
Method Detail

getVersionFileList

public static java.util.Enumeration getVersionFileList(java.lang.String type,
                                                       java.math.BigDecimal versionId)
                                                throws java.sql.SQLException
Returns a list of files of a given type (or all files, if type is not specified) in a version.
Parameters:
type - Optionally specifiy what type of files to check, for instance "java_procs"
version_id - The version to retrieve the file list from.

getFileExtension

public static java.lang.String getFileExtension(java.lang.String filename)
Gets the extension of a filename.

guessFileType

public static java.lang.String guessFileType(java.lang.String package_key,
                                             java.lang.String path)
Guesses and returns the file type key corresponding to a particular path (or an empty string if none is known). $path should be relative to the package directory (e.g., www/index.tcl for /packages/bboard/admin-www/index.tcl. We use the following rules:
  1. Files with extension .sql are considered data-model files, or if any path contains the substring upgrade, data-model upgrade files.
  2. Files with extension .sqlj are considered sqlj_code files.
  3. Files with extension .info are considered package specification files.
  4. Files with a path component named doc are considered documentation files.
  5. Files with extension .pl or .sh or which have a path component named bin, are considered shell-executable files.
  6. Files with a path component named templates are considered template files.
  7. Files with extension .html or .adp, in the top level of the package, are considered documentation files.
  8. Files with a path component named www or admin-www are considered content-page files.
  9. Files ending in -procs.tcl or -init.tcl are considered Tcl procedure or Tcl initialization files, respectively.
TODO: Figure out what types should be added for Java. Rules are applied in this order (stopping with the first match).

addFile

public static java.math.BigDecimal addFile(java.math.BigDecimal version_id,
                                           java.lang.String path,
                                           java.lang.String file_type)
                                    throws java.sql.SQLException
Adds one file into the specified version.
Returns:
the id of the file.

addFile

public static java.math.BigDecimal addFile(java.math.BigDecimal version_id,
                                           java.lang.String path,
                                           java.lang.String file_type,
                                           java.math.BigDecimal file_id)
                                    throws java.sql.SQLException