Skip to content

Commit

Permalink
add guard for non-literal titles
Browse files Browse the repository at this point in the history
  • Loading branch information
acoburn committed Nov 3, 2015
1 parent 9d28989 commit a9d945c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 1 deletion.
Expand Up @@ -212,7 +212,10 @@ public String getObjectTitle(final Graph graph, final Node subject) {
final Iterator<Triple> objects = getObjects(graph, subject, p);

if (objects.hasNext()) {
return objects.next().getObject().getLiteral().getLexicalForm();
final Node object = objects.next().getObject();
if (object.isLiteral()) {
return object.getLiteral().getLexicalForm();
}
}
}

Expand Down
Expand Up @@ -250,6 +250,7 @@ private void shouldExtractTitleFromNode( final Property property ) {
@Test
public void shouldUseTheObjectUriIfATitleIsNotAvailable() {
final Graph mem = createDefaultModel().getGraph();
mem.add(new Triple(createURI("a/b/c"), DC_TITLE.asNode(), createURI("d/e/f")));

assertEquals("a/b/c", testObj.getObjectTitle(mem, createURI("a/b/c")));

Expand Down

0 comments on commit a9d945c

Please sign in to comment.