15
15
import uk .gov .hmcts .reform .bulkscanprocessor .tasks .processor .ZipFileContentDetail ;
16
16
import uk .gov .hmcts .reform .bulkscanprocessor .tasks .processor .ZipFileProcessor ;
17
17
18
+ import java .util .Optional ;
18
19
import java .util .zip .ZipInputStream ;
19
20
20
21
import static java .util .stream .Collectors .joining ;
@@ -40,6 +41,8 @@ public class FileContentProcessor {
40
41
41
42
private final FileRejector fileRejector ;
42
43
44
+ private static final String CASE_REFERENCE_NOT_PRESENT = "(NOT PRESENT)" ;
45
+
43
46
/**
44
47
* Constructor for the FileContentProcessor.
45
48
* @param zipFileProcessor The zip file processor
@@ -70,18 +73,20 @@ public void processZipFileContent(
70
73
String zipFilename ,
71
74
String containerName
72
75
) {
76
+ Optional <String > caseReference = Optional .empty ();
73
77
try {
74
78
ZipFileContentDetail zipDetail = zipFileProcessor .getZipContentDetail (zis , zipFilename );
75
79
76
80
InputEnvelope inputEnvelope = envelopeProcessor .parseEnvelope (zipDetail .getMetadata (), zipFilename );
81
+ caseReference = Optional .ofNullable (inputEnvelope .caseNumber );
77
82
78
83
log .info (
79
84
"Parsed envelope. File name: {}. Container: {}. Payment DCNs: {}. Document DCNs: {}, caseNumber {}" ,
80
85
zipFilename ,
81
86
containerName ,
82
87
inputEnvelope .payments .stream ().map (payment -> payment .documentControlNumber ).collect (joining ("," )),
83
88
inputEnvelope .scannableItems .stream ().map (doc -> doc .documentControlNumber ).collect (joining ("," )),
84
- inputEnvelope . caseNumber
89
+ caseReference . orElse ( CASE_REFERENCE_NOT_PRESENT )
85
90
);
86
91
87
92
envelopeHandler .handleEnvelope (
@@ -92,22 +97,26 @@ public void processZipFileContent(
92
97
);
93
98
} catch (PaymentsDisabledException ex ) {
94
99
log .error (
95
- "Rejected file {} from container {} - Payments processing is disabled" , zipFilename , containerName
100
+ "Rejected file {} from container {}, Case reference: {} - Payments processing is disabled" ,
101
+ zipFilename , containerName , caseReference .orElse (CASE_REFERENCE_NOT_PRESENT )
96
102
);
97
103
Long eventId = createEvent (FILE_VALIDATION_FAILURE , containerName , zipFilename , ex .getMessage ());
98
104
fileRejector .handleInvalidBlob (eventId , containerName , zipFilename , ex );
99
105
} catch (ServiceDisabledException ex ) {
100
106
log .error (
101
- "Rejected file {} from container {} - Service is disabled" , zipFilename , containerName
107
+ "Rejected file {} from container {}, Case reference: {} - Service is disabled" ,
108
+ zipFilename , containerName , caseReference .orElse (CASE_REFERENCE_NOT_PRESENT )
102
109
);
103
110
Long eventId = createEvent (DISABLED_SERVICE_FAILURE , containerName , zipFilename , ex .getMessage ());
104
111
fileRejector .handleInvalidBlob (eventId , containerName , zipFilename , ex );
105
112
} catch (EnvelopeRejectionException ex ) {
106
- log .warn ("Rejected file {} from container {} - invalid" , zipFilename , containerName , ex );
113
+ log .warn ("Rejected file {} from container {}, Case reference: {} - invalid" ,
114
+ zipFilename , containerName , caseReference .orElse (CASE_REFERENCE_NOT_PRESENT ), ex );
107
115
Long eventId = createEvent (FILE_VALIDATION_FAILURE , containerName , zipFilename , ex .getMessage ());
108
116
fileRejector .handleInvalidBlob (eventId , containerName , zipFilename , ex );
109
117
} catch (PreviouslyFailedToUploadException ex ) {
110
- log .warn ("Rejected file {} from container {} - failed previously" , zipFilename , containerName , ex );
118
+ log .warn ("Rejected file {} from container {}, Case reference: {} - failed previously" ,
119
+ zipFilename , containerName , caseReference .orElse (CASE_REFERENCE_NOT_PRESENT ), ex );
111
120
createEvent (DOC_UPLOAD_FAILURE , containerName , zipFilename , ex .getMessage ());
112
121
} catch (Exception ex ) {
113
122
log .error ("Failed to process file {} from container {}" , zipFilename , containerName , ex );
0 commit comments