org.alfresco.filesys.repo
Class ContentDiskDriver

java.lang.Object
  extended by org.alfresco.filesys.alfresco.AlfrescoDiskDriver
      extended by org.alfresco.filesys.repo.ContentDiskDriver
All Implemented Interfaces:
org.alfresco.jlan.server.core.DeviceInterface, org.alfresco.jlan.server.filesys.DiskInterface, org.alfresco.jlan.server.filesys.IOCtlInterface, org.alfresco.jlan.server.filesys.TransactionalFilesystemInterface, org.alfresco.jlan.server.locking.FileLockingInterface

public class ContentDiskDriver
extends AlfrescoDiskDriver
implements org.alfresco.jlan.server.filesys.DiskInterface, org.alfresco.jlan.server.locking.FileLockingInterface

Content repository filesystem driver class

Provides a filesystem interface for various protocols such as SMB/CIFS and FTP.


Constructor Summary
ContentDiskDriver(CifsHelper cifsHelper)
          Class constructor
 
Method Summary
 void closeFile(org.alfresco.jlan.server.SrvSession sess, org.alfresco.jlan.server.filesys.TreeConnection tree, org.alfresco.jlan.server.filesys.NetworkFile file)
          Close the file.
 org.alfresco.jlan.server.core.DeviceContext createContext(java.lang.String shareName, org.alfresco.config.ConfigElement cfg)
          Parse and validate the parameter string and create a device context object for this instance of the shared device.
 void createDirectory(org.alfresco.jlan.server.SrvSession sess, org.alfresco.jlan.server.filesys.TreeConnection tree, org.alfresco.jlan.server.filesys.FileOpenParams params)
          Create a new directory on this file system.
 org.alfresco.jlan.server.filesys.NetworkFile createFile(org.alfresco.jlan.server.SrvSession sess, org.alfresco.jlan.server.filesys.TreeConnection tree, org.alfresco.jlan.server.filesys.FileOpenParams params)
          Create a new file on the file system.
 void deleteDirectory(org.alfresco.jlan.server.SrvSession sess, org.alfresco.jlan.server.filesys.TreeConnection tree, java.lang.String dir)
          Delete the directory from the filesystem.
 void deleteFile(org.alfresco.jlan.server.SrvSession sess, org.alfresco.jlan.server.filesys.TreeConnection tree, java.lang.String name)
          Delete the specified file.
 int fileExists(org.alfresco.jlan.server.SrvSession sess, org.alfresco.jlan.server.filesys.TreeConnection tree, java.lang.String name)
          Check if the specified file exists, and whether it is a file or directory.
 void flushFile(org.alfresco.jlan.server.SrvSession sess, org.alfresco.jlan.server.filesys.TreeConnection tree, org.alfresco.jlan.server.filesys.NetworkFile file)
          Flush any buffered output for the specified file.
 AuthenticationComponent getAuthComponent()
          Return the authentication component
 AuthenticationService getAuthenticationService()
          Return the authentication service
 CifsHelper getCifsHelper()
          Return the CIFS helper
 ContentService getContentService()
          Return the content service
 FileFolderService getFileFolderService()
          Return the file folder service
 org.alfresco.jlan.server.filesys.FileInfo getFileInformation(org.alfresco.jlan.server.SrvSession session, org.alfresco.jlan.server.filesys.TreeConnection tree, java.lang.String path)
          Get the file information for the specified file.
 org.alfresco.jlan.server.locking.LockManager getLockManager(org.alfresco.jlan.server.SrvSession sess, org.alfresco.jlan.server.filesys.TreeConnection tree)
          Return the lock manager used by this filesystem
 NamespaceService getNamespaceService()
          Return the namespace service
 NodeRef getNodeForPath(org.alfresco.jlan.server.filesys.TreeConnection tree, java.lang.String path)
          Get the node for the specified path
 NodeService getNodeService()
          Return the node service
 java.lang.String getPathForNode(org.alfresco.jlan.server.filesys.TreeConnection tree, NodeRef nodeRef)
          Convert a node into a share relative path
 PermissionService getPermissionService()
          Return the permission service
 org.alfresco.jlan.server.filesys.pseudo.PseudoFileInterface getPseudoFileInterface(ContentContext context)
          Return the pseudo file support implementation
 SearchService getSearchService()
          Return the search service
 FileState getStateForPath(org.alfresco.jlan.server.filesys.TreeConnection tree, java.lang.String path)
          Get the file state for the specified path
 boolean hasPseudoFileInterface(ContentContext context)
          Check if pseudo file support is enabled
 boolean isReadOnly(org.alfresco.jlan.server.SrvSession sess, org.alfresco.jlan.server.core.DeviceContext ctx)
          Determine if the disk device is read-only.
 org.alfresco.jlan.server.filesys.NetworkFile openFile(org.alfresco.jlan.server.SrvSession sess, org.alfresco.jlan.server.filesys.TreeConnection tree, org.alfresco.jlan.server.filesys.FileOpenParams params)
          Open a file or folder
 int readFile(org.alfresco.jlan.server.SrvSession sess, org.alfresco.jlan.server.filesys.TreeConnection tree, org.alfresco.jlan.server.filesys.NetworkFile file, byte[] buffer, int bufferPosition, int size, long fileOffset)
          Read a block of data from the specified file.
 void renameFile(org.alfresco.jlan.server.SrvSession sess, org.alfresco.jlan.server.filesys.TreeConnection tree, java.lang.String oldName, java.lang.String newName)
          Rename the specified file.
 long seekFile(org.alfresco.jlan.server.SrvSession sess, org.alfresco.jlan.server.filesys.TreeConnection tree, org.alfresco.jlan.server.filesys.NetworkFile file, long pos, int typ)
          Seek to the specified file position.
 void setAuthenticationComponent(AuthenticationComponent authComponent)
          Set the authentication component
 void setAuthenticationService(AuthenticationService authService)
          Set the authentication service
 void setContentService(ContentService contentService)
           
 void setFileFolderService(FileFolderService fileService)
          Set the file folder service
 void setFileInformation(org.alfresco.jlan.server.SrvSession sess, org.alfresco.jlan.server.filesys.TreeConnection tree, java.lang.String name, org.alfresco.jlan.server.filesys.FileInfo info)
          Set file information
 void setMimetypeService(MimetypeService mimetypeService)
           
 void setNamespaceService(NamespaceService namespaceService)
           
 void setNodeMonitorFactory(NodeMonitorFactory nodeMonitorFactory)
          Set the node monitor factory
 void setNodeService(NodeService nodeService)
           
 void setPermissionService(PermissionService permissionService)
          Set the permission service
 void setSearchService(SearchService searchService)
           
 org.alfresco.jlan.server.filesys.SearchContext startSearch(org.alfresco.jlan.server.SrvSession sess, org.alfresco.jlan.server.filesys.TreeConnection tree, java.lang.String searchPath, int attributes)
          Start a new search on the filesystem using the specified searchPath that may contain wildcards.
 void treeClosed(org.alfresco.jlan.server.SrvSession sess, org.alfresco.jlan.server.filesys.TreeConnection tree)
          Connection opened to this disk device
 void treeOpened(org.alfresco.jlan.server.SrvSession sess, org.alfresco.jlan.server.filesys.TreeConnection tree)
          Connection closed to this device
 void truncateFile(org.alfresco.jlan.server.SrvSession sess, org.alfresco.jlan.server.filesys.TreeConnection tree, org.alfresco.jlan.server.filesys.NetworkFile file, long size)
          Truncate a file to the specified size
 int writeFile(org.alfresco.jlan.server.SrvSession sess, org.alfresco.jlan.server.filesys.TreeConnection tree, org.alfresco.jlan.server.filesys.NetworkFile file, byte[] buffer, int bufferOffset, int size, long fileOffset)
          Write a block of data to the file.
 
