You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by ma...@apache.org on 2022/09/09 14:15:15 UTC
[tomcat] branch main updated: Refactoring and clean-up
This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/main by this push:
new 8a83a47d11 Refactoring and clean-up
8a83a47d11 is described below
commit 8a83a47d11c59389878a9428ebfcce81f199a7b9
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 b67db6560f..54c4d0df78 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.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
@@ -204,9 +207,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
@@ -217,28 +219,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<>());
/**
@@ -263,13 +261,11 @@ public class WebdavServlet extends DefaultServlet {
// --------------------------------------------------------- Public Methods
-
/**
* Initialize this servlet.
*/
@Override
- public void init()
- throws ServletException {
+ public void init() throws ServletException {
super.init();
@@ -291,15 +287,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 {
@@ -307,11 +301,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;
}
@@ -321,8 +313,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);
@@ -368,7 +359,6 @@ public class WebdavServlet extends DefaultServlet {
// DefaultServlet processing
super.service(req, resp);
}
-
}
@@ -386,10 +376,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;
@@ -471,9 +459,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");
@@ -487,8 +473,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);
@@ -501,7 +486,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
@@ -527,8 +512,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();
@@ -561,7 +545,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();
@@ -581,11 +565,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);
@@ -594,28 +577,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;
}
@@ -637,12 +610,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<>();
@@ -654,8 +625,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);
@@ -675,23 +645,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()) {
@@ -718,8 +679,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);
@@ -732,7 +692,6 @@ public class WebdavServlet extends DefaultServlet {
}
resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED);
-
}
@@ -743,8 +702,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);
@@ -801,8 +759,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);
@@ -815,7 +772,6 @@ public class WebdavServlet extends DefaultServlet {
}
deleteResource(req, resp);
-
}
@@ -829,8 +785,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);
@@ -848,17 +803,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);
@@ -866,7 +820,6 @@ public class WebdavServlet extends DefaultServlet {
}
copyResource(req, resp);
-
}
@@ -876,8 +829,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);
@@ -894,7 +846,6 @@ public class WebdavServlet extends DefaultServlet {
if (copyResource(req, resp)) {
deleteResource(path, req, resp, false);
}
-
}
@@ -905,8 +856,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);
@@ -977,8 +927,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();
@@ -1030,8 +979,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;
}
@@ -1060,8 +1008,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;
}
@@ -1105,7 +1052,6 @@ public class WebdavServlet extends DefaultServlet {
} else {
lock.owner = "";
}
-
}
String path = getRelativePath(req);
@@ -1114,16 +1060,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)));
@@ -1133,33 +1077,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);
}
}
@@ -1168,54 +1106,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()) {
@@ -1228,17 +1149,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 {
@@ -1255,13 +1174,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
@@ -1271,24 +1190,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) {
@@ -1301,13 +1216,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;
@@ -1316,33 +1228,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);
@@ -1357,7 +1259,6 @@ public class WebdavServlet extends DefaultServlet {
Writer writer = resp.getWriter();
writer.write(generatedXML.toString());
writer.close();
-
}
@@ -1367,8 +1268,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);
@@ -1390,16 +1290,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);
}
}
@@ -1412,34 +1308,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
/**
@@ -1467,7 +1356,6 @@ public class WebdavServlet extends DefaultServlet {
}
return isLocked(path, ifHeader + lockTokenHeader);
-
}
@@ -1485,17 +1373,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;
@@ -1504,22 +1389,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;
@@ -1528,12 +1406,10 @@ public class WebdavServlet extends DefaultServlet {
if (!tokenMatch) {
return true;
}
-
}
}
return false;
-
}
@@ -1666,13 +1542,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);
}
@@ -1703,8 +1579,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);
@@ -1779,14 +1654,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);
-
}
@@ -1801,8 +1671,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");
@@ -1834,7 +1703,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()) {
@@ -1860,9 +1729,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);
@@ -1926,8 +1793,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);
@@ -1936,10 +1803,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);
@@ -1970,13 +1834,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)) {
@@ -2002,10 +1864,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));
}
@@ -2016,13 +1877,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)) {
@@ -2043,19 +1902,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 + " ";
@@ -2083,8 +1939,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);
@@ -2098,8 +1953,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);
@@ -2156,19 +2010,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")) {
@@ -2177,36 +2026,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) {
@@ -2237,12 +2083,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);
@@ -2251,18 +2096,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);
@@ -2270,11 +2112,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);
@@ -2288,11 +2128,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;
@@ -2302,8 +2140,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;
@@ -2321,7 +2158,6 @@ public class WebdavServlet extends DefaultServlet {
}
return true;
-
}
@@ -2333,6 +2169,7 @@ public class WebdavServlet extends DefaultServlet {
return creationDateFormat.format(new Date(creationDate));
}
+
/**
* Determines the methods normally allowed for the resource.
*
@@ -2343,13 +2180,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");
@@ -2359,8 +2194,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");
}
@@ -2401,7 +2235,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();
@@ -2424,10 +2258,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();
@@ -2486,11 +2319,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);
@@ -2516,10 +2347,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"));
}
}
}
@@ -2527,7 +2356,6 @@ public class WebdavServlet extends DefaultServlet {
// -------------------------------------------------------- WebdavStatus Class
-
/**
* Wraps the HttpServletResponse class to abstract the
* specific protocol used. To support other protocols
@@ -2574,8 +2402,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;
/**
@@ -2583,32 +2410,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;
/**
@@ -2629,16 +2452,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;
/**
@@ -2646,16 +2467,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;
/**
@@ -2664,14 +2483,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;
/**
@@ -2679,7 +2498,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;
/**
@@ -2687,7 +2506,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;
/**
@@ -2695,7 +2514,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;
/**
@@ -2704,7 +2523,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
@@ -2754,5 +2573,4 @@ class WebdavStatus {
* a lock held by another principal.
*/
public static final int SC_LOCKED = 423;
-
}
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org