1 23 package org.apache.slide.webdav.method; 24 25 import java.io.IOException ; 26 27 import org.apache.slide.common.NamespaceAccessToken; 28 import org.apache.slide.common.ServiceAccessException; 29 import org.apache.slide.event.EventDispatcher; 30 import org.apache.slide.webdav.WebdavException; 31 import org.apache.slide.webdav.WebdavServletConfig; 32 import org.apache.slide.webdav.event.WebdavEvent; 33 import org.apache.slide.webdav.util.DeltavConstants; 34 import org.apache.slide.webdav.util.PreconditionViolationException; 35 import org.apache.slide.webdav.util.VersioningHelper; 36 import org.apache.slide.webdav.util.WebdavStatus; 37 import org.jdom.JDOMException; 38 39 43 public class UncheckoutMethod extends AbstractWebdavMethod implements DeltavConstants, WriteMethod { 44 45 48 protected static final String NO_CACHE = "no-cache"; 49 50 53 private String resourcePath; 54 55 56 58 59 65 public UncheckoutMethod(NamespaceAccessToken token, 66 WebdavServletConfig config) { 67 super(token, config); 68 } 69 70 75 protected void parseRequest() throws WebdavException { 76 resourcePath = requestUri; 78 if (resourcePath == null) { 79 resourcePath = "/"; 80 } 81 if (req.getContentLength() > 0) { 82 try{ 83 parseRequestContent(); 84 } 85 catch (JDOMException e){ 86 int statusCode = WebdavStatus.SC_BAD_REQUEST; 87 sendError( statusCode, e ); 88 throw new WebdavException( statusCode ); 89 } 90 catch (IOException e){ 91 int statusCode = WebdavStatus.SC_INTERNAL_SERVER_ERROR; 92 sendError( statusCode, e ); 93 throw new WebdavException( statusCode ); 94 } 95 } 96 } 97 98 104 protected void executeRequest() throws WebdavException, IOException { 105 106 slideToken.setForceStoreEnlistment(true); 108 109 try { 111 if (isLockNull(resourcePath)) { 112 int statusCode = WebdavStatus.SC_NOT_FOUND; 113 sendError( statusCode, "lock-null resource", new Object []{resourcePath} ); 114 throw new WebdavException( statusCode ); 115 } 116 } 117 catch (ServiceAccessException e) { 118 int statusCode = getErrorCode((Exception )e); 119 sendError( statusCode, e ); 120 throw new WebdavException( statusCode ); 121 } 122 123 try { 124 if ( WebdavEvent.UNCHECKOUT.isEnabled() ) EventDispatcher.getInstance().fireVetoableEvent(WebdavEvent.UNCHECKOUT, new WebdavEvent(this)); 125 126 VersioningHelper vh = VersioningHelper.getVersioningHelper( 127 slideToken, token, req, resp, getConfig() ); 128 vh.uncheckout(resourcePath); 129 } 130 catch (PreconditionViolationException e) { 131 sendPreconditionViolation(e); 132 throw e; 133 } 134 catch (Exception e) { 135 int statusCode = getErrorCode(e); 136 sendError( statusCode, e ); 137 throw new WebdavException( statusCode ); 138 } 139 finally { 140 resp.setHeader(H_CACHE_CONTROL, NO_CACHE); 141 } 142 143 } 144 145 146 } 147 148 149 150 | Popular Tags |