CStockage 4.2_beta-RC-1
API Documentation

org.esupportail.portal.channels.CStockage.provider.access
Class CifsAccessImpl

java.lang.Object
  extended byorg.esupportail.portal.channels.CStockage.provider.access.ServerAccess
      extended byorg.esupportail.portal.channels.CStockage.provider.access.CifsAccessImpl

public class CifsAccessImpl
extends ServerAccess

Implements the ServerAccess interface to access a CIFS(SMB) server
Id: CifsAccessImpl.java
Classes: CifsAccessImpl
Creation date: 17/12/2004
Last modification: 24/02/2005
Modifications :
24/02/2005 Thomas Bellembois Correcting some bugs Copyright (c) 2004 Esup Portail (www.esup-portail.org).
Notes :

  • 1. In this document the term resource refer to a directory or a file
  • 2. An URI like /myDirectory/mySubDirectory/myResource is called full path (of myResource) whereas an URI like /myDirectory/mySubDirectory is called path (of myResource)
  • 3. A resource (file/directory) can be written in many ways to call methods. For example you can write /myResource, or /myResource/, but also myResource. Even if the resource is a file you can write /myFile.txt/ !
  • Version:
    1.2
    Author:
    Thomas Bellembois

    Constructor Summary
    CifsAccessImpl()
               
     
    Method Summary
     boolean canPaste(Space fromSpace, java.lang.String toSpaceKey, java.lang.String clipboardPath, java.util.Vector clipboard, java.lang.String curentDirPath)
              Check that we can paste a file in the target directory
    This version does not support inter spaces paste !
     boolean canRead(java.lang.String path)
              Check if we are authorized to read this resource (file or directory)
     boolean canRead(java.lang.String resourceName, java.lang.String path)
              Check if we are authorized to read this resource (file or directory)
     boolean[] checkPrivileges(java.lang.String path)
              Check The privileges for the current user
     void connect()
              Connect to the server
     boolean createDir(java.lang.String name, java.lang.String path)
              Create a directory
     boolean delete(java.lang.String file, java.lang.String path)
              Delete a resource (file or directory)
     org.esupportail.portal.utils.webdav.acl.EsupPermissions deny(java.lang.String path, java.lang.String principal, java.lang.String permissionType, boolean inheritable)
              not implemented
     void disconnect()
              Disconnect from the server
     ChannelResource download(java.lang.String name, java.lang.String path)
              Download a file
     boolean exists(java.lang.String fullPath)
              Check is the resource (file or directory) exists
     boolean exists(java.lang.String resourceName, java.lang.String path)
              Check is the resource (file or directory) exists
     java.io.InputStream getMethodData(java.lang.String fullPath)
              Return the stream of a file
     org.esupportail.portal.utils.webdav.acl.EsupPermissions getPermissions(java.lang.String path)
              not implemented
     org.esupportail.portal.utils.webdav.acl.EsupPermissions getPermissions(java.lang.String path, java.lang.String permissionType)
              not implemented
     java.lang.String getProperty(java.lang.String namespace, java.lang.String path, java.lang.String propertyName)
              not implemented
     org.esupportail.portal.utils.webdav.acl.EsupPermissions grant(java.lang.String path, java.lang.String principal, java.lang.String permissionType, boolean inheritable)
              not implemented
     java.util.Vector hasInheritedPermission(java.lang.String path, java.lang.String principal, java.lang.String permissionType, boolean negative, boolean inheritable)
              not implemented
     boolean hasNotInheritedPermission(java.lang.String path, java.lang.String principal, java.lang.String permissionType, boolean negative, boolean inheritable)
              not implemented
     void init(Space space)
              Initializes the CIFS server parameters
    You have to call this method before calling the connect method.
     boolean isDirectory(java.lang.String name, java.lang.String path)
              Check that the resource is a directory
     boolean isEmpty(java.lang.String dir, java.lang.String path)
              Check that the directory is empty
     ChannelResource[] ls(java.lang.String fullPath)
              List all the resources of a directory
     ChannelResource[] ls(java.lang.String path, java.lang.String targetDirectory)
              List all the resources of the given directory
     boolean rename(java.lang.String oldName, java.lang.String newName, java.lang.String path)
              Rename a resource (file or directory)
     org.esupportail.portal.utils.webdav.acl.EsupPermissions revoke(java.lang.String path, java.lang.String principal, java.lang.String permissionType, boolean inheritable)
              not implemented
     void revokeAllPermissons(java.lang.String path)
              not implemented
     boolean setProperty(java.lang.String namespace, java.lang.String path, java.lang.String propertyName, java.lang.String propertyValue)
              not implemented
     boolean upload(java.lang.String fileName, java.io.InputStream fileStream, java.lang.String path)
              Upload a file to the path given in argument
     
    Methods inherited from class org.esupportail.portal.channels.CStockage.provider.access.ServerAccess
    copy, move
     
    Methods inherited from class java.lang.Object
    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
     

    Constructor Detail

    CifsAccessImpl

    public CifsAccessImpl()
    Method Detail

    init

    public void init(Space space)
              throws java.net.MalformedURLException,
                     PropertiesException
    Initializes the CIFS server parameters
    You have to call this method before calling the connect method.
    About Space parameters :
    A lot of parameters could be used to configure the access to the CIFS server. But only the more required parameters are used by this class.
    For more details about all the available parameters, refer to the JCIFS documentation at http://jcifs.samba.org/src/docs/api/
  • login : login to connect to the server
  • password : password to connect to the server
  • uri : URL of the CIFS server - example : smb://myServer:myPort
  • resourcePath : resource full path on the CIFS server - example : /myHomeDir/myDirectory/myFile.txt
  • domain : domain of the CIFS server
  • resolveOrder : A comma separated list of name resolution method identifiers that specify which methods will be used and in what order to resolve hostnames. The possible identifiers in default order are LMHOSTS, WINS, BCAST, and DNS.
  • disablePlainTextPassword : Plain text passwords should never be used and are disabled by default. To enable jCIFS to use plain text password this property must be set to false.
  • Specified by:
    init in class ServerAccess
    Parameters:
    space - space used to get connexion parameters
    Throws:
    java.net.MalformedURLException
    PropertiesException

    connect

    public void connect()
                 throws ServerException,
                        BadConnexionParameters
    Connect to the server

    Specified by:
    connect in class ServerAccess
    Throws:
    ServerException
    BadConnexionParameters

    disconnect

    public void disconnect()
                    throws ServerException
    Disconnect from the server

    Specified by:
    disconnect in class ServerAccess
    Throws:
    ServerException

    ls

    public ChannelResource[] ls(java.lang.String fullPath)
                         throws NotExistsResourceException,
                                ApplicationException,
                                NotAuthorizedException
    List all the resources of a directory

    Specified by:
    ls in class ServerAccess
    Parameters:
    fullPath - full path of the directory to list
    Returns:
    the list of resources as an array of ChannelWebdavResource
    Throws:
    NotExistsResourceException
    ApplicationException
    NotAuthorizedException

    ls

    public ChannelResource[] ls(java.lang.String path,
                                java.lang.String targetDirectory)
                         throws NotExistsResourceException,
                                ApplicationException,
                                NotAuthorizedException
    List all the resources of the given directory

    Specified by:
    ls in class ServerAccess
    Parameters:
    path - path of the directory to list
    targetDirectory - name of the directory to list
    Returns:
    the list of resources as an array of ChannelWebdavResource
    Throws:
    NotExistsResourceException
    ApplicationException
    NotAuthorizedException

    upload

    public boolean upload(java.lang.String fileName,
                          java.io.InputStream fileStream,
                          java.lang.String path)
                   throws ApplicationException,
                          ServerException,
                          NotExistsResourceException,
                          StillExistsException,
                          BadFormatException,
                          UploadException,
                          EmptyFileOnUploadException,
                          OverQuotaException,
                          NotAuthorizedDeleteException,
                          NotAuthorizedUploadException,
                          NotAuthorizedException,
                          PropertiesException
    Upload a file to the path given in argument

    Specified by:
    upload in class ServerAccess
    Parameters:
    fileName - the input file name
    fileStream - the input file stream
    path - the path
    Returns:
    boolean true if no problem, else false
    Throws:
    ApplicationException
    ServerException
    NotExistsResourceException
    StillExistsException
    BadFormatException
    UploadException
    EmptyFileOnUploadException
    OverQuotaException
    NotAuthorizedDeleteException
    NotAuthorizedUploadException
    NotAuthorizedException
    PropertiesException

    delete

    public boolean delete(java.lang.String file,
                          java.lang.String path)
                   throws ApplicationException,
                          DeleteException,
                          NotAuthorizedDeleteException,
                          NotExistsResourceException,
                          NotAuthorizedException
    Delete a resource (file or directory)

    Specified by:
    delete in class ServerAccess
    Parameters:
    file - resource to delete
    path - path of the resource
    Returns:
    boolean true if no problem occured else false
    Throws:
    ApplicationException
    DeleteException
    NotAuthorizedDeleteException
    NotExistsResourceException
    NotAuthorizedException

    rename

    public boolean rename(java.lang.String oldName,
                          java.lang.String newName,
                          java.lang.String path)
                   throws StillExistsException,
                          BadFormatException,
                          ApplicationException,
                          RenameException,
                          NotAuthorizedRenameException,
                          NotExistsResourceException,
                          NotAuthorizedException,
                          PropertiesException
    Rename a resource (file or directory)

    Specified by:
    rename in class ServerAccess
    Parameters:
    oldName - resource to rename
    newName - new name of the resource
    path - path of the resource
    Returns:
    boolean true if no problem occured else false
    Throws:
    StillExistsException
    BadFormatException
    ApplicationException
    RenameException
    NotAuthorizedRenameException
    NotExistsResourceException
    NotAuthorizedException
    PropertiesException

    createDir

    public boolean createDir(java.lang.String name,
                             java.lang.String path)
                      throws ApplicationException,
                             CreateDirectoryException,
                             StillExistsException,
                             BadFormatException,
                             NotAuthorizedNewDirException,
                             NotExistsResourceException,
                             NotAuthorizedException,
                             PropertiesException
    Create a directory

    Specified by:
    createDir in class ServerAccess
    Parameters:
    name - name of the directory to create
    path - path where to create the directory
    Returns:
    boolean true if no problem occured else false
    Throws:
    ApplicationException
    CreateDirectoryException
    StillExistsException
    BadFormatException
    NotAuthorizedNewDirException
    NotExistsResourceException
    NotAuthorizedException
    PropertiesException

    canPaste

    public boolean canPaste(Space fromSpace,
                            java.lang.String toSpaceKey,
                            java.lang.String clipboardPath,
                            java.util.Vector clipboard,
                            java.lang.String curentDirPath)
                     throws ApplicationException,
                            PasteInChildDirectoryException,
                            PasteWithSameNameException,
                            PasteDeletedResourceException,
                            NotAuthorizedException
    Check that we can paste a file in the target directory
    This version does not support inter spaces paste !

    Specified by:
    canPaste in class ServerAccess
    Parameters:
    fromSpace - the space from which we want to paste - not used
    toSpaceKey - the space key where we want to paste - not used
    clipboardPath - the path of the clipboad
    clipboard - the contain of the clipboard
    curentDirPath - the path of the current dir
    Returns:
    true if no problem occured else an exception is thrown
    Throws:
    ApplicationException
    PasteInChildDirectoryException
    PasteWithSameNameException
    PasteDeletedResourceException
    NotAuthorizedException

    download

    public ChannelResource download(java.lang.String name,
                                    java.lang.String path)
                             throws DownloadException
    Download a file

    Specified by:
    download in class ServerAccess
    Parameters:
    name - the file name
    path - the path of the file
    Returns:
    the ChannelWebdavResource
    Throws:
    DownloadException

    getMethodData

    public java.io.InputStream getMethodData(java.lang.String fullPath)
                                      throws java.io.IOException
    Return the stream of a file

    Specified by:
    getMethodData in class ServerAccess
    Parameters:
    fullPath - the full path of the file
    Returns:
    the InputStream
    Throws:
    java.io.IOException

    exists

    public boolean exists(java.lang.String fullPath)
                   throws ApplicationException,
                          NotAuthorizedException
    Check is the resource (file or directory) exists

    Specified by:
    exists in class ServerAccess
    Parameters:
    fullPath - the full path of the resource
    Returns:
    true if the resource exists else false
    Throws:
    ApplicationException
    NotAuthorizedException

    exists

    public boolean exists(java.lang.String resourceName,
                          java.lang.String path)
                   throws ApplicationException,
                          NotAuthorizedException
    Check is the resource (file or directory) exists

    Specified by:
    exists in class ServerAccess
    Parameters:
    resourceName - the name of the resource
    path - the relative path of the resource
    Returns:
    true if the resource exists else false
    Throws:
    ApplicationException
    NotAuthorizedException

    canRead

    public boolean canRead(java.lang.String resourceName,
                           java.lang.String path)
                    throws ApplicationException
    Check if we are authorized to read this resource (file or directory)

    Specified by:
    canRead in class ServerAccess
    Parameters:
    resourceName - the name of the resource
    path - relative path of the resource
    Returns:
    true if authorized else false
    Throws:
    ApplicationException

    canRead

    public boolean canRead(java.lang.String path)
                    throws ApplicationException
    Check if we are authorized to read this resource (file or directory)

    Specified by:
    canRead in class ServerAccess
    Parameters:
    path - full path of the resource
    Returns:
    true if authorized else false
    Throws:
    ApplicationException

    isDirectory

    public boolean isDirectory(java.lang.String name,
                               java.lang.String path)
                        throws ApplicationException,
                               NotAuthorizedException,
                               NotExistsResourceException
    Check that the resource is a directory

    Specified by:
    isDirectory in class ServerAccess
    Parameters:
    name - the name of the resource
    path - the relative path of the resource
    Returns:
    true if the resource is a directory, false else
    Throws:
    ApplicationException
    NotAuthorizedException
    NotExistsResourceException

    isEmpty

    public boolean isEmpty(java.lang.String dir,
                           java.lang.String path)
                    throws ApplicationException,
                           NotExistsResourceException,
                           NotAuthorizedException
    Check that the directory is empty

    Specified by:
    isEmpty in class ServerAccess
    Parameters:
    dir - the name of the directory
    path - the relative path of the directory
    Returns:
    true if the directory is empty, else false
    Throws:
    ApplicationException
    NotExistsResourceException
    NotAuthorizedException

    getProperty

    public java.lang.String getProperty(java.lang.String namespace,
                                        java.lang.String path,
                                        java.lang.String propertyName)
                                 throws ServerException
    not implemented

    Specified by:
    getProperty in class ServerAccess
    Parameters:
    namespace - the namespace used for this metadata
    path - the resource path
    propertyName - the property name
    Returns:
    the property as a String object
    Throws:
    ServerException

    setProperty

    public boolean setProperty(java.lang.String namespace,
                               java.lang.String path,
                               java.lang.String propertyName,
                               java.lang.String propertyValue)
                        throws ServerException
    not implemented

    Specified by:
    setProperty in class ServerAccess
    Parameters:
    namespace - the namespace used for this metadata
    path - the resource path
    propertyName - the name of the property to set
    propertyValue - the value of the property to set
    Returns:
    true if well done
    Throws:
    ServerException

    getPermissions

    public org.esupportail.portal.utils.webdav.acl.EsupPermissions getPermissions(java.lang.String path,
                                                                                  java.lang.String permissionType)
                                                                           throws AclReadException,
                                                                                  AclAccessException,
                                                                                  NotSupportedAclException
    not implemented

    Specified by:
    getPermissions in class ServerAccess
    Parameters:
    path - the resource path
    permissionType - the type of permission (read, write, ....)
    Returns:
    an EsupPermissions object representing the permissions
    Throws:
    AclReadException
    AclAccessException
    NotSupportedAclException

    getPermissions

    public org.esupportail.portal.utils.webdav.acl.EsupPermissions getPermissions(java.lang.String path)
                                                                           throws AclReadException,
                                                                                  AclAccessException,
                                                                                  NotSupportedAclException
    not implemented

    Specified by:
    getPermissions in class ServerAccess
    Parameters:
    path - the resource path
    Returns:
    an EsupPermissions object representing the permissions
    Throws:
    NotSupportedAclException
    AclAccessException
    AclReadException

    grant

    public org.esupportail.portal.utils.webdav.acl.EsupPermissions grant(java.lang.String path,
                                                                         java.lang.String principal,
                                                                         java.lang.String permissionType,
                                                                         boolean inheritable)
                                                                  throws AclReadException,
                                                                         AclAccessException,
                                                                         AclWriteException,
                                                                         NotSupportedAclException
    not implemented

    Specified by:
    grant in class ServerAccess
    Parameters:
    path - the resource path
    principal - the concerned user role
    permissionType - the permission type: [read|read-acl|read-current-user-privilege-set|write|write-acl|write-properties|write-content]
    Returns:
    the EsupPermissions object modified by the action
    Throws:
    NotSupportedAclException
    AclAccessException
    AclWriteException
    AclReadException

    deny

    public org.esupportail.portal.utils.webdav.acl.EsupPermissions deny(java.lang.String path,
                                                                        java.lang.String principal,
                                                                        java.lang.String permissionType,
                                                                        boolean inheritable)
                                                                 throws AclReadException,
                                                                        AclAccessException,
                                                                        AclWriteException,
                                                                        NotSupportedAclException
    not implemented

    Specified by:
    deny in class ServerAccess
    Parameters:
    path - the resource path
    principal - the concerned user role
    permissionType - the permission type: [read|read-acl|read-current-user-privilege-set|write|write-acl|write-properties|write-content]
    Returns:
    the EsupPermissions object modified by the action
    Throws:
    AclAccessException
    AclWriteException
    NotSupportedAclException
    AclReadException

    revoke

    public org.esupportail.portal.utils.webdav.acl.EsupPermissions revoke(java.lang.String path,
                                                                          java.lang.String principal,
                                                                          java.lang.String permissionType,
                                                                          boolean inheritable)
                                                                   throws AclReadException,
                                                                          AclAccessException,
                                                                          AclWriteException,
                                                                          NotSupportedAclException
    not implemented

    Specified by:
    revoke in class ServerAccess
    Parameters:
    path - the resource path
    principal - the concerned user role
    permissionType - the permission type: [read|read-acl|read-current-user-privilege-set|write|write-acl|write-properties|write-content]
    Returns:
    the EsupPermissions object modified by the action
    Throws:
    NotSupportedAclException
    AclAccessException
    AclReadException
    AclWriteException

    revokeAllPermissons

    public void revokeAllPermissons(java.lang.String path)
                             throws AclReadException,
                                    AclAccessException,
                                    AclWriteException,
                                    NotSupportedAclException
    not implemented

    Specified by:
    revokeAllPermissons in class ServerAccess
    Parameters:
    path - the resource path
    Throws:
    AclReadException
    AclAccessException
    AclWriteException
    NotSupportedAclException

    hasInheritedPermission

    public java.util.Vector hasInheritedPermission(java.lang.String path,
                                                   java.lang.String principal,
                                                   java.lang.String permissionType,
                                                   boolean negative,
                                                   boolean inheritable)
                                            throws AclReadException,
                                                   AclAccessException,
                                                   NotSupportedAclException
    not implemented

    Specified by:
    hasInheritedPermission in class ServerAccess
    Parameters:
    path - the resource path
    principal - the concerned user role
    permissionType - the permission type: [read|read-acl|read-current-user-privilege-set|write|write-acl|write-properties|write-content]
    negative - false for grant, true for deny
    Returns:
    null if not inherited permission, else return the inherited permissions
    Throws:
    AclAccessException
    AclReadException
    NotSupportedAclException

    hasNotInheritedPermission

    public boolean hasNotInheritedPermission(java.lang.String path,
                                             java.lang.String principal,
                                             java.lang.String permissionType,
                                             boolean negative,
                                             boolean inheritable)
                                      throws AclReadException,
                                             AclAccessException,
                                             NotSupportedAclException
    not implemented

    Specified by:
    hasNotInheritedPermission in class ServerAccess
    Parameters:
    path - the resource path
    principal - the concerned user role
    permissionType - the permission type: [read|read-acl|read-current-user-privilege-set|write|write-acl|write-properties|write-content]
    negative - false for grant, true for deny
    Throws:
    AclAccessException
    AclReadException
    NotSupportedAclException

    checkPrivileges

    public boolean[] checkPrivileges(java.lang.String path)
    Check The privileges for the current user

    Specified by:
    checkPrivileges in class ServerAccess
    Parameters:
    path - the path of the space
    Returns:
    an array containing the values of reading, writing and sharing

    CStockage 4.2_beta-RC-1
    API Documentation