-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Implementation of Publication Archive * Finetuning for Publication Unit Test for Publication Archive * Fix Typo * Add ability to switch off publication * Update URLs in Readme and License File * Add ability to switch off synchronize call
- Loading branch information
Showing
19 changed files
with
1,143 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
lombok.copyableAnnotations += org.springframework.beans.factory.annotation.Qualifier |
71 changes: 71 additions & 0 deletions
71
src/main/java/eu/europa/ec/dgc/gateway/client/AssetManagerClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/*- | ||
* ---license-start | ||
* EU Digital Green Certificate Gateway Service / dgc-gateway | ||
* --- | ||
* Copyright (C) 2021 - 2022 T-Systems International GmbH and all other contributors | ||
* --- | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* ---license-end | ||
*/ | ||
|
||
package eu.europa.ec.dgc.gateway.client; | ||
|
||
import eu.europa.ec.dgc.gateway.model.AssetManagerSynchronizeResponseDto; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; | ||
import org.springframework.cloud.openfeign.FeignClient; | ||
import org.springframework.http.HttpHeaders; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.PostMapping; | ||
import org.springframework.web.bind.annotation.PutMapping; | ||
import org.springframework.web.bind.annotation.RequestBody; | ||
import org.springframework.web.bind.annotation.RequestHeader; | ||
|
||
@FeignClient( | ||
name = "assetManagerClient", | ||
url = "${dgc.publication.url}", | ||
configuration = AssetManagerClientConfig.class) | ||
@ConditionalOnProperty("dgc.publication.enabled") | ||
public interface AssetManagerClient { | ||
|
||
@PutMapping( | ||
value = "/remote.php/dav/files/{uid}/{path}/{filename}", | ||
consumes = MediaType.APPLICATION_OCTET_STREAM_VALUE, | ||
produces = MediaType.ALL_VALUE) | ||
ResponseEntity<Void> uploadFile(@RequestHeader(HttpHeaders.AUTHORIZATION) String authHeader, | ||
@PathVariable("uid") String uid, | ||
@PathVariable("path") String path, | ||
@PathVariable("filename") String filename, | ||
@RequestBody byte[] file); | ||
|
||
@PostMapping( | ||
value = "/ocs/v2.php/apps/files/api/v2/synchronize", | ||
consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE, | ||
produces = MediaType.APPLICATION_JSON_VALUE | ||
) | ||
ResponseEntity<AssetManagerSynchronizeResponseDto> synchronize( | ||
@RequestHeader(HttpHeaders.AUTHORIZATION) String authHeader, | ||
@RequestHeader("OCS-APIRequest") String ocsApiRequest, | ||
@RequestBody SynchronizeFormData formData); | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
class SynchronizeFormData { | ||
private String path; | ||
private String nodeList; | ||
private String notifyEmails; | ||
} | ||
} |
73 changes: 73 additions & 0 deletions
73
src/main/java/eu/europa/ec/dgc/gateway/client/AssetManagerClientConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
/*- | ||
* ---license-start | ||
* EU Digital Green Certificate Gateway Service / dgc-gateway | ||
* --- | ||
* Copyright (C) 2021 - 2022 T-Systems International GmbH and all other contributors | ||
* --- | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* ---license-end | ||
*/ | ||
|
||
package eu.europa.ec.dgc.gateway.client; | ||
|
||
import eu.europa.ec.dgc.gateway.config.DgcConfigProperties; | ||
import feign.Client; | ||
import feign.codec.Encoder; | ||
import feign.form.spring.SpringFormEncoder; | ||
import feign.httpclient.ApacheHttpClient; | ||
import java.security.NoSuchAlgorithmException; | ||
import javax.net.ssl.SSLContext; | ||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.apache.http.conn.ssl.DefaultHostnameVerifier; | ||
import org.apache.http.impl.client.HttpClientBuilder; | ||
import org.springframework.beans.factory.ObjectFactory; | ||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; | ||
import org.springframework.boot.autoconfigure.http.HttpMessageConverters; | ||
import org.springframework.cloud.openfeign.support.SpringEncoder; | ||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@Configuration | ||
@RequiredArgsConstructor | ||
@Slf4j | ||
@ConditionalOnProperty("dgc.publication.enabled") | ||
public class AssetManagerClientConfig { | ||
|
||
private final ObjectFactory<HttpMessageConverters> messageConverters; | ||
|
||
private final DgcConfigProperties config; | ||
|
||
/** | ||
* Form Encoder for Multipart File Upload. | ||
*/ | ||
@Bean | ||
public Encoder feignFormEncoder() { | ||
return new SpringFormEncoder(new SpringEncoder(messageConverters)); | ||
} | ||
|
||
/** | ||
* Configure the client depending on the ssl properties. | ||
* | ||
* @return an Apache Http Client with or without SSL features | ||
*/ | ||
@Bean | ||
public Client assetManagerClient() throws NoSuchAlgorithmException { | ||
HttpClientBuilder httpClientBuilder = HttpClientBuilder.create(); | ||
|
||
httpClientBuilder.setSSLContext(SSLContext.getDefault()); | ||
httpClientBuilder.setSSLHostnameVerifier(new DefaultHostnameVerifier()); | ||
|
||
return new ApacheHttpClient(httpClientBuilder.build()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
src/main/java/eu/europa/ec/dgc/gateway/model/AssetManagerSynchronizeResponseDto.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/*- | ||
* ---license-start | ||
* EU Digital Green Certificate Gateway Service / dgc-gateway | ||
* --- | ||
* Copyright (C) 2021 - 2022 T-Systems International GmbH and all other contributors | ||
* --- | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
* ---license-end | ||
*/ | ||
|
||
package eu.europa.ec.dgc.gateway.model; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
import lombok.NoArgsConstructor; | ||
import lombok.Setter; | ||
|
||
@Getter | ||
@Setter | ||
@NoArgsConstructor | ||
public class AssetManagerSynchronizeResponseDto { | ||
|
||
/** | ||
* Initialize Dto with values for embedded sub-classed. | ||
*/ | ||
public AssetManagerSynchronizeResponseDto( | ||
String status, int statusCode, String message, String path, String token) { | ||
Ocs.Data data = new Ocs.Data(statusCode, message, token, path); | ||
Ocs.Meta meta = new Ocs.Meta(status, statusCode, message); | ||
|
||
ocs = new Ocs(meta, data); | ||
} | ||
|
||
private Ocs ocs; | ||
|
||
@Getter | ||
@Setter | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public static class Ocs { | ||
|
||
private Meta meta; | ||
private Data data; | ||
|
||
@Getter | ||
@Setter | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public static class Meta { | ||
private String status; | ||
private Integer statuscode; | ||
private String message; | ||
} | ||
|
||
@Getter | ||
@Setter | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public static class Data { | ||
private Integer statusCode; | ||
private String statusMessage; | ||
private String token; | ||
private String path; | ||
} | ||
} | ||
} |
Oops, something went wrong.