|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.esupportail.portal.channels.CStockage.provider.access.ServerAccess
org.esupportail.portal.channels.CStockage.provider.access.CifsAccessImpl
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 :
/myDirectory/mySubDirectory/myResource
is called full path (of myResource)
whereas an URI like /myDirectory/mySubDirectory
is called path (of myResource)/myResource
,
or /myResource/
, but also myResource
. Even if the resource is a file you can write /myFile.txt/
!
Field Summary | |
private java.lang.String |
disablePlainTextPassword
|
private java.lang.String |
domain
|
private static int |
INPUTSTREAM_BUFFER
|
protected static Log |
log
|
private static int |
LOG_DEBUG
|
private static int |
LOG_ERROR
|
private static int |
LOG_INFO
|
private static int |
LOG_WARN
|
private java.lang.String |
login
|
private jcifs.smb.NtlmPasswordAuthentication |
ntlmPasswordAuthentication
|
private java.lang.String |
password
|
private java.lang.String |
resolveOrder
|
private java.lang.String |
resourcePath
|
private static int |
RESSOURCE_FILE_PATH
|
private static int |
RESSOURCE_FILEORFOLDER_NAME
|
private static int |
RESSOURCE_FOLDER_PATH
|
private static int |
RESSOURCE_UNKNOWN_PATH
|
private static int |
RESSOURCE_URI
|
private jcifs.smb.SmbFile |
smbFile
|
private java.lang.String |
uri
|
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) |
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)
not implemented |
void |
disconnect()
Disconnect from the server |
private boolean |
distantCopy(ChannelResource resource,
ServerAccess fromAccess,
java.lang.String toPath)
Copy a resource from a server to the CIFS server All required checking (if a directory exists...) are supposed to be done by the calling application |
protected boolean |
distantCopy(java.lang.String resource,
ServerAccess fromAccess,
java.lang.String fromPath,
java.lang.String toPath)
Copy a resource from a server to the CIFS server All required checking (if a directory exists...) are supposed to be done by the calling application |
private boolean |
distantCopyDirectory(java.lang.String directoryName,
ServerAccess fromAccess,
java.lang.String absoluteFromPath,
java.lang.String toPath)
Copy a directory from a server to the CIFS server All required checking (if a directory exists...) are supposed to be done by the calling application |
private boolean |
distantCopyFile(java.lang.String fileName,
ServerAccess fromAccess,
java.lang.String absoluteFromPath,
java.lang.String toPath)
Copy a file from a server to the CIFS server All required checking (if a directory exists...) are supposed to be done by the calling application |
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)
not implemented |
java.util.Vector |
hasInheritedPermission(java.lang.String path,
java.lang.String principal,
java.lang.String permissionType,
boolean negative)
not implemented |
boolean |
hasNotInheritedPermission(java.lang.String path,
java.lang.String principal,
java.lang.String permissionType,
boolean negative)
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 |
protected boolean |
localCopy(java.lang.String resource,
java.lang.String fromPath,
java.lang.String toPath)
Copy a resource |
protected boolean |
localMove(java.lang.String resource,
java.lang.String fromPath,
java.lang.String toPath)
Move a resource |
private void |
logMethod(int type,
java.lang.String message)
|
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 |
private java.lang.String |
normalizeResourceUri(java.lang.String stringToProcess,
int ressourceType)
|
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)
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 |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
protected static final Log log
private static final int LOG_DEBUG
private static final int LOG_INFO
private static final int LOG_WARN
private static final int LOG_ERROR
private static final int RESSOURCE_FILEORFOLDER_NAME
private static final int RESSOURCE_FILE_PATH
private static final int RESSOURCE_FOLDER_PATH
private static final int RESSOURCE_UNKNOWN_PATH
private static final int RESSOURCE_URI
private static final int INPUTSTREAM_BUFFER
private java.lang.String uri
private java.lang.String resourcePath
private java.lang.String domain
private java.lang.String login
private java.lang.String password
private java.lang.String resolveOrder
private jcifs.smb.NtlmPasswordAuthentication ntlmPasswordAuthentication
private java.lang.String disablePlainTextPassword
private jcifs.smb.SmbFile smbFile
Constructor Detail |
public CifsAccessImpl()
Method Detail |
private void logMethod(int type, java.lang.String message)
private java.lang.String normalizeResourceUri(java.lang.String stringToProcess, int ressourceType)
public void init(Space space) throws java.net.MalformedURLException, PropertiesException
http://jcifs.samba.org/src/docs/api/
login
: login to connect to the serverpassword
: password to connect to the serveruri
: URL of the CIFS server - example : smb://myServer:myPortresourcePath
: resource full path on the CIFS server - example : /myHomeDir/myDirectory/myFile.txtdomain
: domain of the CIFS serverresolveOrder
: 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.
init
in class ServerAccess
space
- space used to get connexion parameters
java.net.MalformedURLException
PropertiesException
public void connect() throws ServerException, BadConnexionParameters
connect
in class ServerAccess
ServerException
BadConnexionParameters
public void disconnect() throws ServerException
disconnect
in class ServerAccess
ServerException
public ChannelResource[] ls(java.lang.String fullPath) throws NotExistsResourceException, ApplicationException, NotAuthorizedException
ls
in class ServerAccess
fullPath
- full path of the directory to list
NotExistsResourceException
ApplicationException
NotAuthorizedException
public ChannelResource[] ls(java.lang.String path, java.lang.String targetDirectory) throws NotExistsResourceException, ApplicationException, NotAuthorizedException
ls
in class ServerAccess
path
- path of the directory to listtargetDirectory
- name of the directory to list
NotExistsResourceException
ApplicationException
NotAuthorizedException
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
in class ServerAccess
fileName
- the input file namefileStream
- the input file streampath
- the path
ApplicationException
ServerException
NotExistsResourceException
StillExistsException
BadFormatException
UploadException
EmptyFileOnUploadException
OverQuotaException
NotAuthorizedDeleteException
NotAuthorizedUploadException
NotAuthorizedException
PropertiesException
public boolean delete(java.lang.String file, java.lang.String path) throws ApplicationException, DeleteException, NotAuthorizedDeleteException, NotExistsResourceException, NotAuthorizedException
delete
in class ServerAccess
file
- resource to deletepath
- path of the resource
ApplicationException
DeleteException
NotAuthorizedDeleteException
NotExistsResourceException
NotAuthorizedException
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
in class ServerAccess
oldName
- resource to renamenewName
- new name of the resourcepath
- path of the resource
StillExistsException
BadFormatException
ApplicationException
RenameException
NotAuthorizedRenameException
NotExistsResourceException
NotAuthorizedException
PropertiesException
public boolean createDir(java.lang.String name, java.lang.String path) throws ApplicationException, CreateDirectoryException, StillExistsException, BadFormatException, NotAuthorizedNewDirException, NotExistsResourceException, NotAuthorizedException, PropertiesException
createDir
in class ServerAccess
name
- name of the directory to createpath
- path where to create the directory
ApplicationException
CreateDirectoryException
StillExistsException
BadFormatException
NotAuthorizedNewDirException
NotExistsResourceException
NotAuthorizedException
PropertiesException
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
canPaste
in class ServerAccess
fromSpace
- the space from which we want to paste - not usedtoSpaceKey
- the space key where we want to paste - not usedclipboardPath
- the path of the clipboadclipboard
- the contain of the clipboardcurentDirPath
- the path of the current dir
ApplicationException
PasteInChildDirectoryException
PasteWithSameNameException
PasteDeletedResourceException
NotAuthorizedException
protected boolean localCopy(java.lang.String resource, java.lang.String fromPath, java.lang.String toPath) throws CopyException, ApplicationException, OverQuotaException, NotExistsResourceException, PasteNotAuthorizedResourceException, NotAuthorizedException, NotAuthorizedUploadException
localCopy
in class ServerAccess
resource
- resource namefromPath
- path of the resourcetoPath
- path where to copy the resource
CopyException
ApplicationException
OverQuotaException
NotExistsResourceException
PasteNotAuthorizedResourceException
NotAuthorizedException
NotAuthorizedUploadException
private boolean distantCopyFile(java.lang.String fileName, ServerAccess fromAccess, java.lang.String absoluteFromPath, java.lang.String toPath) throws CopyException, ApplicationException, OverQuotaException, PasteNotAuthorizedResourceException, NotExistsResourceException, PasteNotAuthorizedResourceException, NotAuthorizedException, NotAuthorizedUploadException
fileName
- name of the file to copyfromAccess
- space access from which we want to copyabsoluteFromPath
- source pathtoPath
- destination path
CopyException
ApplicationException
OverQuotaException
PasteNotAuthorizedResourceException
NotExistsResourceException
PasteNotAuthorizedResourceException
NotAuthorizedException
NotAuthorizedUploadException
private boolean distantCopyDirectory(java.lang.String directoryName, ServerAccess fromAccess, java.lang.String absoluteFromPath, java.lang.String toPath) throws CopyException, ApplicationException, OverQuotaException, PasteNotAuthorizedResourceException, NotExistsResourceException, PasteNotAuthorizedResourceException, NotAuthorizedException, NotAuthorizedUploadException, ServerException
directoryName
- name of the directory to copyfromAccess
- space access from which we want to copyabsoluteFromPath
- source pathtoPath
- destination path
CopyException
ApplicationException
OverQuotaException
PasteNotAuthorizedResourceException
NotExistsResourceException
PasteNotAuthorizedResourceException
NotAuthorizedException
NotAuthorizedUploadException
ServerException
protected boolean distantCopy(java.lang.String resource, ServerAccess fromAccess, java.lang.String fromPath, java.lang.String toPath) throws CopyException, ApplicationException, OverQuotaException, NotExistsResourceException, PasteNotAuthorizedResourceException, NotAuthorizedException, NotAuthorizedUploadException, ServerException
distantCopy
in class ServerAccess
resource
- name of the resource to copyfromAccess
- space access from which we want to copytoPath
- destination pathfromPath
- path where is the resource
CopyException
ApplicationException
OverQuotaException
PasteNotAuthorizedResourceException
NotExistsResourceException
PasteNotAuthorizedResourceException
NotAuthorizedException
NotAuthorizedUploadException
ServerException
private boolean distantCopy(ChannelResource resource, ServerAccess fromAccess, java.lang.String toPath) throws CopyException, ApplicationException, OverQuotaException, PasteNotAuthorizedResourceException, NotExistsResourceException, PasteNotAuthorizedResourceException, NotAuthorizedException, NotAuthorizedUploadException, ServerException
resource
- ChannelResource to copyfromAccess
- space access from which we want to copytoPath
- destination path
CopyException
ApplicationException
OverQuotaException
PasteNotAuthorizedResourceException
NotExistsResourceException
PasteNotAuthorizedResourceException
NotAuthorizedException
NotAuthorizedUploadException
ServerException
protected boolean localMove(java.lang.String resource, java.lang.String fromPath, java.lang.String toPath) throws MoveException, ApplicationException, OverQuotaException, NotExistsResourceException, PasteNotAuthorizedResourceException, NotAuthorizedException, NotAuthorizedUploadException
localMove
in class ServerAccess
resource
- resource namefromPath
- path of the resourcetoPath
- path where to copy the resource
MoveException
ApplicationException
OverQuotaException
NotExistsResourceException
PasteNotAuthorizedResourceException
NotAuthorizedException
NotAuthorizedUploadException
public ChannelResource download(java.lang.String name, java.lang.String path) throws DownloadException
download
in class ServerAccess
name
- the file namepath
- the path of the file
DownloadException
public java.io.InputStream getMethodData(java.lang.String fullPath) throws java.io.IOException
getMethodData
in class ServerAccess
fullPath
- the full path of the file
java.io.IOException
public boolean exists(java.lang.String fullPath) throws ApplicationException, NotAuthorizedException
exists
in class ServerAccess
fullPath
- the full path of the resource
ApplicationException
NotAuthorizedException
public boolean exists(java.lang.String resourceName, java.lang.String path) throws ApplicationException, NotAuthorizedException
exists
in class ServerAccess
resourceName
- the name of the resourcepath
- the relative path of the resource
ApplicationException
NotAuthorizedException
public boolean canRead(java.lang.String resourceName, java.lang.String path) throws ApplicationException
canRead
in class ServerAccess
resourceName
- the name of the resourcepath
- relative path of the resource
ApplicationException
public boolean canRead(java.lang.String path) throws ApplicationException
canRead
in class ServerAccess
path
- full path of the resource
ApplicationException
public boolean isDirectory(java.lang.String name, java.lang.String path) throws ApplicationException, NotAuthorizedException, NotExistsResourceException
isDirectory
in class ServerAccess
name
- the name of the resourcepath
- the relative path of the resource
ApplicationException
NotAuthorizedException
NotExistsResourceException
public boolean isEmpty(java.lang.String dir, java.lang.String path) throws ApplicationException, NotExistsResourceException, NotAuthorizedException
isEmpty
in class ServerAccess
dir
- the name of the directorypath
- the relative path of the directory
ApplicationException
NotExistsResourceException
NotAuthorizedException
public java.lang.String getProperty(java.lang.String namespace, java.lang.String path, java.lang.String propertyName) throws ServerException
getProperty
in class ServerAccess
namespace
- the namespace used for this metadatapath
- the resource pathpropertyName
- the property name
ServerException
public boolean setProperty(java.lang.String namespace, java.lang.String path, java.lang.String propertyName, java.lang.String propertyValue) throws ServerException
setProperty
in class ServerAccess
namespace
- the namespace used for this metadatapath
- the resource pathpropertyName
- the name of the property to setpropertyValue
- the value of the property to set
ServerException
public org.esupportail.portal.utils.webdav.acl.EsupPermissions getPermissions(java.lang.String path, java.lang.String permissionType) throws AclReadException, AclAccessException, NotSupportedAclException
getPermissions
in class ServerAccess
path
- the resource pathpermissionType
- the type of permission (read, write, ....)
AclAccessException
AclReadException
NotSupportedAclException
public org.esupportail.portal.utils.webdav.acl.EsupPermissions getPermissions(java.lang.String path) throws AclReadException, AclAccessException, NotSupportedAclException
getPermissions
in class ServerAccess
path
- the resource path
AclAccessException
NotSupportedAclException
AclReadException
public org.esupportail.portal.utils.webdav.acl.EsupPermissions grant(java.lang.String path, java.lang.String principal, java.lang.String permissionType) throws AclReadException, AclAccessException, AclWriteException, NotSupportedAclException
grant
in class ServerAccess
path
- the resource pathprincipal
- the concerned user rolepermissionType
- the permission type: [read|read-acl|read-current-user-privilege-set|write|write-acl|write-properties|write-content]
AclWriteException
AclAccessException
AclReadException
NotSupportedAclException
public org.esupportail.portal.utils.webdav.acl.EsupPermissions deny(java.lang.String path, java.lang.String principal, java.lang.String permissionType) throws AclReadException, AclAccessException, AclWriteException, NotSupportedAclException
deny
in class ServerAccess
path
- the resource pathprincipal
- the concerned user rolepermissionType
- the permission type: [read|read-acl|read-current-user-privilege-set|write|write-acl|write-properties|write-content]
NotSupportedAclException
AclReadException
AclAccessException
AclWriteException
public org.esupportail.portal.utils.webdav.acl.EsupPermissions revoke(java.lang.String path, java.lang.String principal, java.lang.String permissionType) throws AclReadException, AclAccessException, AclWriteException, NotSupportedAclException
revoke
in class ServerAccess
path
- the resource pathprincipal
- the concerned user rolepermissionType
- the permission type: [read|read-acl|read-current-user-privilege-set|write|write-acl|write-properties|write-content]
AclWriteException
NotSupportedAclException
AclAccessException
AclReadException
public java.util.Vector hasInheritedPermission(java.lang.String path, java.lang.String principal, java.lang.String permissionType, boolean negative) throws AclReadException, AclAccessException, NotSupportedAclException
hasInheritedPermission
in class ServerAccess
path
- the resource pathprincipal
- the concerned user rolepermissionType
- 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
NotSupportedAclException
AclReadException
AclAccessException
public boolean hasNotInheritedPermission(java.lang.String path, java.lang.String principal, java.lang.String permissionType, boolean negative) throws AclReadException, AclAccessException, NotSupportedAclException
hasNotInheritedPermission
in class ServerAccess
path
- the resource pathprincipal
- the concerned user rolepermissionType
- 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
AclAccessException
AclReadException
NotSupportedAclException
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |