Sonic Management API

com.sonicsw.mx.config.util
Class SonicFSFileSystem

java.lang.Object
  extended by com.sonicsw.mx.config.util.SonicFSFileSystem

public class SonicFSFileSystem
extends java.lang.Object

This class provides an API for accessing files stored in the DS using sonicfs://


Field Summary
static java.util.Comparator COMPARATOR
           
static java.lang.String SCHEME
           
static java.lang.String separator
           
static char separatorChar
           
 
Constructor Summary
SonicFSFileSystem(IDirectoryFileSystemService dfs, java.lang.String user)
          Note: This constructor is for internal use only.
SonicFSFileSystem(JMSConnectorClient connector, java.lang.String domain, java.lang.String user)
          Constuctor for the SonicFSFileSystem.
 
Method Summary
 void close()
          Close the DS if local to this JVM
 SonicFSFile createDirectory(SonicFSFile baseFolder, java.lang.String newSubFolderName)
          Create a directory under the specified subfolder
 SonicFSFile createDirectory(java.lang.String path)
          Create the specified directory.
 void createDirectoryPath(java.lang.String path)
          Create the specified directory.
 void createFile(java.lang.String path, byte[] content)
          Create a file in sonicfs with the specified file name and the specified content.
 void createFile(java.lang.String path, java.io.File file)
          Create a file in sonicfs with the specified file name and the specified content.
 void createFile(java.lang.String path, java.io.InputStream stream, int size)
          Create a file in sonicfs with the specified file name and the specified content.
 void createFile(java.lang.String path, java.lang.String content)
          Create a file in sonicfs with the specified file name and the specified content.
 void deleteDirectory(java.lang.String path)
          Delete the specified directory.
 void deleteDirectoryPath(java.lang.String path)
          Recursively delete all files and folders under the specified path including the path folder itself.
 void deleteFile(java.lang.String path)
          Delete the specified file.
 void deleteFiles(java.lang.String path)
           
 boolean exists(java.lang.String path)
          Check to see if a path is valid in the DS
 java.lang.String getContent(java.lang.String path)
          Get the content of the specified file returning the content as a String
 byte[] getContentBytes(java.lang.String path)
          Get the content of the specified file returning the content as a byte[]
 SonicFSFile getDetails(java.lang.String path)
          Get detailed information about the specified file or folder
 SonicFSFile[] getDetails(java.lang.String[] path)
          Get detailed information for a set of specified DS locations
 IDirectoryFileSystemService getDirectoryService()
          Get the directory service being used for this SonicFSFileSystem
 SonicFSFile getFileDetails(java.lang.String path)
          Get detailed information about the specified file.
 java.lang.String getRoot()
          Get the root folder as a String.
 SonicFSFile getRootFile()
          Get the root folder as a SonicFSFile object.
 java.lang.String getUser()
          Get the user name associated with this SonicFSFileSystem
 void importFiles(java.lang.String fsPath, java.lang.String dsPath)
           
 boolean isDirectory(java.lang.String path)
          Check to see if a path is a valid directory in the DS
 boolean isFile(java.lang.String path)
          Check to see if a path is a valid file in the DS
 java.lang.String[] list(java.lang.String path)
          List the contents of the DS at the specified path.
 java.lang.String[] list(java.lang.String path, boolean listSubFolders)
          List the contents of the DS at the specified path.
 SonicFSFile[] listAllFolderDetails()
          Obtain a listing of the DS contents at the specified location returning the information as an arrange of SonicFSFile objects.
 java.lang.String[] listAllFolders()
          Obtain a recursive listing of all folders within the DS
 SonicFSFile[] listDetails(java.lang.String path)
          Obtain a listing of the DS contents at the specified location returning the information as an array of SonicFSFile objects.
 SonicFSFile[] listFolderDetails(java.lang.String path)
          Obtain a listing of the DS contents at the specified location returning the information as an arrange of SonicFSFile objects.
 java.lang.String[] listFolders(java.lang.String path)
          List the contents of the DS at the specified path.
static void main(java.lang.String[] args)
           
 SonicFSFile rename(SonicFSFile oldFile, java.lang.String newName)
          Rename either a folder or a file where the original object is identied by the specified SonicFSFile object and the new name is specified as a String.
 void rename(java.lang.String oldPath, java.lang.String newPath)
          Rename either a folder or a file from oldPath to newPath
 void updateFile(java.lang.String path, byte[] content, boolean create)
           
 void updateFile(java.lang.String path, java.io.File file, boolean create)
          Update the contents of the specified file where the content is stored in the specified file.
 void updateFile(java.lang.String path, java.io.InputStream stream, boolean create, int size)
          Update the contents of the specified file using the given byte[] contents.
 void updateFile(java.lang.String path, java.lang.String content, boolean create)
          Update the contents of the specified file using the given string contents.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COMPARATOR

public static final java.util.Comparator COMPARATOR

SCHEME

public static final java.lang.String SCHEME
See Also:
Constant Field Values

separator

public static final java.lang.String separator
See Also:
Constant Field Values

separatorChar

public static final char separatorChar
See Also:
Constant Field Values
Constructor Detail

