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: Stuff for PDV added and Quarkus updated. #24

Merged
merged 3 commits into from
May 16, 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
679 changes: 378 additions & 301 deletions dep-sha256.json

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<!-- Quarkus version -->
<quarkus.platform.artifact-id>quarkus-bom</quarkus.platform.artifact-id>
<quarkus.platform.group-id>io.quarkus.platform</quarkus.platform.group-id>
<quarkus.platform.version>3.9.5</quarkus.platform.version>
<quarkus.platform.version>3.10.1</quarkus.platform.version>
<!-- Plugins version -->
<compiler-plugin.version>3.12.1</compiler-plugin.version>
<surefire-plugin.version>3.2.5</surefire-plugin.version>
Expand Down Expand Up @@ -87,6 +87,11 @@
<artifactId>quarkus-opentelemetry</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-rest-client-jackson</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
import lombok.Getter;

/**
* Normalize the body of Constraint Violation Exception (BAD REQUEST) handled directly by Quarkus.
* <p>Normalize the body of Constraint Violation Exception (BAD REQUEST) handled directly by Quarkus.</p>
*
* @author Antonio Tarricone
*/
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/it/pagopa/swclient/mil/ErrorCode.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
* @author Antonio Tarricone
*/
public final class ErrorCode {
/*
*
*/
public static final String MODULE_ID = "000";

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import lombok.experimental.Accessors;

/**
* Common header attributes
* <p>Common header attributes</p>
*
* @author Antonio Tarricone
*/
Expand Down
4 changes: 3 additions & 1 deletion src/main/java/it/pagopa/swclient/mil/bean/Errors.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import lombok.experimental.Accessors;

/**
* List of violations.
* <p>List of violations.</p>
*
* @author Antonio Tarricone
*/
Expand All @@ -43,13 +43,15 @@ public class Errors {
private List<String> descriptions;

/**
*
* @param errors
*/
public Errors(List<String> errors) {
this.errors = errors;
}

/**
*
* @param error
* @param description
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@
import jakarta.interceptor.InvocationContext;

/**
* <p>
* This class implements the logic to trace with OpenTelemetry standard the invocations to classes
* which implements io.quarkus.mongodb.panache.reactive.ReactivePanacheMongoRepositoryBase
* which implements {@code io.quarkus.mongodb.panache.reactive.ReactivePanacheMongoRepositoryBase}
* interface.
* </p>
*
* @author Antonio Tarricone
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,14 @@
import jakarta.interceptor.InterceptorBinding;

/**
* Annotation to mark the classes which implements
* io.quarkus.mongodb.panache.reactive.ReactivePanacheMongoRepositoryBase that must be traced.
* io.quarkus:quarkus-opentelemetry must be added among the dependecies.
* <p>
* Annotation to mark the classes which implement
* {@code io.quarkus.mongodb.panache.reactive.ReactivePanacheMongoRepositoryBase } that must be
* traced.
* </p>
* <p>
* {@code io.quarkus:quarkus-opentelemetry} must be added among the dependencies.
* </p>
*
* @author Antonio Tarricone
*/
Expand Down
30 changes: 30 additions & 0 deletions src/main/java/it/pagopa/swclient/mil/pdv/bean/PersonalData.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* PersonalData.java
*
* 16 mag 2024
*/
package it.pagopa.swclient.mil.pdv.bean;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.Accessors;

/**
*
* @author Antonio Tarricone
*/
@NoArgsConstructor
@AllArgsConstructor
@Getter
@Setter
@Accessors(chain = true)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class PersonalData {
@JsonProperty("pii")
private String value;
}
32 changes: 32 additions & 0 deletions src/main/java/it/pagopa/swclient/mil/pdv/bean/Token.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* Token.java
*
* 16 mag 2024
*/
package it.pagopa.swclient.mil.pdv.bean;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.JsonProperty;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Accessors;

/**
*
* @author Antonio Tarricone
*/
@NoArgsConstructor
@AllArgsConstructor
@Getter
@Setter
@ToString
@Accessors(chain = true)
@JsonInclude(JsonInclude.Include.NON_NULL)
public class Token {
@JsonProperty("token")
private String value;
}
58 changes: 58 additions & 0 deletions src/main/java/it/pagopa/swclient/mil/pdv/client/Tokenizer.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
/*
* Tokenizer.java
*
* 16 mag 2024
*/
package it.pagopa.swclient.mil.pdv.client;

import org.eclipse.microprofile.rest.client.annotation.ClientHeaderParam;
import org.eclipse.microprofile.rest.client.inject.RegisterRestClient;

import io.smallrye.mutiny.Uni;
import it.pagopa.swclient.mil.pdv.bean.PersonalData;
import it.pagopa.swclient.mil.pdv.bean.Token;
import jakarta.ws.rs.Consumes;
import jakarta.ws.rs.GET;
import jakarta.ws.rs.PUT;
import jakarta.ws.rs.Path;
import jakarta.ws.rs.PathParam;
import jakarta.ws.rs.Produces;
import jakarta.ws.rs.core.MediaType;

/**
* <p>
* To use this:
* <ul>
* <li>Add {@code io.quarkus:quarkus-rest-client-jackson} to the dependencies.</li>
* <li>Add {@code quarkus.rest-client.pdv-api.url} to {@code application.properties} with the URL to
* reach PDV, e.g.: {@code https://api.uat.tokenizer.pdv.pagopa.it/tokenizer/v1/tokens}</li>
* <li>Add {@code pdv-api.api-key} to {@code application.properties} with the API-key of PDV.</li>
* </ul>
* </p>
*
* @author Antonio Tarricone
*/
@RegisterRestClient(configKey = "pdv-api")
public interface Tokenizer {
/**
*
* @param personalData
* @return
*/
@PUT
@Produces(MediaType.APPLICATION_JSON)
@Consumes(MediaType.APPLICATION_JSON)
@ClientHeaderParam(name = "x-api-key", value = "${pdv-api.api-key}", required = true)
Uni<Token> tokenize(PersonalData personalData);

/**
*
* @param tokenValue
* @return
*/
@GET
@Path("/{token}")
@Produces(MediaType.APPLICATION_JSON)
@ClientHeaderParam(name = "x-api-key", value = "${pdv-api.api-key}", required = true)
Uni<PersonalData> detokenize(@PathParam("token") String tokenValue);
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@
import jakarta.validation.Payload;

/**
* If Channel equals to POS, the MerchantId must not be null.
* <p>
* If {@code Channel} equals to {@code POS}, the {@code MerchantId} must not be null.
* </p>
*
* @author Antonio Tarricone
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
import jakarta.validation.ConstraintValidatorContext;

/**
* If Channel equals to POS, the MerchantId must not be null.
* <p>
* If {@code Channel} equals to {@code POS}, the {@code MerchantId} must not be null.
* </p>
*
* @author Antonio Tarricone
*/
Expand Down
Loading