use of org.dcm4che3.net.ApplicationEntity 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.dcm4che3.net.ApplicationEntity in project dcm4chee-arc-light by dcm4che.
the class StorageRS method getStorageSystems.
private List<StorageSystem> getStorageSystems() {
if (dicomAETitle != null) {
ApplicationEntity ae = device.getApplicationEntity(dicomAETitle, true);
if (ae == null || !ae.isInstalled()) {
LOG.info("Archive AE {} not provided by Device {}", dicomAETitle, device.getDeviceName());
return Collections.EMPTY_LIST;
}
}
List<StorageSystem> storageSystems = new ArrayList<>();
ArchiveDeviceExtension arcdev = device.getDeviceExtensionNotNull(ArchiveDeviceExtension.class);
arcdev.getStorageDescriptors().forEach(desc -> {
String storageID = desc.getStorageID();
Set<String> usages = new HashSet<>();
Set<String> aets = new HashSet<>();
if (StringUtils.contains(arcdev.getSeriesMetadataStorageIDs(), storageID))
usages.add("dcmSeriesMetadataStorageID");
for (ApplicationEntity ae : device.getApplicationEntities()) {
ArchiveAEExtension arcAE = ae.getAEExtension(ArchiveAEExtension.class);
if (arcAE == null) {
LOG.info("Archive AE Extension not configured for AE : {}", ae.getAETitle());
continue;
}
if (StringUtils.contains(arcAE.getObjectStorageIDs(), desc.getStorageID())) {
usages.add("dcmObjectStorageID");
aets.add(ae.getAETitle());
}
if (StringUtils.contains(arcAE.getMetadataStorageIDs(), desc.getStorageID())) {
usages.add("dcmMetadataStorageID");
aets.add(ae.getAETitle());
}
}
if ((dicomAETitle == null || aets.contains(dicomAETitle)) && (usage == null || usages.contains(usage)) && (storageClusterID == null || storageClusterID.equals(desc.getStorageClusterID())) && (uriScheme == null || desc.getStorageURI().getScheme().equals(uriScheme))) {
try (Storage storage = storageFactory.getStorage(desc)) {
long usableSpace = storage.getUsableSpace();
if (usableSpaceBelow == null || usableSpace < usableSpaceBelow) {
long totalSpace = storage.getTotalSpace();
storageSystems.add(new StorageSystem(desc, usableSpace, totalSpace, usages, aets));
}
} catch (IOException e) {
LOG.warn("Failed to access {}", desc, e);
}
}
});
storageSystems.sort(Comparator.comparing(storageSystem -> storageSystem.desc.getStorageID()));
return storageSystems;
}
use of org.dcm4che3.net.ApplicationEntity in project dcm4chee-arc-light by dcm4che.
the class StowRS method store.
private void store(AsyncResponse ar, InputStream in, final Input input, OutputType output) throws Exception {
ApplicationEntity ae = getApplicationEntity();
if (aet.equals(ae.getAETitle()))
validateWebApp();
ar.register((CompletionCallback) throwable -> purgeSpoolDirectory());
final StoreSession session = service.newStoreSession(HttpServletRequestInfo.valueOf(request), ae, aet, null);
new MultipartParser(boundary()).parse(new BufferedInputStream(in), (partNumber, multipartInputStream) -> {
Map<String, List<String>> headerParams = multipartInputStream.readHeaderParams();
LOG.info("storeInstances: Extract Part #{}{}", partNumber, headerParams);
String contentLocation = getHeaderParamValue(headerParams, "content-location");
String contentType = getHeaderParamValue(headerParams, "content-type");
MediaType mediaType = normalize(MediaType.valueOf(contentType));
try {
if (!input.readBodyPart(StowRS.this, session, multipartInputStream, mediaType, contentLocation)) {
LOG.info("{}: Ignore Part with Content-Type={}", session, mediaType);
multipartInputStream.skipAll();
}
} catch (JsonParsingException e) {
throw new WebApplicationException(errResponse(e.getMessage() + " at location : " + e.getLocation(), Response.Status.BAD_REQUEST));
} catch (Exception e) {
if (instances.size() == 1)
throw new WebApplicationException(errResponseAsTextPlain(exceptionAsString(e), Response.Status.INTERNAL_SERVER_ERROR));
else {
LOG.warn("Failed to process Part #" + partNumber + headerParams);
throw new WebApplicationException(errResponseAsTextPlain(exceptionAsString(e), Response.Status.INTERNAL_SERVER_ERROR));
}
}
});
int instanceNumber = 0;
for (Attributes instance : instances) storeDicomObject(session, instance, ++instanceNumber);
response.setString(Tag.RetrieveURL, VR.UR, retrieveURL());
Response.ResponseBuilder responseBuilder = Response.status(status());
ar.resume(responseBuilder.entity(output.entity(response, ae)).header("Warning", warning).build());
}
use of org.dcm4che3.net.ApplicationEntity in project dcm4chee-arc-light by dcm4che.
the class ArchiveDeviceConfigurationTest method testPersist.
@Test
public void testPersist() throws Exception {
ArchiveDeviceFactory.ConfigType configType = ArchiveDeviceFactory.ConfigType.valueOf(System.getProperty("configType", ArchiveDeviceFactory.ConfigType.DEFAULT.name()));
Device arrDevice = ArchiveDeviceFactory.createARRDevice(configType);
Device[] otherDevices = new Device[ArchiveDeviceFactory.OTHER_DEVICES.length];
EnumSet<DicomConfiguration.Option> register = EnumSet.of(DicomConfiguration.Option.REGISTER);
config.persist(arrDevice, register);
config.persist(otherDevices[0] = ArchiveDeviceFactory.createOtherDevice(0), register);
config.persist(ArchiveDeviceFactory.createStoreSCPDevice(), register);
config.persist(ArchiveDeviceFactory.createStowRSDevice(), register);
if (configType == ArchiveDeviceFactory.ConfigType.SAMPLE) {
for (int i = 1; i < ArchiveDeviceFactory.OTHER_DEVICES.length; i++) {
config.persist(otherDevices[i] = ArchiveDeviceFactory.createOtherDevice(i), register);
}
config.persist(ArchiveDeviceFactory.qualifyDevice(ArchiveDeviceFactory.createHL7Device("hl7rcv", ArchiveDeviceFactory.PIX_MANAGER, "localhost", 2576, 12576), "DSS", ArchiveDeviceFactory.SITE_A, ArchiveDeviceFactory.INST_A), register);
}
Device arc = ArchiveDeviceFactory.createArchiveDevice("dcm4chee-arc", configType, arrDevice, otherDevices[ArchiveDeviceFactory.SCHEDULED_STATION_INDEX], otherDevices[ArchiveDeviceFactory.STORESCU_INDEX], otherDevices[ArchiveDeviceFactory.MPPSSCU_INDEX]);
config.persist(arc, register);
Device keycloak = ArchiveDeviceFactory.createKeycloakDevice("keycloak", arrDevice, configType);
config.persist(keycloak, null);
ApplicationEntity ae = config.findApplicationEntity("DCM4CHEE");
assertNotNull(ae);
assertDeviceEquals(arc, ae.getDevice());
}
use of org.dcm4che3.net.ApplicationEntity 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