Methods inherited from class org.alfresco.filesys.alfresco.AlfrescoDiskDriver
beginReadTransaction, beginWriteTransaction, endTransaction, getServiceRegistry, getStateReaper, getTransactionService, processIOControl, setServiceRegistry, setStateReaper, setTransactionService
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ContentDiskDriver

public ContentDiskDriver(CifsHelper cifsHelper)
Class constructor

Parameters:
serviceRegistry - to connect to the repository services
Method Detail

getCifsHelper

public final CifsHelper getCifsHelper()
Return the CIFS helper

Returns:
CifsHelper

getAuthenticationService

public final AuthenticationService getAuthenticationService()
Return the authentication service

Returns:
AuthenticationService

getAuthComponent

public final AuthenticationComponent getAuthComponent()
Return the authentication component

Returns:
AuthenticationComponent

getNodeService

public final NodeService getNodeService()
Return the node service

Returns:
NodeService

getContentService

public final ContentService getContentService()
Return the content service

Returns:
ContentService

getNamespaceService

public final NamespaceService getNamespaceService()
Return the namespace service

Returns:
NamespaceService

getSearchService

public final SearchService getSearchService()
Return the search service

Returns:
SearchService

getFileFolderService

public final FileFolderService getFileFolderService()
Return the file folder service

