ozeigermann    2004/07/05 03:15:23

  Modified:    src/webdav/server/org/apache/slide/webdav/method
                        AbstractWebdavMethod.java DefaultMethodFactory.java
                        LockMethod.java
  Removed:     src/webdav/server/org/apache/slide/webdav/method
                        TransactionMethod.java
  Log:
  Finished migration to MS Exchange Server compatible
  external transaction control
  
  Revision  Changes    Path
  1.35      +7 -9      
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.34
  retrieving revision 1.35
  diff -u -r1.34 -r1.35
  --- AbstractWebdavMethod.java 2 Jul 2004 12:04:28 -0000       1.34
  +++ AbstractWebdavMethod.java 5 Jul 2004 10:15:23 -0000       1.35
  @@ -307,7 +307,6 @@
           parseRequestHeaders();
           
           boolean transactionIsStarted = false;
  -        boolean isExternalTx = false;
           String txId = null;
           try {
               parseRequest();
  @@ -319,7 +318,6 @@
                   externalTransaction = 
ExternalTransactionContext.lookupContext(txId);
                   if (externalTransaction != null) {
                       Domain.log("Using external transaction " + txId, LOG_CHANNEL, 
Logger.INFO);
  -                    isExternalTx = true;
                       slideToken.setExternalTx();
                       // pure reads must be guaranteed to be inside transaction as 
well
                       slideToken.setForceStoreEnlistment(true);
  @@ -329,7 +327,7 @@
                   }
               }
               
  -            if (!isExternalTx && methodNeedsTransactionSupport()) {
  +            if (!slideToken.isExternalTransaction() && 
methodNeedsTransactionSupport()) {
                   token.begin();
                   transactionIsStarted = true;
               }
  @@ -361,7 +359,7 @@
               }
               
               executeRequest();
  -            if (!isExternalTx && transactionIsStarted) {
  +            if (!slideToken.isExternalTransaction() && transactionIsStarted) {
                   token.commit();
                   transactionIsStarted = false;
               }
  @@ -378,14 +376,14 @@
               sendError( statusCode, ex );
               throw new WebdavException( statusCode );
           } finally {
  -            if (!isExternalTx && transactionIsStarted) {
  +            if (!slideToken.isExternalTransaction() && transactionIsStarted) {
                   // Something went wrong, we are here and the TA is still open
                   try {
                       token.rollback();
                   } catch (Exception e) {
                   }
               }
  -            if (isExternalTx) {
  +            if (slideToken.isExternalTransaction()) {
                   Transaction transaction;
                   try {
                       if (token.getStatus() == 
javax.transaction.Status.STATUS_ACTIVE) {
  
  
  
  1.11      +3 -5      
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.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- DefaultMethodFactory.java 15 Mar 2004 13:17:18 -0000      1.10
  +++ DefaultMethodFactory.java 5 Jul 2004 10:15:23 -0000       1.11
  @@ -100,8 +100,6 @@
               return new PollMethod(token, config);
           } else if (name.equals("EVENT")) {
               return new EventMethod(token, config);
  -        } else if (name.equals("TRANSACTION")) {
  -            return new TransactionMethod(token, config);
           } else {
               if (Configuration.useIntegratedSecurity()) {
                   if (name.equals("ACL")) {
  
  
  
  1.64      +51 -37    
jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/LockMethod.java
  
  Index: LockMethod.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-slide/src/webdav/server/org/apache/slide/webdav/method/LockMethod.java,v
  retrieving revision 1.63
  retrieving revision 1.64
  diff -u -r1.63 -r1.64
  --- LockMethod.java   2 Jul 2004 12:04:28 -0000       1.63
  +++ LockMethod.java   5 Jul 2004 10:15:23 -0000       1.64
  @@ -35,10 +35,17 @@
   
   import org.apache.slide.common.NamespaceAccessToken;
   import org.apache.slide.common.NamespaceConfig;
  +import org.apache.slide.common.ServiceAccessException;
   import org.apache.slide.common.SlideException;
   import org.apache.slide.content.NodeRevisionDescriptor;
  +import org.apache.slide.content.RevisionAlreadyExistException;
  +import org.apache.slide.event.VetoException;
   import org.apache.slide.lock.NodeLock;
   import org.apache.slide.lock.ObjectIsAlreadyLockedException;
  +import org.apache.slide.lock.ObjectLockedException;
  +import org.apache.slide.security.AccessDeniedException;
  +import org.apache.slide.structure.LinkedObjectNotFoundException;
  +import org.apache.slide.structure.ObjectAlreadyExistsException;
   import org.apache.slide.structure.ObjectNotFoundException;
   import org.apache.slide.structure.SubjectNode;
   import org.apache.slide.transaction.ExternalTransactionContext;
  @@ -331,16 +338,20 @@
                                try {
                                        NamespaceConfig namespaceConfig = token
                                        .getNamespaceConfig();
  +                    toLockSubject = getToLockSubject();
  +                    if (lockDate == null)
  +                        lockDate = new Date((new Date()).getTime()
  +                                + ((long) lockDuration * 1000L));
                                        NodeLock lockToken = new 
NodeLock(toLockSubject.getUri(),((SubjectNode)security.getPrincipal(slideToken)).getUri(),
                                                        
namespaceConfig.getCreateObjectAction().getUri(), lockDate,
                                                        inheritance, NodeLock.LOCAL, 
lockInfo_lockOwner);
  -                                     Transaction transaction = 
token.getTransactionManager()
  -                                                     .suspend();
  -                                     Object txId = lockToken.getLockId();
  -                                     
ExternalTransactionContext.registerContext(txId,
  -                                                     transaction);
  -                                     slideToken.setExternalTx();
  -                                     showLockDiscoveryInfo(lockToken);
  +                                     Transaction transaction = 
token.getTransactionManager().suspend();
  +                    String txId = lockToken.getLockId();
  +                    String fullTxId = "<" + S_LOCK_TOKEN + lockToken.getLockId() + 
">";
  +                    ExternalTransactionContext.registerContext(fullTxId, 
transaction);
  +                    slideToken.setExternalTx();
  +                    resp.setHeader("Lock-Token", fullTxId);
  +                    showLockDiscoveryInfo(lockToken);
                                } catch (Exception e) {
                                        int statusCode = getErrorCode(e);
                                        sendError(statusCode, e);
  @@ -350,31 +361,7 @@
                                try {
                                        NamespaceConfig namespaceConfig = token
                                                        .getNamespaceConfig();
  -                                     try {
  -                                             toLockSubject = (SubjectNode) 
structure.retrieve(
  -                                                             slideToken, 
lockInfo_lockSubject);
  -                                     } catch (ObjectNotFoundException ex) {
  -
  -                                             // Creating a lock null resource
  -                                             toLockSubject = new SubjectNode();
  -
  -                                             // Creating new subject
  -                                             structure.create(slideToken, 
toLockSubject,
  -                                                             lockInfo_lockSubject);
  -
  -                                             NodeRevisionDescriptor 
revisionDescriptor = new NodeRevisionDescriptor(
  -                                                             0);
  -
  -                                             // Resource type
  -                                             XMLValue lockNull = new XMLValue(new 
Element(
  -                                                             E_LOCKNULL, DNSP));
  -                                             
revisionDescriptor.setResourceType(lockNull.toString());
  -
  -                                             // Creating the revision descriptor
  -                                             content.create(slideToken, 
lockInfo_lockSubject,
  -                                                             revisionDescriptor, 
null);
  -                                     }
  -
  +                    toLockSubject = getToLockSubject();
                                        NodeLock lockToken = null;
   
                                        inheritance = (depth != 0);
  @@ -471,9 +458,36 @@
   
        }
   
  +    protected SubjectNode getToLockSubject() throws ObjectAlreadyExistsException, 
ObjectNotFoundException,
  +            AccessDeniedException, RevisionAlreadyExistException, 
LinkedObjectNotFoundException, ObjectLockedException,
  +            ServiceAccessException, VetoException {
  +        
  +        SubjectNode toLockSubject;
  +        try {
  +            toLockSubject = (SubjectNode) structure.retrieve(slideToken, 
lockInfo_lockSubject);
  +        } catch (ObjectNotFoundException ex) {
  +
  +            // Creating a lock null resource
  +            toLockSubject = new SubjectNode();
  +
  +            // Creating new subject
  +            structure.create(slideToken, toLockSubject, lockInfo_lockSubject);
  +
  +            NodeRevisionDescriptor revisionDescriptor = new 
NodeRevisionDescriptor(0);
  +
  +            // Resource type
  +            XMLValue lockNull = new XMLValue(new Element(E_LOCKNULL, DNSP));
  +            revisionDescriptor.setResourceType(lockNull.toString());
  +
  +            // Creating the revision descriptor
  +            content.create(slideToken, lockInfo_lockSubject, revisionDescriptor, 
null);
  +        }
  +        return toLockSubject;
  +    }
  +    
        /**
  -      * Get return status based on exception type.
  -      */
  +     * Get return status based on exception type.
  +     */
        protected int getErrorCode(Exception ex) {
                try {
                        throw ex;
  
  
  

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

Reply via email to