Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
ca14566
LPT-2348 - Change SJP to POST payload to new SJP publishing endpoint
ynegi Jul 15, 2026
05c7d25
LPT-2348 - Change SJP to POST payload to new SJP publishing endpoint
ynegi Jul 15, 2026
363025a
Merge remote-tracking branch 'origin/LPT-2348' into LPT-2348
ynegi Jul 16, 2026
38d9083
Merge pull request #123 from hmcts/LPT-2348
ynegi Jul 16, 2026
c6c0d43
fix enforcer rules have failed
ynegi Jul 17, 2026
62c723d
Merge branch 'team/cct-1981' into LPT-2348
ynegi Jul 17, 2026
7bc51dc
Merge pull request #125 from hmcts/LPT-2348
ynegi Jul 17, 2026
34cc124
keep the actual and stub URL same for testing
ynegi Jul 21, 2026
87c9767
Merge branch 'team/cct-1981' into LPT-2348
arcadiushmcts Jul 21, 2026
98289f2
Merge pull request #126 from hmcts/LPT-2348
arcadiushmcts Jul 21, 2026
cbf473c
New 17.104.183-SNAPSHOT
Jul 21, 2026
6cd69bf
LPT-2348 - updated POMs version
ynegi Jul 28, 2026
d59c916
LPT-2348 - updated POMs version
ynegi Jul 28, 2026
b785f34
LPT-2348 - updated POMs version
ynegi Jul 28, 2026
846e722
Merge remote-tracking branch 'origin/LPT-2348' into LPT-2348
ynegi Jul 28, 2026
515d79b
Merge pull request #127 from hmcts/LPT-2348
ynegi Jul 28, 2026
60a44a2
New 17.104.184-CCT-1981-SNAPSHOT
Jul 28, 2026
71fb699
fix end URL and added extra logging
ynegi Aug 10, 2026
b603c99
fix end URL and added extra logging
ynegi Aug 10, 2026
ac4ec14
Merge remote-tracking branch 'origin/fix/extra-logging' into fix/extr…
ynegi Aug 11, 2026
e604954
Merge remote-tracking branch 'origin/fix/extra-logging' into fix/extr…
ynegi Aug 11, 2026
7c4b725
Merge remote-tracking branch 'origin/fix/extra-logging' into fix/extr…
ynegi Aug 11, 2026
42ea5c0
Merge pull request #132 from hmcts/fix/extra-logging
arcadiushmcts Aug 13, 2026
4f6cffb
New 17.104.185-CCT-1981-SNAPSHOT
Aug 13, 2026
004ca16
Adding log Transparency report (#135)
ynegi Aug 14, 2026
e6d4394
merge main into cct-1981 branch SJP
ynegi Aug 17, 2026
9df073e
Merge pull request #136 from hmcts/rebase-main
arcadiushmcts Aug 17, 2026
c1f09b7
LPT-2348 - fix publish court list issue
ynegi Aug 18, 2026
1282ef6
Merge pull request #138 from hmcts/fix-LPT-2348
arcadiushmcts Aug 18, 2026
f48cc01
fix intergation test
ynegi Aug 18, 2026
3b7d9d9
Merge pull request #139 from hmcts/fix-LPT-2348
arcadiushmcts Aug 18, 2026
1076fb2
New 17.104.187-CCT-1981-SNAPSHOT
Aug 18, 2026
8c367fd
async sjp publishing (#141)
arcadiushmcts Aug 20, 2026
54e17ba
fix IT test for LPT-2348
ynegi Aug 21, 2026
63944ed
Merge pull request #142 from hmcts/LPT-2348-ITtests
arcadiushmcts Aug 21, 2026
e769def
New 17.104.188-CCT-1981-SNAPSHOT
Aug 21, 2026
7c7cc65
bump POMs version
ynegi Aug 21, 2026
070c843
Merge pull request #143 from hmcts/LPT-2348-ITtests
arcadiushmcts Aug 21, 2026
4b9c6ab
New 17.104.189-CCT-1981-SNAPSHOT
Aug 21, 2026
3d5f322
LPT-2486 - merge main into team/cct-1981
ynegi Sep 1, 2026
a97178c
Merge pull request #144 from hmcts/cct-1981-rel
arcadiushmcts Sep 1, 2026
194781d
New 17.104.190-CCT-1981-SNAPSHOT
Sep 1, 2026
a702fd3
LPT-2518 - merge main into release branch
ynegi Sep 8, 2026
a79fa54
LPT-2518 - merge main into release branch
ynegi Sep 8, 2026
49ea877
Merge remote-tracking branch 'origin/dev/lpt-2518-rel-26.27' into dev…
ynegi Sep 9, 2026
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

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -34,15 +34,15 @@
import uk.gov.justice.services.messaging.JsonEnvelope;
import uk.gov.justice.services.messaging.JsonObjects;
import uk.gov.moj.cpp.sjp.domain.ListType;
import uk.gov.moj.cpp.sjp.event.processor.service.CourtListPublishingService;
import uk.gov.moj.cpp.sjp.event.processor.service.ExportType;
import uk.gov.moj.cpp.sjp.event.processor.service.ReferenceDataOffencesService;
import uk.gov.moj.cpp.sjp.event.processor.service.ReferenceDataService;
import uk.gov.moj.cpp.sjp.event.processor.service.SjpService;
import uk.gov.moj.cpp.sjp.event.processor.utils.PayloadHelper;
import uk.gov.moj.cpp.sjp.event.transparency.PressTransparencyJSONReportRequested;
import uk.gov.moj.cpp.sjp.event.transparency.PressTransparencyPDFReportRequested;

import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.time.LocalDate;
import java.time.format.DateTimeParseException;
import java.util.List;
Expand All @@ -63,7 +63,9 @@
@ServiceComponent(EVENT_PROCESSOR)
public class PressTransparencyReportRequestedProcessor {

public static final String PUBLIC_SJP_PRESS_TRANSPARENCY_REPORT_GENERATED = "public.sjp.press-transparency-report-generated";
private static final String LIST_TYPE = "listType";
private static final String SJP_PRESS_LIST = "SJP_PRESS_LIST";
private static final String SJP_DELTA_PRESS_LIST = "SJP_DELTA_PRESS_LIST";
public static final String CASE_URN = "caseUrn";
public static final String FIRST_NAME = "firstName";
public static final String LAST_NAME = "lastName";
Expand All @@ -79,7 +81,6 @@ public class PressTransparencyReportRequestedProcessor {
public static final String OFFENCES = "offences";
public static final String PROSECUTOR_NAME = "prosecutorName";
public static final String EMPTY = "";
public static final String STRING_FORMAT_COMMA = " %s,";
public static final String STRING_FORMAT_COMMA_PREFIX = ", %s";
public static final String STRING_FORMAT = " %s";
public static final String SJP_OFFENCES = "sjpOffences";
Expand All @@ -103,14 +104,12 @@ public class PressTransparencyReportRequestedProcessor {
@Inject
private SjpService sjpService;
@Inject
private ReferenceDataOffencesService referenceDataOffencesService;
@Inject
private ReferenceDataService referenceDataService;
@Inject
private PayloadHelper payloadHelper;
@Inject
@FrameworkComponent(EVENT_PROCESSOR)
private Sender sender;
@Inject
private CourtListPublishingService courtListPublishingService;

private String getTemplateIdentifier(final String type, final String lang) {
return "PressPendingCases" + type + lang;
Expand Down Expand Up @@ -143,53 +142,45 @@ public void handlePressTransparencyPDFReportRequest(final JsonEnvelope envelope)
public void handlePressTransparencyJSONReportRequest(final JsonEnvelope envelope) {
payloadHelper.initCache();

final List<JsonObject> pendingCasesFromViewStore = getPendingCasesFromViewStore(envelope);
final JsonObject eventPayload = envelope.payloadAsJsonObject();
final UUID reportId = fromString(eventPayload.getString(PRESS_TRANSPARENCY_REPORT_ID));
final boolean isWelsh = WELSH.name().equalsIgnoreCase(eventPayload.getString(LANGUAGE));
LOGGER.info("generating press transparency JSON report for press report {}", reportId);
sendPublicEvent(envelope, buildPayload(pendingCasesFromViewStore, true, envelope, isWelsh));
}

/**
* @deprecated with CCT-1587 now we are using two separate events for PDF and JSON report
* generation {@link PressTransparencyPDFReportRequested} and {@link
* PressTransparencyJSONReportRequested}
*/
@Deprecated(forRemoval = true)
@Handles("sjp.events.press-transparency-report-requested")
@Transactional
@SuppressWarnings({"squid:S00112", "squid:S1133"})
public void handlePressTransparencyRequest(final JsonEnvelope envelope) {
payloadHelper.initCache();
final String requestType = eventPayload.getString(REQUEST_TYPE);
final String language = eventPayload.getString(LANGUAGE);
LOGGER.info("handling press transparency JSON report request for press report {}, requestType {}, language {}",
reportId, requestType, language);

final List<JsonObject> pendingCasesFromViewStore = getPendingCasesFromViewStore(envelope);
final JsonObject eventPayload = envelope.payloadAsJsonObject();
final UUID reportId = fromString(eventPayload.getString(PRESS_TRANSPARENCY_REPORT_ID));
try {
final JsonObject payloadForDocumentGeneration = buildPayload(pendingCasesFromViewStore, false, envelope, false);
requestDocumentGeneration(envelope, reportId, payloadForDocumentGeneration);
sendPublicEvent(envelope, buildPayload(pendingCasesFromViewStore, true, envelope, false));
storeReportMetadata(envelope, reportId, pendingCasesFromViewStore);
} catch (FileServiceException e) {
throw new RuntimeException("IO Exception happened during press transparency report generation", e);
}
LOGGER.info("fetched {} pending case(s) from view store for press report {}", pendingCasesFromViewStore.size(), reportId);

final boolean isWelsh = WELSH.name().equalsIgnoreCase(language);
LOGGER.info("generating press transparency JSON report for press report {}", reportId);
publishCourtList(envelope, buildPayload(pendingCasesFromViewStore, true, envelope, isWelsh));
LOGGER.info("completed handling press transparency JSON report request for press report {}", reportId);
}

private void sendPublicEvent(final JsonEnvelope envelope, final JsonObject payloadForDocumentGeneration) {
LOGGER.info("publishing public event for sjp pending cases for public list in english");
private void publishCourtList(final JsonEnvelope envelope, final JsonObject payloadForDocumentGeneration) {
final String type = envelope.payloadAsJsonObject().getString(REQUEST_TYPE);
final String language = envelope.payloadAsJsonObject().getString(LANGUAGE);
final JsonObjectBuilder pendingListEnglishBuilder = createObjectBuilder()
// FULL/DELTA is part of the CaTH list-type vocabulary, not a separate field: sending
// SJP_PRESS_LIST for delta content makes CaTH render it with the full-list template.
final String listType = FULL.name().equals(type) ? SJP_PRESS_LIST : SJP_DELTA_PRESS_LIST;
LOGGER.info("building sjp press court list publish request, listType {}, requestType {}, language {}",
listType, type, language);
final JsonObject courtListPublishRequest = createObjectBuilder()
.add(LIST_TYPE, listType)
.add(LANGUAGE, language)
.add(REQUEST_TYPE, type)
.add("listPayload", payloadForDocumentGeneration);
if (LOGGER.isInfoEnabled()) {
LOGGER.info("publishing Sjp public event for press report {}, {}", PUBLIC_SJP_PRESS_TRANSPARENCY_REPORT_GENERATED, payloadForDocumentGeneration);
.add("listPayload", payloadForDocumentGeneration)
.build();

LOGGER.info("publishing sjp press pending cases list to court list publishing service");
try {
courtListPublishingService.publishCourtList(courtListPublishRequest.toString());
LOGGER.info("publishing sjp press pending cases list to court list publishing service called successfully");
} catch (IOException e) {
LOGGER.error("IO Exception happened while publishing sjp press court list", e);
throw new RuntimeException("IO Exception happened while publishing sjp press court list", e);
}
sender.send(Envelope.envelopeFrom(metadataFrom(envelope.metadata())
.withName(PUBLIC_SJP_PRESS_TRANSPARENCY_REPORT_GENERATED),
pendingListEnglishBuilder.build()));
}

private void storeReportMetadata(final JsonEnvelope envelope,
Expand Down Expand Up @@ -427,7 +418,7 @@ private boolean hasDefendantDateOfBirth(final JsonObject pendingCase) {

private Optional<String> getPersonDefendantFullName(final JsonObject pendingCase) {
if( JsonObjects.getString(pendingCase, FIRST_NAME).isPresent() || JsonObjects.getString(pendingCase, LAST_NAME).isPresent() ) {
return Optional.of((String) format("%s %s", pendingCase.getString(FIRST_NAME, ""), pendingCase.getString(LAST_NAME, "").toUpperCase()));
return Optional.of(format("%s %s", pendingCase.getString(FIRST_NAME, ""), pendingCase.getString(LAST_NAME, "").toUpperCase()));
}
return Optional.empty();
}
Expand Down
Loading
Loading