Returns:
FileFolderService

getPermissionService

public final PermissionService getPermissionService()
Return the permission service

Returns:
PermissionService

setContentService

public void setContentService(ContentService contentService)
Parameters:
contentService - the content service

setNamespaceService

public void setNamespaceService(NamespaceService namespaceService)
Parameters:
namespaceService - the namespace service

setNodeService

public void setNodeService(NodeService nodeService)
Parameters:
nodeService - the node service

setSearchService

public void setSearchService(SearchService searchService)
Parameters:
searchService - the search service

setPermissionService

public void setPermissionService(PermissionService permissionService)
Set the permission service

Parameters:
permissionService - PermissionService

setAuthenticationComponent

public void setAuthenticationComponent(AuthenticationComponent authComponent)
Set the authentication component

Parameters:
authComponent - AuthenticationComponent

setAuthenticationService

public void setAuthenticationService(AuthenticationService authService)
Set the authentication service

Parameters:
authService - AuthenticationService

setFileFolderService

public void setFileFolderService(FileFolderService fileService)
Set the file folder service

Parameters:
fileService - FileFolderService

setMimetypeService

public void setMimetypeService(MimetypeService mimetypeService)
Parameters:
mimetypeService - service for helping with mimetypes and encoding

setNodeMonitorFactory

public void setNodeMonitorFactory(NodeMonitorFactory nodeMonitorFactory)
Set the node monitor factory

Parameters:
nodeMonitorFactory - NodeMonitorFactory

createContext

public org.alfresco.jlan.server.core.DeviceContext createContext(java.lang.String shareName,
                                                                 org.alfresco.config.ConfigElement cfg)
                                                          throws org.alfresco.jlan.server.core.DeviceContextException
Parse and validate the parameter string and create a device context object for this instance of the shared device. The same DeviceInterface implementation may be used for multiple shares.

Specified by:
createContext in interface org.alfresco.jlan.server.core.DeviceInterface
Parameters:
shareName - String
args - ConfigElement
Returns:
DeviceContext
Throws:
org.alfresco.jlan.server.core.DeviceContextException

hasPseudoFileInterface

public final boolean hasPseudoFileInterface(ContentContext context)
Check if pseudo file support is enabled

Parameters:
context - ContentContext
Returns:
boolean

getPseudoFileInterface

public final org.alfresco.jlan.server.filesys.pseudo.PseudoFileInterface getPseudoFileInterface(ContentContext context)
Return the pseudo file support implementation

Parameters:
context - ContentContext
Returns:
PseudoFileInterface

isReadOnly

public boolean isReadOnly(org.alfresco.jlan.server.SrvSession sess,
                          org.alfresco.jlan.server.core.DeviceContext ctx)
                   throws java.io.IOException
