Created
May 2, 2011 18:11
-
-
Save peterdietz/952058 to your computer and use it in GitHub Desktop.
Fixing NPE when viewing a community on the DSpace REST API
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
Index: src/main/java/org/dspace/rest/entities/CommunityEntity.java | |
=================================================================== | |
--- src/main/java/org/dspace/rest/entities/CommunityEntity.java (revision 6356) | |
+++ src/main/java/org/dspace/rest/entities/CommunityEntity.java (working copy) | |
@@ -118,7 +118,17 @@ | |
this.subCommunities.add(includeFull ? new CommunityEntity(c, level, uparams) : new CommunityEntityId(c)); | |
} | |
try { | |
- this.parent = includeFull ? new CommunityEntity(res.getParentCommunity(), level, uparams) : new CommunityEntityId(res.getParentCommunity()); | |
+ Community parentCommunity = res.getParentCommunity(); | |
+ if(parentCommunity == null) { | |
+ this.parent = null; | |
+ } else { | |
+ if(includeFull) { | |
+ this.parent = new CommunityEntity(parentCommunity, level, uparams); | |
+ } else { | |
+ this.parent = new CommunityEntityId(parentCommunity); | |
+ } | |
+ } | |
+ | |
} catch (NullPointerException ex) { | |
this.parent = null; | |
} | |
@@ -131,7 +141,16 @@ | |
} catch (RecentSubmissionsException ex) { | |
} | |
- this.administrators = includeFull ? new GroupEntity(res.getAdministrators(), level, uparams) : new GroupEntityId(res.getAdministrators()); | |
+ Group administrators = res.getAdministrators(); | |
+ if(administrators == null) { | |
+ this.administrators = null; | |
+ } else { | |
+ if(includeFull) { | |
+ this.administrators = new GroupEntity(res.getAdministrators(), level, uparams); | |
+ } else { | |
+ this.administrators = new GroupEntityId(res.getAdministrators()); | |
+ } | |
+ } | |
} catch (NumberFormatException ex) { | |
} | |
//context.complete(); //<-important |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment