Redirect warning in compaction
This commit is contained in:
+15
-22
@@ -34,29 +34,22 @@ public class JsonLDCompactionProve extends Probe<Credential> {
|
||||
|
||||
@Override
|
||||
public ReportItems run(Credential crd, RunContext ctx) throws Exception {
|
||||
try {
|
||||
// compact JSON
|
||||
JsonDocument jsonDocument = JsonDocument.of(new StringReader(crd.getJson().toString()));
|
||||
CompactionApi compactApi = JsonLd.compact(jsonDocument, context);
|
||||
compactApi.options(new JsonLdOptions(new CachingDocumentLoader(localDomains)));
|
||||
JsonObject compactedObject = compactApi.get();
|
||||
try {
|
||||
// compact JSON
|
||||
JsonDocument jsonDocument = JsonDocument.of(new StringReader(crd.getJson().toString()));
|
||||
CompactionApi compactApi = JsonLd.compact(jsonDocument, context);
|
||||
compactApi.options(new JsonLdOptions(new CachingDocumentLoader(localDomains)));
|
||||
JsonObject compactedObject = compactApi.get();
|
||||
|
||||
// TODO: Handle mismatch between URL node source and declared ID.
|
||||
if (compactedObject.get("id") != null && crd.getResource().getID() != null
|
||||
&& !compactedObject.get("id").toString().equals(crd.getResource().getID())) {
|
||||
|
||||
// TODO: warning!!
|
||||
// report_message(
|
||||
// "Node fetched from source {} declared its id as {}".format(
|
||||
// task_meta['node_id'], node_id), MESSAGE_LEVEL_WARNING, success=False
|
||||
// ),
|
||||
|
||||
}
|
||||
return success(this, ctx);
|
||||
|
||||
} catch (Exception e) {
|
||||
return fatal("Error while parsing credential: " + e.getMessage(), ctx);
|
||||
}
|
||||
// Handle mismatch between URL node source and declared ID.
|
||||
if (compactedObject.get("id") != null && crd.getResource().getID() != null
|
||||
&& !compactedObject.get("id").toString().equals(crd.getResource().getID())) {
|
||||
return warning("Node fetched from source " + crd.getResource().getID() + " declared its id as " + compactedObject.get("id").toString(), ctx);
|
||||
}
|
||||
return success(this, ctx);
|
||||
} catch (Exception e) {
|
||||
return fatal("Error while parsing credential: " + e.getMessage(), ctx);
|
||||
}
|
||||
}
|
||||
|
||||
public static final String ID = JsonLDCompactionProve.class.getSimpleName();
|
||||
|
||||
Reference in New Issue
Block a user