SonicFSFileSystem

public SonicFSFileSystem(IDirectoryFileSystemService dfs,
                         java.lang.String user)
Note: This constructor is for internal use only. Constuctor for the SonicFSFileSystem. This object will provide access to the specified directory service

Parameters:
dfs - The Directory Service being accessed
user - The name of the user (will be written into sonicfs elements)

SonicFSFileSystem

public SonicFSFileSystem(JMSConnectorClient connector,
                         java.lang.String domain,
                         java.lang.String user)
                  throws SonicFSException
Constuctor for the SonicFSFileSystem. This object will provide access to the specified directory service

Parameters:
connector - The JMS Connection to use for the DS connection
domain - The name of the DS domain
user - The name of the user (will be written into sonicfs elements)
Throws:
SonicFSException
Method Detail

close

public void close()
           throws SonicFSException
Close the DS if local to this JVM

Throws:
SonicFSException

createDirectory

public SonicFSFile createDirectory(SonicFSFile baseFolder,
                                   java.lang.String newSubFolderName)
                            throws SonicFSException
Create a directory under the specified subfolder

Parameters:
baseFolder -
newSubFolderName -
Returns:
Throws:
SonicFSException

createDirectory

public SonicFSFile createDirectory(java.lang.String path)
                            throws SonicFSException
Create the specified directory. The parent directory must already exist

Parameters:
path -
Throws:
SonicFSException

createDirectoryPath

public void createDirectoryPath(java.lang.String path)
                         throws SonicFSException
Create the specified directory. This method will create all directories in the path.

Parameters:
path -
Throws:
SonicFSException

createFile

public void createFile(java.lang.String path,
                       byte[] content)
                throws SonicFSException
Create a file in sonicfs with the specified file name and the specified content. If the file already exists, or a folder or other configuration already exists then an exception is thrown.

Parameters:
path - The logical name of the file in the DS
content - The contents as a byte array
Throws:
SonicFSException

createFile

public void createFile(java.lang.String path,
                       java.io.File file)
                throws SonicFSException
Create a file in sonicfs with the specified file name and the specified content. If the file already exists, or a folder or other configuration already exists then an exception is thrown.

Parameters:
path - The logical name of the filel in the DS
file - The disk file with the contents for the DS file. An InputStream will be created from this file and the contents read to create the new DS file.
Throws:
SonicFSException - If there is a problem reading the file on disk

createFile

public void createFile(java.lang.String path,
                       java.io.InputStream stream,
                       int size)
                throws SonicFSException
Create a file in sonicfs with the specified file name and the specified content. If the file already exists, or a folder or other configuration already exists then an exception is thrown.

Parameters:
path - The logical name of the file element in the DS
stream - The input stream for the contents of the file
size - The size of the entire contents of the file.
Throws:
SonicFSException

createFile

public void createFile(java.lang.String path,
                       java.lang.String content)
                throws SonicFSException
Create a file in sonicfs with the specified file name and the specified content. If the file already exists, or a folder or other configuration already exists then an exception is thrown.

Parameters:
path -
content -
Throws:
SonicFSException

deleteDirectory

public void deleteDirectory(java.lang.String path)
                     throws SonicFSException
Delete the specified directory. This method will fail if the directory isn't empty.

Parameters:
path -
Throws:
SonicFSException

deleteDirectoryPath

public void deleteDirectoryPath(java.lang.String path)
                         throws SonicFSException
Recursively delete all files and folders under the specified path including the path folder itself. Note this method will fail if a folder contains a configuration.

Parameters:
path -
Throws:
SonicFSException

deleteFile

public void deleteFile(java.lang.String path)
                throws SonicFSException
Delete the specified file. An exception is thrown if this path specifies a folder or a non-file configuration in the DS.

Parameters:
path -
Throws:
SonicFSException

deleteFiles

public void deleteFiles(java.lang.String path)
                 throws SonicFSException
Throws:
SonicFSException

exists

public boolean exists(java.lang.String path)
Check to see if a path is valid in the DS

Parameters:
path -
Returns:

getContent

public java.lang.String getContent(java.lang.String path)
                            throws SonicFSException
Get the content of the specified file returning the content as a String

Parameters:
path -
Returns:
Throws:
SonicFSException

getContentBytes

public byte[] getContentBytes(java.lang.String path)
                       throws SonicFSException
Get the content of the specified file returning the content as a byte[]

Parameters:
path -
Returns:
Throws:
SonicFSException

getDetails

public SonicFSFile getDetails(java.lang.String path)
                       throws SonicFSException
Get detailed information about the specified file or folder

Parameters:
path -
Returns:
Throws:
SonicFSException

getDetails

public SonicFSFile[] getDetails(java.lang.String[] path)
                         throws SonicFSException
Get detailed information for a set of specified DS locations

Parameters:
path -
Returns:
Throws:
SonicFSException

getDirectoryService

public IDirectoryFileSystemService getDirectoryService()
Get the directory service being used for this SonicFSFileSystem

Returns:
the Directory Service reference

getFileDetails

public SonicFSFile getFileDetails(java.lang.String path)
                           throws SonicFSException
