You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@archiva.apache.org by br...@apache.org on 2008/03/13 19:28:50 UTC
svn commit: r636822 [6/9] - in /maven/archiva/branches/springy: ./
archiva-base/archiva-common/
archiva-base/archiva-consumers/archiva-database-consumers/src/test/java/org/apache/maven/archiva/consumers/database/
archiva-base/archiva-consumers/archiva-...
Added: maven/archiva/branches/springy/archiva-web/archiva-webdav/src/main/java/it/could/webdav/methods/COPY.java
URL: http://svn.apache.org/viewvc/maven/archiva/branches/springy/archiva-web/archiva-webdav/src/main/java/it/could/webdav/methods/COPY.java?rev=636822&view=auto
==============================================================================
--- maven/archiva/branches/springy/archiva-web/archiva-webdav/src/main/java/it/could/webdav/methods/COPY.java (added)
+++ maven/archiva/branches/springy/archiva-web/archiva-webdav/src/main/java/it/could/webdav/methods/COPY.java Thu Mar 13 11:28:26 2008
@@ -0,0 +1,71 @@
+/* ========================================================================== *
+ * Copyright (C) 2004-2006, Pier Fumagalli <http://could.it/> *
+ * All rights reserved. *
+ * ========================================================================== *
+ * *
+ * Licensed under the Apache License, Version 2.0 (the "License"). You may *
+ * not use this file except in compliance with the License. You may obtain a *
+ * copy of the License at <http://www.apache.org/licenses/LICENSE-2.0>. *
+ * *
+ * Unless required by applicable law or agreed to in writing, software *
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT *
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the *
+ * License for the specific language governing permissions and limitations *
+ * under the License. *
+ * *
+ * ========================================================================== */
+package it.could.webdav.methods;
+
+import it.could.webdav.DAVException;
+import it.could.webdav.DAVMethod;
+import it.could.webdav.DAVMultiStatus;
+import it.could.webdav.DAVResource;
+import it.could.webdav.DAVTransaction;
+
+import java.io.IOException;
+import java.net.URI;
+
+
+/**
+ * <p><a href="http://www.rfc-editor.org/rfc/rfc2518.txt">WebDAV</a>
+ * <code>COPY</code> metohd implementation.</p>
+ *
+ * @author <a href="http://could.it/">Pier Fumagalli</a>
+ */
+public class COPY implements DAVMethod {
+
+ /**
+ * <p>Create a new {@link COPY} instance.</p>
+ */
+ public COPY() {
+ super();
+ }
+
+ /**
+ * <p>Process the <code>COPY</code> method.</p>
+ */
+ public void process(DAVTransaction transaction, DAVResource resource)
+ throws IOException {
+
+ URI target = transaction.getDestination();
+ if (target == null) throw new DAVException(412, "No destination");
+ DAVResource dest = resource.getRepository().getResource(target);
+
+ int depth = transaction.getDepth();
+ boolean recursive = false;
+ if (depth == 0) {
+ recursive = false;
+ } else if (depth == DAVTransaction.INFINITY) {
+ recursive = true;
+ } else {
+ throw new DAVException(412, "Invalid Depth specified");
+ }
+
+ try {
+ resource.copy(dest, transaction.getOverwrite(), recursive);
+ transaction.setStatus(transaction.getOverwrite() ? 204 : 201);
+ } catch (DAVMultiStatus multistatus) {
+ multistatus.write(transaction);
+ }
+ }
+}
Propchange: maven/archiva/branches/springy/archiva-web/archiva-webdav/src/main/java/it/could/webdav/methods/COPY.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: maven/archiva/branches/springy/archiva-web/archiva-webdav/src/main/java/it/could/webdav/methods/DELETE.java
URL: http://svn.apache.org/viewvc/maven/archiva/branches/springy/archiva-web/archiva-webdav/src/main/java/it/could/webdav/methods/DELETE.java?rev=636822&view=auto
==============================================================================
--- maven/archiva/branches/springy/archiva-web/archiva-webdav/src/main/java/it/could/webdav/methods/DELETE.java (added)
+++ maven/archiva/branches/springy/archiva-web/archiva-webdav/src/main/java/it/could/webdav/methods/DELETE.java Thu Mar 13 11:28:26 2008
@@ -0,0 +1,54 @@
+/* ========================================================================== *
+ * Copyright (C) 2004-2006, Pier Fumagalli <http://could.it/> *
+ * All rights reserved. *
+ * ========================================================================== *
+ * *
+ * Licensed under the Apache License, Version 2.0 (the "License"). You may *
+ * not use this file except in compliance with the License. You may obtain a *
+ * copy of the License at <http://www.apache.org/licenses/LICENSE-2.0>. *
+ * *
+ * Unless required by applicable law or agreed to in writing, software *
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT *
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the *
+ * License for the specific language governing permissions and limitations *
+ * under the License. *
+ * *
+ * ========================================================================== */
+package it.could.webdav.methods;
+
+import it.could.webdav.DAVMethod;
+import it.could.webdav.DAVMultiStatus;
+import it.could.webdav.DAVResource;
+import it.could.webdav.DAVTransaction;
+
+import java.io.IOException;
+
+
+/**
+ * <p><a href="http://www.rfc-editor.org/rfc/rfc2518.txt">WebDAV</a>
+ * <code>DELETE</code> metohd implementation.</p>
+ *
+ * @author <a href="http://could.it/">Pier Fumagalli</a>
+ */
+public class DELETE implements DAVMethod {
+
+ /**
+ * <p>Create a new {@link DELETE} instance.</p>
+ */
+ public DELETE() {
+ super();
+ }
+
+ /**
+ * <p>Process the <code>DELETE</code> method.</p>
+ */
+ public void process(DAVTransaction transaction, DAVResource resource)
+ throws IOException {
+ try {
+ resource.delete();
+ transaction.setStatus(204);
+ } catch (DAVMultiStatus multistatus) {
+ multistatus.write(transaction);
+ }
+ }
+}
Propchange: maven/archiva/branches/springy/archiva-web/archiva-webdav/src/main/java/it/could/webdav/methods/DELETE.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: maven/archiva/branches/springy/archiva-web/archiva-webdav/src/main/java/it/could/webdav/methods/GET.java
URL: http://svn.apache.org/viewvc/maven/archiva/branches/springy/archiva-web/archiva-webdav/src/main/java/it/could/webdav/methods/GET.java?rev=636822&view=auto
==============================================================================
--- maven/archiva/branches/springy/archiva-web/archiva-webdav/src/main/java/it/could/webdav/methods/GET.java (added)
+++ maven/archiva/branches/springy/archiva-web/archiva-webdav/src/main/java/it/could/webdav/methods/GET.java Thu Mar 13 11:28:26 2008
@@ -0,0 +1,144 @@
+/* ========================================================================== *
+ * Copyright (C) 2004-2006, Pier Fumagalli <http://could.it/> *
+ * All rights reserved. *
+ * ========================================================================== *
+ * *
+ * Licensed under the Apache License, Version 2.0 (the "License"). You may *
+ * not use this file except in compliance with the License. You may obtain a *
+ * copy of the License at <http://www.apache.org/licenses/LICENSE-2.0>. *
+ * *
+ * Unless required by applicable law or agreed to in writing, software *
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT *
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the *
+ * License for the specific language governing permissions and limitations *
+ * under the License. *
+ * *
+ * ========================================================================== */
+package it.could.webdav.methods;
+
+import it.could.webdav.DAVInputStream;
+import it.could.webdav.DAVResource;
+import it.could.webdav.DAVTransaction;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.PrintWriter;
+import java.util.Iterator;
+import java.util.Set;
+import java.util.TreeSet;
+
+
+/**
+ * <p><a href="http://www.rfc-editor.org/rfc/rfc2616.txt">HTTP</a>
+ * <code>GET</code> metohd implementation.</p>
+ *
+ * @author <a href="http://could.it/">Pier Fumagalli</a>
+ */
+public class GET extends HEAD {
+
+ /** <p>The encoding charset to repsesent collections.</p> */
+ public static final String ENCODING = "UTF-8";
+
+ /** <p>The mime type that {@link GET} will use serving collections.</p> */
+ public static final String COLLECTION_MIME_TYPE = "text/html ;charset=\""
+ + ENCODING + "\"";
+
+ /**
+ * <p>Create a new {@link GET} instance.</p>
+ */
+ public GET() {
+ super();
+ }
+
+ /**
+ * <p>Process the <code>GET</code> method.</p>
+ */
+ public void process(DAVTransaction transaction, DAVResource resource)
+ throws IOException {
+ super.process(transaction, resource);
+
+ final String originalPath = transaction.getOriginalPath();
+ final String normalizedPath = transaction.getNormalizedPath();
+ final String current;
+ final String parent;
+ if (originalPath.equals(normalizedPath)) {
+ final String relativePath = resource.getRelativePath();
+ if (relativePath.equals("")) {
+ current = transaction.lookup(resource).toASCIIString();
+ } else {
+ current = relativePath;
+ }
+ parent = "./";
+ } else {
+ current = "./";
+ parent = "../";
+ }
+
+ if (resource.isCollection()) {
+ transaction.setHeader( "Content-Disposition", "inline; filename=\"index.html\"");
+ PrintWriter out = transaction.write(ENCODING);
+ String path = resource.getRelativePath();
+ out.println("<html>");
+ out.println("<head>");
+ out.println("<title>Collection: /" + path + "</title>");
+ out.println("</head>");
+ out.println("<body>");
+ out.println("<h2>Collection: /" + path + "</h2>");
+ out.println("<ul>");
+
+ /* Process the parent */
+ final DAVResource parentResource = resource.getParent();
+ if (parentResource != null) {
+ out.print("<li><a href=\"");
+ out.print(parent);
+ out.print("\">");
+ out.print(parentResource.getDisplayName());
+ out.println("</a> <i><small>(Parent)</small></i></li>");
+ out.println("</ul>");
+ out.println("<ul>");
+ }
+
+ /* Process the children (in two sorted sets, for nice ordering) */
+ Set resources = new TreeSet();
+ Set collections = new TreeSet();
+ Iterator iterator = resource.getChildren();
+ while (iterator.hasNext()) {
+ final DAVResource child = (DAVResource) iterator.next();
+ final StringBuffer buffer = new StringBuffer();
+ final String childPath = child.getDisplayName();
+ buffer.append("<li><a href=\"");
+ buffer.append(current);
+ buffer.append(childPath);
+ buffer.append("\">");
+ buffer.append(childPath);
+ buffer.append("</li>");
+ if (child.isCollection()) {
+ collections.add(buffer.toString());
+ } else {
+ resources.add(buffer.toString());
+ }
+ }
+
+ /* Spit out the collections first and the resources then */
+ for (Iterator i = collections.iterator(); i.hasNext(); )
+ out.println(i.next());
+ for (Iterator i = resources.iterator(); i.hasNext(); )
+ out.println(i.next());
+
+ out.println("</ul>");
+ out.println("</body>");
+ out.println("</html>");
+ out.flush();
+ return;
+ }
+
+ /* Processing a normal resource request */
+ OutputStream out = transaction.write();
+ DAVInputStream in = resource.read();
+ byte buffer[] = new byte[4096];
+ int k = -1;
+ while ((k = in.read(buffer)) != -1) out.write(buffer, 0, k);
+ in.close();
+ out.flush();
+ }
+}
Propchange: maven/archiva/branches/springy/archiva-web/archiva-webdav/src/main/java/it/could/webdav/methods/GET.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: maven/archiva/branches/springy/archiva-web/archiva-webdav/src/main/java/it/could/webdav/methods/HEAD.java
URL: http://svn.apache.org/viewvc/maven/archiva/branches/springy/archiva-web/archiva-webdav/src/main/java/it/could/webdav/methods/HEAD.java?rev=636822&view=auto
==============================================================================
--- maven/archiva/branches/springy/archiva-web/archiva-webdav/src/main/java/it/could/webdav/methods/HEAD.java (added)
+++ maven/archiva/branches/springy/archiva-web/archiva-webdav/src/main/java/it/could/webdav/methods/HEAD.java Thu Mar 13 11:28:26 2008
@@ -0,0 +1,79 @@
+/* ========================================================================== *
+ * Copyright (C) 2004-2006, Pier Fumagalli <http://could.it/> *
+ * All rights reserved. *
+ * ========================================================================== *
+ * *
+ * Licensed under the Apache License, Version 2.0 (the "License"). You may *
+ * not use this file except in compliance with the License. You may obtain a *
+ * copy of the License at <http://www.apache.org/licenses/LICENSE-2.0>. *
+ * *
+ * Unless required by applicable law or agreed to in writing, software *
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT *
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the *
+ * License for the specific language governing permissions and limitations *
+ * under the License. *
+ * *
+ * ========================================================================== */
+package it.could.webdav.methods;
+
+import it.could.webdav.DAVException;
+import it.could.webdav.DAVMethod;
+import it.could.webdav.DAVNotModified;
+import it.could.webdav.DAVResource;
+import it.could.webdav.DAVTransaction;
+import it.could.webdav.DAVUtilities;
+
+import java.io.IOException;
+import java.util.Date;
+
+
+/**
+ * <p><a href="http://www.rfc-editor.org/rfc/rfc2616.txt">HTTP</a>
+ * <code>HEAD</code> metohd implementation.</p>
+ *
+ * @author <a href="http://could.it/">Pier Fumagalli</a>
+ */
+public class HEAD implements DAVMethod {
+
+ /**
+ * <p>Create a new {@link HEAD} instance.</p>
+ */
+ public HEAD() {
+ super();
+ }
+
+ /**
+ * <p>Process the <code>HEAD</code> method.</p>
+ */
+ public void process(DAVTransaction transaction, DAVResource resource)
+ throws IOException {
+ /* Check if we have to force a resource not found or a redirection */
+ if (resource.isNull())
+ throw new DAVException(404, "Not found", resource);
+
+ /* Check if this is a conditional (processable only for resources) */
+ Date ifmod = transaction.getIfModifiedSince();
+ Date lsmod = resource.getLastModified();
+ if (resource.isResource() && (ifmod != null) && (lsmod != null)) {
+ /* HTTP doesn't send milliseconds, but Java does, so, reset them */
+ lsmod = new Date(((long)(lsmod.getTime() / 1000)) * 1000);
+ if (!ifmod.before(lsmod)) throw new DAVNotModified(resource);
+ }
+
+ /* Get the headers of this method */
+ String ctyp = resource.getContentType();
+ String etag = resource.getEntityTag();
+ String lmod = DAVUtilities.formatHttpDate(resource.getLastModified());
+ String clen = DAVUtilities.formatNumber(resource.getContentLength());
+
+ /* Set the normal headers that are required for a GET */
+ if (resource.isCollection()) {
+ transaction.setContentType(GET.COLLECTION_MIME_TYPE);
+ } else if (ctyp != null) {
+ transaction.setContentType(ctyp);
+ }
+ if (etag != null) transaction.setHeader("ETag", etag);
+ if (lmod != null) transaction.setHeader("Last-Modified", lmod);
+ if (clen != null) transaction.setHeader("Content-Length", clen);
+ }
+}
Propchange: maven/archiva/branches/springy/archiva-web/archiva-webdav/src/main/java/it/could/webdav/methods/HEAD.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: maven/archiva/branches/springy/archiva-web/archiva-webdav/src/main/java/it/could/webdav/methods/MKCOL.java
URL: http://svn.apache.org/viewvc/maven/archiva/branches/springy/archiva-web/archiva-webdav/src/main/java/it/could/webdav/methods/MKCOL.java?rev=636822&view=auto
==============================================================================
--- maven/archiva/branches/springy/archiva-web/archiva-webdav/src/main/java/it/could/webdav/methods/MKCOL.java (added)
+++ maven/archiva/branches/springy/archiva-web/archiva-webdav/src/main/java/it/could/webdav/methods/MKCOL.java Thu Mar 13 11:28:26 2008
@@ -0,0 +1,57 @@
+/* ========================================================================== *
+ * Copyright (C) 2004-2006, Pier Fumagalli <http://could.it/> *
+ * All rights reserved. *
+ * ========================================================================== *
+ * *
+ * Licensed under the Apache License, Version 2.0 (the "License"). You may *
+ * not use this file except in compliance with the License. You may obtain a *
+ * copy of the License at <http://www.apache.org/licenses/LICENSE-2.0>. *
+ * *
+ * Unless required by applicable law or agreed to in writing, software *
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT *
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the *
+ * License for the specific language governing permissions and limitations *
+ * under the License. *
+ * *
+ * ========================================================================== */
+package it.could.webdav.methods;
+
+import it.could.webdav.DAVException;
+import it.could.webdav.DAVMethod;
+import it.could.webdav.DAVResource;
+import it.could.webdav.DAVTransaction;
+
+import java.io.IOException;
+
+
+/**
+ * <p><a href="http://www.rfc-editor.org/rfc/rfc2518.txt">WebDAV</a>
+ * <code>MKCOL</code> metohd implementation.</p>
+ *
+ * @author <a href="http://could.it/">Pier Fumagalli</a>
+ */
+public class MKCOL implements DAVMethod {
+
+ /**
+ * <p>Create a new {@link MKCOL} instance.</p>
+ */
+ public MKCOL() {
+ super();
+ }
+
+ /**
+ * <p>Process the <code>MKCOL</code> method.</p>
+ */
+ public void process(DAVTransaction transaction, DAVResource resource)
+ throws IOException {
+
+ /* Unsupported media type, we don't want content */
+ if (transaction.hasRequestBody()) {
+ throw new DAVException (415, "No request body allowed in request");
+ }
+
+ /* Create the collection */
+ resource.makeCollection();
+ transaction.setStatus(201);
+ }
+}
Propchange: maven/archiva/branches/springy/archiva-web/archiva-webdav/src/main/java/it/could/webdav/methods/MKCOL.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: maven/archiva/branches/springy/archiva-web/archiva-webdav/src/main/java/it/could/webdav/methods/MOVE.java
URL: http://svn.apache.org/viewvc/maven/archiva/branches/springy/archiva-web/archiva-webdav/src/main/java/it/could/webdav/methods/MOVE.java?rev=636822&view=auto
==============================================================================
--- maven/archiva/branches/springy/archiva-web/archiva-webdav/src/main/java/it/could/webdav/methods/MOVE.java (added)
+++ maven/archiva/branches/springy/archiva-web/archiva-webdav/src/main/java/it/could/webdav/methods/MOVE.java Thu Mar 13 11:28:26 2008
@@ -0,0 +1,80 @@
+/* ========================================================================== *
+ * Copyright (C) 2004-2006, Pier Fumagalli <http://could.it/> *
+ * All rights reserved. *
+ * ========================================================================== *
+ * *
+ * Licensed under the Apache License, Version 2.0 (the "License"). You may *
+ * not use this file except in compliance with the License. You may obtain a *
+ * copy of the License at <http://www.apache.org/licenses/LICENSE-2.0>. *
+ * *
+ * Unless required by applicable law or agreed to in writing, software *
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT *
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the *
+ * License for the specific language governing permissions and limitations *
+ * under the License. *
+ * *
+ * ========================================================================== */
+package it.could.webdav.methods;
+
+import it.could.webdav.DAVException;
+import it.could.webdav.DAVMethod;
+import it.could.webdav.DAVMultiStatus;
+import it.could.webdav.DAVResource;
+import it.could.webdav.DAVTransaction;
+
+import java.io.IOException;
+import java.net.URI;
+
+
+/**
+ * <p><a href="http://www.rfc-editor.org/rfc/rfc2518.txt">WebDAV</a>
+ * <code>MOVE</code> metohd implementation.</p>
+ *
+ * @author <a href="http://could.it/">Pier Fumagalli</a>
+ */
+public class MOVE implements DAVMethod {
+
+ /**
+ * <p>Create a new {@link MOVE} instance.</p>
+ */
+ public MOVE() {
+ super();
+ }
+
+ /**
+ * <p>Process the <code>MOVE</code> method.</p>
+ */
+ public void process(DAVTransaction transaction, DAVResource resource)
+ throws IOException {
+ URI target = transaction.getDestination();
+ if (target == null) throw new DAVException(412, "No destination");
+ DAVResource dest = resource.getRepository().getResource(target);
+
+ int depth = transaction.getDepth();
+ boolean recursive = false;
+ if (depth == 0) {
+ recursive = false;
+ } else if (depth == DAVTransaction.INFINITY) {
+ recursive = true;
+ } else {
+ throw new DAVException(412, "Invalid Depth specified");
+ }
+
+ try {
+ int status;
+ if(! dest.isNull() && ! transaction.getOverwrite()) {
+ status = 412; // MOVE-on-existing should fail with 412
+ } else {
+ resource.move(dest, transaction.getOverwrite(), recursive);
+ if(transaction.getOverwrite()) {
+ status = 204; // No Content
+ } else {
+ status = 201; // Created
+ }
+ }
+ transaction.setStatus(status);
+ } catch (DAVMultiStatus multistatus) {
+ multistatus.write(transaction);
+ }
+ }
+}
Propchange: maven/archiva/branches/springy/archiva-web/archiva-webdav/src/main/java/it/could/webdav/methods/MOVE.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: maven/archiva/branches/springy/archiva-web/archiva-webdav/src/main/java/it/could/webdav/methods/OPTIONS.java
URL: http://svn.apache.org/viewvc/maven/archiva/branches/springy/archiva-web/archiva-webdav/src/main/java/it/could/webdav/methods/OPTIONS.java?rev=636822&view=auto
==============================================================================
--- maven/archiva/branches/springy/archiva-web/archiva-webdav/src/main/java/it/could/webdav/methods/OPTIONS.java (added)
+++ maven/archiva/branches/springy/archiva-web/archiva-webdav/src/main/java/it/could/webdav/methods/OPTIONS.java Thu Mar 13 11:28:26 2008
@@ -0,0 +1,52 @@
+/* ========================================================================== *
+ * Copyright (C) 2004-2006, Pier Fumagalli <http://could.it/> *
+ * All rights reserved. *
+ * ========================================================================== *
+ * *
+ * Licensed under the Apache License, Version 2.0 (the "License"). You may *
+ * not use this file except in compliance with the License. You may obtain a *
+ * copy of the License at <http://www.apache.org/licenses/LICENSE-2.0>. *
+ * *
+ * Unless required by applicable law or agreed to in writing, software *
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT *
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the *
+ * License for the specific language governing permissions and limitations *
+ * under the License. *
+ * *
+ * ========================================================================== */
+package it.could.webdav.methods;
+
+import it.could.webdav.DAVMethod;
+import it.could.webdav.DAVProcessor;
+import it.could.webdav.DAVResource;
+import it.could.webdav.DAVTransaction;
+
+import java.io.IOException;
+
+
+/**
+ * <p><a href="http://www.rfc-editor.org/rfc/rfc2616.txt">HTTP</a>
+ * <code>OPTIONS</code> metohd implementation.</p>
+ *
+ * @author <a href="http://could.it/">Pier Fumagalli</a>
+ */
+public class OPTIONS implements DAVMethod {
+
+ /**
+ * <p>Create a new {@link OPTIONS} instance.</p>
+ */
+ public OPTIONS() {
+ super();
+ }
+
+ /**
+ * <p>Process the <code>OPTIONS</code> method.</p>
+ */
+ public void process(DAVTransaction transaction, DAVResource resource)
+ throws IOException {
+ transaction.setHeader("Content-Type", resource.getContentType());
+ transaction.setHeader("Allow", DAVProcessor.METHODS);
+ transaction.setStatus(200);
+ }
+
+}
Propchange: maven/archiva/branches/springy/archiva-web/archiva-webdav/src/main/java/it/could/webdav/methods/OPTIONS.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: maven/archiva/branches/springy/archiva-web/archiva-webdav/src/main/java/it/could/webdav/methods/PROPFIND.java
URL: http://svn.apache.org/viewvc/maven/archiva/branches/springy/archiva-web/archiva-webdav/src/main/java/it/could/webdav/methods/PROPFIND.java?rev=636822&view=auto
==============================================================================
--- maven/archiva/branches/springy/archiva-web/archiva-webdav/src/main/java/it/could/webdav/methods/PROPFIND.java (added)
+++ maven/archiva/branches/springy/archiva-web/archiva-webdav/src/main/java/it/could/webdav/methods/PROPFIND.java Thu Mar 13 11:28:26 2008
@@ -0,0 +1,122 @@
+/* ========================================================================== *
+ * Copyright (C) 2004-2006, Pier Fumagalli <http://could.it/> *
+ * All rights reserved. *
+ * ========================================================================== *
+ * *
+ * Licensed under the Apache License, Version 2.0 (the "License"). You may *
+ * not use this file except in compliance with the License. You may obtain a *
+ * copy of the License at <http://www.apache.org/licenses/LICENSE-2.0>. *
+ * *
+ * Unless required by applicable law or agreed to in writing, software *
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT *
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the *
+ * License for the specific language governing permissions and limitations *
+ * under the License. *
+ * *
+ * ========================================================================== */
+package it.could.webdav.methods;
+
+import it.could.webdav.DAVException;
+import it.could.webdav.DAVMethod;
+import it.could.webdav.DAVResource;
+import it.could.webdav.DAVTransaction;
+import it.could.webdav.DAVUtilities;
+
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.util.Iterator;
+
+
+/**
+ * <p><a href="http://www.rfc-editor.org/rfc/rfc2518.txt">WebDAV</a>
+ * <code>PROPFIND</code> metohd implementation.</p>
+ *
+ * @author <a href="http://could.it/">Pier Fumagalli</a>
+ */
+public class PROPFIND implements DAVMethod {
+
+ /**
+ * <p>Create a new {@link PROPFIND} instance.</p>
+ */
+ public PROPFIND() {
+ super();
+ }
+
+ /**
+ * <p>Process the <code>PROPFIND</code> method.</p>
+ */
+ public void process(DAVTransaction transaction, DAVResource resource)
+ throws IOException {
+ /* Check if we have to force a resource not found or a redirection */
+ if (resource.isNull())
+ throw new DAVException(404, "Not found", resource);
+
+ /* Check depth */
+ int depth = transaction.getDepth();
+ if (depth > 1) new DAVException(403, "Invalid depth");
+
+ /* What to do on a collection resource */
+ transaction.setStatus(207);
+ transaction.setContentType("text/xml; charset=\"UTF-8\"");
+ PrintWriter out = transaction.write("UTF-8");
+
+ /* Output the XML declaration and the root document tag */
+ out.print("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
+ out.println("<D:multistatus xmlns:D=\"DAV:\">");
+
+ /* Process this resource's property (always) */
+ this.process(transaction, out, resource);
+
+ /* Process this resource's children (if required) */
+ if (resource.isCollection() && (depth > 0)) {
+ Iterator children = resource.getChildren();
+ while (children.hasNext()) {
+ DAVResource child = (DAVResource) children.next();
+ this.process(transaction, out, child);
+ }
+ }
+
+ /* Close up the XML Multi-Status response */
+ out.println("</D:multistatus>");
+ out.flush();
+ }
+
+ private void process(DAVTransaction txn, PrintWriter out, DAVResource res) {
+ /* The href of the resource is only the absolute path */
+ out.println(" <D:response>");
+ out.println(" <D:href>" + txn.lookup(res).getPath() + "</D:href>");
+ out.println(" <D:propstat>");
+ out.println(" <D:prop>");
+
+ /* Figure out what we're dealing with here */
+ if (res.isCollection()) {
+ this.process(out, "resourcetype", "<D:collection/>");
+ }
+ this.process(out, "getcontenttype", res.getContentType());
+
+ this.process(out, "getetag", res.getEntityTag());
+ String date = DAVUtilities.formatIsoDate(res.getCreationDate());
+ this.process(out, "creationdate", date);
+ String lmod = DAVUtilities.formatHttpDate(res.getLastModified());
+ this.process(out, "getlastmodified", lmod);
+ String clen = DAVUtilities.formatNumber(res.getContentLength());
+ this.process(out, "getcontentlength", clen);
+
+ out.println(" </D:prop>");
+ out.println(" <D:status>HTTP/1.1 200 OK</D:status>");
+ out.println(" </D:propstat>");
+ out.println(" </D:response>");
+ }
+
+ private void process(PrintWriter out, String name, String value) {
+ if (value == null) return;
+ out.print(" <D:");
+ out.print(name);
+ out.print(">");
+ out.print(value);
+ out.print("</D:");
+ out.print(name);
+ out.println(">");
+ }
+
+}
Propchange: maven/archiva/branches/springy/archiva-web/archiva-webdav/src/main/java/it/could/webdav/methods/PROPFIND.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: maven/archiva/branches/springy/archiva-web/archiva-webdav/src/main/java/it/could/webdav/methods/PROPPATCH.java
URL: http://svn.apache.org/viewvc/maven/archiva/branches/springy/archiva-web/archiva-webdav/src/main/java/it/could/webdav/methods/PROPPATCH.java?rev=636822&view=auto
==============================================================================
--- maven/archiva/branches/springy/archiva-web/archiva-webdav/src/main/java/it/could/webdav/methods/PROPPATCH.java (added)
+++ maven/archiva/branches/springy/archiva-web/archiva-webdav/src/main/java/it/could/webdav/methods/PROPPATCH.java Thu Mar 13 11:28:26 2008
@@ -0,0 +1,55 @@
+/* ========================================================================== *
+ * Copyright (C) 2004-2006, Pier Fumagalli <http://could.it/> *
+ * All rights reserved. *
+ * ========================================================================== *
+ * *
+ * Licensed under the Apache License, Version 2.0 (the "License"). You may *
+ * not use this file except in compliance with the License. You may obtain a *
+ * copy of the License at <http://www.apache.org/licenses/LICENSE-2.0>. *
+ * *
+ * Unless required by applicable law or agreed to in writing, software *
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT *
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the *
+ * License for the specific language governing permissions and limitations *
+ * under the License. *
+ * *
+ * ========================================================================== */
+package it.could.webdav.methods;
+
+import it.could.webdav.DAVException;
+import it.could.webdav.DAVMethod;
+import it.could.webdav.DAVResource;
+import it.could.webdav.DAVTransaction;
+
+import java.io.IOException;
+
+
+/**
+ * <p><a href="http://www.rfc-editor.org/rfc/rfc2518.txt">WebDAV</a>
+ * <code>PROPPATCH</code> metohd implementation.</p>
+ *
+ * <p>As this servlet does not handle the creation of custom properties, this
+ * method will always fail with a <code>403</code> (Forbidden).</p>
+ *
+ * @author <a href="http://could.it/">Pier Fumagalli</a>
+ */
+public class PROPPATCH implements DAVMethod {
+
+ /**
+ * <p>Create a new {@link PROPPATCH} instance.</p>
+ */
+ public PROPPATCH() {
+ super();
+ }
+
+ /**
+ * <p>Process the <code>PROPPATCH</code> method.</p>
+ *
+ * <p>As this servlet does not handle the creation of custom properties,
+ * this method will always fail with a <code>403</code> (Forbidden).</p>
+ */
+ public void process(DAVTransaction transaction, DAVResource resource)
+ throws IOException {
+ throw new DAVException(403, "All properties are immutable");
+ }
+}
Propchange: maven/archiva/branches/springy/archiva-web/archiva-webdav/src/main/java/it/could/webdav/methods/PROPPATCH.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: maven/archiva/branches/springy/archiva-web/archiva-webdav/src/main/java/it/could/webdav/methods/PUT.java
URL: http://svn.apache.org/viewvc/maven/archiva/branches/springy/archiva-web/archiva-webdav/src/main/java/it/could/webdav/methods/PUT.java?rev=636822&view=auto
==============================================================================
--- maven/archiva/branches/springy/archiva-web/archiva-webdav/src/main/java/it/could/webdav/methods/PUT.java (added)
+++ maven/archiva/branches/springy/archiva-web/archiva-webdav/src/main/java/it/could/webdav/methods/PUT.java Thu Mar 13 11:28:26 2008
@@ -0,0 +1,72 @@
+/* ========================================================================== *
+ * Copyright (C) 2004-2006, Pier Fumagalli <http://could.it/> *
+ * All rights reserved. *
+ * ========================================================================== *
+ * *
+ * Licensed under the Apache License, Version 2.0 (the "License"). You may *
+ * not use this file except in compliance with the License. You may obtain a *
+ * copy of the License at <http://www.apache.org/licenses/LICENSE-2.0>. *
+ * *
+ * Unless required by applicable law or agreed to in writing, software *
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT *
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the *
+ * License for the specific language governing permissions and limitations *
+ * under the License. *
+ * *
+ * ========================================================================== */
+package it.could.webdav.methods;
+
+import it.could.webdav.DAVException;
+import it.could.webdav.DAVMethod;
+import it.could.webdav.DAVOutputStream;
+import it.could.webdav.DAVResource;
+import it.could.webdav.DAVTransaction;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+
+/**
+ * <p><a href="http://www.rfc-editor.org/rfc/rfc2518.txt">WebDAV</a>
+ * <code>PUT</code> metohd implementation.</p>
+ *
+ * @author <a href="http://could.it/">Pier Fumagalli</a>
+ */
+public class PUT implements DAVMethod {
+
+ /**
+ * <p>Create a new {@link PUT} instance.</p>
+ */
+ public PUT() {
+ super();
+ }
+
+ /**
+ * <p>Process the <code>PUT</code> method.</p>
+ */
+ public void process(DAVTransaction transaction, DAVResource resource)
+ throws IOException {
+ /*
+ * The HTTP status code will depend on the existance of the resource:
+ * if not found: HTTP/1.1 201 Created
+ * if existing: HTTP/1.1 204 No Content
+ */
+ transaction.setStatus(resource.isNull()? 201: 204);
+
+ /* Open the streams for reading and writing */
+ InputStream in = transaction.read();
+ if (in == null) throw new DAVException(411, "Content-Length required");
+ DAVOutputStream out = resource.write();
+
+ /* Write the content from the PUT to the specified resource */
+ try {
+ byte buffer[] = new byte[4096];
+ int k = -1;
+ while ((k = in.read(buffer)) != -1) out.write(buffer, 0, k);
+ in.close();
+ out.close();
+ } finally {
+ out.abort();
+ }
+ }
+}
Propchange: maven/archiva/branches/springy/archiva-web/archiva-webdav/src/main/java/it/could/webdav/methods/PUT.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: maven/archiva/branches/springy/archiva-web/archiva-webdav/src/main/java/it/could/webdav/methods/package.html
URL: http://svn.apache.org/viewvc/maven/archiva/branches/springy/archiva-web/archiva-webdav/src/main/java/it/could/webdav/methods/package.html?rev=636822&view=auto
==============================================================================
--- maven/archiva/branches/springy/archiva-web/archiva-webdav/src/main/java/it/could/webdav/methods/package.html (added)
+++ maven/archiva/branches/springy/archiva-web/archiva-webdav/src/main/java/it/could/webdav/methods/package.html Thu Mar 13 11:28:26 2008
@@ -0,0 +1,12 @@
+<html>
+ <head>
+ <title>Could.IT WebDAV Servlet</title>
+ </head>
+ <body>
+ <p>
+ This package contains the implementation of all Level 1
+ <a href="http://www.rfc-editor.org/rfc/rfc2518.txt">WebDAV</a>
+ methods provided by this framework.
+ </p>
+ </body>
+</html>
\ No newline at end of file
Propchange: maven/archiva/branches/springy/archiva-web/archiva-webdav/src/main/java/it/could/webdav/methods/package.html
------------------------------------------------------------------------------
svn:eol-style = native
Added: maven/archiva/branches/springy/archiva-web/archiva-webdav/src/main/java/it/could/webdav/package.html
URL: http://svn.apache.org/viewvc/maven/archiva/branches/springy/archiva-web/archiva-webdav/src/main/java/it/could/webdav/package.html?rev=636822&view=auto
==============================================================================
--- maven/archiva/branches/springy/archiva-web/archiva-webdav/src/main/java/it/could/webdav/package.html (added)
+++ maven/archiva/branches/springy/archiva-web/archiva-webdav/src/main/java/it/could/webdav/package.html Thu Mar 13 11:28:26 2008
@@ -0,0 +1,134 @@
+<html>
+ <head>
+ <title>Could.IT WebDAV Servlet</title>
+ </head>
+ <body>
+ <p>
+ This package contains a minimal
+ <a href="http://java.sun.com/products/servlet/">Servlet</a>
+ based implementation of the
+ <a href="http://www.rfc-editor.org/rfc/rfc2518.txt">WebDAV</a>
+ specification.
+ </p>
+ <p>
+ This implementation does not in any way try to replace or extend the
+ <a href="http://jakarta.apache.org/slide/">Apache Slide</a>
+ <a href="http://www.rfc-editor.org/rfc/rfc2518.txt">WebDAV</a>
+ implementation, but tries to provide a <i>very light</i> and <i>extremely
+ minimal</i> alternative to be used in those scenarios where space is
+ a constraint (the <code>.jar</code> file is less than 100 kylobites),
+ and advanced features are not required.
+ </p>
+ <p>
+ The most visible limitations of this approach is that this
+ implementation does not offer any support for the <code>LOCK</code>
+ method (it is therefore not <i>DAV Level 2</i> compliant), and that
+ there limited support for properties:
+ </p>
+ <ul>
+ <li>
+ The <code>PROPFIND</code> will only return the <i>read-only</i>
+ <code>getcontenttype</code>, <code>getlastmodified</code>,
+ <code>getcontentlength</code>, <code>getetag</code> and
+ <code>resourcetype</code> properties.
+ </li>
+ <li>
+ The <code>PROPPATCH</code> will <i>always</i> fail with a
+ <code>403</code> <i>Not Found</i> error.
+ </li>
+ </ul>
+ <p>
+ Another important limitation is that this implementation will only and
+ exclusively provide access to a {@link java.io.File} based backend.
+ If you want to deploy your repository on another kind of backend (such
+ as SQL databases) please look at the WebDAV implementation provided by
+ <a href="http://jakarta.apache.org/slide/">Apache Slide</a>.
+ </p>
+
+ <h2>Configuration</h2>
+ <p>
+ The main entry point of this implementation is defined in the
+ {@link it.could.webdav.DAVServlet} class, which will handle all
+ <a href="http://www.rfc-editor.org/rfc/rfc2616.txt">HTTP</a> and
+ <a href="http://www.rfc-editor.org/rfc/rfc2518.txt">WebDAV</a> requests
+ for the URI path it is configured to handle.
+ </p>
+ <p>
+ To operate properly the {@link it.could.webdav.DAVServlet} class
+ must be configured in the web-application's <code>web.xml</code>
+ deployment descriptor. The relevant parts of a snippet of an example
+ configuration deployment descriptor might look like the following:
+ </p>
+ <pre>
+<servlet>
+ <servlet-name>dav</servlet-name>
+ <servlet-class>it.could.webdav.DAVServlet</servlet-class>
+ <init-param>
+ <param-name>rootPath</param-name>
+ <param-value>dav</param-value>
+ </init-param>
+ <init-param>
+ <param-name>xmlOnly</param-name>
+ <param-value>false</param-value>
+ </init-param>
+ <init-param>
+ <param-name>debugEnabled</param-name>
+ <param-value>false</param-value>
+ </init-param>
+ <load-on-startup>1</load-on-startup>
+</servlet>
+
+...
+
+<servlet-mapping>
+ <servlet-name>dav</servlet-name>
+ <url-pattern>/dav/*</url-pattern>
+</servlet-mapping>
+ </pre>
+ <p>
+ In this example the {@link it.could.webdav.DAVServlet} servlet
+ is configured with all parameters its parameters:
+ </p>
+ <dl>
+ <dt>rootPath</dt>
+ <dd>
+ <i>[required]</i> This parameter indicates the path of the root of the
+ repository.<br />
+ If the specified parameter represents a relative path, it will be
+ treated as a {@link javax.servlet.ServletContext#getResource(String)
+ ServletContext resource}.<br />
+ Note that if you choose to distribute your web application in a
+ <code>.war</code> archive, your container will have to expand it
+ before intializing the {@link javax.servlet.ServletContext} as this
+ this implementation <i>requires</i> a {@link java.io.File} based
+ repository.
+ </dd>
+ <dt>xmlOnly</dt>
+ <dd>
+ <i>[optional, default="<code>false</code>"]</i> This parameter
+ will instruct the {@link it.could.webdav.DAVServlet} to create
+ a very specialized version of the repository accepting only
+ <a href="http://www.w3.org/TR/REC-xml/#sec-well-formed">well-formed
+ XML</a> resources and collections.<br />
+ Note that when set to <code>true</code> this implementation will rely
+ on the <a href="http://java.sun.com/xml/jaxp/">JAXP</a> specification
+ to access a XML parser used to verify the <code>PUT</code> content.
+ </dd>
+ <dt>debugEnabled</dt>
+ <dd>
+ <i>[optional, default="<code>false</code>"]</i> This parameter
+ will instruct the {@link it.could.webdav.DAVServlet} to log
+ unimportant debugging information (such as the methods called by the
+ client) in the {@link javax.servlet.ServletContext#log(String) context
+ log}.
+ </dd>
+ </dl>
+ <p>
+ The configured {@link it.could.webdav.DAVServlet} will then have
+ to be mapped to a path, and in the example above, every request for
+ any URL beginning in <code>/dav/</code> will be handled by this
+ implementation, with a repository rooted in the <code>/dav/</code>
+ directory of the web application.
+ </p>
+ </body>
+</html>
\ No newline at end of file
Propchange: maven/archiva/branches/springy/archiva-web/archiva-webdav/src/main/java/it/could/webdav/package.html
------------------------------------------------------------------------------
svn:eol-style = native
Added: maven/archiva/branches/springy/archiva-web/archiva-webdav/src/main/java/it/could/webdav/replication/DAVReplica.java
URL: http://svn.apache.org/viewvc/maven/archiva/branches/springy/archiva-web/archiva-webdav/src/main/java/it/could/webdav/replication/DAVReplica.java?rev=636822&view=auto
==============================================================================
--- maven/archiva/branches/springy/archiva-web/archiva-webdav/src/main/java/it/could/webdav/replication/DAVReplica.java (added)
+++ maven/archiva/branches/springy/archiva-web/archiva-webdav/src/main/java/it/could/webdav/replication/DAVReplica.java Thu Mar 13 11:28:26 2008
@@ -0,0 +1,242 @@
+/* ========================================================================== *
+ * Copyright (C) 2004-2006, Pier Fumagalli <http://could.it/> *
+ * All rights reserved. *
+ * ========================================================================== *
+ * *
+ * Licensed under the Apache License, Version 2.0 (the "License"). You may *
+ * not use this file except in compliance with the License. You may obtain a *
+ * copy of the License at <http://www.apache.org/licenses/LICENSE-2.0>. *
+ * *
+ * Unless required by applicable law or agreed to in writing, software *
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT *
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the *
+ * License for the specific language governing permissions and limitations *
+ * under the License. *
+ * *
+ * ========================================================================== */
+package it.could.webdav.replication;
+
+import it.could.util.StreamTools;
+import it.could.util.http.WebDavClient;
+import it.could.util.location.Location;
+import it.could.webdav.DAVListener;
+import it.could.webdav.DAVLogger;
+import it.could.webdav.DAVRepository;
+import it.could.webdav.DAVResource;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * <p>TODO: Document this class.</p>
+ *
+ * @author <a href="http://could.it/">Pier Fumagalli</a>
+ */
+public class DAVReplica extends Thread implements DAVListener {
+
+ private static final int SYNCHRONIZE = -1;
+
+ private final DAVRepository repository;
+ private final DAVLogger logger;
+ private final Location location;
+ private final List actions = new ArrayList();
+
+ public DAVReplica(DAVRepository repository, Location location,
+ DAVLogger logger)
+ throws IOException {
+ this.location = new WebDavClient(location).getLocation();
+ this.repository = repository;
+ this.logger = logger;
+ this.start();
+ }
+
+ public void synchronize()
+ throws IOException {
+ this.logger.log("Scheduling full synchronization");
+ this.notify(this.repository.getResource((String)null), SYNCHRONIZE);
+ }
+
+ public void notify(DAVResource resource, int event) {
+ this.logger.debug("Event for \"" + resource.getRelativePath() + "\"");
+ if (resource.getRepository() != this.repository) return;
+ synchronized (this.actions) {
+ this.actions.add(new Action(resource, event));
+ this.actions.notify();
+ }
+ }
+
+ public void run() {
+ this.logger.debug("Starting background replica thread on " + location);
+ while (true) try {
+ final DAVReplica.Action array[];
+ synchronized(this.actions) {
+ try {
+ if (this.actions.isEmpty()) this.actions.wait();
+ final int s = this.actions.size();
+ array = (Action []) this.actions.toArray(new Action[s]);
+ this.actions.clear();
+ } catch (InterruptedException exception) {
+ this.logger.debug("Exiting background replica thread");
+ return;
+ }
+ }
+
+ for (int x = 0; x < array.length; x ++) try {
+ this.replicate(array[x]);
+ } catch (Throwable throwable) {
+ final String path = array[x].resource.getRelativePath();
+ final String message = "Error synchronizing resource " + path;
+ this.logger.log(message, throwable);
+ }
+ } catch (Throwable throwable) {
+ this.logger.log("Replica thread attempted suicide", throwable);
+ }
+ }
+
+ private void replicate(DAVReplica.Action action) {
+ final DAVResource resource = action.resource;
+
+ if (action.event == SYNCHRONIZE) {
+ this.synchronize(resource);
+
+ } else try {
+ final String path = resource.getParent().getRelativePath();
+ final Location location = this.location.resolve(path);
+ final WebDavClient client = new WebDavClient(location);
+ final String child = resource.getName();
+
+ switch(action.event) {
+ case RESOURCE_CREATED:
+ case RESOURCE_MODIFIED:
+ this.logger.debug("Putting resource " + path);
+ this.put(resource, client);
+ break;
+ case RESOURCE_REMOVED:
+ case COLLECTION_REMOVED:
+ this.logger.debug("Deleting resource " + path);
+ client.delete(child);
+ break;
+ case COLLECTION_CREATED:
+ this.logger.debug("Creating collection " + path);
+ client.mkcol(child);
+ break;
+ }
+ } catch (IOException exception) {
+ String message = "Error replicating " + resource.getRelativePath();
+ this.logger.log(message, exception);
+ }
+ }
+
+ private void put(DAVResource resource, WebDavClient client)
+ throws IOException {
+ final String name = resource.getName();
+ final long length = resource.getContentLength().longValue();
+ final OutputStream output = client.put(name, length);
+ final InputStream input = resource.read();
+ StreamTools.copy(input, output);
+ }
+
+ private void synchronize(DAVResource resource) {
+ /* Figure out the path of the resource */
+ final String path = resource.getRelativePath();
+
+ /* If it's a file or null, just skip the whole thing */
+ if (! resource.isCollection()) {
+ this.logger.log("Synchronization on non-collection " + path);
+ return;
+ }
+
+ /* Open a webdav client to the collection to synchronize */
+ this.logger.log("Synchronizing collection " + path);
+ final WebDavClient client;
+ try {
+ final Location location = this.location.resolve(path);
+ client = new WebDavClient(location);
+ } catch (IOException exception) {
+ this.logger.log("Error creating WebDAV client", exception);
+ return;
+ }
+
+ /* Create a list of all children from the DAV client */
+ final Set children = new HashSet();
+ for (Iterator iter = client.iterator(); iter.hasNext(); )
+ children.add(iter.next());
+
+ /* Process all resource children one by one and ensure they exist */
+ for (Iterator iter = resource.getChildren(); iter.hasNext(); ) {
+ final DAVResource child = (DAVResource) iter.next();
+ final String name = child.getName();
+
+ /* Remove this from the resources that will be removed later */
+ children.remove(name);
+
+ /* If the client doesn't have this child, add it to the replica */
+ if (! client.hasChild(name)) try {
+ if (child.isCollection()) {
+ this.logger.debug("Client doesn't have collection " + name);
+ client.mkcol(name);
+ this.synchronize(child);
+
+ } else {
+ this.logger.debug("Client doesn't have resource " + name);
+ this.put(child, client);
+ }
+ } catch (IOException exception) {
+ this.logger.log("Error creating new child " + name, exception);
+
+ /* If this child is a collection, it must be a collection on dav */
+ } else if (child.isCollection()) try {
+ if (!client.isCollection(name)) {
+ this.logger.debug("Recreating collection " + name);
+ client.delete(name).mkcol(name);
+ }
+ this.synchronize(child);
+ } catch (IOException exception) {
+ this.logger.log("Error creating collection " + name, exception);
+
+ /* Ok, the resource is a normal one, verify size and timestamp */
+ } else try {
+ final Date rlast = child.getLastModified();
+ final Date dlast = client.getLastModified(name);
+ if ((rlast != null) && (rlast.equals(dlast))) {
+ final Long rlen = child.getContentLength();
+ final long dlen = client.getContentLength(name);
+ if ((rlen == null) || (rlen.longValue() != dlen)) {
+ this.logger.debug("Resending resource " + name);
+ this.put(child, client.delete(name));
+ }
+ }
+ } catch (IOException exception) {
+ this.logger.log("Error resending resource " + name, exception);
+ }
+ }
+
+ /* Any other child that was not removed above, will go away now! */
+ for (Iterator iter = children.iterator(); iter.hasNext(); ) {
+ final String name = (String) iter.next();
+ try {
+ this.logger.debug("Removing leftovers " + name);
+ client.delete(name);
+ } catch (IOException exception) {
+ this.logger.log("Error removing left over " + name, exception);
+ }
+ }
+ }
+
+ private static final class Action {
+ final DAVResource resource;
+ final int event;
+
+ private Action(DAVResource resource, int event) {
+ this.resource = resource;
+ this.event = event;
+ }
+ }
+}
\ No newline at end of file
Propchange: maven/archiva/branches/springy/archiva-web/archiva-webdav/src/main/java/it/could/webdav/replication/DAVReplica.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: maven/archiva/branches/springy/archiva-web/archiva-webdav/src/main/java/it/could/webdav/replication/DAVReplicator.java
URL: http://svn.apache.org/viewvc/maven/archiva/branches/springy/archiva-web/archiva-webdav/src/main/java/it/could/webdav/replication/DAVReplicator.java?rev=636822&view=auto
==============================================================================
--- maven/archiva/branches/springy/archiva-web/archiva-webdav/src/main/java/it/could/webdav/replication/DAVReplicator.java (added)
+++ maven/archiva/branches/springy/archiva-web/archiva-webdav/src/main/java/it/could/webdav/replication/DAVReplicator.java Thu Mar 13 11:28:26 2008
@@ -0,0 +1,131 @@
+/* ========================================================================== *
+ * Copyright (C) 2004-2006, Pier Fumagalli <http://could.it/> *
+ * All rights reserved. *
+ * ========================================================================== *
+ * *
+ * Licensed under the Apache License, Version 2.0 (the "License"). You may *
+ * not use this file except in compliance with the License. You may obtain a *
+ * copy of the License at <http://www.apache.org/licenses/LICENSE-2.0>. *
+ * *
+ * Unless required by applicable law or agreed to in writing, software *
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT *
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the *
+ * License for the specific language governing permissions and limitations *
+ * under the License. *
+ * *
+ * ========================================================================== */
+package it.could.webdav.replication;
+
+import it.could.util.location.Location;
+import it.could.webdav.DAVListener;
+import it.could.webdav.DAVLogger;
+import it.could.webdav.DAVRepository;
+import it.could.webdav.DAVServlet;
+
+import javax.servlet.Servlet;
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServlet;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+import java.util.StringTokenizer;
+
+/**
+ * <p>The {@link DAVReplicator} class is a {@link DAVListener} replicating
+ * all content to the WebDAV repository specified at construction.</p>
+ *
+ * @author <a href="http://could.it/">Pier Fumagalli</a>
+ */
+public class DAVReplicator extends HttpServlet {
+
+ /** <p>The {@link DAVReplica} instances managed by this.</p> */
+ private final List replicas = new ArrayList();
+
+ /**
+ * <p>Create a new {@link DAVServlet} instance.</p>
+ */
+ public DAVReplicator() {
+ super();
+ }
+
+ /**
+ * <p>Initialize this {@link Servlet} instance.</p>
+ *
+ * <p>This servlet requires a couple of initialization parameters: the
+ * first one is "<code>repository</code>" indicating the name of
+ * the {@link DAVServlet} in the "<code>web.xml</code>" deployment
+ * descriptor whose repository should be replicated.</p>
+ *
+ * <p>The second required parameter "<code>replicas</code>"
+ * must contain a (whitespace separated list of) URL(s) where the original
+ * repository should be replicated to.</p>
+ *
+ * <p>Finally, when set to <code>true</code>, the optional parameter
+ * <code>debugEnabled</code> will enable logging of method invocation and
+ * events in the repository.</p>
+ */
+ public void init(ServletConfig config)
+ throws ServletException {
+ /* Initialize the super, just in case, and remember the context */
+ super.init(config);
+
+ /* Setup logging */
+ boolean debug = "true".equals(config.getInitParameter("debugEnabled"));
+ DAVLogger logger = new DAVLogger(config, debug);
+
+ /* Try to retrieve the WebDAV repository from the servlet context */
+ final String repositoryName = config.getInitParameter("repository");
+ final DAVRepository repository;
+ if (repositoryName == null) {
+ throw new ServletException("Parameter \"rootPath\" not specified");
+ } else try {
+ final String key = DAVServlet.getRepositoryKey(repositoryName);
+ final ServletContext context = config.getServletContext();
+ repository = (DAVRepository) context.getAttribute(key);
+ if (repository == null)
+ throw new ServletException("Unable to access repository from " +
+ "servlet \"" + repository + "\"");
+ } catch (ClassCastException exception) {
+ final String message = "Class cast exception accessing repository";
+ throw new ServletException(message, exception);
+ }
+
+ /* Access the different WebDAV replicas */
+ final String replicas = config.getInitParameter("replicas");
+ if (replicas == null) {
+ throw new ServletException("Parameter \"replicas\" not specified");
+ }
+
+ try {
+ final StringTokenizer tokenizer = new StringTokenizer(replicas);
+ while (tokenizer.hasMoreTokens()) {
+ final Location location = Location.parse(tokenizer.nextToken());
+ final DAVReplica replica = new DAVReplica(repository, location,
+ logger);
+ logger.log("Added repository replica to \"" + location + "\"");
+ repository.addListener(replica);
+ this.replicas.add(replica);
+ replica.synchronize();
+ }
+ } catch (IOException exception) {
+ throw new ServletException("Error creating replica", exception);
+ }
+
+ /* Check that we have at least one replica in */
+ if (this.replicas.size() != 0) return;
+ throw new ServletException("No replicas specified for repository");
+ }
+
+ /**
+ * <p>Destroy {@link DAVServlet} instance interrupting all running
+ * {@link DAVReplica} instances.</p>
+ */
+ public void destroy() {
+ for (Iterator iter = this.replicas.iterator(); iter.hasNext() ; ) {
+ ((DAVReplica) iter.next()).interrupt();
+ }
+ }
+}
Propchange: maven/archiva/branches/springy/archiva-web/archiva-webdav/src/main/java/it/could/webdav/replication/DAVReplicator.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: maven/archiva/branches/springy/archiva-web/archiva-webdav/src/main/java/it/could/webdav/replication/package.html
URL: http://svn.apache.org/viewvc/maven/archiva/branches/springy/archiva-web/archiva-webdav/src/main/java/it/could/webdav/replication/package.html?rev=636822&view=auto
==============================================================================
--- maven/archiva/branches/springy/archiva-web/archiva-webdav/src/main/java/it/could/webdav/replication/package.html (added)
+++ maven/archiva/branches/springy/archiva-web/archiva-webdav/src/main/java/it/could/webdav/replication/package.html Thu Mar 13 11:28:26 2008
@@ -0,0 +1,12 @@
+<html>
+ <head>
+ <title>Could.IT WebDAV Servlet</title>
+ </head>
+ <body>
+ <p>
+ This package contains a framework for maintaining fully replicated
+ <a href="http://www.rfc-editor.org/rfc/rfc2518.txt">WebDAV</a>
+ repositories.
+ </p>
+ </body>
+</html>
\ No newline at end of file
Propchange: maven/archiva/branches/springy/archiva-web/archiva-webdav/src/main/java/it/could/webdav/replication/package.html
------------------------------------------------------------------------------
svn:eol-style = native
Added: maven/archiva/branches/springy/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/AbstractDavServerComponent.java
URL: http://svn.apache.org/viewvc/maven/archiva/branches/springy/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/AbstractDavServerComponent.java?rev=636822&view=auto
==============================================================================
--- maven/archiva/branches/springy/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/AbstractDavServerComponent.java (added)
+++ maven/archiva/branches/springy/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/AbstractDavServerComponent.java Thu Mar 13 11:28:26 2008
@@ -0,0 +1,159 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.maven.archiva.webdav;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
+/**
+ * AbstractDavServerComponent
+ *
+ * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
+ * @version $Id: AbstractDavServerComponent.java 6000 2007-03-04 22:01:49Z joakime $
+ */
+public abstract class AbstractDavServerComponent
+ implements DavServerComponent
+{
+ private List listeners;
+ protected boolean useIndexHtml = false;
+
+ public AbstractDavServerComponent()
+ {
+ listeners = new ArrayList();
+ }
+
+ public void addListener( DavServerListener listener )
+ {
+ listeners.add( listener );
+ }
+
+ public void removeListener( DavServerListener listener )
+ {
+ listeners.remove( listener );
+ }
+
+ protected void triggerCollectionCreated( String resource )
+ {
+ Iterator it = listeners.iterator();
+ while ( it.hasNext() )
+ {
+ DavServerListener listener = (DavServerListener) it.next();
+ try
+ {
+ listener.serverCollectionCreated( this, resource );
+ }
+ catch ( Exception e )
+ {
+ /* ignore error */
+ }
+ }
+ }
+
+ protected void triggerCollectionRemoved( String resource )
+ {
+ Iterator it = listeners.iterator();
+ while ( it.hasNext() )
+ {
+ DavServerListener listener = (DavServerListener) it.next();
+ try
+ {
+ listener.serverCollectionRemoved( this, resource );
+ }
+ catch ( Exception e )
+ {
+ /* ignore error */
+ }
+ }
+ }
+
+ protected void triggerResourceCreated( String resource )
+ {
+ Iterator it = listeners.iterator();
+ while ( it.hasNext() )
+ {
+ DavServerListener listener = (DavServerListener) it.next();
+ try
+ {
+ listener.serverResourceCreated( this, resource );
+ }
+ catch ( Exception e )
+ {
+ /* ignore error */
+ }
+ }
+ }
+
+ protected void triggerResourceRemoved( String resource )
+ {
+ Iterator it = listeners.iterator();
+ while ( it.hasNext() )
+ {
+ DavServerListener listener = (DavServerListener) it.next();
+ try
+ {
+ listener.serverResourceRemoved( this, resource );
+ }
+ catch ( Exception e )
+ {
+ /* ignore error */
+ }
+ }
+ }
+
+ protected void triggerResourceModified( String resource )
+ {
+ Iterator it = listeners.iterator();
+ while ( it.hasNext() )
+ {
+ DavServerListener listener = (DavServerListener) it.next();
+ try
+ {
+ listener.serverResourceModified( this, resource );
+ }
+ catch ( Exception e )
+ {
+ /* ignore error */
+ }
+ }
+ }
+
+ public boolean hasResource( String resource )
+ {
+ File rootDir = getRootDirectory();
+ if ( rootDir == null )
+ {
+ return false;
+ }
+ File resourceFile = new File( rootDir, resource );
+ return resourceFile.exists();
+ }
+
+ public boolean isUseIndexHtml()
+ {
+ return this.useIndexHtml;
+ }
+
+ public void setUseIndexHtml( boolean useIndexHtml )
+ {
+ this.useIndexHtml = useIndexHtml;
+ }
+}
Propchange: maven/archiva/branches/springy/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/AbstractDavServerComponent.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: maven/archiva/branches/springy/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/DavServerComponent.java
URL: http://svn.apache.org/viewvc/maven/archiva/branches/springy/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/DavServerComponent.java?rev=636822&view=auto
==============================================================================
--- maven/archiva/branches/springy/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/DavServerComponent.java (added)
+++ maven/archiva/branches/springy/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/DavServerComponent.java Thu Mar 13 11:28:26 2008
@@ -0,0 +1,143 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.maven.archiva.webdav;
+
+import org.apache.maven.archiva.webdav.servlet.DavServerRequest;
+
+import javax.servlet.ServletConfig;
+import javax.servlet.ServletException;
+import javax.servlet.http.HttpServletResponse;
+import java.io.File;
+import java.io.IOException;
+
+/**
+ * DavServerComponent
+ *
+ * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
+ * @version $Id: DavServerComponent.java 6000 2007-03-04 22:01:49Z joakime $
+ */
+public interface DavServerComponent
+{
+ /** The Plexus ROLE name */
+ public static final String ROLE = DavServerComponent.class.getName();
+
+ /**
+ * Get the Prefix for this server component.
+ * @return the prefix associated with this component.
+ */
+ public String getPrefix();
+
+ /**
+ * Set the prefix for this server component.
+ * @param prefix the prefix to use.
+ */
+ public void setPrefix( String prefix );
+
+ /**
+ * <p>
+ * Flag to indicate how the dav server component should treat a GET request against
+ * a DAV Collection.
+ * </p>
+ *
+ * <p>
+ * If true, the collection being requested will be searched for an index.html (or index.htm)
+ * file to serve back, before it defaults to displaying the collection (directory) contents.
+ * </p>
+ *
+ * <p>
+ * If false, the collection will always be presented in as a list of contents.
+ * </p>
+ *
+ * @return true to use the index.html instead of directory contents.
+ */
+ public boolean isUseIndexHtml();
+
+ /**
+ * <p>
+ * Flag to indicate how the dav server component should treat a GET request against
+ * a DAV Collection.
+ * </p>
+ *
+ * <p>
+ * If true, the collection being requested will be searched for an index.html (or index.htm)
+ * file to serve back, before it defaults to displaying the collection (directory) contents.
+ * </p>
+ *
+ * <p>
+ * If false, the collection will always be presented in as a list of contents.
+ * </p>
+ *
+ * @param useIndexHtml true to use the index.html instead of directory contents.
+ */
+ public void setUseIndexHtml( boolean useIndexHtml );
+
+ /**
+ * Get the root directory for this server.
+ *
+ * @return the root directory for this server.
+ */
+ public File getRootDirectory();
+
+ /**
+ * Set the root directory for this server's content.
+ *
+ * @param rootDirectory the root directory for this server's content.
+ */
+ public void setRootDirectory( File rootDirectory );
+
+ /**
+ * Add a Server Listener for this server component.
+ *
+ * @param listener the listener to add for this component.
+ */
+ public void addListener( DavServerListener listener );
+
+ /**
+ * Remove a server listener for this server component.
+ *
+ * @param listener the listener to remove.
+ */
+ public void removeListener( DavServerListener listener );
+
+ /**
+ * Perform any initialization needed.
+ *
+ * @param servletConfig the servlet config that might be needed.
+ * @throws DavServerException if there was a problem initializing the server component.
+ */
+ public void init( ServletConfig servletConfig ) throws DavServerException;
+
+ /**
+ * Performs a simple filesystem check for the specified resource.
+ *
+ * @param resource the resource to check for.
+ * @return true if the resource exists.
+ */
+ public boolean hasResource( String resource );
+
+ /**
+ * Process incoming request.
+ *
+ * @param request the incoming request to process.
+ * @param response the outgoing response to provide.
+ */
+ public void process( DavServerRequest request, HttpServletResponse response )
+ throws DavServerException, ServletException, IOException;
+}
Propchange: maven/archiva/branches/springy/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/DavServerComponent.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: maven/archiva/branches/springy/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/DavServerException.java
URL: http://svn.apache.org/viewvc/maven/archiva/branches/springy/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/DavServerException.java?rev=636822&view=auto
==============================================================================
--- maven/archiva/branches/springy/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/DavServerException.java (added)
+++ maven/archiva/branches/springy/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/DavServerException.java Thu Mar 13 11:28:26 2008
@@ -0,0 +1,51 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.maven.archiva.webdav;
+
+/**
+ * DavServerException
+ *
+ * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
+ * @version $Id: DavServerException.java 5379 2007-01-07 22:54:41Z joakime $
+ */
+public class DavServerException
+ extends Exception
+{
+
+ public DavServerException()
+ {
+ }
+
+ public DavServerException( String message )
+ {
+ super( message );
+ }
+
+ public DavServerException( Throwable cause )
+ {
+ super( cause );
+ }
+
+ public DavServerException( String message, Throwable cause )
+ {
+ super( message, cause );
+ }
+
+}
Propchange: maven/archiva/branches/springy/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/DavServerException.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: maven/archiva/branches/springy/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/DavServerListener.java
URL: http://svn.apache.org/viewvc/maven/archiva/branches/springy/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/DavServerListener.java?rev=636822&view=auto
==============================================================================
--- maven/archiva/branches/springy/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/DavServerListener.java (added)
+++ maven/archiva/branches/springy/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/DavServerListener.java Thu Mar 13 11:28:26 2008
@@ -0,0 +1,39 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.maven.archiva.webdav;
+
+/**
+ * DavServerListener
+ *
+ * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
+ * @version $Id: DavServerListener.java 5379 2007-01-07 22:54:41Z joakime $
+ */
+public interface DavServerListener
+{
+ public void serverCollectionCreated( DavServerComponent server, String resource );
+
+ public void serverCollectionRemoved( DavServerComponent server, String resource );
+
+ public void serverResourceCreated( DavServerComponent server, String resource );
+
+ public void serverResourceRemoved( DavServerComponent server, String resource );
+
+ public void serverResourceModified( DavServerComponent server, String resource );
+}
Propchange: maven/archiva/branches/springy/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/DavServerListener.java
------------------------------------------------------------------------------
svn:eol-style = native
Added: maven/archiva/branches/springy/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/DavServerManager.java
URL: http://svn.apache.org/viewvc/maven/archiva/branches/springy/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/DavServerManager.java?rev=636822&view=auto
==============================================================================
--- maven/archiva/branches/springy/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/DavServerManager.java (added)
+++ maven/archiva/branches/springy/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/DavServerManager.java Thu Mar 13 11:28:26 2008
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+
+package org.apache.maven.archiva.webdav;
+
+import java.io.File;
+import java.util.Collection;
+
+/**
+ * DavServerManager
+ *
+ * @author <a href="mailto:joakim@erdfelt.com">Joakim Erdfelt</a>
+ * @version $Id: DavServerManager.java 6017 2007-03-06 00:39:53Z joakime $
+ */
+public interface DavServerManager
+{
+ /** The Plexus ROLE name. */
+ public static final String ROLE = DavServerManager.class.getName();
+
+ /**
+ * Create a DavServerComponent and start tracking it.
+ *
+ * @param prefix the prefix for this component.
+ * @param rootDirectory the root directory for this component's content. null to not set a root directory.
+ * @return the created component, suitable for use.
+ * @throws DavServerException
+ */
+ public DavServerComponent createServer( String prefix, File rootDirectory ) throws DavServerException;
+
+ /**
+ * Get the collection of tracked servers.
+ *
+ * @return Collection of {@link DavServerComponent} objects.
+ */
+ public Collection getServers();
+
+ /**
+ * Removes a specific server from the tracked list of servers.
+ *
+ * NOTE: This does not remove the associated files on disk, merely the reference being tracked.
+ *
+ * @param prefix the prefix to remove.
+ */
+ public void removeServer( String prefix );
+
+ /**
+ * Get the {@link DavServerComponent} associated with the specified prefix.
+ *
+ * @param prefix the prefix for the dav server component to use.
+ * @return the DavServerComponent, or null if not found.
+ */
+ public DavServerComponent getServer( String prefix );
+
+ /**
+ * Remove all servers being tracked by the manager.
+ */
+ public void removeAllServers();
+}
Propchange: maven/archiva/branches/springy/archiva-web/archiva-webdav/src/main/java/org/apache/maven/archiva/webdav/DavServerManager.java
------------------------------------------------------------------------------
svn:eol-style = native