jpl.mipl.phx.pgs
Class Utils

java.lang.Object
  extended by jpl.mipl.phx.pgs.Utils

public class Utils
extends Object

Some useful Phx utilities

Author:
ems

Constructor Summary
Utils()
           
 
Method Summary
static String chooseFiletype(org.jbpm.graph.exe.ExecutionContext executionContext)
          Choose one of the fei filetypes from the context, if none found return null
static void copyCompleteFile(String source, String target)
          Copy one file to another
static void copyFile(String source, String target)
          Copy file
static boolean deleteFile(String dir, String filename)
          Delete file
static String expandPhxUpfVars(String value, String varStart, String varEnd, org.jbpm.graph.exe.ExecutionContext executionContext)
          Expands all context variables in the given string.
static String getApid(String filename)
           
static String getBareFilename(String filename)
          Return the filename substring before version which is at character 26
static String getInstrument(String filename)
          Determine what instrument this edr is from S == "ssi" O == "om" R == "rac" A == "ra" F == "afm" // MECA-AFM P == "tecp" // MECA-TECP W == "wce" // MECA-WCE X == "misc" // MECA-misc else retrun "unk"
static String getInstrumentName(String filename)
          Returns full instrument name of an EDR S == "SURFACE STEREO IMAGER" R == "ROBOTIC ARM CAMERA"
static String getNewFilename(String filename, String replace, boolean pds)
          Create filenames for all the products Replace characters at index 5,6,7 (zero-based), with the string 'replace' This is used to generate filenames for the different product types
static String getNextVersion(String filename)
          Look at the file on disk and return the latest version.
static short getObservationType(String filename)
           
static String getProductLogName(String filename)
          Construct a log filename for the given product
static String getVersion(String filename)
           
static List initPhxLoggers(org.jbpm.graph.exe.ExecutionContext executionContext, String pdName, List phxLoggers)
          Set up phx logging and log files
static boolean isMosaic(String filename)
           
static boolean isStereo(String filename)
           
static void logPhx(List phxLoggers, Level level, String msg)
          Write log messages to all phxLoggers.
static void logPhx(List phxLoggers, Level level, String msg, Throwable t)
           
static void moveFile(String source, String target)
           
static String parseSol(String filename)
          Return SOL from the filename (3 chars, index 2-4)
static String parseType(String filename)
          Return type (epic) from the filename (1 char: index 1)
static void publishToFei(String filetype, String filename, String rename, UPF upf)
          Add the file to fei
static void publishToOss(String fullname, String oss_root, String rename)
          Copy the given file to the Oss.
static String[] updateOutfilename(String[] command, String next)
          Update the version number of the out file parameter in this command
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Utils

public Utils()
Method Detail

getNewFilename

public static String getNewFilename(String filename,
                                    String replace,
                                    boolean pds)
Create filenames for all the products Replace characters at index 5,6,7 (zero-based), with the string 'replace' This is used to generate filenames for the different product types

Parameters:
filename -
replace -
Returns:
new filename

getBareFilename

public static String getBareFilename(String filename)
Return the filename substring before version which is at character 26

Parameters:
filename - may include a path
Returns:

getVersion

public static String getVersion(String filename)
Parameters:
filename -
Returns:

getProductLogName

public static String getProductLogName(String filename)
                                throws Exception
Construct a log filename for the given product

Parameters:
filename - may include a path
Returns:
Throws:
Exception

getNextVersion

public static String getNextVersion(String filename)
                             throws PhxFilenameException
Look at the file on disk and return the latest version. Make sure you are using the lock server to keep other threads from attempting this at the same time. Version are 1,2,3,..,9,A,B,C,..,Z (After version 'Z' issue error)

Parameters:
filename - may include a path
Returns:
Throws:
PhxFilenameException

expandPhxUpfVars

public static String expandPhxUpfVars(String value,
                                      String varStart,
                                      String varEnd,
                                      org.jbpm.graph.exe.ExecutionContext executionContext)
                               throws PhxUpfException
