Skip to content

Commit

Permalink
Second draft.
Browse files Browse the repository at this point in the history
  • Loading branch information
antoniotarricone committed Nov 28, 2022
1 parent a7d8c07 commit 1772905
Show file tree
Hide file tree
Showing 6 changed files with 103 additions and 2 deletions.
41 changes: 41 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#Maven
target/
pom.xml.tag
pom.xml.releaseBackup
pom.xml.versionsBackup
release.properties
.flattened-pom.xml

# Eclipse
.project
.classpath
.settings/
bin/

# IntelliJ
.idea
*.ipr
*.iml
*.iws

# NetBeans
nb-configuration.xml

# Visual Studio Code
.vscode
.factorypath

# OSX
.DS_Store

# Vim
*.swp
*.swo

# patch
*.orig
*.rej

# Local environment
.env
/.mvn/
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Multi-channel Integration Layer Common
Common classes used by services that make up the Multi-channel Intagration Layer of SW Client project.
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</parent>

<artifactId>common</artifactId>
<version>0.0.6-SNAPSHOT</version>
<version>0.0.14-SNAPSHOT</version>
<packaging>jar</packaging>

<description>Common classes for Multi-channel Integration Layer of SW Client Project</description>
Expand Down Expand Up @@ -48,7 +48,7 @@
<goals>
<goal>build</goal>
<goal>generate-code</goal>
<goal>generate-code-tests</goal>
<!-- <goal>generate-code-tests</goal> -->
</goals>
</execution>
</executions>
Expand Down
25 changes: 25 additions & 0 deletions src/main/java/it/gov/pagopa/swclient/mil/dto/CommonHeader.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@
* @author Antonio Tarricone
*/
public class CommonHeader {
/*
* Request ID
*/
@HeaderParam("RequestId")
@NotNull(message = "RequestId must not be null")
@Pattern(regexp = "^[a-fA-F0-9]{8}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{4}-[a-fA-F0-9]{12}$" , message = "RequestId must match {regexp}")
private String requestId;

/*
* Version of the required API
*/
Expand Down Expand Up @@ -50,6 +58,22 @@ public class CommonHeader {
@Pattern(regexp = "^[0-9a-zA-Z]{8}$", message = "TerminalId must match {regexp}")
private String terminalId;

/**
*
* @return
*/
public String getRequestId() {
return requestId;
}

/**
*
* @param requestId
*/
public void setRequestId(String requestId) {
this.requestId = requestId;
}

/**
*
* @return
Expand Down Expand Up @@ -120,6 +144,7 @@ public void setTerminalId(String terminalId) {
@Override
public String toString() {
return new StringJoiner(", ", CommonHeader.class.getSimpleName() + "[", "]")
.add("requestId='" + requestId + "'")
.add("version='" + version + "'")
.add("acquirerId='" + acquirerId + "'")
.add("channel=" + channel)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* MappedDiagnosticContextFilter.java
*
* 28 nov 2022
*/
package it.gov.pagopa.swclient.mil.util;

import java.io.IOException;

import javax.ws.rs.container.ContainerRequestContext;
import javax.ws.rs.container.ContainerRequestFilter;
import javax.ws.rs.container.PreMatching;
import javax.ws.rs.ext.Provider;

import org.jboss.logging.MDC;

/**
*
* @author Antonio Tarricone
*/
@Provider
@PreMatching
public class MappedDiagnosticContextFilter implements ContainerRequestFilter {
@Override
public void filter(ContainerRequestContext requestContext) throws IOException {
String requestId = requestContext.getHeaderString("RequestId");
if (requestId == null) {
requestId = "null";
}
MDC.put("requestId", requestId);
}
}
1 change: 1 addition & 0 deletions src/main/resources/META-INF/beans.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<beans/>

0 comments on commit 1772905

Please sign in to comment.