Determine if the disk device is read-only.

Specified by:
isReadOnly in interface org.alfresco.jlan.server.filesys.DiskInterface
Parameters:
sess - Server session
ctx - Device context
Returns:
boolean
Throws:
java.io.IOException - If an error occurs.

getFileInformation

public org.alfresco.jlan.server.filesys.FileInfo getFileInformation(org.alfresco.jlan.server.SrvSession session,
                                                                    org.alfresco.jlan.server.filesys.TreeConnection tree,
                                                                    java.lang.String path)
                                                             throws java.io.IOException
Get the file information for the specified file.

Specified by:
getFileInformation in interface org.alfresco.jlan.server.filesys.DiskInterface
Parameters:
sess - Server session
tree - Tree connection
name - File name/path that information is required for.
Returns:
File information if valid, else null
Throws:
java.io.IOException - The exception description.

startSearch

public org.alfresco.jlan.server.filesys.SearchContext startSearch(org.alfresco.jlan.server.SrvSession sess,
                                                                  org.alfresco.jlan.server.filesys.TreeConnection tree,
                                                                  java.lang.String searchPath,
                                                                  int attributes)
                                                           throws java.io.FileNotFoundException
Start a new search on the filesystem using the specified searchPath that may contain wildcards.

Specified by:
startSearch in interface org.alfresco.jlan.server.filesys.DiskInterface
Parameters:
sess - Server session
tree - Tree connection
searchPath - File(s) to search for, may include wildcards.
attrib - Attributes of the file(s) to search for, see class SMBFileAttribute.
Returns:
SearchContext
Throws:
java.io.FileNotFoundException - If the search could not be started.

fileExists

public int fileExists(org.alfresco.jlan.server.SrvSession sess,
                      org.alfresco.jlan.server.filesys.TreeConnection tree,
                      java.lang.String name)
Check if the specified file exists, and whether it is a file or directory.

Specified by:
fileExists in interface org.alfresco.jlan.server.filesys.DiskInterface
Parameters:
sess - Server session
tree - Tree connection
name - java.lang.String
Returns:
int
See Also:
FileStatus

openFile

public org.alfresco.jlan.server.filesys.NetworkFile openFile(org.alfresco.jlan.server.SrvSession sess,
                                                             org.alfresco.jlan.server.filesys.TreeConnection tree,
                                                             org.alfresco.jlan.server.filesys.FileOpenParams params)
                                                      throws java.io.IOException
Open a file or folder

Specified by:
openFile in interface org.alfresco.jlan.server.filesys.DiskInterface
Parameters:
sess - SrvSession
tree - TreeConnection
params - FileOpenParams
Returns:
NetworkFile
Throws:
java.io.IOException

createFile

public org.alfresco.jlan.server.filesys.NetworkFile createFile(org.alfresco.jlan.server.SrvSession sess,
                                                               org.alfresco.jlan.server.filesys.TreeConnection tree,
                                                               org.alfresco.jlan.server.filesys.FileOpenParams params)
                                                        throws java.io.IOException
Create a new file on the file system.

Specified by:
createFile in interface org.alfresco.jlan.server.filesys.DiskInterface
Parameters:
sess - Server session
tree - Tree connection
params - File create parameters
Returns:
NetworkFile
Throws:
java.io.IOException - If an error occurs.

createDirectory

public void createDirectory(org.alfresco.jlan.server.SrvSession sess,
                            org.alfresco.jlan.server.filesys.TreeConnection tree,
                            org.alfresco.jlan.server.filesys.FileOpenParams params)
                     throws java.io.IOException
Create a new directory on this file system.

Specified by:
createDirectory in interface org.alfresco.jlan.server.filesys.DiskInterface
Parameters:
sess - Server session
tree - Tree connection.
params - Directory create parameters
Throws:
java.io.IOException - If an error occurs.

deleteDirectory

public void deleteDirectory(org.alfresco.jlan.server.SrvSession sess,
                            org.alfresco.jlan.server.filesys.TreeConnection tree,
                            java.lang.String dir)
                     throws java.io.IOException
Delete the directory from the filesystem.

Specified by:
deleteDirectory in interface org.alfresco.jlan.server.filesys.DiskInterface
Parameters:
sess - Server session
tree - Tree connection
dir - Directory name.
Throws:
java.io.IOException - The exception description.

flushFile

public void flushFile(org.alfresco.jlan.server.SrvSession sess,
                      org.alfresco.jlan.server.filesys.TreeConnection tree,
                      org.alfresco.jlan.server.filesys.NetworkFile file)
               throws java.io.IOException
Flush any buffered output for the specified file.

Specified by:
flushFile in interface org.alfresco.jlan.server.filesys.DiskInterface
Parameters:
sess - Server session
tree - Tree connection
file - Network file context.
Throws:
java.io.IOException - The exception description.

closeFile

public void closeFile(org.alfresco.jlan.server.SrvSession sess,
                      org.alfresco.jlan.server.filesys.TreeConnection tree,
                      org.alfresco.jlan.server.filesys.NetworkFile file)
               throws java.io.IOException
Close the file.

Specified by:
closeFile in interface org.alfresco.jlan.server.filesys.DiskInterface
Parameters:
sess - Server session
tree - Tree connection.
param - Network file context.
Throws:
java.io.IOException - If an error occurs.

deleteFile

public void deleteFile(org.alfresco.jlan.server.SrvSession sess,
                       org.alfresco.jlan.server.filesys.TreeConnection tree,
                       java.lang.String name)
                throws java.io.IOException
Delete the specified file.

Specified by:
deleteFile in interface org.alfresco.jlan.server.filesys.DiskInterface
Parameters:
sess - Server session
tree - Tree connection
file - NetworkFile
Throws:
java.io.IOException - The exception description.

renameFile

public void renameFile(org.alfresco.jlan.server.SrvSession sess,
                       org.alfresco.jlan.server.filesys.TreeConnection tree,
                       java.lang.String oldName,
                       java.lang.String newName)
                throws java.io.IOException
Rename the specified file.

Specified by:
renameFile in interface org.alfresco.jlan.server.filesys.DiskInterface
Parameters:
sess - Server session
tree - Tree connection
oldName - java.lang.String
newName - java.lang.String
Throws:
java.io.IOException - The exception description.

setFileInformation

public void setFileInformation(org.alfresco.jlan.server.SrvSession sess,
                               org.alfresco.jlan.server.filesys.TreeConnection tree,
                               java.lang.String name,
                               org.alfresco.jlan.server.filesys.FileInfo info)
                        throws java.io.IOException
Set file information

Specified by:
setFileInformation in interface org.alfresco.jlan.server.filesys.DiskInterface
Parameters:
sess - SrvSession
tree - TreeConnection
name - String
info - FileInfo
Throws:
java.io.IOException

truncateFile

public void truncateFile(org.alfresco.jlan.server.SrvSession sess,
                         org.alfresco.jlan.server.filesys.TreeConnection tree,
                         org.alfresco.jlan.server.filesys.NetworkFile file,
                         long size)
                  throws java.io.IOException
Truncate a file to the specified size

Specified by:
truncateFile in interface org.alfresco.jlan.server.filesys.DiskInterface
Parameters:
sess - Server session
tree - Tree connection
file - Network file details
size - New file length
Throws:
java.io.IOException - The exception description.

readFile

public int readFile(org.alfresco.jlan.server.SrvSession sess,
                    org.alfresco.jlan.server.filesys.TreeConnection tree,
                    org.alfresco.jlan.server.filesys.NetworkFile file,
                    byte[] buffer,
                    int bufferPosition,
                    int size,
                    long fileOffset)
             throws java.io.IOException
Read a block of data from the specified file.