Get detailed information about the specified file. If the path doesn't reference a valid file then an exception is thrown.

Parameters:
path -
Returns:
Throws:
SonicFSException

getRoot

public java.lang.String getRoot()
Get the root folder as a String. For SonicFSFileSystem this is always '/'

Returns:
the root folder name

getRootFile

public SonicFSFile getRootFile()
Get the root folder as a SonicFSFile object.

Returns:
the root folder

getUser

public java.lang.String getUser()
Get the user name associated with this SonicFSFileSystem

Returns:
the user as a String

importFiles

public void importFiles(java.lang.String fsPath,
                        java.lang.String dsPath)
                 throws SonicFSException
Throws:
SonicFSException

isDirectory

public boolean isDirectory(java.lang.String path)
Check to see if a path is a valid directory in the DS

Parameters:
path -
Returns:

isFile

public boolean isFile(java.lang.String path)
Check to see if a path is a valid file in the DS

Parameters:
path -
Returns:

list

public java.lang.String[] list(java.lang.String path)
                        throws SonicFSException
List the contents of the DS at the specified path. The listing will return all files at the specified path and any subfolders (returned as /

Parameters:
path - the DS path to list
Returns:
A String array of the contents of the path.
Throws:
SonicFSException

list

public java.lang.String[] list(java.lang.String path,
                               boolean listSubFolders)
                        throws SonicFSException
List the contents of the DS at the specified path. The listing will return all files at the specified path and any subfolders (returned as /

Parameters:
path - the DS path to list
listSubFolders - if 'true', lists subfolders recursively
Returns:
A String array of the contents of the path.
Throws:
SonicFSException

listAllFolderDetails

public SonicFSFile[] listAllFolderDetails()
                                   throws SonicFSException
Obtain a listing of the DS contents at the specified location returning the information as an arrange of SonicFSFile objects. It includes details for the root folder.

Returns:
Throws:
SonicFSException

listAllFolders

public java.lang.String[] listAllFolders()
                                  throws SonicFSException
Obtain a recursive listing of all folders within the DS

Returns:
Throws:
SonicFSException

listDetails

public SonicFSFile[] listDetails(java.lang.String path)
                          throws SonicFSException
Obtain a listing of the DS contents at the specified location returning the information as an array of SonicFSFile objects.

Parameters:
path - the DS path to list
Returns:
An array of SonicFSFile objects for the contents of the path.
Throws:
SonicFSException

listFolderDetails

public SonicFSFile[] listFolderDetails(java.lang.String path)
                                throws SonicFSException
Obtain a listing of the DS contents at the specified location returning the information as an arrange of SonicFSFile objects.

Parameters:
path -
Returns:
Throws:
SonicFSException

listFolders

public java.lang.String[] listFolders(java.lang.String path)
                               throws SonicFSException
List the contents of the DS at the specified path. The listing will return all the immediate subfolders (returned as /)

Parameters:
path -
Returns:
Throws:
SonicFSException

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Throws:
java.lang.Exception

rename

public SonicFSFile rename(SonicFSFile oldFile,
                          java.lang.String newName)
                   throws SonicFSException
Rename either a folder or a file where the original object is identied by the specified SonicFSFile object and the new name is specified as a String. This method then returns the new SonicFSFile object for the renamed object

Parameters:
oldFile -
newName -
Returns:
Throws:
SonicFSException

rename

public void rename(java.lang.String oldPath,
                   java.lang.String newPath)
            throws SonicFSException
Rename either a folder or a file from oldPath to newPath

Parameters:
oldPath -
newPath -
Throws:
SonicFSException

updateFile

public void updateFile(java.lang.String path,
                       byte[] content,
                       boolean create)
                throws SonicFSException
Throws:
SonicFSException

updateFile

public void updateFile(java.lang.String path,
                       java.io.File file,
                       boolean create)
                throws SonicFSException
Update the contents of the specified file where the content is stored in the specified file. If the file doesn't already exist in the DS and create == true then the file will be created. If the file doesn't already exist in the DS and create == false then an exception is thrown.

Parameters:
path - The logical name of the file in the DS
file - The disk file where the contents of the updated DS file are read from
create - true if the file should be created if it's not already in the DS
Throws:
SonicFSException

updateFile

public void updateFile(java.lang.String path,
                       java.io.InputStream stream,
                       boolean create,
                       int size)
                throws SonicFSException
Update the contents of the specified file using the given byte[] contents. If the file doesn't already exist in the DS and create == true then the file will be created. If the file doesn't already exist in the DS and create == false then an exception is thrown.

Parameters:
path -
content -
create -
Throws:
SonicFSException

updateFile

public void updateFile(java.lang.String path,
                       java.lang.String content,
                       boolean create)
                throws SonicFSException
Update the contents of the specified file using the given string contents. If the file doesn't already exist in the DS and create == true then the file will be created. If the file doesn't already exist in the DS and create == false then an exception is thrown.

Parameters:
path -
content -
create -
Throws:
SonicFSException

Sonic Management API

Copyright © 2001-2010 Progress Software Corporation. All Rights Reserved.
HTML formatted on 16-Sep-2010.