Skip to content
This repository was archived by the owner on Mar 14, 2025. It is now read-only.

Commit 8472f23

Browse files
authored
Merge pull request #2 from cryptomator/feature/webdav
Implemented a "WebDAV" CloudProvider
2 parents fc3f932 + a5f7d6b commit 8472f23

File tree

49 files changed

+2964
-9
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+2964
-9
lines changed

pom.xml

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,16 @@
1313

1414
<properties>
1515
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
16-
1716
<guava.version>29.0-jre</guava.version>
17+
18+
<okhttp.version>4.7.2</okhttp.version>
19+
<okhttp-digest.version>2.3</okhttp-digest.version>
20+
<okhttp.mockwebserver.version>4.7.2</okhttp.mockwebserver.version>
21+
<kxml2.version>2.3.0</kxml2.version>
22+
23+
<slf4j.version>1.7.28</slf4j.version>
24+
<logback.version>1.2.3</logback.version>
25+
1826
<junit.jupiter.version>5.6.2</junit.jupiter.version>
1927
<mockito.version>3.3.3</mockito.version>
2028
<hamcrest.version>2.2</hamcrest.version>
@@ -49,7 +57,36 @@
4957
<artifactId>guava</artifactId>
5058
<version>${guava.version}</version>
5159
</dependency>
52-
60+
61+
<!-- Logging -->
62+
<dependency>
63+
<groupId>org.slf4j</groupId>
64+
<artifactId>slf4j-api</artifactId>
65+
<version>${slf4j.version}</version>
66+
</dependency>
67+
<dependency>
68+
<groupId>org.slf4j</groupId>
69+
<artifactId>slf4j-simple</artifactId>
70+
<version>${slf4j.version}</version>
71+
</dependency>
72+
73+
<!-- WebDAV -->
74+
<dependency>
75+
<groupId>com.squareup.okhttp3</groupId>
76+
<artifactId>okhttp</artifactId>
77+
<version>${okhttp.version}</version>
78+
</dependency>
79+
<dependency>
80+
<groupId>com.burgstaller</groupId>
81+
<artifactId>okhttp-digest</artifactId>
82+
<version>${okhttp-digest.version}</version>
83+
</dependency>
84+
<dependency>
85+
<groupId>net.sf.kxml</groupId>
86+
<artifactId>kxml2</artifactId>
87+
<version>${kxml2.version}</version>
88+
</dependency>
89+
5390
<!-- Test -->
5491
<dependency>
5592
<groupId>org.junit.jupiter</groupId>
@@ -69,6 +106,12 @@
69106
<version>${hamcrest.version}</version>
70107
<scope>test</scope>
71108
</dependency>
109+
<dependency>
110+
<groupId>com.squareup.okhttp3</groupId>
111+
<artifactId>mockwebserver</artifactId>
112+
<version>${okhttp.mockwebserver.version}</version>
113+
<scope>test</scope>
114+
</dependency>
72115
</dependencies>
73116

74117
<build>

src/main/java/module-info.java

Lines changed: 0 additions & 6 deletions
This file was deleted.

src/main/java/org/cryptomator/cloudaccess/api/CloudItemList.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,13 @@ public CloudItemList add(final List<CloudItemMetadata> items, final Optional<Str
3232
final List<CloudItemMetadata> union = Stream.concat(this.items.stream(), items.stream()).collect(Collectors.toList());
3333
return new CloudItemList(union, nextPageToken);
3434
}
35+
36+
public CloudItemList add(final List<CloudItemMetadata> items) {
37+
return add(items, Optional.empty());
38+
}
3539

3640
public static CloudItemList empty() {
3741
return new CloudItemList(Collections.emptyList());
3842
}
43+
3944
}

src/main/java/org/cryptomator/cloudaccess/api/CloudItemMetadata.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package org.cryptomator.cloudaccess.api;
22

3+
import com.google.common.base.Objects;
4+
35
import java.nio.file.Path;
46
import java.time.Instant;
57
import java.util.Optional;
@@ -42,4 +44,21 @@ public Optional<Instant> getLastModifiedDate() {
4244
public Optional<Long> getSize() {
4345
return size;
4446
}
47+
48+
@Override
49+
public boolean equals(Object o) {
50+
if (this == o) return true;
51+
if (o == null || getClass() != o.getClass()) return false;
52+
CloudItemMetadata that = (CloudItemMetadata) o;
53+
return Objects.equal(this.name, that.name) &&
54+
Objects.equal(this.path, that.path) &&
55+
this.itemType == that.itemType &&
56+
Objects.equal(this.lastModifiedDate, that.lastModifiedDate) &&
57+
Objects.equal(this.size, that.size);
58+
}
59+
60+
@Override
61+
public int hashCode() {
62+
return Objects.hashCode(name, path, itemType, lastModifiedDate, size);
63+
}
4564
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
package org.cryptomator.cloudaccess.api;
2+
3+
import java.util.concurrent.TimeUnit;
4+
5+
import static java.util.concurrent.TimeUnit.SECONDS;
6+
7+
public enum NetworkTimeout {
8+
9+
CONNECTION(30L, SECONDS), //
10+
READ(30L, SECONDS), //
11+
WRITE(30L, SECONDS);
12+
13+
private final long timeout;
14+
private final TimeUnit unit;
15+
16+
NetworkTimeout(final long timeout, final TimeUnit unit) {
17+
this.timeout = timeout;
18+
this.unit = unit;
19+
}
20+
21+
public long getTimeout() {
22+
return timeout;
23+
}
24+
25+
public TimeUnit getUnit() {
26+
return unit;
27+
}
28+
29+
public long asMilliseconds() {
30+
return unit.toMillis(timeout);
31+
}
32+
}

src/main/java/org/cryptomator/cloudaccess/api/ProgressListener.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ public interface ProgressListener {
44

55
ProgressListener NO_PROGRESS_AWARE = value -> {};
66

7-
void onProgress(int value);
7+
void onProgress(long value);
88

99
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package org.cryptomator.cloudaccess.api.exceptions;
2+
3+
import java.util.concurrent.CompletionException;
4+
5+
public class BackendException extends CompletionException {
6+
7+
public BackendException() {
8+
super();
9+
}
10+
11+
public BackendException(Throwable e) {
12+
super(e);
13+
}
14+
15+
public BackendException(String message) {
16+
super(message);
17+
}
18+
19+
public BackendException(String message, Throwable e) {
20+
super(message, e);
21+
}
22+
23+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
package org.cryptomator.cloudaccess.api.exceptions;
2+
3+
public class CloudNodeAlreadyExistsException extends BackendException {
4+
5+
public CloudNodeAlreadyExistsException(String name) {
6+
super(name);
7+
}
8+
9+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package org.cryptomator.cloudaccess.api.exceptions;
2+
3+
public class ForbiddenException extends BackendException {
4+
}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
package org.cryptomator.cloudaccess.api.exceptions;
2+
3+
public class InsufficientStorageException extends BackendException {
4+
}

0 commit comments

Comments
 (0)