org.esupportail.portal.channels.CWebdav.provider
Class DavAccessImpl

java.lang.Object
  extended byorg.esupportail.portal.channels.CWebdav.provider.DavAccess
      extended byorg.esupportail.portal.channels.CWebdav.provider.DavAccessImpl

public class DavAccessImpl
extends DavAccess

Id: DavAccessImpl.java,v 1.0 14 avr. 2004
Copyright (c) 2004 Esup Portail (www.esup-portail.org)
Classes: DavAccessImpl
Original Author: Yohan Colmant
Implements the DavAccess methods


Field Summary
private  org.apache.commons.httpclient.HttpURL httpURL
          The Http url used to access the webdav
private  java.lang.String login
          The user login
private  java.lang.String password
          The password for the dav acccess
private  org.apache.webdav.lib.WebdavResource resource
          The WebDAV ressource
private  java.lang.String uri
          The dav access uri
 
Constructor Summary
DavAccessImpl()
          Default constructor
 
Method Summary
 boolean canPaste(java.lang.String clipboardPath, java.util.Vector clipboard, java.lang.String curentDirPath)
          Check if we can paste here
 boolean canRead(java.lang.String path)
          Check if we are authorized to read this resource
 boolean canRead(java.lang.String resourceName, java.lang.String path)
          Check if we are authorized to read this resource
 void connect()
          Connect this object to the server
 boolean copy(java.lang.String resource, java.lang.String fromPath, java.lang.String toPath)
          Copy method
 boolean createDir(java.lang.String name, java.lang.String path)
          Create the directory given in argument
 boolean delete(java.lang.String file, java.lang.String path)
          Delete the resource given in argument
 void disconnect()
          Disconnection of the server
 ChannelWebdavResource dowload(java.lang.String name, java.lang.String path)
          Return the resource associated to the file to download
 boolean exists(java.lang.String fullPath)
          Check is the resource exists
 boolean exists(java.lang.String resourceName, java.lang.String path)
          Check is the resource exists
private  boolean fileIsEmptyOnServer(java.lang.String fileName, java.lang.String path)
          Check if a file is empty on the server
 java.lang.String getLogin()
          Give the user login
 java.lang.String getPassword()
          Give the user password
 java.lang.String getRedirectionPath(java.lang.String path)
          This method is used to know the redirected path when we have an url in this form: http://SERVER:PORT/~context
 java.lang.String getServerCurrentHierPath()
          Return the hierarchy path oh the server. for example, if the server's url is http://URL:PORT/slide, the currentHierPath is "/slide"
 java.lang.String getUri()
          Give the uri webdav access
 void init(java.lang.String uri, java.lang.String login, java.lang.String password)
          This method initialize the parameters.
 boolean isDirectory(java.lang.String name, java.lang.String path)
          Check if the resource named name is a directory in the path given
 boolean isEmpty(java.lang.String dir, java.lang.String path)
          Check if the directory named dir is empty or not.
 ChannelWebdavResource[] ls(java.lang.String fullPath)
          List all ressources for a given path
 ChannelWebdavResource[] ls(java.lang.String path, java.lang.String targetDirectory)
          List all ressources for a given path
 boolean move(java.lang.String resource, java.lang.String fromPath, java.lang.String toPath)
          Move method
 boolean rename(java.lang.String oldName, java.lang.String newName, java.lang.String path)
          Rename the resource
 boolean upload(org.jasig.portal.MultipartDataSource inputFile, java.lang.String path)
          Upload a file to the path given in argument
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

uri

private java.lang.String uri
The dav access uri


login

private java.lang.String login
The user login


password

private java.lang.String password
The password for the dav acccess


httpURL

private org.apache.commons.httpclient.HttpURL httpURL
The Http url used to access the webdav


resource

private org.apache.webdav.lib.WebdavResource resource
The WebDAV ressource

Constructor Detail

DavAccessImpl

public DavAccessImpl()
Default constructor

Method Detail

getLogin

public java.lang.String getLogin()
Give the user login

Specified by:
getLogin in class DavAccess
Returns:
the user login

getPassword

