Skip to content

Commit 0ae5871

Browse files
committed
more cleanups and addressing feedback
1 parent c023387 commit 0ae5871

2 files changed

Lines changed: 18 additions & 8 deletions

File tree

src/firefly/java/edu/caltech/ipac/firefly/server/query/alert/AlertViewerSearchProcessor.java

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,23 @@ public String fetchData(ServerRequest req) throws DataAccessException {
6767
}
6868
final int responseCode = fileInfo.getResponseCode();
6969
if (responseCode > 305 || responseCode < 200) {
70-
final String responseMsg = StringUtils.isEmpty(fileInfo.getResponseCodeMsg())
70+
String responseMsg = StringUtils.isEmpty(fileInfo.getResponseCodeMsg())
7171
? "Unknown error"
7272
: fileInfo.getResponseCodeMsg();
73-
return makeError(source,
74-
"Unable to retrieve the FITS file: " + responseCode + " " + responseMsg);
73+
74+
String message = switch (responseCode) {
75+
case 400 -> "400 Bad Request: unknown query parameter, or malformed alert ID";
76+
case 401 -> "401 Unauthorized: missing or invalid token";
77+
case 404 -> "404 Not Found: no alert exists for the given ID";
78+
case 415 -> "415 Unsupported Media Type: unrecognised RESPONSEFORMAT value";
79+
case 500 -> "500 Internal Server Error: alert service internal error.";
80+
default -> "Unable to retrieve the FITS file: " + responseCode + " " + responseMsg;
81+
};
82+
83+
return makeError(source, message);
7584
}
7685

86+
7787
FileAnalysisReport report = FileAnalysis.analyze(fileInfo, Details, ANALYZER_ID, Collections.emptyMap());
7888
return makeSuccess(source, fileInfo, report);
7989
} catch (Exception e) {
@@ -169,9 +179,9 @@ private static String makeAlertServiceUrl(String alertId) throws DataAccessExcep
169179
throw new DataAccessException("Missing required property: " + ALERT_SERVICE_BASE_URL_PROP);
170180
}
171181
final String joiner = baseUrl.contains("?") ? "&" : "?";
172-
return baseUrl + joiner +
173-
ALERT_ID + "=" + URLEncoder.encode(alertId, StandardCharsets.UTF_8) + "&" +
174-
RESPONSEFORMAT + "=" + FITS_RESPONSE_FORMAT;
182+
return String.format("%s%s%s=%s&%s=%s",
183+
baseUrl, joiner, ALERT_ID, URLEncoder.encode(alertId, StandardCharsets.UTF_8),
184+
RESPONSEFORMAT, FITS_RESPONSE_FORMAT);
175185
}
176186

177187
private static JSONObject baseResponse(String source, boolean success, String message) {

src/firefly/js/apps/alertviewer/AlertResultView.jsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,12 @@ export function AlertResultView() {
8989
const fallbackTitle = fileName || source || 'Alert Viewer';
9090
const alertTitleDisplay = id ? (
9191
<Stack direction='row' spacing={1} alignItems='baseline' sx={{minWidth: 0}}>
92-
<Typography level='title-md' sx={{fontFamily: 'monospace'}} color='neutral'>
92+
<Typography level='title-md'>
9393
Alert ID: {id}
9494
</Typography>
9595
</Stack>
9696
) : (
97-
<Typography level='title-md' sx={{fontFamily: 'monospace'}}>
97+
<Typography level='body-md'>
9898
{fallbackTitle}
9999
</Typography>
100100
);

0 commit comments

Comments
 (0)