Skip to content

Commit

Permalink
Merge pull request #344 from wcmc-its/exception_error_hotfix
Browse files Browse the repository at this point in the history
Exception error hotfix
  • Loading branch information
paulalbert1 authored May 17, 2019
2 parents 387dcf0 + 998a220 commit ed91318
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ public double executeStrategy(List<ReCiterArticle> reCiterArticles, Identity ide
for(Integer afid: matchingAfids) {
TargetAuthorScopusAffiliation scopusAffiliationEvidence = new TargetAuthorScopusAffiliation();
if(reCiterArticle.getScopusArticle().getAffiliations() != null) {
Affiliation affiliationScopus = reCiterArticle.getScopusArticle().getAffiliations().stream().filter(affiliation -> affiliation.getAfid() == afid).findFirst().get();
Affiliation affiliationScopus = reCiterArticle.getScopusArticle().getAffiliations().stream().filter(affiliation -> affiliation.getAfid() == afid).findFirst().orElse(null);
if(affiliationScopus != null
&&
affiliationScopus.getAffilname() != null) {
Expand All @@ -135,7 +135,7 @@ public double executeStrategy(List<ReCiterArticle> reCiterArticles, Identity ide
for(Integer afid: matchingAfids) {
TargetAuthorScopusAffiliation scopusAffiliationEvidence = new TargetAuthorScopusAffiliation();
if(reCiterArticle.getScopusArticle().getAffiliations() != null) {
Affiliation affiliationScopus = reCiterArticle.getScopusArticle().getAffiliations().stream().filter(affiliation -> affiliation.getAfid() == afid).findFirst().get();
Affiliation affiliationScopus = reCiterArticle.getScopusArticle().getAffiliations().stream().filter(affiliation -> affiliation.getAfid() == afid).findFirst().orElse(null);
if(affiliationScopus != null
&&
affiliationScopus.getAffilname() != null) {
Expand Down
13 changes: 5 additions & 8 deletions src/main/java/reciter/controller/ReCiterController.java
Original file line number Diff line number Diff line change
Expand Up @@ -269,11 +269,8 @@ public ResponseEntity retrieveArticlesByUid(String uid, RetrievalRefreshFlag ref
LocalDate initial = LocalDate.now();
LocalDate startDate = initial.withDayOfMonth(1);
LocalDate endDate = LocalDate.parse("3000-01-01");
Identity identity;

try {
identity = identityService.findByUid(uid);
} catch (NullPointerException ne) {
Identity identity = identityService.findByUid(uid);
if(identity == null) {
estimatedTime = System.currentTimeMillis() - startTime;
slf4jLogger.info("elapsed time: " + estimatedTime);
return ResponseEntity.status(HttpStatus.NOT_FOUND).body("The uid provided '" + uid + "' was not found in the Identity table");
Expand Down Expand Up @@ -368,9 +365,9 @@ public ResponseEntity runFeatureGenerator(@RequestParam(value = "uid") String ui
EngineOutput engineOutput;
EngineParameters parameters;
List<ReCiterArticleFeature> originalFeatures = new ArrayList<ReCiterArticleFeature>();
try {
identityService.findByUid(uid);
} catch (NullPointerException n) {

Identity identity = identityService.findByUid(uid);
if(identity == null) {
return ResponseEntity.status(HttpStatus.NOT_FOUND).body("The uid provided '" + uid + "' was not found in the Identity table");
}
AnalysisOutput analysis = analysisService.findByUid(uid.trim());
Expand Down

0 comments on commit ed91318

Please sign in to comment.