pnever 2005/02/25 09:02:40
Modified: proposals/wvcm/src/javax/wvcm Tag: WVCM_1_0_BRANCH
AccessControlElement.java Resource.java
proposals/wvcm/src/org/apache/wvcm/store/webdav Tag:
WVCM_1_0_BRANCH
ControllableFolderWebdavAccessor.java
ControllableResourceWebdavAccessor.java
FolderWebdavAccessor.java
PrincipalWebdavAccessor.java
PrivilegeWebdavAccessor.java
ResourceWebdavAccessor.java WebdavAccessor.java
WorkspaceWebdavAccessor.java
proposals/wvcm/src/org/apache/wvcm/store/webdav/response
Tag: WVCM_1_0_BRANCH PropertiesFactory.java
proposals/wvcm/src/org/apache/wvcm/model Tag:
WVCM_1_0_BRANCH PropertyDescriptor.java
Log:
Added RetryHandler for CONFLICT responses from the server
Revision Changes Path
No revision
No revision
1.4.4.1 +5 -1
jakarta-slide/proposals/wvcm/src/javax/wvcm/AccessControlElement.java
Index: AccessControlElement.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/proposals/wvcm/src/javax/wvcm/AccessControlElement.java,v
retrieving revision 1.4
retrieving revision 1.4.4.1
diff -u -r1.4 -r1.4.4.1
--- AccessControlElement.java 30 Jul 2004 06:52:22 -0000 1.4
+++ AccessControlElement.java 25 Feb 2005 17:02:40 -0000 1.4.4.1
@@ -228,6 +228,10 @@
public void doCreateResource() throws WvcmException {
throw new UnsupportedOperationException("Not supported for
generic resources");
}
+
+ public String toString() {
+ return location().lastSegment();
+ }
}
}
}
1.10.4.1 +5 -1 jakarta-slide/proposals/wvcm/src/javax/wvcm/Resource.java
Index: Resource.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/proposals/wvcm/src/javax/wvcm/Resource.java,v
retrieving revision 1.10
retrieving revision 1.10.4.1
diff -u -r1.10 -r1.10.4.1
--- Resource.java 30 Jul 2004 06:52:22 -0000 1.10
+++ Resource.java 25 Feb 2005 17:02:40 -0000 1.10.4.1
@@ -1328,5 +1328,9 @@
public void doUnlock(LockToken lockToken) throws WvcmException {
throw new UnsupportedOperationException("Not supported for
generic resources");
}
+
+ public String toString() {
+ return location().string();
+ }
}
}
No revision
No revision
1.5.4.1 +5 -5
jakarta-slide/proposals/wvcm/src/org/apache/wvcm/store/webdav/ControllableFolderWebdavAccessor.java
Index: ControllableFolderWebdavAccessor.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/proposals/wvcm/src/org/apache/wvcm/store/webdav/ControllableFolderWebdavAccessor.java,v
retrieving revision 1.5
retrieving revision 1.5.4.1
diff -u -r1.5 -r1.5.4.1
--- ControllableFolderWebdavAccessor.java 30 Jul 2004 06:52:28 -0000
1.5
+++ ControllableFolderWebdavAccessor.java 25 Feb 2005 17:02:40 -0000
1.5.4.1
@@ -107,7 +107,7 @@
addLockTokens(method);
try {
- client().executeMethod( method );
+ method = (MkcolMethod)retryHandler().executeMethod( method );
int sc = method.getStatusCode();
String st = method.getStatusText();
switch( sc ) {
1.15.4.1 +11 -11
jakarta-slide/proposals/wvcm/src/org/apache/wvcm/store/webdav/ControllableResourceWebdavAccessor.java
Index: ControllableResourceWebdavAccessor.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/proposals/wvcm/src/org/apache/wvcm/store/webdav/ControllableResourceWebdavAccessor.java,v
retrieving revision 1.15
retrieving revision 1.15.4.1
diff -u -r1.15 -r1.15.4.1
--- ControllableResourceWebdavAccessor.java 30 Jul 2004 06:52:28 -0000
1.15
+++ ControllableResourceWebdavAccessor.java 25 Feb 2005 17:02:40 -0000
1.15.4.1
@@ -126,7 +126,7 @@
addLockTokens(method);
try {
- client().executeMethod( method );
+ method = (PutMethod)retryHandler().executeMethod( method );
int sc = method.getStatusCode();
String st = method.getStatusText();
switch( sc ) {
@@ -183,7 +183,7 @@
addLockTokens(method);
try {
- client().executeMethod( method );
+ method =
(CheckoutMethod)retryHandler(req.reqBodyAsString()).executeMethod( method );
int sc = method.getStatusCode();
String st = method.getStatusText();
switch( sc ) {
@@ -239,7 +239,7 @@
addLockTokens(method);
try {
- client().executeMethod( method );
+ method =
(CheckinMethod)retryHandler(req.reqBodyAsString()).executeMethod( method );
int sc = method.getStatusCode();
String st = method.getStatusText();
switch( sc ) {
@@ -285,7 +285,7 @@
addLockTokens(method);
try {
- client().executeMethod( method );
+ method = (UncheckoutMethod)retryHandler().executeMethod( method
);
int sc = method.getStatusCode();
String st = method.getStatusText();
switch( sc ) {
@@ -332,7 +332,7 @@
addLockTokens(method);
try {
- client().executeMethod( method );
+ method = (VersionControlMethod)retryHandler().executeMethod(
method );
int sc = method.getStatusCode();
String st = method.getStatusText();
switch( sc ) {
@@ -387,7 +387,7 @@
addLockTokens(method);
try {
- client().executeMethod( method );
+ method =
(UpdateMethod)retryHandler(req.reqBodyAsString()).executeMethod( method );
int sc = method.getStatusCode();
String st = method.getStatusText();
switch( sc ) {
@@ -444,7 +444,7 @@
addLockTokens(method);
try {
- client().executeMethod( method );
+ method =
(VersionControlMethod)retryHandler(req.reqBodyAsString()).executeMethod( method
);
int sc = method.getStatusCode();
String st = method.getStatusText();
switch( sc ) {
1.16.2.1 +7 -7
jakarta-slide/proposals/wvcm/src/org/apache/wvcm/store/webdav/FolderWebdavAccessor.java
Index: FolderWebdavAccessor.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/proposals/wvcm/src/org/apache/wvcm/store/webdav/FolderWebdavAccessor.java,v
retrieving revision 1.16
retrieving revision 1.16.2.1
diff -u -r1.16 -r1.16.2.1
--- FolderWebdavAccessor.java 8 Sep 2004 12:27:40 -0000 1.16
+++ FolderWebdavAccessor.java 25 Feb 2005 17:02:40 -0000 1.16.2.1
@@ -188,7 +188,7 @@
addLockTokens(method);
try {
- client().executeMethod( method );
+ method =
(BindMethod)retryHandler(req.reqBodyAsString()).executeMethod( method );
int sc = method.getStatusCode();
String st = method.getStatusText();
switch( sc ) {
@@ -251,7 +251,7 @@
addLockTokens(method);
try {
- client().executeMethod( method );
+ method =
(UnbindMethod)retryHandler(req.reqBodyAsString()).executeMethod( method );
int sc = method.getStatusCode();
String st = method.getStatusText();
switch( sc ) {
@@ -316,7 +316,7 @@
method.addRequestHeader( "Overwrite", (overwrite ? "T" : "F") );
try {
- client().executeMethod( method );
+ method =
(RebindMethod)retryHandler(req.reqBodyAsString()).executeMethod( method );
int sc = method.getStatusCode();
String st = method.getStatusText();
switch( sc ) {
1.3.4.1 +5 -5
jakarta-slide/proposals/wvcm/src/org/apache/wvcm/store/webdav/PrincipalWebdavAccessor.java
Index: PrincipalWebdavAccessor.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/proposals/wvcm/src/org/apache/wvcm/store/webdav/PrincipalWebdavAccessor.java,v
retrieving revision 1.3
retrieving revision 1.3.4.1
diff -u -r1.3 -r1.3.4.1
--- PrincipalWebdavAccessor.java 30 Jul 2004 06:52:28 -0000 1.3
+++ PrincipalWebdavAccessor.java 25 Feb 2005 17:02:40 -0000 1.3.4.1
@@ -106,7 +106,7 @@
method.addRequestHeader( "Content-Length", "0" );
try {
- client().executeMethod( method );
+ method = (MkcolMethod)retryHandler().executeMethod( method );
int sc = method.getStatusCode();
String st = method.getStatusText();
switch( sc ) {
1.3.4.1 +5 -5
jakarta-slide/proposals/wvcm/src/org/apache/wvcm/store/webdav/PrivilegeWebdavAccessor.java
Index: PrivilegeWebdavAccessor.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/proposals/wvcm/src/org/apache/wvcm/store/webdav/PrivilegeWebdavAccessor.java,v
retrieving revision 1.3
retrieving revision 1.3.4.1
diff -u -r1.3 -r1.3.4.1
--- PrivilegeWebdavAccessor.java 30 Jul 2004 06:52:28 -0000 1.3
+++ PrivilegeWebdavAccessor.java 25 Feb 2005 17:02:40 -0000 1.3.4.1
@@ -106,7 +106,7 @@
method.addRequestHeader( "Content-Length", "0" );
try {
- client().executeMethod( method );
+ method = (MkcolMethod)retryHandler().executeMethod( method );
int sc = method.getStatusCode();
String st = method.getStatusText();
switch( sc ) {
1.17.2.1 +126 -13
jakarta-slide/proposals/wvcm/src/org/apache/wvcm/store/webdav/ResourceWebdavAccessor.java
Index: ResourceWebdavAccessor.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/proposals/wvcm/src/org/apache/wvcm/store/webdav/ResourceWebdavAccessor.java,v
retrieving revision 1.17
retrieving revision 1.17.2.1
diff -u -r1.17 -r1.17.2.1
--- ResourceWebdavAccessor.java 8 Sep 2004 12:27:40 -0000 1.17
+++ ResourceWebdavAccessor.java 25 Feb 2005 17:02:40 -0000 1.17.2.1
@@ -66,8 +66,10 @@
import org.apache.wvcm.store.webdav.request.*;
import org.apache.wvcm.store.webdav.response.*;
+import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
+import java.lang.reflect.Constructor;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
@@ -81,6 +83,8 @@
import javax.wvcm.SearchToken;
import javax.wvcm.WvcmException;
import javax.wvcm.WvcmException.ReasonCode;
+import org.apache.commons.httpclient.Header;
+import org.apache.commons.httpclient.HttpException;
import org.apache.commons.httpclient.HttpMethod;
import org.apache.commons.httpclient.HttpStatus;
import org.apache.commons.httpclient.methods.EntityEnclosingMethod;
@@ -136,6 +140,18 @@
return getHttpClient( providerImpl, hostname, port );
}
+ protected RetryHandler retryHandler(InputStream content) {
+ return new RetryHandler(content);
+ }
+
+ protected RetryHandler retryHandler(String content) {
+ return new RetryHandler(content);
+ }
+
+ protected RetryHandler retryHandler() {
+ return retryHandler((String)null);
+ }
+
/**
* Return a new resource proxy at the location of the associated
resource containing
* the wanted properties. The exact resource type of the resulting
resource proxy
@@ -332,7 +348,7 @@
addLockTokens(method);
try {
- client().executeMethod( method );
+ method = (PutMethod)retryHandler(content).executeMethod( method
);
int sc = method.getStatusCode();
String st = method.getStatusText();
switch( sc ) {
@@ -384,7 +400,7 @@
addLockTokens(method);
try {
- client().executeMethod( method );
+ method =
(ProppatchMethod)retryHandler(req.reqBodyAsString()).executeMethod( method );
int sc = method.getStatusCode();
String st = method.getStatusText();
switch( sc ) {
@@ -455,7 +471,7 @@
addLockTokens(method);
try {
- client().executeMethod( method );
+ method = (DeleteMethod)retryHandler().executeMethod( method );
int sc = method.getStatusCode();
String st = method.getStatusText();
switch( sc ) {
@@ -541,7 +557,7 @@
addLockTokens(method);
try {
- client().executeMethod( method );
+ method = (MoveMethod)retryHandler().executeMethod( method );
int sc = method.getStatusCode();
String st = method.getStatusText();
switch( sc ) {
@@ -592,7 +608,7 @@
addLockTokens(method);
try {
- client().executeMethod( method );
+ method = (CopyMethod)retryHandler().executeMethod( method );
int sc = method.getStatusCode();
String st = method.getStatusText();
switch( sc ) {
@@ -796,7 +812,7 @@
addLockTokens(method);
try {
- client().executeMethod( method );
+ method =
(LabelMethod)retryHandler(req.reqBodyAsString()).executeMethod( method );
int sc = method.getStatusCode();
String st = method.getStatusText();
switch( sc ) {
@@ -908,7 +924,7 @@
addLockTokens(method);
try {
- client().executeMethod( method );
+ method =
(AclMethod)retryHandler(req.reqBodyAsString()).executeMethod( method );
int sc = method.getStatusCode();
String st = method.getStatusText();
switch( sc ) {
@@ -990,7 +1006,7 @@
method.addRequestHeader( "Depth", "0" );
try {
- client().executeMethod( method );
+ method =
(LockMethod)retryHandler(req.reqBodyAsString()).executeMethod( method );
int sc = method.getStatusCode();
String st = method.getStatusText();
switch( sc ) {
@@ -1037,7 +1053,7 @@
method.addRequestHeader( "Lock-Token",
"<"+((LockTokenImpl)lockToken).getLockId()+">" );
try {
- client().executeMethod( method );
+ method = (UnlockMethod)retryHandler().executeMethod( method );
int sc = method.getStatusCode();
String st = method.getStatusText();
switch( sc ) {
@@ -1067,6 +1083,103 @@
method.releaseConnection();
}
}
+
+ protected class RetryHandler {
+ private int retryMax = 5;
+ private long retryTimeout = 5000;
+ private long retrySleep = 500;
+ private InputStream content;
+ private String contentAsStr;
+
+ private int tries = 0;
+ private int rc = -1;
+ private long start = System.currentTimeMillis();
+
+ public RetryHandler(InputStream content) {
+ this.content = content;
+ init();
+ }
+
+ public RetryHandler(String content) {
+ this.contentAsStr = content;
+ init();
+ }
+
+ private void init() {
+ try { this.retryMax = Integer.parseInt(
(String)providerImpl.initParameter("retryMax") ); }
+ catch (NumberFormatException e) {}
+ try { this.retryTimeout = Integer.parseInt(
(String)providerImpl.initParameter("retryTimeout") ); }
+ catch (NumberFormatException e) {}
+ try { this.retrySleep = Integer.parseInt(
(String)providerImpl.initParameter("retrySleep") ); }
+ catch (NumberFormatException e) {}
+ }
+
+ public boolean canRetry() {
+ return (System.currentTimeMillis() - start) < retryTimeout &&
+ tries < retryMax &&
+ (rc == -1 || rc == HttpStatus.SC_CONFLICT);
+ }
+
+ public HttpMethod executeMethod(HttpMethod method) throws
IOException, HttpException {
+ while (canRetry()) {
+ if (rc > 0) {
+ try {
+ Thread.currentThread().sleep(retrySleep);
+ } catch (InterruptedException e) {}
+
+ // recycle method
+ Header[] headers = method.getRequestHeaders();
+ String resourcePath = method.getPath();
+ Class mclass = method.getClass();
+ Constructor mc = null;
+ HttpMethod newMethod = null;
+ try {
+ mc = mclass.getConstructor(new
Class[]{String.class});
+ newMethod = (HttpMethod)mc.newInstance(new
Object[]{resourcePath});
+ for (int i = 0; i < headers.length; i++) {
+ newMethod.setRequestHeader(headers[i]);
+ }
+ if (newMethod instanceof EntityEnclosingMethod) {
+ if (content != null) {
+ content.reset();
+
((EntityEnclosingMethod)newMethod).setRequestBody(content);
+ }
+ else if (contentAsStr != null) {
+
((EntityEnclosingMethod)newMethod).setRequestBody(contentAsStr);
+ }
+ }
+ }
+ catch (Exception e) {
+ e.printStackTrace();
+
//System.out.println("["+Thread.currentThread().getName()+"] RETRY FAILED
tries="+tries+", max tries="+maxtries+", elapsed="+(System.currentTimeMillis()
- start)+", timeout="+timeout);
+ return method;
+ }
+ method.releaseConnection();
+ method = newMethod;
+ }
+ rc = client().executeMethod(method);
+ //System.out.println("["+Thread.currentThread().getName()+"]
rc="+rc);
+ tries++;
+ }
+ if (tries > 1) {
+ if (rc != HttpStatus.SC_CONFLICT) {
+
//System.out.println("["+Thread.currentThread().getName()+"] RETRY SUCCESSFUL
tries="+tries+", max tries="+retryMax+", elapsed="+(System.currentTimeMillis()
- start)+", timeout="+retryTimeout);
+ }
+ else {
+
System.out.println("["+Thread.currentThread().getName()+"] RETRY FAILED
tries="+tries+", max tries="+retryMax+", elapsed="+(System.currentTimeMillis()
- start)+", timeout="+retryTimeout);
+ }
+ }
+ else {
+ if (rc != HttpStatus.SC_CONFLICT) {
+
//System.out.println("["+Thread.currentThread().getName()+"] FIRST TRY OK");
+ }
+ else {
+
System.out.println("["+Thread.currentThread().getName()+"] FIRST TRY FAILED
tries="+tries+", max tries="+retryMax+", elapsed="+(System.currentTimeMillis()
- start)+", timeout="+retryTimeout);
+ }
+ }
+ return method;
+ }
+ }
}
1.14.4.1 +43 -51
jakarta-slide/proposals/wvcm/src/org/apache/wvcm/store/webdav/WebdavAccessor.java
Index: WebdavAccessor.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/proposals/wvcm/src/org/apache/wvcm/store/webdav/WebdavAccessor.java,v
retrieving revision 1.14
retrieving revision 1.14.4.1
diff -u -r1.14 -r1.14.4.1
--- WebdavAccessor.java 30 Jul 2004 06:52:28 -0000 1.14
+++ WebdavAccessor.java 25 Feb 2005 17:02:40 -0000 1.14.4.1
@@ -62,13 +62,10 @@
*/
package org.apache.wvcm.store.webdav;
+import java.util.*;
+import org.apache.commons.httpclient.*;
+
import java.io.IOException;
-import java.util.Collections;
-import java.util.Enumeration;
-import java.util.HashMap;
-import java.util.Hashtable;
-import java.util.List;
-import java.util.Map;
import javax.wvcm.PropertyNameList;
import javax.wvcm.PropertyNameList.PropertyName;
import javax.wvcm.Provider;
@@ -76,12 +73,6 @@
import javax.wvcm.ProviderFactory.Callback.Authentication;
import javax.wvcm.WvcmException;
import javax.wvcm.WvcmException.ReasonCode;
-import org.apache.commons.httpclient.HttpClient;
-import org.apache.commons.httpclient.HttpException;
-import org.apache.commons.httpclient.HttpMethod;
-import org.apache.commons.httpclient.HttpState;
-import org.apache.commons.httpclient.HttpStatus;
-import org.apache.commons.httpclient.UsernamePasswordCredentials;
import org.apache.webdav.methods.OptionsMethod;
import org.apache.wvcm.ProviderImpl;
import org.apache.wvcm.store.Accessor;
@@ -96,30 +87,31 @@
* @version $Revision$
*/
public class WebdavAccessor implements Accessor {
-
+
+ // provider -> HttpClientWrapper
private static Map httpclients = Collections.synchronizedMap( new
HashMap() );
-
+
protected ProviderImpl providerImpl;
-
+
private String hostname = null;
private int port = 0;
private String defaultContext = null;
private Hashtable headers = null;
-
+
// caches
private String defaultContextPath = null;
-
+
static {
// do preemptive authentication
System.setProperty( "httpclient.authentication.preemptive", "true" );
}
-
+
/**
* Dummy constructor
*/
public WebdavAccessor() {
}
-
+
/**
* Constructor.
*/
@@ -136,7 +128,7 @@
}
initialize( hostname, port );
}
-
+
/**
* Return a list of [EMAIL PROTECTED] Folder} objects that identify
folders
* on the server that contain workspaces for the Provider of this
accessor.
@@ -147,14 +139,14 @@
public List serverWorkspaceFolderList(PropertyNameList
wantedPropertyList) throws WvcmException {
PropertyName[] wsfollist = {PropertyName.WORKSPACE_FOLDER_LIST};
OptionsRequest req = new OptionsRequest( new
PropertyNameList(wsfollist) );
-
+
// TODO: prio=h, effort=0.5, descr=(switch to live property
workspace-collection-set when implemeneted in server)
-
+
String resourcepath = defaultContextPath();
OptionsMethod method = new OptionsMethod( resourcepath );
method.setRequestBody( req.reqBodyAsString() );
method.addRequestHeader( "Content-Type", "text/xml;
charset=\"utf-8\"" );
-
+
try {
client().executeMethod( method );
int sc = method.getStatusCode();
@@ -176,20 +168,20 @@
throw new WvcmException(
"Read failed", resourcepath, ReasonCode.READ_FAILED, new
Exception[]{e});
}
-
+
}
-
+
//
-------------------------------------------------------------------------
// Non-interface methods
//
-------------------------------------------------------------------------
-
+
protected void initialize( String hostname, int port ) throws
IllegalStateException {
this.hostname = hostname;
this.port = port;
this.defaultContext = (String)providerImpl.initParameter( "context"
);
this.headers = (Hashtable)providerImpl.initParameter( "headers" );
}
-
+
/**
* Get the HttpClient of this accessor.
*
@@ -198,7 +190,7 @@
protected HttpClientWrapper client() {
return getHttpClient( providerImpl, hostname, port );
}
-
+
/**
* HttpClient factory.
*/
@@ -206,7 +198,7 @@
Host host = new Host( hostname, port );
HttpClientWrapper result = (HttpClientWrapper)httpclients.get( host
);
HttpClient httpclient = null;
-
+
if( result == null ) {
httpclient = new HttpClient();
httpclient.getHostConfiguration().setHost( hostname, port,
"http" );
@@ -216,11 +208,11 @@
else {
httpclient = result.getClient();
}
-
+
getAuthentication( hostname, result );
return result;
}
-
+
private void getAuthentication(String hostname, HttpClientWrapper
httpclientWrapper) {
String username = null;
String password = null;
@@ -231,7 +223,7 @@
Authentication authentication = cb.getAuthentication(realm, new
Integer(0));
username = authentication.loginName();
password = authentication.password();
-
+
if( authenticationChanged(hostname, realm, username, password,
httpclientWrapper.getClient()) ) {
HttpState state = new HttpState();
state.setCredentials(
@@ -240,7 +232,7 @@
}
}
}
-
+
private boolean authenticationChanged( String hostname, String realm,
String username, String password, HttpClient httpclient ) {
boolean sameUsername = false;
boolean samePassword = false;
@@ -248,20 +240,20 @@
UsernamePasswordCredentials currentCredentials = (currentState !=
null ? (UsernamePasswordCredentials)currentState.getCredentials(realm,
hostname) : null);
String currentUsername = (currentCredentials != null ?
currentCredentials.getUserName() : null);
String currentPassword = (currentCredentials != null ?
currentCredentials.getPassword() : null);
-
+
if( username == null )
sameUsername = (currentUsername == null);
else
sameUsername = username.equals( currentUsername );
-
+
if( password == null )
samePassword = (currentPassword == null);
else
samePassword = password.equals( currentPassword );
-
+
return !(sameUsername && samePassword);
}
-
+
/**
* Get context path
*
@@ -276,7 +268,7 @@
}
return defaultContextPath;
}
-
+
/**
* Host class
*/
@@ -284,21 +276,21 @@
String host;
int port;
String thread;
-
+
Host( String host, int port ) {
this.host = host;
this.port = port;
this.thread = Thread.currentThread().getName();
}
-
+
public int hashCode() {
return port;
}
-
+
public boolean equals( Object o ) {
if( !(o instanceof Host) )
return false;
-
+
Host a = (Host)o;
if( host != null && !host.equals(a.host) || host == null &&
a.host != null )
return false;
@@ -309,15 +301,15 @@
return true;
}
}
-
+
/**
* Wrapper for HttpClient
*/
protected static class HttpClientWrapper {
-
+
private HttpClient client;
private Provider provider;
-
+
/**
* Constructor
*
@@ -327,7 +319,7 @@
this.client = client;
this.provider = provider;
}
-
+
public int executeMethod(HttpMethod method) throws IOException,
HttpException {
ProviderImpl p = (ProviderImpl)provider;
method.addRequestHeader("User-Agent", "wvcm");
@@ -342,7 +334,7 @@
}
return client.executeMethod(method);
}
-
+
public HttpClient getClient() {
return client;
}
1.15.4.1 +5 -5
jakarta-slide/proposals/wvcm/src/org/apache/wvcm/store/webdav/WorkspaceWebdavAccessor.java
Index: WorkspaceWebdavAccessor.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/proposals/wvcm/src/org/apache/wvcm/store/webdav/WorkspaceWebdavAccessor.java,v
retrieving revision 1.15
retrieving revision 1.15.4.1
diff -u -r1.15 -r1.15.4.1
--- WorkspaceWebdavAccessor.java 30 Jul 2004 06:52:28 -0000 1.15
+++ WorkspaceWebdavAccessor.java 25 Feb 2005 17:02:40 -0000 1.15.4.1
@@ -105,7 +105,7 @@
method.addRequestHeader( "Content-Length", "0" );
try {
- client().executeMethod( method );
+ method = (MkworkspaceMethod)retryHandler().executeMethod( method
);
int sc = method.getStatusCode();
String st = method.getStatusText();
switch( sc ) {
No revision
No revision
1.4.4.1 +31 -35
jakarta-slide/proposals/wvcm/src/org/apache/wvcm/store/webdav/response/PropertiesFactory.java
Index: PropertiesFactory.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/proposals/wvcm/src/org/apache/wvcm/store/webdav/response/PropertiesFactory.java,v
retrieving revision 1.4
retrieving revision 1.4.4.1
diff -u -r1.4 -r1.4.4.1
--- PropertiesFactory.java 30 Jul 2004 06:52:31 -0000 1.4
+++ PropertiesFactory.java 25 Feb 2005 17:02:40 -0000 1.4.4.1
@@ -62,49 +62,23 @@
*/
package org.apache.wvcm.store.webdav.response;
+import java.util.*;
+import javax.wvcm.*;
+import org.apache.wvcm.*;
+import org.jdom.*;
+
import java.io.IOException;
import java.io.StringBufferInputStream;
import java.io.StringWriter;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Date;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Locale;
-import java.util.Map;
-import java.util.NoSuchElementException;
-import java.util.StringTokenizer;
-import javax.wvcm.ControllableFolder;
-import javax.wvcm.Location;
-import javax.wvcm.PropertyNameList;
import javax.wvcm.PropertyNameList.AttributeName;
import javax.wvcm.PropertyNameList.NestedPropertyName;
import javax.wvcm.PropertyNameList.PropertyName;
-import javax.wvcm.Provider;
-import javax.wvcm.Resource;
-import javax.wvcm.WvcmException;
import javax.wvcm.WvcmException.ReasonCode;
-import org.apache.wvcm.ControllableFolderImpl;
-import org.apache.wvcm.FolderImpl;
-import org.apache.wvcm.LocationImpl;
-import org.apache.wvcm.PrivilegeImpl;
-import org.apache.wvcm.ProviderImpl;
-import org.apache.wvcm.ResourceImpl;
import org.apache.wvcm.model.PropertyDescriptor;
import org.apache.wvcm.store.webdav.DateRepresentations;
import org.apache.wvcm.store.webdav.WebdavProperties;
import org.apache.wvcm.util.PropertyNameLists;
import org.apache.wvcm.util.XPathWrapper;
-import org.jdom.CDATA;
-import org.jdom.Comment;
-import org.jdom.Document;
-import org.jdom.Element;
-import org.jdom.EntityRef;
-import org.jdom.JDOMException;
-import org.jdom.Namespace;
-import org.jdom.ProcessingInstruction;
-import org.jdom.Text;
-import org.jdom.input.SAXBuilder;
import org.jdom.output.XMLOutputter;
/**
@@ -297,6 +271,10 @@
propvalue = propertyElm.getTextTrim();
propvalue = new Float( (String)propvalue );
}
+
+ if (propname.getString().endsWith("privilege-list")) {
+ propvalue = createSupportedPrivilegeList(propertyElm);
+ }
}
else {
Iterator k = propertyElm.getContent().iterator();
@@ -384,6 +362,24 @@
return privileges;
}
+ private List createSupportedPrivilegeList(Element propertyElm) throws
WvcmException {
+ List privileges = new ArrayList();
+ XPathWrapper xp = new XPathWrapper("//d:privilege", dnsp);
+ Iterator i = xp.selectNodes(propertyElm).iterator();
+ while (i.hasNext()) {
+ Element pElm = (Element)((Element)i.next()).getChildren().get(0);
+ Location privilegesLocation =
((ProviderImpl)provider).serverPrivilegesLocation();
+ if ("all".equals(pElm.getName())) {
+ privileges.add(AccessControlElement.Privilege.ALL);
+ }
+ else {
+ LocationImpl l =
(LocationImpl)privilegesLocation.child(pElm.getName());
+ privileges.add( l.resource(PrivilegeImpl.class) );
+ }
+ }
+ return privileges;
+ }
+
private String[] tokenizeContentType( String propvalue ) {
String[] result = new String[]{"",""};
if( propvalue == null || propvalue.length() == 0 )
No revision
No revision
1.14.4.1 +6 -5
jakarta-slide/proposals/wvcm/src/org/apache/wvcm/model/PropertyDescriptor.java
Index: PropertyDescriptor.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/proposals/wvcm/src/org/apache/wvcm/model/PropertyDescriptor.java,v
retrieving revision 1.14
retrieving revision 1.14.4.1
diff -u -r1.14 -r1.14.4.1
--- PropertyDescriptor.java 30 Jul 2004 06:52:26 -0000 1.14
+++ PropertyDescriptor.java 25 Feb 2005 17:02:40 -0000 1.14.4.1
@@ -198,7 +198,8 @@
propertyDescriptors.put( PropertyName.OWNER, new
PropertyDescriptor(PrincipalImpl.class, null) );
propertyDescriptors.put( PropertyName.PRINCIPAL_FOLDER_LIST, new
PropertyDescriptor(FolderImpl.class, ArrayList.class) );
propertyDescriptors.put( PropertyName.PRIVILEGE_FOLDER_LIST, new
PropertyDescriptor(FolderImpl.class, ArrayList.class) );
- propertyDescriptors.put( PropertyName.SUPPORTED_PRIVILEGE_LIST, new
PropertyDescriptor(PrivilegeImpl.class, ArrayList.class) );
+// propertyDescriptors.put( PropertyName.SUPPORTED_PRIVILEGE_LIST,
new PropertyDescriptor(ResourceImpl.XmlPropertyValue.class, ArrayList.class));
+ propertyDescriptors.put( PropertyName.SUPPORTED_PRIVILEGE_LIST, new
PropertyDescriptor(PrivilegeImpl.class, ArrayList.class){public boolean
isHref(){return false;}});
propertyDescriptors.put( PropertyName.MODIFICATION_DATE, new
PropertyDescriptor(Date.class, null) );
propertyDescriptors.put( PropertyName.CREATION_USER, new
PropertyDescriptor(PrincipalImpl.class, null) );
propertyDescriptors.put( PropertyName.MODIFICATION_USER, new
PropertyDescriptor(PrincipalImpl.class, null) );
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]