Skip to content

Commit a964d26

Browse files
authored
Merge pull request #91 from a-schild/main
Keep in sinch with main branch
2 parents a7a6ee9 + eab3737 commit a964d26

24 files changed

Lines changed: 1296 additions & 1303 deletions

Changelog.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,14 @@
11
# Changelog for nextcloud api
2+
## Version 13.0.2
3+
- 2024-03-16
4+
- Typo fixes
5+
- Javadoc url's
6+
- Modifiers should be declared in the correct order
7+
- Try-with resources
8+
- Use constants where possible
9+
- Removed redundant Exception throwing
10+
- Simplified assertions in tests
11+
212
## Version 13.0.1
313
- 2023-09-29
414
- Release 13.0.1

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Java api library to access nextcloud features from java applications
1919
<dependency>
2020
<groupId>com.github.a-schild</groupId>
2121
<artifactId>nextcloud-java-api</artifactId>
22-
<version>13.0.1</version>
22+
<version>13.1.0</version>
2323
</dependency>
2424
```
2525

pom.xml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,19 +3,19 @@
33
<modelVersion>4.0.0</modelVersion>
44
<groupId>org.aarboard.nextcloud</groupId>
55
<artifactId>nextcloud-api</artifactId>
6-
<version>13.0.1</version>
6+
<version>13.1.0</version>
77
<packaging>jar</packaging>
88
<properties>
99
<!-- compile time dependencies -->
1010
<httpcore.version>4.4.16</httpcore.version>
1111
<httpasyncclient.version>4.1.5</httpasyncclient.version>
1212
<httpclient.version>4.5.14</httpclient.version>
13-
<slf4j-api.version>2.0.9</slf4j-api.version>
13+
<slf4j-api.version>2.0.13</slf4j-api.version>
1414
<sardine.version>5.12</sardine.version>
15-
<commons-io.version>2.13.0</commons-io.version>
16-
<commons-lang3.version>3.13.0</commons-lang3.version>
17-
<commons-codec.version>1.16.0</commons-codec.version>
18-
<jackson.version>2.15.2</jackson.version>
15+
<commons-io.version>2.16.1</commons-io.version>
16+
<commons-lang3.version>3.18.0</commons-lang3.version>
17+
<commons-codec.version>1.17.0</commons-codec.version>
18+
<jackson.version>2.17.1</jackson.version>
1919
<jakarta.xml.bind-api.version>4.0.1</jakarta.xml.bind-api.version>
2020
<jakarta-annotation-api.version>2.1.1</jakarta-annotation-api.version>
2121
<jaxb-impl.version>3.0.0</jaxb-impl.version>
@@ -42,8 +42,8 @@
4242
<maven-surefire-plugin.version>3.1.2</maven-surefire-plugin.version>
4343
<cyclonedx-maven-plugin.version>2.7.9</cyclonedx-maven-plugin.version>
4444

45-
<maven.compiler.source>1.8</maven.compiler.source>
46-
<maven.compiler.target>1.8</maven.compiler.target>
45+
<maven.compiler.source>11</maven.compiler.source>
46+
<maven.compiler.target>11</maven.compiler.target>
4747
<netbeans.hint.license>gpl30</netbeans.hint.license>
4848
</properties>
4949
<name>NextCloud Java API library</name>
@@ -274,7 +274,7 @@
274274
</executions>
275275
<configuration>
276276
<doCheck>false</doCheck>
277-
<doUpdate>true</doUpdate>
277+
<doUpdate>false</doUpdate>
278278
</configuration>
279279
</plugin>
280280
<plugin>

src/main/java/org/aarboard/nextcloud/api/NextcloudConnector.java

Lines changed: 45 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@
3939
import org.aarboard.nextcloud.api.webdav.pathresolver.WebDavPathResolver;
4040
import org.aarboard.nextcloud.api.webdav.pathresolver.WebDavPathResolverBuilder;
4141

42-
public class NextcloudConnector {
42+
public class NextcloudConnector implements AutoCloseable {
4343

44-
private final ServerConfig _serverConfig;
44+
private final ServerConfig serverConfig;
4545
private final ProvisionConnector pc;
4646
private final FilesharingConnector fc;
4747
private final ConfigConnector cc;
@@ -73,7 +73,7 @@ public NextcloudConnector(String serverName, boolean useHTTPS, int port, String
7373

7474
/**
7575
* @param serviceUrl url of the nextcloud instance, e.g.
76-
* https://nextcloud.instance.com:8443/cloud
76+
* <a href="https://nextcloud.instance.com:8443/cloud">...</a>
7777
* @param loginName User for login
7878
* @param password Password for login
7979
*/
@@ -83,32 +83,32 @@ public NextcloudConnector(String serviceUrl, String loginName, String password)
8383

8484
/**
8585
* @param serviceUrl url of the nextcloud instance, e.g.
86-
* https://nextcloud.instance.com:8443/cloud
86+
* <a href="https://nextcloud.instance.com:8443/cloud">...</a>
8787
* @param bearerToken Bearer token for login
8888
*/
8989
public NextcloudConnector(String serviceUrl, String bearerToken) {
9090
this(serviceUrl, new AuthenticationConfig(bearerToken));
9191
}
9292

9393
/**
94-
* @param serviceUrl url of the nextcloud instance, e.g.
95-
* https://nextcloud.instance.com:8443/cloud
94+
* @param originalServiceUrl url of the nextcloud instance, e.g.
95+
* <a href="https://nextcloud.instance.com:8443/cloud">...</a>
9696
* @param authenticationConfig Authentication config
9797
*/
98-
public NextcloudConnector(String serviceUrl, AuthenticationConfig authenticationConfig) {
98+
public NextcloudConnector(String originalServiceUrl, AuthenticationConfig authenticationConfig) {
9999
try {
100-
URL _serviceUrl = new URL(serviceUrl);
101-
boolean useHTTPS = serviceUrl.startsWith("https");
102-
_serverConfig = new ServerConfig(_serviceUrl.getHost(), useHTTPS, _serviceUrl.getPort(),
100+
URL serviceUrl = new URL(originalServiceUrl);
101+
boolean useHTTPS = originalServiceUrl.startsWith("https");
102+
this.serverConfig = new ServerConfig(serviceUrl.getHost(), useHTTPS, serviceUrl.getPort(),
103103
authenticationConfig);
104-
if (!_serviceUrl.getPath().isEmpty()) {
105-
_serverConfig.setSubPathPrefix(_serviceUrl.getPath());
104+
if (!serviceUrl.getPath().isEmpty()) {
105+
this.serverConfig.setSubPathPrefix(serviceUrl.getPath());
106106
}
107-
pc = new ProvisionConnector(_serverConfig);
108-
fc = new FilesharingConnector(_serverConfig);
109-
cc = new ConfigConnector(_serverConfig);
110-
fd = new Folders(_serverConfig);
111-
fl = new Files(_serverConfig);
107+
pc = new ProvisionConnector(this.serverConfig);
108+
fc = new FilesharingConnector(this.serverConfig);
109+
cc = new ConfigConnector(this.serverConfig);
110+
fd = new Folders(this.serverConfig);
111+
fl = new Files(this.serverConfig);
112112

113113
} catch (MalformedURLException e) {
114114
throw new IllegalArgumentException(e);
@@ -124,12 +124,12 @@ public NextcloudConnector(String serviceUrl, AuthenticationConfig authentication
124124
*/
125125
public NextcloudConnector(String serverName, boolean useHTTPS, int port,
126126
AuthenticationConfig authenticationConfig) {
127-
_serverConfig = new ServerConfig(serverName, useHTTPS, port, authenticationConfig);
128-
pc = new ProvisionConnector(_serverConfig);
129-
fc = new FilesharingConnector(_serverConfig);
130-
cc = new ConfigConnector(_serverConfig);
131-
fd = new Folders(_serverConfig);
132-
fl = new Files(_serverConfig);
127+
this.serverConfig = new ServerConfig(serverName, useHTTPS, port, authenticationConfig);
128+
pc = new ProvisionConnector(this.serverConfig);
129+
fc = new FilesharingConnector(this.serverConfig);
130+
cc = new ConfigConnector(this.serverConfig);
131+
fd = new Folders(this.serverConfig);
132+
fl = new Files(this.serverConfig);
133133
}
134134

135135
/**
@@ -171,8 +171,8 @@ public void setWebDavPathResolverAsType(final WebDavPathResolverBuilder.TYPE typ
171171
WebDavPathResolver resolver = WebDavPathResolverBuilder.get(type)
172172
.ofVersion(NextcloudVersion.get(getServerVersion()))
173173
.withUserName(getCurrentUser().getId())
174-
// .withUserName(_serverConfig.getUserName())
175-
.withBasePathPrefix(_serverConfig.getSubPathPrefix()).build();
174+
// .withUserName(this.serverConfig.getUserName())
175+
.withBasePathPrefix(this.serverConfig.getSubPathPrefix()).build();
176176

177177
this.fd.setWebDavPathResolver(resolver);
178178
this.fl.setWebDavPathResolver(resolver);
@@ -188,14 +188,24 @@ public void shutdown() throws IOException {
188188
ConnectorCommon.shutdown();
189189
}
190190

191+
/**
192+
* Close the HTTP client. Perform this to cleanly shut down this
193+
* application.
194+
*
195+
* @throws Exception In case of errors
196+
*/
197+
public void close() throws Exception {
198+
shutdown();
199+
}
200+
191201
/**
192202
* Trust all HTTPS certificates presented by the server. This is e.g. used
193203
* to work against a Nextcloud instance with a self-signed certificate.
194204
*
195-
* @param trustAllCertificates Do we accep self signed certificates or not
205+
* @param trustAllCertificates Do we accept self-signed certificates or not
196206
*/
197207
public void trustAllCertificates(boolean trustAllCertificates) {
198-
_serverConfig.setTrustAllCertificates(trustAllCertificates);
208+
this.serverConfig.setTrustAllCertificates(trustAllCertificates);
199209
}
200210

201211
/**
@@ -206,7 +216,7 @@ public void trustAllCertificates(boolean trustAllCertificates) {
206216
* installed in root
207217
*/
208218
public void setSubpathPrefix(String subpathPrefix) {
209-
_serverConfig.setSubPathPrefix(subpathPrefix);
219+
this.serverConfig.setSubPathPrefix(subpathPrefix);
210220
}
211221

212222
/**
@@ -662,7 +672,7 @@ public CompletableFuture<UserDetailsAnswer> getUserAsync(String userId) {
662672
}
663673

664674
/**
665-
* Gets user details of currently logged in user
675+
* Gets user details of currently logged-in user
666676
*
667677
* @return all user details
668678
*/
@@ -968,7 +978,7 @@ public void uploadFile(File srcFile, String remotePath) {
968978
* @deprecated Since some nextcloud installations use fpm or fastcgi to
969979
* connect to php, here the uploads might get zero empty on the server Use a
970980
* (temp) file to upload the data, so the content length is known in advance
971-
* https://github.com/a-schild/nextcloud-java-api/issues/20
981+
* <a href="https://github.com/a-schild/nextcloud-java-api/issues/20">...</a>
972982
*/
973983
public void uploadFile(InputStream inputStream, String remotePath) {
974984
fl.uploadFile(inputStream, remotePath);
@@ -987,7 +997,7 @@ public void uploadFile(InputStream inputStream, String remotePath) {
987997
* @deprecated Since some nextcloud installations use fpm or fastcgi to
988998
* connect to php, here the uploads might get zero empty on the server Use a
989999
* (temp) file to upload the data, so the content length is known in advance
990-
* https://github.com/a-schild/nextcloud-java-api/issues/20
1000+
* <a href="https://github.com/a-schild/nextcloud-java-api/issues/20">...</a>
9911001
*/
9921002
public void uploadFile(InputStream inputStream, String remotePath, boolean continueHeader) {
9931003
fl.uploadFile(inputStream, remotePath, continueHeader);
@@ -1136,7 +1146,7 @@ public CompletableFuture<XMLAnswer> editShareAsync(int shareId, Map<ShareData, S
11361146
* nextcloud server
11371147
* @param downloadpath Local path where the file has to be downloaded in the
11381148
* local machine
1139-
* @return boolean true if sucessfull
1149+
* @return boolean true if successful
11401150
* @throws java.io.IOException In case of IO errors
11411151
*/
11421152
public boolean downloadFile(String remotepath, String downloadpath) throws IOException {
@@ -1219,7 +1229,7 @@ public String getAppConfigAppKeyValue(String appConfigAppKeyPath) {
12191229
* @param appConfigAppKey a key name as returned by
12201230
* {@link #getAppConfigAppKeys(String)}
12211231
* @param value the value to set
1222-
* @return true if sucessfully set
1232+
* @return true if successfully set
12231233
*/
12241234
public boolean setAppConfigAppKeyValue(String appConfigApp, String appConfigAppKey, Object value) {
12251235
return cc.setAppConfigAppKeyValue(appConfigApp, appConfigAppKey, value);
@@ -1230,7 +1240,7 @@ public boolean setAppConfigAppKeyValue(String appConfigApp, String appConfigAppK
12301240
* @param appConfigAppKeyPath the full appConfigAppKeyPath combining
12311241
* appConfigApp and appConfigAppKey with "/"
12321242
* @param value the value to set
1233-
* @return Operation sucessfull
1243+
* @return Operation successful
12341244
*/
12351245
public boolean setAppConfigAppKeyValue(String appConfigAppKeyPath, Object value) {
12361246
return cc.setAppConfigAppKeyValue(appConfigAppKeyPath, value);
@@ -1243,7 +1253,7 @@ public boolean setAppConfigAppKeyValue(String appConfigAppKeyPath, Object value)
12431253
* {@link #getAppConfigApps()}
12441254
* @param appConfigAppkey a key name as returned by
12451255
* {@link #getAppConfigAppKeys(String)}
1246-
* @return Operation sucessfull
1256+
* @return Operation successful
12471257
*/
12481258
public boolean deleteAppConfigAppKeyEntry(String appConfigApp, String appConfigAppkey) {
12491259
return cc.deleteAppConfigAppKeyEntry(appConfigApp, appConfigAppkey);

0 commit comments

Comments
 (0)