diff --git a/bindings/java/src/org/sleuthkit/datamodel/BlackboardArtifact.java b/bindings/java/src/org/sleuthkit/datamodel/BlackboardArtifact.java index 8bdd7e2cc3bf00bb41c8e33a2767d89bc0830e64..2a5de21e401a7d0ea6b8eb6ea6317ad43c035a8b 100644 --- a/bindings/java/src/org/sleuthkit/datamodel/BlackboardArtifact.java +++ b/bindings/java/src/org/sleuthkit/datamodel/BlackboardArtifact.java @@ -1202,6 +1202,8 @@ static public ARTIFACT_TYPE fromLabel(String label) { /** * Gets the artifact type enum value that corresponds to a given type * id. + * This method should only be used when the id is known to be one of the + * built-in types - otherwise use getArtifactType() in SleuthkitCase. * * @param id The type id. * diff --git a/bindings/java/src/org/sleuthkit/datamodel/SleuthkitCase.java b/bindings/java/src/org/sleuthkit/datamodel/SleuthkitCase.java index 4ec8b70f25abd82609df0467115369e6dfe0e860..b75f4b7cb1e31068ac184019fa1529f4de7f5eb1 100644 --- a/bindings/java/src/org/sleuthkit/datamodel/SleuthkitCase.java +++ b/bindings/java/src/org/sleuthkit/datamodel/SleuthkitCase.java @@ -7404,14 +7404,20 @@ List<Content> fileChildren(ResultSet rs, CaseDbConnection connection, long paren * * @throws SQLException Thrown if there is a problem iterating through the * result set. + * @throws TskCoreException Thrown if there is an error looking up the artifact type id */ - private List<BlackboardArtifact> resultSetToArtifacts(ResultSet rs) throws SQLException { + private List<BlackboardArtifact> resultSetToArtifacts(ResultSet rs) throws SQLException, TskCoreException { ArrayList<BlackboardArtifact> artifacts = new ArrayList<BlackboardArtifact>(); try { while (rs.next()) { - artifacts.add(new BlackboardArtifact(this, rs.getLong("artifact_id"), rs.getLong("obj_id"), rs.getLong("artifact_obj_id"), rs.getLong("data_source_obj_id"), - rs.getInt("artifact_type_id"), BlackboardArtifact.ARTIFACT_TYPE.fromID(rs.getInt("artifact_type_id")).getLabel(), BlackboardArtifact.ARTIFACT_TYPE.fromID(rs.getInt("artifact_type_id")).getDisplayName(), - BlackboardArtifact.ReviewStatus.withID(rs.getInt("review_status_id")))); + BlackboardArtifact.Type artifactType = getArtifactType(rs.getInt("artifact_type_id")); + if (artifactType != null) { + artifacts.add(new BlackboardArtifact(this, rs.getLong("artifact_id"), rs.getLong("obj_id"), rs.getLong("artifact_obj_id"), rs.getLong("data_source_obj_id"), + rs.getInt("artifact_type_id"), artifactType.getTypeName(), artifactType.getDisplayName(), + BlackboardArtifact.ReviewStatus.withID(rs.getInt("review_status_id")))); + } else { + throw new TskCoreException("Error looking up artifact type ID " + rs.getInt("artifact_type_id") + " from artifact " + rs.getLong("artifact_id")); + } } //end for each resultSet } catch (SQLException e) { logger.log(Level.SEVERE, "Error getting artifacts from result set", e); //NON-NLS