Merge pull request #64 in ITERATE/cyberduck from feature/windows/9074 to master
[cyberduck.git] / source / ch / cyberduck / core / azure / AzureMoveFeature.java
blob6f6a051baa509c507bcbd2f8825be6ac5a2a313a
1 package ch.cyberduck.core.azure;
3 /*
4 * Copyright (c) 2002-2014 David Kocher. All rights reserved.
5 * http://cyberduck.io/
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.io
21 import ch.cyberduck.core.DisabledListProgressListener;
22 import ch.cyberduck.core.DisabledLoginCallback;
23 import ch.cyberduck.core.Path;
24 import ch.cyberduck.core.PathContainerService;
25 import ch.cyberduck.core.exception.BackgroundException;
26 import ch.cyberduck.core.features.Delete;
27 import ch.cyberduck.core.features.Move;
29 import java.util.Collections;
31 import com.microsoft.azure.storage.OperationContext;
33 /**
34 * @version $Id$
36 public class AzureMoveFeature implements Move {
38 private AzureSession session;
40 private OperationContext context;
42 private PathContainerService containerService
43 = new AzurePathContainerService();
45 public AzureMoveFeature(final AzureSession session, final OperationContext context) {
46 this.session = session;
47 this.context = context;
50 @Override
51 public boolean isSupported(final Path file) {
52 return !containerService.isContainer(file);
55 @Override
56 public void move(final Path file, final Path renamed, final boolean exists, final Delete.Callback callback) throws BackgroundException {
57 if(file.isFile() || file.isPlaceholder()) {
58 new AzureCopyFeature(session, context).copy(file, renamed);
59 new AzureDeleteFeature(session, context).delete(Collections.singletonList(file),
60 new DisabledLoginCallback(), callback);
62 else if(file.isDirectory()) {
63 for(Path i : session.list(file, new DisabledListProgressListener())) {
64 this.move(i, new Path(renamed, i.getName(), i.getType()), false, callback);