ozeigermann 2004/07/06 05:43:51
Modified: webdavclient/clientlib/src/java/org/apache/webdav/lib
WebdavResource.java
webdavclient/commandline/src/java/org/apache/webdav/cmd
Client.java
Log:
Removed superfluous path parameter and added Javadocs
Revision Changes Path
1.21 +51 -9
jakarta-slide/webdavclient/clientlib/src/java/org/apache/webdav/lib/WebdavResource.java
Index: WebdavResource.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/webdavclient/clientlib/src/java/org/apache/webdav/lib/WebdavResource.java,v
retrieving revision 1.20
retrieving revision 1.21
diff -u -r1.20 -r1.21
--- WebdavResource.java 5 Jul 2004 15:23:55 -0000 1.20
+++ WebdavResource.java 6 Jul 2004 12:43:51 -0000 1.21
@@ -4194,8 +4194,23 @@
return lockMethod(path, owner, (int) timeout);
}
-
- public boolean startTransaction(String path, String owner, int timeout) throws
IOException {
+ /**
+ * Begins a new transaction.
+ * The transaction handle returned by the WebDAV server will be remembered and
included
+ * as a header of subsequent requests until either [EMAIL PROTECTED]
#commitTransaction()} or [EMAIL PROTECTED] #abortTransaction()}
+ * are called. You can retrieve it using [EMAIL PROTECTED]
#getTransactionHandle()}.
+ *
+ * @param owner the owner of this transaction
+ * @param timeout timeout in milleseconds
+ * @return <code>true</code> if the transaction has been successfully started,
<code>false</code> otherwise
+ * @throws IOException if anything goes wrong
+ * @see #commitTransaction()
+ * @see #abortTransaction()
+ * @see #getTransactionHandle()
+ */
+ public boolean startTransaction(String owner, int timeout) throws IOException {
+ String path = httpURL.getPath();
+
setClient();
if (owner == null) {
@@ -4222,7 +4237,14 @@
return (statusCode >= 200 && statusCode < 300) ? true : false;
}
-
+
+ /**
+ * Returns the transaction handle set by [EMAIL PROTECTED]
#startTransaction(String, int)}.
+ *
+ * @return the current transaction handle or <code>null</code> if the client
does not operate inside a transaction
+ * @throws IOException if anything goes wrong
+ * @see #startTransaction(String, int)
+ */
public String getTransactionHandle() throws IOException {
setClient();
@@ -4233,15 +4255,35 @@
return txHandle;
}
- public boolean commitTransaction(String path) throws IOException {
+ /**
+ * Commits the transaction started by [EMAIL PROTECTED]
#startTransaction(String, int)} and resets the transaction handle.
+ *
+ * @return <code>true</code> if the transaction has been successfully
committed, <code>false</code> otherwise
+ * @throws IOException if anything goes wrong
+ * @see #startTransaction(String, int)
+ * @see #abortTransaction()
+ * @see #getTransactionHandle()
+ */
+ public boolean commitTransaction() throws IOException {
+ String path = httpURL.getPath();
return endTransaction(path, UnlockMethod.COMMIT_TRANSACTION);
}
- public boolean abortTransaction(String path) throws IOException {
+ /**
+ * Aborts - i.e. rolls back all changes of - the transaction started by [EMAIL
PROTECTED] #startTransaction(String, int)} and resets the transaction handle.
+ *
+ * @return <code>true</code> if the transaction has been successfully
committed, <code>false</code> otherwise
+ * @throws IOException if anything goes wrong
+ * @see #startTransaction(String, int)
+ * @see #abortTransaction()
+ * @see #getTransactionHandle()
+ */
+ public boolean abortTransaction() throws IOException {
+ String path = httpURL.getPath();
return endTransaction(path, UnlockMethod.ABORT_TRANSACTION);
}
- public boolean endTransaction(String path, int transactionStatus) throws
IOException {
+ protected boolean endTransaction(String path, int transactionStatus) throws
IOException {
setClient();
// Get the lock for the given path.
1.18 +9 -9
jakarta-slide/webdavclient/commandline/src/java/org/apache/webdav/cmd/Client.java
Index: Client.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/webdavclient/commandline/src/java/org/apache/webdav/cmd/Client.java,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -r1.17 -r1.18
--- Client.java 5 Jul 2004 15:34:45 -0000 1.17
+++ Client.java 6 Jul 2004 12:43:51 -0000 1.18
@@ -1482,7 +1482,7 @@
void beginTransaction(String timeout, String owner)
{
try {
- String path = checkUri(null);
+ checkUri(null);
// Test the parameter
//
@@ -1498,7 +1498,7 @@
owner = (owner != null) ? (owner.substring(2)) : owner;
out.print("Starting transaction ");
- if (webdavResource.startTransaction(path, owner, to)) {
+ if (webdavResource.startTransaction(owner, to)) {
out.println("succeeded.");
out.println("Handle: '"+webdavResource.getTransactionHandle()+"'");
} else {
@@ -1514,10 +1514,10 @@
void commitTransaction()
{
try {
- String path = checkUri(null);
+ checkUri(null);
out.print("Committing transaction: '" +
webdavResource.getTransactionHandle() + "' ");
- if (webdavResource.commitTransaction(path)) {
+ if (webdavResource.commitTransaction()) {
out.println("succeeded.");
} else {
out.println("failed.");
@@ -1532,10 +1532,10 @@
void abortTransaction()
{
try {
- String path = checkUri(null);
+ checkUri(null);
out.print("Rolling back transaction: '"
+webdavResource.getTransactionHandle()+ "' ");
- if (webdavResource.abortTransaction(path)) {
+ if (webdavResource.abortTransaction()) {
out.println("succeeded.");
} else {
out.println("failed.");
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]