dirkv 01/07/30 13:11:43
Modified: src/webdav/client/src/org/apache/webdav/cmd Slide.java
Log:
new command:
locks [<path>] Displays locks on specified resource
Revision Changes Path
1.35 +94 -3
jakarta-slide/src/webdav/client/src/org/apache/webdav/cmd/Slide.java
Index: Slide.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/cmd/Slide.java,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -r1.34 -r1.35
--- Slide.java 2001/07/22 16:56:22 1.34
+++ Slide.java 2001/07/30 20:11:43 1.35
@@ -1,7 +1,7 @@
/*
- * $Header:
/home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/cmd/Slide.java,v 1.34
2001/07/22 16:56:22 remm Exp $
- * $Revision: 1.34 $
- * $Date: 2001/07/22 16:56:22 $
+ * $Header:
/home/cvs/jakarta-slide/src/webdav/client/src/org/apache/webdav/cmd/Slide.java,v 1.35
2001/07/30 20:11:43 dirkv Exp $
+ * $Revision: 1.35 $
+ * $Date: 2001/07/30 20:11:43 $
*
* ====================================================================
*
@@ -86,10 +86,13 @@
import org.apache.webdav.lib.WebdavResource;
import org.apache.webdav.lib.methods.*;
+import org.apache.webdav.lib.methods.DepthSupport;
import org.apache.webdav.lib.properties.AclProperty;
import org.apache.webdav.lib.properties.PrincipalCollectionSetProperty;
+import org.apache.webdav.lib.properties.LockDiscoveryProperty;
import org.apache.webdav.lib.Ace;
import org.apache.webdav.lib.Privilege;
+import org.apache.webdav.lib.Lock;
/**
* The Slide client, the command line version for WebDAV client.
@@ -1281,6 +1284,28 @@
}
}
} else
+ if (todo.equalsIgnoreCase("locks")) {
+ String path=null;
+ int count = params.size();
+ if (count>1) {
+ System.out.println("locks has a maximum of
1 argument");
+ continue;
+ }
+ if (count==1) {
+ path=checkUri((String)params.pop());
+ }
+ else {
+ path=webdavResource.getPath();
+ }
+ LockDiscoveryProperty
lockDiscoveryProperty=webdavResource.lockDiscoveryPropertyFindMethod(path);
+ if (lockDiscoveryProperty==null) {
+ System.out.println("Server did not
return a LockDiscoveryProperty.");
+
System.err.println(webdavResource.getStatusMessage());
+ continue;
+ }
+ Lock[]
locks=lockDiscoveryProperty.getActiveLocks();
+ showLocks(path,locks);
+ } else
if (todo.equalsIgnoreCase("lock")) {
if (params.size() == 1) {
String path = checkUri((String) params.pop());
@@ -1300,6 +1325,9 @@
e.getMessage());
}
}
+ else {
+ System.out.println("Syntax: lock
<path>");
+ }
} else
if (todo.equalsIgnoreCase("unlock")) {
if (params.size() == 1) {
@@ -1320,6 +1348,9 @@
e.getMessage());
}
}
+ else {
+ System.out.println("Syntax: unlock <path>");
+ }
} else
if (todo.equalsIgnoreCase("set")) {
if (params.size() == 2) {
@@ -1597,6 +1628,8 @@
"Lock specified resource");
System.out.println(" unlock path " +
"Unlock specified resource");
+ System.out.println(" locks [<path>] " +
+ "Displays locks on specified resource");
System.out.println(" propget path property ... " +
"Print value of specified property");
System.out.println(" propput path property value " +
@@ -1842,5 +1875,63 @@
}
}
System.out.println("------------------------------------------------------------");
+ }
+
+ private void showLocks(String path, Lock[] locks)
+ {
+ System.out.println("Locks for " + path + ":");
+
System.out.println("------------------------------------------------------------");
+ for (int i=0; i<locks.length ; i++)
+ {
+ int lockScope = locks[i].getLockScope();
+ if (lockScope==Lock.SCOPE_EXCLUSIVE) {
+ System.out.print("Exclusive ");
+ }
+ else if (lockScope==Lock.SCOPE_SHARED) {
+ System.out.print("Shared ");
+ }
+ else if (lockScope==-1) {
+ System.out.print("Unknown scope ");
+ }
+ else {
+ System.out.println("!!! Internal error !!!");
+ return;
+ }
+
+ int lockType = locks[i].getLockType();
+ if (lockType==Lock.TYPE_WRITE) {
+ System.out.println("write lock");
+ }
+ else if (lockType==-1) {
+ System.out.println("unknown type");
+ }
+ else {
+ System.out.println("!!! Internal error !!!");
+ return;
+ }
+
+ int depth=locks[i].getDepth();
+ if (depth==DepthSupport.DEPTH_INFINITY) {
+ System.out.println(" depth: infinity");
+ }
+ else if (depth==-1) {
+ // unknown
+ }
+ else {
+ System.out.println(" depth: " + depth);
+ }
+
+ String owner=locks[i].getOwner();
+ if (owner!=null)
+ System.out.println(" owner: " + owner);
+
+ long timeout=locks[i].getTimeout();
+ if (timeout!=-1)
+ System.out.println(" timeout: " + timeout);
+
+ String token=locks[i].getLockToken();
+ if (token!=null)
+ System.out.println(" token: " + token);
+ }
}
}
- cvs commit: jakarta-slide/src/webdav/client/src/org/apache/webdav/... remm
- cvs commit: jakarta-slide/src/webdav/client/src/org/apache/webdav/... remm
- cvs commit: jakarta-slide/src/webdav/client/src/org/apache/webdav/... jericho
- cvs commit: jakarta-slide/src/webdav/client/src/org/apache/webdav/... jericho
- cvs commit: jakarta-slide/src/webdav/client/src/org/apache/webdav/... remm
- cvs commit: jakarta-slide/src/webdav/client/src/org/apache/webdav/... dirkv
- cvs commit: jakarta-slide/src/webdav/client/src/org/apache/webdav/... dirkv
- cvs commit: jakarta-slide/src/webdav/client/src/org/apache/webdav/... dirkv
- cvs commit: jakarta-slide/src/webdav/client/src/org/apache/webdav/... dirkv
- cvs commit: jakarta-slide/src/webdav/client/src/org/apache/webdav/... remm
- cvs commit: jakarta-slide/src/webdav/client/src/org/apache/webdav/... dirkv
- cvs commit: jakarta-slide/src/webdav/client/src/org/apache/webdav/... dirkv
- cvs commit: jakarta-slide/src/webdav/client/src/org/apache/webdav/... dirkv
- cvs commit: jakarta-slide/src/webdav/client/src/org/apache/webdav/... dirkv
- cvs commit: jakarta-slide/src/webdav/client/src/org/apache/webdav/... dirkv
- cvs commit: jakarta-slide/src/webdav/client/src/org/apache/webdav/... dirkv
- cvs commit: jakarta-slide/src/webdav/client/src/org/apache/webdav/... dirkv
- cvs commit: jakarta-slide/src/webdav/client/src/org/apache/webdav/... juergen
- cvs commit: jakarta-slide/src/webdav/client/src/org/apache/webdav/... jericho
- Re: cvs commit: jakarta-slide/src/webdav/client/src/org/apache/web... Sung-Gu
