1 package ch
.cyberduck
.core
.dav
;
4 * Copyright (c) 2002-2013 David Kocher. All rights reserved.
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
;
36 public class DAVMoveFeature
implements Move
{
38 private DAVSession session
;
40 public DAVMoveFeature(final DAVSession session
) {
41 this.session
= session
;
45 public void move(final Path file
, final Path renamed
, boolean exists
, final Delete
.Callback callback
) throws BackgroundException
{
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
);
59 public boolean isSupported(final Path file
) {