Skip to content

Commit

Permalink
Add resource path header for exposed services
Browse files Browse the repository at this point in the history
To facilitate services that might need a Fedora resource *path*, rather
than a URI, a new header Apix-Ldp-Resource-Path has been added
  • Loading branch information
birkland authored and emetsger committed Nov 8, 2016
1 parent f6e6166 commit 254723f
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ public interface Routing {
/** Fedora repository resource relevant to a resource-scoped exposed service */
public static final String HTTP_HEADER_REPOSITORY_RESOURCE_URI = "Apix-Ldp-Resource";

/** Fedora repository resource path relevant to a resource-scoped exposed service */
public static final String HTTP_HEADER_REPOSITORY_RESOURCE_PATH = "Apix-Ldp-Resource-Path";

/** Repository or resource-scoped exposed service URI */
public static final String HTTP_HEADER_EXPOSED_SERVICE_URI = "Apix-Exposed-Uri";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,7 @@ public ServiceExposingBinding match(final URI requestURI) {
extension,
resourcePath != null ? append(fcrepoBaseURI, resourcePath) : null,
exposedServiceURI,
resourcePath,
requestURI.toString().replace(exposedServiceURI.toString(), ""));

} else {
Expand All @@ -206,6 +207,8 @@ public class ServiceExposingBinding {

public String additionalPath;

public String resourcePath;

/**
* Create a concrete binding
*
Expand All @@ -215,11 +218,13 @@ public class ServiceExposingBinding {
* @param additionalPath Additional path segments from request.
*/
public ServiceExposingBinding(final Extension extension, final URI resource, final URI exposed,
final String resourcePath,
final String additionalPath) {
this.extension = extension;
this.repositoryResourceURI = resource;
this.baseURI = exposed;
this.additionalPath = additionalPath;
this.resourcePath = resourcePath;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package org.fcrepo.apix.routing.impl;

import static org.fcrepo.apix.model.components.Routing.HTTP_HEADER_EXPOSED_SERVICE_URI;
import static org.fcrepo.apix.model.components.Routing.HTTP_HEADER_REPOSITORY_RESOURCE_PATH;
import static org.fcrepo.apix.model.components.Routing.HTTP_HEADER_REPOSITORY_RESOURCE_URI;
import static org.fcrepo.apix.model.components.Routing.HTTP_HEADER_REPOSITORY_ROOT_URI;
import static org.fcrepo.apix.routing.Util.append;
Expand Down Expand Up @@ -228,6 +229,7 @@ public void configure() throws Exception {
// resource URI is only conveyed for resource-scope services
if (Scope.RESOURCE.equals(binding.extension.exposed().scope())) {
ex.getIn().setHeader(HTTP_HEADER_REPOSITORY_RESOURCE_URI, binding.repositoryResourceURI);
ex.getIn().setHeader(HTTP_HEADER_REPOSITORY_RESOURCE_PATH, binding.resourcePath);
} else {
ex.getIn().setHeader(HTTP_HEADER_REPOSITORY_ROOT_URI, fcrepoBaseURI);
}
Expand Down

0 comments on commit 254723f

Please sign in to comment.