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
.MappingMimeTypeService
;
23 import ch
.cyberduck
.core
.MimeTypeService
;
24 import ch
.cyberduck
.core
.Path
;
25 import ch
.cyberduck
.core
.PathContainerService
;
26 import ch
.cyberduck
.core
.exception
.BackgroundException
;
27 import ch
.cyberduck
.core
.features
.Touch
;
29 import java
.io
.ByteArrayInputStream
;
30 import java
.io
.IOException
;
31 import java
.util
.Collections
;
36 public class SwiftTouchFeature
implements Touch
{
38 private SwiftSession session
;
40 final PathContainerService containerService
41 = new SwiftPathContainerService();
43 private MimeTypeService mapping
44 = new MappingMimeTypeService();
46 public SwiftTouchFeature(final SwiftSession session
) {
47 this.session
= session
;
51 public void touch(final Path file
) throws BackgroundException
{
53 session
.getClient().storeObject(new SwiftRegionService(session
).lookup(file
),
54 containerService
.getContainer(file
).getName(),
55 new ByteArrayInputStream(new byte[]{}), mapping
.getMime(file
.getName()), containerService
.getKey(file
),
56 Collections
.<String
, String
>emptyMap());
58 catch(IOException e
) {
59 throw new DefaultIOExceptionMappingService().map("Cannot create file {0}", e
, file
);
64 public boolean isSupported(final Path workdir
) {
65 // Creating files is only possible inside a container.
66 return !workdir
.isRoot();