Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions service/application.wadl
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@
<param name="longestonly" style="query" default="false" type="xsd:boolean"/>
<param name="csegments" style="query" default="false" type="xsd:boolean"/>

<param name="nodata" style="query" type="xsd:int" default="204">
<option value="204"/>
<option value="404"/>
</param>

<!-- Metrics may be appended with a logical operator -->
<param name="sample_rate" style="query" type="xsd:float"/>
<param name="record_length" style="query" type="xsd:float"/>
Expand Down
2 changes: 0 additions & 2 deletions service/configuration.json.sample
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
"NAME": "ODC-WFCATALOG",
"ARCHIVE": "ORFEUS ODC/KNMI",
"AGENT": "ObsPy mSEED-QC",
"VERSION": "1.0.1",
"VERSION_DATE": "2025.03.10",
"DOCUMENTATION_URI": "ENTER_URI_HERE",
"BASE_URL": "/eidaws/wfcatalog/1/",
"HOST": "127.0.0.1",
Expand Down
25 changes: 21 additions & 4 deletions service/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ module.exports = function (CONFIG, WFCatalogCallback) {
var WFCatalogger;
setupLogger();

const VERSION = "1.0.2"

// The service is powered by express
var WFCatalog = require("express")();

Expand Down Expand Up @@ -100,7 +102,7 @@ module.exports = function (CONFIG, WFCatalogCallback) {
*/
WFCatalog.get(CONFIG.BASE_URL + "version", function (req, res, next) {
res.setHeader("Content-Type", "text/plain");
res.status(200).send(CONFIG.VERSION);
res.status(200).send(VERSION);
});

/*
Expand Down Expand Up @@ -479,6 +481,7 @@ module.exports = function (CONFIG, WFCatalogCallback) {
format: "json",
include: "default",
gran: "day",
nodata: 204,
longestonly: getStringAsBoolean(req.WFCatalog.query.longestonly),
csegments: getStringAsBoolean(req.WFCatalog.query.csegments),
};
Expand Down Expand Up @@ -550,6 +553,20 @@ module.exports = function (CONFIG, WFCatalogCallback) {
delete req.WFCatalog.query.format;
}

// Check the nodata; only 204 or 404 are supported
if (req.WFCatalog.query.nodata) {
if (!["204", "404"].inArray(req.WFCatalog.query.nodata)) {
return sendErrorPage(
req,
res,
ERROR.NODATA_UNSUPPORTED,
req.WFCatalog.query.nodata
);
}
req.WFCatalog.options.nodata = parseInt(req.WFCatalog.query.nodata);
delete req.WFCatalog.query.nodata;
}

// If [minimumlength] or [longestonly] is specified
// include the continuous segments by default
if (
Expand Down Expand Up @@ -856,9 +873,9 @@ module.exports = function (CONFIG, WFCatalogCallback) {
return res.status(499).end();
}

// If no documents, return 204
// If no documents, return 204 or 404
if (!req.WFCatalog.nDocuments) {
return res.status(204).end();
return res.status(req.WFCatalog.options.nodata).end();
}

// Close JSON and celebrate a succesful request
Expand Down Expand Up @@ -1390,7 +1407,7 @@ module.exports = function (CONFIG, WFCatalogCallback) {
"Request Submitted:",
req.WFCatalog.requestSubmitted,
"Service Version:",
CONFIG.VERSION,
VERSION,
].join("\n");

return res.send(response);
Expand Down
3 changes: 2 additions & 1 deletion service/static/dbmap.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
"format": "format",
"longestonly": "longestonly",
"csegments": "csegments",
"include": "include"
"include": "include",
"nodata": "nodata"

}
4 changes: 4 additions & 0 deletions service/static/errors.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@
"code": 400,
"msg": "The requested granularity is not supported: %s"
},
"NODATA_UNSUPPORTED": {
"code": 400,
"msg": "The requested nodata is not supported: %s"
},
"INCLUDE_UNSUPPORTED": {
"code": 400,
"msg": "The requested include options is not supported: %s"
Expand Down
3 changes: 2 additions & 1 deletion service/static/types.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
"olen": "float",
"avail": "float",

"minlen": "float"
"minlen": "float",
"nodata": "int"

}
Loading