public java.lang.String getPassword()
Give the user password

Specified by:
getPassword in class DavAccess
Returns:
the user password

getUri

public java.lang.String getUri()
Give the uri webdav access

Specified by:
getUri in class DavAccess
Returns:
the uri webdav access

init

public void init(java.lang.String uri,
                 java.lang.String login,
                 java.lang.String password)
          throws java.net.MalformedURLException
This method initialize the parameters. You have to call this method after calling connect method.

Specified by:
init in class DavAccess
Parameters:
uri - webdav uri
login - connexion login
password - connexioàn password
Throws:
java.net.MalformedURLException

getServerCurrentHierPath

public java.lang.String getServerCurrentHierPath()
                                          throws java.net.MalformedURLException
Return the hierarchy path oh the server. for example, if the server's url is http://URL:PORT/slide, the currentHierPath is "/slide"

Specified by:
getServerCurrentHierPath in class DavAccess
Returns:
a String
Throws:
java.net.MalformedURLException

connect

public void connect()
             throws ServerException
Connect this object to the server

Specified by:
connect in class DavAccess
Throws:
ServerException

disconnect

public void disconnect()
                throws ServerException
Disconnection of the server

Specified by:
disconnect in class DavAccess
Throws:
ServerException

ls

public ChannelWebdavResource[] ls(java.lang.String fullPath)
                           throws NotExistsResourceException,
                                  ApplicationException,
                                  NotAuthorizedException
List all ressources for a given path

Specified by:
ls in class DavAccess
Parameters:
fullPath - directory path on the dav server
Returns:
ChannelWebdavResource array
Throws:
NotExistsResourceException
ApplicationException
NotAuthorizedException

ls

public ChannelWebdavResource[] ls(java.lang.String path,
                                  java.lang.String targetDirectory)
                           throws NotExistsResourceException,
                                  ApplicationException,
                                  NotAuthorizedException
List all ressources for a given path

Specified by:
ls in class DavAccess
Parameters:
path - directory path on the dav server
targetDirectory - the directory name to list
Returns:
ChannelWebdavResource array
Throws:
NotExistsResourceException
ApplicationException
NotAuthorizedException

upload

public boolean upload(org.jasig.portal.MultipartDataSource inputFile,
                      java.lang.String path)
               throws ApplicationException,
                      ServerException,
                      NotExistsResourceException,
                      StillExistsException,
                      BadFormatException,
                      UploadException,
                      EmptyFileOnUploadException,
                      OverQuotaException,
                      NotAuthorizedDeleteException,
                      NotAuthorizedUploadException,
                      NotAuthorizedException
Upload a file to the path given in argument

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

fileIsEmptyOnServer

private boolean fileIsEmptyOnServer(java.lang.String fileName,
                                    java.lang.String path)
                             throws ApplicationException
Check if a file is empty on the server

Parameters:
fileName - the name of the file to check
path - the path where is the file on the server
Returns:
true if the file is empty on the server, false else
Throws:
ApplicationException

delete

public boolean delete(java.lang.String file,
                      java.lang.String path)
               throws ApplicationException,
                      DeleteException,
                      NotAuthorizedDeleteException,
                      NotExistsResourceException,
                      NotAuthorizedException
Delete the resource given in argument

Specified by:
delete in class DavAccess
Parameters:
file - file/directory to delete
path - path where is file/directory
Returns:
boolean true if well done 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
Rename the resource

Specified by:
rename in class DavAccess
Parameters:
oldName - file/directory to rename
newName - new name of the file/directory
path - path where is file/directory
Returns:
boolean true if well done else false
Throws:
StillExistsException
BadFormatException
ApplicationException
RenameException
NotAuthorizedRenameException
NotExistsResourceException
NotAuthorizedException

createDir

public boolean createDir(java.lang.String name,
                         java.lang.String path)
                  throws ApplicationException,
                         CreateDirectoryException,
                         StillExistsException,
                         BadFormatException,
                         NotAuthorizedNewDirException,
                         NotExistsResourceException,
                         NotAuthorizedException
Create the directory given in argument

