1 23 24 package org.apache.slide.webdav.method; 25 26 import org.apache.slide.common.NamespaceAccessToken; 27 import org.apache.slide.common.NestedSlideException; 28 import org.apache.slide.common.SlideException; 29 import org.apache.slide.webdav.WebdavException; 30 import org.apache.slide.webdav.WebdavServletConfig; 31 import org.apache.slide.webdav.util.WebdavStatus; 32 33 38 public abstract class AbstractMultistatusResponseMethod extends AbstractWebdavMethod { 39 40 41 43 44 47 protected String sourceUri; 48 49 50 53 protected String destinationUri; 54 55 56 59 protected boolean overwrite; 60 61 62 64 65 71 public AbstractMultistatusResponseMethod(NamespaceAccessToken token, 72 WebdavServletConfig config) { 73 super(token, config); 74 } 75 76 77 79 80 85 protected void parseRequest() 86 throws WebdavException { 87 88 sourceUri = requestUri; 89 if (sourceUri == null) { 90 sourceUri = "/"; 91 } 92 93 destinationUri = requestHeaders.getDestination(); 94 95 if (destinationUri == null) { 96 int statusCode = WebdavStatus.SC_BAD_REQUEST; 97 sendError( statusCode, getClass().getName()+".missingDestinationHeader" ); 98 throw new WebdavException( statusCode ); 99 } 100 101 destinationUri = parseUri(destinationUri); 102 overwrite = requestHeaders.getOverwrite(true); 103 } 104 105 112 113 public static boolean generateMultiStatusResponse(boolean isCollection, NestedSlideException causeException, String resourceURI) { 114 boolean isMultiStatus = false; 115 if (isCollection) { 116 if (causeException.getExceptionsCount() > 1) { 117 isMultiStatus = true; 118 } 119 else if (causeException.getExceptionsCount() == 1) { 120 SlideException unpackedException = causeException.unpackSingleException(); 121 isMultiStatus = ! resourceURI.equals(MethodUtil.getURI(unpackedException)); 122 } 123 } 124 return isMultiStatus; 125 } 126 } 127 128 | Popular Tags |