Skip to content

Commit

Permalink
Partial fix for 404 on missing entity
Browse files Browse the repository at this point in the history
There are two cases to handle.
This patch handles the case where the request has no flags
by validating entity graph to check external refs.

If the request is _view=with_metadata then we also have to run
a similar check. However, a number of existing test cases
currently fail because they (accidentally) use external items.

Partially addresses: #159
  • Loading branch information
der committed Jun 30, 2022
1 parent 9634584 commit 9c194af
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/main/java/com/epimorphics/registry/RegRun.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,8 @@ public static void main(String[] args) throws Exception {

tomcat.setBaseDir(".");

// String contextPath = "/registry"; // Use for local testing without nginx/apache front end reverse proxy
String contextPath = "/ldregistry";
String contextPath = "/registry"; // Use for local testing without nginx/apache front end reverse proxy
// String contextPath = "/ldregistry";

File rootF = new File(root);
if (!rootF.exists()) {
Expand Down
14 changes: 14 additions & 0 deletions src/main/java/com/epimorphics/registry/commands/CommandRead.java
Original file line number Diff line number Diff line change
Expand Up @@ -203,6 +203,20 @@ public Response doExecute() {
} else if (ri.getEntity() != null) {
m.add( ri.getEntity().getModel() );
}

// Full solution here would also apply this to the case where entityWithMetadata is set
// that's why the check is inject at this point.
// That full solution currently disabled due to test case issues.
// if (graphEntity || entityWithMetadata) {
if (graphEntity ) {
// Validate that the graph contains a matching entity definition with a type property.
// For both plain and graph registered entities this is enforced at registration time.
// If this is an external entity then the graph will not contain a matching root resource
// and we prefer to return a 404 in that case.
if ( ! m.getResource(target).hasProperty(RDF.type) ) {
throw new NotFoundException();
}
}
}

List<Resource> members = (paged) ? new ArrayList<Resource>(length) : new ArrayList<Resource>() ;
Expand Down

0 comments on commit 9c194af

Please sign in to comment.