Lines 338-348
Link Here
|
338 |
protected void doOptions(HttpServletRequest req, HttpServletResponse resp) |
338 |
protected void doOptions(HttpServletRequest req, HttpServletResponse resp) |
339 |
throws ServletException, IOException { |
339 |
throws ServletException, IOException { |
340 |
|
340 |
|
341 |
String path = getRelativePath(req); |
|
|
342 |
|
343 |
resp.addHeader("DAV", "1,2"); |
341 |
resp.addHeader("DAV", "1,2"); |
344 |
String methodsAllowed = null; |
342 |
|
345 |
|
|
|
346 |
// Retrieve the resources |
343 |
// Retrieve the resources |
347 |
DirContext resources = getResources(); |
344 |
DirContext resources = getResources(); |
348 |
|
345 |
|
Lines 351-378
Link Here
|
351 |
return; |
348 |
return; |
352 |
} |
349 |
} |
353 |
|
350 |
|
354 |
boolean exists = true; |
351 |
StringBuffer methodsAllowed = determineMethodsAllowed(resources, |
355 |
Object object = null; |
352 |
req); |
356 |
try { |
|
|
357 |
object = resources.lookup(path); |
358 |
} catch (NamingException e) { |
359 |
exists = false; |
360 |
} |
361 |
|
362 |
if (!exists) { |
363 |
methodsAllowed = "OPTIONS, MKCOL, PUT, LOCK"; |
364 |
resp.addHeader("Allow", methodsAllowed); |
365 |
return; |
366 |
} |
367 |
|
368 |
methodsAllowed = "OPTIONS, GET, HEAD, POST, DELETE, TRACE, " |
369 |
+ "PROPFIND, PROPPATCH, COPY, MOVE, LOCK, UNLOCK"; |
370 |
if (!(object instanceof DirContext)) { |
371 |
methodsAllowed += ", PUT"; |
372 |
} |
373 |
|
374 |
resp.addHeader("Allow", methodsAllowed); |
375 |
|
353 |
|
|
|
354 |
resp.addHeader("Allow", methodsAllowed.toString()); |
376 |
resp.addHeader("MS-Author-Via", "DAV"); |
355 |
resp.addHeader("MS-Author-Via", "DAV"); |
377 |
|
356 |
|
378 |
} |
357 |
} |
Lines 385-390
Link Here
|
385 |
throws ServletException, IOException { |
364 |
throws ServletException, IOException { |
386 |
|
365 |
|
387 |
if (!listings) { |
366 |
if (!listings) { |
|
|
367 |
// Retrieve the resources |
368 |
DirContext resources = getResources(); |
369 |
|
370 |
if (resources == null) { |
371 |
resp.sendError(HttpServletResponse.SC_INTERNAL_SERVER_ERROR); |
372 |
return; |
373 |
} |
374 |
|
375 |
// Get allowed methods |
376 |
StringBuffer methodsAllowed = determineMethodsAllowed(resources, |
377 |
req); |
378 |
|
379 |
resp.addHeader("Allow", methodsAllowed.toString()); |
388 |
resp.sendError(WebdavStatus.SC_METHOD_NOT_ALLOWED); |
380 |
resp.sendError(WebdavStatus.SC_METHOD_NOT_ALLOWED); |
389 |
return; |
381 |
return; |
390 |
} |
382 |
} |
Lines 649-655
Link Here
|
649 |
return; |
641 |
return; |
650 |
} |
642 |
} |
651 |
|
643 |
|
652 |
resp.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED); |
644 |
resp.sendError(HttpServletResponse.SC_NOT_IMPLEMENTED); |
653 |
|
645 |
|
654 |
} |
646 |
} |
655 |
|
647 |
|
Lines 697-702
Link Here
|
697 |
// Can't create a collection if a resource already exists at the given |
689 |
// Can't create a collection if a resource already exists at the given |
698 |
// path |
690 |
// path |
699 |
if (exists) { |
691 |
if (exists) { |
|
|
692 |
// Get allowed methods |
693 |
StringBuffer methodsAllowed = determineMethodsAllowed(resources, |
694 |
req); |
695 |
|
696 |
resp.addHeader("Allow", methodsAllowed.toString()); |
697 |
|
700 |
resp.sendError(WebdavStatus.SC_METHOD_NOT_ALLOWED); |
698 |
resp.sendError(WebdavStatus.SC_METHOD_NOT_ALLOWED); |
701 |
return; |
699 |
return; |
702 |
} |
700 |
} |
Lines 2566-2571
Link Here
|
2566 |
return creationDateValue.toString(); |
2564 |
return creationDateValue.toString(); |
2567 |
} |
2565 |
} |
2568 |
|
2566 |
|
|
|
2567 |
/** |
2568 |
* Determines the methods normally allowed for the resource. |
2569 |
* |
2570 |
*/ |
2571 |
private StringBuffer determineMethodsAllowed(DirContext resources, |
2572 |
HttpServletRequest req) { |
2573 |
|
2574 |
StringBuffer methodsAllowed = new StringBuffer(); |
2575 |
boolean exists = true; |
2576 |
Object object = null; |
2577 |
try { |
2578 |
String path = getRelativePath(req); |
2579 |
|
2580 |
object = resources.lookup(path); |
2581 |
} catch (NamingException e) { |
2582 |
exists = false; |
2583 |
} |
2584 |
|
2585 |
if (!exists) { |
2586 |
methodsAllowed.append("OPTIONS, MKCOL, PUT, LOCK"); |
2587 |
return methodsAllowed; |
2588 |
} |
2589 |
|
2590 |
methodsAllowed.append("OPTIONS, GET, HEAD, POST, DELETE, TRACE, "); |
2591 |
methodsAllowed.append("PROPPATCH, COPY, MOVE, LOCK, UNLOCK"); |
2592 |
|
2593 |
if (listings) { |
2594 |
methodsAllowed.append("PROPFIND, "); |
2595 |
} |
2596 |
|
2597 |
if (!(object instanceof DirContext)) { |
2598 |
methodsAllowed.append(", PUT"); |
2599 |
} |
2600 |
|
2601 |
return methodsAllowed; |
2602 |
} |
2569 |
|
2603 |
|
2570 |
// -------------------------------------------------- LockInfo Inner Class |
2604 |
// -------------------------------------------------- LockInfo Inner Class |
2571 |
|
2605 |
|
Lines 3041-3047
Link Here
|
3041 |
private static void addStatusCodeMap(int nKey, String strVal) { |
3075 |
private static void addStatusCodeMap(int nKey, String strVal) { |
3042 |
mapStatusCodes.put(new Integer(nKey), strVal); |
3076 |
mapStatusCodes.put(new Integer(nKey), strVal); |
3043 |
} |
3077 |
} |
3044 |
|
|
|
3045 |
|
3078 |
|
3046 |
}; |
3079 |
}; |
3047 |
|
3080 |
|