Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Support Hash URIs within resources
- Loading branch information
Showing
10 changed files
with
130 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
fcrepo-kernel-impl/src/main/java/org/fcrepo/kernel/impl/identifiers/HashConverter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
package org.fcrepo.kernel.impl.identifiers; | ||
|
||
import org.fcrepo.kernel.identifiers.InternalIdentifierConverter; | ||
|
||
/** | ||
* @author cabeer | ||
* @since 10/9/14 | ||
*/ | ||
public class HashConverter extends InternalIdentifierConverter { | ||
|
||
@Override | ||
protected String doForward(final String externalId) { | ||
return externalId.replace("#", "/#"); | ||
} | ||
|
||
@Override | ||
protected String doBackward(final String internalId) { | ||
return internalId.replace("/#", "#"); | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
fcrepo-kernel-impl/src/main/java/org/fcrepo/kernel/impl/rdf/impl/HashRdfContext.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package org.fcrepo.kernel.impl.rdf.impl; | ||
|
||
import com.google.common.base.Function; | ||
import com.google.common.collect.Iterators; | ||
import com.hp.hpl.jena.graph.Triple; | ||
import com.hp.hpl.jena.rdf.model.Resource; | ||
import org.fcrepo.kernel.exception.RepositoryRuntimeException; | ||
import org.fcrepo.kernel.identifiers.IdentifierConverter; | ||
import org.fcrepo.kernel.utils.iterators.NodeIterator; | ||
|
||
import javax.jcr.Node; | ||
import javax.jcr.RepositoryException; | ||
import java.util.Collection; | ||
import java.util.Iterator; | ||
|
||
/** | ||
* @author cabeer | ||
* @since 10/9/14 | ||
*/ | ||
public class HashRdfContext extends NodeRdfContext { | ||
|
||
|
||
/** | ||
* Default constructor. | ||
* | ||
* @param node | ||
* @param graphSubjects | ||
* @throws javax.jcr.RepositoryException | ||
*/ | ||
public HashRdfContext(final Node node, final IdentifierConverter<Resource, Node> graphSubjects) | ||
throws RepositoryException { | ||
super(node, graphSubjects); | ||
|
||
|
||
concat(Iterators.concat(Iterators.transform(new NodeIterator(node().getNodes("#*")), new Function<Node, Iterator<Triple>>() { | ||
@Override | ||
public Iterator<Triple> apply(final Node input) { | ||
try { | ||
return new PropertiesRdfContext(node, graphSubjects); | ||
} catch (final RepositoryException e) { | ||
throw new RepositoryRuntimeException(e); | ||
} | ||
} | ||
}))); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters