Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: split emd-message-core #49

Merged
merged 20 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion .spectral.yaml
Original file line number Diff line number Diff line change
@@ -1 +1,14 @@
extends: ["spectral:oas", "spectral:asyncapi", "https://unpkg.com/@stoplight/spectral-owasp-ruleset/dist/ruleset.mjs"]
extends:
- "spectral:oas"
- "spectral:asyncapi"
- "https://unpkg.com/@stoplight/spectral-owasp-ruleset/dist/ruleset.mjs"
overrides:
- files:
- "src/main/resources/META-INF/openapi.yaml#/paths/~1token/post/security"
rules:
owasp:api2:2023-write-restricted: "off"
- files:
- "src/main/resources/META-INF/openapi.yaml#/paths/~1.well-known~1jwks.json/get/security"
- "src/main/resources/META-INF/openapi.yaml#/paths/~1.well-known~1openid-configuration/get/security"
rules:
owasp:api2:2023-read-restricted: "off"

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package it.gov.pagopa.message.connector;

import reactor.core.publisher.Mono;
public interface CitizenConnector {
Mono<String> checkFiscalCode(String fiscalCode);


}
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package it.gov.pagopa.message.connector;


import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.web.reactive.function.client.WebClient;
import reactor.core.publisher.Mono;

@Service
public class CitizenConnectorImpl implements CitizenConnector {

private final WebClient webClient;
public CitizenConnectorImpl( @Value("${rest-client.citizen.baseUrl}") String baseUrl) {
this.webClient = WebClient.builder().baseUrl(baseUrl).build();

}

@Override
public Mono<String> checkFiscalCode(String fiscalCode) {
return webClient.get()
.uri("/emd/citizen/filter/{fiscalCode}",fiscalCode)
.retrieve()
.bodyToMono(String.class);
}
}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,20 +1,10 @@
package it.gov.pagopa.message.constants;

public class MessageCoreConstants {
public static final class ExceptionCode {
public static final String GENERI_ERROR = "GENERIC_ERROR";
private ExceptionCode() {}
}

public static final class ExceptionMessage {
public static final String GENERI_ERROR = "GENERIC_ERROR";
private ExceptionMessage() {}
}
public static final class MessageHeader {
public static final String ERROR_MSG_AUTH_URL = "authenticationUrl";
public static final String ERROR_MSG_MESSAGE_URL = "messageUrl";
public static final String ERROR_MSG_HEADER_RETRY = "retry";
public static final String ERROR_MSG_ENTITY_ID = "entityId";

private MessageHeader() {}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@


import it.gov.pagopa.message.dto.MessageDTO;
import it.gov.pagopa.message.model.Outcome;
import jakarta.validation.Valid;

import org.springframework.http.ResponseEntity;
Expand All @@ -22,6 +21,6 @@ public interface MessageCoreController {
* @return outcome of sending the message
*/
@PostMapping("/sendMessage")
Mono<ResponseEntity<Outcome>> sendMessage(@Valid @RequestBody MessageDTO messageDTO);
Mono<ResponseEntity<String>> send(@Valid @RequestBody MessageDTO messageDTO);

}
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package it.gov.pagopa.message.controller;

import it.gov.pagopa.message.enums.OutcomeStatus;
import it.gov.pagopa.message.dto.MessageDTO;
import it.gov.pagopa.message.model.Outcome;
import it.gov.pagopa.message.service.MessageCoreServiceImpl;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
Expand All @@ -17,14 +15,10 @@ public MessageCoreControllerImpl(MessageCoreServiceImpl messageCoreService) {
this.messageCoreService = messageCoreService;
}

public Mono<ResponseEntity<Outcome>> sendMessage(MessageDTO messageDTO) {
return messageCoreService.sendMessage(messageDTO)
.map(outcome -> {
if (outcome.getOutcomeStatus().equals(OutcomeStatus.OK)) {
return ResponseEntity.ok(outcome);
} else {
return ResponseEntity.status(HttpStatus.ACCEPTED).body(outcome);
}
});
public Mono<ResponseEntity<String>> send(MessageDTO messageDTO) {
return messageCoreService.send(messageDTO)
.map(outcome -> Boolean.TRUE.equals(outcome) ?
ResponseEntity.ok("OK") :
ResponseEntity.status(HttpStatus.ACCEPTED).body("NO CHANNELS ENABLED"));
}
}

This file was deleted.

This file was deleted.

22 changes: 0 additions & 22 deletions src/main/java/it/gov/pagopa/message/dto/CitizenConsentDTO.java

This file was deleted.

15 changes: 0 additions & 15 deletions src/main/java/it/gov/pagopa/message/dto/Contact.java

This file was deleted.

11 changes: 10 additions & 1 deletion src/main/java/it/gov/pagopa/message/dto/MessageDTO.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package it.gov.pagopa.message.dto;


import com.fasterxml.jackson.annotation.JsonAlias;
import it.gov.pagopa.common.utils.CommonUtilities;
import jakarta.annotation.PostConstruct;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
Expand All @@ -18,8 +19,15 @@ public class MessageDTO {
private String senderDescription;
private String messageUrl;
private String originId;
@JsonAlias("message")
private String content;
private String entityId;
private Boolean associatedPayment;

@PostConstruct
private void postConstruct() {
this.associatedPayment = true;
}

@Override
public String toString() {
Expand All @@ -31,6 +39,7 @@ public String toString() {
", senderDescription='" + senderDescription + '\'' +
", messageUrl='" + messageUrl + '\'' +
", originId='" + originId + '\'' +
", associatedPayment='" + associatedPayment + '\'' +
'}';
}
}

This file was deleted.

18 changes: 0 additions & 18 deletions src/main/java/it/gov/pagopa/message/dto/TokenDTO.java

This file was deleted.

Loading
Loading