diff --git a/src/main/java/com/omertron/themoviedbapi/methods/AbstractMethod.java b/src/main/java/com/omertron/themoviedbapi/methods/AbstractMethod.java index 23c6a00ec..ac5a7ca54 100644 --- a/src/main/java/com/omertron/themoviedbapi/methods/AbstractMethod.java +++ b/src/main/java/com/omertron/themoviedbapi/methods/AbstractMethod.java @@ -23,12 +23,12 @@ import com.fasterxml.jackson.core.type.TypeReference; import com.fasterxml.jackson.databind.ObjectMapper; import com.omertron.themoviedbapi.MovieDbException; import com.omertron.themoviedbapi.model.MovieDb; -import com.omertron.themoviedbapi.model2.keyword.Keyword; -import com.omertron.themoviedbapi.model2.person.Person; import com.omertron.themoviedbapi.model2.collection.Collection; import com.omertron.themoviedbapi.model2.company.Company; +import com.omertron.themoviedbapi.model2.keyword.Keyword; import com.omertron.themoviedbapi.model2.list.UserList; import com.omertron.themoviedbapi.model2.movie.MovieBasic; +import com.omertron.themoviedbapi.model2.person.Person; import com.omertron.themoviedbapi.model2.person.PersonFind; import com.omertron.themoviedbapi.model2.tv.TVBasic; import com.omertron.themoviedbapi.tools.HttpTools; @@ -56,7 +56,7 @@ public class AbstractMethod { // Jackson JSON configuration protected static final ObjectMapper MAPPER = new ObjectMapper(); // Logger - protected static final Logger LOG = LoggerFactory.getLogger(TmdbAccount.class); + protected static final Logger LOG = LoggerFactory.getLogger(AbstractMethod.class); private static final Map TYPE_REFS = new HashMap(); @@ -81,14 +81,6 @@ public class AbstractMethod { }); } - protected static TypeReference getTypeReference(Class aClass) { - if (TYPE_REFS.containsKey(aClass)) { - return TYPE_REFS.get(aClass); - } else { - throw new RuntimeException("Class type reference for '" + aClass.getSimpleName() + "' not found!"); - } - } - /** * Default constructor for the methods * @@ -100,6 +92,21 @@ public class AbstractMethod { this.httpTools = httpTools; } + /** + * Helper function to get a pre-generated TypeReference for a class + * + * @param aClass + * @return + * @throws MovieDbException + */ + protected static TypeReference getTypeReference(Class aClass) throws MovieDbException { + if (TYPE_REFS.containsKey(aClass)) { + return TYPE_REFS.get(aClass); + } else { + throw new MovieDbException(ApiExceptionType.UNKNOWN_CAUSE, "Class type reference for '" + aClass.getSimpleName() + "' not found!"); + } + } + /** * Process the wrapper list and return the results * diff --git a/src/main/java/com/omertron/themoviedbapi/methods/TmdbPeople.java b/src/main/java/com/omertron/themoviedbapi/methods/TmdbPeople.java index aafd4741f..9141d4b2e 100644 --- a/src/main/java/com/omertron/themoviedbapi/methods/TmdbPeople.java +++ b/src/main/java/com/omertron/themoviedbapi/methods/TmdbPeople.java @@ -139,7 +139,7 @@ public class TmdbPeople extends AbstractMethod { return MAPPER.readValue(webpage, new TypeReference>() { }); } catch (IOException ex) { - throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get person movie credits", url, ex); + throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get person TV credits", url, ex); } } @@ -171,7 +171,7 @@ public class TmdbPeople extends AbstractMethod { return MAPPER.readValue(webpage, new TypeReference>() { }); } catch (IOException ex) { - throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get person movie credits", url, ex); + throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get person combined credits", url, ex); } } @@ -192,7 +192,7 @@ public class TmdbPeople extends AbstractMethod { try { return MAPPER.readValue(webpage, ExternalID.class); } catch (IOException ex) { - throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get person movie credits", url, ex); + throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get person external IDs", url, ex); } } @@ -315,7 +315,7 @@ public class TmdbPeople extends AbstractMethod { results.copyWrapper(wrapper); return results; } catch (IOException ex) { - throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get tagged images", url, ex); + throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get person popular", url, ex); } } diff --git a/src/main/java/com/omertron/themoviedbapi/model2/config/Configuration.java b/src/main/java/com/omertron/themoviedbapi/model2/config/Configuration.java index 501e04450..cdf25bd39 100644 --- a/src/main/java/com/omertron/themoviedbapi/model2/config/Configuration.java +++ b/src/main/java/com/omertron/themoviedbapi/model2/config/Configuration.java @@ -19,7 +19,6 @@ */ package com.omertron.themoviedbapi.model2.config; -import com.omertron.themoviedbapi.model2.AbstractJsonMapping; import com.fasterxml.jackson.annotation.JsonProperty; import com.omertron.themoviedbapi.MovieDbException; import com.omertron.themoviedbapi.model2.AbstractJsonMapping; @@ -203,7 +202,7 @@ public class Configuration extends AbstractJsonMapping { StringBuilder sb = new StringBuilder(getBaseUrl()); sb.append(requiredSize); sb.append(imagePath); - + try { return new URL(sb.toString()); } catch (MalformedURLException ex) { diff --git a/src/main/java/com/omertron/themoviedbapi/model2/config/JobDepartment.java b/src/main/java/com/omertron/themoviedbapi/model2/config/JobDepartment.java index 403d48584..288f5a1a6 100644 --- a/src/main/java/com/omertron/themoviedbapi/model2/config/JobDepartment.java +++ b/src/main/java/com/omertron/themoviedbapi/model2/config/JobDepartment.java @@ -19,10 +19,8 @@ */ package com.omertron.themoviedbapi.model2.config; -import com.omertron.themoviedbapi.model2.AbstractJsonMapping; import com.fasterxml.jackson.annotation.JsonProperty; import com.omertron.themoviedbapi.model2.AbstractJsonMapping; - import java.util.List; public class JobDepartment extends AbstractJsonMapping {