Skip to content

Commit 8fef5a7

Browse files
authored
Added logs (#96)
* Added logs * Added logs * Added logs * Added logs * Added logs * Added logs
1 parent 9d30dad commit 8fef5a7

File tree

5 files changed

+15
-24
lines changed

5 files changed

+15
-24
lines changed

src/main/java/uk/gov/hmcts/cp/controllers/CourtScheduleController.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
import uk.gov.hmcts.cp.services.CaseUrnMapperService;
1212
import uk.gov.hmcts.cp.services.CourtScheduleService;
1313

14+
import java.util.stream.Collectors;
15+
1416
import static uk.gov.hmcts.cp.utils.Utils.sanitizeString;
1517

1618
@RestController
@@ -31,13 +33,15 @@ public ResponseEntity<CourtScheduleResponse> getCourtScheduleByCaseUrn(final Str
3133
final CourtScheduleResponse courtScheduleResponse;
3234
try {
3335
sanitizedCaseUrn = sanitizeString(caseUrn);
34-
String caseId = caseUrnMapperService.getCaseId(sanitizedCaseUrn);
36+
LOG.atInfo().log("Received request to get court schedule for caseUrn: {}", sanitizedCaseUrn);
37+
final String caseId = caseUrnMapperService.getCaseId(sanitizedCaseUrn);
3538
courtScheduleResponse = courtScheduleService.getCourtScheduleByCaseId(caseId);
39+
LOG.atInfo().log("caseUrn : {} -> Court Schedule Hearing Ids : {}", caseUrn, courtScheduleResponse.getCourtSchedule().stream()
40+
.flatMap(a -> a.getHearings().stream().map(b -> b.getHearingId())).collect(Collectors.joining(",")));
3641
} catch (ResponseStatusException e) {
3742
LOG.atError().log(e.getMessage());
3843
throw e;
3944
}
40-
LOG.atDebug().log("Found court schedule for caseUrn: {}", sanitizedCaseUrn);
4145
return ResponseEntity.ok()
4246
.contentType(MediaType.APPLICATION_JSON)
4347
.body(courtScheduleResponse);

src/main/java/uk/gov/hmcts/cp/repositories/CourtScheduleClientImpl.java

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -52,23 +52,19 @@ public CourtScheduleClientImpl() throws NoSuchAlgorithmException, KeyManagementE
5252
}
5353

5454
public String getCourtScheduleClientUrl() {
55-
LOG.info("courtScheduleClientUrl is : {}", this.courtScheduleClientUrl);
5655
return this.courtScheduleClientUrl;
5756
}
5857

5958
public String getCourtScheduleClientPath() {
60-
LOG.info("courtScheduleClientPath is : {}", this.courtScheduleClientPath);
6159
return this.courtScheduleClientPath;
6260
}
6361

6462
public String getCjscppuid() {
65-
LOG.info("cjscppuid is : {}", this.cjscppuid);
6663
return this.cjscppuid;
6764
}
6865

6966
public CourtScheduleResponse getCourtScheduleByCaseId(final String caseId) {
7067
final List<Hearing> hearingList = getHearings(caseId);
71-
LOG.info("In function createCourtScheduleResponse Response Body: {} ", hearingList);
7268
return CourtScheduleResponse.builder()
7369
.courtSchedule(List.of(
7470
CourtSchedule.builder()
@@ -137,8 +133,8 @@ private List<Hearing> getHearingData(final HearingResponse hearingResponse) {
137133
return hearings;
138134
}
139135

140-
private static CourtSitting getCourtSitting(HearingResponse.HearingResult.HearingDay hearingDay, String judiciaryId) {
141-
CourtSitting courtSitting = new CourtSitting();
136+
private static CourtSitting getCourtSitting(final HearingResponse.HearingResult.HearingDay hearingDay, final String judiciaryId) {
137+
final CourtSitting courtSitting = new CourtSitting();
142138
courtSitting.setSittingStart(OffsetDateTime.parse(hearingDay.getStartTime()));
143139
courtSitting.setSittingEnd(OffsetDateTime.parse(hearingDay.getEndTime()));
144140
courtSitting.setJudiciaryId(judiciaryId);

src/main/java/uk/gov/hmcts/cp/services/CaseUrnMapperService.java

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public class CaseUrnMapperService {
3434
public String getCaseId(final String caseUrn) {
3535
try {
3636
ignoreCertificates();
37-
ResponseEntity<CaseMapperResponse> responseEntity = restTemplate.exchange(
37+
final ResponseEntity<CaseMapperResponse> responseEntity = restTemplate.exchange(
3838
getCaseIdUrl(caseUrn),
3939
HttpMethod.GET,
4040
getRequestEntity(),
@@ -43,31 +43,24 @@ public String getCaseId(final String caseUrn) {
4343
LOG.atInfo().log(" CaseMapperResponse is : {} and body : {} caseurn : {} ", responseEntity.getStatusCode(), responseEntity.getBody(), caseUrn);
4444

4545
if (responseEntity.getStatusCode().is2xxSuccessful() && responseEntity.getBody() != null) {
46-
CaseMapperResponse body = responseEntity.getBody();
46+
final CaseMapperResponse body = responseEntity.getBody();
4747
return body.getCaseId();
4848
}
4949
} catch (Exception e) {
50-
LOG.atError().log("Error while getting case id from case urn", e);
50+
LOG.atError().log("Error while getting case id from case urn: {}", caseUrn, e);
5151
}
5252
throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Case not found by urn: " + caseUrn);
5353
}
5454

5555
public String getCaseMapperServiceUrl() {
56-
// if (this.caseMapperServiceUrl != null) {
57-
// LOG.info(" caseMapperServiceUrl is : {}", this.caseMapperServiceUrl);
58-
// return this.caseMapperServiceUrl;
59-
// }
60-
LOG.info(" caseMapperServiceUrl is : {}", this.caseMapperServiceUrl);
6156
return this.caseMapperServiceUrl;
6257
}
6358

6459
public String getCaseMapperServicePath() {
65-
LOG.info(" caseMapperServicePath is : {}", this.caseMapperServicePath);
6660
return this.caseMapperServicePath;
6761
}
6862

69-
private String getCaseIdUrl(String caseUrn) {
70-
LOG.atDebug().log("Fetching case id for case urn: {}", caseUrn);
63+
private String getCaseIdUrl(final String caseUrn) {
7164
return UriComponentsBuilder
7265
.fromUriString(getCaseMapperServiceUrl())
7366
.pathSegment(getCaseMapperServicePath())
@@ -77,7 +70,7 @@ private String getCaseIdUrl(String caseUrn) {
7770
}
7871

7972
private HttpEntity<String> getRequestEntity() {
80-
HttpHeaders headers = new HttpHeaders();
73+
final HttpHeaders headers = new HttpHeaders();
8174
headers.set("Accept", MediaType.APPLICATION_JSON_VALUE);
8275
return new HttpEntity<>(headers);
8376
}

src/main/java/uk/gov/hmcts/cp/services/CourtScheduleService.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,7 @@ public CourtScheduleResponse getCourtScheduleByCaseId(final String caseId) throw
2626
throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "caseId is required");
2727
}
2828
LOG.atWarn().log("NOTE: System configured to return stubbed Court Schedule details. Ignoring provided caseId : {}", sanitizeString(caseId));
29-
final CourtScheduleResponse stubbedCourtScheduleResponse = courtScheduleClient.getCourtScheduleByCaseId(caseId);
30-
LOG.atDebug().log("Court Schedule response: {}", stubbedCourtScheduleResponse);
31-
return stubbedCourtScheduleResponse;
29+
return courtScheduleClient.getCourtScheduleByCaseId(caseId);
3230
}
3331

3432
}

src/main/resources/application.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,4 @@ azure:
4646

4747
logging:
4848
level:
49-
uk.gov.hmcts.cp: DEBUG
49+
uk.gov.hmcts.cp: INFO

0 commit comments

Comments
 (0)