Skip to content

Commit b178db9

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

15 files changed

+93
-93
lines changed

storegate/src/main/java/ch/cyberduck/core/storegate/StoregateDirectoryFeature.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
import ch.cyberduck.core.exception.AccessDeniedException;
2121
import ch.cyberduck.core.exception.BackgroundException;
2222
import ch.cyberduck.core.features.Directory;
23+
import ch.cyberduck.core.features.Write;
2324
import ch.cyberduck.core.storegate.io.swagger.client.ApiException;
2425
import ch.cyberduck.core.storegate.io.swagger.client.api.FilesApi;
2526
import ch.cyberduck.core.storegate.io.swagger.client.model.CreateFolderRequest;
@@ -39,7 +40,7 @@ public StoregateDirectoryFeature(final StoregateSession session, final Storegate
3940
}
4041

4142
@Override
42-
public Path mkdir(final Path folder, final TransferStatus status) throws BackgroundException {
43+
public Path mkdir(final Write<File> writer, final Path folder, final TransferStatus status) throws BackgroundException {
4344
try {
4445
final FilesApi files = new FilesApi(session.getClient());
4546
final CreateFolderRequest request = new CreateFolderRequest();

storegate/src/main/java/ch/cyberduck/core/storegate/StoregateTouchFeature.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
public class StoregateTouchFeature extends DefaultTouchFeature<File> {
2828

2929
public StoregateTouchFeature(final StoregateSession session, final StoregateIdProvider fileid) {
30-
super(new StoregateWriteFeature(session, fileid));
30+
super(session);
3131
}
3232

3333
@Override

storegate/src/test/java/ch/cyberduck/core/storegate/StoregateAttributesFinderFeatureTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,11 @@ public void testDefaultPaths() throws Exception {
6565
public void testFind() throws Exception {
6666
final StoregateIdProvider nodeid = new StoregateIdProvider(session);
6767
final Path room = new StoregateDirectoryFeature(session, nodeid).mkdir(
68-
new Path(String.format("/My files/%s", new AlphanumericRandomStringService().random()),
68+
new StoregateWriteFeature(session, nodeid), new Path(String.format("/My files/%s", new AlphanumericRandomStringService().random()),
6969
EnumSet.of(Path.Type.directory, Path.Type.volume)), new TransferStatus());
7070
assertTrue(room.attributes().getPermission().isExecutable());
7171
final Path test = new StoregateTouchFeature(session, nodeid).touch(
72-
new Path(room, String.format("%s", new AlphanumericRandomStringService().random()), EnumSet.of(Path.Type.file)), new TransferStatus());
72+
new StoregateWriteFeature(session, nodeid), new Path(room, String.format("%s", new AlphanumericRandomStringService().random()), EnumSet.of(Path.Type.file)), new TransferStatus());
7373
final PathAttributes attr = new StoregateAttributesFinderFeature(session, nodeid).find(test);
7474
assertEquals(attr, new StoregateAttributesFinderFeature(session, nodeid).find(new Path(test.getParent(), StringUtils.upperCase(test.getName()), test.getType())));
7575
assertEquals(attr, new StoregateAttributesFinderFeature(session, nodeid).find(new Path(test.getParent(), StringUtils.lowerCase(test.getName()), test.getType())));
@@ -90,9 +90,9 @@ public void testFind() throws Exception {
9090
public void testChangedNodeId() throws Exception {
9191
final StoregateIdProvider nodeid = new StoregateIdProvider(session);
9292
final Path room = new StoregateDirectoryFeature(session, nodeid).mkdir(
93-
new Path(String.format("/My files/%s", new AlphanumericRandomStringService().random()),
93+
new StoregateWriteFeature(session, nodeid), new Path(String.format("/My files/%s", new AlphanumericRandomStringService().random()),
9494
EnumSet.of(Path.Type.directory, Path.Type.volume)), new TransferStatus());
95-
final Path test = new StoregateTouchFeature(session, nodeid).touch(new Path(room, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)), new TransferStatus());
95+
final Path test = new StoregateTouchFeature(session, nodeid).touch(new StoregateWriteFeature(session, nodeid), new Path(room, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)), new TransferStatus());
9696
final String latestnodeid = test.attributes().getFileId();
9797
assertNotNull(latestnodeid);
9898
// Assume previously seen but changed on server

storegate/src/test/java/ch/cyberduck/core/storegate/StoregateCopyFeatureTest.java

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,12 @@ public class StoregateCopyFeatureTest extends AbstractStoregateTest {
4444
@Test
4545
public void testCopyFileServerSide() throws Exception {
4646
final StoregateIdProvider nodeid = new StoregateIdProvider(session);
47-
final Path room = new StoregateDirectoryFeature(session, nodeid).mkdir(new Path(
47+
final Path room = new StoregateDirectoryFeature(session, nodeid).mkdir(new StoregateWriteFeature(session, nodeid), new Path(
4848
String.format("/My files/%s", new AlphanumericRandomStringService().random()), EnumSet.of(Path.Type.directory, Path.Type.volume)), new TransferStatus());
49-
final Path test = new StoregateTouchFeature(session, nodeid).touch(new Path(room, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)), new TransferStatus());
50-
final Path copy = new Path(new StoregateDirectoryFeature(session, nodeid).mkdir(new Path(room, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory)), new TransferStatus()), test.getName(), EnumSet.of(Path.Type.file));
49+
final Path test = new StoregateTouchFeature(session, nodeid).touch(new StoregateWriteFeature(session, nodeid), new Path(room, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)), new TransferStatus());
50+
final Path copy = new Path(new StoregateDirectoryFeature(session, nodeid).mkdir(new StoregateWriteFeature(session, nodeid), new Path(room, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory)), new TransferStatus()), test.getName(), EnumSet.of(Path.Type.file));
5151
final TransferStatus status = new TransferStatus();
52-
new StoregateTouchFeature(session, nodeid).touch(copy, status);
52+
new StoregateTouchFeature(session, nodeid).touch(new StoregateWriteFeature(session, nodeid), copy, status);
5353
final StoregateCopyFeature feature = new StoregateCopyFeature(session, nodeid);
5454
assertTrue(feature.isSupported(test, Optional.of(copy)));
5555
assertNotEquals(test.attributes().getFileId(), new StoregateCopyFeature(session, nodeid).copy(test, copy, new TransferStatus(), new DisabledConnectionCallback(), new DisabledStreamListener()).attributes().getFileId());
@@ -61,10 +61,10 @@ public void testCopyFileServerSide() throws Exception {
6161
@Test
6262
public void testCopyFileWithRename() throws Exception {
6363
final StoregateIdProvider fileid = new StoregateIdProvider(session);
64-
final Path room = new StoregateDirectoryFeature(session, fileid).mkdir(new Path(
64+
final Path room = new StoregateDirectoryFeature(session, fileid).mkdir(new StoregateWriteFeature(session, fileid), new Path(
6565
String.format("/My files/%s", new AlphanumericRandomStringService().random()), EnumSet.of(Path.Type.directory, Path.Type.volume)), new TransferStatus());
66-
final Path test = new StoregateTouchFeature(session, fileid).touch(new Path(room, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)), new TransferStatus());
67-
final Path copy = new Path(new StoregateDirectoryFeature(session, fileid).mkdir(new Path(room, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory)), new TransferStatus()), new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
66+
final Path test = new StoregateTouchFeature(session, fileid).touch(new StoregateWriteFeature(session, fileid), new Path(room, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)), new TransferStatus());
67+
final Path copy = new Path(new StoregateDirectoryFeature(session, fileid).mkdir(new StoregateWriteFeature(session, fileid), new Path(room, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory)), new TransferStatus()), new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
6868
assertNotEquals(test.attributes().getFileId(), new StoregateCopyFeature(session, fileid).copy(test, copy, new TransferStatus(), new DisabledConnectionCallback(), new DisabledStreamListener()).attributes().getFileId());
6969
assertTrue(new DefaultFindFeature(session).find(test));
7070
assertTrue(new DefaultFindFeature(session).find(copy));
@@ -74,15 +74,15 @@ public void testCopyFileWithRename() throws Exception {
7474
@Test
7575
public void testCopyServerSideToExistingFile() throws Exception {
7676
final StoregateIdProvider fileid = new StoregateIdProvider(session);
77-
final Path top = new StoregateDirectoryFeature(session, fileid).mkdir(new Path(
77+
final Path top = new StoregateDirectoryFeature(session, fileid).mkdir(new StoregateWriteFeature(session, fileid), new Path(
7878
String.format("/My files/%s", new AlphanumericRandomStringService().random()), EnumSet.of(Path.Type.directory, Path.Type.volume)), new TransferStatus());
7979
final Path sourceFolder = new Path(top, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory));
8080
final Path targetFolder = new Path(top, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory));
81-
new StoregateDirectoryFeature(session, fileid).mkdir(sourceFolder, new TransferStatus());
82-
new StoregateDirectoryFeature(session, fileid).mkdir(targetFolder, new TransferStatus());
83-
final Path test = new StoregateTouchFeature(session, fileid).touch(new Path(sourceFolder, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)), new TransferStatus());
81+
new StoregateDirectoryFeature(session, fileid).mkdir(new StoregateWriteFeature(session, fileid), sourceFolder, new TransferStatus());
82+
new StoregateDirectoryFeature(session, fileid).mkdir(new StoregateWriteFeature(session, fileid), targetFolder, new TransferStatus());
83+
final Path test = new StoregateTouchFeature(session, fileid).touch(new StoregateWriteFeature(session, fileid), new Path(sourceFolder, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)), new TransferStatus());
8484
final Path copy = new Path(targetFolder, test.getName(), EnumSet.of(Path.Type.file));
85-
new StoregateTouchFeature(session, fileid).touch(copy, new TransferStatus());
85+
new StoregateTouchFeature(session, fileid).touch(new StoregateWriteFeature(session, fileid), copy, new TransferStatus());
8686
final StoregateCopyFeature feature = new StoregateCopyFeature(session, fileid);
8787
assertTrue(feature.isSupported(test, Optional.of(copy)));
8888
assertNotEquals(test.attributes().getFileId(), new StoregateCopyFeature(session, fileid).copy(test, copy, new TransferStatus().setExists(true), new DisabledConnectionCallback(), new DisabledStreamListener()).attributes().getFileId());
@@ -95,13 +95,13 @@ public void testCopyServerSideToExistingFile() throws Exception {
9595
@Test
9696
public void testCopyWithRenameToExistingFile() throws Exception {
9797
final StoregateIdProvider fileid = new StoregateIdProvider(session);
98-
final Path top = new StoregateDirectoryFeature(session, fileid).mkdir(new Path(
98+
final Path top = new StoregateDirectoryFeature(session, fileid).mkdir(new StoregateWriteFeature(session, fileid), new Path(
9999
String.format("/My files/%s", new AlphanumericRandomStringService().random()), EnumSet.of(Path.Type.directory, Path.Type.volume)), new TransferStatus());
100100
final Path folder = new Path(top, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory));
101-
new StoregateDirectoryFeature(session, fileid).mkdir(folder, new TransferStatus());
102-
final Path test = new StoregateTouchFeature(session, fileid).touch(new Path(folder, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)), new TransferStatus());
101+
new StoregateDirectoryFeature(session, fileid).mkdir(new StoregateWriteFeature(session, fileid), folder, new TransferStatus());
102+
final Path test = new StoregateTouchFeature(session, fileid).touch(new StoregateWriteFeature(session, fileid), new Path(folder, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file)), new TransferStatus());
103103
final Path test2 = new Path(folder, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
104-
new StoregateTouchFeature(session, fileid).touch(test2, new TransferStatus());
104+
new StoregateTouchFeature(session, fileid).touch(new StoregateWriteFeature(session, fileid), test2, new TransferStatus());
105105
assertNotEquals(test.attributes().getFileId(), new StoregateCopyFeature(session, fileid).copy(test, test2, new TransferStatus().setExists(true), new DisabledConnectionCallback(), new DisabledStreamListener()).attributes().getFileId());
106106
final Find find = new DefaultFindFeature(session);
107107
assertTrue(find.find(test));
@@ -112,13 +112,13 @@ public void testCopyWithRenameToExistingFile() throws Exception {
112112
@Test
113113
public void testCopyDirectoryServerSide() throws Exception {
114114
final StoregateIdProvider fileid = new StoregateIdProvider(session);
115-
final Path top = new StoregateDirectoryFeature(session, fileid).mkdir(new Path(
115+
final Path top = new StoregateDirectoryFeature(session, fileid).mkdir(new StoregateWriteFeature(session, fileid), new Path(
116116
String.format("/My files/%s", new AlphanumericRandomStringService().random()), EnumSet.of(Path.Type.directory, Path.Type.volume)), new TransferStatus());
117-
final Path directory = new StoregateDirectoryFeature(session, fileid).mkdir(new Path(top, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory)), new TransferStatus());
117+
final Path directory = new StoregateDirectoryFeature(session, fileid).mkdir(new StoregateWriteFeature(session, fileid), new Path(top, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory)), new TransferStatus());
118118
final String name = new AlphanumericRandomStringService().random();
119119
final TransferStatus status = new TransferStatus();
120-
final Path file = new StoregateTouchFeature(session, fileid).touch(new Path(directory, name, EnumSet.of(Path.Type.file)), status);
121-
final Path target_parent = new StoregateDirectoryFeature(session, fileid).mkdir(new Path(top, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory)), new TransferStatus());
120+
final Path file = new StoregateTouchFeature(session, fileid).touch(new StoregateWriteFeature(session, fileid), new Path(directory, name, EnumSet.of(Path.Type.file)), status);
121+
final Path target_parent = new StoregateDirectoryFeature(session, fileid).mkdir(new StoregateWriteFeature(session, fileid), new Path(top, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.directory)), new TransferStatus());
122122
final Path target = new Path(target_parent, directory.getName(), EnumSet.of(Path.Type.directory));
123123
final StoregateCopyFeature feature = new StoregateCopyFeature(session, fileid);
124124
assertTrue(feature.isSupported(directory, Optional.of(target)));

storegate/src/test/java/ch/cyberduck/core/storegate/StoregateDeleteFeatureTest.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ public void testDeleteFile() throws Exception {
4242
final StoregateIdProvider nodeid = new StoregateIdProvider(session);
4343
final Path room = new Path("/My files", EnumSet.of(Path.Type.directory, Path.Type.volume));
4444
final Path fileInRoom = new Path(room, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
45-
new StoregateTouchFeature(session, nodeid).touch(fileInRoom, new TransferStatus());
45+
new StoregateTouchFeature(session, nodeid).touch(new StoregateWriteFeature(session, nodeid), fileInRoom, new TransferStatus());
4646
assertTrue(new DefaultFindFeature(session).find(fileInRoom));
4747
new StoregateDeleteFeature(session, nodeid).delete(Collections.singletonList(fileInRoom), new DisabledLoginCallback(), new Delete.DisabledCallback());
4848
assertFalse(new DefaultFindFeature(session).find(fileInRoom));
@@ -53,7 +53,7 @@ public void testDeleteFileWithLock() throws Exception {
5353
final StoregateIdProvider nodeid = new StoregateIdProvider(session);
5454
final Path room = new Path("/My files", EnumSet.of(Path.Type.directory, Path.Type.volume));
5555
final Path fileInRoom = new Path(room, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
56-
new StoregateTouchFeature(session, nodeid).touch(fileInRoom, new TransferStatus());
56+
new StoregateTouchFeature(session, nodeid).touch(new StoregateWriteFeature(session, nodeid), fileInRoom, new TransferStatus());
5757
final String lock = new StoregateLockFeature(session, nodeid).lock(fileInRoom);
5858
assertTrue(new DefaultFindFeature(session).find(fileInRoom));
5959
new StoregateDeleteFeature(session, nodeid).delete(Collections.singletonMap(fileInRoom, new TransferStatus().setLockId(lock)), new DisabledLoginCallback(), new Delete.DisabledCallback());
@@ -63,13 +63,13 @@ public void testDeleteFileWithLock() throws Exception {
6363
@Test
6464
public void testDeleteFolderRoomWithContent() throws Exception {
6565
final StoregateIdProvider nodeid = new StoregateIdProvider(session);
66-
final Path room = new StoregateDirectoryFeature(session, nodeid).mkdir(new Path(
66+
final Path room = new StoregateDirectoryFeature(session, nodeid).mkdir(new StoregateWriteFeature(session, nodeid), new Path(
6767
String.format("/My files/%s", new AlphanumericRandomStringService().random()), EnumSet.of(Path.Type.directory, Path.Type.volume)), new TransferStatus());
68-
final Path folder = new StoregateDirectoryFeature(session, nodeid).mkdir(new Path(room,
68+
final Path folder = new StoregateDirectoryFeature(session, nodeid).mkdir(new StoregateWriteFeature(session, nodeid), new Path(room,
6969
new AlphanumericRandomStringService().random().toLowerCase(), EnumSet.of(Path.Type.directory)), new TransferStatus());
7070
assertTrue(new DefaultFindFeature(session).find(folder));
7171
final Path file = new Path(folder, new AlphanumericRandomStringService().random(), EnumSet.of(Path.Type.file));
72-
new StoregateTouchFeature(session, nodeid).touch(file, new TransferStatus());
72+
new StoregateTouchFeature(session, nodeid).touch(new StoregateWriteFeature(session, nodeid), file, new TransferStatus());
7373
assertTrue(new DefaultFindFeature(session).find(file));
7474
new StoregateDeleteFeature(session, nodeid).delete(Collections.singletonList(folder), new DisabledLoginCallback(), new Delete.DisabledCallback());
7575
assertFalse(new DefaultFindFeature(session).find(folder));

storegate/src/test/java/ch/cyberduck/core/storegate/StoregateDirectoryFeatureTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ public class StoregateDirectoryFeatureTest extends AbstractStoregateTest {
3939
public void testCreateDirectory() throws Exception {
4040
final StoregateIdProvider nodeid = new StoregateIdProvider(session);
4141
final Path folder = new StoregateDirectoryFeature(session, nodeid).mkdir(
42-
new Path(String.format("/My files/%s", new AlphanumericRandomStringService().random()), EnumSet.of(Path.Type.directory)), new TransferStatus());
42+
new StoregateWriteFeature(session, nodeid), new Path(String.format("/My files/%s", new AlphanumericRandomStringService().random()), EnumSet.of(Path.Type.directory)), new TransferStatus());
4343
assertTrue(new StoregateFindFeature(session, nodeid).find(folder));
4444
// Can create again regardless if exists
45-
new StoregateDirectoryFeature(session, nodeid).mkdir(folder, new TransferStatus());
45+
new StoregateDirectoryFeature(session, nodeid).mkdir(new StoregateWriteFeature(session, nodeid), folder, new TransferStatus());
4646
new StoregateDeleteFeature(session, nodeid).delete(Collections.singletonList(folder), new DisabledLoginCallback(), new Delete.DisabledCallback());
4747
assertFalse(new DefaultFindFeature(session).find(folder));
4848
}

0 commit comments

Comments
 (0)