From 535efd98ee7b16b9d6d64130fffb56cc0837dd98 Mon Sep 17 00:00:00 2001 From: Jannik Date: Fri, 27 Apr 2018 15:06:40 +0200 Subject: [PATCH] release 0.7.0 * version 0.6.100 -> 0.7.0 * fixed a nullpointer if there is a false response from omdbapi --- pom.xml | 2 +- .../application/MainWindowController.java | 4 ++-- .../controller/OMDbAPIController.java | 24 ++++++++++--------- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/pom.xml b/pom.xml index 5977fc7..95f22a2 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ org.kellerkinder Project-HomeFlix - 0.6.99 + 0.7.0 jar Project-HomeFlix diff --git a/src/main/java/kellerkinder/HomeFlix/application/MainWindowController.java b/src/main/java/kellerkinder/HomeFlix/application/MainWindowController.java index 74bcdd1..45cb8b0 100644 --- a/src/main/java/kellerkinder/HomeFlix/application/MainWindowController.java +++ b/src/main/java/kellerkinder/HomeFlix/application/MainWindowController.java @@ -209,9 +209,9 @@ public class MainWindowController { private static final Logger LOGGER = LogManager.getLogger(MainWindowController.class.getName()); private int hashA = -647380320; - private final String version = "0.6.100"; + private final String version = "0.7.0"; private final String buildNumber = "151"; - private final String versionName = "toothless dragon RC"; + private final String versionName = "toothless dragon"; private String dialogBtnStyle; private String color; private String local; diff --git a/src/main/java/kellerkinder/HomeFlix/controller/OMDbAPIController.java b/src/main/java/kellerkinder/HomeFlix/controller/OMDbAPIController.java index a02d6fb..bc4db09 100644 --- a/src/main/java/kellerkinder/HomeFlix/controller/OMDbAPIController.java +++ b/src/main/java/kellerkinder/HomeFlix/controller/OMDbAPIController.java @@ -75,12 +75,11 @@ public class OMDbAPIController implements Runnable { BufferedReader ina = new BufferedReader(new InputStreamReader(apiUrl.openStream())); output = ina.readLine(); ina.close(); - LOGGER.info("response from " + URL + " was valid"); - LOGGER.info("Title was: " + mainWindowController.getCurrentTitle()); - LOGGER.info(output); + System.out.println(apiUrl); + LOGGER.info("response from '" + URL + "&t=" + mainWindowController.getCurrentTitle() + "' was:" + output); } catch (IOException e) { LOGGER.error("error while making api request or reading response"); - LOGGER.error("response from " + URL + " was: \n" + output, e); + LOGGER.error("response from '" + URL + "&t=" + mainWindowController.getCurrentTitle() + "' was:" + output, e); return; } @@ -89,20 +88,21 @@ public class OMDbAPIController implements Runnable { if (object.getString("Error", "").equals("Movie not found!")) { // if the movie was not found try to search it LOGGER.warn("Movie was not found at first try, searching again!"); - // TODO split the name intelligent as it may contain the film title - // query the api + /** TODO + * split the name intelligent as it may contain the film title + * search for English name + * use tmdb + */ try { URL apiUrl = new URL(URL + mainWindowController.getOmdbAPIKey() + "&s=" + mainWindowController.getCurrentTitle().replace(" ", "%20")); BufferedReader ina = new BufferedReader(new InputStreamReader(apiUrl.openStream())); output = ina.readLine(); ina.close(); - LOGGER.info("response from search " + URL + " was valid"); - LOGGER.info("Title was: " + mainWindowController.getCurrentTitle()); - LOGGER.info(output); + LOGGER.info("response from '" + URL + "&s=" + mainWindowController.getCurrentTitle() + "' was:" + output); } catch (Exception e) { LOGGER.error("error while making api request or reading response"); - LOGGER.error("response from search" + URL + " was: \n" + output, e); + LOGGER.error("response from '" + URL + "&s=" + mainWindowController.getCurrentTitle() + "' was:" + output, e); return; } @@ -110,13 +110,15 @@ public class OMDbAPIController implements Runnable { if (searchObject.getString("Response", "").equals("True")) { for (JsonValue movie : searchObject.get("Search").asArray()) { // get first entry from the array and set object = movie - // TODO probably we have a NullPointerException here! object = (JsonObject) movie; System.out.println(movie.toString()); break; } System.out.println(object.getString("Title", "")); + } else { + LOGGER.warn("Movie not found! Not adding cache!"); + return; } }