-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: andregroseth <lord.andre.groseth@nav.no>
- Loading branch information
1 parent
0750463
commit 8e68f5d
Showing
14 changed files
with
350 additions
and
0 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
16 changes: 16 additions & 0 deletions
16
apps/backend/src/main/java/no/nav/data/integration/p360/P360Properties.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,16 @@ | ||
package no.nav.data.integration.p360; | ||
|
||
import lombok.Data; | ||
import org.springframework.boot.context.properties.ConfigurationProperties; | ||
import org.springframework.context.annotation.Configuration; | ||
|
||
@Data | ||
@Configuration | ||
@ConfigurationProperties(prefix = "client.p360") | ||
public class P360Properties { | ||
private String url; | ||
private String caseUrl; | ||
private String documentUrl; | ||
private String authKey; | ||
private String clientId; | ||
} |
136 changes: 136 additions & 0 deletions
136
apps/backend/src/main/java/no/nav/data/integration/p360/P360Service.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,136 @@ | ||
package no.nav.data.integration.p360; | ||
|
||
import lombok.RequiredArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import no.nav.data.integration.p360.dto.*; | ||
import org.springframework.http.HttpEntity; | ||
import org.springframework.http.HttpHeaders; | ||
import org.springframework.stereotype.Service; | ||
import org.springframework.web.client.RestClientException; | ||
import org.springframework.web.client.RestTemplate; | ||
|
||
import java.util.List; | ||
|
||
import static java.util.Objects.requireNonNull; | ||
|
||
@Slf4j | ||
@Service | ||
@RequiredArgsConstructor | ||
public class P360Service { | ||
|
||
private final RestTemplate restTemplate; | ||
private final P360Properties p360Properties; | ||
|
||
|
||
public List<P360Case> getCasesByTitle(String title) { | ||
List<P360Case> cases = List.of(); | ||
|
||
var headers = new HttpHeaders(); | ||
headers.setBearerAuth("token placeholder for azure token"); | ||
headers.set("authkey", p360Properties.getAuthKey()); | ||
headers.set("clientid", p360Properties.getClientId()); | ||
|
||
try { | ||
var response = restTemplate.postForEntity(p360Properties.getCaseUrl() + "/GetCases", | ||
new HttpEntity<>( P360GetRequest.builder().title("%" + title + "%").build(), headers), | ||
P360CasePageResponse.class); | ||
cases = response.hasBody() ? requireNonNull(response.getBody()).getCases() : List.of(); | ||
} catch (RestClientException e) { | ||
log.error("Unable to connect to P360, error: {}", String.valueOf(e)); | ||
} | ||
return cases; | ||
} | ||
|
||
public List<P360Case> getCasesByCaseNumber(String caseNumber) { | ||
List<P360Case> cases = List.of(); | ||
|
||
var headers = new HttpHeaders(); | ||
headers.setBearerAuth("token placeholder for azure token"); | ||
headers.set("authkey", p360Properties.getAuthKey()); | ||
headers.set("clientid", p360Properties.getClientId()); | ||
|
||
try { | ||
var response = restTemplate.postForEntity(p360Properties.getCaseUrl() + "/GetCases", | ||
new HttpEntity<>( P360GetRequest.builder().CaseNumber(caseNumber).build(), headers), | ||
P360CasePageResponse.class); | ||
cases = response.hasBody() ? requireNonNull(response.getBody()).getCases() : List.of(); | ||
} catch (RestClientException e) { | ||
log.error("Unable to connect to P360, error: {}", String.valueOf(e)); | ||
} | ||
return cases; | ||
} | ||
|
||
public P360Case createCase(P360CaseRequest request) { | ||
|
||
var headers = new HttpHeaders(); | ||
headers.setBearerAuth("token placeholder for azure token"); | ||
headers.set("authkey", p360Properties.getAuthKey()); | ||
headers.set("clientid", p360Properties.getClientId()); | ||
|
||
try { | ||
var response = restTemplate.postForEntity(p360Properties.getCaseUrl() + "/CreateCase", | ||
new HttpEntity<>( request, headers), | ||
P360Case.class); | ||
return response.getBody(); | ||
} catch (RestClientException e) { | ||
log.error("Unable to connect to P360, error: {}", String.valueOf(e)); | ||
return null; | ||
} | ||
} | ||
|
||
public List<P360Document> getDocumentByCaseNumber(String caseNumber) { | ||
List<P360Document> documents = List.of(); | ||
|
||
var headers = new HttpHeaders(); | ||
headers.setBearerAuth("token placeholder for azure token"); | ||
headers.set("authkey", p360Properties.getAuthKey()); | ||
headers.set("clientid", p360Properties.getClientId()); | ||
|
||
try { | ||
var response = restTemplate.postForEntity(p360Properties.getCaseUrl() + "/GetDocuments", | ||
new HttpEntity<>( P360GetRequest.builder().CaseNumber(caseNumber).build(), headers), | ||
P360DocumentPageResponse.class); | ||
documents = response.hasBody() ? requireNonNull(response.getBody()).getDocuments() : List.of(); | ||
} catch (RestClientException e) { | ||
log.error("Unable to connect to P360, error: {}", String.valueOf(e)); | ||
} | ||
return documents; | ||
} | ||
|
||
public P360Document createDocument(P360DocumentCreateRequest request) { | ||
|
||
var headers = new HttpHeaders(); | ||
headers.setBearerAuth("token placeholder for azure token"); | ||
headers.set("authkey", p360Properties.getAuthKey()); | ||
headers.set("clientid", p360Properties.getClientId()); | ||
|
||
try { | ||
var response = restTemplate.postForEntity(p360Properties.getCaseUrl() + "/CreateDocument", | ||
new HttpEntity<>(request, headers), | ||
P360Document.class); | ||
return response.getBody(); | ||
} catch (RestClientException e) { | ||
log.error("Unable to connect to P360, error: {}", String.valueOf(e)); | ||
return null; | ||
} | ||
} | ||
|
||
public P360Document updateDocument(P360DocumentUpdateRequest request) { | ||
|
||
var headers = new HttpHeaders(); | ||
headers.setBearerAuth("token placeholder for azure token"); | ||
headers.set("authkey", p360Properties.getAuthKey()); | ||
headers.set("clientid", p360Properties.getClientId()); | ||
|
||
try { | ||
var response = restTemplate.postForEntity(p360Properties.getCaseUrl() + "/UpdateDocument", | ||
new HttpEntity<>(request, headers), | ||
P360Document.class); | ||
return response.getBody(); | ||
} catch (RestClientException e) { | ||
log.error("Unable to connect to P360, error: {}", String.valueOf(e)); | ||
return null; | ||
} | ||
} | ||
|
||
} |
20 changes: 20 additions & 0 deletions
20
apps/backend/src/main/java/no/nav/data/integration/p360/dto/P360Case.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,20 @@ | ||
package no.nav.data.integration.p360.dto; | ||
|
||
import com.fasterxml.jackson.annotation.JsonPropertyOrder; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Data | ||
@Builder | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class P360Case { | ||
private Integer Recno; | ||
private String CaseNumber; | ||
private Boolean Successful; | ||
private String ErrorMessage; | ||
private String ErrorDetails; | ||
|
||
} |
21 changes: 21 additions & 0 deletions
21
apps/backend/src/main/java/no/nav/data/integration/p360/dto/P360CasePageResponse.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,21 @@ | ||
package no.nav.data.integration.p360.dto; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.util.List; | ||
|
||
@Data | ||
@Builder | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class P360CasePageResponse { | ||
private List<P360Case> Cases; | ||
private Integer TotalPageCount; | ||
private Integer TotalCount; | ||
private Boolean Successful; | ||
private String ErrorMessage; | ||
private String ErrorDetails; | ||
} |
23 changes: 23 additions & 0 deletions
23
apps/backend/src/main/java/no/nav/data/integration/p360/dto/P360CaseRequest.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,23 @@ | ||
package no.nav.data.integration.p360.dto; | ||
|
||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
import lombok.experimental.FieldNameConstants; | ||
|
||
@Data | ||
@Builder | ||
@FieldNameConstants | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class P360CaseRequest { | ||
private String CaseType; | ||
private String DefaultValueSet; | ||
private String Title; | ||
private String Status; | ||
private String AccessCode; | ||
private String AccessGroup; | ||
private String ResponsiblePersonEmail; | ||
} |
18 changes: 18 additions & 0 deletions
18
apps/backend/src/main/java/no/nav/data/integration/p360/dto/P360Document.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,18 @@ | ||
package no.nav.data.integration.p360.dto; | ||
|
||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Data | ||
@Builder | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class P360Document { | ||
|
||
private Integer Recno; | ||
private String DocumentNumber; | ||
|
||
} |
26 changes: 26 additions & 0 deletions
26
apps/backend/src/main/java/no/nav/data/integration/p360/dto/P360DocumentCreateRequest.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,26 @@ | ||
package no.nav.data.integration.p360.dto; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.util.List; | ||
|
||
@Data | ||
@Builder | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class P360DocumentCreateRequest { | ||
|
||
private String CaseNumber; | ||
private String Archive; | ||
private String DefaultValueSet; | ||
private String Title; | ||
private String DocumentDate; | ||
private String Category; | ||
private String Status; | ||
private String AccessGroup; | ||
private String ResponsiblePersonEmail; | ||
private List<P360File> Files; | ||
} |
21 changes: 21 additions & 0 deletions
21
apps/backend/src/main/java/no/nav/data/integration/p360/dto/P360DocumentPageResponse.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,21 @@ | ||
package no.nav.data.integration.p360.dto; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.util.List; | ||
|
||
@Data | ||
@Builder | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class P360DocumentPageResponse { | ||
private List<P360Document> Documents; | ||
private Integer TotalPageCount; | ||
private Integer TotalCount; | ||
private Boolean Successful; | ||
private String ErrorMessage; | ||
private String ErrorDetails; | ||
} |
26 changes: 26 additions & 0 deletions
26
apps/backend/src/main/java/no/nav/data/integration/p360/dto/P360DocumentUpdateRequest.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,26 @@ | ||
package no.nav.data.integration.p360.dto; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.util.List; | ||
|
||
@Data | ||
@Builder | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class P360DocumentUpdateRequest { | ||
|
||
private String DocumentNumber; | ||
private String Archive; | ||
private String DefaultValueSet; | ||
private String Title; | ||
private String DocumentDate; | ||
private String Category; | ||
private String Status; | ||
private String AccessGroup; | ||
private String ResponsiblePersonEmail; | ||
private List<P360File> Files; | ||
} |
16 changes: 16 additions & 0 deletions
16
apps/backend/src/main/java/no/nav/data/integration/p360/dto/P360File.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,16 @@ | ||
package no.nav.data.integration.p360.dto; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
@Data | ||
@Builder | ||
@AllArgsConstructor | ||
@NoArgsConstructor | ||
public class P360File { | ||
private String Format; | ||
private String Title; | ||
private String Base64Data; | ||
} |
17 changes: 17 additions & 0 deletions
17
apps/backend/src/main/java/no/nav/data/integration/p360/dto/P360GetRequest.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,17 @@ | ||
package no.nav.data.integration.p360.dto; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
import lombok.experimental.FieldNameConstants; | ||
|
||
@Data | ||
@Builder | ||
@FieldNameConstants | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
public class P360GetRequest { | ||
private String title; | ||
private String CaseNumber; | ||
} |
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