Skip to content

Commit 4f9209b

Browse files
committed
Add writer as parameter to allow wrapping with encryption feature.
1 parent b178db9 commit 4f9209b

File tree

10 files changed

+35
-33
lines changed

10 files changed

+35
-33
lines changed

manta/src/main/java/ch/cyberduck/core/manta/MantaDirectoryFeature.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import ch.cyberduck.core.exception.AccessDeniedException;
2222
import ch.cyberduck.core.exception.BackgroundException;
2323
import ch.cyberduck.core.features.Directory;
24+
import ch.cyberduck.core.features.Write;
2425
import ch.cyberduck.core.transfer.TransferStatus;
2526

2627
import java.io.IOException;
@@ -38,7 +39,7 @@ public MantaDirectoryFeature(MantaSession session) {
3839
}
3940

4041
@Override
41-
public Path mkdir(final Path folder, final TransferStatus status) throws BackgroundException {
42+
public Path mkdir(final Write writer, final Path folder, final TransferStatus status) throws BackgroundException {
4243
try {
4344
session.getClient().putDirectory(folder.getAbsolute());
4445
return folder;

manta/src/main/java/ch/cyberduck/core/manta/MantaTouchFeature.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import ch.cyberduck.core.exception.AccessDeniedException;
2222
import ch.cyberduck.core.exception.BackgroundException;
2323
import ch.cyberduck.core.features.Touch;
24+
import ch.cyberduck.core.features.Write;
2425
import ch.cyberduck.core.transfer.TransferStatus;
2526

2627
import java.io.IOException;
@@ -30,7 +31,7 @@
3031
import com.joyent.manta.exception.MantaClientHttpResponseException;
3132
import com.joyent.manta.exception.MantaException;
3233

33-
public class MantaTouchFeature implements Touch {
34+
public class MantaTouchFeature implements Touch<Void> {
3435

3536
private final MantaSession session;
3637

@@ -39,7 +40,7 @@ public MantaTouchFeature(final MantaSession session) {
3940
}
4041

4142
@Override
42-
public Path touch(final Path file, final TransferStatus status) throws BackgroundException {
43+
public Path touch(final Write<Void> writer, final Path file, final TransferStatus status) throws BackgroundException {
4344
try {
4445
if(!session.getClient().existsAndIsAccessible(file.getParent().getAbsolute())) {
4546
session.getClient().putDirectory(file.getParent().getAbsolute());

manta/src/test/java/ch/cyberduck/core/manta/MantaAttributesFinderFeatureTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public void testFindNotFound() throws Exception {
4747
@Test
4848
public void testFindFile() throws Exception {
4949
final Path file = randomFile();
50-
new MantaTouchFeature(session).touch(file, new TransferStatus().setMime("x-application/cyberduck"));
50+
new MantaTouchFeature(session).touch(new MantaWriteFeature(session), file, new TransferStatus().setMime("x-application/cyberduck"));
5151
final PathAttributes attributes = new MantaAttributesFinderFeature(session).find(file);
5252
assertNotNull(attributes);
5353
assertEquals(-1L, attributes.getCreationDate());

manta/src/test/java/ch/cyberduck/core/manta/MantaDirectoryFeatureTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public class MantaDirectoryFeatureTest extends AbstractMantaTest {
3939

4040
@Test
4141
public void testMkdir() throws Exception {
42-
final Path target = new MantaDirectoryFeature(session).mkdir(randomDirectory(), null);
42+
final Path target = new MantaDirectoryFeature(session).mkdir(new MantaWriteFeature(session), randomDirectory(), null);
4343
final PathAttributes found = new MantaAttributesFinderFeature(session).find(target);
4444
assertNotEquals(Permission.EMPTY, found.getPermission());
4545
new MantaDeleteFeature(session).delete(Collections.singletonList(target), new DisabledLoginCallback(), new Delete.DisabledCallback());
@@ -50,7 +50,7 @@ public void testWhitespaceMkdir() throws Exception {
5050
final RandomStringService randomStringService = new AlphanumericRandomStringService();
5151
final Path target = new MantaDirectoryFeature(session)
5252
.mkdir(
53-
new Path(
53+
new MantaWriteFeature(session), new Path(
5454
testPathPrefix,
5555
String.format("%s %s", randomStringService.random(), randomStringService.random()),
5656
EnumSet.of(Path.Type.directory)

manta/src/test/java/ch/cyberduck/core/manta/MantaListServiceTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public void testListNotFoundFolder() throws Exception {
4444

4545
@Test
4646
public void testListEmptyFolder() throws Exception {
47-
final Path folder = new MantaDirectoryFeature(session).mkdir(new Path(
47+
final Path folder = new MantaDirectoryFeature(session).mkdir(new MantaWriteFeature(session), new Path(
4848
testPathPrefix, UUID.randomUUID().toString(), EnumSet.of(Path.Type.directory)), new TransferStatus());
4949
assertTrue(new MantaListService(session).list(folder, new DisabledListProgressListener()).isEmpty());
5050
new MantaDeleteFeature(session).delete(Collections.singletonList(folder), new DisabledLoginCallback(), new Delete.DisabledCallback());

manta/src/test/java/ch/cyberduck/core/manta/MantaMoveFeatureTest.java

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -46,9 +46,9 @@ public void testRename() throws BackgroundException {
4646
final Move move = new MantaMoveFeature(session);
4747
final Delete delete = new MantaDeleteFeature(session);
4848
final AttributesFinder attributesFinder = new MantaAttributesFinderFeature(session);
49-
final Path drive = new MantaDirectoryFeature(session).mkdir(randomDirectory(), new TransferStatus());
49+
final Path drive = new MantaDirectoryFeature(session).mkdir(new MantaWriteFeature(session), randomDirectory(), new TransferStatus());
5050
final Path file = new Path(drive, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
51-
touch.touch(file, new TransferStatus().setMime("x-application/cyberduck"));
51+
touch.touch(new MantaWriteFeature(session), file, new TransferStatus().setMime("x-application/cyberduck"));
5252
assertNotNull(attributesFinder.find(file));
5353
Path rename = new Path(drive, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
5454
assertTrue(move.isSupported(file, Optional.of(rename)));
@@ -66,12 +66,12 @@ public void testMove() throws BackgroundException {
6666
final Move move = new MantaMoveFeature(session);
6767
final Delete delete = new MantaDeleteFeature(session);
6868
final AttributesFinder attributesFinder = new MantaAttributesFinderFeature(session);
69-
final Path drive = new MantaDirectoryFeature(session).mkdir(randomDirectory(), new TransferStatus());
69+
final Path drive = new MantaDirectoryFeature(session).mkdir(new MantaWriteFeature(session), randomDirectory(), new TransferStatus());
7070
Path targetDirectory = new Path(drive, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory));
71-
directory.mkdir(targetDirectory, null);
71+
directory.mkdir(new MantaWriteFeature(session), targetDirectory, null);
7272
assertNotNull(attributesFinder.find(targetDirectory));
7373
Path touchedFile = new Path(drive, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
74-
touch.touch(touchedFile, new TransferStatus().setMime("x-application/cyberduck"));
74+
touch.touch(new MantaWriteFeature(session), touchedFile, new TransferStatus().setMime("x-application/cyberduck"));
7575
assertNotNull(attributesFinder.find(touchedFile));
7676
Path rename = new Path(targetDirectory, touchedFile.getName(), EnumSet.of(Path.Type.file));
7777
assertTrue(move.isSupported(touchedFile, Optional.of(rename)));
@@ -89,12 +89,12 @@ public void testMoveRename() throws BackgroundException {
8989
final Move move = new MantaMoveFeature(session);
9090
final Delete delete = new MantaDeleteFeature(session);
9191
final AttributesFinder attributesFinder = new MantaAttributesFinderFeature(session);
92-
final Path drive = new MantaDirectoryFeature(session).mkdir(randomDirectory(), new TransferStatus());
92+
final Path drive = new MantaDirectoryFeature(session).mkdir(new MantaWriteFeature(session), randomDirectory(), new TransferStatus());
9393
Path targetDirectory = new Path(drive, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory));
94-
directory.mkdir(targetDirectory, null);
94+
directory.mkdir(new MantaWriteFeature(session), targetDirectory, null);
9595
assertNotNull(attributesFinder.find(targetDirectory));
9696
Path touchedFile = new Path(drive, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
97-
touch.touch(touchedFile, new TransferStatus().setMime("x-application/cyberduck"));
97+
touch.touch(new MantaWriteFeature(session), touchedFile, new TransferStatus().setMime("x-application/cyberduck"));
9898
assertNotNull(attributesFinder.find(touchedFile));
9999
Path rename = new Path(targetDirectory, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
100100
assertTrue(move.isSupported(touchedFile, Optional.of(rename)));

manta/src/test/java/ch/cyberduck/core/manta/MantaReadFeatureTest.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public class MantaReadFeatureTest extends AbstractMantaTest {
5050
public void testReadNotFound() throws Exception {
5151
final TransferStatus status = new TransferStatus();
5252
try {
53-
final Path drive = new MantaDirectoryFeature(session).mkdir(randomDirectory(), new TransferStatus());
53+
final Path drive = new MantaDirectoryFeature(session).mkdir(new MantaWriteFeature(session), randomDirectory(), new TransferStatus());
5454
new MantaReadFeature(session).read(new Path(drive, "nosuchname", EnumSet.of(Path.Type.file)), status, new DisabledConnectionCallback());
5555
}
5656
catch(NotfoundException e) {
@@ -61,9 +61,9 @@ public void testReadNotFound() throws Exception {
6161

6262
@Test
6363
public void testReadInterrupt() throws Exception {
64-
final Path drive = new MantaDirectoryFeature(session).mkdir(randomDirectory(), new TransferStatus());
64+
final Path drive = new MantaDirectoryFeature(session).mkdir(new MantaWriteFeature(session), randomDirectory(), new TransferStatus());
6565
final Path test = new Path(drive, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
66-
new MantaTouchFeature(session).touch(test, new TransferStatus());
66+
new MantaTouchFeature(session).touch(new MantaWriteFeature(session), test, new TransferStatus());
6767
// Unknown length in status
6868
final TransferStatus status = new TransferStatus();
6969
// Read a single byte
@@ -83,9 +83,9 @@ public void testReadInterrupt() throws Exception {
8383

8484
@Test
8585
public void testReadRange() throws Exception {
86-
final Path drive = new MantaDirectoryFeature(session).mkdir(randomDirectory(), new TransferStatus());
86+
final Path drive = new MantaDirectoryFeature(session).mkdir(new MantaWriteFeature(session), randomDirectory(), new TransferStatus());
8787
final Path test = new Path(drive, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
88-
new MantaTouchFeature(session).touch(test, new TransferStatus());
88+
new MantaTouchFeature(session).touch(new MantaWriteFeature(session), test, new TransferStatus());
8989

9090
final Local local = new Local(PROPERTIES.get("java.io.tmpdir"), new AlphanumericRandomStringService().random());
9191

@@ -123,9 +123,9 @@ public void testReadRange() throws Exception {
123123

124124
@Test
125125
public void testReadRangeUnknownLength() throws Exception {
126-
final Path drive = new MantaDirectoryFeature(session).mkdir(randomDirectory(), new TransferStatus());
126+
final Path drive = new MantaDirectoryFeature(session).mkdir(new MantaWriteFeature(session), randomDirectory(), new TransferStatus());
127127
final Path test = new Path(drive, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
128-
new MantaTouchFeature(session).touch(test, new TransferStatus());
128+
new MantaTouchFeature(session).touch(new MantaWriteFeature(session), test, new TransferStatus());
129129

130130
final Local local = new Local(PROPERTIES.get("java.io.tmpdir"), new AlphanumericRandomStringService().random());
131131
final byte[] content = RandomUtils.nextBytes(1000);

manta/src/test/java/ch/cyberduck/core/manta/MantaSearchFeatureTest.java

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ public void testSearchFileNotFound() throws Exception {
4646

4747
final String emptyDirectoryName = new AlphanumericRandomStringService().random();
4848
final Path emptyDirectory = new Path(testPathPrefix, emptyDirectoryName, EnumSet.of(AbstractPath.Type.directory));
49-
new MantaDirectoryFeature(session).mkdir(emptyDirectory, null);
49+
new MantaDirectoryFeature(session).mkdir(new MantaWriteFeature(session), emptyDirectory, null);
5050

5151
final MantaSearchFeature s = new MantaSearchFeature(session);
5252
final AttributedList<Path> search = s.search(emptyDirectory, new NullFilter<>(), new DisabledListProgressListener());
@@ -61,8 +61,8 @@ public void testSearchSameDirectory() throws Exception {
6161
final String newDirectoryName = new AlphanumericRandomStringService().random();
6262
final Path newDirectory = new Path(testPathPrefix, newDirectoryName, TYPE_DIRECTORY);
6363
final String newFileName = new AlphanumericRandomStringService().random();
64-
new MantaDirectoryFeature(session).mkdir(newDirectory, null);
65-
new MantaTouchFeature(session).touch(new Path(newDirectory, newFileName, TYPE_FILE), null);
64+
new MantaDirectoryFeature(session).mkdir(new MantaWriteFeature(session), newDirectory, null);
65+
new MantaTouchFeature(session).touch(new MantaWriteFeature(session), new Path(newDirectory, newFileName, TYPE_FILE), null);
6666

6767
final MantaSearchFeature s = new MantaSearchFeature(session);
6868
final AttributedList<Path> search = s.search(newDirectory, new NullFilter<>(), new DisabledListProgressListener());
@@ -82,10 +82,10 @@ public void testSearchNestedDirectory() throws Exception {
8282

8383
final Path newDirectory = new Path(testPathPrefix, newDirectoryName, TYPE_DIRECTORY);
8484
final Path intermediateDirectory = new Path(newDirectory, intermediateDirectoryName, TYPE_DIRECTORY);
85-
new MantaDirectoryFeature(session).mkdir(newDirectory, null);
86-
new MantaDirectoryFeature(session).mkdir(intermediateDirectory, null);
87-
new MantaTouchFeature(session).touch(new Path(newDirectory, intermediateFileName, TYPE_FILE), null);
88-
new MantaTouchFeature(session).touch(new Path(intermediateDirectory, nestedFileName, TYPE_FILE), null);
85+
new MantaDirectoryFeature(session).mkdir(new MantaWriteFeature(session), newDirectory, null);
86+
new MantaDirectoryFeature(session).mkdir(new MantaWriteFeature(session), intermediateDirectory, null);
87+
new MantaTouchFeature(session).touch(new MantaWriteFeature(session), new Path(newDirectory, intermediateFileName, TYPE_FILE), null);
88+
new MantaTouchFeature(session).touch(new MantaWriteFeature(session), new Path(intermediateDirectory, nestedFileName, TYPE_FILE), null);
8989

9090
final MantaSearchFeature s = new MantaSearchFeature(session);
9191
final AttributedList<Path> search = s.search(newDirectory, new NullFilter<>(), new DisabledListProgressListener());

manta/src/test/java/ch/cyberduck/core/manta/MantaTouchFeatureTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public void testTouch() throws Exception {
4040
testPathPrefix,
4141
new AlphanumericRandomStringService().random(),
4242
EnumSet.of(Path.Type.file));
43-
new MantaTouchFeature(session).touch(file, new TransferStatus().setMime("x-application/cyberduck"));
43+
new MantaTouchFeature(session).touch(new MantaWriteFeature(session), file, new TransferStatus().setMime("x-application/cyberduck"));
4444
assertNotNull(new MantaAttributesFinderFeature(session).find(file));
4545
new MantaDeleteFeature(session).delete(Collections.singletonList(file), new DisabledLoginCallback(), new Delete.DisabledCallback());
4646
}
@@ -52,7 +52,7 @@ public void testWhitespaceTouch() throws Exception {
5252
testPathPrefix,
5353
String.format("%s %s", randomStringService.random(), randomStringService.random()),
5454
EnumSet.of(Path.Type.file));
55-
new MantaTouchFeature(session).touch(file, new TransferStatus().setMime("x-application/cyberduck"));
55+
new MantaTouchFeature(session).touch(new MantaWriteFeature(session), file, new TransferStatus().setMime("x-application/cyberduck"));
5656
assertNotNull(new MantaAttributesFinderFeature(session).find(file));
5757
new MantaDeleteFeature(session).delete(Collections.singletonList(file), new DisabledLoginCallback(), new Delete.DisabledCallback());
5858
}

manta/src/test/java/ch/cyberduck/core/manta/MantaWriteFeatureTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ public class MantaWriteFeatureTest extends AbstractMantaTest {
4444
@Test
4545
public void testWrite() throws Exception {
4646
final MantaWriteFeature feature = new MantaWriteFeature(session);
47-
final Path container = new MantaDirectoryFeature(session).mkdir(randomDirectory(), new TransferStatus());
47+
final Path container = new MantaDirectoryFeature(session).mkdir(new MantaWriteFeature(session), randomDirectory(), new TransferStatus());
4848
final byte[] content = RandomUtils.nextBytes(5 * 1024 * 1024);
4949
final TransferStatus status = new TransferStatus();
5050
status.setLength(content.length);
@@ -69,7 +69,7 @@ public void testWrite() throws Exception {
6969
public void testWriteUnknownLength() throws Exception {
7070
final MantaWriteFeature feature = new MantaWriteFeature(session);
7171
final Path container = randomDirectory();
72-
new MantaDirectoryFeature(session).mkdir(container, new TransferStatus());
72+
new MantaDirectoryFeature(session).mkdir(new MantaWriteFeature(session), container, new TransferStatus());
7373
final byte[] content = RandomUtils.nextBytes(5 * 1024 * 1024);
7474

7575
final TransferStatus status = new TransferStatus();

0 commit comments

Comments
 (0)