public class DBDiskDriver extends Object implements DiskInterface, DiskSizeInterface, DiskVolumeInterface, NTFSStreamsInterface, FileLockingInterface, FileIdInterface, SymbolicLinkInterface, OpLockInterface, SecurityDescriptorInterface
Modifier and Type | Field and Description |
---|---|
static String |
DBStreamList |
static int |
DefaultNFSDirMode |
static int |
DefaultNFSFileMode |
static int |
MaxFileNameLen |
static long |
MaxTimestampValue |
Constructor and Description |
---|
DBDiskDriver() |
Modifier and Type | Method and Description |
---|---|
String |
buildPathForFileId(SrvSession sess,
TreeConnection tree,
int dirid,
int fileid)
Convert a file id to a share relative path
|
void |
closeFile(SrvSession sess,
TreeConnection tree,
NetworkFile file)
Close the specified file
|
protected void |
closeStream(SrvSession sess,
TreeConnection tree,
NetworkFile stream)
Close an NTFS stream
|
DeviceContext |
createContext(String shareName,
org.springframework.extensions.config.ConfigElement args)
Parse/validate the parameter string and create a device context for this share
|
void |
createDirectory(SrvSession sess,
TreeConnection tree,
FileOpenParams params)
Create a new directory
|
NetworkFile |
createFile(SrvSession sess,
TreeConnection tree,
FileOpenParams params)
Create a new file entry
|
protected NetworkFile |
createStream(SrvSession sess,
TreeConnection tree,
FileOpenParams params,
FileState parent,
DBDeviceContext dbCtx)
Create a new stream with the specified parent file
|
void |
deleteDirectory(SrvSession sess,
TreeConnection tree,
String dir)
Delete a directory
|
void |
deleteFile(SrvSession sess,
TreeConnection tree,
String name)
Delete a file
|
protected void |
deleteStream(SrvSession sess,
TreeConnection tree,
String name)
Delete a stream within a file
|
int |
fileExists(SrvSession sess,
TreeConnection tree,
String name)
Check if the specified file exists, and it is a file.
|
protected int |
findParentDirectoryId(DBDeviceContext ctx,
String path,
boolean filePath)
Find the directory id for the parent directory in the specified path
|
protected int[] |
findParentDirectoryIdList(DBDeviceContext ctx,
String path,
boolean filePath)
Find the directory ids for the specified path list
|
void |
flushFile(SrvSession sess,
TreeConnection tree,
NetworkFile file)
Flush buffered data for the specified file
|
void |
getDiskInformation(DiskDeviceContext ctx,
SrvDiskInfo info)
Return disk information about a shared filesystem
|
protected DBFileInfo |
getFileDetails(String path,
DBDeviceContext dbCtx)
Get the file id for a file
|
protected DBFileInfo |
getFileDetails(String path,
DBDeviceContext dbCtx,
FileState fstate)
Get the file id for a file
|
protected int |
getFileId(String path,
String name,
int dirId,
DBDeviceContext dbCtx)
Get the file id for a file
|
DBFileInfo |
getFileInfo(String path,
int dirId,
int fid,
DBDeviceContext dbCtx)
Return file information about the specified file, using the internal file id
|
FileInfo |
getFileInformation(SrvSession sess,
TreeConnection tree,
String name)
Return file information about the specified file
|
protected FileState |
getFileState(String path,
DBDeviceContext ctx,
boolean create)
Get the cached file state for the specified path
|
LockManager |
getLockManager(SrvSession sess,
TreeConnection tree)
Return the lock manager implementation
|
OpLockManager |
getOpLockManager(SrvSession sess,
TreeConnection tree)
Return the oplock manager implementation
|
protected void |
getRetentionDetailsForState(DBDeviceContext dbCtx,
FileState fstate)
Load the retention details for a file state, if enabled
|
int |
getSecurityDescriptorLength(SrvSession sess,
TreeConnection tree,
NetworkFile netFile)
Return the security descriptor length for the specified file
|
DBFileInfo |
getStreamInfo(FileState parent,
String[] paths,
DBDeviceContext dbCtx)
Get the details for a file stream
|
StreamInfo |
getStreamInformation(SrvSession sess,
TreeConnection tree,
StreamInfo streamInfo)
Get the stream information for the specified file stream
|
StreamInfoList |
getStreamList(SrvSession sess,
TreeConnection tree,
String fileName)
Return the list of available streams for the specified file
|
VolumeInfo |
getVolumeInformation(DiskDeviceContext ctx)
Return the volume information
|
protected boolean |
hasDebug()
Check if general debug output is enabled
|
boolean |
hasStreamsEnabled(SrvSession sess,
TreeConnection tree)
Determine if NTFS streams support is enabled.
|
boolean |
hasSymbolicLinksEnabled(SrvSession sess,
TreeConnection tree)
Determine if symbolic links are enabled
|
boolean |
isOpLocksEnabled(SrvSession sess,
TreeConnection tree)
Enable/disable oplock support
|
boolean |
isReadOnly(SrvSession sess,
DeviceContext ctx)
Determine if the disk device is read-only.
|
SecurityDescriptor |
loadSecurityDescriptor(SrvSession sess,
TreeConnection tree,
NetworkFile netFile)
Load a security descriptor for the specified file
|
protected StreamInfoList |
loadStreamList(FileState fstate,
DBFileInfo finfo,
DBDeviceContext dbCtx,
boolean dbLoad)
Load the stream list for the specified file
|
NetworkFile |
openFile(SrvSession sess,
TreeConnection tree,
FileOpenParams params)
Open a file
|
protected NetworkFile |
openStream(SrvSession sess,
TreeConnection tree,
FileOpenParams params,
FileState parent,
DBDeviceContext dbCtx)
Open an existing stream with the specified parent file
|
int |
readFile(SrvSession sess,
TreeConnection tree,
NetworkFile file,
byte[] buf,
int bufPos,
int siz,
long pos)
Read a block of data from a file
|
String |
readSymbolicLink(SrvSession sess,
TreeConnection tree,
String path)
Read the link data for a symbolic link
|
void |
renameFile(SrvSession sess,
TreeConnection tree,
String oldName,
String newName)
Rename a file
|
void |
renameStream(SrvSession sess,
TreeConnection tree,
String oldName,
String newName,
boolean overWrite)
Rename a stream
|
void |
saveSecurityDescriptor(SrvSession sess,
TreeConnection tree,
NetworkFile netFile,
SecurityDescriptor secDesc)
Save the security descriptor for the specified file
|
long |
seekFile(SrvSession sess,
TreeConnection tree,
NetworkFile file,
long pos,
int typ)
Seek to the specified point within a file
|
void |
setFileInformation(SrvSession sess,
TreeConnection tree,
String name,
FileInfo info)
Set file information
|
SearchContext |
startSearch(SrvSession sess,
TreeConnection tree,
String searchPath,
int attrib)
Start a search of the file system
|
void |
treeClosed(SrvSession sess,
TreeConnection tree)
Connection closed to this device
|
void |
treeOpened(SrvSession sess,
TreeConnection tree)
Connection opened to this disk device
|
void |
truncateFile(SrvSession sess,
TreeConnection tree,
NetworkFile file,
long siz)
Truncate a file to the specified size
|
int |
writeFile(SrvSession sess,
TreeConnection tree,
NetworkFile file,
byte[] buf,
int bufoff,
int siz,
long fileoff)
Write a block of data to a file
|
public static final String DBStreamList
public static final int DefaultNFSFileMode
public static final int DefaultNFSDirMode
public static final int MaxFileNameLen
public static final long MaxTimestampValue
public void closeFile(SrvSession sess, TreeConnection tree, NetworkFile file) throws IOException
closeFile
in interface DiskInterface
sess
- Session detailstree
- Tree connectionfile
- Network file detailsIOException
public void createDirectory(SrvSession sess, TreeConnection tree, FileOpenParams params) throws IOException
createDirectory
in interface DiskInterface
sess
- Session detailstree
- Tree connectionparams
- Directory create parametersIOException
public NetworkFile createFile(SrvSession sess, TreeConnection tree, FileOpenParams params) throws IOException
createFile
in interface DiskInterface
sess
- SrvSessiontree
- TreeConnectionparams
- FileOpenParamsIOException
- If an error occurs.public void deleteDirectory(SrvSession sess, TreeConnection tree, String dir) throws IOException
deleteDirectory
in interface DiskInterface
sess
- Session detailstree
- Tree connectiondir
- Path of directory to deleteIOException
public void deleteFile(SrvSession sess, TreeConnection tree, String name) throws IOException
deleteFile
in interface DiskInterface
sess
- Session detailstree
- Tree connectionname
- Name of file to deleteIOException
public int fileExists(SrvSession sess, TreeConnection tree, String name)
fileExists
in interface DiskInterface
sess
- Session detailstree
- Tree connectionname
- File nameFileStatus
public void flushFile(SrvSession sess, TreeConnection tree, NetworkFile file) throws IOException
flushFile
in interface DiskInterface
sess
- Session detailstree
- Tree connectionfile
- Network fileIOException
public FileInfo getFileInformation(SrvSession sess, TreeConnection tree, String name) throws IOException
getFileInformation
in interface DiskInterface
sess
- Session detailstree
- Tree connectionname
- File nameIOException
public boolean isReadOnly(SrvSession sess, DeviceContext ctx) throws IOException
isReadOnly
in interface DiskInterface
sess
- Session detailsctx
- Device contextIOException
- If an error occurs.public NetworkFile openFile(SrvSession sess, TreeConnection tree, FileOpenParams params) throws IOException
openFile
in interface DiskInterface
sess
- Session detailstree
- Tree connectionparams
- File open parametersIOException
public int readFile(SrvSession sess, TreeConnection tree, NetworkFile file, byte[] buf, int bufPos, int siz, long pos) throws IOException
readFile
in interface DiskInterface
sess
- Session detailstree
- Tree connectionfile
- Network filebuf
- Buffer to return data tobufPos
- Starting position in the return buffersiz
- Maximum size of data to returnpos
- File offset to read dataIOException
public void renameFile(SrvSession sess, TreeConnection tree, String oldName, String newName) throws IOException
renameFile
in interface DiskInterface
sess
- Session detailstree
- Tree connectionoldName
- Existing file namenewName
- New file nameIOException
public long seekFile(SrvSession sess, TreeConnection tree, NetworkFile file, long pos, int typ) throws IOException
seekFile
in interface DiskInterface
sess
- Session detailstree
- Tree connectionfile
- Network filepos
- New file positiontyp
- Seek typeIOException
public void setFileInformation(SrvSession sess, TreeConnection tree, String name, FileInfo info) throws IOException
setFileInformation
in interface DiskInterface
sess
- Session detailstree
- Tree connectionname
- File nameinfo
- File information to be setIOException
public SearchContext startSearch(SrvSession sess, TreeConnection tree, String searchPath, int attrib) throws FileNotFoundException
startSearch
in interface DiskInterface
sess
- SrvSessiontree
- TreeConnectionsearchPath
- Stringattrib
- intFileNotFoundException
public void truncateFile(SrvSession sess, TreeConnection tree, NetworkFile file, long siz) throws IOException
truncateFile
in interface DiskInterface
sess
- Server sessiontree
- Tree connectionfile
- Network file detailssiz
- New file lengthIOException
- The exception description.public int writeFile(SrvSession sess, TreeConnection tree, NetworkFile file, byte[] buf, int bufoff, int siz, long fileoff) throws IOException
writeFile
in interface DiskInterface
sess
- Session detailstree
- Tree connectionfile
- Network filebuf
- Data to be writtenbufoff
- Offset of data within the buffersiz
- Number of bytes to be writtenfileoff
- Offset within the file to start writing the dataIOException
- The exception description.public DeviceContext createContext(String shareName, org.springframework.extensions.config.ConfigElement args) throws DeviceContextException
createContext
in interface DeviceInterface
shareName
- Stringargs
- ConfigElementDeviceContextException
protected final DBFileInfo getFileDetails(String path, DBDeviceContext dbCtx)
path
- StringdbCtx
- DBDeviceContextprotected final DBFileInfo getFileDetails(String path, DBDeviceContext dbCtx, FileState fstate)
path
- StringdbCtx
- DBDeviceContextfstate
- FileStateprotected final int getFileId(String path, String name, int dirId, DBDeviceContext dbCtx)
path
- Stringname
- StringdirId
- intdbCtx
- DBDeviceContextprotected final void getRetentionDetailsForState(DBDeviceContext dbCtx, FileState fstate) throws DBException
dbCtx
- DBDeviceContextfstate
- FileStateDBException
protected final int findParentDirectoryId(DBDeviceContext ctx, String path, boolean filePath)
ctx
- DBDeviceContextpath
- StringfilePath
- booleanprotected final int[] findParentDirectoryIdList(DBDeviceContext ctx, String path, boolean filePath)
ctx
- DBDeviceContextpath
- StringfilePath
- booleanpublic DBFileInfo getFileInfo(String path, int dirId, int fid, DBDeviceContext dbCtx)
path
- StringdirId
- intfid
- intdbCtx
- DBDeviceContextpublic DBFileInfo getStreamInfo(FileState parent, String[] paths, DBDeviceContext dbCtx)
parent
- FileStatepaths
- String[]dbCtx
- DBDeviceContextprotected final FileState getFileState(String path, DBDeviceContext ctx, boolean create)
path
- Stringctx
- DBDeviceContextcreate
- booleanpublic void treeOpened(SrvSession sess, TreeConnection tree)
treeOpened
in interface DeviceInterface
sess
- Server sessiontree
- Tree connectionpublic void treeClosed(SrvSession sess, TreeConnection tree)
treeClosed
in interface DeviceInterface
sess
- Server sessiontree
- Tree connectionprotected final boolean hasDebug()
public final void getDiskInformation(DiskDeviceContext ctx, SrvDiskInfo info) throws IOException
getDiskInformation
in interface DiskSizeInterface
ctx
- DiskDeviceContextinfo
- SrvDiskInfoIOException
public boolean hasStreamsEnabled(SrvSession sess, TreeConnection tree)
hasStreamsEnabled
in interface NTFSStreamsInterface
sess
- SrvSessiontree
- TreeConnectionpublic StreamInfo getStreamInformation(SrvSession sess, TreeConnection tree, StreamInfo streamInfo) throws IOException
getStreamInformation
in interface NTFSStreamsInterface
sess
- SrvSessiontree
- TreeConnectionstreamInfo
- StreamInfoIOException
public StreamInfoList getStreamList(SrvSession sess, TreeConnection tree, String fileName) throws IOException
getStreamList
in interface NTFSStreamsInterface
sess
- SrvSessiontree
- TreeConnectionfileName
- StringIOException
protected final NetworkFile createStream(SrvSession sess, TreeConnection tree, FileOpenParams params, FileState parent, DBDeviceContext dbCtx) throws IOException
sess
- SrvSessiontree
- TreeConnectionparams
- FileOpenParamsparent
- FileStatedbCtx
- DBDeviceContextIOException
protected final NetworkFile openStream(SrvSession sess, TreeConnection tree, FileOpenParams params, FileState parent, DBDeviceContext dbCtx) throws IOException
sess
- SrvSessiontree
- TreeConnectionparams
- FileOpenParamsparent
- FileStatedbCtx
- DBDeviceContextIOException
protected final void closeStream(SrvSession sess, TreeConnection tree, NetworkFile stream) throws IOException
sess
- Session detailstree
- Tree connectionstream
- Network file detailsIOException
protected final void deleteStream(SrvSession sess, TreeConnection tree, String name) throws IOException
sess
- SrvSessiontree
- TreeConnectionname
- StringIOException
protected final StreamInfoList loadStreamList(FileState fstate, DBFileInfo finfo, DBDeviceContext dbCtx, boolean dbLoad)
fstate
- FileStatefinfo
- DBFileInfodbCtx
- DBDeviceContextdbLoad
- booleanpublic void renameStream(SrvSession sess, TreeConnection tree, String oldName, String newName, boolean overWrite) throws IOException
renameStream
in interface NTFSStreamsInterface
sess
- SrvSessiontree
- TreeConnectionoldName
- StringnewName
- StringoverWrite
- booleanIOException
public VolumeInfo getVolumeInformation(DiskDeviceContext ctx)
getVolumeInformation
in interface DiskVolumeInterface
ctx
- DiskDeviceContextpublic LockManager getLockManager(SrvSession sess, TreeConnection tree)
getLockManager
in interface FileLockingInterface
sess
- SrvSessiontree
- TreeConnectionpublic OpLockManager getOpLockManager(SrvSession sess, TreeConnection tree)
getOpLockManager
in interface OpLockInterface
sess
- SrvSessiontree
- TreeConnectionpublic boolean isOpLocksEnabled(SrvSession sess, TreeConnection tree)
isOpLocksEnabled
in interface OpLockInterface
sess
- SrvSessiontree
- TreeConnectionpublic String buildPathForFileId(SrvSession sess, TreeConnection tree, int dirid, int fileid) throws FileNotFoundException
buildPathForFileId
in interface FileIdInterface
sess
- SrvSessiontree
- TreeConnectiondirid
- intfileid
- intFileNotFoundException
public boolean hasSymbolicLinksEnabled(SrvSession sess, TreeConnection tree)
hasSymbolicLinksEnabled
in interface SymbolicLinkInterface
sess
- SrvSessiontree
- TreeConnectionpublic String readSymbolicLink(SrvSession sess, TreeConnection tree, String path) throws AccessDeniedException, FileNotFoundException
readSymbolicLink
in interface SymbolicLinkInterface
sess
- SrvSessiontree
- TreeConnectionpath
- StringAccessDeniedException
FileNotFoundException
public int getSecurityDescriptorLength(SrvSession sess, TreeConnection tree, NetworkFile netFile) throws SMBSrvException
getSecurityDescriptorLength
in interface SecurityDescriptorInterface
sess
- Server sessiontree
- Tree connectionnetFile
- Network fileSMBSrvException
public SecurityDescriptor loadSecurityDescriptor(SrvSession sess, TreeConnection tree, NetworkFile netFile) throws SMBSrvException
loadSecurityDescriptor
in interface SecurityDescriptorInterface
sess
- Server sessiontree
- Tree connectionnetFile
- Network fileSMBSrvException
public void saveSecurityDescriptor(SrvSession sess, TreeConnection tree, NetworkFile netFile, SecurityDescriptor secDesc) throws SMBSrvException
saveSecurityDescriptor
in interface SecurityDescriptorInterface
sess
- Server sessiontree
- Tree connectionnetFile
- Network filesecDesc
- Security descriptorSMBSrvException
Copyright © 2005–2017 Alfresco Software. All rights reserved.