You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@jena.apache.org by an...@apache.org on 2016/07/21 12:43:27 UTC

[3/3] jena git commit: JENA-1213: Test whether the root is a subject at all.

JENA-1213: Test whether the root is a subject at all.


Project: http://git-wip-us.apache.org/repos/asf/jena/repo
Commit: http://git-wip-us.apache.org/repos/asf/jena/commit/9d7e822b
Tree: http://git-wip-us.apache.org/repos/asf/jena/tree/9d7e822b
Diff: http://git-wip-us.apache.org/repos/asf/jena/diff/9d7e822b

Branch: refs/heads/master
Commit: 9d7e822ba0ebf694a348e2201869057ac6fe8b6c
Parents: 08d8de7
Author: Andy Seaborne <an...@apache.org>
Authored: Thu Jul 21 13:43:00 2016 +0100
Committer: Andy Seaborne <an...@apache.org>
Committed: Thu Jul 21 13:43:00 2016 +0100

----------------------------------------------------------------------
 .../jena/assembler/assemblers/AssemblerGroup.java    | 15 ++++++++++++++-
 1 file changed, 14 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/jena/blob/9d7e822b/jena-core/src/main/java/org/apache/jena/assembler/assemblers/AssemblerGroup.java
----------------------------------------------------------------------
diff --git a/jena-core/src/main/java/org/apache/jena/assembler/assemblers/AssemblerGroup.java b/jena-core/src/main/java/org/apache/jena/assembler/assemblers/AssemblerGroup.java
index 02d21ca..8f478d4 100644
--- a/jena-core/src/main/java/org/apache/jena/assembler/assemblers/AssemblerGroup.java
+++ b/jena-core/src/main/java/org/apache/jena/assembler/assemblers/AssemblerGroup.java
@@ -109,8 +109,21 @@ public abstract class AssemblerGroup extends AssemblerBase implements Assembler
         @Override public Object open( Assembler a, Resource root, Mode mode )
             {
             Set <Resource>types = AssemblerHelp.findSpecificTypes( root, JA.Object );
-            if (types.size() == 0)
+            if (types.size() == 0) {
+                // Does it exist as a subject in the model? Mistyped?
+                boolean noSuchSubject = ! root.listProperties().hasNext() ;
+                if ( noSuchSubject ) {
+                    String s ;
+                    if ( root.isURIResource() )
+                        s = "<"+root.getURI()+">" ;
+                    else if ( root.isAnon() )
+                        s = "_:"+root.getId() ;
+                    else
+                        s = String.valueOf(root) ;
+                    throw new AssemblerException(root, "Can't find "+s+" as a subject") ;
+                }
                 throw new NoSpecificTypeException( root );
+            }
             else if (types.size() > 1)
                 throw new AmbiguousSpecificTypeException( root, new ArrayList<>( types ) );
             else