Search in sources :

Example 1 with CountingInputStream

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);
    }
}
Also used : CountingInputStream(org.dcm4che3.util.CountingInputStream) DicomServiceException(org.dcm4che3.net.service.DicomServiceException) EJBException(javax.ejb.EJBException) SAXException(org.xml.sax.SAXException) ConfigurationException(org.dcm4che3.conf.api.ConfigurationException) DicomServiceException(org.dcm4che3.net.service.DicomServiceException) TransformerConfigurationException(javax.xml.transform.TransformerConfigurationException) IOException(java.io.IOException)

Aggregations

IOException (java.io.IOException)1 EJBException (javax.ejb.EJBException)1 TransformerConfigurationException (javax.xml.transform.TransformerConfigurationException)1 ConfigurationException (org.dcm4che3.conf.api.ConfigurationException)1 DicomServiceException (org.dcm4che3.net.service.DicomServiceException)1 CountingInputStream (org.dcm4che3.util.CountingInputStream)1 SAXException (org.xml.sax.SAXException)1