You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by "Arne v.Irmer" <Ar...@tu-dortmund.de> on 2009/05/20 09:46:27 UTC

WebDAV-enabled Root-Folder

Hi,

with Jackrabbit I got a WebDAV-Server that listens to something like
http://localhost:8080/jackrabbit-webapp/repository/default
Where "jackrabbit-webapp" is the name of the deployed war. "repository" is the servlet name and "default" is the name of the repository.

I would like to enable WebDAV for the Root-Folder of the Server "/".
For that I renamed jackrabbit-webapp.war to ROOT.war and do a servlet-mapping from /* to the Webdav-Servlet in the web.xml of ROOT.war (aka jackrabbit-webapp.war).

The last thing I need to is to get rid of the name of the repository in the url.
- Is there a possibility to use a nameless repository?
- Can I configure jackrabbit to map webdav-access for the root folder to the default repository?
- How can I configure a webdav enabled root-folder with jackrabbit?

Yours
 Arne

Re: WebDAV-enabled Root-Folder

Posted by "Arne v.Irmer" <Ar...@tu-dortmund.de>.
Hi Charly,
that was a perfect hint! Now everything works perfectly.

For anyone who wants to build a server with a webdav-enabled Root-Folder (i.e. http://localhost:8080 )
here is a small cooking recipe:
Normally the jackrabbit-webdav servlet can be reached at http://localhost:8080/jackrabbit-webapp/repository/default/ 
We have to remove three parts from that URL.
1) "jackrabbit-webapp"
To remove "jackrabbit-webapp" from the URL rename "jackrabbit-webapp.war" to "ROOT.war". This will cause the Servlet-Container to start the URL of all servlets in "ROOT.war" at "/".
Be sure that not other ROOT.war is in the Servlet-Container. In JBoss 4.x.x the ROOT.war resides in server/deploy/jboss-web.deployer 

2) "repository"
To remove "repository" from the URL open the web.xml in the ROOT.war (aka jackrabbit-webapp.war) and replace all "/repository" with "/" 

3) "default" 
To remove "repository" from the URL build the following class and put it in the classpath of your servlet-container:

package my.package;
import javax.jcr.Repository;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import javax.servlet.ServletException;

import org.apache.jackrabbit.j2ee.SimpleWebdavServlet;
import org.apache.jackrabbit.webdav.simple.LocatorFactoryImpl;

public class MyWebdavServlet extends SimpleWebdavServlet {
	private static final long serialVersionUID = 1L;

	@Override
	public void init() throws ServletException {
		super.init();
		try {
			final InitialContext ctx = new InitialContext();
			final Repository repository = (Repository) ctx.lookup("java:jcr/local");
			setRepository(repository);
		} catch (NamingException e) {
			e.printStackTrace();
		}

		// Use LocatorFactoryImpl instead of LocatorFactoryImplEx:
		// paths don't include workspace so no "/default" at start.
		setLocatorFactory(new LocatorFactoryImpl(getPathPrefix()));
	}
}

After that open the web.xml in the ROOT.war (aka jackrabbit-webapp.war) and replace "org.apache.jackrabbit.j2ee.SimpleWebdavServlet" with your servlet-class (here it would be my.package.MyWebdavServlet)

That's it
 
Yours
 Arne


Re: WebDAV-enabled Root-Folder

Posted by Charles Brooking <pu...@charlie.brooking.id.au>.
G'day

> with Jackrabbit I got a WebDAV-Server that listens to something like
> http://localhost:8080/jackrabbit-webapp/repository/default
> Where "jackrabbit-webapp" is the name of the deployed war. "repository" is
> the servlet name and "default" is the name of the repository.
>
> I would like to enable WebDAV for the Root-Folder of the Server "/".

I also wanted to get rid of the "/default" - I only use a single workspace
in my application and it made URLs inconsistent with my other servlets.

You can remove it by setting the "locator factory" of the WebDAV servlet. Eg:

public class YourWebdavServlet extends SimpleWebdavServlet {
  public void init(ServletConfig config) throws ServletException {
    super.init(config);
    setRepository(...);

    // Use LocatorFactoryImpl instead of LocatorFactoryImplEx:
    // paths don't include workspace so no "/default" at start.
    setLocatorFactory(new LocatorFactoryImpl(getPathPrefix()));
  }
}

Later
Charlie


Re: WebDAV-enabled Root-Folder

Posted by Alexander Klimetschek <ak...@day.com>.
On Wed, May 20, 2009 at 2:46 AM, Arne v.Irmer
<Ar...@tu-dortmund.de> wrote:
> I would like to enable WebDAV for the Root-Folder of the Server "/".
> For that I renamed jackrabbit-webapp.war to ROOT.war and do a servlet-mapping from /* to the Webdav-Servlet in the web.xml of ROOT.war (aka jackrabbit-webapp.war).
>
> The last thing I need to is to get rid of the name of the repository in the url.
> - Is there a possibility to use a nameless repository?
> - Can I configure jackrabbit to map webdav-access for the root folder to the default repository?
> - How can I configure a webdav enabled root-folder with jackrabbit?

Have you tried setting the resource-path-prefix parameter of the
SimpleWebdavServlet to "" or "/" in the web.xml?

Regards,
Alex

-- 
Alexander Klimetschek
alexander.klimetschek@day.com