Add callback for delete operation.
[cyberduck.git] / source / ch / cyberduck / core / dav / DAVMoveFeature.java
blob416d223b934ca1d22e730720d82e1b11942f0fb6
1 package ch.cyberduck.core.dav;
3 /*
4 * Copyright (c) 2002-2013 David Kocher. All rights reserved.
5 * http://cyberduck.ch/
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 2 of the License, or
10 * (at your option) any later version.
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * Bug fixes, suggestions and comments should be sent to:
18 * feedback@cyberduck.ch
21 import ch.cyberduck.core.DefaultIOExceptionMappingService;
22 import ch.cyberduck.core.DescriptiveUrl;
23 import ch.cyberduck.core.Path;
24 import ch.cyberduck.core.exception.BackgroundException;
25 import ch.cyberduck.core.features.Delete;
26 import ch.cyberduck.core.features.Move;
27 import ch.cyberduck.core.shared.DefaultUrlProvider;
29 import java.io.IOException;
31 import com.github.sardine.impl.SardineException;
33 /**
34 * @version $Id$
36 public class DAVMoveFeature implements Move {
38 private DAVSession session;
40 public DAVMoveFeature(final DAVSession session) {
41 this.session = session;
44 @Override
45 public void move(final Path file, final Path renamed, boolean exists, final Delete.Callback callback) throws BackgroundException {
46 try {
47 session.getClient().move(new DAVPathEncoder().encode(file),
48 new DefaultUrlProvider(session.getHost()).toUrl(renamed).find(DescriptiveUrl.Type.provider).getUrl());
50 catch(SardineException e) {
51 throw new DAVExceptionMappingService().map("Cannot rename {0}", e, file);
53 catch(IOException e) {
54 throw new DefaultIOExceptionMappingService().map(e, file);
58 @Override
59 public boolean isSupported(final Path file) {
60 return true;