Last updated by darthvader 2 years ago
This plugin provides a webdav interface for grails. It's core functionalitiy is to provide support for exposing your domain model to a webdav interface. This is especially useful when your domain objects contain binary data to be edited with a locally install application, e.g. word documents, images, etc.For the underlying webdav stuff, the webdav-servlet project is used. Thanks to those folks for providing a open source webdav servlet implementation.The plugin code itself is nothing more than a small integration layer between Grails and the Webdav Servlet. In details, it provides:
A webdav share with the internal name 'webdav' is accessible under http://localhost:8080/<app>/webdavExample 2:
Provides three webdav shares: webdav1 maps to http://localhost:8080/<app>/webdav_folder1
and webdav2 maps to http://localhost:8080/<app>/webdav_folder2. The third one provides
some servlet init parameters.If you're fine with a single webdav folder mapping
webdav -> http://localhost:8080/<app>/webdav
you don't have to do anything in Config.groovy - this is the plugin's default
behaviour by convention.
- autoconfiguration of the webdav servlet by adding the necessary stuff in web.xml
- an implementation of IWebdavStore for Grails's needs
- a customized WebdavServlet
- an abstract base class for creating your own WebdavMapper implementation.
The plugin is currently available in a initial 0.1 release. I'd appreciate any feedback on the plugin. Use the grails-user mailinglist for this.
How to use the plugin
To use webdav in your app you need to take the following steps:1. install the webdav plugin in your application
grails install-plugin webdav
2. add a webdav definition part to your Config.groovy file:
Example 1:grails.webdav = [
webdav: [ url: '/webdav/*', ]
]grails.webdav = [
webdav1: [ url: '/webdav_folder1/*' ],
webdav2: [ url: '/webdav_folder2/*' ],
webdav3: [
url: '/filesystemview/*,
init: [
rootpath: System.properties.'java.io.tmpdir',
storeDebug: 1,
'no-content-length-headers': 0,
lazyFolderCreationOnPut: 0
] ]3. add a service class extending AbstractWebdavMapperService for each entry in your webdav configuration. This class defines the contents of your webdav shares.
There's a special naming convention for these service classes: WebdavMapper_<internalname>Service.groovySo for the above example 1 you have to implement WebdavMappper_webdavService, for example 2 you need WebdavMapper_webdav1Service and WebdavMapper_webdav2Service. These service should be in the root package (aka no package declaration). For a sample implementation of a WebdavMapper, take a look in the sample application.If the plugin does not find your service class for a specific webdav share, it falls back and uses the net.sf.webdav.LocalFileSystemStore to expose a local directory to webdav.4. prevent Grails UrlMapping acting on Webdav-URLs
add an exlcude setting in your UrlMappings.groovy Example:class UrlMappings {
static mappings = {
"/$controller/$action?/$id?"{
constraints {
// apply constraints here
}
}
"500"(view:'/error')
static excludes = ["/webdav_folder1*"] // repeat this one for each of your webdav shares
}5. Use authentication (optional)
For a real world app, you might apply some security constraints to your webdav enabled app. Out of the box, you might use the Grails Acegi Plugin (+). The trick you have to do is enabling http basic auth and prevent Acegi from returning a 302 for requesting authentication in favour of a 401. The sample application (see below) uses authentication, so take a look thereSample application
In SVN there's a short sample application showing the basic usage of the plugin. You can also download the sample application as a zip archive.Todo
- add some gant scripts to automate the manual steps above
- care about timestamps of the webdav-enabled objects
Release history
- 2009-02-20: released initial 0.1 version
- 2009-06-29: updated the sample app to use authentication
Resources
- SVN: https://svn.codehaus.org/grails-plugins/grails-webdav/
- Jira issue tracker: http://jira.codehaus.org/browse/GRAILSPLUGINS, please use component 'Grails-webdav'.



