goldengate.common.file
Class AbstractDir

java.lang.Object
  extended by goldengate.common.file.AbstractDir
All Implemented Interfaces:
DirInterface
Direct Known Subclasses:
FilesystemBasedDirImpl, PassthroughBasedDirImpl

public abstract class AbstractDir
extends Object
implements DirInterface

Abstract Main Implementation of Directory

Author:
Frederic Bregier

Field Summary
protected  String currentDir
          Current Directory
protected static Boolean ISUNIX
          Hack to say Windows or Unix (root like X:\ or /)
protected  OptsMLSxInterface optsMLSx
          Opts command for MLSx. (-1) means not supported, 0 supported but not active, 1 supported and active
protected static File[] roots
          Roots for Windows system
protected  SessionInterface session
          SessionInterface
 
Fields inherited from interface goldengate.common.file.DirInterface
SEPARATOR, SEPARATORCHAR
 
Constructor Summary
AbstractDir()
           
 
Method Summary
 boolean changeParentDirectory()
          Change for parent directory
 void checkIdentify()
          Check if the authentication is correct
 void clear()
          Set empty this FtpDir, mark it unReady.
protected  String consolidatePath(String path)
          Consolidate Path as relative or absolute path to an absolute path
protected  String getCanonicalPath(File dir)
          Construct the CanonicalPath without taking into account symbolic link
protected  File getCorrespondingRoot(File file)
           
 OptsMLSxInterface getOptsMLSx()
           
 String getPwd()
           
 SessionInterface getSession()
           
 void initAfterIdentification()
          Init DirInterface after authentication is done
protected static void initWindowsSupport()
          Init Windows Support
 boolean isAbsoluteWindows(String path)
           
static String normalizePath(String path)
          Normalize Path to Internal unique representation
 FileInterface setFile(String path, boolean append)
          Set a path as the current FileInterface
protected  String validatePath(File dir)
          Same as validatePath but from a FileInterface
 String validatePath(String path)
          Construct and Check if the given path is valid from business point of view (see AuthInterface)
protected abstract  List<String> wildcardFiles(String pathWithWildcard)
          Finds all files matching a wildcard expression (based on '?'
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface goldengate.common.file.DirInterface
canRead, canWrite, changeDirectory, changeDirectoryNotChecked, exists, fileFull, getCRC, getFreeSpace, getMD5, getModificationTime, getSHA1, isDirectory, isFile, list, listFull, mkdir, newFile, rmdir, setUniqueFile
 

Field Detail

currentDir

protected String currentDir
Current Directory


session

protected SessionInterface session
SessionInterface


optsMLSx

protected OptsMLSxInterface optsMLSx
Opts command for MLSx. (-1) means not supported, 0 supported but not active, 1 supported and active


ISUNIX

protected static Boolean ISUNIX
Hack to say Windows or Unix (root like X:\ or /)


roots

protected static File[] roots
Roots for Windows system

Constructor Detail

AbstractDir

public AbstractDir()
Method Detail

initWindowsSupport

protected static void initWindowsSupport()
Init Windows Support


getCorrespondingRoot

protected File getCorrespondingRoot(File file)
Parameters:
file -
Returns:
The corresponding Root file

normalizePath

public static String normalizePath(String path)
Normalize Path to Internal unique representation

Parameters:
path -
Returns:
the normalized path

getSession

public SessionInterface getSession()
Specified by:
getSession in interface DirInterface
Returns:
the SessionInterface

validatePath

public String validatePath(String path)
                    throws CommandAbstractException
Description copied from interface: DirInterface
Construct and Check if the given path is valid from business point of view (see AuthInterface)

Specified by:
validatePath in interface DirInterface
Returns:
the construct and validated path (could be different than the one given as argument, example: '..' are removed)
Throws:
CommandAbstractException

isAbsoluteWindows

public boolean isAbsoluteWindows(String path)
Parameters:
path -
Returns:
True if the given Path is an absolute one under Windows System

consolidatePath

protected String consolidatePath(String path)
                          throws CommandAbstractException
Consolidate Path as relative or absolute path to an absolute path

Parameters:
path -
Returns:
the consolidated path
Throws:
CommandAbstractException

getCanonicalPath

protected String getCanonicalPath(File dir)
Construct the CanonicalPath without taking into account symbolic link

Parameters:
dir -
Returns:
the canonicalPath

validatePath

protected String validatePath(File dir)
                       throws CommandAbstractException
Same as validatePath but from a FileInterface

Parameters:
dir -
Returns:
the construct and validated path (could be different than the one given as argument, example: '..' are removed)
Throws:
CommandAbstractException

wildcardFiles

protected abstract List<String> wildcardFiles(String pathWithWildcard)
                                       throws CommandAbstractException
Finds all files matching a wildcard expression (based on '?', '~' or '*').

Parameters:
pathWithWildcard - The wildcard expression with a business path.
Returns:
List of String as relative paths matching the wildcard expression. Those files are tested as valid from business point of view. If Wildcard support is not active, if the path contains any wildcards, it will throw an error.
Throws:
CommandAbstractException

getPwd

public String getPwd()
              throws CommandAbstractException
Specified by:
getPwd in interface DirInterface
Returns:
the current PWD
Throws:
CommandAbstractException

changeParentDirectory

public boolean changeParentDirectory()
                              throws CommandAbstractException
Description copied from interface: DirInterface
Change for parent directory

Specified by:
changeParentDirectory in interface DirInterface
Returns:
True if the change is valid
Throws:
CommandAbstractException

setFile

public FileInterface setFile(String path,
                             boolean append)
                      throws CommandAbstractException
Description copied from interface: DirInterface
Set a path as the current FileInterface

Specified by:
setFile in interface DirInterface
append - True if this file is supposed to be in append mode (APPE), False in any other cases
Returns:
the FileInterface if it is correctly initiate
Throws:
CommandAbstractException

checkIdentify

public void checkIdentify()
                   throws Reply530Exception
Description copied from interface: DirInterface
Check if the authentication is correct

Specified by:
checkIdentify in interface DirInterface
Throws:
Reply530Exception

clear

public void clear()
Description copied from interface: DirInterface
Set empty this FtpDir, mark it unReady.

Specified by:
clear in interface DirInterface

initAfterIdentification

public void initAfterIdentification()
Description copied from interface: DirInterface
Init DirInterface after authentication is done

Specified by:
initAfterIdentification in interface DirInterface

getOptsMLSx

public OptsMLSxInterface getOptsMLSx()
Specified by:
getOptsMLSx in interface DirInterface
Returns:
the current value of Options for MLSx


Copyright © 2009-2012 Frederic Bregier. All Rights Reserved.