use of org.dcm4che3.json.JSONReader in project dcm4chee-arc-light by dcm4che.
the class StoreServiceEJB method restoreInstances.
private void restoreInstances(StoreSession session, Series series, String studyUID, Duration duration, List<Instance> instList) throws DicomServiceException {
if (series == null || series.getInstancePurgeState() == Series.InstancePurgeState.NO)
return;
LOG.info("Restore Instance records of Series[pk={}]", series.getPk());
Metadata metadata = series.getMetadata();
try (ZipInputStream zip = session.getStoreService().openZipInputStream(session, metadata.getStorageID(), metadata.getStoragePath(), studyUID)) {
ZipEntry entry;
while ((entry = zip.getNextEntry()) != null) {
JSONReader jsonReader = new JSONReader(Json.createParser(new InputStreamReader(zip, StandardCharsets.UTF_8)));
jsonReader.setSkipBulkDataURI(true);
Instance inst = restoreInstance(session, series, jsonReader.readDataset(null));
if (instList != null)
instList.add(inst);
}
} catch (IOException e) {
LOG.warn("Failed to restore Instance records of Series[pk={}]", series.getPk(), e);
throw new DicomServiceException(Status.ProcessingFailure, e);
}
series.setInstancePurgeState(Series.InstancePurgeState.NO);
series.scheduleInstancePurge(duration);
}
use of org.dcm4che3.json.JSONReader in project dcm4chee-arc-light by dcm4che.
the class PurgeStorageScheduler method instancesNotStoredOnOtherStorage.
private static int instancesNotStoredOnOtherStorage(ReadContext ctx, String storageID, String[] exportStorageID) {
int count = 0;
LOG.debug("Read Metadata {} from {}", ctx.getStoragePath(), ctx.getStorage().getStorageDescriptor());
try (InputStream in = ctx.getStorage().openInputStream(ctx)) {
ZipInputStream zip = new ZipInputStream(in);
while (zip.getNextEntry() != null) {
JSONReader jsonReader = new JSONReader(Json.createParser(new InputStreamReader(zip, "UTF-8")));
Attributes metadata = jsonReader.readDataset(null);
if (containsStorageID(metadata, PurgeStorageScheduler::matchStorageID, storageID) && !containsStorageID(metadata, PurgeStorageScheduler::matchStorageIDAndCheckStatus, exportStorageID))
count++;
zip.closeEntry();
}
} catch (Exception e) {
LOG.error("Failed to read Metadata {} from {}", ctx.getStoragePath(), ctx.getStorage().getStorageDescriptor());
count++;
}
return count;
}
use of org.dcm4che3.json.JSONReader in project Weasis by nroduit.
the class RsQueryResult method parseJSON.
public static List<Attributes> parseJSON(String url, AuthMethod authMethod, URLParameters urlParameters) throws Exception {
List<Attributes> items = new ArrayList<>();
try (HttpResponse response = NetworkUtil.getHttpResponse(url, urlParameters, authMethod);
InputStreamReader instream = new InputStreamReader(response.getInputStream(), StandardCharsets.UTF_8)) {
int code = response.getResponseCode();
if (code == HttpURLConnection.HTTP_OK || code == HttpURLConnection.HTTP_PARTIAL) {
JSONReader reader = new JSONReader(Json.createParser(instream));
Callback callback = (fmi, dataset) -> items.add(dataset);
reader.readDatasets(callback);
}
if (code == HttpURLConnection.HTTP_ENTITY_TOO_LARGE) {
throw new IllegalStateException("The size of the results exceeds the maximum payload size supported by the origin server.");
} else if (authMethod != null && code == HttpURLConnection.HTTP_UNAUTHORIZED) {
authMethod.resetToken();
authMethod.getToken();
}
}
return items;
}
use of org.dcm4che3.json.JSONReader in project dcm4che by dcm4che.
the class JsonImageWriterConfiguration method loadDeviceExtension.
@Override
public boolean loadDeviceExtension(Device device, JsonReader reader, ConfigurationDelegate config) {
if (!reader.getString().equals("dcmImageWriter"))
return false;
ImageWriterFactory factory = new ImageWriterFactory();
reader.next();
reader.expect(JsonParser.Event.START_ARRAY);
while (reader.next() == JsonParser.Event.START_OBJECT) {
String tsuid = null;
String formatName = null;
String className = null;
String patchJPEGLS = null;
String[] imageWriteParam = {};
while (reader.next() == JsonParser.Event.KEY_NAME) {
switch(reader.getString()) {
case "dicomTransferSyntax":
tsuid = reader.stringValue();
break;
case "dcmIIOFormatName":
formatName = reader.stringValue();
break;
case "dcmJavaClassName":
className = reader.stringValue();
break;
case "dcmPatchJPEGLS":
patchJPEGLS = reader.stringValue();
break;
case "dcmImageWriteParam":
imageWriteParam = reader.stringArray();
break;
default:
reader.skipUnknownProperty();
}
}
reader.expect(JsonParser.Event.END_OBJECT);
factory.put(tsuid, new ImageWriterFactory.ImageWriterParam(formatName, className, patchJPEGLS, imageWriteParam));
}
device.addDeviceExtension(new ImageWriterExtension(factory));
return true;
}
use of org.dcm4che3.json.JSONReader in project dcm4che by dcm4che.
the class JsonAuditLoggerConfiguration method loadDeviceExtension.
@Override
public boolean loadDeviceExtension(Device device, JsonReader reader, ConfigurationDelegate config) throws ConfigurationException {
if (!reader.getString().equals("dcmAuditLogger"))
return false;
AuditLoggerDeviceExtension ext = new AuditLoggerDeviceExtension();
loadFrom(ext, reader, device.listConnections(), config);
device.addDeviceExtension(ext);
return true;
}
Aggregations