@Override
public void invoke(IDavContext ctxt) throws MethodException {
try {
IDavRepo repo = getRepo();
IDavItem sourceItem = repo.getItem(getDavContext(), this.getPath());
if (sourceItem != null) {
String destination = URLDecoder.decode(this.getRequest().getHeader("Destination"), "UTF-8");
// Can only move a file within this repository
if (destination.startsWith(this.getBaseUrl())) {
// Remove the prefix (leaving leading slash)
destination = destination.substring(this.getBaseUrl().length());
// Check if there is already another file at this destination
IDavItem destinationItem = null;
try {
destinationItem = repo.getItem(getDavContext(), destination);
} catch (Exception e) {
// Item does not exist
}