Skip to content

Commit 06a462e

Browse files
committed
Add docs, better function names, and less logging
1 parent e909ffc commit 06a462e

File tree

4 files changed

+31
-16
lines changed

4 files changed

+31
-16
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ image region microservice server endpoint::
112112
...
113113

114114

115-
location ~ ^/(webclient|webgateway)/(render_(thumbnail_ngff|image|image_region|image_region_rdef|image_rdef|shape_mask)|get_thumbnails_ngff|histogram_json)/ {
115+
location ~ ^/(webclient|webgateway)/(render_(thumbnail_ngff|image|image_region|image_region_rdef|image_rdef|shape_mask)|get_thumbnails_ngff|histogram_json|annotation)/ {
116116
proxy_pass http://image_region_backend;
117117
}
118118

src/main/java/com/glencoesoftware/omero/ms/image/region/AnnotationRequestHandler.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,13 @@ public AnnotationRequestHandler(
5757
this.annotationCtx = annotationCtx;
5858
}
5959

60+
/**
61+
* Queries the database for the file metadata assiciated with the
62+
* {@link OriginalFile} associated with the given {@link FileAnnotation}
63+
* @param client OMERO client
64+
* @return JsonObject with the {@link OriginalFile} ID and file name if
65+
* present, otherwise null
66+
*/
6067
public JsonObject getFileIdAndNameForAnnotation(omero.client client) {
6168
Map<String, String> ctx = new HashMap<String, String>();
6269
ctx.put("omero.group", "-1");
@@ -74,7 +81,6 @@ public JsonObject getFileIdAndNameForAnnotation(omero.client client) {
7481
if (rows.isEmpty()) {
7582
return null;
7683
}
77-
log.info(rows.get(0).toString());
7884
JsonObject retObj = new JsonObject();
7985
retObj.put("originalFileId", ((RLong) rows.get(0).get(0)).getValue());
8086
retObj.put("originalFileName", ((RString) rows.get(0).get(1)).getValue());

src/main/java/com/glencoesoftware/omero/ms/image/region/ImageRegionMicroserviceVerticle.java

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -351,7 +351,7 @@ public void deploy(JsonObject config, Promise<Void> prom) {
351351
// Annotation Download
352352
router.get(
353353
"/webclient/annotation/:annotationId")
354-
.handler(this::getFileAnnotation);
354+
.handler(this::downloadFileAnnotation);
355355

356356
// ImageData request handlers
357357
router.get("/webgateway/imgData/:imageId/:keys*").handler(this::getImageData);
@@ -744,7 +744,7 @@ private void getImageData(RoutingContext event) {
744744
}
745745
imageDataCtx.injectCurrentTraceContext();
746746
vertx.eventBus().<JsonObject>request(
747-
ImageRegionVerticle.GET_IMAGE_DATA,
747+
ImageRegionVerticle.GET_IMAGE_DATA_EVENT,
748748
Json.encode(imageDataCtx), result -> {
749749
String chunk = "";
750750
try {
@@ -827,7 +827,7 @@ private void getHistogramJson(RoutingContext event) {
827827
}
828828
histogramCtx.injectCurrentTraceContext();
829829
vertx.eventBus().<JsonObject>request(
830-
ImageRegionVerticle.GET_HISTOGRAM_JSON,
830+
ImageRegionVerticle.GET_HISTOGRAM_JSON_EVENT,
831831
Json.encode(histogramCtx), result -> {
832832
final HttpServerResponse response = event.response();
833833
try {
@@ -944,8 +944,12 @@ private void getThumbnails(RoutingContext event) {
944944
});
945945
}
946946

947-
private void getFileAnnotation(RoutingContext event) {
948-
log.info("Get File Annotation");
947+
/**
948+
* Downloads the {@link OriginalFile} associated with the given
949+
* {@link FileAnnotation}
950+
* @param event Current routing context
951+
*/
952+
private void downloadFileAnnotation(RoutingContext event) {
949953
HttpServerRequest request = event.request();
950954
HttpServerResponse response = event.response();
951955
final AnnotationCtx annotationCtx;
@@ -960,7 +964,7 @@ private void getFileAnnotation(RoutingContext event) {
960964
}
961965
annotationCtx.injectCurrentTraceContext();
962966
vertx.eventBus().<JsonObject>request(
963-
ImageRegionVerticle.GET_FILE_ANNOTATION_EVENT,
967+
ImageRegionVerticle.GET_FILE_ANNOTATION_METADATA_EVENT,
964968
Json.encode(annotationCtx), new Handler<AsyncResult<Message<JsonObject>>>() {
965969
@Override
966970
public void handle(AsyncResult<Message<JsonObject>> result) {

src/main/java/com/glencoesoftware/omero/ms/image/region/ImageRegionVerticle.java

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,13 @@ public class ImageRegionVerticle extends OmeroMsAbstractVerticle {
6767
public static final String GET_THUMBNAILS_EVENT =
6868
"omero.get_thumbnails";
6969

70-
public static final String GET_IMAGE_DATA =
70+
public static final String GET_IMAGE_DATA_EVENT =
7171
"omero.get_image_data";
7272

73-
public static final String GET_HISTOGRAM_JSON =
73+
public static final String GET_HISTOGRAM_JSON_EVENT =
7474
"omero.get_histogram_json";
7575

76-
public static final String GET_FILE_ANNOTATION_EVENT =
76+
public static final String GET_FILE_ANNOTATION_METADATA_EVENT =
7777
"omero.get_file_annotation";
7878

7979
/** OMERO server host */
@@ -146,11 +146,11 @@ public void start(Promise<Void> startPromise) {
146146
vertx.eventBus().<String>consumer(
147147
GET_THUMBNAILS_EVENT, this::getThumbnails);
148148
vertx.eventBus().<String>consumer(
149-
GET_IMAGE_DATA, this::getImageData);
149+
GET_IMAGE_DATA_EVENT, this::getImageData);
150150
vertx.eventBus().<String>consumer(
151-
GET_HISTOGRAM_JSON, this::getHistogramJson);
151+
GET_HISTOGRAM_JSON_EVENT, this::getHistogramJson);
152152
vertx.eventBus().<String>consumer(
153-
GET_FILE_ANNOTATION_EVENT, this::getFileAnnotation);
153+
GET_FILE_ANNOTATION_METADATA_EVENT, this::getFileAnnotationMetadata);
154154
} catch (Exception e) {
155155
startPromise.fail(e);
156156
}
@@ -494,7 +494,13 @@ private void getHistogramJson(Message<String> message) {
494494
});
495495
}
496496

497-
private void getFileAnnotation(Message<String> message) {
497+
/**
498+
* Gets the file name and path of the {@link OriginalFile} associated with
499+
* A given {@link FileAnnotation} and returns them as JSON
500+
* @param message JSON-encoded event data. Required keys are
501+
* <code>omeroSessionKey</code> (String) and <code>annotationId</code>
502+
*/
503+
private void getFileAnnotationMetadata(Message<String> message) {
498504
ObjectMapper mapper = new ObjectMapper();
499505
AnnotationCtx annotationCtx;
500506
try {
@@ -524,7 +530,6 @@ private void getFileAnnotation(Message<String> message) {
524530
} catch (PermissionDeniedException
525531
| CannotCreateSessionException e) {
526532
String v = "Permission denied";
527-
log.debug(v);
528533
message.fail(403, v);
529534
} catch (Exception e) {
530535
String v = "Exception while getting annotation";

0 commit comments

Comments
 (0)