Skip to content
This repository has been archived by the owner on Jan 22, 2025. It is now read-only.

Commit

Permalink
upgrade to java 21 and replace deprecated methods
Browse files Browse the repository at this point in the history
  • Loading branch information
Parisa68 committed Feb 15, 2024
1 parent 429eaae commit d35ef93
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 6 deletions.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>3.1.3</version>
<version>3.2.2</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>no.elixir.fega</groupId>
Expand All @@ -15,7 +15,7 @@
<description>LocalEGA TSD Proxy</description>

<properties>
<java.version>17</java.version>
<java.version>21</java.version>
</properties>

<dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public TSDFileAPIClient tsdFileAPIClient(@Value("${tsd.host}") String tsdHost,
.host(tsdHost)
.project(tsdProject)
.accessKey(tsdAccessKey);
if (!StringUtils.isEmpty(tsdRootCA) && !StringUtils.isEmpty(tsdRootCAPassword)) {
if (StringUtils.hasLength(tsdRootCA) && StringUtils.hasLength(tsdRootCAPassword)) {
X509TrustManager trustManager = trustManagerForCertificates(Files.newInputStream(Path.of(tsdRootCA)), tsdRootCAPassword);
SSLContext sslContext = SSLContext.getInstance("TLS");
sslContext.init(null, new TrustManager[]{trustManager}, null);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import org.springframework.web.client.RestTemplate;

import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.Base64;
Expand Down Expand Up @@ -45,7 +46,7 @@ public class CEGACredentialsProvider {
*/
@Cacheable("cega-credentials")
public Credentials getCredentials(String username) throws MalformedURLException, URISyntaxException {
URL url = new URL(String.format(cegaAuthURL + "%s?idType=username", username));
URL url = new URI(String.format(cegaAuthURL + "%s?idType=username", username)).toURL();
org.springframework.http.HttpHeaders headers = new org.springframework.http.HttpHeaders();
headers.set(HttpHeaders.AUTHORIZATION, "Basic " + Base64.getEncoder().encodeToString((cegaUsername + ":" + cegaPassword).getBytes()));
ResponseEntity<Credentials> response = restTemplate.exchange(url.toURI(), HttpMethod.GET,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public ResponseEntity<?> stream(InputStream inputStream,
byte[] chunkBytes = inputStream.readAllBytes();

// new upload
if (StringUtils.isEmpty(uploadId)) {
if (!StringUtils.hasLength(uploadId)) {
Chunk response = tsdFileAPIClient.initializeResumableUpload(token.getToken(), tsdAppId, chunkBytes, fileName);
return validateChunkChecksum(token, response, md5);
}
Expand Down Expand Up @@ -133,7 +133,7 @@ public ResponseEntity<?> deleteFile(@RequestHeader(HttpHeaders.PROXY_AUTHORIZATI
public ResponseEntity<?> getResumables(@RequestHeader(HttpHeaders.PROXY_AUTHORIZATION) String bearerAuthorization,
@RequestParam(value = "uploadId", required = false) String uploadId) {
Token token = tsdFileAPIClient.getToken(TOKEN_TYPE, TOKEN_TYPE, getElixirAAIToken(bearerAuthorization));
if (StringUtils.isEmpty(uploadId)) {
if (!StringUtils.hasLength(uploadId)) {
return ResponseEntity.ok(tsdFileAPIClient.listResumableUploads(token.getToken(), tsdAppId));
} else {
return ResponseEntity.ok(tsdFileAPIClient.getResumableUpload(token.getToken(), tsdAppId, uploadId));
Expand Down

0 comments on commit d35ef93

Please sign in to comment.