Expands all context variables in the given string. For example,
  • "this string will not be changed"
  • Given that HOME has value /user/home in the context, then the string "%{HOME}" will be expanded to /user/home
  • %{HOME}/rrp/%{OS_DIR}/t.txt will be expended to /home/rrp/linux/t.txt, given that OS_DIR maps to linux.
  • file:%{HOME}jplmipl will be expanded to file:/usr/homejplmipl.
  • in the string "%{HOME/some/%{VICSYS}", "HOME/some/%{VICSYS" will be interpreted as a context variable and will thus have unpredictable results.
  • Parameters:
    value -
    Returns:
    Throws:
    PhxUpfException

    updateOutfilename

    public static String[] updateOutfilename(String[] command,
                                             String next)
                                      throws PhxUpfException
    Update the version number of the out file parameter in this command

    Parameters:
    command -
    next -
    Returns:
    Throws:
    PhxUpfException

    deleteFile

    public static boolean deleteFile(String dir,
                                     String filename)
                              throws Exception
    Delete file

    Parameters:
    dir -
    filename -
    Returns:
    true if deleted, false otherwise
    Throws:
    Exception

    copyFile

    public static void copyFile(String source,
                                String target)
                         throws Exception
    Copy file

    Parameters:
    source -
    target -
    Throws:
    Exception

    copyCompleteFile

    public static void copyCompleteFile(String source,
                                        String target)
                                 throws Exception
    Copy one file to another

    Parameters:
    source -
    target -
    Throws:
    Exception

    moveFile

    public static void moveFile(String source,
                                String target)
                         throws Exception
    Parameters:
    source -
    target -
    Throws:
    Exception

    parseType

    public static String parseType(String filename)
    Return type (epic) from the filename (1 char: index 1)

    Parameters:
    filename -
    Returns:

    parseSol

    public static String parseSol(String filename)
    Return SOL from the filename (3 chars, index 2-4)

    Parameters:
    filename -
    Returns:

    getInstrument

    public static String getInstrument(String filename)
    Determine what instrument this edr is from S == "ssi" O == "om" R == "rac" A == "ra" F == "afm" // MECA-AFM P == "tecp" // MECA-TECP W == "wce" // MECA-WCE X == "misc" // MECA-misc else retrun "unk"

    Parameters:
    filename -
    Returns:

    getInstrumentName

    public static String getInstrumentName(String filename)
    Returns full instrument name of an EDR S == "SURFACE STEREO IMAGER" R == "ROBOTIC ARM CAMERA"

    Parameters:
    filename -
    Returns:

    publishToOss

    public static void publishToOss(String fullname,
                                    String oss_root,
                                    String rename)
                             throws Throwable
    Copy the given file to the Oss. The structure of the Oss is hardcoded in this method, only the root is configurable

    Parameters:
    fullname - filename including path
    rename - filename only, if not null than file will have this name on the oss, otherwise keeps original name
    Throws:
    Throwable

    publishToFei

    public static void publishToFei(String filetype,
                                    String filename,
                                    String rename,
                                    UPF upf)
                             throws Throwable
    Add the file to fei

    Parameters:
    path -
    name -
    Throws:
    Throwable

    initPhxLoggers

    public static List initPhxLoggers(org.jbpm.graph.exe.ExecutionContext executionContext,
                                      String pdName,
                                      List phxLoggers)
                               throws Exception
    Set up phx logging and log files

    Throws:
    Exception

    chooseFiletype

    public static String chooseFiletype(org.jbpm.graph.exe.ExecutionContext executionContext)
                                 throws Exception
    Choose one of the fei filetypes from the context, if none found return null

    Parameters:
    executionContext -
    Returns:
    Throws:
    Exception

    getApid

    public static String getApid(String filename)
    Parameters:
    filename -
    Returns:

    isStereo

    public static boolean isStereo(String filename)
    Parameters:
    filename -
    Returns:

    isMosaic

    public static boolean isMosaic(String filename)
    Parameters:
    filename -
    Returns:

    getObservationType

    public static short getObservationType(String filename)
    Parameters:
    filename -
    Returns:

    logPhx

    public static void logPhx(List phxLoggers,
                              Level level,
                              String msg)
    Write log messages to all phxLoggers. (For stereo processing we want log messages to go to the Left sclk and the Right Sclk log file)

    Parameters:
    level -
    msg -

    logPhx

    public static void logPhx(List phxLoggers,
                              Level level,
                              String msg,
                              Throwable t)