1 package ch
.cyberduck
.core
.openstack
;
4 * Copyright (c) 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
.Path
;
23 import ch
.cyberduck
.core
.PathContainerService
;
24 import ch
.cyberduck
.core
.exception
.BackgroundException
;
25 import ch
.cyberduck
.core
.features
.Copy
;
27 import java
.io
.IOException
;
29 import ch
.iterate
.openstack
.swift
.exception
.GenericException
;
34 public class SwiftCopyFeature
implements Copy
{
36 private SwiftSession session
;
38 private PathContainerService containerService
39 = new SwiftPathContainerService();
41 public SwiftCopyFeature(final SwiftSession session
) {
42 this.session
= session
;
46 public void copy(final Path source
, final Path copy
) throws BackgroundException
{
49 session
.getClient().copyObject(new SwiftRegionService(session
).lookup(source
),
50 containerService
.getContainer(source
).getName(), containerService
.getKey(source
),
51 containerService
.getContainer(copy
).getName(), containerService
.getKey(copy
));
54 catch(GenericException e
) {
55 throw new SwiftExceptionMappingService().map("Cannot copy {0}", e
, source
);
57 catch(IOException e
) {
58 throw new DefaultIOExceptionMappingService().map("Cannot copy {0}", e
, source
);