Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Updating DefaultIdentifierTranslator to make it usable by audit service
  • Loading branch information
escowles committed Apr 23, 2015
1 parent 48610ce commit d9cc048
Showing 1 changed file with 12 additions and 7 deletions.
Expand Up @@ -51,18 +51,23 @@ public class DefaultIdentifierTranslator extends IdentifierConverter<Resource, F

private static final NodeResourceConverter nodeResourceConverter = new NodeResourceConverter();

/**
* Default namespace to use for node URIs
*/
public static final String RESOURCE_NAMESPACE = "info:fedora/";
private final String resourceNamespace;
private final Session session;

/**
* Construct the graph with a placeholder context resource
* @param session the session
*/
public DefaultIdentifierTranslator(final Session session) {
this(session, "info:fedora/");
}

/**
* Construct the graph with the provided resource namespace.
**/
public DefaultIdentifierTranslator(final Session session, final String resourceNamespace) {
this.session = session;
this.resourceNamespace = resourceNamespace;
setTranslationChain();
}

Expand Down Expand Up @@ -109,7 +114,7 @@ protected Resource doBackward(final FedoraResource resource) {

@Override
public boolean inDomain(final Resource subject) {
return subject.isURIResource() && subject.getURI().startsWith(RESOURCE_NAMESPACE);
return subject.isURIResource() && subject.getURI().startsWith(resourceNamespace);
}

@Override
Expand All @@ -121,7 +126,7 @@ public Resource toDomain(final String absPath) {
} else {
relativePath = absPath;
}
return createResource(RESOURCE_NAMESPACE + reverse.convert(relativePath));
return createResource(resourceNamespace + reverse.convert(relativePath));
}

@Override
Expand All @@ -130,7 +135,7 @@ public String asString(final Resource subject) {
return null;
}

final String path = subject.getURI().substring(RESOURCE_NAMESPACE.length() - 1);
final String path = subject.getURI().substring(resourceNamespace.length() - 1);

final String absPath = forward.convert(path);

Expand Down

0 comments on commit d9cc048

Please sign in to comment.