in import/src/main/java/com/google/cloud/healthcare/imaging/dicomadapter/CStoreService.java [79:156]
protected void store(
Association association,
PresentationContext presentationContext,
Attributes request,
PDVInputStream inPdvStream,
Attributes response)
throws IOException {
try {
MonitoringService.addEvent(Event.CSTORE_REQUEST);
String sopClassUID = request.getString(Tag.AffectedSOPClassUID);
String sopInstanceUID = request.getString(Tag.AffectedSOPInstanceUID);
String transferSyntax = presentationContext.getTransferSyntax();
validateParam(sopClassUID, "AffectedSOPClassUID");
validateParam(sopInstanceUID, "AffectedSOPInstanceUID");
DestinationHolder destinationHolder =
destinationClientFactory.create(association.getAAssociateAC().getCallingAET(), transferSyntax, inPdvStream);
final CountingInputStream countingStream = destinationHolder.getCountingInputStream();
List<StreamProcessor> processorList = new ArrayList<>();
if (redactor != null) {
processorList.add(redactor::redact);
}
if(transcodeToSyntax != null && !transcodeToSyntax.equals(transferSyntax)) {
processorList.add((inputStream, outputStream) -> {
try (Transcoder transcoder = new Transcoder(inputStream)) {
transcoder.setIncludeFileMetaInformation(true);
transcoder.setDestinationTransferSyntax(transcodeToSyntax);
transcoder.transcode((transcoder1, dataset) -> outputStream);
}
});
}
if (multipleSendService != null) {
processorList.add((inputStream, outputStream) -> {
multipleSendService.start(
destinationHolder.getHealthcareDestinations(),
destinationHolder.getDicomDestinations(),
inputStream,
sopClassUID,
sopInstanceUID,
association.getSerialNo()
);
});
} else {
processorList.add((inputStream, outputStream) -> {
destinationHolder.getSingleDestination().stowRs(inputStream);
});
}
try(InputStream inWithHeader = DicomStreamUtil.dicomStreamWithFileMetaHeader(
sopInstanceUID, sopClassUID, transferSyntax, countingStream)) {
processStream(association.getApplicationEntity().getDevice().getExecutor(),
inWithHeader, processorList);
} catch (IOException e) {
throw new DicomServiceException(Status.ProcessingFailure, e);
}
response.setInt(Tag.Status, VR.US, Status.Success);
MonitoringService.addEvent(Event.CSTORE_BYTES, countingStream.getCount());
} catch (DicomWebException e) {
reportError(e, Event.CSTORE_ERROR);
throw new DicomServiceException(e.getStatus(), e);
} catch (DicomServiceException e) {
reportError(e, Event.CSTORE_ERROR);
throw e;
} catch (MultipleDestinationUploadServiceException me) {
reportError(me, null);
throw new DicomServiceException(me.getDicomStatus() != null ? me.getDicomStatus() : Status.ProcessingFailure, me);
} catch (Throwable e) {
reportError(e, Event.CSTORE_ERROR);
throw new DicomServiceException(Status.ProcessingFailure, e);
}
}