Skip to content

Should we gracefully handle cases where servers do not support (even) shape tree auxiliary metadata? #46

@justinwb

Description

@justinwb

Currently we throw an exception when the client cannot discover a shapetree metadata auxiliary resource advertised by the solid server. Should clients gracefully handle these cases? Options would be:

  1. Don't do any validation at all - act like a normal client
  2. Use an alternative location, such as a general metadata auxiliary resource... Given the fact that our logic relies on the server providing link relations to locators, I'm not sure this would be feasible. If the server could be configured to do that, it could be configured to just do it properly in the first place.
  3. Halt and catch fire
@NotNull
public String getMetadataURI() throws IOException {
    if (!this.parsedLinkHeaders.containsKey(LinkRelations.SHAPETREE_LOCATOR.getValue())) {
        log.error("The resource {} does not contain a link header of {}", this.getUri(), LinkRelations.SHAPETREE_LOCATOR.getValue());
        // TODO: Should this be gracefully handled by the client?
        throw new ShapeTreeException(500, "No Link header with relation of " + LinkRelations.SHAPETREE_LOCATOR.getValue() + " found");
    }
    String metaDataURIString = this.parsedLinkHeaders.get(LinkRelations.SHAPETREE_LOCATOR.getValue()).stream().findFirst().orElse(null);
    if (metaDataURIString != null && metaDataURIString.startsWith("/")) {
        // If the header value doesn't include scheme/host, prefix it with the scheme & host from container
        URI shapeTreeContainerURI = this.getUri();
        String portFragment;
        if (shapeTreeContainerURI.getPort() > 0) {
            portFragment = ":" + shapeTreeContainerURI.getPort();
        } else {
            portFragment = "";
        }
        metaDataURIString = shapeTreeContainerURI.getScheme() + "://" + shapeTreeContainerURI.getHost() + portFragment + metaDataURIString;
    }

    if (metaDataURIString == null) {
        throw new ShapeTreeException(500, "No Link header with relation of " + LinkRelations.SHAPETREE_LOCATOR.getValue() + " found");
    }

    return metaDataURIString;
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions