Class CmsJlanDiskInterface

java.lang.Object
org.opencms.jlan.CmsJlanDiskInterface
All Implemented Interfaces:
org.alfresco.jlan.server.core.DeviceInterface, org.alfresco.jlan.server.filesys.DiskInterface

public class CmsJlanDiskInterface extends Object implements org.alfresco.jlan.server.filesys.DiskInterface
OpenCms implementation of the JLAN DiskInterface interface.

This class, together with the CmsJlanNetworkFile class, contains the main repository access functionality.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    Attribute to control whether we need the filesize or not when reading a resource.
    static final CmsResourceFilter
    The standard resource filter used for reading resources.
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    closeFile(org.alfresco.jlan.server.SrvSession session, org.alfresco.jlan.server.filesys.TreeConnection connection, org.alfresco.jlan.server.filesys.NetworkFile file)
     
    Tries to convert a CmsException to the matching exception type from JLAN.
    org.alfresco.jlan.server.core.DeviceContext
    createContext(String shareName, org.springframework.extensions.config.ConfigElement args)
     
    void
    createDirectory(org.alfresco.jlan.server.SrvSession session, org.alfresco.jlan.server.filesys.TreeConnection connection, org.alfresco.jlan.server.filesys.FileOpenParams params)
     
    org.alfresco.jlan.server.filesys.NetworkFile
    createFile(org.alfresco.jlan.server.SrvSession session, org.alfresco.jlan.server.filesys.TreeConnection connection, org.alfresco.jlan.server.filesys.FileOpenParams params)
     
    void
    deleteDirectory(org.alfresco.jlan.server.SrvSession session, org.alfresco.jlan.server.filesys.TreeConnection connection, String path)
     
    void
    deleteFile(org.alfresco.jlan.server.SrvSession session, org.alfresco.jlan.server.filesys.TreeConnection connection, String path)
     
    int
    fileExists(org.alfresco.jlan.server.SrvSession session, org.alfresco.jlan.server.filesys.TreeConnection connection, String path)
     
    void
    flushFile(org.alfresco.jlan.server.SrvSession session, org.alfresco.jlan.server.filesys.TreeConnection connection, org.alfresco.jlan.server.filesys.NetworkFile file)
     
    getCms(org.alfresco.jlan.server.SrvSession session, org.alfresco.jlan.server.filesys.TreeConnection connection)
    Creates a CmsObjectWrapper for the current session.
    protected static String
    Converts a CIFS path to an OpenCms path by converting backslashes to slashes and translating special characters in the file name.
    getFileForPath(org.alfresco.jlan.server.SrvSession session, org.alfresco.jlan.server.filesys.TreeConnection connection, String path)
    Helper method to get a network file object given a path.
    getFileForPath(CmsObjectWrapper cms, org.alfresco.jlan.server.SrvSession session, org.alfresco.jlan.server.filesys.TreeConnection connection, String path)
    Helper method to get a network file object given a path.
    org.alfresco.jlan.server.filesys.FileInfo
    getFileInformation(org.alfresco.jlan.server.SrvSession session, org.alfresco.jlan.server.filesys.TreeConnection connection, String path)
     
    protected org.alfresco.jlan.server.filesys.NetworkFile
    internalCreateFile(org.alfresco.jlan.server.SrvSession session, org.alfresco.jlan.server.filesys.TreeConnection connection, org.alfresco.jlan.server.filesys.FileOpenParams params, String typeName)
    Internal method for creating a new file.
    boolean
    isReadOnly(org.alfresco.jlan.server.SrvSession session, org.alfresco.jlan.server.core.DeviceContext context)
     
    org.alfresco.jlan.server.filesys.NetworkFile
    openFile(org.alfresco.jlan.server.SrvSession session, org.alfresco.jlan.server.filesys.TreeConnection connection, org.alfresco.jlan.server.filesys.FileOpenParams params)
     
    int
    readFile(org.alfresco.jlan.server.SrvSession sess, org.alfresco.jlan.server.filesys.TreeConnection tree, org.alfresco.jlan.server.filesys.NetworkFile file, byte[] buf, int bufPos, int siz, long filePos)
     
    void
    renameFile(org.alfresco.jlan.server.SrvSession session, org.alfresco.jlan.server.filesys.TreeConnection connection, String oldName, String newName)
     
    long
    seekFile(org.alfresco.jlan.server.SrvSession session, org.alfresco.jlan.server.filesys.TreeConnection connection, org.alfresco.jlan.server.filesys.NetworkFile file, long pos, int seekMode)
     
    void
    setFileInformation(org.alfresco.jlan.server.SrvSession session, org.alfresco.jlan.server.filesys.TreeConnection connection, String path, org.alfresco.jlan.server.filesys.FileInfo info)
     
    org.alfresco.jlan.server.filesys.SearchContext
    startSearch(org.alfresco.jlan.server.SrvSession session, org.alfresco.jlan.server.filesys.TreeConnection connection, String searchPath, int searchAttributes)
     
    protected String
    Translates the last path segment of a path using the configured OpenCms file translations.
    void
    treeClosed(org.alfresco.jlan.server.SrvSession sess, org.alfresco.jlan.server.filesys.TreeConnection tree)
     
    void
    treeOpened(org.alfresco.jlan.server.SrvSession arg0, org.alfresco.jlan.server.filesys.TreeConnection arg1)
     
    void
    truncateFile(org.alfresco.jlan.server.SrvSession session, org.alfresco.jlan.server.filesys.TreeConnection connection, org.alfresco.jlan.server.filesys.NetworkFile file, long size)
     
    int
    writeFile(org.alfresco.jlan.server.SrvSession session, org.alfresco.jlan.server.filesys.TreeConnection connection, org.alfresco.jlan.server.filesys.NetworkFile file, byte[] data, int bufferOffset, int length, long fileOffset)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

  • Method Details

    • convertCmsException

      Tries to convert a CmsException to the matching exception type from JLAN.

      Parameters:
      e - the exception to convert
      Returns:
      the converted exception
    • getCmsPath

      protected static String getCmsPath(String path)
      Converts a CIFS path to an OpenCms path by converting backslashes to slashes and translating special characters in the file name.

      Parameters:
      path - the path to transform
      Returns:
      the OpenCms path for the given path
    • closeFile

      public void closeFile(org.alfresco.jlan.server.SrvSession session, org.alfresco.jlan.server.filesys.TreeConnection connection, org.alfresco.jlan.server.filesys.NetworkFile file) throws IOException
      Specified by:
      closeFile in interface org.alfresco.jlan.server.filesys.DiskInterface
      Throws:
      IOException
      See Also:
      • DiskInterface.closeFile(org.alfresco.jlan.server.SrvSession, org.alfresco.jlan.server.filesys.TreeConnection, org.alfresco.jlan.server.filesys.NetworkFile)
    • createContext

      public org.alfresco.jlan.server.core.DeviceContext createContext(String shareName, org.springframework.extensions.config.ConfigElement args)
      Specified by:
      createContext in interface org.alfresco.jlan.server.core.DeviceInterface
      See Also:
      • DeviceInterface.createContext(java.lang.String, org.springframework.extensions.config.ConfigElement)
    • createDirectory

      public void createDirectory(org.alfresco.jlan.server.SrvSession session, org.alfresco.jlan.server.filesys.TreeConnection connection, org.alfresco.jlan.server.filesys.FileOpenParams params) throws IOException
      Specified by:
      createDirectory in interface org.alfresco.jlan.server.filesys.DiskInterface
      Throws:
      IOException
      See Also:
      • DiskInterface.createDirectory(org.alfresco.jlan.server.SrvSession, org.alfresco.jlan.server.filesys.TreeConnection, org.alfresco.jlan.server.filesys.FileOpenParams)
    • createFile

      public org.alfresco.jlan.server.filesys.NetworkFile createFile(org.alfresco.jlan.server.SrvSession session, org.alfresco.jlan.server.filesys.TreeConnection connection, org.alfresco.jlan.server.filesys.FileOpenParams params) throws IOException
      Specified by:
      createFile in interface org.alfresco.jlan.server.filesys.DiskInterface
      Throws:
      IOException
      See Also:
      • DiskInterface.createFile(org.alfresco.jlan.server.SrvSession, org.alfresco.jlan.server.filesys.TreeConnection, org.alfresco.jlan.server.filesys.FileOpenParams)
    • deleteDirectory

      public void deleteDirectory(org.alfresco.jlan.server.SrvSession session, org.alfresco.jlan.server.filesys.TreeConnection connection, String path) throws IOException
      Specified by:
      deleteDirectory in interface org.alfresco.jlan.server.filesys.DiskInterface
      Throws:
      IOException
      See Also:
      • DiskInterface.deleteDirectory(org.alfresco.jlan.server.SrvSession, org.alfresco.jlan.server.filesys.TreeConnection, java.lang.String)
    • deleteFile

      public void deleteFile(org.alfresco.jlan.server.SrvSession session, org.alfresco.jlan.server.filesys.TreeConnection connection, String path) throws IOException
      Specified by:
      deleteFile in interface org.alfresco.jlan.server.filesys.DiskInterface
      Throws:
      IOException
      See Also:
      • DiskInterface.deleteFile(org.alfresco.jlan.server.SrvSession, org.alfresco.jlan.server.filesys.TreeConnection, java.lang.String)
    • fileExists

      public int fileExists(org.alfresco.jlan.server.SrvSession session, org.alfresco.jlan.server.filesys.TreeConnection connection, String path)
      Specified by:
      fileExists in interface org.alfresco.jlan.server.filesys.DiskInterface
      See Also:
      • DiskInterface.fileExists(org.alfresco.jlan.server.SrvSession, org.alfresco.jlan.server.filesys.TreeConnection, java.lang.String)
    • flushFile

      public void flushFile(org.alfresco.jlan.server.SrvSession session, org.alfresco.jlan.server.filesys.TreeConnection connection, org.alfresco.jlan.server.filesys.NetworkFile file) throws IOException
      Specified by:
      flushFile in interface org.alfresco.jlan.server.filesys.DiskInterface
      Throws:
      IOException
      See Also:
      • DiskInterface.flushFile(org.alfresco.jlan.server.SrvSession, org.alfresco.jlan.server.filesys.TreeConnection, org.alfresco.jlan.server.filesys.NetworkFile)
    • getFileInformation

      public org.alfresco.jlan.server.filesys.FileInfo getFileInformation(org.alfresco.jlan.server.SrvSession session, org.alfresco.jlan.server.filesys.TreeConnection connection, String path) throws IOException
      Specified by:
      getFileInformation in interface org.alfresco.jlan.server.filesys.DiskInterface
      Throws:
      IOException
      See Also:
      • DiskInterface.getFileInformation(org.alfresco.jlan.server.SrvSession, org.alfresco.jlan.server.filesys.TreeConnection, java.lang.String)
    • isReadOnly

      public boolean isReadOnly(org.alfresco.jlan.server.SrvSession session, org.alfresco.jlan.server.core.DeviceContext context)
      Specified by:
      isReadOnly in interface org.alfresco.jlan.server.filesys.DiskInterface
      See Also:
      • DiskInterface.isReadOnly(org.alfresco.jlan.server.SrvSession, org.alfresco.jlan.server.core.DeviceContext)
    • openFile

      public org.alfresco.jlan.server.filesys.NetworkFile openFile(org.alfresco.jlan.server.SrvSession session, org.alfresco.jlan.server.filesys.TreeConnection connection, org.alfresco.jlan.server.filesys.FileOpenParams params) throws IOException
      Specified by:
      openFile in interface org.alfresco.jlan.server.filesys.DiskInterface
      Throws:
      IOException
      See Also:
      • DiskInterface.openFile(org.alfresco.jlan.server.SrvSession, org.alfresco.jlan.server.filesys.TreeConnection, org.alfresco.jlan.server.filesys.FileOpenParams)
    • 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[] buf, int bufPos, int siz, long filePos) throws IOException
      Specified by:
      readFile in interface org.alfresco.jlan.server.filesys.DiskInterface
      Throws:
      IOException
      See Also:
      • DiskInterface.readFile(org.alfresco.jlan.server.SrvSession, org.alfresco.jlan.server.filesys.TreeConnection, org.alfresco.jlan.server.filesys.NetworkFile, byte[], int, int, long)
    • renameFile

      public void renameFile(org.alfresco.jlan.server.SrvSession session, org.alfresco.jlan.server.filesys.TreeConnection connection, String oldName, String newName) throws IOException
      Specified by:
      renameFile in interface org.alfresco.jlan.server.filesys.DiskInterface
      Throws:
      IOException
      See Also:
      • DiskInterface.renameFile(org.alfresco.jlan.server.SrvSession, org.alfresco.jlan.server.filesys.TreeConnection, java.lang.String, java.lang.String)
    • seekFile

      public long seekFile(org.alfresco.jlan.server.SrvSession session, org.alfresco.jlan.server.filesys.TreeConnection connection, org.alfresco.jlan.server.filesys.NetworkFile file, long pos, int seekMode) throws IOException
      Specified by:
      seekFile in interface org.alfresco.jlan.server.filesys.DiskInterface
      Throws:
      IOException
      See Also:
      • DiskInterface.seekFile(org.alfresco.jlan.server.SrvSession, org.alfresco.jlan.server.filesys.TreeConnection, org.alfresco.jlan.server.filesys.NetworkFile, long, int)
    • setFileInformation

      public void setFileInformation(org.alfresco.jlan.server.SrvSession session, org.alfresco.jlan.server.filesys.TreeConnection connection, String path, org.alfresco.jlan.server.filesys.FileInfo info) throws IOException
      Specified by:
      setFileInformation in interface org.alfresco.jlan.server.filesys.DiskInterface
      Throws:
      IOException
      See Also:
      • DiskInterface.setFileInformation(org.alfresco.jlan.server.SrvSession, org.alfresco.jlan.server.filesys.TreeConnection, java.lang.String, org.alfresco.jlan.server.filesys.FileInfo)
    • startSearch

      public org.alfresco.jlan.server.filesys.SearchContext startSearch(org.alfresco.jlan.server.SrvSession session, org.alfresco.jlan.server.filesys.TreeConnection connection, String searchPath, int searchAttributes)
      Specified by:
      startSearch in interface org.alfresco.jlan.server.filesys.DiskInterface
      See Also:
      • DiskInterface.startSearch(org.alfresco.jlan.server.SrvSession, org.alfresco.jlan.server.filesys.TreeConnection, java.lang.String, int)
    • treeClosed

      public void treeClosed(org.alfresco.jlan.server.SrvSession sess, org.alfresco.jlan.server.filesys.TreeConnection tree)
      Specified by:
      treeClosed in interface org.alfresco.jlan.server.core.DeviceInterface
      See Also:
      • DeviceInterface.treeClosed(org.alfresco.jlan.server.SrvSession, org.alfresco.jlan.server.filesys.TreeConnection)
    • treeOpened

      public void treeOpened(org.alfresco.jlan.server.SrvSession arg0, org.alfresco.jlan.server.filesys.TreeConnection arg1)
      Specified by:
      treeOpened in interface org.alfresco.jlan.server.core.DeviceInterface
      See Also:
      • DeviceInterface.treeOpened(org.alfresco.jlan.server.SrvSession, org.alfresco.jlan.server.filesys.TreeConnection)
    • truncateFile

      public void truncateFile(org.alfresco.jlan.server.SrvSession session, org.alfresco.jlan.server.filesys.TreeConnection connection, org.alfresco.jlan.server.filesys.NetworkFile file, long size) throws IOException
      Specified by:
      truncateFile in interface org.alfresco.jlan.server.filesys.DiskInterface
      Throws:
      IOException
      See Also:
      • DiskInterface.truncateFile(org.alfresco.jlan.server.SrvSession, org.alfresco.jlan.server.filesys.TreeConnection, org.alfresco.jlan.server.filesys.NetworkFile, long)
    • writeFile

      public int writeFile(org.alfresco.jlan.server.SrvSession session, org.alfresco.jlan.server.filesys.TreeConnection connection, org.alfresco.jlan.server.filesys.NetworkFile file, byte[] data, int bufferOffset, int length, long fileOffset) throws IOException
      Specified by:
      writeFile in interface org.alfresco.jlan.server.filesys.DiskInterface
      Throws:
      IOException
      See Also:
      • DiskInterface.writeFile(org.alfresco.jlan.server.SrvSession, org.alfresco.jlan.server.filesys.TreeConnection, org.alfresco.jlan.server.filesys.NetworkFile, byte[], int, int, long)
    • getCms

      protected CmsObjectWrapper getCms(org.alfresco.jlan.server.SrvSession session, org.alfresco.jlan.server.filesys.TreeConnection connection) throws CmsException
      Creates a CmsObjectWrapper for the current session.

      Parameters:
      session - the current session
      connection - the tree connection
      Returns:
      the correctly configured CmsObjectWrapper for this session
      Throws:
      CmsException - if something goes wrong
    • getFileForPath

      protected CmsJlanNetworkFile getFileForPath(CmsObjectWrapper cms, org.alfresco.jlan.server.SrvSession session, org.alfresco.jlan.server.filesys.TreeConnection connection, String path) throws CmsException
      Helper method to get a network file object given a path.

      Parameters:
      cms - the CMS context wrapper
      session - the current session
      connection - the current connection
      path - the file path
      Returns:
      the network file object for the given path
      Throws:
      CmsException - if something goes wrong
    • getFileForPath

      protected CmsJlanNetworkFile getFileForPath(org.alfresco.jlan.server.SrvSession session, org.alfresco.jlan.server.filesys.TreeConnection connection, String path) throws CmsException
      Helper method to get a network file object given a path.

      Parameters:
      session - the current session
      connection - the current connection
      path - the file path
      Returns:
      the network file object for the given path
      Throws:
      CmsException - if something goes wrong
    • internalCreateFile

      protected org.alfresco.jlan.server.filesys.NetworkFile internalCreateFile(org.alfresco.jlan.server.SrvSession session, org.alfresco.jlan.server.filesys.TreeConnection connection, org.alfresco.jlan.server.filesys.FileOpenParams params, String typeName) throws IOException
      Internal method for creating a new file.

      Parameters:
      session - the session
      connection - the tree connection
      params - the parameters for opening the file
      typeName - the name of the resource type for the new file
      Returns:
      a NetworkFile instance representing the newly created file
      Throws:
      IOException - if something goes wrong
    • translateName

      protected String translateName(String path)
      Translates the last path segment of a path using the configured OpenCms file translations.

      Parameters:
      path - the path for which the last segment should be translated
      Returns:
      the path with the translated last segment