This is an automated email from the ASF dual-hosted git repository. markt pushed a commit to branch 9.0.x in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/9.0.x by this push: new 0005948a92 Refactoring and clean-up 0005948a92 is described below commit 0005948a9251fdc771ee91ecfe2752f613442f8f Author: Mark Thomas <ma...@apache.org> AuthorDate: Fri Sep 9 15:14:19 2022 +0100 Refactoring and clean-up What started out as "remove use of Vector" turned into a wider clean-up including: - Remove use of Vector, Hashtable and Enumeration - Use enhanced for loops - Use 120 line length No functional change. --- .../apache/catalina/servlets/WebdavServlet.java | 546 +++++++-------------- 1 file changed, 182 insertions(+), 364 deletions(-) diff --git a/java/org/apache/catalina/servlets/WebdavServlet.java b/java/org/apache/catalina/servlets/WebdavServlet.java index e45f6e66c5..33ae4f9bd6 100644 --- a/java/org/apache/catalina/servlets/WebdavServlet.java +++ b/java/org/apache/catalina/servlets/WebdavServlet.java @@ -25,13 +25,16 @@ import java.io.Writer; import java.net.URI; import java.net.URISyntaxException; import java.nio.charset.StandardCharsets; +import java.util.ArrayList; +import java.util.Collections; import java.util.Date; -import java.util.Enumeration; -import java.util.Hashtable; +import java.util.HashMap; +import java.util.List; import java.util.Locale; +import java.util.Map; import java.util.Stack; import java.util.TimeZone; -import java.util.Vector; +import java.util.concurrent.ConcurrentHashMap; import javax.servlet.DispatcherType; import javax.servlet.RequestDispatcher; @@ -203,9 +206,8 @@ public class WebdavServlet extends DefaultServlet { /** * Simple date format for the creation date ISO representation (partial). */ - protected static final ConcurrentDateFormat creationDateFormat = - new ConcurrentDateFormat("yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.US, - TimeZone.getTimeZone("GMT")); + protected static final ConcurrentDateFormat creationDateFormat = new ConcurrentDateFormat( + "yyyy-MM-dd'T'HH:mm:ss'Z'", Locale.US, TimeZone.getTimeZone("GMT")); // ----------------------------------------------------- Instance Variables @@ -216,28 +218,24 @@ public class WebdavServlet extends DefaultServlet { * Key : path <br> * Value : LockInfo */ - private final Hashtable<String,LockInfo> resourceLocks = new Hashtable<>(); + private final Map<String,LockInfo> resourceLocks = new ConcurrentHashMap<>(); /** * Repository of the lock-null resources. * <p> * Key : path of the collection containing the lock-null resource<br> - * Value : Vector of lock-null resource which are members of the - * collection. Each element of the Vector is the path associated with + * Value : List of lock-null resource which are members of the + * collection. Each element of the List is the path associated with * the lock-null resource. */ - private final Hashtable<String,Vector<String>> lockNullResources = - new Hashtable<>(); + private final Map<String,List<String>> lockNullResources = new ConcurrentHashMap<>(); /** - * Vector of the heritable locks. - * <p> - * Key : path <br> - * Value : LockInfo + * List of the inheritable collection locks. */ - private final Vector<LockInfo> collectionLocks = new Vector<>(); + private final List<LockInfo> collectionLocks = Collections.synchronizedList(new ArrayList<>()); /** @@ -262,13 +260,11 @@ public class WebdavServlet extends DefaultServlet { // --------------------------------------------------------- Public Methods - /** * Initialize this servlet. */ @Override - public void init() - throws ServletException { + public void init() throws ServletException { super.init(); @@ -290,15 +286,13 @@ public class WebdavServlet extends DefaultServlet { // ------------------------------------------------------ Protected Methods - /** * Return JAXP document builder instance. * @return the document builder * @throws ServletException document builder creation failed * (wrapped <code>ParserConfigurationException</code> exception) */ - protected DocumentBuilder getDocumentBuilder() - throws ServletException { + protected DocumentBuilder getDocumentBuilder() throws ServletException { DocumentBuilder documentBuilder = null; DocumentBuilderFactory documentBuilderFactory = null; try { @@ -306,11 +300,9 @@ public class WebdavServlet extends DefaultServlet { documentBuilderFactory.setNamespaceAware(true); documentBuilderFactory.setExpandEntityReferences(false); documentBuilder = documentBuilderFactory.newDocumentBuilder(); - documentBuilder.setEntityResolver( - new WebdavResolver(this.getServletContext())); + documentBuilder.setEntityResolver(new WebdavResolver(this.getServletContext())); } catch(ParserConfigurationException e) { - throw new ServletException - (sm.getString("webdavservlet.jaxpfailed")); + throw new ServletException(sm.getString("webdavservlet.jaxpfailed")); } return documentBuilder; } @@ -320,8 +312,7 @@ public class WebdavServlet extends DefaultServlet { * Handles the special WebDAV methods. */ @Override - protected void service(HttpServletRequest req, HttpServletResponse resp) - throws ServletException, IOException { + protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { final String path = getRelativePath(req); @@ -367,7 +358,6 @@ public class WebdavServlet extends DefaultServlet { // DefaultServlet processing super.service(req, resp); } - } @@ -385,10 +375,8 @@ public class WebdavServlet extends DefaultServlet { @Override - protected boolean checkIfHeaders(HttpServletRequest request, - HttpServletResponse response, - WebResource resource) - throws IOException { + protected boolean checkIfHeaders(HttpServletRequest request, HttpServletResponse response, WebResource resource) + throws IOException { if (!super.checkIfHeaders(request, response, resource)) { return false; @@ -470,9 +458,7 @@ public class WebdavServlet extends DefaultServlet { * @throws IOException If an IO error occurs */ @Override - protected void doOptions(HttpServletRequest req, HttpServletResponse resp) - throws ServletException, IOException { - + protected void doOptions(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { resp.addHeader("DAV", "1,2"); resp.addHeader("Allow", determineMethodsAllowed(req)); resp.addHeader("MS-Author-Via", "DAV"); @@ -486,8 +472,7 @@ public class WebdavServlet extends DefaultServlet { * @throws ServletException If an error occurs * @throws IOException If an IO error occurs */ - protected void doPropfind(HttpServletRequest req, HttpServletResponse resp) - throws ServletException, IOException { + protected void doPropfind(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { if (!listings) { sendNotAllowed(req, resp); @@ -500,7 +485,7 @@ public class WebdavServlet extends DefaultServlet { } // Properties which are to be displayed. - Vector<String> properties = null; + List<String> properties = null; // Propfind depth int depth = maxDepth; // Propfind type @@ -526,8 +511,7 @@ public class WebdavServlet extends DefaultServlet { DocumentBuilder documentBuilder = getDocumentBuilder(); try { - Document document = documentBuilder.parse - (new InputSource(req.getInputStream())); + Document document = documentBuilder.parse(new InputSource(req.getInputStream())); // Get the root element of the document Element rootElement = document.getDocumentElement(); @@ -560,7 +544,7 @@ public class WebdavServlet extends DefaultServlet { } if (type == FIND_BY_PROPERTY) { - properties = new Vector<>(); + properties = new ArrayList<>(); // propNode must be non-null if type == FIND_BY_PROPERTY @SuppressWarnings("null") NodeList childList = propNode.getChildNodes(); @@ -580,11 +564,10 @@ public class WebdavServlet extends DefaultServlet { propertyName = nodeName; } // href is a live property which is handled differently - properties.addElement(propertyName); + properties.add(propertyName); break; } } - } WebResource resource = resources.getResource(path); @@ -593,28 +576,18 @@ public class WebdavServlet extends DefaultServlet { int slash = path.lastIndexOf('/'); if (slash != -1) { String parentPath = path.substring(0, slash); - Vector<String> currentLockNullResources = - lockNullResources.get(parentPath); + List<String> currentLockNullResources = lockNullResources.get(parentPath); if (currentLockNullResources != null) { - Enumeration<String> lockNullResourcesList = - currentLockNullResources.elements(); - while (lockNullResourcesList.hasMoreElements()) { - String lockNullPath = - lockNullResourcesList.nextElement(); + for (String lockNullPath : currentLockNullResources) { if (lockNullPath.equals(path)) { resp.setStatus(WebdavStatus.SC_MULTI_STATUS); resp.setContentType("text/xml; charset=UTF-8"); // Create multistatus object - XMLWriter generatedXML = - new XMLWriter(resp.getWriter()); + XMLWriter generatedXML = new XMLWriter(resp.getWriter()); generatedXML.writeXMLHeader(); - generatedXML.writeElement("D", DEFAULT_NAMESPACE, - "multistatus", XMLWriter.OPENING); - parseLockNullProperties - (req, generatedXML, lockNullPath, type, - properties); - generatedXML.writeElement("D", "multistatus", - XMLWriter.CLOSING); + generatedXML.writeElement("D", DEFAULT_NAMESPACE, "multistatus", XMLWriter.OPENING); + parseLockNullProperties(req, generatedXML, lockNullPath, type, properties); + generatedXML.writeElement("D", "multistatus", XMLWriter.CLOSING); generatedXML.sendData(); return; } @@ -636,12 +609,10 @@ public class WebdavServlet extends DefaultServlet { XMLWriter generatedXML = new XMLWriter(resp.getWriter()); generatedXML.writeXMLHeader(); - generatedXML.writeElement("D", DEFAULT_NAMESPACE, "multistatus", - XMLWriter.OPENING); + generatedXML.writeElement("D", DEFAULT_NAMESPACE, "multistatus", XMLWriter.OPENING); if (depth == 0) { - parseProperties(req, generatedXML, path, type, - properties); + parseProperties(req, generatedXML, path, type, properties); } else { // The stack always contains the object of the current level Stack<String> stack = new Stack<>(); @@ -653,8 +624,7 @@ public class WebdavServlet extends DefaultServlet { while ((!stack.isEmpty()) && (depth >= 0)) { String currentPath = stack.pop(); - parseProperties(req, generatedXML, currentPath, - type, properties); + parseProperties(req, generatedXML, currentPath, type, properties); resource = resources.getResource(currentPath); @@ -674,23 +644,14 @@ public class WebdavServlet extends DefaultServlet { // collection String lockPath = currentPath; if (lockPath.endsWith("/")) { - lockPath = - lockPath.substring(0, lockPath.length() - 1); + lockPath = lockPath.substring(0, lockPath.length() - 1); } - Vector<String> currentLockNullResources = - lockNullResources.get(lockPath); + List<String> currentLockNullResources = lockNullResources.get(lockPath); if (currentLockNullResources != null) { - Enumeration<String> lockNullResourcesList = - currentLockNullResources.elements(); - while (lockNullResourcesList.hasMoreElements()) { - String lockNullPath = - lockNullResourcesList.nextElement(); - parseLockNullProperties - (req, generatedXML, lockNullPath, type, - properties); + for (String lockNullPath : currentLockNullResources) { + parseLockNullProperties(req, generatedXML, lockNullPath, type, properties); } } - } if (stack.isEmpty()) { @@ -717,8 +678,7 @@ public class WebdavServlet extends DefaultServlet { * @param resp The Servlet response * @throws IOException If an IO error occurs */ - protected void doProppatch(HttpServletRequest req, HttpServletResponse resp) - throws IOException { + protected void doProppatch(HttpServletRequest req, HttpServletResponse resp) throws IOException { if (readOnly) { resp.sendError(WebdavStatus.SC_FORBIDDEN); @@ -731,7 +691,6 @@ public class WebdavServlet extends DefaultServlet { } resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED); - } @@ -742,8 +701,7 @@ public class WebdavServlet extends DefaultServlet { * @throws ServletException If an error occurs * @throws IOException If an IO error occurs */ - protected void doMkcol(HttpServletRequest req, HttpServletResponse resp) - throws ServletException, IOException { + protected void doMkcol(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { String path = getRelativePath(req); @@ -800,8 +758,7 @@ public class WebdavServlet extends DefaultServlet { * @throws IOException If an IO error occurs */ @Override - protected void doDelete(HttpServletRequest req, HttpServletResponse resp) - throws ServletException, IOException { + protected void doDelete(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { if (readOnly) { sendNotAllowed(req, resp); @@ -814,7 +771,6 @@ public class WebdavServlet extends DefaultServlet { } deleteResource(req, resp); - } @@ -828,8 +784,7 @@ public class WebdavServlet extends DefaultServlet { * @exception ServletException if a servlet-specified error occurs */ @Override - protected void doPut(HttpServletRequest req, HttpServletResponse resp) - throws ServletException, IOException { + protected void doPut(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { if (isLocked(req)) { resp.sendError(WebdavStatus.SC_LOCKED); @@ -847,17 +802,16 @@ public class WebdavServlet extends DefaultServlet { // Removing any lock-null resource which would be present lockNullResources.remove(path); - } + /** * COPY Method. * @param req The Servlet request * @param resp The Servlet response * @throws IOException If an IO error occurs */ - protected void doCopy(HttpServletRequest req, HttpServletResponse resp) - throws IOException { + protected void doCopy(HttpServletRequest req, HttpServletResponse resp) throws IOException { if (readOnly) { resp.sendError(WebdavStatus.SC_FORBIDDEN); @@ -865,7 +819,6 @@ public class WebdavServlet extends DefaultServlet { } copyResource(req, resp); - } @@ -875,8 +828,7 @@ public class WebdavServlet extends DefaultServlet { * @param resp The Servlet response * @throws IOException If an IO error occurs */ - protected void doMove(HttpServletRequest req, HttpServletResponse resp) - throws IOException { + protected void doMove(HttpServletRequest req, HttpServletResponse resp) throws IOException { if (readOnly) { resp.sendError(WebdavStatus.SC_FORBIDDEN); @@ -893,7 +845,6 @@ public class WebdavServlet extends DefaultServlet { if (copyResource(req, resp)) { deleteResource(path, req, resp, false); } - } @@ -904,8 +855,7 @@ public class WebdavServlet extends DefaultServlet { * @throws ServletException If an error occurs * @throws IOException If an IO error occurs */ - protected void doLock(HttpServletRequest req, HttpServletResponse resp) - throws ServletException, IOException { + protected void doLock(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { if (readOnly) { resp.sendError(WebdavStatus.SC_FORBIDDEN); @@ -976,8 +926,7 @@ public class WebdavServlet extends DefaultServlet { DocumentBuilder documentBuilder = getDocumentBuilder(); try { - Document document = documentBuilder.parse(new InputSource - (req.getInputStream())); + Document document = documentBuilder.parse(new InputSource(req.getInputStream())); // Get the root element of the document Element rootElement = document.getDocumentElement(); @@ -1029,8 +978,7 @@ public class WebdavServlet extends DefaultServlet { case Node.ELEMENT_NODE: String tempScope = currentNode.getNodeName(); if (tempScope.indexOf(':') != -1) { - lock.scope = tempScope.substring - (tempScope.indexOf(':') + 1); + lock.scope = tempScope.substring(tempScope.indexOf(':') + 1); } else { lock.scope = tempScope; } @@ -1059,8 +1007,7 @@ public class WebdavServlet extends DefaultServlet { case Node.ELEMENT_NODE: String tempType = currentNode.getNodeName(); if (tempType.indexOf(':') != -1) { - lock.type = - tempType.substring(tempType.indexOf(':') + 1); + lock.type = tempType.substring(tempType.indexOf(':') + 1); } else { lock.type = tempType; } @@ -1104,7 +1051,6 @@ public class WebdavServlet extends DefaultServlet { } else { lock.owner = ""; } - } String path = getRelativePath(req); @@ -1113,16 +1059,14 @@ public class WebdavServlet extends DefaultServlet { WebResource resource = resources.getResource(path); - Enumeration<LockInfo> locksList = null; - if (lockRequestType == LOCK_CREATION) { // Generating lock id - String lockTokenStr = req.getServletPath() + "-" + lock.type + "-" - + lock.scope + "-" + req.getUserPrincipal() + "-" - + lock.depth + "-" + lock.owner + "-" + lock.tokens + "-" - + lock.expiresAt + "-" + System.currentTimeMillis() + "-" - + secret; + String lockTokenStr = req.getServletPath() + "-" + lock.type + "-" + + lock.scope + "-" + req.getUserPrincipal() + "-" + + lock.depth + "-" + lock.owner + "-" + lock.tokens + "-" + + lock.expiresAt + "-" + System.currentTimeMillis() + "-" + + secret; String lockToken = MD5Encoder.encode(ConcurrentMessageDigest.digestMD5( lockTokenStr.getBytes(StandardCharsets.ISO_8859_1))); @@ -1132,33 +1076,27 @@ public class WebdavServlet extends DefaultServlet { // Checking if a child resource of this collection is // already locked - Vector<String> lockPaths = new Vector<>(); - locksList = collectionLocks.elements(); - while (locksList.hasMoreElements()) { - LockInfo currentLock = locksList.nextElement(); + List<String> lockPaths = new ArrayList<>(); + for (LockInfo currentLock : collectionLocks) { if (currentLock.hasExpired()) { resourceLocks.remove(currentLock.path); continue; } - if ( (currentLock.path.startsWith(lock.path)) && - ((currentLock.isExclusive()) || - (lock.isExclusive())) ) { + if (currentLock.path.startsWith(lock.path) && + (currentLock.isExclusive() || lock.isExclusive())) { // A child collection of this collection is locked - lockPaths.addElement(currentLock.path); + lockPaths.add(currentLock.path); } } - locksList = resourceLocks.elements(); - while (locksList.hasMoreElements()) { - LockInfo currentLock = locksList.nextElement(); + for (LockInfo currentLock : resourceLocks.values()) { if (currentLock.hasExpired()) { resourceLocks.remove(currentLock.path); continue; } - if ( (currentLock.path.startsWith(lock.path)) && - ((currentLock.isExclusive()) || - (lock.isExclusive())) ) { + if (currentLock.path.startsWith(lock.path) && + (currentLock.isExclusive() || lock.isExclusive())) { // A child resource of this collection is locked - lockPaths.addElement(currentLock.path); + lockPaths.add(currentLock.path); } } @@ -1167,54 +1105,37 @@ public class WebdavServlet extends DefaultServlet { // One of the child paths was locked // We generate a multistatus error report - Enumeration<String> lockPathsList = lockPaths.elements(); - resp.setStatus(WebdavStatus.SC_CONFLICT); XMLWriter generatedXML = new XMLWriter(); generatedXML.writeXMLHeader(); - generatedXML.writeElement("D", DEFAULT_NAMESPACE, - "multistatus", XMLWriter.OPENING); - - while (lockPathsList.hasMoreElements()) { - generatedXML.writeElement("D", "response", - XMLWriter.OPENING); - generatedXML.writeElement("D", "href", - XMLWriter.OPENING); - generatedXML.writeText(lockPathsList.nextElement()); - generatedXML.writeElement("D", "href", - XMLWriter.CLOSING); - generatedXML.writeElement("D", "status", - XMLWriter.OPENING); - generatedXML - .writeText("HTTP/1.1 " + WebdavStatus.SC_LOCKED - + " "); - generatedXML.writeElement("D", "status", - XMLWriter.CLOSING); - - generatedXML.writeElement("D", "response", - XMLWriter.CLOSING); + generatedXML.writeElement("D", DEFAULT_NAMESPACE, "multistatus", XMLWriter.OPENING); + + for (String lockPath : lockPaths) { + generatedXML.writeElement("D", "response", XMLWriter.OPENING); + generatedXML.writeElement("D", "href", XMLWriter.OPENING); + generatedXML.writeText(lockPath); + generatedXML.writeElement("D", "href", XMLWriter.CLOSING); + generatedXML.writeElement("D", "status", XMLWriter.OPENING); + generatedXML.writeText("HTTP/1.1 " + WebdavStatus.SC_LOCKED + " "); + generatedXML.writeElement("D", "status", XMLWriter.CLOSING); + generatedXML.writeElement("D", "response", XMLWriter.CLOSING); } - generatedXML.writeElement("D", "multistatus", - XMLWriter.CLOSING); + generatedXML.writeElement("D", "multistatus", XMLWriter.CLOSING); Writer writer = resp.getWriter(); writer.write(generatedXML.toString()); writer.close(); return; - } boolean addLock = true; // Checking if there is already a shared lock on this path - locksList = collectionLocks.elements(); - while (locksList.hasMoreElements()) { - - LockInfo currentLock = locksList.nextElement(); + for (LockInfo currentLock : collectionLocks) { if (currentLock.path.equals(lock.path)) { if (currentLock.isExclusive()) { @@ -1227,17 +1148,15 @@ public class WebdavServlet extends DefaultServlet { } } - currentLock.tokens.addElement(lockToken); + currentLock.tokens.add(lockToken); lock = currentLock; addLock = false; - } - } if (addLock) { - lock.tokens.addElement(lockToken); - collectionLocks.addElement(lock); + lock.tokens.add(lockToken); + collectionLocks.add(lock); } } else { @@ -1254,13 +1173,13 @@ public class WebdavServlet extends DefaultServlet { resp.sendError(WebdavStatus.SC_PRECONDITION_FAILED); return; } else { - presentLock.tokens.addElement(lockToken); + presentLock.tokens.add(lockToken); lock = presentLock; } } else { - lock.tokens.addElement(lockToken); + lock.tokens.add(lockToken); resourceLocks.put(lock.path, lock); // Checking if a resource exists at this path @@ -1270,24 +1189,20 @@ public class WebdavServlet extends DefaultServlet { int slash = lock.path.lastIndexOf('/'); String parentPath = lock.path.substring(0, slash); - Vector<String> lockNulls = - lockNullResources.get(parentPath); + List<String> lockNulls = lockNullResources.get(parentPath); if (lockNulls == null) { - lockNulls = new Vector<>(); + lockNulls = new ArrayList<>(); lockNullResources.put(parentPath, lockNulls); } - lockNulls.addElement(lock.path); - + lockNulls.add(lock.path); } + // Add the Lock-Token header as by RFC 2518 8.10.1 // - only do this for newly created locks - resp.addHeader("Lock-Token", "<opaquelocktoken:" - + lockToken + ">"); + resp.addHeader("Lock-Token", "<opaquelocktoken:" + lockToken + ">"); } - } - } if (lockRequestType == LOCK_REFRESH) { @@ -1300,13 +1215,10 @@ public class WebdavServlet extends DefaultServlet { // Checking resource locks LockInfo toRenew = resourceLocks.get(path); - Enumeration<String> tokenList = null; if (toRenew != null) { // At least one of the tokens of the locks must have been given - tokenList = toRenew.tokens.elements(); - while (tokenList.hasMoreElements()) { - String token = tokenList.nextElement(); + for (String token : toRenew.tokens) { if (ifHeader.contains(token)) { toRenew.expiresAt = lock.expiresAt; lock = toRenew; @@ -1315,33 +1227,23 @@ public class WebdavServlet extends DefaultServlet { } // Checking inheritable collection locks - - Enumeration<LockInfo> collectionLocksList = - collectionLocks.elements(); - while (collectionLocksList.hasMoreElements()) { - toRenew = collectionLocksList.nextElement(); - if (path.equals(toRenew.path)) { - - tokenList = toRenew.tokens.elements(); - while (tokenList.hasMoreElements()) { - String token = tokenList.nextElement(); + for (LockInfo collecionLock : collectionLocks) { + if (path.equals(collecionLock.path)) { + for (String token : collecionLock.tokens) { if (ifHeader.contains(token)) { - toRenew.expiresAt = lock.expiresAt; - lock = toRenew; + collecionLock.expiresAt = lock.expiresAt; + lock = collecionLock; } } - } } - } // Set the status, then generate the XML response containing // the lock information XMLWriter generatedXML = new XMLWriter(); generatedXML.writeXMLHeader(); - generatedXML.writeElement("D", DEFAULT_NAMESPACE, "prop", - XMLWriter.OPENING); + generatedXML.writeElement("D", DEFAULT_NAMESPACE, "prop", XMLWriter.OPENING); generatedXML.writeElement("D", "lockdiscovery", XMLWriter.OPENING); @@ -1356,7 +1258,6 @@ public class WebdavServlet extends DefaultServlet { Writer writer = resp.getWriter(); writer.write(generatedXML.toString()); writer.close(); - } @@ -1366,8 +1267,7 @@ public class WebdavServlet extends DefaultServlet { * @param resp The Servlet response * @throws IOException If an IO error occurs */ - protected void doUnlock(HttpServletRequest req, HttpServletResponse resp) - throws IOException { + protected void doUnlock(HttpServletRequest req, HttpServletResponse resp) throws IOException { if (readOnly) { resp.sendError(WebdavStatus.SC_FORBIDDEN); @@ -1389,16 +1289,12 @@ public class WebdavServlet extends DefaultServlet { // Checking resource locks LockInfo lock = resourceLocks.get(path); - Enumeration<String> tokenList = null; if (lock != null) { // At least one of the tokens of the locks must have been given - - tokenList = lock.tokens.elements(); - while (tokenList.hasMoreElements()) { - String token = tokenList.nextElement(); + for (String token : lock.tokens) { if (lockTokenHeader.contains(token)) { - lock.tokens.removeElement(token); + lock.tokens.remove(token); } } @@ -1411,34 +1307,27 @@ public class WebdavServlet extends DefaultServlet { } // Checking inheritable collection locks - - Enumeration<LockInfo> collectionLocksList = collectionLocks.elements(); - while (collectionLocksList.hasMoreElements()) { - lock = collectionLocksList.nextElement(); - if (path.equals(lock.path)) { - - tokenList = lock.tokens.elements(); - while (tokenList.hasMoreElements()) { - String token = tokenList.nextElement(); + for (LockInfo collectionLock : collectionLocks) { + if (path.equals(collectionLock.path)) { + for (String token : collectionLock.tokens) { if (lockTokenHeader.contains(token)) { - lock.tokens.removeElement(token); + collectionLock.tokens.remove(token); break; } } - if (lock.tokens.isEmpty()) { - collectionLocks.removeElement(lock); + if (collectionLock.tokens.isEmpty()) { + collectionLocks.remove(collectionLock); // Removing any lock-null resource which would be present lockNullResources.remove(path); } - } } resp.setStatus(WebdavStatus.SC_NO_CONTENT); - } + // -------------------------------------------------------- Private Methods /** @@ -1466,7 +1355,6 @@ public class WebdavServlet extends DefaultServlet { } return isLocked(path, ifHeader + lockTokenHeader); - } @@ -1484,17 +1372,14 @@ public class WebdavServlet extends DefaultServlet { // Checking resource locks LockInfo lock = resourceLocks.get(path); - Enumeration<String> tokenList = null; if ((lock != null) && (lock.hasExpired())) { resourceLocks.remove(path); } else if (lock != null) { // At least one of the tokens of the locks must have been given - tokenList = lock.tokens.elements(); boolean tokenMatch = false; - while (tokenList.hasMoreElements()) { - String token = tokenList.nextElement(); + for (String token : lock.tokens) { if (ifHeader.contains(token)) { tokenMatch = true; break; @@ -1503,22 +1388,15 @@ public class WebdavServlet extends DefaultServlet { if (!tokenMatch) { return true; } - } // Checking inheritable collection locks - - Enumeration<LockInfo> collectionLocksList = collectionLocks.elements(); - while (collectionLocksList.hasMoreElements()) { - lock = collectionLocksList.nextElement(); - if (lock.hasExpired()) { - collectionLocks.removeElement(lock); - } else if (path.startsWith(lock.path)) { - - tokenList = lock.tokens.elements(); + for (LockInfo collectionsLock : collectionLocks) { + if (collectionsLock.hasExpired()) { + collectionLocks.remove(collectionsLock); + } else if (path.startsWith(collectionsLock.path)) { boolean tokenMatch = false; - while (tokenList.hasMoreElements()) { - String token = tokenList.nextElement(); + for (String token : collectionsLock.tokens) { if (ifHeader.contains(token)) { tokenMatch = true; break; @@ -1527,12 +1405,10 @@ public class WebdavServlet extends DefaultServlet { if (!tokenMatch) { return true; } - } } return false; - } @@ -1665,13 +1541,13 @@ public class WebdavServlet extends DefaultServlet { // Copying source to destination - Hashtable<String,Integer> errorList = new Hashtable<>(); + Map<String,Integer> errorList = new HashMap<>(); boolean result = copyResource(errorList, path, destinationPath); if ((!result) || (!errorList.isEmpty())) { if (errorList.size() == 1) { - resp.sendError(errorList.elements().nextElement().intValue()); + resp.sendError(errorList.values().iterator().next().intValue()); } else { sendReport(req, resp, errorList); } @@ -1702,8 +1578,7 @@ public class WebdavServlet extends DefaultServlet { * @param dest Destination path * @return <code>true</code> if the copy was successful */ - private boolean copyResource(Hashtable<String,Integer> errorList, - String source, String dest) { + private boolean copyResource(Map<String,Integer> errorList, String source, String dest) { if (debug > 1) { log("Copy: " + source + " To: " + dest); @@ -1778,14 +1653,9 @@ public class WebdavServlet extends DefaultServlet { * @return <code>true</code> if the delete is successful * @throws IOException If an IO error occurs */ - private boolean deleteResource(HttpServletRequest req, - HttpServletResponse resp) - throws IOException { - + private boolean deleteResource(HttpServletRequest req, HttpServletResponse resp) throws IOException { String path = getRelativePath(req); - return deleteResource(path, req, resp, true); - } @@ -1800,8 +1670,7 @@ public class WebdavServlet extends DefaultServlet { * @return <code>true</code> if the delete is successful * @throws IOException If an IO error occurs */ - private boolean deleteResource(String path, HttpServletRequest req, - HttpServletResponse resp, boolean setStatus) + private boolean deleteResource(String path, HttpServletRequest req, HttpServletResponse resp, boolean setStatus) throws IOException { String ifHeader = req.getHeader("If"); @@ -1833,7 +1702,7 @@ public class WebdavServlet extends DefaultServlet { } } else { - Hashtable<String,Integer> errorList = new Hashtable<>(); + Map<String,Integer> errorList = new HashMap<>(); deleteCollection(req, path, errorList); if (!resource.delete()) { @@ -1859,9 +1728,7 @@ public class WebdavServlet extends DefaultServlet { * @param path Path to the collection to be deleted * @param errorList Contains the list of the errors which occurred */ - private void deleteCollection(HttpServletRequest req, - String path, - Hashtable<String,Integer> errorList) { + private void deleteCollection(HttpServletRequest req, String path, Map<String,Integer> errorList) { if (debug > 1) { log("Delete:" + path); @@ -1925,8 +1792,8 @@ public class WebdavServlet extends DefaultServlet { * * @throws IOException If an IO error occurs */ - private void sendReport(HttpServletRequest req, HttpServletResponse resp, - Hashtable<String,Integer> errorList) throws IOException { + private void sendReport(HttpServletRequest req, HttpServletResponse resp, Map<String,Integer> errorList) + throws IOException { resp.setStatus(WebdavStatus.SC_MULTI_STATUS); @@ -1935,10 +1802,7 @@ public class WebdavServlet extends DefaultServlet { generatedXML.writeElement("D", DEFAULT_NAMESPACE, "multistatus", XMLWriter.OPENING); - Enumeration<String> pathList = errorList.keys(); - while (pathList.hasMoreElements()) { - - String errorPath = pathList.nextElement(); + for (String errorPath : errorList.keySet()) { int errorCode = errorList.get(errorPath).intValue(); generatedXML.writeElement("D", "response", XMLWriter.OPENING); @@ -1969,13 +1833,11 @@ public class WebdavServlet extends DefaultServlet { * @param generatedXML XML response to the Propfind request * @param path Path of the current resource * @param type Propfind type - * @param propertiesVector If the propfind type is find properties by - * name, then this Vector contains those properties + * @param properties If the propfind type is find properties by name, then + * this List contains those properties */ - private void parseProperties(HttpServletRequest req, - XMLWriter generatedXML, - String path, int type, - Vector<String> propertiesVector) { + private void parseProperties(HttpServletRequest req, XMLWriter generatedXML, String path, int type, + List<String> properties) { // Exclude any resource in the /WEB-INF and /META-INF subdirectories if (isSpecialPath(path)) { @@ -2001,10 +1863,9 @@ public class WebdavServlet extends DefaultServlet { String rewrittenUrl = rewriteUrl(href); - generatePropFindResponse(generatedXML, rewrittenUrl, path, type, propertiesVector, - resource.isFile(), false, resource.getCreation(), resource.getLastModified(), - resource.getContentLength(), getServletContext().getMimeType(resource.getName()), - generateETag(resource)); + generatePropFindResponse(generatedXML, rewrittenUrl, path, type, properties, resource.isFile(), false, + resource.getCreation(), resource.getLastModified(), resource.getContentLength(), + getServletContext().getMimeType(resource.getName()), generateETag(resource)); } @@ -2015,13 +1876,11 @@ public class WebdavServlet extends DefaultServlet { * @param generatedXML XML response to the Propfind request * @param path Path of the current resource * @param type Propfind type - * @param propertiesVector If the propfind type is find properties by - * name, then this Vector contains those properties + * @param properties If the propfind type is find properties by name, then + * this List contains those properties */ - private void parseLockNullProperties(HttpServletRequest req, - XMLWriter generatedXML, - String path, int type, - Vector<String> propertiesVector) { + private void parseLockNullProperties(HttpServletRequest req, XMLWriter generatedXML, String path, int type, + List<String> properties) { // Exclude any resource in the /WEB-INF and /META-INF subdirectories if (isSpecialPath(path)) { @@ -2042,19 +1901,16 @@ public class WebdavServlet extends DefaultServlet { toAppend = "/" + toAppend; } - String rewrittenUrl = rewriteUrl(RequestUtil.normalize( - absoluteUri + toAppend)); + String rewrittenUrl = rewriteUrl(RequestUtil.normalize(absoluteUri + toAppend)); - generatePropFindResponse(generatedXML, rewrittenUrl, path, type, propertiesVector, - true, true, lock.creationDate.getTime(), lock.creationDate.getTime(), - 0, "", ""); + generatePropFindResponse(generatedXML, rewrittenUrl, path, type, properties, true, true, + lock.creationDate.getTime(), lock.creationDate.getTime(), 0, "", ""); } - private void generatePropFindResponse(XMLWriter generatedXML, String rewrittenUrl, - String path, int propFindType, Vector<String> propertiesVector, boolean isFile, - boolean isLockNull, long created, long lastModified, long contentLength, - String contentType, String eTag) { + private void generatePropFindResponse(XMLWriter generatedXML, String rewrittenUrl, String path, int propFindType, + List<String> properties, boolean isFile, boolean isLockNull, long created, long lastModified, + long contentLength, String contentType, String eTag) { generatedXML.writeElement("D", "response", XMLWriter.OPENING); String status = "HTTP/1.1 " + WebdavStatus.SC_OK + " "; @@ -2082,8 +1938,7 @@ public class WebdavServlet extends DefaultServlet { generatedXML.writeData(resourceName); generatedXML.writeElement("D", "displayname", XMLWriter.CLOSING); if (isFile) { - generatedXML.writeProperty("D", "getlastmodified", - FastHttpDateFormat.formatDate(lastModified)); + generatedXML.writeProperty("D", "getlastmodified", FastHttpDateFormat.formatDate(lastModified)); generatedXML.writeProperty("D", "getcontentlength", Long.toString(contentLength)); if (contentType != null) { generatedXML.writeProperty("D", "getcontenttype", contentType); @@ -2097,8 +1952,7 @@ public class WebdavServlet extends DefaultServlet { generatedXML.writeElement("D", "resourcetype", XMLWriter.NO_CONTENT); } } else { - generatedXML.writeProperty("D", "getlastmodified", - FastHttpDateFormat.formatDate(lastModified)); + generatedXML.writeProperty("D", "getlastmodified", FastHttpDateFormat.formatDate(lastModified)); generatedXML.writeElement("D", "resourcetype", XMLWriter.OPENING); generatedXML.writeElement("D", "collection", XMLWriter.NO_CONTENT); generatedXML.writeElement("D", "resourcetype", XMLWriter.CLOSING); @@ -2155,19 +2009,14 @@ public class WebdavServlet extends DefaultServlet { case FIND_BY_PROPERTY : - Vector<String> propertiesNotFound = new Vector<>(); + List<String> propertiesNotFound = new ArrayList<>(); // Parse the list of properties generatedXML.writeElement("D", "propstat", XMLWriter.OPENING); generatedXML.writeElement("D", "prop", XMLWriter.OPENING); - Enumeration<String> properties = propertiesVector.elements(); - - while (properties.hasMoreElements()) { - - String property = properties.nextElement(); - + for (String property : properties) { if (property.equals("creationdate")) { generatedXML.writeProperty("D", "creationdate", getISOCreationDate(created)); } else if (property.equals("displayname")) { @@ -2176,36 +2025,33 @@ public class WebdavServlet extends DefaultServlet { generatedXML.writeElement("D", "displayname", XMLWriter.CLOSING); } else if (property.equals("getcontentlanguage")) { if (isFile) { - generatedXML.writeElement("D", "getcontentlanguage", - XMLWriter.NO_CONTENT); + generatedXML.writeElement("D", "getcontentlanguage", XMLWriter.NO_CONTENT); } else { - propertiesNotFound.addElement(property); + propertiesNotFound.add(property); } } else if (property.equals("getcontentlength")) { if (isFile) { - generatedXML.writeProperty("D", "getcontentlength", - Long.toString(contentLength)); + generatedXML.writeProperty("D", "getcontentlength", Long.toString(contentLength)); } else { - propertiesNotFound.addElement(property); + propertiesNotFound.add(property); } } else if (property.equals("getcontenttype")) { if (isFile) { generatedXML.writeProperty("D", "getcontenttype", contentType); } else { - propertiesNotFound.addElement(property); + propertiesNotFound.add(property); } } else if (property.equals("getetag")) { if (isFile) { generatedXML.writeProperty("D", "getetag", eTag); } else { - propertiesNotFound.addElement(property); + propertiesNotFound.add(property); } } else if (property.equals("getlastmodified")) { if (isFile) { - generatedXML.writeProperty("D", "getlastmodified", - FastHttpDateFormat.formatDate(lastModified)); + generatedXML.writeProperty("D", "getlastmodified", FastHttpDateFormat.formatDate(lastModified)); } else { - propertiesNotFound.addElement(property); + propertiesNotFound.add(property); } } else if (property.equals("resourcetype")) { if (isFile) { @@ -2236,12 +2082,11 @@ public class WebdavServlet extends DefaultServlet { generatedXML.writeElement("D", "supportedlock", XMLWriter.CLOSING); } else if (property.equals("lockdiscovery")) { if (!generateLockDiscovery(path, generatedXML)) { - propertiesNotFound.addElement(property); + propertiesNotFound.add(property); } } else { - propertiesNotFound.addElement(property); + propertiesNotFound.add(property); } - } generatedXML.writeElement("D", "prop", XMLWriter.CLOSING); @@ -2250,18 +2095,15 @@ public class WebdavServlet extends DefaultServlet { generatedXML.writeElement("D", "status", XMLWriter.CLOSING); generatedXML.writeElement("D", "propstat", XMLWriter.CLOSING); - Enumeration<String> propertiesNotFoundList = propertiesNotFound.elements(); - - if (propertiesNotFoundList.hasMoreElements()) { + if (!propertiesNotFound.isEmpty()) { status = "HTTP/1.1 " + WebdavStatus.SC_NOT_FOUND + " "; generatedXML.writeElement("D", "propstat", XMLWriter.OPENING); generatedXML.writeElement("D", "prop", XMLWriter.OPENING); - while (propertiesNotFoundList.hasMoreElements()) { - generatedXML.writeElement("D", propertiesNotFoundList.nextElement(), - XMLWriter.NO_CONTENT); + for (String propertyNotFound : propertiesNotFound) { + generatedXML.writeElement("D", propertyNotFound, XMLWriter.NO_CONTENT); } generatedXML.writeElement("D", "prop", XMLWriter.CLOSING); @@ -2269,11 +2111,9 @@ public class WebdavServlet extends DefaultServlet { generatedXML.writeText(status); generatedXML.writeElement("D", "status", XMLWriter.CLOSING); generatedXML.writeElement("D", "propstat", XMLWriter.CLOSING); - } break; - } generatedXML.writeElement("D", "response", XMLWriter.CLOSING); @@ -2287,11 +2127,9 @@ public class WebdavServlet extends DefaultServlet { * @param generatedXML XML data to which the locks info will be appended * @return <code>true</code> if at least one lock was displayed */ - private boolean generateLockDiscovery - (String path, XMLWriter generatedXML) { + private boolean generateLockDiscovery(String path, XMLWriter generatedXML) { LockInfo resourceLock = resourceLocks.get(path); - Enumeration<LockInfo> collectionLocksList = collectionLocks.elements(); boolean wroteStart = false; @@ -2301,8 +2139,7 @@ public class WebdavServlet extends DefaultServlet { resourceLock.toXML(generatedXML); } - while (collectionLocksList.hasMoreElements()) { - LockInfo currentLock = collectionLocksList.nextElement(); + for (LockInfo currentLock : collectionLocks) { if (path.startsWith(currentLock.path)) { if (!wroteStart) { wroteStart = true; @@ -2320,7 +2157,6 @@ public class WebdavServlet extends DefaultServlet { } return true; - } @@ -2332,6 +2168,7 @@ public class WebdavServlet extends DefaultServlet { return creationDateFormat.format(new Date(creationDate)); } + /** * Determines the methods normally allowed for the resource. * @@ -2342,13 +2179,11 @@ public class WebdavServlet extends DefaultServlet { @Override protected String determineMethodsAllowed(HttpServletRequest req) { - WebResource resource = resources.getResource(getRelativePath(req)); // These methods are always allowed. They may return a 404 (not a 405) // if the resource does not exist. - StringBuilder methodsAllowed = new StringBuilder( - "OPTIONS, GET, POST, HEAD"); + StringBuilder methodsAllowed = new StringBuilder("OPTIONS, GET, POST, HEAD"); if (!readOnly) { methodsAllowed.append(", DELETE"); @@ -2358,8 +2193,7 @@ public class WebdavServlet extends DefaultServlet { } // Trace - assume disabled unless we can prove otherwise - if (req instanceof RequestFacade && - ((RequestFacade) req).getAllowTrace()) { + if (req instanceof RequestFacade && ((RequestFacade) req).getAllowTrace()) { methodsAllowed.append(", TRACE"); } @@ -2400,7 +2234,7 @@ public class WebdavServlet extends DefaultServlet { String scope = "exclusive"; int depth = 0; String owner = ""; - Vector<String> tokens = new Vector<>(); + List<String> tokens = Collections.synchronizedList(new ArrayList<>()); long expiresAt = 0; Date creationDate = new Date(); @@ -2423,10 +2257,9 @@ public class WebdavServlet extends DefaultServlet { result.append(owner); result.append("\nExpiration:"); result.append(FastHttpDateFormat.formatDate(expiresAt)); - Enumeration<String> tokensList = tokens.elements(); - while (tokensList.hasMoreElements()) { + for (String token : tokens) { result.append("\nToken:"); - result.append(tokensList.nextElement()); + result.append(token); } result.append("\n"); return result.toString(); @@ -2485,11 +2318,9 @@ public class WebdavServlet extends DefaultServlet { generatedXML.writeElement("D", "timeout", XMLWriter.CLOSING); generatedXML.writeElement("D", "locktoken", XMLWriter.OPENING); - Enumeration<String> tokensList = tokens.elements(); - while (tokensList.hasMoreElements()) { + for (String token : tokens) { generatedXML.writeElement("D", "href", XMLWriter.OPENING); - generatedXML.writeText("opaquelocktoken:" - + tokensList.nextElement()); + generatedXML.writeText("opaquelocktoken:" + token); generatedXML.writeElement("D", "href", XMLWriter.CLOSING); } generatedXML.writeElement("D", "locktoken", XMLWriter.CLOSING); @@ -2515,10 +2346,8 @@ public class WebdavServlet extends DefaultServlet { @Override public InputSource resolveEntity (String publicId, String systemId) { - context.log(sm.getString("webdavservlet.externalEntityIgnored", - publicId, systemId)); - return new InputSource( - new StringReader("Ignored external entity")); + context.log(sm.getString("webdavservlet.externalEntityIgnored", publicId, systemId)); + return new InputSource(new StringReader("Ignored external entity")); } } } @@ -2526,7 +2355,6 @@ public class WebdavServlet extends DefaultServlet { // -------------------------------------------------------- WebdavStatus Class - /** * Wraps the HttpServletResponse class to abstract the * specific protocol used. To support other protocols @@ -2573,8 +2401,7 @@ class WebdavStatus { * moved to a new location, and that future references should use a * new URI with their requests. */ - public static final int SC_MOVED_PERMANENTLY = - HttpServletResponse.SC_MOVED_PERMANENTLY; + public static final int SC_MOVED_PERMANENTLY = HttpServletResponse.SC_MOVED_PERMANENTLY; /** @@ -2582,32 +2409,28 @@ class WebdavStatus { * moved to another location, but that future references should * still use the original URI to access the resource. */ - public static final int SC_MOVED_TEMPORARILY = - HttpServletResponse.SC_MOVED_TEMPORARILY; + public static final int SC_MOVED_TEMPORARILY = HttpServletResponse.SC_MOVED_TEMPORARILY; /** * Status code (304) indicating that a conditional GET operation * found that the resource was available and not modified. */ - public static final int SC_NOT_MODIFIED = - HttpServletResponse.SC_NOT_MODIFIED; + public static final int SC_NOT_MODIFIED = HttpServletResponse.SC_NOT_MODIFIED; /** * Status code (400) indicating the request sent by the client was * syntactically incorrect. */ - public static final int SC_BAD_REQUEST = - HttpServletResponse.SC_BAD_REQUEST; + public static final int SC_BAD_REQUEST = HttpServletResponse.SC_BAD_REQUEST; /** * Status code (401) indicating that the request requires HTTP * authentication. */ - public static final int SC_UNAUTHORIZED = - HttpServletResponse.SC_UNAUTHORIZED; + public static final int SC_UNAUTHORIZED = HttpServletResponse.SC_UNAUTHORIZED; /** @@ -2628,16 +2451,14 @@ class WebdavStatus { * Status code (500) indicating an error inside the HTTP service * which prevented it from fulfilling the request. */ - public static final int SC_INTERNAL_SERVER_ERROR = - HttpServletResponse.SC_INTERNAL_SERVER_ERROR; + public static final int SC_INTERNAL_SERVER_ERROR = HttpServletResponse.SC_INTERNAL_SERVER_ERROR; /** * Status code (501) indicating the HTTP service does not support * the functionality needed to fulfill the request. */ - public static final int SC_NOT_IMPLEMENTED = - HttpServletResponse.SC_NOT_IMPLEMENTED; + public static final int SC_NOT_IMPLEMENTED = HttpServletResponse.SC_NOT_IMPLEMENTED; /** @@ -2645,16 +2466,14 @@ class WebdavStatus { * invalid response from a server it consulted when acting as a * proxy or gateway. */ - public static final int SC_BAD_GATEWAY = - HttpServletResponse.SC_BAD_GATEWAY; + public static final int SC_BAD_GATEWAY = HttpServletResponse.SC_BAD_GATEWAY; /** * Status code (503) indicating that the HTTP service is * temporarily overloaded, and unable to handle the request. */ - public static final int SC_SERVICE_UNAVAILABLE = - HttpServletResponse.SC_SERVICE_UNAVAILABLE; + public static final int SC_SERVICE_UNAVAILABLE = HttpServletResponse.SC_SERVICE_UNAVAILABLE; /** @@ -2663,14 +2482,14 @@ class WebdavStatus { * client that the initial part of the request has been * received and has not yet been rejected by the server. */ - public static final int SC_CONTINUE = 100; + public static final int SC_CONTINUE = HttpServletResponse.SC_CONTINUE; /** * Status code (405) indicating the method specified is not * allowed for the resource. */ - public static final int SC_METHOD_NOT_ALLOWED = 405; + public static final int SC_METHOD_NOT_ALLOWED = HttpServletResponse.SC_METHOD_NOT_ALLOWED; /** @@ -2678,7 +2497,7 @@ class WebdavStatus { * completed due to a conflict with the current state of the * resource. */ - public static final int SC_CONFLICT = 409; + public static final int SC_CONFLICT = HttpServletResponse.SC_CONFLICT; /** @@ -2686,7 +2505,7 @@ class WebdavStatus { * or more of the request-header fields evaluated to false * when it was tested on the server. */ - public static final int SC_PRECONDITION_FAILED = 412; + public static final int SC_PRECONDITION_FAILED = HttpServletResponse.SC_PRECONDITION_FAILED; /** @@ -2694,7 +2513,7 @@ class WebdavStatus { * process a request because the request entity is larger * than the server is willing or able to process. */ - public static final int SC_REQUEST_TOO_LONG = 413; + public static final int SC_REQUEST_TOO_LONG = HttpServletResponse.SC_REQUEST_ENTITY_TOO_LARGE; /** @@ -2703,7 +2522,7 @@ class WebdavStatus { * not supported by the requested resource for the requested * method. */ - public static final int SC_UNSUPPORTED_MEDIA_TYPE = 415; + public static final int SC_UNSUPPORTED_MEDIA_TYPE = HttpServletResponse.SC_UNSUPPORTED_MEDIA_TYPE; // -------------------------------------------- Extended WebDav status code @@ -2753,5 +2572,4 @@ class WebdavStatus { * a lock held by another principal. */ public static final int SC_LOCKED = 423; - } --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscr...@tomcat.apache.org For additional commands, e-mail: dev-h...@tomcat.apache.org