From: <rv...@us...> - 2010-06-22 15:02:40
|
Revision: 723 http://treebase.svn.sourceforge.net/treebase/?rev=723&view=rev Author: rvos Date: 2010-06-22 15:02:32 +0000 (Tue, 22 Jun 2010) Log Message: ----------- Apparently there are situations where the list with authors has null elements in it. This probably due to some inconsistency in the database, but it was causing null pointer exceptions in the code here. I've coded more defensively to take this possibility into account. Modified Paths: -------------- trunk/treebase-core/src/main/java/org/cipres/treebase/domain/study/Citation.java Modified: trunk/treebase-core/src/main/java/org/cipres/treebase/domain/study/Citation.java =================================================================== --- trunk/treebase-core/src/main/java/org/cipres/treebase/domain/study/Citation.java 2010-06-16 15:01:17 UTC (rev 722) +++ trunk/treebase-core/src/main/java/org/cipres/treebase/domain/study/Citation.java 2010-06-22 15:02:32 UTC (rev 723) @@ -482,13 +482,13 @@ if (size > 0) { for (int i = 0; i < size; i++) { - - authorsCitationStyle.append(authors.get(i).getFullNameCitationStyle()); - - if (size > 1 && i == size - 2) { - authorsCitationStyle.append(", & "); - } else if (size > 1 && i < size - 2) { - authorsCitationStyle.append(", "); + if ( null != authors.get(i) ) { + authorsCitationStyle.append(authors.get(i).getFullNameCitationStyle()); + if (size > 1 && i == size - 2) { + authorsCitationStyle.append(", & "); + } else if (size > 1 && i < size - 2) { + authorsCitationStyle.append(", "); + } } } @@ -510,12 +510,14 @@ int size = authors.size(); if (size > 0) { for ( int i = 0; i < size; i++ ) { - authorsCitationStyle.append(authors.get(i).getFullNameCitationStyle()); - if ( size > 1 && i == size - 2 ) { - authorsCitationStyle.append(", & "); - } - else if (size > 1 && i < size - 2) { - authorsCitationStyle.append(", "); + if ( null != authors.get(i) ) { + authorsCitationStyle.append(authors.get(i).getFullNameCitationStyle()); + if ( size > 1 && i == size - 2 ) { + authorsCitationStyle.append(", & "); + } + else if (size > 1 && i < size - 2) { + authorsCitationStyle.append(", "); + } } } } @@ -696,8 +698,10 @@ annotations.add(new Annotation(Constants.DCURI,"dc:title",getTitle())); annotations.add(new Annotation(Constants.DCURI,"dc:creator",getAuthorsAsString())); for ( Person person : getAuthors() ) { - String personName = person.getFullNameCitationStyle(); - annotations.add(new Annotation(Constants.DCURI,"dc:contributor",personName)); + if ( null != person ) { + String personName = person.getFullNameCitationStyle(); + annotations.add(new Annotation(Constants.DCURI,"dc:contributor",personName)); + } } try { if ( null != getPublishYear() ) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |