1 17 package com.sslexplorer.vfs.webdav.methods; 18 19 import java.io.IOException ; 20 import java.net.URI ; 21 22 import com.sslexplorer.vfs.VFSLockManager; 23 import com.sslexplorer.vfs.VFSResource; 24 import com.sslexplorer.vfs.webdav.DAVException; 25 import com.sslexplorer.vfs.webdav.DAVMethod; 26 import com.sslexplorer.vfs.webdav.DAVMultiStatus; 27 import com.sslexplorer.vfs.webdav.DAVProcessor; 28 import com.sslexplorer.vfs.webdav.DAVServlet; 29 import com.sslexplorer.vfs.webdav.DAVTransaction; 30 import com.sslexplorer.vfs.webdav.LockedException; 31 32 40 public class MOVE implements DAVMethod { 41 42 47 public MOVE() { 48 super(); 49 } 50 51 58 public void process(DAVTransaction transaction, VFSResource resource) throws LockedException, IOException { 59 String handle = VFSLockManager.getNewHandle(); 60 VFSResource dest = null; 61 VFSLockManager.getInstance().lock(resource, transaction.getSessionInfo(), true, true, handle); 62 63 try { 64 try { 65 DAVProcessor processor = DAVServlet.getDAVProcessor(transaction.getRequest()); 67 URI target = transaction.getDestination(); 68 if (target == null) 69 throw new DAVException(412, "No destination"); 70 dest = processor.getRepository().getResource(resource.getLaunchSession(), target.getPath(), transaction.getCredentials()); 71 72 VFSLockManager.getInstance().lock(resource, transaction.getSessionInfo(), true, false, handle); 73 74 resource.move(dest, true); 75 resource.getMount().resourceMoved(resource, dest, transaction, null); 76 transaction.setStatus(204); 77 } catch (DAVMultiStatus multistatus) { 78 multistatus.write(transaction); 79 } 80 } catch (Exception e) { 81 resource.getMount().resourceMoved(resource, dest, transaction, e); 82 if(e instanceof LockedException) 83 throw (LockedException) e; 84 IOException ioe = new IOException (e.getMessage()); 85 ioe.initCause(e); 86 throw ioe; 87 } finally { 88 VFSLockManager.getInstance().unlock(transaction.getSessionInfo(), handle); 89 } 90 } 91 } 92 | Popular Tags |