Specified by:
readFile in interface org.alfresco.jlan.server.filesys.DiskInterface
Parameters:
sess - Session details
tree - Tree connection
file - Network file
buf - Buffer to return data to
bufPos - Starting position in the return buffer
siz - Maximum size of data to return
filePos - File offset to read data
Returns:
Number of bytes read
Throws:
java.io.IOException - The exception description.

seekFile

public long seekFile(org.alfresco.jlan.server.SrvSession sess,
                     org.alfresco.jlan.server.filesys.TreeConnection tree,
                     org.alfresco.jlan.server.filesys.NetworkFile file,
                     long pos,
                     int typ)
              throws java.io.IOException
Seek to the specified file position.

Specified by:
seekFile in interface org.alfresco.jlan.server.filesys.DiskInterface
Parameters:
sess - Server session
tree - Tree connection
file - Network file.
pos - Position to seek to.
typ - Seek type.
Returns:
New file position, relative to the start of file.
Throws:
java.io.IOException

writeFile

public int writeFile(org.alfresco.jlan.server.SrvSession sess,
                     org.alfresco.jlan.server.filesys.TreeConnection tree,
                     org.alfresco.jlan.server.filesys.NetworkFile file,
                     byte[] buffer,
                     int bufferOffset,
                     int size,
                     long fileOffset)
              throws java.io.IOException
Write a block of data to the file.

Specified by:
writeFile in interface org.alfresco.jlan.server.filesys.DiskInterface
Parameters:
sess - Server session
tree - Tree connection
file - Network file details
buf - byte[] Data to be written
bufoff - Offset within the buffer that the data starts
siz - int Data length
fileoff - Position within the file that the data is to be written.
Returns:
Number of bytes actually written
Throws:
java.io.IOException - The exception description.

getNodeForPath

public NodeRef getNodeForPath(org.alfresco.jlan.server.filesys.TreeConnection tree,
                              java.lang.String path)
                       throws java.io.FileNotFoundException
Get the node for the specified path

Parameters:
tree - TreeConnection
path - String
Returns:
NodeRef
Throws:
java.io.FileNotFoundException

getPathForNode

public java.lang.String getPathForNode(org.alfresco.jlan.server.filesys.TreeConnection tree,
                                       NodeRef nodeRef)
                                throws java.io.FileNotFoundException
Convert a node into a share relative path

Parameters:
tree - TreeConnection
nodeRef - NodeRef
Returns:
String
Throws:
java.io.FileNotFoundException

getStateForPath

public FileState getStateForPath(org.alfresco.jlan.server.filesys.TreeConnection tree,
                                 java.lang.String path)
                          throws java.io.FileNotFoundException
Get the file state for the specified path

Parameters:
tree - TreeConnection
path - String
Returns:
FileState
Throws:
java.io.FileNotFoundException

treeClosed

public void treeClosed(org.alfresco.jlan.server.SrvSession sess,
                       org.alfresco.jlan.server.filesys.TreeConnection tree)
Connection opened to this disk device

Specified by:
treeClosed in interface org.alfresco.jlan.server.core.DeviceInterface
Parameters:
sess - Server session
tree - Tree connection

treeOpened

public void treeOpened(org.alfresco.jlan.server.SrvSession sess,
                       org.alfresco.jlan.server.filesys.TreeConnection tree)
Connection closed to this device

Specified by:
treeOpened in interface org.alfresco.jlan.server.core.DeviceInterface
Parameters:
sess - Server session
tree - Tree connection

getLockManager

public org.alfresco.jlan.server.locking.LockManager getLockManager(org.alfresco.jlan.server.SrvSession sess,
                                                                   org.alfresco.jlan.server.filesys.TreeConnection tree)
Return the lock manager used by this filesystem

Specified by:
getLockManager in interface org.alfresco.jlan.server.locking.FileLockingInterface
Parameters:
sess - SrvSession
tree - TreeConnection
Returns:
LockManager


Copyright © 2005 - 2008 Alfresco Software, Inc. All Rights Reserved.