use of org.dcm4chee.arc.conf.AttributeSet in project dcm4chee-arc-light by dcm4che.
the class QueryAttributeSets method listAttributeSets.
@GET
@NoCache
@Path("/{type}")
@Produces("application/json")
public Response listAttributeSets(@PathParam("type") String type) {
logRequest();
try {
ArchiveDeviceExtension arcDev = device.getDeviceExtensionNotNull(ArchiveDeviceExtension.class);
final AttributeSet.Type attrSetType = AttributeSet.Type.valueOf(type);
return Response.ok((StreamingOutput) out -> {
JsonGenerator gen = Json.createGenerator(out);
gen.writeStartArray();
for (AttributeSet attrSet : sortedAttributeSets(arcDev.getAttributeSet(attrSetType))) {
JsonWriter writer = new JsonWriter(gen);
gen.writeStartObject();
writer.writeNotNullOrDef("type", attrSet.getType().name(), null);
writer.writeNotNullOrDef("id", attrSet.getID(), null);
writer.writeNotNullOrDef("description", attrSet.getDescription(), null);
writer.writeNotNullOrDef("title", attrSet.getTitle(), null);
attrSet.getProperties().forEach((key, value) -> writer.writeNotNullOrDef(key, value, null));
gen.writeEnd();
}
gen.writeEnd();
gen.flush();
}).build();
} catch (IllegalStateException e) {
return errResponse(e.getMessage(), Response.Status.NOT_FOUND);
} catch (IllegalArgumentException e) {
return errResponse("Attribute Set of type : " + type + " not found.", Response.Status.NOT_FOUND);
} catch (Exception e) {
return errResponseAsTextPlain(exceptionAsString(e), Response.Status.INTERNAL_SERVER_ERROR);
}
}
Aggregations