You are viewing a plain text version of this content. The canonical link for it is here.
Posted to slide-dev@jakarta.apache.org by ju...@apache.org on 2003/04/02 14:59:33 UTC
cvs commit: jakarta-slide/src/webdav/client/src/org/apache/webdav/lib WebdavResource.java
juergen 2003/04/02 04:59:33
Modified: src/webdav/client/src/org/apache/webdav/lib
WebdavResource.java
Log:
implemented WebDAVResource.aclReportMethod. thanks to Martin Dulisch [mdulisch@s-und-n.de] for the donation.
Revision Changes Path
1.58 +95 -74 jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/WebdavResource.java
Index: WebdavResource.java
===================================================================
RCS file: /home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/lib/WebdavResource.java,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -r1.57 -r1.58
--- WebdavResource.java 1 Apr 2003 10:11:26 -0000 1.57
+++ WebdavResource.java 2 Apr 2003 12:59:33 -0000 1.58
@@ -63,6 +63,10 @@
package org.apache.webdav.lib;
+import java.util.*;
+import org.apache.commons.httpclient.*;
+import org.apache.webdav.lib.methods.*;
+
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
@@ -73,44 +77,12 @@
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.Enumeration;
-import java.util.Hashtable;
-import java.util.Locale;
-import java.util.TimeZone;
-import java.util.Vector;
-import org.apache.commons.httpclient.Credentials;
-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.commons.httpclient.methods.GetMethod;
import org.apache.commons.httpclient.methods.HeadMethod;
import org.apache.commons.httpclient.methods.PutMethod;
import org.apache.util.DOMUtils;
import org.apache.util.HttpURL;
import org.apache.util.WebdavStatus;
-import org.apache.webdav.lib.methods.AclMethod;
-import org.apache.webdav.lib.methods.CheckinMethod;
-import org.apache.webdav.lib.methods.CheckoutMethod;
-import org.apache.webdav.lib.methods.CopyMethod;
-import org.apache.webdav.lib.methods.DeleteMethod;
-import org.apache.webdav.lib.methods.DepthSupport;
-import org.apache.webdav.lib.methods.LabelMethod;
-import org.apache.webdav.lib.methods.LockMethod;
-import org.apache.webdav.lib.methods.MkWorkspaceMethod;
-import org.apache.webdav.lib.methods.MkcolMethod;
-import org.apache.webdav.lib.methods.MoveMethod;
-import org.apache.webdav.lib.methods.OptionsMethod;
-import org.apache.webdav.lib.methods.PropFindMethod;
-import org.apache.webdav.lib.methods.PropPatchMethod;
-import org.apache.webdav.lib.methods.ReportMethod;
-import org.apache.webdav.lib.methods.UncheckoutMethod;
-import org.apache.webdav.lib.methods.UnlockMethod;
-import org.apache.webdav.lib.methods.UpdateMethod;
-import org.apache.webdav.lib.methods.VersionControlMethod;
import org.apache.webdav.lib.properties.AclProperty;
import org.apache.webdav.lib.properties.LockDiscoveryProperty;
import org.apache.webdav.lib.properties.PrincipalCollectionSetProperty;
@@ -2100,7 +2072,7 @@
* respond with a <code>PrincipalCollectionSetProperty</code>
*/
public PrincipalCollectionSetProperty principalCollectionSetFindMethod(
- String path) throws HttpException, IOException {
+ String path) throws HttpException, IOException {
setClient();
@@ -2560,7 +2532,7 @@
if (aMethod != null && optionsMethod(httpURL.getPath())) {
while (allowedMethods.hasMoreElements()) {
if (aMethod.equalsIgnoreCase((String)
- allowedMethods.nextElement()))
+ allowedMethods.nextElement()))
return true;
}
}
@@ -2650,12 +2622,12 @@
if (type == OPTIONS_WORKSPACE){
Enumeration workspaces = response.getWorkspaces();
while (workspaces.hasMoreElements()){
- options.add(workspaces.nextElement().toString());
+ options.add(workspaces.nextElement().toString());
}
} else if (type == OPTIONS_VERSION_HISTORY){
Enumeration histories = response.getHistories();
while (histories.hasMoreElements()){
- options.add(histories.nextElement().toString());
+ options.add(histories.nextElement().toString());
}
}
@@ -2769,14 +2741,14 @@
// Default depth=0, type=by_name
ReportMethod method =
new ReportMethod(httpURL.getPath(), DepthSupport.DEPTH_0,
- properties.elements());
+ properties.elements());
client.executeMethod(method);
return method.getResponses();
}
public Enumeration reportMethod(HttpURL httpURL, Vector properties,
- int depth)
+ int depth)
throws HttpException, IOException {
setClient();
@@ -2786,15 +2758,15 @@
client.executeMethod(method);
/*first draft, does work anyhow
- Enumeration results = method.getAllResponseURLs();
+ Enumeration results = method.getAllResponseURLs();
- return results;*/
+ return results;*/
/* Enumeration responses = method.getResponses();
- ResponseEntity response = (ResponseEntity) responses.nextElement();
- String href = (String) response.getHref();
- Enumeration results = method.getResponseProperties(href);
+ ResponseEntity response = (ResponseEntity) responses.nextElement();
+ String href = (String) response.getHref();
+ Enumeration results = method.getResponseProperties(href);
- return results;*/
+ return results;*/
Vector results = new Vector();
@@ -2807,14 +2779,14 @@
// Set status code for this resource.
if ((thisResource == true) && (response.getStatusCode() > 0))
setStatusCode(response.getStatusCode());
- thisResource = false;
+ thisResource = false;
Enumeration responseProperties = method.getResponseProperties(href);
while (responseProperties.hasMoreElements()) {
Property property = (Property) responseProperties.nextElement();
sResult += "\n" + property.getName() + ":\t" +
DOMUtils.getTextValue(property.getElement());
- // results.addElement(DOMUtils.getTextValue(property.getElement()));
+ // results.addElement(DOMUtils.getTextValue(property.getElement()));
}
results.addElement(sResult);
}
@@ -2825,14 +2797,14 @@
// locate-by-history Report
public Enumeration reportMethod(HttpURL httpURL, Vector properties,
- Vector histUri, int depth)
+ Vector histUri, int depth)
throws HttpException, IOException {
setClient();
// Default depth=0, type=by_name
ReportMethod method =
new ReportMethod(httpURL.getPath(), depth, properties.elements(),
- histUri.elements());
+ histUri.elements());
client.executeMethod(method);
Vector results = new Vector();
@@ -2884,8 +2856,8 @@
sResult = response.toString();
/*while (responseProperties.hasMoreElements()) {
- Property property = (Property) responseProperties.nextElement();
- sResult += "\t" + DOMUtils.getTextValue(property.getElement());
+ Property property = (Property) responseProperties.nextElement();
+ sResult += "\t" + DOMUtils.getTextValue(property.getElement());
}*/
results.addElement(sResult);
@@ -3149,10 +3121,10 @@
* @deprecated it could be removed after the major version changes
*/
public boolean proppatchMethod(String propertyName, String propertyValue)
- throws HttpException, IOException {
+ throws HttpException, IOException {
boolean result = proppatchMethod(httpURL.getPath(),
- propertyName, propertyValue, true);
+ propertyName, propertyValue, true);
if (result) refresh();
return result;
@@ -3171,10 +3143,10 @@
* @exception IOException
*/
public boolean proppatchMethod(String propertyName, String propertyValue,
- boolean action) throws HttpException, IOException {
+ boolean action) throws HttpException, IOException {
boolean result = proppatchMethod(httpURL.getPath(),
- propertyName, propertyValue, action);
+ propertyName, propertyValue, action);
if (result) refresh();
return result;
@@ -3192,11 +3164,11 @@
* @deprecated it could be removed after the major version changes
*/
public boolean proppatchMethod(PropertyName propertyName,
- String propertyValue)
- throws HttpException, IOException {
+ String propertyValue)
+ throws HttpException, IOException {
boolean result = proppatchMethod(httpURL.getPath(),
- propertyName, propertyValue, true);
+ propertyName, propertyValue, true);
if (result) refresh();
return result;
@@ -3215,11 +3187,11 @@
* @exception IOException
*/
public boolean proppatchMethod(PropertyName propertyName,
- String propertyValue, boolean action)
- throws HttpException, IOException {
+ String propertyValue, boolean action)
+ throws HttpException, IOException {
boolean result = proppatchMethod(httpURL.getPath(),
- propertyName, propertyValue, action);
+ propertyName, propertyValue, action);
if (result) refresh();
return result;
@@ -3238,7 +3210,7 @@
* @deprecated it could be removed after the major version changes
*/
public boolean proppatchMethod(String path, String propertyName,
- String propertyValue) throws HttpException, IOException {
+ String propertyValue) throws HttpException, IOException {
Hashtable property = new Hashtable();
property.put(propertyName, propertyValue);
@@ -3260,8 +3232,8 @@
* @exception IOException
*/
public boolean proppatchMethod(String path, String propertyName,
- String propertyValue, boolean action)
- throws HttpException, IOException {
+ String propertyValue, boolean action)
+ throws HttpException, IOException {
Hashtable property = new Hashtable();
property.put(propertyName, propertyValue);
@@ -3281,7 +3253,7 @@
* @deprecated it could be removed after the major version changes
*/
public boolean proppatchMethod(String path, PropertyName propertyName,
- String propertyValue) throws HttpException, IOException {
+ String propertyValue) throws HttpException, IOException {
Hashtable property = new Hashtable();
property.put(propertyName, propertyValue);
@@ -3303,8 +3275,8 @@
* @exception IOException
*/
public boolean proppatchMethod(String path, PropertyName propertyName,
- String propertyValue, boolean action)
- throws HttpException, IOException {
+ String propertyValue, boolean action)
+ throws HttpException, IOException {
Hashtable property = new Hashtable();
property.put(propertyName, propertyValue);
@@ -3344,7 +3316,7 @@
* @exception IOException
*/
public boolean proppatchMethod(Hashtable properties, boolean action)
- throws HttpException, IOException {
+ throws HttpException, IOException {
boolean result = proppatchMethod(httpURL.getPath(), properties, action);
if (result) refresh();
@@ -3385,7 +3357,7 @@
* @exception IOException
*/
public boolean proppatchMethod(String path, Hashtable properties,
- boolean action) throws HttpException, IOException {
+ boolean action) throws HttpException, IOException {
setClient();
PropPatchMethod method = new PropPatchMethod(HttpURL.getPath(path));
@@ -3787,7 +3759,7 @@
* @exception IOException
*/
public boolean unlockMethod(String path)
- throws HttpException, IOException {
+ throws HttpException, IOException {
String owner = (httpURL.getUserName() != null) ?
httpURL.getUserName() : defaultOwner;
@@ -3841,7 +3813,7 @@
* @return state probably having lock information renewly
*/
protected WebdavState discoverLock(String owner, String path,
- WebdavState state) {
+ WebdavState state) {
if (lockDiscovery == null) return state;
Lock[] activeLocks = lockDiscovery.getActiveLocks();
@@ -4185,7 +4157,7 @@
*/
protected void processProperty(Property property) {
if (property.getLocalName().equals(DISPLAYNAME)) {
- displayName = property.getPropertyAsString();
+ displayName = property.getPropertyAsString();
}
else if (property.getLocalName().equals(GETCONTENTLENGTH)) {
String getContentLength = property.getPropertyAsString();
@@ -4230,6 +4202,55 @@
setLockDiscovery(lockDiscovery);
}
}
+
+
+ /**
+ * Execute REPORT method.
+ * This method is for the special Access Control Reports:
+ * - acl-principal-prop-set (not supported yet)
+ * - principal-match (not supported yet)
+ * - principal-property-search
+ * - principal-search-property-set (not supported yet)
+ *
+ * @param path The path to request.
+ * @param properties The named properties.
+ * @return an enumeration of <code>ResponseEntity</code>
+ * @exception HttpException
+ * @exception IOException
+ */
+ public Enumeration aclReportMethod(
+ String path,
+ Collection properties,
+ int reportType)
+ throws HttpException, IOException {
+
+ setClient();
+ AclReportMethod method =
+ new AclReportMethod(
+ HttpURL.getPath(path),
+ properties,
+ DepthSupport.DEPTH_INFINITY,
+ reportType);
+ int status = client.executeMethod(method);
+
+ // Set status code for this resource.
+ if (thisResource == true) {
+ // Set the status code.
+ setStatusCode(method.getStatusLine().getStatusCode());
+ }
+
+ //slide/tamino delivers status code OK.
+ //can be removed when the server sends MULTI_STATUS
+ if (status != HttpStatus.SC_MULTI_STATUS && status != HttpStatus.SC_OK) {
+ HttpException ex = new HttpException();
+ ex.setReasonCode(status);
+ throw ex;
+ }
+ thisResource = false;
+
+ return method.getResponses();
+ }
+
}
---------------------------------------------------------------------
To unsubscribe, e-mail: slide-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: slide-dev-help@jakarta.apache.org