use of org.dcm4che3.util.CountingInputStream in project dcm4chee-arc-light by dcm4che.
the class StoreServiceImpl method store.
@Override
public void store(StoreContext ctx, InputStream data, Consumer<Attributes> coerce) throws IOException {
UpdateDBResult result = null;
try {
CountingInputStream countingInputStream = new CountingInputStream(data);
long startTime = System.nanoTime();
writeToStorage(ctx, countingInputStream);
coerce.accept(ctx.getAttributes());
String callingAET = ctx.getStoreSession().getCallingAET();
if (callingAET != null) {
metricsService.acceptDataRate("receive-from-" + callingAET, countingInputStream.getCount(), startTime);
}
if (ctx.getAcceptedStudyInstanceUID() != null && !ctx.getAcceptedStudyInstanceUID().equals(ctx.getStudyInstanceUID())) {
LOG.info("{}: Received Instance[studyUID={},seriesUID={},objectUID={}]" + " does not match requested studyUID={}", ctx.getStoreSession(), ctx.getStudyInstanceUID(), ctx.getSeriesInstanceUID(), ctx.getSopInstanceUID(), ctx.getAcceptedStudyInstanceUID());
throw new DicomServiceException(DIFF_STUDY_INSTANCE_UID);
}
supplementDefaultCharacterSet(ctx);
storeMetadata(ctx);
coerceAttributes(ctx);
result = updateDB(ctx);
postUpdateDB(ctx, result);
} catch (DicomServiceException e) {
ctx.setException(e);
throw e;
} catch (Exception e) {
LOG.info("{}: Unexpected Exception: ", ctx.getStoreSession(), e);
DicomServiceException dse = new DicomServiceException(Status.ProcessingFailure, e);
ctx.setException(dse);
throw dse;
} finally {
revokeStorage(ctx, result);
fireStoreEvent(ctx);
}
}
Aggregations