Search in sources :

Example 1 with ApplicationEntity

use of org.dcm4che3.net.ApplicationEntity in project dcm4chee-arc-light by dcm4che.

the class RejectionServiceImpl method onExport.

public void onExport(@Observes ExportContext ctx) {
    ExporterDescriptor desc = ctx.getExporter().getExporterDescriptor();
    if (ctx.getException() != null || !desc.isRejectForDataRetentionExpiry() || ctx.getOutcome().getStatus() != Task.Status.COMPLETED)
        return;
    ApplicationEntity ae = getApplicationEntity(desc.getAETitle());
    if (ae == null || !ae.isInstalled()) {
        LOG.warn("No such Application Entity: {}", desc.getAETitle());
        return;
    }
    ArchiveDeviceExtension arcDev = device.getDeviceExtension(ArchiveDeviceExtension.class);
    RejectionNote rn = arcDev.getRejectionNote(RejectionNote.Type.DATA_RETENTION_POLICY_EXPIRED);
    if (rn == null) {
        LOG.warn("Data Retention Policy Expired Rejection Note not configured.");
        return;
    }
    LOG.info("Export completed, invoke rejection of objects.");
    try {
        if (ejb.claimExpired(ctx.getStudyInstanceUID(), ctx.getSeriesInstanceUID(), ExpirationState.REJECTED))
            reject(ae, ctx.getAETitle(), ctx.getStudyInstanceUID(), ctx.getSeriesInstanceUID(), ctx.getSopInstanceUID(), rn, ctx.getHttpServletRequestInfo());
    } catch (Exception e) {
        LOG.warn("Rejection of Expired Study[UID={}], Series[UID={}], SOPInstance[UID={}] failed.\n", ctx.getStudyInstanceUID(), ctx.getSeriesInstanceUID(), ctx.getSopInstanceUID(), e);
        ejb.claimExpired(ctx.getStudyInstanceUID(), ctx.getSeriesInstanceUID(), ExpirationState.FAILED_TO_REJECT);
    }
}
Also used : ArchiveDeviceExtension(org.dcm4chee.arc.conf.ArchiveDeviceExtension) ApplicationEntity(org.dcm4che3.net.ApplicationEntity) ExporterDescriptor(org.dcm4chee.arc.conf.ExporterDescriptor) RejectionNote(org.dcm4chee.arc.conf.RejectionNote)

Example 2 with ApplicationEntity

use of org.dcm4che3.net.ApplicationEntity in project dcm4chee-arc-light by dcm4che.

the class RejectionServiceImpl method reject.

@Override
public int reject(ApplicationEntity ae, String aet, String studyIUID, String seriesIUID, String sopIUID, RejectionNote rjNote, HttpServletRequestInfo httpRequest) throws Exception {
    String changeRequesterAET = ae.getAEExtension(ArchiveAEExtension.class).changeRequesterAET();
    StoreSession storeSession = storeService.newStoreSession(httpRequest, ae, aet, changeRequesterAET != null ? changeRequesterAET : ae.getAETitle());
    String rejectionNoteObjectStorageID = rejectionNoteObjectStorageID(storeSession);
    storeSession.withObjectStorageID(rejectionNoteObjectStorageID);
    storeService.restoreInstances(storeSession, studyIUID, seriesIUID, null);
    Attributes attrs = queryService.createRejectionNote(ae, studyIUID, seriesIUID, sopIUID, rjNote);
    if (attrs == null)
        return 0;
    int count = countInstances(attrs);
    LOG.info("Start rejection of {} instances of Study[UID={}], Series[UID={}], SOPInstance[UID={}].", count, studyIUID, seriesIUID, sopIUID);
    StoreContext storeCtx = storeService.newStoreContext(storeSession);
    storeCtx.setReceiveTransferSyntax(UID.ExplicitVRLittleEndian);
    storeService.store(storeCtx, attrs);
    LOG.info("Rejection of {} instances of Study[UID={}], Series[UID={}], SOPInstance[UID={}] completed.", count, studyIUID, seriesIUID, sopIUID);
    return count;
}
Also used : ArchiveAEExtension(org.dcm4chee.arc.conf.ArchiveAEExtension) Attributes(org.dcm4che3.data.Attributes) StoreSession(org.dcm4chee.arc.store.StoreSession) StoreContext(org.dcm4chee.arc.store.StoreContext)

Example 3 with ApplicationEntity

use of org.dcm4che3.net.ApplicationEntity in project dcm4chee-arc-light by dcm4che.

the class RejectionServiceImpl method rejectionNoteObjectStorageID.

