use of org.dcm4chee.arc.conf.RejectionNote 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);
}
}
use of org.dcm4chee.arc.conf.RejectionNote in project dcm4chee-arc-light by dcm4che.
the class QueryRejectionNotes method query.
@GET
@NoCache
@Produces("application/json")
public Response query() {
logRequest();
try {
return Response.ok((StreamingOutput) out -> {
JsonGenerator gen = Json.createGenerator(out);
gen.writeStartArray();
for (RejectionNote rjNote : sortedRejectionNotes()) {
Code code = rjNote.getRejectionNoteCode();
JsonWriter writer = new JsonWriter(gen);
gen.writeStartObject();
writer.writeNotNullOrDef("label", rjNote.getRejectionNoteLabel(), null);
writer.writeNotNullOrDef("type", rjNote.getRejectionNoteType(), null);
writer.writeNotNullOrDef("codeValue", code.getCodeValue(), null);
writer.writeNotNullOrDef("codingSchemeDesignator", code.getCodingSchemeDesignator(), null);
writer.writeNotNullOrDef("codeMeaning", code.getCodeMeaning(), null);
gen.writeEnd();
}
gen.writeEnd();
gen.flush();
}).build();
} catch (IllegalStateException e) {
return errResponse(e.getMessage(), Response.Status.NOT_FOUND);
} catch (Exception e) {
return errResponseAsTextPlain(exceptionAsString(e), Response.Status.INTERNAL_SERVER_ERROR);
}
}
use of org.dcm4chee.arc.conf.RejectionNote in project dcm4chee-arc-light by dcm4che.
the class RejectRS method reject.
private Response reject(String studyUID, String seriesUID, String objectUID, String findscp, String codeValue, String designator) {
logRequest();
ApplicationEntity localAE = device.getApplicationEntity(aet, true);
if (localAE == null || !localAE.isInstalled())
return errResponse("No such Application Entity: " + aet, Response.Status.NOT_FOUND);
try {
ApplicationEntity storescpAE = aeCache.findApplicationEntity(storescp);
ArchiveDeviceExtension arcDev = localAE.getDevice().getDeviceExtensionNotNull(ArchiveDeviceExtension.class);
Code code = new Code(codeValue, designator, null, "?");
RejectionNote rjNote = arcDev.getRejectionNote(code);
if (rjNote == null)
return errResponse("No such Rejection Note : " + code, Response.Status.NOT_FOUND);
List<Attributes> matches;
try {
matches = findSCU.findInstance(localAE, findscp, priority(), studyUID, seriesUID, objectUID, Tag.SOPClassUID, Tag.SOPInstanceUID, Tag.StudyDate, Tag.StudyTime, Tag.AccessionNumber, Tag.IssuerOfAccessionNumberSequence, Tag.PatientID, Tag.IssuerOfPatientID, Tag.PatientName, Tag.PatientBirthDate, Tag.PatientSex, Tag.StudyID, Tag.StudyInstanceUID, Tag.SeriesInstanceUID);
} catch (DicomServiceException e) {
return failed(e.getStatus(), e.getMessage(), null);
} catch (IOException e) {
return errResponse(e.getMessage(), Response.Status.BAD_GATEWAY);
} catch (Exception e) {
return failed(Status.ProcessingFailure, e.getMessage(), null);
}
if (matches.isEmpty())
return errResponse("No matches found for rejection", Response.Status.NOT_FOUND);
KOSBuilder builder = new KOSBuilder(rjNote.getRejectionNoteCode(), 999, 1);
matches.forEach(builder::addInstanceRef);
Attributes kos = builder.getAttributes();
try {
Attributes cmd = storeSCU.store(localAE, storescpAE, priority(), kos);
int status = cmd.getInt(Tag.Status, -1);
String errorComment = cmd.getString(Tag.ErrorComment);
boolean studyDeleted = seriesUID == null;
rejectionNoteSentEvent.fire(new RejectionNoteSent(request, localAE, storescpAE, kos, studyDeleted, status, errorComment));
switch(status) {
case Status.Success:
case Status.CoercionOfDataElements:
case Status.ElementsDiscarded:
case Status.DataSetDoesNotMatchSOPClassWarning:
return success(status, errorComment, matches);
default:
return failed(status, errorComment, matches);
}
} catch (IOException e) {
return errResponse(e.getMessage(), Response.Status.BAD_GATEWAY);
} catch (Exception e) {
return failed(Status.ProcessingFailure, e.getMessage(), matches);
}
} catch (ConfigurationException e) {
return errResponse(e.getMessage(), Response.Status.NOT_FOUND);
} catch (Exception e) {
return errResponseAsTextPlain(exceptionAsString(e), Response.Status.INTERNAL_SERVER_ERROR);
}
}
use of org.dcm4chee.arc.conf.RejectionNote in project dcm4chee-arc-light by dcm4che.
the class StgCmtEJB method isRejectionNoteDataRetentionPolicyExpired.
private boolean isRejectionNoteDataRetentionPolicyExpired(Instance inst) {
if (!inst.getSopClassUID().equals(UID.KeyObjectSelectionDocumentStorage) || inst.getConceptNameCode() == null)
return false;
ArchiveDeviceExtension arcdev = device.getDeviceExtension(ArchiveDeviceExtension.class);
RejectionNote rjnote = arcdev.getRejectionNote(inst.getConceptNameCode().getCode());
return rjnote != null && rjnote.getRejectionNoteType() == RejectionNote.Type.DATA_RETENTION_POLICY_EXPIRED;
}
use of org.dcm4chee.arc.conf.RejectionNote in project dcm4chee-arc-light by dcm4che.
the class AuditService method spoolStoreEvent.
void spoolStoreEvent(StoreContext ctx) {
try {
if (ctx.getRejectedInstance() != null) {
LOG.info("Suppress audit on receive of instances rejected by a previous received Rejection Note : {}", ctx.getRejectedInstance());
return;
}
RejectionNote rejectionNote = ctx.getRejectionNote();
if (rejectionNote != null && !rejectionNote.isRevokeRejection()) {
spoolInstancesDeleted(ctx, null);
return;
}
if (isDuplicateReceivedInstance(ctx)) {
if (rejectionNote != null && rejectionNote.isRevokeRejection())
spoolInstancesStored(ctx);
return;
}
if (ctx.getAttributes() == null) {
LOG.warn("Instances stored is not audited as store context attributes are not set. " + (ctx.getException() != null ? ctx.getException().getMessage() : null));
return;
}
spoolInstancesStored(ctx);
} catch (Exception e) {
LOG.warn("Failed to spool Store Event.\n", e);
}
}
Aggregations