dflorey 2004/03/04 01:41:50
Modified: src/webdav/server/org/apache/slide/webdav/method
AbstractWebdavMethod.java DefaultMethodFactory.java
src/webdav/server/org/apache/slide/webdav/util
NotificationConstants.java
Added: src/webdav/server/org/apache/slide/webdav/method
TransactionMethod.java
src/webdav/server/org/apache/slide/webdav/util
TransactionConstants.java
Log:
Some classes for enabling work on experimental transaction support
Revision Changes Path
1.24 +58 -4
jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/AbstractWebdavMethod.java
Index: AbstractWebdavMethod.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/AbstractWebdavMethod.java,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -r1.23 -r1.24
--- AbstractWebdavMethod.java 26 Feb 2004 15:45:55 -0000 1.23
+++ AbstractWebdavMethod.java 4 Mar 2004 09:41:50 -0000 1.24
@@ -77,7 +77,7 @@
* @author Christopher Lenz
*/
public abstract class AbstractWebdavMethod
- implements WebdavMethod, WebdavConstants, DeltavConstants, BindConstants,
NotificationConstants {
+ implements WebdavMethod, WebdavConstants, DeltavConstants, BindConstants,
NotificationConstants, TransactionConstants {
// -------------------------------------------------------------- Constants
@@ -938,6 +938,8 @@
private String hSubscriptionIdStr;
private String hNotificationDelayStr;
private String hSubscriptionLifetimeStr;
+ private String hTxIdStr;
+ private String hTxMethodStr;
// parsed headers
private List hIf;
@@ -952,6 +954,8 @@
private int []hSubscriptionId;
private int hNotificationDelay;
private int hSubscriptionLifetime;
+ private String hTxId;
+ private String hTxMethod;
// states
private int stIf = ST_UNDEFINED;
@@ -966,6 +970,8 @@
private int stSubscriptionId = ST_UNDEFINED;
private int stNotificationDelay = ST_UNDEFINED;
private int stSubscriptionLifetime = ST_UNDEFINED;
+ private int stTxId = ST_UNDEFINED;
+ private int stTxMethod= ST_UNDEFINED;
private RequestHeaders() {
}
@@ -1139,7 +1145,55 @@
}
}
+ protected String getTxId() throws WebdavException {
+ if (stTxId == ST_UNDEFINED) {
+ return null;
+ } else if (stTxId == ST_INVALID) {
+ int sc = WebdavStatus.SC_PRECONDITION_FAILED;
+ sendError( sc, "Invalid transaction id: "+hTxIdStr );
+ throw new WebdavException( sc );
+ }
+ else {
+ return hTxId;
+ }
+ }
+
+ protected String getTxMethod() throws WebdavException {
+ if (stTxMethod == ST_UNDEFINED) {
+ return null;
+ } else if (stTxMethod == ST_INVALID) {
+ int sc = WebdavStatus.SC_PRECONDITION_FAILED;
+ sendError( sc, "Invalid transaction method: "+hTxMethodStr );
+ throw new WebdavException( sc );
+ }
+ else {
+ return hTxMethod;
+ }
+ }
+
private void parse() {
+ // TramsactionId header
+ hTxIdStr = req.getHeader(H_TRANSACTION_ID);
+ if (hTxIdStr != null) {
+ stTxId = ST_DEFINED;
+ try {
+ hTxId = hTxIdStr;
+ } catch (Exception e) {
+ stTxId = ST_INVALID;
+ }
+ }
+
+ // TramsactionMethod header
+ hTxMethodStr = req.getHeader(H_TRANSACTION_METHOD);
+ if (hTxMethodStr != null) {
+ stTxMethod = ST_DEFINED;
+ try {
+ hTxMethod = hTxMethodStr;
+ } catch (Exception e) {
+ stTxMethod = ST_INVALID;
+ }
+ }
+
// NotificationType header
hNotificationTypeStr = req.getHeader(H_NOTIFICATION_TYPE);
if (hNotificationTypeStr != null) {
1.8 +5 -3
jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/DefaultMethodFactory.java
Index: DefaultMethodFactory.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/DefaultMethodFactory.java,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -r1.7 -r1.8
--- DefaultMethodFactory.java 24 Feb 2004 17:03:33 -0000 1.7
+++ DefaultMethodFactory.java 4 Mar 2004 09:41:50 -0000 1.8
@@ -94,6 +94,8 @@
return new ReportMethod(token, config);
} else if (name.equals("SUBSCRIBE")) {
return new SubscribeMethod(token, config);
+ } else if (name.equals("TRANSACTION")) {
+ return new TransactionMethod(token, config);
} else if (name.equals("POLL")) {
return new PollMethod(token, config);
} else {
1.1
jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/TransactionMethod.java
Index: TransactionMethod.java
===================================================================
/*
* $Header:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/TransactionMethod.java,v
1.1 2004/03/04 09:41:50 dflorey Exp $
* $Revision: 1.1 $
* $Date: 2004/03/04 09:41:50 $
*
* ====================================================================
*
* Copyright 2004 The Apache Software Foundation
*
* 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 org.apache.slide.webdav.method;
import org.apache.slide.common.NamespaceAccessToken;
import org.apache.slide.common.SlideException;
import org.apache.slide.common.Domain;
import org.apache.slide.event.EventDispatcher;
import org.apache.slide.webdav.WebdavException;
import org.apache.slide.webdav.WebdavServletConfig;
import org.apache.slide.webdav.event.WebdavEvent;
import org.apache.slide.webdav.event.NotificationTrigger;
import org.apache.slide.webdav.event.Subscriber;
import org.apache.slide.webdav.util.NotificationConstants;
import org.apache.slide.webdav.util.TransactionConstants;
import org.apache.slide.util.logger.Logger;
import org.apache.util.WebdavStatus;
import org.jdom.output.XMLOutputter;
import org.jdom.output.Format;
import java.net.URL;
import java.net.MalformedURLException;
/**
* Subscribe Method.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Daniel Florey</a>
*/
public class TransactionMethod extends AbstractWebdavMethod implements
TransactionConstants {
protected static final String LOG_CHANNEL = TransactionMethod.class.getName();
private final static int DEFAULT_SUBSCRIPTION_LIFETIME = 3600;
// An XML outputter
private XMLOutputter xmlOut;
// ----------------------------------------------------------- Constructors
/**
* Constructor.
*
* @param token the token for accessing the namespace
* @param config configuration of the WebDAV servlet
*/
public TransactionMethod(NamespaceAccessToken token,
WebdavServletConfig config) {
super(token, config);
Format format = Format.getPrettyFormat();
format.setIndent(XML_RESPONSE_INDENT);
xmlOut = new XMLOutputter(format);
}
protected void parseRequest() throws WebdavException {
}
protected void executeRequest() throws WebdavException {
try {
// if ( WebdavEvent.SUBSCRIBE.isEnabled() )
EventDispatcher.getInstance().fireVetoableEvent(WebdavEvent.SUBSCRIBE, new
WebdavEvent(this));
String txId = requestHeaders.getTxId();
String method = requestHeaders.getTxMethod();
Domain.log("Transaction method called with method="+method+", txId:
"+txId, LOG_CHANNEL, Logger.INFO);
resp.setHeader(H_TRANSACTION_ID, txId);
resp.setStatus(WebdavStatus.SC_OK);
} catch (Exception e) {
int statusCode = getErrorCode( (Exception)e );
sendError( statusCode, e );
throw new WebdavException( statusCode );
}
}
}
1.3 +4 -4
jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/NotificationConstants.java
Index: NotificationConstants.java
===================================================================
RCS file:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/NotificationConstants.java,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -r1.2 -r1.3
--- NotificationConstants.java 25 Feb 2004 11:09:12 -0000 1.2
+++ NotificationConstants.java 4 Mar 2004 09:41:50 -0000 1.3
@@ -24,7 +24,7 @@
package org.apache.slide.webdav.util;
/**
- * DeltaV constants.
+ * Notification constants.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Daniel Florey</a>
*/
1.1
jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/TransactionConstants.java
Index: TransactionConstants.java
===================================================================
/*
* $Header:
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/util/TransactionConstants.java,v
1.1 2004/03/04 09:41:50 dflorey Exp $
* $Revision: 1.1 $
* $Date: 2004/03/04 09:41:50 $
*
* ====================================================================
*
* Copyright 2004 The Apache Software Foundation
*
* 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 org.apache.slide.webdav.util;
/**
* Transaction constants.
*
* @author <a href="mailto:[EMAIL PROTECTED]">Daniel Florey</a>
*/
public interface TransactionConstants extends WebdavConstants {
/** Headers */
String H_TRANSACTION_ID = "Tx-ID";
String H_TRANSACTION_METHOD =
"Tx-Method";
}
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]