private String rejectionNoteObjectStorageID(StoreSession storeSession) {
    String rejectionNoteStorageAET = device.getDeviceExtension(ArchiveDeviceExtension.class).getRejectionNoteStorageAET();
    if (rejectionNoteStorageAET == null)
        return null;
    ApplicationEntity rjAE = getApplicationEntity(rejectionNoteStorageAET);
    ArchiveAEExtension rjArcAE;
    if (rjAE == null || !rjAE.isInstalled() || (rjArcAE = rjAE.getAEExtension(ArchiveAEExtension.class)) == null) {
        LOG.warn("Rejection Note Storage Application Entity with an Archive AE Extension not configured: {}", rejectionNoteStorageAET);
        return null;
    }
    String[] objectStorageIDs;
    if ((objectStorageIDs = rjArcAE.getObjectStorageIDs()).length > 0)
        return objectStorageIDs[0];
    LOG.warn("Object storage for rejection notes shall fall back on those configured for AE: {} since none are " + "configured for RejectionNoteStorageAE: {}", storeSession.getLocalApplicationEntity().getAETitle(), rejectionNoteStorageAET);
    return null;
}
Also used : ArchiveAEExtension(org.dcm4chee.arc.conf.ArchiveAEExtension) ArchiveDeviceExtension(org.dcm4chee.arc.conf.ArchiveDeviceExtension) ApplicationEntity(org.dcm4che3.net.ApplicationEntity)

Example 4 with ApplicationEntity

use of org.dcm4che3.net.ApplicationEntity in project dcm4chee-arc-light by dcm4che.

the class UPSEventSCP method mkAAssociateRQ.

private static AAssociateRQ mkAAssociateRQ(ApplicationEntity localAE, String subscriberAET) {
    AAssociateRQ aarq = new AAssociateRQ();
    aarq.setCalledAET(subscriberAET);
    TransferCapability tc = localAE.getTransferCapabilityFor(UID.UnifiedProcedureStepEvent, TransferCapability.Role.SCP);
    aarq.addPresentationContext(new PresentationContext(1, UID.UnifiedProcedureStepEvent, tc != null ? tc.getTransferSyntaxes() : new String[] { UID.ImplicitVRLittleEndian }));
    aarq.addRoleSelection(new RoleSelection(UID.UnifiedProcedureStepEvent, false, true));
    return aarq;
}
Also used : AAssociateRQ(org.dcm4che3.net.pdu.AAssociateRQ) RoleSelection(org.dcm4che3.net.pdu.RoleSelection) PresentationContext(org.dcm4che3.net.pdu.PresentationContext)

Example 5 with ApplicationEntity

use of org.dcm4che3.net.ApplicationEntity in project dcm4chee-arc-light by dcm4che.

the class CStoreForward method createTask.

private CStoreForwardTask createTask(final Association as) {
    ApplicationEntity localAE = retrieveCtx.getLocalApplicationEntity();
    Association storeas = openAssociation(as, localAE);
    final CStoreForwardTask task = new CStoreForwardTask(retrieveCtx, storeas);
    forwardTasks.put(as, task);
    as.addAssociationListener(new AssociationListener() {

        @Override
        public void onClose(Association association) {
            task.onStore(null);
            forwardTasks.remove(as);
        }
    });
    if (storeas != null) {
        retrieveCtx.incrementPendingCStoreForward();
        localAE.getDevice().execute(task);
    }
    return task;
}
Also used : Association(org.dcm4che3.net.Association) ApplicationEntity(org.dcm4che3.net.ApplicationEntity) AssociationListener(org.dcm4che3.net.AssociationListener)

Aggregations

ApplicationEntity (org.dcm4che3.net.ApplicationEntity)58 IOException (java.io.IOException)18 Attributes (org.dcm4che3.data.Attributes)18 ConfigurationException (org.dcm4che3.conf.api.ConfigurationException)15 AAssociateRQ (org.dcm4che3.net.pdu.AAssociateRQ)14 Response (javax.ws.rs.core.Response)13 DicomServiceException (org.dcm4che3.net.service.DicomServiceException)13 ArchiveDeviceExtension (org.dcm4chee.arc.conf.ArchiveDeviceExtension)12 Query (org.dcm4chee.arc.query.Query)12 QueryContext (org.dcm4chee.arc.query.QueryContext)12 Device (org.dcm4che3.net.Device)11 StoreSession (org.dcm4chee.arc.store.StoreSession)10 ArchiveAEExtension (org.dcm4chee.arc.conf.ArchiveAEExtension)9 QueryAttributes (org.dcm4chee.arc.query.util.QueryAttributes)9 PresentationContext (org.dcm4che3.net.pdu.PresentationContext)7 StoreContext (org.dcm4chee.arc.store.StoreContext)7 Logger (org.slf4j.Logger)7 LoggerFactory (org.slf4j.LoggerFactory)7 Outcome (org.dcm4chee.arc.qmgt.Outcome)6 java.util (java.util)5