use of org.dcm4chee.arc.conf.ArchiveAEExtension 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;
}
use of org.dcm4chee.arc.conf.ArchiveAEExtension in project dcm4chee-arc-light by dcm4che.
the class UPSQueryTask method run0.
private void run0() {
try {
QueryContext ctx = query.getQueryContext();
ArchiveAEExtension arcAE = ctx.getArchiveAEExtension();
ArchiveDeviceExtension arcdev = arcAE.getArchiveDeviceExtension();
query.executeQuery(arcdev.getQueryFetchSize());
super.run();
} catch (Exception e) {
writeDimseRSP(new DicomServiceException(Status.UnableToProcess, e));
} finally {
query.close();
}
}
use of org.dcm4chee.arc.conf.ArchiveAEExtension in project dcm4chee-arc-light by dcm4che.
the class UpsMatchingRS method createWorkitemsMatching.
private Response createWorkitemsMatching(String method, QueryRetrieveLevel2 qrlevel, String studyIUID, String seriesIUID, InputStream in) {
InputType inputType = InputType.valueOf(headers.getMediaType());
if (inputType == null)
return notAcceptable();
try {
ArchiveDeviceExtension arcDev = device.getDeviceExtensionNotNull(ArchiveDeviceExtension.class);
ArchiveAEExtension arcAE = getArchiveAE();
Attributes upsTemplateAttrs = inputType.parse(in);
upsTemplateAttrs.setDate(Tag.ScheduledProcedureStepStartDateTime, VR.DT, scheduledTime());
if (upsLabel != null)
upsTemplateAttrs.setString(Tag.ProcedureStepLabel, VR.LO, upsLabel);
QueryContext ctx = queryContext(method, qrlevel, studyIUID, seriesIUID, arcAE.getApplicationEntity());
String warning = null;
AtomicInteger count = new AtomicInteger();
Response.Status status = Response.Status.ACCEPTED;
Attributes ups = new Attributes(upsTemplateAttrs);
int matches = 0;
try (Query query = queryService.createQuery(ctx)) {
try {
query.executeQuery(arcDev.getQueryFetchSize());
while (query.hasMoreMatches()) {
Attributes match = query.nextMatch();
if (match == null)
continue;
ups = studyIUID == null ? new Attributes(upsTemplateAttrs) : ups;
UPSUtils.updateUPSAttributes(ups, match, studyIUID, seriesIUID, aet);
matches++;
if (studyIUID == null)
createUPS(arcAE, ups, count);
}
if (matches > 0 && studyIUID != null)
createUPS(arcAE, ups, count);
} catch (Exception e) {
warning = e.getMessage();
status = Response.Status.INTERNAL_SERVER_ERROR;
}
}
if (count.get() == 0) {
warning = "No matching Instances found. No Workitem was created.";
status = Response.Status.NO_CONTENT;
}
Response.ResponseBuilder builder = Response.status(status);
if (warning != null) {
LOG.warn("Response {} caused by {}", status, warning);
builder.header("Warning", warning);
}
return builder.entity("{\"count\":" + count + '}').build();
} catch (IllegalStateException e) {
return errResponse(Response.Status.NOT_FOUND, e.getMessage());
} catch (Exception e) {
return errResponseAsTextPlain(exceptionAsString(e), Response.Status.INTERNAL_SERVER_ERROR);
}
}
use of org.dcm4chee.arc.conf.ArchiveAEExtension in project dcm4chee-arc-light by dcm4che.
the class ImportStorageRS method reimportStudy.
@POST
@Path("/studies/{study}/reimport")
public void reimportStudy(@Suspended AsyncResponse ar, @PathParam("study") String studyUID) {
Output output = selectMediaType();
ApplicationEntity ae = getApplicationEntity();
try {
ArchiveAEExtension arcAE = ae.getAEExtensionNotNull(ArchiveAEExtension.class);
List<Location> locations = deletionService.reimportStudy(studyUID, HttpServletRequestInfo.valueOf(request), arcAE);
Attributes coerce = new QueryAttributes(uriInfo, null).getQueryKeys();
Date now = reasonForModification != null && !coerce.isEmpty() ? new Date() : null;
Attributes.UpdatePolicy updatePolicy = Attributes.UpdatePolicy.valueOf(this.updatePolicy);
for (Location location : locations) {
if (location.getObjectType() == Location.ObjectType.METADATA)
continue;
Storage storage = storageFactory.getStorage(getStorageDesc(location.getStorageID()));
final StoreSession session = service.newStoreSession(HttpServletRequestInfo.valueOf(request), ae, aet, null).withObjectStorageID(location.getStorageID());
StoreContext ctx = service.newStoreContext(session);
ctx.getLocations().add(location);
importInstanceOnStorage(storage, ctx, coerce, updatePolicy, now, location.getStoragePath());
}
rsForward.forward(RSOperation.ReimportStudy, arcAE, null, request);
} catch (StudyNotFoundException e) {
throw new WebApplicationException(e.getMessage(), Response.Status.NOT_FOUND);
} catch (StudyNotEmptyException e) {
throw new WebApplicationException(e.getMessage(), Response.Status.FORBIDDEN);
} catch (Exception e) {
throw new WebApplicationException(errResponseAsTextPlain(exceptionAsString(e), Response.Status.INTERNAL_SERVER_ERROR));
}
response.setString(Tag.RetrieveURL, VR.UR, retrieveURL());
Response.ResponseBuilder responseBuilder = Response.status(status());
ar.resume(responseBuilder.entity(output.entity(response, ae)).header("Warning", response.getString(Tag.ErrorComment)).build());
}
use of org.dcm4chee.arc.conf.ArchiveAEExtension in project dcm4chee-arc-light by dcm4che.
the class QueryAETs method writeTo.
private void writeTo(ApplicationEntity ae, JsonGenerator gen) {
ArchiveAEExtension arcAE = ae.getAEExtension(ArchiveAEExtension.class);
JsonWriter writer = new JsonWriter(gen);
gen.writeStartObject();
gen.write("dicomAETitle", ae.getAETitle());
writer.writeNotNullOrDef("dicomDescription", ae.getDescription(), null);
writer.writeNotEmpty("dcmOtherAETitle", ae.getOtherAETitles());
if (arcAE != null) {
QueryRetrieveView queryRetrieveView = arcAE.getQueryRetrieveView();
writer.writeNotDef("dcmHideNotRejectedInstances", queryRetrieveView != null && queryRetrieveView.isHideNotRejectedInstances(), false);
writer.writeNotNullOrDef("dcmAllowDeletePatient", arcAE.allowDeletePatient(), null);
writer.writeNotNullOrDef("dcmAllowDeleteStudyPermanently", arcAE.allowDeleteStudy(), null);
}
gen.writeEnd();
}
Aggregations