Specified by:
createDir in class DavAccess
Parameters:
name - file/directory to delete
path - path where is file/directory
Returns:
boolean true if well done else false
Throws:
ApplicationException
CreateDirectoryException
StillExistsException
BadFormatException
NotAuthorizedNewDirException
NotExistsResourceException
NotAuthorizedException

canPaste

public boolean canPaste(java.lang.String clipboardPath,
                        java.util.Vector clipboard,
                        java.lang.String curentDirPath)
                 throws ApplicationException,
                        PasteInChildDirectoryException,
                        PasteWithSameNameException,
                        PasteDeletedResourceException,
                        NotAuthorizedException
Check if we can paste here

Specified by:
canPaste in class DavAccess
Parameters:
clipboardPath - the path where is the clipboad
clipboard - the containt of the clipboard
curentDirPath - the path of the curent dir
Returns:
true if ok excpetion else
Throws:
ApplicationException
PasteInChildDirectoryException
PasteWithSameNameException
PasteDeletedResourceException
NotAuthorizedException

copy

public boolean copy(java.lang.String resource,
                    java.lang.String fromPath,
                    java.lang.String toPath)
             throws CopyException,
                    ApplicationException,
                    OverQuotaException,
                    PasteNotAuthorizedResourceException,
                    NotExistsResourceException,
                    PasteNotAuthorizedResourceException,
                    NotAuthorizedException,
                    NotAuthorizedUploadException
Copy method

Specified by:
copy in class DavAccess
Parameters:
resource - resource to copy
fromPath - path where is the resource
toPath - path to copy the resource
Returns:
boolean true if well done else false
Throws:
CopyException
ApplicationException
OverQuotaException
NotAuthorizedException
NotExistsResourceException
PasteNotAuthorizedResourceException
NotAuthorizedUploadException

move

public boolean move(java.lang.String resource,
                    java.lang.String fromPath,
                    java.lang.String toPath)
             throws ApplicationException,
                    MoveException,
                    PasteNotAuthorizedResourceException,
                    NotExistsResourceException,
                    PasteNotAuthorizedResourceException,
                    NotAuthorizedException,
                    NotAuthorizedUploadException
Move method

Specified by:
move in class DavAccess
Parameters:
resource - resource to move
fromPath - path where is the resource
toPath - path to move the resource
Returns:
boolean true if well done else false
Throws:
ApplicationException
MoveException
NotAuthorizedException
NotExistsResourceException
PasteNotAuthorizedResourceException
NotAuthorizedUploadException

dowload

public ChannelWebdavResource dowload(java.lang.String name,
                                     java.lang.String path)
                              throws DownloadException
Return the resource associated to the file to download

Specified by:
dowload in class DavAccess
Parameters:
name - the file name
path - the path where to find the file
Returns:
the ChannelWebdavResource
Throws:
DownloadException

exists

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

Specified by:
exists in class DavAccess
Parameters:
resourceName - name of the file/directory to verify
path - path to find the file/directory
Returns:
true if file/directory exists else false
Throws:
ApplicationException
NotAuthorizedException

exists

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

Specified by:
exists in class DavAccess
Parameters:
fullPath - path to find the file/directory
Returns:
true if file/directory 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

Specified by:
canRead in class DavAccess
Parameters:
resourceName - name of the file/directory to verify
path - path to find the file/directory
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

Specified by:
canRead in class DavAccess
Parameters:
path - path to find the file/directory
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 if the resource named name is a directory in the path given

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

isEmpty

public boolean isEmpty(java.lang.String dir,
                       java.lang.String path)
                throws ApplicationException,
                       NotExistsResourceException,
                       NotAuthorizedException
Check if the directory named dir is empty or not. We suppose that dir has been checked as a directory before

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

getRedirectionPath

public java.lang.String getRedirectionPath(java.lang.String path)
This method is used to know the redirected path when we have an url in this form: http://SERVER:PORT/~context

Specified by:
getRedirectionPath in class DavAccess
Parameters:
path - the context path, for example /slide/~bidon
Returns:
the redirection path, for example: /slide/files/storage/users/n/no/bidon