ozeigermann    2004/07/05 03:46:52

  Modified:    src/webdav/server/org/apache/slide/webdav/method
                        UnlockMethod.java
  Log:
  Finished migration to MS Exchange Server compatible
  external transaction control
  
  Revision  Changes    Path
  1.35      +43 -21    
jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/UnlockMethod.java
  
  Index: UnlockMethod.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/UnlockMethod.java,v
  retrieving revision 1.34
  retrieving revision 1.35
  diff -u -r1.34 -r1.35
  --- UnlockMethod.java 2 Jul 2004 12:04:28 -0000       1.34
  +++ UnlockMethod.java 5 Jul 2004 10:46:52 -0000       1.35
  @@ -26,6 +26,9 @@
   import java.io.IOException;
   import java.util.Enumeration;
   
  +import javax.transaction.Transaction;
  +
  +import org.apache.slide.common.Domain;
   import org.apache.slide.common.NamespaceAccessToken;
   import org.apache.slide.common.ServiceAccessException;
   import org.apache.slide.common.SlideException;
  @@ -41,6 +44,7 @@
   import org.apache.slide.structure.ObjectNotFoundException;
   import org.apache.slide.transaction.ExternalTransactionContext;
   import org.apache.slide.util.Configuration;
  +import org.apache.slide.util.logger.Logger;
   import org.apache.slide.webdav.WebdavException;
   import org.apache.slide.webdav.WebdavServletConfig;
   import org.apache.slide.webdav.event.WebdavEvent;
  @@ -56,6 +60,7 @@
   import org.apache.util.WebdavStatus;
   import org.jdom.Document;
   import org.jdom.Element;
  +import org.jdom.Namespace;
   
   /**
    * UNLOCK method.
  @@ -134,15 +139,16 @@
                        if (requestContent != null) {
                                Element transactioninfo = 
requestContent.getRootElement();
                                if 
(E_TRANSACTIONINFO.equals(transactioninfo.getName())) {
  +                    slideToken.setExternalTx();
                                        Element transactionstatus = transactioninfo
  -                                                     .getChild(E_TRANSACTIONINFO);
  +                                                     .getChild(E_TRANSACTIONSTATUS, 
Namespace.getNamespace(S_DAV));
                                        if (transactionstatus != null) {
  -                                             Element action = (Element) 
transactioninfo
  +                                             Element action = (Element) 
transactionstatus
                                                                .getChildren().get(0);
                                                if (action != null) {
                                                        if 
(E_COMMIT.equals(action.getName())) {
                                                                command = 
COMMIT_TRANSACTION;
  -                                                     } else if 
(E_COMMIT.equals(action.getName())) {
  +                                                     } else if 
(E_ABORT.equals(action.getName())) {
                                                                command = 
ABORT_TRANSACTION;
                                                        }
                                                }
  @@ -163,21 +169,37 @@
   
                // Prevent dirty reads
                slideToken.setForceStoreEnlistment(true);
  -             if (command == COMMIT_TRANSACTION) {
  -                     try {
  -                             token.commit();
  -                             ExternalTransactionContext.deregisterContext(lockId);
  -                     } catch (Exception exception) {
  -                             resp.setStatus(WebdavStatus.SC_METHOD_FAILURE);
  -                     }
  -             } else if (command == ABORT_TRANSACTION) {
  -                     try {
  -                             token.rollback();
  -                             ExternalTransactionContext.deregisterContext(lockId);
  -                     } catch (Exception exception) {
  -                             resp.setStatus(WebdavStatus.SC_METHOD_FAILURE);
  -                     }
  -             } else {
  +        if (command == COMMIT_TRANSACTION || command == ABORT_TRANSACTION) {
  +
  +            String fullTxId = "<" + S_LOCK_TOKEN + lockId + ">";
  +
  +            ExternalTransactionContext externalTransaction = 
ExternalTransactionContext.lookupContext(fullTxId);
  +            if (externalTransaction != null) {
  +                Transaction tx = externalTransaction.getTransaction();
  +                try {
  +                    token.getTransactionManager().resume(tx);
  +                } catch (Exception exception) {
  +                    sendError(WebdavStatus.SC_METHOD_FAILURE, "No such 
transaction");
  +                }
  +            } else {
  +                sendError(WebdavStatus.SC_METHOD_FAILURE, "No such transaction");
  +            }
  +
  +            if (command == COMMIT_TRANSACTION) {
  +                try {
  +                    token.commit();
  +                } catch (Exception exception) {
  +                    sendError(WebdavStatus.SC_METHOD_FAILURE, "Could not commit 
transaction");
  +                }
  +            } else if (command == ABORT_TRANSACTION) {
  +                try {
  +                    token.rollback();
  +                } catch (Exception exception) {
  +                    sendError(WebdavStatus.SC_METHOD_FAILURE, "Could not roll back 
transaction");
  +                }
  +            }
  +            ExternalTransactionContext.deregisterContext(lockId);
  +        } else {
                        try {
                                if (WebdavEvent.UNLOCK.isEnabled())
                                        
EventDispatcher.getInstance().fireVetoableEvent(
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to