try {
// check preconditions
ViolatedPrecondition violatedPrecondition = getPreconditionViolation(sourceUri, destinationUri);
if (violatedPrecondition != null) {
PreconditionViolationException e =
new PreconditionViolationException(violatedPrecondition, sourceUri);
sendPreconditionViolation(e);
throw e;
}
destinationExistsBefore = exists(destinationUri);
if (!overwrite && destinationExistsBefore) {
int statusCode = WebdavStatus.SC_PRECONDITION_FAILED;
sendError( statusCode, getClass().getName()+".noOverwrite", new Object[]{destinationUri} );
throw new WebdavException( statusCode );
}
macro.move(slideToken, sourceUri, destinationUri, macroParameters, null, this, null, this);
if (overwrite && destinationExistsBefore) {
resp.setStatus(WebdavStatus.SC_NO_CONTENT);
} else {
resp.setStatus(WebdavStatus.SC_CREATED);
}
} catch (MacroException e) {
if(generateMultiStatusResponse(isCollection, e, requestUri)) {
String errorMessage = generateErrorMessage(e);
// Write it on the servlet writer
resp.setStatus(WebdavStatus.SC_MULTI_STATUS);
try {
resp.setContentType(TEXT_XML_UTF_8);
resp.getWriter().write(errorMessage);
} catch(IOException ex) {
// Critical error ... Servlet container is dead or something
int statusCode = WebdavStatus.SC_INTERNAL_SERVER_ERROR;
sendError( statusCode, e );
throw new WebdavException( statusCode );
}
} else {
// Returning 207 on non-collection requests is generally
// considered bad. So let's not do it, since this way
// makes clients generally behave better.
SlideException exception = (SlideException)e.enumerateExceptions().nextElement();
if (exception instanceof PreconditionViolationException) {
try {
sendPreconditionViolation((PreconditionViolationException)exception);
} catch(IOException ex) {
// Critical error ... Servlet container is dead or something