-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add patch endpoint to assessment api
- Loading branch information
1 parent
ec7c688
commit 49c4324
Showing
11 changed files
with
391 additions
and
19 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
openapi: '3.0.0' | ||
info: | ||
title: 'laa-ccms-assessment-api' | ||
title: 'laa-ccms-caab-assessment-api' | ||
version: '1.0.0' | ||
paths: | ||
/assessments: | ||
get: | ||
tags: | ||
- 'assessment' | ||
- assessments | ||
summary: 'get assessments' | ||
operationId: 'getAssessments' | ||
parameters: | ||
|
@@ -44,7 +44,7 @@ paths: | |
/assessments/{assessment-id}: | ||
get: | ||
tags: | ||
- 'assessment' | ||
- assessments | ||
summary: 'get assessment by id ' | ||
operationId: 'getAssessment' | ||
parameters: | ||
|
@@ -70,6 +70,41 @@ paths: | |
description: 'Not found' | ||
'500': | ||
description: 'Internal server error' | ||
patch: | ||
tags: | ||
- assessments | ||
summary: 'update assessment' | ||
operationId: 'updateAssessment' | ||
requestBody: | ||
description: Create a application | ||
content: | ||
application/json: | ||
schema: | ||
$ref: '#/components/schemas/baseAssessmentDetail' | ||
parameters: | ||
- name: 'assessment-id' | ||
in: 'path' | ||
required: true | ||
schema: | ||
type: 'integer' | ||
format: 'int64' | ||
example: '1234567890' | ||
- $ref: '#/components/parameters/requiredUserLoginId' | ||
responses: | ||
'200': | ||
description: 'Successful operation' | ||
content: | ||
application/json: | ||
schema: | ||
$ref: "#/components/schemas/assessmentDetail" | ||
'400': | ||
description: 'Bad request' | ||
'401': | ||
description: 'Unauthorized' | ||
'404': | ||
description: 'Not found' | ||
'500': | ||
description: 'Internal server error' | ||
|
||
components: | ||
parameters: | ||
|
@@ -89,6 +124,14 @@ components: | |
- 'meritsAssessment_PREPOP' | ||
example: 'meansAssessment' | ||
|
||
requiredUserLoginId: | ||
name: 'Caab-User-Login-Id' | ||
in: header | ||
required: true | ||
schema: | ||
type: 'string' | ||
example: '[email protected]' | ||
|
||
schemas: | ||
assessmentDetails: | ||
type: 'object' | ||
|
@@ -99,10 +142,24 @@ components: | |
items: | ||
$ref: "#/components/schemas/assessmentDetail" | ||
assessmentDetail: | ||
allOf: | ||
- $ref: "#/components/schemas/baseAssessmentDetail" | ||
- type: 'object' | ||
properties: | ||
id: | ||
type: 'string' | ||
entity_types: | ||
type: array | ||
default: [ ] | ||
items: | ||
$ref: '#/components/schemas/assessmentEntityTypeDetail' | ||
audit_detail: | ||
$ref: '#/components/schemas/auditDetail' | ||
baseAssessmentDetail: | ||
type: 'object' | ||
discriminator: | ||
propertyName: baseAssessmentDetail | ||
properties: | ||
id: | ||
type: 'string' | ||
provider_id: | ||
type: 'string' | ||
case_reference_number: | ||
|
@@ -111,13 +168,6 @@ components: | |
type: 'string' | ||
status: | ||
type: 'string' | ||
entity_types: | ||
type: array | ||
default: [ ] | ||
items: | ||
$ref: '#/components/schemas/assessmentEntityTypeDetail' | ||
audit_detail: | ||
$ref: '#/components/schemas/auditDetail' | ||
auditDetail: | ||
type: 'object' | ||
properties: | ||
|
27 changes: 27 additions & 0 deletions
27
assessment-service/src/main/java/uk/gov/laa/ccms/caab/assessment/advice/AuditAdvice.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,27 @@ | ||
package uk.gov.laa.ccms.caab.assessment.advice; | ||
|
||
import static uk.gov.laa.ccms.caab.assessment.audit.AuditorAwareImpl.currentUserHolder; | ||
|
||
import org.springframework.web.bind.annotation.ControllerAdvice; | ||
import org.springframework.web.bind.annotation.ModelAttribute; | ||
import org.springframework.web.bind.annotation.RequestHeader; | ||
|
||
/** | ||
* Controller advice class responsible for setting the current user holder if available. | ||
*/ | ||
@ControllerAdvice | ||
public class AuditAdvice { | ||
|
||
/** | ||
* Sets the current user holder if available from the request header. | ||
* | ||
* @param caabUserLoginId the caab user login id | ||
*/ | ||
@ModelAttribute | ||
public void setCurrentUserHolderIfAvailable( | ||
@RequestHeader(value = "Caab-User-Login-Id", required = false) String caabUserLoginId) { | ||
if (caabUserLoginId != null) { | ||
currentUserHolder.set(caabUserLoginId); | ||
} | ||
} | ||
} |
20 changes: 20 additions & 0 deletions
20
assessment-service/src/main/java/uk/gov/laa/ccms/caab/assessment/audit/AuditorAwareImpl.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 uk.gov.laa.ccms.caab.assessment.audit; | ||
|
||
|
||
import java.util.Optional; | ||
import org.springframework.data.domain.AuditorAware; | ||
|
||
/** | ||
* Auditor provider implementation for the application. This class is responsible for storing the | ||
* current user in a thread local variable, and returning it when requested. | ||
*/ | ||
public class AuditorAwareImpl implements AuditorAware<String> { | ||
|
||
public static final ThreadLocal<String> currentUserHolder = new ThreadLocal<String>(); | ||
|
||
@Override | ||
public Optional<String> getCurrentAuditor() { | ||
return Optional.of(currentUserHolder.get()); | ||
} | ||
|
||
} |
21 changes: 21 additions & 0 deletions
21
...sment-service/src/main/java/uk/gov/laa/ccms/caab/assessment/config/ApplicationConfig.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 uk.gov.laa.ccms.caab.assessment.config; | ||
|
||
import org.springframework.context.annotation.Bean; | ||
import org.springframework.context.annotation.Configuration; | ||
import org.springframework.data.domain.AuditorAware; | ||
import org.springframework.data.jpa.repository.config.EnableJpaAuditing; | ||
import uk.gov.laa.ccms.caab.assessment.audit.AuditorAwareImpl; | ||
|
||
/** | ||
* Configuration for the application, and the auditor provider. | ||
*/ | ||
@Configuration | ||
@EnableJpaAuditing(auditorAwareRef = "auditorProvider") | ||
public class ApplicationConfig { | ||
|
||
@Bean("auditorProvider") | ||
public AuditorAware<String> auditorProvider() { | ||
return new AuditorAwareImpl(); | ||
} | ||
|
||
} |
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
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
Oops, something went wrong.