From d2f4a7b1321d7984e2894949532bb3a52270c779 Mon Sep 17 00:00:00 2001 From: Omertron Date: Sat, 12 Jun 2010 10:46:58 +0000 Subject: [PATCH 003/207] Updated --- themoviedbapi/.classpath | 7 + themoviedbapi/.project | 17 + themoviedbapi/build.xml | 57 ++ .../moviejukebox/themoviedb/TheMovieDb.java | 608 ++++++++++++++++++ .../themoviedb/model/Artwork.java | 103 +++ .../themoviedb/model/Category.java | 50 ++ .../themoviedb/model/Country.java | 50 ++ .../themoviedb/model/MovieDB.java | 350 ++++++++++ .../moviejukebox/themoviedb/model/Person.java | 68 ++ .../themoviedb/tools/LogFormatter.java | 31 + .../themoviedb/tools/XMLHelper.java | 61 ++ themoviedbapi/src/readme.txt | 9 + 12 files changed, 1411 insertions(+) create mode 100644 themoviedbapi/.classpath create mode 100644 themoviedbapi/.project create mode 100644 themoviedbapi/build.xml create mode 100644 themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java create mode 100644 themoviedbapi/src/com/moviejukebox/themoviedb/model/Artwork.java create mode 100644 themoviedbapi/src/com/moviejukebox/themoviedb/model/Category.java create mode 100644 themoviedbapi/src/com/moviejukebox/themoviedb/model/Country.java create mode 100644 themoviedbapi/src/com/moviejukebox/themoviedb/model/MovieDB.java create mode 100644 themoviedbapi/src/com/moviejukebox/themoviedb/model/Person.java create mode 100644 themoviedbapi/src/com/moviejukebox/themoviedb/tools/LogFormatter.java create mode 100644 themoviedbapi/src/com/moviejukebox/themoviedb/tools/XMLHelper.java create mode 100644 themoviedbapi/src/readme.txt diff --git a/themoviedbapi/.classpath b/themoviedbapi/.classpath new file mode 100644 index 000000000..b148297dc --- /dev/null +++ b/themoviedbapi/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/themoviedbapi/.project b/themoviedbapi/.project new file mode 100644 index 000000000..63e67b96e --- /dev/null +++ b/themoviedbapi/.project @@ -0,0 +1,17 @@ + + + themoviedbapi + + + + + + org.eclipse.jdt.core.javabuilder + + + + + + org.eclipse.jdt.core.javanature + + diff --git a/themoviedbapi/build.xml b/themoviedbapi/build.xml new file mode 100644 index 000000000..ed4f360d9 --- /dev/null +++ b/themoviedbapi/build.xml @@ -0,0 +1,57 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + ${project}${line.separator} + Build Date: ${builddate}${line.separator} + Revision: r${revision}${line.separator} + + + + + + + + + + + + + + + + + + + + + + + diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java b/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java new file mode 100644 index 000000000..9b1e8c7b6 --- /dev/null +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java @@ -0,0 +1,608 @@ +/* + * Copyright (c) 2004-2009 YAMJ Members + * http://code.google.com/p/moviejukebox/people/list + * + * Web: http://code.google.com/p/moviejukebox/ + * + * This software is licensed under a Creative Commons License + * See this page: http://code.google.com/p/moviejukebox/wiki/License + * + * For any reuse or distribution, you must make clear to others the + * license terms of this work. + */ + +package com.moviejukebox.themoviedb; + +import java.net.URLEncoder; +import java.util.Iterator; +import java.util.logging.ConsoleHandler; +import java.util.logging.Level; +import java.util.logging.Logger; + +import javax.xml.stream.XMLEventReader; +import javax.xml.stream.XMLStreamException; +import javax.xml.stream.events.Attribute; +import javax.xml.stream.events.EndElement; +import javax.xml.stream.events.StartElement; +import javax.xml.stream.events.XMLEvent; + +import com.moviejukebox.themoviedb.model.*; +import com.moviejukebox.themoviedb.tools.*; + +/** + * This is the main class for the API to connect to TheMovieDb.org The implementation is for v2.1 of the API as detailed here + * http://api.themoviedb.org/2.1/docs/ + * + * @author Stuart.Boston + * @version 1.1 + */ +public class TheMovieDb { + + private String apiKey; + private static String apiSite = "http://api.themoviedb.org/2.1/"; + private static String defaultLanguage = "en"; + private static Logger logger; + + public TheMovieDb(String apiKey) { + logger = Logger.getLogger("TheMovieDB"); + LogFormatter mjbFormatter = new LogFormatter(); + ConsoleHandler ch = new ConsoleHandler(); + ch.setFormatter(mjbFormatter); + ch.setLevel(Level.FINE); + logger.addHandler(ch); + logger.setUseParentHandlers(true); + logger.setLevel(Level.ALL); + + this.apiKey = apiKey; + mjbFormatter.addApiKey(apiKey); + } + + /** + * Build the search URL from the search prefix and movie title. + * This will change between v2.0 and v2.1 of the API + * + * @param prefix The search prefix before the movie title + * @param language The two digit language code. E.g. en=English + * @param searchTerm The search key to use, e.g. movie title or IMDb ID + * @return The search URL + */ + private String buildSearchUrl(String prefix, String searchTerm, String language) { + String searchUrl = apiSite + prefix + "/" + language + "/xml/" + apiKey + "/" + searchTerm; + logger.finest("Search URL: " + searchUrl); + return searchUrl; + } + + /** + * Searches the database using the movie title passed + * + * @param movieTitle The title to search for + * @param language The two digit language code. E.g. en=English + * @return A movie bean with the data extracted + */ + public MovieDB moviedbSearch(String movieTitle, String language) { + XMLEventReader xmlReader = null; + MovieDB movie = null; + + language = validateLanguage(language); + + // If the title is null, then exit + if (movieTitle == null || movieTitle.equals("")) + return movie; + + try { + String searchUrl = buildSearchUrl("Movie.search", URLEncoder.encode(movieTitle, "UTF-8"), language); + xmlReader = XMLHelper.getEventReader(searchUrl); + movie = parseMovieInfo(xmlReader); + } catch (Exception error) { + System.err.println("ERROR: TheMovieDb API -> " + error.getMessage()); + } finally { + XMLHelper.closeEventReader(xmlReader); + } + return movie; + } + + /** + * Searches the database using the IMDd reference + * + * @param imdbID IMDb reference, must include the "tt" at the start + * @param language The two digit language code. E.g. en=English + * @return A movie bean with the data extracted + */ + public MovieDB moviedbImdbLookup(String imdbID, String language) { + XMLEventReader xmlReader = null; + MovieDB movie = null; + + language = validateLanguage(language); + + // If the imdbID is null, then exit + if (imdbID == null || imdbID.equals("")) + return movie; + + try { + String searchUrl = buildSearchUrl("Movie.imdbLookup", imdbID, language); + xmlReader = XMLHelper.getEventReader(searchUrl); + movie = parseMovieInfo(xmlReader); + } catch (Exception error) { + System.err.println("ERROR: TheMovieDb API -> " + error.getMessage()); + } finally { + XMLHelper.closeEventReader(xmlReader); + } + return movie; + } + + /** + * Passes a null MovieDB object to the full function + * + * @param tmdbID TheMovieDB ID of the movie to get the information for + * @param language The two digit language code. E.g. en=English + * @return A movie bean with all of the information + */ + public MovieDB moviedbGetInfo(String tmdbID, String language) { + MovieDB movie = null; + movie = moviedbGetInfo(tmdbID, movie, language); + return movie; + } + + /** + * Gets all the information for a given TheMovieDb ID + * + * @param movie + * An existing MovieDB object to populate with the data + * @param tmdbID + * The Movie Db ID for the movie to get information for + * @param language + * The two digit language code. E.g. en=English + * @return A movie bean with all of the information + */ + public MovieDB moviedbGetInfo(String tmdbID, MovieDB movie, String language) { + XMLEventReader xmlReader = null; + + // If the tmdbID is null, then exit + if (tmdbID == null || tmdbID.equals("") || tmdbID.equalsIgnoreCase("UNKNOWN")) + return movie; + + language = validateLanguage(language); + + try { + String searchUrl = buildSearchUrl("Movie.getImages", tmdbID, language); + xmlReader = XMLHelper.getEventReader(searchUrl); + movie = parseMovieInfo(xmlReader); + } catch (Exception error) { + System.err.println("ERROR: TheMovieDb API -> " + error.getMessage()); + } finally { + XMLHelper.closeEventReader(xmlReader); + } + return movie; + } + + public MovieDB moviedbGetImages(String searchTerm, String language) { + MovieDB movie = null; + movie = moviedbGetInfo(searchTerm, movie, language); + return movie; + } + + /** + * Get all the image information from TheMovieDb. + * @param searchTerm Can be either the IMDb ID or TMDb ID + * @param movie + * @param language + * @return + */ + public MovieDB moviedbGetImages(String searchTerm, MovieDB movie, String language) { + XMLEventReader xmlReader = null; + + // If the searchTerm is null, then exit + if (searchTerm == null || searchTerm.equals("") || searchTerm.equalsIgnoreCase("UNKNOWN")) + return movie; + + language = validateLanguage(language); + + try { + String searchUrl = buildSearchUrl("Movie.getImages", searchTerm, language); + xmlReader = XMLHelper.getEventReader(searchUrl); + movie = parseMovieInfo(xmlReader); + } catch (Exception error) { + System.err.println("ERROR: TheMovieDb API -> " + error.getMessage()); + } finally { + XMLHelper.closeEventReader(xmlReader); + } + + return movie; + } + + /** + * Search the XML passed and decode to a movieDB bean + * + * @param xmlReader + * The XML stream read from TheMovieDB.org + * @return a MovieDB bean with the data + * @throws XMLStreamException + */ + // TODO Waring if match is low (i.e. score != 1.0) + @SuppressWarnings("unchecked") + public MovieDB parseMovieInfo(XMLEventReader xmlReader) throws XMLStreamException { + MovieDB movie = null; + try { + while (xmlReader.hasNext()) { + XMLEvent event = xmlReader.nextEvent(); + + if (event.isStartElement()) { + StartElement startElement = event.asStartElement(); + + if (startElement.getName().getLocalPart().equalsIgnoreCase("movie")) { + movie = new MovieDB(); + } + + if (event.isStartElement()) { + if (event.asStartElement().getName().getLocalPart().equalsIgnoreCase("popularity")) { + event = xmlReader.nextEvent(); + movie.setPopularity(event.asCharacters().getData()); + continue; + } + } + + if (event.isStartElement()) { + if (event.asStartElement().getName().getLocalPart().equalsIgnoreCase("name")) { + event = xmlReader.nextEvent(); + movie.setTitle(event.asCharacters().getData()); + continue; + } + } + + if (event.isStartElement()) { + if (event.asStartElement().getName().getLocalPart().equalsIgnoreCase("type")) { + event = xmlReader.nextEvent(); + movie.setType(event.asCharacters().getData()); + continue; + } + } + + if (event.isStartElement()) { + if (event.asStartElement().getName().getLocalPart().equalsIgnoreCase("id")) { + event = xmlReader.nextEvent(); + movie.setId(event.asCharacters().getData()); + continue; + } + } + + if (event.isStartElement()) { + if (event.asStartElement().getName().getLocalPart().equalsIgnoreCase("imdb_id")) { + event = xmlReader.nextEvent(); + movie.setImdb(event.asCharacters().getData()); + continue; + } + } + + if (event.isStartElement()) { + if (event.asStartElement().getName().getLocalPart().equalsIgnoreCase("url")) { + event = xmlReader.nextEvent(); + movie.setUrl(event.asCharacters().getData()); + continue; + } + } + + if (event.isStartElement()) { + if (event.asStartElement().getName().getLocalPart().equalsIgnoreCase("overview")) { + event = xmlReader.nextEvent(); + movie.setOverview(event.asCharacters().getData()); + continue; + } + } + + if (event.isStartElement()) { + if (event.asStartElement().getName().getLocalPart().equalsIgnoreCase("rating")) { + event = xmlReader.nextEvent(); + movie.setRating(event.asCharacters().getData()); + continue; + } + } + + if (event.isStartElement()) { + if (event.asStartElement().getName().getLocalPart().equalsIgnoreCase("released")) { + event = xmlReader.nextEvent(); + movie.setReleaseDate(event.asCharacters().getData()); + continue; + } + } + + if (event.isStartElement()) { + if (event.asStartElement().getName().getLocalPart().equalsIgnoreCase("runtime")) { + event = xmlReader.nextEvent(); + movie.setRuntime(event.asCharacters().getData()); + continue; + } + } + + if (event.isStartElement()) { + if (event.asStartElement().getName().getLocalPart().equalsIgnoreCase("budget")) { + event = xmlReader.nextEvent(); + movie.setBudget(event.asCharacters().getData()); + continue; + } + } + + if (event.isStartElement()) { + if (event.asStartElement().getName().getLocalPart().equalsIgnoreCase("revenue")) { + event = xmlReader.nextEvent(); + movie.setRevenue(event.asCharacters().getData()); + continue; + } + } + + if (event.isStartElement()) { + if (event.asStartElement().getName().getLocalPart().equalsIgnoreCase("homepage")) { + event = xmlReader.nextEvent(); + movie.setHomepage(event.asCharacters().getData()); + continue; + } + } + + if (event.isStartElement()) { + if (event.asStartElement().getName().getLocalPart().equalsIgnoreCase("trailer")) { + event = xmlReader.nextEvent(); + movie.setTrailer(event.asCharacters().getData()); + continue; + } + } + + if (event.isStartElement()) { + if (event.asStartElement().getName().getLocalPart().equalsIgnoreCase("categories")) { + event = xmlReader.nextEvent(); + startElement = event.asStartElement(); + + while (!event.isEndElement() && !event.asEndElement().getName().getLocalPart().equalsIgnoreCase("category")) { + Category category = new Category(); + Iterator attributes = startElement.getAttributes(); + while (attributes.hasNext()) { + Attribute attribute = attributes.next(); + if (attribute.getName().toString().equals("type")) + category.setType(attribute.getValue()); + if (attribute.getName().toString().equals("url")) + category.setUrl(attribute.getValue()); + if (attribute.getName().toString().equals("name")) + category.setName(attribute.getValue()); + + } + movie.addCategory(category); + } + } + } + + if (event.isStartElement()) { + if (event.asStartElement().getName().getLocalPart().equalsIgnoreCase("countries")) { + event = xmlReader.nextEvent(); + startElement = event.asStartElement(); + + while (!event.isEndElement() && !event.asEndElement().getName().getLocalPart().equalsIgnoreCase("country")) { + Country country = new Country(); + Iterator attributes = startElement.getAttributes(); + while (attributes.hasNext()) { + Attribute attribute = attributes.next(); + if (attribute.getName().toString().equals("code")) + country.setCode(attribute.getValue()); + if (attribute.getName().toString().equals("url")) + country.setUrl(attribute.getValue()); + if (attribute.getName().toString().equals("name")) + country.setName(attribute.getValue()); + } + movie.addProductionCountry(country); + } + } + } + + if (event.isStartElement()) { + if (event.asStartElement().getName().getLocalPart().equalsIgnoreCase("cast")) { + event = xmlReader.nextEvent(); + startElement = event.asStartElement(); + + while (!event.isEndElement() && !event.asEndElement().getName().getLocalPart().equalsIgnoreCase("person")) { + Person person = new Person(); + Iterator attributes = startElement.getAttributes(); + while (attributes.hasNext()) { + Attribute attribute = attributes.next(); + if (attribute.getName().toString().equals("url")) + person.setUrl(attribute.getValue()); + if (attribute.getName().toString().equals("name")) + person.setName(attribute.getValue()); + if (attribute.getName().toString().equals("job")) + person.setJob(attribute.getValue()); + if (attribute.getName().toString().equals("character")) + person.setCharacter(attribute.getValue()); + if (attribute.getName().toString().equals("id")) + person.setId(attribute.getValue()); + } + movie.addPerson(person); + } + } + } + + /* + * This processes the image elements. There are two formats to deal with: + * Movie.imdbLookup, Movie.getInfo & Movie.search: + * + * + * + * + * + * Movie.getImages: + * + * + * + * + * + * + * + * + * + * + * + * + * + */ + if (checkStartEvent(event, "images")) { + event = xmlReader.nextEvent(); + + while (!checkEndEvent(event, "images")) { + if (checkStartEvent(event, "image")) { + Artwork artwork = new Artwork(); + Iterator attributes = event.asStartElement().getAttributes(); + while (attributes.hasNext()) { + Attribute attribute = attributes.next(); + if (attribute.getName().toString().equalsIgnoreCase("type")) + artwork.setType(attribute.getValue()); + if (attribute.getName().toString().equalsIgnoreCase("size")) + artwork.setSize(attribute.getValue()); + if (attribute.getName().toString().equalsIgnoreCase("url")) + artwork.setUrl(attribute.getValue()); + if (attribute.getName().toString().equalsIgnoreCase("id")) + artwork.setId(attribute.getValue()); + } + event = xmlReader.nextEvent(); // Skip the characters at the end of the attributes + movie.addArtwork(artwork); + } + + if (checkStartEvent(event, "poster")) { + Artwork artwork = new Artwork(); + String imageId = getImageId(event); + event = xmlReader.nextEvent(); // Skip the characters at the end of the attributes + event = xmlReader.nextEvent(); + + while (!checkEndEvent(event, "poster")) { + artwork = new Artwork(); + artwork.setType(Artwork.ARTWORK_TYPE_POSTER); + artwork.setId(imageId); + + if (checkStartEvent(event, "image")) { + Iterator attributes = event.asStartElement().getAttributes(); + while (attributes.hasNext()) { + Attribute attribute = attributes.next(); + if (attribute.getName().toString().equalsIgnoreCase("url")) + artwork.setUrl(attribute.getValue()); + if (attribute.getName().toString().equalsIgnoreCase("size")) + artwork.setSize(attribute.getValue()); + } + event = xmlReader.nextEvent(); // Skip the characters at the end of the attributes + movie.addArtwork(artwork); + } + event = xmlReader.nextEvent(); + } + } + + if (checkStartEvent(event, "backdrop")) { + Artwork artwork = new Artwork(); + String imageId = getImageId(event); + event = xmlReader.nextEvent(); // Skip the characters at the end of the attributes + event = xmlReader.nextEvent(); + + while (!checkEndEvent(event, "backdrop")) { + artwork = new Artwork(); + artwork.setType(Artwork.ARTWORK_TYPE_BACKDROP); + artwork.setId(imageId); + + if (checkStartEvent(event, "image")) { + Iterator attributes = event.asStartElement().getAttributes(); + while (attributes.hasNext()) { + Attribute attribute = attributes.next(); + if (attribute.getName().toString().equalsIgnoreCase("url")) + artwork.setUrl(attribute.getValue()); + if (attribute.getName().toString().equalsIgnoreCase("size")) + artwork.setSize(attribute.getValue()); + } + event = xmlReader.nextEvent(); // Skip the characters at the end of the attributes + movie.addArtwork(artwork); + } + event = xmlReader.nextEvent(); + } + } + event = xmlReader.nextEvent(); + } // While "images" + } // If "images" + } // if start element + + if (event.isEndElement()) { + EndElement endElement = event.asEndElement(); + if (endElement.getName().getLocalPart().equalsIgnoreCase("movie")) { + break; + } + } + } + } catch (Exception error) { + System.err.println("Error: " + error.getMessage()); + error.printStackTrace(); + } + return movie; + } + + /** + * Check to see if the event passed is a start element and matches the eventName + * @param event + * @param endString + * @return True if the event is an end element and matches the eventName + */ + private boolean checkStartEvent(XMLEvent event, String eventName) { + boolean validElement = false; + + if (event.isStartElement()) { + if (event.asStartElement().getName().getLocalPart().equalsIgnoreCase(eventName)) { + validElement = true; + } + } + return validElement; + } + + /** + * Check to see if the event passed is an end element and matches the eventName + * @param event + * @param endString + * @return True if the event is an end element and matches the eventName + */ + private boolean checkEndEvent(XMLEvent event, String eventName) { + boolean validElement = false; + + if (event.isEndElement()) { + if (event.asEndElement().getName().getLocalPart().equalsIgnoreCase(eventName)) { + validElement = true; + } + } + return validElement; + } + + /** + * Find the ID in the element attributes + * @param event + * @return the imageId + */ + @SuppressWarnings({"unchecked"}) + private String getImageId(XMLEvent event) { + String imageId = null; + + try { + // read the id attribute from the element + Iterator attributes = event.asStartElement().getAttributes(); + while (attributes.hasNext()) { + Attribute attribute = attributes.next(); + if (attribute.getName().toString().equalsIgnoreCase("id")) + imageId = attribute.getValue(); + } + } catch (Exception error) { + imageId = null; + } + + return imageId; + } + + /** + * This function will check the passed language against a list of known themoviedb.org languages + * Currently the only available language is English "en" and so that is what this function returns + * @param language + * @return + */ + private String validateLanguage(String language) { + if (language == null) { + language = defaultLanguage; + } else { + language = defaultLanguage; + } + return language; + } +} diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/model/Artwork.java b/themoviedbapi/src/com/moviejukebox/themoviedb/model/Artwork.java new file mode 100644 index 000000000..6f2de7579 --- /dev/null +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/model/Artwork.java @@ -0,0 +1,103 @@ +/* + * Copyright (c) 2004-2009 YAMJ Members + * http://code.google.com/p/moviejukebox/people/list + * + * Web: http://code.google.com/p/moviejukebox/ + * + * This software is licensed under a Creative Commons License + * See this page: http://code.google.com/p/moviejukebox/wiki/License + * + * For any reuse or distribution, you must make clear to others the + * license terms of this work. + */ + +package com.moviejukebox.themoviedb.model; + +/** + * This is the new bean for the Artwork + * + * @author Stuart.Boston + * + */ +public class Artwork implements Comparable { + public static String ARTWORK_TYPE_POSTER = "poster"; + public static String ARTWORK_TYPE_BACKDROP = "backdrop"; + public static String[] ARTWORK_TYPES = {ARTWORK_TYPE_POSTER, ARTWORK_TYPE_BACKDROP}; + + public static String ARTWORK_SIZE_ORIGINAL = "original"; + public static String ARTWORK_SIZE_THUMB = "thumb"; + public static String ARTWORK_SIZE_MID = "mid"; + public static String ARTWORK_SIZE_COVER = "cover"; + public static String ARTWORK_SIZE_POSTER = "poster"; + public static String[] ARTWORK_SIZES = {ARTWORK_SIZE_ORIGINAL, ARTWORK_SIZE_THUMB, ARTWORK_SIZE_MID, ARTWORK_SIZE_COVER, ARTWORK_SIZE_POSTER}; + + public String type; + public String size; + public String url; + public int id; + + public String[] getArtworkSizes() { + return ARTWORK_SIZES; + } + + public String[] getArtworkTypes() { + return ARTWORK_TYPES; + } + + public String getType() { + if (type == null) { + return MovieDB.UNKNOWN; + } else { + return type; + } + } + + public void setType(String type) { + this.type = type; + } + + public String getSize() { + if (size == null) { + return MovieDB.UNKNOWN; + } else { + return size; + } + } + + public void setSize(String size) { + this.size = size; + } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + public int getId() { + return id; + } + + public void setId(String id) { + try { + this.id = Integer.parseInt(id); + } catch (Exception ignore) { + // If there is an issue with casting the Id then use Zero + this.id = 0; + } + } + + public void setId(int id) { + this.id = id; + } + + @Override + public int compareTo(Object otherArtwork) throws ClassCastException { + if (!(otherArtwork instanceof Artwork)) + throw new ClassCastException("TheMovieDB API: An Artwork object is expected."); + int anotherId = ((Artwork) otherArtwork).getId(); + return this.id - anotherId; + } + } diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/model/Category.java b/themoviedbapi/src/com/moviejukebox/themoviedb/model/Category.java new file mode 100644 index 000000000..b9bff0a32 --- /dev/null +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/model/Category.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2004-2009 YAMJ Members + * http://code.google.com/p/moviejukebox/people/list + * + * Web: http://code.google.com/p/moviejukebox/ + * + * This software is licensed under a Creative Commons License + * See this page: http://code.google.com/p/moviejukebox/wiki/License + * + * For any reuse or distribution, you must make clear to others the + * license terms of this work. + */ + +package com.moviejukebox.themoviedb.model; + +/** + * Category from the MovieDB.org + * + * @author Stuart.Boston + * + */ +public class Category { + public String type; + public String name; + public String url; + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } +} diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/model/Country.java b/themoviedbapi/src/com/moviejukebox/themoviedb/model/Country.java new file mode 100644 index 000000000..db08d6992 --- /dev/null +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/model/Country.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2004-2009 YAMJ Members + * http://code.google.com/p/moviejukebox/people/list + * + * Web: http://code.google.com/p/moviejukebox/ + * + * This software is licensed under a Creative Commons License + * See this page: http://code.google.com/p/moviejukebox/wiki/License + * + * For any reuse or distribution, you must make clear to others the + * license terms of this work. + */ + +package com.moviejukebox.themoviedb.model; + +/** + * Country from the MovieDB.org + * + * @author Stuart.Boston + * + */ +public class Country { + public String url; + public String name; + public String code; + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getCode() { + return code; + } + + public void setCode(String code) { + this.code = code; + } +} diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/model/MovieDB.java b/themoviedbapi/src/com/moviejukebox/themoviedb/model/MovieDB.java new file mode 100644 index 000000000..0c84bce36 --- /dev/null +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/model/MovieDB.java @@ -0,0 +1,350 @@ +/* + * Copyright (c) 2004-2009 YAMJ Members + * http://code.google.com/p/moviejukebox/people/list + * + * Web: http://code.google.com/p/moviejukebox/ + * + * This software is licensed under a Creative Commons License + * See this page: http://code.google.com/p/moviejukebox/wiki/License + * + * For any reuse or distribution, you must make clear to others the + * license terms of this work. + */ + +package com.moviejukebox.themoviedb.model; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +/** + * This is the Movie Search bean for the MovieDb.org search + * + * @author Stuart.Boston + */ + +public class MovieDB { + public static String UNKNOWN = "UNKNOWN"; + + private String score = UNKNOWN; + private String popularity = UNKNOWN; + private String title = UNKNOWN; + private String type = UNKNOWN; + private String id = UNKNOWN; + private String imdb = UNKNOWN; + private String url = UNKNOWN; + private String overview = UNKNOWN; + private String rating = UNKNOWN; + private String releaseDate = UNKNOWN; + private String runtime = UNKNOWN; + private String budget = UNKNOWN; + private String revenue = UNKNOWN; + private String homepage = UNKNOWN; + private String trailer = UNKNOWN; + private List artwork = new ArrayList(); + private List countries = new ArrayList(); + private List people = new ArrayList(); + private List categories = new ArrayList(); + + public String getScore() { + return score; + } + + public void setScore(String score) { + this.score = score; + } + + public String getPopularity() { + return popularity; + } + + public void setPopularity(String popularity) { + this.popularity = popularity; + } + + public String getTitle() { + return title; + } + + public void setTitle(String title) { + this.title = title; + } + + public String getType() { + return type; + } + + public void setType(String type) { + this.type = type; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getImdb() { + return imdb; + } + + public void setImdb(String imdb) { + this.imdb = imdb; + } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + public String getOverview() { + return overview; + } + + public void setOverview(String overview) { + this.overview = overview; + } + + public String getReleaseDate() { + return releaseDate; + } + + public void setReleaseDate(String releaseDate) { + this.releaseDate = releaseDate; + } + + public String getRating() { + return rating; + } + + public void setRating(String rating) { + this.rating = rating; + } + + public String getRuntime() { + return runtime; + } + + public void setRuntime(String runtime) { + this.runtime = runtime; + } + + public String getBudget() { + return budget; + } + + public void setBudget(String budget) { + this.budget = budget; + } + + public String getRevenue() { + return revenue; + } + + public void setRevenue(String revenue) { + this.revenue = revenue; + } + + public String getHomepage() { + return homepage; + } + + public void setHomepage(String homepage) { + this.homepage = homepage; + } + + public String getTrailer() { + return trailer; + } + + public void setTrailer(String trailer) { + this.trailer = trailer; + } + + /** + * Add a piece of artwork to the artwork array + * @param artworkType must be one of Artwork.ARTWORK_TYPES + * @param artworkSize must be one of Artwork.ARTWORK_SIZES + * @param artworkUrl + * @param posterId + */ + public void addArtwork(String artworkType, String artworkSize, String artworkUrl, String artworkId) { + if (validateElement(Artwork.ARTWORK_TYPES, artworkType) && validateElement(Artwork.ARTWORK_SIZES, artworkSize)) { + Artwork newArtwork = new Artwork(); + + newArtwork.setType(artworkType); + newArtwork.setSize(artworkSize); + newArtwork.setUrl(artworkUrl); + newArtwork.setId(artworkId); + + artwork.add(newArtwork); + Collections.sort(artwork); + } + return; + } + + /** + * Add a piece of artwork to the artwork array + * @param newArtwork an Artwork object to add to the array + */ + public void addArtwork(Artwork newArtwork) { + if (validateElement(Artwork.ARTWORK_TYPES, newArtwork.getType()) && validateElement(Artwork.ARTWORK_SIZES, newArtwork.getSize())) { + artwork.add(newArtwork); + Collections.sort(artwork); + } + return; + } + + /** + * Check to see if element is contained in elementArray + * @param elementArray + * @param element + * @return + */ + private boolean validateElement(String[] elementArray, String element) { + boolean valid = false; + + for (String arrayEntry : elementArray) { + if (arrayEntry.equalsIgnoreCase(element)) { + valid = true; + break; + } + } + + return valid; + } + + public List getProductionCountries() { + return countries; + } + + public void addProductionCountry(Country country) { + if (country != null) { + countries.add(country); + } + } + + public List getPeople() { + return people; + } + + public void addPerson(Person person) { + if (person != null) { + people.add(person); + } + } + + public List getCategories() { + return categories; + } + + public void addCategory(Category category) { + if (category != null) { + categories.add(category); + } + } + + /** + * Return all the artwork for a movie + * @return + */ + public List getArtwork() { + return artwork; + } + + /** + * Get all the artwork of a specific type + * @param artworkType + * @return + */ + public List getArtwork(String artworkType) { + // Validate the Type and Size arguments + if (!validateElement(Artwork.ARTWORK_TYPES, artworkType)) { + return null; + } + + List artworkList = new ArrayList(); + + for (Artwork singleArtwork : artwork) { + if (singleArtwork.getType().equalsIgnoreCase(artworkType)) { + artworkList.add(singleArtwork); + } + } + + return artworkList; + } + + /** + * Get all artwork of a specific Type and Size + * @param artworkType + * @param artworkSize + * @return + */ + public List getArtwork(String artworkType, String artworkSize) { + List artworkList = new ArrayList(); + // Validate the Type and Size arguments + if (!validateElement(Artwork.ARTWORK_TYPES, artworkType) && !validateElement(Artwork.ARTWORK_SIZES, artworkSize)) { + return null; + } + + for (Artwork singleArtwork : artwork) { + if (singleArtwork.getType().equalsIgnoreCase(artworkType) && singleArtwork.getSize().equalsIgnoreCase(artworkSize)) { + artworkList.add(singleArtwork); + } + } + + return artworkList; + } + + /** + * Return a specific artwork entry for a Type & Size + * @param artworkType + * @param artworkSize + * @param artworkNumber + * @return + */ + public Artwork getArtwork(String artworkType, String artworkSize, int artworkNumber) { + // Validate the Type and Size arguments + if (!validateElement(Artwork.ARTWORK_TYPES, artworkType) && !validateElement(Artwork.ARTWORK_SIZES, artworkSize)) { + return null; + } + + // Validate the number + if (artworkNumber <= 0) { + artworkNumber = 0; + } else { + // Artwork elements start at 0 (Zero) + artworkNumber -= 1; + } + + List artworkList = getArtwork(artworkType, artworkSize); + + int artworkCount = artworkList.size(); + if (artworkCount < 1) { + return null; + } + + // If the number requested is greater than the array size, loop around until it's within scope + while (artworkNumber > artworkCount) { + artworkNumber = artworkNumber - artworkCount; + } + + return artworkList.get(artworkNumber); + } + + /** + * Get the first artwork that matches the Type and Size + * @param artworkType + * @param artworkSize + * @return + */ + public Artwork getFirstArtwork(String artworkType, String artworkSize) { + return getArtwork(artworkType, artworkSize, 1); + } + +} diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/model/Person.java b/themoviedbapi/src/com/moviejukebox/themoviedb/model/Person.java new file mode 100644 index 000000000..b76ea3788 --- /dev/null +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/model/Person.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2004-2009 YAMJ Members + * http://code.google.com/p/moviejukebox/people/list + * + * Web: http://code.google.com/p/moviejukebox/ + * + * This software is licensed under a Creative Commons License + * See this page: http://code.google.com/p/moviejukebox/wiki/License + * + * For any reuse or distribution, you must make clear to others the + * license terms of this work. + */ + +package com.moviejukebox.themoviedb.model; + +/** + * This is the new bean for the Person + * + * @author Stuart.Boston + * + */ +public class Person { + public String url; + public String name; + public String job; + public String character; + public String id; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getJob() { + return job; + } + + public void setJob(String job) { + this.job = job; + } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getCharacter() { + return character; + } + + public void setCharacter(String character) { + this.character = character; + } +} diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/tools/LogFormatter.java b/themoviedbapi/src/com/moviejukebox/themoviedb/tools/LogFormatter.java new file mode 100644 index 000000000..42d5e3bef --- /dev/null +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/tools/LogFormatter.java @@ -0,0 +1,31 @@ +package com.moviejukebox.themoviedb.tools; + +import java.security.PrivilegedAction; +import java.util.logging.LogRecord; + +public class LogFormatter extends java.util.logging.Formatter +{ + private static String API_KEY = null; + private static String EOL = (String)java.security.AccessController.doPrivileged(new PrivilegedAction() { + public Object run() { + return System.getProperty("line.separator"); + } + }); + + public synchronized String format(LogRecord logRecord) { + String logMessage = logRecord.getMessage(); + + logMessage = "[TheMovieDb API] " + logMessage.replace(API_KEY, "[APIKEY]") + EOL; + + Throwable thrown = logRecord.getThrown(); + if (thrown != null) { + logMessage = logMessage + thrown.toString(); + } + return logMessage; + } + + public void addApiKey(String apiKey) { + API_KEY = apiKey; + return; + } +} diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/tools/XMLHelper.java b/themoviedbapi/src/com/moviejukebox/themoviedb/tools/XMLHelper.java new file mode 100644 index 000000000..8b8e55969 --- /dev/null +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/tools/XMLHelper.java @@ -0,0 +1,61 @@ +/* + * Copyright (c) 2004-2009 YAMJ Members + * http://code.google.com/p/moviejukebox/people/list + * + * Web: http://code.google.com/p/moviejukebox/ + * + * This software is licensed under a Creative Commons License + * See this page: http://code.google.com/p/moviejukebox/wiki/License + * + * For any reuse or distribution, you must make clear to others the + * license terms of this work. + */ + +package com.moviejukebox.themoviedb.tools; + +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; +import javax.xml.stream.XMLEventReader; +import javax.xml.stream.XMLInputFactory; +import javax.xml.stream.XMLStreamException; + +/** + * + * @author altman.matthew (Original) + * @author stuart.boston + */ +public class XMLHelper { + + public static XMLEventReader getEventReader(String url) throws IOException, XMLStreamException { + InputStream in = (new URL(url)).openStream(); + return XMLInputFactory.newInstance().createXMLEventReader(in); + } + + public static void closeEventReader(XMLEventReader reader) { + if (reader != null) { + try { + reader.close(); + } catch (XMLStreamException ex) { + System.err.println("ERROR: TheMovieDb API -> " + ex.getMessage()); + } + } + } + + public static String getCData(XMLEventReader r) throws XMLStreamException { + StringBuffer sb = new StringBuffer(); + while (r.peek().isCharacters()) { + sb.append(r.nextEvent().asCharacters().getData()); + } + return sb.toString().trim(); + } + + public static int parseInt(XMLEventReader r) throws XMLStreamException { + int i = 0; + String val = getCData(r); + if (val != null && !val.isEmpty()) { + i = Integer.parseInt(val); + } + return i; + } +} diff --git a/themoviedbapi/src/readme.txt b/themoviedbapi/src/readme.txt new file mode 100644 index 000000000..f481fb77c --- /dev/null +++ b/themoviedbapi/src/readme.txt @@ -0,0 +1,9 @@ +Author: Stuart.Boston AT Gmail DOT com (Omertron) + +Originally written for use by YetAnotherMovieJukebox (YAMJ) http://code.google.com/p/moviejukebox/ +But anyone can feel free to use it for other projects as well. + +This uses TheMovieDB.org API as specified here http://api.themoviedb.org/ +TheMovieDB.org is an excellent open database for movie and film content. I encourage you to check it +out and contribute to keep it growing. +http://www.themoviedb.org \ No newline at end of file From 50221b7702da4e0a53658943f9d6e4ce0ee8017d Mon Sep 17 00:00:00 2001 From: Omertron Date: Mon, 26 Jul 2010 16:52:33 +0000 Subject: [PATCH 004/207] Updated copyright information --- themoviedbapi/.classpath | 13 ++++++------- .../com/moviejukebox/themoviedb/model/Artwork.java | 2 +- .../com/moviejukebox/themoviedb/model/Category.java | 2 +- .../com/moviejukebox/themoviedb/model/Country.java | 2 +- .../com/moviejukebox/themoviedb/model/MovieDB.java | 2 +- .../com/moviejukebox/themoviedb/model/Person.java | 2 +- .../moviejukebox/themoviedb/tools/LogFormatter.java | 13 +++++++++++++ 7 files changed, 24 insertions(+), 12 deletions(-) diff --git a/themoviedbapi/.classpath b/themoviedbapi/.classpath index b148297dc..d171cd4c1 100644 --- a/themoviedbapi/.classpath +++ b/themoviedbapi/.classpath @@ -1,7 +1,6 @@ - - - - - - - + + + + + + diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/model/Artwork.java b/themoviedbapi/src/com/moviejukebox/themoviedb/model/Artwork.java index 6f2de7579..e79e77d95 100644 --- a/themoviedbapi/src/com/moviejukebox/themoviedb/model/Artwork.java +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/model/Artwork.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2009 YAMJ Members + * Copyright (c) 2004-2010 YAMJ Members * http://code.google.com/p/moviejukebox/people/list * * Web: http://code.google.com/p/moviejukebox/ diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/model/Category.java b/themoviedbapi/src/com/moviejukebox/themoviedb/model/Category.java index b9bff0a32..7e3dba6be 100644 --- a/themoviedbapi/src/com/moviejukebox/themoviedb/model/Category.java +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/model/Category.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2009 YAMJ Members + * Copyright (c) 2004-2010 YAMJ Members * http://code.google.com/p/moviejukebox/people/list * * Web: http://code.google.com/p/moviejukebox/ diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/model/Country.java b/themoviedbapi/src/com/moviejukebox/themoviedb/model/Country.java index db08d6992..a37dd2cbe 100644 --- a/themoviedbapi/src/com/moviejukebox/themoviedb/model/Country.java +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/model/Country.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2009 YAMJ Members + * Copyright (c) 2004-2010 YAMJ Members * http://code.google.com/p/moviejukebox/people/list * * Web: http://code.google.com/p/moviejukebox/ diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/model/MovieDB.java b/themoviedbapi/src/com/moviejukebox/themoviedb/model/MovieDB.java index 0c84bce36..a22ab7642 100644 --- a/themoviedbapi/src/com/moviejukebox/themoviedb/model/MovieDB.java +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/model/MovieDB.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2009 YAMJ Members + * Copyright (c) 2004-2010 YAMJ Members * http://code.google.com/p/moviejukebox/people/list * * Web: http://code.google.com/p/moviejukebox/ diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/model/Person.java b/themoviedbapi/src/com/moviejukebox/themoviedb/model/Person.java index b76ea3788..8f19afed4 100644 --- a/themoviedbapi/src/com/moviejukebox/themoviedb/model/Person.java +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/model/Person.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2009 YAMJ Members + * Copyright (c) 2004-2010 YAMJ Members * http://code.google.com/p/moviejukebox/people/list * * Web: http://code.google.com/p/moviejukebox/ diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/tools/LogFormatter.java b/themoviedbapi/src/com/moviejukebox/themoviedb/tools/LogFormatter.java index 42d5e3bef..e6992779b 100644 --- a/themoviedbapi/src/com/moviejukebox/themoviedb/tools/LogFormatter.java +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/tools/LogFormatter.java @@ -1,3 +1,16 @@ +/* + * Copyright (c) 2004-2010 YAMJ Members + * http://code.google.com/p/moviejukebox/people/list + * + * Web: http://code.google.com/p/moviejukebox/ + * + * This software is licensed under a Creative Commons License + * See this page: http://code.google.com/p/moviejukebox/wiki/License + * + * For any reuse or distribution, you must make clear to others the + * license terms of this work. + */ + package com.moviejukebox.themoviedb.tools; import java.security.PrivilegedAction; From c1f2bb663af7c5459a75f9fa87f072b284758d70 Mon Sep 17 00:00:00 2001 From: Omertron Date: Mon, 26 Jul 2010 17:28:11 +0000 Subject: [PATCH 005/207] Updated the reader to use a DOM Document rather than XML Reader --- .../moviejukebox/themoviedb/TheMovieDb.java | 673 +++++++----------- .../themoviedb/tools/XMLHelper.java | 61 -- 2 files changed, 256 insertions(+), 478 deletions(-) delete mode 100644 themoviedbapi/src/com/moviejukebox/themoviedb/tools/XMLHelper.java diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java b/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java index 9b1e8c7b6..97b5e2c80 100644 --- a/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2009 YAMJ Members + * Copyright (c) 2004-2010 YAMJ Members * http://code.google.com/p/moviejukebox/people/list * * Web: http://code.google.com/p/moviejukebox/ @@ -13,25 +13,35 @@ package com.moviejukebox.themoviedb; +import java.io.IOException; +import java.io.InputStream; +import java.net.MalformedURLException; +import java.net.URL; import java.net.URLEncoder; -import java.util.Iterator; import java.util.logging.ConsoleHandler; import java.util.logging.Level; import java.util.logging.Logger; -import javax.xml.stream.XMLEventReader; -import javax.xml.stream.XMLStreamException; -import javax.xml.stream.events.Attribute; -import javax.xml.stream.events.EndElement; -import javax.xml.stream.events.StartElement; -import javax.xml.stream.events.XMLEvent; +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; -import com.moviejukebox.themoviedb.model.*; -import com.moviejukebox.themoviedb.tools.*; +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import org.xml.sax.SAXException; + +import com.moviejukebox.themoviedb.model.Artwork; +import com.moviejukebox.themoviedb.model.Category; +import com.moviejukebox.themoviedb.model.Country; +import com.moviejukebox.themoviedb.model.MovieDB; +import com.moviejukebox.themoviedb.model.Person; +import com.moviejukebox.themoviedb.tools.LogFormatter; /** - * This is the main class for the API to connect to TheMovieDb.org The implementation is for v2.1 of the API as detailed here - * http://api.themoviedb.org/2.1/docs/ + * This is the main class for the API to connect to TheMovieDb.org The implementation is for v2.1 + * of the API as detailed here http://api.themoviedb.org/2.1/docs/ * * @author Stuart.Boston * @version 1.1 @@ -80,8 +90,8 @@ public class TheMovieDb { * @return A movie bean with the data extracted */ public MovieDB moviedbSearch(String movieTitle, String language) { - XMLEventReader xmlReader = null; MovieDB movie = null; + Document doc = null; language = validateLanguage(language); @@ -91,12 +101,11 @@ public class TheMovieDb { try { String searchUrl = buildSearchUrl("Movie.search", URLEncoder.encode(movieTitle, "UTF-8"), language); - xmlReader = XMLHelper.getEventReader(searchUrl); - movie = parseMovieInfo(xmlReader); + doc = getEventDocFromUrl(searchUrl); + movie = parseMovieInfo(doc); + } catch (Exception error) { - System.err.println("ERROR: TheMovieDb API -> " + error.getMessage()); - } finally { - XMLHelper.closeEventReader(xmlReader); + logger.severe("ERROR: " + error.getMessage()); } return movie; } @@ -109,8 +118,8 @@ public class TheMovieDb { * @return A movie bean with the data extracted */ public MovieDB moviedbImdbLookup(String imdbID, String language) { - XMLEventReader xmlReader = null; MovieDB movie = null; + Document doc = null; language = validateLanguage(language); @@ -120,12 +129,14 @@ public class TheMovieDb { try { String searchUrl = buildSearchUrl("Movie.imdbLookup", imdbID, language); - xmlReader = XMLHelper.getEventReader(searchUrl); - movie = parseMovieInfo(xmlReader); + //xmlReader = XMLHelper.getEventReader(searchUrl); + //movie = parseMovieInfo(xmlReader); + + doc = getEventDocFromUrl(searchUrl); + movie = parseMovieInfo(doc); + } catch (Exception error) { - System.err.println("ERROR: TheMovieDb API -> " + error.getMessage()); - } finally { - XMLHelper.closeEventReader(xmlReader); + logger.severe("ERROR: " + error.getMessage()); } return movie; } @@ -155,7 +166,7 @@ public class TheMovieDb { * @return A movie bean with all of the information */ public MovieDB moviedbGetInfo(String tmdbID, MovieDB movie, String language) { - XMLEventReader xmlReader = null; + Document doc = null; // If the tmdbID is null, then exit if (tmdbID == null || tmdbID.equals("") || tmdbID.equalsIgnoreCase("UNKNOWN")) @@ -165,12 +176,14 @@ public class TheMovieDb { try { String searchUrl = buildSearchUrl("Movie.getImages", tmdbID, language); - xmlReader = XMLHelper.getEventReader(searchUrl); - movie = parseMovieInfo(xmlReader); + //xmlReader = XMLHelper.getEventReader(searchUrl); + //movie = parseMovieInfo(xmlReader); + + doc = getEventDocFromUrl(searchUrl); + movie = parseMovieInfo(doc); + } catch (Exception error) { - System.err.println("ERROR: TheMovieDb API -> " + error.getMessage()); - } finally { - XMLHelper.closeEventReader(xmlReader); + logger.severe("ERROR: " + error.getMessage()); } return movie; } @@ -189,7 +202,7 @@ public class TheMovieDb { * @return */ public MovieDB moviedbGetImages(String searchTerm, MovieDB movie, String language) { - XMLEventReader xmlReader = null; + Document doc = null; // If the searchTerm is null, then exit if (searchTerm == null || searchTerm.equals("") || searchTerm.equalsIgnoreCase("UNKNOWN")) @@ -199,398 +212,19 @@ public class TheMovieDb { try { String searchUrl = buildSearchUrl("Movie.getImages", searchTerm, language); - xmlReader = XMLHelper.getEventReader(searchUrl); - movie = parseMovieInfo(xmlReader); - } catch (Exception error) { - System.err.println("ERROR: TheMovieDb API -> " + error.getMessage()); - } finally { - XMLHelper.closeEventReader(xmlReader); - } - - return movie; - } - - /** - * Search the XML passed and decode to a movieDB bean - * - * @param xmlReader - * The XML stream read from TheMovieDB.org - * @return a MovieDB bean with the data - * @throws XMLStreamException - */ - // TODO Waring if match is low (i.e. score != 1.0) - @SuppressWarnings("unchecked") - public MovieDB parseMovieInfo(XMLEventReader xmlReader) throws XMLStreamException { - MovieDB movie = null; - try { - while (xmlReader.hasNext()) { - XMLEvent event = xmlReader.nextEvent(); - - if (event.isStartElement()) { - StartElement startElement = event.asStartElement(); - - if (startElement.getName().getLocalPart().equalsIgnoreCase("movie")) { - movie = new MovieDB(); - } - - if (event.isStartElement()) { - if (event.asStartElement().getName().getLocalPart().equalsIgnoreCase("popularity")) { - event = xmlReader.nextEvent(); - movie.setPopularity(event.asCharacters().getData()); - continue; - } - } - - if (event.isStartElement()) { - if (event.asStartElement().getName().getLocalPart().equalsIgnoreCase("name")) { - event = xmlReader.nextEvent(); - movie.setTitle(event.asCharacters().getData()); - continue; - } - } - - if (event.isStartElement()) { - if (event.asStartElement().getName().getLocalPart().equalsIgnoreCase("type")) { - event = xmlReader.nextEvent(); - movie.setType(event.asCharacters().getData()); - continue; - } - } - - if (event.isStartElement()) { - if (event.asStartElement().getName().getLocalPart().equalsIgnoreCase("id")) { - event = xmlReader.nextEvent(); - movie.setId(event.asCharacters().getData()); - continue; - } - } - - if (event.isStartElement()) { - if (event.asStartElement().getName().getLocalPart().equalsIgnoreCase("imdb_id")) { - event = xmlReader.nextEvent(); - movie.setImdb(event.asCharacters().getData()); - continue; - } - } - - if (event.isStartElement()) { - if (event.asStartElement().getName().getLocalPart().equalsIgnoreCase("url")) { - event = xmlReader.nextEvent(); - movie.setUrl(event.asCharacters().getData()); - continue; - } - } - - if (event.isStartElement()) { - if (event.asStartElement().getName().getLocalPart().equalsIgnoreCase("overview")) { - event = xmlReader.nextEvent(); - movie.setOverview(event.asCharacters().getData()); - continue; - } - } - - if (event.isStartElement()) { - if (event.asStartElement().getName().getLocalPart().equalsIgnoreCase("rating")) { - event = xmlReader.nextEvent(); - movie.setRating(event.asCharacters().getData()); - continue; - } - } - - if (event.isStartElement()) { - if (event.asStartElement().getName().getLocalPart().equalsIgnoreCase("released")) { - event = xmlReader.nextEvent(); - movie.setReleaseDate(event.asCharacters().getData()); - continue; - } - } - - if (event.isStartElement()) { - if (event.asStartElement().getName().getLocalPart().equalsIgnoreCase("runtime")) { - event = xmlReader.nextEvent(); - movie.setRuntime(event.asCharacters().getData()); - continue; - } - } - - if (event.isStartElement()) { - if (event.asStartElement().getName().getLocalPart().equalsIgnoreCase("budget")) { - event = xmlReader.nextEvent(); - movie.setBudget(event.asCharacters().getData()); - continue; - } - } - - if (event.isStartElement()) { - if (event.asStartElement().getName().getLocalPart().equalsIgnoreCase("revenue")) { - event = xmlReader.nextEvent(); - movie.setRevenue(event.asCharacters().getData()); - continue; - } - } - - if (event.isStartElement()) { - if (event.asStartElement().getName().getLocalPart().equalsIgnoreCase("homepage")) { - event = xmlReader.nextEvent(); - movie.setHomepage(event.asCharacters().getData()); - continue; - } - } - - if (event.isStartElement()) { - if (event.asStartElement().getName().getLocalPart().equalsIgnoreCase("trailer")) { - event = xmlReader.nextEvent(); - movie.setTrailer(event.asCharacters().getData()); - continue; - } - } - - if (event.isStartElement()) { - if (event.asStartElement().getName().getLocalPart().equalsIgnoreCase("categories")) { - event = xmlReader.nextEvent(); - startElement = event.asStartElement(); - - while (!event.isEndElement() && !event.asEndElement().getName().getLocalPart().equalsIgnoreCase("category")) { - Category category = new Category(); - Iterator attributes = startElement.getAttributes(); - while (attributes.hasNext()) { - Attribute attribute = attributes.next(); - if (attribute.getName().toString().equals("type")) - category.setType(attribute.getValue()); - if (attribute.getName().toString().equals("url")) - category.setUrl(attribute.getValue()); - if (attribute.getName().toString().equals("name")) - category.setName(attribute.getValue()); - - } - movie.addCategory(category); - } - } - } - - if (event.isStartElement()) { - if (event.asStartElement().getName().getLocalPart().equalsIgnoreCase("countries")) { - event = xmlReader.nextEvent(); - startElement = event.asStartElement(); - - while (!event.isEndElement() && !event.asEndElement().getName().getLocalPart().equalsIgnoreCase("country")) { - Country country = new Country(); - Iterator attributes = startElement.getAttributes(); - while (attributes.hasNext()) { - Attribute attribute = attributes.next(); - if (attribute.getName().toString().equals("code")) - country.setCode(attribute.getValue()); - if (attribute.getName().toString().equals("url")) - country.setUrl(attribute.getValue()); - if (attribute.getName().toString().equals("name")) - country.setName(attribute.getValue()); - } - movie.addProductionCountry(country); - } - } - } - - if (event.isStartElement()) { - if (event.asStartElement().getName().getLocalPart().equalsIgnoreCase("cast")) { - event = xmlReader.nextEvent(); - startElement = event.asStartElement(); - - while (!event.isEndElement() && !event.asEndElement().getName().getLocalPart().equalsIgnoreCase("person")) { - Person person = new Person(); - Iterator attributes = startElement.getAttributes(); - while (attributes.hasNext()) { - Attribute attribute = attributes.next(); - if (attribute.getName().toString().equals("url")) - person.setUrl(attribute.getValue()); - if (attribute.getName().toString().equals("name")) - person.setName(attribute.getValue()); - if (attribute.getName().toString().equals("job")) - person.setJob(attribute.getValue()); - if (attribute.getName().toString().equals("character")) - person.setCharacter(attribute.getValue()); - if (attribute.getName().toString().equals("id")) - person.setId(attribute.getValue()); - } - movie.addPerson(person); - } - } - } - - /* - * This processes the image elements. There are two formats to deal with: - * Movie.imdbLookup, Movie.getInfo & Movie.search: - * - * - * - * - * - * Movie.getImages: - * - * - * - * - * - * - * - * - * - * - * - * - * - */ - if (checkStartEvent(event, "images")) { - event = xmlReader.nextEvent(); - - while (!checkEndEvent(event, "images")) { - if (checkStartEvent(event, "image")) { - Artwork artwork = new Artwork(); - Iterator attributes = event.asStartElement().getAttributes(); - while (attributes.hasNext()) { - Attribute attribute = attributes.next(); - if (attribute.getName().toString().equalsIgnoreCase("type")) - artwork.setType(attribute.getValue()); - if (attribute.getName().toString().equalsIgnoreCase("size")) - artwork.setSize(attribute.getValue()); - if (attribute.getName().toString().equalsIgnoreCase("url")) - artwork.setUrl(attribute.getValue()); - if (attribute.getName().toString().equalsIgnoreCase("id")) - artwork.setId(attribute.getValue()); - } - event = xmlReader.nextEvent(); // Skip the characters at the end of the attributes - movie.addArtwork(artwork); - } - - if (checkStartEvent(event, "poster")) { - Artwork artwork = new Artwork(); - String imageId = getImageId(event); - event = xmlReader.nextEvent(); // Skip the characters at the end of the attributes - event = xmlReader.nextEvent(); - - while (!checkEndEvent(event, "poster")) { - artwork = new Artwork(); - artwork.setType(Artwork.ARTWORK_TYPE_POSTER); - artwork.setId(imageId); - - if (checkStartEvent(event, "image")) { - Iterator attributes = event.asStartElement().getAttributes(); - while (attributes.hasNext()) { - Attribute attribute = attributes.next(); - if (attribute.getName().toString().equalsIgnoreCase("url")) - artwork.setUrl(attribute.getValue()); - if (attribute.getName().toString().equalsIgnoreCase("size")) - artwork.setSize(attribute.getValue()); - } - event = xmlReader.nextEvent(); // Skip the characters at the end of the attributes - movie.addArtwork(artwork); - } - event = xmlReader.nextEvent(); - } - } - - if (checkStartEvent(event, "backdrop")) { - Artwork artwork = new Artwork(); - String imageId = getImageId(event); - event = xmlReader.nextEvent(); // Skip the characters at the end of the attributes - event = xmlReader.nextEvent(); - - while (!checkEndEvent(event, "backdrop")) { - artwork = new Artwork(); - artwork.setType(Artwork.ARTWORK_TYPE_BACKDROP); - artwork.setId(imageId); - - if (checkStartEvent(event, "image")) { - Iterator attributes = event.asStartElement().getAttributes(); - while (attributes.hasNext()) { - Attribute attribute = attributes.next(); - if (attribute.getName().toString().equalsIgnoreCase("url")) - artwork.setUrl(attribute.getValue()); - if (attribute.getName().toString().equalsIgnoreCase("size")) - artwork.setSize(attribute.getValue()); - } - event = xmlReader.nextEvent(); // Skip the characters at the end of the attributes - movie.addArtwork(artwork); - } - event = xmlReader.nextEvent(); - } - } - event = xmlReader.nextEvent(); - } // While "images" - } // If "images" - } // if start element + //xmlReader = XMLHelper.getEventReader(searchUrl); + //movie = parseMovieInfo(xmlReader); - if (event.isEndElement()) { - EndElement endElement = event.asEndElement(); - if (endElement.getName().getLocalPart().equalsIgnoreCase("movie")) { - break; - } - } - } + doc = getEventDocFromUrl(searchUrl); + movie = parseMovieInfo(doc); + } catch (Exception error) { - System.err.println("Error: " + error.getMessage()); - error.printStackTrace(); + logger.severe("ERROR: " + error.getMessage()); } + return movie; } - - /** - * Check to see if the event passed is a start element and matches the eventName - * @param event - * @param endString - * @return True if the event is an end element and matches the eventName - */ - private boolean checkStartEvent(XMLEvent event, String eventName) { - boolean validElement = false; - - if (event.isStartElement()) { - if (event.asStartElement().getName().getLocalPart().equalsIgnoreCase(eventName)) { - validElement = true; - } - } - return validElement; - } - - /** - * Check to see if the event passed is an end element and matches the eventName - * @param event - * @param endString - * @return True if the event is an end element and matches the eventName - */ - private boolean checkEndEvent(XMLEvent event, String eventName) { - boolean validElement = false; - - if (event.isEndElement()) { - if (event.asEndElement().getName().getLocalPart().equalsIgnoreCase(eventName)) { - validElement = true; - } - } - return validElement; - } - /** - * Find the ID in the element attributes - * @param event - * @return the imageId - */ - @SuppressWarnings({"unchecked"}) - private String getImageId(XMLEvent event) { - String imageId = null; - - try { - // read the id attribute from the element - Iterator attributes = event.asStartElement().getAttributes(); - while (attributes.hasNext()) { - Attribute attribute = attributes.next(); - if (attribute.getName().toString().equalsIgnoreCase("id")) - imageId = attribute.getValue(); - } - } catch (Exception error) { - imageId = null; - } - - return imageId; - } - /** * This function will check the passed language against a list of known themoviedb.org languages * Currently the only available language is English "en" and so that is what this function returns @@ -605,4 +239,209 @@ public class TheMovieDb { } return language; } + + public MovieDB parseMovieInfo(Document doc) { + // Borrowed from http://www.java-tips.org/java-se-tips/javax.xml.parsers/how-to-read-xml-file-in-java.html + MovieDB movie = null; + NodeList movieNodeList, subNodeList; + Node movieNode, subNode; + Element movieElement, subElement; + + try { + movie = new MovieDB(); + movieNodeList = doc.getElementsByTagName("movie"); + + // Only get the first movie from the list + movieNode = movieNodeList.item(0); + + if (movieNode.getNodeType() == Node.ELEMENT_NODE) { + movieElement = (Element) movieNode; + + movie.setTitle(getValueFromElement(movieElement, "name")); + movie.setPopularity(getValueFromElement(movieElement, "popularity")); + movie.setType(getValueFromElement(movieElement, "type")); + movie.setId(getValueFromElement(movieElement, "id")); + movie.setImdb(getValueFromElement(movieElement, "imdb_id")); + movie.setUrl(getValueFromElement(movieElement, "url")); + movie.setOverview(getValueFromElement(movieElement, "overview")); + movie.setRating(getValueFromElement(movieElement, "rating")); + movie.setReleaseDate(getValueFromElement(movieElement, "released")); + movie.setRuntime(getValueFromElement(movieElement, "runtime")); + movie.setBudget(getValueFromElement(movieElement, "budget")); + movie.setRevenue(getValueFromElement(movieElement, "revenue")); + movie.setHomepage(getValueFromElement(movieElement, "homepage")); + movie.setTrailer(getValueFromElement(movieElement, "trailer")); + + // Process the "categories" + subNodeList = doc.getElementsByTagName("categories"); + + for (int nodeLoop = 0; nodeLoop < subNodeList.getLength(); nodeLoop++) { + subNode = subNodeList.item(nodeLoop); + if (subNode.getNodeType() == Node.ELEMENT_NODE) { + subElement = (Element) subNode; + Category category = new Category(); + + category.setType(getValueFromElement(subElement, "type")); + category.setUrl(getValueFromElement(subElement, "url")); + category.setName(getValueFromElement(subElement, "name")); + + movie.addCategory(category); + } + } + + // Process the "countries" + subNodeList = doc.getElementsByTagName("countries"); + + for (int nodeLoop = 0; nodeLoop < subNodeList.getLength(); nodeLoop++) { + subNode = subNodeList.item(nodeLoop); + if (subNode.getNodeType() == Node.ELEMENT_NODE) { + subElement = (Element) subNode; + Country country = new Country(); + + country.setCode(getValueFromElement(subElement, "code")); + country.setUrl(getValueFromElement(subElement, "url")); + country.setName(getValueFromElement(subElement, "name")); + + movie.addProductionCountry(country); + } + } + + // Process the "cast" + subNodeList = doc.getElementsByTagName("cast"); + + for (int nodeLoop = 0; nodeLoop < subNodeList.getLength(); nodeLoop++) { + subNode = subNodeList.item(nodeLoop); + if (subNode.getNodeType() == Node.ELEMENT_NODE) { + subElement = (Element) subNode; + Person person = new Person(); + + person.setUrl(getValueFromElement(subElement, "url")); + person.setName(getValueFromElement(subElement, "name")); + person.setJob(getValueFromElement(subElement, "job")); + person.setCharacter(getValueFromElement(subElement, "character")); + person.setId(getValueFromElement(subElement, "id")); + + movie.addPerson(person); + } + } + + /* + * This processes the image elements. There are two formats to deal with: + * Movie.imdbLookup, Movie.getInfo & Movie.search: + * + * + * + * + * + * Movie.getImages: + * + * + * + * + * + * + * + * + * + * + * + * + * + */ + subNodeList = doc.getElementsByTagName("images"); + + for (int nodeLoop = 0; nodeLoop < subNodeList.getLength(); nodeLoop++) { + subNode = subNodeList.item(nodeLoop); + + if (subNode.getNodeType() == Node.ELEMENT_NODE) { + System.out.println("Element Node: " + subNode.getNodeName() + " Attribs: " + subNode.hasAttributes() + " Children: " + subNode.hasChildNodes()); + + NodeList artworkNodeList = subNode.getChildNodes(); + for (int artworkLoop = 0; artworkLoop < artworkNodeList.getLength(); artworkLoop++) { + Node artworkNode = artworkNodeList.item(artworkLoop); + if (artworkNode.getNodeType() == Node.ELEMENT_NODE) { + subElement = (Element) artworkNode; + + if (subElement.getNodeName().equalsIgnoreCase("image")) { + // This is the format used in Movie.imdbLookup, Movie.getInfo & Movie.search + Artwork artwork = new Artwork(); + artwork.setType(subElement.getAttribute("type")); + artwork.setSize(subElement.getAttribute("size")); + artwork.setUrl(subElement.getAttribute("url")); + artwork.setId(subElement.getAttribute("id")); + movie.addArtwork(artwork); + } else if (subElement.getNodeName().equalsIgnoreCase("backdrop") || + subElement.getNodeName().equalsIgnoreCase("poster")) { + // This is the format used in Movie.getImages + String artworkId = subElement.getAttribute("id"); + String artworkType = subElement.getNodeName(); + + // We need to decode and loop round the child nodes to get the data + NodeList imageNodeList = subElement.getChildNodes(); + for (int imageLoop = 0; imageLoop < imageNodeList.getLength(); imageLoop++) { + Node imageNode = imageNodeList.item(imageLoop); + if (imageNode.getNodeType() == Node.ELEMENT_NODE) { + Element imageElement = (Element) imageNode; + Artwork artwork = new Artwork(); + artwork.setId(artworkId); + artwork.setType(artworkType); + artwork.setUrl(imageElement.getAttribute("url")); + artwork.setSize(imageElement.getAttribute("size")); + movie.addArtwork(artwork); + } + } + } else { + // This is a classic, it should never happen error + logger.severe("UNKNOWN Image type"); + } + } + } + } + } + } + } catch (Exception error) { + logger.severe("ERROR: " + error.getMessage()); + error.printStackTrace(); + } + return movie; + } + + /** + * Gets the string value of the tag element name passed + * @param element + * @param tagName + * @return + */ + private String getValueFromElement(Element element, String tagName) { + String returnValue = ""; + + try { + NodeList elementNodeList = element.getElementsByTagName(tagName); + Element tagElement = (Element) elementNodeList.item(0); + NodeList tagNodeList = tagElement.getChildNodes(); + returnValue = ((Node) tagNodeList.item(0)).getNodeValue(); + } catch (Exception ignore) { + return returnValue; + } + + return returnValue; + } + + /** + * Get a DOM document from the supplied URL + * @param url + * @return + * @throws MalformedURLException + * @throws IOException + * @throws ParserConfigurationException + * @throws SAXException + */ + public static Document getEventDocFromUrl(String url) throws MalformedURLException, IOException, ParserConfigurationException, SAXException { + InputStream in = (new URL(url)).openStream(); + DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); + DocumentBuilder db = dbf.newDocumentBuilder(); + Document doc = db.parse(in); + doc.getDocumentElement().normalize(); + return doc; + } } diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/tools/XMLHelper.java b/themoviedbapi/src/com/moviejukebox/themoviedb/tools/XMLHelper.java deleted file mode 100644 index 8b8e55969..000000000 --- a/themoviedbapi/src/com/moviejukebox/themoviedb/tools/XMLHelper.java +++ /dev/null @@ -1,61 +0,0 @@ -/* - * Copyright (c) 2004-2009 YAMJ Members - * http://code.google.com/p/moviejukebox/people/list - * - * Web: http://code.google.com/p/moviejukebox/ - * - * This software is licensed under a Creative Commons License - * See this page: http://code.google.com/p/moviejukebox/wiki/License - * - * For any reuse or distribution, you must make clear to others the - * license terms of this work. - */ - -package com.moviejukebox.themoviedb.tools; - -import java.io.IOException; -import java.io.InputStream; -import java.net.URL; -import javax.xml.stream.XMLEventReader; -import javax.xml.stream.XMLInputFactory; -import javax.xml.stream.XMLStreamException; - -/** - * - * @author altman.matthew (Original) - * @author stuart.boston - */ -public class XMLHelper { - - public static XMLEventReader getEventReader(String url) throws IOException, XMLStreamException { - InputStream in = (new URL(url)).openStream(); - return XMLInputFactory.newInstance().createXMLEventReader(in); - } - - public static void closeEventReader(XMLEventReader reader) { - if (reader != null) { - try { - reader.close(); - } catch (XMLStreamException ex) { - System.err.println("ERROR: TheMovieDb API -> " + ex.getMessage()); - } - } - } - - public static String getCData(XMLEventReader r) throws XMLStreamException { - StringBuffer sb = new StringBuffer(); - while (r.peek().isCharacters()) { - sb.append(r.nextEvent().asCharacters().getData()); - } - return sb.toString().trim(); - } - - public static int parseInt(XMLEventReader r) throws XMLStreamException { - int i = 0; - String val = getCData(r); - if (val != null && !val.isEmpty()) { - i = Integer.parseInt(val); - } - return i; - } -} From c933817444a585f06c2483dbcf1247cf4806edbe Mon Sep 17 00:00:00 2001 From: Omertron Date: Mon, 26 Jul 2010 18:04:52 +0000 Subject: [PATCH 006/207] Updated build file --- themoviedbapi/build.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themoviedbapi/build.xml b/themoviedbapi/build.xml index ed4f360d9..3608c9cef 100644 --- a/themoviedbapi/build.xml +++ b/themoviedbapi/build.xml @@ -45,7 +45,7 @@ - + From cf21478246327a5f73c3c662212fd2ebaf72007d Mon Sep 17 00:00:00 2001 From: Omertron Date: Tue, 27 Jul 2010 06:53:31 +0000 Subject: [PATCH 007/207] Removed debug messages --- .../src/com/moviejukebox/themoviedb/TheMovieDb.java | 7 ------- 1 file changed, 7 deletions(-) diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java b/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java index 97b5e2c80..7155a531b 100644 --- a/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java @@ -129,8 +129,6 @@ public class TheMovieDb { try { String searchUrl = buildSearchUrl("Movie.imdbLookup", imdbID, language); - //xmlReader = XMLHelper.getEventReader(searchUrl); - //movie = parseMovieInfo(xmlReader); doc = getEventDocFromUrl(searchUrl); movie = parseMovieInfo(doc); @@ -176,8 +174,6 @@ public class TheMovieDb { try { String searchUrl = buildSearchUrl("Movie.getImages", tmdbID, language); - //xmlReader = XMLHelper.getEventReader(searchUrl); - //movie = parseMovieInfo(xmlReader); doc = getEventDocFromUrl(searchUrl); movie = parseMovieInfo(doc); @@ -212,8 +208,6 @@ public class TheMovieDb { try { String searchUrl = buildSearchUrl("Movie.getImages", searchTerm, language); - //xmlReader = XMLHelper.getEventReader(searchUrl); - //movie = parseMovieInfo(xmlReader); doc = getEventDocFromUrl(searchUrl); movie = parseMovieInfo(doc); @@ -354,7 +348,6 @@ public class TheMovieDb { subNode = subNodeList.item(nodeLoop); if (subNode.getNodeType() == Node.ELEMENT_NODE) { - System.out.println("Element Node: " + subNode.getNodeName() + " Attribs: " + subNode.hasAttributes() + " Children: " + subNode.hasChildNodes()); NodeList artworkNodeList = subNode.getChildNodes(); for (int artworkLoop = 0; artworkLoop < artworkNodeList.getLength(); artworkLoop++) { From 958eb24050e086d590ecc767bd3bbb5501fee9b8 Mon Sep 17 00:00:00 2001 From: Omertron Date: Tue, 27 Jul 2010 11:42:59 +0000 Subject: [PATCH 008/207] Updates the build.xml file to include source code in the jar --- themoviedbapi/build.xml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/themoviedbapi/build.xml b/themoviedbapi/build.xml index 3608c9cef..27027c642 100644 --- a/themoviedbapi/build.xml +++ b/themoviedbapi/build.xml @@ -43,7 +43,14 @@ - + + + + + + + + From 56c3bfb9cba9d9d70bf5d5b1f5dea27015d015b8 Mon Sep 17 00:00:00 2001 From: Omertron Date: Tue, 27 Jul 2010 11:47:12 +0000 Subject: [PATCH 009/207] Fixes null errors for films that aren't found New issue Status: fixed Summary: Null errors for films that aren't found on the site --- .../src/com/moviejukebox/themoviedb/TheMovieDb.java | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java b/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java index 7155a531b..fcdcbe96d 100644 --- a/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java @@ -247,6 +247,11 @@ public class TheMovieDb { // Only get the first movie from the list movieNode = movieNodeList.item(0); + + if (movieNode == null) { + logger.finest("Movie not found"); + return movie; + } if (movieNode.getNodeType() == Node.ELEMENT_NODE) { movieElement = (Element) movieNode; From 92c056ec0b14aef5a6b7c6b20b54b0807d5a41ae Mon Sep 17 00:00:00 2001 From: Omertron Date: Wed, 28 Jul 2010 08:22:46 +0000 Subject: [PATCH 010/207] Fixes issue 1 Fixes issue 2 --- .../moviejukebox/themoviedb/TheMovieDb.java | 341 ++++++------------ .../themoviedb/model/Artwork.java | 6 +- .../themoviedb/model/Filmography.java | 71 ++++ .../themoviedb/model/MovieDB.java | 158 +------- .../moviejukebox/themoviedb/model/Person.java | 149 +++++++- .../themoviedb/tools/DOMHelper.java | 75 ++++ .../themoviedb/tools/DOMParser.java | 276 ++++++++++++++ .../themoviedb/tools/ModelTools.java | 176 +++++++++ 8 files changed, 850 insertions(+), 402 deletions(-) create mode 100644 themoviedbapi/src/com/moviejukebox/themoviedb/model/Filmography.java create mode 100644 themoviedbapi/src/com/moviejukebox/themoviedb/tools/DOMHelper.java create mode 100644 themoviedbapi/src/com/moviejukebox/themoviedb/tools/DOMParser.java create mode 100644 themoviedbapi/src/com/moviejukebox/themoviedb/tools/ModelTools.java diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java b/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java index fcdcbe96d..afe38f2dd 100644 --- a/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java @@ -13,30 +13,17 @@ package com.moviejukebox.themoviedb; -import java.io.IOException; -import java.io.InputStream; -import java.net.MalformedURLException; -import java.net.URL; import java.net.URLEncoder; import java.util.logging.ConsoleHandler; import java.util.logging.Level; import java.util.logging.Logger; -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; - import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.xml.sax.SAXException; -import com.moviejukebox.themoviedb.model.Artwork; -import com.moviejukebox.themoviedb.model.Category; -import com.moviejukebox.themoviedb.model.Country; import com.moviejukebox.themoviedb.model.MovieDB; import com.moviejukebox.themoviedb.model.Person; +import com.moviejukebox.themoviedb.tools.DOMHelper; +import com.moviejukebox.themoviedb.tools.DOMParser; import com.moviejukebox.themoviedb.tools.LogFormatter; /** @@ -44,7 +31,7 @@ import com.moviejukebox.themoviedb.tools.LogFormatter; * of the API as detailed here http://api.themoviedb.org/2.1/docs/ * * @author Stuart.Boston - * @version 1.1 + * @version 1.3 */ public class TheMovieDb { @@ -52,21 +39,41 @@ public class TheMovieDb { private static String apiSite = "http://api.themoviedb.org/2.1/"; private static String defaultLanguage = "en"; private static Logger logger; + private static LogFormatter tmdbFormatter = new LogFormatter(); + private static ConsoleHandler tmdbConsoleHandler = new ConsoleHandler(); - public TheMovieDb(String apiKey) { - logger = Logger.getLogger("TheMovieDB"); - LogFormatter mjbFormatter = new LogFormatter(); - ConsoleHandler ch = new ConsoleHandler(); - ch.setFormatter(mjbFormatter); - ch.setLevel(Level.FINE); - logger.addHandler(ch); - logger.setUseParentHandlers(true); - logger.setLevel(Level.ALL); - - this.apiKey = apiKey; - mjbFormatter.addApiKey(apiKey); + public TheMovieDb(String apiKey) { + setLogger(Logger.getLogger("TheMovieDB")); + setApiKey(apiKey); } + public TheMovieDb(String apiKey, Logger logger) { + setLogger(logger); + setApiKey(apiKey); + } + + public static Logger getLogger() { + return logger; + } + + public static void setLogger(Logger logger) { + TheMovieDb.logger = logger; + tmdbConsoleHandler.setFormatter(tmdbFormatter); + tmdbConsoleHandler.setLevel(Level.FINE); + logger.addHandler(tmdbConsoleHandler); + logger.setUseParentHandlers(true); + logger.setLevel(Level.ALL); + } + + public String getApiKey() { + return apiKey; + } + + public void setApiKey(String apiKey) { + this.apiKey = apiKey; + tmdbFormatter.addApiKey(apiKey); + } + /** * Build the search URL from the search prefix and movie title. * This will change between v2.0 and v2.1 of the API @@ -101,8 +108,8 @@ public class TheMovieDb { try { String searchUrl = buildSearchUrl("Movie.search", URLEncoder.encode(movieTitle, "UTF-8"), language); - doc = getEventDocFromUrl(searchUrl); - movie = parseMovieInfo(doc); + doc = DOMHelper.getEventDocFromUrl(searchUrl); + movie = DOMParser.parseMovieInfo(doc); } catch (Exception error) { logger.severe("ERROR: " + error.getMessage()); @@ -130,8 +137,8 @@ public class TheMovieDb { try { String searchUrl = buildSearchUrl("Movie.imdbLookup", imdbID, language); - doc = getEventDocFromUrl(searchUrl); - movie = parseMovieInfo(doc); + doc = DOMHelper.getEventDocFromUrl(searchUrl); + movie = DOMParser.parseMovieInfo(doc); } catch (Exception error) { logger.severe("ERROR: " + error.getMessage()); @@ -175,8 +182,8 @@ public class TheMovieDb { try { String searchUrl = buildSearchUrl("Movie.getImages", tmdbID, language); - doc = getEventDocFromUrl(searchUrl); - movie = parseMovieInfo(doc); + doc = DOMHelper.getEventDocFromUrl(searchUrl); + movie = DOMParser.parseMovieInfo(doc); } catch (Exception error) { logger.severe("ERROR: " + error.getMessage()); @@ -209,8 +216,8 @@ public class TheMovieDb { try { String searchUrl = buildSearchUrl("Movie.getImages", searchTerm, language); - doc = getEventDocFromUrl(searchUrl); - movie = parseMovieInfo(doc); + doc = DOMHelper.getEventDocFromUrl(searchUrl); + movie = DOMParser.parseMovieInfo(doc); } catch (Exception error) { logger.severe("ERROR: " + error.getMessage()); @@ -234,212 +241,94 @@ public class TheMovieDb { return language; } - public MovieDB parseMovieInfo(Document doc) { - // Borrowed from http://www.java-tips.org/java-se-tips/javax.xml.parsers/how-to-read-xml-file-in-java.html - MovieDB movie = null; - NodeList movieNodeList, subNodeList; - Node movieNode, subNode; - Element movieElement, subElement; + + /** + * The Person.search method is used to search for an actor, actress or production member. + * http://api.themoviedb.org/2.1/methods/Person.search + * + * @param personName + * @param language + * @return + */ + public Person personSearch(String personName, String language) { + Person person = new Person(); + Document doc = null; + + language = validateLanguage(language); + + if (personName == null || personName.equals("")) { + return person; + } try { - movie = new MovieDB(); - movieNodeList = doc.getElementsByTagName("movie"); - - // Only get the first movie from the list - movieNode = movieNodeList.item(0); - - if (movieNode == null) { - logger.finest("Movie not found"); - return movie; - } - - if (movieNode.getNodeType() == Node.ELEMENT_NODE) { - movieElement = (Element) movieNode; - - movie.setTitle(getValueFromElement(movieElement, "name")); - movie.setPopularity(getValueFromElement(movieElement, "popularity")); - movie.setType(getValueFromElement(movieElement, "type")); - movie.setId(getValueFromElement(movieElement, "id")); - movie.setImdb(getValueFromElement(movieElement, "imdb_id")); - movie.setUrl(getValueFromElement(movieElement, "url")); - movie.setOverview(getValueFromElement(movieElement, "overview")); - movie.setRating(getValueFromElement(movieElement, "rating")); - movie.setReleaseDate(getValueFromElement(movieElement, "released")); - movie.setRuntime(getValueFromElement(movieElement, "runtime")); - movie.setBudget(getValueFromElement(movieElement, "budget")); - movie.setRevenue(getValueFromElement(movieElement, "revenue")); - movie.setHomepage(getValueFromElement(movieElement, "homepage")); - movie.setTrailer(getValueFromElement(movieElement, "trailer")); - - // Process the "categories" - subNodeList = doc.getElementsByTagName("categories"); - - for (int nodeLoop = 0; nodeLoop < subNodeList.getLength(); nodeLoop++) { - subNode = subNodeList.item(nodeLoop); - if (subNode.getNodeType() == Node.ELEMENT_NODE) { - subElement = (Element) subNode; - Category category = new Category(); - - category.setType(getValueFromElement(subElement, "type")); - category.setUrl(getValueFromElement(subElement, "url")); - category.setName(getValueFromElement(subElement, "name")); - - movie.addCategory(category); - } - } - - // Process the "countries" - subNodeList = doc.getElementsByTagName("countries"); - - for (int nodeLoop = 0; nodeLoop < subNodeList.getLength(); nodeLoop++) { - subNode = subNodeList.item(nodeLoop); - if (subNode.getNodeType() == Node.ELEMENT_NODE) { - subElement = (Element) subNode; - Country country = new Country(); - - country.setCode(getValueFromElement(subElement, "code")); - country.setUrl(getValueFromElement(subElement, "url")); - country.setName(getValueFromElement(subElement, "name")); - - movie.addProductionCountry(country); - } - } - - // Process the "cast" - subNodeList = doc.getElementsByTagName("cast"); - - for (int nodeLoop = 0; nodeLoop < subNodeList.getLength(); nodeLoop++) { - subNode = subNodeList.item(nodeLoop); - if (subNode.getNodeType() == Node.ELEMENT_NODE) { - subElement = (Element) subNode; - Person person = new Person(); - - person.setUrl(getValueFromElement(subElement, "url")); - person.setName(getValueFromElement(subElement, "name")); - person.setJob(getValueFromElement(subElement, "job")); - person.setCharacter(getValueFromElement(subElement, "character")); - person.setId(getValueFromElement(subElement, "id")); - - movie.addPerson(person); - } - } - - /* - * This processes the image elements. There are two formats to deal with: - * Movie.imdbLookup, Movie.getInfo & Movie.search: - * - * - * - * - * - * Movie.getImages: - * - * - * - * - * - * - * - * - * - * - * - * - * - */ - subNodeList = doc.getElementsByTagName("images"); - - for (int nodeLoop = 0; nodeLoop < subNodeList.getLength(); nodeLoop++) { - subNode = subNodeList.item(nodeLoop); - - if (subNode.getNodeType() == Node.ELEMENT_NODE) { - - NodeList artworkNodeList = subNode.getChildNodes(); - for (int artworkLoop = 0; artworkLoop < artworkNodeList.getLength(); artworkLoop++) { - Node artworkNode = artworkNodeList.item(artworkLoop); - if (artworkNode.getNodeType() == Node.ELEMENT_NODE) { - subElement = (Element) artworkNode; - - if (subElement.getNodeName().equalsIgnoreCase("image")) { - // This is the format used in Movie.imdbLookup, Movie.getInfo & Movie.search - Artwork artwork = new Artwork(); - artwork.setType(subElement.getAttribute("type")); - artwork.setSize(subElement.getAttribute("size")); - artwork.setUrl(subElement.getAttribute("url")); - artwork.setId(subElement.getAttribute("id")); - movie.addArtwork(artwork); - } else if (subElement.getNodeName().equalsIgnoreCase("backdrop") || - subElement.getNodeName().equalsIgnoreCase("poster")) { - // This is the format used in Movie.getImages - String artworkId = subElement.getAttribute("id"); - String artworkType = subElement.getNodeName(); - - // We need to decode and loop round the child nodes to get the data - NodeList imageNodeList = subElement.getChildNodes(); - for (int imageLoop = 0; imageLoop < imageNodeList.getLength(); imageLoop++) { - Node imageNode = imageNodeList.item(imageLoop); - if (imageNode.getNodeType() == Node.ELEMENT_NODE) { - Element imageElement = (Element) imageNode; - Artwork artwork = new Artwork(); - artwork.setId(artworkId); - artwork.setType(artworkType); - artwork.setUrl(imageElement.getAttribute("url")); - artwork.setSize(imageElement.getAttribute("size")); - movie.addArtwork(artwork); - } - } - } else { - // This is a classic, it should never happen error - logger.severe("UNKNOWN Image type"); - } - } - } - } - } - } + String searchUrl = buildSearchUrl("Person.search", personName, language); + doc = DOMHelper.getEventDocFromUrl(searchUrl); + person = DOMParser.parsePersonInfo(doc); } catch (Exception error) { logger.severe("ERROR: " + error.getMessage()); - error.printStackTrace(); } - return movie; + + return person; } - + /** - * Gets the string value of the tag element name passed - * @param element - * @param tagName + * The Person.getInfo method is used to retrieve the full filmography, known movies, + * images and things like birthplace for a specific person in the TMDb database. + * + * @param personID + * @param language * @return */ - private String getValueFromElement(Element element, String tagName) { - String returnValue = ""; + public Person personGetInfo(String personID, String language) { + Person person = new Person(); + Document doc = null; + + language = validateLanguage(language); + + if (personID == null || personID.equals("")) { + return person; + } try { - NodeList elementNodeList = element.getElementsByTagName(tagName); - Element tagElement = (Element) elementNodeList.item(0); - NodeList tagNodeList = tagElement.getChildNodes(); - returnValue = ((Node) tagNodeList.item(0)).getNodeValue(); - } catch (Exception ignore) { - return returnValue; + String searchUrl = buildSearchUrl("Person.getInfo", personID, language); + doc = DOMHelper.getEventDocFromUrl(searchUrl); + person = DOMParser.parsePersonInfo(doc); + } catch (Exception error) { + logger.severe("ERROR: " + error.getMessage()); } - return returnValue; + return person; } - + /** - * Get a DOM document from the supplied URL - * @param url + * The Person.getVersion method is used to retrieve the last modified time along with + * the current version number of the called object(s). This is useful if you've already + * called the object sometime in the past and simply want to do a quick check for updates. + * + * @param personID + * @param language * @return - * @throws MalformedURLException - * @throws IOException - * @throws ParserConfigurationException - * @throws SAXException */ - public static Document getEventDocFromUrl(String url) throws MalformedURLException, IOException, ParserConfigurationException, SAXException { - InputStream in = (new URL(url)).openStream(); - DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); - DocumentBuilder db = dbf.newDocumentBuilder(); - Document doc = db.parse(in); - doc.getDocumentElement().normalize(); - return doc; + public Person personGetVersion(String personID, String language) { + Person person = new Person(); + Document doc = null; + + language = validateLanguage(language); + + if (personID == null || personID.equals("")) { + return person; + } + + try { + String searchUrl = buildSearchUrl("Person.getVersion", personID, language); + doc = DOMHelper.getEventDocFromUrl(searchUrl); + person = DOMParser.parsePersonGetVersion(doc); + } catch (Exception error) { + logger.severe("ERROR: " + error.getMessage()); + } + + return person; } + + } diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/model/Artwork.java b/themoviedbapi/src/com/moviejukebox/themoviedb/model/Artwork.java index e79e77d95..95d32f2ed 100644 --- a/themoviedbapi/src/com/moviejukebox/themoviedb/model/Artwork.java +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/model/Artwork.java @@ -22,14 +22,16 @@ package com.moviejukebox.themoviedb.model; public class Artwork implements Comparable { public static String ARTWORK_TYPE_POSTER = "poster"; public static String ARTWORK_TYPE_BACKDROP = "backdrop"; - public static String[] ARTWORK_TYPES = {ARTWORK_TYPE_POSTER, ARTWORK_TYPE_BACKDROP}; + public static String ARTWORK_TYPE_PERSON = "profile"; + public static String[] ARTWORK_TYPES = {ARTWORK_TYPE_POSTER, ARTWORK_TYPE_BACKDROP, ARTWORK_TYPE_PERSON}; public static String ARTWORK_SIZE_ORIGINAL = "original"; public static String ARTWORK_SIZE_THUMB = "thumb"; public static String ARTWORK_SIZE_MID = "mid"; public static String ARTWORK_SIZE_COVER = "cover"; public static String ARTWORK_SIZE_POSTER = "poster"; - public static String[] ARTWORK_SIZES = {ARTWORK_SIZE_ORIGINAL, ARTWORK_SIZE_THUMB, ARTWORK_SIZE_MID, ARTWORK_SIZE_COVER, ARTWORK_SIZE_POSTER}; + public static String ARTWORK_SIZE_PROFILE = "profile"; + public static String[] ARTWORK_SIZES = {ARTWORK_SIZE_ORIGINAL, ARTWORK_SIZE_THUMB, ARTWORK_SIZE_MID, ARTWORK_SIZE_COVER, ARTWORK_SIZE_POSTER, ARTWORK_SIZE_PROFILE}; public String type; public String size; diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/model/Filmography.java b/themoviedbapi/src/com/moviejukebox/themoviedb/model/Filmography.java new file mode 100644 index 000000000..6237d1b83 --- /dev/null +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/model/Filmography.java @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2004-2010 YAMJ Members + * http://code.google.com/p/moviejukebox/people/list + * + * Web: http://code.google.com/p/moviejukebox/ + * + * This software is licensed under a Creative Commons License + * See this page: http://code.google.com/p/moviejukebox/wiki/License + * + * For any reuse or distribution, you must make clear to others the + * license terms of this work. + */ + +package com.moviejukebox.themoviedb.model; + +public class Filmography { + private String url; + private String name; + private String department; + private String character; + private String job; + private String id; + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDepartment() { + return department; + } + + public void setDepartment(String department) { + this.department = department; + } + + public String getCharacter() { + return character; + } + + public void setCharacter(String character) { + this.character = character; + } + + public String getJob() { + return job; + } + + public void setJob(String job) { + this.job = job; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } +} diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/model/MovieDB.java b/themoviedbapi/src/com/moviejukebox/themoviedb/model/MovieDB.java index a22ab7642..63ef59e2b 100644 --- a/themoviedbapi/src/com/moviejukebox/themoviedb/model/MovieDB.java +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/model/MovieDB.java @@ -14,16 +14,17 @@ package com.moviejukebox.themoviedb.model; import java.util.ArrayList; -import java.util.Collections; import java.util.List; +import com.moviejukebox.themoviedb.tools.ModelTools; + /** * This is the Movie Search bean for the MovieDb.org search * * @author Stuart.Boston */ -public class MovieDB { +public class MovieDB extends ModelTools { public static String UNKNOWN = "UNKNOWN"; private String score = UNKNOWN; @@ -41,7 +42,6 @@ public class MovieDB { private String revenue = UNKNOWN; private String homepage = UNKNOWN; private String trailer = UNKNOWN; - private List artwork = new ArrayList(); private List countries = new ArrayList(); private List people = new ArrayList(); private List categories = new ArrayList(); @@ -166,59 +166,6 @@ public class MovieDB { this.trailer = trailer; } - /** - * Add a piece of artwork to the artwork array - * @param artworkType must be one of Artwork.ARTWORK_TYPES - * @param artworkSize must be one of Artwork.ARTWORK_SIZES - * @param artworkUrl - * @param posterId - */ - public void addArtwork(String artworkType, String artworkSize, String artworkUrl, String artworkId) { - if (validateElement(Artwork.ARTWORK_TYPES, artworkType) && validateElement(Artwork.ARTWORK_SIZES, artworkSize)) { - Artwork newArtwork = new Artwork(); - - newArtwork.setType(artworkType); - newArtwork.setSize(artworkSize); - newArtwork.setUrl(artworkUrl); - newArtwork.setId(artworkId); - - artwork.add(newArtwork); - Collections.sort(artwork); - } - return; - } - - /** - * Add a piece of artwork to the artwork array - * @param newArtwork an Artwork object to add to the array - */ - public void addArtwork(Artwork newArtwork) { - if (validateElement(Artwork.ARTWORK_TYPES, newArtwork.getType()) && validateElement(Artwork.ARTWORK_SIZES, newArtwork.getSize())) { - artwork.add(newArtwork); - Collections.sort(artwork); - } - return; - } - - /** - * Check to see if element is contained in elementArray - * @param elementArray - * @param element - * @return - */ - private boolean validateElement(String[] elementArray, String element) { - boolean valid = false; - - for (String arrayEntry : elementArray) { - if (arrayEntry.equalsIgnoreCase(element)) { - valid = true; - break; - } - } - - return valid; - } - public List getProductionCountries() { return countries; } @@ -248,103 +195,4 @@ public class MovieDB { categories.add(category); } } - - /** - * Return all the artwork for a movie - * @return - */ - public List getArtwork() { - return artwork; - } - - /** - * Get all the artwork of a specific type - * @param artworkType - * @return - */ - public List getArtwork(String artworkType) { - // Validate the Type and Size arguments - if (!validateElement(Artwork.ARTWORK_TYPES, artworkType)) { - return null; - } - - List artworkList = new ArrayList(); - - for (Artwork singleArtwork : artwork) { - if (singleArtwork.getType().equalsIgnoreCase(artworkType)) { - artworkList.add(singleArtwork); - } - } - - return artworkList; - } - - /** - * Get all artwork of a specific Type and Size - * @param artworkType - * @param artworkSize - * @return - */ - public List getArtwork(String artworkType, String artworkSize) { - List artworkList = new ArrayList(); - // Validate the Type and Size arguments - if (!validateElement(Artwork.ARTWORK_TYPES, artworkType) && !validateElement(Artwork.ARTWORK_SIZES, artworkSize)) { - return null; - } - - for (Artwork singleArtwork : artwork) { - if (singleArtwork.getType().equalsIgnoreCase(artworkType) && singleArtwork.getSize().equalsIgnoreCase(artworkSize)) { - artworkList.add(singleArtwork); - } - } - - return artworkList; - } - - /** - * Return a specific artwork entry for a Type & Size - * @param artworkType - * @param artworkSize - * @param artworkNumber - * @return - */ - public Artwork getArtwork(String artworkType, String artworkSize, int artworkNumber) { - // Validate the Type and Size arguments - if (!validateElement(Artwork.ARTWORK_TYPES, artworkType) && !validateElement(Artwork.ARTWORK_SIZES, artworkSize)) { - return null; - } - - // Validate the number - if (artworkNumber <= 0) { - artworkNumber = 0; - } else { - // Artwork elements start at 0 (Zero) - artworkNumber -= 1; - } - - List artworkList = getArtwork(artworkType, artworkSize); - - int artworkCount = artworkList.size(); - if (artworkCount < 1) { - return null; - } - - // If the number requested is greater than the array size, loop around until it's within scope - while (artworkNumber > artworkCount) { - artworkNumber = artworkNumber - artworkCount; - } - - return artworkList.get(artworkNumber); - } - - /** - * Get the first artwork that matches the Type and Size - * @param artworkType - * @param artworkSize - * @return - */ - public Artwork getFirstArtwork(String artworkType, String artworkSize) { - return getArtwork(artworkType, artworkSize, 1); - } - } diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/model/Person.java b/themoviedbapi/src/com/moviejukebox/themoviedb/model/Person.java index 8f19afed4..4adb0a2ed 100644 --- a/themoviedbapi/src/com/moviejukebox/themoviedb/model/Person.java +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/model/Person.java @@ -13,25 +13,58 @@ package com.moviejukebox.themoviedb.model; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Date; +import java.util.List; + +import com.moviejukebox.themoviedb.tools.ModelTools; + /** * This is the new bean for the Person * * @author Stuart.Boston * */ -public class Person { - public String url; - public String name; - public String job; - public String character; - public String id; +public class Person extends ModelTools { + private String biography; + private String character; + private String id; + private String job; + private String name; + private String url; + private int version; + private Date lastModifiedAt; + private List filmography = new ArrayList(); + private List aka = new ArrayList(); + private int knownMovies; + private Date birthday; + private String birthPlace; + - public String getName() { - return name; + public String getBiography() { + return biography; } - public void setName(String name) { - this.name = name; + public void setBiography(String biography) { + this.biography = biography; + } + + public String getCharacter() { + return character; + } + + public void setCharacter(String character) { + this.character = character; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; } public String getJob() { @@ -42,6 +75,14 @@ public class Person { this.job = job; } + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + public String getUrl() { return url; } @@ -49,20 +90,90 @@ public class Person { public void setUrl(String url) { this.url = url; } - - public String getId() { - return id; + + public int getVersion() { + return version; } - public void setId(String id) { - this.id = id; + public void setVersion(int version) { + this.version = version; } - public String getCharacter() { - return character; + public List getFilmography() { + return filmography; + } + + public void setFilmography(List filmography) { + this.filmography = filmography; } - public void setCharacter(String character) { - this.character = character; + public void addFilm(Filmography film) { + this.filmography.add(film); + } + + public List getAka() { + return aka; + } + + public void setAka(List aka) { + this.aka = aka; + } + + public void addAka(String alsoKnownAs) { + this.aka.add(alsoKnownAs); + } + + public Date getLastModifiedAt() { + return lastModifiedAt; + } + + public void setLastModifiedAt(Date lastModifiedAt) { + this.lastModifiedAt = lastModifiedAt; + } + + public void setLastModifiedAt(String lastModifiedAt) { + DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + + try { + Date lma = df.parse(lastModifiedAt); + setLastModifiedAt(lma); + } catch (Exception ignore) { + return; + } + } + + public int getKnownMovies() { + return knownMovies; + } + + public void setKnownMovies(int knownMovies) { + this.knownMovies = knownMovies; + } + + public Date getBirthday() { + return birthday; + } + + public void setBirthday(Date birthday) { + this.birthday = birthday; + } + + public void setBirthday(String sBirthday) { + DateFormat df = new SimpleDateFormat("yyyy-MM-dd"); + + try { + Date birthday = df.parse(sBirthday); + setBirthday(birthday); + } catch (Exception ignore) { + return; + } + } + + public String getBirthPlace() { + return birthPlace; + } + + public void setBirthPlace(String birthPlace) { + this.birthPlace = birthPlace; } } diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/tools/DOMHelper.java b/themoviedbapi/src/com/moviejukebox/themoviedb/tools/DOMHelper.java new file mode 100644 index 000000000..ae4e5efa0 --- /dev/null +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/tools/DOMHelper.java @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2004-2010 YAMJ Members + * http://code.google.com/p/moviejukebox/people/list + * + * Web: http://code.google.com/p/moviejukebox/ + * + * This software is licensed under a Creative Commons License + * See this page: http://code.google.com/p/moviejukebox/wiki/License + * + * For any reuse or distribution, you must make clear to others the + * license terms of this work. + */ + +package com.moviejukebox.themoviedb.tools; + +import java.io.IOException; +import java.io.InputStream; +import java.net.MalformedURLException; +import java.net.URL; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; +import javax.xml.parsers.ParserConfigurationException; + +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; +import org.xml.sax.SAXException; + +/** + * Generic set of routines to process the DOM model data + * @author Stuart + * + */ +public class DOMHelper { + /** + * Gets the string value of the tag element name passed + * @param element + * @param tagName + * @return + */ + public static String getValueFromElement(Element element, String tagName) { + String returnValue = ""; + + try { + NodeList elementNodeList = element.getElementsByTagName(tagName); + Element tagElement = (Element) elementNodeList.item(0); + NodeList tagNodeList = tagElement.getChildNodes(); + returnValue = ((Node) tagNodeList.item(0)).getNodeValue(); + } catch (Exception ignore) { + return returnValue; + } + + return returnValue; + } + + /** + * Get a DOM document from the supplied URL + * @param url + * @return + * @throws MalformedURLException + * @throws IOException + * @throws ParserConfigurationException + * @throws SAXException + */ + public static Document getEventDocFromUrl(String url) throws MalformedURLException, IOException, ParserConfigurationException, SAXException { + InputStream in = (new URL(url)).openStream(); + DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); + DocumentBuilder db = dbf.newDocumentBuilder(); + Document doc = db.parse(in); + doc.getDocumentElement().normalize(); + return doc; + } +} diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/tools/DOMParser.java b/themoviedbapi/src/com/moviejukebox/themoviedb/tools/DOMParser.java new file mode 100644 index 000000000..699609e7a --- /dev/null +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/tools/DOMParser.java @@ -0,0 +1,276 @@ +/* + * Copyright (c) 2004-2010 YAMJ Members + * http://code.google.com/p/moviejukebox/people/list + * + * Web: http://code.google.com/p/moviejukebox/ + * + * This software is licensed under a Creative Commons License + * See this page: http://code.google.com/p/moviejukebox/wiki/License + * + * For any reuse or distribution, you must make clear to others the + * license terms of this work. + */ + +package com.moviejukebox.themoviedb.tools; + +import java.util.logging.Logger; + +import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; + +import com.moviejukebox.themoviedb.TheMovieDb; +import com.moviejukebox.themoviedb.model.Artwork; +import com.moviejukebox.themoviedb.model.Category; +import com.moviejukebox.themoviedb.model.Country; +import com.moviejukebox.themoviedb.model.Filmography; +import com.moviejukebox.themoviedb.model.MovieDB; +import com.moviejukebox.themoviedb.model.Person; + +public class DOMParser { + static Logger logger = TheMovieDb.getLogger(); + + public static MovieDB parseMovieInfo(Document doc) { + // Borrowed from http://www.java-tips.org/java-se-tips/javax.xml.parsers/how-to-read-xml-file-in-java.html + MovieDB movie = null; + NodeList movieNodeList, subNodeList; + Node movieNode, subNode; + Element movieElement, subElement; + + try { + movie = new MovieDB(); + movieNodeList = doc.getElementsByTagName("movie"); + + // Only get the first movie from the list + movieNode = movieNodeList.item(0); + + if (movieNode == null) { + logger.finest("Movie not found"); + return movie; + } + + if (movieNode.getNodeType() == Node.ELEMENT_NODE) { + movieElement = (Element) movieNode; + + movie.setTitle(DOMHelper.getValueFromElement(movieElement, "name")); + movie.setPopularity(DOMHelper.getValueFromElement(movieElement, "popularity")); + movie.setType(DOMHelper.getValueFromElement(movieElement, "type")); + movie.setId(DOMHelper.getValueFromElement(movieElement, "id")); + movie.setImdb(DOMHelper.getValueFromElement(movieElement, "imdb_id")); + movie.setUrl(DOMHelper.getValueFromElement(movieElement, "url")); + movie.setOverview(DOMHelper.getValueFromElement(movieElement, "overview")); + movie.setRating(DOMHelper.getValueFromElement(movieElement, "rating")); + movie.setReleaseDate(DOMHelper.getValueFromElement(movieElement, "released")); + movie.setRuntime(DOMHelper.getValueFromElement(movieElement, "runtime")); + movie.setBudget(DOMHelper.getValueFromElement(movieElement, "budget")); + movie.setRevenue(DOMHelper.getValueFromElement(movieElement, "revenue")); + movie.setHomepage(DOMHelper.getValueFromElement(movieElement, "homepage")); + movie.setTrailer(DOMHelper.getValueFromElement(movieElement, "trailer")); + + // Process the "categories" + subNodeList = doc.getElementsByTagName("categories"); + + for (int nodeLoop = 0; nodeLoop < subNodeList.getLength(); nodeLoop++) { + subNode = subNodeList.item(nodeLoop); + if (subNode.getNodeType() == Node.ELEMENT_NODE) { + subElement = (Element) subNode; + Category category = new Category(); + + category.setType(DOMHelper.getValueFromElement(subElement, "type")); + category.setUrl(DOMHelper.getValueFromElement(subElement, "url")); + category.setName(DOMHelper.getValueFromElement(subElement, "name")); + + movie.addCategory(category); + } + } + + // Process the "countries" + subNodeList = doc.getElementsByTagName("countries"); + + for (int nodeLoop = 0; nodeLoop < subNodeList.getLength(); nodeLoop++) { + subNode = subNodeList.item(nodeLoop); + if (subNode.getNodeType() == Node.ELEMENT_NODE) { + subElement = (Element) subNode; + Country country = new Country(); + + country.setCode(DOMHelper.getValueFromElement(subElement, "code")); + country.setUrl(DOMHelper.getValueFromElement(subElement, "url")); + country.setName(DOMHelper.getValueFromElement(subElement, "name")); + + movie.addProductionCountry(country); + } + } + + // Process the "cast" + subNodeList = doc.getElementsByTagName("cast"); + + for (int nodeLoop = 0; nodeLoop < subNodeList.getLength(); nodeLoop++) { + subNode = subNodeList.item(nodeLoop); + if (subNode.getNodeType() == Node.ELEMENT_NODE) { + subElement = (Element) subNode; + Person person = new Person(); + + person.setUrl(DOMHelper.getValueFromElement(subElement, "url")); + person.setName(DOMHelper.getValueFromElement(subElement, "name")); + person.setJob(DOMHelper.getValueFromElement(subElement, "job")); + person.setCharacter(DOMHelper.getValueFromElement(subElement, "character")); + person.setId(DOMHelper.getValueFromElement(subElement, "id")); + + movie.addPerson(person); + } + } + + /* + * This processes the image elements. There are two formats to deal with: + * Movie.imdbLookup, Movie.getInfo & Movie.search: + * + * + * + * + * + * Movie.getImages: + * + * + * + * + * + * + * + * + * + * + * + * + * + */ + subNodeList = doc.getElementsByTagName("images"); + + for (int nodeLoop = 0; nodeLoop < subNodeList.getLength(); nodeLoop++) { + subNode = subNodeList.item(nodeLoop); + + if (subNode.getNodeType() == Node.ELEMENT_NODE) { + + NodeList artworkNodeList = subNode.getChildNodes(); + for (int artworkLoop = 0; artworkLoop < artworkNodeList.getLength(); artworkLoop++) { + Node artworkNode = artworkNodeList.item(artworkLoop); + if (artworkNode.getNodeType() == Node.ELEMENT_NODE) { + subElement = (Element) artworkNode; + + if (subElement.getNodeName().equalsIgnoreCase("image")) { + // This is the format used in Movie.imdbLookup, Movie.getInfo & Movie.search + Artwork artwork = new Artwork(); + artwork.setType(subElement.getAttribute("type")); + artwork.setSize(subElement.getAttribute("size")); + artwork.setUrl(subElement.getAttribute("url")); + artwork.setId(subElement.getAttribute("id")); + movie.addArtwork(artwork); + } else if (subElement.getNodeName().equalsIgnoreCase("backdrop") || + subElement.getNodeName().equalsIgnoreCase("poster")) { + // This is the format used in Movie.getImages + String artworkId = subElement.getAttribute("id"); + String artworkType = subElement.getNodeName(); + + // We need to decode and loop round the child nodes to get the data + NodeList imageNodeList = subElement.getChildNodes(); + for (int imageLoop = 0; imageLoop < imageNodeList.getLength(); imageLoop++) { + Node imageNode = imageNodeList.item(imageLoop); + if (imageNode.getNodeType() == Node.ELEMENT_NODE) { + Element imageElement = (Element) imageNode; + Artwork artwork = new Artwork(); + artwork.setId(artworkId); + artwork.setType(artworkType); + artwork.setUrl(imageElement.getAttribute("url")); + artwork.setSize(imageElement.getAttribute("size")); + movie.addArtwork(artwork); + } + } + } else { + // This is a classic, it should never happen error + logger.severe("UNKNOWN Image type"); + } + } + } + } + } + } + } catch (Exception error) { + logger.severe("ERROR: " + error.getMessage()); + error.printStackTrace(); + } + return movie; + } + + public static Person parsePersonInfo(Document doc) { + Person person = null; + + try { + person = new Person(); + NodeList personNodeList = doc.getElementsByTagName("person"); + + // Only get the first movie from the list + Node personNode = personNodeList.item(0); + + if (personNode == null) { + logger.finest("Person not found"); + return person; + } + + if (personNode.getNodeType() == Node.ELEMENT_NODE) { + Element personElement = (Element) personNode; + + person.setName(DOMHelper.getValueFromElement(personElement, "name")); + person.setId(DOMHelper.getValueFromElement(personElement, "id")); + person.setBiography(DOMHelper.getValueFromElement(personElement, "biography")); + person.setKnownMovies(Integer.parseInt(DOMHelper.getValueFromElement(personElement, "known_movies"))); + person.setBirthday(DOMHelper.getValueFromElement(personElement, "birthday")); + person.setBirthPlace(DOMHelper.getValueFromElement(personElement, "birthplace")); + person.setUrl(DOMHelper.getValueFromElement(personElement, "url")); + person.setVersion(Integer.parseInt(DOMHelper.getValueFromElement(personElement, "version"))); + person.setLastModifiedAt(DOMHelper.getValueFromElement(personElement, "last_modified_at")); + + NodeList artworkNodeList = doc.getElementsByTagName("image"); + for (int nodeLoop = 0; nodeLoop < artworkNodeList.getLength(); nodeLoop++) { + Node artworkNode = artworkNodeList.item(nodeLoop); + if (artworkNode.getNodeType() == Node.ELEMENT_NODE) { + Element artworkElement = (Element) artworkNode; + Artwork artwork = new Artwork(); + artwork.setType(artworkElement.getAttribute("type")); + artwork.setUrl(artworkElement.getAttribute("url")); + artwork.setSize(artworkElement.getAttribute("size")); + artwork.setId(artworkElement.getAttribute("id")); + person.addArtwork(artwork); + } + } + + NodeList filmNodeList = doc.getElementsByTagName("movie"); + for (int nodeLoop = 0; nodeLoop < filmNodeList.getLength(); nodeLoop++) { + Node filmNode = filmNodeList.item(nodeLoop); + if (filmNode.getNodeType() == Node.ELEMENT_NODE) { + Element filmElement = (Element) filmNode; + Filmography film = new Filmography(); + + film.setCharacter(filmElement.getAttribute("character")); + film.setDepartment(filmElement.getAttribute("department")); + film.setId(filmElement.getAttribute("id")); + film.setJob(filmElement.getAttribute("job")); + film.setName(filmElement.getAttribute("name")); + film.setUrl(filmElement.getAttribute("url")); + + person.addFilm(film); + } + } + } + } catch (Exception error) { + logger.severe("ERROR: " + error.getMessage()); + error.printStackTrace(); + } + + return person; + } + + public static Person parsePersonGetVersion(Document doc) { + // TODO Auto-generated method stub + return null; + } +} diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/tools/ModelTools.java b/themoviedbapi/src/com/moviejukebox/themoviedb/tools/ModelTools.java new file mode 100644 index 000000000..00833b2d4 --- /dev/null +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/tools/ModelTools.java @@ -0,0 +1,176 @@ +/* + * Copyright (c) 2004-2010 YAMJ Members + * http://code.google.com/p/moviejukebox/people/list + * + * Web: http://code.google.com/p/moviejukebox/ + * + * This software is licensed under a Creative Commons License + * See this page: http://code.google.com/p/moviejukebox/wiki/License + * + * For any reuse or distribution, you must make clear to others the + * license terms of this work. + */ + +package com.moviejukebox.themoviedb.tools; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +import com.moviejukebox.themoviedb.model.Artwork; + +public class ModelTools { + private List artwork = new ArrayList(); + + /** + * Add a piece of artwork to the artwork array + * @param artworkType must be one of Artwork.ARTWORK_TYPES + * @param artworkSize must be one of Artwork.ARTWORK_SIZES + * @param artworkUrl + * @param posterId + */ + public void addArtwork(String artworkType, String artworkSize, String artworkUrl, String artworkId) { + if (validateElement(Artwork.ARTWORK_TYPES, artworkType) && validateElement(Artwork.ARTWORK_SIZES, artworkSize)) { + Artwork newArtwork = new Artwork(); + + newArtwork.setType(artworkType); + newArtwork.setSize(artworkSize); + newArtwork.setUrl(artworkUrl); + newArtwork.setId(artworkId); + + artwork.add(newArtwork); + Collections.sort(artwork); + } + return; + } + + /** + * Add a piece of artwork to the artwork array + * @param newArtwork an Artwork object to add to the array + */ + public void addArtwork(Artwork newArtwork) { + if (validateElement(Artwork.ARTWORK_TYPES, newArtwork.getType()) && validateElement(Artwork.ARTWORK_SIZES, newArtwork.getSize())) { + artwork.add(newArtwork); + Collections.sort(artwork); + } + return; + } + + /** + * Get the first artwork that matches the Type and Size + * @param artworkType + * @param artworkSize + * @return + */ + public Artwork getFirstArtwork(String artworkType, String artworkSize) { + return getArtwork(artworkType, artworkSize, 1); + } + + /** + * Check to see if element is contained in elementArray + * @param elementArray + * @param element + * @return + */ + private boolean validateElement(String[] elementArray, String element) { + boolean valid = false; + + for (String arrayEntry : elementArray) { + if (arrayEntry.equalsIgnoreCase(element)) { + valid = true; + break; + } + } + + return valid; + } + + /** + * Return all the artwork for a movie + * @return + */ + public List getArtwork() { + return artwork; + } + + /** + * Get all the artwork of a specific type + * @param artworkType + * @return + */ + public List getArtwork(String artworkType) { + // Validate the Type and Size arguments + if (!validateElement(Artwork.ARTWORK_TYPES, artworkType)) { + return null; + } + + List artworkList = new ArrayList(); + + for (Artwork singleArtwork : artwork) { + if (singleArtwork.getType().equalsIgnoreCase(artworkType)) { + artworkList.add(singleArtwork); + } + } + + return artworkList; + } + + /** + * Get all artwork of a specific Type and Size + * @param artworkType + * @param artworkSize + * @return + */ + public List getArtwork(String artworkType, String artworkSize) { + List artworkList = new ArrayList(); + // Validate the Type and Size arguments + if (!validateElement(Artwork.ARTWORK_TYPES, artworkType) && !validateElement(Artwork.ARTWORK_SIZES, artworkSize)) { + return null; + } + + for (Artwork singleArtwork : artwork) { + if (singleArtwork.getType().equalsIgnoreCase(artworkType) && singleArtwork.getSize().equalsIgnoreCase(artworkSize)) { + artworkList.add(singleArtwork); + } + } + + return artworkList; + } + + /** + * Return a specific artwork entry for a Type & Size + * @param artworkType + * @param artworkSize + * @param artworkNumber + * @return + */ + public Artwork getArtwork(String artworkType, String artworkSize, int artworkNumber) { + // Validate the Type and Size arguments + if (!validateElement(Artwork.ARTWORK_TYPES, artworkType) && !validateElement(Artwork.ARTWORK_SIZES, artworkSize)) { + return null; + } + + // Validate the number + if (artworkNumber <= 0) { + artworkNumber = 0; + } else { + // Artwork elements start at 0 (Zero) + artworkNumber -= 1; + } + + List artworkList = getArtwork(artworkType, artworkSize); + + int artworkCount = artworkList.size(); + if (artworkCount < 1) { + return null; + } + + // If the number requested is greater than the array size, loop around until it's within scope + while (artworkNumber > artworkCount) { + artworkNumber = artworkNumber - artworkCount; + } + + return artworkList.get(artworkNumber); + } + +} From d106bcaeeb5bec8698e3a4030569e372af9882b6 Mon Sep 17 00:00:00 2001 From: Omertron Date: Thu, 30 Sep 2010 13:57:49 +0000 Subject: [PATCH 011/207] Fixes issue 5 WebBrowser Proxy Connection --- .../moviejukebox/themoviedb/TheMovieDb.java | 9 +- .../moviejukebox/themoviedb/tools/Base64.java | 41 +++ .../themoviedb/tools/DOMHelper.java | 12 +- .../themoviedb/tools/WebBrowser.java | 237 ++++++++++++++++++ 4 files changed, 291 insertions(+), 8 deletions(-) create mode 100644 themoviedbapi/src/com/moviejukebox/themoviedb/tools/Base64.java create mode 100644 themoviedbapi/src/com/moviejukebox/themoviedb/tools/WebBrowser.java diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java b/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java index afe38f2dd..91a0da97c 100644 --- a/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java @@ -112,7 +112,7 @@ public class TheMovieDb { movie = DOMParser.parseMovieInfo(doc); } catch (Exception error) { - logger.severe("ERROR: " + error.getMessage()); + logger.severe("TheMovieDb Error: " + error.getMessage()); } return movie; } @@ -141,7 +141,7 @@ public class TheMovieDb { movie = DOMParser.parseMovieInfo(doc); } catch (Exception error) { - logger.severe("ERROR: " + error.getMessage()); + logger.severe("TheMovieDb Error: " + error.getMessage()); } return movie; } @@ -186,7 +186,7 @@ public class TheMovieDb { movie = DOMParser.parseMovieInfo(doc); } catch (Exception error) { - logger.severe("ERROR: " + error.getMessage()); + logger.severe("TheMovieDb Error: " + error.getMessage()); } return movie; } @@ -220,7 +220,7 @@ public class TheMovieDb { movie = DOMParser.parseMovieInfo(doc); } catch (Exception error) { - logger.severe("ERROR: " + error.getMessage()); + logger.severe("TheMovieDb Error: " + error.getMessage()); } return movie; @@ -241,7 +241,6 @@ public class TheMovieDb { return language; } - /** * The Person.search method is used to search for an actor, actress or production member. * http://api.themoviedb.org/2.1/methods/Person.search diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/tools/Base64.java b/themoviedbapi/src/com/moviejukebox/themoviedb/tools/Base64.java new file mode 100644 index 000000000..e4f56aba0 --- /dev/null +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/tools/Base64.java @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2004-2010 YAMJ Members + * http://code.google.com/p/moviejukebox/people/list + * + * Web: http://code.google.com/p/moviejukebox/ + * + * This software is licensed under a Creative Commons License + * See this page: http://code.google.com/p/moviejukebox/wiki/License + * + * For any reuse or distribution, you must make clear to others the + * license terms of this work. + */ + +package com.moviejukebox.themoviedb.tools; + +public class Base64 { + public static String base64code = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + + "abcdefghijklmnopqrstuvwxyz" + "0123456789" + "+/"; + + public static int splitLinesAt = 76; + public static String base64Encode(String string) { + + String encoded = ""; + // determine how many padding bytes to add to the output + int paddingCount = (3 - (string.length() % 3)) % 3; + // add any necessary padding to the input + string += "\0\0".substring(0, paddingCount); + // process 3 bytes at a time, churning out 4 output bytes + // worry about CRLF insertions later + for (int i = 0; i < string.length(); i += 3) { + int j = (string.charAt(i) << 16) + (string.charAt(i + 1) << 8) + string.charAt(i + 2); + encoded = encoded + base64code.charAt((j >> 18) & 0x3f) + + base64code.charAt((j >> 12) & 0x3f) + + base64code.charAt((j >> 6) & 0x3f) + + base64code.charAt(j & 0x3f); + } + // replace encoded padding nulls with "=" + // return encoded; + return "Basic " + encoded; + } +} \ No newline at end of file diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/tools/DOMHelper.java b/themoviedbapi/src/com/moviejukebox/themoviedb/tools/DOMHelper.java index ae4e5efa0..521943db6 100644 --- a/themoviedbapi/src/com/moviejukebox/themoviedb/tools/DOMHelper.java +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/tools/DOMHelper.java @@ -13,10 +13,11 @@ package com.moviejukebox.themoviedb.tools; +import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; +import java.io.UnsupportedEncodingException; import java.net.MalformedURLException; -import java.net.URL; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; @@ -64,11 +65,16 @@ public class DOMHelper { * @throws ParserConfigurationException * @throws SAXException */ - public static Document getEventDocFromUrl(String url) throws MalformedURLException, IOException, ParserConfigurationException, SAXException { - InputStream in = (new URL(url)).openStream(); + public static Document getEventDocFromUrl(String url) + throws MalformedURLException, IOException, ParserConfigurationException, SAXException, UnsupportedEncodingException { + //InputStream in = (new URL(url)).openStream(); + String webPage = WebBrowser.request(url); + InputStream in = new ByteArrayInputStream(webPage.getBytes("UTF-8")); + DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); DocumentBuilder db = dbf.newDocumentBuilder(); Document doc = db.parse(in); + doc.getDocumentElement().normalize(); return doc; } diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/tools/WebBrowser.java b/themoviedbapi/src/com/moviejukebox/themoviedb/tools/WebBrowser.java new file mode 100644 index 000000000..b9695f2ed --- /dev/null +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/tools/WebBrowser.java @@ -0,0 +1,237 @@ +/* + * Copyright (c) 2004-2010 YAMJ Members + * http://code.google.com/p/moviejukebox/people/list + * + * Web: http://code.google.com/p/moviejukebox/ + * + * This software is licensed under a Creative Commons License + * See this page: http://code.google.com/p/moviejukebox/wiki/License + * + * For any reuse or distribution, you must make clear to others the + * license terms of this work. + */ + +package com.moviejukebox.themoviedb.tools; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.StringWriter; +import java.net.HttpURLConnection; +import java.net.URL; +import java.net.URLConnection; +import java.nio.charset.Charset; +import java.nio.charset.UnsupportedCharsetException; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * Web browser with simple cookies support + */ +public final class WebBrowser { + private static Map browserProperties = new HashMap(); + private static Map> cookies; + private static String proxyHost = null; + private static String proxyPort = null; + private static String proxyUsername = null; + private static String proxyPassword = null; + private static String proxyEncodedPassword = null; + + public WebBrowser() { + browserProperties.put("User-Agent", "Mozilla/5.25 Netscape/5.0 (Windows; I; Win95)"); + cookies = new HashMap>(); + } + + public static String request(String url) throws IOException { + return request(new URL(url)); + } + + public static URLConnection openProxiedConnection(URL url) throws IOException { + if (proxyHost != null) { + System.getProperties().put("proxySet", "true"); + System.getProperties().put("proxyHost", proxyHost); + System.getProperties().put("proxyPort", proxyPort); + } + + URLConnection cnx = url.openConnection(); + + if (proxyUsername != null) { + cnx.setRequestProperty("Proxy-Authorization", proxyEncodedPassword); + } + + return cnx; + } + + public static String request(URL url) throws IOException { + StringWriter content = null; + + try { + content = new StringWriter(); + + BufferedReader in = null; + URLConnection cnx = null; + try { + cnx = openProxiedConnection(url); + + sendHeader(cnx); + readHeader(cnx); + + in = new BufferedReader(new InputStreamReader(cnx.getInputStream(), getCharset(cnx))); + String line; + while ((line = in.readLine()) != null) { + content.write(line); + } + } finally { + if (in != null) { + in.close(); + } + if (cnx != null) { + if(cnx instanceof HttpURLConnection) { + ((HttpURLConnection)cnx).disconnect(); + } + } + if (cnx != null) { + if(cnx instanceof HttpURLConnection) { + ((HttpURLConnection)cnx).disconnect(); + } + } + } + return content.toString(); + } finally { + if (content != null) { + content.close(); + } + } + } + + private static void sendHeader(URLConnection cnx) { + // send browser properties + for (Map.Entry browserProperty : browserProperties.entrySet()) { + cnx.setRequestProperty(browserProperty.getKey(), browserProperty.getValue()); + } + // send cookies + String cookieHeader = createCookieHeader(cnx); + if (!cookieHeader.isEmpty()) { + cnx.setRequestProperty("Cookie", cookieHeader); + } + } + + private static String createCookieHeader(URLConnection cnx) { + String host = cnx.getURL().getHost(); + StringBuilder cookiesHeader = new StringBuilder(); + for (Map.Entry> domainCookies : cookies.entrySet()) { + if (host.endsWith(domainCookies.getKey())) { + for (Map.Entry cookie : domainCookies.getValue().entrySet()) { + cookiesHeader.append(cookie.getKey()); + cookiesHeader.append("="); + cookiesHeader.append(cookie.getValue()); + cookiesHeader.append(";"); + } + } + } + if (cookiesHeader.length() > 0) { + // remove last ; char + cookiesHeader.deleteCharAt(cookiesHeader.length() - 1); + } + return cookiesHeader.toString(); + } + + private static void readHeader(URLConnection cnx) { + // read new cookies and update our cookies + for (Map.Entry> header : cnx.getHeaderFields().entrySet()) { + if ("Set-Cookie".equals(header.getKey())) { + for (String cookieHeader : header.getValue()) { + String[] cookieElements = cookieHeader.split(" *; *"); + if (cookieElements.length >= 1) { + String[] firstElem = cookieElements[0].split(" *= *"); + String cookieName = firstElem[0]; + String cookieValue = firstElem.length > 1 ? firstElem[1] : null; + String cookieDomain = null; + // find cookie domain + for (int i = 1; i < cookieElements.length; i++) { + String[] cookieElement = cookieElements[i].split(" *= *"); + if ("domain".equals(cookieElement[0])) { + cookieDomain = cookieElement.length > 1 ? cookieElement[1] : null; + break; + } + } + if (cookieDomain == null) { + // if domain isn't set take current host + cookieDomain = cnx.getURL().getHost(); + } + Map domainCookies = cookies.get(cookieDomain); + if (domainCookies == null) { + domainCookies = new HashMap(); + cookies.put(cookieDomain, domainCookies); + } + // add or replace cookie + domainCookies.put(cookieName, cookieValue); + } + } + } + } + } + + private static Charset getCharset(URLConnection cnx) { + Charset charset = null; + // content type will be string like "text/html; charset=UTF-8" or "text/html" + String contentType = cnx.getContentType(); + if (contentType != null) { + // changed 'charset' to 'harset' in regexp because some sites send 'Charset' + Matcher m = Pattern.compile("harset *=[ '\"]*([^ ;'\"]+)[ ;'\"]*").matcher(contentType); + if (m.find()) { + String encoding = m.group(1); + try { + charset = Charset.forName(encoding); + } catch (UnsupportedCharsetException e) { + // there will be used default charset + } + } + } + if (charset == null) { + charset = Charset.defaultCharset(); + } + + return charset; + } + + public static String getProxyHost() { + return proxyHost; + } + + public static void setProxyHost(String tvdbProxyHost) { + WebBrowser.proxyHost = tvdbProxyHost; + } + + public static String getProxyPort() { + return proxyPort; + } + + public static void setProxyPort(String tvdbProxyPort) { + WebBrowser.proxyPort = tvdbProxyPort; + } + + public static String getTvdbProxyUsername() { + return proxyUsername; + } + + public static void setProxyUsername(String tvdbProxyUsername) { + WebBrowser.proxyUsername = tvdbProxyUsername; + } + + public static String getProxyPassword() { + return proxyPassword; + } + + public static void setProxyPassword(String tvdbProxyPassword) { + WebBrowser.proxyPassword = tvdbProxyPassword; + + if (proxyUsername != null) { + proxyEncodedPassword = proxyUsername + ":" + tvdbProxyPassword; + proxyEncodedPassword = Base64.base64Encode(proxyEncodedPassword); + } + } +} From d85595689580ec05a8824fc541c494278a7b8843 Mon Sep 17 00:00:00 2001 From: Omertron Date: Fri, 1 Oct 2010 13:15:36 +0000 Subject: [PATCH 012/207] WebBrowser Update --- .../src/com/moviejukebox/themoviedb/tools/WebBrowser.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/tools/WebBrowser.java b/themoviedbapi/src/com/moviejukebox/themoviedb/tools/WebBrowser.java index b9695f2ed..6f55caf73 100644 --- a/themoviedbapi/src/com/moviejukebox/themoviedb/tools/WebBrowser.java +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/tools/WebBrowser.java @@ -40,7 +40,7 @@ public final class WebBrowser { private static String proxyPassword = null; private static String proxyEncodedPassword = null; - public WebBrowser() { + static { browserProperties.put("User-Agent", "Mozilla/5.25 Netscape/5.0 (Windows; I; Win95)"); cookies = new HashMap>(); } From 4592095bcc80c5756021f464beca9bcf55bfd548 Mon Sep 17 00:00:00 2001 From: Omertron Date: Sat, 2 Oct 2010 10:55:36 +0000 Subject: [PATCH 013/207] Updated build.xml file --- themoviedbapi/build.xml | 44 ++++++++++++++++++++++++++--------------- 1 file changed, 28 insertions(+), 16 deletions(-) diff --git a/themoviedbapi/build.xml b/themoviedbapi/build.xml index 27027c642..9e8cf3f4a 100644 --- a/themoviedbapi/build.xml +++ b/themoviedbapi/build.xml @@ -25,15 +25,24 @@ - + + ${project}${line.separator} Build Date: ${builddate}${line.separator} Revision: r${revision}${line.separator} + + + + + + + + @@ -42,22 +51,25 @@ - - - - - - - + + + + + + + + + + + + + + + + + + - - - - - - - - From 17ce5e6a8a9e71e86d6371415dd4469d4c29f064 Mon Sep 17 00:00:00 2001 From: Omertron Date: Tue, 5 Oct 2010 16:59:42 +0000 Subject: [PATCH 014/207] Fixed error with moviedbGetInfo using the wrong method --- themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java b/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java index 91a0da97c..e4cfbf71d 100644 --- a/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java @@ -180,7 +180,7 @@ public class TheMovieDb { language = validateLanguage(language); try { - String searchUrl = buildSearchUrl("Movie.getImages", tmdbID, language); + String searchUrl = buildSearchUrl("Movie.getInfo", tmdbID, language); doc = DOMHelper.getEventDocFromUrl(searchUrl); movie = DOMParser.parseMovieInfo(doc); From 3cad80c6acbd908a26bb8d1a1870e767eea324b8 Mon Sep 17 00:00:00 2001 From: Omertron Date: Wed, 6 Oct 2010 16:30:56 +0000 Subject: [PATCH 015/207] Fix for categories and cast --- .../themoviedb/tools/DOMParser.java | 48 ++++++++++++------- 1 file changed, 31 insertions(+), 17 deletions(-) diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/tools/DOMParser.java b/themoviedbapi/src/com/moviejukebox/themoviedb/tools/DOMParser.java index 699609e7a..38a4f727a 100644 --- a/themoviedbapi/src/com/moviejukebox/themoviedb/tools/DOMParser.java +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/tools/DOMParser.java @@ -75,13 +75,20 @@ public class DOMParser { subNode = subNodeList.item(nodeLoop); if (subNode.getNodeType() == Node.ELEMENT_NODE) { subElement = (Element) subNode; - Category category = new Category(); - - category.setType(DOMHelper.getValueFromElement(subElement, "type")); - category.setUrl(DOMHelper.getValueFromElement(subElement, "url")); - category.setName(DOMHelper.getValueFromElement(subElement, "name")); - - movie.addCategory(category); + + NodeList castList = subNode.getChildNodes(); + for (int i = 0; i < castList.getLength(); i++) { + Node personNode = castList.item(i); + if (personNode.getNodeType() == Node.ELEMENT_NODE) { + subElement = (Element) personNode; + Category category = new Category(); + + category.setType(subElement.getAttribute("type")); + category.setUrl(subElement.getAttribute("url")); + category.setName(subElement.getAttribute("name")); + movie.addCategory(category); + } + } } } @@ -109,18 +116,25 @@ public class DOMParser { subNode = subNodeList.item(nodeLoop); if (subNode.getNodeType() == Node.ELEMENT_NODE) { subElement = (Element) subNode; - Person person = new Person(); - - person.setUrl(DOMHelper.getValueFromElement(subElement, "url")); - person.setName(DOMHelper.getValueFromElement(subElement, "name")); - person.setJob(DOMHelper.getValueFromElement(subElement, "job")); - person.setCharacter(DOMHelper.getValueFromElement(subElement, "character")); - person.setId(DOMHelper.getValueFromElement(subElement, "id")); - - movie.addPerson(person); + + NodeList castList = subNode.getChildNodes(); + for (int i = 0; i < castList.getLength(); i++) { + Node personNode = castList.item(i); + if (personNode.getNodeType() == Node.ELEMENT_NODE) { + subElement = (Element) personNode; + Person person = new Person(); + + person.setUrl(subElement.getAttribute("url")); + person.setName(subElement.getAttribute("name")); + person.setJob(subElement.getAttribute("job")); + person.setCharacter(subElement.getAttribute("character")); + person.setId(subElement.getAttribute("id")); + movie.addPerson(person); + } + } } } - + /* * This processes the image elements. There are two formats to deal with: * Movie.imdbLookup, Movie.getInfo & Movie.search: From c49e48191d4c37e55694078cd0b3785e141de9e0 Mon Sep 17 00:00:00 2001 From: Mohammed Le Doze Date: Thu, 7 Oct 2010 08:50:07 +0000 Subject: [PATCH 016/207] in some methods, moved parameters declaration after the initial check for null or empty strings --- .../moviejukebox/themoviedb/TheMovieDb.java | 39 ++++++++----------- 1 file changed, 16 insertions(+), 23 deletions(-) diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java b/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java index e4cfbf71d..502d4dd62 100644 --- a/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java @@ -118,7 +118,7 @@ public class TheMovieDb { } /** - * Searches the database using the IMDd reference + * Searches the database using the IMDb reference * * @param imdbID IMDb reference, must include the "tt" at the start * @param language The two digit language code. E.g. en=English @@ -126,14 +126,14 @@ public class TheMovieDb { */ public MovieDB moviedbImdbLookup(String imdbID, String language) { MovieDB movie = null; - Document doc = null; - - language = validateLanguage(language); // If the imdbID is null, then exit if (imdbID == null || imdbID.equals("")) return movie; + Document doc = null; + language = validateLanguage(language); + try { String searchUrl = buildSearchUrl("Movie.imdbLookup", imdbID, language); @@ -171,12 +171,11 @@ public class TheMovieDb { * @return A movie bean with all of the information */ public MovieDB moviedbGetInfo(String tmdbID, MovieDB movie, String language) { - Document doc = null; - // If the tmdbID is null, then exit if (tmdbID == null || tmdbID.equals("") || tmdbID.equalsIgnoreCase("UNKNOWN")) return movie; + Document doc = null; language = validateLanguage(language); try { @@ -205,12 +204,11 @@ public class TheMovieDb { * @return */ public MovieDB moviedbGetImages(String searchTerm, MovieDB movie, String language) { - Document doc = null; - // If the searchTerm is null, then exit if (searchTerm == null || searchTerm.equals("") || searchTerm.equalsIgnoreCase("UNKNOWN")) return movie; + Document doc = null; language = validateLanguage(language); try { @@ -251,13 +249,12 @@ public class TheMovieDb { */ public Person personSearch(String personName, String language) { Person person = new Person(); - Document doc = null; - - language = validateLanguage(language); - if (personName == null || personName.equals("")) { return person; } + + Document doc = null; + language = validateLanguage(language); try { String searchUrl = buildSearchUrl("Person.search", personName, language); @@ -280,14 +277,13 @@ public class TheMovieDb { */ public Person personGetInfo(String personID, String language) { Person person = new Person(); - Document doc = null; - - language = validateLanguage(language); - if (personID == null || personID.equals("")) { return person; } + Document doc = null; + language = validateLanguage(language); + try { String searchUrl = buildSearchUrl("Person.getInfo", personID, language); doc = DOMHelper.getEventDocFromUrl(searchUrl); @@ -310,14 +306,13 @@ public class TheMovieDb { */ public Person personGetVersion(String personID, String language) { Person person = new Person(); - Document doc = null; - - language = validateLanguage(language); - if (personID == null || personID.equals("")) { return person; } - + + Document doc = null; + language = validateLanguage(language); + try { String searchUrl = buildSearchUrl("Person.getVersion", personID, language); doc = DOMHelper.getEventDocFromUrl(searchUrl); @@ -328,6 +323,4 @@ public class TheMovieDb { return person; } - - } From e5d07ccddbf8e65fd39901797a6f6cfc8f7f64b1 Mon Sep 17 00:00:00 2001 From: Omertron Date: Thu, 7 Oct 2010 09:22:37 +0000 Subject: [PATCH 017/207] Update Movie bean with new fields from TheMovieDb.org New Studio Bean --- .../themoviedb/model/MovieDB.java | 140 ++++++++++++++---- .../moviejukebox/themoviedb/model/Studio.java | 50 +++++++ 2 files changed, 164 insertions(+), 26 deletions(-) create mode 100644 themoviedbapi/src/com/moviejukebox/themoviedb/model/Studio.java diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/model/MovieDB.java b/themoviedbapi/src/com/moviejukebox/themoviedb/model/MovieDB.java index 63ef59e2b..d6ccb816b 100644 --- a/themoviedbapi/src/com/moviejukebox/themoviedb/model/MovieDB.java +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/model/MovieDB.java @@ -27,32 +27,32 @@ import com.moviejukebox.themoviedb.tools.ModelTools; public class MovieDB extends ModelTools { public static String UNKNOWN = "UNKNOWN"; - private String score = UNKNOWN; - private String popularity = UNKNOWN; - private String title = UNKNOWN; - private String type = UNKNOWN; - private String id = UNKNOWN; - private String imdb = UNKNOWN; - private String url = UNKNOWN; - private String overview = UNKNOWN; - private String rating = UNKNOWN; - private String releaseDate = UNKNOWN; - private String runtime = UNKNOWN; - private String budget = UNKNOWN; - private String revenue = UNKNOWN; - private String homepage = UNKNOWN; - private String trailer = UNKNOWN; - private List countries = new ArrayList(); - private List people = new ArrayList(); - private List categories = new ArrayList(); - - public String getScore() { - return score; - } - - public void setScore(String score) { - this.score = score; - } + private String popularity = UNKNOWN; + private String translated = UNKNOWN; + private String adult = UNKNOWN; + private String language = UNKNOWN; + private String title = UNKNOWN; // "name" in the XML + private String originalName = UNKNOWN; // "original_name" in the XML + private String alternativeName = UNKNOWN; // "alternative_name" in the XML + private String type = UNKNOWN; + private String id = UNKNOWN; + private String imdb = UNKNOWN; // "imdb_id" in the XML + private String url = UNKNOWN; + private String overview = UNKNOWN; + private String rating = UNKNOWN; + private String tagline = UNKNOWN; + private String certification = UNKNOWN; + private String releaseDate = UNKNOWN; // "released" in the XML + private String runtime = UNKNOWN; + private String budget = UNKNOWN; + private String revenue = UNKNOWN; + private String homepage = UNKNOWN; + private String trailer = UNKNOWN; + private List categories = new ArrayList(); + private List studios = new ArrayList(); + private List countries = new ArrayList(); + private List people = new ArrayList(); + private List artwork = new ArrayList(); public String getPopularity() { return popularity; @@ -195,4 +195,92 @@ public class MovieDB extends ModelTools { categories.add(category); } } + + public String getTranslated() { + return translated; + } + + public String getAdult() { + return adult; + } + + public String getLanguage() { + return language; + } + + public String getOriginalName() { + return originalName; + } + + public String getAlternativeName() { + return alternativeName; + } + + public String getTagline() { + return tagline; + } + + public String getCertification() { + return certification; + } + + public List getStudios() { + return studios; + } + + public List getCountries() { + return countries; + } + + public List getArtwork() { + return artwork; + } + + public void setTranslated(String translated) { + this.translated = translated; + } + + public void setAdult(String adult) { + this.adult = adult; + } + + public void setLanguage(String language) { + this.language = language; + } + + public void setOriginalName(String originalName) { + this.originalName = originalName; + } + + public void setAlternativeName(String alternativeName) { + this.alternativeName = alternativeName; + } + + public void setTagline(String tagline) { + this.tagline = tagline; + } + + public void setCertification(String certification) { + this.certification = certification; + } + + public void setCategories(List categories) { + this.categories = categories; + } + + public void setStudios(List studios) { + this.studios = studios; + } + + public void setCountries(List countries) { + this.countries = countries; + } + + public void setPeople(List people) { + this.people = people; + } + + public void setArtwork(List artwork) { + this.artwork = artwork; + } } diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/model/Studio.java b/themoviedbapi/src/com/moviejukebox/themoviedb/model/Studio.java new file mode 100644 index 000000000..a1601a08c --- /dev/null +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/model/Studio.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2004-2010 YAMJ Members + * http://code.google.com/p/moviejukebox/people/list + * + * Web: http://code.google.com/p/moviejukebox/ + * + * This software is licensed under a Creative Commons License + * See this page: http://code.google.com/p/moviejukebox/wiki/License + * + * For any reuse or distribution, you must make clear to others the + * license terms of this work. + */ + +package com.moviejukebox.themoviedb.model; + +/** + * Studio from the MovieDB.org + * + * @author Stuart.Boston + * + */ +public class Studio { + public String name; + public String url; + public String id; + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getUrl() { + return url; + } + + public void setUrl(String url) { + this.url = url; + } +} From ef4e2a0fa0e723f35eb0fc91aeb5853794571df0 Mon Sep 17 00:00:00 2001 From: Omertron Date: Thu, 7 Oct 2010 09:48:41 +0000 Subject: [PATCH 018/207] Updated Category, MovieDB & Person --- .../themoviedb/model/Category.java | 25 +- .../themoviedb/model/MovieDB.java | 8 +- .../moviejukebox/themoviedb/model/Person.java | 237 +++++++++++------- 3 files changed, 164 insertions(+), 106 deletions(-) diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/model/Category.java b/themoviedbapi/src/com/moviejukebox/themoviedb/model/Category.java index 7e3dba6be..a32615fc1 100644 --- a/themoviedbapi/src/com/moviejukebox/themoviedb/model/Category.java +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/model/Category.java @@ -23,27 +23,36 @@ public class Category { public String type; public String name; public String url; + public String id; - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; + public String getId() { + return id; } public String getName() { return name; } - public void setName(String name) { - this.name = name; + public String getType() { + return type; } public String getUrl() { return url; } + public void setId(String id) { + this.id = id; + } + + public void setName(String name) { + this.name = name; + } + + public void setType(String type) { + this.type = type; + } + public void setUrl(String url) { this.url = url; } diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/model/MovieDB.java b/themoviedbapi/src/com/moviejukebox/themoviedb/model/MovieDB.java index d6ccb816b..18efa4e5c 100644 --- a/themoviedbapi/src/com/moviejukebox/themoviedb/model/MovieDB.java +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/model/MovieDB.java @@ -271,7 +271,13 @@ public class MovieDB extends ModelTools { public void setStudios(List studios) { this.studios = studios; } - + + public void addStudio(Studio studio) { + if (studio != null) { + this.studios.add(studio); + } + } + public void setCountries(List countries) { this.countries = countries; } diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/model/Person.java b/themoviedbapi/src/com/moviejukebox/themoviedb/model/Person.java index 4adb0a2ed..757a17045 100644 --- a/themoviedbapi/src/com/moviejukebox/themoviedb/model/Person.java +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/model/Person.java @@ -28,136 +28,120 @@ import com.moviejukebox.themoviedb.tools.ModelTools; * */ public class Person extends ModelTools { - private String biography; - private String character; - private String id; - private String job; - private String name; - private String url; - private int version; + private static String UNKNOWN = MovieDB.UNKNOWN; + + private String name = UNKNOWN; + private String character = UNKNOWN; + private String job = UNKNOWN; + private String id = UNKNOWN; + private String department = UNKNOWN; + private String biography = UNKNOWN; + private String url = UNKNOWN; + private int order = -1; + private int castId = -1; + private int version = -1; private Date lastModifiedAt; + private int knownMovies = -1; + private Date birthday; + private String birthPlace = UNKNOWN; private List filmography = new ArrayList(); private List aka = new ArrayList(); - private int knownMovies; - private Date birthday; - private String birthPlace; - + private List images = new ArrayList(); + + public void addAka(String alsoKnownAs) { + this.aka.add(alsoKnownAs); + } + + public void addFilm(Filmography film) { + this.filmography.add(film); + } + + public void addImage(Artwork image) { + if (image != null) { + this.images.add(image); + } + } + + public List getAka() { + return aka; + } public String getBiography() { return biography; } - public void setBiography(String biography) { - this.biography = biography; + public Date getBirthday() { + return birthday; + } + + public String getBirthPlace() { + return birthPlace; + } + + public int getCastId() { + return castId; } public String getCharacter() { return character; } - public void setCharacter(String character) { - this.character = character; + public String getDepartment() { + return department; + } + + public List getFilmography() { + return filmography; } public String getId() { return id; } - public void setId(String id) { - this.id = id; + public List getImages() { + return images; } public String getJob() { return job; } - - public void setJob(String job) { - this.job = job; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getUrl() { - return url; - } - - public void setUrl(String url) { - this.url = url; - } - - public int getVersion() { - return version; - } - - public void setVersion(int version) { - this.version = version; - } - - public List getFilmography() { - return filmography; - } - - public void setFilmography(List filmography) { - this.filmography = filmography; - } - - public void addFilm(Filmography film) { - this.filmography.add(film); - } - - public List getAka() { - return aka; - } - - public void setAka(List aka) { - this.aka = aka; - } - - public void addAka(String alsoKnownAs) { - this.aka.add(alsoKnownAs); - } - - public Date getLastModifiedAt() { - return lastModifiedAt; - } - - public void setLastModifiedAt(Date lastModifiedAt) { - this.lastModifiedAt = lastModifiedAt; - } - - public void setLastModifiedAt(String lastModifiedAt) { - DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - - try { - Date lma = df.parse(lastModifiedAt); - setLastModifiedAt(lma); - } catch (Exception ignore) { - return; - } - } public int getKnownMovies() { return knownMovies; } - public void setKnownMovies(int knownMovies) { - this.knownMovies = knownMovies; + public Date getLastModifiedAt() { + return lastModifiedAt; + } + + public String getName() { + return name; } - public Date getBirthday() { - return birthday; + public int getOrder() { + return order; } + public String getUrl() { + return url; + } + + public int getVersion() { + return version; + } + + public void setAka(List aka) { + this.aka = aka; + } + + public void setBiography(String biography) { + this.biography = biography; + } + public void setBirthday(Date birthday) { this.birthday = birthday; } - + public void setBirthday(String sBirthday) { DateFormat df = new SimpleDateFormat("yyyy-MM-dd"); @@ -169,11 +153,70 @@ public class Person extends ModelTools { } } - public String getBirthPlace() { - return birthPlace; - } - public void setBirthPlace(String birthPlace) { this.birthPlace = birthPlace; } + + public void setCastId(int castId) { + this.castId = castId; + } + + public void setCharacter(String character) { + this.character = character; + } + + public void setDepartment(String department) { + this.department = department; + } + + public void setFilmography(List filmography) { + this.filmography = filmography; + } + + public void setId(String id) { + this.id = id; + } + + public void setImages(List images) { + this.images = images; + } + + public void setJob(String job) { + this.job = job; + } + + public void setKnownMovies(int knownMovies) { + this.knownMovies = knownMovies; + } + + public void setLastModifiedAt(Date lastModifiedAt) { + this.lastModifiedAt = lastModifiedAt; + } + + public void setLastModifiedAt(String lastModifiedAt) { + DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + + try { + Date lma = df.parse(lastModifiedAt); + setLastModifiedAt(lma); + } catch (Exception ignore) { + return; + } + } + + public void setName(String name) { + this.name = name; + } + + public void setOrder(int order) { + this.order = order; + } + + public void setUrl(String url) { + this.url = url; + } + + public void setVersion(int version) { + this.version = version; + } } From ce52629e8cfb86cc936528dc371ab4382a8fb449 Mon Sep 17 00:00:00 2001 From: Omertron Date: Thu, 7 Oct 2010 10:05:42 +0000 Subject: [PATCH 019/207] Updated parseMovieInfo --- .../moviejukebox/themoviedb/model/Person.java | 16 +++++ .../themoviedb/tools/DOMParser.java | 58 ++++++++++++++++--- 2 files changed, 67 insertions(+), 7 deletions(-) diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/model/Person.java b/themoviedbapi/src/com/moviejukebox/themoviedb/model/Person.java index 757a17045..8a9e58c5d 100644 --- a/themoviedbapi/src/com/moviejukebox/themoviedb/model/Person.java +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/model/Person.java @@ -160,6 +160,14 @@ public class Person extends ModelTools { public void setCastId(int castId) { this.castId = castId; } + + public void setCastId(String castId) { + try { + this.castId = Integer.parseInt(castId); + } catch (Exception ignore) { + this.castId = -1; + } + } public void setCharacter(String character) { this.character = character; @@ -211,6 +219,14 @@ public class Person extends ModelTools { public void setOrder(int order) { this.order = order; } + + public void setOrder(String order) { + try { + this.order = Integer.parseInt(order); + } catch (Exception ignore) { + this.order = -1; + } + } public void setUrl(String url) { this.url = url; diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/tools/DOMParser.java b/themoviedbapi/src/com/moviejukebox/themoviedb/tools/DOMParser.java index 38a4f727a..4cba62e96 100644 --- a/themoviedbapi/src/com/moviejukebox/themoviedb/tools/DOMParser.java +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/tools/DOMParser.java @@ -27,12 +27,13 @@ import com.moviejukebox.themoviedb.model.Country; import com.moviejukebox.themoviedb.model.Filmography; import com.moviejukebox.themoviedb.model.MovieDB; import com.moviejukebox.themoviedb.model.Person; +import com.moviejukebox.themoviedb.model.Studio; public class DOMParser { static Logger logger = TheMovieDb.getLogger(); public static MovieDB parseMovieInfo(Document doc) { - // Borrowed from http://www.java-tips.org/java-se-tips/javax.xml.parsers/how-to-read-xml-file-in-java.html + // Inspired by http://www.java-tips.org/java-se-tips/javax.xml.parsers/how-to-read-xml-file-in-java.html MovieDB movie = null; NodeList movieNodeList, subNodeList; Node movieNode, subNode; @@ -52,15 +53,24 @@ public class DOMParser { if (movieNode.getNodeType() == Node.ELEMENT_NODE) { movieElement = (Element) movieNode; - - movie.setTitle(DOMHelper.getValueFromElement(movieElement, "name")); + + // DOMHelper.getValueFromElement(movieElement, "") + movie.setPopularity(DOMHelper.getValueFromElement(movieElement, "popularity")); + movie.setTranslated(DOMHelper.getValueFromElement(movieElement, "translated")); + movie.setAdult(DOMHelper.getValueFromElement(movieElement, "adult")); + movie.setLanguage(DOMHelper.getValueFromElement(movieElement, "language")); + movie.setOriginalName(DOMHelper.getValueFromElement(movieElement, "original_name")); + movie.setTitle(DOMHelper.getValueFromElement(movieElement, "name")); + movie.setAlternativeName(DOMHelper.getValueFromElement(movieElement, "alternative_name")); movie.setType(DOMHelper.getValueFromElement(movieElement, "type")); movie.setId(DOMHelper.getValueFromElement(movieElement, "id")); movie.setImdb(DOMHelper.getValueFromElement(movieElement, "imdb_id")); movie.setUrl(DOMHelper.getValueFromElement(movieElement, "url")); movie.setOverview(DOMHelper.getValueFromElement(movieElement, "overview")); movie.setRating(DOMHelper.getValueFromElement(movieElement, "rating")); + movie.setTagline(DOMHelper.getValueFromElement(movieElement, "tagline")); + movie.setCertification(DOMHelper.getValueFromElement(movieElement, "certification")); movie.setReleaseDate(DOMHelper.getValueFromElement(movieElement, "released")); movie.setRuntime(DOMHelper.getValueFromElement(movieElement, "runtime")); movie.setBudget(DOMHelper.getValueFromElement(movieElement, "budget")); @@ -86,12 +96,39 @@ public class DOMParser { category.setType(subElement.getAttribute("type")); category.setUrl(subElement.getAttribute("url")); category.setName(subElement.getAttribute("name")); + category.setId(subElement.getAttribute("id")); + movie.addCategory(category); } } } } + // Process the "studios" + subNodeList = doc.getElementsByTagName("studios"); + + for (int nodeLoop = 0; nodeLoop < subNodeList.getLength(); nodeLoop++) { + subNode = subNodeList.item(nodeLoop); + if (subNode.getNodeType() == Node.ELEMENT_NODE) { + subElement = (Element) subNode; + + NodeList studioList = subNode.getChildNodes(); + for (int i = 0; i < studioList.getLength(); i++) { + Node studioNode = studioList.item(i); + if (studioNode.getNodeType() == Node.ELEMENT_NODE) { + subElement = (Element) studioNode; + Studio studio = new Studio(); + + studio.setUrl(subElement.getAttribute("url")); + studio.setName(subElement.getAttribute("name")); + studio.setId(subElement.getAttribute("id")); + + movie.addStudio(studio); + } + } + } + } + // Process the "countries" subNodeList = doc.getElementsByTagName("countries"); @@ -101,9 +138,9 @@ public class DOMParser { subElement = (Element) subNode; Country country = new Country(); + country.setName(DOMHelper.getValueFromElement(subElement, "name")); country.setCode(DOMHelper.getValueFromElement(subElement, "code")); country.setUrl(DOMHelper.getValueFromElement(subElement, "url")); - country.setName(DOMHelper.getValueFromElement(subElement, "name")); movie.addProductionCountry(country); } @@ -124,11 +161,18 @@ public class DOMParser { subElement = (Element) personNode; Person person = new Person(); - person.setUrl(subElement.getAttribute("url")); person.setName(subElement.getAttribute("name")); - person.setJob(subElement.getAttribute("job")); person.setCharacter(subElement.getAttribute("character")); + person.setJob(subElement.getAttribute("job")); person.setId(subElement.getAttribute("id")); + person.addArtwork(Artwork.ARTWORK_TYPE_PERSON, + Artwork.ARTWORK_SIZE_THUMB, + subElement.getAttribute("thumb"), "-1"); + person.setDepartment(subElement.getAttribute("department")); + person.setUrl(subElement.getAttribute("url")); + person.setOrder(subElement.getAttribute("order")); + person.setCastId(subElement.getAttribute("cast_id")); + movie.addPerson(person); } } @@ -201,7 +245,7 @@ public class DOMParser { } } else { // This is a classic, it should never happen error - logger.severe("UNKNOWN Image type"); + logger.severe("UNKNOWN Image type: " + subElement.getNodeName()); } } } From f4f64b59628f17f4db68352d1b3786cf89ce56fc Mon Sep 17 00:00:00 2001 From: Omertron Date: Thu, 7 Oct 2010 10:32:16 +0000 Subject: [PATCH 020/207] Added a method to return a single country --- .../com/moviejukebox/themoviedb/model/MovieDB.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/model/MovieDB.java b/themoviedbapi/src/com/moviejukebox/themoviedb/model/MovieDB.java index 18efa4e5c..2a60da8e4 100644 --- a/themoviedbapi/src/com/moviejukebox/themoviedb/model/MovieDB.java +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/model/MovieDB.java @@ -54,6 +54,18 @@ public class MovieDB extends ModelTools { private List people = new ArrayList(); private List artwork = new ArrayList(); + /** + * Just return the first country + * @return + */ + public String getCountry() { + if (!countries.isEmpty()) { + Country country = countries.get(0); + return country.getName(); + } + return UNKNOWN; + } + public String getPopularity() { return popularity; } From 47de11b73bc5421160712cbc26bb7913f4a9a332 Mon Sep 17 00:00:00 2001 From: Omertron Date: Thu, 7 Oct 2010 11:16:02 +0000 Subject: [PATCH 021/207] Fixed country parsing --- .../themoviedb/model/MovieDB.java | 12 -------- .../themoviedb/tools/DOMParser.java | 28 +++++++++++++------ 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/model/MovieDB.java b/themoviedbapi/src/com/moviejukebox/themoviedb/model/MovieDB.java index 2a60da8e4..18efa4e5c 100644 --- a/themoviedbapi/src/com/moviejukebox/themoviedb/model/MovieDB.java +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/model/MovieDB.java @@ -54,18 +54,6 @@ public class MovieDB extends ModelTools { private List people = new ArrayList(); private List artwork = new ArrayList(); - /** - * Just return the first country - * @return - */ - public String getCountry() { - if (!countries.isEmpty()) { - Country country = countries.get(0); - return country.getName(); - } - return UNKNOWN; - } - public String getPopularity() { return popularity; } diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/tools/DOMParser.java b/themoviedbapi/src/com/moviejukebox/themoviedb/tools/DOMParser.java index 4cba62e96..f944c6e48 100644 --- a/themoviedbapi/src/com/moviejukebox/themoviedb/tools/DOMParser.java +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/tools/DOMParser.java @@ -136,16 +136,28 @@ public class DOMParser { subNode = subNodeList.item(nodeLoop); if (subNode.getNodeType() == Node.ELEMENT_NODE) { subElement = (Element) subNode; - Country country = new Country(); - - country.setName(DOMHelper.getValueFromElement(subElement, "name")); - country.setCode(DOMHelper.getValueFromElement(subElement, "code")); - country.setUrl(DOMHelper.getValueFromElement(subElement, "url")); - - movie.addProductionCountry(country); + + NodeList countryList = subNode.getChildNodes(); + for (int i = 0; i < countryList.getLength(); i++) { + Node countryNode = countryList.item(i); + if (countryNode.getNodeType() == Node.ELEMENT_NODE) { + subElement = (Element) countryNode; + Country country = new Country(); + + country.setName(subElement.getAttribute("name")); + country.setCode(subElement.getAttribute("code")); + country.setUrl(subElement.getAttribute("url")); + + System.out.println("Name: " + country.getName()); + System.out.println("Code: " + country.getCode()); + System.out.println("Url : " + country.getUrl()); + + movie.addProductionCountry(country); + } + } } } - + // Process the "cast" subNodeList = doc.getElementsByTagName("cast"); From 2ac7df338eaf403074fb976506acb312bca9d2d1 Mon Sep 17 00:00:00 2001 From: Omertron Date: Thu, 7 Oct 2010 11:16:41 +0000 Subject: [PATCH 022/207] Fixed country parsing --- .../src/com/moviejukebox/themoviedb/tools/DOMParser.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/tools/DOMParser.java b/themoviedbapi/src/com/moviejukebox/themoviedb/tools/DOMParser.java index f944c6e48..33ac6b61d 100644 --- a/themoviedbapi/src/com/moviejukebox/themoviedb/tools/DOMParser.java +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/tools/DOMParser.java @@ -148,10 +148,6 @@ public class DOMParser { country.setCode(subElement.getAttribute("code")); country.setUrl(subElement.getAttribute("url")); - System.out.println("Name: " + country.getName()); - System.out.println("Code: " + country.getCode()); - System.out.println("Url : " + country.getUrl()); - movie.addProductionCountry(country); } } From 5367907eee578ebce6c30957d58f0c52c8f05c07 Mon Sep 17 00:00:00 2001 From: Mohammed Le Doze Date: Thu, 7 Oct 2010 11:46:12 +0000 Subject: [PATCH 023/207] moved parameters declaration after the initial check for null or empty strings --- .../src/com/moviejukebox/themoviedb/TheMovieDb.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java b/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java index 502d4dd62..92776f888 100644 --- a/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java @@ -98,14 +98,13 @@ public class TheMovieDb { */ public MovieDB moviedbSearch(String movieTitle, String language) { MovieDB movie = null; - Document doc = null; - - language = validateLanguage(language); - // If the title is null, then exit if (movieTitle == null || movieTitle.equals("")) return movie; + Document doc = null; + language = validateLanguage(language); + try { String searchUrl = buildSearchUrl("Movie.search", URLEncoder.encode(movieTitle, "UTF-8"), language); doc = DOMHelper.getEventDocFromUrl(searchUrl); From 635c7017a972e5ac9eab341e7e8b08792f2196e4 Mon Sep 17 00:00:00 2001 From: Mohammed Le Doze Date: Thu, 7 Oct 2010 12:07:01 +0000 Subject: [PATCH 024/207] added a finally block to ensure that the InputStream is closed if an exception is raised --- .../themoviedb/tools/DOMHelper.java | 37 ++++++++++--------- 1 file changed, 20 insertions(+), 17 deletions(-) diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/tools/DOMHelper.java b/themoviedbapi/src/com/moviejukebox/themoviedb/tools/DOMHelper.java index 521943db6..c87de81c4 100644 --- a/themoviedbapi/src/com/moviejukebox/themoviedb/tools/DOMHelper.java +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/tools/DOMHelper.java @@ -10,14 +10,11 @@ * For any reuse or distribution, you must make clear to others the * license terms of this work. */ - package com.moviejukebox.themoviedb.tools; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; -import java.io.UnsupportedEncodingException; -import java.net.MalformedURLException; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; @@ -35,6 +32,7 @@ import org.xml.sax.SAXException; * */ public class DOMHelper { + /** * Gets the string value of the tag element name passed * @param element @@ -43,7 +41,7 @@ public class DOMHelper { */ public static String getValueFromElement(Element element, String tagName) { String returnValue = ""; - + try { NodeList elementNodeList = element.getElementsByTagName(tagName); Element tagElement = (Element) elementNodeList.item(0); @@ -52,7 +50,7 @@ public class DOMHelper { } catch (Exception ignore) { return returnValue; } - + return returnValue; } @@ -60,22 +58,27 @@ public class DOMHelper { * Get a DOM document from the supplied URL * @param url * @return - * @throws MalformedURLException * @throws IOException * @throws ParserConfigurationException * @throws SAXException */ - public static Document getEventDocFromUrl(String url) - throws MalformedURLException, IOException, ParserConfigurationException, SAXException, UnsupportedEncodingException { - //InputStream in = (new URL(url)).openStream(); - String webPage = WebBrowser.request(url); - InputStream in = new ByteArrayInputStream(webPage.getBytes("UTF-8")); - - DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); - DocumentBuilder db = dbf.newDocumentBuilder(); - Document doc = db.parse(in); - - doc.getDocumentElement().normalize(); + public static Document getEventDocFromUrl(String url) + throws IOException, ParserConfigurationException, SAXException { + Document doc = null; + InputStream in = null; + try { + String webPage = WebBrowser.request(url); + in = new ByteArrayInputStream(webPage.getBytes("UTF-8")); + + DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); + DocumentBuilder db = dbf.newDocumentBuilder(); + doc = db.parse(in); + doc.getDocumentElement().normalize(); + } finally { + if (in != null) { + in.close(); + } + } return doc; } } From 40b085aceb06aae2f7956ad58e570539ba9da671 Mon Sep 17 00:00:00 2001 From: Omertron Date: Thu, 7 Oct 2010 14:21:46 +0000 Subject: [PATCH 025/207] Updated build files --- themoviedbapi/build.xml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/themoviedbapi/build.xml b/themoviedbapi/build.xml index 9e8cf3f4a..392df835c 100644 --- a/themoviedbapi/build.xml +++ b/themoviedbapi/build.xml @@ -62,11 +62,12 @@ - + - + + From 76fd55148a25863f290916a28375ab3d182317a5 Mon Sep 17 00:00:00 2001 From: Mohammed Le Doze Date: Fri, 8 Oct 2010 07:38:57 +0000 Subject: [PATCH 026/207] removed private member "artwork" in MovieDB because it is already defined in super class ModelTools; the method getArtwork returned an empty list --- .../src/com/moviejukebox/themoviedb/model/MovieDB.java | 9 --------- 1 file changed, 9 deletions(-) diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/model/MovieDB.java b/themoviedbapi/src/com/moviejukebox/themoviedb/model/MovieDB.java index 18efa4e5c..3836237ab 100644 --- a/themoviedbapi/src/com/moviejukebox/themoviedb/model/MovieDB.java +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/model/MovieDB.java @@ -52,7 +52,6 @@ public class MovieDB extends ModelTools { private List studios = new ArrayList(); private List countries = new ArrayList(); private List people = new ArrayList(); - private List artwork = new ArrayList(); public String getPopularity() { return popularity; @@ -232,10 +231,6 @@ public class MovieDB extends ModelTools { return countries; } - public List getArtwork() { - return artwork; - } - public void setTranslated(String translated) { this.translated = translated; } @@ -285,8 +280,4 @@ public class MovieDB extends ModelTools { public void setPeople(List people) { this.people = people; } - - public void setArtwork(List artwork) { - this.artwork = artwork; - } } From b1d1f6a6ce729c1ea9ac1db4673781e887253208 Mon Sep 17 00:00:00 2001 From: Omertron Date: Fri, 8 Oct 2010 20:11:09 +0000 Subject: [PATCH 027/207] Updated validate language --- .../moviejukebox/themoviedb/TheMovieDb.java | 67 ++++++++++--------- 1 file changed, 36 insertions(+), 31 deletions(-) diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java b/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java index 92776f888..ef4c11962 100644 --- a/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java @@ -37,7 +37,7 @@ public class TheMovieDb { private String apiKey; private static String apiSite = "http://api.themoviedb.org/2.1/"; - private static String defaultLanguage = "en"; + private static String defaultLanguage = "en-US"; private static Logger logger; private static LogFormatter tmdbFormatter = new LogFormatter(); private static ConsoleHandler tmdbConsoleHandler = new ConsoleHandler(); @@ -93,7 +93,7 @@ public class TheMovieDb { * Searches the database using the movie title passed * * @param movieTitle The title to search for - * @param language The two digit language code. E.g. en=English + * @param language The two digit language code. E.g. en=English * @return A movie bean with the data extracted */ public MovieDB moviedbSearch(String movieTitle, String language) { @@ -103,10 +103,9 @@ public class TheMovieDb { return movie; Document doc = null; - language = validateLanguage(language); try { - String searchUrl = buildSearchUrl("Movie.search", URLEncoder.encode(movieTitle, "UTF-8"), language); + String searchUrl = buildSearchUrl("Movie.search", URLEncoder.encode(movieTitle, "UTF-8"), validateLanguage(language)); doc = DOMHelper.getEventDocFromUrl(searchUrl); movie = DOMParser.parseMovieInfo(doc); @@ -131,10 +130,9 @@ public class TheMovieDb { return movie; Document doc = null; - language = validateLanguage(language); try { - String searchUrl = buildSearchUrl("Movie.imdbLookup", imdbID, language); + String searchUrl = buildSearchUrl("Movie.imdbLookup", imdbID, validateLanguage(language)); doc = DOMHelper.getEventDocFromUrl(searchUrl); movie = DOMParser.parseMovieInfo(doc); @@ -175,10 +173,9 @@ public class TheMovieDb { return movie; Document doc = null; - language = validateLanguage(language); try { - String searchUrl = buildSearchUrl("Movie.getInfo", tmdbID, language); + String searchUrl = buildSearchUrl("Movie.getInfo", tmdbID, validateLanguage(language)); doc = DOMHelper.getEventDocFromUrl(searchUrl); movie = DOMParser.parseMovieInfo(doc); @@ -208,10 +205,9 @@ public class TheMovieDb { return movie; Document doc = null; - language = validateLanguage(language); try { - String searchUrl = buildSearchUrl("Movie.getImages", searchTerm, language); + String searchUrl = buildSearchUrl("Movie.getImages", searchTerm, validateLanguage(language)); doc = DOMHelper.getEventDocFromUrl(searchUrl); movie = DOMParser.parseMovieInfo(doc); @@ -222,21 +218,6 @@ public class TheMovieDb { return movie; } - - /** - * This function will check the passed language against a list of known themoviedb.org languages - * Currently the only available language is English "en" and so that is what this function returns - * @param language - * @return - */ - private String validateLanguage(String language) { - if (language == null) { - language = defaultLanguage; - } else { - language = defaultLanguage; - } - return language; - } /** * The Person.search method is used to search for an actor, actress or production member. @@ -253,10 +234,9 @@ public class TheMovieDb { } Document doc = null; - language = validateLanguage(language); try { - String searchUrl = buildSearchUrl("Person.search", personName, language); + String searchUrl = buildSearchUrl("Person.search", personName, validateLanguage(language)); doc = DOMHelper.getEventDocFromUrl(searchUrl); person = DOMParser.parsePersonInfo(doc); } catch (Exception error) { @@ -281,10 +261,9 @@ public class TheMovieDb { } Document doc = null; - language = validateLanguage(language); try { - String searchUrl = buildSearchUrl("Person.getInfo", personID, language); + String searchUrl = buildSearchUrl("Person.getInfo", personID, validateLanguage(language)); doc = DOMHelper.getEventDocFromUrl(searchUrl); person = DOMParser.parsePersonInfo(doc); } catch (Exception error) { @@ -310,10 +289,9 @@ public class TheMovieDb { } Document doc = null; - language = validateLanguage(language); try { - String searchUrl = buildSearchUrl("Person.getVersion", personID, language); + String searchUrl = buildSearchUrl("Person.getVersion", personID, validateLanguage(language)); doc = DOMHelper.getEventDocFromUrl(searchUrl); person = DOMParser.parsePersonGetVersion(doc); } catch (Exception error) { @@ -322,4 +300,31 @@ public class TheMovieDb { return person; } + + /** + * This function will check the passed language against a list of known themoviedb.org languages + * Currently the only available language is English "en" and so that is what this function returns + * @param language + * @return + */ + private String validateLanguage(String language) { + if (language == null) { + return defaultLanguage; + } else { + /* + * Rather than check every conceivable language, we'll just validate the format of the language + * The language should either be 2 or 5 characters "xx" or "xx-YY" + * http://api.themoviedb.org/2.1/language-tags + */ + if (language.length() == 2) { + return language.toLowerCase(); + } else if (language.length() == 5) { + return language.substring(1, 2).toLowerCase() + "-" + language.substring(4, 5).toUpperCase(); + } else { + // The format of the language is wrong, so just cut the first two characters and use that + // The site will take care of invalid languages + return language.substring(1, 2).toLowerCase(); + } + } + } } From 9a5fdc330e7beb065779c8440a5ffc25787bae91 Mon Sep 17 00:00:00 2001 From: Omertron Date: Sun, 10 Oct 2010 14:54:35 +0000 Subject: [PATCH 028/207] Updated methods to return lists rather than single movies --- .../moviejukebox/themoviedb/TheMovieDb.java | 169 +++++++- .../themoviedb/tools/DOMParser.java | 371 +++++++++--------- 2 files changed, 327 insertions(+), 213 deletions(-) diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java b/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java index ef4c11962..5dc4d172b 100644 --- a/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java @@ -14,11 +14,17 @@ package com.moviejukebox.themoviedb; import java.net.URLEncoder; +import java.util.ArrayList; +import java.util.Collection; +import java.util.List; import java.util.logging.ConsoleHandler; import java.util.logging.Level; import java.util.logging.Logger; import org.w3c.dom.Document; +import org.w3c.dom.Element; +import org.w3c.dom.Node; +import org.w3c.dom.NodeList; import com.moviejukebox.themoviedb.model.MovieDB; import com.moviejukebox.themoviedb.model.Person; @@ -96,23 +102,39 @@ public class TheMovieDb { * @param language The two digit language code. E.g. en=English * @return A movie bean with the data extracted */ - public MovieDB moviedbSearch(String movieTitle, String language) { + public List moviedbSearch(String movieTitle, String language) { MovieDB movie = null; + List movieList = new ArrayList(); + // If the title is null, then exit - if (movieTitle == null || movieTitle.equals("")) - return movie; + if (!isValidString(movieTitle)) { + return movieList; + } Document doc = null; try { String searchUrl = buildSearchUrl("Movie.search", URLEncoder.encode(movieTitle, "UTF-8"), validateLanguage(language)); doc = DOMHelper.getEventDocFromUrl(searchUrl); - movie = DOMParser.parseMovieInfo(doc); - + NodeList nlMovies = doc.getElementsByTagName("movie"); + if (nlMovies == null) { + return movieList; + } + + for (int loop = 0; loop < nlMovies.getLength(); loop++) { + Node nMovie = nlMovies.item(loop); + if (nMovie.getNodeType() == Node.ELEMENT_NODE) { + Element eMovie = (Element) nMovie; + movie = DOMParser.parseMovieInfo(eMovie); + if (movie != null) { + movieList.add(movie); + } + } + } } catch (Exception error) { logger.severe("TheMovieDb Error: " + error.getMessage()); } - return movie; + return movieList; } /** @@ -123,11 +145,12 @@ public class TheMovieDb { * @return A movie bean with the data extracted */ public MovieDB moviedbImdbLookup(String imdbID, String language) { - MovieDB movie = null; + MovieDB movie = new MovieDB(); // If the imdbID is null, then exit - if (imdbID == null || imdbID.equals("")) + if (!isValidString(imdbID)) { return movie; + } Document doc = null; @@ -135,8 +158,18 @@ public class TheMovieDb { String searchUrl = buildSearchUrl("Movie.imdbLookup", imdbID, validateLanguage(language)); doc = DOMHelper.getEventDocFromUrl(searchUrl); - movie = DOMParser.parseMovieInfo(doc); - + NodeList nlMovies = doc.getElementsByTagName("movie"); + if (nlMovies == null) { + return movie; + } + + for (int loop = 0; loop < nlMovies.getLength(); loop++) { + Node nMovie = nlMovies.item(loop); + if (nMovie.getNodeType() == Node.ELEMENT_NODE) { + Element eMovie = (Element) nMovie; + movie = DOMParser.parseMovieInfo(eMovie); + } + } } catch (Exception error) { logger.severe("TheMovieDb Error: " + error.getMessage()); } @@ -169,7 +202,7 @@ public class TheMovieDb { */ public MovieDB moviedbGetInfo(String tmdbID, MovieDB movie, String language) { // If the tmdbID is null, then exit - if (tmdbID == null || tmdbID.equals("") || tmdbID.equalsIgnoreCase("UNKNOWN")) + if (!isValidString(tmdbID)) return movie; Document doc = null; @@ -178,8 +211,18 @@ public class TheMovieDb { String searchUrl = buildSearchUrl("Movie.getInfo", tmdbID, validateLanguage(language)); doc = DOMHelper.getEventDocFromUrl(searchUrl); - movie = DOMParser.parseMovieInfo(doc); - + NodeList nlMovies = doc.getElementsByTagName("movie"); + if (nlMovies == null) { + return movie; + } + + for (int loop = 0; loop < nlMovies.getLength(); loop++) { + Node nMovie = nlMovies.item(loop); + if (nMovie.getNodeType() == Node.ELEMENT_NODE) { + Element eMovie = (Element) nMovie; + movie = DOMParser.parseMovieInfo(eMovie); + } + } } catch (Exception error) { logger.severe("TheMovieDb Error: " + error.getMessage()); } @@ -201,7 +244,7 @@ public class TheMovieDb { */ public MovieDB moviedbGetImages(String searchTerm, MovieDB movie, String language) { // If the searchTerm is null, then exit - if (searchTerm == null || searchTerm.equals("") || searchTerm.equalsIgnoreCase("UNKNOWN")) + if (isValidString(searchTerm)) return movie; Document doc = null; @@ -210,7 +253,18 @@ public class TheMovieDb { String searchUrl = buildSearchUrl("Movie.getImages", searchTerm, validateLanguage(language)); doc = DOMHelper.getEventDocFromUrl(searchUrl); - movie = DOMParser.parseMovieInfo(doc); + NodeList nlMovies = doc.getElementsByTagName("movie"); + if (nlMovies == null) { + return movie; + } + + for (int loop = 0; loop < nlMovies.getLength(); loop++) { + Node nMovie = nlMovies.item(loop); + if (nMovie.getNodeType() == Node.ELEMENT_NODE) { + Element eMovie = (Element) nMovie; + movie = DOMParser.parseMovieInfo(eMovie); + } + } } catch (Exception error) { logger.severe("TheMovieDb Error: " + error.getMessage()); @@ -229,7 +283,7 @@ public class TheMovieDb { */ public Person personSearch(String personName, String language) { Person person = new Person(); - if (personName == null || personName.equals("")) { + if (!isValidString(personName)) { return person; } @@ -256,7 +310,7 @@ public class TheMovieDb { */ public Person personGetInfo(String personID, String language) { Person person = new Person(); - if (personID == null || personID.equals("")) { + if (!isValidString(personID)) { return person; } @@ -284,7 +338,7 @@ public class TheMovieDb { */ public Person personGetVersion(String personID, String language) { Person person = new Person(); - if (personID == null || personID.equals("")) { + if (!isValidString(personID)) { return person; } @@ -308,7 +362,7 @@ public class TheMovieDb { * @return */ private String validateLanguage(String language) { - if (language == null) { + if (!isValidString(language)) { return defaultLanguage; } else { /* @@ -327,4 +381,81 @@ public class TheMovieDb { } } } + + /** + * Check the string passed to see if it contains a value. + * @param testString The string to test + * @return False if the string is empty, null or UNKNOWN, True otherwise + */ + public static boolean isValidString(String testString) { + if (testString == null) { + return false; + } + + if (testString.equalsIgnoreCase(MovieDB.UNKNOWN)) { + return false; + } + + if (testString.trim().equals("")) { + return false; + } + + return true; + } + + /** + * Search a list of movies and return the one that matches the title & year + * @param movieList The list of movies to search + * @param title The title to search for + * @param year The year of the title to search for + * @return The matching movie + */ + public static MovieDB findMovie(Collection movieList, String title, String year) { + if (movieList == null || movieList.isEmpty()) { + return null; + } + + System.out.println("Looking for: " + title + " - Year: " + year); + + for (MovieDB moviedb : movieList) { + if (compareMovies(moviedb, title, year)) { + System.out.println("Matched: " + moviedb.getTitle()); + return moviedb; + } else { + System.out.println("Not Matched: " + moviedb.getTitle() + " - " + moviedb.getReleaseDate()); + } + } + + return null; + } + + /** + * Compare the MovieDB object with a title & year + * @param moviedb The moviedb object to compare too + * @param title The title of the movie to compare + * @param year The year of the movie to compare + * @return True if there is a match, False otherwise. + */ + public static boolean compareMovies(MovieDB moviedb, String title, String year) { + if (!isValidString(title)) { + return false; + } + + if (isValidString(year)) { + if (isValidString(moviedb.getReleaseDate())) { + // Compare with year + String movieYear = moviedb.getReleaseDate().substring(0, 4); + logger.fine("Comparing against: " + moviedb.getTitle() + " - " + moviedb.getReleaseDate() + " - " + movieYear); + if (moviedb.getTitle().equalsIgnoreCase(title) && movieYear.equals(year)) { + return true; + } + } + } else { + // Compare without year + if (moviedb.getTitle().equalsIgnoreCase(title)) { + return true; + } + } + return false; + } } diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/tools/DOMParser.java b/themoviedbapi/src/com/moviejukebox/themoviedb/tools/DOMParser.java index 33ac6b61d..6e9431a80 100644 --- a/themoviedbapi/src/com/moviejukebox/themoviedb/tools/DOMParser.java +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/tools/DOMParser.java @@ -32,229 +32,212 @@ import com.moviejukebox.themoviedb.model.Studio; public class DOMParser { static Logger logger = TheMovieDb.getLogger(); - public static MovieDB parseMovieInfo(Document doc) { + public static MovieDB parseMovieInfo(Element movieElement) { // Inspired by http://www.java-tips.org/java-se-tips/javax.xml.parsers/how-to-read-xml-file-in-java.html - MovieDB movie = null; - NodeList movieNodeList, subNodeList; - Node movieNode, subNode; - Element movieElement, subElement; + MovieDB movie = new MovieDB(); + NodeList subNodeList; + Node subNode; + Element subElement; try { - movie = new MovieDB(); - movieNodeList = doc.getElementsByTagName("movie"); + movie.setPopularity(DOMHelper.getValueFromElement(movieElement, "popularity")); + movie.setTranslated(DOMHelper.getValueFromElement(movieElement, "translated")); + movie.setAdult(DOMHelper.getValueFromElement(movieElement, "adult")); + movie.setLanguage(DOMHelper.getValueFromElement(movieElement, "language")); + movie.setOriginalName(DOMHelper.getValueFromElement(movieElement, "original_name")); + movie.setTitle(DOMHelper.getValueFromElement(movieElement, "name")); + movie.setAlternativeName(DOMHelper.getValueFromElement(movieElement, "alternative_name")); + movie.setType(DOMHelper.getValueFromElement(movieElement, "type")); + movie.setId(DOMHelper.getValueFromElement(movieElement, "id")); + movie.setImdb(DOMHelper.getValueFromElement(movieElement, "imdb_id")); + movie.setUrl(DOMHelper.getValueFromElement(movieElement, "url")); + movie.setOverview(DOMHelper.getValueFromElement(movieElement, "overview")); + movie.setRating(DOMHelper.getValueFromElement(movieElement, "rating")); + movie.setTagline(DOMHelper.getValueFromElement(movieElement, "tagline")); + movie.setCertification(DOMHelper.getValueFromElement(movieElement, "certification")); + movie.setReleaseDate(DOMHelper.getValueFromElement(movieElement, "released")); + movie.setRuntime(DOMHelper.getValueFromElement(movieElement, "runtime")); + movie.setBudget(DOMHelper.getValueFromElement(movieElement, "budget")); + movie.setRevenue(DOMHelper.getValueFromElement(movieElement, "revenue")); + movie.setHomepage(DOMHelper.getValueFromElement(movieElement, "homepage")); + movie.setTrailer(DOMHelper.getValueFromElement(movieElement, "trailer")); - // Only get the first movie from the list - movieNode = movieNodeList.item(0); - - if (movieNode == null) { - logger.finest("Movie not found"); - return movie; + // Process the "categories" + subNodeList = movieElement.getElementsByTagName("categories"); + + for (int nodeLoop = 0; nodeLoop < subNodeList.getLength(); nodeLoop++) { + subNode = subNodeList.item(nodeLoop); + if (subNode.getNodeType() == Node.ELEMENT_NODE) { + subElement = (Element) subNode; + + NodeList castList = subNode.getChildNodes(); + for (int i = 0; i < castList.getLength(); i++) { + Node personNode = castList.item(i); + if (personNode.getNodeType() == Node.ELEMENT_NODE) { + subElement = (Element) personNode; + Category category = new Category(); + + category.setType(subElement.getAttribute("type")); + category.setUrl(subElement.getAttribute("url")); + category.setName(subElement.getAttribute("name")); + category.setId(subElement.getAttribute("id")); + + movie.addCategory(category); + } + } + } } + + // Process the "studios" + subNodeList = movieElement.getElementsByTagName("studios"); - if (movieNode.getNodeType() == Node.ELEMENT_NODE) { - movieElement = (Element) movieNode; - - // DOMHelper.getValueFromElement(movieElement, "") - - movie.setPopularity(DOMHelper.getValueFromElement(movieElement, "popularity")); - movie.setTranslated(DOMHelper.getValueFromElement(movieElement, "translated")); - movie.setAdult(DOMHelper.getValueFromElement(movieElement, "adult")); - movie.setLanguage(DOMHelper.getValueFromElement(movieElement, "language")); - movie.setOriginalName(DOMHelper.getValueFromElement(movieElement, "original_name")); - movie.setTitle(DOMHelper.getValueFromElement(movieElement, "name")); - movie.setAlternativeName(DOMHelper.getValueFromElement(movieElement, "alternative_name")); - movie.setType(DOMHelper.getValueFromElement(movieElement, "type")); - movie.setId(DOMHelper.getValueFromElement(movieElement, "id")); - movie.setImdb(DOMHelper.getValueFromElement(movieElement, "imdb_id")); - movie.setUrl(DOMHelper.getValueFromElement(movieElement, "url")); - movie.setOverview(DOMHelper.getValueFromElement(movieElement, "overview")); - movie.setRating(DOMHelper.getValueFromElement(movieElement, "rating")); - movie.setTagline(DOMHelper.getValueFromElement(movieElement, "tagline")); - movie.setCertification(DOMHelper.getValueFromElement(movieElement, "certification")); - movie.setReleaseDate(DOMHelper.getValueFromElement(movieElement, "released")); - movie.setRuntime(DOMHelper.getValueFromElement(movieElement, "runtime")); - movie.setBudget(DOMHelper.getValueFromElement(movieElement, "budget")); - movie.setRevenue(DOMHelper.getValueFromElement(movieElement, "revenue")); - movie.setHomepage(DOMHelper.getValueFromElement(movieElement, "homepage")); - movie.setTrailer(DOMHelper.getValueFromElement(movieElement, "trailer")); + for (int nodeLoop = 0; nodeLoop < subNodeList.getLength(); nodeLoop++) { + subNode = subNodeList.item(nodeLoop); + if (subNode.getNodeType() == Node.ELEMENT_NODE) { + subElement = (Element) subNode; - // Process the "categories" - subNodeList = doc.getElementsByTagName("categories"); + NodeList studioList = subNode.getChildNodes(); + for (int i = 0; i < studioList.getLength(); i++) { + Node studioNode = studioList.item(i); + if (studioNode.getNodeType() == Node.ELEMENT_NODE) { + subElement = (Element) studioNode; + Studio studio = new Studio(); - for (int nodeLoop = 0; nodeLoop < subNodeList.getLength(); nodeLoop++) { - subNode = subNodeList.item(nodeLoop); - if (subNode.getNodeType() == Node.ELEMENT_NODE) { - subElement = (Element) subNode; - - NodeList castList = subNode.getChildNodes(); - for (int i = 0; i < castList.getLength(); i++) { - Node personNode = castList.item(i); - if (personNode.getNodeType() == Node.ELEMENT_NODE) { - subElement = (Element) personNode; - Category category = new Category(); - - category.setType(subElement.getAttribute("type")); - category.setUrl(subElement.getAttribute("url")); - category.setName(subElement.getAttribute("name")); - category.setId(subElement.getAttribute("id")); - - movie.addCategory(category); - } + studio.setUrl(subElement.getAttribute("url")); + studio.setName(subElement.getAttribute("name")); + studio.setId(subElement.getAttribute("id")); + + movie.addStudio(studio); } } } - - // Process the "studios" - subNodeList = doc.getElementsByTagName("studios"); + } + + // Process the "countries" + subNodeList = movieElement.getElementsByTagName("countries"); - for (int nodeLoop = 0; nodeLoop < subNodeList.getLength(); nodeLoop++) { - subNode = subNodeList.item(nodeLoop); - if (subNode.getNodeType() == Node.ELEMENT_NODE) { - subElement = (Element) subNode; + for (int nodeLoop = 0; nodeLoop < subNodeList.getLength(); nodeLoop++) { + subNode = subNodeList.item(nodeLoop); + if (subNode.getNodeType() == Node.ELEMENT_NODE) { + subElement = (Element) subNode; - NodeList studioList = subNode.getChildNodes(); - for (int i = 0; i < studioList.getLength(); i++) { - Node studioNode = studioList.item(i); - if (studioNode.getNodeType() == Node.ELEMENT_NODE) { - subElement = (Element) studioNode; - Studio studio = new Studio(); + NodeList countryList = subNode.getChildNodes(); + for (int i = 0; i < countryList.getLength(); i++) { + Node countryNode = countryList.item(i); + if (countryNode.getNodeType() == Node.ELEMENT_NODE) { + subElement = (Element) countryNode; + Country country = new Country(); - studio.setUrl(subElement.getAttribute("url")); - studio.setName(subElement.getAttribute("name")); - studio.setId(subElement.getAttribute("id")); - - movie.addStudio(studio); - } + country.setName(subElement.getAttribute("name")); + country.setCode(subElement.getAttribute("code")); + country.setUrl(subElement.getAttribute("url")); + + movie.addProductionCountry(country); } } } - - // Process the "countries" - subNodeList = doc.getElementsByTagName("countries"); + } + + // Process the "cast" + subNodeList = movieElement.getElementsByTagName("cast"); - for (int nodeLoop = 0; nodeLoop < subNodeList.getLength(); nodeLoop++) { - subNode = subNodeList.item(nodeLoop); - if (subNode.getNodeType() == Node.ELEMENT_NODE) { - subElement = (Element) subNode; + for (int nodeLoop = 0; nodeLoop < subNodeList.getLength(); nodeLoop++) { + subNode = subNodeList.item(nodeLoop); + if (subNode.getNodeType() == Node.ELEMENT_NODE) { + subElement = (Element) subNode; - NodeList countryList = subNode.getChildNodes(); - for (int i = 0; i < countryList.getLength(); i++) { - Node countryNode = countryList.item(i); - if (countryNode.getNodeType() == Node.ELEMENT_NODE) { - subElement = (Element) countryNode; - Country country = new Country(); + NodeList castList = subNode.getChildNodes(); + for (int i = 0; i < castList.getLength(); i++) { + Node personNode = castList.item(i); + if (personNode.getNodeType() == Node.ELEMENT_NODE) { + subElement = (Element) personNode; + Person person = new Person(); - country.setName(subElement.getAttribute("name")); - country.setCode(subElement.getAttribute("code")); - country.setUrl(subElement.getAttribute("url")); - - movie.addProductionCountry(country); - } + person.setName(subElement.getAttribute("name")); + person.setCharacter(subElement.getAttribute("character")); + person.setJob(subElement.getAttribute("job")); + person.setId(subElement.getAttribute("id")); + person.addArtwork(Artwork.ARTWORK_TYPE_PERSON, + Artwork.ARTWORK_SIZE_THUMB, + subElement.getAttribute("thumb"), "-1"); + person.setDepartment(subElement.getAttribute("department")); + person.setUrl(subElement.getAttribute("url")); + person.setOrder(subElement.getAttribute("order")); + person.setCastId(subElement.getAttribute("cast_id")); + + movie.addPerson(person); } } } - - // Process the "cast" - subNodeList = doc.getElementsByTagName("cast"); + } + + /* + * This processes the image elements. There are two formats to deal with: + * Movie.imdbLookup, Movie.getInfo & Movie.search: + * + * + * + * + * + * Movie.getImages: + * + * + * + * + * + * + * + * + * + * + * + * + * + */ + subNodeList = movieElement.getElementsByTagName("images"); - for (int nodeLoop = 0; nodeLoop < subNodeList.getLength(); nodeLoop++) { - subNode = subNodeList.item(nodeLoop); - if (subNode.getNodeType() == Node.ELEMENT_NODE) { - subElement = (Element) subNode; - - NodeList castList = subNode.getChildNodes(); - for (int i = 0; i < castList.getLength(); i++) { - Node personNode = castList.item(i); - if (personNode.getNodeType() == Node.ELEMENT_NODE) { - subElement = (Element) personNode; - Person person = new Person(); - - person.setName(subElement.getAttribute("name")); - person.setCharacter(subElement.getAttribute("character")); - person.setJob(subElement.getAttribute("job")); - person.setId(subElement.getAttribute("id")); - person.addArtwork(Artwork.ARTWORK_TYPE_PERSON, - Artwork.ARTWORK_SIZE_THUMB, - subElement.getAttribute("thumb"), "-1"); - person.setDepartment(subElement.getAttribute("department")); - person.setUrl(subElement.getAttribute("url")); - person.setOrder(subElement.getAttribute("order")); - person.setCastId(subElement.getAttribute("cast_id")); - - movie.addPerson(person); - } - } - } - } + for (int nodeLoop = 0; nodeLoop < subNodeList.getLength(); nodeLoop++) { + subNode = subNodeList.item(nodeLoop); - /* - * This processes the image elements. There are two formats to deal with: - * Movie.imdbLookup, Movie.getInfo & Movie.search: - * - * - * - * - * - * Movie.getImages: - * - * - * - * - * - * - * - * - * - * - * - * - * - */ - subNodeList = doc.getElementsByTagName("images"); - - for (int nodeLoop = 0; nodeLoop < subNodeList.getLength(); nodeLoop++) { - subNode = subNodeList.item(nodeLoop); + if (subNode.getNodeType() == Node.ELEMENT_NODE) { - if (subNode.getNodeType() == Node.ELEMENT_NODE) { - - NodeList artworkNodeList = subNode.getChildNodes(); - for (int artworkLoop = 0; artworkLoop < artworkNodeList.getLength(); artworkLoop++) { - Node artworkNode = artworkNodeList.item(artworkLoop); - if (artworkNode.getNodeType() == Node.ELEMENT_NODE) { - subElement = (Element) artworkNode; + NodeList artworkNodeList = subNode.getChildNodes(); + for (int artworkLoop = 0; artworkLoop < artworkNodeList.getLength(); artworkLoop++) { + Node artworkNode = artworkNodeList.item(artworkLoop); + if (artworkNode.getNodeType() == Node.ELEMENT_NODE) { + subElement = (Element) artworkNode; - if (subElement.getNodeName().equalsIgnoreCase("image")) { - // This is the format used in Movie.imdbLookup, Movie.getInfo & Movie.search - Artwork artwork = new Artwork(); - artwork.setType(subElement.getAttribute("type")); - artwork.setSize(subElement.getAttribute("size")); - artwork.setUrl(subElement.getAttribute("url")); - artwork.setId(subElement.getAttribute("id")); - movie.addArtwork(artwork); - } else if (subElement.getNodeName().equalsIgnoreCase("backdrop") || - subElement.getNodeName().equalsIgnoreCase("poster")) { - // This is the format used in Movie.getImages - String artworkId = subElement.getAttribute("id"); - String artworkType = subElement.getNodeName(); - - // We need to decode and loop round the child nodes to get the data - NodeList imageNodeList = subElement.getChildNodes(); - for (int imageLoop = 0; imageLoop < imageNodeList.getLength(); imageLoop++) { - Node imageNode = imageNodeList.item(imageLoop); - if (imageNode.getNodeType() == Node.ELEMENT_NODE) { - Element imageElement = (Element) imageNode; - Artwork artwork = new Artwork(); - artwork.setId(artworkId); - artwork.setType(artworkType); - artwork.setUrl(imageElement.getAttribute("url")); - artwork.setSize(imageElement.getAttribute("size")); - movie.addArtwork(artwork); - } + if (subElement.getNodeName().equalsIgnoreCase("image")) { + // This is the format used in Movie.imdbLookup, Movie.getInfo & Movie.search + Artwork artwork = new Artwork(); + artwork.setType(subElement.getAttribute("type")); + artwork.setSize(subElement.getAttribute("size")); + artwork.setUrl(subElement.getAttribute("url")); + artwork.setId(subElement.getAttribute("id")); + movie.addArtwork(artwork); + } else if (subElement.getNodeName().equalsIgnoreCase("backdrop") || + subElement.getNodeName().equalsIgnoreCase("poster")) { + // This is the format used in Movie.getImages + String artworkId = subElement.getAttribute("id"); + String artworkType = subElement.getNodeName(); + + // We need to decode and loop round the child nodes to get the data + NodeList imageNodeList = subElement.getChildNodes(); + for (int imageLoop = 0; imageLoop < imageNodeList.getLength(); imageLoop++) { + Node imageNode = imageNodeList.item(imageLoop); + if (imageNode.getNodeType() == Node.ELEMENT_NODE) { + Element imageElement = (Element) imageNode; + Artwork artwork = new Artwork(); + artwork.setId(artworkId); + artwork.setType(artworkType); + artwork.setUrl(imageElement.getAttribute("url")); + artwork.setSize(imageElement.getAttribute("size")); + movie.addArtwork(artwork); } - } else { - // This is a classic, it should never happen error - logger.severe("UNKNOWN Image type: " + subElement.getNodeName()); } + } else { + // This is a classic, it should never happen error + logger.severe("UNKNOWN Image type: " + subElement.getNodeName()); } } } From 5d7931a3d6112e2e15ab7eacbc6db088e5231beb Mon Sep 17 00:00:00 2001 From: Omertron Date: Sun, 10 Oct 2010 15:12:34 +0000 Subject: [PATCH 029/207] Removed debug lines --- .../src/com/moviejukebox/themoviedb/TheMovieDb.java | 6 ------ 1 file changed, 6 deletions(-) diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java b/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java index 5dc4d172b..91dab0c78 100644 --- a/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java @@ -415,14 +415,9 @@ public class TheMovieDb { return null; } - System.out.println("Looking for: " + title + " - Year: " + year); - for (MovieDB moviedb : movieList) { if (compareMovies(moviedb, title, year)) { - System.out.println("Matched: " + moviedb.getTitle()); return moviedb; - } else { - System.out.println("Not Matched: " + moviedb.getTitle() + " - " + moviedb.getReleaseDate()); } } @@ -445,7 +440,6 @@ public class TheMovieDb { if (isValidString(moviedb.getReleaseDate())) { // Compare with year String movieYear = moviedb.getReleaseDate().substring(0, 4); - logger.fine("Comparing against: " + moviedb.getTitle() + " - " + moviedb.getReleaseDate() + " - " + movieYear); if (moviedb.getTitle().equalsIgnoreCase(title) && movieYear.equals(year)) { return true; } From 367fb6b3f0ef5ea417fff59d41c91cbb900a6d97 Mon Sep 17 00:00:00 2001 From: Omertron Date: Mon, 11 Oct 2010 15:25:48 +0000 Subject: [PATCH 030/207] Added timeout settings to the URLConnection --- .../moviejukebox/themoviedb/TheMovieDb.java | 13 +++++++++++++ .../themoviedb/tools/WebBrowser.java | 19 +++++++++++++++++++ 2 files changed, 32 insertions(+) diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java b/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java index 91dab0c78..f2dccc0f6 100644 --- a/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java @@ -31,6 +31,7 @@ import com.moviejukebox.themoviedb.model.Person; import com.moviejukebox.themoviedb.tools.DOMHelper; import com.moviejukebox.themoviedb.tools.DOMParser; import com.moviejukebox.themoviedb.tools.LogFormatter; +import com.moviejukebox.themoviedb.tools.WebBrowser; /** * This is the main class for the API to connect to TheMovieDb.org The implementation is for v2.1 @@ -58,6 +59,18 @@ public class TheMovieDb { setApiKey(apiKey); } + public void setProxy(String host, String port, String username, String password) { + WebBrowser.setProxyHost(host); + WebBrowser.setProxyPort(port); + WebBrowser.setProxyUsername(username); + WebBrowser.setProxyPassword(password); + } + + public void setTimeout(int webTimeoutConnect, int webTimeoutRead) { + WebBrowser.setWebTimeoutConnect(webTimeoutConnect); + WebBrowser.setWebTimeoutRead(webTimeoutRead); + } + public static Logger getLogger() { return logger; } diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/tools/WebBrowser.java b/themoviedbapi/src/com/moviejukebox/themoviedb/tools/WebBrowser.java index 6f55caf73..c122fcba4 100644 --- a/themoviedbapi/src/com/moviejukebox/themoviedb/tools/WebBrowser.java +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/tools/WebBrowser.java @@ -32,6 +32,7 @@ import java.util.regex.Pattern; * Web browser with simple cookies support */ public final class WebBrowser { + private static Map browserProperties = new HashMap(); private static Map> cookies; private static String proxyHost = null; @@ -39,6 +40,8 @@ public final class WebBrowser { private static String proxyUsername = null; private static String proxyPassword = null; private static String proxyEncodedPassword = null; + private static int webTimeoutConnect = 10000; // 10 second timeout + private static int webTimeoutRead = 90000; // 90 second timeout static { browserProperties.put("User-Agent", "Mozilla/5.25 Netscape/5.0 (Windows; I; Win95)"); @@ -234,4 +237,20 @@ public final class WebBrowser { proxyEncodedPassword = Base64.base64Encode(proxyEncodedPassword); } } + + public static int getWebTimeoutConnect() { + return webTimeoutConnect; + } + + public static int getWebTimeoutRead() { + return webTimeoutRead; + } + + public static void setWebTimeoutConnect(int webTimeoutConnect) { + WebBrowser.webTimeoutConnect = webTimeoutConnect; + } + + public static void setWebTimeoutRead(int webTimeoutRead) { + WebBrowser.webTimeoutRead = webTimeoutRead; + } } From 868a4ac7a9bf623a70a5be48c47fd9b772b6b06f Mon Sep 17 00:00:00 2001 From: Omertron Date: Tue, 12 Oct 2010 11:55:15 +0000 Subject: [PATCH 031/207] Better error trapping with Movie.getInfo and DOMHelper --- .../moviejukebox/themoviedb/TheMovieDb.java | 55 +++++++------------ .../themoviedb/tools/DOMHelper.java | 37 +++++++++++-- 2 files changed, 50 insertions(+), 42 deletions(-) diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java b/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java index f2dccc0f6..8d7405ea9 100644 --- a/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java @@ -127,7 +127,7 @@ public class TheMovieDb { Document doc = null; try { - String searchUrl = buildSearchUrl("Movie.search", URLEncoder.encode(movieTitle, "UTF-8"), validateLanguage(language)); + String searchUrl = buildSearchUrl("Movie.search", URLEncoder.encode(movieTitle, "UTF-8"), language); doc = DOMHelper.getEventDocFromUrl(searchUrl); NodeList nlMovies = doc.getElementsByTagName("movie"); if (nlMovies == null) { @@ -168,7 +168,7 @@ public class TheMovieDb { Document doc = null; try { - String searchUrl = buildSearchUrl("Movie.imdbLookup", imdbID, validateLanguage(language)); + String searchUrl = buildSearchUrl("Movie.imdbLookup", imdbID, language); doc = DOMHelper.getEventDocFromUrl(searchUrl); NodeList nlMovies = doc.getElementsByTagName("movie"); @@ -214,16 +214,26 @@ public class TheMovieDb { * @return A movie bean with all of the information */ public MovieDB moviedbGetInfo(String tmdbID, MovieDB movie, String language) { - // If the tmdbID is null, then exit + // If the tmdbID is invalid, then exit if (!isValidString(tmdbID)) return movie; Document doc = null; try { - String searchUrl = buildSearchUrl("Movie.getInfo", tmdbID, validateLanguage(language)); + String searchUrl = buildSearchUrl("Movie.getInfo", tmdbID, language); doc = DOMHelper.getEventDocFromUrl(searchUrl); + if (doc == null && !language.equalsIgnoreCase(defaultLanguage)) { + logger.fine("Trying to get the default version"); + Thread.dumpStack(); + searchUrl = buildSearchUrl("Movie.getInfo", tmdbID, defaultLanguage); + } + + if (doc == null) { + return movie; + } + NodeList nlMovies = doc.getElementsByTagName("movie"); if (nlMovies == null) { return movie; @@ -237,7 +247,7 @@ public class TheMovieDb { } } } catch (Exception error) { - logger.severe("TheMovieDb Error: " + error.getMessage()); + logger.severe("Error: " + error.getMessage()); } return movie; } @@ -263,7 +273,7 @@ public class TheMovieDb { Document doc = null; try { - String searchUrl = buildSearchUrl("Movie.getImages", searchTerm, validateLanguage(language)); + String searchUrl = buildSearchUrl("Movie.getImages", searchTerm, language); doc = DOMHelper.getEventDocFromUrl(searchUrl); NodeList nlMovies = doc.getElementsByTagName("movie"); @@ -303,7 +313,7 @@ public class TheMovieDb { Document doc = null; try { - String searchUrl = buildSearchUrl("Person.search", personName, validateLanguage(language)); + String searchUrl = buildSearchUrl("Person.search", personName, language); doc = DOMHelper.getEventDocFromUrl(searchUrl); person = DOMParser.parsePersonInfo(doc); } catch (Exception error) { @@ -330,7 +340,7 @@ public class TheMovieDb { Document doc = null; try { - String searchUrl = buildSearchUrl("Person.getInfo", personID, validateLanguage(language)); + String searchUrl = buildSearchUrl("Person.getInfo", personID, language); doc = DOMHelper.getEventDocFromUrl(searchUrl); person = DOMParser.parsePersonInfo(doc); } catch (Exception error) { @@ -358,7 +368,7 @@ public class TheMovieDb { Document doc = null; try { - String searchUrl = buildSearchUrl("Person.getVersion", personID, validateLanguage(language)); + String searchUrl = buildSearchUrl("Person.getVersion", personID, language); doc = DOMHelper.getEventDocFromUrl(searchUrl); person = DOMParser.parsePersonGetVersion(doc); } catch (Exception error) { @@ -368,33 +378,6 @@ public class TheMovieDb { return person; } - /** - * This function will check the passed language against a list of known themoviedb.org languages - * Currently the only available language is English "en" and so that is what this function returns - * @param language - * @return - */ - private String validateLanguage(String language) { - if (!isValidString(language)) { - return defaultLanguage; - } else { - /* - * Rather than check every conceivable language, we'll just validate the format of the language - * The language should either be 2 or 5 characters "xx" or "xx-YY" - * http://api.themoviedb.org/2.1/language-tags - */ - if (language.length() == 2) { - return language.toLowerCase(); - } else if (language.length() == 5) { - return language.substring(1, 2).toLowerCase() + "-" + language.substring(4, 5).toUpperCase(); - } else { - // The format of the language is wrong, so just cut the first two characters and use that - // The site will take care of invalid languages - return language.substring(1, 2).toLowerCase(); - } - } - } - /** * Check the string passed to see if it contains a value. * @param testString The string to test diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/tools/DOMHelper.java b/themoviedbapi/src/com/moviejukebox/themoviedb/tools/DOMHelper.java index c87de81c4..19dd76137 100644 --- a/themoviedbapi/src/com/moviejukebox/themoviedb/tools/DOMHelper.java +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/tools/DOMHelper.java @@ -15,6 +15,7 @@ package com.moviejukebox.themoviedb.tools; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; +import java.util.logging.Logger; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; @@ -26,12 +27,15 @@ import org.w3c.dom.Node; import org.w3c.dom.NodeList; import org.xml.sax.SAXException; +import com.moviejukebox.themoviedb.TheMovieDb; + /** * Generic set of routines to process the DOM model data * @author Stuart * */ public class DOMHelper { + static Logger logger = TheMovieDb.getLogger(); /** * Gets the string value of the tag element name passed @@ -66,14 +70,35 @@ public class DOMHelper { throws IOException, ParserConfigurationException, SAXException { Document doc = null; InputStream in = null; + String webPage = null; + try { - String webPage = WebBrowser.request(url); - in = new ByteArrayInputStream(webPage.getBytes("UTF-8")); + boolean validWebPage = false; - DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance(); - DocumentBuilder db = dbf.newDocumentBuilder(); - doc = db.parse(in); - doc.getDocumentElement().normalize(); + + webPage = WebBrowser.request(url); + + // There seems to be an error with some of the web pages that returns garbage + if (webPage.startsWith(" Date: Tue, 12 Oct 2010 12:51:06 +0000 Subject: [PATCH 032/207] made field UNKNOWN final in MovieDB --- .../src/com/moviejukebox/themoviedb/model/MovieDB.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/model/MovieDB.java b/themoviedbapi/src/com/moviejukebox/themoviedb/model/MovieDB.java index 3836237ab..d5cf9a694 100644 --- a/themoviedbapi/src/com/moviejukebox/themoviedb/model/MovieDB.java +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/model/MovieDB.java @@ -25,7 +25,7 @@ import com.moviejukebox.themoviedb.tools.ModelTools; */ public class MovieDB extends ModelTools { - public static String UNKNOWN = "UNKNOWN"; + public static final String UNKNOWN = "UNKNOWN"; private String popularity = UNKNOWN; private String translated = UNKNOWN; From a4009be32f8e61ab4fadf422db47a2bd76ee7eb3 Mon Sep 17 00:00:00 2001 From: Mohammed Le Doze Date: Tue, 12 Oct 2010 13:08:31 +0000 Subject: [PATCH 033/207] added moviedbBrowse in TheMovieDb modified buildSearchUrl to handle Movie.browse specific url added constants in TheMovieDb made isValidString method private made apiSite and defaultLanguage private --- .../moviejukebox/themoviedb/TheMovieDb.java | 190 ++++++++++++++---- 1 file changed, 147 insertions(+), 43 deletions(-) diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java b/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java index 8d7405ea9..5e3d9ce14 100644 --- a/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java @@ -10,13 +10,14 @@ * For any reuse or distribution, you must make clear to others the * license terms of this work. */ - package com.moviejukebox.themoviedb; import java.net.URLEncoder; import java.util.ArrayList; import java.util.Collection; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.logging.ConsoleHandler; import java.util.logging.Level; import java.util.logging.Logger; @@ -43,17 +44,25 @@ import com.moviejukebox.themoviedb.tools.WebBrowser; public class TheMovieDb { private String apiKey; - private static String apiSite = "http://api.themoviedb.org/2.1/"; - private static String defaultLanguage = "en-US"; private static Logger logger; private static LogFormatter tmdbFormatter = new LogFormatter(); private static ConsoleHandler tmdbConsoleHandler = new ConsoleHandler(); + private static final String apiSite = "http://api.themoviedb.org/2.1/"; + private static final String defaultLanguage = "en-US"; + private static final String MOVIE_SEARCH = "Movie.search"; + private static final String MOVIE_BROWSE = "Movie.browse"; + private static final String MOVIE_IMDB_LOOKUP = "Movie.imdbLookup"; + private static final String MOVIE_GET_INFO = "Movie.getInfo"; + private static final String MOVIE_GET_IMAGES = "Movie.getImages"; + private static final String PERSON_GET_VERSION = "Person.getVersion"; + private static final String PERSON_GET_INFO = "Person.getInfo"; + private static final String PERSON_SEARCH = "Person.search"; public TheMovieDb(String apiKey) { setLogger(Logger.getLogger("TheMovieDB")); setApiKey(apiKey); } - + public TheMovieDb(String apiKey, Logger logger) { setLogger(logger); setApiKey(apiKey); @@ -65,7 +74,7 @@ public class TheMovieDb { WebBrowser.setProxyUsername(username); WebBrowser.setProxyPassword(password); } - + public void setTimeout(int webTimeoutConnect, int webTimeoutRead) { WebBrowser.setWebTimeoutConnect(webTimeoutConnect); WebBrowser.setWebTimeoutRead(webTimeoutRead); @@ -103,7 +112,13 @@ public class TheMovieDb { * @return The search URL */ private String buildSearchUrl(String prefix, String searchTerm, String language) { - String searchUrl = apiSite + prefix + "/" + language + "/xml/" + apiKey + "/" + searchTerm; + String searchUrl = apiSite + prefix + "/" + language + "/xml/" + apiKey; + if (prefix.equals(MOVIE_BROWSE)) { + searchUrl += "?"; + } else { + searchUrl += "/"; + } + searchUrl += searchTerm; logger.finest("Search URL: " + searchUrl); return searchUrl; } @@ -118,7 +133,7 @@ public class TheMovieDb { public List moviedbSearch(String movieTitle, String language) { MovieDB movie = null; List movieList = new ArrayList(); - + // If the title is null, then exit if (!isValidString(movieTitle)) { return movieList; @@ -127,13 +142,96 @@ public class TheMovieDb { Document doc = null; try { - String searchUrl = buildSearchUrl("Movie.search", URLEncoder.encode(movieTitle, "UTF-8"), language); + String searchUrl = buildSearchUrl(MOVIE_SEARCH, URLEncoder.encode(movieTitle, "UTF-8"), language); doc = DOMHelper.getEventDocFromUrl(searchUrl); NodeList nlMovies = doc.getElementsByTagName("movie"); if (nlMovies == null) { return movieList; } - + + for (int loop = 0; loop < nlMovies.getLength(); loop++) { + Node nMovie = nlMovies.item(loop); + if (nMovie.getNodeType() == Node.ELEMENT_NODE) { + Element eMovie = (Element) nMovie; + movie = DOMParser.parseMovieInfo(eMovie); + if (movie != null) { + movieList.add(movie); + } + } + } + } catch (Exception error) { + logger.severe("TheMovieDb Error: " + error.getMessage()); + } + return movieList; + } + + /** + * Browse the database using the default parameters. + * http://api.themoviedb.org/2.1/methods/Movie.browse + * + * @param orderBy either rating, + * release or title + * @param order how results are ordered. Either asc or + * desc + * @param language the two digit language code. E.g. en=English + * @return a list of MovieDB objects + */ + public List moviedbBrowse(String orderBy, String order, String language) { + return this.moviedbBrowse(orderBy, order, new HashMap(), language); + } + + /** + * Browse the database using optional parameters. + * http://api.themoviedb.org/2.1/methods/Movie.browse + * + * @param orderBy either rating, + * release or title + * @param order how results are ordered. Either asc or + * desc + * @param parameters a Map of optional parameters. See the complete list + * in the url above. + * @param language the two digit language code. E.g. en=English + * @return a list of MovieDB objects + */ + public List moviedbBrowse(String orderBy, String order, + Map parameters, String language) { + + List validParameters = new ArrayList(); + validParameters.add("per_page"); + validParameters.add("page"); + validParameters.add("query"); + validParameters.add("min_votes"); + validParameters.add("rating_min"); + validParameters.add("rating_max"); + validParameters.add("genres"); + validParameters.add("genres_selector"); + validParameters.add("release_min"); + validParameters.add("release_max"); + validParameters.add("year"); + validParameters.add("certifications"); + validParameters.add("companies"); + validParameters.add("countries"); + + String url = "order_by=" + orderBy + "&order=" + order; + for (String key : validParameters) { + if (parameters.containsKey(key)) { + url += "&" + key + "=" + parameters.get(key); + } + } + logger.finest("Browse URL : " + url); + + MovieDB movie = null; + List movieList = new ArrayList(); + Document doc = null; + + try { + String searchUrl = buildSearchUrl(MOVIE_BROWSE, url, language); + doc = DOMHelper.getEventDocFromUrl(searchUrl); + NodeList nlMovies = doc.getElementsByTagName("movie"); + if (nlMovies == null) { + return movieList; + } + for (int loop = 0; loop < nlMovies.getLength(); loop++) { Node nMovie = nlMovies.item(loop); if (nMovie.getNodeType() == Node.ELEMENT_NODE) { @@ -164,11 +262,11 @@ public class TheMovieDb { if (!isValidString(imdbID)) { return movie; } - + Document doc = null; try { - String searchUrl = buildSearchUrl("Movie.imdbLookup", imdbID, language); + String searchUrl = buildSearchUrl(MOVIE_IMDB_LOOKUP, imdbID, language); doc = DOMHelper.getEventDocFromUrl(searchUrl); NodeList nlMovies = doc.getElementsByTagName("movie"); @@ -215,25 +313,26 @@ public class TheMovieDb { */ public MovieDB moviedbGetInfo(String tmdbID, MovieDB movie, String language) { // If the tmdbID is invalid, then exit - if (!isValidString(tmdbID)) + if (!isValidString(tmdbID)) { return movie; - + } + Document doc = null; - + try { - String searchUrl = buildSearchUrl("Movie.getInfo", tmdbID, language); - + String searchUrl = buildSearchUrl(MOVIE_GET_INFO, tmdbID, language); + doc = DOMHelper.getEventDocFromUrl(searchUrl); if (doc == null && !language.equalsIgnoreCase(defaultLanguage)) { logger.fine("Trying to get the default version"); Thread.dumpStack(); - searchUrl = buildSearchUrl("Movie.getInfo", tmdbID, defaultLanguage); + searchUrl = buildSearchUrl(MOVIE_GET_INFO, tmdbID, defaultLanguage); } - + if (doc == null) { return movie; } - + NodeList nlMovies = doc.getElementsByTagName("movie"); if (nlMovies == null) { return movie; @@ -257,7 +356,7 @@ public class TheMovieDb { movie = moviedbGetInfo(searchTerm, movie, language); return movie; } - + /** * Get all the image information from TheMovieDb. * @param searchTerm Can be either the IMDb ID or TMDb ID @@ -267,14 +366,15 @@ public class TheMovieDb { */ public MovieDB moviedbGetImages(String searchTerm, MovieDB movie, String language) { // If the searchTerm is null, then exit - if (isValidString(searchTerm)) + if (isValidString(searchTerm)) { return movie; - + } + Document doc = null; - + try { - String searchUrl = buildSearchUrl("Movie.getImages", searchTerm, language); - + String searchUrl = buildSearchUrl(MOVIE_GET_IMAGES, searchTerm, language); + doc = DOMHelper.getEventDocFromUrl(searchUrl); NodeList nlMovies = doc.getElementsByTagName("movie"); if (nlMovies == null) { @@ -311,18 +411,18 @@ public class TheMovieDb { } Document doc = null; - + try { - String searchUrl = buildSearchUrl("Person.search", personName, language); + String searchUrl = buildSearchUrl(PERSON_SEARCH, personName, language); doc = DOMHelper.getEventDocFromUrl(searchUrl); person = DOMParser.parsePersonInfo(doc); } catch (Exception error) { logger.severe("ERROR: " + error.getMessage()); } - + return person; } - + /** * The Person.getInfo method is used to retrieve the full filmography, known movies, * images and things like birthplace for a specific person in the TMDb database. @@ -336,20 +436,20 @@ public class TheMovieDb { if (!isValidString(personID)) { return person; } - + Document doc = null; try { - String searchUrl = buildSearchUrl("Person.getInfo", personID, language); + String searchUrl = buildSearchUrl(PERSON_GET_INFO, personID, language); doc = DOMHelper.getEventDocFromUrl(searchUrl); person = DOMParser.parsePersonInfo(doc); } catch (Exception error) { logger.severe("ERROR: " + error.getMessage()); } - + return person; } - + /** * The Person.getVersion method is used to retrieve the last modified time along with * the current version number of the called object(s). This is useful if you've already @@ -368,34 +468,34 @@ public class TheMovieDb { Document doc = null; try { - String searchUrl = buildSearchUrl("Person.getVersion", personID, language); + String searchUrl = buildSearchUrl(PERSON_GET_VERSION, personID, language); doc = DOMHelper.getEventDocFromUrl(searchUrl); person = DOMParser.parsePersonGetVersion(doc); } catch (Exception error) { logger.severe("ERROR: " + error.getMessage()); } - + return person; } - + /** * Check the string passed to see if it contains a value. * @param testString The string to test * @return False if the string is empty, null or UNKNOWN, True otherwise */ - public static boolean isValidString(String testString) { + private static boolean isValidString(String testString) { if (testString == null) { return false; } - + if (testString.equalsIgnoreCase(MovieDB.UNKNOWN)) { return false; } - + if (testString.trim().equals("")) { return false; } - + return true; } @@ -410,16 +510,16 @@ public class TheMovieDb { if (movieList == null || movieList.isEmpty()) { return null; } - + for (MovieDB moviedb : movieList) { if (compareMovies(moviedb, title, year)) { return moviedb; } } - + return null; } - + /** * Compare the MovieDB object with a title & year * @param moviedb The moviedb object to compare too @@ -428,6 +528,10 @@ public class TheMovieDb { * @return True if there is a match, False otherwise. */ public static boolean compareMovies(MovieDB moviedb, String title, String year) { + if (moviedb == null) { + return false; + } + if (!isValidString(title)) { return false; } From 25092f3747fd78a1975b92161a541ecfd3c79ced Mon Sep 17 00:00:00 2001 From: Omertron Date: Tue, 12 Oct 2010 13:28:43 +0000 Subject: [PATCH 034/207] Logging changes --- .../moviejukebox/themoviedb/TheMovieDb.java | 28 ++++++++++--------- .../themoviedb/tools/DOMHelper.java | 4 +-- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java b/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java index 5e3d9ce14..ab8417b04 100644 --- a/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java @@ -44,7 +44,7 @@ import com.moviejukebox.themoviedb.tools.WebBrowser; public class TheMovieDb { private String apiKey; - private static Logger logger; + private static Logger logger = null; private static LogFormatter tmdbFormatter = new LogFormatter(); private static ConsoleHandler tmdbConsoleHandler = new ConsoleHandler(); private static final String apiSite = "http://api.themoviedb.org/2.1/"; @@ -64,7 +64,9 @@ public class TheMovieDb { } public TheMovieDb(String apiKey, Logger logger) { - setLogger(logger); + if (logger == null) { + setLogger(logger); + } setApiKey(apiKey); } @@ -84,12 +86,12 @@ public class TheMovieDb { return logger; } - public static void setLogger(Logger logger) { + public void setLogger(Logger logger) { TheMovieDb.logger = logger; tmdbConsoleHandler.setFormatter(tmdbFormatter); tmdbConsoleHandler.setLevel(Level.FINE); logger.addHandler(tmdbConsoleHandler); - logger.setUseParentHandlers(true); + logger.setUseParentHandlers(false); logger.setLevel(Level.ALL); } @@ -243,7 +245,7 @@ public class TheMovieDb { } } } catch (Exception error) { - logger.severe("TheMovieDb Error: " + error.getMessage()); + logger.severe("Search error: " + error.getMessage()); } return movieList; } @@ -282,7 +284,7 @@ public class TheMovieDb { } } } catch (Exception error) { - logger.severe("TheMovieDb Error: " + error.getMessage()); + logger.severe("ImdbLookup error: " + error.getMessage()); } return movie; } @@ -324,8 +326,7 @@ public class TheMovieDb { doc = DOMHelper.getEventDocFromUrl(searchUrl); if (doc == null && !language.equalsIgnoreCase(defaultLanguage)) { - logger.fine("Trying to get the default version"); - Thread.dumpStack(); + logger.fine("Trying to get the '" + defaultLanguage + "' version"); searchUrl = buildSearchUrl(MOVIE_GET_INFO, tmdbID, defaultLanguage); } @@ -346,7 +347,8 @@ public class TheMovieDb { } } } catch (Exception error) { - logger.severe("Error: " + error.getMessage()); + logger.severe("GetInfo error: " + error.getMessage()); + error.printStackTrace(); } return movie; } @@ -390,7 +392,7 @@ public class TheMovieDb { } } catch (Exception error) { - logger.severe("TheMovieDb Error: " + error.getMessage()); + logger.severe("GetImages Error: " + error.getMessage()); } return movie; @@ -417,7 +419,7 @@ public class TheMovieDb { doc = DOMHelper.getEventDocFromUrl(searchUrl); person = DOMParser.parsePersonInfo(doc); } catch (Exception error) { - logger.severe("ERROR: " + error.getMessage()); + logger.severe("PersonSearch error: " + error.getMessage()); } return person; @@ -444,7 +446,7 @@ public class TheMovieDb { doc = DOMHelper.getEventDocFromUrl(searchUrl); person = DOMParser.parsePersonInfo(doc); } catch (Exception error) { - logger.severe("ERROR: " + error.getMessage()); + logger.severe("PersonGetInfo error: " + error.getMessage()); } return person; @@ -472,7 +474,7 @@ public class TheMovieDb { doc = DOMHelper.getEventDocFromUrl(searchUrl); person = DOMParser.parsePersonGetVersion(doc); } catch (Exception error) { - logger.severe("ERROR: " + error.getMessage()); + logger.severe("PersonGetVersion error: " + error.getMessage()); } return person; diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/tools/DOMHelper.java b/themoviedbapi/src/com/moviejukebox/themoviedb/tools/DOMHelper.java index 19dd76137..d3d7615f1 100644 --- a/themoviedbapi/src/com/moviejukebox/themoviedb/tools/DOMHelper.java +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/tools/DOMHelper.java @@ -31,7 +31,7 @@ import com.moviejukebox.themoviedb.TheMovieDb; /** * Generic set of routines to process the DOM model data - * @author Stuart + * @author Stuart.Boston * */ public class DOMHelper { @@ -74,8 +74,6 @@ public class DOMHelper { try { boolean validWebPage = false; - - webPage = WebBrowser.request(url); // There seems to be an error with some of the web pages that returns garbage From 6fcdf585c7a347c39c1e2e75051a9d4cb8a0ea7e Mon Sep 17 00:00:00 2001 From: Mohammed Le Doze Date: Tue, 12 Oct 2010 13:45:09 +0000 Subject: [PATCH 035/207] made members in Studio, Person, Country, Category and Artwork private --- .../themoviedb/model/Artwork.java | 8 +++---- .../themoviedb/model/Category.java | 22 +++++++++---------- .../themoviedb/model/Country.java | 18 +++++++-------- .../moviejukebox/themoviedb/model/Person.java | 2 +- .../moviejukebox/themoviedb/model/Studio.java | 16 +++++++------- 5 files changed, 33 insertions(+), 33 deletions(-) diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/model/Artwork.java b/themoviedbapi/src/com/moviejukebox/themoviedb/model/Artwork.java index 95d32f2ed..b106d89de 100644 --- a/themoviedbapi/src/com/moviejukebox/themoviedb/model/Artwork.java +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/model/Artwork.java @@ -33,10 +33,10 @@ public class Artwork implements Comparable { public static String ARTWORK_SIZE_PROFILE = "profile"; public static String[] ARTWORK_SIZES = {ARTWORK_SIZE_ORIGINAL, ARTWORK_SIZE_THUMB, ARTWORK_SIZE_MID, ARTWORK_SIZE_COVER, ARTWORK_SIZE_POSTER, ARTWORK_SIZE_PROFILE}; - public String type; - public String size; - public String url; - public int id; + private String type; + private String size; + private String url; + private int id; public String[] getArtworkSizes() { return ARTWORK_SIZES; diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/model/Category.java b/themoviedbapi/src/com/moviejukebox/themoviedb/model/Category.java index a32615fc1..4f58a8990 100644 --- a/themoviedbapi/src/com/moviejukebox/themoviedb/model/Category.java +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/model/Category.java @@ -10,7 +10,6 @@ * For any reuse or distribution, you must make clear to others the * license terms of this work. */ - package com.moviejukebox.themoviedb.model; /** @@ -20,31 +19,32 @@ package com.moviejukebox.themoviedb.model; * */ public class Category { - public String type; - public String name; - public String url; - public String id; - + + private String type; + private String name; + private String url; + private String id; + public String getId() { return id; } - + public String getName() { return name; } - + public String getType() { return type; } - + public String getUrl() { return url; } - + public void setId(String id) { this.id = id; } - + public void setName(String name) { this.name = name; } diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/model/Country.java b/themoviedbapi/src/com/moviejukebox/themoviedb/model/Country.java index a37dd2cbe..55e64a9e4 100644 --- a/themoviedbapi/src/com/moviejukebox/themoviedb/model/Country.java +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/model/Country.java @@ -10,7 +10,6 @@ * For any reuse or distribution, you must make clear to others the * license terms of this work. */ - package com.moviejukebox.themoviedb.model; /** @@ -20,14 +19,15 @@ package com.moviejukebox.themoviedb.model; * */ public class Country { - public String url; - public String name; - public String code; - + + private String url; + private String name; + private String code; + public String getUrl() { return url; } - + public void setUrl(String url) { this.url = url; } @@ -35,15 +35,15 @@ public class Country { public String getName() { return name; } - + public void setName(String name) { this.name = name; } - + public String getCode() { return code; } - + public void setCode(String code) { this.code = code; } diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/model/Person.java b/themoviedbapi/src/com/moviejukebox/themoviedb/model/Person.java index 8a9e58c5d..de1f70457 100644 --- a/themoviedbapi/src/com/moviejukebox/themoviedb/model/Person.java +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/model/Person.java @@ -28,7 +28,7 @@ import com.moviejukebox.themoviedb.tools.ModelTools; * */ public class Person extends ModelTools { - private static String UNKNOWN = MovieDB.UNKNOWN; + private static final String UNKNOWN = MovieDB.UNKNOWN; private String name = UNKNOWN; private String character = UNKNOWN; diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/model/Studio.java b/themoviedbapi/src/com/moviejukebox/themoviedb/model/Studio.java index a1601a08c..322e6d1d8 100644 --- a/themoviedbapi/src/com/moviejukebox/themoviedb/model/Studio.java +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/model/Studio.java @@ -10,7 +10,6 @@ * For any reuse or distribution, you must make clear to others the * license terms of this work. */ - package com.moviejukebox.themoviedb.model; /** @@ -20,10 +19,11 @@ package com.moviejukebox.themoviedb.model; * */ public class Studio { - public String name; - public String url; - public String id; - + + private String name; + private String url; + private String id; + public String getId() { return id; } @@ -35,15 +35,15 @@ public class Studio { public String getName() { return name; } - + public void setName(String name) { this.name = name; } - + public String getUrl() { return url; } - + public void setUrl(String url) { this.url = url; } From 0fcb17107837cd5dde4781a7499875339c0394b4 Mon Sep 17 00:00:00 2001 From: Mohammed Le Doze Date: Tue, 12 Oct 2010 14:06:35 +0000 Subject: [PATCH 036/207] made contants in Artwork final --- .../themoviedb/model/Artwork.java | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/model/Artwork.java b/themoviedbapi/src/com/moviejukebox/themoviedb/model/Artwork.java index b106d89de..888a5ba29 100644 --- a/themoviedbapi/src/com/moviejukebox/themoviedb/model/Artwork.java +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/model/Artwork.java @@ -20,18 +20,18 @@ package com.moviejukebox.themoviedb.model; * */ public class Artwork implements Comparable { - public static String ARTWORK_TYPE_POSTER = "poster"; - public static String ARTWORK_TYPE_BACKDROP = "backdrop"; - public static String ARTWORK_TYPE_PERSON = "profile"; - public static String[] ARTWORK_TYPES = {ARTWORK_TYPE_POSTER, ARTWORK_TYPE_BACKDROP, ARTWORK_TYPE_PERSON}; + public static final String ARTWORK_TYPE_POSTER = "poster"; + public static final String ARTWORK_TYPE_BACKDROP = "backdrop"; + public static final String ARTWORK_TYPE_PERSON = "profile"; + public static final String[] ARTWORK_TYPES = {ARTWORK_TYPE_POSTER, ARTWORK_TYPE_BACKDROP, ARTWORK_TYPE_PERSON}; - public static String ARTWORK_SIZE_ORIGINAL = "original"; - public static String ARTWORK_SIZE_THUMB = "thumb"; - public static String ARTWORK_SIZE_MID = "mid"; - public static String ARTWORK_SIZE_COVER = "cover"; - public static String ARTWORK_SIZE_POSTER = "poster"; - public static String ARTWORK_SIZE_PROFILE = "profile"; - public static String[] ARTWORK_SIZES = {ARTWORK_SIZE_ORIGINAL, ARTWORK_SIZE_THUMB, ARTWORK_SIZE_MID, ARTWORK_SIZE_COVER, ARTWORK_SIZE_POSTER, ARTWORK_SIZE_PROFILE}; + public static final String ARTWORK_SIZE_ORIGINAL = "original"; + public static final String ARTWORK_SIZE_THUMB = "thumb"; + public static final String ARTWORK_SIZE_MID = "mid"; + public static final String ARTWORK_SIZE_COVER = "cover"; + public static final String ARTWORK_SIZE_POSTER = "poster"; + public static final String ARTWORK_SIZE_PROFILE = "profile"; + public static final String[] ARTWORK_SIZES = {ARTWORK_SIZE_ORIGINAL, ARTWORK_SIZE_THUMB, ARTWORK_SIZE_MID, ARTWORK_SIZE_COVER, ARTWORK_SIZE_POSTER, ARTWORK_SIZE_PROFILE}; private String type; private String size; From 6a90041f06b4e1fb0939dceca3245977af9b4386 Mon Sep 17 00:00:00 2001 From: Omertron Date: Tue, 12 Oct 2010 18:10:09 +0000 Subject: [PATCH 037/207] Updated timeout --- .../src/com/moviejukebox/themoviedb/tools/WebBrowser.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/tools/WebBrowser.java b/themoviedbapi/src/com/moviejukebox/themoviedb/tools/WebBrowser.java index c122fcba4..ccc0d632d 100644 --- a/themoviedbapi/src/com/moviejukebox/themoviedb/tools/WebBrowser.java +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/tools/WebBrowser.java @@ -40,7 +40,7 @@ public final class WebBrowser { private static String proxyUsername = null; private static String proxyPassword = null; private static String proxyEncodedPassword = null; - private static int webTimeoutConnect = 10000; // 10 second timeout + private static int webTimeoutConnect = 25000; // 25 second timeout private static int webTimeoutRead = 90000; // 90 second timeout static { From 1ce2426a0c4679da532252525d1c621f8c42e996 Mon Sep 17 00:00:00 2001 From: Mohammed Le Doze Date: Wed, 13 Oct 2010 08:14:38 +0000 Subject: [PATCH 038/207] rearranged methods in TheMovieDb --- .../moviejukebox/themoviedb/TheMovieDb.java | 92 +++++++++---------- 1 file changed, 42 insertions(+), 50 deletions(-) diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java b/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java index ab8417b04..882995bfb 100644 --- a/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java @@ -104,27 +104,6 @@ public class TheMovieDb { tmdbFormatter.addApiKey(apiKey); } - /** - * Build the search URL from the search prefix and movie title. - * This will change between v2.0 and v2.1 of the API - * - * @param prefix The search prefix before the movie title - * @param language The two digit language code. E.g. en=English - * @param searchTerm The search key to use, e.g. movie title or IMDb ID - * @return The search URL - */ - private String buildSearchUrl(String prefix, String searchTerm, String language) { - String searchUrl = apiSite + prefix + "/" + language + "/xml/" + apiKey; - if (prefix.equals(MOVIE_BROWSE)) { - searchUrl += "?"; - } else { - searchUrl += "/"; - } - searchUrl += searchTerm; - logger.finest("Search URL: " + searchUrl); - return searchUrl; - } - /** * Searches the database using the movie title passed * @@ -198,6 +177,11 @@ public class TheMovieDb { public List moviedbBrowse(String orderBy, String order, Map parameters, String language) { + List movieList = new ArrayList(); + if (!isValidString(orderBy) || (!isValidString(order))) { + return movieList; + } + List validParameters = new ArrayList(); validParameters.add("per_page"); validParameters.add("page"); @@ -220,10 +204,8 @@ public class TheMovieDb { url += "&" + key + "=" + parameters.get(key); } } - logger.finest("Browse URL : " + url); MovieDB movie = null; - List movieList = new ArrayList(); Document doc = null; try { @@ -245,7 +227,7 @@ public class TheMovieDb { } } } catch (Exception error) { - logger.severe("Search error: " + error.getMessage()); + logger.severe("Browse error: " + error.getMessage()); } return movieList; } @@ -480,27 +462,6 @@ public class TheMovieDb { return person; } - /** - * Check the string passed to see if it contains a value. - * @param testString The string to test - * @return False if the string is empty, null or UNKNOWN, True otherwise - */ - private static boolean isValidString(String testString) { - if (testString == null) { - return false; - } - - if (testString.equalsIgnoreCase(MovieDB.UNKNOWN)) { - return false; - } - - if (testString.trim().equals("")) { - return false; - } - - return true; - } - /** * Search a list of movies and return the one that matches the title & year * @param movieList The list of movies to search @@ -530,11 +491,7 @@ public class TheMovieDb { * @return True if there is a match, False otherwise. */ public static boolean compareMovies(MovieDB moviedb, String title, String year) { - if (moviedb == null) { - return false; - } - - if (!isValidString(title)) { + if ((moviedb == null) || (!isValidString(title))) { return false; } @@ -554,4 +511,39 @@ public class TheMovieDb { } return false; } + + /** + * Build the search URL from the search prefix and movie title. + * This will change between v2.0 and v2.1 of the API + * + * @param prefix The search prefix before the movie title + * @param language The two digit language code. E.g. en=English + * @param searchTerm The search key to use, e.g. movie title or IMDb ID + * @return The search URL + */ + private String buildSearchUrl(String prefix, String searchTerm, String language) { + String searchUrl = apiSite + prefix + "/" + language + "/xml/" + apiKey; + if (prefix.equals(MOVIE_BROWSE)) { + searchUrl += "?"; + } else { + searchUrl += "/"; + } + searchUrl += searchTerm; + logger.finest("Search URL: " + searchUrl); + return searchUrl; + } + + /** + * Check the string passed to see if it contains a value. + * @param testString The string to test + * @return False if the string is empty, null or UNKNOWN, True otherwise + */ + private static boolean isValidString(String testString) { + if ((testString == null) + || (testString.trim().equals("")) + || (testString.equalsIgnoreCase(MovieDB.UNKNOWN))) { + return false; + } + return true; + } } From c872d87edf3f802549fa5a062890c91682f7158f Mon Sep 17 00:00:00 2001 From: Mohammed Le Doze Date: Wed, 13 Oct 2010 09:00:11 +0000 Subject: [PATCH 039/207] updated DOMParser: it now takes a DOM document and returns MovieDB objects updated TheMovieDb accordingly --- .../moviejukebox/themoviedb/TheMovieDb.java | 91 +----- .../themoviedb/tools/DOMParser.java | 284 +++++++++++------- 2 files changed, 183 insertions(+), 192 deletions(-) diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java b/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java index 882995bfb..e2141cbe8 100644 --- a/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java @@ -12,6 +12,7 @@ */ package com.moviejukebox.themoviedb; +import com.moviejukebox.themoviedb.model.Category; import java.net.URLEncoder; import java.util.ArrayList; import java.util.Collection; @@ -112,12 +113,11 @@ public class TheMovieDb { * @return A movie bean with the data extracted */ public List moviedbSearch(String movieTitle, String language) { - MovieDB movie = null; - List movieList = new ArrayList(); + List movies = new ArrayList(); // If the title is null, then exit if (!isValidString(movieTitle)) { - return movieList; + return movies; } Document doc = null; @@ -125,25 +125,11 @@ public class TheMovieDb { try { String searchUrl = buildSearchUrl(MOVIE_SEARCH, URLEncoder.encode(movieTitle, "UTF-8"), language); doc = DOMHelper.getEventDocFromUrl(searchUrl); - NodeList nlMovies = doc.getElementsByTagName("movie"); - if (nlMovies == null) { - return movieList; - } - - for (int loop = 0; loop < nlMovies.getLength(); loop++) { - Node nMovie = nlMovies.item(loop); - if (nMovie.getNodeType() == Node.ELEMENT_NODE) { - Element eMovie = (Element) nMovie; - movie = DOMParser.parseMovieInfo(eMovie); - if (movie != null) { - movieList.add(movie); - } - } - } + movies = DOMParser.parseMovies(doc); } catch (Exception error) { logger.severe("TheMovieDb Error: " + error.getMessage()); } - return movieList; + return movies; } /** @@ -177,9 +163,9 @@ public class TheMovieDb { public List moviedbBrowse(String orderBy, String order, Map parameters, String language) { - List movieList = new ArrayList(); + List movies = new ArrayList(); if (!isValidString(orderBy) || (!isValidString(order))) { - return movieList; + return movies; } List validParameters = new ArrayList(); @@ -205,31 +191,16 @@ public class TheMovieDb { } } - MovieDB movie = null; Document doc = null; + String searchUrl = buildSearchUrl(MOVIE_BROWSE, url, language); try { - String searchUrl = buildSearchUrl(MOVIE_BROWSE, url, language); doc = DOMHelper.getEventDocFromUrl(searchUrl); - NodeList nlMovies = doc.getElementsByTagName("movie"); - if (nlMovies == null) { - return movieList; - } - - for (int loop = 0; loop < nlMovies.getLength(); loop++) { - Node nMovie = nlMovies.item(loop); - if (nMovie.getNodeType() == Node.ELEMENT_NODE) { - Element eMovie = (Element) nMovie; - movie = DOMParser.parseMovieInfo(eMovie); - if (movie != null) { - movieList.add(movie); - } - } - } } catch (Exception error) { logger.severe("Browse error: " + error.getMessage()); } - return movieList; + movies = DOMParser.parseMovies(doc); + return movies; } /** @@ -253,18 +224,7 @@ public class TheMovieDb { String searchUrl = buildSearchUrl(MOVIE_IMDB_LOOKUP, imdbID, language); doc = DOMHelper.getEventDocFromUrl(searchUrl); - NodeList nlMovies = doc.getElementsByTagName("movie"); - if (nlMovies == null) { - return movie; - } - - for (int loop = 0; loop < nlMovies.getLength(); loop++) { - Node nMovie = nlMovies.item(loop); - if (nMovie.getNodeType() == Node.ELEMENT_NODE) { - Element eMovie = (Element) nMovie; - movie = DOMParser.parseMovieInfo(eMovie); - } - } + movie = DOMParser.parseMovie(doc); } catch (Exception error) { logger.severe("ImdbLookup error: " + error.getMessage()); } @@ -316,18 +276,7 @@ public class TheMovieDb { return movie; } - NodeList nlMovies = doc.getElementsByTagName("movie"); - if (nlMovies == null) { - return movie; - } - - for (int loop = 0; loop < nlMovies.getLength(); loop++) { - Node nMovie = nlMovies.item(loop); - if (nMovie.getNodeType() == Node.ELEMENT_NODE) { - Element eMovie = (Element) nMovie; - movie = DOMParser.parseMovieInfo(eMovie); - } - } + movie = DOMParser.parseMovie(doc); } catch (Exception error) { logger.severe("GetInfo error: " + error.getMessage()); error.printStackTrace(); @@ -337,7 +286,7 @@ public class TheMovieDb { public MovieDB moviedbGetImages(String searchTerm, String language) { MovieDB movie = null; - movie = moviedbGetInfo(searchTerm, movie, language); + movie = moviedbGetImages(searchTerm, movie, language); return movie; } @@ -360,18 +309,7 @@ public class TheMovieDb { String searchUrl = buildSearchUrl(MOVIE_GET_IMAGES, searchTerm, language); doc = DOMHelper.getEventDocFromUrl(searchUrl); - NodeList nlMovies = doc.getElementsByTagName("movie"); - if (nlMovies == null) { - return movie; - } - - for (int loop = 0; loop < nlMovies.getLength(); loop++) { - Node nMovie = nlMovies.item(loop); - if (nMovie.getNodeType() == Node.ELEMENT_NODE) { - Element eMovie = (Element) nMovie; - movie = DOMParser.parseMovieInfo(eMovie); - } - } + movie = DOMParser.parseMovie(doc); } catch (Exception error) { logger.severe("GetImages Error: " + error.getMessage()); @@ -462,6 +400,7 @@ public class TheMovieDb { return person; } + /** * Search a list of movies and return the one that matches the title & year * @param movieList The list of movies to search diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/tools/DOMParser.java b/themoviedbapi/src/com/moviejukebox/themoviedb/tools/DOMParser.java index 6e9431a80..e1555c877 100644 --- a/themoviedbapi/src/com/moviejukebox/themoviedb/tools/DOMParser.java +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/tools/DOMParser.java @@ -10,9 +10,10 @@ * For any reuse or distribution, you must make clear to others the * license terms of this work. */ - package com.moviejukebox.themoviedb.tools; +import java.util.ArrayList; +import java.util.List; import java.util.logging.Logger; import org.w3c.dom.Document; @@ -30,15 +31,139 @@ import com.moviejukebox.themoviedb.model.Person; import com.moviejukebox.themoviedb.model.Studio; public class DOMParser { + static Logger logger = TheMovieDb.getLogger(); - - public static MovieDB parseMovieInfo(Element movieElement) { - // Inspired by http://www.java-tips.org/java-se-tips/javax.xml.parsers/how-to-read-xml-file-in-java.html + + /** + * Returns a list of MovieDB object parsed from the DOM Document + * even if there is only one movie + * @param doc DOM Document + * @return + */ + public static List parseMovies(Document doc) { + List movies = new ArrayList(); + NodeList nlMovies = doc.getElementsByTagName("movie"); + if ((nlMovies == null) || nlMovies.getLength() == 0) { + return movies; + } + + MovieDB movie = null; + + for (int i = 0; i < nlMovies.getLength(); i++) { + Node movieNode = nlMovies.item(i); + if (movieNode.getNodeType() == Node.ELEMENT_NODE) { + Element movieElement = (Element) movieNode; + movie = DOMParser.parseMovieInfo(movieElement); + if (movie != null) { + movies.add(movie); + } + } + } + return movies; + } + + /** + * Returns the first MovieDB from the DOM Document. + * @param doc a DOM Document + * @return + */ + public static MovieDB parseMovie(Document doc) { + MovieDB movie = new MovieDB(); + NodeList nlMovies = doc.getElementsByTagName("movie"); + if ((nlMovies == null) || nlMovies.getLength() == 0) { + return movie; + } + + Node nMovie = nlMovies.item(0); + if (nMovie.getNodeType() == Node.ELEMENT_NODE) { + Element eMovie = (Element) nMovie; + movie = DOMParser.parseMovieInfo(eMovie); + } + + return movie; + } + + public static Person parsePersonInfo(Document doc) { + Person person = null; + + try { + person = new Person(); + NodeList personNodeList = doc.getElementsByTagName("person"); + + // Only get the first movie from the list + Node personNode = personNodeList.item(0); + + if (personNode == null) { + logger.finest("Person not found"); + return person; + } + + if (personNode.getNodeType() == Node.ELEMENT_NODE) { + Element personElement = (Element) personNode; + + person.setName(DOMHelper.getValueFromElement(personElement, "name")); + person.setId(DOMHelper.getValueFromElement(personElement, "id")); + person.setBiography(DOMHelper.getValueFromElement(personElement, "biography")); + person.setKnownMovies(Integer.parseInt(DOMHelper.getValueFromElement(personElement, "known_movies"))); + person.setBirthday(DOMHelper.getValueFromElement(personElement, "birthday")); + person.setBirthPlace(DOMHelper.getValueFromElement(personElement, "birthplace")); + person.setUrl(DOMHelper.getValueFromElement(personElement, "url")); + person.setVersion(Integer.parseInt(DOMHelper.getValueFromElement(personElement, "version"))); + person.setLastModifiedAt(DOMHelper.getValueFromElement(personElement, "last_modified_at")); + + NodeList artworkNodeList = doc.getElementsByTagName("image"); + for (int nodeLoop = 0; nodeLoop < artworkNodeList.getLength(); nodeLoop++) { + Node artworkNode = artworkNodeList.item(nodeLoop); + if (artworkNode.getNodeType() == Node.ELEMENT_NODE) { + Element artworkElement = (Element) artworkNode; + Artwork artwork = new Artwork(); + artwork.setType(artworkElement.getAttribute("type")); + artwork.setUrl(artworkElement.getAttribute("url")); + artwork.setSize(artworkElement.getAttribute("size")); + artwork.setId(artworkElement.getAttribute("id")); + person.addArtwork(artwork); + } + } + + NodeList filmNodeList = doc.getElementsByTagName("movie"); + for (int nodeLoop = 0; nodeLoop < filmNodeList.getLength(); nodeLoop++) { + Node filmNode = filmNodeList.item(nodeLoop); + if (filmNode.getNodeType() == Node.ELEMENT_NODE) { + Element filmElement = (Element) filmNode; + Filmography film = new Filmography(); + + film.setCharacter(filmElement.getAttribute("character")); + film.setDepartment(filmElement.getAttribute("department")); + film.setId(filmElement.getAttribute("id")); + film.setJob(filmElement.getAttribute("job")); + film.setName(filmElement.getAttribute("name")); + film.setUrl(filmElement.getAttribute("url")); + + person.addFilm(film); + } + } + } + } catch (Exception error) { + logger.severe("ERROR: " + error.getMessage()); + error.printStackTrace(); + } + + return person; + } + + public static Person parsePersonGetVersion(Document doc) { + // TODO Auto-generated method stub + return null; + } + + private static MovieDB parseMovieInfo(Element movieElement) { + // Inspired by + // http://www.java-tips.org/java-se-tips/javax.xml.parsers/how-to-read-xml-file-in-java.html MovieDB movie = new MovieDB(); NodeList subNodeList; Node subNode; Element subElement; - + try { movie.setPopularity(DOMHelper.getValueFromElement(movieElement, "popularity")); movie.setTranslated(DOMHelper.getValueFromElement(movieElement, "translated")); @@ -50,7 +175,7 @@ public class DOMParser { movie.setType(DOMHelper.getValueFromElement(movieElement, "type")); movie.setId(DOMHelper.getValueFromElement(movieElement, "id")); movie.setImdb(DOMHelper.getValueFromElement(movieElement, "imdb_id")); - movie.setUrl(DOMHelper.getValueFromElement(movieElement, "url")); + movie.setUrl(DOMHelper.getValueFromElement(movieElement, "url")); movie.setOverview(DOMHelper.getValueFromElement(movieElement, "overview")); movie.setRating(DOMHelper.getValueFromElement(movieElement, "rating")); movie.setTagline(DOMHelper.getValueFromElement(movieElement, "tagline")); @@ -81,13 +206,13 @@ public class DOMParser { category.setUrl(subElement.getAttribute("url")); category.setName(subElement.getAttribute("name")); category.setId(subElement.getAttribute("id")); - + movie.addCategory(category); } } } } - + // Process the "studios" subNodeList = movieElement.getElementsByTagName("studios"); @@ -106,13 +231,13 @@ public class DOMParser { studio.setUrl(subElement.getAttribute("url")); studio.setName(subElement.getAttribute("name")); studio.setId(subElement.getAttribute("id")); - + movie.addStudio(studio); } } } } - + // Process the "countries" subNodeList = movieElement.getElementsByTagName("countries"); @@ -137,7 +262,7 @@ public class DOMParser { } } } - + // Process the "cast" subNodeList = movieElement.getElementsByTagName("cast"); @@ -157,50 +282,50 @@ public class DOMParser { person.setCharacter(subElement.getAttribute("character")); person.setJob(subElement.getAttribute("job")); person.setId(subElement.getAttribute("id")); - person.addArtwork(Artwork.ARTWORK_TYPE_PERSON, - Artwork.ARTWORK_SIZE_THUMB, - subElement.getAttribute("thumb"), "-1"); + person.addArtwork(Artwork.ARTWORK_TYPE_PERSON, + Artwork.ARTWORK_SIZE_THUMB, + subElement.getAttribute("thumb"), "-1"); person.setDepartment(subElement.getAttribute("department")); person.setUrl(subElement.getAttribute("url")); person.setOrder(subElement.getAttribute("order")); person.setCastId(subElement.getAttribute("cast_id")); - + movie.addPerson(person); } } } } - + /* - * This processes the image elements. There are two formats to deal with: - * Movie.imdbLookup, Movie.getInfo & Movie.search: - * - * - * - * - * - * Movie.getImages: - * - * - * - * - * - * - * - * - * - * - * - * - * - */ + * This processes the image elements. There are two formats to deal with: + * Movie.imdbLookup, Movie.getInfo & Movie.search: + * + * + * + * + * + * Movie.getImages: + * + * + * + * + * + * + * + * + * + * + * + * + * + */ subNodeList = movieElement.getElementsByTagName("images"); for (int nodeLoop = 0; nodeLoop < subNodeList.getLength(); nodeLoop++) { subNode = subNodeList.item(nodeLoop); - + if (subNode.getNodeType() == Node.ELEMENT_NODE) { - + NodeList artworkNodeList = subNode.getChildNodes(); for (int artworkLoop = 0; artworkLoop < artworkNodeList.getLength(); artworkLoop++) { Node artworkNode = artworkNodeList.item(artworkLoop); @@ -215,12 +340,12 @@ public class DOMParser { artwork.setUrl(subElement.getAttribute("url")); artwork.setId(subElement.getAttribute("id")); movie.addArtwork(artwork); - } else if (subElement.getNodeName().equalsIgnoreCase("backdrop") || - subElement.getNodeName().equalsIgnoreCase("poster")) { + } else if (subElement.getNodeName().equalsIgnoreCase("backdrop") + || subElement.getNodeName().equalsIgnoreCase("poster")) { // This is the format used in Movie.getImages String artworkId = subElement.getAttribute("id"); String artworkType = subElement.getNodeName(); - + // We need to decode and loop round the child nodes to get the data NodeList imageNodeList = subElement.getChildNodes(); for (int imageLoop = 0; imageLoop < imageNodeList.getLength(); imageLoop++) { @@ -249,77 +374,4 @@ public class DOMParser { } return movie; } - - public static Person parsePersonInfo(Document doc) { - Person person = null; - - try { - person = new Person(); - NodeList personNodeList = doc.getElementsByTagName("person"); - - // Only get the first movie from the list - Node personNode = personNodeList.item(0); - - if (personNode == null) { - logger.finest("Person not found"); - return person; - } - - if (personNode.getNodeType() == Node.ELEMENT_NODE) { - Element personElement = (Element) personNode; - - person.setName(DOMHelper.getValueFromElement(personElement, "name")); - person.setId(DOMHelper.getValueFromElement(personElement, "id")); - person.setBiography(DOMHelper.getValueFromElement(personElement, "biography")); - person.setKnownMovies(Integer.parseInt(DOMHelper.getValueFromElement(personElement, "known_movies"))); - person.setBirthday(DOMHelper.getValueFromElement(personElement, "birthday")); - person.setBirthPlace(DOMHelper.getValueFromElement(personElement, "birthplace")); - person.setUrl(DOMHelper.getValueFromElement(personElement, "url")); - person.setVersion(Integer.parseInt(DOMHelper.getValueFromElement(personElement, "version"))); - person.setLastModifiedAt(DOMHelper.getValueFromElement(personElement, "last_modified_at")); - - NodeList artworkNodeList = doc.getElementsByTagName("image"); - for (int nodeLoop = 0; nodeLoop < artworkNodeList.getLength(); nodeLoop++) { - Node artworkNode = artworkNodeList.item(nodeLoop); - if (artworkNode.getNodeType() == Node.ELEMENT_NODE) { - Element artworkElement = (Element) artworkNode; - Artwork artwork = new Artwork(); - artwork.setType(artworkElement.getAttribute("type")); - artwork.setUrl(artworkElement.getAttribute("url")); - artwork.setSize(artworkElement.getAttribute("size")); - artwork.setId(artworkElement.getAttribute("id")); - person.addArtwork(artwork); - } - } - - NodeList filmNodeList = doc.getElementsByTagName("movie"); - for (int nodeLoop = 0; nodeLoop < filmNodeList.getLength(); nodeLoop++) { - Node filmNode = filmNodeList.item(nodeLoop); - if (filmNode.getNodeType() == Node.ELEMENT_NODE) { - Element filmElement = (Element) filmNode; - Filmography film = new Filmography(); - - film.setCharacter(filmElement.getAttribute("character")); - film.setDepartment(filmElement.getAttribute("department")); - film.setId(filmElement.getAttribute("id")); - film.setJob(filmElement.getAttribute("job")); - film.setName(filmElement.getAttribute("name")); - film.setUrl(filmElement.getAttribute("url")); - - person.addFilm(film); - } - } - } - } catch (Exception error) { - logger.severe("ERROR: " + error.getMessage()); - error.printStackTrace(); - } - - return person; - } - - public static Person parsePersonGetVersion(Document doc) { - // TODO Auto-generated method stub - return null; - } } From a26192e6d2cd6b95bc76ccea901b77906de83aff Mon Sep 17 00:00:00 2001 From: Mohammed Le Doze Date: Wed, 13 Oct 2010 09:49:31 +0000 Subject: [PATCH 040/207] added getCategories in TheMovieDb to retrieve the list of genres --- .../moviejukebox/themoviedb/TheMovieDb.java | 19 +++++++++++++ .../themoviedb/tools/DOMParser.java | 28 +++++++++++++++++++ 2 files changed, 47 insertions(+) diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java b/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java index e2141cbe8..6785076d2 100644 --- a/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java @@ -58,6 +58,7 @@ public class TheMovieDb { private static final String PERSON_GET_VERSION = "Person.getVersion"; private static final String PERSON_GET_INFO = "Person.getInfo"; private static final String PERSON_SEARCH = "Person.search"; + private static final String GENRES_GET_LIST = "Genres.getList"; public TheMovieDb(String apiKey) { setLogger(Logger.getLogger("TheMovieDB")); @@ -400,6 +401,24 @@ public class TheMovieDb { return person; } + /** + * Retrieve a list of valid genres within TMDb. + * @param language the two digit language code. E.g. en=English + * @return + */ + public List getCategories(String language) { + List categories = new ArrayList(); + Document doc = null; + String url = this.buildSearchUrl(GENRES_GET_LIST, "", language); + try { + doc = DOMHelper.getEventDocFromUrl(url); + categories = DOMParser.parseCategories(doc); + } catch (Exception error) { + logger.severe("Get categories error: " + error.getMessage()); + } + + return categories; + } /** * Search a list of movies and return the one that matches the title & year diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/tools/DOMParser.java b/themoviedbapi/src/com/moviejukebox/themoviedb/tools/DOMParser.java index e1555c877..2bb76da98 100644 --- a/themoviedbapi/src/com/moviejukebox/themoviedb/tools/DOMParser.java +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/tools/DOMParser.java @@ -374,4 +374,32 @@ public class DOMParser { } return movie; } + + /** + * Retrieve a list of valid genres within TMDb. + * @param doc a DOM document + * @return + */ + public static List parseCategories(Document doc) { + List categories = new ArrayList(); + NodeList genres = doc.getElementsByTagName("genres"); + if( (genres == null) || genres.getLength() == 0) { + return categories; + } + + for (int i= 0; i < genres.getLength(); i++) { + Node node = genres.item(i); + if (node.getNodeType() == Node.ELEMENT_NODE) { + Element element = (Element) node; + Category category = new Category(); + category.setId(element.getAttribute("id")); + category.setName(DOMHelper.getValueFromElement(element, "name")); + category.setType(DOMHelper.getValueFromElement(element, "type")); + category.setUrl(DOMHelper.getValueFromElement(element, "url")); + categories.add(category); + } + } + + return categories; + } } From 998d33adec5c1d5b71478e0d7a9571b221e9d4dd Mon Sep 17 00:00:00 2001 From: Mohammed Le Doze Date: Wed, 13 Oct 2010 12:56:02 +0000 Subject: [PATCH 041/207] updated parseCategories updated buildSearchUrl to handle the Genre.getList specific url --- .../src/com/moviejukebox/themoviedb/TheMovieDb.java | 3 ++- .../src/com/moviejukebox/themoviedb/tools/DOMParser.java | 8 ++++---- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java b/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java index 6785076d2..f2ef7bc29 100644 --- a/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java @@ -410,6 +410,7 @@ public class TheMovieDb { List categories = new ArrayList(); Document doc = null; String url = this.buildSearchUrl(GENRES_GET_LIST, "", language); + try { doc = DOMHelper.getEventDocFromUrl(url); categories = DOMParser.parseCategories(doc); @@ -483,7 +484,7 @@ public class TheMovieDb { String searchUrl = apiSite + prefix + "/" + language + "/xml/" + apiKey; if (prefix.equals(MOVIE_BROWSE)) { searchUrl += "?"; - } else { + } else if (!prefix.equals(GENRES_GET_LIST)) { searchUrl += "/"; } searchUrl += searchTerm; diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/tools/DOMParser.java b/themoviedbapi/src/com/moviejukebox/themoviedb/tools/DOMParser.java index 2bb76da98..c764016ae 100644 --- a/themoviedbapi/src/com/moviejukebox/themoviedb/tools/DOMParser.java +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/tools/DOMParser.java @@ -382,7 +382,7 @@ public class DOMParser { */ public static List parseCategories(Document doc) { List categories = new ArrayList(); - NodeList genres = doc.getElementsByTagName("genres"); + NodeList genres = doc.getElementsByTagName("genre"); if( (genres == null) || genres.getLength() == 0) { return categories; } @@ -392,10 +392,10 @@ public class DOMParser { if (node.getNodeType() == Node.ELEMENT_NODE) { Element element = (Element) node; Category category = new Category(); - category.setId(element.getAttribute("id")); - category.setName(DOMHelper.getValueFromElement(element, "name")); - category.setType(DOMHelper.getValueFromElement(element, "type")); + category.setName(element.getAttribute("name")); + category.setId(DOMHelper.getValueFromElement(element, "id")); category.setUrl(DOMHelper.getValueFromElement(element, "url")); + category.setType(""); // there are no type in the XML categories.add(category); } } From 4b0bd10156883cad5bd0a65c93b67e50aa581fb7 Mon Sep 17 00:00:00 2001 From: Mohammed Le Doze Date: Wed, 13 Oct 2010 13:20:22 +0000 Subject: [PATCH 042/207] removed unused imports --- themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java b/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java index f2ef7bc29..646167229 100644 --- a/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java @@ -24,9 +24,6 @@ import java.util.logging.Level; import java.util.logging.Logger; import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; import com.moviejukebox.themoviedb.model.MovieDB; import com.moviejukebox.themoviedb.model.Person; From 3c14c62226c44217d8b8950d034c046e038f4dcb Mon Sep 17 00:00:00 2001 From: Mohammed Le Doze Date: Wed, 13 Oct 2010 14:30:19 +0000 Subject: [PATCH 043/207] implemented personGetVersion in TheMovieDb and parsePersonGetVersion in DOMParser --- .../moviejukebox/themoviedb/TheMovieDb.java | 38 +++++++++++++++---- .../themoviedb/model/Category.java | 10 +++-- .../themoviedb/model/Country.java | 8 ++-- .../themoviedb/model/Filmography.java | 15 +++++--- .../moviejukebox/themoviedb/model/Studio.java | 8 ++-- .../themoviedb/tools/DOMParser.java | 33 +++++++++++++--- 6 files changed, 84 insertions(+), 28 deletions(-) diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java b/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java index 646167229..205444121 100644 --- a/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java @@ -31,6 +31,7 @@ import com.moviejukebox.themoviedb.tools.DOMHelper; import com.moviejukebox.themoviedb.tools.DOMParser; import com.moviejukebox.themoviedb.tools.LogFormatter; import com.moviejukebox.themoviedb.tools.WebBrowser; +import java.util.Arrays; /** * This is the main class for the API to connect to TheMovieDb.org The implementation is for v2.1 @@ -375,27 +376,50 @@ public class TheMovieDb { * the current version number of the called object(s). This is useful if you've already * called the object sometime in the past and simply want to do a quick check for updates. * - * @param personID - * @param language + * @param personID a Person TMDb id + * @param language the two digit language code. E.g. en=English * @return */ public Person personGetVersion(String personID, String language) { - Person person = new Person(); if (!isValidString(personID)) { - return person; + return new Person(); + } + + List people = new ArrayList(); + people = this.personGetVersion(Arrays.asList(personID), language); + + return people.get(0); + } + + /** + * Retrieve the last modified time along with the current version of a Person. + * @param personIDs one or multiple Person TMDb ids + * @param language the two digit language code. E.g. en=English + * @return + */ + public List personGetVersion(List personIDs, String language) { + List people = new ArrayList(); + + String ids = ""; + for (int i = 0; i < personIDs.size(); i++) { + if (i == 0) { + ids += personIDs.get(i); + continue; + } + ids += "," + personIDs.get(i); } Document doc = null; try { - String searchUrl = buildSearchUrl(PERSON_GET_VERSION, personID, language); + String searchUrl = buildSearchUrl(PERSON_GET_VERSION, ids, language); doc = DOMHelper.getEventDocFromUrl(searchUrl); - person = DOMParser.parsePersonGetVersion(doc); + people = DOMParser.parsePersonGetVersion(doc); } catch (Exception error) { logger.severe("PersonGetVersion error: " + error.getMessage()); } - return person; + return people; } /** diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/model/Category.java b/themoviedbapi/src/com/moviejukebox/themoviedb/model/Category.java index 4f58a8990..aaf589d1b 100644 --- a/themoviedbapi/src/com/moviejukebox/themoviedb/model/Category.java +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/model/Category.java @@ -20,10 +20,12 @@ package com.moviejukebox.themoviedb.model; */ public class Category { - private String type; - private String name; - private String url; - private String id; + private static final String UNKNOWN = MovieDB.UNKNOWN; + + private String type = UNKNOWN; + private String name = UNKNOWN; + private String url = UNKNOWN; + private String id = UNKNOWN; public String getId() { return id; diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/model/Country.java b/themoviedbapi/src/com/moviejukebox/themoviedb/model/Country.java index 55e64a9e4..69d90e1d0 100644 --- a/themoviedbapi/src/com/moviejukebox/themoviedb/model/Country.java +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/model/Country.java @@ -20,9 +20,11 @@ package com.moviejukebox.themoviedb.model; */ public class Country { - private String url; - private String name; - private String code; + private static final String UNKNOWN = MovieDB.UNKNOWN; + + private String url = UNKNOWN; + private String name = UNKNOWN; + private String code = UNKNOWN; public String getUrl() { return url; diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/model/Filmography.java b/themoviedbapi/src/com/moviejukebox/themoviedb/model/Filmography.java index 6237d1b83..00cc6eb78 100644 --- a/themoviedbapi/src/com/moviejukebox/themoviedb/model/Filmography.java +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/model/Filmography.java @@ -14,12 +14,15 @@ package com.moviejukebox.themoviedb.model; public class Filmography { - private String url; - private String name; - private String department; - private String character; - private String job; - private String id; + + private static final String UNKNOWN = MovieDB.UNKNOWN; + + private String url = UNKNOWN; + private String name = UNKNOWN; + private String department = UNKNOWN; + private String character = UNKNOWN; + private String job = UNKNOWN; + private String id = UNKNOWN; public String getUrl() { return url; diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/model/Studio.java b/themoviedbapi/src/com/moviejukebox/themoviedb/model/Studio.java index 322e6d1d8..1c113e445 100644 --- a/themoviedbapi/src/com/moviejukebox/themoviedb/model/Studio.java +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/model/Studio.java @@ -20,9 +20,11 @@ package com.moviejukebox.themoviedb.model; */ public class Studio { - private String name; - private String url; - private String id; + private static final String UNKNOWN = MovieDB.UNKNOWN; + + private String name = UNKNOWN; + private String url = UNKNOWN; + private String id = UNKNOWN; public String getId() { return id; diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/tools/DOMParser.java b/themoviedbapi/src/com/moviejukebox/themoviedb/tools/DOMParser.java index c764016ae..2b2af3c06 100644 --- a/themoviedbapi/src/com/moviejukebox/themoviedb/tools/DOMParser.java +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/tools/DOMParser.java @@ -151,11 +151,6 @@ public class DOMParser { return person; } - public static Person parsePersonGetVersion(Document doc) { - // TODO Auto-generated method stub - return null; - } - private static MovieDB parseMovieInfo(Element movieElement) { // Inspired by // http://www.java-tips.org/java-se-tips/javax.xml.parsers/how-to-read-xml-file-in-java.html @@ -375,6 +370,34 @@ public class DOMParser { return movie; } + /** + * Parse a DOM document and returns a list of Person + * @param doc a DOM document + * @return + */ + public static List parsePersonGetVersion(Document doc) { + List people = new ArrayList(); + NodeList movies = doc.getElementsByTagName("movie"); + if( (movies == null) || movies.getLength() == 0) { + return people; + } + + for (int i= 0; i < movies.getLength(); i++) { + Node node = movies.item(i); + if(node.getNodeType() == Node.ELEMENT_NODE) { + Element element = (Element) node; + Person person = new Person(); + person.setName(DOMHelper.getValueFromElement(element, "name")); + person.setId(DOMHelper.getValueFromElement(element, "id")); + person.setVersion(Integer.valueOf(DOMHelper.getValueFromElement(element, "version"))); + person.setLastModifiedAt(DOMHelper.getValueFromElement(element, "last_modified_at")); + people.add(person); + } + } + + return people; + } + /** * Retrieve a list of valid genres within TMDb. * @param doc a DOM document From 1b7dbee8dfbd99db950f41f0ec05f44dedb7aaf3 Mon Sep 17 00:00:00 2001 From: Omertron Date: Thu, 14 Oct 2010 17:29:39 +0000 Subject: [PATCH 044/207] Updated compareMovies method for better detection of non-English languages --- .../moviejukebox/themoviedb/TheMovieDb.java | 24 +++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java b/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java index 205444121..f9bf2c536 100644 --- a/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java @@ -479,15 +479,35 @@ public class TheMovieDb { if (isValidString(moviedb.getReleaseDate())) { // Compare with year String movieYear = moviedb.getReleaseDate().substring(0, 4); - if (moviedb.getTitle().equalsIgnoreCase(title) && movieYear.equals(year)) { - return true; + if (movieYear.equals(year)) { + if (moviedb.getOriginalName().equalsIgnoreCase(title)) { + return true; + } + + if (moviedb.getTitle().equalsIgnoreCase(title)) { + return true; + } + + // Try matching the alternative name too + if (moviedb.getAlternativeName().equalsIgnoreCase(title)) { + return true; + } } } } else { // Compare without year + if (moviedb.getOriginalName().equalsIgnoreCase(title)) { + return true; + } + if (moviedb.getTitle().equalsIgnoreCase(title)) { return true; } + + // Try matching the alternative name too + if (moviedb.getAlternativeName().equalsIgnoreCase(title)) { + return true; + } } return false; } From 909a494ede54921e9d04d56c525c679220bac500 Mon Sep 17 00:00:00 2001 From: Mohammed Le Doze Date: Fri, 15 Oct 2010 14:31:47 +0000 Subject: [PATCH 045/207] implemented Movie.getLatest renamed method buildSearchUrl to buildUrl --- .../moviejukebox/themoviedb/TheMovieDb.java | 85 ++++++++++++------- .../themoviedb/tools/DOMParser.java | 36 ++++++-- 2 files changed, 87 insertions(+), 34 deletions(-) diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java b/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java index f9bf2c536..8b35d92b2 100644 --- a/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java @@ -53,6 +53,7 @@ public class TheMovieDb { private static final String MOVIE_IMDB_LOOKUP = "Movie.imdbLookup"; private static final String MOVIE_GET_INFO = "Movie.getInfo"; private static final String MOVIE_GET_IMAGES = "Movie.getImages"; + private static final String MOVIE_GET_LATEST = "Movie.getLatest"; private static final String PERSON_GET_VERSION = "Person.getVersion"; private static final String PERSON_GET_INFO = "Person.getInfo"; private static final String PERSON_SEARCH = "Person.search"; @@ -122,7 +123,7 @@ public class TheMovieDb { Document doc = null; try { - String searchUrl = buildSearchUrl(MOVIE_SEARCH, URLEncoder.encode(movieTitle, "UTF-8"), language); + String searchUrl = buildUrl(MOVIE_SEARCH, URLEncoder.encode(movieTitle, "UTF-8"), language); doc = DOMHelper.getEventDocFromUrl(searchUrl); movies = DOMParser.parseMovies(doc); } catch (Exception error) { @@ -192,7 +193,7 @@ public class TheMovieDb { Document doc = null; - String searchUrl = buildSearchUrl(MOVIE_BROWSE, url, language); + String searchUrl = buildUrl(MOVIE_BROWSE, url, language); try { doc = DOMHelper.getEventDocFromUrl(searchUrl); } catch (Exception error) { @@ -220,7 +221,7 @@ public class TheMovieDb { Document doc = null; try { - String searchUrl = buildSearchUrl(MOVIE_IMDB_LOOKUP, imdbID, language); + String searchUrl = buildUrl(MOVIE_IMDB_LOOKUP, imdbID, language); doc = DOMHelper.getEventDocFromUrl(searchUrl); movie = DOMParser.parseMovie(doc); @@ -263,12 +264,12 @@ public class TheMovieDb { Document doc = null; try { - String searchUrl = buildSearchUrl(MOVIE_GET_INFO, tmdbID, language); + String searchUrl = buildUrl(MOVIE_GET_INFO, tmdbID, language); doc = DOMHelper.getEventDocFromUrl(searchUrl); if (doc == null && !language.equalsIgnoreCase(defaultLanguage)) { logger.fine("Trying to get the '" + defaultLanguage + "' version"); - searchUrl = buildSearchUrl(MOVIE_GET_INFO, tmdbID, defaultLanguage); + searchUrl = buildUrl(MOVIE_GET_INFO, tmdbID, defaultLanguage); } if (doc == null) { @@ -283,6 +284,28 @@ public class TheMovieDb { return movie; } + /** + * The Movie.getLatest method is a simple method. It returns the ID of the + * last movie created in the database. This is useful if you are scanning + * the database and want to know which id to stop at.
+ * The MovieDB object returned only has its title, TMDb id and IMDB id + * initialized. + * @param language the two digit language code. E.g. en=English + * @return + */ + public MovieDB moviedbGetLatest(String language) { + Document doc = null; + MovieDB movie = new MovieDB(); + try { + String url = buildUrl(MOVIE_GET_LATEST, "", language); + doc = DOMHelper.getEventDocFromUrl(url); + movie = DOMParser.parseLatestMovie(doc); + } catch (Exception error) { + logger.severe("GetLatest error: " + error.getMessage()); + } + return movie; + } + public MovieDB moviedbGetImages(String searchTerm, String language) { MovieDB movie = null; movie = moviedbGetImages(searchTerm, movie, language); @@ -305,7 +328,7 @@ public class TheMovieDb { Document doc = null; try { - String searchUrl = buildSearchUrl(MOVIE_GET_IMAGES, searchTerm, language); + String searchUrl = buildUrl(MOVIE_GET_IMAGES, searchTerm, language); doc = DOMHelper.getEventDocFromUrl(searchUrl); movie = DOMParser.parseMovie(doc); @@ -334,7 +357,7 @@ public class TheMovieDb { Document doc = null; try { - String searchUrl = buildSearchUrl(PERSON_SEARCH, personName, language); + String searchUrl = buildUrl(PERSON_SEARCH, personName, language); doc = DOMHelper.getEventDocFromUrl(searchUrl); person = DOMParser.parsePersonInfo(doc); } catch (Exception error) { @@ -361,7 +384,7 @@ public class TheMovieDb { Document doc = null; try { - String searchUrl = buildSearchUrl(PERSON_GET_INFO, personID, language); + String searchUrl = buildUrl(PERSON_GET_INFO, personID, language); doc = DOMHelper.getEventDocFromUrl(searchUrl); person = DOMParser.parsePersonInfo(doc); } catch (Exception error) { @@ -385,10 +408,7 @@ public class TheMovieDb { return new Person(); } - List people = new ArrayList(); - people = this.personGetVersion(Arrays.asList(personID), language); - - return people.get(0); + return this.personGetVersion(Arrays.asList(personID), language).get(0); } /** @@ -400,6 +420,11 @@ public class TheMovieDb { public List personGetVersion(List personIDs, String language) { List people = new ArrayList(); + if (personIDs.isEmpty()) { + logger.warning("There are no Person ids!"); + return people; + } + String ids = ""; for (int i = 0; i < personIDs.size(); i++) { if (i == 0) { @@ -412,7 +437,7 @@ public class TheMovieDb { Document doc = null; try { - String searchUrl = buildSearchUrl(PERSON_GET_VERSION, ids, language); + String searchUrl = buildUrl(PERSON_GET_VERSION, ids, language); doc = DOMHelper.getEventDocFromUrl(searchUrl); people = DOMParser.parsePersonGetVersion(doc); } catch (Exception error) { @@ -430,7 +455,7 @@ public class TheMovieDb { public List getCategories(String language) { List categories = new ArrayList(); Document doc = null; - String url = this.buildSearchUrl(GENRES_GET_LIST, "", language); + String url = this.buildUrl(GENRES_GET_LIST, "", language); try { doc = DOMHelper.getEventDocFromUrl(url); @@ -483,11 +508,11 @@ public class TheMovieDb { if (moviedb.getOriginalName().equalsIgnoreCase(title)) { return true; } - + if (moviedb.getTitle().equalsIgnoreCase(title)) { return true; } - + // Try matching the alternative name too if (moviedb.getAlternativeName().equalsIgnoreCase(title)) { return true; @@ -499,11 +524,11 @@ public class TheMovieDb { if (moviedb.getOriginalName().equalsIgnoreCase(title)) { return true; } - + if (moviedb.getTitle().equalsIgnoreCase(title)) { return true; } - + // Try matching the alternative name too if (moviedb.getAlternativeName().equalsIgnoreCase(title)) { return true; @@ -513,24 +538,26 @@ public class TheMovieDb { } /** - * Build the search URL from the search prefix and movie title. - * This will change between v2.0 and v2.1 of the API + * Build the URL that is used to get the XML from TMDb. * * @param prefix The search prefix before the movie title * @param language The two digit language code. E.g. en=English * @param searchTerm The search key to use, e.g. movie title or IMDb ID * @return The search URL */ - private String buildSearchUrl(String prefix, String searchTerm, String language) { - String searchUrl = apiSite + prefix + "/" + language + "/xml/" + apiKey; - if (prefix.equals(MOVIE_BROWSE)) { - searchUrl += "?"; - } else if (!prefix.equals(GENRES_GET_LIST)) { - searchUrl += "/"; + private String buildUrl(String prefix, String searchTerm, String language) { + String url = apiSite + prefix + "/" + language + "/xml/" + apiKey; + if (searchTerm.equals("")) { + return url; } - searchUrl += searchTerm; - logger.finest("Search URL: " + searchUrl); - return searchUrl; + if (prefix.equals(MOVIE_BROWSE)) { + url += "?"; + } else { + url += "/"; + } + url += searchTerm; + logger.finest("Search URL: " + url); + return url; } /** diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/tools/DOMParser.java b/themoviedbapi/src/com/moviejukebox/themoviedb/tools/DOMParser.java index 2b2af3c06..8399cfe4e 100644 --- a/themoviedbapi/src/com/moviejukebox/themoviedb/tools/DOMParser.java +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/tools/DOMParser.java @@ -378,13 +378,13 @@ public class DOMParser { public static List parsePersonGetVersion(Document doc) { List people = new ArrayList(); NodeList movies = doc.getElementsByTagName("movie"); - if( (movies == null) || movies.getLength() == 0) { + if ((movies == null) || movies.getLength() == 0) { return people; } - for (int i= 0; i < movies.getLength(); i++) { + for (int i = 0; i < movies.getLength(); i++) { Node node = movies.item(i); - if(node.getNodeType() == Node.ELEMENT_NODE) { + if (node.getNodeType() == Node.ELEMENT_NODE) { Element element = (Element) node; Person person = new Person(); person.setName(DOMHelper.getValueFromElement(element, "name")); @@ -406,11 +406,11 @@ public class DOMParser { public static List parseCategories(Document doc) { List categories = new ArrayList(); NodeList genres = doc.getElementsByTagName("genre"); - if( (genres == null) || genres.getLength() == 0) { + if ((genres == null) || genres.getLength() == 0) { return categories; } - for (int i= 0; i < genres.getLength(); i++) { + for (int i = 0; i < genres.getLength(); i++) { Node node = genres.item(i); if (node.getNodeType() == Node.ELEMENT_NODE) { Element element = (Element) node; @@ -425,4 +425,30 @@ public class DOMParser { return categories; } + + /** + * Parse a DOM document and returns the latest Movie. + * @param doc + * @return + */ + public static MovieDB parseLatestMovie(Document doc) { + MovieDB movie = new MovieDB(); + NodeList movies = doc.getElementsByTagName("movie"); + if ((movies == null) || movies.getLength() == 0) { + return movie; + } + + Node node = movies.item(0); + if (node.getNodeType() == Node.ELEMENT_NODE) { + Element element = (Element) node; + movie.setTitle(DOMHelper.getValueFromElement(element, "name")); + movie.setId(DOMHelper.getValueFromElement(element, "id")); + movie.setImdb(DOMHelper.getValueFromElement(element, "imdb_id")); + // to be done: + //movie.setVersion(DOMHelper.getValueFromElement(element, "version")); + //movie.setLastModifiedAt(DOMHelper.getValueFromElement(element, "last_modified_at")); + } + + return movie; + } } From a04060b96be61fb4c69d221391e0f66e1ed3c1e4 Mon Sep 17 00:00:00 2001 From: Omertron Date: Fri, 15 Oct 2010 17:55:58 +0000 Subject: [PATCH 046/207] Fix for moviedbGetImages not returning images --- .../com/moviejukebox/themoviedb/TheMovieDb.java | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java b/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java index 8b35d92b2..0df7d9609 100644 --- a/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java @@ -65,9 +65,7 @@ public class TheMovieDb { } public TheMovieDb(String apiKey, Logger logger) { - if (logger == null) { - setLogger(logger); - } + setLogger(logger); setApiKey(apiKey); } @@ -88,6 +86,10 @@ public class TheMovieDb { } public void setLogger(Logger logger) { + if (logger == null) { + return; + } + TheMovieDb.logger = logger; tmdbConsoleHandler.setFormatter(tmdbFormatter); tmdbConsoleHandler.setLevel(Level.FINE); @@ -307,9 +309,7 @@ public class TheMovieDb { } public MovieDB moviedbGetImages(String searchTerm, String language) { - MovieDB movie = null; - movie = moviedbGetImages(searchTerm, movie, language); - return movie; + return moviedbGetImages(searchTerm, new MovieDB(), language); } /** @@ -321,7 +321,7 @@ public class TheMovieDb { */ public MovieDB moviedbGetImages(String searchTerm, MovieDB movie, String language) { // If the searchTerm is null, then exit - if (isValidString(searchTerm)) { + if (!isValidString(searchTerm)) { return movie; } From 5144d99f3a1158da31e12e5e3b92bb5652eee5b6 Mon Sep 17 00:00:00 2001 From: Omertron Date: Fri, 15 Oct 2010 21:22:00 +0000 Subject: [PATCH 047/207] Moved all parsing code into the MovieDbParser class --- .../moviejukebox/themoviedb/TheMovieDb.java | 171 +++++------------- .../{DOMParser.java => MovieDbParser.java} | 109 +++++++++-- 2 files changed, 140 insertions(+), 140 deletions(-) rename themoviedbapi/src/com/moviejukebox/themoviedb/tools/{DOMParser.java => MovieDbParser.java} (86%) diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java b/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java index 0df7d9609..ee362b606 100644 --- a/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java @@ -13,6 +13,8 @@ package com.moviejukebox.themoviedb; import com.moviejukebox.themoviedb.model.Category; + +import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.util.ArrayList; import java.util.Collection; @@ -23,12 +25,9 @@ import java.util.logging.ConsoleHandler; import java.util.logging.Level; import java.util.logging.Logger; -import org.w3c.dom.Document; - import com.moviejukebox.themoviedb.model.MovieDB; import com.moviejukebox.themoviedb.model.Person; -import com.moviejukebox.themoviedb.tools.DOMHelper; -import com.moviejukebox.themoviedb.tools.DOMParser; +import com.moviejukebox.themoviedb.tools.MovieDbParser; import com.moviejukebox.themoviedb.tools.LogFormatter; import com.moviejukebox.themoviedb.tools.WebBrowser; import java.util.Arrays; @@ -122,16 +121,8 @@ public class TheMovieDb { return movies; } - Document doc = null; - - try { - String searchUrl = buildUrl(MOVIE_SEARCH, URLEncoder.encode(movieTitle, "UTF-8"), language); - doc = DOMHelper.getEventDocFromUrl(searchUrl); - movies = DOMParser.parseMovies(doc); - } catch (Exception error) { - logger.severe("TheMovieDb Error: " + error.getMessage()); - } - return movies; + String searchUrl = buildUrl(MOVIE_SEARCH, movieTitle, language); + return MovieDbParser.parseMovies(searchUrl); } /** @@ -193,16 +184,9 @@ public class TheMovieDb { } } - Document doc = null; - String searchUrl = buildUrl(MOVIE_BROWSE, url, language); - try { - doc = DOMHelper.getEventDocFromUrl(searchUrl); - } catch (Exception error) { - logger.severe("Browse error: " + error.getMessage()); - } - movies = DOMParser.parseMovies(doc); - return movies; + return MovieDbParser.parseMovies(searchUrl); + } /** @@ -220,17 +204,8 @@ public class TheMovieDb { return movie; } - Document doc = null; - - try { - String searchUrl = buildUrl(MOVIE_IMDB_LOOKUP, imdbID, language); - - doc = DOMHelper.getEventDocFromUrl(searchUrl); - movie = DOMParser.parseMovie(doc); - } catch (Exception error) { - logger.severe("ImdbLookup error: " + error.getMessage()); - } - return movie; + String searchUrl = buildUrl(MOVIE_IMDB_LOOKUP, imdbID, language); + return MovieDbParser.parseMovie(searchUrl); } /** @@ -262,27 +237,16 @@ public class TheMovieDb { if (!isValidString(tmdbID)) { return movie; } - - Document doc = null; - - try { - String searchUrl = buildUrl(MOVIE_GET_INFO, tmdbID, language); - - doc = DOMHelper.getEventDocFromUrl(searchUrl); - if (doc == null && !language.equalsIgnoreCase(defaultLanguage)) { - logger.fine("Trying to get the '" + defaultLanguage + "' version"); - searchUrl = buildUrl(MOVIE_GET_INFO, tmdbID, defaultLanguage); - } - - if (doc == null) { - return movie; - } - - movie = DOMParser.parseMovie(doc); - } catch (Exception error) { - logger.severe("GetInfo error: " + error.getMessage()); - error.printStackTrace(); + + String searchUrl = buildUrl(MOVIE_GET_INFO, tmdbID, language); + movie = MovieDbParser.parseMovie(searchUrl); + + if (movie == null && !language.equalsIgnoreCase(defaultLanguage)) { + logger.fine("Trying to get the '" + defaultLanguage + "' version"); + searchUrl = buildUrl(MOVIE_GET_INFO, tmdbID, defaultLanguage); + movie = MovieDbParser.parseMovie(searchUrl); } + return movie; } @@ -296,16 +260,8 @@ public class TheMovieDb { * @return */ public MovieDB moviedbGetLatest(String language) { - Document doc = null; - MovieDB movie = new MovieDB(); - try { - String url = buildUrl(MOVIE_GET_LATEST, "", language); - doc = DOMHelper.getEventDocFromUrl(url); - movie = DOMParser.parseLatestMovie(doc); - } catch (Exception error) { - logger.severe("GetLatest error: " + error.getMessage()); - } - return movie; + String url = buildUrl(MOVIE_GET_LATEST, "", language); + return MovieDbParser.parseLatestMovie(url); } public MovieDB moviedbGetImages(String searchTerm, String language) { @@ -325,19 +281,8 @@ public class TheMovieDb { return movie; } - Document doc = null; - - try { - String searchUrl = buildUrl(MOVIE_GET_IMAGES, searchTerm, language); - - doc = DOMHelper.getEventDocFromUrl(searchUrl); - movie = DOMParser.parseMovie(doc); - - } catch (Exception error) { - logger.severe("GetImages Error: " + error.getMessage()); - } - - return movie; + String searchUrl = buildUrl(MOVIE_GET_IMAGES, searchTerm, language); + return MovieDbParser.parseMovie(searchUrl); } /** @@ -349,22 +294,12 @@ public class TheMovieDb { * @return */ public Person personSearch(String personName, String language) { - Person person = new Person(); if (!isValidString(personName)) { - return person; + return new Person(); } - Document doc = null; - - try { - String searchUrl = buildUrl(PERSON_SEARCH, personName, language); - doc = DOMHelper.getEventDocFromUrl(searchUrl); - person = DOMParser.parsePersonInfo(doc); - } catch (Exception error) { - logger.severe("PersonSearch error: " + error.getMessage()); - } - - return person; + String searchUrl = buildUrl(PERSON_SEARCH, personName, language); + return MovieDbParser.parsePersonInfo(searchUrl); } /** @@ -381,17 +316,8 @@ public class TheMovieDb { return person; } - Document doc = null; - - try { - String searchUrl = buildUrl(PERSON_GET_INFO, personID, language); - doc = DOMHelper.getEventDocFromUrl(searchUrl); - person = DOMParser.parsePersonInfo(doc); - } catch (Exception error) { - logger.severe("PersonGetInfo error: " + error.getMessage()); - } - - return person; + String searchUrl = buildUrl(PERSON_GET_INFO, personID, language); + return MovieDbParser.parsePersonInfo(searchUrl); } /** @@ -434,17 +360,8 @@ public class TheMovieDb { ids += "," + personIDs.get(i); } - Document doc = null; - - try { - String searchUrl = buildUrl(PERSON_GET_VERSION, ids, language); - doc = DOMHelper.getEventDocFromUrl(searchUrl); - people = DOMParser.parsePersonGetVersion(doc); - } catch (Exception error) { - logger.severe("PersonGetVersion error: " + error.getMessage()); - } - - return people; + String searchUrl = buildUrl(PERSON_GET_VERSION, ids, language); + return MovieDbParser.parsePersonGetVersion(searchUrl); } /** @@ -453,18 +370,8 @@ public class TheMovieDb { * @return */ public List getCategories(String language) { - List categories = new ArrayList(); - Document doc = null; - String url = this.buildUrl(GENRES_GET_LIST, "", language); - - try { - doc = DOMHelper.getEventDocFromUrl(url); - categories = DOMParser.parseCategories(doc); - } catch (Exception error) { - logger.severe("Get categories error: " + error.getMessage()); - } - - return categories; + String searchUrl = this.buildUrl(GENRES_GET_LIST, "", language); + return MovieDbParser.parseCategories(searchUrl); } /** @@ -547,15 +454,27 @@ public class TheMovieDb { */ private String buildUrl(String prefix, String searchTerm, String language) { String url = apiSite + prefix + "/" + language + "/xml/" + apiKey; - if (searchTerm.equals("")) { + + if (!isValidString(searchTerm)) { return url; } + + String encodedSearchTerm; + + try { + encodedSearchTerm = URLEncoder.encode(searchTerm, "UTF-8"); + } catch (UnsupportedEncodingException e) { + encodedSearchTerm = searchTerm; + } + if (prefix.equals(MOVIE_BROWSE)) { url += "?"; } else { url += "/"; } - url += searchTerm; + + url += encodedSearchTerm; + logger.finest("Search URL: " + url); return url; } diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/tools/DOMParser.java b/themoviedbapi/src/com/moviejukebox/themoviedb/tools/MovieDbParser.java similarity index 86% rename from themoviedbapi/src/com/moviejukebox/themoviedb/tools/DOMParser.java rename to themoviedbapi/src/com/moviejukebox/themoviedb/tools/MovieDbParser.java index 8399cfe4e..1d8440766 100644 --- a/themoviedbapi/src/com/moviejukebox/themoviedb/tools/DOMParser.java +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/tools/MovieDbParser.java @@ -30,7 +30,7 @@ import com.moviejukebox.themoviedb.model.MovieDB; import com.moviejukebox.themoviedb.model.Person; import com.moviejukebox.themoviedb.model.Studio; -public class DOMParser { +public class MovieDbParser { static Logger logger = TheMovieDb.getLogger(); @@ -40,9 +40,24 @@ public class DOMParser { * @param doc DOM Document * @return */ - public static List parseMovies(Document doc) { + public static List parseMovies(String searchUrl) { List movies = new ArrayList(); + + Document doc = null; + + try { + doc = DOMHelper.getEventDocFromUrl(searchUrl); + } catch (Exception error) { + logger.severe("TheMovieDb Error: " + error.getMessage()); + return movies; + } + + if (doc == null) { + return movies; + } + NodeList nlMovies = doc.getElementsByTagName("movie"); + if ((nlMovies == null) || nlMovies.getLength() == 0) { return movies; } @@ -53,7 +68,7 @@ public class DOMParser { Node movieNode = nlMovies.item(i); if (movieNode.getNodeType() == Node.ELEMENT_NODE) { Element movieElement = (Element) movieNode; - movie = DOMParser.parseMovieInfo(movieElement); + movie = parseMovieInfo(movieElement); if (movie != null) { movies.add(movie); } @@ -67,8 +82,21 @@ public class DOMParser { * @param doc a DOM Document * @return */ - public static MovieDB parseMovie(Document doc) { - MovieDB movie = new MovieDB(); + public static MovieDB parseMovie(String searchUrl) { + MovieDB movie = null; + Document doc = null; + + try { + doc = DOMHelper.getEventDocFromUrl(searchUrl); + } catch (Exception error) { + logger.severe("TheMovieDb Error: " + error.getMessage()); + return movie; + } + + if (doc == null) { + return movie; + } + NodeList nlMovies = doc.getElementsByTagName("movie"); if ((nlMovies == null) || nlMovies.getLength() == 0) { return movie; @@ -77,15 +105,27 @@ public class DOMParser { Node nMovie = nlMovies.item(0); if (nMovie.getNodeType() == Node.ELEMENT_NODE) { Element eMovie = (Element) nMovie; - movie = DOMParser.parseMovieInfo(eMovie); + movie = parseMovieInfo(eMovie); } return movie; } - public static Person parsePersonInfo(Document doc) { + public static Person parsePersonInfo(String searchUrl) { Person person = null; + Document doc = null; + + try { + doc = DOMHelper.getEventDocFromUrl(searchUrl); + } catch (Exception error) { + logger.severe("PersonSearch error: " + error.getMessage()); + return person; + } + if (doc == null) { + return person; + } + try { person = new Person(); NodeList personNodeList = doc.getElementsByTagName("person"); @@ -375,8 +415,21 @@ public class DOMParser { * @param doc a DOM document * @return */ - public static List parsePersonGetVersion(Document doc) { + public static List parsePersonGetVersion(String searchUrl) { List people = new ArrayList(); + Document doc = null; + + try { + doc = DOMHelper.getEventDocFromUrl(searchUrl); + } catch (Exception error) { + logger.severe("PersonGetVersion error: " + error.getMessage()); + return people; + } + + if (doc == null) { + return people; + } + NodeList movies = doc.getElementsByTagName("movie"); if ((movies == null) || movies.getLength() == 0) { return people; @@ -403,8 +456,20 @@ public class DOMParser { * @param doc a DOM document * @return */ - public static List parseCategories(Document doc) { + public static List parseCategories(String searchUrl) { + Document doc = null; List categories = new ArrayList(); + + try { + doc = DOMHelper.getEventDocFromUrl(searchUrl); + } catch (Exception error) { + return categories; + } + + if (doc == null) { + return categories; + } + NodeList genres = doc.getElementsByTagName("genre"); if ((genres == null) || genres.getLength() == 0) { return categories; @@ -431,15 +496,31 @@ public class DOMParser { * @param doc * @return */ - public static MovieDB parseLatestMovie(Document doc) { - MovieDB movie = new MovieDB(); - NodeList movies = doc.getElementsByTagName("movie"); - if ((movies == null) || movies.getLength() == 0) { + public static MovieDB parseLatestMovie(String searchUrl) { + MovieDB movie = null; + Document doc = null; + + try { + doc = DOMHelper.getEventDocFromUrl(searchUrl); + } catch (Exception error) { + logger.severe("GetLatest error: " + error.getMessage()); + return movie; + } + + if (doc == null) { + return movie; + } + + NodeList nlMovies = doc.getElementsByTagName("movie"); + + if ((nlMovies == null) || nlMovies.getLength() == 0) { return movie; } - Node node = movies.item(0); + Node node = nlMovies.item(0); if (node.getNodeType() == Node.ELEMENT_NODE) { + movie = new MovieDB(); + Element element = (Element) node; movie.setTitle(DOMHelper.getValueFromElement(element, "name")); movie.setId(DOMHelper.getValueFromElement(element, "id")); From 3f2ec3fb193205f793d79f895f6308b38786d870 Mon Sep 17 00:00:00 2001 From: Mohammed Le Doze Date: Sat, 16 Oct 2010 19:37:34 +0000 Subject: [PATCH 048/207] added Movie.getVersion added 2 fields in MovieDB: version and lastModifiedAt updated javadoc in TheMovieDb --- .../moviejukebox/themoviedb/TheMovieDb.java | 176 ++++++++++++------ .../themoviedb/model/MovieDB.java | 31 +++ .../themoviedb/tools/MovieDbParser.java | 93 ++++++--- 3 files changed, 216 insertions(+), 84 deletions(-) diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java b/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java index ee362b606..f54bada2e 100644 --- a/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java @@ -33,8 +33,9 @@ import com.moviejukebox.themoviedb.tools.WebBrowser; import java.util.Arrays; /** - * This is the main class for the API to connect to TheMovieDb.org The implementation is for v2.1 - * of the API as detailed here http://api.themoviedb.org/2.1/docs/ + * This is the main class for the API to connect to TheMovieDb.org. + * The implementation is for v2.1 of the API as detailed here: + * http://api.themoviedb.org/2.1 * * @author Stuart.Boston * @version 1.3 @@ -53,6 +54,7 @@ public class TheMovieDb { private static final String MOVIE_GET_INFO = "Movie.getInfo"; private static final String MOVIE_GET_IMAGES = "Movie.getImages"; private static final String MOVIE_GET_LATEST = "Movie.getLatest"; + private static final String MOVIE_GET_VERSION = "Movie.getVersion"; private static final String PERSON_GET_VERSION = "Person.getVersion"; private static final String PERSON_GET_INFO = "Person.getInfo"; private static final String PERSON_SEARCH = "Person.search"; @@ -88,7 +90,7 @@ public class TheMovieDb { if (logger == null) { return; } - + TheMovieDb.logger = logger; tmdbConsoleHandler.setFormatter(tmdbFormatter); tmdbConsoleHandler.setLevel(Level.FINE); @@ -114,11 +116,9 @@ public class TheMovieDb { * @return A movie bean with the data extracted */ public List moviedbSearch(String movieTitle, String language) { - List movies = new ArrayList(); - // If the title is null, then exit if (!isValidString(movieTitle)) { - return movies; + return new ArrayList(); } String searchUrl = buildUrl(MOVIE_SEARCH, movieTitle, language); @@ -130,9 +130,9 @@ public class TheMovieDb { * http://api.themoviedb.org/2.1/methods/Movie.browse * * @param orderBy either rating, - * release or title + * release or title * @param order how results are ordered. Either asc or - * desc + * desc * @param language the two digit language code. E.g. en=English * @return a list of MovieDB objects */ @@ -145,11 +145,11 @@ public class TheMovieDb { * http://api.themoviedb.org/2.1/methods/Movie.browse * * @param orderBy either rating, - * release or title + * release or title * @param order how results are ordered. Either asc or - * desc + * desc * @param parameters a Map of optional parameters. See the complete list - * in the url above. + * in the url above. * @param language the two digit language code. E.g. en=English * @return a list of MovieDB objects */ @@ -186,7 +186,7 @@ public class TheMovieDb { String searchUrl = buildUrl(MOVIE_BROWSE, url, language); return MovieDbParser.parseMovies(searchUrl); - + } /** @@ -237,16 +237,16 @@ public class TheMovieDb { if (!isValidString(tmdbID)) { return movie; } - + String searchUrl = buildUrl(MOVIE_GET_INFO, tmdbID, language); movie = MovieDbParser.parseMovie(searchUrl); - + if (movie == null && !language.equalsIgnoreCase(defaultLanguage)) { logger.fine("Trying to get the '" + defaultLanguage + "' version"); searchUrl = buildUrl(MOVIE_GET_INFO, tmdbID, defaultLanguage); movie = MovieDbParser.parseMovie(searchUrl); } - + return movie; } @@ -254,34 +254,86 @@ public class TheMovieDb { * The Movie.getLatest method is a simple method. It returns the ID of the * last movie created in the database. This is useful if you are scanning * the database and want to know which id to stop at.
- * The MovieDB object returned only has its title, TMDb id and IMDB id - * initialized. + * The MovieDB object returned only has its title, TMDb id, IMDB id, + * version and last modified date initialized. * @param language the two digit language code. E.g. en=English * @return */ public MovieDB moviedbGetLatest(String language) { - String url = buildUrl(MOVIE_GET_LATEST, "", language); - return MovieDbParser.parseLatestMovie(url); - } - - public MovieDB moviedbGetImages(String searchTerm, String language) { - return moviedbGetImages(searchTerm, new MovieDB(), language); + return MovieDbParser.parseLatestMovie(buildUrl(MOVIE_GET_LATEST, "", language)); } /** - * Get all the image information from TheMovieDb. - * @param searchTerm Can be either the IMDb ID or TMDb ID - * @param movie - * @param language + * The Movie.getVersion method is used to retrieve the last modified time + * along with the current version number of the called object(s). This is + * useful if you've already called the object sometime in the past and + * simply want to do a quick check for updates.
+ * The MovieDB object returned only has its title, TMDb id, IMDB id, + * version and last modified date initialized. + * @param movieId the TMDb ID or IMDB ID of the movie + * @param language the two digit language code. E.g. en=English * @return */ - public MovieDB moviedbGetImages(String searchTerm, MovieDB movie, String language) { + public MovieDB moviedbGetVersion(String movieId, String language) { + return this.moviedbGetVersion(Arrays.asList(movieId), language).get(0); + } + + /** + * The Movie.getVersion method is used to retrieve the last modified time + * along with the current version number of the called object(s). This is + * useful if you've already called the object sometime in the past and + * simply want to do a quick check for updates.
+ * The MovieDB object returned only has its title, TMDb id, IMDB id, + * version and last modified date initialized. + * @param movieIds the ID of the TMDb movie you are looking for. + * This field supports an integer value (TMDb movie id) an + * IMDB ID or a combination of both. + * @param language the two digit language code. E.g. en=English + * @return + */ + public List moviedbGetVersion(List movieIds, String language) { + List movies = new ArrayList(); + + if (movieIds.isEmpty()) { + logger.warning("There are no Movie ids!"); + return movies; + } + + String url = buildUrl(MOVIE_GET_VERSION, this.buildIds(movieIds), language); + return MovieDbParser.parseMovieGetVersion(url); + + } + + /** + * The Movie.getImages method is used to retrieve all of the backdrops and + * posters for a particular movie. This is useful to scan for updates, or + * new images if that's all you're after. + * @param movieId the TMDb or IMDB ID (starting with tt) of the movie you + * are searching for. + * @param language the two digit language code. E.g. en=English + * @return + */ + public MovieDB moviedbGetImages(String movieId, String language) { + return moviedbGetImages(movieId, new MovieDB(), language); + } + + /** + * The Movie.getImages method is used to retrieve all of the backdrops and + * posters for a particular movie. This is useful to scan for updates, or + * new images if that's all you're after. + * @param movieId the TMDb or IMDB ID (starting with tt) of the movie you + * are searching for. + * @param movie a MovieDB object + * @param language the two digit language code. E.g. en=English + * @return + */ + public MovieDB moviedbGetImages(String movieId, MovieDB movie, String language) { // If the searchTerm is null, then exit - if (!isValidString(searchTerm)) { + if (!isValidString(movieId)) { return movie; } - String searchUrl = buildUrl(MOVIE_GET_IMAGES, searchTerm, language); + String searchUrl = buildUrl(MOVIE_GET_IMAGES, movieId, language); return MovieDbParser.parseMovie(searchUrl); } @@ -311,9 +363,8 @@ public class TheMovieDb { * @return */ public Person personGetInfo(String personID, String language) { - Person person = new Person(); if (!isValidString(personID)) { - return person; + return new Person(); } String searchUrl = buildUrl(PERSON_GET_INFO, personID, language); @@ -321,9 +372,10 @@ public class TheMovieDb { } /** - * The Person.getVersion method is used to retrieve the last modified time along with - * the current version number of the called object(s). This is useful if you've already - * called the object sometime in the past and simply want to do a quick check for updates. + * The Person.getVersion method is used to retrieve the last modified time + * along with the current version number of the called object(s). This is + * useful if you've already called the object sometime in the past and + * simply want to do a quick check for updates. * * @param personID a Person TMDb id * @param language the two digit language code. E.g. en=English @@ -338,29 +390,21 @@ public class TheMovieDb { } /** - * Retrieve the last modified time along with the current version of a Person. + * The Person.getVersion method is used to retrieve the last modified time + * along with the current version number of the called object(s). This is + * useful if you've already called the object sometime in the past and + * simply want to do a quick check for updates. * @param personIDs one or multiple Person TMDb ids * @param language the two digit language code. E.g. en=English * @return */ public List personGetVersion(List personIDs, String language) { - List people = new ArrayList(); - if (personIDs.isEmpty()) { logger.warning("There are no Person ids!"); - return people; + return new ArrayList(); } - String ids = ""; - for (int i = 0; i < personIDs.size(); i++) { - if (i == 0) { - ids += personIDs.get(i); - continue; - } - ids += "," + personIDs.get(i); - } - - String searchUrl = buildUrl(PERSON_GET_VERSION, ids, language); + String searchUrl = buildUrl(PERSON_GET_VERSION, this.buildIds(personIDs), language); return MovieDbParser.parsePersonGetVersion(searchUrl); } @@ -370,8 +414,7 @@ public class TheMovieDb { * @return */ public List getCategories(String language) { - String searchUrl = this.buildUrl(GENRES_GET_LIST, "", language); - return MovieDbParser.parseCategories(searchUrl); + return MovieDbParser.parseCategories(this.buildUrl(GENRES_GET_LIST, "", language)); } /** @@ -382,7 +425,9 @@ public class TheMovieDb { * @return The matching movie */ public static MovieDB findMovie(Collection movieList, String title, String year) { - if (movieList == null || movieList.isEmpty()) { + if ((movieList == null) || (movieList.isEmpty()) + || (!isValidString(title)) + || (!isValidString(year))) { return null; } @@ -458,27 +503,44 @@ public class TheMovieDb { if (!isValidString(searchTerm)) { return url; } - + String encodedSearchTerm; - + try { encodedSearchTerm = URLEncoder.encode(searchTerm, "UTF-8"); } catch (UnsupportedEncodingException e) { encodedSearchTerm = searchTerm; } - + if (prefix.equals(MOVIE_BROWSE)) { url += "?"; } else { url += "/"; } - + url += encodedSearchTerm; - + logger.finest("Search URL: " + url); return url; } + /** + * Build comma separated ids for Movie.getLatest and Movie.getVersion. + * @param ids a List of ids + * @return + */ + private String buildIds(List ids) { + String s = ""; + for (int i = 0; i < ids.size(); i++) { + if (i == 0) { + s += ids.get(i); + continue; + } + s += "," + ids.get(i); + } + return s; + } + /** * Check the string passed to see if it contains a value. * @param testString The string to test diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/model/MovieDB.java b/themoviedbapi/src/com/moviejukebox/themoviedb/model/MovieDB.java index d5cf9a694..31c5a6dfc 100644 --- a/themoviedbapi/src/com/moviejukebox/themoviedb/model/MovieDB.java +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/model/MovieDB.java @@ -13,8 +13,11 @@ package com.moviejukebox.themoviedb.model; +import java.text.DateFormat; +import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.List; +import java.util.Date; import com.moviejukebox.themoviedb.tools.ModelTools; @@ -48,6 +51,8 @@ public class MovieDB extends ModelTools { private String revenue = UNKNOWN; private String homepage = UNKNOWN; private String trailer = UNKNOWN; + private int version = -1; + private Date lastModifiedAt; private List categories = new ArrayList(); private List studios = new ArrayList(); private List countries = new ArrayList(); @@ -280,4 +285,30 @@ public class MovieDB extends ModelTools { public void setPeople(List people) { this.people = people; } + + public Date getLastModifiedAt() { + return lastModifiedAt; + } + + public void setLastModifiedAt(Date lastModifiedAt) { + this.lastModifiedAt = lastModifiedAt; + } + + public void setLastModifiedAt(String lastModifiedAt) { + DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); + + try { + setLastModifiedAt(df.parse(lastModifiedAt)); + } catch (Exception ignore) { + return; + } + } + + public int getVersion() { + return version; + } + + public void setVersion(int version) { + this.version = version; + } } diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/tools/MovieDbParser.java b/themoviedbapi/src/com/moviejukebox/themoviedb/tools/MovieDbParser.java index 1d8440766..86713a9cd 100644 --- a/themoviedbapi/src/com/moviejukebox/themoviedb/tools/MovieDbParser.java +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/tools/MovieDbParser.java @@ -42,20 +42,20 @@ public class MovieDbParser { */ public static List parseMovies(String searchUrl) { List movies = new ArrayList(); - + Document doc = null; - + try { doc = DOMHelper.getEventDocFromUrl(searchUrl); } catch (Exception error) { logger.severe("TheMovieDb Error: " + error.getMessage()); return movies; } - + if (doc == null) { return movies; } - + NodeList nlMovies = doc.getElementsByTagName("movie"); if ((nlMovies == null) || nlMovies.getLength() == 0) { @@ -85,18 +85,18 @@ public class MovieDbParser { public static MovieDB parseMovie(String searchUrl) { MovieDB movie = null; Document doc = null; - + try { doc = DOMHelper.getEventDocFromUrl(searchUrl); } catch (Exception error) { logger.severe("TheMovieDb Error: " + error.getMessage()); return movie; } - + if (doc == null) { return movie; } - + NodeList nlMovies = doc.getElementsByTagName("movie"); if ((nlMovies == null) || nlMovies.getLength() == 0) { return movie; @@ -114,7 +114,7 @@ public class MovieDbParser { public static Person parsePersonInfo(String searchUrl) { Person person = null; Document doc = null; - + try { doc = DOMHelper.getEventDocFromUrl(searchUrl); } catch (Exception error) { @@ -125,7 +125,7 @@ public class MovieDbParser { if (doc == null) { return person; } - + try { person = new Person(); NodeList personNodeList = doc.getElementsByTagName("person"); @@ -418,18 +418,18 @@ public class MovieDbParser { public static List parsePersonGetVersion(String searchUrl) { List people = new ArrayList(); Document doc = null; - + try { doc = DOMHelper.getEventDocFromUrl(searchUrl); } catch (Exception error) { logger.severe("PersonGetVersion error: " + error.getMessage()); return people; } - + if (doc == null) { return people; } - + NodeList movies = doc.getElementsByTagName("movie"); if ((movies == null) || movies.getLength() == 0) { return people; @@ -459,17 +459,17 @@ public class MovieDbParser { public static List parseCategories(String searchUrl) { Document doc = null; List categories = new ArrayList(); - + try { doc = DOMHelper.getEventDocFromUrl(searchUrl); } catch (Exception error) { return categories; } - + if (doc == null) { return categories; } - + NodeList genres = doc.getElementsByTagName("genre"); if ((genres == null) || genres.getLength() == 0) { return categories; @@ -490,29 +490,31 @@ public class MovieDbParser { return categories; } - + /** * Parse a DOM document and returns the latest Movie. + * This method is used for Movie.getLatest and Movie.getVersion where only + * a few fields are initialized. * @param doc * @return */ public static MovieDB parseLatestMovie(String searchUrl) { MovieDB movie = null; Document doc = null; - + try { doc = DOMHelper.getEventDocFromUrl(searchUrl); } catch (Exception error) { logger.severe("GetLatest error: " + error.getMessage()); return movie; } - + if (doc == null) { return movie; } - + NodeList nlMovies = doc.getElementsByTagName("movie"); - + if ((nlMovies == null) || nlMovies.getLength() == 0) { return movie; } @@ -520,16 +522,53 @@ public class MovieDbParser { Node node = nlMovies.item(0); if (node.getNodeType() == Node.ELEMENT_NODE) { movie = new MovieDB(); - + Element element = (Element) node; - movie.setTitle(DOMHelper.getValueFromElement(element, "name")); - movie.setId(DOMHelper.getValueFromElement(element, "id")); - movie.setImdb(DOMHelper.getValueFromElement(element, "imdb_id")); - // to be done: - //movie.setVersion(DOMHelper.getValueFromElement(element, "version")); - //movie.setLastModifiedAt(DOMHelper.getValueFromElement(element, "last_modified_at")); + movie = MovieDbParser.parseSimpleMovie(element); } return movie; } + + public static List parseMovieGetVersion(String url) { + List movies = new ArrayList(); + Document doc = null; + + try { + doc = DOMHelper.getEventDocFromUrl(url); + } catch (Exception e) { + logger.severe("Movie.getVersion error: " + e.getMessage()); + return movies; + } + + if (doc == null) { + return movies; + } + + NodeList nlMovies = doc.getElementsByTagName("movie"); + + if ((nlMovies == null) || nlMovies.getLength() == 0) { + return movies; + } + + for (int i = 0; i < nlMovies.getLength(); i++) { + Node node = nlMovies.item(i); + if (node.getNodeType() == Node.ELEMENT_NODE) { + Element element = (Element) node; + movies.add(MovieDbParser.parseSimpleMovie(element)); + } + } + + return movies; + } + + private static MovieDB parseSimpleMovie(Element element) { + MovieDB movie = new MovieDB(); + movie.setTitle(DOMHelper.getValueFromElement(element, "name")); + movie.setId(DOMHelper.getValueFromElement(element, "id")); + movie.setImdb(DOMHelper.getValueFromElement(element, "imdb_id")); + movie.setVersion(Integer.valueOf(DOMHelper.getValueFromElement(element, "version"))); + movie.setLastModifiedAt(DOMHelper.getValueFromElement(element, "last_modified_at")); + return movie; + } } From 0e30623c5c1e9cee29d3e4f9dfe341d221d84f61 Mon Sep 17 00:00:00 2001 From: Mohammed Le Doze Date: Sat, 16 Oct 2010 21:05:55 +0000 Subject: [PATCH 049/207] added Person.getLatest --- .../moviejukebox/themoviedb/TheMovieDb.java | 40 ++++++++--- .../themoviedb/tools/MovieDbParser.java | 71 +++++++++++++++++-- 2 files changed, 96 insertions(+), 15 deletions(-) diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java b/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java index f54bada2e..62077b004 100644 --- a/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java @@ -48,17 +48,18 @@ public class TheMovieDb { private static ConsoleHandler tmdbConsoleHandler = new ConsoleHandler(); private static final String apiSite = "http://api.themoviedb.org/2.1/"; private static final String defaultLanguage = "en-US"; - private static final String MOVIE_SEARCH = "Movie.search"; + private static final String GENRES_GET_LIST = "Genres.getList"; private static final String MOVIE_BROWSE = "Movie.browse"; - private static final String MOVIE_IMDB_LOOKUP = "Movie.imdbLookup"; private static final String MOVIE_GET_INFO = "Movie.getInfo"; private static final String MOVIE_GET_IMAGES = "Movie.getImages"; private static final String MOVIE_GET_LATEST = "Movie.getLatest"; private static final String MOVIE_GET_VERSION = "Movie.getVersion"; - private static final String PERSON_GET_VERSION = "Person.getVersion"; + private static final String MOVIE_IMDB_LOOKUP = "Movie.imdbLookup"; + private static final String MOVIE_SEARCH = "Movie.search"; private static final String PERSON_GET_INFO = "Person.getInfo"; + private static final String PERSON_GET_LATEST = "Person.getLatest"; + private static final String PERSON_GET_VERSION = "Person.getVersion"; private static final String PERSON_SEARCH = "Person.search"; - private static final String GENRES_GET_LIST = "Genres.getList"; public TheMovieDb(String apiKey) { setLogger(Logger.getLogger("TheMovieDB")); @@ -275,7 +276,11 @@ public class TheMovieDb { * @return */ public MovieDB moviedbGetVersion(String movieId, String language) { - return this.moviedbGetVersion(Arrays.asList(movieId), language).get(0); + List movies = this.moviedbGetVersion(Arrays.asList(movieId), language); + if (movies.isEmpty()) { + return new MovieDB(); + } + return movies.get(0); } /** @@ -294,7 +299,7 @@ public class TheMovieDb { public List moviedbGetVersion(List movieIds, String language) { List movies = new ArrayList(); - if (movieIds.isEmpty()) { + if ((movieIds == null) || movieIds.isEmpty()) { logger.warning("There are no Movie ids!"); return movies; } @@ -371,6 +376,17 @@ public class TheMovieDb { return MovieDbParser.parsePersonInfo(searchUrl); } + /** + * The Person.getLatest method is a simple method. It returns the ID of the + * last person created in the db. This is useful if you are scanning the + * database and want to know which id to stop at. + * @param language the two digit language code. E.g. en=English + * @return + */ + public Person personGetLatest(String language) { + return MovieDbParser.parseLatestPerson(buildUrl(PERSON_GET_LATEST, "", language)); + } + /** * The Person.getVersion method is used to retrieve the last modified time * along with the current version number of the called object(s). This is @@ -382,11 +398,17 @@ public class TheMovieDb { * @return */ public Person personGetVersion(String personID, String language) { + Person person = new Person(); if (!isValidString(personID)) { - return new Person(); + return person; } - return this.personGetVersion(Arrays.asList(personID), language).get(0); + List people = this.personGetVersion(Arrays.asList(personID), language); + if (people.isEmpty()) { + return person; + } + + return people.get(0); } /** @@ -399,7 +421,7 @@ public class TheMovieDb { * @return */ public List personGetVersion(List personIDs, String language) { - if (personIDs.isEmpty()) { + if ((personIDs == null) || (personIDs.isEmpty())) { logger.warning("There are no Person ids!"); return new ArrayList(); } diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/tools/MovieDbParser.java b/themoviedbapi/src/com/moviejukebox/themoviedb/tools/MovieDbParser.java index 86713a9cd..6eee3ffcf 100644 --- a/themoviedbapi/src/com/moviejukebox/themoviedb/tools/MovieDbParser.java +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/tools/MovieDbParser.java @@ -439,12 +439,7 @@ public class MovieDbParser { Node node = movies.item(i); if (node.getNodeType() == Node.ELEMENT_NODE) { Element element = (Element) node; - Person person = new Person(); - person.setName(DOMHelper.getValueFromElement(element, "name")); - person.setId(DOMHelper.getValueFromElement(element, "id")); - person.setVersion(Integer.valueOf(DOMHelper.getValueFromElement(element, "version"))); - person.setLastModifiedAt(DOMHelper.getValueFromElement(element, "last_modified_at")); - people.add(person); + people.add(MovieDbParser.parseSimplePerson(element)); } } @@ -562,6 +557,50 @@ public class MovieDbParser { return movies; } + public static Person parseLatestPerson(String url) { + Person person = new Person(); + Document doc = null; + + try { + doc = DOMHelper.getEventDocFromUrl(url); + } catch (Exception error) { + logger.severe("Person.getLatest error: " + error.getMessage()); + return person; + } + + if (doc == null) { + return person; + } + + NodeList nlMovies = doc.getElementsByTagName("person"); + + if ((nlMovies == null) || nlMovies.getLength() == 0) { + return person; + } + + Node node = nlMovies.item(0); + if (node.getNodeType() == Node.ELEMENT_NODE) { + person = new Person(); + + Element element = (Element) node; + person = MovieDbParser.parseSimplePerson(element); + } + + return person; + } + + /** + * Parse a "simple" Movie in the form: + * + * Inception + * 36462 + * tt1375666 + * 11 + * 2010-07-26 17:06:18 + * + * @param element + * @return + */ private static MovieDB parseSimpleMovie(Element element) { MovieDB movie = new MovieDB(); movie.setTitle(DOMHelper.getValueFromElement(element, "name")); @@ -571,4 +610,24 @@ public class MovieDbParser { movie.setLastModifiedAt(DOMHelper.getValueFromElement(element, "last_modified_at")); return movie; } + + /** + * Parse a "simple" Person in the form: + * + * John Joseph + * 111830 + * 3 + * 2010-07-19 10:59:13 + * + * @param element + * @return + */ + private static Person parseSimplePerson(Element element) { + Person person = new Person(); + person.setName(DOMHelper.getValueFromElement(element, "name")); + person.setId(DOMHelper.getValueFromElement(element, "id")); + person.setVersion(Integer.valueOf(DOMHelper.getValueFromElement(element, "version"))); + person.setLastModifiedAt(DOMHelper.getValueFromElement(element, "last_modified_at")); + return person; + } } From 0e4794fc4465b549d36d752342e97e603f5313ca Mon Sep 17 00:00:00 2001 From: Mohammed Le Doze Date: Sat, 16 Oct 2010 21:08:11 +0000 Subject: [PATCH 050/207] added first TheMovieDb JUnit tests (tester must specify it's API key in this file) JUnit 4.5 is required --- .../themoviedb/TheMovieDbTest.java | 229 ++++++++++++++++++ 1 file changed, 229 insertions(+) create mode 100644 themoviedbapi/test/com/moviejukebox/themoviedb/TheMovieDbTest.java diff --git a/themoviedbapi/test/com/moviejukebox/themoviedb/TheMovieDbTest.java b/themoviedbapi/test/com/moviejukebox/themoviedb/TheMovieDbTest.java new file mode 100644 index 000000000..2f637387d --- /dev/null +++ b/themoviedbapi/test/com/moviejukebox/themoviedb/TheMovieDbTest.java @@ -0,0 +1,229 @@ +package com.moviejukebox.themoviedb; + +import com.moviejukebox.themoviedb.model.Person; +import java.util.ArrayList; +import com.moviejukebox.themoviedb.model.MovieDB; +import java.util.List; +import org.junit.After; +import org.junit.AfterClass; +import org.junit.Before; +import org.junit.BeforeClass; +import org.junit.Test; +import static org.junit.Assert.*; + +/** + * + * @author mledoze + */ +public class TheMovieDbTest { + + private static String apikey = ""; + private TheMovieDb tmdb; + + public TheMovieDbTest() { + } + + @BeforeClass + public static void setUpClass() throws Exception { + } + + @AfterClass + public static void tearDownClass() throws Exception { + } + + @Before + public void setUp() { + tmdb = new TheMovieDb(apikey); + } + + @After + public void tearDown() { + } + + @Test + public void testGetApiKey() { + assertEquals(apikey, tmdb.getApiKey()); + } + + //@Test + public void testMoviedbSearch() { + } + + //@Test + public void testMoviedbBrowse_3args() { + } + + //@Test + public void testMoviedbBrowse_4args() { + } + + //@Test + public void testMoviedbImdbLookup() { + } + + //@Test + public void testMoviedbGetInfo_String_String() { + } + + //@Test + public void testMoviedbGetInfo_3args() { + } + + /** + * Test of moviedbGetLatest method, of class TheMovieDb. + */ + @Test + public void testMoviedbGetLatest() { + MovieDB movie = tmdb.moviedbGetLatest("en"); + assertFalse(movie.getTitle().equals(MovieDB.UNKNOWN)); + } + + /** + * Test of moviedbGetVersion method, of class TheMovieDb. + */ + @Test + public void testMoviedbGetVersion_String_String() { + MovieDB movie = tmdb.moviedbGetVersion("155", "en"); + assertEquals("The Dark Knight", movie.getTitle()); + assertEquals("155", movie.getId()); + assertEquals("tt0468569", movie.getImdb()); + } + + @Test + public void testMoviedbGetVersion_withWrongId() { + MovieDB movie = tmdb.moviedbGetVersion("0", "en"); + assertEquals(MovieDB.UNKNOWN, movie.getTitle()); + assertEquals(MovieDB.UNKNOWN, movie.getId()); + } + + @Test + public void testMoviedbGetVersion_withNullId() { + MovieDB movie = tmdb.moviedbGetVersion((String) null, "en"); + assertEquals(MovieDB.UNKNOWN, movie.getTitle()); + assertEquals(MovieDB.UNKNOWN, movie.getId()); + } + + @Test + public void testMoviedbGetVersion_withEmptyId() { + MovieDB movie = tmdb.moviedbGetVersion("", "en"); + assertEquals(MovieDB.UNKNOWN, movie.getTitle()); + assertEquals(MovieDB.UNKNOWN, movie.getId()); + } + + @Test + public void testMoviedbGetVersion_List_String() { + List ids = new ArrayList(); + ids.add("585"); + ids.add("11"); + List movies = tmdb.moviedbGetVersion(ids, "en"); + + assertEquals("Monsters, Inc.", movies.get(0).getTitle()); + assertEquals("585", movies.get(0).getId()); + assertEquals("tt0198781", movies.get(0).getImdb()); + + assertEquals("Star Wars: Episode IV - A New Hope", movies.get(1).getTitle()); + assertEquals("11", movies.get(1).getId()); + assertEquals("tt0076759", movies.get(1).getImdb()); + + } + + @Test + public void testMoviedbGetVersion_withEmptyList() { + List movies = tmdb.moviedbGetVersion(new ArrayList(), "en"); + assertTrue(movies.isEmpty()); + } + + @Test + public void testMoviedbGetVersion_withNullList() { + List movies = tmdb.moviedbGetVersion((List) null, "en"); + assertTrue(movies.isEmpty()); + } + + //@Test + public void testMoviedbGetImages_String_String() { + } + + //@Test + public void testMoviedbGetImages_3args() { + } + + //@Test + public void testPersonSearch() { + } + + //@Test + public void testPersonGetInfo() { + } + + @Test + public void testPersonGetLatest() { + Person person = tmdb.personGetLatest("en"); + assertFalse(person.getName().equals(MovieDB.UNKNOWN)); + } + + @Test + public void testPersonGetVersion() { + Person person = tmdb.personGetVersion("288", "en"); + assertEquals("Jon Seda", person.getName()); + assertEquals("288", person.getId()); + } + + @Test + public void testPersonGetVersion_withWrongId() { + Person person = tmdb.personGetVersion("0", "en"); + assertEquals(MovieDB.UNKNOWN, person.getName()); + assertEquals(MovieDB.UNKNOWN, person.getId()); + } + + @Test + public void testPersonGetVersion_withNullId() { + Person person = tmdb.personGetVersion((String) null, "en"); + assertEquals(MovieDB.UNKNOWN, person.getName()); + assertEquals(MovieDB.UNKNOWN, person.getId()); + } + + @Test + public void testPersonGetVersion_withEmptyId() { + Person person = tmdb.personGetVersion("", "en"); + assertEquals(MovieDB.UNKNOWN, person.getName()); + assertEquals(MovieDB.UNKNOWN, person.getId()); + } + + @Test + public void testPersonGetVersion_List_String() { + List ids = new ArrayList(); + ids.add("287"); + ids.add("5064"); + List people = tmdb.personGetVersion(ids, "en"); + + assertEquals("Brad Pitt", people.get(0).getName()); + assertEquals("287", people.get(0).getId()); + + assertEquals("Meryl Streep", people.get(1).getName()); + assertEquals("5064", people.get(1).getId()); + } + + @Test + public void testPersonGetVersion_withEmptyList() { + List people = tmdb.personGetVersion(new ArrayList(), "en"); + assertTrue(people.isEmpty()); + } + + @Test + public void testPersonGetVersion_withNullList() { + List people = tmdb.personGetVersion((List) null, "en"); + assertTrue(people.isEmpty()); + } + + //@Test + public void testGetCategories() { + } + + //@Test + public void testFindMovie() { + } + + //@Test + public void testCompareMovies() { + } +} From b4eece7ace43887978da96a9af2890d0a6a32609 Mon Sep 17 00:00:00 2001 From: Mohammed Le Doze Date: Mon, 18 Oct 2010 09:31:35 +0000 Subject: [PATCH 051/207] removed category.setType("") in MovieDbParser.parseCategories so that this field keeps its UNKNOWN value added getDefaultLanguage in TheMovieDb updated javadoc --- .../moviejukebox/themoviedb/TheMovieDb.java | 39 +++++++++++++++++-- .../themoviedb/tools/MovieDbParser.java | 1 - 2 files changed, 36 insertions(+), 4 deletions(-) diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java b/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java index 62077b004..8ea884585 100644 --- a/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java @@ -12,11 +12,10 @@ */ package com.moviejukebox.themoviedb; -import com.moviejukebox.themoviedb.model.Category; - import java.io.UnsupportedEncodingException; import java.net.URLEncoder; import java.util.ArrayList; +import java.util.Arrays; import java.util.Collection; import java.util.HashMap; import java.util.List; @@ -25,12 +24,12 @@ import java.util.logging.ConsoleHandler; import java.util.logging.Level; import java.util.logging.Logger; +import com.moviejukebox.themoviedb.model.Category; import com.moviejukebox.themoviedb.model.MovieDB; import com.moviejukebox.themoviedb.model.Person; import com.moviejukebox.themoviedb.tools.MovieDbParser; import com.moviejukebox.themoviedb.tools.LogFormatter; import com.moviejukebox.themoviedb.tools.WebBrowser; -import java.util.Arrays; /** * This is the main class for the API to connect to TheMovieDb.org. @@ -63,14 +62,27 @@ public class TheMovieDb { public TheMovieDb(String apiKey) { setLogger(Logger.getLogger("TheMovieDB")); + if (!isValidString(apiKey)) { + logger.severe("TheMovieDb was initialized with a wrong API key!"); + } setApiKey(apiKey); } public TheMovieDb(String apiKey, Logger logger) { setLogger(logger); + if (!isValidString(apiKey)) { + logger.severe("TheMovieDb was initialized with a wrong API key!"); + } setApiKey(apiKey); } + /** + * Set proxy parameters. + * @param host proxy host URL + * @param port proxy port + * @param username proxy username + * @param password proxy password + */ public void setProxy(String host, String port, String username, String password) { WebBrowser.setProxyHost(host); WebBrowser.setProxyPort(port); @@ -78,6 +90,11 @@ public class TheMovieDb { WebBrowser.setProxyPassword(password); } + /** + * Set web browser timeout. + * @param webTimeoutConnect + * @param webTimeoutRead + */ public void setTimeout(int webTimeoutConnect, int webTimeoutRead) { WebBrowser.setWebTimeoutConnect(webTimeoutConnect); WebBrowser.setWebTimeoutRead(webTimeoutRead); @@ -100,15 +117,31 @@ public class TheMovieDb { logger.setLevel(Level.ALL); } + /** + * Return the API key. + * @return + */ public String getApiKey() { return apiKey; } + /** + * Set the TMDb API key. + * @param apiKey a valid TMDb API key. + */ public void setApiKey(String apiKey) { this.apiKey = apiKey; tmdbFormatter.addApiKey(apiKey); } + /** + * Return the TMDb default language: en-US. + * @return + */ + public String getDefaultLanguage() { + return defaultLanguage; + } + /** * Searches the database using the movie title passed * diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/tools/MovieDbParser.java b/themoviedbapi/src/com/moviejukebox/themoviedb/tools/MovieDbParser.java index 6eee3ffcf..14eacfa24 100644 --- a/themoviedbapi/src/com/moviejukebox/themoviedb/tools/MovieDbParser.java +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/tools/MovieDbParser.java @@ -478,7 +478,6 @@ public class MovieDbParser { category.setName(element.getAttribute("name")); category.setId(DOMHelper.getValueFromElement(element, "id")); category.setUrl(DOMHelper.getValueFromElement(element, "url")); - category.setType(""); // there are no type in the XML categories.add(category); } } From 76deef5d3bc07ff2ec367ca73607f6e53ce23f34 Mon Sep 17 00:00:00 2001 From: Mohammed Le Doze Date: Mon, 18 Oct 2010 12:51:23 +0000 Subject: [PATCH 052/207] --- themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java b/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java index 8ea884585..9207826e4 100644 --- a/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java @@ -191,7 +191,8 @@ public class TheMovieDb { Map parameters, String language) { List movies = new ArrayList(); - if (!isValidString(orderBy) || (!isValidString(order))) { + if (!isValidString(orderBy) || (!isValidString(order)) + || (parameters == null)) { return movies; } From 773cf589daf79e2e84ea0b535091fd7c1a4e29a7 Mon Sep 17 00:00:00 2001 From: Mohammed Le Doze Date: Mon, 18 Oct 2010 12:51:44 +0000 Subject: [PATCH 053/207] added junit tests --- .../themoviedb/TheMovieDbTest.java | 124 ++++++++++++++++-- 1 file changed, 115 insertions(+), 9 deletions(-) diff --git a/themoviedbapi/test/com/moviejukebox/themoviedb/TheMovieDbTest.java b/themoviedbapi/test/com/moviejukebox/themoviedb/TheMovieDbTest.java index 2f637387d..66b3df34b 100644 --- a/themoviedbapi/test/com/moviejukebox/themoviedb/TheMovieDbTest.java +++ b/themoviedbapi/test/com/moviejukebox/themoviedb/TheMovieDbTest.java @@ -1,9 +1,11 @@ package com.moviejukebox.themoviedb; -import com.moviejukebox.themoviedb.model.Person; +import java.util.Map; import java.util.ArrayList; -import com.moviejukebox.themoviedb.model.MovieDB; import java.util.List; +import com.moviejukebox.themoviedb.model.Person; +import com.moviejukebox.themoviedb.model.MovieDB; +import java.util.HashMap; import org.junit.After; import org.junit.AfterClass; import org.junit.Before; @@ -12,12 +14,13 @@ import org.junit.Test; import static org.junit.Assert.*; /** - * + * JUnit tests for TheMovieDb class. The tester must enter its IMDb API key for + * these tests to work. Require JUnit 4.5. * @author mledoze */ public class TheMovieDbTest { - private static String apikey = ""; + private static String apikey = "41237ccbf3059915ada1ae4cacc2e3b8"; private TheMovieDb tmdb; public TheMovieDbTest() { @@ -45,18 +48,119 @@ public class TheMovieDbTest { assertEquals(apikey, tmdb.getApiKey()); } - //@Test + @Test + public void testGetDefaultLanguage() { + assertEquals("en-US", tmdb.getDefaultLanguage()); + } + + @Test public void testMoviedbSearch() { + String title = "Inception"; + List movies = tmdb.moviedbSearch(title, "en"); + assertFalse(movies.isEmpty()); + assertEquals(title, movies.get(0).getTitle()); } - //@Test - public void testMoviedbBrowse_3args() { + @Test + public void testMoviedbSearch_withWrongTitle(){ + List movies = tmdb.moviedbSearch("à(é!àç'(è!çé(èçéè'(éàç!'(èéàç!(èç'", "en"); + assertTrue(movies.isEmpty()); } - //@Test - public void testMoviedbBrowse_4args() { + @Test + public void testMoviedbSearch_withEmptyTitle(){ + List movies = tmdb.moviedbSearch("", "en"); + assertTrue(movies.isEmpty()); } + @Test + public void testMoviedbSearch_withNullTitle(){ + List movies = tmdb.moviedbSearch((String) null, "en"); + assertTrue(movies.isEmpty()); + } + + + //*** Start moviedbBrowse + @Test + public void testMoviedbBrowseRatingAsc() { + List movies = tmdb.moviedbBrowse("rating", "asc", "en"); + assertFalse(movies.isEmpty()); + } + + @Test + public void testMoviedbBrowseReleaseAsc() { + List movies = tmdb.moviedbBrowse("release", "asc", "en"); + assertFalse(movies.isEmpty()); + } + + @Test + public void testMoviedbBrowseTitleAsc() { + List movies = tmdb.moviedbBrowse("title", "asc", "en"); + assertFalse(movies.isEmpty()); + } + + @Test + public void testMoviedbBrowseRatingDesc() { + List movies = tmdb.moviedbBrowse("rating", "desc", "en"); + assertFalse(movies.isEmpty()); + } + + @Test + public void testMoviedbBrowseReleaseDesc() { + List movies = tmdb.moviedbBrowse("release", "desc", "en"); + assertFalse(movies.isEmpty()); + } + + @Test + public void testMoviedbBrowseTitleDesc() { + List movies = tmdb.moviedbBrowse("title", "desc", "en"); + assertFalse(movies.isEmpty()); + } + + @Test + public void testMoviedbBrowse_withEmptyOrderBy() { + assertTrue(tmdb.moviedbBrowse("", "asc", "en").isEmpty()); + } + + @Test + public void testMoviedbBrowse_withNullOrderBy() { + assertTrue(tmdb.moviedbBrowse((String) null, "asc", "en").isEmpty()); + } + + @Test + public void testMoviedbBrowse_withEmptyOrder() { + assertTrue(tmdb.moviedbBrowse("rating", "", "en").isEmpty()); + } + + @Test + public void testMoviedbBrowse_withNullOrder() { + assertTrue(tmdb.moviedbBrowse("rating", (String) null, "en").isEmpty()); + } + + @Test + public void testMoviedbBrowse_incorrectParameters() { + assertTrue(tmdb.moviedbBrowse("bla", "bla", "en").isEmpty()); + } + + @Test + public void testMoviedbBrowse_withNullParameters() { + assertTrue(tmdb.moviedbBrowse("rating", "asc", (Map) null, "en").isEmpty()); + } + + @Test + public void testMoviedbBrowse_withInvalidParameters() { + Map params = new HashMap(); + params.put("bla", "bla"); + params.put("yo", "yo"); + List movies = tmdb.moviedbBrowse("title", "desc", params, "en"); + + // even if parameters are incorrect we should get the result of + // the search with the default parameters (orderBy and order) so the + // list of movies is not empty + assertFalse(movies.isEmpty()); + } + //*** End moviedbBrowse + //@Test public void testMoviedbImdbLookup() { } @@ -76,6 +180,8 @@ public class TheMovieDbTest { public void testMoviedbGetLatest() { MovieDB movie = tmdb.moviedbGetLatest("en"); assertFalse(movie.getTitle().equals(MovieDB.UNKNOWN)); + assertFalse(movie.getId().equals(MovieDB.UNKNOWN)); + assertFalse(movie.getImdb().equals(MovieDB.UNKNOWN)); } /** From ffd8a6b391e84783702cc6e70a49f3f3fe2adaef Mon Sep 17 00:00:00 2001 From: Mohammed Le Doze Date: Mon, 18 Oct 2010 12:53:11 +0000 Subject: [PATCH 054/207] removed api key --- .../test/com/moviejukebox/themoviedb/TheMovieDbTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themoviedbapi/test/com/moviejukebox/themoviedb/TheMovieDbTest.java b/themoviedbapi/test/com/moviejukebox/themoviedb/TheMovieDbTest.java index 66b3df34b..99458bf50 100644 --- a/themoviedbapi/test/com/moviejukebox/themoviedb/TheMovieDbTest.java +++ b/themoviedbapi/test/com/moviejukebox/themoviedb/TheMovieDbTest.java @@ -20,7 +20,7 @@ import static org.junit.Assert.*; */ public class TheMovieDbTest { - private static String apikey = "41237ccbf3059915ada1ae4cacc2e3b8"; + private static String apikey = ""; private TheMovieDb tmdb; public TheMovieDbTest() { From f35ac9d80e5907c107177a102d287f966fc26b34 Mon Sep 17 00:00:00 2001 From: Mohammed Le Doze Date: Tue, 19 Oct 2010 10:36:33 +0000 Subject: [PATCH 055/207] tested if parameters are empty in moviedb.browse --- .../src/com/moviejukebox/themoviedb/TheMovieDb.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java b/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java index 9207826e4..c7039194e 100644 --- a/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java @@ -213,9 +213,11 @@ public class TheMovieDb { validParameters.add("countries"); String url = "order_by=" + orderBy + "&order=" + order; - for (String key : validParameters) { - if (parameters.containsKey(key)) { - url += "&" + key + "=" + parameters.get(key); + if(!parameters.isEmpty()) { + for (String key : validParameters) { + if (parameters.containsKey(key)) { + url += "&" + key + "=" + parameters.get(key); + } } } From 827ccd77bf2b134d082dd0e41b2b38255d0cb916 Mon Sep 17 00:00:00 2001 From: Mohammed Le Doze Date: Tue, 19 Oct 2010 10:38:09 +0000 Subject: [PATCH 056/207] added junits tests code coverage stats: - total classes covered: 80% - total lines covered: 70% - coverage for TheMovieDb: 74% --- .../themoviedb/TheMovieDbTest.java | 152 +++++++++++++++--- 1 file changed, 133 insertions(+), 19 deletions(-) diff --git a/themoviedbapi/test/com/moviejukebox/themoviedb/TheMovieDbTest.java b/themoviedbapi/test/com/moviejukebox/themoviedb/TheMovieDbTest.java index 99458bf50..afd322742 100644 --- a/themoviedbapi/test/com/moviejukebox/themoviedb/TheMovieDbTest.java +++ b/themoviedbapi/test/com/moviejukebox/themoviedb/TheMovieDbTest.java @@ -1,5 +1,6 @@ package com.moviejukebox.themoviedb; +import com.moviejukebox.themoviedb.model.Category; import java.util.Map; import java.util.ArrayList; import java.util.List; @@ -62,24 +63,23 @@ public class TheMovieDbTest { } @Test - public void testMoviedbSearch_withWrongTitle(){ + public void testMoviedbSearch_withWrongTitle() { List movies = tmdb.moviedbSearch("à(é!àç'(è!çé(èçéè'(éàç!'(èéàç!(èç'", "en"); assertTrue(movies.isEmpty()); } @Test - public void testMoviedbSearch_withEmptyTitle(){ + public void testMoviedbSearch_withEmptyTitle() { List movies = tmdb.moviedbSearch("", "en"); assertTrue(movies.isEmpty()); } @Test - public void testMoviedbSearch_withNullTitle(){ + public void testMoviedbSearch_withNullTitle() { List movies = tmdb.moviedbSearch((String) null, "en"); assertTrue(movies.isEmpty()); } - //*** Start moviedbBrowse @Test public void testMoviedbBrowseRatingAsc() { @@ -161,21 +161,82 @@ public class TheMovieDbTest { } //*** End moviedbBrowse - //@Test + @Test public void testMoviedbImdbLookup() { + MovieDB movie = tmdb.moviedbImdbLookup("tt0137523", "en"); + assertEquals("Fight Club", movie.getTitle()); + assertEquals("550", movie.getId()); + assertEquals("tt0137523", movie.getImdb()); + assertEquals("138", movie.getRuntime()); } - //@Test - public void testMoviedbGetInfo_String_String() { + @Test + public void testMoviedbImdbLookup_withEmptyId() { + MovieDB movie = tmdb.moviedbImdbLookup("", "en"); + assertTrue(movie.getTitle().equals(MovieDB.UNKNOWN)); + assertTrue(movie.getId().equals(MovieDB.UNKNOWN)); + assertTrue(movie.getImdb().equals(MovieDB.UNKNOWN)); } - //@Test - public void testMoviedbGetInfo_3args() { + @Test + public void testMoviedbImdbLookup_withNullId() { + MovieDB movie = tmdb.moviedbImdbLookup((String) null, "en"); + assertTrue(movie.getTitle().equals(MovieDB.UNKNOWN)); + assertTrue(movie.getId().equals(MovieDB.UNKNOWN)); + assertTrue(movie.getImdb().equals(MovieDB.UNKNOWN)); + } + + @Test + public void testMoviedbGetInfo() { + MovieDB movie = tmdb.moviedbGetInfo("187", "en"); + assertEquals("Sin City", movie.getTitle()); + assertEquals("187", movie.getId()); + assertEquals("tt0401792", movie.getImdb()); + assertEquals("124", movie.getRuntime()); + + } + + @Test + public void testMoviedbGetInfo_withExistingMovie() { + MovieDB movie = tmdb.moviedbGetInfo("200", new MovieDB(), "en"); + assertEquals("Star Trek: Insurrection", movie.getTitle()); + assertEquals("200", movie.getId()); + assertEquals("tt0120844", movie.getImdb()); + assertEquals("103", movie.getRuntime()); + } + + @Test + public void testMoviedbGetInfo_withNullMovie() { + MovieDB movie = tmdb.moviedbGetInfo("306", null, "en"); + assertEquals("Beverly Hills Cop III", movie.getTitle()); + assertEquals("306", movie.getId()); + assertEquals("tt0109254", movie.getImdb()); + assertEquals("104", movie.getRuntime()); + } + + @Test + public void testMoviedbGetInfo_withNullMovieAndEmptyId() { + MovieDB movie = tmdb.moviedbGetInfo("", null, "en"); + assertNull(movie); + } + + @Test + public void testMoviedbGetInfo_withNullMovieAndNullId() { + MovieDB movie = tmdb.moviedbGetInfo((String) null, null, "en"); + assertNull(movie); + } + + @Test + public void testMoviedbGetInfo_withInitializedMovie() { + MovieDB input = new MovieDB(); + String title = "The 300 Spartans"; + String id = "19972"; + input.setTitle(title); + MovieDB movie = tmdb.moviedbGetInfo(id, input, "en"); + assertEquals(title, movie.getTitle()); + assertEquals(id, movie.getId()); } - /** - * Test of moviedbGetLatest method, of class TheMovieDb. - */ @Test public void testMoviedbGetLatest() { MovieDB movie = tmdb.moviedbGetLatest("en"); @@ -184,9 +245,6 @@ public class TheMovieDbTest { assertFalse(movie.getImdb().equals(MovieDB.UNKNOWN)); } - /** - * Test of moviedbGetVersion method, of class TheMovieDb. - */ @Test public void testMoviedbGetVersion_String_String() { MovieDB movie = tmdb.moviedbGetVersion("155", "en"); @@ -253,12 +311,46 @@ public class TheMovieDbTest { public void testMoviedbGetImages_3args() { } - //@Test + @Test public void testPersonSearch() { + Person person = tmdb.personSearch("Tom Cruise", "en"); + assertEquals("Tom Cruise", person.getName()); + assertEquals("500", person.getId()); } - //@Test + @Test + public void testPersonSearch_withEmptyName() { + Person person = tmdb.personSearch("", "en"); + assertTrue(person.getName().equals(MovieDB.UNKNOWN)); + assertTrue(person.getId().equals(MovieDB.UNKNOWN)); + } + + @Test + public void testPersonSearch_withNullName() { + Person person = tmdb.personSearch((String) null, "en"); + assertTrue(person.getName().equals(MovieDB.UNKNOWN)); + assertTrue(person.getId().equals(MovieDB.UNKNOWN)); + } + + @Test public void testPersonGetInfo() { + Person person = tmdb.personGetInfo("260", "en"); + assertEquals("Marco Pérez", person.getName()); + assertEquals("260", person.getId()); + } + + @Test + public void testPersonGetInfo_withEmptyId() { + Person person = tmdb.personGetInfo("", "en"); + assertTrue(person.getName().equals(MovieDB.UNKNOWN)); + assertTrue(person.getId().equals(MovieDB.UNKNOWN)); + } + + @Test + public void testPersonGetInfo_withNullId() { + Person person = tmdb.personGetInfo((String) null, "en"); + assertTrue(person.getName().equals(MovieDB.UNKNOWN)); + assertTrue(person.getId().equals(MovieDB.UNKNOWN)); } @Test @@ -321,15 +413,37 @@ public class TheMovieDbTest { assertTrue(people.isEmpty()); } - //@Test + @Test public void testGetCategories() { + List genres = tmdb.getCategories("en"); + assertFalse(genres.isEmpty()); + assertEquals(30, genres.size()); } //@Test public void testFindMovie() { } - //@Test + @Test public void testCompareMovies() { + MovieDB movie = tmdb.moviedbGetInfo("27205", "en"); + assertTrue(TheMovieDb.compareMovies(movie, "Inception", "2010")); + } + + //@Test + public void testCompareMovies_sameTitleAndDifferentYear() { + MovieDB movie = tmdb.moviedbGetInfo("27205", "en"); + assertTrue(TheMovieDb.compareMovies(movie, "Inception", "1999")); + } + + //@Test + public void testCompareMovies_differentTitleAndSameYear() { + MovieDB movie = tmdb.moviedbGetInfo("27205", "en"); + assertTrue(TheMovieDb.compareMovies(movie, "xxx", "2010")); + } + + @Test + public void testCompareMovies_wrongArgument() { + assertFalse(TheMovieDb.compareMovies(null, "", "2010")); } } From 2ec7c56e3531d5090c68298ac51878991e95bb61 Mon Sep 17 00:00:00 2001 From: Omertron Date: Thu, 4 Nov 2010 13:20:51 +0000 Subject: [PATCH 057/207] Fix for movies without a year not being found --- themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java b/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java index c7039194e..5dd7be1cf 100644 --- a/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java @@ -483,9 +483,7 @@ public class TheMovieDb { * @return The matching movie */ public static MovieDB findMovie(Collection movieList, String title, String year) { - if ((movieList == null) || (movieList.isEmpty()) - || (!isValidString(title)) - || (!isValidString(year))) { + if ((movieList == null) || (movieList.isEmpty()) || (!isValidString(title))) { return null; } From ec442572ba77903e04552d24ede359de29e6ade6 Mon Sep 17 00:00:00 2001 From: Omertron Date: Fri, 26 Nov 2010 15:36:57 +0000 Subject: [PATCH 058/207] Added getTranslations method --- .../moviejukebox/themoviedb/TheMovieDb.java | 610 +++++++++--------- .../themoviedb/model/Category.java | 2 +- .../themoviedb/model/Language.java | 65 ++ .../themoviedb/tools/MovieDbParser.java | 475 ++++++++------ 4 files changed, 650 insertions(+), 502 deletions(-) create mode 100644 themoviedbapi/src/com/moviejukebox/themoviedb/model/Language.java diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java b/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java index 5dd7be1cf..f27eb3caa 100644 --- a/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java @@ -25,6 +25,7 @@ import java.util.logging.Level; import java.util.logging.Logger; import com.moviejukebox.themoviedb.model.Category; +import com.moviejukebox.themoviedb.model.Language; import com.moviejukebox.themoviedb.model.MovieDB; import com.moviejukebox.themoviedb.model.Person; import com.moviejukebox.themoviedb.tools.MovieDbParser; @@ -41,25 +42,140 @@ import com.moviejukebox.themoviedb.tools.WebBrowser; */ public class TheMovieDb { + /** + * Compare the MovieDB object with a title & year + * @param moviedb The moviedb object to compare too + * @param title The title of the movie to compare + * @param year The year of the movie to compare + * @return True if there is a match, False otherwise. + */ + public static boolean compareMovies(MovieDB moviedb, String title, String year) { + if ((moviedb == null) || (!isValidString(title))) { + return false; + } + + if (isValidString(year)) { + if (isValidString(moviedb.getReleaseDate())) { + // Compare with year + String movieYear = moviedb.getReleaseDate().substring(0, 4); + if (movieYear.equals(year)) { + if (moviedb.getOriginalName().equalsIgnoreCase(title)) { + return true; + } + + if (moviedb.getTitle().equalsIgnoreCase(title)) { + return true; + } + + // Try matching the alternative name too + if (moviedb.getAlternativeName().equalsIgnoreCase(title)) { + return true; + } + } + } + } else { + // Compare without year + if (moviedb.getOriginalName().equalsIgnoreCase(title)) { + return true; + } + + if (moviedb.getTitle().equalsIgnoreCase(title)) { + return true; + } + + // Try matching the alternative name too + if (moviedb.getAlternativeName().equalsIgnoreCase(title)) { + return true; + } + } + return false; + } + /** + * Search a list of movies and return the one that matches the title & year + * @param movieList The list of movies to search + * @param title The title to search for + * @param year The year of the title to search for + * @return The matching movie + */ + public static MovieDB findMovie(Collection movieList, String title, String year) { + if ((movieList == null) || (movieList.isEmpty()) || (!isValidString(title))) { + return null; + } + + for (MovieDB moviedb : movieList) { + if (compareMovies(moviedb, title, year)) { + return moviedb; + } + } + + return null; + } + /** + * Check the string passed to see if it contains a value. + * @param testString The string to test + * @return False if the string is empty, null or UNKNOWN, True otherwise + */ + private static boolean isValidString(String testString) { + if ((testString == null) + || (testString.trim().equals("")) + || (testString.equalsIgnoreCase(MovieDB.UNKNOWN))) { + return false; + } + return true; + } private String apiKey; private static Logger logger = null; private static LogFormatter tmdbFormatter = new LogFormatter(); + + /* + * API Methods + * http://api.themoviedb.org/2.1 + * Note: This is currently a read-only interface and as such, no write methods exist. + */ + private static ConsoleHandler tmdbConsoleHandler = new ConsoleHandler(); + private static final String apiSite = "http://api.themoviedb.org/2.1/"; private static final String defaultLanguage = "en-US"; - private static final String GENRES_GET_LIST = "Genres.getList"; - private static final String MOVIE_BROWSE = "Movie.browse"; - private static final String MOVIE_GET_INFO = "Movie.getInfo"; - private static final String MOVIE_GET_IMAGES = "Movie.getImages"; - private static final String MOVIE_GET_LATEST = "Movie.getLatest"; - private static final String MOVIE_GET_VERSION = "Movie.getVersion"; - private static final String MOVIE_IMDB_LOOKUP = "Movie.imdbLookup"; - private static final String MOVIE_SEARCH = "Movie.search"; - private static final String PERSON_GET_INFO = "Person.getInfo"; - private static final String PERSON_GET_LATEST = "Person.getLatest"; - private static final String PERSON_GET_VERSION = "Person.getVersion"; - private static final String PERSON_SEARCH = "Person.search"; + /* + * Media + */ + @SuppressWarnings("unused") + private static final String MEDIA_GET_INFO = "Media.getInfo"; + + /* + * Movies + */ + private static final String MOVIE_BROWSE = "Movie.browse"; + private static final String MOVIE_GET_IMAGES = "Movie.getImages"; + private static final String MOVIE_GET_INFO = "Movie.getInfo"; + private static final String MOVIE_GET_LATEST = "Movie.getLatest"; + private static final String MOVIE_GET_TRANSLATIONS = "Movie.getTranslations"; + private static final String MOVIE_GET_VERSION = "Movie.getVersion"; + private static final String MOVIE_IMDB_LOOKUP = "Movie.imdbLookup"; + private static final String MOVIE_SEARCH = "Movie.search"; + + /* + * People + */ + private static final String PERSON_GET_INFO = "Person.getInfo"; + private static final String PERSON_GET_LATEST = "Person.getLatest"; + private static final String PERSON_GET_VERSION = "Person.getVersion"; + private static final String PERSON_SEARCH = "Person.search"; + /* + * Misc + */ + private static final String GENRES_GET_LIST = "Genres.getList"; + + public static Logger getLogger() { + return logger; + } + + /** + * Constructor with default logger. + * @param apiKey + */ public TheMovieDb(String apiKey) { setLogger(Logger.getLogger("TheMovieDB")); if (!isValidString(apiKey)) { @@ -77,44 +193,55 @@ public class TheMovieDb { } /** - * Set proxy parameters. - * @param host proxy host URL - * @param port proxy port - * @param username proxy username - * @param password proxy password + * Build comma separated ids for Movie.getLatest and Movie.getVersion. + * @param ids a List of ids + * @return */ - public void setProxy(String host, String port, String username, String password) { - WebBrowser.setProxyHost(host); - WebBrowser.setProxyPort(port); - WebBrowser.setProxyUsername(username); - WebBrowser.setProxyPassword(password); + private String buildIds(List ids) { + String s = ""; + for (int i = 0; i < ids.size(); i++) { + if (i == 0) { + s += ids.get(i); + continue; + } + s += "," + ids.get(i); + } + return s; } /** - * Set web browser timeout. - * @param webTimeoutConnect - * @param webTimeoutRead + * Build the URL that is used to get the XML from TMDb. + * + * @param prefix The search prefix before the movie title + * @param language The two digit language code. E.g. en=English + * @param searchTerm The search key to use, e.g. movie title or IMDb ID + * @return The search URL */ - public void setTimeout(int webTimeoutConnect, int webTimeoutRead) { - WebBrowser.setWebTimeoutConnect(webTimeoutConnect); - WebBrowser.setWebTimeoutRead(webTimeoutRead); - } + private String buildUrl(String prefix, String searchTerm, String language) { + String url = apiSite + prefix + "/" + language + "/xml/" + apiKey; - public static Logger getLogger() { - return logger; - } - - public void setLogger(Logger logger) { - if (logger == null) { - return; + if (!isValidString(searchTerm)) { + return url; } - TheMovieDb.logger = logger; - tmdbConsoleHandler.setFormatter(tmdbFormatter); - tmdbConsoleHandler.setLevel(Level.FINE); - logger.addHandler(tmdbConsoleHandler); - logger.setUseParentHandlers(false); - logger.setLevel(Level.ALL); + String encodedSearchTerm; + + try { + encodedSearchTerm = URLEncoder.encode(searchTerm, "UTF-8"); + } catch (UnsupportedEncodingException e) { + encodedSearchTerm = searchTerm; + } + + if (prefix.equals(MOVIE_BROWSE)) { + url += "?"; + } else { + url += "/"; + } + + url += encodedSearchTerm; + + logger.finest("Search URL: " + url); + return url; } /** @@ -126,12 +253,12 @@ public class TheMovieDb { } /** - * Set the TMDb API key. - * @param apiKey a valid TMDb API key. + * Retrieve a list of valid genres within TMDb. + * @param language the two digit language code. E.g. en=English + * @return */ - public void setApiKey(String apiKey) { - this.apiKey = apiKey; - tmdbFormatter.addApiKey(apiKey); + public List getCategories(String language) { + return MovieDbParser.parseCategories(this.buildUrl(GENRES_GET_LIST, "", language)); } /** @@ -142,36 +269,8 @@ public class TheMovieDb { return defaultLanguage; } - /** - * Searches the database using the movie title passed - * - * @param movieTitle The title to search for - * @param language The two digit language code. E.g. en=English - * @return A movie bean with the data extracted - */ - public List moviedbSearch(String movieTitle, String language) { - // If the title is null, then exit - if (!isValidString(movieTitle)) { - return new ArrayList(); - } - - String searchUrl = buildUrl(MOVIE_SEARCH, movieTitle, language); - return MovieDbParser.parseMovies(searchUrl); - } - - /** - * Browse the database using the default parameters. - * http://api.themoviedb.org/2.1/methods/Movie.browse - * - * @param orderBy either rating, - * release or title - * @param order how results are ordered. Either asc or - * desc - * @param language the two digit language code. E.g. en=English - * @return a list of MovieDB objects - */ - public List moviedbBrowse(String orderBy, String order, String language) { - return this.moviedbBrowse(orderBy, order, new HashMap(), language); + public List getTranslations(String movieId, String language) { + return MovieDbParser.parseLanguages(this.buildUrl(MOVIE_GET_TRANSLATIONS, movieId, language)); } /** @@ -227,35 +326,51 @@ public class TheMovieDb { } /** - * Searches the database using the IMDb reference - * - * @param imdbID IMDb reference, must include the "tt" at the start - * @param language The two digit language code. E.g. en=English - * @return A movie bean with the data extracted + * Browse the database using the default parameters. + * http://api.themoviedb.org/2.1/methods/Movie.browse + * + * @param orderBy either rating, + * release or title + * @param order how results are ordered. Either asc or + * desc + * @param language the two digit language code. E.g. en=English + * @return a list of MovieDB objects */ - public MovieDB moviedbImdbLookup(String imdbID, String language) { - MovieDB movie = new MovieDB(); + public List moviedbBrowse(String orderBy, String order, String language) { + return this.moviedbBrowse(orderBy, order, new HashMap(), language); + } - // If the imdbID is null, then exit - if (!isValidString(imdbID)) { + /** + * The Movie.getImages method is used to retrieve all of the backdrops and + * posters for a particular movie. This is useful to scan for updates, or + * new images if that's all you're after. + * @param movieId the TMDb or IMDB ID (starting with tt) of the movie you + * are searching for. + * @param movie a MovieDB object + * @param language the two digit language code. E.g. en=English + * @return + */ + public MovieDB moviedbGetImages(String movieId, MovieDB movie, String language) { + // If the searchTerm is null, then exit + if (!isValidString(movieId)) { return movie; } - String searchUrl = buildUrl(MOVIE_IMDB_LOOKUP, imdbID, language); + String searchUrl = buildUrl(MOVIE_GET_IMAGES, movieId, language); return MovieDbParser.parseMovie(searchUrl); } /** - * Passes a null MovieDB object to the full function - * - * @param tmdbID TheMovieDB ID of the movie to get the information for - * @param language The two digit language code. E.g. en=English - * @return A movie bean with all of the information + * The Movie.getImages method is used to retrieve all of the backdrops and + * posters for a particular movie. This is useful to scan for updates, or + * new images if that's all you're after. + * @param movieId the TMDb or IMDB ID (starting with tt) of the movie you + * are searching for. + * @param language the two digit language code. E.g. en=English + * @return */ - public MovieDB moviedbGetInfo(String tmdbID, String language) { - MovieDB movie = null; - movie = moviedbGetInfo(tmdbID, movie, language); - return movie; + public MovieDB moviedbGetImages(String movieId, String language) { + return moviedbGetImages(movieId, new MovieDB(), language); } /** @@ -287,6 +402,19 @@ public class TheMovieDb { return movie; } + /** + * Passes a null MovieDB object to the full function + * + * @param tmdbID TheMovieDB ID of the movie to get the information for + * @param language The two digit language code. E.g. en=English + * @return A movie bean with all of the information + */ + public MovieDB moviedbGetInfo(String tmdbID, String language) { + MovieDB movie = null; + movie = moviedbGetInfo(tmdbID, movie, language); + return movie; + } + /** * The Movie.getLatest method is a simple method. It returns the ID of the * last movie created in the database. This is useful if you are scanning @@ -300,25 +428,6 @@ public class TheMovieDb { return MovieDbParser.parseLatestMovie(buildUrl(MOVIE_GET_LATEST, "", language)); } - /** - * The Movie.getVersion method is used to retrieve the last modified time - * along with the current version number of the called object(s). This is - * useful if you've already called the object sometime in the past and - * simply want to do a quick check for updates.
- * The MovieDB object returned only has its title, TMDb id, IMDB id, - * version and last modified date initialized. - * @param movieId the TMDb ID or IMDB ID of the movie - * @param language the two digit language code. E.g. en=English - * @return - */ - public MovieDB moviedbGetVersion(String movieId, String language) { - List movies = this.moviedbGetVersion(Arrays.asList(movieId), language); - if (movies.isEmpty()) { - return new MovieDB(); - } - return movies.get(0); - } - /** * The Movie.getVersion method is used to retrieve the last modified time * along with the current version number of the called object(s). This is @@ -346,53 +455,58 @@ public class TheMovieDb { } /** - * The Movie.getImages method is used to retrieve all of the backdrops and - * posters for a particular movie. This is useful to scan for updates, or - * new images if that's all you're after. - * @param movieId the TMDb or IMDB ID (starting with tt) of the movie you - * are searching for. + * The Movie.getVersion method is used to retrieve the last modified time + * along with the current version number of the called object(s). This is + * useful if you've already called the object sometime in the past and + * simply want to do a quick check for updates.
+ * The MovieDB object returned only has its title, TMDb id, IMDB id, + * version and last modified date initialized. + * @param movieId the TMDb ID or IMDB ID of the movie * @param language the two digit language code. E.g. en=English * @return */ - public MovieDB moviedbGetImages(String movieId, String language) { - return moviedbGetImages(movieId, new MovieDB(), language); + public MovieDB moviedbGetVersion(String movieId, String language) { + List movies = this.moviedbGetVersion(Arrays.asList(movieId), language); + if (movies.isEmpty()) { + return new MovieDB(); + } + return movies.get(0); } /** - * The Movie.getImages method is used to retrieve all of the backdrops and - * posters for a particular movie. This is useful to scan for updates, or - * new images if that's all you're after. - * @param movieId the TMDb or IMDB ID (starting with tt) of the movie you - * are searching for. - * @param movie a MovieDB object - * @param language the two digit language code. E.g. en=English - * @return + * Searches the database using the IMDb reference + * + * @param imdbID IMDb reference, must include the "tt" at the start + * @param language The two digit language code. E.g. en=English + * @return A movie bean with the data extracted */ - public MovieDB moviedbGetImages(String movieId, MovieDB movie, String language) { - // If the searchTerm is null, then exit - if (!isValidString(movieId)) { + public MovieDB moviedbImdbLookup(String imdbID, String language) { + MovieDB movie = new MovieDB(); + + // If the imdbID is null, then exit + if (!isValidString(imdbID)) { return movie; } - String searchUrl = buildUrl(MOVIE_GET_IMAGES, movieId, language); + String searchUrl = buildUrl(MOVIE_IMDB_LOOKUP, imdbID, language); return MovieDbParser.parseMovie(searchUrl); } /** - * The Person.search method is used to search for an actor, actress or production member. - * http://api.themoviedb.org/2.1/methods/Person.search + * Searches the database using the movie title passed * - * @param personName - * @param language - * @return + * @param movieTitle The title to search for + * @param language The two digit language code. E.g. en=English + * @return A movie bean with the data extracted */ - public Person personSearch(String personName, String language) { - if (!isValidString(personName)) { - return new Person(); + public List moviedbSearch(String movieTitle, String language) { + // If the title is null, then exit + if (!isValidString(movieTitle)) { + return new ArrayList(); } - String searchUrl = buildUrl(PERSON_SEARCH, personName, language); - return MovieDbParser.parsePersonInfo(searchUrl); + String searchUrl = buildUrl(MOVIE_SEARCH, movieTitle, language); + return MovieDbParser.parseMovies(searchUrl); } /** @@ -423,6 +537,25 @@ public class TheMovieDb { return MovieDbParser.parseLatestPerson(buildUrl(PERSON_GET_LATEST, "", language)); } + /** + * The Person.getVersion method is used to retrieve the last modified time + * along with the current version number of the called object(s). This is + * useful if you've already called the object sometime in the past and + * simply want to do a quick check for updates. + * @param personIDs one or multiple Person TMDb ids + * @param language the two digit language code. E.g. en=English + * @return + */ + public List personGetVersion(List personIDs, String language) { + if ((personIDs == null) || (personIDs.isEmpty())) { + logger.warning("There are no Person ids!"); + return new ArrayList(); + } + + String searchUrl = buildUrl(PERSON_GET_VERSION, this.buildIds(personIDs), language); + return MovieDbParser.parsePersonGetVersion(searchUrl); + } + /** * The Person.getVersion method is used to retrieve the last modified time * along with the current version number of the called object(s). This is @@ -448,166 +581,65 @@ public class TheMovieDb { } /** - * The Person.getVersion method is used to retrieve the last modified time - * along with the current version number of the called object(s). This is - * useful if you've already called the object sometime in the past and - * simply want to do a quick check for updates. - * @param personIDs one or multiple Person TMDb ids - * @param language the two digit language code. E.g. en=English + * The Person.search method is used to search for an actor, actress or production member. + * http://api.themoviedb.org/2.1/methods/Person.search + * + * @param personName + * @param language * @return */ - public List personGetVersion(List personIDs, String language) { - if ((personIDs == null) || (personIDs.isEmpty())) { - logger.warning("There are no Person ids!"); - return new ArrayList(); + public Person personSearch(String personName, String language) { + if (!isValidString(personName)) { + return new Person(); } - String searchUrl = buildUrl(PERSON_GET_VERSION, this.buildIds(personIDs), language); - return MovieDbParser.parsePersonGetVersion(searchUrl); + String searchUrl = buildUrl(PERSON_SEARCH, personName, language); + return MovieDbParser.parsePersonInfo(searchUrl); } /** - * Retrieve a list of valid genres within TMDb. - * @param language the two digit language code. E.g. en=English - * @return + * Set the TMDb API key. + * @param apiKey a valid TMDb API key. */ - public List getCategories(String language) { - return MovieDbParser.parseCategories(this.buildUrl(GENRES_GET_LIST, "", language)); + public void setApiKey(String apiKey) { + this.apiKey = apiKey; + tmdbFormatter.addApiKey(apiKey); + } + + public void setLogger(Logger logger) { + if (logger == null) { + return; + } + + TheMovieDb.logger = logger; + tmdbConsoleHandler.setFormatter(tmdbFormatter); + tmdbConsoleHandler.setLevel(Level.FINE); + logger.addHandler(tmdbConsoleHandler); + logger.setUseParentHandlers(false); + logger.setLevel(Level.ALL); } /** - * Search a list of movies and return the one that matches the title & year - * @param movieList The list of movies to search - * @param title The title to search for - * @param year The year of the title to search for - * @return The matching movie + * Set proxy parameters. + * @param host proxy host URL + * @param port proxy port + * @param username proxy username + * @param password proxy password */ - public static MovieDB findMovie(Collection movieList, String title, String year) { - if ((movieList == null) || (movieList.isEmpty()) || (!isValidString(title))) { - return null; - } - - for (MovieDB moviedb : movieList) { - if (compareMovies(moviedb, title, year)) { - return moviedb; - } - } - - return null; + public void setProxy(String host, String port, String username, String password) { + WebBrowser.setProxyHost(host); + WebBrowser.setProxyPort(port); + WebBrowser.setProxyUsername(username); + WebBrowser.setProxyPassword(password); } /** - * Compare the MovieDB object with a title & year - * @param moviedb The moviedb object to compare too - * @param title The title of the movie to compare - * @param year The year of the movie to compare - * @return True if there is a match, False otherwise. + * Set web browser timeout. + * @param webTimeoutConnect + * @param webTimeoutRead */ - public static boolean compareMovies(MovieDB moviedb, String title, String year) { - if ((moviedb == null) || (!isValidString(title))) { - return false; - } - - if (isValidString(year)) { - if (isValidString(moviedb.getReleaseDate())) { - // Compare with year - String movieYear = moviedb.getReleaseDate().substring(0, 4); - if (movieYear.equals(year)) { - if (moviedb.getOriginalName().equalsIgnoreCase(title)) { - return true; - } - - if (moviedb.getTitle().equalsIgnoreCase(title)) { - return true; - } - - // Try matching the alternative name too - if (moviedb.getAlternativeName().equalsIgnoreCase(title)) { - return true; - } - } - } - } else { - // Compare without year - if (moviedb.getOriginalName().equalsIgnoreCase(title)) { - return true; - } - - if (moviedb.getTitle().equalsIgnoreCase(title)) { - return true; - } - - // Try matching the alternative name too - if (moviedb.getAlternativeName().equalsIgnoreCase(title)) { - return true; - } - } - return false; - } - - /** - * Build the URL that is used to get the XML from TMDb. - * - * @param prefix The search prefix before the movie title - * @param language The two digit language code. E.g. en=English - * @param searchTerm The search key to use, e.g. movie title or IMDb ID - * @return The search URL - */ - private String buildUrl(String prefix, String searchTerm, String language) { - String url = apiSite + prefix + "/" + language + "/xml/" + apiKey; - - if (!isValidString(searchTerm)) { - return url; - } - - String encodedSearchTerm; - - try { - encodedSearchTerm = URLEncoder.encode(searchTerm, "UTF-8"); - } catch (UnsupportedEncodingException e) { - encodedSearchTerm = searchTerm; - } - - if (prefix.equals(MOVIE_BROWSE)) { - url += "?"; - } else { - url += "/"; - } - - url += encodedSearchTerm; - - logger.finest("Search URL: " + url); - return url; - } - - /** - * Build comma separated ids for Movie.getLatest and Movie.getVersion. - * @param ids a List of ids - * @return - */ - private String buildIds(List ids) { - String s = ""; - for (int i = 0; i < ids.size(); i++) { - if (i == 0) { - s += ids.get(i); - continue; - } - s += "," + ids.get(i); - } - return s; - } - - /** - * Check the string passed to see if it contains a value. - * @param testString The string to test - * @return False if the string is empty, null or UNKNOWN, True otherwise - */ - private static boolean isValidString(String testString) { - if ((testString == null) - || (testString.trim().equals("")) - || (testString.equalsIgnoreCase(MovieDB.UNKNOWN))) { - return false; - } - return true; + public void setTimeout(int webTimeoutConnect, int webTimeoutRead) { + WebBrowser.setWebTimeoutConnect(webTimeoutConnect); + WebBrowser.setWebTimeoutRead(webTimeoutRead); } } diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/model/Category.java b/themoviedbapi/src/com/moviejukebox/themoviedb/model/Category.java index aaf589d1b..7cf867642 100644 --- a/themoviedbapi/src/com/moviejukebox/themoviedb/model/Category.java +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/model/Category.java @@ -13,7 +13,7 @@ package com.moviejukebox.themoviedb.model; /** - * Category from the MovieDB.org + * Category from TheMovieDB.org * * @author Stuart.Boston * diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/model/Language.java b/themoviedbapi/src/com/moviejukebox/themoviedb/model/Language.java new file mode 100644 index 000000000..2994b9cde --- /dev/null +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/model/Language.java @@ -0,0 +1,65 @@ +/* + * Copyright (c) 2004-2010 YAMJ Members + * http://code.google.com/p/moviejukebox/people/list + * + * Web: http://code.google.com/p/moviejukebox/ + * + * This software is licensed under a Creative Commons License + * See this page: http://code.google.com/p/moviejukebox/wiki/License + * + * For any reuse or distribution, you must make clear to others the + * license terms of this work. + */ +package com.moviejukebox.themoviedb.model; + +/** + * Language from TheMovieDB.org + * @author stuart.boston + * + */ +public class Language { + + private static final String UNKNOWN = MovieDB.UNKNOWN; + + private String isoCode = UNKNOWN; // The iso 639.1 Language code + private String englishName = UNKNOWN; + private String nativeName = UNKNOWN; + + public Language() { + this.isoCode = UNKNOWN; + this.englishName = UNKNOWN; + this.nativeName = UNKNOWN; + } + + public Language(String isoCode, String englishName, String nativeName) { + this.isoCode = isoCode; + this.englishName = englishName; + this.nativeName = nativeName; + } + + public String getEnglishName() { + return englishName; + } + + public String getIsoCode() { + return isoCode; + } + + public String getNativeName() { + return nativeName; + } + + public void setEnglishName(String englishName) { + this.englishName = englishName; + } + + public void setIsoCode(String isoCode) { + this.isoCode = isoCode; + } + + public void setNativeName(String nativeName) { + this.nativeName = nativeName; + } + + +} diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/tools/MovieDbParser.java b/themoviedbapi/src/com/moviejukebox/themoviedb/tools/MovieDbParser.java index 14eacfa24..4249428b2 100644 --- a/themoviedbapi/src/com/moviejukebox/themoviedb/tools/MovieDbParser.java +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/tools/MovieDbParser.java @@ -26,6 +26,7 @@ import com.moviejukebox.themoviedb.model.Artwork; import com.moviejukebox.themoviedb.model.Category; import com.moviejukebox.themoviedb.model.Country; import com.moviejukebox.themoviedb.model.Filmography; +import com.moviejukebox.themoviedb.model.Language; import com.moviejukebox.themoviedb.model.MovieDB; import com.moviejukebox.themoviedb.model.Person; import com.moviejukebox.themoviedb.model.Studio; @@ -35,46 +36,145 @@ public class MovieDbParser { static Logger logger = TheMovieDb.getLogger(); /** - * Returns a list of MovieDB object parsed from the DOM Document - * even if there is only one movie - * @param doc DOM Document + * Retrieve a list of valid genres within TMDb. + * @param doc a DOM document * @return */ - public static List parseMovies(String searchUrl) { - List movies = new ArrayList(); + public static List parseCategories(String searchUrl) { + Document doc = null; + List categories = new ArrayList(); + try { + doc = DOMHelper.getEventDocFromUrl(searchUrl); + } catch (Exception error) { + return categories; + } + + if (doc == null) { + return categories; + } + + NodeList genres = doc.getElementsByTagName("genre"); + if ((genres == null) || genres.getLength() == 0) { + return categories; + } + + for (int i = 0; i < genres.getLength(); i++) { + Node node = genres.item(i); + if (node.getNodeType() == Node.ELEMENT_NODE) { + Element element = (Element) node; + Category category = new Category(); + category.setName(element.getAttribute("name")); + category.setId(DOMHelper.getValueFromElement(element, "id")); + category.setUrl(DOMHelper.getValueFromElement(element, "url")); + categories.add(category); + } + } + + return categories; + } + + public static List parseLanguages(String url) { + List languages = new ArrayList(); + Document doc = null; + + try { + doc = DOMHelper.getEventDocFromUrl(url); + } catch (Exception e) { + logger.severe("Movie.getTranslations error: " + e.getMessage()); + return languages; + } + + if (doc == null) { + return languages; + } + + NodeList nlLanguages = doc.getElementsByTagName("language"); + + if ((nlLanguages == null) || nlLanguages.getLength() == 0) { + return languages; + } + + for (int i = 0; i < nlLanguages.getLength(); i++) { + Node node = nlLanguages.item(i); + if (node.getNodeType() == Node.ELEMENT_NODE) { + Element element = (Element) node; + languages.add(parseSimpleLanguage(element)); + } + } + + return languages; + } + + /** + * Parse a DOM document and returns the latest Movie. + * This method is used for Movie.getLatest and Movie.getVersion where only + * a few fields are initialized. + * @param doc + * @return + */ + public static MovieDB parseLatestMovie(String searchUrl) { + MovieDB movie = null; Document doc = null; try { doc = DOMHelper.getEventDocFromUrl(searchUrl); } catch (Exception error) { - logger.severe("TheMovieDb Error: " + error.getMessage()); - return movies; + logger.severe("GetLatest error: " + error.getMessage()); + return movie; } if (doc == null) { - return movies; + return movie; } NodeList nlMovies = doc.getElementsByTagName("movie"); if ((nlMovies == null) || nlMovies.getLength() == 0) { - return movies; + return movie; } - MovieDB movie = null; + Node node = nlMovies.item(0); + if (node.getNodeType() == Node.ELEMENT_NODE) { + movie = new MovieDB(); - for (int i = 0; i < nlMovies.getLength(); i++) { - Node movieNode = nlMovies.item(i); - if (movieNode.getNodeType() == Node.ELEMENT_NODE) { - Element movieElement = (Element) movieNode; - movie = parseMovieInfo(movieElement); - if (movie != null) { - movies.add(movie); - } - } + Element element = (Element) node; + movie = MovieDbParser.parseSimpleMovie(element); } - return movies; + + return movie; + } + + public static Person parseLatestPerson(String url) { + Person person = new Person(); + Document doc = null; + + try { + doc = DOMHelper.getEventDocFromUrl(url); + } catch (Exception error) { + logger.severe("Person.getLatest error: " + error.getMessage()); + return person; + } + + if (doc == null) { + return person; + } + + NodeList nlMovies = doc.getElementsByTagName("person"); + + if ((nlMovies == null) || nlMovies.getLength() == 0) { + return person; + } + + Node node = nlMovies.item(0); + if (node.getNodeType() == Node.ELEMENT_NODE) { + person = new Person(); + + Element element = (Element) node; + person = MovieDbParser.parseSimplePerson(element); + } + + return person; } /** @@ -111,84 +211,36 @@ public class MovieDbParser { return movie; } - public static Person parsePersonInfo(String searchUrl) { - Person person = null; + public static List parseMovieGetVersion(String url) { + List movies = new ArrayList(); Document doc = null; try { - doc = DOMHelper.getEventDocFromUrl(searchUrl); - } catch (Exception error) { - logger.severe("PersonSearch error: " + error.getMessage()); - return person; + doc = DOMHelper.getEventDocFromUrl(url); + } catch (Exception e) { + logger.severe("Movie.getVersion error: " + e.getMessage()); + return movies; } if (doc == null) { - return person; + return movies; } - try { - person = new Person(); - NodeList personNodeList = doc.getElementsByTagName("person"); + NodeList nlMovies = doc.getElementsByTagName("movie"); - // Only get the first movie from the list - Node personNode = personNodeList.item(0); - - if (personNode == null) { - logger.finest("Person not found"); - return person; - } - - if (personNode.getNodeType() == Node.ELEMENT_NODE) { - Element personElement = (Element) personNode; - - person.setName(DOMHelper.getValueFromElement(personElement, "name")); - person.setId(DOMHelper.getValueFromElement(personElement, "id")); - person.setBiography(DOMHelper.getValueFromElement(personElement, "biography")); - person.setKnownMovies(Integer.parseInt(DOMHelper.getValueFromElement(personElement, "known_movies"))); - person.setBirthday(DOMHelper.getValueFromElement(personElement, "birthday")); - person.setBirthPlace(DOMHelper.getValueFromElement(personElement, "birthplace")); - person.setUrl(DOMHelper.getValueFromElement(personElement, "url")); - person.setVersion(Integer.parseInt(DOMHelper.getValueFromElement(personElement, "version"))); - person.setLastModifiedAt(DOMHelper.getValueFromElement(personElement, "last_modified_at")); - - NodeList artworkNodeList = doc.getElementsByTagName("image"); - for (int nodeLoop = 0; nodeLoop < artworkNodeList.getLength(); nodeLoop++) { - Node artworkNode = artworkNodeList.item(nodeLoop); - if (artworkNode.getNodeType() == Node.ELEMENT_NODE) { - Element artworkElement = (Element) artworkNode; - Artwork artwork = new Artwork(); - artwork.setType(artworkElement.getAttribute("type")); - artwork.setUrl(artworkElement.getAttribute("url")); - artwork.setSize(artworkElement.getAttribute("size")); - artwork.setId(artworkElement.getAttribute("id")); - person.addArtwork(artwork); - } - } - - NodeList filmNodeList = doc.getElementsByTagName("movie"); - for (int nodeLoop = 0; nodeLoop < filmNodeList.getLength(); nodeLoop++) { - Node filmNode = filmNodeList.item(nodeLoop); - if (filmNode.getNodeType() == Node.ELEMENT_NODE) { - Element filmElement = (Element) filmNode; - Filmography film = new Filmography(); - - film.setCharacter(filmElement.getAttribute("character")); - film.setDepartment(filmElement.getAttribute("department")); - film.setId(filmElement.getAttribute("id")); - film.setJob(filmElement.getAttribute("job")); - film.setName(filmElement.getAttribute("name")); - film.setUrl(filmElement.getAttribute("url")); - - person.addFilm(film); - } - } - } - } catch (Exception error) { - logger.severe("ERROR: " + error.getMessage()); - error.printStackTrace(); + if ((nlMovies == null) || nlMovies.getLength() == 0) { + return movies; } - return person; + for (int i = 0; i < nlMovies.getLength(); i++) { + Node node = nlMovies.item(i); + if (node.getNodeType() == Node.ELEMENT_NODE) { + Element element = (Element) node; + movies.add(MovieDbParser.parseSimpleMovie(element)); + } + } + + return movies; } private static MovieDB parseMovieInfo(Element movieElement) { @@ -410,6 +462,49 @@ public class MovieDbParser { return movie; } + /** + * Returns a list of MovieDB object parsed from the DOM Document + * even if there is only one movie + * @param doc DOM Document + * @return + */ + public static List parseMovies(String searchUrl) { + List movies = new ArrayList(); + + Document doc = null; + + try { + doc = DOMHelper.getEventDocFromUrl(searchUrl); + } catch (Exception error) { + logger.severe("TheMovieDb Error: " + error.getMessage()); + return movies; + } + + if (doc == null) { + return movies; + } + + NodeList nlMovies = doc.getElementsByTagName("movie"); + + if ((nlMovies == null) || nlMovies.getLength() == 0) { + return movies; + } + + MovieDB movie = null; + + for (int i = 0; i < nlMovies.getLength(); i++) { + Node movieNode = nlMovies.item(i); + if (movieNode.getNodeType() == Node.ELEMENT_NODE) { + Element movieElement = (Element) movieNode; + movie = parseMovieInfo(movieElement); + if (movie != null) { + movies.add(movie); + } + } + } + return movies; + } + /** * Parse a DOM document and returns a list of Person * @param doc a DOM document @@ -446,148 +541,103 @@ public class MovieDbParser { return people; } - /** - * Retrieve a list of valid genres within TMDb. - * @param doc a DOM document - * @return - */ - public static List parseCategories(String searchUrl) { - Document doc = null; - List categories = new ArrayList(); - - try { - doc = DOMHelper.getEventDocFromUrl(searchUrl); - } catch (Exception error) { - return categories; - } - - if (doc == null) { - return categories; - } - - NodeList genres = doc.getElementsByTagName("genre"); - if ((genres == null) || genres.getLength() == 0) { - return categories; - } - - for (int i = 0; i < genres.getLength(); i++) { - Node node = genres.item(i); - if (node.getNodeType() == Node.ELEMENT_NODE) { - Element element = (Element) node; - Category category = new Category(); - category.setName(element.getAttribute("name")); - category.setId(DOMHelper.getValueFromElement(element, "id")); - category.setUrl(DOMHelper.getValueFromElement(element, "url")); - categories.add(category); - } - } - - return categories; - } - - /** - * Parse a DOM document and returns the latest Movie. - * This method is used for Movie.getLatest and Movie.getVersion where only - * a few fields are initialized. - * @param doc - * @return - */ - public static MovieDB parseLatestMovie(String searchUrl) { - MovieDB movie = null; + public static Person parsePersonInfo(String searchUrl) { + Person person = null; Document doc = null; try { doc = DOMHelper.getEventDocFromUrl(searchUrl); } catch (Exception error) { - logger.severe("GetLatest error: " + error.getMessage()); - return movie; + logger.severe("PersonSearch error: " + error.getMessage()); + return person; } if (doc == null) { - return movie; + return person; } - NodeList nlMovies = doc.getElementsByTagName("movie"); - - if ((nlMovies == null) || nlMovies.getLength() == 0) { - return movie; - } - - Node node = nlMovies.item(0); - if (node.getNodeType() == Node.ELEMENT_NODE) { - movie = new MovieDB(); - - Element element = (Element) node; - movie = MovieDbParser.parseSimpleMovie(element); - } - - return movie; - } - - public static List parseMovieGetVersion(String url) { - List movies = new ArrayList(); - Document doc = null; - try { - doc = DOMHelper.getEventDocFromUrl(url); - } catch (Exception e) { - logger.severe("Movie.getVersion error: " + e.getMessage()); - return movies; - } - - if (doc == null) { - return movies; - } - - NodeList nlMovies = doc.getElementsByTagName("movie"); - - if ((nlMovies == null) || nlMovies.getLength() == 0) { - return movies; - } - - for (int i = 0; i < nlMovies.getLength(); i++) { - Node node = nlMovies.item(i); - if (node.getNodeType() == Node.ELEMENT_NODE) { - Element element = (Element) node; - movies.add(MovieDbParser.parseSimpleMovie(element)); - } - } - - return movies; - } - - public static Person parseLatestPerson(String url) { - Person person = new Person(); - Document doc = null; - - try { - doc = DOMHelper.getEventDocFromUrl(url); - } catch (Exception error) { - logger.severe("Person.getLatest error: " + error.getMessage()); - return person; - } - - if (doc == null) { - return person; - } - - NodeList nlMovies = doc.getElementsByTagName("person"); - - if ((nlMovies == null) || nlMovies.getLength() == 0) { - return person; - } - - Node node = nlMovies.item(0); - if (node.getNodeType() == Node.ELEMENT_NODE) { person = new Person(); + NodeList personNodeList = doc.getElementsByTagName("person"); - Element element = (Element) node; - person = MovieDbParser.parseSimplePerson(element); + // Only get the first movie from the list + Node personNode = personNodeList.item(0); + + if (personNode == null) { + logger.finest("Person not found"); + return person; + } + + if (personNode.getNodeType() == Node.ELEMENT_NODE) { + Element personElement = (Element) personNode; + + person.setName(DOMHelper.getValueFromElement(personElement, "name")); + person.setId(DOMHelper.getValueFromElement(personElement, "id")); + person.setBiography(DOMHelper.getValueFromElement(personElement, "biography")); + person.setKnownMovies(Integer.parseInt(DOMHelper.getValueFromElement(personElement, "known_movies"))); + person.setBirthday(DOMHelper.getValueFromElement(personElement, "birthday")); + person.setBirthPlace(DOMHelper.getValueFromElement(personElement, "birthplace")); + person.setUrl(DOMHelper.getValueFromElement(personElement, "url")); + person.setVersion(Integer.parseInt(DOMHelper.getValueFromElement(personElement, "version"))); + person.setLastModifiedAt(DOMHelper.getValueFromElement(personElement, "last_modified_at")); + + NodeList artworkNodeList = doc.getElementsByTagName("image"); + for (int nodeLoop = 0; nodeLoop < artworkNodeList.getLength(); nodeLoop++) { + Node artworkNode = artworkNodeList.item(nodeLoop); + if (artworkNode.getNodeType() == Node.ELEMENT_NODE) { + Element artworkElement = (Element) artworkNode; + Artwork artwork = new Artwork(); + artwork.setType(artworkElement.getAttribute("type")); + artwork.setUrl(artworkElement.getAttribute("url")); + artwork.setSize(artworkElement.getAttribute("size")); + artwork.setId(artworkElement.getAttribute("id")); + person.addArtwork(artwork); + } + } + + NodeList filmNodeList = doc.getElementsByTagName("movie"); + for (int nodeLoop = 0; nodeLoop < filmNodeList.getLength(); nodeLoop++) { + Node filmNode = filmNodeList.item(nodeLoop); + if (filmNode.getNodeType() == Node.ELEMENT_NODE) { + Element filmElement = (Element) filmNode; + Filmography film = new Filmography(); + + film.setCharacter(filmElement.getAttribute("character")); + film.setDepartment(filmElement.getAttribute("department")); + film.setId(filmElement.getAttribute("id")); + film.setJob(filmElement.getAttribute("job")); + film.setName(filmElement.getAttribute("name")); + film.setUrl(filmElement.getAttribute("url")); + + person.addFilm(film); + } + } + } + } catch (Exception error) { + logger.severe("ERROR: " + error.getMessage()); + error.printStackTrace(); } return person; } + /** + * Parse a "simple" Language in the form: + * + * English + * English + * + * @param element + * @return + */ + private static Language parseSimpleLanguage(Element element) { + Language language = new Language(); + language.setIsoCode(element.getAttribute("iso_639_1")); + language.setEnglishName(DOMHelper.getValueFromElement(element, "english_name")); + language.setNativeName(DOMHelper.getValueFromElement(element, "native_name")); + return language; + } + /** * Parse a "simple" Movie in the form: * @@ -609,7 +659,7 @@ public class MovieDbParser { movie.setLastModifiedAt(DOMHelper.getValueFromElement(element, "last_modified_at")); return movie; } - + /** * Parse a "simple" Person in the form: * @@ -629,4 +679,5 @@ public class MovieDbParser { person.setLastModifiedAt(DOMHelper.getValueFromElement(element, "last_modified_at")); return person; } + } From 9436701f5cc07038bba37138b34bca098d101572 Mon Sep 17 00:00:00 2001 From: Omertron Date: Mon, 17 Jan 2011 21:20:27 +0000 Subject: [PATCH 059/207] Updated copyright date --- .../src/com/moviejukebox/themoviedb/TheMovieDb.java | 2 +- .../com/moviejukebox/themoviedb/model/Artwork.java | 3 +-- .../com/moviejukebox/themoviedb/model/Category.java | 2 +- .../com/moviejukebox/themoviedb/model/Country.java | 2 +- .../moviejukebox/themoviedb/model/Filmography.java | 2 +- .../com/moviejukebox/themoviedb/model/Language.java | 2 +- .../com/moviejukebox/themoviedb/model/MovieDB.java | 3 +-- .../com/moviejukebox/themoviedb/model/Person.java | 3 +-- .../com/moviejukebox/themoviedb/model/Studio.java | 2 +- .../com/moviejukebox/themoviedb/tools/Base64.java | 3 +-- .../com/moviejukebox/themoviedb/tools/DOMHelper.java | 2 +- .../moviejukebox/themoviedb/tools/LogFormatter.java | 3 +-- .../moviejukebox/themoviedb/tools/ModelTools.java | 3 +-- .../moviejukebox/themoviedb/tools/MovieDbParser.java | 2 +- .../moviejukebox/themoviedb/tools/WebBrowser.java | 3 +-- .../com/moviejukebox/themoviedb/TheMovieDbTest.java | 12 ++++++++++++ 16 files changed, 27 insertions(+), 22 deletions(-) diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java b/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java index f27eb3caa..1f7f53355 100644 --- a/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2010 YAMJ Members + * Copyright (c) 2004-2011 YAMJ Members * http://code.google.com/p/moviejukebox/people/list * * Web: http://code.google.com/p/moviejukebox/ diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/model/Artwork.java b/themoviedbapi/src/com/moviejukebox/themoviedb/model/Artwork.java index 888a5ba29..23ea3e9a7 100644 --- a/themoviedbapi/src/com/moviejukebox/themoviedb/model/Artwork.java +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/model/Artwork.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2010 YAMJ Members + * Copyright (c) 2004-2011 YAMJ Members * http://code.google.com/p/moviejukebox/people/list * * Web: http://code.google.com/p/moviejukebox/ @@ -10,7 +10,6 @@ * For any reuse or distribution, you must make clear to others the * license terms of this work. */ - package com.moviejukebox.themoviedb.model; /** diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/model/Category.java b/themoviedbapi/src/com/moviejukebox/themoviedb/model/Category.java index 7cf867642..22f418ab1 100644 --- a/themoviedbapi/src/com/moviejukebox/themoviedb/model/Category.java +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/model/Category.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2010 YAMJ Members + * Copyright (c) 2004-2011 YAMJ Members * http://code.google.com/p/moviejukebox/people/list * * Web: http://code.google.com/p/moviejukebox/ diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/model/Country.java b/themoviedbapi/src/com/moviejukebox/themoviedb/model/Country.java index 69d90e1d0..e1b0ab6de 100644 --- a/themoviedbapi/src/com/moviejukebox/themoviedb/model/Country.java +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/model/Country.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2010 YAMJ Members + * Copyright (c) 2004-2011 YAMJ Members * http://code.google.com/p/moviejukebox/people/list * * Web: http://code.google.com/p/moviejukebox/ diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/model/Filmography.java b/themoviedbapi/src/com/moviejukebox/themoviedb/model/Filmography.java index 00cc6eb78..e6b4f8d55 100644 --- a/themoviedbapi/src/com/moviejukebox/themoviedb/model/Filmography.java +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/model/Filmography.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2010 YAMJ Members + * Copyright (c) 2004-2011 YAMJ Members * http://code.google.com/p/moviejukebox/people/list * * Web: http://code.google.com/p/moviejukebox/ diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/model/Language.java b/themoviedbapi/src/com/moviejukebox/themoviedb/model/Language.java index 2994b9cde..f66a8f155 100644 --- a/themoviedbapi/src/com/moviejukebox/themoviedb/model/Language.java +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/model/Language.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2010 YAMJ Members + * Copyright (c) 2004-2011 YAMJ Members * http://code.google.com/p/moviejukebox/people/list * * Web: http://code.google.com/p/moviejukebox/ diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/model/MovieDB.java b/themoviedbapi/src/com/moviejukebox/themoviedb/model/MovieDB.java index 31c5a6dfc..ab056e5e9 100644 --- a/themoviedbapi/src/com/moviejukebox/themoviedb/model/MovieDB.java +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/model/MovieDB.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2010 YAMJ Members + * Copyright (c) 2004-2011 YAMJ Members * http://code.google.com/p/moviejukebox/people/list * * Web: http://code.google.com/p/moviejukebox/ @@ -10,7 +10,6 @@ * For any reuse or distribution, you must make clear to others the * license terms of this work. */ - package com.moviejukebox.themoviedb.model; import java.text.DateFormat; diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/model/Person.java b/themoviedbapi/src/com/moviejukebox/themoviedb/model/Person.java index de1f70457..1a1ba07de 100644 --- a/themoviedbapi/src/com/moviejukebox/themoviedb/model/Person.java +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/model/Person.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2010 YAMJ Members + * Copyright (c) 2004-2011 YAMJ Members * http://code.google.com/p/moviejukebox/people/list * * Web: http://code.google.com/p/moviejukebox/ @@ -10,7 +10,6 @@ * For any reuse or distribution, you must make clear to others the * license terms of this work. */ - package com.moviejukebox.themoviedb.model; import java.text.DateFormat; diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/model/Studio.java b/themoviedbapi/src/com/moviejukebox/themoviedb/model/Studio.java index 1c113e445..1238669b1 100644 --- a/themoviedbapi/src/com/moviejukebox/themoviedb/model/Studio.java +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/model/Studio.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2010 YAMJ Members + * Copyright (c) 2004-2011 YAMJ Members * http://code.google.com/p/moviejukebox/people/list * * Web: http://code.google.com/p/moviejukebox/ diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/tools/Base64.java b/themoviedbapi/src/com/moviejukebox/themoviedb/tools/Base64.java index e4f56aba0..8af02639e 100644 --- a/themoviedbapi/src/com/moviejukebox/themoviedb/tools/Base64.java +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/tools/Base64.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2010 YAMJ Members + * Copyright (c) 2004-2011 YAMJ Members * http://code.google.com/p/moviejukebox/people/list * * Web: http://code.google.com/p/moviejukebox/ @@ -10,7 +10,6 @@ * For any reuse or distribution, you must make clear to others the * license terms of this work. */ - package com.moviejukebox.themoviedb.tools; public class Base64 { diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/tools/DOMHelper.java b/themoviedbapi/src/com/moviejukebox/themoviedb/tools/DOMHelper.java index d3d7615f1..612ab6db8 100644 --- a/themoviedbapi/src/com/moviejukebox/themoviedb/tools/DOMHelper.java +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/tools/DOMHelper.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2010 YAMJ Members + * Copyright (c) 2004-2011 YAMJ Members * http://code.google.com/p/moviejukebox/people/list * * Web: http://code.google.com/p/moviejukebox/ diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/tools/LogFormatter.java b/themoviedbapi/src/com/moviejukebox/themoviedb/tools/LogFormatter.java index e6992779b..c000d4841 100644 --- a/themoviedbapi/src/com/moviejukebox/themoviedb/tools/LogFormatter.java +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/tools/LogFormatter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2010 YAMJ Members + * Copyright (c) 2004-2011 YAMJ Members * http://code.google.com/p/moviejukebox/people/list * * Web: http://code.google.com/p/moviejukebox/ @@ -10,7 +10,6 @@ * For any reuse or distribution, you must make clear to others the * license terms of this work. */ - package com.moviejukebox.themoviedb.tools; import java.security.PrivilegedAction; diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/tools/ModelTools.java b/themoviedbapi/src/com/moviejukebox/themoviedb/tools/ModelTools.java index 00833b2d4..67de92a07 100644 --- a/themoviedbapi/src/com/moviejukebox/themoviedb/tools/ModelTools.java +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/tools/ModelTools.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2010 YAMJ Members + * Copyright (c) 2004-2011 YAMJ Members * http://code.google.com/p/moviejukebox/people/list * * Web: http://code.google.com/p/moviejukebox/ @@ -10,7 +10,6 @@ * For any reuse or distribution, you must make clear to others the * license terms of this work. */ - package com.moviejukebox.themoviedb.tools; import java.util.ArrayList; diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/tools/MovieDbParser.java b/themoviedbapi/src/com/moviejukebox/themoviedb/tools/MovieDbParser.java index 4249428b2..b9b6ea934 100644 --- a/themoviedbapi/src/com/moviejukebox/themoviedb/tools/MovieDbParser.java +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/tools/MovieDbParser.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2010 YAMJ Members + * Copyright (c) 2004-2011 YAMJ Members * http://code.google.com/p/moviejukebox/people/list * * Web: http://code.google.com/p/moviejukebox/ diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/tools/WebBrowser.java b/themoviedbapi/src/com/moviejukebox/themoviedb/tools/WebBrowser.java index ccc0d632d..62c68315a 100644 --- a/themoviedbapi/src/com/moviejukebox/themoviedb/tools/WebBrowser.java +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/tools/WebBrowser.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2010 YAMJ Members + * Copyright (c) 2004-2011 YAMJ Members * http://code.google.com/p/moviejukebox/people/list * * Web: http://code.google.com/p/moviejukebox/ @@ -10,7 +10,6 @@ * For any reuse or distribution, you must make clear to others the * license terms of this work. */ - package com.moviejukebox.themoviedb.tools; import java.io.BufferedReader; diff --git a/themoviedbapi/test/com/moviejukebox/themoviedb/TheMovieDbTest.java b/themoviedbapi/test/com/moviejukebox/themoviedb/TheMovieDbTest.java index afd322742..8b319514e 100644 --- a/themoviedbapi/test/com/moviejukebox/themoviedb/TheMovieDbTest.java +++ b/themoviedbapi/test/com/moviejukebox/themoviedb/TheMovieDbTest.java @@ -1,3 +1,15 @@ +/* + * Copyright (c) 2004-2011 YAMJ Members + * http://code.google.com/p/moviejukebox/people/list + * + * Web: http://code.google.com/p/moviejukebox/ + * + * This software is licensed under a Creative Commons License + * See this page: http://code.google.com/p/moviejukebox/wiki/License + * + * For any reuse or distribution, you must make clear to others the + * license terms of this work. + */ package com.moviejukebox.themoviedb; import com.moviejukebox.themoviedb.model.Category; From 844d8bbdf34ef3657cac229c4d981dc6f57ddc45 Mon Sep 17 00:00:00 2001 From: Omertron Date: Tue, 18 Jan 2011 09:59:52 +0000 Subject: [PATCH 060/207] Cleanup --- .../moviejukebox/themoviedb/TheMovieDb.java | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java b/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java index 1f7f53355..578684e4c 100644 --- a/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java +++ b/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java @@ -41,7 +41,13 @@ import com.moviejukebox.themoviedb.tools.WebBrowser; * @version 1.3 */ public class TheMovieDb { - + private String apiKey; + private static Logger logger = null; + private static LogFormatter tmdbFormatter = new LogFormatter(); + private static ConsoleHandler tmdbConsoleHandler = new ConsoleHandler(); + private static final String apiSite = "http://api.themoviedb.org/2.1/"; + private static final String defaultLanguage = "en-US"; + /** * Compare the MovieDB object with a title & year * @param moviedb The moviedb object to compare too @@ -90,6 +96,7 @@ public class TheMovieDb { } return false; } + /** * Search a list of movies and return the one that matches the title & year * @param movieList The list of movies to search @@ -110,6 +117,7 @@ public class TheMovieDb { return null; } + /** * Check the string passed to see if it contains a value. * @param testString The string to test @@ -123,9 +131,6 @@ public class TheMovieDb { } return true; } - private String apiKey; - private static Logger logger = null; - private static LogFormatter tmdbFormatter = new LogFormatter(); /* * API Methods @@ -133,10 +138,6 @@ public class TheMovieDb { * Note: This is currently a read-only interface and as such, no write methods exist. */ - private static ConsoleHandler tmdbConsoleHandler = new ConsoleHandler(); - - private static final String apiSite = "http://api.themoviedb.org/2.1/"; - private static final String defaultLanguage = "en-US"; /* * Media */ @@ -642,4 +643,5 @@ public class TheMovieDb { WebBrowser.setWebTimeoutConnect(webTimeoutConnect); WebBrowser.setWebTimeoutRead(webTimeoutRead); } + } From 188beca85b61aca0f1809fb79329d714062a718c Mon Sep 17 00:00:00 2001 From: Yves Blusseau Date: Sat, 29 Jan 2011 22:50:36 +0000 Subject: [PATCH 061/207] Migrating from Ant to Maven to build the project --- themoviedbapi/.classpath | 14 +- themoviedbapi/.project | 40 +++-- .../.settings/org.eclipse.jdt.core.prefs | 6 + .../.settings/org.maven.ide.eclipse.prefs | 8 + themoviedbapi/build.xml | 77 --------- themoviedbapi/pom.xml | 147 ++++++++++++++++++ themoviedbapi/{src => }/readme.txt | 0 .../moviejukebox/themoviedb/TheMovieDb.java | 0 .../themoviedb/model/Artwork.java | 0 .../themoviedb/model/Category.java | 0 .../themoviedb/model/Country.java | 0 .../themoviedb/model/Filmography.java | 0 .../themoviedb/model/Language.java | 0 .../themoviedb/model/MovieDB.java | 0 .../moviejukebox/themoviedb/model/Person.java | 0 .../moviejukebox/themoviedb/model/Studio.java | 0 .../moviejukebox/themoviedb/tools/Base64.java | 0 .../themoviedb/tools/DOMHelper.java | 0 .../themoviedb/tools/LogFormatter.java | 0 .../themoviedb/tools/ModelTools.java | 0 .../themoviedb/tools/MovieDbParser.java | 0 .../themoviedb/tools/WebBrowser.java | 0 .../themoviedb/TheMovieDbTest.java | 0 23 files changed, 192 insertions(+), 100 deletions(-) create mode 100644 themoviedbapi/.settings/org.eclipse.jdt.core.prefs create mode 100644 themoviedbapi/.settings/org.maven.ide.eclipse.prefs delete mode 100644 themoviedbapi/build.xml create mode 100644 themoviedbapi/pom.xml rename themoviedbapi/{src => }/readme.txt (100%) rename themoviedbapi/src/{ => main/java}/com/moviejukebox/themoviedb/TheMovieDb.java (100%) rename themoviedbapi/src/{ => main/java}/com/moviejukebox/themoviedb/model/Artwork.java (100%) rename themoviedbapi/src/{ => main/java}/com/moviejukebox/themoviedb/model/Category.java (100%) rename themoviedbapi/src/{ => main/java}/com/moviejukebox/themoviedb/model/Country.java (100%) rename themoviedbapi/src/{ => main/java}/com/moviejukebox/themoviedb/model/Filmography.java (100%) rename themoviedbapi/src/{ => main/java}/com/moviejukebox/themoviedb/model/Language.java (100%) rename themoviedbapi/src/{ => main/java}/com/moviejukebox/themoviedb/model/MovieDB.java (100%) rename themoviedbapi/src/{ => main/java}/com/moviejukebox/themoviedb/model/Person.java (100%) rename themoviedbapi/src/{ => main/java}/com/moviejukebox/themoviedb/model/Studio.java (100%) rename themoviedbapi/src/{ => main/java}/com/moviejukebox/themoviedb/tools/Base64.java (100%) rename themoviedbapi/src/{ => main/java}/com/moviejukebox/themoviedb/tools/DOMHelper.java (100%) rename themoviedbapi/src/{ => main/java}/com/moviejukebox/themoviedb/tools/LogFormatter.java (100%) rename themoviedbapi/src/{ => main/java}/com/moviejukebox/themoviedb/tools/ModelTools.java (100%) rename themoviedbapi/src/{ => main/java}/com/moviejukebox/themoviedb/tools/MovieDbParser.java (100%) rename themoviedbapi/src/{ => main/java}/com/moviejukebox/themoviedb/tools/WebBrowser.java (100%) rename themoviedbapi/{test => src/test/java}/com/moviejukebox/themoviedb/TheMovieDbTest.java (100%) diff --git a/themoviedbapi/.classpath b/themoviedbapi/.classpath index d171cd4c1..31cf404a4 100644 --- a/themoviedbapi/.classpath +++ b/themoviedbapi/.classpath @@ -1,6 +1,8 @@ - - - - - - + + + + + + + + diff --git a/themoviedbapi/.project b/themoviedbapi/.project index 63e67b96e..88028eef1 100644 --- a/themoviedbapi/.project +++ b/themoviedbapi/.project @@ -1,17 +1,23 @@ - - - themoviedbapi - - - - - - org.eclipse.jdt.core.javabuilder - - - - - - org.eclipse.jdt.core.javanature - - + + + themoviedbapi + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.maven.ide.eclipse.maven2Builder + + + + + + org.maven.ide.eclipse.maven2Nature + org.eclipse.jdt.core.javanature + + diff --git a/themoviedbapi/.settings/org.eclipse.jdt.core.prefs b/themoviedbapi/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 000000000..483d704da --- /dev/null +++ b/themoviedbapi/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,6 @@ +#Sat Jan 29 22:13:58 CET 2011 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 +org.eclipse.jdt.core.compiler.compliance=1.6 +org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning +org.eclipse.jdt.core.compiler.source=1.6 diff --git a/themoviedbapi/.settings/org.maven.ide.eclipse.prefs b/themoviedbapi/.settings/org.maven.ide.eclipse.prefs new file mode 100644 index 000000000..341107664 --- /dev/null +++ b/themoviedbapi/.settings/org.maven.ide.eclipse.prefs @@ -0,0 +1,8 @@ +#Sat Jan 29 22:13:55 CET 2011 +activeProfiles= +eclipse.preferences.version=1 +fullBuildGoals=process-test-resources +resolveWorkspaceProjects=true +resourceFilterGoals=process-resources resources\:testResources +skipCompilerPlugin=true +version=1 diff --git a/themoviedbapi/build.xml b/themoviedbapi/build.xml deleted file mode 100644 index 392df835c..000000000 --- a/themoviedbapi/build.xml +++ /dev/null @@ -1,77 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ${project}${line.separator} - Build Date: ${builddate}${line.separator} - Revision: r${revision}${line.separator} - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/themoviedbapi/pom.xml b/themoviedbapi/pom.xml new file mode 100644 index 000000000..f07319517 --- /dev/null +++ b/themoviedbapi/pom.xml @@ -0,0 +1,147 @@ + + + 4.0.0 + + org.sonatype.oss + oss-parent + 6 + + com.moviejukebox + themoviedbapi + 1.0-SNAPSHOT + The MovieDB API + + + Google Code + http://code.google.com/p/themoviedbapi/issues/list + + + Hudson CI + http://mediadeveloper.org:8080/job/themoviedbapi/ + + + scm:svn:http://themoviedbapi.googlecode.com/svn/trunk/themoviedbapi + scm:svn:https://themoviedbapi.googlecode.com/svn/trunk/themoviedbapi + HEAD + http://code.google.com/p/themoviedbapi/source/browse/trunk/themoviedbapi + + + + UTF-8 + true + + + + + + junit + junit + 4.5 + test + + + + + + + junit + junit + + + + + + + + org.apache.maven.plugins + maven-clean-plugin + 2.4.1 + + + org.apache.maven.plugins + maven-compiler-plugin + 2.3.2 + + + org.apache.maven.plugins + maven-jar-plugin + 2.3.1 + + + org.apache.maven.plugins + maven-surefire-plugin + 2.7.1 + + + org.codehaus.mojo + buildnumber-maven-plugin + 1.0-beta-4 + + + org.codehaus.mojo + build-helper-maven-plugin + 1.5 + + + + + + + org.codehaus.mojo + buildnumber-maven-plugin + + true + 0000 + {0,date,yyyy-MM-dd HH:mm:ss} + + + + validate + + create + + + + + + + maven-compiler-plugin + + 1.6 + 1.6 + true + true + + + + + + maven-jar-plugin + + + + ${project.name} + ${project.version} + ${buildNumber} + ${timestamp} + + + + + + + + maven-surefire-plugin + + ${skipTests} + + + + + + ${artifactId}-${project.version}-r${buildNumber} + + + diff --git a/themoviedbapi/src/readme.txt b/themoviedbapi/readme.txt similarity index 100% rename from themoviedbapi/src/readme.txt rename to themoviedbapi/readme.txt diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java similarity index 100% rename from themoviedbapi/src/com/moviejukebox/themoviedb/TheMovieDb.java rename to themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/model/Artwork.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Artwork.java similarity index 100% rename from themoviedbapi/src/com/moviejukebox/themoviedb/model/Artwork.java rename to themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Artwork.java diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/model/Category.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Category.java similarity index 100% rename from themoviedbapi/src/com/moviejukebox/themoviedb/model/Category.java rename to themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Category.java diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/model/Country.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Country.java similarity index 100% rename from themoviedbapi/src/com/moviejukebox/themoviedb/model/Country.java rename to themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Country.java diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/model/Filmography.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Filmography.java similarity index 100% rename from themoviedbapi/src/com/moviejukebox/themoviedb/model/Filmography.java rename to themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Filmography.java diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/model/Language.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Language.java similarity index 100% rename from themoviedbapi/src/com/moviejukebox/themoviedb/model/Language.java rename to themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Language.java diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/model/MovieDB.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/MovieDB.java similarity index 100% rename from themoviedbapi/src/com/moviejukebox/themoviedb/model/MovieDB.java rename to themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/MovieDB.java diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/model/Person.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Person.java similarity index 100% rename from themoviedbapi/src/com/moviejukebox/themoviedb/model/Person.java rename to themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Person.java diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/model/Studio.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Studio.java similarity index 100% rename from themoviedbapi/src/com/moviejukebox/themoviedb/model/Studio.java rename to themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Studio.java diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/tools/Base64.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/Base64.java similarity index 100% rename from themoviedbapi/src/com/moviejukebox/themoviedb/tools/Base64.java rename to themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/Base64.java diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/tools/DOMHelper.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/DOMHelper.java similarity index 100% rename from themoviedbapi/src/com/moviejukebox/themoviedb/tools/DOMHelper.java rename to themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/DOMHelper.java diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/tools/LogFormatter.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/LogFormatter.java similarity index 100% rename from themoviedbapi/src/com/moviejukebox/themoviedb/tools/LogFormatter.java rename to themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/LogFormatter.java diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/tools/ModelTools.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/ModelTools.java similarity index 100% rename from themoviedbapi/src/com/moviejukebox/themoviedb/tools/ModelTools.java rename to themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/ModelTools.java diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/tools/MovieDbParser.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/MovieDbParser.java similarity index 100% rename from themoviedbapi/src/com/moviejukebox/themoviedb/tools/MovieDbParser.java rename to themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/MovieDbParser.java diff --git a/themoviedbapi/src/com/moviejukebox/themoviedb/tools/WebBrowser.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/WebBrowser.java similarity index 100% rename from themoviedbapi/src/com/moviejukebox/themoviedb/tools/WebBrowser.java rename to themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/WebBrowser.java diff --git a/themoviedbapi/test/com/moviejukebox/themoviedb/TheMovieDbTest.java b/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java similarity index 100% rename from themoviedbapi/test/com/moviejukebox/themoviedb/TheMovieDbTest.java rename to themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java From 374b4fa3c96d79e247b1ba23c884e45c0731834d Mon Sep 17 00:00:00 2001 From: Omertron Date: Tue, 8 Feb 2011 10:32:51 +0000 Subject: [PATCH 064/207] Updated POM --- themoviedbapi/pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themoviedbapi/pom.xml b/themoviedbapi/pom.xml index f07319517..60879da44 100644 --- a/themoviedbapi/pom.xml +++ b/themoviedbapi/pom.xml @@ -19,7 +19,7 @@ Hudson CI - http://mediadeveloper.org:8080/job/themoviedbapi/ + http://mediadeveloper.org:8080/job/API-TheMovieDb/ scm:svn:http://themoviedbapi.googlecode.com/svn/trunk/themoviedbapi From f03b762fbe44c2f6d7dbf77aa2885d42a9b944ec Mon Sep 17 00:00:00 2001 From: Omertron Date: Thu, 10 Feb 2011 20:16:16 +0000 Subject: [PATCH 065/207] Updated POM --- themoviedbapi/.project | 46 +++++++++++++++++++++--------------------- themoviedbapi/pom.xml | 38 ++++++++++++++++++++++++++++------ 2 files changed, 55 insertions(+), 29 deletions(-) diff --git a/themoviedbapi/.project b/themoviedbapi/.project index 88028eef1..58de97bb0 100644 --- a/themoviedbapi/.project +++ b/themoviedbapi/.project @@ -1,23 +1,23 @@ - - - themoviedbapi - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.maven.ide.eclipse.maven2Builder - - - - - - org.maven.ide.eclipse.maven2Nature - org.eclipse.jdt.core.javanature - - + + + API-TheMovieDb + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.maven.ide.eclipse.maven2Builder + + + + + + org.maven.ide.eclipse.maven2Nature + org.eclipse.jdt.core.javanature + + diff --git a/themoviedbapi/pom.xml b/themoviedbapi/pom.xml index 60879da44..b5c3c5d9d 100644 --- a/themoviedbapi/pom.xml +++ b/themoviedbapi/pom.xml @@ -44,12 +44,33 @@ - - - junit - junit - - + + + release-sign-artifacts + + + performRelease + true + + + + + + maven-gpg-plugin + + + sign-artifacts + verify + + sign + + + + + + + + @@ -64,6 +85,11 @@ maven-compiler-plugin 2.3.2 + + org.apache.maven.plugins + maven-gpg-plugin + 1.1 + org.apache.maven.plugins maven-jar-plugin From 98c8401f1346e8c699847afb0c8cef5933eb2e4c Mon Sep 17 00:00:00 2001 From: Omertron Date: Fri, 11 Feb 2011 11:45:24 +0000 Subject: [PATCH 067/207] Updated Classpath with Junit --- themoviedbapi/.classpath | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/themoviedbapi/.classpath b/themoviedbapi/.classpath index 31cf404a4..3a4681cd0 100644 --- a/themoviedbapi/.classpath +++ b/themoviedbapi/.classpath @@ -1,8 +1,9 @@ - - - - - - - - + + + + + + + + + From d12331c3a051c472cb9c0fd03556a9197a49cc4f Mon Sep 17 00:00:00 2001 From: Omertron Date: Fri, 11 Feb 2011 11:55:01 +0000 Subject: [PATCH 068/207] Updated POM for junit --- themoviedbapi/pom.xml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/themoviedbapi/pom.xml b/themoviedbapi/pom.xml index b5c3c5d9d..3cd03ba3e 100644 --- a/themoviedbapi/pom.xml +++ b/themoviedbapi/pom.xml @@ -33,6 +33,13 @@ true + + + junit + junit + 4.8.2 + + From 070bae22845928f830dd6990f3692f5c8db4add4 Mon Sep 17 00:00:00 2001 From: Omertron Date: Fri, 11 Feb 2011 11:58:06 +0000 Subject: [PATCH 069/207] [maven-release-plugin] prepare release themoviedbapi-1.0 --- themoviedbapi/pom.xml | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/themoviedbapi/pom.xml b/themoviedbapi/pom.xml index 3cd03ba3e..d10174568 100644 --- a/themoviedbapi/pom.xml +++ b/themoviedbapi/pom.xml @@ -1,7 +1,5 @@ - + 4.0.0 org.sonatype.oss @@ -10,7 +8,7 @@ com.moviejukebox themoviedbapi - 1.0-SNAPSHOT + 1.0 The MovieDB API @@ -22,10 +20,10 @@ http://mediadeveloper.org:8080/job/API-TheMovieDb/ - scm:svn:http://themoviedbapi.googlecode.com/svn/trunk/themoviedbapi - scm:svn:https://themoviedbapi.googlecode.com/svn/trunk/themoviedbapi + scm:svn:http://themoviedbapi.googlecode.com/svn/tags/themoviedbapi-1.0 + scm:svn:https://themoviedbapi.googlecode.com/svn/tags/themoviedbapi-1.0 HEAD - http://code.google.com/p/themoviedbapi/source/browse/trunk/themoviedbapi + http://code.google.com/p/themoviedbapi/source/browse/tags/themoviedbapi-1.0 From ad18d597c737a82ae47b6231df8f01cc55bd8d48 Mon Sep 17 00:00:00 2001 From: Omertron Date: Fri, 11 Feb 2011 12:01:17 +0000 Subject: [PATCH 070/207] Updated POM & Tags directory --- themoviedbapi/pom.xml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/themoviedbapi/pom.xml b/themoviedbapi/pom.xml index d10174568..3cd03ba3e 100644 --- a/themoviedbapi/pom.xml +++ b/themoviedbapi/pom.xml @@ -1,5 +1,7 @@ - + 4.0.0 org.sonatype.oss @@ -8,7 +10,7 @@ com.moviejukebox themoviedbapi - 1.0 + 1.0-SNAPSHOT The MovieDB API @@ -20,10 +22,10 @@ http://mediadeveloper.org:8080/job/API-TheMovieDb/ - scm:svn:http://themoviedbapi.googlecode.com/svn/tags/themoviedbapi-1.0 - scm:svn:https://themoviedbapi.googlecode.com/svn/tags/themoviedbapi-1.0 + scm:svn:http://themoviedbapi.googlecode.com/svn/trunk/themoviedbapi + scm:svn:https://themoviedbapi.googlecode.com/svn/trunk/themoviedbapi HEAD - http://code.google.com/p/themoviedbapi/source/browse/tags/themoviedbapi-1.0 + http://code.google.com/p/themoviedbapi/source/browse/trunk/themoviedbapi From 02ec81beecc47c49f707a47ac204e4b4cbece01e Mon Sep 17 00:00:00 2001 From: Omertron Date: Fri, 11 Feb 2011 12:46:55 +0000 Subject: [PATCH 072/207] [maven-release-plugin] prepare release themoviedbapi-1.0 --- themoviedbapi/pom.xml | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/themoviedbapi/pom.xml b/themoviedbapi/pom.xml index 3cd03ba3e..d10174568 100644 --- a/themoviedbapi/pom.xml +++ b/themoviedbapi/pom.xml @@ -1,7 +1,5 @@ - + 4.0.0 org.sonatype.oss @@ -10,7 +8,7 @@ com.moviejukebox themoviedbapi - 1.0-SNAPSHOT + 1.0 The MovieDB API @@ -22,10 +20,10 @@ http://mediadeveloper.org:8080/job/API-TheMovieDb/ - scm:svn:http://themoviedbapi.googlecode.com/svn/trunk/themoviedbapi - scm:svn:https://themoviedbapi.googlecode.com/svn/trunk/themoviedbapi + scm:svn:http://themoviedbapi.googlecode.com/svn/tags/themoviedbapi-1.0 + scm:svn:https://themoviedbapi.googlecode.com/svn/tags/themoviedbapi-1.0 HEAD - http://code.google.com/p/themoviedbapi/source/browse/trunk/themoviedbapi + http://code.google.com/p/themoviedbapi/source/browse/tags/themoviedbapi-1.0 From e2a51f9d1b9c491d2a8290579cadde044b6298c4 Mon Sep 17 00:00:00 2001 From: Omertron Date: Fri, 11 Feb 2011 12:47:07 +0000 Subject: [PATCH 073/207] [maven-release-plugin] prepare for next development iteration --- themoviedbapi/pom.xml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/themoviedbapi/pom.xml b/themoviedbapi/pom.xml index d10174568..ebbc600ab 100644 --- a/themoviedbapi/pom.xml +++ b/themoviedbapi/pom.xml @@ -8,7 +8,7 @@ com.moviejukebox themoviedbapi - 1.0 + 1.1-SNAPSHOT The MovieDB API @@ -20,10 +20,9 @@ http://mediadeveloper.org:8080/job/API-TheMovieDb/ - scm:svn:http://themoviedbapi.googlecode.com/svn/tags/themoviedbapi-1.0 - scm:svn:https://themoviedbapi.googlecode.com/svn/tags/themoviedbapi-1.0 - HEAD - http://code.google.com/p/themoviedbapi/source/browse/tags/themoviedbapi-1.0 + scm:svn:http://themoviedbapi.googlecode.com/svn/trunk/themoviedbapi + scm:svn:https://themoviedbapi.googlecode.com/svn/trunk/themoviedbapi + http://code.google.com/p/themoviedbapi/source/browse/trunk/themoviedbapi From fee8d9663c53d827767c3e2b3f8a1584f68f0fa4 Mon Sep 17 00:00:00 2001 From: Omertron Date: Wed, 30 Mar 2011 14:45:02 +0000 Subject: [PATCH 074/207] Update POM.XML and build routine Now will also ZIP the jar for packaging --- themoviedbapi/pom.xml | 68 +++++++++++++++++++++--- themoviedbapi/src/main/resources/bin.xml | 39 ++++++++++++++ 2 files changed, 100 insertions(+), 7 deletions(-) create mode 100644 themoviedbapi/src/main/resources/bin.xml diff --git a/themoviedbapi/pom.xml b/themoviedbapi/pom.xml index ebbc600ab..640ffcd01 100644 --- a/themoviedbapi/pom.xml +++ b/themoviedbapi/pom.xml @@ -15,10 +15,12 @@ Google Code http://code.google.com/p/themoviedbapi/issues/list + Hudson CI http://mediadeveloper.org:8080/job/API-TheMovieDb/ + scm:svn:http://themoviedbapi.googlecode.com/svn/trunk/themoviedbapi scm:svn:https://themoviedbapi.googlecode.com/svn/trunk/themoviedbapi @@ -26,8 +28,10 @@ - UTF-8 true + UTF-8 + UTF-8 + zip @@ -37,6 +41,7 @@ 4.8.2 + @@ -89,11 +94,11 @@ maven-compiler-plugin 2.3.2 - - org.apache.maven.plugins - maven-gpg-plugin - 1.1 - + + org.apache.maven.plugins + maven-gpg-plugin + 1.1 + org.apache.maven.plugins maven-jar-plugin @@ -169,9 +174,58 @@ + + org.apache.maven.plugins + maven-antrun-plugin + 1.6 + + + create-version-txt + generate-resources + + + + + + + + Writing version file: ${version_file} + ${header_line} + ${build_date_line} + ${version_line} + ${revision_line} + + + + run + + + + + + org.apache.maven.plugins + maven-assembly-plugin + 2.2.1 + + + distro-assembly + package + + single + + + + src/main/resources/bin.xml + + + + + - ${artifactId}-${project.version}-r${buildNumber} + ${project.artifactId}-${project.version}-r${buildNumber} + + diff --git a/themoviedbapi/src/main/resources/bin.xml b/themoviedbapi/src/main/resources/bin.xml new file mode 100644 index 000000000..c12f07f36 --- /dev/null +++ b/themoviedbapi/src/main/resources/bin.xml @@ -0,0 +1,39 @@ + + bin + + ${distribution.format} + + false + + + + ${project.build.directory} + + + version.txt + + + + + + ${basedir} + + + readme.txt + + + + + + ${project.build.directory} + + + **/*.jar + + + + + + From d054e6cf2443ba1e9e34a8f7942184e26b5309b3 Mon Sep 17 00:00:00 2001 From: Omertron Date: Thu, 21 Apr 2011 12:35:08 +0000 Subject: [PATCH 075/207] Update POM versions --- themoviedbapi/pom.xml | 33 ++++++++++++++++++++++++++------- 1 file changed, 26 insertions(+), 7 deletions(-) diff --git a/themoviedbapi/pom.xml b/themoviedbapi/pom.xml index 640ffcd01..97bd4d39c 100644 --- a/themoviedbapi/pom.xml +++ b/themoviedbapi/pom.xml @@ -38,7 +38,6 @@ junit junit - 4.8.2 @@ -47,7 +46,7 @@ junit junit - 4.5 + 4.8.2 test @@ -97,7 +96,7 @@ org.apache.maven.plugins maven-gpg-plugin - 1.1 + 1.2 org.apache.maven.plugins @@ -107,18 +106,33 @@ org.apache.maven.plugins maven-surefire-plugin - 2.7.1 + 2.8 org.codehaus.mojo buildnumber-maven-plugin - 1.0-beta-4 + 1.0 org.codehaus.mojo build-helper-maven-plugin 1.5 + + org.apache.maven.plugins + maven-antrun-plugin + 1.6 + + + org.apache.maven.plugins + maven-assembly-plugin + 2.2.1 + + + org.codehaus.mojo + versions-maven-plugin + 1.2 + @@ -142,6 +156,7 @@ + org.apache.maven.plugins maven-compiler-plugin 1.6 @@ -153,6 +168,7 @@ + org.apache.maven.plugins maven-jar-plugin @@ -168,6 +184,7 @@ + org.apache.maven.plugins maven-surefire-plugin ${skipTests} @@ -177,7 +194,6 @@ org.apache.maven.plugins maven-antrun-plugin - 1.6 create-version-txt @@ -205,7 +221,6 @@ org.apache.maven.plugins maven-assembly-plugin - 2.2.1 distro-assembly @@ -221,6 +236,10 @@ + + org.codehaus.mojo + versions-maven-plugin + ${project.artifactId}-${project.version}-r${buildNumber} From b4dd214e7091dee111b07556db253ccab70fdfc6 Mon Sep 17 00:00:00 2001 From: Omertron Date: Fri, 17 Jun 2011 15:11:11 +0000 Subject: [PATCH 076/207] Update server information in POM.xml --- themoviedbapi/.classpath | 2 ++ themoviedbapi/pom.xml | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/themoviedbapi/.classpath b/themoviedbapi/.classpath index 3a4681cd0..943b5e150 100644 --- a/themoviedbapi/.classpath +++ b/themoviedbapi/.classpath @@ -1,7 +1,9 @@ + + diff --git a/themoviedbapi/pom.xml b/themoviedbapi/pom.xml index 97bd4d39c..c4728de97 100644 --- a/themoviedbapi/pom.xml +++ b/themoviedbapi/pom.xml @@ -18,7 +18,7 @@ Hudson CI - http://mediadeveloper.org:8080/job/API-TheMovieDb/ + http://jenkins.omertron.com/job/API-TheMovieDb/ From 70de0c781a8ab750b10c0ef0d7d9114543b7c216 Mon Sep 17 00:00:00 2001 From: Omertron Date: Wed, 20 Jul 2011 13:59:22 +0000 Subject: [PATCH 077/207] All tests now complete successfully --- .../moviejukebox/themoviedb/TheMovieDb.java | 92 +++++++------ .../themoviedb/model/Artwork.java | 15 +++ .../themoviedb/model/Category.java | 15 +++ .../themoviedb/model/Country.java | 13 ++ .../themoviedb/model/Filmography.java | 19 +++ .../themoviedb/model/Language.java | 13 ++ .../themoviedb/model/MovieDB.java | 61 +++++++++ .../moviejukebox/themoviedb/model/Person.java | 41 ++++++ .../moviejukebox/themoviedb/model/Studio.java | 13 ++ .../themoviedb/tools/DOMHelper.java | 4 +- .../themoviedb/tools/MovieDbParser.java | 125 ++++++++++-------- .../themoviedb/TheMovieDbTest.java | 113 +++++++++++----- 12 files changed, 391 insertions(+), 133 deletions(-) diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java index 578684e4c..8b219788a 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java @@ -45,8 +45,8 @@ public class TheMovieDb { private static Logger logger = null; private static LogFormatter tmdbFormatter = new LogFormatter(); private static ConsoleHandler tmdbConsoleHandler = new ConsoleHandler(); - private static final String apiSite = "http://api.themoviedb.org/2.1/"; - private static final String defaultLanguage = "en-US"; + private static final String API_SITE = "http://api.themoviedb.org/2.1/"; + private static final String DEFAULT_LANGUAGE = "en-US"; /** * Compare the MovieDB object with a title & year @@ -199,15 +199,16 @@ public class TheMovieDb { * @return */ private String buildIds(List ids) { - String s = ""; + StringBuilder builder = new StringBuilder(); + for (int i = 0; i < ids.size(); i++) { if (i == 0) { - s += ids.get(i); + builder.append(ids.get(i)); continue; } - s += "," + ids.get(i); + builder.append(",").append(ids.get(i)); } - return s; + return builder.toString(); } /** @@ -219,30 +220,33 @@ public class TheMovieDb { * @return The search URL */ private String buildUrl(String prefix, String searchTerm, String language) { - String url = apiSite + prefix + "/" + language + "/xml/" + apiKey; + StringBuilder url = new StringBuilder(); + + url.append(API_SITE); + url.append(prefix); + url.append("/"); + url.append(language); + url.append("/xml/"); + url.append(apiKey); if (!isValidString(searchTerm)) { - return url; - } - - String encodedSearchTerm; - - try { - encodedSearchTerm = URLEncoder.encode(searchTerm, "UTF-8"); - } catch (UnsupportedEncodingException e) { - encodedSearchTerm = searchTerm; + return url.toString(); } if (prefix.equals(MOVIE_BROWSE)) { - url += "?"; + url.append("?"); } else { - url += "/"; + url.append("/"); } - url += encodedSearchTerm; + // Try to encode the search term to append + try { + url.append(URLEncoder.encode(searchTerm, "UTF-8")); + } catch (UnsupportedEncodingException e) { + url.append(searchTerm); + } - logger.finest("Search URL: " + url); - return url; + return url.toString(); } /** @@ -267,7 +271,7 @@ public class TheMovieDb { * @return */ public String getDefaultLanguage() { - return defaultLanguage; + return DEFAULT_LANGUAGE; } public List getTranslations(String movieId, String language) { @@ -287,12 +291,11 @@ public class TheMovieDb { * @param language the two digit language code. E.g. en=English * @return a list of MovieDB objects */ - public List moviedbBrowse(String orderBy, String order, - Map parameters, String language) { + public List moviedbBrowse(String orderBy, String order, Map parameters, String language) { List movies = new ArrayList(); if (!isValidString(orderBy) || (!isValidString(order)) - || (parameters == null)) { + || (parameters == null) || parameters.isEmpty()) { return movies; } @@ -312,17 +315,27 @@ public class TheMovieDb { validParameters.add("companies"); validParameters.add("countries"); - String url = "order_by=" + orderBy + "&order=" + order; + + StringBuilder searchUrl = new StringBuilder(); + searchUrl.append("order_by=").append(orderBy); + searchUrl.append("&order=").append(order); + if(!parameters.isEmpty()) { for (String key : validParameters) { if (parameters.containsKey(key)) { - url += "&" + key + "=" + parameters.get(key); + searchUrl.append("&").append(key).append("=").append(parameters.get(key)); } } } - String searchUrl = buildUrl(MOVIE_BROWSE, url, language); - return MovieDbParser.parseMovies(searchUrl); + // Get the search url + String baseUrl = buildUrl(MOVIE_BROWSE, "", language); + + // Now append the parameter url to the end of the search url + searchUrl.insert(0, "?"); + searchUrl.insert(0, baseUrl); + + return MovieDbParser.parseMovies(searchUrl.toString()); } @@ -338,7 +351,7 @@ public class TheMovieDb { * @return a list of MovieDB objects */ public List moviedbBrowse(String orderBy, String order, String language) { - return this.moviedbBrowse(orderBy, order, new HashMap(), language); + return moviedbBrowse(orderBy, order, new HashMap(), language); } /** @@ -394,9 +407,9 @@ public class TheMovieDb { String searchUrl = buildUrl(MOVIE_GET_INFO, tmdbID, language); movie = MovieDbParser.parseMovie(searchUrl); - if (movie == null && !language.equalsIgnoreCase(defaultLanguage)) { - logger.fine("Trying to get the '" + defaultLanguage + "' version"); - searchUrl = buildUrl(MOVIE_GET_INFO, tmdbID, defaultLanguage); + if (movie == null && !language.equalsIgnoreCase(DEFAULT_LANGUAGE)) { + logger.fine("Trying to get the '" + DEFAULT_LANGUAGE + "' version"); + searchUrl = buildUrl(MOVIE_GET_INFO, tmdbID, DEFAULT_LANGUAGE); movie = MovieDbParser.parseMovie(searchUrl); } @@ -426,7 +439,8 @@ public class TheMovieDb { * @return */ public MovieDB moviedbGetLatest(String language) { - return MovieDbParser.parseLatestMovie(buildUrl(MOVIE_GET_LATEST, "", language)); + String searchUrl = buildUrl(MOVIE_GET_LATEST, "", language); + return MovieDbParser.parseLatestMovie(searchUrl); } /** @@ -446,7 +460,6 @@ public class TheMovieDb { List movies = new ArrayList(); if ((movieIds == null) || movieIds.isEmpty()) { - logger.warning("There are no Movie ids!"); return movies; } @@ -518,9 +531,9 @@ public class TheMovieDb { * @param language * @return */ - public Person personGetInfo(String personID, String language) { + public ArrayList personGetInfo(String personID, String language) { if (!isValidString(personID)) { - return new Person(); + return new ArrayList(); } String searchUrl = buildUrl(PERSON_GET_INFO, personID, language); @@ -549,7 +562,6 @@ public class TheMovieDb { */ public List personGetVersion(List personIDs, String language) { if ((personIDs == null) || (personIDs.isEmpty())) { - logger.warning("There are no Person ids!"); return new ArrayList(); } @@ -589,9 +601,9 @@ public class TheMovieDb { * @param language * @return */ - public Person personSearch(String personName, String language) { + public ArrayList personSearch(String personName, String language) { if (!isValidString(personName)) { - return new Person(); + return new ArrayList(); } String searchUrl = buildUrl(PERSON_SEARCH, personName, language); diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Artwork.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Artwork.java index 23ea3e9a7..79872791b 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Artwork.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Artwork.java @@ -101,4 +101,19 @@ public class Artwork implements Comparable { int anotherId = ((Artwork) otherArtwork).getId(); return this.id - anotherId; } + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("[Artwork=[type="); + builder.append(type); + builder.append("][size="); + builder.append(size); + builder.append("][url="); + builder.append(url); + builder.append("][id="); + builder.append(id); + builder.append("]]"); + return builder.toString(); + } } diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Category.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Category.java index 22f418ab1..af054e065 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Category.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Category.java @@ -58,4 +58,19 @@ public class Category { public void setUrl(String url) { this.url = url; } + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("[Category=[type="); + builder.append(type); + builder.append("][name="); + builder.append(name); + builder.append("][url="); + builder.append(url); + builder.append("][id="); + builder.append(id); + builder.append("]]"); + return builder.toString(); + } } diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Country.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Country.java index e1b0ab6de..207365506 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Country.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Country.java @@ -49,4 +49,17 @@ public class Country { public void setCode(String code) { this.code = code; } + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("[Country=[url="); + builder.append(url); + builder.append("][name="); + builder.append(name); + builder.append("][code="); + builder.append(code); + builder.append("]]"); + return builder.toString(); + } } diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Filmography.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Filmography.java index e6b4f8d55..0c193e6ea 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Filmography.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Filmography.java @@ -71,4 +71,23 @@ public class Filmography { public void setId(String id) { this.id = id; } + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("[Filmography=[url="); + builder.append(url); + builder.append("][name="); + builder.append(name); + builder.append("][department="); + builder.append(department); + builder.append("][character="); + builder.append(character); + builder.append("][job="); + builder.append(job); + builder.append("][id="); + builder.append(id); + builder.append("]]"); + return builder.toString(); + } } diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Language.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Language.java index f66a8f155..ce4c9a64c 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Language.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Language.java @@ -60,6 +60,19 @@ public class Language { public void setNativeName(String nativeName) { this.nativeName = nativeName; } + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("[Language=[isoCode="); + builder.append(isoCode); + builder.append("][englishName="); + builder.append(englishName); + builder.append("][nativeName="); + builder.append(nativeName); + builder.append("]]"); + return builder.toString(); + } } diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/MovieDB.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/MovieDB.java index ab056e5e9..b764a5c05 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/MovieDB.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/MovieDB.java @@ -310,4 +310,65 @@ public class MovieDB extends ModelTools { public void setVersion(int version) { this.version = version; } + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("[MovieDB=[popularity="); + builder.append(popularity); + builder.append("][translated="); + builder.append(translated); + builder.append("][adult="); + builder.append(adult); + builder.append("][language="); + builder.append(language); + builder.append("][title="); + builder.append(title); + builder.append("][originalName="); + builder.append(originalName); + builder.append("][alternativeName="); + builder.append(alternativeName); + builder.append("][type="); + builder.append(type); + builder.append("][id="); + builder.append(id); + builder.append("][imdb="); + builder.append(imdb); + builder.append("][url="); + builder.append(url); + builder.append("][overview="); + builder.append(overview); + builder.append("][rating="); + builder.append(rating); + builder.append("][tagline="); + builder.append(tagline); + builder.append("][certification="); + builder.append(certification); + builder.append("][releaseDate="); + builder.append(releaseDate); + builder.append("][runtime="); + builder.append(runtime); + builder.append("][budget="); + builder.append(budget); + builder.append("][revenue="); + builder.append(revenue); + builder.append("][homepage="); + builder.append(homepage); + builder.append("][trailer="); + builder.append(trailer); + builder.append("][version="); + builder.append(version); + builder.append("][lastModifiedAt="); + builder.append(lastModifiedAt); + builder.append("][categories="); + builder.append(categories); + builder.append("][studios="); + builder.append(studios); + builder.append("][countries="); + builder.append(countries); + builder.append("][people="); + builder.append(people); + builder.append("]]"); + return builder.toString(); + } } diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Person.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Person.java index 1a1ba07de..163e4be6b 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Person.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Person.java @@ -234,4 +234,45 @@ public class Person extends ModelTools { public void setVersion(int version) { this.version = version; } + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("[Person=[name="); + builder.append(name); + builder.append("][character="); + builder.append(character); + builder.append("][job="); + builder.append(job); + builder.append("][id="); + builder.append(id); + builder.append("][department="); + builder.append(department); + builder.append("][biography="); + builder.append(biography); + builder.append("][url="); + builder.append(url); + builder.append("][order="); + builder.append(order); + builder.append("][castId="); + builder.append(castId); + builder.append("][version="); + builder.append(version); + builder.append("][lastModifiedAt="); + builder.append(lastModifiedAt); + builder.append("][knownMovies="); + builder.append(knownMovies); + builder.append("][birthday="); + builder.append(birthday); + builder.append("][birthPlace="); + builder.append(birthPlace); + builder.append("][filmography="); + builder.append(filmography); + builder.append("][aka="); + builder.append(aka); + builder.append("][images="); + builder.append(images); + builder.append("]]"); + return builder.toString(); + } } diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Studio.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Studio.java index 1238669b1..6c18cd730 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Studio.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Studio.java @@ -49,4 +49,17 @@ public class Studio { public void setUrl(String url) { this.url = url; } + + @Override + public String toString() { + StringBuilder builder = new StringBuilder(); + builder.append("[Studio=[name="); + builder.append(name); + builder.append("][url="); + builder.append(url); + builder.append("][id="); + builder.append(id); + builder.append("]]"); + return builder.toString(); + } } diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/DOMHelper.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/DOMHelper.java index 612ab6db8..f7ac0532a 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/DOMHelper.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/DOMHelper.java @@ -81,7 +81,7 @@ public class DOMHelper { // This looks like a valid web page validWebPage = true; } else { - logger.fine("Error with API Call for: " + url); + logger.fine("DOMHelper: Error with API Call for: " + url); return null; } @@ -94,7 +94,7 @@ public class DOMHelper { doc.getDocumentElement().normalize(); } } catch (Exception error) { - logger.fine("Error parsing: " + url); + logger.fine("DOMHelper: Error parsing: " + url); // Some sort of error occurred getting the data, so clear the document doc = null; } finally { diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/MovieDbParser.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/MovieDbParser.java index b9b6ea934..40ff0c443 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/MovieDbParser.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/MovieDbParser.java @@ -541,7 +541,8 @@ public class MovieDbParser { return people; } - public static Person parsePersonInfo(String searchUrl) { + public static ArrayList parsePersonInfo(String searchUrl) { + ArrayList people = new ArrayList(); Person person = null; Document doc = null; @@ -549,76 +550,90 @@ public class MovieDbParser { doc = DOMHelper.getEventDocFromUrl(searchUrl); } catch (Exception error) { logger.severe("PersonSearch error: " + error.getMessage()); - return person; + return people; } if (doc == null) { - return person; + return people; } - try { + NodeList personNodeList = doc.getElementsByTagName("person"); + + + if ((personNodeList == null) || personNodeList.getLength() == 0) { + return people; + } + + for (int loop = 0; loop < personNodeList.getLength(); loop++) { + Node personNode = personNodeList.item(loop); person = new Person(); - NodeList personNodeList = doc.getElementsByTagName("person"); - - // Only get the first movie from the list - Node personNode = personNodeList.item(0); - + if (personNode == null) { logger.finest("Person not found"); - return person; + return people; } if (personNode.getNodeType() == Node.ELEMENT_NODE) { - Element personElement = (Element) personNode; - - person.setName(DOMHelper.getValueFromElement(personElement, "name")); - person.setId(DOMHelper.getValueFromElement(personElement, "id")); - person.setBiography(DOMHelper.getValueFromElement(personElement, "biography")); - person.setKnownMovies(Integer.parseInt(DOMHelper.getValueFromElement(personElement, "known_movies"))); - person.setBirthday(DOMHelper.getValueFromElement(personElement, "birthday")); - person.setBirthPlace(DOMHelper.getValueFromElement(personElement, "birthplace")); - person.setUrl(DOMHelper.getValueFromElement(personElement, "url")); - person.setVersion(Integer.parseInt(DOMHelper.getValueFromElement(personElement, "version"))); - person.setLastModifiedAt(DOMHelper.getValueFromElement(personElement, "last_modified_at")); - - NodeList artworkNodeList = doc.getElementsByTagName("image"); - for (int nodeLoop = 0; nodeLoop < artworkNodeList.getLength(); nodeLoop++) { - Node artworkNode = artworkNodeList.item(nodeLoop); - if (artworkNode.getNodeType() == Node.ELEMENT_NODE) { - Element artworkElement = (Element) artworkNode; - Artwork artwork = new Artwork(); - artwork.setType(artworkElement.getAttribute("type")); - artwork.setUrl(artworkElement.getAttribute("url")); - artwork.setSize(artworkElement.getAttribute("size")); - artwork.setId(artworkElement.getAttribute("id")); - person.addArtwork(artwork); + try { + Element personElement = (Element) personNode; + + person.setName(DOMHelper.getValueFromElement(personElement, "name")); + person.setId(DOMHelper.getValueFromElement(personElement, "id")); + person.setBiography(DOMHelper.getValueFromElement(personElement, "biography")); + + try { + person.setKnownMovies(Integer.parseInt(DOMHelper.getValueFromElement(personElement, "known_movies"))); + } catch (NumberFormatException error) { + person.setKnownMovies(0); } - } - - NodeList filmNodeList = doc.getElementsByTagName("movie"); - for (int nodeLoop = 0; nodeLoop < filmNodeList.getLength(); nodeLoop++) { - Node filmNode = filmNodeList.item(nodeLoop); - if (filmNode.getNodeType() == Node.ELEMENT_NODE) { - Element filmElement = (Element) filmNode; - Filmography film = new Filmography(); - - film.setCharacter(filmElement.getAttribute("character")); - film.setDepartment(filmElement.getAttribute("department")); - film.setId(filmElement.getAttribute("id")); - film.setJob(filmElement.getAttribute("job")); - film.setName(filmElement.getAttribute("name")); - film.setUrl(filmElement.getAttribute("url")); - - person.addFilm(film); + + person.setBirthday(DOMHelper.getValueFromElement(personElement, "birthday")); + person.setBirthPlace(DOMHelper.getValueFromElement(personElement, "birthplace")); + person.setUrl(DOMHelper.getValueFromElement(personElement, "url")); + person.setVersion(Integer.parseInt(DOMHelper.getValueFromElement(personElement, "version"))); + person.setLastModifiedAt(DOMHelper.getValueFromElement(personElement, "last_modified_at")); + + NodeList artworkNodeList = doc.getElementsByTagName("image"); + for (int nodeLoop = 0; nodeLoop < artworkNodeList.getLength(); nodeLoop++) { + Node artworkNode = artworkNodeList.item(nodeLoop); + if (artworkNode.getNodeType() == Node.ELEMENT_NODE) { + Element artworkElement = (Element) artworkNode; + Artwork artwork = new Artwork(); + artwork.setType(artworkElement.getAttribute("type")); + artwork.setUrl(artworkElement.getAttribute("url")); + artwork.setSize(artworkElement.getAttribute("size")); + artwork.setId(artworkElement.getAttribute("id")); + person.addArtwork(artwork); + } } + + NodeList filmNodeList = doc.getElementsByTagName("movie"); + for (int nodeLoop = 0; nodeLoop < filmNodeList.getLength(); nodeLoop++) { + Node filmNode = filmNodeList.item(nodeLoop); + if (filmNode.getNodeType() == Node.ELEMENT_NODE) { + Element filmElement = (Element) filmNode; + Filmography film = new Filmography(); + + film.setCharacter(filmElement.getAttribute("character")); + film.setDepartment(filmElement.getAttribute("department")); + film.setId(filmElement.getAttribute("id")); + film.setJob(filmElement.getAttribute("job")); + film.setName(filmElement.getAttribute("name")); + film.setUrl(filmElement.getAttribute("url")); + + person.addFilm(film); + } + } + + people.add(person); + } catch (Exception error) { + logger.severe("PersonInfo: " + error.getMessage()); + error.printStackTrace(); } } - } catch (Exception error) { - logger.severe("ERROR: " + error.getMessage()); - error.printStackTrace(); } - - return person; + + return people; } /** diff --git a/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java b/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java index 8b319514e..ba28683ab 100644 --- a/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java +++ b/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java @@ -12,19 +12,25 @@ */ package com.moviejukebox.themoviedb; -import com.moviejukebox.themoviedb.model.Category; -import java.util.Map; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertNull; +import static org.junit.Assert.assertTrue; + import java.util.ArrayList; -import java.util.List; -import com.moviejukebox.themoviedb.model.Person; -import com.moviejukebox.themoviedb.model.MovieDB; import java.util.HashMap; +import java.util.List; +import java.util.Map; + import org.junit.After; import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; -import static org.junit.Assert.*; + +import com.moviejukebox.themoviedb.model.Category; +import com.moviejukebox.themoviedb.model.MovieDB; +import com.moviejukebox.themoviedb.model.Person; /** * JUnit tests for TheMovieDb class. The tester must enter its IMDb API key for @@ -33,7 +39,7 @@ import static org.junit.Assert.*; */ public class TheMovieDbTest { - private static String apikey = ""; + private static String apikey = "5a1a77e2eba8984804586122754f969f"; private TheMovieDb tmdb; public TheMovieDbTest() { @@ -95,37 +101,56 @@ public class TheMovieDbTest { //*** Start moviedbBrowse @Test public void testMoviedbBrowseRatingAsc() { - List movies = tmdb.moviedbBrowse("rating", "asc", "en"); + Map params = new HashMap(); + params.put("year", "2011"); + + List movies = tmdb.moviedbBrowse("rating", "asc", params, "en"); + assertFalse(movies.isEmpty()); } @Test public void testMoviedbBrowseReleaseAsc() { - List movies = tmdb.moviedbBrowse("release", "asc", "en"); + Map params = new HashMap(); + params.put("year", "2011"); + + List movies = tmdb.moviedbBrowse("release", "asc", params, "en"); assertFalse(movies.isEmpty()); } @Test public void testMoviedbBrowseTitleAsc() { - List movies = tmdb.moviedbBrowse("title", "asc", "en"); + Map params = new HashMap(); + params.put("year", "2011"); + + List movies = tmdb.moviedbBrowse("title", "asc", params, "en"); assertFalse(movies.isEmpty()); } @Test public void testMoviedbBrowseRatingDesc() { - List movies = tmdb.moviedbBrowse("rating", "desc", "en"); + Map params = new HashMap(); + params.put("year", "2011"); + + List movies = tmdb.moviedbBrowse("rating", "desc", params, "en"); assertFalse(movies.isEmpty()); } @Test public void testMoviedbBrowseReleaseDesc() { - List movies = tmdb.moviedbBrowse("release", "desc", "en"); + Map params = new HashMap(); + params.put("year", "2011"); + + List movies = tmdb.moviedbBrowse("release", "desc", params, "en"); assertFalse(movies.isEmpty()); } @Test public void testMoviedbBrowseTitleDesc() { - List movies = tmdb.moviedbBrowse("title", "desc", "en"); + Map params = new HashMap(); + params.put("year", "2011"); + + List movies = tmdb.moviedbBrowse("title", "desc", params, "en"); assertFalse(movies.isEmpty()); } @@ -297,7 +322,7 @@ public class TheMovieDbTest { assertEquals("585", movies.get(0).getId()); assertEquals("tt0198781", movies.get(0).getImdb()); - assertEquals("Star Wars: Episode IV - A New Hope", movies.get(1).getTitle()); + assertEquals("Star Wars: Episode IV: A New Hope", movies.get(1).getTitle()); assertEquals("11", movies.get(1).getId()); assertEquals("tt0076759", movies.get(1).getImdb()); @@ -315,54 +340,70 @@ public class TheMovieDbTest { assertTrue(movies.isEmpty()); } - //@Test + @Test public void testMoviedbGetImages_String_String() { } - //@Test + @Test public void testMoviedbGetImages_3args() { } @Test public void testPersonSearch() { - Person person = tmdb.personSearch("Tom Cruise", "en"); + ArrayList people = tmdb.personSearch("Tom Cruise", "en"); + + Person person = new Person(); + + for (Person foundPerson : people) { + if (foundPerson.getId().equals("500")) { + person = foundPerson; + break; + } + } + assertEquals("Tom Cruise", person.getName()); assertEquals("500", person.getId()); } @Test public void testPersonSearch_withEmptyName() { - Person person = tmdb.personSearch("", "en"); - assertTrue(person.getName().equals(MovieDB.UNKNOWN)); - assertTrue(person.getId().equals(MovieDB.UNKNOWN)); + ArrayList people = tmdb.personSearch("", "en"); + assertTrue(people.isEmpty()); } @Test public void testPersonSearch_withNullName() { - Person person = tmdb.personSearch((String) null, "en"); - assertTrue(person.getName().equals(MovieDB.UNKNOWN)); - assertTrue(person.getId().equals(MovieDB.UNKNOWN)); + ArrayList people = tmdb.personSearch((String) null, "en"); + assertTrue(people.isEmpty()); } @Test public void testPersonGetInfo() { - Person person = tmdb.personGetInfo("260", "en"); + ArrayList people = tmdb.personGetInfo("260", "en"); + + Person person = new Person(); + + for (Person foundPerson : people) { + if (foundPerson.getId().equals("260")) { + person = foundPerson; + break; + } + } + assertEquals("Marco Pérez", person.getName()); assertEquals("260", person.getId()); } @Test public void testPersonGetInfo_withEmptyId() { - Person person = tmdb.personGetInfo("", "en"); - assertTrue(person.getName().equals(MovieDB.UNKNOWN)); - assertTrue(person.getId().equals(MovieDB.UNKNOWN)); + ArrayList people = tmdb.personGetInfo("", "en"); + assertTrue(people.isEmpty()); } @Test public void testPersonGetInfo_withNullId() { - Person person = tmdb.personGetInfo((String) null, "en"); - assertTrue(person.getName().equals(MovieDB.UNKNOWN)); - assertTrue(person.getId().equals(MovieDB.UNKNOWN)); + ArrayList people = tmdb.personGetInfo((String) null, "en"); + assertTrue(people.isEmpty()); } @Test @@ -429,10 +470,10 @@ public class TheMovieDbTest { public void testGetCategories() { List genres = tmdb.getCategories("en"); assertFalse(genres.isEmpty()); - assertEquals(30, genres.size()); + assertTrue(genres.size() > 0); } - //@Test + @Test public void testFindMovie() { } @@ -442,16 +483,16 @@ public class TheMovieDbTest { assertTrue(TheMovieDb.compareMovies(movie, "Inception", "2010")); } - //@Test + @Test public void testCompareMovies_sameTitleAndDifferentYear() { MovieDB movie = tmdb.moviedbGetInfo("27205", "en"); - assertTrue(TheMovieDb.compareMovies(movie, "Inception", "1999")); + assertFalse(TheMovieDb.compareMovies(movie, "Inception", "1999")); } - //@Test + @Test public void testCompareMovies_differentTitleAndSameYear() { MovieDB movie = tmdb.moviedbGetInfo("27205", "en"); - assertTrue(TheMovieDb.compareMovies(movie, "xxx", "2010")); + assertFalse(TheMovieDb.compareMovies(movie, "xxx", "2010")); } @Test From 0bb538c240aa3be37d42b9c08ab414efd21c741e Mon Sep 17 00:00:00 2001 From: Omertron Date: Wed, 20 Jul 2011 14:01:56 +0000 Subject: [PATCH 078/207] remove debug key --- .../test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java b/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java index ba28683ab..1dd9427b5 100644 --- a/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java +++ b/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java @@ -39,7 +39,7 @@ import com.moviejukebox.themoviedb.model.Person; */ public class TheMovieDbTest { - private static String apikey = "5a1a77e2eba8984804586122754f969f"; + private static String apikey = ""; private TheMovieDb tmdb; public TheMovieDbTest() { From 7bae6756a65930dd17db2028baa2dacd67333187 Mon Sep 17 00:00:00 2001 From: Omertron Date: Wed, 20 Jul 2011 20:01:57 +0000 Subject: [PATCH 079/207] Tidied up some methods Removed some Sonar Critical issues --- .../moviejukebox/themoviedb/TheMovieDb.java | 4 +-- .../themoviedb/model/Artwork.java | 16 ++++++++++++ .../moviejukebox/themoviedb/tools/Base64.java | 26 +++++++++---------- .../themoviedb/tools/MovieDbParser.java | 4 --- 4 files changed, 29 insertions(+), 21 deletions(-) diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java index 8b219788a..1e6c41198 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java @@ -424,9 +424,7 @@ public class TheMovieDb { * @return A movie bean with all of the information */ public MovieDB moviedbGetInfo(String tmdbID, String language) { - MovieDB movie = null; - movie = moviedbGetInfo(tmdbID, movie, language); - return movie; + return moviedbGetInfo(tmdbID, new MovieDB(), language); } /** diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Artwork.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Artwork.java index 79872791b..61f7b3309 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Artwork.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Artwork.java @@ -116,4 +116,20 @@ public class Artwork implements Comparable { builder.append("]]"); return builder.toString(); } + + + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (obj == null) + return false; + if (getClass() != obj.getClass()) + return false; + Artwork other = (Artwork)obj; + if (id != other.id) + return false; + return true; + } } diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/Base64.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/Base64.java index 8af02639e..b6f54b773 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/Base64.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/Base64.java @@ -13,28 +13,26 @@ package com.moviejukebox.themoviedb.tools; public class Base64 { - public static String base64code = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + - "abcdefghijklmnopqrstuvwxyz" + "0123456789" + "+/"; + public static String base64code = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "abcdefghijklmnopqrstuvwxyz" + "0123456789" + "+/"; public static int splitLinesAt = 76; - public static String base64Encode(String string) { - String encoded = ""; + public static String base64Encode(String string) { + String unEncoded = string; // Copy the string so we can modify it + StringBuffer encoded = new StringBuffer(); // determine how many padding bytes to add to the output - int paddingCount = (3 - (string.length() % 3)) % 3; + int paddingCount = (3 - (unEncoded.length() % 3)) % 3; // add any necessary padding to the input - string += "\0\0".substring(0, paddingCount); + unEncoded += "\0\0".substring(0, paddingCount); // process 3 bytes at a time, churning out 4 output bytes // worry about CRLF insertions later - for (int i = 0; i < string.length(); i += 3) { - int j = (string.charAt(i) << 16) + (string.charAt(i + 1) << 8) + string.charAt(i + 2); - encoded = encoded + base64code.charAt((j >> 18) & 0x3f) + - base64code.charAt((j >> 12) & 0x3f) + - base64code.charAt((j >> 6) & 0x3f) + - base64code.charAt(j & 0x3f); + for (int i = 0; i < unEncoded.length(); i += 3) { + int j = (unEncoded.charAt(i) << 16) + (unEncoded.charAt(i + 1) << 8) + unEncoded.charAt(i + 2); + encoded.append(base64code.charAt((j >> 18) & 0x3f) + base64code.charAt((j >> 12) & 0x3f) + base64code.charAt((j >> 6) & 0x3f) + + base64code.charAt(j & 0x3f)); } // replace encoded padding nulls with "=" // return encoded; - return "Basic " + encoded; + return "Basic " + encoded.toString(); } -} \ No newline at end of file +} diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/MovieDbParser.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/MovieDbParser.java index 40ff0c443..3827995a5 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/MovieDbParser.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/MovieDbParser.java @@ -136,8 +136,6 @@ public class MovieDbParser { Node node = nlMovies.item(0); if (node.getNodeType() == Node.ELEMENT_NODE) { - movie = new MovieDB(); - Element element = (Element) node; movie = MovieDbParser.parseSimpleMovie(element); } @@ -168,8 +166,6 @@ public class MovieDbParser { Node node = nlMovies.item(0); if (node.getNodeType() == Node.ELEMENT_NODE) { - person = new Person(); - Element element = (Element) node; person = MovieDbParser.parseSimplePerson(element); } From 0c524ecb87780ddd71910a970eb8b61c3e393db9 Mon Sep 17 00:00:00 2001 From: Omertron Date: Wed, 20 Jul 2011 21:02:50 +0000 Subject: [PATCH 080/207] Tidied up some methods Removed some Sonar issues --- .../moviejukebox/themoviedb/TheMovieDb.java | 8 +- .../themoviedb/model/Artwork.java | 56 +++++++- .../moviejukebox/themoviedb/model/Person.java | 3 +- .../moviejukebox/themoviedb/tools/Base64.java | 4 +- .../themoviedb/tools/DOMHelper.java | 2 +- .../themoviedb/tools/LogFormatter.java | 6 +- .../themoviedb/tools/ModelTools.java | 14 +- .../themoviedb/tools/MovieDbParser.java | 120 ++++++++++-------- .../themoviedb/tools/WebBrowser.java | 13 +- 9 files changed, 141 insertions(+), 85 deletions(-) diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java index 1e6c41198..dbd8e45a4 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java @@ -405,15 +405,15 @@ public class TheMovieDb { } String searchUrl = buildUrl(MOVIE_GET_INFO, tmdbID, language); - movie = MovieDbParser.parseMovie(searchUrl); + MovieDB foundMovie = MovieDbParser.parseMovie(searchUrl); - if (movie == null && !language.equalsIgnoreCase(DEFAULT_LANGUAGE)) { + if (foundMovie == null && !language.equalsIgnoreCase(DEFAULT_LANGUAGE)) { logger.fine("Trying to get the '" + DEFAULT_LANGUAGE + "' version"); searchUrl = buildUrl(MOVIE_GET_INFO, tmdbID, DEFAULT_LANGUAGE); - movie = MovieDbParser.parseMovie(searchUrl); + foundMovie = MovieDbParser.parseMovie(searchUrl); } - return movie; + return foundMovie; } /** diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Artwork.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Artwork.java index 61f7b3309..c180c8c91 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Artwork.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Artwork.java @@ -96,8 +96,10 @@ public class Artwork implements Comparable { @Override public int compareTo(Object otherArtwork) throws ClassCastException { - if (!(otherArtwork instanceof Artwork)) + if (!(otherArtwork instanceof Artwork)) { throw new ClassCastException("TheMovieDB API: An Artwork object is expected."); + } + int anotherId = ((Artwork) otherArtwork).getId(); return this.id - anotherId; } @@ -117,19 +119,61 @@ public class Artwork implements Comparable { return builder.toString(); } - + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + id; + result = prime * result + ((size == null) ? 0 : size.hashCode()); + result = prime * result + ((type == null) ? 0 : type.hashCode()); + result = prime * result + ((url == null) ? 0 : url.hashCode()); + return result; + } @Override public boolean equals(Object obj) { - if (this == obj) + if (this == obj) { return true; - if (obj == null) + } + + if (obj == null) { return false; - if (getClass() != obj.getClass()) + } + + if (!(obj instanceof Artwork)) { return false; + } + Artwork other = (Artwork)obj; - if (id != other.id) + + if (id != other.id) { return false; + } + + if (size == null) { + if (other.size != null) { + return false; + } + } else if (!size.equals(other.size)) { + return false; + } + + if (type == null) { + if (other.type != null) { + return false; + } + } else if (!type.equals(other.type)) { + return false; + } + + if (url == null) { + if (other.url != null) { + return false; + } + } else if (!url.equals(other.url)) { + return false; + } + return true; } } diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Person.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Person.java index 163e4be6b..6aa132ffe 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Person.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Person.java @@ -145,8 +145,7 @@ public class Person extends ModelTools { DateFormat df = new SimpleDateFormat("yyyy-MM-dd"); try { - Date birthday = df.parse(sBirthday); - setBirthday(birthday); + setBirthday(df.parse(sBirthday)); } catch (Exception ignore) { return; } diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/Base64.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/Base64.java index b6f54b773..7560e50a2 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/Base64.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/Base64.java @@ -13,9 +13,7 @@ package com.moviejukebox.themoviedb.tools; public class Base64 { - public static String base64code = "ABCDEFGHIJKLMNOPQRSTUVWXYZ" + "abcdefghijklmnopqrstuvwxyz" + "0123456789" + "+/"; - - public static int splitLinesAt = 76; + private static final String base64code = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; public static String base64Encode(String string) { String unEncoded = string; // Copy the string so we can modify it diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/DOMHelper.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/DOMHelper.java index f7ac0532a..22146b0e4 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/DOMHelper.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/DOMHelper.java @@ -35,7 +35,7 @@ import com.moviejukebox.themoviedb.TheMovieDb; * */ public class DOMHelper { - static Logger logger = TheMovieDb.getLogger(); + private static Logger logger = TheMovieDb.getLogger(); /** * Gets the string value of the tag element name passed diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/LogFormatter.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/LogFormatter.java index c000d4841..f0e4bddff 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/LogFormatter.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/LogFormatter.java @@ -17,7 +17,7 @@ import java.util.logging.LogRecord; public class LogFormatter extends java.util.logging.Formatter { - private static String API_KEY = null; + private static String apiKey = null; private static String EOL = (String)java.security.AccessController.doPrivileged(new PrivilegedAction() { public Object run() { return System.getProperty("line.separator"); @@ -27,7 +27,7 @@ public class LogFormatter extends java.util.logging.Formatter public synchronized String format(LogRecord logRecord) { String logMessage = logRecord.getMessage(); - logMessage = "[TheMovieDb API] " + logMessage.replace(API_KEY, "[APIKEY]") + EOL; + logMessage = "[TheMovieDb API] " + logMessage.replace(apiKey, "[APIKEY]") + EOL; Throwable thrown = logRecord.getThrown(); if (thrown != null) { @@ -37,7 +37,7 @@ public class LogFormatter extends java.util.logging.Formatter } public void addApiKey(String apiKey) { - API_KEY = apiKey; + LogFormatter.apiKey = apiKey; return; } } diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/ModelTools.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/ModelTools.java index 67de92a07..89b8ccbe8 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/ModelTools.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/ModelTools.java @@ -149,12 +149,14 @@ public class ModelTools { return null; } + + int validArtworkNumber = artworkNumber; // Validate the number - if (artworkNumber <= 0) { - artworkNumber = 0; + if (validArtworkNumber <= 0) { + validArtworkNumber = 0; } else { // Artwork elements start at 0 (Zero) - artworkNumber -= 1; + validArtworkNumber -= 1; } List artworkList = getArtwork(artworkType, artworkSize); @@ -165,11 +167,11 @@ public class ModelTools { } // If the number requested is greater than the array size, loop around until it's within scope - while (artworkNumber > artworkCount) { - artworkNumber = artworkNumber - artworkCount; + while (validArtworkNumber > artworkCount) { + validArtworkNumber = validArtworkNumber - artworkCount; } - return artworkList.get(artworkNumber); + return artworkList.get(validArtworkNumber); } } diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/MovieDbParser.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/MovieDbParser.java index 3827995a5..d927f46a1 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/MovieDbParser.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/MovieDbParser.java @@ -12,6 +12,9 @@ */ package com.moviejukebox.themoviedb.tools; +import java.io.PrintWriter; +import java.io.StringWriter; +import java.io.Writer; import java.util.ArrayList; import java.util.List; import java.util.logging.Logger; @@ -33,7 +36,16 @@ import com.moviejukebox.themoviedb.model.Studio; public class MovieDbParser { - static Logger logger = TheMovieDb.getLogger(); + private static Logger logger = TheMovieDb.getLogger(); + + private static final String NAME = "name"; + private static final String GENRE = "genre"; + private static final String ID = "id"; + private static final String URL = "url"; + private static final String LANGUAGE = "language"; + private static final String MOVIE = "movie"; + private static final String PERSON = "person"; + private static final String TYPE = "type"; /** * Retrieve a list of valid genres within TMDb. @@ -54,7 +66,7 @@ public class MovieDbParser { return categories; } - NodeList genres = doc.getElementsByTagName("genre"); + NodeList genres = doc.getElementsByTagName(GENRE); if ((genres == null) || genres.getLength() == 0) { return categories; } @@ -64,9 +76,9 @@ public class MovieDbParser { if (node.getNodeType() == Node.ELEMENT_NODE) { Element element = (Element) node; Category category = new Category(); - category.setName(element.getAttribute("name")); - category.setId(DOMHelper.getValueFromElement(element, "id")); - category.setUrl(DOMHelper.getValueFromElement(element, "url")); + category.setName(element.getAttribute(NAME)); + category.setId(DOMHelper.getValueFromElement(element, ID)); + category.setUrl(DOMHelper.getValueFromElement(element, URL)); categories.add(category); } } @@ -89,7 +101,7 @@ public class MovieDbParser { return languages; } - NodeList nlLanguages = doc.getElementsByTagName("language"); + NodeList nlLanguages = doc.getElementsByTagName(LANGUAGE); if ((nlLanguages == null) || nlLanguages.getLength() == 0) { return languages; @@ -128,7 +140,7 @@ public class MovieDbParser { return movie; } - NodeList nlMovies = doc.getElementsByTagName("movie"); + NodeList nlMovies = doc.getElementsByTagName(MOVIE); if ((nlMovies == null) || nlMovies.getLength() == 0) { return movie; @@ -158,7 +170,7 @@ public class MovieDbParser { return person; } - NodeList nlMovies = doc.getElementsByTagName("person"); + NodeList nlMovies = doc.getElementsByTagName(PERSON); if ((nlMovies == null) || nlMovies.getLength() == 0) { return person; @@ -193,7 +205,7 @@ public class MovieDbParser { return movie; } - NodeList nlMovies = doc.getElementsByTagName("movie"); + NodeList nlMovies = doc.getElementsByTagName(MOVIE); if ((nlMovies == null) || nlMovies.getLength() == 0) { return movie; } @@ -222,7 +234,7 @@ public class MovieDbParser { return movies; } - NodeList nlMovies = doc.getElementsByTagName("movie"); + NodeList nlMovies = doc.getElementsByTagName(MOVIE); if ((nlMovies == null) || nlMovies.getLength() == 0) { return movies; @@ -251,14 +263,14 @@ public class MovieDbParser { movie.setPopularity(DOMHelper.getValueFromElement(movieElement, "popularity")); movie.setTranslated(DOMHelper.getValueFromElement(movieElement, "translated")); movie.setAdult(DOMHelper.getValueFromElement(movieElement, "adult")); - movie.setLanguage(DOMHelper.getValueFromElement(movieElement, "language")); + movie.setLanguage(DOMHelper.getValueFromElement(movieElement, LANGUAGE)); movie.setOriginalName(DOMHelper.getValueFromElement(movieElement, "original_name")); - movie.setTitle(DOMHelper.getValueFromElement(movieElement, "name")); + movie.setTitle(DOMHelper.getValueFromElement(movieElement, NAME)); movie.setAlternativeName(DOMHelper.getValueFromElement(movieElement, "alternative_name")); - movie.setType(DOMHelper.getValueFromElement(movieElement, "type")); - movie.setId(DOMHelper.getValueFromElement(movieElement, "id")); + movie.setType(DOMHelper.getValueFromElement(movieElement, TYPE)); + movie.setId(DOMHelper.getValueFromElement(movieElement, ID)); movie.setImdb(DOMHelper.getValueFromElement(movieElement, "imdb_id")); - movie.setUrl(DOMHelper.getValueFromElement(movieElement, "url")); + movie.setUrl(DOMHelper.getValueFromElement(movieElement, URL)); movie.setOverview(DOMHelper.getValueFromElement(movieElement, "overview")); movie.setRating(DOMHelper.getValueFromElement(movieElement, "rating")); movie.setTagline(DOMHelper.getValueFromElement(movieElement, "tagline")); @@ -285,10 +297,10 @@ public class MovieDbParser { subElement = (Element) personNode; Category category = new Category(); - category.setType(subElement.getAttribute("type")); - category.setUrl(subElement.getAttribute("url")); - category.setName(subElement.getAttribute("name")); - category.setId(subElement.getAttribute("id")); + category.setType(subElement.getAttribute(TYPE)); + category.setUrl(subElement.getAttribute(URL)); + category.setName(subElement.getAttribute(NAME)); + category.setId(subElement.getAttribute(ID)); movie.addCategory(category); } @@ -311,9 +323,9 @@ public class MovieDbParser { subElement = (Element) studioNode; Studio studio = new Studio(); - studio.setUrl(subElement.getAttribute("url")); - studio.setName(subElement.getAttribute("name")); - studio.setId(subElement.getAttribute("id")); + studio.setUrl(subElement.getAttribute(URL)); + studio.setName(subElement.getAttribute(NAME)); + studio.setId(subElement.getAttribute(ID)); movie.addStudio(studio); } @@ -336,9 +348,9 @@ public class MovieDbParser { subElement = (Element) countryNode; Country country = new Country(); - country.setName(subElement.getAttribute("name")); + country.setName(subElement.getAttribute(NAME)); country.setCode(subElement.getAttribute("code")); - country.setUrl(subElement.getAttribute("url")); + country.setUrl(subElement.getAttribute(URL)); movie.addProductionCountry(country); } @@ -361,15 +373,15 @@ public class MovieDbParser { subElement = (Element) personNode; Person person = new Person(); - person.setName(subElement.getAttribute("name")); + person.setName(subElement.getAttribute(NAME)); person.setCharacter(subElement.getAttribute("character")); person.setJob(subElement.getAttribute("job")); - person.setId(subElement.getAttribute("id")); + person.setId(subElement.getAttribute(ID)); person.addArtwork(Artwork.ARTWORK_TYPE_PERSON, Artwork.ARTWORK_SIZE_THUMB, subElement.getAttribute("thumb"), "-1"); person.setDepartment(subElement.getAttribute("department")); - person.setUrl(subElement.getAttribute("url")); + person.setUrl(subElement.getAttribute(URL)); person.setOrder(subElement.getAttribute("order")); person.setCastId(subElement.getAttribute("cast_id")); @@ -418,15 +430,15 @@ public class MovieDbParser { if (subElement.getNodeName().equalsIgnoreCase("image")) { // This is the format used in Movie.imdbLookup, Movie.getInfo & Movie.search Artwork artwork = new Artwork(); - artwork.setType(subElement.getAttribute("type")); + artwork.setType(subElement.getAttribute(TYPE)); artwork.setSize(subElement.getAttribute("size")); - artwork.setUrl(subElement.getAttribute("url")); - artwork.setId(subElement.getAttribute("id")); + artwork.setUrl(subElement.getAttribute(URL)); + artwork.setId(subElement.getAttribute(ID)); movie.addArtwork(artwork); } else if (subElement.getNodeName().equalsIgnoreCase("backdrop") || subElement.getNodeName().equalsIgnoreCase("poster")) { // This is the format used in Movie.getImages - String artworkId = subElement.getAttribute("id"); + String artworkId = subElement.getAttribute(ID); String artworkType = subElement.getNodeName(); // We need to decode and loop round the child nodes to get the data @@ -438,7 +450,7 @@ public class MovieDbParser { Artwork artwork = new Artwork(); artwork.setId(artworkId); artwork.setType(artworkType); - artwork.setUrl(imageElement.getAttribute("url")); + artwork.setUrl(imageElement.getAttribute(URL)); artwork.setSize(imageElement.getAttribute("size")); movie.addArtwork(artwork); } @@ -453,7 +465,10 @@ public class MovieDbParser { } } catch (Exception error) { logger.severe("ERROR: " + error.getMessage()); - error.printStackTrace(); + final Writer eResult = new StringWriter(); + final PrintWriter printWriter = new PrintWriter(eResult); + error.printStackTrace(printWriter); + logger.severe(eResult.toString()); } return movie; } @@ -480,7 +495,7 @@ public class MovieDbParser { return movies; } - NodeList nlMovies = doc.getElementsByTagName("movie"); + NodeList nlMovies = doc.getElementsByTagName(MOVIE); if ((nlMovies == null) || nlMovies.getLength() == 0) { return movies; @@ -521,7 +536,7 @@ public class MovieDbParser { return people; } - NodeList movies = doc.getElementsByTagName("movie"); + NodeList movies = doc.getElementsByTagName(MOVIE); if ((movies == null) || movies.getLength() == 0) { return people; } @@ -553,7 +568,7 @@ public class MovieDbParser { return people; } - NodeList personNodeList = doc.getElementsByTagName("person"); + NodeList personNodeList = doc.getElementsByTagName(PERSON); if ((personNodeList == null) || personNodeList.getLength() == 0) { @@ -573,8 +588,8 @@ public class MovieDbParser { try { Element personElement = (Element) personNode; - person.setName(DOMHelper.getValueFromElement(personElement, "name")); - person.setId(DOMHelper.getValueFromElement(personElement, "id")); + person.setName(DOMHelper.getValueFromElement(personElement, NAME)); + person.setId(DOMHelper.getValueFromElement(personElement, ID)); person.setBiography(DOMHelper.getValueFromElement(personElement, "biography")); try { @@ -585,7 +600,7 @@ public class MovieDbParser { person.setBirthday(DOMHelper.getValueFromElement(personElement, "birthday")); person.setBirthPlace(DOMHelper.getValueFromElement(personElement, "birthplace")); - person.setUrl(DOMHelper.getValueFromElement(personElement, "url")); + person.setUrl(DOMHelper.getValueFromElement(personElement, URL)); person.setVersion(Integer.parseInt(DOMHelper.getValueFromElement(personElement, "version"))); person.setLastModifiedAt(DOMHelper.getValueFromElement(personElement, "last_modified_at")); @@ -595,15 +610,15 @@ public class MovieDbParser { if (artworkNode.getNodeType() == Node.ELEMENT_NODE) { Element artworkElement = (Element) artworkNode; Artwork artwork = new Artwork(); - artwork.setType(artworkElement.getAttribute("type")); - artwork.setUrl(artworkElement.getAttribute("url")); + artwork.setType(artworkElement.getAttribute(TYPE)); + artwork.setUrl(artworkElement.getAttribute(URL)); artwork.setSize(artworkElement.getAttribute("size")); - artwork.setId(artworkElement.getAttribute("id")); + artwork.setId(artworkElement.getAttribute(ID)); person.addArtwork(artwork); } } - NodeList filmNodeList = doc.getElementsByTagName("movie"); + NodeList filmNodeList = doc.getElementsByTagName(MOVIE); for (int nodeLoop = 0; nodeLoop < filmNodeList.getLength(); nodeLoop++) { Node filmNode = filmNodeList.item(nodeLoop); if (filmNode.getNodeType() == Node.ELEMENT_NODE) { @@ -612,10 +627,10 @@ public class MovieDbParser { film.setCharacter(filmElement.getAttribute("character")); film.setDepartment(filmElement.getAttribute("department")); - film.setId(filmElement.getAttribute("id")); + film.setId(filmElement.getAttribute(ID)); film.setJob(filmElement.getAttribute("job")); - film.setName(filmElement.getAttribute("name")); - film.setUrl(filmElement.getAttribute("url")); + film.setName(filmElement.getAttribute(NAME)); + film.setUrl(filmElement.getAttribute(URL)); person.addFilm(film); } @@ -624,7 +639,10 @@ public class MovieDbParser { people.add(person); } catch (Exception error) { logger.severe("PersonInfo: " + error.getMessage()); - error.printStackTrace(); + final Writer eResult = new StringWriter(); + final PrintWriter printWriter = new PrintWriter(eResult); + error.printStackTrace(printWriter); + logger.severe(eResult.toString()); } } } @@ -663,8 +681,8 @@ public class MovieDbParser { */ private static MovieDB parseSimpleMovie(Element element) { MovieDB movie = new MovieDB(); - movie.setTitle(DOMHelper.getValueFromElement(element, "name")); - movie.setId(DOMHelper.getValueFromElement(element, "id")); + movie.setTitle(DOMHelper.getValueFromElement(element, NAME)); + movie.setId(DOMHelper.getValueFromElement(element, ID)); movie.setImdb(DOMHelper.getValueFromElement(element, "imdb_id")); movie.setVersion(Integer.valueOf(DOMHelper.getValueFromElement(element, "version"))); movie.setLastModifiedAt(DOMHelper.getValueFromElement(element, "last_modified_at")); @@ -684,8 +702,8 @@ public class MovieDbParser { */ private static Person parseSimplePerson(Element element) { Person person = new Person(); - person.setName(DOMHelper.getValueFromElement(element, "name")); - person.setId(DOMHelper.getValueFromElement(element, "id")); + person.setName(DOMHelper.getValueFromElement(element, NAME)); + person.setId(DOMHelper.getValueFromElement(element, ID)); person.setVersion(Integer.valueOf(DOMHelper.getValueFromElement(element, "version"))); person.setLastModifiedAt(DOMHelper.getValueFromElement(element, "last_modified_at")); return person; diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/WebBrowser.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/WebBrowser.java index 62c68315a..7dfa17d53 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/WebBrowser.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/WebBrowser.java @@ -90,16 +90,11 @@ public final class WebBrowser { if (in != null) { in.close(); } - if (cnx != null) { - if(cnx instanceof HttpURLConnection) { - ((HttpURLConnection)cnx).disconnect(); - } - } - if (cnx != null) { - if(cnx instanceof HttpURLConnection) { - ((HttpURLConnection)cnx).disconnect(); - } + + if ((cnx != null) && (cnx instanceof HttpURLConnection)) { + ((HttpURLConnection)cnx).disconnect(); } + } return content.toString(); } finally { From 57c5140e20209b8e6e0baae364921a0af0d22f86 Mon Sep 17 00:00:00 2001 From: Omertron Date: Tue, 26 Jul 2011 14:37:47 +0000 Subject: [PATCH 081/207] Update class path --- themoviedbapi/.classpath | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/themoviedbapi/.classpath b/themoviedbapi/.classpath index 943b5e150..691a73b87 100644 --- a/themoviedbapi/.classpath +++ b/themoviedbapi/.classpath @@ -1,7 +1,7 @@ - - + + From aec0ddf735a911ba7c5d2f6cea3e189b778ef5da Mon Sep 17 00:00:00 2001 From: Omertron Date: Wed, 14 Sep 2011 12:10:14 +0000 Subject: [PATCH 082/207] Fixes issue 6 Add serializable interface on objects --- .../java/com/moviejukebox/themoviedb/model/Artwork.java | 6 +++++- .../java/com/moviejukebox/themoviedb/model/Category.java | 7 +++++-- .../java/com/moviejukebox/themoviedb/model/Country.java | 7 +++++-- .../com/moviejukebox/themoviedb/model/Filmography.java | 5 ++++- .../java/com/moviejukebox/themoviedb/model/Language.java | 5 ++++- .../java/com/moviejukebox/themoviedb/model/MovieDB.java | 5 ++++- .../java/com/moviejukebox/themoviedb/model/Person.java | 5 ++++- .../java/com/moviejukebox/themoviedb/model/Studio.java | 5 ++++- 8 files changed, 35 insertions(+), 10 deletions(-) diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Artwork.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Artwork.java index c180c8c91..ea1340315 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Artwork.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Artwork.java @@ -12,13 +12,17 @@ */ package com.moviejukebox.themoviedb.model; +import java.io.Serializable; + /** * This is the new bean for the Artwork * * @author Stuart.Boston * */ -public class Artwork implements Comparable { +public class Artwork implements Comparable, Serializable { + private static final long serialVersionUID = 1L; + public static final String ARTWORK_TYPE_POSTER = "poster"; public static final String ARTWORK_TYPE_BACKDROP = "backdrop"; public static final String ARTWORK_TYPE_PERSON = "profile"; diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Category.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Category.java index af054e065..612b364ab 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Category.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Category.java @@ -12,14 +12,17 @@ */ package com.moviejukebox.themoviedb.model; +import java.io.Serializable; + /** * Category from TheMovieDB.org * * @author Stuart.Boston * */ -public class Category { - +public class Category implements Serializable { + private static final long serialVersionUID = 1L; + private static final String UNKNOWN = MovieDB.UNKNOWN; private String type = UNKNOWN; diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Country.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Country.java index 207365506..e1626b71a 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Country.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Country.java @@ -12,14 +12,17 @@ */ package com.moviejukebox.themoviedb.model; +import java.io.Serializable; + /** * Country from the MovieDB.org * * @author Stuart.Boston * */ -public class Country { - +public class Country implements Serializable { + private static final long serialVersionUID = 1L; + private static final String UNKNOWN = MovieDB.UNKNOWN; private String url = UNKNOWN; diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Filmography.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Filmography.java index 0c193e6ea..308385ba7 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Filmography.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Filmography.java @@ -13,7 +13,10 @@ package com.moviejukebox.themoviedb.model; -public class Filmography { +import java.io.Serializable; + +public class Filmography implements Serializable { + private static final long serialVersionUID = 1L; private static final String UNKNOWN = MovieDB.UNKNOWN; diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Language.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Language.java index ce4c9a64c..4c986f160 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Language.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Language.java @@ -12,12 +12,15 @@ */ package com.moviejukebox.themoviedb.model; +import java.io.Serializable; + /** * Language from TheMovieDB.org * @author stuart.boston * */ -public class Language { +public class Language implements Serializable { + private static final long serialVersionUID = 1L; private static final String UNKNOWN = MovieDB.UNKNOWN; diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/MovieDB.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/MovieDB.java index b764a5c05..b3c9e7a5d 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/MovieDB.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/MovieDB.java @@ -12,6 +12,7 @@ */ package com.moviejukebox.themoviedb.model; +import java.io.Serializable; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.ArrayList; @@ -26,7 +27,9 @@ import com.moviejukebox.themoviedb.tools.ModelTools; * @author Stuart.Boston */ -public class MovieDB extends ModelTools { +public class MovieDB extends ModelTools implements Serializable { + private static final long serialVersionUID = 1L; + public static final String UNKNOWN = "UNKNOWN"; private String popularity = UNKNOWN; diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Person.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Person.java index 6aa132ffe..07218142b 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Person.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Person.java @@ -12,6 +12,7 @@ */ package com.moviejukebox.themoviedb.model; +import java.io.Serializable; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.ArrayList; @@ -26,7 +27,9 @@ import com.moviejukebox.themoviedb.tools.ModelTools; * @author Stuart.Boston * */ -public class Person extends ModelTools { +public class Person extends ModelTools implements Serializable { + private static final long serialVersionUID = 1L; + private static final String UNKNOWN = MovieDB.UNKNOWN; private String name = UNKNOWN; diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Studio.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Studio.java index 6c18cd730..fc9b0626d 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Studio.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Studio.java @@ -12,13 +12,16 @@ */ package com.moviejukebox.themoviedb.model; +import java.io.Serializable; + /** * Studio from the MovieDB.org * * @author Stuart.Boston * */ -public class Studio { +public class Studio implements Serializable { + private static final long serialVersionUID = 1L; private static final String UNKNOWN = MovieDB.UNKNOWN; From 04e680c257d152c634dbe47dda69dced046f7490 Mon Sep 17 00:00:00 2001 From: Omertron Date: Mon, 24 Oct 2011 11:21:34 +0000 Subject: [PATCH 083/207] [maven-release-plugin] prepare release themoviedbapi-1.1 --- themoviedbapi/pom.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/themoviedbapi/pom.xml b/themoviedbapi/pom.xml index c4728de97..bd74655b8 100644 --- a/themoviedbapi/pom.xml +++ b/themoviedbapi/pom.xml @@ -8,7 +8,7 @@ com.moviejukebox themoviedbapi - 1.1-SNAPSHOT + 1.1 The MovieDB API @@ -22,9 +22,9 @@ - scm:svn:http://themoviedbapi.googlecode.com/svn/trunk/themoviedbapi - scm:svn:https://themoviedbapi.googlecode.com/svn/trunk/themoviedbapi - http://code.google.com/p/themoviedbapi/source/browse/trunk/themoviedbapi + scm:svn:http://themoviedbapi.googlecode.com/svn/tags/themoviedbapi-1.1 + scm:svn:https://themoviedbapi.googlecode.com/svn/tags/themoviedbapi-1.1 + http://code.google.com/p/themoviedbapi/source/browse/tags/themoviedbapi-1.1 From e05ec3f1b36ccb7e9b1d6da3af7fe09cbc2469ff Mon Sep 17 00:00:00 2001 From: Omertron Date: Mon, 24 Oct 2011 11:21:43 +0000 Subject: [PATCH 084/207] [maven-release-plugin] prepare for next development iteration --- themoviedbapi/pom.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/themoviedbapi/pom.xml b/themoviedbapi/pom.xml index bd74655b8..993654ea5 100644 --- a/themoviedbapi/pom.xml +++ b/themoviedbapi/pom.xml @@ -8,7 +8,7 @@ com.moviejukebox themoviedbapi - 1.1 + 1.2-SNAPSHOT The MovieDB API @@ -22,9 +22,9 @@ - scm:svn:http://themoviedbapi.googlecode.com/svn/tags/themoviedbapi-1.1 - scm:svn:https://themoviedbapi.googlecode.com/svn/tags/themoviedbapi-1.1 - http://code.google.com/p/themoviedbapi/source/browse/tags/themoviedbapi-1.1 + scm:svn:http://themoviedbapi.googlecode.com/svn/trunk/themoviedbapi + scm:svn:https://themoviedbapi.googlecode.com/svn/trunk/themoviedbapi + http://code.google.com/p/themoviedbapi/source/browse/trunk/themoviedbapi From a68a1c72f82d36fa3805e9a93c691ac768c14ddb Mon Sep 17 00:00:00 2001 From: Omertron Date: Thu, 27 Oct 2011 18:30:59 +0000 Subject: [PATCH 085/207] Updated test --- themoviedbapi/pom.xml | 2 +- .../themoviedb/TheMovieDbTest.java | 21 +++---------------- 2 files changed, 4 insertions(+), 19 deletions(-) diff --git a/themoviedbapi/pom.xml b/themoviedbapi/pom.xml index 993654ea5..1ef7d80dd 100644 --- a/themoviedbapi/pom.xml +++ b/themoviedbapi/pom.xml @@ -28,7 +28,7 @@ - true + false UTF-8 UTF-8 zip diff --git a/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java b/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java index 1dd9427b5..d85df4a5e 100644 --- a/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java +++ b/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java @@ -22,10 +22,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; -import org.junit.After; -import org.junit.AfterClass; import org.junit.Before; -import org.junit.BeforeClass; import org.junit.Test; import com.moviejukebox.themoviedb.model.Category; @@ -39,29 +36,17 @@ import com.moviejukebox.themoviedb.model.Person; */ public class TheMovieDbTest { - private static String apikey = ""; + private static String apikey = "5a1a77e2eba8984804586122754f969f"; private TheMovieDb tmdb; public TheMovieDbTest() { } - @BeforeClass - public static void setUpClass() throws Exception { - } - - @AfterClass - public static void tearDownClass() throws Exception { - } - @Before public void setUp() { tmdb = new TheMovieDb(apikey); } - @After - public void tearDown() { - } - @Test public void testGetApiKey() { assertEquals(apikey, tmdb.getApiKey()); @@ -322,7 +307,7 @@ public class TheMovieDbTest { assertEquals("585", movies.get(0).getId()); assertEquals("tt0198781", movies.get(0).getImdb()); - assertEquals("Star Wars: Episode IV: A New Hope", movies.get(1).getTitle()); + assertEquals("Star Wars: Episode IV - A New Hope", movies.get(1).getTitle()); assertEquals("11", movies.get(1).getId()); assertEquals("tt0076759", movies.get(1).getImdb()); @@ -390,7 +375,7 @@ public class TheMovieDbTest { } } - assertEquals("Marco Pérez", person.getName()); + assertEquals("Marco Prez", person.getName()); assertEquals("260", person.getId()); } From 52a11f4fc08e43e8e035fef5a187f1bd6ade8d77 Mon Sep 17 00:00:00 2001 From: Omertron Date: Thu, 27 Oct 2011 18:46:26 +0000 Subject: [PATCH 086/207] Updated test --- themoviedbapi/pom.xml | 2 +- .../test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/themoviedbapi/pom.xml b/themoviedbapi/pom.xml index 1ef7d80dd..993654ea5 100644 --- a/themoviedbapi/pom.xml +++ b/themoviedbapi/pom.xml @@ -28,7 +28,7 @@ - false + true UTF-8 UTF-8 zip diff --git a/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java b/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java index d85df4a5e..9400968a6 100644 --- a/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java +++ b/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java @@ -36,7 +36,7 @@ import com.moviejukebox.themoviedb.model.Person; */ public class TheMovieDbTest { - private static String apikey = "5a1a77e2eba8984804586122754f969f"; + private static String apikey = ""; private TheMovieDb tmdb; public TheMovieDbTest() { From 7691fc7b630d6fb110354014d9c5e7606b6d62e8 Mon Sep 17 00:00:00 2001 From: Omertron Date: Thu, 27 Oct 2011 21:16:36 +0000 Subject: [PATCH 087/207] Update POM versions --- themoviedbapi/pom.xml | 2 +- .../test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/themoviedbapi/pom.xml b/themoviedbapi/pom.xml index 993654ea5..4123db571 100644 --- a/themoviedbapi/pom.xml +++ b/themoviedbapi/pom.xml @@ -46,7 +46,7 @@ junit junit - 4.8.2 + 4.10 test diff --git a/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java b/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java index 9400968a6..fce4e4f07 100644 --- a/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java +++ b/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java @@ -67,7 +67,7 @@ public class TheMovieDbTest { @Test public void testMoviedbSearch_withWrongTitle() { - List movies = tmdb.moviedbSearch("à(é!àç'(è!çé(èçéè'(éàç!'(èéàç!(èç'", "en"); + List movies = tmdb.moviedbSearch("à(é!àç'(è!çé(èçéè'(éàç!'(èéàç!(èç'", "en"); assertTrue(movies.isEmpty()); } @@ -375,7 +375,7 @@ public class TheMovieDbTest { } } - assertEquals("Marco Prez", person.getName()); + assertEquals("Marco Pérez", person.getName()); assertEquals("260", person.getId()); } From 44b962a60d90b818e4e9eebef3ee34fbd9e8e92d Mon Sep 17 00:00:00 2001 From: Omertron Date: Sun, 30 Oct 2011 21:48:17 +0000 Subject: [PATCH 088/207] Added language trim to fix MovieDB API error --- .../java/com/moviejukebox/themoviedb/TheMovieDb.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java index dbd8e45a4..14058252e 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java @@ -222,10 +222,16 @@ public class TheMovieDb { private String buildUrl(String prefix, String searchTerm, String language) { StringBuilder url = new StringBuilder(); + + url.append(API_SITE); url.append(prefix); url.append("/"); - url.append(language); + if (language.length() > 2) { + url.append(language.substring(0, 2)); + } else { + url.append(language); + } url.append("/xml/"); url.append(apiKey); @@ -579,6 +585,7 @@ public class TheMovieDb { */ public Person personGetVersion(String personID, String language) { Person person = new Person(); + if (!isValidString(personID)) { return person; } From d0ca6931ecd842a29652254a3d53a157e50b2e88 Mon Sep 17 00:00:00 2001 From: Omertron Date: Tue, 6 Dec 2011 12:25:39 +0000 Subject: [PATCH 089/207] Source code cleanup --- themoviedbapi/pom.xml | 11 +- .../moviejukebox/themoviedb/TheMovieDb.java | 168 ++++++------- .../themoviedb/model/MovieDB.java | 65 ++--- .../moviejukebox/themoviedb/model/Person.java | 237 +++++++++++++++--- .../moviejukebox/themoviedb/tools/Base64.java | 36 --- .../themoviedb/tools/DOMHelper.java | 22 +- .../themoviedb/tools/LogFormatter.java | 31 +-- .../themoviedb/tools/MovieDbParser.java | 81 ++++-- .../themoviedb/tools/WebBrowser.java | 191 ++++++++++---- 9 files changed, 545 insertions(+), 297 deletions(-) delete mode 100644 themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/Base64.java diff --git a/themoviedbapi/pom.xml b/themoviedbapi/pom.xml index 4123db571..fd0b362ae 100644 --- a/themoviedbapi/pom.xml +++ b/themoviedbapi/pom.xml @@ -15,12 +15,12 @@ Google Code http://code.google.com/p/themoviedbapi/issues/list - + Hudson CI http://jenkins.omertron.com/job/API-TheMovieDb/ - + scm:svn:http://themoviedbapi.googlecode.com/svn/trunk/themoviedbapi scm:svn:https://themoviedbapi.googlecode.com/svn/trunk/themoviedbapi @@ -39,8 +39,13 @@ junit junit + + commons-codec + commons-codec + 1.4 + - + diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java index 14058252e..28146eb88 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java @@ -1,14 +1,14 @@ /* * Copyright (c) 2004-2011 YAMJ Members - * http://code.google.com/p/moviejukebox/people/list - * + * http://code.google.com/p/moviejukebox/people/list + * * Web: http://code.google.com/p/moviejukebox/ - * + * * This software is licensed under a Creative Commons License * See this page: http://code.google.com/p/moviejukebox/wiki/License - * - * For any reuse or distribution, you must make clear to others the - * license terms of this work. + * + * For any reuse or distribution, you must make clear to others the + * license terms of this work. */ package com.moviejukebox.themoviedb; @@ -36,7 +36,7 @@ import com.moviejukebox.themoviedb.tools.WebBrowser; * This is the main class for the API to connect to TheMovieDb.org. * The implementation is for v2.1 of the API as detailed here: * http://api.themoviedb.org/2.1 - * + * * @author Stuart.Boston * @version 1.3 */ @@ -47,7 +47,56 @@ public class TheMovieDb { private static ConsoleHandler tmdbConsoleHandler = new ConsoleHandler(); private static final String API_SITE = "http://api.themoviedb.org/2.1/"; private static final String DEFAULT_LANGUAGE = "en-US"; - + + /** + * Constructor with default logger. + * @param apiKey + */ + public TheMovieDb(String apiKey) { + setLogger(Logger.getLogger("TheMovieDB")); + if (!isValidString(apiKey)) { + logger.severe("TheMovieDb was initialized with a wrong API key!"); + } + setApiKey(apiKey); + } + + /* + * API Methods + * http://api.themoviedb.org/2.1 + * Note: This is currently a read-only interface and as such, no write methods exist. + */ + + /* + * Media + */ + @SuppressWarnings("unused") + private static final String MEDIA_GET_INFO = "Media.getInfo"; + + /* + * Movies + */ + private static final String MOVIE_BROWSE = "Movie.browse"; + private static final String MOVIE_GET_IMAGES = "Movie.getImages"; + private static final String MOVIE_GET_INFO = "Movie.getInfo"; + private static final String MOVIE_GET_LATEST = "Movie.getLatest"; + private static final String MOVIE_GET_TRANSLATIONS = "Movie.getTranslations"; + private static final String MOVIE_GET_VERSION = "Movie.getVersion"; + private static final String MOVIE_IMDB_LOOKUP = "Movie.imdbLookup"; + private static final String MOVIE_SEARCH = "Movie.search"; + + /* + * People + */ + private static final String PERSON_GET_INFO = "Person.getInfo"; + private static final String PERSON_GET_LATEST = "Person.getLatest"; + private static final String PERSON_GET_VERSION = "Person.getVersion"; + private static final String PERSON_SEARCH = "Person.search"; + + /* + * Misc + */ + private static final String GENRES_GET_LIST = "Genres.getList"; + /** * Compare the MovieDB object with a title & year * @param moviedb The moviedb object to compare too @@ -96,7 +145,7 @@ public class TheMovieDb { } return false; } - + /** * Search a list of movies and return the one that matches the title & year * @param movieList The list of movies to search @@ -117,7 +166,7 @@ public class TheMovieDb { return null; } - + /** * Check the string passed to see if it contains a value. * @param testString The string to test @@ -131,68 +180,11 @@ public class TheMovieDb { } return true; } - - /* - * API Methods - * http://api.themoviedb.org/2.1 - * Note: This is currently a read-only interface and as such, no write methods exist. - */ - - /* - * Media - */ - @SuppressWarnings("unused") - private static final String MEDIA_GET_INFO = "Media.getInfo"; - - /* - * Movies - */ - private static final String MOVIE_BROWSE = "Movie.browse"; - private static final String MOVIE_GET_IMAGES = "Movie.getImages"; - private static final String MOVIE_GET_INFO = "Movie.getInfo"; - private static final String MOVIE_GET_LATEST = "Movie.getLatest"; - private static final String MOVIE_GET_TRANSLATIONS = "Movie.getTranslations"; - private static final String MOVIE_GET_VERSION = "Movie.getVersion"; - private static final String MOVIE_IMDB_LOOKUP = "Movie.imdbLookup"; - private static final String MOVIE_SEARCH = "Movie.search"; - - /* - * People - */ - private static final String PERSON_GET_INFO = "Person.getInfo"; - private static final String PERSON_GET_LATEST = "Person.getLatest"; - private static final String PERSON_GET_VERSION = "Person.getVersion"; - private static final String PERSON_SEARCH = "Person.search"; - - /* - * Misc - */ - private static final String GENRES_GET_LIST = "Genres.getList"; public static Logger getLogger() { return logger; } - /** - * Constructor with default logger. - * @param apiKey - */ - public TheMovieDb(String apiKey) { - setLogger(Logger.getLogger("TheMovieDB")); - if (!isValidString(apiKey)) { - logger.severe("TheMovieDb was initialized with a wrong API key!"); - } - setApiKey(apiKey); - } - - public TheMovieDb(String apiKey, Logger logger) { - setLogger(logger); - if (!isValidString(apiKey)) { - logger.severe("TheMovieDb was initialized with a wrong API key!"); - } - setApiKey(apiKey); - } - /** * Build comma separated ids for Movie.getLatest and Movie.getVersion. * @param ids a List of ids @@ -200,7 +192,7 @@ public class TheMovieDb { */ private String buildIds(List ids) { StringBuilder builder = new StringBuilder(); - + for (int i = 0; i < ids.size(); i++) { if (i == 0) { builder.append(ids.get(i)); @@ -221,9 +213,9 @@ public class TheMovieDb { */ private String buildUrl(String prefix, String searchTerm, String language) { StringBuilder url = new StringBuilder(); - - - + + + url.append(API_SITE); url.append(prefix); url.append("/"); @@ -321,11 +313,11 @@ public class TheMovieDb { validParameters.add("companies"); validParameters.add("countries"); - + StringBuilder searchUrl = new StringBuilder(); searchUrl.append("order_by=").append(orderBy); searchUrl.append("&order=").append(order); - + if(!parameters.isEmpty()) { for (String key : validParameters) { if (parameters.containsKey(key)) { @@ -336,11 +328,11 @@ public class TheMovieDb { // Get the search url String baseUrl = buildUrl(MOVIE_BROWSE, "", language); - + // Now append the parameter url to the end of the search url searchUrl.insert(0, "?"); searchUrl.insert(0, baseUrl); - + return MovieDbParser.parseMovies(searchUrl.toString()); } @@ -395,13 +387,13 @@ public class TheMovieDb { /** * Gets all the information for a given TheMovieDb ID - * + * * @param movie * An existing MovieDB object to populate with the data * @param tmdbID * The Movie Db ID for the movie to get information for * @param language - * The two digit language code. E.g. en=English + * The two digit language code. E.g. en=English * @return A movie bean with all of the information */ public MovieDB moviedbGetInfo(String tmdbID, MovieDB movie, String language) { @@ -424,9 +416,9 @@ public class TheMovieDb { /** * Passes a null MovieDB object to the full function - * + * * @param tmdbID TheMovieDB ID of the movie to get the information for - * @param language The two digit language code. E.g. en=English + * @param language The two digit language code. E.g. en=English * @return A movie bean with all of the information */ public MovieDB moviedbGetInfo(String tmdbID, String language) { @@ -493,9 +485,9 @@ public class TheMovieDb { /** * Searches the database using the IMDb reference - * + * * @param imdbID IMDb reference, must include the "tt" at the start - * @param language The two digit language code. E.g. en=English + * @param language The two digit language code. E.g. en=English * @return A movie bean with the data extracted */ public MovieDB moviedbImdbLookup(String imdbID, String language) { @@ -512,7 +504,7 @@ public class TheMovieDb { /** * Searches the database using the movie title passed - * + * * @param movieTitle The title to search for * @param language The two digit language code. E.g. en=English * @return A movie bean with the data extracted @@ -528,9 +520,9 @@ public class TheMovieDb { } /** - * The Person.getInfo method is used to retrieve the full filmography, known movies, + * The Person.getInfo method is used to retrieve the full filmography, known movies, * images and things like birthplace for a specific person in the TMDb database. - * + * * @param personID * @param language * @return @@ -574,18 +566,18 @@ public class TheMovieDb { } /** - * The Person.getVersion method is used to retrieve the last modified time + * The Person.getVersion method is used to retrieve the last modified time * along with the current version number of the called object(s). This is * useful if you've already called the object sometime in the past and * simply want to do a quick check for updates. - * + * * @param personID a Person TMDb id * @param language the two digit language code. E.g. en=English * @return */ public Person personGetVersion(String personID, String language) { Person person = new Person(); - + if (!isValidString(personID)) { return person; } @@ -601,7 +593,7 @@ public class TheMovieDb { /** * The Person.search method is used to search for an actor, actress or production member. * http://api.themoviedb.org/2.1/methods/Person.search - * + * * @param personName * @param language * @return diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/MovieDB.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/MovieDB.java index b3c9e7a5d..f9ca36905 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/MovieDB.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/MovieDB.java @@ -1,34 +1,38 @@ /* * Copyright (c) 2004-2011 YAMJ Members - * http://code.google.com/p/moviejukebox/people/list - * + * http://code.google.com/p/moviejukebox/people/list + * * Web: http://code.google.com/p/moviejukebox/ - * + * * This software is licensed under a Creative Commons License * See this page: http://code.google.com/p/moviejukebox/wiki/License - * - * For any reuse or distribution, you must make clear to others the - * license terms of this work. + * + * For any reuse or distribution, you must make clear to others the + * license terms of this work. */ package com.moviejukebox.themoviedb.model; +import com.moviejukebox.themoviedb.TheMovieDb; import java.io.Serializable; import java.text.DateFormat; +import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.List; import java.util.Date; import com.moviejukebox.themoviedb.tools.ModelTools; +import java.util.logging.Logger; /** * This is the Movie Search bean for the MovieDb.org search - * + * * @author Stuart.Boston */ public class MovieDB extends ModelTools implements Serializable { private static final long serialVersionUID = 1L; + private static final Logger logger = TheMovieDb.getLogger(); public static final String UNKNOWN = "UNKNOWN"; @@ -63,7 +67,7 @@ public class MovieDB extends ModelTools implements Serializable { public String getPopularity() { return popularity; } - + public void setPopularity(String popularity) { this.popularity = popularity; } @@ -71,7 +75,7 @@ public class MovieDB extends ModelTools implements Serializable { public String getTitle() { return title; } - + public void setTitle(String title) { this.title = title; } @@ -79,11 +83,11 @@ public class MovieDB extends ModelTools implements Serializable { public String getType() { return type; } - + public void setType(String type) { this.type = type; } - + public String getId() { return id; } @@ -91,11 +95,11 @@ public class MovieDB extends ModelTools implements Serializable { public void setId(String id) { this.id = id; } - + public String getImdb() { return imdb; } - + public void setImdb(String imdb) { this.imdb = imdb; } @@ -103,7 +107,7 @@ public class MovieDB extends ModelTools implements Serializable { public String getUrl() { return url; } - + public void setUrl(String url) { this.url = url; } @@ -111,7 +115,7 @@ public class MovieDB extends ModelTools implements Serializable { public String getOverview() { return overview; } - + public void setOverview(String overview) { this.overview = overview; } @@ -119,7 +123,7 @@ public class MovieDB extends ModelTools implements Serializable { public String getReleaseDate() { return releaseDate; } - + public void setReleaseDate(String releaseDate) { this.releaseDate = releaseDate; } @@ -127,7 +131,7 @@ public class MovieDB extends ModelTools implements Serializable { public String getRating() { return rating; } - + public void setRating(String rating) { this.rating = rating; } @@ -135,7 +139,7 @@ public class MovieDB extends ModelTools implements Serializable { public String getRuntime() { return runtime; } - + public void setRuntime(String runtime) { this.runtime = runtime; } @@ -143,7 +147,7 @@ public class MovieDB extends ModelTools implements Serializable { public String getBudget() { return budget; } - + public void setBudget(String budget) { this.budget = budget; } @@ -151,7 +155,7 @@ public class MovieDB extends ModelTools implements Serializable { public String getRevenue() { return revenue; } - + public void setRevenue(String revenue) { this.revenue = revenue; } @@ -159,7 +163,7 @@ public class MovieDB extends ModelTools implements Serializable { public String getHomepage() { return homepage; } - + public void setHomepage(String homepage) { this.homepage = homepage; } @@ -167,7 +171,7 @@ public class MovieDB extends ModelTools implements Serializable { public String getTrailer() { return trailer; } - + public void setTrailer(String trailer) { this.trailer = trailer; } @@ -175,17 +179,17 @@ public class MovieDB extends ModelTools implements Serializable { public List getProductionCountries() { return countries; } - + public void addProductionCountry(Country country) { if (country != null) { countries.add(country); } } - + public List getPeople() { return people; } - + public void addPerson(Person person) { if (person != null) { people.add(person); @@ -195,7 +199,7 @@ public class MovieDB extends ModelTools implements Serializable { public List getCategories() { return categories; } - + public void addCategory(Category category) { if (category != null) { categories.add(category); @@ -273,13 +277,13 @@ public class MovieDB extends ModelTools implements Serializable { public void setStudios(List studios) { this.studios = studios; } - + public void addStudio(Studio studio) { if (studio != null) { this.studios.add(studio); } } - + public void setCountries(List countries) { this.countries = countries; } @@ -298,11 +302,10 @@ public class MovieDB extends ModelTools implements Serializable { public void setLastModifiedAt(String lastModifiedAt) { DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - try { setLastModifiedAt(df.parse(lastModifiedAt)); - } catch (Exception ignore) { - return; + } catch (ParseException ex) { + logger.fine("MovieDB: Error parsing date: " + lastModifiedAt); } } diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Person.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Person.java index 07218142b..637da5a38 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Person.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Person.java @@ -1,34 +1,38 @@ /* * Copyright (c) 2004-2011 YAMJ Members - * http://code.google.com/p/moviejukebox/people/list - * + * http://code.google.com/p/moviejukebox/people/list + * * Web: http://code.google.com/p/moviejukebox/ - * + * * This software is licensed under a Creative Commons License * See this page: http://code.google.com/p/moviejukebox/wiki/License - * - * For any reuse or distribution, you must make clear to others the - * license terms of this work. + * + * For any reuse or distribution, you must make clear to others the + * license terms of this work. */ package com.moviejukebox.themoviedb.model; +import com.moviejukebox.themoviedb.TheMovieDb; import java.io.Serializable; import java.text.DateFormat; +import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Date; import java.util.List; import com.moviejukebox.themoviedb.tools.ModelTools; +import java.util.logging.Logger; /** - * This is the new bean for the Person - * + * This is the new bean for the Person + * * @author Stuart.Boston * */ public class Person extends ModelTools implements Serializable { private static final long serialVersionUID = 1L; + private static final Logger logger = TheMovieDb.getLogger(); private static final String UNKNOWN = MovieDB.UNKNOWN; @@ -49,119 +53,226 @@ public class Person extends ModelTools implements Serializable { private List filmography = new ArrayList(); private List aka = new ArrayList(); private List images = new ArrayList(); - + + /** + * Add a single AKA + * @param alsoKnownAs + */ public void addAka(String alsoKnownAs) { this.aka.add(alsoKnownAs); } - + + /** + * Add a film for the person + * @param film + */ public void addFilm(Filmography film) { this.filmography.add(film); } - + + /** + * Add an artwork image to the person + * @param image + */ public void addImage(Artwork image) { if (image != null) { this.images.add(image); } } - + + /** + * Get all the AKA values + * @return + */ public List getAka() { return aka; } - + + /** + * Get the biography information + * @return + */ public String getBiography() { return biography; } - + + /** + * Get the birthday of the person + * @return + */ public Date getBirthday() { return birthday; } - + + /** + * Get the birthplace + * @return + */ public String getBirthPlace() { return birthPlace; } - + + /** + * get the cast ID + * @return + */ public int getCastId() { return castId; } - + + /** + * get the character + * @return + */ public String getCharacter() { return character; } - + + /** + * get the department + * @return + */ public String getDepartment() { return department; } - + + /** + * get the list of films + * @return + */ public List getFilmography() { return filmography; } - + + /** + * get the ID of the person + * @return + */ public String getId() { return id; } - + + /** + * get a list of images for the person + * @return + */ public List getImages() { return images; } - + + /** + * get the job + * @return + */ public String getJob() { return job; } + /** + * get the known movies + * @return + */ public int getKnownMovies() { return knownMovies; } + /** + * get the last modified date for the person + * @return + */ public Date getLastModifiedAt() { return lastModifiedAt; } - + + /** + * get the name + * @return + */ public String getName() { return name; } + /** + * get the order + * @return + */ public int getOrder() { return order; } + /** + * get the URL for the person + * @return + */ public String getUrl() { return url; } - + + /** + * get the version + * @return + */ public int getVersion() { return version; } + /** + * Set the AKA list for the person + * @param aka + */ public void setAka(List aka) { this.aka = aka; } + /** + * Set the biography + * @param biography + */ public void setBiography(String biography) { this.biography = biography; } - + + /** + * Set the person's birthday + * @param birthday + */ public void setBirthday(Date birthday) { this.birthday = birthday; } + /** + * Set the person's birthday + * @param sBirthday + */ public void setBirthday(String sBirthday) { DateFormat df = new SimpleDateFormat("yyyy-MM-dd"); - try { setBirthday(df.parse(sBirthday)); - } catch (Exception ignore) { - return; + } catch (ParseException ex) { + logger.fine("TheMovieDB - Person: Error parsing birthday: " + sBirthday); } } + /** + * Set the birth place + * @param birthPlace + */ public void setBirthPlace(String birthPlace) { this.birthPlace = birthPlace; } + /** + * Set the cast ID for the person + * @param castId + */ public void setCastId(int castId) { this.castId = castId; } - + + /** + * Set the cast ID for the person + * @param castId + */ public void setCastId(String castId) { try { this.castId = Integer.parseInt(castId); @@ -170,41 +281,77 @@ public class Person extends ModelTools implements Serializable { } } + /** + * Set the character + * @param character + */ public void setCharacter(String character) { this.character = character; } - + + /** + * set the Department + * @param department + */ public void setDepartment(String department) { this.department = department; } + /** + * Add a list of films + * @param filmography + */ public void setFilmography(List filmography) { this.filmography = filmography; } + /** + * Set the ID of the person + * @param id + */ public void setId(String id) { this.id = id; } + /** + * Set a list of images for the person + * @param images + */ public void setImages(List images) { this.images = images; } + /** + * Set the job for the person + * @param job + */ public void setJob(String job) { this.job = job; } + /** + * Set the known movie for the person + * @param knownMovies + */ public void setKnownMovies(int knownMovies) { this.knownMovies = knownMovies; } + /** + * Set the last modified date + * @param lastModifiedAt + */ public void setLastModifiedAt(Date lastModifiedAt) { this.lastModifiedAt = lastModifiedAt; } + /** + * Set the last modified date + * @param lastModifiedAt + */ public void setLastModifiedAt(String lastModifiedAt) { DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - + try { Date lma = df.parse(lastModifiedAt); setLastModifiedAt(lma); @@ -213,14 +360,26 @@ public class Person extends ModelTools implements Serializable { } } + /** + * Set the person's anme + * @param name + */ public void setName(String name) { this.name = name; } + /** + *Set the order + * @param order + */ public void setOrder(int order) { this.order = order; } - + + /** + * Set the order + * @param order + */ public void setOrder(String order) { try { this.order = Integer.parseInt(order); @@ -229,14 +388,26 @@ public class Person extends ModelTools implements Serializable { } } + /** + * Set the URL + * @param url + */ public void setUrl(String url) { this.url = url; } - + + /** + * Set the version + * @param version + */ public void setVersion(int version) { this.version = version; } + /** + * Generate a String representation of the person + * @return + */ @Override public String toString() { StringBuilder builder = new StringBuilder(); diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/Base64.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/Base64.java deleted file mode 100644 index 7560e50a2..000000000 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/Base64.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright (c) 2004-2011 YAMJ Members - * http://code.google.com/p/moviejukebox/people/list - * - * Web: http://code.google.com/p/moviejukebox/ - * - * This software is licensed under a Creative Commons License - * See this page: http://code.google.com/p/moviejukebox/wiki/License - * - * For any reuse or distribution, you must make clear to others the - * license terms of this work. - */ -package com.moviejukebox.themoviedb.tools; - -public class Base64 { - private static final String base64code = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; - - public static String base64Encode(String string) { - String unEncoded = string; // Copy the string so we can modify it - StringBuffer encoded = new StringBuffer(); - // determine how many padding bytes to add to the output - int paddingCount = (3 - (unEncoded.length() % 3)) % 3; - // add any necessary padding to the input - unEncoded += "\0\0".substring(0, paddingCount); - // process 3 bytes at a time, churning out 4 output bytes - // worry about CRLF insertions later - for (int i = 0; i < unEncoded.length(); i += 3) { - int j = (unEncoded.charAt(i) << 16) + (unEncoded.charAt(i + 1) << 8) + unEncoded.charAt(i + 2); - encoded.append(base64code.charAt((j >> 18) & 0x3f) + base64code.charAt((j >> 12) & 0x3f) + base64code.charAt((j >> 6) & 0x3f) - + base64code.charAt(j & 0x3f)); - } - // replace encoded padding nulls with "=" - // return encoded; - return "Basic " + encoded.toString(); - } -} diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/DOMHelper.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/DOMHelper.java index 22146b0e4..a5c4be580 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/DOMHelper.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/DOMHelper.java @@ -1,14 +1,14 @@ /* * Copyright (c) 2004-2011 YAMJ Members - * http://code.google.com/p/moviejukebox/people/list - * + * http://code.google.com/p/moviejukebox/people/list + * * Web: http://code.google.com/p/moviejukebox/ - * + * * This software is licensed under a Creative Commons License * See this page: http://code.google.com/p/moviejukebox/wiki/License - * - * For any reuse or distribution, you must make clear to others the - * license terms of this work. + * + * For any reuse or distribution, you must make clear to others the + * license terms of this work. */ package com.moviejukebox.themoviedb.tools; @@ -35,7 +35,7 @@ import com.moviejukebox.themoviedb.TheMovieDb; * */ public class DOMHelper { - private static Logger logger = TheMovieDb.getLogger(); + private static final Logger logger = TheMovieDb.getLogger(); /** * Gets the string value of the tag element name passed @@ -71,11 +71,11 @@ public class DOMHelper { Document doc = null; InputStream in = null; String webPage = null; - + try { boolean validWebPage = false; webPage = WebBrowser.request(url); - + // There seems to be an error with some of the web pages that returns garbage if (webPage.startsWith("() { + private static final String EOL = (String) java.security.AccessController.doPrivileged(new PrivilegedAction() { + + @Override public Object run() { return System.getProperty("line.separator"); } }); + @Override public synchronized String format(LogRecord logRecord) { String logMessage = logRecord.getMessage(); logMessage = "[TheMovieDb API] " + logMessage.replace(apiKey, "[APIKEY]") + EOL; - + Throwable thrown = logRecord.getThrown(); - if (thrown != null) { - logMessage = logMessage + thrown.toString(); + if (thrown != null) { + logMessage = logMessage + thrown.toString(); } return logMessage; } - + public void addApiKey(String apiKey) { - LogFormatter.apiKey = apiKey; + LogFormatter.apiKey = apiKey; return; } } diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/MovieDbParser.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/MovieDbParser.java index d927f46a1..64d48acd1 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/MovieDbParser.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/MovieDbParser.java @@ -1,14 +1,14 @@ /* * Copyright (c) 2004-2011 YAMJ Members - * http://code.google.com/p/moviejukebox/people/list - * + * http://code.google.com/p/moviejukebox/people/list + * * Web: http://code.google.com/p/moviejukebox/ - * + * * This software is licensed under a Creative Commons License * See this page: http://code.google.com/p/moviejukebox/wiki/License - * - * For any reuse or distribution, you must make clear to others the - * license terms of this work. + * + * For any reuse or distribution, you must make clear to others the + * license terms of this work. */ package com.moviejukebox.themoviedb.tools; @@ -34,10 +34,14 @@ import com.moviejukebox.themoviedb.model.MovieDB; import com.moviejukebox.themoviedb.model.Person; import com.moviejukebox.themoviedb.model.Studio; +/** + * The parser helper class for TheMovieDb API + * @author stuart.boston + */ public class MovieDbParser { - private static Logger logger = TheMovieDb.getLogger(); - + private static final Logger logger = TheMovieDb.getLogger(); + private static final String NAME = "name"; private static final String GENRE = "genre"; private static final String ID = "id"; @@ -86,27 +90,32 @@ public class MovieDbParser { return categories; } + /** + * Get the list of available languages + * @param url + * @return + */ public static List parseLanguages(String url) { List languages = new ArrayList(); Document doc = null; - + try { doc = DOMHelper.getEventDocFromUrl(url); } catch (Exception e) { logger.severe("Movie.getTranslations error: " + e.getMessage()); return languages; } - + if (doc == null) { return languages; } - + NodeList nlLanguages = doc.getElementsByTagName(LANGUAGE); - + if ((nlLanguages == null) || nlLanguages.getLength() == 0) { return languages; } - + for (int i = 0; i < nlLanguages.getLength(); i++) { Node node = nlLanguages.item(i); if (node.getNodeType() == Node.ELEMENT_NODE) { @@ -114,7 +123,7 @@ public class MovieDbParser { languages.add(parseSimpleLanguage(element)); } } - + return languages; } @@ -155,6 +164,11 @@ public class MovieDbParser { return movie; } + /** + * Parse a DOM document and return the person information + * @param url + * @return + */ public static Person parseLatestPerson(String url) { Person person = new Person(); Document doc = null; @@ -219,6 +233,11 @@ public class MovieDbParser { return movie; } + /** + * Parse the DOM document for movie information and return a list of movies + * @param url + * @return + */ public static List parseMovieGetVersion(String url) { List movies = new ArrayList(); Document doc = null; @@ -251,6 +270,11 @@ public class MovieDbParser { return movies; } + /** + * Returns a MovieDB object from the Element + * @param movieElement + * @return + */ private static MovieDB parseMovieInfo(Element movieElement) { // Inspired by // http://www.java-tips.org/java-se-tips/javax.xml.parsers/how-to-read-xml-file-in-java.html @@ -552,6 +576,9 @@ public class MovieDbParser { return people; } + /** + * Parse the URL and return a list of the people found in the DOM document + */ public static ArrayList parsePersonInfo(String searchUrl) { ArrayList people = new ArrayList(); Person person = null; @@ -570,15 +597,15 @@ public class MovieDbParser { NodeList personNodeList = doc.getElementsByTagName(PERSON); - + if ((personNodeList == null) || personNodeList.getLength() == 0) { return people; } - + for (int loop = 0; loop < personNodeList.getLength(); loop++) { Node personNode = personNodeList.item(loop); person = new Person(); - + if (personNode == null) { logger.finest("Person not found"); return people; @@ -587,23 +614,23 @@ public class MovieDbParser { if (personNode.getNodeType() == Node.ELEMENT_NODE) { try { Element personElement = (Element) personNode; - + person.setName(DOMHelper.getValueFromElement(personElement, NAME)); person.setId(DOMHelper.getValueFromElement(personElement, ID)); person.setBiography(DOMHelper.getValueFromElement(personElement, "biography")); - + try { person.setKnownMovies(Integer.parseInt(DOMHelper.getValueFromElement(personElement, "known_movies"))); } catch (NumberFormatException error) { person.setKnownMovies(0); } - + person.setBirthday(DOMHelper.getValueFromElement(personElement, "birthday")); person.setBirthPlace(DOMHelper.getValueFromElement(personElement, "birthplace")); person.setUrl(DOMHelper.getValueFromElement(personElement, URL)); person.setVersion(Integer.parseInt(DOMHelper.getValueFromElement(personElement, "version"))); person.setLastModifiedAt(DOMHelper.getValueFromElement(personElement, "last_modified_at")); - + NodeList artworkNodeList = doc.getElementsByTagName("image"); for (int nodeLoop = 0; nodeLoop < artworkNodeList.getLength(); nodeLoop++) { Node artworkNode = artworkNodeList.item(nodeLoop); @@ -617,25 +644,25 @@ public class MovieDbParser { person.addArtwork(artwork); } } - + NodeList filmNodeList = doc.getElementsByTagName(MOVIE); for (int nodeLoop = 0; nodeLoop < filmNodeList.getLength(); nodeLoop++) { Node filmNode = filmNodeList.item(nodeLoop); if (filmNode.getNodeType() == Node.ELEMENT_NODE) { Element filmElement = (Element) filmNode; Filmography film = new Filmography(); - + film.setCharacter(filmElement.getAttribute("character")); film.setDepartment(filmElement.getAttribute("department")); film.setId(filmElement.getAttribute(ID)); film.setJob(filmElement.getAttribute("job")); film.setName(filmElement.getAttribute(NAME)); film.setUrl(filmElement.getAttribute(URL)); - + person.addFilm(film); } } - + people.add(person); } catch (Exception error) { logger.severe("PersonInfo: " + error.getMessage()); @@ -646,7 +673,7 @@ public class MovieDbParser { } } } - + return people; } @@ -688,7 +715,7 @@ public class MovieDbParser { movie.setLastModifiedAt(DOMHelper.getValueFromElement(element, "last_modified_at")); return movie; } - + /** * Parse a "simple" Person in the form: * diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/WebBrowser.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/WebBrowser.java index 7dfa17d53..53c66d1c8 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/WebBrowser.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/WebBrowser.java @@ -1,14 +1,14 @@ /* * Copyright (c) 2004-2011 YAMJ Members - * http://code.google.com/p/moviejukebox/people/list - * + * http://code.google.com/p/moviejukebox/people/list + * * Web: http://code.google.com/p/moviejukebox/ - * + * * This software is licensed under a Creative Commons License * See this page: http://code.google.com/p/moviejukebox/wiki/License - * - * For any reuse or distribution, you must make clear to others the - * license terms of this work. + * + * For any reuse or distribution, you must make clear to others the + * license terms of this work. */ package com.moviejukebox.themoviedb.tools; @@ -26,14 +26,15 @@ import java.util.List; import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; +import org.apache.commons.codec.binary.Base64; /** * Web browser with simple cookies support */ public final class WebBrowser { - + private static Map browserProperties = new HashMap(); - private static Map> cookies; + private static Map> cookies = new HashMap>(); private static String proxyHost = null; private static String proxyPort = null; private static String proxyUsername = null; @@ -42,68 +43,87 @@ public final class WebBrowser { private static int webTimeoutConnect = 25000; // 25 second timeout private static int webTimeoutRead = 90000; // 90 second timeout - static { - browserProperties.put("User-Agent", "Mozilla/5.25 Netscape/5.0 (Windows; I; Win95)"); - cookies = new HashMap>(); + /** + * Constructor for WebBrowser. + * Does instantiates the browser properties. + */ + public WebBrowser() { + if (browserProperties.isEmpty()) { + browserProperties.put("User-Agent", "Mozilla/5.25 Netscape/5.0 (Windows; I; Win95)"); + } } - + + /** + * Request the web page at the specified URL + * @param url + * @return + * @throws IOException + */ public static String request(String url) throws IOException { return request(new URL(url)); } - + + /** + * Open a connection using proxy parameters if they exist. + * @param url + * @return + * @throws IOException + */ public static URLConnection openProxiedConnection(URL url) throws IOException { if (proxyHost != null) { System.getProperties().put("proxySet", "true"); System.getProperties().put("proxyHost", proxyHost); System.getProperties().put("proxyPort", proxyPort); } - + URLConnection cnx = url.openConnection(); - + if (proxyUsername != null) { cnx.setRequestProperty("Proxy-Authorization", proxyEncodedPassword); } - + return cnx; } + /** + * Request the web page at the specified URL + * @param url + * @return + * @throws IOException + */ public static String request(URL url) throws IOException { - StringWriter content = null; + StringBuilder content = new StringBuilder(); + BufferedReader in = null; + URLConnection cnx = null; try { - content = new StringWriter(); + cnx = openProxiedConnection(url); - BufferedReader in = null; - URLConnection cnx = null; - try { - cnx = openProxiedConnection(url); + sendHeader(cnx); + readHeader(cnx); - sendHeader(cnx); - readHeader(cnx); - - in = new BufferedReader(new InputStreamReader(cnx.getInputStream(), getCharset(cnx))); - String line; - while ((line = in.readLine()) != null) { - content.write(line); - } - } finally { - if (in != null) { - in.close(); - } - - if ((cnx != null) && (cnx instanceof HttpURLConnection)) { - ((HttpURLConnection)cnx).disconnect(); - } - + in = new BufferedReader(new InputStreamReader(cnx.getInputStream(), getCharset(cnx))); + String line; + while ((line = in.readLine()) != null) { + content.append(line); } - return content.toString(); } finally { - if (content != null) { - content.close(); + if (in != null) { + in.close(); } + + if ((cnx != null) && (cnx instanceof HttpURLConnection)) { + ((HttpURLConnection) cnx).disconnect(); + } + } + return content.toString(); } + /** + * Set the header information for the connection + * @param cnx + */ private static void sendHeader(URLConnection cnx) { // send browser properties for (Map.Entry browserProperty : browserProperties.entrySet()) { @@ -116,6 +136,11 @@ public final class WebBrowser { } } + /** + * Create the cookies for the header + * @param cnx + * @return + */ private static String createCookieHeader(URLConnection cnx) { String host = cnx.getURL().getHost(); StringBuilder cookiesHeader = new StringBuilder(); @@ -136,6 +161,10 @@ public final class WebBrowser { return cookiesHeader.toString(); } + /** + * Read the header information into the cookies + * @param cnx + */ private static void readHeader(URLConnection cnx) { // read new cookies and update our cookies for (Map.Entry> header : cnx.getHeaderFields().entrySet()) { @@ -172,6 +201,11 @@ public final class WebBrowser { } } + /** + * Determine the charset for the connection + * @param cnx + * @return + */ private static Charset getCharset(URLConnection cnx) { Charset charset = null; // content type will be string like "text/html; charset=UTF-8" or "text/html" @@ -191,59 +225,108 @@ public final class WebBrowser { if (charset == null) { charset = Charset.defaultCharset(); } - + return charset; } + /** + * Return the proxy host name + * @return + */ public static String getProxyHost() { return proxyHost; } + /** + * Set the proxy host name + * @param tvdbProxyHost + */ public static void setProxyHost(String tvdbProxyHost) { WebBrowser.proxyHost = tvdbProxyHost; } + /** + * Get the proxy port + * @return + */ public static String getProxyPort() { return proxyPort; } - public static void setProxyPort(String tvdbProxyPort) { - WebBrowser.proxyPort = tvdbProxyPort; + /** + * Set the proxy port + * @param proxyPort + */ + public static void setProxyPort(String proxyPort) { + WebBrowser.proxyPort = proxyPort; } - public static String getTvdbProxyUsername() { + /** + * Get the proxy username + * @return + */ + public static String getProxyUsername() { return proxyUsername; } - public static void setProxyUsername(String tvdbProxyUsername) { - WebBrowser.proxyUsername = tvdbProxyUsername; + /** + * Set the proxy username + * @param proxyUsername + */ + public static void setProxyUsername(String proxyUsername) { + WebBrowser.proxyUsername = proxyUsername; } + /** + * Get the proxy password + * @return + */ public static String getProxyPassword() { return proxyPassword; } - public static void setProxyPassword(String tvdbProxyPassword) { - WebBrowser.proxyPassword = tvdbProxyPassword; - - if (proxyUsername != null) { - proxyEncodedPassword = proxyUsername + ":" + tvdbProxyPassword; - proxyEncodedPassword = Base64.base64Encode(proxyEncodedPassword); + /** + * Set the proxy password. + * Note this will automatically encode the password + * @param proxyPassword + */ + public static void setProxyPassword(String proxyPassword) { + WebBrowser.proxyPassword = proxyPassword; + + if (proxyUsername != null && !proxyPassword.isEmpty()) { + proxyEncodedPassword = proxyUsername + ":" + proxyPassword; + proxyEncodedPassword = "Basic " + new String(Base64.encodeBase64((proxyUsername + ":" + proxyPassword).getBytes())); } } + /** + * Get the current web connect timeout value + * @return + */ public static int getWebTimeoutConnect() { return webTimeoutConnect; } + /** + * Get the current web read timeout value + * @return + */ public static int getWebTimeoutRead() { return webTimeoutRead; } + /** + * Set the web connect timeout value + * @param webTimeoutConnect + */ public static void setWebTimeoutConnect(int webTimeoutConnect) { WebBrowser.webTimeoutConnect = webTimeoutConnect; } + /** + * Set the web read timeout value + * @param webTimeoutRead + */ public static void setWebTimeoutRead(int webTimeoutRead) { WebBrowser.webTimeoutRead = webTimeoutRead; } From f050ce62134f2b52f722796b27be57631be4d81b Mon Sep 17 00:00:00 2001 From: Omertron Date: Tue, 6 Dec 2011 13:10:25 +0000 Subject: [PATCH 090/207] Source code cleanup --- themoviedbapi/pom.xml | 4 ++-- .../java/com/moviejukebox/themoviedb/tools/WebBrowser.java | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/themoviedbapi/pom.xml b/themoviedbapi/pom.xml index fd0b362ae..2e20e6364 100644 --- a/themoviedbapi/pom.xml +++ b/themoviedbapi/pom.xml @@ -9,7 +9,7 @@ com.moviejukebox themoviedbapi 1.2-SNAPSHOT - The MovieDB API + API-The MovieDB Google Code @@ -42,7 +42,7 @@ commons-codec commons-codec - 1.4 + 1.5 diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/WebBrowser.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/WebBrowser.java index 53c66d1c8..f61c959aa 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/WebBrowser.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/WebBrowser.java @@ -15,7 +15,6 @@ package com.moviejukebox.themoviedb.tools; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; -import java.io.StringWriter; import java.net.HttpURLConnection; import java.net.URL; import java.net.URLConnection; @@ -293,7 +292,7 @@ public final class WebBrowser { public static void setProxyPassword(String proxyPassword) { WebBrowser.proxyPassword = proxyPassword; - if (proxyUsername != null && !proxyPassword.isEmpty()) { + if (proxyUsername != null) { proxyEncodedPassword = proxyUsername + ":" + proxyPassword; proxyEncodedPassword = "Basic " + new String(Base64.encodeBase64((proxyUsername + ":" + proxyPassword).getBytes())); } From 913392b5f4b4e5e5bd2be867b1297ec63d0717f5 Mon Sep 17 00:00:00 2001 From: Omertron Date: Thu, 5 Jan 2012 16:05:04 +0000 Subject: [PATCH 091/207] Updated copyright year --- .../src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java | 2 +- .../main/java/com/moviejukebox/themoviedb/model/Artwork.java | 2 +- .../main/java/com/moviejukebox/themoviedb/model/Category.java | 2 +- .../main/java/com/moviejukebox/themoviedb/model/Country.java | 2 +- .../java/com/moviejukebox/themoviedb/model/Filmography.java | 2 +- .../main/java/com/moviejukebox/themoviedb/model/Language.java | 2 +- .../main/java/com/moviejukebox/themoviedb/model/MovieDB.java | 2 +- .../src/main/java/com/moviejukebox/themoviedb/model/Person.java | 2 +- .../src/main/java/com/moviejukebox/themoviedb/model/Studio.java | 2 +- .../main/java/com/moviejukebox/themoviedb/tools/DOMHelper.java | 2 +- .../java/com/moviejukebox/themoviedb/tools/LogFormatter.java | 2 +- .../main/java/com/moviejukebox/themoviedb/tools/ModelTools.java | 2 +- .../java/com/moviejukebox/themoviedb/tools/MovieDbParser.java | 2 +- .../main/java/com/moviejukebox/themoviedb/tools/WebBrowser.java | 2 +- .../test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java | 2 +- 15 files changed, 15 insertions(+), 15 deletions(-) diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java index 28146eb88..cf675fc7a 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2011 YAMJ Members + * Copyright (c) 2004-2012 YAMJ Members * http://code.google.com/p/moviejukebox/people/list * * Web: http://code.google.com/p/moviejukebox/ diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Artwork.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Artwork.java index ea1340315..8cbed0983 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Artwork.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Artwork.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2011 YAMJ Members + * Copyright (c) 2004-2012 YAMJ Members * http://code.google.com/p/moviejukebox/people/list * * Web: http://code.google.com/p/moviejukebox/ diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Category.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Category.java index 612b364ab..3958d8c3f 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Category.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Category.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2011 YAMJ Members + * Copyright (c) 2004-2012 YAMJ Members * http://code.google.com/p/moviejukebox/people/list * * Web: http://code.google.com/p/moviejukebox/ diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Country.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Country.java index e1626b71a..1e59e92e5 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Country.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Country.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2011 YAMJ Members + * Copyright (c) 2004-2012 YAMJ Members * http://code.google.com/p/moviejukebox/people/list * * Web: http://code.google.com/p/moviejukebox/ diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Filmography.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Filmography.java index 308385ba7..0e7e496be 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Filmography.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Filmography.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2011 YAMJ Members + * Copyright (c) 2004-2012 YAMJ Members * http://code.google.com/p/moviejukebox/people/list * * Web: http://code.google.com/p/moviejukebox/ diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Language.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Language.java index 4c986f160..5fe0b8efb 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Language.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Language.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2011 YAMJ Members + * Copyright (c) 2004-2012 YAMJ Members * http://code.google.com/p/moviejukebox/people/list * * Web: http://code.google.com/p/moviejukebox/ diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/MovieDB.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/MovieDB.java index f9ca36905..d8a1cad8f 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/MovieDB.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/MovieDB.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2011 YAMJ Members + * Copyright (c) 2004-2012 YAMJ Members * http://code.google.com/p/moviejukebox/people/list * * Web: http://code.google.com/p/moviejukebox/ diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Person.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Person.java index 637da5a38..fb2598fbc 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Person.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Person.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2011 YAMJ Members + * Copyright (c) 2004-2012 YAMJ Members * http://code.google.com/p/moviejukebox/people/list * * Web: http://code.google.com/p/moviejukebox/ diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Studio.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Studio.java index fc9b0626d..2804be103 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Studio.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Studio.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2011 YAMJ Members + * Copyright (c) 2004-2012 YAMJ Members * http://code.google.com/p/moviejukebox/people/list * * Web: http://code.google.com/p/moviejukebox/ diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/DOMHelper.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/DOMHelper.java index a5c4be580..a9e4ea9d7 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/DOMHelper.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/DOMHelper.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2011 YAMJ Members + * Copyright (c) 2004-2012 YAMJ Members * http://code.google.com/p/moviejukebox/people/list * * Web: http://code.google.com/p/moviejukebox/ diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/LogFormatter.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/LogFormatter.java index a1371781b..02781f390 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/LogFormatter.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/LogFormatter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2011 YAMJ Members + * Copyright (c) 2004-2012 YAMJ Members * http://code.google.com/p/moviejukebox/people/list * * Web: http://code.google.com/p/moviejukebox/ diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/ModelTools.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/ModelTools.java index 89b8ccbe8..1f3f93d1f 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/ModelTools.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/ModelTools.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2011 YAMJ Members + * Copyright (c) 2004-2012 YAMJ Members * http://code.google.com/p/moviejukebox/people/list * * Web: http://code.google.com/p/moviejukebox/ diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/MovieDbParser.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/MovieDbParser.java index 64d48acd1..24173b960 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/MovieDbParser.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/MovieDbParser.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2011 YAMJ Members + * Copyright (c) 2004-2012 YAMJ Members * http://code.google.com/p/moviejukebox/people/list * * Web: http://code.google.com/p/moviejukebox/ diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/WebBrowser.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/WebBrowser.java index f61c959aa..f8459f622 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/WebBrowser.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/WebBrowser.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2011 YAMJ Members + * Copyright (c) 2004-2012 YAMJ Members * http://code.google.com/p/moviejukebox/people/list * * Web: http://code.google.com/p/moviejukebox/ diff --git a/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java b/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java index fce4e4f07..65765d4d7 100644 --- a/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java +++ b/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2011 YAMJ Members + * Copyright (c) 2004-2012 YAMJ Members * http://code.google.com/p/moviejukebox/people/list * * Web: http://code.google.com/p/moviejukebox/ From 10c0470880c96a6ded3c7ab48d818a9de597721c Mon Sep 17 00:00:00 2001 From: Omertron Date: Mon, 16 Jan 2012 15:59:08 +0000 Subject: [PATCH 092/207] Updated pom --- themoviedbapi/pom.xml | 416 +++++++++++++++++++++--------------------- 1 file changed, 208 insertions(+), 208 deletions(-) diff --git a/themoviedbapi/pom.xml b/themoviedbapi/pom.xml index 2e20e6364..8b0ae5760 100644 --- a/themoviedbapi/pom.xml +++ b/themoviedbapi/pom.xml @@ -1,61 +1,61 @@ - 4.0.0 - - org.sonatype.oss - oss-parent - 6 - - com.moviejukebox - themoviedbapi - 1.2-SNAPSHOT - API-The MovieDB + 4.0.0 + + org.sonatype.oss + oss-parent + 7 + + com.moviejukebox + themoviedbapi + 1.2-SNAPSHOT + API-The MovieDB - - Google Code - http://code.google.com/p/themoviedbapi/issues/list - + + Google Code + http://code.google.com/p/themoviedbapi/issues/list + - - Hudson CI - http://jenkins.omertron.com/job/API-TheMovieDb/ - + + Hudson CI + http://jenkins.omertron.com/job/API-TheMovieDb/ + - - scm:svn:http://themoviedbapi.googlecode.com/svn/trunk/themoviedbapi - scm:svn:https://themoviedbapi.googlecode.com/svn/trunk/themoviedbapi - http://code.google.com/p/themoviedbapi/source/browse/trunk/themoviedbapi - + + scm:svn:http://themoviedbapi.googlecode.com/svn/trunk/themoviedbapi + scm:svn:https://themoviedbapi.googlecode.com/svn/trunk/themoviedbapi + http://code.google.com/p/themoviedbapi/source/browse/trunk/themoviedbapi + - - true - UTF-8 - UTF-8 - zip - + + true + UTF-8 + UTF-8 + zip + - - - junit - junit - - - commons-codec - commons-codec - 1.5 - - + + + junit + junit + + + commons-codec + commons-codec + 1.6 + + - - - - junit - junit - 4.10 - test - - - + + + + junit + junit + 4.10 + test + + + @@ -85,171 +85,171 @@ - - - - - org.apache.maven.plugins - maven-clean-plugin - 2.4.1 - - - org.apache.maven.plugins - maven-compiler-plugin - 2.3.2 - - - org.apache.maven.plugins - maven-gpg-plugin - 1.2 - - - org.apache.maven.plugins - maven-jar-plugin - 2.3.1 - - - org.apache.maven.plugins - maven-surefire-plugin - 2.8 - - - org.codehaus.mojo - buildnumber-maven-plugin - 1.0 - - - org.codehaus.mojo - build-helper-maven-plugin - 1.5 - - - org.apache.maven.plugins - maven-antrun-plugin - 1.6 - - - org.apache.maven.plugins - maven-assembly-plugin - 2.2.1 - - - org.codehaus.mojo - versions-maven-plugin - 1.2 - - - + + + + + org.apache.maven.plugins + maven-clean-plugin + 2.4.1 + + + org.apache.maven.plugins + maven-compiler-plugin + 2.3.2 + + + org.apache.maven.plugins + maven-gpg-plugin + 1.2 + + + org.apache.maven.plugins + maven-jar-plugin + 2.3.1 + + + org.apache.maven.plugins + maven-surefire-plugin + 2.8 + + + org.codehaus.mojo + buildnumber-maven-plugin + 1.0 + + + org.codehaus.mojo + build-helper-maven-plugin + 1.5 + + + org.apache.maven.plugins + maven-antrun-plugin + 1.6 + + + org.apache.maven.plugins + maven-assembly-plugin + 2.2.1 + + + org.codehaus.mojo + versions-maven-plugin + 1.2 + + + - - - org.codehaus.mojo - buildnumber-maven-plugin - - true - 0000 - {0,date,yyyy-MM-dd HH:mm:ss} - - - - validate - - create - - - - + + + org.codehaus.mojo + buildnumber-maven-plugin + + true + 0000 + {0,date,yyyy-MM-dd HH:mm:ss} + + + + validate + + create + + + + - - org.apache.maven.plugins - maven-compiler-plugin - - 1.6 - 1.6 - true - true + + org.apache.maven.plugins + maven-compiler-plugin + + 1.6 + 1.6 + true + true - - + + - - org.apache.maven.plugins - maven-jar-plugin - - - - ${project.name} - ${project.version} - ${buildNumber} - ${timestamp} - - - - + + org.apache.maven.plugins + maven-jar-plugin + + + + ${project.name} + ${project.version} + ${buildNumber} + ${timestamp} + + + + - - org.apache.maven.plugins - maven-surefire-plugin - - ${skipTests} - - + + org.apache.maven.plugins + maven-surefire-plugin + + ${skipTests} + + - - org.apache.maven.plugins - maven-antrun-plugin - - - create-version-txt - generate-resources - - - - - - - - Writing version file: ${version_file} - ${header_line} - ${build_date_line} - ${version_line} - ${revision_line} - - - - run - - - - - - org.apache.maven.plugins - maven-assembly-plugin - - - distro-assembly - package - - single - - - - src/main/resources/bin.xml - - - - - - - org.codehaus.mojo - versions-maven-plugin - - + + org.apache.maven.plugins + maven-antrun-plugin + + + create-version-txt + generate-resources + + + + + + + + Writing version file: ${version_file} + ${header_line} + ${build_date_line} + ${version_line} + ${revision_line} + + + + run + + + + + + org.apache.maven.plugins + maven-assembly-plugin + + + distro-assembly + package + + single + + + + src/main/resources/bin.xml + + + + + + + org.codehaus.mojo + versions-maven-plugin + + - ${project.artifactId}-${project.version}-r${buildNumber} - - + ${project.artifactId}-${project.version}-r${buildNumber} + + - + From 672083ec6be378f9c780df9afdb134b19dde87dd Mon Sep 17 00:00:00 2001 From: Omertron Date: Wed, 25 Jan 2012 13:00:13 +0000 Subject: [PATCH 093/207] [maven-release-plugin] prepare release themoviedbapi-2.1 --- themoviedbapi/pom.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/themoviedbapi/pom.xml b/themoviedbapi/pom.xml index 8b0ae5760..825cec283 100644 --- a/themoviedbapi/pom.xml +++ b/themoviedbapi/pom.xml @@ -8,7 +8,7 @@ com.moviejukebox themoviedbapi - 1.2-SNAPSHOT + 2.1 API-The MovieDB @@ -22,9 +22,9 @@ - scm:svn:http://themoviedbapi.googlecode.com/svn/trunk/themoviedbapi - scm:svn:https://themoviedbapi.googlecode.com/svn/trunk/themoviedbapi - http://code.google.com/p/themoviedbapi/source/browse/trunk/themoviedbapi + scm:svn:http://themoviedbapi.googlecode.com/svn/tags/themoviedbapi-2.1 + scm:svn:https://themoviedbapi.googlecode.com/svn/tags/themoviedbapi-2.1 + http://code.google.com/p/themoviedbapi/source/browse/tags/themoviedbapi-2.1 From 0100408a3e9586cb5914161d755c75e8c07011b0 Mon Sep 17 00:00:00 2001 From: Omertron Date: Wed, 25 Jan 2012 13:00:26 +0000 Subject: [PATCH 094/207] [maven-release-plugin] prepare for next development iteration --- themoviedbapi/pom.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/themoviedbapi/pom.xml b/themoviedbapi/pom.xml index 825cec283..b50c54a0d 100644 --- a/themoviedbapi/pom.xml +++ b/themoviedbapi/pom.xml @@ -8,7 +8,7 @@ com.moviejukebox themoviedbapi - 2.1 + 3.0-SNAPSHOT API-The MovieDB @@ -22,9 +22,9 @@ - scm:svn:http://themoviedbapi.googlecode.com/svn/tags/themoviedbapi-2.1 - scm:svn:https://themoviedbapi.googlecode.com/svn/tags/themoviedbapi-2.1 - http://code.google.com/p/themoviedbapi/source/browse/tags/themoviedbapi-2.1 + scm:svn:http://themoviedbapi.googlecode.com/svn/trunk/themoviedbapi + scm:svn:https://themoviedbapi.googlecode.com/svn/trunk/themoviedbapi + http://code.google.com/p/themoviedbapi/source/browse/trunk/themoviedbapi From 018c2b6bc53c416b57a32b92a91f32ed1ee772f0 Mon Sep 17 00:00:00 2001 From: Omertron Date: Wed, 25 Jan 2012 14:59:14 +0000 Subject: [PATCH 095/207] Remove v2.1 files --- .../moviejukebox/themoviedb/TheMovieDb.java | 656 ---------------- .../themoviedb/model/Artwork.java | 183 ----- .../themoviedb/model/Category.java | 79 -- .../themoviedb/model/Country.java | 68 -- .../themoviedb/model/Filmography.java | 96 --- .../themoviedb/model/Language.java | 81 -- .../themoviedb/model/MovieDB.java | 380 --------- .../moviejukebox/themoviedb/model/Person.java | 451 ----------- .../moviejukebox/themoviedb/model/Studio.java | 68 -- .../themoviedb/tools/DOMHelper.java | 107 --- .../themoviedb/tools/LogFormatter.java | 46 -- .../themoviedb/tools/ModelTools.java | 177 ----- .../themoviedb/tools/MovieDbParser.java | 739 ------------------ .../themoviedb/tools/WebBrowser.java | 332 -------- .../themoviedb/TheMovieDbTest.java | 487 ------------ 15 files changed, 3950 deletions(-) delete mode 100644 themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java delete mode 100644 themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Artwork.java delete mode 100644 themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Category.java delete mode 100644 themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Country.java delete mode 100644 themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Filmography.java delete mode 100644 themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Language.java delete mode 100644 themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/MovieDB.java delete mode 100644 themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Person.java delete mode 100644 themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Studio.java delete mode 100644 themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/DOMHelper.java delete mode 100644 themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/LogFormatter.java delete mode 100644 themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/ModelTools.java delete mode 100644 themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/MovieDbParser.java delete mode 100644 themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/WebBrowser.java delete mode 100644 themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java deleted file mode 100644 index cf675fc7a..000000000 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java +++ /dev/null @@ -1,656 +0,0 @@ -/* - * Copyright (c) 2004-2012 YAMJ Members - * http://code.google.com/p/moviejukebox/people/list - * - * Web: http://code.google.com/p/moviejukebox/ - * - * This software is licensed under a Creative Commons License - * See this page: http://code.google.com/p/moviejukebox/wiki/License - * - * For any reuse or distribution, you must make clear to others the - * license terms of this work. - */ -package com.moviejukebox.themoviedb; - -import java.io.UnsupportedEncodingException; -import java.net.URLEncoder; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.logging.ConsoleHandler; -import java.util.logging.Level; -import java.util.logging.Logger; - -import com.moviejukebox.themoviedb.model.Category; -import com.moviejukebox.themoviedb.model.Language; -import com.moviejukebox.themoviedb.model.MovieDB; -import com.moviejukebox.themoviedb.model.Person; -import com.moviejukebox.themoviedb.tools.MovieDbParser; -import com.moviejukebox.themoviedb.tools.LogFormatter; -import com.moviejukebox.themoviedb.tools.WebBrowser; - -/** - * This is the main class for the API to connect to TheMovieDb.org. - * The implementation is for v2.1 of the API as detailed here: - * http://api.themoviedb.org/2.1 - * - * @author Stuart.Boston - * @version 1.3 - */ -public class TheMovieDb { - private String apiKey; - private static Logger logger = null; - private static LogFormatter tmdbFormatter = new LogFormatter(); - private static ConsoleHandler tmdbConsoleHandler = new ConsoleHandler(); - private static final String API_SITE = "http://api.themoviedb.org/2.1/"; - private static final String DEFAULT_LANGUAGE = "en-US"; - - /** - * Constructor with default logger. - * @param apiKey - */ - public TheMovieDb(String apiKey) { - setLogger(Logger.getLogger("TheMovieDB")); - if (!isValidString(apiKey)) { - logger.severe("TheMovieDb was initialized with a wrong API key!"); - } - setApiKey(apiKey); - } - - /* - * API Methods - * http://api.themoviedb.org/2.1 - * Note: This is currently a read-only interface and as such, no write methods exist. - */ - - /* - * Media - */ - @SuppressWarnings("unused") - private static final String MEDIA_GET_INFO = "Media.getInfo"; - - /* - * Movies - */ - private static final String MOVIE_BROWSE = "Movie.browse"; - private static final String MOVIE_GET_IMAGES = "Movie.getImages"; - private static final String MOVIE_GET_INFO = "Movie.getInfo"; - private static final String MOVIE_GET_LATEST = "Movie.getLatest"; - private static final String MOVIE_GET_TRANSLATIONS = "Movie.getTranslations"; - private static final String MOVIE_GET_VERSION = "Movie.getVersion"; - private static final String MOVIE_IMDB_LOOKUP = "Movie.imdbLookup"; - private static final String MOVIE_SEARCH = "Movie.search"; - - /* - * People - */ - private static final String PERSON_GET_INFO = "Person.getInfo"; - private static final String PERSON_GET_LATEST = "Person.getLatest"; - private static final String PERSON_GET_VERSION = "Person.getVersion"; - private static final String PERSON_SEARCH = "Person.search"; - - /* - * Misc - */ - private static final String GENRES_GET_LIST = "Genres.getList"; - - /** - * Compare the MovieDB object with a title & year - * @param moviedb The moviedb object to compare too - * @param title The title of the movie to compare - * @param year The year of the movie to compare - * @return True if there is a match, False otherwise. - */ - public static boolean compareMovies(MovieDB moviedb, String title, String year) { - if ((moviedb == null) || (!isValidString(title))) { - return false; - } - - if (isValidString(year)) { - if (isValidString(moviedb.getReleaseDate())) { - // Compare with year - String movieYear = moviedb.getReleaseDate().substring(0, 4); - if (movieYear.equals(year)) { - if (moviedb.getOriginalName().equalsIgnoreCase(title)) { - return true; - } - - if (moviedb.getTitle().equalsIgnoreCase(title)) { - return true; - } - - // Try matching the alternative name too - if (moviedb.getAlternativeName().equalsIgnoreCase(title)) { - return true; - } - } - } - } else { - // Compare without year - if (moviedb.getOriginalName().equalsIgnoreCase(title)) { - return true; - } - - if (moviedb.getTitle().equalsIgnoreCase(title)) { - return true; - } - - // Try matching the alternative name too - if (moviedb.getAlternativeName().equalsIgnoreCase(title)) { - return true; - } - } - return false; - } - - /** - * Search a list of movies and return the one that matches the title & year - * @param movieList The list of movies to search - * @param title The title to search for - * @param year The year of the title to search for - * @return The matching movie - */ - public static MovieDB findMovie(Collection movieList, String title, String year) { - if ((movieList == null) || (movieList.isEmpty()) || (!isValidString(title))) { - return null; - } - - for (MovieDB moviedb : movieList) { - if (compareMovies(moviedb, title, year)) { - return moviedb; - } - } - - return null; - } - - /** - * Check the string passed to see if it contains a value. - * @param testString The string to test - * @return False if the string is empty, null or UNKNOWN, True otherwise - */ - private static boolean isValidString(String testString) { - if ((testString == null) - || (testString.trim().equals("")) - || (testString.equalsIgnoreCase(MovieDB.UNKNOWN))) { - return false; - } - return true; - } - - public static Logger getLogger() { - return logger; - } - - /** - * Build comma separated ids for Movie.getLatest and Movie.getVersion. - * @param ids a List of ids - * @return - */ - private String buildIds(List ids) { - StringBuilder builder = new StringBuilder(); - - for (int i = 0; i < ids.size(); i++) { - if (i == 0) { - builder.append(ids.get(i)); - continue; - } - builder.append(",").append(ids.get(i)); - } - return builder.toString(); - } - - /** - * Build the URL that is used to get the XML from TMDb. - * - * @param prefix The search prefix before the movie title - * @param language The two digit language code. E.g. en=English - * @param searchTerm The search key to use, e.g. movie title or IMDb ID - * @return The search URL - */ - private String buildUrl(String prefix, String searchTerm, String language) { - StringBuilder url = new StringBuilder(); - - - - url.append(API_SITE); - url.append(prefix); - url.append("/"); - if (language.length() > 2) { - url.append(language.substring(0, 2)); - } else { - url.append(language); - } - url.append("/xml/"); - url.append(apiKey); - - if (!isValidString(searchTerm)) { - return url.toString(); - } - - if (prefix.equals(MOVIE_BROWSE)) { - url.append("?"); - } else { - url.append("/"); - } - - // Try to encode the search term to append - try { - url.append(URLEncoder.encode(searchTerm, "UTF-8")); - } catch (UnsupportedEncodingException e) { - url.append(searchTerm); - } - - return url.toString(); - } - - /** - * Return the API key. - * @return - */ - public String getApiKey() { - return apiKey; - } - - /** - * Retrieve a list of valid genres within TMDb. - * @param language the two digit language code. E.g. en=English - * @return - */ - public List getCategories(String language) { - return MovieDbParser.parseCategories(this.buildUrl(GENRES_GET_LIST, "", language)); - } - - /** - * Return the TMDb default language: en-US. - * @return - */ - public String getDefaultLanguage() { - return DEFAULT_LANGUAGE; - } - - public List getTranslations(String movieId, String language) { - return MovieDbParser.parseLanguages(this.buildUrl(MOVIE_GET_TRANSLATIONS, movieId, language)); - } - - /** - * Browse the database using optional parameters. - * http://api.themoviedb.org/2.1/methods/Movie.browse - * - * @param orderBy either rating, - * release or title - * @param order how results are ordered. Either asc or - * desc - * @param parameters a Map of optional parameters. See the complete list - * in the url above. - * @param language the two digit language code. E.g. en=English - * @return a list of MovieDB objects - */ - public List moviedbBrowse(String orderBy, String order, Map parameters, String language) { - - List movies = new ArrayList(); - if (!isValidString(orderBy) || (!isValidString(order)) - || (parameters == null) || parameters.isEmpty()) { - return movies; - } - - List validParameters = new ArrayList(); - validParameters.add("per_page"); - validParameters.add("page"); - validParameters.add("query"); - validParameters.add("min_votes"); - validParameters.add("rating_min"); - validParameters.add("rating_max"); - validParameters.add("genres"); - validParameters.add("genres_selector"); - validParameters.add("release_min"); - validParameters.add("release_max"); - validParameters.add("year"); - validParameters.add("certifications"); - validParameters.add("companies"); - validParameters.add("countries"); - - - StringBuilder searchUrl = new StringBuilder(); - searchUrl.append("order_by=").append(orderBy); - searchUrl.append("&order=").append(order); - - if(!parameters.isEmpty()) { - for (String key : validParameters) { - if (parameters.containsKey(key)) { - searchUrl.append("&").append(key).append("=").append(parameters.get(key)); - } - } - } - - // Get the search url - String baseUrl = buildUrl(MOVIE_BROWSE, "", language); - - // Now append the parameter url to the end of the search url - searchUrl.insert(0, "?"); - searchUrl.insert(0, baseUrl); - - return MovieDbParser.parseMovies(searchUrl.toString()); - - } - - /** - * Browse the database using the default parameters. - * http://api.themoviedb.org/2.1/methods/Movie.browse - * - * @param orderBy either rating, - * release or title - * @param order how results are ordered. Either asc or - * desc - * @param language the two digit language code. E.g. en=English - * @return a list of MovieDB objects - */ - public List moviedbBrowse(String orderBy, String order, String language) { - return moviedbBrowse(orderBy, order, new HashMap(), language); - } - - /** - * The Movie.getImages method is used to retrieve all of the backdrops and - * posters for a particular movie. This is useful to scan for updates, or - * new images if that's all you're after. - * @param movieId the TMDb or IMDB ID (starting with tt) of the movie you - * are searching for. - * @param movie a MovieDB object - * @param language the two digit language code. E.g. en=English - * @return - */ - public MovieDB moviedbGetImages(String movieId, MovieDB movie, String language) { - // If the searchTerm is null, then exit - if (!isValidString(movieId)) { - return movie; - } - - String searchUrl = buildUrl(MOVIE_GET_IMAGES, movieId, language); - return MovieDbParser.parseMovie(searchUrl); - } - - /** - * The Movie.getImages method is used to retrieve all of the backdrops and - * posters for a particular movie. This is useful to scan for updates, or - * new images if that's all you're after. - * @param movieId the TMDb or IMDB ID (starting with tt) of the movie you - * are searching for. - * @param language the two digit language code. E.g. en=English - * @return - */ - public MovieDB moviedbGetImages(String movieId, String language) { - return moviedbGetImages(movieId, new MovieDB(), language); - } - - /** - * Gets all the information for a given TheMovieDb ID - * - * @param movie - * An existing MovieDB object to populate with the data - * @param tmdbID - * The Movie Db ID for the movie to get information for - * @param language - * The two digit language code. E.g. en=English - * @return A movie bean with all of the information - */ - public MovieDB moviedbGetInfo(String tmdbID, MovieDB movie, String language) { - // If the tmdbID is invalid, then exit - if (!isValidString(tmdbID)) { - return movie; - } - - String searchUrl = buildUrl(MOVIE_GET_INFO, tmdbID, language); - MovieDB foundMovie = MovieDbParser.parseMovie(searchUrl); - - if (foundMovie == null && !language.equalsIgnoreCase(DEFAULT_LANGUAGE)) { - logger.fine("Trying to get the '" + DEFAULT_LANGUAGE + "' version"); - searchUrl = buildUrl(MOVIE_GET_INFO, tmdbID, DEFAULT_LANGUAGE); - foundMovie = MovieDbParser.parseMovie(searchUrl); - } - - return foundMovie; - } - - /** - * Passes a null MovieDB object to the full function - * - * @param tmdbID TheMovieDB ID of the movie to get the information for - * @param language The two digit language code. E.g. en=English - * @return A movie bean with all of the information - */ - public MovieDB moviedbGetInfo(String tmdbID, String language) { - return moviedbGetInfo(tmdbID, new MovieDB(), language); - } - - /** - * The Movie.getLatest method is a simple method. It returns the ID of the - * last movie created in the database. This is useful if you are scanning - * the database and want to know which id to stop at.
- * The MovieDB object returned only has its title, TMDb id, IMDB id, - * version and last modified date initialized. - * @param language the two digit language code. E.g. en=English - * @return - */ - public MovieDB moviedbGetLatest(String language) { - String searchUrl = buildUrl(MOVIE_GET_LATEST, "", language); - return MovieDbParser.parseLatestMovie(searchUrl); - } - - /** - * The Movie.getVersion method is used to retrieve the last modified time - * along with the current version number of the called object(s). This is - * useful if you've already called the object sometime in the past and - * simply want to do a quick check for updates.
- * The MovieDB object returned only has its title, TMDb id, IMDB id, - * version and last modified date initialized. - * @param movieIds the ID of the TMDb movie you are looking for. - * This field supports an integer value (TMDb movie id) an - * IMDB ID or a combination of both. - * @param language the two digit language code. E.g. en=English - * @return - */ - public List moviedbGetVersion(List movieIds, String language) { - List movies = new ArrayList(); - - if ((movieIds == null) || movieIds.isEmpty()) { - return movies; - } - - String url = buildUrl(MOVIE_GET_VERSION, this.buildIds(movieIds), language); - return MovieDbParser.parseMovieGetVersion(url); - - } - - /** - * The Movie.getVersion method is used to retrieve the last modified time - * along with the current version number of the called object(s). This is - * useful if you've already called the object sometime in the past and - * simply want to do a quick check for updates.
- * The MovieDB object returned only has its title, TMDb id, IMDB id, - * version and last modified date initialized. - * @param movieId the TMDb ID or IMDB ID of the movie - * @param language the two digit language code. E.g. en=English - * @return - */ - public MovieDB moviedbGetVersion(String movieId, String language) { - List movies = this.moviedbGetVersion(Arrays.asList(movieId), language); - if (movies.isEmpty()) { - return new MovieDB(); - } - return movies.get(0); - } - - /** - * Searches the database using the IMDb reference - * - * @param imdbID IMDb reference, must include the "tt" at the start - * @param language The two digit language code. E.g. en=English - * @return A movie bean with the data extracted - */ - public MovieDB moviedbImdbLookup(String imdbID, String language) { - MovieDB movie = new MovieDB(); - - // If the imdbID is null, then exit - if (!isValidString(imdbID)) { - return movie; - } - - String searchUrl = buildUrl(MOVIE_IMDB_LOOKUP, imdbID, language); - return MovieDbParser.parseMovie(searchUrl); - } - - /** - * Searches the database using the movie title passed - * - * @param movieTitle The title to search for - * @param language The two digit language code. E.g. en=English - * @return A movie bean with the data extracted - */ - public List moviedbSearch(String movieTitle, String language) { - // If the title is null, then exit - if (!isValidString(movieTitle)) { - return new ArrayList(); - } - - String searchUrl = buildUrl(MOVIE_SEARCH, movieTitle, language); - return MovieDbParser.parseMovies(searchUrl); - } - - /** - * The Person.getInfo method is used to retrieve the full filmography, known movies, - * images and things like birthplace for a specific person in the TMDb database. - * - * @param personID - * @param language - * @return - */ - public ArrayList personGetInfo(String personID, String language) { - if (!isValidString(personID)) { - return new ArrayList(); - } - - String searchUrl = buildUrl(PERSON_GET_INFO, personID, language); - return MovieDbParser.parsePersonInfo(searchUrl); - } - - /** - * The Person.getLatest method is a simple method. It returns the ID of the - * last person created in the db. This is useful if you are scanning the - * database and want to know which id to stop at. - * @param language the two digit language code. E.g. en=English - * @return - */ - public Person personGetLatest(String language) { - return MovieDbParser.parseLatestPerson(buildUrl(PERSON_GET_LATEST, "", language)); - } - - /** - * The Person.getVersion method is used to retrieve the last modified time - * along with the current version number of the called object(s). This is - * useful if you've already called the object sometime in the past and - * simply want to do a quick check for updates. - * @param personIDs one or multiple Person TMDb ids - * @param language the two digit language code. E.g. en=English - * @return - */ - public List personGetVersion(List personIDs, String language) { - if ((personIDs == null) || (personIDs.isEmpty())) { - return new ArrayList(); - } - - String searchUrl = buildUrl(PERSON_GET_VERSION, this.buildIds(personIDs), language); - return MovieDbParser.parsePersonGetVersion(searchUrl); - } - - /** - * The Person.getVersion method is used to retrieve the last modified time - * along with the current version number of the called object(s). This is - * useful if you've already called the object sometime in the past and - * simply want to do a quick check for updates. - * - * @param personID a Person TMDb id - * @param language the two digit language code. E.g. en=English - * @return - */ - public Person personGetVersion(String personID, String language) { - Person person = new Person(); - - if (!isValidString(personID)) { - return person; - } - - List people = this.personGetVersion(Arrays.asList(personID), language); - if (people.isEmpty()) { - return person; - } - - return people.get(0); - } - - /** - * The Person.search method is used to search for an actor, actress or production member. - * http://api.themoviedb.org/2.1/methods/Person.search - * - * @param personName - * @param language - * @return - */ - public ArrayList personSearch(String personName, String language) { - if (!isValidString(personName)) { - return new ArrayList(); - } - - String searchUrl = buildUrl(PERSON_SEARCH, personName, language); - return MovieDbParser.parsePersonInfo(searchUrl); - } - - /** - * Set the TMDb API key. - * @param apiKey a valid TMDb API key. - */ - public void setApiKey(String apiKey) { - this.apiKey = apiKey; - tmdbFormatter.addApiKey(apiKey); - } - - public void setLogger(Logger logger) { - if (logger == null) { - return; - } - - TheMovieDb.logger = logger; - tmdbConsoleHandler.setFormatter(tmdbFormatter); - tmdbConsoleHandler.setLevel(Level.FINE); - logger.addHandler(tmdbConsoleHandler); - logger.setUseParentHandlers(false); - logger.setLevel(Level.ALL); - } - - /** - * Set proxy parameters. - * @param host proxy host URL - * @param port proxy port - * @param username proxy username - * @param password proxy password - */ - public void setProxy(String host, String port, String username, String password) { - WebBrowser.setProxyHost(host); - WebBrowser.setProxyPort(port); - WebBrowser.setProxyUsername(username); - WebBrowser.setProxyPassword(password); - } - - /** - * Set web browser timeout. - * @param webTimeoutConnect - * @param webTimeoutRead - */ - public void setTimeout(int webTimeoutConnect, int webTimeoutRead) { - WebBrowser.setWebTimeoutConnect(webTimeoutConnect); - WebBrowser.setWebTimeoutRead(webTimeoutRead); - } - -} diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Artwork.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Artwork.java deleted file mode 100644 index 8cbed0983..000000000 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Artwork.java +++ /dev/null @@ -1,183 +0,0 @@ -/* - * Copyright (c) 2004-2012 YAMJ Members - * http://code.google.com/p/moviejukebox/people/list - * - * Web: http://code.google.com/p/moviejukebox/ - * - * This software is licensed under a Creative Commons License - * See this page: http://code.google.com/p/moviejukebox/wiki/License - * - * For any reuse or distribution, you must make clear to others the - * license terms of this work. - */ -package com.moviejukebox.themoviedb.model; - -import java.io.Serializable; - -/** - * This is the new bean for the Artwork - * - * @author Stuart.Boston - * - */ -public class Artwork implements Comparable, Serializable { - private static final long serialVersionUID = 1L; - - public static final String ARTWORK_TYPE_POSTER = "poster"; - public static final String ARTWORK_TYPE_BACKDROP = "backdrop"; - public static final String ARTWORK_TYPE_PERSON = "profile"; - public static final String[] ARTWORK_TYPES = {ARTWORK_TYPE_POSTER, ARTWORK_TYPE_BACKDROP, ARTWORK_TYPE_PERSON}; - - public static final String ARTWORK_SIZE_ORIGINAL = "original"; - public static final String ARTWORK_SIZE_THUMB = "thumb"; - public static final String ARTWORK_SIZE_MID = "mid"; - public static final String ARTWORK_SIZE_COVER = "cover"; - public static final String ARTWORK_SIZE_POSTER = "poster"; - public static final String ARTWORK_SIZE_PROFILE = "profile"; - public static final String[] ARTWORK_SIZES = {ARTWORK_SIZE_ORIGINAL, ARTWORK_SIZE_THUMB, ARTWORK_SIZE_MID, ARTWORK_SIZE_COVER, ARTWORK_SIZE_POSTER, ARTWORK_SIZE_PROFILE}; - - private String type; - private String size; - private String url; - private int id; - - public String[] getArtworkSizes() { - return ARTWORK_SIZES; - } - - public String[] getArtworkTypes() { - return ARTWORK_TYPES; - } - - public String getType() { - if (type == null) { - return MovieDB.UNKNOWN; - } else { - return type; - } - } - - public void setType(String type) { - this.type = type; - } - - public String getSize() { - if (size == null) { - return MovieDB.UNKNOWN; - } else { - return size; - } - } - - public void setSize(String size) { - this.size = size; - } - - public String getUrl() { - return url; - } - - public void setUrl(String url) { - this.url = url; - } - - public int getId() { - return id; - } - - public void setId(String id) { - try { - this.id = Integer.parseInt(id); - } catch (Exception ignore) { - // If there is an issue with casting the Id then use Zero - this.id = 0; - } - } - - public void setId(int id) { - this.id = id; - } - - @Override - public int compareTo(Object otherArtwork) throws ClassCastException { - if (!(otherArtwork instanceof Artwork)) { - throw new ClassCastException("TheMovieDB API: An Artwork object is expected."); - } - - int anotherId = ((Artwork) otherArtwork).getId(); - return this.id - anotherId; - } - - @Override - public String toString() { - StringBuilder builder = new StringBuilder(); - builder.append("[Artwork=[type="); - builder.append(type); - builder.append("][size="); - builder.append(size); - builder.append("][url="); - builder.append(url); - builder.append("][id="); - builder.append(id); - builder.append("]]"); - return builder.toString(); - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + id; - result = prime * result + ((size == null) ? 0 : size.hashCode()); - result = prime * result + ((type == null) ? 0 : type.hashCode()); - result = prime * result + ((url == null) ? 0 : url.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - - if (obj == null) { - return false; - } - - if (!(obj instanceof Artwork)) { - return false; - } - - Artwork other = (Artwork)obj; - - if (id != other.id) { - return false; - } - - if (size == null) { - if (other.size != null) { - return false; - } - } else if (!size.equals(other.size)) { - return false; - } - - if (type == null) { - if (other.type != null) { - return false; - } - } else if (!type.equals(other.type)) { - return false; - } - - if (url == null) { - if (other.url != null) { - return false; - } - } else if (!url.equals(other.url)) { - return false; - } - - return true; - } - } diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Category.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Category.java deleted file mode 100644 index 3958d8c3f..000000000 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Category.java +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright (c) 2004-2012 YAMJ Members - * http://code.google.com/p/moviejukebox/people/list - * - * Web: http://code.google.com/p/moviejukebox/ - * - * This software is licensed under a Creative Commons License - * See this page: http://code.google.com/p/moviejukebox/wiki/License - * - * For any reuse or distribution, you must make clear to others the - * license terms of this work. - */ -package com.moviejukebox.themoviedb.model; - -import java.io.Serializable; - -/** - * Category from TheMovieDB.org - * - * @author Stuart.Boston - * - */ -public class Category implements Serializable { - private static final long serialVersionUID = 1L; - - private static final String UNKNOWN = MovieDB.UNKNOWN; - - private String type = UNKNOWN; - private String name = UNKNOWN; - private String url = UNKNOWN; - private String id = UNKNOWN; - - public String getId() { - return id; - } - - public String getName() { - return name; - } - - public String getType() { - return type; - } - - public String getUrl() { - return url; - } - - public void setId(String id) { - this.id = id; - } - - public void setName(String name) { - this.name = name; - } - - public void setType(String type) { - this.type = type; - } - - public void setUrl(String url) { - this.url = url; - } - - @Override - public String toString() { - StringBuilder builder = new StringBuilder(); - builder.append("[Category=[type="); - builder.append(type); - builder.append("][name="); - builder.append(name); - builder.append("][url="); - builder.append(url); - builder.append("][id="); - builder.append(id); - builder.append("]]"); - return builder.toString(); - } -} diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Country.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Country.java deleted file mode 100644 index 1e59e92e5..000000000 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Country.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 2004-2012 YAMJ Members - * http://code.google.com/p/moviejukebox/people/list - * - * Web: http://code.google.com/p/moviejukebox/ - * - * This software is licensed under a Creative Commons License - * See this page: http://code.google.com/p/moviejukebox/wiki/License - * - * For any reuse or distribution, you must make clear to others the - * license terms of this work. - */ -package com.moviejukebox.themoviedb.model; - -import java.io.Serializable; - -/** - * Country from the MovieDB.org - * - * @author Stuart.Boston - * - */ -public class Country implements Serializable { - private static final long serialVersionUID = 1L; - - private static final String UNKNOWN = MovieDB.UNKNOWN; - - private String url = UNKNOWN; - private String name = UNKNOWN; - private String code = UNKNOWN; - - public String getUrl() { - return url; - } - - public void setUrl(String url) { - this.url = url; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getCode() { - return code; - } - - public void setCode(String code) { - this.code = code; - } - - @Override - public String toString() { - StringBuilder builder = new StringBuilder(); - builder.append("[Country=[url="); - builder.append(url); - builder.append("][name="); - builder.append(name); - builder.append("][code="); - builder.append(code); - builder.append("]]"); - return builder.toString(); - } -} diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Filmography.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Filmography.java deleted file mode 100644 index 0e7e496be..000000000 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Filmography.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright (c) 2004-2012 YAMJ Members - * http://code.google.com/p/moviejukebox/people/list - * - * Web: http://code.google.com/p/moviejukebox/ - * - * This software is licensed under a Creative Commons License - * See this page: http://code.google.com/p/moviejukebox/wiki/License - * - * For any reuse or distribution, you must make clear to others the - * license terms of this work. - */ - -package com.moviejukebox.themoviedb.model; - -import java.io.Serializable; - -public class Filmography implements Serializable { - private static final long serialVersionUID = 1L; - - private static final String UNKNOWN = MovieDB.UNKNOWN; - - private String url = UNKNOWN; - private String name = UNKNOWN; - private String department = UNKNOWN; - private String character = UNKNOWN; - private String job = UNKNOWN; - private String id = UNKNOWN; - - public String getUrl() { - return url; - } - - public void setUrl(String url) { - this.url = url; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getDepartment() { - return department; - } - - public void setDepartment(String department) { - this.department = department; - } - - public String getCharacter() { - return character; - } - - public void setCharacter(String character) { - this.character = character; - } - - public String getJob() { - return job; - } - - public void setJob(String job) { - this.job = job; - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - @Override - public String toString() { - StringBuilder builder = new StringBuilder(); - builder.append("[Filmography=[url="); - builder.append(url); - builder.append("][name="); - builder.append(name); - builder.append("][department="); - builder.append(department); - builder.append("][character="); - builder.append(character); - builder.append("][job="); - builder.append(job); - builder.append("][id="); - builder.append(id); - builder.append("]]"); - return builder.toString(); - } -} diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Language.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Language.java deleted file mode 100644 index 5fe0b8efb..000000000 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Language.java +++ /dev/null @@ -1,81 +0,0 @@ -/* - * Copyright (c) 2004-2012 YAMJ Members - * http://code.google.com/p/moviejukebox/people/list - * - * Web: http://code.google.com/p/moviejukebox/ - * - * This software is licensed under a Creative Commons License - * See this page: http://code.google.com/p/moviejukebox/wiki/License - * - * For any reuse or distribution, you must make clear to others the - * license terms of this work. - */ -package com.moviejukebox.themoviedb.model; - -import java.io.Serializable; - -/** - * Language from TheMovieDB.org - * @author stuart.boston - * - */ -public class Language implements Serializable { - private static final long serialVersionUID = 1L; - - private static final String UNKNOWN = MovieDB.UNKNOWN; - - private String isoCode = UNKNOWN; // The iso 639.1 Language code - private String englishName = UNKNOWN; - private String nativeName = UNKNOWN; - - public Language() { - this.isoCode = UNKNOWN; - this.englishName = UNKNOWN; - this.nativeName = UNKNOWN; - } - - public Language(String isoCode, String englishName, String nativeName) { - this.isoCode = isoCode; - this.englishName = englishName; - this.nativeName = nativeName; - } - - public String getEnglishName() { - return englishName; - } - - public String getIsoCode() { - return isoCode; - } - - public String getNativeName() { - return nativeName; - } - - public void setEnglishName(String englishName) { - this.englishName = englishName; - } - - public void setIsoCode(String isoCode) { - this.isoCode = isoCode; - } - - public void setNativeName(String nativeName) { - this.nativeName = nativeName; - } - - @Override - public String toString() { - StringBuilder builder = new StringBuilder(); - builder.append("[Language=[isoCode="); - builder.append(isoCode); - builder.append("][englishName="); - builder.append(englishName); - builder.append("][nativeName="); - builder.append(nativeName); - builder.append("]]"); - return builder.toString(); - } - - -} diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/MovieDB.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/MovieDB.java deleted file mode 100644 index d8a1cad8f..000000000 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/MovieDB.java +++ /dev/null @@ -1,380 +0,0 @@ -/* - * Copyright (c) 2004-2012 YAMJ Members - * http://code.google.com/p/moviejukebox/people/list - * - * Web: http://code.google.com/p/moviejukebox/ - * - * This software is licensed under a Creative Commons License - * See this page: http://code.google.com/p/moviejukebox/wiki/License - * - * For any reuse or distribution, you must make clear to others the - * license terms of this work. - */ -package com.moviejukebox.themoviedb.model; - -import com.moviejukebox.themoviedb.TheMovieDb; -import java.io.Serializable; -import java.text.DateFormat; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.List; -import java.util.Date; - -import com.moviejukebox.themoviedb.tools.ModelTools; -import java.util.logging.Logger; - -/** - * This is the Movie Search bean for the MovieDb.org search - * - * @author Stuart.Boston - */ - -public class MovieDB extends ModelTools implements Serializable { - private static final long serialVersionUID = 1L; - private static final Logger logger = TheMovieDb.getLogger(); - - public static final String UNKNOWN = "UNKNOWN"; - - private String popularity = UNKNOWN; - private String translated = UNKNOWN; - private String adult = UNKNOWN; - private String language = UNKNOWN; - private String title = UNKNOWN; // "name" in the XML - private String originalName = UNKNOWN; // "original_name" in the XML - private String alternativeName = UNKNOWN; // "alternative_name" in the XML - private String type = UNKNOWN; - private String id = UNKNOWN; - private String imdb = UNKNOWN; // "imdb_id" in the XML - private String url = UNKNOWN; - private String overview = UNKNOWN; - private String rating = UNKNOWN; - private String tagline = UNKNOWN; - private String certification = UNKNOWN; - private String releaseDate = UNKNOWN; // "released" in the XML - private String runtime = UNKNOWN; - private String budget = UNKNOWN; - private String revenue = UNKNOWN; - private String homepage = UNKNOWN; - private String trailer = UNKNOWN; - private int version = -1; - private Date lastModifiedAt; - private List categories = new ArrayList(); - private List studios = new ArrayList(); - private List countries = new ArrayList(); - private List people = new ArrayList(); - - public String getPopularity() { - return popularity; - } - - public void setPopularity(String popularity) { - this.popularity = popularity; - } - - public String getTitle() { - return title; - } - - public void setTitle(String title) { - this.title = title; - } - - public String getType() { - return type; - } - - public void setType(String type) { - this.type = type; - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getImdb() { - return imdb; - } - - public void setImdb(String imdb) { - this.imdb = imdb; - } - - public String getUrl() { - return url; - } - - public void setUrl(String url) { - this.url = url; - } - - public String getOverview() { - return overview; - } - - public void setOverview(String overview) { - this.overview = overview; - } - - public String getReleaseDate() { - return releaseDate; - } - - public void setReleaseDate(String releaseDate) { - this.releaseDate = releaseDate; - } - - public String getRating() { - return rating; - } - - public void setRating(String rating) { - this.rating = rating; - } - - public String getRuntime() { - return runtime; - } - - public void setRuntime(String runtime) { - this.runtime = runtime; - } - - public String getBudget() { - return budget; - } - - public void setBudget(String budget) { - this.budget = budget; - } - - public String getRevenue() { - return revenue; - } - - public void setRevenue(String revenue) { - this.revenue = revenue; - } - - public String getHomepage() { - return homepage; - } - - public void setHomepage(String homepage) { - this.homepage = homepage; - } - - public String getTrailer() { - return trailer; - } - - public void setTrailer(String trailer) { - this.trailer = trailer; - } - - public List getProductionCountries() { - return countries; - } - - public void addProductionCountry(Country country) { - if (country != null) { - countries.add(country); - } - } - - public List getPeople() { - return people; - } - - public void addPerson(Person person) { - if (person != null) { - people.add(person); - } - } - - public List getCategories() { - return categories; - } - - public void addCategory(Category category) { - if (category != null) { - categories.add(category); - } - } - - public String getTranslated() { - return translated; - } - - public String getAdult() { - return adult; - } - - public String getLanguage() { - return language; - } - - public String getOriginalName() { - return originalName; - } - - public String getAlternativeName() { - return alternativeName; - } - - public String getTagline() { - return tagline; - } - - public String getCertification() { - return certification; - } - - public List getStudios() { - return studios; - } - - public List getCountries() { - return countries; - } - - public void setTranslated(String translated) { - this.translated = translated; - } - - public void setAdult(String adult) { - this.adult = adult; - } - - public void setLanguage(String language) { - this.language = language; - } - - public void setOriginalName(String originalName) { - this.originalName = originalName; - } - - public void setAlternativeName(String alternativeName) { - this.alternativeName = alternativeName; - } - - public void setTagline(String tagline) { - this.tagline = tagline; - } - - public void setCertification(String certification) { - this.certification = certification; - } - - public void setCategories(List categories) { - this.categories = categories; - } - - public void setStudios(List studios) { - this.studios = studios; - } - - public void addStudio(Studio studio) { - if (studio != null) { - this.studios.add(studio); - } - } - - public void setCountries(List countries) { - this.countries = countries; - } - - public void setPeople(List people) { - this.people = people; - } - - public Date getLastModifiedAt() { - return lastModifiedAt; - } - - public void setLastModifiedAt(Date lastModifiedAt) { - this.lastModifiedAt = lastModifiedAt; - } - - public void setLastModifiedAt(String lastModifiedAt) { - DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - try { - setLastModifiedAt(df.parse(lastModifiedAt)); - } catch (ParseException ex) { - logger.fine("MovieDB: Error parsing date: " + lastModifiedAt); - } - } - - public int getVersion() { - return version; - } - - public void setVersion(int version) { - this.version = version; - } - - @Override - public String toString() { - StringBuilder builder = new StringBuilder(); - builder.append("[MovieDB=[popularity="); - builder.append(popularity); - builder.append("][translated="); - builder.append(translated); - builder.append("][adult="); - builder.append(adult); - builder.append("][language="); - builder.append(language); - builder.append("][title="); - builder.append(title); - builder.append("][originalName="); - builder.append(originalName); - builder.append("][alternativeName="); - builder.append(alternativeName); - builder.append("][type="); - builder.append(type); - builder.append("][id="); - builder.append(id); - builder.append("][imdb="); - builder.append(imdb); - builder.append("][url="); - builder.append(url); - builder.append("][overview="); - builder.append(overview); - builder.append("][rating="); - builder.append(rating); - builder.append("][tagline="); - builder.append(tagline); - builder.append("][certification="); - builder.append(certification); - builder.append("][releaseDate="); - builder.append(releaseDate); - builder.append("][runtime="); - builder.append(runtime); - builder.append("][budget="); - builder.append(budget); - builder.append("][revenue="); - builder.append(revenue); - builder.append("][homepage="); - builder.append(homepage); - builder.append("][trailer="); - builder.append(trailer); - builder.append("][version="); - builder.append(version); - builder.append("][lastModifiedAt="); - builder.append(lastModifiedAt); - builder.append("][categories="); - builder.append(categories); - builder.append("][studios="); - builder.append(studios); - builder.append("][countries="); - builder.append(countries); - builder.append("][people="); - builder.append(people); - builder.append("]]"); - return builder.toString(); - } -} diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Person.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Person.java deleted file mode 100644 index fb2598fbc..000000000 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Person.java +++ /dev/null @@ -1,451 +0,0 @@ -/* - * Copyright (c) 2004-2012 YAMJ Members - * http://code.google.com/p/moviejukebox/people/list - * - * Web: http://code.google.com/p/moviejukebox/ - * - * This software is licensed under a Creative Commons License - * See this page: http://code.google.com/p/moviejukebox/wiki/License - * - * For any reuse or distribution, you must make clear to others the - * license terms of this work. - */ -package com.moviejukebox.themoviedb.model; - -import com.moviejukebox.themoviedb.TheMovieDb; -import java.io.Serializable; -import java.text.DateFormat; -import java.text.ParseException; -import java.text.SimpleDateFormat; -import java.util.ArrayList; -import java.util.Date; -import java.util.List; - -import com.moviejukebox.themoviedb.tools.ModelTools; -import java.util.logging.Logger; - -/** - * This is the new bean for the Person - * - * @author Stuart.Boston - * - */ -public class Person extends ModelTools implements Serializable { - private static final long serialVersionUID = 1L; - private static final Logger logger = TheMovieDb.getLogger(); - - private static final String UNKNOWN = MovieDB.UNKNOWN; - - private String name = UNKNOWN; - private String character = UNKNOWN; - private String job = UNKNOWN; - private String id = UNKNOWN; - private String department = UNKNOWN; - private String biography = UNKNOWN; - private String url = UNKNOWN; - private int order = -1; - private int castId = -1; - private int version = -1; - private Date lastModifiedAt; - private int knownMovies = -1; - private Date birthday; - private String birthPlace = UNKNOWN; - private List filmography = new ArrayList(); - private List aka = new ArrayList(); - private List images = new ArrayList(); - - /** - * Add a single AKA - * @param alsoKnownAs - */ - public void addAka(String alsoKnownAs) { - this.aka.add(alsoKnownAs); - } - - /** - * Add a film for the person - * @param film - */ - public void addFilm(Filmography film) { - this.filmography.add(film); - } - - /** - * Add an artwork image to the person - * @param image - */ - public void addImage(Artwork image) { - if (image != null) { - this.images.add(image); - } - } - - /** - * Get all the AKA values - * @return - */ - public List getAka() { - return aka; - } - - /** - * Get the biography information - * @return - */ - public String getBiography() { - return biography; - } - - /** - * Get the birthday of the person - * @return - */ - public Date getBirthday() { - return birthday; - } - - /** - * Get the birthplace - * @return - */ - public String getBirthPlace() { - return birthPlace; - } - - /** - * get the cast ID - * @return - */ - public int getCastId() { - return castId; - } - - /** - * get the character - * @return - */ - public String getCharacter() { - return character; - } - - /** - * get the department - * @return - */ - public String getDepartment() { - return department; - } - - /** - * get the list of films - * @return - */ - public List getFilmography() { - return filmography; - } - - /** - * get the ID of the person - * @return - */ - public String getId() { - return id; - } - - /** - * get a list of images for the person - * @return - */ - public List getImages() { - return images; - } - - /** - * get the job - * @return - */ - public String getJob() { - return job; - } - - /** - * get the known movies - * @return - */ - public int getKnownMovies() { - return knownMovies; - } - - /** - * get the last modified date for the person - * @return - */ - public Date getLastModifiedAt() { - return lastModifiedAt; - } - - /** - * get the name - * @return - */ - public String getName() { - return name; - } - - /** - * get the order - * @return - */ - public int getOrder() { - return order; - } - - /** - * get the URL for the person - * @return - */ - public String getUrl() { - return url; - } - - /** - * get the version - * @return - */ - public int getVersion() { - return version; - } - - /** - * Set the AKA list for the person - * @param aka - */ - public void setAka(List aka) { - this.aka = aka; - } - - /** - * Set the biography - * @param biography - */ - public void setBiography(String biography) { - this.biography = biography; - } - - /** - * Set the person's birthday - * @param birthday - */ - public void setBirthday(Date birthday) { - this.birthday = birthday; - } - - /** - * Set the person's birthday - * @param sBirthday - */ - public void setBirthday(String sBirthday) { - DateFormat df = new SimpleDateFormat("yyyy-MM-dd"); - try { - setBirthday(df.parse(sBirthday)); - } catch (ParseException ex) { - logger.fine("TheMovieDB - Person: Error parsing birthday: " + sBirthday); - } - } - - /** - * Set the birth place - * @param birthPlace - */ - public void setBirthPlace(String birthPlace) { - this.birthPlace = birthPlace; - } - - /** - * Set the cast ID for the person - * @param castId - */ - public void setCastId(int castId) { - this.castId = castId; - } - - /** - * Set the cast ID for the person - * @param castId - */ - public void setCastId(String castId) { - try { - this.castId = Integer.parseInt(castId); - } catch (Exception ignore) { - this.castId = -1; - } - } - - /** - * Set the character - * @param character - */ - public void setCharacter(String character) { - this.character = character; - } - - /** - * set the Department - * @param department - */ - public void setDepartment(String department) { - this.department = department; - } - - /** - * Add a list of films - * @param filmography - */ - public void setFilmography(List filmography) { - this.filmography = filmography; - } - - /** - * Set the ID of the person - * @param id - */ - public void setId(String id) { - this.id = id; - } - - /** - * Set a list of images for the person - * @param images - */ - public void setImages(List images) { - this.images = images; - } - - /** - * Set the job for the person - * @param job - */ - public void setJob(String job) { - this.job = job; - } - - /** - * Set the known movie for the person - * @param knownMovies - */ - public void setKnownMovies(int knownMovies) { - this.knownMovies = knownMovies; - } - - /** - * Set the last modified date - * @param lastModifiedAt - */ - public void setLastModifiedAt(Date lastModifiedAt) { - this.lastModifiedAt = lastModifiedAt; - } - - /** - * Set the last modified date - * @param lastModifiedAt - */ - public void setLastModifiedAt(String lastModifiedAt) { - DateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); - - try { - Date lma = df.parse(lastModifiedAt); - setLastModifiedAt(lma); - } catch (Exception ignore) { - return; - } - } - - /** - * Set the person's anme - * @param name - */ - public void setName(String name) { - this.name = name; - } - - /** - *Set the order - * @param order - */ - public void setOrder(int order) { - this.order = order; - } - - /** - * Set the order - * @param order - */ - public void setOrder(String order) { - try { - this.order = Integer.parseInt(order); - } catch (Exception ignore) { - this.order = -1; - } - } - - /** - * Set the URL - * @param url - */ - public void setUrl(String url) { - this.url = url; - } - - /** - * Set the version - * @param version - */ - public void setVersion(int version) { - this.version = version; - } - - /** - * Generate a String representation of the person - * @return - */ - @Override - public String toString() { - StringBuilder builder = new StringBuilder(); - builder.append("[Person=[name="); - builder.append(name); - builder.append("][character="); - builder.append(character); - builder.append("][job="); - builder.append(job); - builder.append("][id="); - builder.append(id); - builder.append("][department="); - builder.append(department); - builder.append("][biography="); - builder.append(biography); - builder.append("][url="); - builder.append(url); - builder.append("][order="); - builder.append(order); - builder.append("][castId="); - builder.append(castId); - builder.append("][version="); - builder.append(version); - builder.append("][lastModifiedAt="); - builder.append(lastModifiedAt); - builder.append("][knownMovies="); - builder.append(knownMovies); - builder.append("][birthday="); - builder.append(birthday); - builder.append("][birthPlace="); - builder.append(birthPlace); - builder.append("][filmography="); - builder.append(filmography); - builder.append("][aka="); - builder.append(aka); - builder.append("][images="); - builder.append(images); - builder.append("]]"); - return builder.toString(); - } -} diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Studio.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Studio.java deleted file mode 100644 index 2804be103..000000000 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Studio.java +++ /dev/null @@ -1,68 +0,0 @@ -/* - * Copyright (c) 2004-2012 YAMJ Members - * http://code.google.com/p/moviejukebox/people/list - * - * Web: http://code.google.com/p/moviejukebox/ - * - * This software is licensed under a Creative Commons License - * See this page: http://code.google.com/p/moviejukebox/wiki/License - * - * For any reuse or distribution, you must make clear to others the - * license terms of this work. - */ -package com.moviejukebox.themoviedb.model; - -import java.io.Serializable; - -/** - * Studio from the MovieDB.org - * - * @author Stuart.Boston - * - */ -public class Studio implements Serializable { - private static final long serialVersionUID = 1L; - - private static final String UNKNOWN = MovieDB.UNKNOWN; - - private String name = UNKNOWN; - private String url = UNKNOWN; - private String id = UNKNOWN; - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getUrl() { - return url; - } - - public void setUrl(String url) { - this.url = url; - } - - @Override - public String toString() { - StringBuilder builder = new StringBuilder(); - builder.append("[Studio=[name="); - builder.append(name); - builder.append("][url="); - builder.append(url); - builder.append("][id="); - builder.append(id); - builder.append("]]"); - return builder.toString(); - } -} diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/DOMHelper.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/DOMHelper.java deleted file mode 100644 index a9e4ea9d7..000000000 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/DOMHelper.java +++ /dev/null @@ -1,107 +0,0 @@ -/* - * Copyright (c) 2004-2012 YAMJ Members - * http://code.google.com/p/moviejukebox/people/list - * - * Web: http://code.google.com/p/moviejukebox/ - * - * This software is licensed under a Creative Commons License - * See this page: http://code.google.com/p/moviejukebox/wiki/License - * - * For any reuse or distribution, you must make clear to others the - * license terms of this work. - */ -package com.moviejukebox.themoviedb.tools; - -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.logging.Logger; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import javax.xml.parsers.ParserConfigurationException; - -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; -import org.xml.sax.SAXException; - -import com.moviejukebox.themoviedb.TheMovieDb; - -/** - * Generic set of routines to process the DOM model data - * @author Stuart.Boston - * - */ -public class DOMHelper { - private static final Logger logger = TheMovieDb.getLogger(); - - /** - * Gets the string value of the tag element name passed - * @param element - * @param tagName - * @return - */ - public static String getValueFromElement(Element element, String tagName) { - String returnValue = ""; - - try { - NodeList elementNodeList = element.getElementsByTagName(tagName); - Element tagElement = (Element) elementNodeList.item(0); - NodeList tagNodeList = tagElement.getChildNodes(); - returnValue = ((Node) tagNodeList.item(0)).getNodeValue(); - } catch (Exception ignore) { - return returnValue; - } - - return returnValue; - } - - /** - * Get a DOM document from the supplied URL - * @param url - * @return - * @throws IOException - * @throws ParserConfigurationException - * @throws SAXException - */ - public static Document getEventDocFromUrl(String url) - throws IOException, ParserConfigurationException, SAXException { - Document doc = null; - InputStream in = null; - String webPage = null; - - try { - boolean validWebPage = false; - webPage = WebBrowser.request(url); - - // There seems to be an error with some of the web pages that returns garbage - if (webPage.startsWith("() { - - @Override - public Object run() { - return System.getProperty("line.separator"); - } - }); - - @Override - public synchronized String format(LogRecord logRecord) { - String logMessage = logRecord.getMessage(); - - logMessage = "[TheMovieDb API] " + logMessage.replace(apiKey, "[APIKEY]") + EOL; - - Throwable thrown = logRecord.getThrown(); - if (thrown != null) { - logMessage = logMessage + thrown.toString(); - } - return logMessage; - } - - public void addApiKey(String apiKey) { - LogFormatter.apiKey = apiKey; - return; - } -} diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/ModelTools.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/ModelTools.java deleted file mode 100644 index 1f3f93d1f..000000000 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/ModelTools.java +++ /dev/null @@ -1,177 +0,0 @@ -/* - * Copyright (c) 2004-2012 YAMJ Members - * http://code.google.com/p/moviejukebox/people/list - * - * Web: http://code.google.com/p/moviejukebox/ - * - * This software is licensed under a Creative Commons License - * See this page: http://code.google.com/p/moviejukebox/wiki/License - * - * For any reuse or distribution, you must make clear to others the - * license terms of this work. - */ -package com.moviejukebox.themoviedb.tools; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -import com.moviejukebox.themoviedb.model.Artwork; - -public class ModelTools { - private List artwork = new ArrayList(); - - /** - * Add a piece of artwork to the artwork array - * @param artworkType must be one of Artwork.ARTWORK_TYPES - * @param artworkSize must be one of Artwork.ARTWORK_SIZES - * @param artworkUrl - * @param posterId - */ - public void addArtwork(String artworkType, String artworkSize, String artworkUrl, String artworkId) { - if (validateElement(Artwork.ARTWORK_TYPES, artworkType) && validateElement(Artwork.ARTWORK_SIZES, artworkSize)) { - Artwork newArtwork = new Artwork(); - - newArtwork.setType(artworkType); - newArtwork.setSize(artworkSize); - newArtwork.setUrl(artworkUrl); - newArtwork.setId(artworkId); - - artwork.add(newArtwork); - Collections.sort(artwork); - } - return; - } - - /** - * Add a piece of artwork to the artwork array - * @param newArtwork an Artwork object to add to the array - */ - public void addArtwork(Artwork newArtwork) { - if (validateElement(Artwork.ARTWORK_TYPES, newArtwork.getType()) && validateElement(Artwork.ARTWORK_SIZES, newArtwork.getSize())) { - artwork.add(newArtwork); - Collections.sort(artwork); - } - return; - } - - /** - * Get the first artwork that matches the Type and Size - * @param artworkType - * @param artworkSize - * @return - */ - public Artwork getFirstArtwork(String artworkType, String artworkSize) { - return getArtwork(artworkType, artworkSize, 1); - } - - /** - * Check to see if element is contained in elementArray - * @param elementArray - * @param element - * @return - */ - private boolean validateElement(String[] elementArray, String element) { - boolean valid = false; - - for (String arrayEntry : elementArray) { - if (arrayEntry.equalsIgnoreCase(element)) { - valid = true; - break; - } - } - - return valid; - } - - /** - * Return all the artwork for a movie - * @return - */ - public List getArtwork() { - return artwork; - } - - /** - * Get all the artwork of a specific type - * @param artworkType - * @return - */ - public List getArtwork(String artworkType) { - // Validate the Type and Size arguments - if (!validateElement(Artwork.ARTWORK_TYPES, artworkType)) { - return null; - } - - List artworkList = new ArrayList(); - - for (Artwork singleArtwork : artwork) { - if (singleArtwork.getType().equalsIgnoreCase(artworkType)) { - artworkList.add(singleArtwork); - } - } - - return artworkList; - } - - /** - * Get all artwork of a specific Type and Size - * @param artworkType - * @param artworkSize - * @return - */ - public List getArtwork(String artworkType, String artworkSize) { - List artworkList = new ArrayList(); - // Validate the Type and Size arguments - if (!validateElement(Artwork.ARTWORK_TYPES, artworkType) && !validateElement(Artwork.ARTWORK_SIZES, artworkSize)) { - return null; - } - - for (Artwork singleArtwork : artwork) { - if (singleArtwork.getType().equalsIgnoreCase(artworkType) && singleArtwork.getSize().equalsIgnoreCase(artworkSize)) { - artworkList.add(singleArtwork); - } - } - - return artworkList; - } - - /** - * Return a specific artwork entry for a Type & Size - * @param artworkType - * @param artworkSize - * @param artworkNumber - * @return - */ - public Artwork getArtwork(String artworkType, String artworkSize, int artworkNumber) { - // Validate the Type and Size arguments - if (!validateElement(Artwork.ARTWORK_TYPES, artworkType) && !validateElement(Artwork.ARTWORK_SIZES, artworkSize)) { - return null; - } - - - int validArtworkNumber = artworkNumber; - // Validate the number - if (validArtworkNumber <= 0) { - validArtworkNumber = 0; - } else { - // Artwork elements start at 0 (Zero) - validArtworkNumber -= 1; - } - - List artworkList = getArtwork(artworkType, artworkSize); - - int artworkCount = artworkList.size(); - if (artworkCount < 1) { - return null; - } - - // If the number requested is greater than the array size, loop around until it's within scope - while (validArtworkNumber > artworkCount) { - validArtworkNumber = validArtworkNumber - artworkCount; - } - - return artworkList.get(validArtworkNumber); - } - -} diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/MovieDbParser.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/MovieDbParser.java deleted file mode 100644 index 24173b960..000000000 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/MovieDbParser.java +++ /dev/null @@ -1,739 +0,0 @@ -/* - * Copyright (c) 2004-2012 YAMJ Members - * http://code.google.com/p/moviejukebox/people/list - * - * Web: http://code.google.com/p/moviejukebox/ - * - * This software is licensed under a Creative Commons License - * See this page: http://code.google.com/p/moviejukebox/wiki/License - * - * For any reuse or distribution, you must make clear to others the - * license terms of this work. - */ -package com.moviejukebox.themoviedb.tools; - -import java.io.PrintWriter; -import java.io.StringWriter; -import java.io.Writer; -import java.util.ArrayList; -import java.util.List; -import java.util.logging.Logger; - -import org.w3c.dom.Document; -import org.w3c.dom.Element; -import org.w3c.dom.Node; -import org.w3c.dom.NodeList; - -import com.moviejukebox.themoviedb.TheMovieDb; -import com.moviejukebox.themoviedb.model.Artwork; -import com.moviejukebox.themoviedb.model.Category; -import com.moviejukebox.themoviedb.model.Country; -import com.moviejukebox.themoviedb.model.Filmography; -import com.moviejukebox.themoviedb.model.Language; -import com.moviejukebox.themoviedb.model.MovieDB; -import com.moviejukebox.themoviedb.model.Person; -import com.moviejukebox.themoviedb.model.Studio; - -/** - * The parser helper class for TheMovieDb API - * @author stuart.boston - */ -public class MovieDbParser { - - private static final Logger logger = TheMovieDb.getLogger(); - - private static final String NAME = "name"; - private static final String GENRE = "genre"; - private static final String ID = "id"; - private static final String URL = "url"; - private static final String LANGUAGE = "language"; - private static final String MOVIE = "movie"; - private static final String PERSON = "person"; - private static final String TYPE = "type"; - - /** - * Retrieve a list of valid genres within TMDb. - * @param doc a DOM document - * @return - */ - public static List parseCategories(String searchUrl) { - Document doc = null; - List categories = new ArrayList(); - - try { - doc = DOMHelper.getEventDocFromUrl(searchUrl); - } catch (Exception error) { - return categories; - } - - if (doc == null) { - return categories; - } - - NodeList genres = doc.getElementsByTagName(GENRE); - if ((genres == null) || genres.getLength() == 0) { - return categories; - } - - for (int i = 0; i < genres.getLength(); i++) { - Node node = genres.item(i); - if (node.getNodeType() == Node.ELEMENT_NODE) { - Element element = (Element) node; - Category category = new Category(); - category.setName(element.getAttribute(NAME)); - category.setId(DOMHelper.getValueFromElement(element, ID)); - category.setUrl(DOMHelper.getValueFromElement(element, URL)); - categories.add(category); - } - } - - return categories; - } - - /** - * Get the list of available languages - * @param url - * @return - */ - public static List parseLanguages(String url) { - List languages = new ArrayList(); - Document doc = null; - - try { - doc = DOMHelper.getEventDocFromUrl(url); - } catch (Exception e) { - logger.severe("Movie.getTranslations error: " + e.getMessage()); - return languages; - } - - if (doc == null) { - return languages; - } - - NodeList nlLanguages = doc.getElementsByTagName(LANGUAGE); - - if ((nlLanguages == null) || nlLanguages.getLength() == 0) { - return languages; - } - - for (int i = 0; i < nlLanguages.getLength(); i++) { - Node node = nlLanguages.item(i); - if (node.getNodeType() == Node.ELEMENT_NODE) { - Element element = (Element) node; - languages.add(parseSimpleLanguage(element)); - } - } - - return languages; - } - - /** - * Parse a DOM document and returns the latest Movie. - * This method is used for Movie.getLatest and Movie.getVersion where only - * a few fields are initialized. - * @param doc - * @return - */ - public static MovieDB parseLatestMovie(String searchUrl) { - MovieDB movie = null; - Document doc = null; - - try { - doc = DOMHelper.getEventDocFromUrl(searchUrl); - } catch (Exception error) { - logger.severe("GetLatest error: " + error.getMessage()); - return movie; - } - - if (doc == null) { - return movie; - } - - NodeList nlMovies = doc.getElementsByTagName(MOVIE); - - if ((nlMovies == null) || nlMovies.getLength() == 0) { - return movie; - } - - Node node = nlMovies.item(0); - if (node.getNodeType() == Node.ELEMENT_NODE) { - Element element = (Element) node; - movie = MovieDbParser.parseSimpleMovie(element); - } - - return movie; - } - - /** - * Parse a DOM document and return the person information - * @param url - * @return - */ - public static Person parseLatestPerson(String url) { - Person person = new Person(); - Document doc = null; - - try { - doc = DOMHelper.getEventDocFromUrl(url); - } catch (Exception error) { - logger.severe("Person.getLatest error: " + error.getMessage()); - return person; - } - - if (doc == null) { - return person; - } - - NodeList nlMovies = doc.getElementsByTagName(PERSON); - - if ((nlMovies == null) || nlMovies.getLength() == 0) { - return person; - } - - Node node = nlMovies.item(0); - if (node.getNodeType() == Node.ELEMENT_NODE) { - Element element = (Element) node; - person = MovieDbParser.parseSimplePerson(element); - } - - return person; - } - - /** - * Returns the first MovieDB from the DOM Document. - * @param doc a DOM Document - * @return - */ - public static MovieDB parseMovie(String searchUrl) { - MovieDB movie = null; - Document doc = null; - - try { - doc = DOMHelper.getEventDocFromUrl(searchUrl); - } catch (Exception error) { - logger.severe("TheMovieDb Error: " + error.getMessage()); - return movie; - } - - if (doc == null) { - return movie; - } - - NodeList nlMovies = doc.getElementsByTagName(MOVIE); - if ((nlMovies == null) || nlMovies.getLength() == 0) { - return movie; - } - - Node nMovie = nlMovies.item(0); - if (nMovie.getNodeType() == Node.ELEMENT_NODE) { - Element eMovie = (Element) nMovie; - movie = parseMovieInfo(eMovie); - } - - return movie; - } - - /** - * Parse the DOM document for movie information and return a list of movies - * @param url - * @return - */ - public static List parseMovieGetVersion(String url) { - List movies = new ArrayList(); - Document doc = null; - - try { - doc = DOMHelper.getEventDocFromUrl(url); - } catch (Exception e) { - logger.severe("Movie.getVersion error: " + e.getMessage()); - return movies; - } - - if (doc == null) { - return movies; - } - - NodeList nlMovies = doc.getElementsByTagName(MOVIE); - - if ((nlMovies == null) || nlMovies.getLength() == 0) { - return movies; - } - - for (int i = 0; i < nlMovies.getLength(); i++) { - Node node = nlMovies.item(i); - if (node.getNodeType() == Node.ELEMENT_NODE) { - Element element = (Element) node; - movies.add(MovieDbParser.parseSimpleMovie(element)); - } - } - - return movies; - } - - /** - * Returns a MovieDB object from the Element - * @param movieElement - * @return - */ - private static MovieDB parseMovieInfo(Element movieElement) { - // Inspired by - // http://www.java-tips.org/java-se-tips/javax.xml.parsers/how-to-read-xml-file-in-java.html - MovieDB movie = new MovieDB(); - NodeList subNodeList; - Node subNode; - Element subElement; - - try { - movie.setPopularity(DOMHelper.getValueFromElement(movieElement, "popularity")); - movie.setTranslated(DOMHelper.getValueFromElement(movieElement, "translated")); - movie.setAdult(DOMHelper.getValueFromElement(movieElement, "adult")); - movie.setLanguage(DOMHelper.getValueFromElement(movieElement, LANGUAGE)); - movie.setOriginalName(DOMHelper.getValueFromElement(movieElement, "original_name")); - movie.setTitle(DOMHelper.getValueFromElement(movieElement, NAME)); - movie.setAlternativeName(DOMHelper.getValueFromElement(movieElement, "alternative_name")); - movie.setType(DOMHelper.getValueFromElement(movieElement, TYPE)); - movie.setId(DOMHelper.getValueFromElement(movieElement, ID)); - movie.setImdb(DOMHelper.getValueFromElement(movieElement, "imdb_id")); - movie.setUrl(DOMHelper.getValueFromElement(movieElement, URL)); - movie.setOverview(DOMHelper.getValueFromElement(movieElement, "overview")); - movie.setRating(DOMHelper.getValueFromElement(movieElement, "rating")); - movie.setTagline(DOMHelper.getValueFromElement(movieElement, "tagline")); - movie.setCertification(DOMHelper.getValueFromElement(movieElement, "certification")); - movie.setReleaseDate(DOMHelper.getValueFromElement(movieElement, "released")); - movie.setRuntime(DOMHelper.getValueFromElement(movieElement, "runtime")); - movie.setBudget(DOMHelper.getValueFromElement(movieElement, "budget")); - movie.setRevenue(DOMHelper.getValueFromElement(movieElement, "revenue")); - movie.setHomepage(DOMHelper.getValueFromElement(movieElement, "homepage")); - movie.setTrailer(DOMHelper.getValueFromElement(movieElement, "trailer")); - - // Process the "categories" - subNodeList = movieElement.getElementsByTagName("categories"); - - for (int nodeLoop = 0; nodeLoop < subNodeList.getLength(); nodeLoop++) { - subNode = subNodeList.item(nodeLoop); - if (subNode.getNodeType() == Node.ELEMENT_NODE) { - subElement = (Element) subNode; - - NodeList castList = subNode.getChildNodes(); - for (int i = 0; i < castList.getLength(); i++) { - Node personNode = castList.item(i); - if (personNode.getNodeType() == Node.ELEMENT_NODE) { - subElement = (Element) personNode; - Category category = new Category(); - - category.setType(subElement.getAttribute(TYPE)); - category.setUrl(subElement.getAttribute(URL)); - category.setName(subElement.getAttribute(NAME)); - category.setId(subElement.getAttribute(ID)); - - movie.addCategory(category); - } - } - } - } - - // Process the "studios" - subNodeList = movieElement.getElementsByTagName("studios"); - - for (int nodeLoop = 0; nodeLoop < subNodeList.getLength(); nodeLoop++) { - subNode = subNodeList.item(nodeLoop); - if (subNode.getNodeType() == Node.ELEMENT_NODE) { - subElement = (Element) subNode; - - NodeList studioList = subNode.getChildNodes(); - for (int i = 0; i < studioList.getLength(); i++) { - Node studioNode = studioList.item(i); - if (studioNode.getNodeType() == Node.ELEMENT_NODE) { - subElement = (Element) studioNode; - Studio studio = new Studio(); - - studio.setUrl(subElement.getAttribute(URL)); - studio.setName(subElement.getAttribute(NAME)); - studio.setId(subElement.getAttribute(ID)); - - movie.addStudio(studio); - } - } - } - } - - // Process the "countries" - subNodeList = movieElement.getElementsByTagName("countries"); - - for (int nodeLoop = 0; nodeLoop < subNodeList.getLength(); nodeLoop++) { - subNode = subNodeList.item(nodeLoop); - if (subNode.getNodeType() == Node.ELEMENT_NODE) { - subElement = (Element) subNode; - - NodeList countryList = subNode.getChildNodes(); - for (int i = 0; i < countryList.getLength(); i++) { - Node countryNode = countryList.item(i); - if (countryNode.getNodeType() == Node.ELEMENT_NODE) { - subElement = (Element) countryNode; - Country country = new Country(); - - country.setName(subElement.getAttribute(NAME)); - country.setCode(subElement.getAttribute("code")); - country.setUrl(subElement.getAttribute(URL)); - - movie.addProductionCountry(country); - } - } - } - } - - // Process the "cast" - subNodeList = movieElement.getElementsByTagName("cast"); - - for (int nodeLoop = 0; nodeLoop < subNodeList.getLength(); nodeLoop++) { - subNode = subNodeList.item(nodeLoop); - if (subNode.getNodeType() == Node.ELEMENT_NODE) { - subElement = (Element) subNode; - - NodeList castList = subNode.getChildNodes(); - for (int i = 0; i < castList.getLength(); i++) { - Node personNode = castList.item(i); - if (personNode.getNodeType() == Node.ELEMENT_NODE) { - subElement = (Element) personNode; - Person person = new Person(); - - person.setName(subElement.getAttribute(NAME)); - person.setCharacter(subElement.getAttribute("character")); - person.setJob(subElement.getAttribute("job")); - person.setId(subElement.getAttribute(ID)); - person.addArtwork(Artwork.ARTWORK_TYPE_PERSON, - Artwork.ARTWORK_SIZE_THUMB, - subElement.getAttribute("thumb"), "-1"); - person.setDepartment(subElement.getAttribute("department")); - person.setUrl(subElement.getAttribute(URL)); - person.setOrder(subElement.getAttribute("order")); - person.setCastId(subElement.getAttribute("cast_id")); - - movie.addPerson(person); - } - } - } - } - - /* - * This processes the image elements. There are two formats to deal with: - * Movie.imdbLookup, Movie.getInfo & Movie.search: - * - * - * - * - * - * Movie.getImages: - * - * - * - * - * - * - * - * - * - * - * - * - * - */ - subNodeList = movieElement.getElementsByTagName("images"); - - for (int nodeLoop = 0; nodeLoop < subNodeList.getLength(); nodeLoop++) { - subNode = subNodeList.item(nodeLoop); - - if (subNode.getNodeType() == Node.ELEMENT_NODE) { - - NodeList artworkNodeList = subNode.getChildNodes(); - for (int artworkLoop = 0; artworkLoop < artworkNodeList.getLength(); artworkLoop++) { - Node artworkNode = artworkNodeList.item(artworkLoop); - if (artworkNode.getNodeType() == Node.ELEMENT_NODE) { - subElement = (Element) artworkNode; - - if (subElement.getNodeName().equalsIgnoreCase("image")) { - // This is the format used in Movie.imdbLookup, Movie.getInfo & Movie.search - Artwork artwork = new Artwork(); - artwork.setType(subElement.getAttribute(TYPE)); - artwork.setSize(subElement.getAttribute("size")); - artwork.setUrl(subElement.getAttribute(URL)); - artwork.setId(subElement.getAttribute(ID)); - movie.addArtwork(artwork); - } else if (subElement.getNodeName().equalsIgnoreCase("backdrop") - || subElement.getNodeName().equalsIgnoreCase("poster")) { - // This is the format used in Movie.getImages - String artworkId = subElement.getAttribute(ID); - String artworkType = subElement.getNodeName(); - - // We need to decode and loop round the child nodes to get the data - NodeList imageNodeList = subElement.getChildNodes(); - for (int imageLoop = 0; imageLoop < imageNodeList.getLength(); imageLoop++) { - Node imageNode = imageNodeList.item(imageLoop); - if (imageNode.getNodeType() == Node.ELEMENT_NODE) { - Element imageElement = (Element) imageNode; - Artwork artwork = new Artwork(); - artwork.setId(artworkId); - artwork.setType(artworkType); - artwork.setUrl(imageElement.getAttribute(URL)); - artwork.setSize(imageElement.getAttribute("size")); - movie.addArtwork(artwork); - } - } - } else { - // This is a classic, it should never happen error - logger.severe("UNKNOWN Image type: " + subElement.getNodeName()); - } - } - } - } - } - } catch (Exception error) { - logger.severe("ERROR: " + error.getMessage()); - final Writer eResult = new StringWriter(); - final PrintWriter printWriter = new PrintWriter(eResult); - error.printStackTrace(printWriter); - logger.severe(eResult.toString()); - } - return movie; - } - - /** - * Returns a list of MovieDB object parsed from the DOM Document - * even if there is only one movie - * @param doc DOM Document - * @return - */ - public static List parseMovies(String searchUrl) { - List movies = new ArrayList(); - - Document doc = null; - - try { - doc = DOMHelper.getEventDocFromUrl(searchUrl); - } catch (Exception error) { - logger.severe("TheMovieDb Error: " + error.getMessage()); - return movies; - } - - if (doc == null) { - return movies; - } - - NodeList nlMovies = doc.getElementsByTagName(MOVIE); - - if ((nlMovies == null) || nlMovies.getLength() == 0) { - return movies; - } - - MovieDB movie = null; - - for (int i = 0; i < nlMovies.getLength(); i++) { - Node movieNode = nlMovies.item(i); - if (movieNode.getNodeType() == Node.ELEMENT_NODE) { - Element movieElement = (Element) movieNode; - movie = parseMovieInfo(movieElement); - if (movie != null) { - movies.add(movie); - } - } - } - return movies; - } - - /** - * Parse a DOM document and returns a list of Person - * @param doc a DOM document - * @return - */ - public static List parsePersonGetVersion(String searchUrl) { - List people = new ArrayList(); - Document doc = null; - - try { - doc = DOMHelper.getEventDocFromUrl(searchUrl); - } catch (Exception error) { - logger.severe("PersonGetVersion error: " + error.getMessage()); - return people; - } - - if (doc == null) { - return people; - } - - NodeList movies = doc.getElementsByTagName(MOVIE); - if ((movies == null) || movies.getLength() == 0) { - return people; - } - - for (int i = 0; i < movies.getLength(); i++) { - Node node = movies.item(i); - if (node.getNodeType() == Node.ELEMENT_NODE) { - Element element = (Element) node; - people.add(MovieDbParser.parseSimplePerson(element)); - } - } - - return people; - } - - /** - * Parse the URL and return a list of the people found in the DOM document - */ - public static ArrayList parsePersonInfo(String searchUrl) { - ArrayList people = new ArrayList(); - Person person = null; - Document doc = null; - - try { - doc = DOMHelper.getEventDocFromUrl(searchUrl); - } catch (Exception error) { - logger.severe("PersonSearch error: " + error.getMessage()); - return people; - } - - if (doc == null) { - return people; - } - - NodeList personNodeList = doc.getElementsByTagName(PERSON); - - - if ((personNodeList == null) || personNodeList.getLength() == 0) { - return people; - } - - for (int loop = 0; loop < personNodeList.getLength(); loop++) { - Node personNode = personNodeList.item(loop); - person = new Person(); - - if (personNode == null) { - logger.finest("Person not found"); - return people; - } - - if (personNode.getNodeType() == Node.ELEMENT_NODE) { - try { - Element personElement = (Element) personNode; - - person.setName(DOMHelper.getValueFromElement(personElement, NAME)); - person.setId(DOMHelper.getValueFromElement(personElement, ID)); - person.setBiography(DOMHelper.getValueFromElement(personElement, "biography")); - - try { - person.setKnownMovies(Integer.parseInt(DOMHelper.getValueFromElement(personElement, "known_movies"))); - } catch (NumberFormatException error) { - person.setKnownMovies(0); - } - - person.setBirthday(DOMHelper.getValueFromElement(personElement, "birthday")); - person.setBirthPlace(DOMHelper.getValueFromElement(personElement, "birthplace")); - person.setUrl(DOMHelper.getValueFromElement(personElement, URL)); - person.setVersion(Integer.parseInt(DOMHelper.getValueFromElement(personElement, "version"))); - person.setLastModifiedAt(DOMHelper.getValueFromElement(personElement, "last_modified_at")); - - NodeList artworkNodeList = doc.getElementsByTagName("image"); - for (int nodeLoop = 0; nodeLoop < artworkNodeList.getLength(); nodeLoop++) { - Node artworkNode = artworkNodeList.item(nodeLoop); - if (artworkNode.getNodeType() == Node.ELEMENT_NODE) { - Element artworkElement = (Element) artworkNode; - Artwork artwork = new Artwork(); - artwork.setType(artworkElement.getAttribute(TYPE)); - artwork.setUrl(artworkElement.getAttribute(URL)); - artwork.setSize(artworkElement.getAttribute("size")); - artwork.setId(artworkElement.getAttribute(ID)); - person.addArtwork(artwork); - } - } - - NodeList filmNodeList = doc.getElementsByTagName(MOVIE); - for (int nodeLoop = 0; nodeLoop < filmNodeList.getLength(); nodeLoop++) { - Node filmNode = filmNodeList.item(nodeLoop); - if (filmNode.getNodeType() == Node.ELEMENT_NODE) { - Element filmElement = (Element) filmNode; - Filmography film = new Filmography(); - - film.setCharacter(filmElement.getAttribute("character")); - film.setDepartment(filmElement.getAttribute("department")); - film.setId(filmElement.getAttribute(ID)); - film.setJob(filmElement.getAttribute("job")); - film.setName(filmElement.getAttribute(NAME)); - film.setUrl(filmElement.getAttribute(URL)); - - person.addFilm(film); - } - } - - people.add(person); - } catch (Exception error) { - logger.severe("PersonInfo: " + error.getMessage()); - final Writer eResult = new StringWriter(); - final PrintWriter printWriter = new PrintWriter(eResult); - error.printStackTrace(printWriter); - logger.severe(eResult.toString()); - } - } - } - - return people; - } - - /** - * Parse a "simple" Language in the form: - * - * English - * English - * - * @param element - * @return - */ - private static Language parseSimpleLanguage(Element element) { - Language language = new Language(); - language.setIsoCode(element.getAttribute("iso_639_1")); - language.setEnglishName(DOMHelper.getValueFromElement(element, "english_name")); - language.setNativeName(DOMHelper.getValueFromElement(element, "native_name")); - return language; - } - - /** - * Parse a "simple" Movie in the form: - * - * Inception - * 36462 - * tt1375666 - * 11 - * 2010-07-26 17:06:18 - * - * @param element - * @return - */ - private static MovieDB parseSimpleMovie(Element element) { - MovieDB movie = new MovieDB(); - movie.setTitle(DOMHelper.getValueFromElement(element, NAME)); - movie.setId(DOMHelper.getValueFromElement(element, ID)); - movie.setImdb(DOMHelper.getValueFromElement(element, "imdb_id")); - movie.setVersion(Integer.valueOf(DOMHelper.getValueFromElement(element, "version"))); - movie.setLastModifiedAt(DOMHelper.getValueFromElement(element, "last_modified_at")); - return movie; - } - - /** - * Parse a "simple" Person in the form: - * - * John Joseph - * 111830 - * 3 - * 2010-07-19 10:59:13 - * - * @param element - * @return - */ - private static Person parseSimplePerson(Element element) { - Person person = new Person(); - person.setName(DOMHelper.getValueFromElement(element, NAME)); - person.setId(DOMHelper.getValueFromElement(element, ID)); - person.setVersion(Integer.valueOf(DOMHelper.getValueFromElement(element, "version"))); - person.setLastModifiedAt(DOMHelper.getValueFromElement(element, "last_modified_at")); - return person; - } - -} diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/WebBrowser.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/WebBrowser.java deleted file mode 100644 index f8459f622..000000000 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/WebBrowser.java +++ /dev/null @@ -1,332 +0,0 @@ -/* - * Copyright (c) 2004-2012 YAMJ Members - * http://code.google.com/p/moviejukebox/people/list - * - * Web: http://code.google.com/p/moviejukebox/ - * - * This software is licensed under a Creative Commons License - * See this page: http://code.google.com/p/moviejukebox/wiki/License - * - * For any reuse or distribution, you must make clear to others the - * license terms of this work. - */ -package com.moviejukebox.themoviedb.tools; - -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStreamReader; -import java.net.HttpURLConnection; -import java.net.URL; -import java.net.URLConnection; -import java.nio.charset.Charset; -import java.nio.charset.UnsupportedCharsetException; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import org.apache.commons.codec.binary.Base64; - -/** - * Web browser with simple cookies support - */ -public final class WebBrowser { - - private static Map browserProperties = new HashMap(); - private static Map> cookies = new HashMap>(); - private static String proxyHost = null; - private static String proxyPort = null; - private static String proxyUsername = null; - private static String proxyPassword = null; - private static String proxyEncodedPassword = null; - private static int webTimeoutConnect = 25000; // 25 second timeout - private static int webTimeoutRead = 90000; // 90 second timeout - - /** - * Constructor for WebBrowser. - * Does instantiates the browser properties. - */ - public WebBrowser() { - if (browserProperties.isEmpty()) { - browserProperties.put("User-Agent", "Mozilla/5.25 Netscape/5.0 (Windows; I; Win95)"); - } - } - - /** - * Request the web page at the specified URL - * @param url - * @return - * @throws IOException - */ - public static String request(String url) throws IOException { - return request(new URL(url)); - } - - /** - * Open a connection using proxy parameters if they exist. - * @param url - * @return - * @throws IOException - */ - public static URLConnection openProxiedConnection(URL url) throws IOException { - if (proxyHost != null) { - System.getProperties().put("proxySet", "true"); - System.getProperties().put("proxyHost", proxyHost); - System.getProperties().put("proxyPort", proxyPort); - } - - URLConnection cnx = url.openConnection(); - - if (proxyUsername != null) { - cnx.setRequestProperty("Proxy-Authorization", proxyEncodedPassword); - } - - return cnx; - } - - /** - * Request the web page at the specified URL - * @param url - * @return - * @throws IOException - */ - public static String request(URL url) throws IOException { - StringBuilder content = new StringBuilder(); - - BufferedReader in = null; - URLConnection cnx = null; - try { - cnx = openProxiedConnection(url); - - sendHeader(cnx); - readHeader(cnx); - - in = new BufferedReader(new InputStreamReader(cnx.getInputStream(), getCharset(cnx))); - String line; - while ((line = in.readLine()) != null) { - content.append(line); - } - } finally { - if (in != null) { - in.close(); - } - - if ((cnx != null) && (cnx instanceof HttpURLConnection)) { - ((HttpURLConnection) cnx).disconnect(); - } - - } - return content.toString(); - } - - /** - * Set the header information for the connection - * @param cnx - */ - private static void sendHeader(URLConnection cnx) { - // send browser properties - for (Map.Entry browserProperty : browserProperties.entrySet()) { - cnx.setRequestProperty(browserProperty.getKey(), browserProperty.getValue()); - } - // send cookies - String cookieHeader = createCookieHeader(cnx); - if (!cookieHeader.isEmpty()) { - cnx.setRequestProperty("Cookie", cookieHeader); - } - } - - /** - * Create the cookies for the header - * @param cnx - * @return - */ - private static String createCookieHeader(URLConnection cnx) { - String host = cnx.getURL().getHost(); - StringBuilder cookiesHeader = new StringBuilder(); - for (Map.Entry> domainCookies : cookies.entrySet()) { - if (host.endsWith(domainCookies.getKey())) { - for (Map.Entry cookie : domainCookies.getValue().entrySet()) { - cookiesHeader.append(cookie.getKey()); - cookiesHeader.append("="); - cookiesHeader.append(cookie.getValue()); - cookiesHeader.append(";"); - } - } - } - if (cookiesHeader.length() > 0) { - // remove last ; char - cookiesHeader.deleteCharAt(cookiesHeader.length() - 1); - } - return cookiesHeader.toString(); - } - - /** - * Read the header information into the cookies - * @param cnx - */ - private static void readHeader(URLConnection cnx) { - // read new cookies and update our cookies - for (Map.Entry> header : cnx.getHeaderFields().entrySet()) { - if ("Set-Cookie".equals(header.getKey())) { - for (String cookieHeader : header.getValue()) { - String[] cookieElements = cookieHeader.split(" *; *"); - if (cookieElements.length >= 1) { - String[] firstElem = cookieElements[0].split(" *= *"); - String cookieName = firstElem[0]; - String cookieValue = firstElem.length > 1 ? firstElem[1] : null; - String cookieDomain = null; - // find cookie domain - for (int i = 1; i < cookieElements.length; i++) { - String[] cookieElement = cookieElements[i].split(" *= *"); - if ("domain".equals(cookieElement[0])) { - cookieDomain = cookieElement.length > 1 ? cookieElement[1] : null; - break; - } - } - if (cookieDomain == null) { - // if domain isn't set take current host - cookieDomain = cnx.getURL().getHost(); - } - Map domainCookies = cookies.get(cookieDomain); - if (domainCookies == null) { - domainCookies = new HashMap(); - cookies.put(cookieDomain, domainCookies); - } - // add or replace cookie - domainCookies.put(cookieName, cookieValue); - } - } - } - } - } - - /** - * Determine the charset for the connection - * @param cnx - * @return - */ - private static Charset getCharset(URLConnection cnx) { - Charset charset = null; - // content type will be string like "text/html; charset=UTF-8" or "text/html" - String contentType = cnx.getContentType(); - if (contentType != null) { - // changed 'charset' to 'harset' in regexp because some sites send 'Charset' - Matcher m = Pattern.compile("harset *=[ '\"]*([^ ;'\"]+)[ ;'\"]*").matcher(contentType); - if (m.find()) { - String encoding = m.group(1); - try { - charset = Charset.forName(encoding); - } catch (UnsupportedCharsetException e) { - // there will be used default charset - } - } - } - if (charset == null) { - charset = Charset.defaultCharset(); - } - - return charset; - } - - /** - * Return the proxy host name - * @return - */ - public static String getProxyHost() { - return proxyHost; - } - - /** - * Set the proxy host name - * @param tvdbProxyHost - */ - public static void setProxyHost(String tvdbProxyHost) { - WebBrowser.proxyHost = tvdbProxyHost; - } - - /** - * Get the proxy port - * @return - */ - public static String getProxyPort() { - return proxyPort; - } - - /** - * Set the proxy port - * @param proxyPort - */ - public static void setProxyPort(String proxyPort) { - WebBrowser.proxyPort = proxyPort; - } - - /** - * Get the proxy username - * @return - */ - public static String getProxyUsername() { - return proxyUsername; - } - - /** - * Set the proxy username - * @param proxyUsername - */ - public static void setProxyUsername(String proxyUsername) { - WebBrowser.proxyUsername = proxyUsername; - } - - /** - * Get the proxy password - * @return - */ - public static String getProxyPassword() { - return proxyPassword; - } - - /** - * Set the proxy password. - * Note this will automatically encode the password - * @param proxyPassword - */ - public static void setProxyPassword(String proxyPassword) { - WebBrowser.proxyPassword = proxyPassword; - - if (proxyUsername != null) { - proxyEncodedPassword = proxyUsername + ":" + proxyPassword; - proxyEncodedPassword = "Basic " + new String(Base64.encodeBase64((proxyUsername + ":" + proxyPassword).getBytes())); - } - } - - /** - * Get the current web connect timeout value - * @return - */ - public static int getWebTimeoutConnect() { - return webTimeoutConnect; - } - - /** - * Get the current web read timeout value - * @return - */ - public static int getWebTimeoutRead() { - return webTimeoutRead; - } - - /** - * Set the web connect timeout value - * @param webTimeoutConnect - */ - public static void setWebTimeoutConnect(int webTimeoutConnect) { - WebBrowser.webTimeoutConnect = webTimeoutConnect; - } - - /** - * Set the web read timeout value - * @param webTimeoutRead - */ - public static void setWebTimeoutRead(int webTimeoutRead) { - WebBrowser.webTimeoutRead = webTimeoutRead; - } -} diff --git a/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java b/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java deleted file mode 100644 index 65765d4d7..000000000 --- a/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java +++ /dev/null @@ -1,487 +0,0 @@ -/* - * Copyright (c) 2004-2012 YAMJ Members - * http://code.google.com/p/moviejukebox/people/list - * - * Web: http://code.google.com/p/moviejukebox/ - * - * This software is licensed under a Creative Commons License - * See this page: http://code.google.com/p/moviejukebox/wiki/License - * - * For any reuse or distribution, you must make clear to others the - * license terms of this work. - */ -package com.moviejukebox.themoviedb; - -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; - -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import org.junit.Before; -import org.junit.Test; - -import com.moviejukebox.themoviedb.model.Category; -import com.moviejukebox.themoviedb.model.MovieDB; -import com.moviejukebox.themoviedb.model.Person; - -/** - * JUnit tests for TheMovieDb class. The tester must enter its IMDb API key for - * these tests to work. Require JUnit 4.5. - * @author mledoze - */ -public class TheMovieDbTest { - - private static String apikey = ""; - private TheMovieDb tmdb; - - public TheMovieDbTest() { - } - - @Before - public void setUp() { - tmdb = new TheMovieDb(apikey); - } - - @Test - public void testGetApiKey() { - assertEquals(apikey, tmdb.getApiKey()); - } - - @Test - public void testGetDefaultLanguage() { - assertEquals("en-US", tmdb.getDefaultLanguage()); - } - - @Test - public void testMoviedbSearch() { - String title = "Inception"; - List movies = tmdb.moviedbSearch(title, "en"); - assertFalse(movies.isEmpty()); - assertEquals(title, movies.get(0).getTitle()); - } - - @Test - public void testMoviedbSearch_withWrongTitle() { - List movies = tmdb.moviedbSearch("à(é!àç'(è!çé(èçéè'(éàç!'(èéàç!(èç'", "en"); - assertTrue(movies.isEmpty()); - } - - @Test - public void testMoviedbSearch_withEmptyTitle() { - List movies = tmdb.moviedbSearch("", "en"); - assertTrue(movies.isEmpty()); - } - - @Test - public void testMoviedbSearch_withNullTitle() { - List movies = tmdb.moviedbSearch((String) null, "en"); - assertTrue(movies.isEmpty()); - } - - //*** Start moviedbBrowse - @Test - public void testMoviedbBrowseRatingAsc() { - Map params = new HashMap(); - params.put("year", "2011"); - - List movies = tmdb.moviedbBrowse("rating", "asc", params, "en"); - - assertFalse(movies.isEmpty()); - } - - @Test - public void testMoviedbBrowseReleaseAsc() { - Map params = new HashMap(); - params.put("year", "2011"); - - List movies = tmdb.moviedbBrowse("release", "asc", params, "en"); - assertFalse(movies.isEmpty()); - } - - @Test - public void testMoviedbBrowseTitleAsc() { - Map params = new HashMap(); - params.put("year", "2011"); - - List movies = tmdb.moviedbBrowse("title", "asc", params, "en"); - assertFalse(movies.isEmpty()); - } - - @Test - public void testMoviedbBrowseRatingDesc() { - Map params = new HashMap(); - params.put("year", "2011"); - - List movies = tmdb.moviedbBrowse("rating", "desc", params, "en"); - assertFalse(movies.isEmpty()); - } - - @Test - public void testMoviedbBrowseReleaseDesc() { - Map params = new HashMap(); - params.put("year", "2011"); - - List movies = tmdb.moviedbBrowse("release", "desc", params, "en"); - assertFalse(movies.isEmpty()); - } - - @Test - public void testMoviedbBrowseTitleDesc() { - Map params = new HashMap(); - params.put("year", "2011"); - - List movies = tmdb.moviedbBrowse("title", "desc", params, "en"); - assertFalse(movies.isEmpty()); - } - - @Test - public void testMoviedbBrowse_withEmptyOrderBy() { - assertTrue(tmdb.moviedbBrowse("", "asc", "en").isEmpty()); - } - - @Test - public void testMoviedbBrowse_withNullOrderBy() { - assertTrue(tmdb.moviedbBrowse((String) null, "asc", "en").isEmpty()); - } - - @Test - public void testMoviedbBrowse_withEmptyOrder() { - assertTrue(tmdb.moviedbBrowse("rating", "", "en").isEmpty()); - } - - @Test - public void testMoviedbBrowse_withNullOrder() { - assertTrue(tmdb.moviedbBrowse("rating", (String) null, "en").isEmpty()); - } - - @Test - public void testMoviedbBrowse_incorrectParameters() { - assertTrue(tmdb.moviedbBrowse("bla", "bla", "en").isEmpty()); - } - - @Test - public void testMoviedbBrowse_withNullParameters() { - assertTrue(tmdb.moviedbBrowse("rating", "asc", (Map) null, "en").isEmpty()); - } - - @Test - public void testMoviedbBrowse_withInvalidParameters() { - Map params = new HashMap(); - params.put("bla", "bla"); - params.put("yo", "yo"); - List movies = tmdb.moviedbBrowse("title", "desc", params, "en"); - - // even if parameters are incorrect we should get the result of - // the search with the default parameters (orderBy and order) so the - // list of movies is not empty - assertFalse(movies.isEmpty()); - } - //*** End moviedbBrowse - - @Test - public void testMoviedbImdbLookup() { - MovieDB movie = tmdb.moviedbImdbLookup("tt0137523", "en"); - assertEquals("Fight Club", movie.getTitle()); - assertEquals("550", movie.getId()); - assertEquals("tt0137523", movie.getImdb()); - assertEquals("138", movie.getRuntime()); - } - - @Test - public void testMoviedbImdbLookup_withEmptyId() { - MovieDB movie = tmdb.moviedbImdbLookup("", "en"); - assertTrue(movie.getTitle().equals(MovieDB.UNKNOWN)); - assertTrue(movie.getId().equals(MovieDB.UNKNOWN)); - assertTrue(movie.getImdb().equals(MovieDB.UNKNOWN)); - } - - @Test - public void testMoviedbImdbLookup_withNullId() { - MovieDB movie = tmdb.moviedbImdbLookup((String) null, "en"); - assertTrue(movie.getTitle().equals(MovieDB.UNKNOWN)); - assertTrue(movie.getId().equals(MovieDB.UNKNOWN)); - assertTrue(movie.getImdb().equals(MovieDB.UNKNOWN)); - } - - @Test - public void testMoviedbGetInfo() { - MovieDB movie = tmdb.moviedbGetInfo("187", "en"); - assertEquals("Sin City", movie.getTitle()); - assertEquals("187", movie.getId()); - assertEquals("tt0401792", movie.getImdb()); - assertEquals("124", movie.getRuntime()); - - } - - @Test - public void testMoviedbGetInfo_withExistingMovie() { - MovieDB movie = tmdb.moviedbGetInfo("200", new MovieDB(), "en"); - assertEquals("Star Trek: Insurrection", movie.getTitle()); - assertEquals("200", movie.getId()); - assertEquals("tt0120844", movie.getImdb()); - assertEquals("103", movie.getRuntime()); - } - - @Test - public void testMoviedbGetInfo_withNullMovie() { - MovieDB movie = tmdb.moviedbGetInfo("306", null, "en"); - assertEquals("Beverly Hills Cop III", movie.getTitle()); - assertEquals("306", movie.getId()); - assertEquals("tt0109254", movie.getImdb()); - assertEquals("104", movie.getRuntime()); - } - - @Test - public void testMoviedbGetInfo_withNullMovieAndEmptyId() { - MovieDB movie = tmdb.moviedbGetInfo("", null, "en"); - assertNull(movie); - } - - @Test - public void testMoviedbGetInfo_withNullMovieAndNullId() { - MovieDB movie = tmdb.moviedbGetInfo((String) null, null, "en"); - assertNull(movie); - } - - @Test - public void testMoviedbGetInfo_withInitializedMovie() { - MovieDB input = new MovieDB(); - String title = "The 300 Spartans"; - String id = "19972"; - input.setTitle(title); - MovieDB movie = tmdb.moviedbGetInfo(id, input, "en"); - assertEquals(title, movie.getTitle()); - assertEquals(id, movie.getId()); - } - - @Test - public void testMoviedbGetLatest() { - MovieDB movie = tmdb.moviedbGetLatest("en"); - assertFalse(movie.getTitle().equals(MovieDB.UNKNOWN)); - assertFalse(movie.getId().equals(MovieDB.UNKNOWN)); - assertFalse(movie.getImdb().equals(MovieDB.UNKNOWN)); - } - - @Test - public void testMoviedbGetVersion_String_String() { - MovieDB movie = tmdb.moviedbGetVersion("155", "en"); - assertEquals("The Dark Knight", movie.getTitle()); - assertEquals("155", movie.getId()); - assertEquals("tt0468569", movie.getImdb()); - } - - @Test - public void testMoviedbGetVersion_withWrongId() { - MovieDB movie = tmdb.moviedbGetVersion("0", "en"); - assertEquals(MovieDB.UNKNOWN, movie.getTitle()); - assertEquals(MovieDB.UNKNOWN, movie.getId()); - } - - @Test - public void testMoviedbGetVersion_withNullId() { - MovieDB movie = tmdb.moviedbGetVersion((String) null, "en"); - assertEquals(MovieDB.UNKNOWN, movie.getTitle()); - assertEquals(MovieDB.UNKNOWN, movie.getId()); - } - - @Test - public void testMoviedbGetVersion_withEmptyId() { - MovieDB movie = tmdb.moviedbGetVersion("", "en"); - assertEquals(MovieDB.UNKNOWN, movie.getTitle()); - assertEquals(MovieDB.UNKNOWN, movie.getId()); - } - - @Test - public void testMoviedbGetVersion_List_String() { - List ids = new ArrayList(); - ids.add("585"); - ids.add("11"); - List movies = tmdb.moviedbGetVersion(ids, "en"); - - assertEquals("Monsters, Inc.", movies.get(0).getTitle()); - assertEquals("585", movies.get(0).getId()); - assertEquals("tt0198781", movies.get(0).getImdb()); - - assertEquals("Star Wars: Episode IV - A New Hope", movies.get(1).getTitle()); - assertEquals("11", movies.get(1).getId()); - assertEquals("tt0076759", movies.get(1).getImdb()); - - } - - @Test - public void testMoviedbGetVersion_withEmptyList() { - List movies = tmdb.moviedbGetVersion(new ArrayList(), "en"); - assertTrue(movies.isEmpty()); - } - - @Test - public void testMoviedbGetVersion_withNullList() { - List movies = tmdb.moviedbGetVersion((List) null, "en"); - assertTrue(movies.isEmpty()); - } - - @Test - public void testMoviedbGetImages_String_String() { - } - - @Test - public void testMoviedbGetImages_3args() { - } - - @Test - public void testPersonSearch() { - ArrayList people = tmdb.personSearch("Tom Cruise", "en"); - - Person person = new Person(); - - for (Person foundPerson : people) { - if (foundPerson.getId().equals("500")) { - person = foundPerson; - break; - } - } - - assertEquals("Tom Cruise", person.getName()); - assertEquals("500", person.getId()); - } - - @Test - public void testPersonSearch_withEmptyName() { - ArrayList people = tmdb.personSearch("", "en"); - assertTrue(people.isEmpty()); - } - - @Test - public void testPersonSearch_withNullName() { - ArrayList people = tmdb.personSearch((String) null, "en"); - assertTrue(people.isEmpty()); - } - - @Test - public void testPersonGetInfo() { - ArrayList people = tmdb.personGetInfo("260", "en"); - - Person person = new Person(); - - for (Person foundPerson : people) { - if (foundPerson.getId().equals("260")) { - person = foundPerson; - break; - } - } - - assertEquals("Marco Pérez", person.getName()); - assertEquals("260", person.getId()); - } - - @Test - public void testPersonGetInfo_withEmptyId() { - ArrayList people = tmdb.personGetInfo("", "en"); - assertTrue(people.isEmpty()); - } - - @Test - public void testPersonGetInfo_withNullId() { - ArrayList people = tmdb.personGetInfo((String) null, "en"); - assertTrue(people.isEmpty()); - } - - @Test - public void testPersonGetLatest() { - Person person = tmdb.personGetLatest("en"); - assertFalse(person.getName().equals(MovieDB.UNKNOWN)); - } - - @Test - public void testPersonGetVersion() { - Person person = tmdb.personGetVersion("288", "en"); - assertEquals("Jon Seda", person.getName()); - assertEquals("288", person.getId()); - } - - @Test - public void testPersonGetVersion_withWrongId() { - Person person = tmdb.personGetVersion("0", "en"); - assertEquals(MovieDB.UNKNOWN, person.getName()); - assertEquals(MovieDB.UNKNOWN, person.getId()); - } - - @Test - public void testPersonGetVersion_withNullId() { - Person person = tmdb.personGetVersion((String) null, "en"); - assertEquals(MovieDB.UNKNOWN, person.getName()); - assertEquals(MovieDB.UNKNOWN, person.getId()); - } - - @Test - public void testPersonGetVersion_withEmptyId() { - Person person = tmdb.personGetVersion("", "en"); - assertEquals(MovieDB.UNKNOWN, person.getName()); - assertEquals(MovieDB.UNKNOWN, person.getId()); - } - - @Test - public void testPersonGetVersion_List_String() { - List ids = new ArrayList(); - ids.add("287"); - ids.add("5064"); - List people = tmdb.personGetVersion(ids, "en"); - - assertEquals("Brad Pitt", people.get(0).getName()); - assertEquals("287", people.get(0).getId()); - - assertEquals("Meryl Streep", people.get(1).getName()); - assertEquals("5064", people.get(1).getId()); - } - - @Test - public void testPersonGetVersion_withEmptyList() { - List people = tmdb.personGetVersion(new ArrayList(), "en"); - assertTrue(people.isEmpty()); - } - - @Test - public void testPersonGetVersion_withNullList() { - List people = tmdb.personGetVersion((List) null, "en"); - assertTrue(people.isEmpty()); - } - - @Test - public void testGetCategories() { - List genres = tmdb.getCategories("en"); - assertFalse(genres.isEmpty()); - assertTrue(genres.size() > 0); - } - - @Test - public void testFindMovie() { - } - - @Test - public void testCompareMovies() { - MovieDB movie = tmdb.moviedbGetInfo("27205", "en"); - assertTrue(TheMovieDb.compareMovies(movie, "Inception", "2010")); - } - - @Test - public void testCompareMovies_sameTitleAndDifferentYear() { - MovieDB movie = tmdb.moviedbGetInfo("27205", "en"); - assertFalse(TheMovieDb.compareMovies(movie, "Inception", "1999")); - } - - @Test - public void testCompareMovies_differentTitleAndSameYear() { - MovieDB movie = tmdb.moviedbGetInfo("27205", "en"); - assertFalse(TheMovieDb.compareMovies(movie, "xxx", "2010")); - } - - @Test - public void testCompareMovies_wrongArgument() { - assertFalse(TheMovieDb.compareMovies(null, "", "2010")); - } -} From d8c81f935091f9fca90b046dc8e16231152e0775 Mon Sep 17 00:00:00 2001 From: Omertron Date: Wed, 25 Jan 2012 15:39:04 +0000 Subject: [PATCH 096/207] Start of code for v3 of the API --- themoviedbapi/pom.xml | 21 +- .../moviejukebox/themoviedb/TheMovieDB.java | 335 ++++++++++++++ .../themoviedb/model/AlternativeTitle.java | 104 +++++ .../themoviedb/model/Artwork.java | 183 ++++++++ .../themoviedb/model/ArtworkType.java | 21 + .../themoviedb/model/Collection.java | 173 ++++++++ .../themoviedb/model/CollectionInfo.java | 113 +++++ .../moviejukebox/themoviedb/model/Genre.java | 106 +++++ .../themoviedb/model/Keyword.java | 106 +++++ .../themoviedb/model/Language.java | 106 +++++ .../themoviedb/model/MovieDB.java | 407 ++++++++++++++++++ .../moviejukebox/themoviedb/model/Person.java | 230 ++++++++++ .../themoviedb/model/PersonCast.java | 149 +++++++ .../themoviedb/model/PersonCrew.java | 149 +++++++ .../themoviedb/model/ProductionCompany.java | 106 +++++ .../themoviedb/model/ProductionCountry.java | 106 +++++ .../themoviedb/model/ReleaseInfo.java | 119 +++++ .../themoviedb/model/StatusCode.java | 77 ++++ .../themoviedb/model/TmdbConfiguration.java | 150 +++++++ .../themoviedb/model/Trailer.java | 134 ++++++ .../themoviedb/model/Translation.java | 119 +++++ .../moviejukebox/themoviedb/tools/ApiUrl.java | 180 ++++++++ .../themoviedb/tools/FilteringLayout.java | 59 +++ .../wrapper/WrapperAlternativeTitles.java | 67 +++ .../themoviedb/wrapper/WrapperMovieCasts.java | 82 ++++ .../wrapper/WrapperMovieImages.java | 81 ++++ .../wrapper/WrapperMovieKeywords.java | 71 +++ .../wrapper/WrapperReleaseInfo.java | 71 +++ .../themoviedb/wrapper/WrapperResultList.java | 101 +++++ .../themoviedb/wrapper/WrapperTrailers.java | 81 ++++ .../wrapper/WrapperTranslations.java | 68 +++ .../src/main/resources/log4j.properties | 7 + .../themoviedb/TheMovieDBTest.java | 220 ++++++++++ 33 files changed, 4099 insertions(+), 3 deletions(-) create mode 100644 themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDB.java create mode 100644 themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/AlternativeTitle.java create mode 100644 themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Artwork.java create mode 100644 themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/ArtworkType.java create mode 100644 themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Collection.java create mode 100644 themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/CollectionInfo.java create mode 100644 themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Genre.java create mode 100644 themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Keyword.java create mode 100644 themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Language.java create mode 100644 themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/MovieDB.java create mode 100644 themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Person.java create mode 100644 themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/PersonCast.java create mode 100644 themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/PersonCrew.java create mode 100644 themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/ProductionCompany.java create mode 100644 themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/ProductionCountry.java create mode 100644 themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/ReleaseInfo.java create mode 100644 themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/StatusCode.java create mode 100644 themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/TmdbConfiguration.java create mode 100644 themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Trailer.java create mode 100644 themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Translation.java create mode 100644 themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/ApiUrl.java create mode 100644 themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/FilteringLayout.java create mode 100644 themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperAlternativeTitles.java create mode 100644 themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperMovieCasts.java create mode 100644 themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperMovieImages.java create mode 100644 themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperMovieKeywords.java create mode 100644 themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperReleaseInfo.java create mode 100644 themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperResultList.java create mode 100644 themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperTrailers.java create mode 100644 themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperTranslations.java create mode 100644 themoviedbapi/src/main/resources/log4j.properties create mode 100644 themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDBTest.java diff --git a/themoviedbapi/pom.xml b/themoviedbapi/pom.xml index b50c54a0d..22362ab20 100644 --- a/themoviedbapi/pom.xml +++ b/themoviedbapi/pom.xml @@ -40,9 +40,24 @@ junit - commons-codec - commons-codec - 1.6 + commons-lang + commons-lang + 2.6 + + + log4j + log4j + 1.2.16 + + + org.codehaus.jackson + jackson-core-lgpl + 1.9.4 + + + org.codehaus.jackson + jackson-mapper-lgpl + 1.9.4 diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDB.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDB.java new file mode 100644 index 000000000..1fb78a653 --- /dev/null +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDB.java @@ -0,0 +1,335 @@ +/* + * Copyright (c) 2004-2012 YAMJ Members + * http://code.google.com/p/moviejukebox/people/list + * + * Web: http://code.google.com/p/moviejukebox/ + * + * This software is licensed under a Creative Commons License + * See this page: http://code.google.com/p/moviejukebox/wiki/License + * + * For any reuse or distribution, you must make clear to others the + * license terms of this work. + */ +package com.moviejukebox.themoviedb; + +import com.moviejukebox.themoviedb.model.*; +import com.moviejukebox.themoviedb.tools.ApiUrl; +import com.moviejukebox.themoviedb.tools.FilteringLayout; +import com.moviejukebox.themoviedb.wrapper.*; +import java.io.IOException; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.ArrayList; +import java.util.List; +import org.apache.log4j.Logger; +import org.codehaus.jackson.map.DeserializationConfig; +import org.codehaus.jackson.map.ObjectMapper; + +/** + * The MovieDB API. + * This is for version 3 of the API as specified here: + * http://help.themoviedb.org/kb/api/about-3 + * @author stuart.boston + */ +public class TheMovieDB { + + private static final Logger logger = Logger.getLogger(TheMovieDB.class); + private static String API_KEY; + private static TmdbConfiguration tmdbConfig; + /* + * TheMovieDB API URLs + */ + protected static final String TMDB_API_BASE = "http://api.themoviedb.org/3/"; + /* + * API Methods + */ + protected static final ApiUrl TMDB_CONFIG_URL = new ApiUrl("configuration"); + protected static final ApiUrl TMDB_SEARCH_MOVIE = new ApiUrl("search/movie"); + protected static final ApiUrl TMDB_SEARCH_PEOPLE = new ApiUrl("search/person"); + protected static final ApiUrl TMDB_COLLECTION_INFO = new ApiUrl("collection/"); + protected static final ApiUrl TMDB_MOVIE_INFO = new ApiUrl("movie/"); + protected static final ApiUrl TMDB_MOVIE_ALT_TITLES = new ApiUrl("movie/", "/alternative_titles"); + protected static final ApiUrl TMDB_MOVIE_CASTS = new ApiUrl("movie/", "/casts"); + protected static final ApiUrl TMDB_MOVIE_IMAGES = new ApiUrl("movie/", "/images"); + protected static final ApiUrl TMDB_MOVIE_KEYWORDS = new ApiUrl("movie/", "/keywords"); + protected static final ApiUrl TMDB_MOVIE_RELEASE_INFO = new ApiUrl("movie/", "/releases"); + protected static final ApiUrl TMDB_MOVIE_TRAILERS = new ApiUrl("movie/", "/trailers"); + protected static final ApiUrl TMDB_MOVIE_TRANSLATIONS = new ApiUrl("movie/", "/translations"); + protected static final ApiUrl TMDB_PERSON_INFO = new ApiUrl("person"); + protected static final ApiUrl TMDB_PERSON_CREDITS = new ApiUrl("person/", "/credits"); + protected static final ApiUrl TMDB_PERSON_IMAGES = new ApiUrl("person/", "/images"); + protected static final ApiUrl TMDB_LATEST_MOVIE = new ApiUrl("latest/movie"); + + /* + * Jackson JSON configuration + */ + private static ObjectMapper mapper = new ObjectMapper(); + + public TheMovieDB(String apiKey) throws IOException { + TheMovieDB.API_KEY = apiKey; + URL configUrl = TMDB_CONFIG_URL.getQueryUrl(""); + mapper.configure(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE, true); + tmdbConfig = mapper.readValue(configUrl, TmdbConfiguration.class); + mapper.configure(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE, false); + FilteringLayout.addApiKey(apiKey); + } + + public static String getApiKey() { + return API_KEY; + } + + public static String getApiBase() { + return TMDB_API_BASE; + } + + /** + * Search Movies + * This is a good starting point to start finding movies on TMDb. + * The idea is to be a quick and light method so you can iterate through movies quickly. + * http://help.themoviedb.org/kb/api/search-movies + */ + public List searchMovie(String movieName, String language, boolean allResults) { + try { + URL url = TMDB_SEARCH_MOVIE.getQueryUrl(movieName, language, 1); + WrapperResultList resultList = mapper.readValue(url, WrapperResultList.class); + return resultList.getResults(); + } catch (IOException ex) { + logger.warn("Failed to find movie: " + ex.getMessage()); + return new ArrayList(); + } + } + + /** + * This method is used to retrieve all of the basic movie information. + * It will return the single highest rated poster and backdrop. + * @param movieId + * @param language + * @return + */ + public MovieDB getMovieInfo(int movieId, String language) { + try { + URL url = TMDB_MOVIE_INFO.getIdUrl(movieId, language); + MovieDB movieDb = mapper.readValue(url, MovieDB.class); + return movieDb; + } catch (IOException ex) { + logger.warn("Failed to get movie info: " + ex.getMessage()); + } + return new MovieDB(); + } + + /** + * This method is used to retrieve all of the alternative titles we have for a particular movie. + * @param movieId + * @param country + * @return + */ + public List getMovieAlternativeTitles(int movieId, String country) { + try { + URL url = TMDB_MOVIE_ALT_TITLES.getIdUrl(movieId, country); + WrapperAlternativeTitles at = mapper.readValue(url, WrapperAlternativeTitles.class); + return at.getTitles(); + } catch (IOException ex) { + logger.warn("Failed to get movie alternative titles: " + ex.getMessage()); + } + return new ArrayList(); + } + + /** + * This method is used to retrieve all of the movie cast information. + * @param movieId + * @return + */ + public List getMovieCasts(int movieId) { + List people = new ArrayList(); + + try { + URL url = TMDB_MOVIE_CASTS.getIdUrl(movieId); + WrapperMovieCasts mc = mapper.readValue(url, WrapperMovieCasts.class); + + // Add a cast member + for (PersonCast cast : mc.getCast()) { + Person person = new Person(); + person.addCast(cast.getId(), cast.getName(), cast.getProfilePath(), cast.getCharacter(), cast.getOrder()); + people.add(person); + } + + // Add a crew member + for (PersonCrew crew : mc.getCrew()) { + Person person = new Person(); + person.addCrew(crew.getId(), crew.getName(), crew.getProfilePath(), crew.getDepartment(), crew.getJob()); + people.add(person); + } + + return people; + } catch (IOException ex) { + logger.warn("Failed to get movie casts: " + ex.getMessage()); + } + return people; + } + + /** + * This method should be used when you’re wanting to retrieve all of the images for a particular movie. + * @param movieId + * @param language + * @return + */ + public List getMovieImages(int movieId, String language) { + List artwork = new ArrayList(); + try { + URL url = TMDB_MOVIE_IMAGES.getIdUrl(movieId, language); + WrapperMovieImages mi = mapper.readValue(url, WrapperMovieImages.class); + + // Add all the posters to the list + for (Artwork poster : mi.getPosters()) { + poster.setArtworkType(ArtworkType.POSTER); + artwork.add(poster); + } + + // Add all the backdrops to the list + for (Artwork backdrop : mi.getBackdrops()) { + backdrop.setArtworkType(ArtworkType.BACKDROP); + artwork.add(backdrop); + } + + return artwork; + } catch (IOException ex) { + logger.warn("Failed to get movie images: " + ex.getMessage()); + } + return artwork; + } + + /** + * This method is used to retrieve all of the keywords that have been added to a particular movie. + * Currently, only English keywords exist. + * @param movieId + * @return + */ + public List getMovieKeywords(int movieId) { + try { + URL url = TMDB_MOVIE_KEYWORDS.getIdUrl(movieId); + WrapperMovieKeywords mk = mapper.readValue(url, WrapperMovieKeywords.class); + return mk.getKeywords(); + } catch (IOException ex) { + logger.warn("Failed to get movie keywords: " + ex.getMessage()); + } + return new ArrayList(); + } + + /** + * This method is used to retrieve all of the release and certification data we have for a specific movie. + * @param movieId + * @param language + * @return + */ + public List getMovieReleaseInfo(int movieId, String language) { + try { + URL url = TMDB_MOVIE_RELEASE_INFO.getIdUrl(movieId); + WrapperReleaseInfo ri = mapper.readValue(url, WrapperReleaseInfo.class); + return ri.getCountries(); + } catch (IOException ex) { + logger.warn("Failed to get movie release information: " + ex.getMessage()); + } + return new ArrayList(); + } + + /** + * This method is used to retrieve all of the trailers for a particular movie. + * Supported sites are YouTube and QuickTime. + * @param movieId + * @param language + * @return + */ + public List getMovieTrailers(int movieId, String language) { + List trailers = new ArrayList(); + try { + URL url = TMDB_MOVIE_TRAILERS.getIdUrl(movieId); + WrapperTrailers wt = mapper.readValue(url, WrapperTrailers.class); + + // Add the trailer to the return list along with it's source + for (Trailer trailer : wt.getQuicktime()) { + trailer.setWebsite(Trailer.WEBSITE_QUICKTIME); + trailers.add(trailer); + } + + // Add the trailer to the return list along with it's source + for (Trailer trailer : wt.getYoutube()) { + trailer.setWebsite(Trailer.WEBSITE_YOUTUBE); + trailers.add(trailer); + } + return trailers; + } catch (IOException ex) { + logger.warn("Failed to get movie trailers: " + ex.getMessage()); + } + return trailers; + } + + /** + * This method is used to retrieve a list of the available translations for a specific movie. + * @param movieId + * @return + */ + public List getMovieTranslations(int movieId) { + try { + URL url = TMDB_MOVIE_TRANSLATIONS.getIdUrl(movieId); + WrapperTranslations wt = mapper.readValue(url, WrapperTranslations.class); + return wt.getTranslations(); + } catch (IOException ex) { + logger.warn("Failed to get movie tranlations: " + ex.getMessage()); + } + return new ArrayList(); + } + + /** + * This method is used to retrieve all of the basic information about a movie collection. + * You can get the ID needed for this method by making a getMovieInfo request for the belongs_to_collection. + * @param movieId + * @param language + * @return + */ + public CollectionInfo getCollectionInfo(int movieId, String language) { + try { + URL url = TMDB_COLLECTION_INFO.getIdUrl(movieId); + CollectionInfo col = mapper.readValue(url, CollectionInfo.class); + return col; + } catch (IOException ex) { + return new CollectionInfo(); + } + } + + /** + * Get the configuration information + * @return + */ + public TmdbConfiguration getConfiguration() { + return tmdbConfig; + } + + /** + * Generate the full image URL from the size and image path + * @param imagePath + * @param requiredSize + * @return + */ + public URL createImageUrl(String imagePath, String requiredSize) { + URL returnUrl = null; + StringBuilder sb; + + if (!tmdbConfig.isValidSize(requiredSize)) { + sb = new StringBuilder(); + sb.append(" - Invalid size requested: ").append(requiredSize); + logger.warn(sb.toString()); + return returnUrl; + } + + try { + sb = new StringBuilder(tmdbConfig.getBaseUrl()); + sb.append(requiredSize); + sb.append(imagePath); + returnUrl = new URL(sb.toString()); + } catch (MalformedURLException ex) { + logger.warn("Failed to create image URL: " + ex.getMessage()); + } + + return returnUrl; + } +} diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/AlternativeTitle.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/AlternativeTitle.java new file mode 100644 index 000000000..785d863e7 --- /dev/null +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/AlternativeTitle.java @@ -0,0 +1,104 @@ +/* + * Copyright (c) 2004-2012 YAMJ Members + * http://code.google.com/p/moviejukebox/people/list + * + * Web: http://code.google.com/p/moviejukebox/ + * + * This software is licensed under a Creative Commons License + * See this page: http://code.google.com/p/moviejukebox/wiki/License + * + * For any reuse or distribution, you must make clear to others the + * license terms of this work. + */ +package com.moviejukebox.themoviedb.model; + +import org.apache.log4j.Logger; +import org.codehaus.jackson.annotate.JsonAnySetter; +import org.codehaus.jackson.annotate.JsonProperty; + +/** + * + * @author Stuart + */ +public class AlternativeTitle { + + /* + * Logger + */ + private static final Logger logger = Logger.getLogger(AlternativeTitle.class); + /* + * Properties + */ + @JsonProperty("iso_3166_1") + private String country; + @JsonProperty("title") + private String title; + + // + public String getCountry() { + return country; + } + + public String getTitle() { + return title; + } + // + + // + public void setCountry(String country) { + this.country = country; + } + + public void setTitle(String title) { + this.title = title; + } + // + + /** + * Handle unknown properties and print a message + * @param key + * @param value + */ + @JsonAnySetter + public void handleUnknown(String key, Object value) { + StringBuilder sb = new StringBuilder(); + sb.append("Unknown property: '").append(key); + sb.append("' value: '").append(value).append("'"); + logger.warn(sb.toString()); + } + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final AlternativeTitle other = (AlternativeTitle) obj; + if ((this.country == null) ? (other.country != null) : !this.country.equals(other.country)) { + return false; + } + if ((this.title == null) ? (other.title != null) : !this.title.equals(other.title)) { + return false; + } + return true; + } + + @Override + public int hashCode() { + int hash = 7; + hash = 89 * hash + (this.country != null ? this.country.hashCode() : 0); + hash = 89 * hash + (this.title != null ? this.title.hashCode() : 0); + return hash; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("[AlternativeTitle="); + sb.append("[country=").append(country); + sb.append("],[title=").append(title); + sb.append("]]"); + return sb.toString(); + } +} diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Artwork.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Artwork.java new file mode 100644 index 000000000..89e209bf8 --- /dev/null +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Artwork.java @@ -0,0 +1,183 @@ +/* + * Copyright (c) 2004-2012 YAMJ Members + * http://code.google.com/p/moviejukebox/people/list + * + * Web: http://code.google.com/p/moviejukebox/ + * + * This software is licensed under a Creative Commons License + * See this page: http://code.google.com/p/moviejukebox/wiki/License + * + * For any reuse or distribution, you must make clear to others the + * license terms of this work. + */ +package com.moviejukebox.themoviedb.model; + +import org.apache.log4j.Logger; +import org.codehaus.jackson.annotate.JsonAnySetter; +import org.codehaus.jackson.annotate.JsonProperty; + +/** + * The artwork type information + * @author Stuart + */ +public class Artwork { + + /* + * Logger + */ + private static final Logger logger = Logger.getLogger(Artwork.class); + /* + * Properties + */ + @JsonProperty("aspect_ratio") + private float aspectRatio; + @JsonProperty("file_path") + private String filePath; + @JsonProperty("height") + private int height; + @JsonProperty("iso_639_1") + private String language; + @JsonProperty("width") + private String width; + @JsonProperty("vote_average") + private float voteAverage; + @JsonProperty("vote_count") + private int voteCount; + private ArtworkType artworkType = ArtworkType.POSTER; + + // + public ArtworkType getArtworkType() { + return artworkType; + } + + public float getAspectRatio() { + return aspectRatio; + } + + public String getFilePath() { + return filePath; + } + + public int getHeight() { + return height; + } + + public String getLanguage() { + return language; + } + + public String getWidth() { + return width; + } + + public float getVoteAverage() { + return voteAverage; + } + + public int getVoteCount() { + return voteCount; + } + // + + // + public void setArtworkType(ArtworkType artworkType) { + this.artworkType = artworkType; + } + + public void setAspectRatio(float aspectRatio) { + this.aspectRatio = aspectRatio; + } + + public void setFilePath(String filePath) { + this.filePath = filePath; + } + + public void setHeight(int height) { + this.height = height; + } + + public void setLanguage(String language) { + this.language = language; + } + + public void setWidth(String width) { + this.width = width; + } + + public void setVoteAverage(float voteAverage) { + this.voteAverage = voteAverage; + } + + public void setVoteCount(int voteCount) { + this.voteCount = voteCount; + } + // + + /** + * Handle unknown properties and print a message + * @param key + * @param value + */ + @JsonAnySetter + public void handleUnknown(String key, Object value) { + StringBuilder sb = new StringBuilder(); + sb.append("Unknown property: '").append(key); + sb.append("' value: '").append(value).append("'"); + logger.warn(sb.toString()); + } + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final Artwork other = (Artwork) obj; + if (Float.floatToIntBits(this.aspectRatio) != Float.floatToIntBits(other.aspectRatio)) { + return false; + } + if ((this.filePath == null) ? (other.filePath != null) : !this.filePath.equals(other.filePath)) { + return false; + } + if (this.height != other.height) { + return false; + } + if ((this.language == null) ? (other.language != null) : !this.language.equals(other.language)) { + return false; + } + if ((this.width == null) ? (other.width != null) : !this.width.equals(other.width)) { + return false; + } + if (this.artworkType != other.artworkType) { + return false; + } + return true; + } + + @Override + public int hashCode() { + int hash = 3; + hash = 71 * hash + Float.floatToIntBits(this.aspectRatio); + hash = 71 * hash + (this.filePath != null ? this.filePath.hashCode() : 0); + hash = 71 * hash + this.height; + hash = 71 * hash + (this.language != null ? this.language.hashCode() : 0); + hash = 71 * hash + (this.width != null ? this.width.hashCode() : 0); + hash = 71 * hash + (this.artworkType != null ? this.artworkType.hashCode() : 0); + return hash; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("[Artwork="); + sb.append("[aspectRatio=").append(aspectRatio); + sb.append("],[filePath=").append(filePath); + sb.append("],[height=").append(height); + sb.append("],[language=").append(language); + sb.append("],[width=").append(width); + sb.append("],[artworkType=").append(artworkType); + sb.append("]]"); + return sb.toString(); + } +} diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/ArtworkType.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/ArtworkType.java new file mode 100644 index 000000000..bc8c32e63 --- /dev/null +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/ArtworkType.java @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2004-2012 YAMJ Members + * http://code.google.com/p/moviejukebox/people/list + * + * Web: http://code.google.com/p/moviejukebox/ + * + * This software is licensed under a Creative Commons License + * See this page: http://code.google.com/p/moviejukebox/wiki/License + * + * For any reuse or distribution, you must make clear to others the + * license terms of this work. + */ +package com.moviejukebox.themoviedb.model; + +/** + * ArtworkType enum List of the artwork types that are available + */ +public enum ArtworkType { + + POSTER, BACKDROP +} diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Collection.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Collection.java new file mode 100644 index 000000000..778c029fb --- /dev/null +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Collection.java @@ -0,0 +1,173 @@ +/* + * Copyright (c) 2004-2012 YAMJ Members + * http://code.google.com/p/moviejukebox/people/list + * + * Web: http://code.google.com/p/moviejukebox/ + * + * This software is licensed under a Creative Commons License + * See this page: http://code.google.com/p/moviejukebox/wiki/License + * + * For any reuse or distribution, you must make clear to others the + * license terms of this work. + */ +package com.moviejukebox.themoviedb.model; + +import org.apache.commons.lang.StringUtils; +import org.apache.log4j.Logger; +import org.codehaus.jackson.annotate.JsonAnySetter; +import org.codehaus.jackson.annotate.JsonProperty; +import org.codehaus.jackson.map.annotate.JsonRootName; + +/** + * + * @author stuart.boston + */ +@JsonRootName("collection") +public class Collection { + + /* + * Logger + */ + private static final Logger logger = Logger.getLogger(Collection.class); + /* + * Properties + */ + @JsonProperty("id") + private int id; + @JsonProperty("title") + private String title; + @JsonProperty("name") + private String name; + @JsonProperty("poster_path") + private String posterPath; + @JsonProperty("backdrop_path") + private String backdropPath; + @JsonProperty("release_date") + private String releaseDate; + + // + public String getBackdropPath() { + return backdropPath; + } + + public int getId() { + return id; + } + + public String getPosterPath() { + return posterPath; + } + + public String getReleaseDate() { + return releaseDate; + } + + public String getTitle() { + if (StringUtils.isBlank(title)) { + return name; + } + return title; + } + + public String getName() { + if (StringUtils.isBlank(name)) { + return title; + } + return name; + } + // + + // + public void setBackdropPath(String backdropPath) { + this.backdropPath = backdropPath; + } + + public void setId(int id) { + this.id = id; + } + + public void setPosterPath(String posterPath) { + this.posterPath = posterPath; + } + + public void setReleaseDate(String releaseDate) { + this.releaseDate = releaseDate; + } + + public void setTitle(String title) { + this.title = title; + } + + public void setName(String name) { + this.name = name; + } + // + + /** + * Handle unknown properties and print a message + * @param key + * @param value + */ + @JsonAnySetter + public void handleUnknown(String key, Object value) { + StringBuilder sb = new StringBuilder(); + sb.append("Unknown property: '").append(key); + sb.append("' value: '").append(value).append("'"); + logger.warn(sb.toString()); + } + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final Collection other = (Collection) obj; + if ((this.backdropPath == null) ? (other.backdropPath != null) : !this.backdropPath.equals(other.backdropPath)) { + return false; + } + if (this.id != other.id) { + return false; + } + if ((this.title == null) ? (other.title != null) : !this.title.equals(other.title)) { + return false; + } + if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) { + return false; + } + if ((this.posterPath == null) ? (other.posterPath != null) : !this.posterPath.equals(other.posterPath)) { + return false; + } + if ((this.releaseDate == null) ? (other.releaseDate != null) : !this.releaseDate.equals(other.releaseDate)) { + return false; + } + return true; + } + + @Override + public int hashCode() { + int hash = 7; + hash = 19 * hash + (this.backdropPath != null ? this.backdropPath.hashCode() : 0); + hash = 19 * hash + this.id; + hash = 19 * hash + (this.title != null ? this.title.hashCode() : 0); + hash = 19 * hash + (this.name != null ? this.name.hashCode() : 0); + hash = 19 * hash + (this.posterPath != null ? this.posterPath.hashCode() : 0); + hash = 19 * hash + (this.releaseDate != null ? this.releaseDate.hashCode() : 0); + return hash; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("[Collection="); + sb.append("[id=").append(id); + sb.append("],[title=").append(title); + sb.append("],[name=").append(name); + sb.append("],[posterPath=").append(posterPath); + sb.append("],[backdropPath=").append(backdropPath); + sb.append("],[releaseDate=").append(releaseDate); + sb.append("]]"); + return sb.toString(); + } +} diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/CollectionInfo.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/CollectionInfo.java new file mode 100644 index 000000000..ec7ed245b --- /dev/null +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/CollectionInfo.java @@ -0,0 +1,113 @@ +/* + * Copyright (c) 2004-2012 YAMJ Members + * http://code.google.com/p/moviejukebox/people/list + * + * Web: http://code.google.com/p/moviejukebox/ + * + * This software is licensed under a Creative Commons License + * See this page: http://code.google.com/p/moviejukebox/wiki/License + * + * For any reuse or distribution, you must make clear to others the + * license terms of this work. + */ +package com.moviejukebox.themoviedb.model; + +import java.util.ArrayList; +import java.util.List; +import org.apache.log4j.Logger; +import org.codehaus.jackson.annotate.JsonAnySetter; +import org.codehaus.jackson.annotate.JsonProperty; + +/** + * + * @author Stuart + */ +public class CollectionInfo { + + /* + * Logger + */ + private static final Logger logger = Logger.getLogger(CollectionInfo.class); + /* + * Properties + */ + @JsonProperty("id") + private int id; + @JsonProperty("name") + private String name; + @JsonProperty("poster_path") + private String posterPath; + @JsonProperty("backdrop_path") + private String backdropPath; + @JsonProperty("parts") + private List parts = new ArrayList(); + + // + public String getBackdropPath() { + return backdropPath; + } + + public int getId() { + return id; + } + + public String getName() { + return name; + } + + public List getParts() { + return parts; + } + + public String getPosterPath() { + return posterPath; + } + // + + // + public void setBackdropPath(String backdropPath) { + this.backdropPath = backdropPath; + } + + public void setId(int id) { + this.id = id; + } + + public void setName(String name) { + this.name = name; + } + + public void setParts(List parts) { + this.parts = parts; + } + + public void setPosterPath(String posterPath) { + this.posterPath = posterPath; + } + // + + /** + * Handle unknown properties and print a message + * @param key + * @param value + */ + @JsonAnySetter + public void handleUnknown(String key, Object value) { + StringBuilder sb = new StringBuilder(); + sb.append("Unknown property: '").append(key); + sb.append("' value: '").append(value).append("'"); + logger.warn(sb.toString()); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("[CollectionInfo="); + sb.append("[id=").append(id); + sb.append("],[name=").append(name); + sb.append("],[posterPath=").append(posterPath); + sb.append("],[backdropPath=").append(backdropPath); + sb.append("],[# of parts=").append(parts.size()); + sb.append("]]"); + return sb.toString(); + } +} diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Genre.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Genre.java new file mode 100644 index 000000000..9f261fe83 --- /dev/null +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Genre.java @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2004-2012 YAMJ Members + * http://code.google.com/p/moviejukebox/people/list + * + * Web: http://code.google.com/p/moviejukebox/ + * + * This software is licensed under a Creative Commons License + * See this page: http://code.google.com/p/moviejukebox/wiki/License + * + * For any reuse or distribution, you must make clear to others the + * license terms of this work. + */ +package com.moviejukebox.themoviedb.model; + +import org.apache.log4j.Logger; +import org.codehaus.jackson.annotate.JsonAnySetter; +import org.codehaus.jackson.annotate.JsonProperty; +import org.codehaus.jackson.map.annotate.JsonRootName; + +/** + * + * @author stuart.boston + */ +@JsonRootName("genre") +public class Genre { + + /* + * Logger + */ + private static final Logger logger = Logger.getLogger(Genre.class); + /* + * Properties + */ + @JsonProperty("id") + private int id; + @JsonProperty("name") + private String name; + + // + public int getId() { + return id; + } + + public String getName() { + return name; + } + // + + // + public void setId(int id) { + this.id = id; + } + + public void setName(String name) { + this.name = name; + } + // + + /** + * Handle unknown properties and print a message + * @param key + * @param value + */ + @JsonAnySetter + public void handleUnknown(String key, Object value) { + StringBuilder sb = new StringBuilder(); + sb.append("Unknown property: '").append(key); + sb.append("' value: '").append(value).append("'"); + logger.warn(sb.toString()); + } + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final Genre other = (Genre) obj; + if (this.id != other.id) { + return false; + } + if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) { + return false; + } + return true; + } + + @Override + public int hashCode() { + int hash = 5; + hash = 53 * hash + this.id; + hash = 53 * hash + (this.name != null ? this.name.hashCode() : 0); + return hash; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("[Genre="); + sb.append("id=").append(id); + sb.append("],[name=").append(name); + sb.append("]]"); + return sb.toString(); + } +} diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Keyword.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Keyword.java new file mode 100644 index 000000000..e53c02542 --- /dev/null +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Keyword.java @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2004-2012 YAMJ Members + * http://code.google.com/p/moviejukebox/people/list + * + * Web: http://code.google.com/p/moviejukebox/ + * + * This software is licensed under a Creative Commons License + * See this page: http://code.google.com/p/moviejukebox/wiki/License + * + * For any reuse or distribution, you must make clear to others the + * license terms of this work. + */ +package com.moviejukebox.themoviedb.model; + +import org.apache.log4j.Logger; +import org.codehaus.jackson.annotate.JsonAnySetter; +import org.codehaus.jackson.annotate.JsonProperty; +import org.codehaus.jackson.map.annotate.JsonRootName; + +/** + * + * @author stuart.boston + */ +@JsonRootName("keyword") +public class Keyword { + + /* + * Logger + */ + private static final Logger logger = Logger.getLogger(Keyword.class); + /* + * Properties + */ + @JsonProperty("id") + private int id; + @JsonProperty("name") + private String name; + + // + public int getId() { + return id; + } + + public String getName() { + return name; + } + // + + // + public void setId(int id) { + this.id = id; + } + + public void setName(String name) { + this.name = name; + } + // + + /** + * Handle unknown properties and print a message + * @param key + * @param value + */ + @JsonAnySetter + public void handleUnknown(String key, Object value) { + StringBuilder sb = new StringBuilder(); + sb.append("Unknown property: '").append(key); + sb.append("' value: '").append(value).append("'"); + logger.warn(sb.toString()); + } + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final Keyword other = (Keyword) obj; + if (this.id != other.id) { + return false; + } + if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) { + return false; + } + return true; + } + + @Override + public int hashCode() { + int hash = 3; + hash = 83 * hash + this.id; + hash = 83 * hash + (this.name != null ? this.name.hashCode() : 0); + return hash; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("[Keyword="); + sb.append("[id=").append(id); + sb.append("],[name=").append(name); + sb.append("]]"); + return sb.toString(); + } +} diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Language.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Language.java new file mode 100644 index 000000000..4238ee0df --- /dev/null +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Language.java @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2004-2012 YAMJ Members + * http://code.google.com/p/moviejukebox/people/list + * + * Web: http://code.google.com/p/moviejukebox/ + * + * This software is licensed under a Creative Commons License + * See this page: http://code.google.com/p/moviejukebox/wiki/License + * + * For any reuse or distribution, you must make clear to others the + * license terms of this work. + */ +package com.moviejukebox.themoviedb.model; + +import org.apache.log4j.Logger; +import org.codehaus.jackson.annotate.JsonAnySetter; +import org.codehaus.jackson.annotate.JsonProperty; +import org.codehaus.jackson.map.annotate.JsonRootName; + +/** + * + * @author stuart.boston + */ +@JsonRootName("spoken_language") +public class Language { + + /* + * Logger + */ + private static final Logger logger = Logger.getLogger(Language.class); + /* + * Properties + */ + @JsonProperty("iso_639_1") + private String isoCode; + @JsonProperty("name") + private String name; + + // + public String getIsoCode() { + return isoCode; + } + + public String getName() { + return name; + } + // + + // + public void setIsoCode(String isoCode) { + this.isoCode = isoCode; + } + + public void setName(String name) { + this.name = name; + } + // + + /** + * Handle unknown properties and print a message + * @param key + * @param value + */ + @JsonAnySetter + public void handleUnknown(String key, Object value) { + StringBuilder sb = new StringBuilder(); + sb.append("Unknown property: '").append(key); + sb.append("' value: '").append(value).append("'"); + logger.warn(sb.toString()); + } + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final Language other = (Language) obj; + if ((this.isoCode == null) ? (other.isoCode != null) : !this.isoCode.equals(other.isoCode)) { + return false; + } + if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) { + return false; + } + return true; + } + + @Override + public int hashCode() { + int hash = 7; + hash = 71 * hash + (this.isoCode != null ? this.isoCode.hashCode() : 0); + hash = 71 * hash + (this.name != null ? this.name.hashCode() : 0); + return hash; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("[Language="); + sb.append("isoCode=").append(isoCode); + sb.append(", name=").append(name); + sb.append("]]"); + return sb.toString(); + } +} diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/MovieDB.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/MovieDB.java new file mode 100644 index 000000000..98b367228 --- /dev/null +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/MovieDB.java @@ -0,0 +1,407 @@ +/* + * Copyright (c) 2004-2012 YAMJ Members + * http://code.google.com/p/moviejukebox/people/list + * + * Web: http://code.google.com/p/moviejukebox/ + * + * This software is licensed under a Creative Commons License + * See this page: http://code.google.com/p/moviejukebox/wiki/License + * + * For any reuse or distribution, you must make clear to others the + * license terms of this work. + */ +package com.moviejukebox.themoviedb.model; + +import java.util.List; +import org.apache.log4j.Logger; +import org.codehaus.jackson.annotate.JsonAnySetter; +import org.codehaus.jackson.annotate.JsonProperty; + +/** + * Movie Bean + * @author stuart.boston + */ +public class MovieDB { + + /* + * Logger + */ + private static final Logger logger = Logger.getLogger(MovieDB.class); + /* + * Properties + */ + @JsonProperty(("backdrop_path")) + private String backdropPath; + @JsonProperty(("id")) + private int id; + @JsonProperty(("original_title")) + private String originalTitle; + @JsonProperty(("popularity")) + private float popularity; + @JsonProperty(("poster_path")) + private String posterPath; + @JsonProperty(("release_date")) + private String releaseDate; + @JsonProperty(("title")) + private String title; + @JsonProperty("adult") + private boolean adult; + @JsonProperty("belongs_to_collection") + private Collection belongsToCollection; + @JsonProperty("budget") + private int budget; + @JsonProperty("genres") + private List genres; + @JsonProperty("homepage") + private String homepage; + @JsonProperty("imdb_id") + private String imdbID; + @JsonProperty("overview") + private String overview; + @JsonProperty("production_companies") + private List productionCompanies; + @JsonProperty("production_countries") + private List productionCountries; + @JsonProperty("revenue") + private int revenue; + @JsonProperty("runtime") + private int runtime; + @JsonProperty("spoken_languages") + private List spokenLanguages; + @JsonProperty("tagline") + private String tagline; + @JsonProperty("vote_average") + private float voteAverage; + @JsonProperty("vote_count") + private int voteCount; + + // + public String getBackdropPath() { + return backdropPath; + } + + public int getId() { + return id; + } + + public String getOriginalTitle() { + return originalTitle; + } + + public float getPopularity() { + return popularity; + } + + public String getPosterPath() { + return posterPath; + } + + public String getReleaseDate() { + return releaseDate; + } + + public String getTitle() { + return title; + } + + public boolean isAdult() { + return adult; + } + + public Collection getBelongsToCollection() { + return belongsToCollection; + } + + public int getBudget() { + return budget; + } + + public List getGenres() { + return genres; + } + + public String getHomepage() { + return homepage; + } + + public String getImdbID() { + return imdbID; + } + + public String getOverview() { + return overview; + } + + public List getProductionCompanies() { + return productionCompanies; + } + + public List getProductionCountries() { + return productionCountries; + } + + public int getRevenue() { + return revenue; + } + + public int getRuntime() { + return runtime; + } + + public List getSpokenLanguages() { + return spokenLanguages; + } + + public String getTagline() { + return tagline; + } + + public float getVoteAverage() { + return voteAverage; + } + + public int getVoteCount() { + return voteCount; + } + // + + // + public void setBackdropPath(String backdropPath) { + this.backdropPath = backdropPath; + } + + public void setId(int id) { + this.id = id; + } + + public void setOriginalTitle(String originalTitle) { + this.originalTitle = originalTitle; + } + + public void setPopularity(float popularity) { + this.popularity = popularity; + } + + public void setPosterPath(String posterPath) { + this.posterPath = posterPath; + } + + public void setReleaseDate(String releaseDate) { + this.releaseDate = releaseDate; + } + + public void setTitle(String title) { + this.title = title; + } + + public void setAdult(boolean adult) { + this.adult = adult; + } + + public void setBelongsToCollection(Collection belongsToCollection) { + this.belongsToCollection = belongsToCollection; + } + + public void setBudget(int budget) { + this.budget = budget; + } + + public void setGenres(List genres) { + this.genres = genres; + } + + public void setHomepage(String homepage) { + this.homepage = homepage; + } + + public void setImdbID(String imdbID) { + this.imdbID = imdbID; + } + + public void setOverview(String overview) { + this.overview = overview; + } + + public void setProductionCompanies(List productionCompanies) { + this.productionCompanies = productionCompanies; + } + + public void setProductionCountries(List productionCountries) { + this.productionCountries = productionCountries; + } + + public void setRevenue(int revenue) { + this.revenue = revenue; + } + + public void setRuntime(int runtime) { + this.runtime = runtime; + } + + public void setSpokenLanguages(List spokenLanguages) { + this.spokenLanguages = spokenLanguages; + } + + public void setTagline(String tagline) { + this.tagline = tagline; + } + + public void setVoteAverage(float voteAverage) { + this.voteAverage = voteAverage; + } + + public void setVoteCount(int voteCount) { + this.voteCount = voteCount; + } + // + + /** + * Handle unknown properties and print a message + * @param key + * @param value + */ + @JsonAnySetter + public void handleUnknown(String key, Object value) { + StringBuilder sb = new StringBuilder(); + sb.append("Unknown property: '").append(key); + sb.append("' value: '").append(value).append("'"); + logger.warn(sb.toString()); + } + + // + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final MovieDB other = (MovieDB) obj; + if ((this.backdropPath == null) ? (other.backdropPath != null) : !this.backdropPath.equals(other.backdropPath)) { + return false; + } + if (this.id != other.id) { + return false; + } + if ((this.originalTitle == null) ? (other.originalTitle != null) : !this.originalTitle.equals(other.originalTitle)) { + return false; + } + if (Float.floatToIntBits(this.popularity) != Float.floatToIntBits(other.popularity)) { + return false; + } + if ((this.posterPath == null) ? (other.posterPath != null) : !this.posterPath.equals(other.posterPath)) { + return false; + } + if ((this.releaseDate == null) ? (other.releaseDate != null) : !this.releaseDate.equals(other.releaseDate)) { + return false; + } + if ((this.title == null) ? (other.title != null) : !this.title.equals(other.title)) { + return false; + } + if (this.adult != other.adult) { + return false; + } + if (this.belongsToCollection != other.belongsToCollection && (this.belongsToCollection == null || !this.belongsToCollection.equals(other.belongsToCollection))) { + return false; + } + if (this.budget != other.budget) { + return false; + } + if (this.genres != other.genres && (this.genres == null || !this.genres.equals(other.genres))) { + return false; + } + if ((this.homepage == null) ? (other.homepage != null) : !this.homepage.equals(other.homepage)) { + return false; + } + if ((this.imdbID == null) ? (other.imdbID != null) : !this.imdbID.equals(other.imdbID)) { + return false; + } + if ((this.overview == null) ? (other.overview != null) : !this.overview.equals(other.overview)) { + return false; + } + if (this.productionCompanies != other.productionCompanies && (this.productionCompanies == null || !this.productionCompanies.equals(other.productionCompanies))) { + return false; + } + if (this.productionCountries != other.productionCountries && (this.productionCountries == null || !this.productionCountries.equals(other.productionCountries))) { + return false; + } + if (this.revenue != other.revenue) { + return false; + } + if (this.runtime != other.runtime) { + return false; + } + if (this.spokenLanguages != other.spokenLanguages && (this.spokenLanguages == null || !this.spokenLanguages.equals(other.spokenLanguages))) { + return false; + } + if ((this.tagline == null) ? (other.tagline != null) : !this.tagline.equals(other.tagline)) { + return false; + } + if (Float.floatToIntBits(this.voteAverage) != Float.floatToIntBits(other.voteAverage)) { + return false; + } + if (this.voteCount != other.voteCount) { + return false; + } + return true; + } + + @Override + public int hashCode() { + int hash = 3; + hash = 97 * hash + (this.backdropPath != null ? this.backdropPath.hashCode() : 0); + hash = 97 * hash + this.id; + hash = 97 * hash + (this.originalTitle != null ? this.originalTitle.hashCode() : 0); + hash = 97 * hash + Float.floatToIntBits(this.popularity); + hash = 97 * hash + (this.posterPath != null ? this.posterPath.hashCode() : 0); + hash = 97 * hash + (this.releaseDate != null ? this.releaseDate.hashCode() : 0); + hash = 97 * hash + (this.title != null ? this.title.hashCode() : 0); + hash = 97 * hash + (this.adult ? 1 : 0); + hash = 97 * hash + (this.belongsToCollection != null ? this.belongsToCollection.hashCode() : 0); + hash = 97 * hash + this.budget; + hash = 97 * hash + (this.genres != null ? this.genres.hashCode() : 0); + hash = 97 * hash + (this.homepage != null ? this.homepage.hashCode() : 0); + hash = 97 * hash + (this.imdbID != null ? this.imdbID.hashCode() : 0); + hash = 97 * hash + (this.overview != null ? this.overview.hashCode() : 0); + hash = 97 * hash + (this.productionCompanies != null ? this.productionCompanies.hashCode() : 0); + hash = 97 * hash + (this.productionCountries != null ? this.productionCountries.hashCode() : 0); + hash = 97 * hash + this.revenue; + hash = 97 * hash + this.runtime; + hash = 97 * hash + (this.spokenLanguages != null ? this.spokenLanguages.hashCode() : 0); + hash = 97 * hash + (this.tagline != null ? this.tagline.hashCode() : 0); + hash = 97 * hash + Float.floatToIntBits(this.voteAverage); + hash = 97 * hash + this.voteCount; + return hash; + } + // + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("[MovieDB="); + sb.append("[backdropPath=").append(backdropPath); + sb.append("],[id=").append(id); + sb.append("],[originalTitle=").append(originalTitle); + sb.append("],[popularity=").append(popularity); + sb.append("],[posterPath=").append(posterPath); + sb.append("],[releaseDate=").append(releaseDate); + sb.append("],[title=").append(title); + sb.append("],[adult=").append(adult); + sb.append("],[belongsToCollection=").append(belongsToCollection); + sb.append("],[budget=").append(budget); + sb.append("],[genres=").append(genres); + sb.append("],[homepage=").append(homepage); + sb.append("],[imdbID=").append(imdbID); + sb.append("],[overview=").append(overview); + sb.append("],[productionCompanies=").append(productionCompanies); + sb.append("],[productionCountries=").append(productionCountries); + sb.append("],[revenue=").append(revenue); + sb.append("],[runtime=").append(runtime); + sb.append("],[spokenLanguages=").append(spokenLanguages); + sb.append("],[tagline=").append(tagline); + sb.append("],[voteAverage=").append(voteAverage); + sb.append("],[voteCount=").append(voteCount); + sb.append("]]"); + return sb.toString(); + } +} diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Person.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Person.java new file mode 100644 index 000000000..97604115f --- /dev/null +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Person.java @@ -0,0 +1,230 @@ +/* + * Copyright (c) 2004-2012 YAMJ Members + * http://code.google.com/p/moviejukebox/people/list + * + * Web: http://code.google.com/p/moviejukebox/ + * + * This software is licensed under a Creative Commons License + * See this page: http://code.google.com/p/moviejukebox/wiki/License + * + * For any reuse or distribution, you must make clear to others the + * license terms of this work. + */ +package com.moviejukebox.themoviedb.model; + +import org.apache.log4j.Logger; +import org.codehaus.jackson.annotate.JsonAnySetter; + +/** + * + * @author stuart.boston + */ +public class Person { + /* + * Logger + */ + + private static final Logger logger = Logger.getLogger(Person.class); + + /* + * Static fields for default cast information + */ + private static final String CAST_DEPARTMENT = "acting"; + private static final String CAST_JOB = "actor"; + /* + * Properties + */ + private int id = -1; + private String name = ""; + private String profilePath = ""; + private PersonType personType; + private String department = ""; // Crew + private String job = ""; // Crew + private String character = ""; // Cast + private int order = -1; // Cast + + public enum PersonType { + + CAST, CREW + } + + /** + * Add a crew member + * @param id + * @param name + * @param profilePath + * @param department + * @param job + */ + public void addCrew(int id, String name, String profilePath, String department, String job) { + this.personType = PersonType.CREW; + this.id = id; + this.name = name; + this.profilePath = profilePath; + this.department = department; + this.job = job; + this.character = ""; + this.order = -1; + } + + /** + * Add a cast member + * @param id + * @param name + * @param profilePath + * @param character + * @param order + */ + public void addCast(int id, String name, String profilePath, String character, int order) { + this.personType = PersonType.CAST; + this.id = id; + this.name = name; + this.profilePath = profilePath; + this.character = character; + this.order = order; + this.department = CAST_DEPARTMENT; + this.job = CAST_JOB; + } + + // + public String getCharacter() { + return character; + } + + public String getDepartment() { + return department; + } + + public int getId() { + return id; + } + + public String getJob() { + return job; + } + + public String getName() { + return name; + } + + public int getOrder() { + return order; + } + + public PersonType getPersonType() { + return personType; + } + + public String getProfilePath() { + return profilePath; + } + // + + // + public void setCharacter(String character) { + this.character = character; + } + + public void setDepartment(String department) { + this.department = department; + } + + public void setId(int id) { + this.id = id; + } + + public void setJob(String job) { + this.job = job; + } + + public void setName(String name) { + this.name = name; + } + + public void setOrder(int order) { + this.order = order; + } + + public void setPersonType(PersonType personType) { + this.personType = personType; + } + + public void setProfilePath(String profilePath) { + this.profilePath = profilePath; + } + // + + /** + * Handle unknown properties and print a message + * @param key + * @param value + */ + @JsonAnySetter + public void handleUnknown(String key, Object value) { + StringBuilder sb = new StringBuilder(); + sb.append("Unknown property: '").append(key); + sb.append("' value: '").append(value).append("'"); + logger.warn(sb.toString()); + } + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final Person other = (Person) obj; + if (this.id != other.id) { + return false; + } + if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) { + return false; + } + if ((this.profilePath == null) ? (other.profilePath != null) : !this.profilePath.equals(other.profilePath)) { + return false; + } + if (this.personType != other.personType) { + return false; + } + if ((this.department == null) ? (other.department != null) : !this.department.equals(other.department)) { + return false; + } + if ((this.job == null) ? (other.job != null) : !this.job.equals(other.job)) { + return false; + } + if ((this.character == null) ? (other.character != null) : !this.character.equals(other.character)) { + return false; + } + return true; + } + + @Override + public int hashCode() { + int hash = 3; + hash = 37 * hash + this.id; + hash = 37 * hash + (this.name != null ? this.name.hashCode() : 0); + hash = 37 * hash + (this.profilePath != null ? this.profilePath.hashCode() : 0); + hash = 37 * hash + (this.personType != null ? this.personType.hashCode() : 0); + hash = 37 * hash + (this.department != null ? this.department.hashCode() : 0); + hash = 37 * hash + (this.job != null ? this.job.hashCode() : 0); + hash = 37 * hash + (this.character != null ? this.character.hashCode() : 0); + return hash; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("[Person="); + sb.append("[id=").append(id); + sb.append("],[name=").append(name); + sb.append("],[profilePath=").append(profilePath); + sb.append("],[personType=").append(personType); + sb.append("],[department=").append(department); + sb.append("],[job=").append(job); + sb.append("],[character=").append(character); + sb.append("],[order=").append(order); + sb.append("]]"); + return sb.toString(); + } +} diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/PersonCast.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/PersonCast.java new file mode 100644 index 000000000..9eb2e5968 --- /dev/null +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/PersonCast.java @@ -0,0 +1,149 @@ +/* + * Copyright (c) 2004-2012 YAMJ Members + * http://code.google.com/p/moviejukebox/people/list + * + * Web: http://code.google.com/p/moviejukebox/ + * + * This software is licensed under a Creative Commons License + * See this page: http://code.google.com/p/moviejukebox/wiki/License + * + * For any reuse or distribution, you must make clear to others the + * license terms of this work. + */ +package com.moviejukebox.themoviedb.model; + +import org.apache.log4j.Logger; +import org.codehaus.jackson.annotate.JsonAnySetter; +import org.codehaus.jackson.annotate.JsonProperty; + +/** + * + * @author Stuart + */ +public class PersonCast { + /* + * Logger + */ + + private static final Logger logger = Logger.getLogger(PersonCast.class); + /* + * Properties + */ + @JsonProperty("id") + private int id; + @JsonProperty("character") + private String character; + @JsonProperty("name") + private String name; + @JsonProperty("order") + private int order; + @JsonProperty("profile_path") + private String profilePath; + + // + public String getCharacter() { + return character; + } + + public int getId() { + return id; + } + + public String getName() { + return name; + } + + public int getOrder() { + return order; + } + + public String getProfilePath() { + return profilePath; + } + // + + // + public void setCharacter(String character) { + this.character = character; + } + + public void setId(int id) { + this.id = id; + } + + public void setName(String name) { + this.name = name; + } + + public void setOrder(int order) { + this.order = order; + } + + public void setProfilePath(String profilePath) { + this.profilePath = profilePath; + } + // + + /** + * Handle unknown properties and print a message + * @param key + * @param value + */ + @JsonAnySetter + public void handleUnknown(String key, Object value) { + StringBuilder sb = new StringBuilder(); + sb.append("Unknown property: '").append(key); + sb.append("' value: '").append(value).append("'"); + logger.warn(sb.toString()); + } + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final PersonCast other = (PersonCast) obj; + if (this.id != other.id) { + return false; + } + if ((this.character == null) ? (other.character != null) : !this.character.equals(other.character)) { + return false; + } + if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) { + return false; + } + if (this.order != other.order) { + return false; + } + if ((this.profilePath == null) ? (other.profilePath != null) : !this.profilePath.equals(other.profilePath)) { + return false; + } + return true; + } + + @Override + public int hashCode() { + int hash = 7; + hash = 41 * hash + this.id; + hash = 41 * hash + (this.character != null ? this.character.hashCode() : 0); + hash = 41 * hash + (this.name != null ? this.name.hashCode() : 0); + hash = 41 * hash + this.order; + hash = 41 * hash + (this.profilePath != null ? this.profilePath.hashCode() : 0); + return hash; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("[PersonCast="); + sb.append("id=").append(id); + sb.append("],[character=").append(character); + sb.append("],[name=").append(name); + sb.append("],[order=").append(order); + sb.append("],[profilePath=").append(profilePath); + sb.append("]]"); + return sb.toString(); + } +} diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/PersonCrew.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/PersonCrew.java new file mode 100644 index 000000000..29d58cd6a --- /dev/null +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/PersonCrew.java @@ -0,0 +1,149 @@ +/* + * Copyright (c) 2004-2012 YAMJ Members + * http://code.google.com/p/moviejukebox/people/list + * + * Web: http://code.google.com/p/moviejukebox/ + * + * This software is licensed under a Creative Commons License + * See this page: http://code.google.com/p/moviejukebox/wiki/License + * + * For any reuse or distribution, you must make clear to others the + * license terms of this work. + */ +package com.moviejukebox.themoviedb.model; + +import org.apache.log4j.Logger; +import org.codehaus.jackson.annotate.JsonAnySetter; +import org.codehaus.jackson.annotate.JsonProperty; + +/** + * + * @author Stuart + */ +public class PersonCrew { + /* + * Logger + */ + + private static final Logger logger = Logger.getLogger(PersonCrew.class); + /* + * Properties + */ + @JsonProperty("id") + private int id; + @JsonProperty("department") + private String department; + @JsonProperty("job") + private String job; + @JsonProperty("name") + private String name; + @JsonProperty("profile_path") + private String profilePath; + + // + public String getDepartment() { + return department; + } + + public int getId() { + return id; + } + + public String getJob() { + return job; + } + + public String getName() { + return name; + } + + public String getProfilePath() { + return profilePath; + } + // + + // + public void setDepartment(String department) { + this.department = department; + } + + public void setId(int id) { + this.id = id; + } + + public void setJob(String job) { + this.job = job; + } + + public void setName(String name) { + this.name = name; + } + + public void setProfilePath(String profilePath) { + this.profilePath = profilePath; + } + // + + /** + * Handle unknown properties and print a message + * @param key + * @param value + */ + @JsonAnySetter + public void handleUnknown(String key, Object value) { + StringBuilder sb = new StringBuilder(); + sb.append("Unknown property: '").append(key); + sb.append("' value: '").append(value).append("'"); + logger.warn(sb.toString()); + } + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final PersonCrew other = (PersonCrew) obj; + if (this.id != other.id) { + return false; + } + if ((this.department == null) ? (other.department != null) : !this.department.equals(other.department)) { + return false; + } + if ((this.job == null) ? (other.job != null) : !this.job.equals(other.job)) { + return false; + } + if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) { + return false; + } + if ((this.profilePath == null) ? (other.profilePath != null) : !this.profilePath.equals(other.profilePath)) { + return false; + } + return true; + } + + @Override + public int hashCode() { + int hash = 7; + hash = 59 * hash + this.id; + hash = 59 * hash + (this.department != null ? this.department.hashCode() : 0); + hash = 59 * hash + (this.job != null ? this.job.hashCode() : 0); + hash = 59 * hash + (this.name != null ? this.name.hashCode() : 0); + hash = 59 * hash + (this.profilePath != null ? this.profilePath.hashCode() : 0); + return hash; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("[PersonCrew="); + sb.append("id=").append(id); + sb.append("],[department=").append(department); + sb.append("],[job=").append(job); + sb.append("],[name=").append(name); + sb.append("],[profilePath=").append(profilePath); + sb.append("]]"); + return sb.toString(); + } +} diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/ProductionCompany.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/ProductionCompany.java new file mode 100644 index 000000000..978b1038c --- /dev/null +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/ProductionCompany.java @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2004-2012 YAMJ Members + * http://code.google.com/p/moviejukebox/people/list + * + * Web: http://code.google.com/p/moviejukebox/ + * + * This software is licensed under a Creative Commons License + * See this page: http://code.google.com/p/moviejukebox/wiki/License + * + * For any reuse or distribution, you must make clear to others the + * license terms of this work. + */ +package com.moviejukebox.themoviedb.model; + +import org.apache.log4j.Logger; +import org.codehaus.jackson.annotate.JsonAnySetter; +import org.codehaus.jackson.annotate.JsonProperty; +import org.codehaus.jackson.map.annotate.JsonRootName; + +/** + * + * @author stuart.boston + */ +@JsonRootName("production_company") +public class ProductionCompany { + /* + * Logger + */ + + private static final Logger logger = Logger.getLogger(ProductionCompany.class); + /* + * Properties + */ + @JsonProperty("id") + private int id; + @JsonProperty("name") + private String name; + + // + public int getId() { + return id; + } + + public String getName() { + return name; + } + // + + // + public void setId(int id) { + this.id = id; + } + + public void setName(String name) { + this.name = name; + } + // + + /** + * Handle unknown properties and print a message + * @param key + * @param value + */ + @JsonAnySetter + public void handleUnknown(String key, Object value) { + StringBuilder sb = new StringBuilder(); + sb.append("Unknown property: '").append(key); + sb.append("' value: '").append(value).append("'"); + logger.warn(sb.toString()); + } + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final ProductionCompany other = (ProductionCompany) obj; + if (this.id != other.id) { + return false; + } + if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) { + return false; + } + return true; + } + + @Override + public int hashCode() { + int hash = 5; + hash = 37 * hash + this.id; + hash = 37 * hash + (this.name != null ? this.name.hashCode() : 0); + return hash; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("[ProductionCompany="); + sb.append("[id=").append(id); + sb.append("],[name=").append(name); + sb.append("]]"); + return sb.toString(); + } +} diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/ProductionCountry.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/ProductionCountry.java new file mode 100644 index 000000000..2b3617e69 --- /dev/null +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/ProductionCountry.java @@ -0,0 +1,106 @@ +/* + * Copyright (c) 2004-2012 YAMJ Members + * http://code.google.com/p/moviejukebox/people/list + * + * Web: http://code.google.com/p/moviejukebox/ + * + * This software is licensed under a Creative Commons License + * See this page: http://code.google.com/p/moviejukebox/wiki/License + * + * For any reuse or distribution, you must make clear to others the + * license terms of this work. + */ +package com.moviejukebox.themoviedb.model; + +import org.apache.log4j.Logger; +import org.codehaus.jackson.annotate.JsonAnySetter; +import org.codehaus.jackson.annotate.JsonProperty; +import org.codehaus.jackson.map.annotate.JsonRootName; + +/** + * + * @author stuart.boston + */ +@JsonRootName("production_country") +public class ProductionCountry { + /* + * Logger + */ + + private static final Logger logger = Logger.getLogger(ProductionCountry.class); + /* + * Properties + */ + @JsonProperty("iso_3166_1") + private String isoCode; + @JsonProperty("name") + private String name; + + // + public String getIsoCode() { + return isoCode; + } + + public String getName() { + return name; + } + // + + // + public void setIsoCode(String isoCode) { + this.isoCode = isoCode; + } + + public void setName(String name) { + this.name = name; + } + // + + /** + * Handle unknown properties and print a message + * @param key + * @param value + */ + @JsonAnySetter + public void handleUnknown(String key, Object value) { + StringBuilder sb = new StringBuilder(); + sb.append("Unknown property: '").append(key); + sb.append("' value: '").append(value).append("'"); + logger.warn(sb.toString()); + } + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final ProductionCountry other = (ProductionCountry) obj; + if ((this.isoCode == null) ? (other.isoCode != null) : !this.isoCode.equals(other.isoCode)) { + return false; + } + if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) { + return false; + } + return true; + } + + @Override + public int hashCode() { + int hash = 7; + hash = 47 * hash + (this.isoCode != null ? this.isoCode.hashCode() : 0); + hash = 47 * hash + (this.name != null ? this.name.hashCode() : 0); + return hash; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("[ProductionCountry="); + sb.append("[isoCode=").append(isoCode); + sb.append("],[name=").append(name); + sb.append("]]"); + return sb.toString(); + } +} diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/ReleaseInfo.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/ReleaseInfo.java new file mode 100644 index 000000000..e46e6fb21 --- /dev/null +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/ReleaseInfo.java @@ -0,0 +1,119 @@ +/* + * Copyright (c) 2004-2012 YAMJ Members + * http://code.google.com/p/moviejukebox/people/list + * + * Web: http://code.google.com/p/moviejukebox/ + * + * This software is licensed under a Creative Commons License + * See this page: http://code.google.com/p/moviejukebox/wiki/License + * + * For any reuse or distribution, you must make clear to others the + * license terms of this work. + */ +package com.moviejukebox.themoviedb.model; + +import org.apache.log4j.Logger; +import org.codehaus.jackson.annotate.JsonAnySetter; +import org.codehaus.jackson.annotate.JsonProperty; + +/** + * + * @author Stuart + */ +public class ReleaseInfo { + /* + * Logger + */ + + private static final Logger logger = Logger.getLogger(ReleaseInfo.class); + /* + * Properties + */ + @JsonProperty("iso_3166_1") + private String country; + @JsonProperty("certification") + private String certification; + @JsonProperty("release_date") + private String releaseDate; + + // + public String getCertification() { + return certification; + } + + public String getCountry() { + return country; + } + + public String getReleaseDate() { + return releaseDate; + } + // + + // + public void setCertification(String certification) { + this.certification = certification; + } + + public void setCountry(String country) { + this.country = country; + } + + public void setReleaseDate(String releaseDate) { + this.releaseDate = releaseDate; + } + // + + /** + * Handle unknown properties and print a message + * @param key + * @param value + */ + @JsonAnySetter + public void handleUnknown(String key, Object value) { + StringBuilder sb = new StringBuilder(); + sb.append("Unknown property: '").append(key); + sb.append("' value: '").append(value).append("'"); + logger.warn(sb.toString()); + } + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final ReleaseInfo other = (ReleaseInfo) obj; + if ((this.country == null) ? (other.country != null) : !this.country.equals(other.country)) { + return false; + } + if ((this.certification == null) ? (other.certification != null) : !this.certification.equals(other.certification)) { + return false; + } + if ((this.releaseDate == null) ? (other.releaseDate != null) : !this.releaseDate.equals(other.releaseDate)) { + return false; + } + return true; + } + + @Override + public int hashCode() { + int hash = 3; + hash = 89 * hash + (this.country != null ? this.country.hashCode() : 0); + hash = 89 * hash + (this.certification != null ? this.certification.hashCode() : 0); + hash = 89 * hash + (this.releaseDate != null ? this.releaseDate.hashCode() : 0); + return hash; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("[ReleaseInfo="); + sb.append("[country=").append(country); + sb.append("],[certification=").append(certification); + sb.append("],[releaseDate=").append(releaseDate); + sb.append("]]"); + return sb.toString(); + } +} diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/StatusCode.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/StatusCode.java new file mode 100644 index 000000000..3a59038ee --- /dev/null +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/StatusCode.java @@ -0,0 +1,77 @@ +/* + * Copyright (c) 2004-2012 YAMJ Members + * http://code.google.com/p/moviejukebox/people/list + * + * Web: http://code.google.com/p/moviejukebox/ + * + * This software is licensed under a Creative Commons License + * See this page: http://code.google.com/p/moviejukebox/wiki/License + * + * For any reuse or distribution, you must make clear to others the + * license terms of this work. + */ +package com.moviejukebox.themoviedb.model; + +import org.apache.log4j.Logger; +import org.codehaus.jackson.annotate.JsonAnySetter; +import org.codehaus.jackson.annotate.JsonProperty; + +/** + * + * @author Stuart + */ +public class StatusCode { + /* + * Logger + */ + + private static final Logger logger = Logger.getLogger(StatusCode.class); + /* + * Properties + */ + @JsonProperty("status_code") + int statusCode; + @JsonProperty("status_message") + String statusMessage; + + // + public int getStatusCode() { + return statusCode; + } + + public void setStatusCode(int statusCode) { + this.statusCode = statusCode; + } + // + + // + public String getStatusMessage() { + return statusMessage; + } + + public void setStatusMessage(String statusMessage) { + this.statusMessage = statusMessage; + } + // + + /** + * Handle unknown properties and print a message + * @param key + * @param value + */ + @JsonAnySetter + public void handleUnknown(String key, Object value) { + StringBuilder sb = new StringBuilder(); + sb.append("Unknown property: '").append(key); + sb.append("' value: '").append(value).append("'"); + logger.warn(sb.toString()); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("Status Code: ").append(statusCode); + sb.append(", Message: ").append(statusMessage); + return sb.toString(); + } +} diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/TmdbConfiguration.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/TmdbConfiguration.java new file mode 100644 index 000000000..4ce101f2b --- /dev/null +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/TmdbConfiguration.java @@ -0,0 +1,150 @@ +/* + * Copyright (c) 2004-2012 YAMJ Members + * http://code.google.com/p/moviejukebox/people/list + * + * Web: http://code.google.com/p/moviejukebox/ + * + * This software is licensed under a Creative Commons License + * See this page: http://code.google.com/p/moviejukebox/wiki/License + * + * For any reuse or distribution, you must make clear to others the + * license terms of this work. + */ +package com.moviejukebox.themoviedb.model; + +import java.util.List; +import org.apache.log4j.Logger; +import org.codehaus.jackson.annotate.JsonAnySetter; +import org.codehaus.jackson.annotate.JsonProperty; +import org.codehaus.jackson.map.annotate.JsonRootName; + +/** + * + * @author stuart.boston + */ +@JsonRootName("images") +public class TmdbConfiguration { + + /* + * Logger + */ + private static final Logger logger = Logger.getLogger(TmdbConfiguration.class); + /* + * Properties + */ + @JsonProperty("base_url") + private String baseUrl; + @JsonProperty("poster_sizes") + private List posterSizes; + @JsonProperty("backdrop_sizes") + private List backdropSizes; + @JsonProperty("profile_sizes") + private List profileSizes; + + // //GEN-BEGIN:getterMethods + public List getBackdropSizes() { + return backdropSizes; + } + + public String getBaseUrl() { + return baseUrl; + } + + public List getPosterSizes() { + return posterSizes; + } + + public List getProfileSizes() { + return profileSizes; + } + // + + // //GEN-BEGIN:setterMethods + public void setBackdropSizes(List backdropSizes) { + this.backdropSizes = backdropSizes; + } + + public void setBaseUrl(String baseUrl) { + this.baseUrl = baseUrl; + } + + public void setPosterSizes(List posterSizes) { + this.posterSizes = posterSizes; + } + + public void setProfileSizes(List profileSizes) { + this.profileSizes = profileSizes; + } +// + + /** + * Copy the data from the passed object to this one + * @param config + */ + public void clone(TmdbConfiguration config) { + backdropSizes = config.getBackdropSizes(); + baseUrl = config.getBaseUrl(); + posterSizes = config.getPosterSizes(); + profileSizes = config.getProfileSizes(); + } + + /** + * Check that the poster size is valid + * @param posterSize + * @return + */ + public boolean isValidPosterSize(String posterSize) { + return posterSizes.contains(posterSize); + } + + /** + * Check that the backdrop size is valid + * @param backdropSize + * @return + */ + public boolean isValidBackdropSize(String backdropSize) { + return backdropSizes.contains(backdropSize); + } + + /** + * Check that the profile size is valid + * @param profileSize + * @return + */ + public boolean isValidProfileSize(String profileSize) { + return profileSizes.contains(profileSize); + } + + /** + * Check to see if the size is valid for any of the images types + * @param sizeToCheck + * @return + */ + public boolean isValidSize(String sizeToCheck) { + return (isValidPosterSize(sizeToCheck) || isValidBackdropSize(sizeToCheck) || isValidProfileSize(sizeToCheck)); + } + + /** + * Handle unknown properties and print a message + * @param key + * @param value + */ + @JsonAnySetter + public void handleUnknown(String key, Object value) { + StringBuilder sb = new StringBuilder(); + sb.append("Unknown property: '").append(key); + sb.append("' value: '").append(value).append("'"); + logger.warn(sb.toString()); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("[ImageConfiguration="); + sb.append("[baseUrl=").append(baseUrl); + sb.append("],[posterSizes=").append(posterSizes.toString()); + sb.append("],[backdropSizes=").append(backdropSizes.toString()); + sb.append("],[profileSizes=").append(profileSizes.toString()); + sb.append(("]]")); + return sb.toString(); + } +} diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Trailer.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Trailer.java new file mode 100644 index 000000000..c41fc69b0 --- /dev/null +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Trailer.java @@ -0,0 +1,134 @@ +/* + * Copyright (c) 2004-2012 YAMJ Members + * http://code.google.com/p/moviejukebox/people/list + * + * Web: http://code.google.com/p/moviejukebox/ + * + * This software is licensed under a Creative Commons License + * See this page: http://code.google.com/p/moviejukebox/wiki/License + * + * For any reuse or distribution, you must make clear to others the + * license terms of this work. + */ +package com.moviejukebox.themoviedb.model; + +import org.apache.log4j.Logger; +import org.codehaus.jackson.annotate.JsonAnySetter; + +/** + * + * @author Stuart + */ +public class Trailer { + /* + * Logger + */ + + private static final Logger logger = Logger.getLogger(Trailer.class); + /* + * Website sources + */ + public static final String WEBSITE_YOUTUBE = "youtube"; + public static final String WEBSITE_QUICKTIME = "quicktime"; + /* + * Properties + */ + private String name; + private String size; + private String source; + private String website; // The website of the trailer + + // + public String getName() { + return name; + } + + public String getSize() { + return size; + } + + public String getSource() { + return source; + } + + public String getWebsite() { + return website; + } + // + + // + public void setName(String name) { + this.name = name; + } + + public void setSize(String size) { + this.size = size; + } + + public void setSource(String source) { + this.source = source; + } + + public void setWebsite(String website) { + this.website = website; + } + // + + /** + * Handle unknown properties and print a message + * @param key + * @param value + */ + @JsonAnySetter + public void handleUnknown(String key, Object value) { + StringBuilder sb = new StringBuilder(); + sb.append("Unknown property: '").append(key); + sb.append("' value: '").append(value).append("'"); + logger.warn(sb.toString()); + } + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final Trailer other = (Trailer) obj; + if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) { + return false; + } + if ((this.size == null) ? (other.size != null) : !this.size.equals(other.size)) { + return false; + } + if ((this.source == null) ? (other.source != null) : !this.source.equals(other.source)) { + return false; + } + if ((this.website == null) ? (other.website != null) : !this.website.equals(other.website)) { + return false; + } + return true; + } + + @Override + public int hashCode() { + int hash = 7; + hash = 61 * hash + (this.name != null ? this.name.hashCode() : 0); + hash = 61 * hash + (this.size != null ? this.size.hashCode() : 0); + hash = 61 * hash + (this.source != null ? this.source.hashCode() : 0); + hash = 61 * hash + (this.website != null ? this.website.hashCode() : 0); + return hash; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("[Trailer="); + sb.append("name=").append(name); + sb.append("],[size=").append(size); + sb.append("],[source=").append(source); + sb.append("],[website=").append(website); + sb.append("]]"); + return sb.toString(); + } +} diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Translation.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Translation.java new file mode 100644 index 000000000..f57ceed75 --- /dev/null +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Translation.java @@ -0,0 +1,119 @@ +/* + * Copyright (c) 2004-2012 YAMJ Members + * http://code.google.com/p/moviejukebox/people/list + * + * Web: http://code.google.com/p/moviejukebox/ + * + * This software is licensed under a Creative Commons License + * See this page: http://code.google.com/p/moviejukebox/wiki/License + * + * For any reuse or distribution, you must make clear to others the + * license terms of this work. + */ +package com.moviejukebox.themoviedb.model; + +import org.apache.log4j.Logger; +import org.codehaus.jackson.annotate.JsonAnySetter; +import org.codehaus.jackson.annotate.JsonProperty; + +/** + * + * @author Stuart + */ +public class Translation { + /* + * Logger + */ + + private static final Logger logger = Logger.getLogger(Translation.class); + /* + * Properties + */ + @JsonProperty("english_name") + private String englishName; + @JsonProperty("iso_639_1") + private String isoCode; + @JsonProperty("name") + private String name; + + // + public String getEnglishName() { + return englishName; + } + + public String getIsoCode() { + return isoCode; + } + + public String getName() { + return name; + } + // + + // + public void setEnglishName(String englishName) { + this.englishName = englishName; + } + + public void setIsoCode(String isoCode) { + this.isoCode = isoCode; + } + + public void setName(String name) { + this.name = name; + } + // + + /** + * Handle unknown properties and print a message + * @param key + * @param value + */ + @JsonAnySetter + public void handleUnknown(String key, Object value) { + StringBuilder sb = new StringBuilder(); + sb.append("Unknown property: '").append(key); + sb.append("' value: '").append(value).append("'"); + logger.warn(sb.toString()); + } + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final Translation other = (Translation) obj; + if ((this.englishName == null) ? (other.englishName != null) : !this.englishName.equals(other.englishName)) { + return false; + } + if ((this.isoCode == null) ? (other.isoCode != null) : !this.isoCode.equals(other.isoCode)) { + return false; + } + if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) { + return false; + } + return true; + } + + @Override + public int hashCode() { + int hash = 3; + hash = 29 * hash + (this.englishName != null ? this.englishName.hashCode() : 0); + hash = 29 * hash + (this.isoCode != null ? this.isoCode.hashCode() : 0); + hash = 29 * hash + (this.name != null ? this.name.hashCode() : 0); + return hash; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("[Translation="); + sb.append("[englishName=").append(englishName); + sb.append("],[isoCode=").append(isoCode); + sb.append("],[name=").append(name); + sb.append("]]"); + return sb.toString(); + } +} diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/ApiUrl.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/ApiUrl.java new file mode 100644 index 000000000..566956f48 --- /dev/null +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/ApiUrl.java @@ -0,0 +1,180 @@ +/* + * Copyright (c) 2004-2012 YAMJ Members + * http://code.google.com/p/moviejukebox/people/list + * + * Web: http://code.google.com/p/moviejukebox/ + * + * This software is licensed under a Creative Commons License + * See this page: http://code.google.com/p/moviejukebox/wiki/License + * + * For any reuse or distribution, you must make clear to others the + * license terms of this work. + */ +package com.moviejukebox.themoviedb.tools; + +import com.moviejukebox.themoviedb.TheMovieDB; +import java.io.UnsupportedEncodingException; +import java.net.MalformedURLException; +import java.net.URL; +import java.net.URLEncoder; +import org.apache.commons.lang.StringUtils; +import org.apache.log4j.Logger; + +/** + * The API URL that is used to construct the API call + * + * @author Stuart + */ +public class ApiUrl { + + /* + * Logger + */ + private static final Logger logger = Logger.getLogger(ApiUrl.class); + /* + * Parameter configuration + */ + private static final String DELIMITER_FIRST = "?"; + private static final String DELIMITER_SUBSEQUENT = "&"; + private static final String PARAMETER_API_KEY = "api_key="; // The API Key is always needed and always first + private static final String PARAMETER_QUERY = "query="; + private static final String PARAMETER_LANGUAGE = DELIMITER_SUBSEQUENT + "language="; + private static final String PARAMETER_COUNTRY = DELIMITER_SUBSEQUENT + "country="; + private static final String PARAMETER_PAGE = DELIMITER_SUBSEQUENT + "page="; + private static final String DEFAULT_QUERY = ""; + private static final int DEFAULT_ID = -1; + private static final String DEFAULT_LANGUAGE = ""; + private static final String DEFAULT_COUNTRY = ""; + private static final int DEFAULT_PAGE = -1; + /* + * Properties + */ + private String method; + private String submethod; + + // + public ApiUrl(String method) { + this.method = method; + this.submethod = DEFAULT_QUERY; + } + + public ApiUrl(String method, String submethod) { + this.method = method; + this.submethod = submethod; + } + // + + /** + * Create the full URL with the API. + * + * @param query + * @param tmdbId + * @param language + * @param country + * @param page + * @return + */ + private URL getFullUrl(String query, int tmdbId, String language, String country, int page) { + StringBuilder urlString = new StringBuilder(TheMovieDB.getApiBase()); + + // Get the start of the URL + urlString.append(method); + + // Append the search term if required + if (StringUtils.isNotBlank(query)) { + urlString.append(DELIMITER_FIRST); + urlString.append(PARAMETER_QUERY); + + try { + urlString.append(URLEncoder.encode(query, "UTF-8")); + } catch (UnsupportedEncodingException ex) { + // If we can't encode it, try it raw + urlString.append(query); + } + } + + // Append the ID if provided + if (tmdbId > DEFAULT_ID) { + urlString.append(tmdbId); + } + + // Append the suffix of the API URL + urlString.append(submethod); + + // Append the key information + if (StringUtils.isBlank(query)) { + // This is the first parameter + urlString.append(DELIMITER_FIRST); + } else { + // The first parameter was the query + urlString.append(DELIMITER_SUBSEQUENT); + } + urlString.append(PARAMETER_API_KEY); + urlString.append(TheMovieDB.getApiKey()); + + // Append the language to the URL + if (StringUtils.isNotBlank(language)) { + urlString.append(PARAMETER_LANGUAGE); + urlString.append(language); + } + + // Append the country to the URL + if (StringUtils.isNotBlank(country)) { + urlString.append(PARAMETER_COUNTRY); + urlString.append(country); + } + + // Append the page to the URL + if (page > DEFAULT_PAGE) { + urlString.append(PARAMETER_PAGE); + urlString.append(page); + } + + try { + logger.trace("URL: " + urlString.toString()); + return new URL(urlString.toString()); + } catch (MalformedURLException ex) { + logger.warn("Failed to create URL " + urlString.toString()); + return null; + } + } + + /** + * Create an URL using a query (string) and optional language and page + * @param query + * @param language + * @param page + * @return + */ + public URL getQueryUrl(String query, String language, int page) { + return getFullUrl(query, DEFAULT_ID, language, null, page); + } + + public URL getQueryUrl(String query) { + return getQueryUrl(query, DEFAULT_LANGUAGE, DEFAULT_PAGE); + } + + public URL getQueryUrl(String query, String language) { + return getQueryUrl(query, language, DEFAULT_PAGE); + } + + /** + * Create an URL using the TheMovieDB ID and optional language an country codes + * @param tmdbId + * @param language + * @param country + * @return + */ + public URL getIdUrl(int tmdbId, String language, String country) { + return getFullUrl(DEFAULT_QUERY, tmdbId, language, country, DEFAULT_PAGE); + } + + public URL getIdUrl(int tmdbId) { + return getIdUrl(tmdbId, DEFAULT_LANGUAGE, DEFAULT_COUNTRY); + } + + public URL getIdUrl(int tmdbId, String language) { + return getIdUrl(tmdbId, language, DEFAULT_COUNTRY); + } + +} diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/FilteringLayout.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/FilteringLayout.java new file mode 100644 index 000000000..8774ec2e3 --- /dev/null +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/FilteringLayout.java @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2004-2012 YAMJ Members + * http://code.google.com/p/moviejukebox/people/list + * + * Web: http://code.google.com/p/moviejukebox/ + * + * This software is licensed under a Creative Commons License + * See this page: http://code.google.com/p/moviejukebox/wiki/License + * + * For any reuse or distribution, you must make clear to others the + * license terms of this work. + */ +package com.moviejukebox.themoviedb.tools; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import org.apache.log4j.Logger; +import org.apache.log4j.PatternLayout; +import org.apache.log4j.spi.LoggingEvent; + +/** + * Log4J Filtering routine to remove API keys from the output + * @author Stuart.Boston + * + */ +public class FilteringLayout extends PatternLayout { + private static Pattern API_KEYS = Pattern.compile("DO_NOT_MATCH"); + + public static void addApiKey(String apiKey) { + API_KEYS = Pattern.compile(apiKey); + } + + /** + * Extend the format to remove the API_KEYS from the output + * @param event + * @return + */ + @Override + public String format(LoggingEvent event) { + if (event.getMessage() instanceof String) { + String message = event.getRenderedMessage(); + + Matcher matcher = API_KEYS.matcher(message); + if (matcher.find()) { + String maskedMessage = matcher.replaceAll("[APIKEY]"); + + Throwable throwable = event.getThrowableInformation() != null ? + event.getThrowableInformation().getThrowable() : null; + + LoggingEvent maskedEvent = new LoggingEvent(event.fqnOfCategoryClass, + Logger.getLogger(event.getLoggerName()), event.timeStamp, + event.getLevel(), maskedMessage, throwable); + + return super.format(maskedEvent); + } + } + return super.format(event); + } +} diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperAlternativeTitles.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperAlternativeTitles.java new file mode 100644 index 000000000..a1987b9ee --- /dev/null +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperAlternativeTitles.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2004-2012 YAMJ Members + * http://code.google.com/p/moviejukebox/people/list + * + * Web: http://code.google.com/p/moviejukebox/ + * + * This software is licensed under a Creative Commons License + * See this page: http://code.google.com/p/moviejukebox/wiki/License + * + * For any reuse or distribution, you must make clear to others the + * license terms of this work. + */ +package com.moviejukebox.themoviedb.wrapper; + +import com.moviejukebox.themoviedb.model.AlternativeTitle; +import java.util.List; +import org.apache.log4j.Logger; +import org.codehaus.jackson.annotate.JsonAnySetter; +import org.codehaus.jackson.annotate.JsonProperty; + +/** + * + * @author Stuart + */ +public class WrapperAlternativeTitles { + /* + * Logger + */ + + private static final Logger logger = Logger.getLogger(WrapperAlternativeTitles.class); + /* + * Properties + */ + @JsonProperty("id") + private int id; + @JsonProperty("titles") + private List titles; + + public int getId() { + return id; + } + + public List getTitles() { + return titles; + } + + public void setId(int id) { + this.id = id; + } + + public void setTitles(List titles) { + this.titles = titles; + } + + /** + * Handle unknown properties and print a message + * @param key + * @param value + */ + @JsonAnySetter + public void handleUnknown(String key, Object value) { + StringBuilder sb = new StringBuilder(); + sb.append("Unknown property: '").append(key); + sb.append("' value: '").append(value).append("'"); + logger.warn(sb.toString()); + } +} diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperMovieCasts.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperMovieCasts.java new file mode 100644 index 000000000..abd7580f9 --- /dev/null +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperMovieCasts.java @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2004-2012 YAMJ Members + * http://code.google.com/p/moviejukebox/people/list + * + * Web: http://code.google.com/p/moviejukebox/ + * + * This software is licensed under a Creative Commons License + * See this page: http://code.google.com/p/moviejukebox/wiki/License + * + * For any reuse or distribution, you must make clear to others the + * license terms of this work. + */ +package com.moviejukebox.themoviedb.wrapper; + +import com.moviejukebox.themoviedb.model.PersonCast; +import com.moviejukebox.themoviedb.model.PersonCrew; +import java.util.List; +import org.apache.log4j.Logger; +import org.codehaus.jackson.annotate.JsonAnySetter; +import org.codehaus.jackson.annotate.JsonProperty; + +/** + * + * @author Stuart + */ +public class WrapperMovieCasts { + /* + * Logger + */ + + private static final Logger logger = Logger.getLogger(WrapperMovieCasts.class); + /* + * Properties + */ + @JsonProperty("id") + private int id; + @JsonProperty("cast") + private List cast; + @JsonProperty("crew") + private List crew; + + // + public List getCast() { + return cast; + } + + public List getCrew() { + return crew; + } + + public int getId() { + return id; + } + // + + // + public void setCast(List cast) { + this.cast = cast; + } + + public void setCrew(List crew) { + this.crew = crew; + } + + public void setId(int id) { + this.id = id; + } + // + + /** + * Handle unknown properties and print a message + * @param key + * @param value + */ + @JsonAnySetter + public void handleUnknown(String key, Object value) { + StringBuilder sb = new StringBuilder(); + sb.append("Unknown property: '").append(key); + sb.append("' value: '").append(value).append("'"); + logger.warn(sb.toString()); + } +} diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperMovieImages.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperMovieImages.java new file mode 100644 index 000000000..2c8ae3c15 --- /dev/null +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperMovieImages.java @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2004-2012 YAMJ Members + * http://code.google.com/p/moviejukebox/people/list + * + * Web: http://code.google.com/p/moviejukebox/ + * + * This software is licensed under a Creative Commons License + * See this page: http://code.google.com/p/moviejukebox/wiki/License + * + * For any reuse or distribution, you must make clear to others the + * license terms of this work. + */ +package com.moviejukebox.themoviedb.wrapper; + +import com.moviejukebox.themoviedb.model.Artwork; +import java.util.List; +import org.apache.log4j.Logger; +import org.codehaus.jackson.annotate.JsonAnySetter; +import org.codehaus.jackson.annotate.JsonProperty; + +/** + * + * @author Stuart + */ +public class WrapperMovieImages { + /* + * Logger + */ + + private static final Logger logger = Logger.getLogger(WrapperMovieImages.class); + /* + * Properties + */ + @JsonProperty("id") + private int id; + @JsonProperty("backdrops") + private List backdrops; + @JsonProperty("posters") + private List posters; + + // + public List getBackdrops() { + return backdrops; + } + + public int getId() { + return id; + } + + public List getPosters() { + return posters; + } + // + + // + public void setBackdrops(List backdrops) { + this.backdrops = backdrops; + } + + public void setId(int id) { + this.id = id; + } + + public void setPosters(List posters) { + this.posters = posters; + } + // + + /** + * Handle unknown properties and print a message + * @param key + * @param value + */ + @JsonAnySetter + public void handleUnknown(String key, Object value) { + StringBuilder sb = new StringBuilder(); + sb.append("Unknown property: '").append(key); + sb.append("' value: '").append(value).append("'"); + logger.warn(sb.toString()); + } +} diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperMovieKeywords.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperMovieKeywords.java new file mode 100644 index 000000000..9225248ed --- /dev/null +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperMovieKeywords.java @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2004-2012 YAMJ Members + * http://code.google.com/p/moviejukebox/people/list + * + * Web: http://code.google.com/p/moviejukebox/ + * + * This software is licensed under a Creative Commons License + * See this page: http://code.google.com/p/moviejukebox/wiki/License + * + * For any reuse or distribution, you must make clear to others the + * license terms of this work. + */ +package com.moviejukebox.themoviedb.wrapper; + +import com.moviejukebox.themoviedb.model.Keyword; +import java.util.List; +import org.apache.log4j.Logger; +import org.codehaus.jackson.annotate.JsonAnySetter; +import org.codehaus.jackson.annotate.JsonProperty; + +/** + * + * @author Stuart + */ +public class WrapperMovieKeywords { + /* + * Logger + */ + + private static final Logger logger = Logger.getLogger(WrapperMovieKeywords.class); + /* + * Properties + */ + @JsonProperty("id") + private int id; + @JsonProperty("keywords") + private List keywords; + + // + public int getId() { + return id; + } + + public List getKeywords() { + return keywords; + } + // + + // + public void setId(int id) { + this.id = id; + } + + public void setKeywords(List keywords) { + this.keywords = keywords; + } + // + + /** + * Handle unknown properties and print a message + * @param key + * @param value + */ + @JsonAnySetter + public void handleUnknown(String key, Object value) { + StringBuilder sb = new StringBuilder(); + sb.append("Unknown property: '").append(key); + sb.append("' value: '").append(value).append("'"); + logger.warn(sb.toString()); + } +} diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperReleaseInfo.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperReleaseInfo.java new file mode 100644 index 000000000..195168111 --- /dev/null +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperReleaseInfo.java @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2004-2012 YAMJ Members + * http://code.google.com/p/moviejukebox/people/list + * + * Web: http://code.google.com/p/moviejukebox/ + * + * This software is licensed under a Creative Commons License + * See this page: http://code.google.com/p/moviejukebox/wiki/License + * + * For any reuse or distribution, you must make clear to others the + * license terms of this work. + */ +package com.moviejukebox.themoviedb.wrapper; + +import com.moviejukebox.themoviedb.model.ReleaseInfo; +import java.util.List; +import org.apache.log4j.Logger; +import org.codehaus.jackson.annotate.JsonAnySetter; +import org.codehaus.jackson.annotate.JsonProperty; + +/** + * + * @author Stuart + */ +public class WrapperReleaseInfo { + /* + * Logger + */ + + private static final Logger logger = Logger.getLogger(WrapperReleaseInfo.class); + /* + * Properties + */ + @JsonProperty("id") + private int id; + @JsonProperty("countries") + private List countries; + + // + public List getCountries() { + return countries; + } + + public int getId() { + return id; + } + // + + // + public void setCountries(List countries) { + this.countries = countries; + } + + public void setId(int id) { + this.id = id; + } + // + + /** + * Handle unknown properties and print a message + * @param key + * @param value + */ + @JsonAnySetter + public void handleUnknown(String key, Object value) { + StringBuilder sb = new StringBuilder(); + sb.append("Unknown property: '").append(key); + sb.append("' value: '").append(value).append("'"); + logger.warn(sb.toString()); + } +} diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperResultList.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperResultList.java new file mode 100644 index 000000000..51ac65507 --- /dev/null +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperResultList.java @@ -0,0 +1,101 @@ +/* + * Copyright (c) 2004-2012 YAMJ Members + * http://code.google.com/p/moviejukebox/people/list + * + * Web: http://code.google.com/p/moviejukebox/ + * + * This software is licensed under a Creative Commons License + * See this page: http://code.google.com/p/moviejukebox/wiki/License + * + * For any reuse or distribution, you must make clear to others the + * license terms of this work. + */ +package com.moviejukebox.themoviedb.wrapper; + +import com.moviejukebox.themoviedb.model.MovieDB; +import java.util.List; +import org.apache.log4j.Logger; +import org.codehaus.jackson.annotate.JsonAnySetter; +import org.codehaus.jackson.annotate.JsonProperty; + +/** + * + * @author stuart.boston + */ +public class WrapperResultList { + /* + * Logger + */ + + private static final Logger logger = Logger.getLogger(WrapperResultList.class); + /* + * Properties + */ + @JsonProperty("page") + int page; + @JsonProperty("results") + List results; + @JsonProperty("total_pages") + int totalPages; + @JsonProperty("total_results") + int totalResults; + + // + public int getPage() { + return page; + } + + public List getResults() { + return results; + } + + public int getTotalPages() { + return totalPages; + } + + public int getTotalResults() { + return totalResults; + } + // + + // + public void setPage(int page) { + this.page = page; + } + + public void setResults(List results) { + this.results = results; + } + + public void setTotalPages(int totalPages) { + this.totalPages = totalPages; + } + + public void setTotalResults(int totalResults) { + this.totalResults = totalResults; + } + // + /** + * Handle unknown properties and print a message + * @param key + * @param value + */ + @JsonAnySetter + public void handleUnknown(String key, Object value) { + StringBuilder sb = new StringBuilder(); + sb.append("Unknown property: '").append(key); + sb.append("' value: '").append(value).append("'"); + logger.warn(sb.toString()); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("[ResultList=["); + sb.append("[page=").append(page); + sb.append("],[pageResults=").append(results.size()); + sb.append("],[totalPages=").append(totalPages); + sb.append("],[totalResults=").append(totalResults); + sb.append("]]"); + return sb.toString(); + } +} diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperTrailers.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperTrailers.java new file mode 100644 index 000000000..dd36047e8 --- /dev/null +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperTrailers.java @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2004-2012 YAMJ Members + * http://code.google.com/p/moviejukebox/people/list + * + * Web: http://code.google.com/p/moviejukebox/ + * + * This software is licensed under a Creative Commons License + * See this page: http://code.google.com/p/moviejukebox/wiki/License + * + * For any reuse or distribution, you must make clear to others the + * license terms of this work. + */ +package com.moviejukebox.themoviedb.wrapper; + +import com.moviejukebox.themoviedb.model.Trailer; +import java.util.List; +import org.apache.log4j.Logger; +import org.codehaus.jackson.annotate.JsonAnySetter; +import org.codehaus.jackson.annotate.JsonProperty; + +/** + * + * @author Stuart + */ +public class WrapperTrailers { + /* + * Logger + */ + + private static final Logger logger = Logger.getLogger(WrapperTrailers.class); + /* + * Properties + */ + @JsonProperty("id") + private int id; + @JsonProperty("quicktime") + private List quicktime; + @JsonProperty("youtube") + private List youtube; + + // + public int getId() { + return id; + } + + public List getQuicktime() { + return quicktime; + } + + public List getYoutube() { + return youtube; + } + // + + // + public void setId(int id) { + this.id = id; + } + + public void setQuicktime(List quicktime) { + this.quicktime = quicktime; + } + + public void setYoutube(List youtube) { + this.youtube = youtube; + } + // + + /** + * Handle unknown properties and print a message + * @param key + * @param value + */ + @JsonAnySetter + public void handleUnknown(String key, Object value) { + StringBuilder sb = new StringBuilder(); + sb.append("Unknown property: '").append(key); + sb.append("' value: '").append(value).append("'"); + logger.warn(sb.toString()); + } +} diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperTranslations.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperTranslations.java new file mode 100644 index 000000000..dc3a995cc --- /dev/null +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperTranslations.java @@ -0,0 +1,68 @@ +/* + * Copyright (c) 2004-2012 YAMJ Members + * http://code.google.com/p/moviejukebox/people/list + * + * Web: http://code.google.com/p/moviejukebox/ + * + * This software is licensed under a Creative Commons License + * See this page: http://code.google.com/p/moviejukebox/wiki/License + * + * For any reuse or distribution, you must make clear to others the + * license terms of this work. + */ +package com.moviejukebox.themoviedb.wrapper; + +import com.moviejukebox.themoviedb.model.Translation; +import java.util.List; +import org.apache.log4j.Logger; +import org.codehaus.jackson.annotate.JsonAnySetter; + +/** + * + * @author Stuart + */ +public class WrapperTranslations { + /* + * Logger + */ + + private static final Logger logger = Logger.getLogger(WrapperTranslations.class); + /* + * Properties + */ + private int id; + private List translations; + + // + public void setId(int id) { + this.id = id; + } + + public void setTranslations(List translations) { + this.translations = translations; + } + // + + // + public int getId() { + return id; + } + + public List getTranslations() { + return translations; + } + // + + /** + * Handle unknown properties and print a message + * @param key + * @param value + */ + @JsonAnySetter + public void handleUnknown(String key, Object value) { + StringBuilder sb = new StringBuilder(); + sb.append("Unknown property: '").append(key); + sb.append("' value: '").append(value).append("'"); + logger.warn(sb.toString()); + } +} diff --git a/themoviedbapi/src/main/resources/log4j.properties b/themoviedbapi/src/main/resources/log4j.properties new file mode 100644 index 000000000..26b472d1e --- /dev/null +++ b/themoviedbapi/src/main/resources/log4j.properties @@ -0,0 +1,7 @@ +log4j.rootLogger=DEBUG, CONSOLE +log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender +log4j.appender.CONSOLE.layout=com.moviejukebox.themoviedb.tools.FilteringLayout +#log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout +log4j.appender.CONSOLE.layout.ConversionPattern=[TheMovieDB API-%C{1}] %m%n +#log4j.appender.CONSOLE.Threshold=DEBUG +log4j.appender.CONSOLE.Encoding=UTF-8 diff --git a/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDBTest.java b/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDBTest.java new file mode 100644 index 000000000..f03cbedba --- /dev/null +++ b/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDBTest.java @@ -0,0 +1,220 @@ +/* + * Copyright (c) 2004-2012 YAMJ Members + * http://code.google.com/p/moviejukebox/people/list + * + * Web: http://code.google.com/p/moviejukebox/ + * + * This software is licensed under a Creative Commons License + * See this page: http://code.google.com/p/moviejukebox/wiki/License + * + * For any reuse or distribution, you must make clear to others the + * license terms of this work. + */ +package com.moviejukebox.themoviedb; + +import com.moviejukebox.themoviedb.model.*; +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.util.List; +import org.apache.commons.lang.StringUtils; +import org.apache.log4j.Logger; +import static org.junit.Assert.*; +import org.junit.*; + +/** + * Test cases for TheMovieDB API + * + * @author stuart.boston + */ +public class TheMovieDBTest { + + private static final Logger logger = Logger.getLogger(TheMovieDBTest.class); + private static final String API_KEY = "5a1a77e2eba8984804586122754f969f"; + private static TheMovieDB tmdb; + /* + * Test data + */ + private static final int ID_BLADE_RUNNER = 78; + private static final int ID_STAR_WARS_COLLECTION = 10; + + public TheMovieDBTest() throws IOException { + tmdb = new TheMovieDB(API_KEY); + } + + @BeforeClass + public static void setUpClass() throws Exception { + } + + @AfterClass + public static void tearDownClass() throws Exception { + } + + @Before + public void setUp() { + } + + @After + public void tearDown() { + } + + /** + * Test of getConfiguration method, of class TheMovieDB. + */ + @Test + public void testConfiguration() throws IOException { + logger.info("Test Configuration"); + + TmdbConfiguration tmdbConfig = tmdb.getConfiguration(); + assertNotNull("Configuration failed", tmdbConfig); + assertTrue("No base URL", StringUtils.isNotBlank(tmdbConfig.getBaseUrl())); + assertTrue("No backdrop sizes", tmdbConfig.getBackdropSizes().size() > 0); + assertTrue("No poster sizes", tmdbConfig.getPosterSizes().size() > 0); + assertTrue("No profile sizes", tmdbConfig.getProfileSizes().size() > 0); + logger.info(tmdbConfig.toString()); + } + + /** + * Test of searchMovie method, of class TheMovieDB. + */ + @Test + public void testSearchMovie() throws UnsupportedEncodingException { + logger.info("searchMovie"); + + // Try a movie with less than 1 page of results + List movieList = tmdb.searchMovie("Blade Runner", "", true); + assertTrue("No movies found, should be at least 1", movieList.size() > 0); + + // Try a russian langugage movie + movieList = tmdb.searchMovie("О чём говорят мужчины", "ru", true); + assertTrue("No movies found, should be at least 1", movieList.size() > 0); + + // Try a movie with more than 20 results + movieList = tmdb.searchMovie("Star Wars", "en", false); + assertTrue("Not enough movies found, should be 20", movieList.size() == 20); + } + + /** + * Test of getMovieInfo method, of class TheMovieDB. + */ + @Test + public void testGetMovieInfo() { + logger.info("getMovieInfo"); + String language = "en"; + MovieDB result = tmdb.getMovieInfo(ID_BLADE_RUNNER, language); + assertEquals("Incorrect movie information", "Blade Runner", result.getOriginalTitle()); + } + + /** + * Test of getMovieAlternativeTitles method, of class TheMovieDB. + */ + @Test + public void testGetMovieAlternativeTitles() { + logger.info("getMovieAlternativeTitles"); + String country = ""; + List results = tmdb.getMovieAlternativeTitles(ID_BLADE_RUNNER, country); + assertTrue("No alternative titles found", results.size() > 0); + + country = "US"; + results = tmdb.getMovieAlternativeTitles(ID_BLADE_RUNNER, country); + assertTrue("No alternative titles found", results.size() > 0); + + } + + /** + * Test of getMovieCasts method, of class TheMovieDB. + */ + @Test + public void testGetMovieCasts() { + logger.info("getMovieCasts"); + List people = tmdb.getMovieCasts(ID_BLADE_RUNNER); + assertTrue("No cast information", people.size() > 0); + + String name1 = "Harrison Ford"; + String name2 = "Charles Knode"; + boolean foundName1 = Boolean.FALSE; + boolean foundName2 = Boolean.FALSE; + + for (Person person : people) { + if (!foundName1 && person.getName().equalsIgnoreCase(name1)) { + foundName1 = Boolean.TRUE; + } + + if (!foundName2 && person.getName().equalsIgnoreCase(name2)) { + foundName2 = Boolean.TRUE; + } + } + assertTrue("Couldn't find " + name1, foundName1); + assertTrue("Couldn't find " + name2, foundName2); + + } + + /** + * Test of getMovieImages method, of class TheMovieDB. + */ + @Test + public void testGetMovieImages() { + logger.info("getMovieImages"); + String language = ""; + List result = tmdb.getMovieImages(ID_BLADE_RUNNER, language); + assertFalse("No artwork found", result.isEmpty()); + } + + /** + * Test of getMovieKeywords method, of class TheMovieDB. + */ + @Test + public void testGetMovieKeywords() { + logger.info("getMovieKeywords"); + List result = tmdb.getMovieKeywords(ID_BLADE_RUNNER); + assertFalse("No keywords found", result.isEmpty()); + } + + /** + * Test of getMovieReleaseInfo method, of class TheMovieDB. + */ + @Test + public void testGetMovieReleaseInfo() { + logger.info("getMovieReleaseInfo"); + List result = tmdb.getMovieReleaseInfo(ID_BLADE_RUNNER, ""); + assertFalse("Release information missing", result.isEmpty()); + } + + /** + * Test of getMovieTrailers method, of class TheMovieDB. + */ + @Test + public void testGetMovieTrailers() { + logger.info("getMovieTrailers"); + List result = tmdb.getMovieTrailers(ID_BLADE_RUNNER, ""); + assertFalse("Movie trailers missing", result.isEmpty()); + } + + /** + * Test of getMovieTranslations method, of class TheMovieDB. + */ + @Test + public void testGetMovieTranslations() { + logger.info("getMovieTranslations"); + List result = tmdb.getMovieTranslations(ID_BLADE_RUNNER); + assertFalse("No translations found", result.isEmpty()); + } + + /** + * Test of getCollectionInfo method, of class TheMovieDB. + */ + @Test + public void testGetCollectionInfo() { + logger.info("getCollectionInfo"); + String language = ""; + CollectionInfo result = tmdb.getCollectionInfo(ID_STAR_WARS_COLLECTION, language); + assertFalse("No collection information", result.getParts().isEmpty()); + } + + @Test + public void testCreateImageUrl() { + logger.info("createImageUrl"); + MovieDB movie = tmdb.getMovieInfo(ID_BLADE_RUNNER, ""); + String result = tmdb.createImageUrl(movie.getPosterPath(), "original").toString(); + assertTrue("Error compiling image URL", !result.isEmpty()); + } +} From f69915b0030dd31cbbb3e8e47474e532dda59a88 Mon Sep 17 00:00:00 2001 From: Omertron Date: Wed, 25 Jan 2012 15:55:43 +0000 Subject: [PATCH 097/207] Fix some sonar issues --- .../moviejukebox/themoviedb/TheMovieDB.java | 36 +++++++++---------- .../themoviedb/model/AlternativeTitle.java | 4 +-- .../themoviedb/model/Artwork.java | 4 +-- .../themoviedb/model/Collection.java | 4 +-- .../themoviedb/model/CollectionInfo.java | 4 +-- .../moviejukebox/themoviedb/model/Genre.java | 4 +-- .../themoviedb/model/Keyword.java | 4 +-- .../themoviedb/model/Language.java | 4 +-- .../themoviedb/model/MovieDB.java | 4 +-- .../moviejukebox/themoviedb/model/Person.java | 4 +-- .../themoviedb/model/PersonCast.java | 4 +-- .../themoviedb/model/PersonCrew.java | 4 +-- .../themoviedb/model/ProductionCompany.java | 4 +-- .../themoviedb/model/ProductionCountry.java | 4 +-- .../themoviedb/model/ReleaseInfo.java | 4 +-- .../themoviedb/model/StatusCode.java | 8 ++--- .../themoviedb/model/TmdbConfiguration.java | 4 +-- .../themoviedb/model/Trailer.java | 4 +-- .../themoviedb/model/Translation.java | 4 +-- .../moviejukebox/themoviedb/tools/ApiUrl.java | 6 ++-- .../themoviedb/tools/FilteringLayout.java | 6 ++-- .../wrapper/WrapperAlternativeTitles.java | 4 +-- .../themoviedb/wrapper/WrapperMovieCasts.java | 4 +-- .../wrapper/WrapperMovieImages.java | 4 +-- .../wrapper/WrapperMovieKeywords.java | 4 +-- .../wrapper/WrapperReleaseInfo.java | 4 +-- .../themoviedb/wrapper/WrapperResultList.java | 13 +++---- .../themoviedb/wrapper/WrapperTrailers.java | 4 +-- .../wrapper/WrapperTranslations.java | 4 +-- .../themoviedb/TheMovieDBTest.java | 28 +++++++-------- 30 files changed, 96 insertions(+), 97 deletions(-) diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDB.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDB.java index 1fb78a653..0c711e869 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDB.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDB.java @@ -33,8 +33,8 @@ import org.codehaus.jackson.map.ObjectMapper; */ public class TheMovieDB { - private static final Logger logger = Logger.getLogger(TheMovieDB.class); - private static String API_KEY; + private static final Logger LOGGER = Logger.getLogger(TheMovieDB.class); + private static String apiKey; private static TmdbConfiguration tmdbConfig; /* * TheMovieDB API URLs @@ -66,7 +66,7 @@ public class TheMovieDB { private static ObjectMapper mapper = new ObjectMapper(); public TheMovieDB(String apiKey) throws IOException { - TheMovieDB.API_KEY = apiKey; + TheMovieDB.apiKey = apiKey; URL configUrl = TMDB_CONFIG_URL.getQueryUrl(""); mapper.configure(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE, true); tmdbConfig = mapper.readValue(configUrl, TmdbConfiguration.class); @@ -75,7 +75,7 @@ public class TheMovieDB { } public static String getApiKey() { - return API_KEY; + return apiKey; } public static String getApiBase() { @@ -94,7 +94,7 @@ public class TheMovieDB { WrapperResultList resultList = mapper.readValue(url, WrapperResultList.class); return resultList.getResults(); } catch (IOException ex) { - logger.warn("Failed to find movie: " + ex.getMessage()); + LOGGER.warn("Failed to find movie: " + ex.getMessage()); return new ArrayList(); } } @@ -109,10 +109,9 @@ public class TheMovieDB { public MovieDB getMovieInfo(int movieId, String language) { try { URL url = TMDB_MOVIE_INFO.getIdUrl(movieId, language); - MovieDB movieDb = mapper.readValue(url, MovieDB.class); - return movieDb; + return mapper.readValue(url, MovieDB.class); } catch (IOException ex) { - logger.warn("Failed to get movie info: " + ex.getMessage()); + LOGGER.warn("Failed to get movie info: " + ex.getMessage()); } return new MovieDB(); } @@ -129,7 +128,7 @@ public class TheMovieDB { WrapperAlternativeTitles at = mapper.readValue(url, WrapperAlternativeTitles.class); return at.getTitles(); } catch (IOException ex) { - logger.warn("Failed to get movie alternative titles: " + ex.getMessage()); + LOGGER.warn("Failed to get movie alternative titles: " + ex.getMessage()); } return new ArrayList(); } @@ -162,7 +161,7 @@ public class TheMovieDB { return people; } catch (IOException ex) { - logger.warn("Failed to get movie casts: " + ex.getMessage()); + LOGGER.warn("Failed to get movie casts: " + ex.getMessage()); } return people; } @@ -193,7 +192,7 @@ public class TheMovieDB { return artwork; } catch (IOException ex) { - logger.warn("Failed to get movie images: " + ex.getMessage()); + LOGGER.warn("Failed to get movie images: " + ex.getMessage()); } return artwork; } @@ -210,7 +209,7 @@ public class TheMovieDB { WrapperMovieKeywords mk = mapper.readValue(url, WrapperMovieKeywords.class); return mk.getKeywords(); } catch (IOException ex) { - logger.warn("Failed to get movie keywords: " + ex.getMessage()); + LOGGER.warn("Failed to get movie keywords: " + ex.getMessage()); } return new ArrayList(); } @@ -227,7 +226,7 @@ public class TheMovieDB { WrapperReleaseInfo ri = mapper.readValue(url, WrapperReleaseInfo.class); return ri.getCountries(); } catch (IOException ex) { - logger.warn("Failed to get movie release information: " + ex.getMessage()); + LOGGER.warn("Failed to get movie release information: " + ex.getMessage()); } return new ArrayList(); } @@ -258,7 +257,7 @@ public class TheMovieDB { } return trailers; } catch (IOException ex) { - logger.warn("Failed to get movie trailers: " + ex.getMessage()); + LOGGER.warn("Failed to get movie trailers: " + ex.getMessage()); } return trailers; } @@ -274,7 +273,7 @@ public class TheMovieDB { WrapperTranslations wt = mapper.readValue(url, WrapperTranslations.class); return wt.getTranslations(); } catch (IOException ex) { - logger.warn("Failed to get movie tranlations: " + ex.getMessage()); + LOGGER.warn("Failed to get movie tranlations: " + ex.getMessage()); } return new ArrayList(); } @@ -289,8 +288,7 @@ public class TheMovieDB { public CollectionInfo getCollectionInfo(int movieId, String language) { try { URL url = TMDB_COLLECTION_INFO.getIdUrl(movieId); - CollectionInfo col = mapper.readValue(url, CollectionInfo.class); - return col; + return mapper.readValue(url, CollectionInfo.class); } catch (IOException ex) { return new CollectionInfo(); } @@ -317,7 +315,7 @@ public class TheMovieDB { if (!tmdbConfig.isValidSize(requiredSize)) { sb = new StringBuilder(); sb.append(" - Invalid size requested: ").append(requiredSize); - logger.warn(sb.toString()); + LOGGER.warn(sb.toString()); return returnUrl; } @@ -327,7 +325,7 @@ public class TheMovieDB { sb.append(imagePath); returnUrl = new URL(sb.toString()); } catch (MalformedURLException ex) { - logger.warn("Failed to create image URL: " + ex.getMessage()); + LOGGER.warn("Failed to create image URL: " + ex.getMessage()); } return returnUrl; diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/AlternativeTitle.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/AlternativeTitle.java index 785d863e7..1ae6dc978 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/AlternativeTitle.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/AlternativeTitle.java @@ -25,7 +25,7 @@ public class AlternativeTitle { /* * Logger */ - private static final Logger logger = Logger.getLogger(AlternativeTitle.class); + private static final Logger LOGGER = Logger.getLogger(AlternativeTitle.class); /* * Properties */ @@ -64,7 +64,7 @@ public class AlternativeTitle { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - logger.warn(sb.toString()); + LOGGER.warn(sb.toString()); } @Override diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Artwork.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Artwork.java index 89e209bf8..981d25de7 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Artwork.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Artwork.java @@ -25,7 +25,7 @@ public class Artwork { /* * Logger */ - private static final Logger logger = Logger.getLogger(Artwork.class); + private static final Logger LOGGER = Logger.getLogger(Artwork.class); /* * Properties */ @@ -123,7 +123,7 @@ public class Artwork { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - logger.warn(sb.toString()); + LOGGER.warn(sb.toString()); } @Override diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Collection.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Collection.java index 778c029fb..969710a71 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Collection.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Collection.java @@ -28,7 +28,7 @@ public class Collection { /* * Logger */ - private static final Logger logger = Logger.getLogger(Collection.class); + private static final Logger LOGGER = Logger.getLogger(Collection.class); /* * Properties */ @@ -113,7 +113,7 @@ public class Collection { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - logger.warn(sb.toString()); + LOGGER.warn(sb.toString()); } @Override diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/CollectionInfo.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/CollectionInfo.java index ec7ed245b..fa6bd0a03 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/CollectionInfo.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/CollectionInfo.java @@ -27,7 +27,7 @@ public class CollectionInfo { /* * Logger */ - private static final Logger logger = Logger.getLogger(CollectionInfo.class); + private static final Logger LOGGER = Logger.getLogger(CollectionInfo.class); /* * Properties */ @@ -96,7 +96,7 @@ public class CollectionInfo { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - logger.warn(sb.toString()); + LOGGER.warn(sb.toString()); } @Override diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Genre.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Genre.java index 9f261fe83..c0454277e 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Genre.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Genre.java @@ -27,7 +27,7 @@ public class Genre { /* * Logger */ - private static final Logger logger = Logger.getLogger(Genre.class); + private static final Logger LOGGER = Logger.getLogger(Genre.class); /* * Properties */ @@ -66,7 +66,7 @@ public class Genre { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - logger.warn(sb.toString()); + LOGGER.warn(sb.toString()); } @Override diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Keyword.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Keyword.java index e53c02542..7de0e3ea9 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Keyword.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Keyword.java @@ -27,7 +27,7 @@ public class Keyword { /* * Logger */ - private static final Logger logger = Logger.getLogger(Keyword.class); + private static final Logger LOGGER = Logger.getLogger(Keyword.class); /* * Properties */ @@ -66,7 +66,7 @@ public class Keyword { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - logger.warn(sb.toString()); + LOGGER.warn(sb.toString()); } @Override diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Language.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Language.java index 4238ee0df..012601e85 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Language.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Language.java @@ -27,7 +27,7 @@ public class Language { /* * Logger */ - private static final Logger logger = Logger.getLogger(Language.class); + private static final Logger LOGGER = Logger.getLogger(Language.class); /* * Properties */ @@ -66,7 +66,7 @@ public class Language { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - logger.warn(sb.toString()); + LOGGER.warn(sb.toString()); } @Override diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/MovieDB.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/MovieDB.java index 98b367228..2ae8c93bb 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/MovieDB.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/MovieDB.java @@ -26,7 +26,7 @@ public class MovieDB { /* * Logger */ - private static final Logger logger = Logger.getLogger(MovieDB.class); + private static final Logger LOGGER = Logger.getLogger(MovieDB.class); /* * Properties */ @@ -265,7 +265,7 @@ public class MovieDB { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - logger.warn(sb.toString()); + LOGGER.warn(sb.toString()); } // diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Person.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Person.java index 97604115f..a26b34845 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Person.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Person.java @@ -24,7 +24,7 @@ public class Person { * Logger */ - private static final Logger logger = Logger.getLogger(Person.class); + private static final Logger LOGGER = Logger.getLogger(Person.class); /* * Static fields for default cast information @@ -164,7 +164,7 @@ public class Person { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - logger.warn(sb.toString()); + LOGGER.warn(sb.toString()); } @Override diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/PersonCast.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/PersonCast.java index 9eb2e5968..2d8ae21cf 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/PersonCast.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/PersonCast.java @@ -25,7 +25,7 @@ public class PersonCast { * Logger */ - private static final Logger logger = Logger.getLogger(PersonCast.class); + private static final Logger LOGGER = Logger.getLogger(PersonCast.class); /* * Properties */ @@ -94,7 +94,7 @@ public class PersonCast { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - logger.warn(sb.toString()); + LOGGER.warn(sb.toString()); } @Override diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/PersonCrew.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/PersonCrew.java index 29d58cd6a..117ec79b2 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/PersonCrew.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/PersonCrew.java @@ -25,7 +25,7 @@ public class PersonCrew { * Logger */ - private static final Logger logger = Logger.getLogger(PersonCrew.class); + private static final Logger LOGGER = Logger.getLogger(PersonCrew.class); /* * Properties */ @@ -94,7 +94,7 @@ public class PersonCrew { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - logger.warn(sb.toString()); + LOGGER.warn(sb.toString()); } @Override diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/ProductionCompany.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/ProductionCompany.java index 978b1038c..85fae5795 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/ProductionCompany.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/ProductionCompany.java @@ -27,7 +27,7 @@ public class ProductionCompany { * Logger */ - private static final Logger logger = Logger.getLogger(ProductionCompany.class); + private static final Logger LOGGER = Logger.getLogger(ProductionCompany.class); /* * Properties */ @@ -66,7 +66,7 @@ public class ProductionCompany { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - logger.warn(sb.toString()); + LOGGER.warn(sb.toString()); } @Override diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/ProductionCountry.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/ProductionCountry.java index 2b3617e69..cc0556466 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/ProductionCountry.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/ProductionCountry.java @@ -27,7 +27,7 @@ public class ProductionCountry { * Logger */ - private static final Logger logger = Logger.getLogger(ProductionCountry.class); + private static final Logger LOGGER = Logger.getLogger(ProductionCountry.class); /* * Properties */ @@ -66,7 +66,7 @@ public class ProductionCountry { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - logger.warn(sb.toString()); + LOGGER.warn(sb.toString()); } @Override diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/ReleaseInfo.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/ReleaseInfo.java index e46e6fb21..5e4735de9 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/ReleaseInfo.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/ReleaseInfo.java @@ -25,7 +25,7 @@ public class ReleaseInfo { * Logger */ - private static final Logger logger = Logger.getLogger(ReleaseInfo.class); + private static final Logger LOGGER = Logger.getLogger(ReleaseInfo.class); /* * Properties */ @@ -74,7 +74,7 @@ public class ReleaseInfo { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - logger.warn(sb.toString()); + LOGGER.warn(sb.toString()); } @Override diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/StatusCode.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/StatusCode.java index 3a59038ee..bfad70828 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/StatusCode.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/StatusCode.java @@ -25,14 +25,14 @@ public class StatusCode { * Logger */ - private static final Logger logger = Logger.getLogger(StatusCode.class); + private static final Logger LOGGER = Logger.getLogger(StatusCode.class); /* * Properties */ @JsonProperty("status_code") - int statusCode; + private int statusCode; @JsonProperty("status_message") - String statusMessage; + private String statusMessage; // public int getStatusCode() { @@ -64,7 +64,7 @@ public class StatusCode { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - logger.warn(sb.toString()); + LOGGER.warn(sb.toString()); } @Override diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/TmdbConfiguration.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/TmdbConfiguration.java index 4ce101f2b..7a25d1684 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/TmdbConfiguration.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/TmdbConfiguration.java @@ -28,7 +28,7 @@ public class TmdbConfiguration { /* * Logger */ - private static final Logger logger = Logger.getLogger(TmdbConfiguration.class); + private static final Logger LOGGER = Logger.getLogger(TmdbConfiguration.class); /* * Properties */ @@ -134,7 +134,7 @@ public class TmdbConfiguration { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - logger.warn(sb.toString()); + LOGGER.warn(sb.toString()); } @Override diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Trailer.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Trailer.java index c41fc69b0..dfa07f5e3 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Trailer.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Trailer.java @@ -24,7 +24,7 @@ public class Trailer { * Logger */ - private static final Logger logger = Logger.getLogger(Trailer.class); + private static final Logger LOGGER = Logger.getLogger(Trailer.class); /* * Website sources */ @@ -84,7 +84,7 @@ public class Trailer { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - logger.warn(sb.toString()); + LOGGER.warn(sb.toString()); } @Override diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Translation.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Translation.java index f57ceed75..7f1af5c0c 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Translation.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Translation.java @@ -25,7 +25,7 @@ public class Translation { * Logger */ - private static final Logger logger = Logger.getLogger(Translation.class); + private static final Logger LOGGER = Logger.getLogger(Translation.class); /* * Properties */ @@ -74,7 +74,7 @@ public class Translation { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - logger.warn(sb.toString()); + LOGGER.warn(sb.toString()); } @Override diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/ApiUrl.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/ApiUrl.java index 566956f48..0b4b3e1a3 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/ApiUrl.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/ApiUrl.java @@ -30,7 +30,7 @@ public class ApiUrl { /* * Logger */ - private static final Logger logger = Logger.getLogger(ApiUrl.class); + private static final Logger LOGGER = Logger.getLogger(ApiUrl.class); /* * Parameter configuration */ @@ -131,10 +131,10 @@ public class ApiUrl { } try { - logger.trace("URL: " + urlString.toString()); + LOGGER.trace("URL: " + urlString.toString()); return new URL(urlString.toString()); } catch (MalformedURLException ex) { - logger.warn("Failed to create URL " + urlString.toString()); + LOGGER.warn("Failed to create URL " + urlString.toString()); return null; } } diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/FilteringLayout.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/FilteringLayout.java index 8774ec2e3..f63079ea1 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/FilteringLayout.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/FilteringLayout.java @@ -24,10 +24,10 @@ import org.apache.log4j.spi.LoggingEvent; * */ public class FilteringLayout extends PatternLayout { - private static Pattern API_KEYS = Pattern.compile("DO_NOT_MATCH"); + private static Pattern apiKeys = Pattern.compile("DO_NOT_MATCH"); public static void addApiKey(String apiKey) { - API_KEYS = Pattern.compile(apiKey); + apiKeys = Pattern.compile(apiKey); } /** @@ -40,7 +40,7 @@ public class FilteringLayout extends PatternLayout { if (event.getMessage() instanceof String) { String message = event.getRenderedMessage(); - Matcher matcher = API_KEYS.matcher(message); + Matcher matcher = apiKeys.matcher(message); if (matcher.find()) { String maskedMessage = matcher.replaceAll("[APIKEY]"); diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperAlternativeTitles.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperAlternativeTitles.java index a1987b9ee..fd0669dbd 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperAlternativeTitles.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperAlternativeTitles.java @@ -27,7 +27,7 @@ public class WrapperAlternativeTitles { * Logger */ - private static final Logger logger = Logger.getLogger(WrapperAlternativeTitles.class); + private static final Logger LOGGER = Logger.getLogger(WrapperAlternativeTitles.class); /* * Properties */ @@ -62,6 +62,6 @@ public class WrapperAlternativeTitles { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - logger.warn(sb.toString()); + LOGGER.warn(sb.toString()); } } diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperMovieCasts.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperMovieCasts.java index abd7580f9..763918df5 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperMovieCasts.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperMovieCasts.java @@ -28,7 +28,7 @@ public class WrapperMovieCasts { * Logger */ - private static final Logger logger = Logger.getLogger(WrapperMovieCasts.class); + private static final Logger LOGGER = Logger.getLogger(WrapperMovieCasts.class); /* * Properties */ @@ -77,6 +77,6 @@ public class WrapperMovieCasts { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - logger.warn(sb.toString()); + LOGGER.warn(sb.toString()); } } diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperMovieImages.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperMovieImages.java index 2c8ae3c15..3d163d4dc 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperMovieImages.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperMovieImages.java @@ -27,7 +27,7 @@ public class WrapperMovieImages { * Logger */ - private static final Logger logger = Logger.getLogger(WrapperMovieImages.class); + private static final Logger LOGGER = Logger.getLogger(WrapperMovieImages.class); /* * Properties */ @@ -76,6 +76,6 @@ public class WrapperMovieImages { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - logger.warn(sb.toString()); + LOGGER.warn(sb.toString()); } } diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperMovieKeywords.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperMovieKeywords.java index 9225248ed..df6c10f83 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperMovieKeywords.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperMovieKeywords.java @@ -27,7 +27,7 @@ public class WrapperMovieKeywords { * Logger */ - private static final Logger logger = Logger.getLogger(WrapperMovieKeywords.class); + private static final Logger LOGGER = Logger.getLogger(WrapperMovieKeywords.class); /* * Properties */ @@ -66,6 +66,6 @@ public class WrapperMovieKeywords { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - logger.warn(sb.toString()); + LOGGER.warn(sb.toString()); } } diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperReleaseInfo.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperReleaseInfo.java index 195168111..08123fd83 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperReleaseInfo.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperReleaseInfo.java @@ -27,7 +27,7 @@ public class WrapperReleaseInfo { * Logger */ - private static final Logger logger = Logger.getLogger(WrapperReleaseInfo.class); + private static final Logger LOGGER = Logger.getLogger(WrapperReleaseInfo.class); /* * Properties */ @@ -66,6 +66,6 @@ public class WrapperReleaseInfo { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - logger.warn(sb.toString()); + LOGGER.warn(sb.toString()); } } diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperResultList.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperResultList.java index 51ac65507..8a2519fef 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperResultList.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperResultList.java @@ -27,18 +27,18 @@ public class WrapperResultList { * Logger */ - private static final Logger logger = Logger.getLogger(WrapperResultList.class); + private static final Logger LOGGER = Logger.getLogger(WrapperResultList.class); /* * Properties */ @JsonProperty("page") - int page; + private int page; @JsonProperty("results") - List results; + private List results; @JsonProperty("total_pages") - int totalPages; + private int totalPages; @JsonProperty("total_results") - int totalResults; + private int totalResults; // public int getPage() { @@ -75,6 +75,7 @@ public class WrapperResultList { this.totalResults = totalResults; } // + /** * Handle unknown properties and print a message * @param key @@ -85,7 +86,7 @@ public class WrapperResultList { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - logger.warn(sb.toString()); + LOGGER.warn(sb.toString()); } @Override diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperTrailers.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperTrailers.java index dd36047e8..e6447dffb 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperTrailers.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperTrailers.java @@ -27,7 +27,7 @@ public class WrapperTrailers { * Logger */ - private static final Logger logger = Logger.getLogger(WrapperTrailers.class); + private static final Logger LOGGER = Logger.getLogger(WrapperTrailers.class); /* * Properties */ @@ -76,6 +76,6 @@ public class WrapperTrailers { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - logger.warn(sb.toString()); + LOGGER.warn(sb.toString()); } } diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperTranslations.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperTranslations.java index dc3a995cc..a270ea572 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperTranslations.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperTranslations.java @@ -26,7 +26,7 @@ public class WrapperTranslations { * Logger */ - private static final Logger logger = Logger.getLogger(WrapperTranslations.class); + private static final Logger LOGGER = Logger.getLogger(WrapperTranslations.class); /* * Properties */ @@ -63,6 +63,6 @@ public class WrapperTranslations { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - logger.warn(sb.toString()); + LOGGER.warn(sb.toString()); } } diff --git a/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDBTest.java b/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDBTest.java index f03cbedba..4a7a11944 100644 --- a/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDBTest.java +++ b/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDBTest.java @@ -28,7 +28,7 @@ import org.junit.*; */ public class TheMovieDBTest { - private static final Logger logger = Logger.getLogger(TheMovieDBTest.class); + private static final Logger LOGGER = Logger.getLogger(TheMovieDBTest.class); private static final String API_KEY = "5a1a77e2eba8984804586122754f969f"; private static TheMovieDB tmdb; /* @@ -62,7 +62,7 @@ public class TheMovieDBTest { */ @Test public void testConfiguration() throws IOException { - logger.info("Test Configuration"); + LOGGER.info("Test Configuration"); TmdbConfiguration tmdbConfig = tmdb.getConfiguration(); assertNotNull("Configuration failed", tmdbConfig); @@ -70,7 +70,7 @@ public class TheMovieDBTest { assertTrue("No backdrop sizes", tmdbConfig.getBackdropSizes().size() > 0); assertTrue("No poster sizes", tmdbConfig.getPosterSizes().size() > 0); assertTrue("No profile sizes", tmdbConfig.getProfileSizes().size() > 0); - logger.info(tmdbConfig.toString()); + LOGGER.info(tmdbConfig.toString()); } /** @@ -78,7 +78,7 @@ public class TheMovieDBTest { */ @Test public void testSearchMovie() throws UnsupportedEncodingException { - logger.info("searchMovie"); + LOGGER.info("searchMovie"); // Try a movie with less than 1 page of results List movieList = tmdb.searchMovie("Blade Runner", "", true); @@ -98,7 +98,7 @@ public class TheMovieDBTest { */ @Test public void testGetMovieInfo() { - logger.info("getMovieInfo"); + LOGGER.info("getMovieInfo"); String language = "en"; MovieDB result = tmdb.getMovieInfo(ID_BLADE_RUNNER, language); assertEquals("Incorrect movie information", "Blade Runner", result.getOriginalTitle()); @@ -109,7 +109,7 @@ public class TheMovieDBTest { */ @Test public void testGetMovieAlternativeTitles() { - logger.info("getMovieAlternativeTitles"); + LOGGER.info("getMovieAlternativeTitles"); String country = ""; List results = tmdb.getMovieAlternativeTitles(ID_BLADE_RUNNER, country); assertTrue("No alternative titles found", results.size() > 0); @@ -125,7 +125,7 @@ public class TheMovieDBTest { */ @Test public void testGetMovieCasts() { - logger.info("getMovieCasts"); + LOGGER.info("getMovieCasts"); List people = tmdb.getMovieCasts(ID_BLADE_RUNNER); assertTrue("No cast information", people.size() > 0); @@ -153,7 +153,7 @@ public class TheMovieDBTest { */ @Test public void testGetMovieImages() { - logger.info("getMovieImages"); + LOGGER.info("getMovieImages"); String language = ""; List result = tmdb.getMovieImages(ID_BLADE_RUNNER, language); assertFalse("No artwork found", result.isEmpty()); @@ -164,7 +164,7 @@ public class TheMovieDBTest { */ @Test public void testGetMovieKeywords() { - logger.info("getMovieKeywords"); + LOGGER.info("getMovieKeywords"); List result = tmdb.getMovieKeywords(ID_BLADE_RUNNER); assertFalse("No keywords found", result.isEmpty()); } @@ -174,7 +174,7 @@ public class TheMovieDBTest { */ @Test public void testGetMovieReleaseInfo() { - logger.info("getMovieReleaseInfo"); + LOGGER.info("getMovieReleaseInfo"); List result = tmdb.getMovieReleaseInfo(ID_BLADE_RUNNER, ""); assertFalse("Release information missing", result.isEmpty()); } @@ -184,7 +184,7 @@ public class TheMovieDBTest { */ @Test public void testGetMovieTrailers() { - logger.info("getMovieTrailers"); + LOGGER.info("getMovieTrailers"); List result = tmdb.getMovieTrailers(ID_BLADE_RUNNER, ""); assertFalse("Movie trailers missing", result.isEmpty()); } @@ -194,7 +194,7 @@ public class TheMovieDBTest { */ @Test public void testGetMovieTranslations() { - logger.info("getMovieTranslations"); + LOGGER.info("getMovieTranslations"); List result = tmdb.getMovieTranslations(ID_BLADE_RUNNER); assertFalse("No translations found", result.isEmpty()); } @@ -204,7 +204,7 @@ public class TheMovieDBTest { */ @Test public void testGetCollectionInfo() { - logger.info("getCollectionInfo"); + LOGGER.info("getCollectionInfo"); String language = ""; CollectionInfo result = tmdb.getCollectionInfo(ID_STAR_WARS_COLLECTION, language); assertFalse("No collection information", result.getParts().isEmpty()); @@ -212,7 +212,7 @@ public class TheMovieDBTest { @Test public void testCreateImageUrl() { - logger.info("createImageUrl"); + LOGGER.info("createImageUrl"); MovieDB movie = tmdb.getMovieInfo(ID_BLADE_RUNNER, ""); String result = tmdb.createImageUrl(movie.getPosterPath(), "original").toString(); assertTrue("Error compiling image URL", !result.isEmpty()); From 613374276869a3271647794e9cc1fccb3edab220 Mon Sep 17 00:00:00 2001 From: Omertron Date: Thu, 26 Jan 2012 09:38:46 +0000 Subject: [PATCH 098/207] Added IMDB ID search --- .../moviejukebox/themoviedb/TheMovieDB.java | 71 ++++++++++++++----- .../moviejukebox/themoviedb/tools/ApiUrl.java | 23 +++++- .../themoviedb/TheMovieDBTest.java | 11 +++ 3 files changed, 83 insertions(+), 22 deletions(-) diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDB.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDB.java index 0c711e869..469614cf8 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDB.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDB.java @@ -26,9 +26,9 @@ import org.codehaus.jackson.map.DeserializationConfig; import org.codehaus.jackson.map.ObjectMapper; /** - * The MovieDB API. - * This is for version 3 of the API as specified here: + * The MovieDB API. This is for version 3 of the API as specified here: * http://help.themoviedb.org/kb/api/about-3 + * * @author stuart.boston */ public class TheMovieDB { @@ -41,7 +41,7 @@ public class TheMovieDB { */ protected static final String TMDB_API_BASE = "http://api.themoviedb.org/3/"; /* - * API Methods + * API Methods */ protected static final ApiUrl TMDB_CONFIG_URL = new ApiUrl("configuration"); protected static final ApiUrl TMDB_SEARCH_MOVIE = new ApiUrl("search/movie"); @@ -83,10 +83,9 @@ public class TheMovieDB { } /** - * Search Movies - * This is a good starting point to start finding movies on TMDb. - * The idea is to be a quick and light method so you can iterate through movies quickly. - * http://help.themoviedb.org/kb/api/search-movies + * Search Movies This is a good starting point to start finding movies on + * TMDb. The idea is to be a quick and light method so you can iterate + * through movies quickly. http://help.themoviedb.org/kb/api/search-movies */ public List searchMovie(String movieName, String language, boolean allResults) { try { @@ -100,8 +99,9 @@ public class TheMovieDB { } /** - * This method is used to retrieve all of the basic movie information. - * It will return the single highest rated poster and backdrop. + * This method is used to retrieve all of the basic movie information. It + * will return the single highest rated poster and backdrop. + * * @param movieId * @param language * @return @@ -117,7 +117,27 @@ public class TheMovieDB { } /** - * This method is used to retrieve all of the alternative titles we have for a particular movie. + * This method is used to retrieve all of the basic movie information. It + * will return the single highest rated poster and backdrop. + * + * @param movieId + * @param language + * @return + */ + public MovieDB getMovieInfoImdb(String imdbId, String language) { + try { + URL url = TMDB_MOVIE_INFO.getIdUrl(imdbId, language); + return mapper.readValue(url, MovieDB.class); + } catch (IOException ex) { + LOGGER.warn("Failed to get movie info: " + ex.getMessage()); + } + return new MovieDB(); + } + + /** + * This method is used to retrieve all of the alternative titles we have for + * a particular movie. + * * @param movieId * @param country * @return @@ -135,6 +155,7 @@ public class TheMovieDB { /** * This method is used to retrieve all of the movie cast information. + * * @param movieId * @return */ @@ -167,7 +188,9 @@ public class TheMovieDB { } /** - * This method should be used when you’re wanting to retrieve all of the images for a particular movie. + * This method should be used when you’re wanting to retrieve all of the + * images for a particular movie. + * * @param movieId * @param language * @return @@ -198,8 +221,9 @@ public class TheMovieDB { } /** - * This method is used to retrieve all of the keywords that have been added to a particular movie. - * Currently, only English keywords exist. + * This method is used to retrieve all of the keywords that have been added + * to a particular movie. Currently, only English keywords exist. + * * @param movieId * @return */ @@ -215,7 +239,9 @@ public class TheMovieDB { } /** - * This method is used to retrieve all of the release and certification data we have for a specific movie. + * This method is used to retrieve all of the release and certification data + * we have for a specific movie. + * * @param movieId * @param language * @return @@ -232,8 +258,9 @@ public class TheMovieDB { } /** - * This method is used to retrieve all of the trailers for a particular movie. - * Supported sites are YouTube and QuickTime. + * This method is used to retrieve all of the trailers for a particular + * movie. Supported sites are YouTube and QuickTime. + * * @param movieId * @param language * @return @@ -263,7 +290,9 @@ public class TheMovieDB { } /** - * This method is used to retrieve a list of the available translations for a specific movie. + * This method is used to retrieve a list of the available translations for + * a specific movie. + * * @param movieId * @return */ @@ -279,8 +308,10 @@ public class TheMovieDB { } /** - * This method is used to retrieve all of the basic information about a movie collection. - * You can get the ID needed for this method by making a getMovieInfo request for the belongs_to_collection. + * This method is used to retrieve all of the basic information about a + * movie collection. You can get the ID needed for this method by making a + * getMovieInfo request for the belongs_to_collection. + * * @param movieId * @param language * @return @@ -296,6 +327,7 @@ public class TheMovieDB { /** * Get the configuration information + * * @return */ public TmdbConfiguration getConfiguration() { @@ -304,6 +336,7 @@ public class TheMovieDB { /** * Generate the full image URL from the size and image path + * * @param imagePath * @param requiredSize * @return diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/ApiUrl.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/ApiUrl.java index 0b4b3e1a3..a663c599e 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/ApiUrl.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/ApiUrl.java @@ -43,6 +43,7 @@ public class ApiUrl { private static final String PARAMETER_PAGE = DELIMITER_SUBSEQUENT + "page="; private static final String DEFAULT_QUERY = ""; private static final int DEFAULT_ID = -1; + private static final int IMDB_ID_TRIGGER = 0; // Use to determine its an IMDB search private static final String DEFAULT_LANGUAGE = ""; private static final String DEFAULT_COUNTRY = ""; private static final int DEFAULT_PAGE = -1; @@ -74,7 +75,7 @@ public class ApiUrl { * @param page * @return */ - private URL getFullUrl(String query, int tmdbId, String language, String country, int page) { + private URL getFullUrl(String query, int tmdbId, String imdbId, String language, String country, int page) { StringBuilder urlString = new StringBuilder(TheMovieDB.getApiBase()); // Get the start of the URL @@ -97,6 +98,11 @@ public class ApiUrl { if (tmdbId > DEFAULT_ID) { urlString.append(tmdbId); } + + // Append the IMDB ID if provided + if (StringUtils.isNotBlank(imdbId)) { + urlString.append(imdbId); + } // Append the suffix of the API URL urlString.append(submethod); @@ -147,7 +153,7 @@ public class ApiUrl { * @return */ public URL getQueryUrl(String query, String language, int page) { - return getFullUrl(query, DEFAULT_ID, language, null, page); + return getFullUrl(query, DEFAULT_ID, DEFAULT_QUERY, language, null, page); } public URL getQueryUrl(String query) { @@ -166,7 +172,7 @@ public class ApiUrl { * @return */ public URL getIdUrl(int tmdbId, String language, String country) { - return getFullUrl(DEFAULT_QUERY, tmdbId, language, country, DEFAULT_PAGE); + return getFullUrl(DEFAULT_QUERY, tmdbId, DEFAULT_QUERY, language, country, DEFAULT_PAGE); } public URL getIdUrl(int tmdbId) { @@ -176,5 +182,16 @@ public class ApiUrl { public URL getIdUrl(int tmdbId, String language) { return getIdUrl(tmdbId, language, DEFAULT_COUNTRY); } + + /** + * Get the movie info for an IMDB ID. + * Note, this is a special case + * @param imdbId + * @param language + * @return + */ + public URL getIdUrl(String imdbId, String language) { + return getFullUrl(DEFAULT_QUERY, DEFAULT_ID, imdbId, language, DEFAULT_COUNTRY, DEFAULT_PAGE); + } } diff --git a/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDBTest.java b/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDBTest.java index 4a7a11944..ddce06de7 100644 --- a/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDBTest.java +++ b/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDBTest.java @@ -217,4 +217,15 @@ public class TheMovieDBTest { String result = tmdb.createImageUrl(movie.getPosterPath(), "original").toString(); assertTrue("Error compiling image URL", !result.isEmpty()); } + + /** + * Test of getMovieInfoImdb method, of class TheMovieDB. + */ + @Test + public void testGetMovieInfoImdb() { + LOGGER.info("getMovieInfoImdb"); + MovieDB result = tmdb.getMovieInfoImdb("tt0076759", "en-US"); + assertTrue("Error getting the movie from IMDB ID", result.getId() == 11); + } + } From 5c809e77fd59dbd7bd5287a7be7643074a0a80c1 Mon Sep 17 00:00:00 2001 From: Omertron Date: Fri, 27 Jan 2012 12:15:37 +0000 Subject: [PATCH 099/207] Finished the ApiUrl class to be more generic for TMDb and IMDb ID values --- .../moviejukebox/themoviedb/TheMovieDB.java | 366 ------------------ .../moviejukebox/themoviedb/tools/ApiUrl.java | 138 ++++--- .../themoviedb/TheMovieDBTest.java | 36 +- 3 files changed, 109 insertions(+), 431 deletions(-) delete mode 100644 themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDB.java diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDB.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDB.java deleted file mode 100644 index 469614cf8..000000000 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDB.java +++ /dev/null @@ -1,366 +0,0 @@ -/* - * Copyright (c) 2004-2012 YAMJ Members - * http://code.google.com/p/moviejukebox/people/list - * - * Web: http://code.google.com/p/moviejukebox/ - * - * This software is licensed under a Creative Commons License - * See this page: http://code.google.com/p/moviejukebox/wiki/License - * - * For any reuse or distribution, you must make clear to others the - * license terms of this work. - */ -package com.moviejukebox.themoviedb; - -import com.moviejukebox.themoviedb.model.*; -import com.moviejukebox.themoviedb.tools.ApiUrl; -import com.moviejukebox.themoviedb.tools.FilteringLayout; -import com.moviejukebox.themoviedb.wrapper.*; -import java.io.IOException; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.ArrayList; -import java.util.List; -import org.apache.log4j.Logger; -import org.codehaus.jackson.map.DeserializationConfig; -import org.codehaus.jackson.map.ObjectMapper; - -/** - * The MovieDB API. This is for version 3 of the API as specified here: - * http://help.themoviedb.org/kb/api/about-3 - * - * @author stuart.boston - */ -public class TheMovieDB { - - private static final Logger LOGGER = Logger.getLogger(TheMovieDB.class); - private static String apiKey; - private static TmdbConfiguration tmdbConfig; - /* - * TheMovieDB API URLs - */ - protected static final String TMDB_API_BASE = "http://api.themoviedb.org/3/"; - /* - * API Methods - */ - protected static final ApiUrl TMDB_CONFIG_URL = new ApiUrl("configuration"); - protected static final ApiUrl TMDB_SEARCH_MOVIE = new ApiUrl("search/movie"); - protected static final ApiUrl TMDB_SEARCH_PEOPLE = new ApiUrl("search/person"); - protected static final ApiUrl TMDB_COLLECTION_INFO = new ApiUrl("collection/"); - protected static final ApiUrl TMDB_MOVIE_INFO = new ApiUrl("movie/"); - protected static final ApiUrl TMDB_MOVIE_ALT_TITLES = new ApiUrl("movie/", "/alternative_titles"); - protected static final ApiUrl TMDB_MOVIE_CASTS = new ApiUrl("movie/", "/casts"); - protected static final ApiUrl TMDB_MOVIE_IMAGES = new ApiUrl("movie/", "/images"); - protected static final ApiUrl TMDB_MOVIE_KEYWORDS = new ApiUrl("movie/", "/keywords"); - protected static final ApiUrl TMDB_MOVIE_RELEASE_INFO = new ApiUrl("movie/", "/releases"); - protected static final ApiUrl TMDB_MOVIE_TRAILERS = new ApiUrl("movie/", "/trailers"); - protected static final ApiUrl TMDB_MOVIE_TRANSLATIONS = new ApiUrl("movie/", "/translations"); - protected static final ApiUrl TMDB_PERSON_INFO = new ApiUrl("person"); - protected static final ApiUrl TMDB_PERSON_CREDITS = new ApiUrl("person/", "/credits"); - protected static final ApiUrl TMDB_PERSON_IMAGES = new ApiUrl("person/", "/images"); - protected static final ApiUrl TMDB_LATEST_MOVIE = new ApiUrl("latest/movie"); - - /* - * Jackson JSON configuration - */ - private static ObjectMapper mapper = new ObjectMapper(); - - public TheMovieDB(String apiKey) throws IOException { - TheMovieDB.apiKey = apiKey; - URL configUrl = TMDB_CONFIG_URL.getQueryUrl(""); - mapper.configure(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE, true); - tmdbConfig = mapper.readValue(configUrl, TmdbConfiguration.class); - mapper.configure(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE, false); - FilteringLayout.addApiKey(apiKey); - } - - public static String getApiKey() { - return apiKey; - } - - public static String getApiBase() { - return TMDB_API_BASE; - } - - /** - * Search Movies This is a good starting point to start finding movies on - * TMDb. The idea is to be a quick and light method so you can iterate - * through movies quickly. http://help.themoviedb.org/kb/api/search-movies - */ - public List searchMovie(String movieName, String language, boolean allResults) { - try { - URL url = TMDB_SEARCH_MOVIE.getQueryUrl(movieName, language, 1); - WrapperResultList resultList = mapper.readValue(url, WrapperResultList.class); - return resultList.getResults(); - } catch (IOException ex) { - LOGGER.warn("Failed to find movie: " + ex.getMessage()); - return new ArrayList(); - } - } - - /** - * This method is used to retrieve all of the basic movie information. It - * will return the single highest rated poster and backdrop. - * - * @param movieId - * @param language - * @return - */ - public MovieDB getMovieInfo(int movieId, String language) { - try { - URL url = TMDB_MOVIE_INFO.getIdUrl(movieId, language); - return mapper.readValue(url, MovieDB.class); - } catch (IOException ex) { - LOGGER.warn("Failed to get movie info: " + ex.getMessage()); - } - return new MovieDB(); - } - - /** - * This method is used to retrieve all of the basic movie information. It - * will return the single highest rated poster and backdrop. - * - * @param movieId - * @param language - * @return - */ - public MovieDB getMovieInfoImdb(String imdbId, String language) { - try { - URL url = TMDB_MOVIE_INFO.getIdUrl(imdbId, language); - return mapper.readValue(url, MovieDB.class); - } catch (IOException ex) { - LOGGER.warn("Failed to get movie info: " + ex.getMessage()); - } - return new MovieDB(); - } - - /** - * This method is used to retrieve all of the alternative titles we have for - * a particular movie. - * - * @param movieId - * @param country - * @return - */ - public List getMovieAlternativeTitles(int movieId, String country) { - try { - URL url = TMDB_MOVIE_ALT_TITLES.getIdUrl(movieId, country); - WrapperAlternativeTitles at = mapper.readValue(url, WrapperAlternativeTitles.class); - return at.getTitles(); - } catch (IOException ex) { - LOGGER.warn("Failed to get movie alternative titles: " + ex.getMessage()); - } - return new ArrayList(); - } - - /** - * This method is used to retrieve all of the movie cast information. - * - * @param movieId - * @return - */ - public List getMovieCasts(int movieId) { - List people = new ArrayList(); - - try { - URL url = TMDB_MOVIE_CASTS.getIdUrl(movieId); - WrapperMovieCasts mc = mapper.readValue(url, WrapperMovieCasts.class); - - // Add a cast member - for (PersonCast cast : mc.getCast()) { - Person person = new Person(); - person.addCast(cast.getId(), cast.getName(), cast.getProfilePath(), cast.getCharacter(), cast.getOrder()); - people.add(person); - } - - // Add a crew member - for (PersonCrew crew : mc.getCrew()) { - Person person = new Person(); - person.addCrew(crew.getId(), crew.getName(), crew.getProfilePath(), crew.getDepartment(), crew.getJob()); - people.add(person); - } - - return people; - } catch (IOException ex) { - LOGGER.warn("Failed to get movie casts: " + ex.getMessage()); - } - return people; - } - - /** - * This method should be used when you’re wanting to retrieve all of the - * images for a particular movie. - * - * @param movieId - * @param language - * @return - */ - public List getMovieImages(int movieId, String language) { - List artwork = new ArrayList(); - try { - URL url = TMDB_MOVIE_IMAGES.getIdUrl(movieId, language); - WrapperMovieImages mi = mapper.readValue(url, WrapperMovieImages.class); - - // Add all the posters to the list - for (Artwork poster : mi.getPosters()) { - poster.setArtworkType(ArtworkType.POSTER); - artwork.add(poster); - } - - // Add all the backdrops to the list - for (Artwork backdrop : mi.getBackdrops()) { - backdrop.setArtworkType(ArtworkType.BACKDROP); - artwork.add(backdrop); - } - - return artwork; - } catch (IOException ex) { - LOGGER.warn("Failed to get movie images: " + ex.getMessage()); - } - return artwork; - } - - /** - * This method is used to retrieve all of the keywords that have been added - * to a particular movie. Currently, only English keywords exist. - * - * @param movieId - * @return - */ - public List getMovieKeywords(int movieId) { - try { - URL url = TMDB_MOVIE_KEYWORDS.getIdUrl(movieId); - WrapperMovieKeywords mk = mapper.readValue(url, WrapperMovieKeywords.class); - return mk.getKeywords(); - } catch (IOException ex) { - LOGGER.warn("Failed to get movie keywords: " + ex.getMessage()); - } - return new ArrayList(); - } - - /** - * This method is used to retrieve all of the release and certification data - * we have for a specific movie. - * - * @param movieId - * @param language - * @return - */ - public List getMovieReleaseInfo(int movieId, String language) { - try { - URL url = TMDB_MOVIE_RELEASE_INFO.getIdUrl(movieId); - WrapperReleaseInfo ri = mapper.readValue(url, WrapperReleaseInfo.class); - return ri.getCountries(); - } catch (IOException ex) { - LOGGER.warn("Failed to get movie release information: " + ex.getMessage()); - } - return new ArrayList(); - } - - /** - * This method is used to retrieve all of the trailers for a particular - * movie. Supported sites are YouTube and QuickTime. - * - * @param movieId - * @param language - * @return - */ - public List getMovieTrailers(int movieId, String language) { - List trailers = new ArrayList(); - try { - URL url = TMDB_MOVIE_TRAILERS.getIdUrl(movieId); - WrapperTrailers wt = mapper.readValue(url, WrapperTrailers.class); - - // Add the trailer to the return list along with it's source - for (Trailer trailer : wt.getQuicktime()) { - trailer.setWebsite(Trailer.WEBSITE_QUICKTIME); - trailers.add(trailer); - } - - // Add the trailer to the return list along with it's source - for (Trailer trailer : wt.getYoutube()) { - trailer.setWebsite(Trailer.WEBSITE_YOUTUBE); - trailers.add(trailer); - } - return trailers; - } catch (IOException ex) { - LOGGER.warn("Failed to get movie trailers: " + ex.getMessage()); - } - return trailers; - } - - /** - * This method is used to retrieve a list of the available translations for - * a specific movie. - * - * @param movieId - * @return - */ - public List getMovieTranslations(int movieId) { - try { - URL url = TMDB_MOVIE_TRANSLATIONS.getIdUrl(movieId); - WrapperTranslations wt = mapper.readValue(url, WrapperTranslations.class); - return wt.getTranslations(); - } catch (IOException ex) { - LOGGER.warn("Failed to get movie tranlations: " + ex.getMessage()); - } - return new ArrayList(); - } - - /** - * This method is used to retrieve all of the basic information about a - * movie collection. You can get the ID needed for this method by making a - * getMovieInfo request for the belongs_to_collection. - * - * @param movieId - * @param language - * @return - */ - public CollectionInfo getCollectionInfo(int movieId, String language) { - try { - URL url = TMDB_COLLECTION_INFO.getIdUrl(movieId); - return mapper.readValue(url, CollectionInfo.class); - } catch (IOException ex) { - return new CollectionInfo(); - } - } - - /** - * Get the configuration information - * - * @return - */ - public TmdbConfiguration getConfiguration() { - return tmdbConfig; - } - - /** - * Generate the full image URL from the size and image path - * - * @param imagePath - * @param requiredSize - * @return - */ - public URL createImageUrl(String imagePath, String requiredSize) { - URL returnUrl = null; - StringBuilder sb; - - if (!tmdbConfig.isValidSize(requiredSize)) { - sb = new StringBuilder(); - sb.append(" - Invalid size requested: ").append(requiredSize); - LOGGER.warn(sb.toString()); - return returnUrl; - } - - try { - sb = new StringBuilder(tmdbConfig.getBaseUrl()); - sb.append(requiredSize); - sb.append(imagePath); - returnUrl = new URL(sb.toString()); - } catch (MalformedURLException ex) { - LOGGER.warn("Failed to create image URL: " + ex.getMessage()); - } - - return returnUrl; - } -} diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/ApiUrl.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/ApiUrl.java index a663c599e..17ce7cffb 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/ApiUrl.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/ApiUrl.java @@ -12,7 +12,7 @@ */ package com.moviejukebox.themoviedb.tools; -import com.moviejukebox.themoviedb.TheMovieDB; +import com.moviejukebox.themoviedb.TheMovieDb; import java.io.UnsupportedEncodingException; import java.net.MalformedURLException; import java.net.URL; @@ -41,12 +41,8 @@ public class ApiUrl { private static final String PARAMETER_LANGUAGE = DELIMITER_SUBSEQUENT + "language="; private static final String PARAMETER_COUNTRY = DELIMITER_SUBSEQUENT + "country="; private static final String PARAMETER_PAGE = DELIMITER_SUBSEQUENT + "page="; - private static final String DEFAULT_QUERY = ""; - private static final int DEFAULT_ID = -1; - private static final int IMDB_ID_TRIGGER = 0; // Use to determine its an IMDB search - private static final String DEFAULT_LANGUAGE = ""; - private static final String DEFAULT_COUNTRY = ""; - private static final int DEFAULT_PAGE = -1; + private static final String DEFAULT_STRING = ""; + private static final int DEFAULT_INT = -1; /* * Properties */ @@ -54,11 +50,20 @@ public class ApiUrl { private String submethod; // + /** + * Constructor for the simple API URL method without a sub-method + * @param method + */ public ApiUrl(String method) { this.method = method; - this.submethod = DEFAULT_QUERY; + this.submethod = DEFAULT_STRING; } + /** + * Constructor for the API URL with a sub-method + * @param method + * @param submethod + */ public ApiUrl(String method, String submethod) { this.method = method; this.submethod = submethod; @@ -75,8 +80,8 @@ public class ApiUrl { * @param page * @return */ - private URL getFullUrl(String query, int tmdbId, String imdbId, String language, String country, int page) { - StringBuilder urlString = new StringBuilder(TheMovieDB.getApiBase()); + private URL getFullUrl(String query, String movieId, String language, String country, int page) { + StringBuilder urlString = new StringBuilder(TheMovieDb.getApiBase()); // Get the start of the URL urlString.append(method); @@ -95,13 +100,8 @@ public class ApiUrl { } // Append the ID if provided - if (tmdbId > DEFAULT_ID) { - urlString.append(tmdbId); - } - - // Append the IMDB ID if provided - if (StringUtils.isNotBlank(imdbId)) { - urlString.append(imdbId); + if (StringUtils.isNotBlank(movieId)) { + urlString.append(movieId); } // Append the suffix of the API URL @@ -116,7 +116,7 @@ public class ApiUrl { urlString.append(DELIMITER_SUBSEQUENT); } urlString.append(PARAMETER_API_KEY); - urlString.append(TheMovieDB.getApiKey()); + urlString.append(TheMovieDb.getApiKey()); // Append the language to the URL if (StringUtils.isNotBlank(language)) { @@ -131,7 +131,7 @@ public class ApiUrl { } // Append the page to the URL - if (page > DEFAULT_PAGE) { + if (page > DEFAULT_INT) { urlString.append(PARAMETER_PAGE); urlString.append(page); } @@ -146,52 +146,96 @@ public class ApiUrl { } /** - * Create an URL using a query (string) and optional language and page + * Create an URL using the query (string), language and page + * * @param query * @param language * @param page * @return */ public URL getQueryUrl(String query, String language, int page) { - return getFullUrl(query, DEFAULT_ID, DEFAULT_QUERY, language, null, page); - } - - public URL getQueryUrl(String query) { - return getQueryUrl(query, DEFAULT_LANGUAGE, DEFAULT_PAGE); - } - - public URL getQueryUrl(String query, String language) { - return getQueryUrl(query, language, DEFAULT_PAGE); + return getFullUrl(query, DEFAULT_STRING, language, null, page); } /** - * Create an URL using the TheMovieDB ID and optional language an country codes - * @param tmdbId + * Create an URL using the query (string) + * @param query + * @return + */ + public URL getQueryUrl(String query) { + return getQueryUrl(query, DEFAULT_STRING, DEFAULT_INT); + } + + /** + * Create an URL using the query (string) and language + * @param query + * @param language + * @return + */ + public URL getQueryUrl(String query, String language) { + return getQueryUrl(query, language, DEFAULT_INT); + } + + /** + * Create an URL using the movie ID, language and country code + * + * @param movieId * @param language * @param country * @return */ - public URL getIdUrl(int tmdbId, String language, String country) { - return getFullUrl(DEFAULT_QUERY, tmdbId, DEFAULT_QUERY, language, country, DEFAULT_PAGE); + public URL getIdUrl(String movieId, String language, String country) { + return getFullUrl(DEFAULT_STRING, movieId, language, country, DEFAULT_INT); } - public URL getIdUrl(int tmdbId) { - return getIdUrl(tmdbId, DEFAULT_LANGUAGE, DEFAULT_COUNTRY); - } - - public URL getIdUrl(int tmdbId, String language) { - return getIdUrl(tmdbId, language, DEFAULT_COUNTRY); - } - /** - * Get the movie info for an IMDB ID. - * Note, this is a special case - * @param imdbId + * Create an URL using the movie ID and language + * @param movieId * @param language - * @return + * @return */ - public URL getIdUrl(String imdbId, String language) { - return getFullUrl(DEFAULT_QUERY, DEFAULT_ID, imdbId, language, DEFAULT_COUNTRY, DEFAULT_PAGE); + public URL getIdUrl(String movieId, String language) { + return getIdUrl(movieId, language, DEFAULT_STRING); + } + + /** + * Create an URL using the movie ID + * @param movieId + * @return + */ + public URL getIdUrl(String movieId) { + return getIdUrl(movieId, DEFAULT_STRING, DEFAULT_STRING); + } + + /** + * Create an URL using the movie ID, language and country code + * + * @param movieId + * @param language + * @param country + * @return + */ + public URL getIdUrl(int movieId, String language, String country) { + return getIdUrl(String.valueOf(movieId), language, country); + } + + /** + * Create an URL using the movie ID and language + * @param movieId + * @param language + * @return + */ + public URL getIdUrl(int movieId, String language) { + return getIdUrl(String.valueOf(movieId), language, DEFAULT_STRING); + } + + /** + * Create an URL using the movie ID + * @param movieId + * @return + */ + public URL getIdUrl(int movieId) { + return getIdUrl(String.valueOf(movieId), DEFAULT_STRING, DEFAULT_STRING); } } diff --git a/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDBTest.java b/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDBTest.java index ddce06de7..fc85de573 100644 --- a/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDBTest.java +++ b/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDBTest.java @@ -22,23 +22,23 @@ import static org.junit.Assert.*; import org.junit.*; /** - * Test cases for TheMovieDB API + * Test cases for TheMovieDb API * * @author stuart.boston */ -public class TheMovieDBTest { +public class TheMovieDbTest { - private static final Logger LOGGER = Logger.getLogger(TheMovieDBTest.class); + private static final Logger LOGGER = Logger.getLogger(TheMovieDbTest.class); private static final String API_KEY = "5a1a77e2eba8984804586122754f969f"; - private static TheMovieDB tmdb; + private static TheMovieDb tmdb; /* * Test data */ private static final int ID_BLADE_RUNNER = 78; private static final int ID_STAR_WARS_COLLECTION = 10; - public TheMovieDBTest() throws IOException { - tmdb = new TheMovieDB(API_KEY); + public TheMovieDbTest() throws IOException { + tmdb = new TheMovieDb(API_KEY); } @BeforeClass @@ -58,7 +58,7 @@ public class TheMovieDBTest { } /** - * Test of getConfiguration method, of class TheMovieDB. + * Test of getConfiguration method, of class TheMovieDb. */ @Test public void testConfiguration() throws IOException { @@ -74,7 +74,7 @@ public class TheMovieDBTest { } /** - * Test of searchMovie method, of class TheMovieDB. + * Test of searchMovie method, of class TheMovieDb. */ @Test public void testSearchMovie() throws UnsupportedEncodingException { @@ -94,7 +94,7 @@ public class TheMovieDBTest { } /** - * Test of getMovieInfo method, of class TheMovieDB. + * Test of getMovieInfo method, of class TheMovieDb. */ @Test public void testGetMovieInfo() { @@ -105,7 +105,7 @@ public class TheMovieDBTest { } /** - * Test of getMovieAlternativeTitles method, of class TheMovieDB. + * Test of getMovieAlternativeTitles method, of class TheMovieDb. */ @Test public void testGetMovieAlternativeTitles() { @@ -121,7 +121,7 @@ public class TheMovieDBTest { } /** - * Test of getMovieCasts method, of class TheMovieDB. + * Test of getMovieCasts method, of class TheMovieDb. */ @Test public void testGetMovieCasts() { @@ -149,7 +149,7 @@ public class TheMovieDBTest { } /** - * Test of getMovieImages method, of class TheMovieDB. + * Test of getMovieImages method, of class TheMovieDb. */ @Test public void testGetMovieImages() { @@ -160,7 +160,7 @@ public class TheMovieDBTest { } /** - * Test of getMovieKeywords method, of class TheMovieDB. + * Test of getMovieKeywords method, of class TheMovieDb. */ @Test public void testGetMovieKeywords() { @@ -170,7 +170,7 @@ public class TheMovieDBTest { } /** - * Test of getMovieReleaseInfo method, of class TheMovieDB. + * Test of getMovieReleaseInfo method, of class TheMovieDb. */ @Test public void testGetMovieReleaseInfo() { @@ -180,7 +180,7 @@ public class TheMovieDBTest { } /** - * Test of getMovieTrailers method, of class TheMovieDB. + * Test of getMovieTrailers method, of class TheMovieDb. */ @Test public void testGetMovieTrailers() { @@ -190,7 +190,7 @@ public class TheMovieDBTest { } /** - * Test of getMovieTranslations method, of class TheMovieDB. + * Test of getMovieTranslations method, of class TheMovieDb. */ @Test public void testGetMovieTranslations() { @@ -200,7 +200,7 @@ public class TheMovieDBTest { } /** - * Test of getCollectionInfo method, of class TheMovieDB. + * Test of getCollectionInfo method, of class TheMovieDb. */ @Test public void testGetCollectionInfo() { @@ -219,7 +219,7 @@ public class TheMovieDBTest { } /** - * Test of getMovieInfoImdb method, of class TheMovieDB. + * Test of getMovieInfoImdb method, of class TheMovieDb. */ @Test public void testGetMovieInfoImdb() { From b4de24d0fa805b63ea3e18f43a0797c5b0fa8549 Mon Sep 17 00:00:00 2001 From: Omertron Date: Fri, 27 Jan 2012 12:23:14 +0000 Subject: [PATCH 100/207] Finished the ApiUrl class to be more generic for TMDb and IMDb ID values --- .../moviejukebox/themoviedb/TheMovieDb.java | 371 ++++++++++++++++++ 1 file changed, 371 insertions(+) create mode 100644 themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java new file mode 100644 index 000000000..01d58d6cf --- /dev/null +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java @@ -0,0 +1,371 @@ +/* + * Copyright (c) 2004-2012 YAMJ Members + * http://code.google.com/p/moviejukebox/people/list + * + * Web: http://code.google.com/p/moviejukebox/ + * + * This software is licensed under a Creative Commons License + * See this page: http://code.google.com/p/moviejukebox/wiki/License + * + * For any reuse or distribution, you must make clear to others the + * license terms of this work. + */ +package com.moviejukebox.themoviedb; + +import com.moviejukebox.themoviedb.model.*; +import com.moviejukebox.themoviedb.tools.ApiUrl; +import com.moviejukebox.themoviedb.tools.FilteringLayout; +import com.moviejukebox.themoviedb.wrapper.*; +import java.io.IOException; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.ArrayList; +import java.util.List; +import org.apache.log4j.Logger; +import org.codehaus.jackson.map.DeserializationConfig; +import org.codehaus.jackson.map.ObjectMapper; + +/** + * The MovieDB API. This is for version 3 of the API as specified here: + * http://help.themoviedb.org/kb/api/about-3 + * + * @author stuart.boston + */ +public class TheMovieDb { + + private static final Logger LOGGER = Logger.getLogger(TheMovieDb.class); + private static String apiKey; + private static TmdbConfiguration tmdbConfig; + /* + * TheMovieDb API URLs + */ + private static final String TMDB_API_BASE = "http://api.themoviedb.org/3/"; + /* + * API Methods + */ + private static final ApiUrl TMDB_CONFIG_URL = new ApiUrl("configuration"); + private static final ApiUrl TMDB_SEARCH_MOVIE = new ApiUrl("search/movie"); + private static final ApiUrl TMDB_SEARCH_PEOPLE = new ApiUrl("search/person"); + private static final ApiUrl TMDB_COLLECTION_INFO = new ApiUrl("collection/"); + private static final ApiUrl TMDB_MOVIE_INFO = new ApiUrl("movie/"); + private static final ApiUrl TMDB_MOVIE_ALT_TITLES = new ApiUrl("movie/", "/alternative_titles"); + private static final ApiUrl TMDB_MOVIE_CASTS = new ApiUrl("movie/", "/casts"); + private static final ApiUrl TMDB_MOVIE_IMAGES = new ApiUrl("movie/", "/images"); + private static final ApiUrl TMDB_MOVIE_KEYWORDS = new ApiUrl("movie/", "/keywords"); + private static final ApiUrl TMDB_MOVIE_RELEASE_INFO = new ApiUrl("movie/", "/releases"); + private static final ApiUrl TMDB_MOVIE_TRAILERS = new ApiUrl("movie/", "/trailers"); + private static final ApiUrl TMDB_MOVIE_TRANSLATIONS = new ApiUrl("movie/", "/translations"); + private static final ApiUrl TMDB_PERSON_INFO = new ApiUrl("person"); + private static final ApiUrl TMDB_PERSON_CREDITS = new ApiUrl("person/", "/credits"); + private static final ApiUrl TMDB_PERSON_IMAGES = new ApiUrl("person/", "/images"); + private static final ApiUrl TMDB_LATEST_MOVIE = new ApiUrl("latest/movie"); + + /* + * Jackson JSON configuration + */ + private static ObjectMapper mapper = new ObjectMapper(); + + /** + * API for The Movie Db. + * @param apiKey + * @throws IOException + */ + public TheMovieDb(String apiKey) throws IOException { + TheMovieDb.apiKey = apiKey; + URL configUrl = TMDB_CONFIG_URL.getQueryUrl(""); + mapper.configure(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE, true); + tmdbConfig = mapper.readValue(configUrl, TmdbConfiguration.class); + mapper.configure(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE, false); + FilteringLayout.addApiKey(apiKey); + } + + public static String getApiKey() { + return apiKey; + } + + public static String getApiBase() { + return TMDB_API_BASE; + } + + /** + * Search Movies This is a good starting point to start finding movies on + * TMDb. The idea is to be a quick and light method so you can iterate + * through movies quickly. http://help.themoviedb.org/kb/api/search-movies + */ + public List searchMovie(String movieName, String language, boolean allResults) { + try { + URL url = TMDB_SEARCH_MOVIE.getQueryUrl(movieName, language, 1); + WrapperResultList resultList = mapper.readValue(url, WrapperResultList.class); + return resultList.getResults(); + } catch (IOException ex) { + LOGGER.warn("Failed to find movie: " + ex.getMessage()); + return new ArrayList(); + } + } + + /** + * This method is used to retrieve all of the basic movie information. It + * will return the single highest rated poster and backdrop. + * + * @param movieId + * @param language + * @return + */ + public MovieDB getMovieInfo(int movieId, String language) { + try { + URL url = TMDB_MOVIE_INFO.getIdUrl(movieId, language); + return mapper.readValue(url, MovieDB.class); + } catch (IOException ex) { + LOGGER.warn("Failed to get movie info: " + ex.getMessage()); + } + return new MovieDB(); + } + + /** + * This method is used to retrieve all of the basic movie information. It + * will return the single highest rated poster and backdrop. + * + * @param movieId + * @param language + * @return + */ + public MovieDB getMovieInfoImdb(String imdbId, String language) { + try { + URL url = TMDB_MOVIE_INFO.getIdUrl(imdbId, language); + return mapper.readValue(url, MovieDB.class); + } catch (IOException ex) { + LOGGER.warn("Failed to get movie info: " + ex.getMessage()); + } + return new MovieDB(); + } + + /** + * This method is used to retrieve all of the alternative titles we have for + * a particular movie. + * + * @param movieId + * @param country + * @return + */ + public List getMovieAlternativeTitles(int movieId, String country) { + try { + URL url = TMDB_MOVIE_ALT_TITLES.getIdUrl(movieId, country); + WrapperAlternativeTitles at = mapper.readValue(url, WrapperAlternativeTitles.class); + return at.getTitles(); + } catch (IOException ex) { + LOGGER.warn("Failed to get movie alternative titles: " + ex.getMessage()); + } + return new ArrayList(); + } + + /** + * This method is used to retrieve all of the movie cast information. + * + * @param movieId + * @return + */ + public List getMovieCasts(int movieId) { + List people = new ArrayList(); + + try { + URL url = TMDB_MOVIE_CASTS.getIdUrl(movieId); + WrapperMovieCasts mc = mapper.readValue(url, WrapperMovieCasts.class); + + // Add a cast member + for (PersonCast cast : mc.getCast()) { + Person person = new Person(); + person.addCast(cast.getId(), cast.getName(), cast.getProfilePath(), cast.getCharacter(), cast.getOrder()); + people.add(person); + } + + // Add a crew member + for (PersonCrew crew : mc.getCrew()) { + Person person = new Person(); + person.addCrew(crew.getId(), crew.getName(), crew.getProfilePath(), crew.getDepartment(), crew.getJob()); + people.add(person); + } + + return people; + } catch (IOException ex) { + LOGGER.warn("Failed to get movie casts: " + ex.getMessage()); + } + return people; + } + + /** + * This method should be used when you’re wanting to retrieve all of the + * images for a particular movie. + * + * @param movieId + * @param language + * @return + */ + public List getMovieImages(int movieId, String language) { + List artwork = new ArrayList(); + try { + URL url = TMDB_MOVIE_IMAGES.getIdUrl(movieId, language); + WrapperMovieImages mi = mapper.readValue(url, WrapperMovieImages.class); + + // Add all the posters to the list + for (Artwork poster : mi.getPosters()) { + poster.setArtworkType(ArtworkType.POSTER); + artwork.add(poster); + } + + // Add all the backdrops to the list + for (Artwork backdrop : mi.getBackdrops()) { + backdrop.setArtworkType(ArtworkType.BACKDROP); + artwork.add(backdrop); + } + + return artwork; + } catch (IOException ex) { + LOGGER.warn("Failed to get movie images: " + ex.getMessage()); + } + return artwork; + } + + /** + * This method is used to retrieve all of the keywords that have been added + * to a particular movie. Currently, only English keywords exist. + * + * @param movieId + * @return + */ + public List getMovieKeywords(int movieId) { + try { + URL url = TMDB_MOVIE_KEYWORDS.getIdUrl(movieId); + WrapperMovieKeywords mk = mapper.readValue(url, WrapperMovieKeywords.class); + return mk.getKeywords(); + } catch (IOException ex) { + LOGGER.warn("Failed to get movie keywords: " + ex.getMessage()); + } + return new ArrayList(); + } + + /** + * This method is used to retrieve all of the release and certification data + * we have for a specific movie. + * + * @param movieId + * @param language + * @return + */ + public List getMovieReleaseInfo(int movieId, String language) { + try { + URL url = TMDB_MOVIE_RELEASE_INFO.getIdUrl(movieId); + WrapperReleaseInfo ri = mapper.readValue(url, WrapperReleaseInfo.class); + return ri.getCountries(); + } catch (IOException ex) { + LOGGER.warn("Failed to get movie release information: " + ex.getMessage()); + } + return new ArrayList(); + } + + /** + * This method is used to retrieve all of the trailers for a particular + * movie. Supported sites are YouTube and QuickTime. + * + * @param movieId + * @param language + * @return + */ + public List getMovieTrailers(int movieId, String language) { + List trailers = new ArrayList(); + try { + URL url = TMDB_MOVIE_TRAILERS.getIdUrl(movieId); + WrapperTrailers wt = mapper.readValue(url, WrapperTrailers.class); + + // Add the trailer to the return list along with it's source + for (Trailer trailer : wt.getQuicktime()) { + trailer.setWebsite(Trailer.WEBSITE_QUICKTIME); + trailers.add(trailer); + } + + // Add the trailer to the return list along with it's source + for (Trailer trailer : wt.getYoutube()) { + trailer.setWebsite(Trailer.WEBSITE_YOUTUBE); + trailers.add(trailer); + } + return trailers; + } catch (IOException ex) { + LOGGER.warn("Failed to get movie trailers: " + ex.getMessage()); + } + return trailers; + } + + /** + * This method is used to retrieve a list of the available translations for + * a specific movie. + * + * @param movieId + * @return + */ + public List getMovieTranslations(int movieId) { + try { + URL url = TMDB_MOVIE_TRANSLATIONS.getIdUrl(movieId); + WrapperTranslations wt = mapper.readValue(url, WrapperTranslations.class); + return wt.getTranslations(); + } catch (IOException ex) { + LOGGER.warn("Failed to get movie tranlations: " + ex.getMessage()); + } + return new ArrayList(); + } + + /** + * This method is used to retrieve all of the basic information about a + * movie collection. You can get the ID needed for this method by making a + * getMovieInfo request for the belongs_to_collection. + * + * @param movieId + * @param language + * @return + */ + public CollectionInfo getCollectionInfo(int movieId, String language) { + try { + URL url = TMDB_COLLECTION_INFO.getIdUrl(movieId); + return mapper.readValue(url, CollectionInfo.class); + } catch (IOException ex) { + return new CollectionInfo(); + } + } + + /** + * Get the configuration information + * + * @return + */ + public TmdbConfiguration getConfiguration() { + return tmdbConfig; + } + + /** + * Generate the full image URL from the size and image path + * + * @param imagePath + * @param requiredSize + * @return + */ + public URL createImageUrl(String imagePath, String requiredSize) { + URL returnUrl = null; + StringBuilder sb; + + if (!tmdbConfig.isValidSize(requiredSize)) { + sb = new StringBuilder(); + sb.append(" - Invalid size requested: ").append(requiredSize); + LOGGER.warn(sb.toString()); + return returnUrl; + } + + try { + sb = new StringBuilder(tmdbConfig.getBaseUrl()); + sb.append(requiredSize); + sb.append(imagePath); + returnUrl = new URL(sb.toString()); + } catch (MalformedURLException ex) { + LOGGER.warn("Failed to create image URL: " + ex.getMessage()); + } + + return returnUrl; + } +} From d65745c1f0dbc1c1b429e7ad4b832dd516490846 Mon Sep 17 00:00:00 2001 From: Omertron Date: Fri, 27 Jan 2012 12:23:54 +0000 Subject: [PATCH 101/207] Finished the ApiUrl class to be more generic for TMDb and IMDb ID values --- .../themoviedb/TheMovieDbTest.java | 231 ++++++++++++++++++ 1 file changed, 231 insertions(+) create mode 100644 themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java diff --git a/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java b/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java new file mode 100644 index 000000000..fc85de573 --- /dev/null +++ b/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java @@ -0,0 +1,231 @@ +/* + * Copyright (c) 2004-2012 YAMJ Members + * http://code.google.com/p/moviejukebox/people/list + * + * Web: http://code.google.com/p/moviejukebox/ + * + * This software is licensed under a Creative Commons License + * See this page: http://code.google.com/p/moviejukebox/wiki/License + * + * For any reuse or distribution, you must make clear to others the + * license terms of this work. + */ +package com.moviejukebox.themoviedb; + +import com.moviejukebox.themoviedb.model.*; +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.util.List; +import org.apache.commons.lang.StringUtils; +import org.apache.log4j.Logger; +import static org.junit.Assert.*; +import org.junit.*; + +/** + * Test cases for TheMovieDb API + * + * @author stuart.boston + */ +public class TheMovieDbTest { + + private static final Logger LOGGER = Logger.getLogger(TheMovieDbTest.class); + private static final String API_KEY = "5a1a77e2eba8984804586122754f969f"; + private static TheMovieDb tmdb; + /* + * Test data + */ + private static final int ID_BLADE_RUNNER = 78; + private static final int ID_STAR_WARS_COLLECTION = 10; + + public TheMovieDbTest() throws IOException { + tmdb = new TheMovieDb(API_KEY); + } + + @BeforeClass + public static void setUpClass() throws Exception { + } + + @AfterClass + public static void tearDownClass() throws Exception { + } + + @Before + public void setUp() { + } + + @After + public void tearDown() { + } + + /** + * Test of getConfiguration method, of class TheMovieDb. + */ + @Test + public void testConfiguration() throws IOException { + LOGGER.info("Test Configuration"); + + TmdbConfiguration tmdbConfig = tmdb.getConfiguration(); + assertNotNull("Configuration failed", tmdbConfig); + assertTrue("No base URL", StringUtils.isNotBlank(tmdbConfig.getBaseUrl())); + assertTrue("No backdrop sizes", tmdbConfig.getBackdropSizes().size() > 0); + assertTrue("No poster sizes", tmdbConfig.getPosterSizes().size() > 0); + assertTrue("No profile sizes", tmdbConfig.getProfileSizes().size() > 0); + LOGGER.info(tmdbConfig.toString()); + } + + /** + * Test of searchMovie method, of class TheMovieDb. + */ + @Test + public void testSearchMovie() throws UnsupportedEncodingException { + LOGGER.info("searchMovie"); + + // Try a movie with less than 1 page of results + List movieList = tmdb.searchMovie("Blade Runner", "", true); + assertTrue("No movies found, should be at least 1", movieList.size() > 0); + + // Try a russian langugage movie + movieList = tmdb.searchMovie("О чём говорят мужчины", "ru", true); + assertTrue("No movies found, should be at least 1", movieList.size() > 0); + + // Try a movie with more than 20 results + movieList = tmdb.searchMovie("Star Wars", "en", false); + assertTrue("Not enough movies found, should be 20", movieList.size() == 20); + } + + /** + * Test of getMovieInfo method, of class TheMovieDb. + */ + @Test + public void testGetMovieInfo() { + LOGGER.info("getMovieInfo"); + String language = "en"; + MovieDB result = tmdb.getMovieInfo(ID_BLADE_RUNNER, language); + assertEquals("Incorrect movie information", "Blade Runner", result.getOriginalTitle()); + } + + /** + * Test of getMovieAlternativeTitles method, of class TheMovieDb. + */ + @Test + public void testGetMovieAlternativeTitles() { + LOGGER.info("getMovieAlternativeTitles"); + String country = ""; + List results = tmdb.getMovieAlternativeTitles(ID_BLADE_RUNNER, country); + assertTrue("No alternative titles found", results.size() > 0); + + country = "US"; + results = tmdb.getMovieAlternativeTitles(ID_BLADE_RUNNER, country); + assertTrue("No alternative titles found", results.size() > 0); + + } + + /** + * Test of getMovieCasts method, of class TheMovieDb. + */ + @Test + public void testGetMovieCasts() { + LOGGER.info("getMovieCasts"); + List people = tmdb.getMovieCasts(ID_BLADE_RUNNER); + assertTrue("No cast information", people.size() > 0); + + String name1 = "Harrison Ford"; + String name2 = "Charles Knode"; + boolean foundName1 = Boolean.FALSE; + boolean foundName2 = Boolean.FALSE; + + for (Person person : people) { + if (!foundName1 && person.getName().equalsIgnoreCase(name1)) { + foundName1 = Boolean.TRUE; + } + + if (!foundName2 && person.getName().equalsIgnoreCase(name2)) { + foundName2 = Boolean.TRUE; + } + } + assertTrue("Couldn't find " + name1, foundName1); + assertTrue("Couldn't find " + name2, foundName2); + + } + + /** + * Test of getMovieImages method, of class TheMovieDb. + */ + @Test + public void testGetMovieImages() { + LOGGER.info("getMovieImages"); + String language = ""; + List result = tmdb.getMovieImages(ID_BLADE_RUNNER, language); + assertFalse("No artwork found", result.isEmpty()); + } + + /** + * Test of getMovieKeywords method, of class TheMovieDb. + */ + @Test + public void testGetMovieKeywords() { + LOGGER.info("getMovieKeywords"); + List result = tmdb.getMovieKeywords(ID_BLADE_RUNNER); + assertFalse("No keywords found", result.isEmpty()); + } + + /** + * Test of getMovieReleaseInfo method, of class TheMovieDb. + */ + @Test + public void testGetMovieReleaseInfo() { + LOGGER.info("getMovieReleaseInfo"); + List result = tmdb.getMovieReleaseInfo(ID_BLADE_RUNNER, ""); + assertFalse("Release information missing", result.isEmpty()); + } + + /** + * Test of getMovieTrailers method, of class TheMovieDb. + */ + @Test + public void testGetMovieTrailers() { + LOGGER.info("getMovieTrailers"); + List result = tmdb.getMovieTrailers(ID_BLADE_RUNNER, ""); + assertFalse("Movie trailers missing", result.isEmpty()); + } + + /** + * Test of getMovieTranslations method, of class TheMovieDb. + */ + @Test + public void testGetMovieTranslations() { + LOGGER.info("getMovieTranslations"); + List result = tmdb.getMovieTranslations(ID_BLADE_RUNNER); + assertFalse("No translations found", result.isEmpty()); + } + + /** + * Test of getCollectionInfo method, of class TheMovieDb. + */ + @Test + public void testGetCollectionInfo() { + LOGGER.info("getCollectionInfo"); + String language = ""; + CollectionInfo result = tmdb.getCollectionInfo(ID_STAR_WARS_COLLECTION, language); + assertFalse("No collection information", result.getParts().isEmpty()); + } + + @Test + public void testCreateImageUrl() { + LOGGER.info("createImageUrl"); + MovieDB movie = tmdb.getMovieInfo(ID_BLADE_RUNNER, ""); + String result = tmdb.createImageUrl(movie.getPosterPath(), "original").toString(); + assertTrue("Error compiling image URL", !result.isEmpty()); + } + + /** + * Test of getMovieInfoImdb method, of class TheMovieDb. + */ + @Test + public void testGetMovieInfoImdb() { + LOGGER.info("getMovieInfoImdb"); + MovieDB result = tmdb.getMovieInfoImdb("tt0076759", "en-US"); + assertTrue("Error getting the movie from IMDB ID", result.getId() == 11); + } + +} From 4602fa29f2de881e6b27eb5d59cb07ad63dcea3f Mon Sep 17 00:00:00 2001 From: Omertron Date: Fri, 27 Jan 2012 16:26:21 +0000 Subject: [PATCH 102/207] Added person methods --- .../moviejukebox/themoviedb/TheMovieDb.java | 121 +++++- .../themoviedb/model/Artwork.java | 2 + .../themoviedb/model/ArtworkType.java | 4 +- .../themoviedb/model/MovieDB.java | 407 ------------------ .../moviejukebox/themoviedb/model/Person.java | 104 ++++- .../themoviedb/model/PersonCredit.java | 156 +++++++ .../themoviedb/model/PersonType.java | 24 ++ ...perMovieImages.java => WrapperImages.java} | 31 +- .../themoviedb/wrapper/WrapperPerson.java | 91 ++++ .../wrapper/WrapperPersonCredits.java | 81 ++++ .../themoviedb/wrapper/WrapperResultList.java | 8 +- .../themoviedb/TheMovieDbTest.java | 109 ++++- 12 files changed, 675 insertions(+), 463 deletions(-) delete mode 100644 themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/MovieDB.java create mode 100644 themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/PersonCredit.java create mode 100644 themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/PersonType.java rename themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/{WrapperMovieImages.java => WrapperImages.java} (87%) create mode 100644 themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperPerson.java create mode 100644 themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperPersonCredits.java diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java index 01d58d6cf..e80336a47 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java @@ -26,7 +26,7 @@ import org.codehaus.jackson.map.DeserializationConfig; import org.codehaus.jackson.map.ObjectMapper; /** - * The MovieDB API. This is for version 3 of the API as specified here: + * The MovieDb API. This is for version 3 of the API as specified here: * http://help.themoviedb.org/kb/api/about-3 * * @author stuart.boston @@ -55,7 +55,7 @@ public class TheMovieDb { private static final ApiUrl TMDB_MOVIE_RELEASE_INFO = new ApiUrl("movie/", "/releases"); private static final ApiUrl TMDB_MOVIE_TRAILERS = new ApiUrl("movie/", "/trailers"); private static final ApiUrl TMDB_MOVIE_TRANSLATIONS = new ApiUrl("movie/", "/translations"); - private static final ApiUrl TMDB_PERSON_INFO = new ApiUrl("person"); + private static final ApiUrl TMDB_PERSON_INFO = new ApiUrl("person/"); private static final ApiUrl TMDB_PERSON_CREDITS = new ApiUrl("person/", "/credits"); private static final ApiUrl TMDB_PERSON_IMAGES = new ApiUrl("person/", "/images"); private static final ApiUrl TMDB_LATEST_MOVIE = new ApiUrl("latest/movie"); @@ -67,6 +67,7 @@ public class TheMovieDb { /** * API for The Movie Db. + * * @param apiKey * @throws IOException */ @@ -91,15 +92,16 @@ public class TheMovieDb { * Search Movies This is a good starting point to start finding movies on * TMDb. The idea is to be a quick and light method so you can iterate * through movies quickly. http://help.themoviedb.org/kb/api/search-movies + * TODO: Make the allResults work */ - public List searchMovie(String movieName, String language, boolean allResults) { + public List searchMovie(String movieName, String language, boolean allResults) { try { URL url = TMDB_SEARCH_MOVIE.getQueryUrl(movieName, language, 1); WrapperResultList resultList = mapper.readValue(url, WrapperResultList.class); return resultList.getResults(); } catch (IOException ex) { LOGGER.warn("Failed to find movie: " + ex.getMessage()); - return new ArrayList(); + return new ArrayList(); } } @@ -111,14 +113,14 @@ public class TheMovieDb { * @param language * @return */ - public MovieDB getMovieInfo(int movieId, String language) { + public MovieDb getMovieInfo(int movieId, String language) { try { URL url = TMDB_MOVIE_INFO.getIdUrl(movieId, language); - return mapper.readValue(url, MovieDB.class); + return mapper.readValue(url, MovieDb.class); } catch (IOException ex) { LOGGER.warn("Failed to get movie info: " + ex.getMessage()); } - return new MovieDB(); + return new MovieDb(); } /** @@ -129,14 +131,14 @@ public class TheMovieDb { * @param language * @return */ - public MovieDB getMovieInfoImdb(String imdbId, String language) { + public MovieDb getMovieInfoImdb(String imdbId, String language) { try { URL url = TMDB_MOVIE_INFO.getIdUrl(imdbId, language); - return mapper.readValue(url, MovieDB.class); + return mapper.readValue(url, MovieDb.class); } catch (IOException ex) { LOGGER.warn("Failed to get movie info: " + ex.getMessage()); } - return new MovieDB(); + return new MovieDb(); } /** @@ -159,7 +161,8 @@ public class TheMovieDb { } /** - * This method is used to retrieve all of the movie cast information. + * This method is used to retrieve all of the movie cast information. TODO: + * Add a function to enrich the data with the people methods * * @param movieId * @return @@ -204,7 +207,7 @@ public class TheMovieDb { List artwork = new ArrayList(); try { URL url = TMDB_MOVIE_IMAGES.getIdUrl(movieId, language); - WrapperMovieImages mi = mapper.readValue(url, WrapperMovieImages.class); + WrapperImages mi = mapper.readValue(url, WrapperImages.class); // Add all the posters to the list for (Artwork poster : mi.getPosters()) { @@ -368,4 +371,98 @@ public class TheMovieDb { return returnUrl; } + + /** + * This is a good starting point to start finding people on TMDb. The idea + * is to be a quick and light method so you can iterate through people + * quickly. TODO: Fix allResults + */ + public List searchPeople(String personName, boolean allResults) { + + try { + URL url = TMDB_SEARCH_PEOPLE.getQueryUrl(personName, "", 1); + WrapperPerson resultList = mapper.readValue(url, WrapperPerson.class); + return resultList.getResults(); + } catch (IOException ex) { + LOGGER.warn("Failed to find person: " + ex.getMessage()); + return new ArrayList(); + } + } + + /** + * This method is used to retrieve all of the basic person information. It + * will return the single highest rated profile image. + * + * @param personId + * @return + */ + public Person getPersonInfo(int personId) { + try { + URL url = TMDB_PERSON_INFO.getIdUrl(personId); + return mapper.readValue(url, Person.class); + } catch (IOException ex) { + LOGGER.warn("Failed to get movie info: " + ex.getMessage()); + return new Person(); + } + } + + /** + * This method is used to retrieve all of the cast & crew information for + * the person. It will return the single highest rated poster for each movie + * record. + * + * @param personId + * @return + */ + public List getPersonCredits(int personId) { + List personCredits = new ArrayList(); + + try { + URL url = TMDB_PERSON_CREDITS.getIdUrl(personId); + WrapperPersonCredits pc = mapper.readValue(url, WrapperPersonCredits.class); + + // Add a cast member + for (PersonCredit cast : pc.getCast()) { + cast.setPersonType(PersonType.CAST); + personCredits.add(cast); + } + + // Add a crew member + for (PersonCredit crew : pc.getCrew()) { + crew.setPersonType(PersonType.CREW); + personCredits.add(crew); + } + + return personCredits; + } catch (IOException ex) { + LOGGER.warn("Failed to get person credits: " + ex.getMessage()); + return personCredits; + } + } + + /** + * This method is used to retrieve all of the profile images for a person. + * + * @param personId + * @return + */ + public List getPersonImages(int personId) { + List personImages = new ArrayList(); + + try { + URL url = TMDB_PERSON_IMAGES.getIdUrl(personId); + WrapperImages images = mapper.readValue(url, WrapperImages.class); + + // Update the image type + for (Artwork artwork : images.getProfiles()) { + artwork.setArtworkType(ArtworkType.PROFILE); + personImages.add(artwork); + } + + return personImages; + } catch (IOException ex) { + LOGGER.warn("Failed to get person images: " + ex.getMessage()); + return personImages; + } + } } diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Artwork.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Artwork.java index 981d25de7..e739de0c1 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Artwork.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Artwork.java @@ -18,6 +18,7 @@ import org.codehaus.jackson.annotate.JsonProperty; /** * The artwork type information + * * @author Stuart */ public class Artwork { @@ -115,6 +116,7 @@ public class Artwork { /** * Handle unknown properties and print a message + * * @param key * @param value */ diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/ArtworkType.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/ArtworkType.java index bc8c32e63..9e952d85d 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/ArtworkType.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/ArtworkType.java @@ -17,5 +17,7 @@ package com.moviejukebox.themoviedb.model; */ public enum ArtworkType { - POSTER, BACKDROP + POSTER, // Poster artwork + BACKDROP, // Fanart/backdrop + PROFILE // Person image } diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/MovieDB.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/MovieDB.java deleted file mode 100644 index 2ae8c93bb..000000000 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/MovieDB.java +++ /dev/null @@ -1,407 +0,0 @@ -/* - * Copyright (c) 2004-2012 YAMJ Members - * http://code.google.com/p/moviejukebox/people/list - * - * Web: http://code.google.com/p/moviejukebox/ - * - * This software is licensed under a Creative Commons License - * See this page: http://code.google.com/p/moviejukebox/wiki/License - * - * For any reuse or distribution, you must make clear to others the - * license terms of this work. - */ -package com.moviejukebox.themoviedb.model; - -import java.util.List; -import org.apache.log4j.Logger; -import org.codehaus.jackson.annotate.JsonAnySetter; -import org.codehaus.jackson.annotate.JsonProperty; - -/** - * Movie Bean - * @author stuart.boston - */ -public class MovieDB { - - /* - * Logger - */ - private static final Logger LOGGER = Logger.getLogger(MovieDB.class); - /* - * Properties - */ - @JsonProperty(("backdrop_path")) - private String backdropPath; - @JsonProperty(("id")) - private int id; - @JsonProperty(("original_title")) - private String originalTitle; - @JsonProperty(("popularity")) - private float popularity; - @JsonProperty(("poster_path")) - private String posterPath; - @JsonProperty(("release_date")) - private String releaseDate; - @JsonProperty(("title")) - private String title; - @JsonProperty("adult") - private boolean adult; - @JsonProperty("belongs_to_collection") - private Collection belongsToCollection; - @JsonProperty("budget") - private int budget; - @JsonProperty("genres") - private List genres; - @JsonProperty("homepage") - private String homepage; - @JsonProperty("imdb_id") - private String imdbID; - @JsonProperty("overview") - private String overview; - @JsonProperty("production_companies") - private List productionCompanies; - @JsonProperty("production_countries") - private List productionCountries; - @JsonProperty("revenue") - private int revenue; - @JsonProperty("runtime") - private int runtime; - @JsonProperty("spoken_languages") - private List spokenLanguages; - @JsonProperty("tagline") - private String tagline; - @JsonProperty("vote_average") - private float voteAverage; - @JsonProperty("vote_count") - private int voteCount; - - // - public String getBackdropPath() { - return backdropPath; - } - - public int getId() { - return id; - } - - public String getOriginalTitle() { - return originalTitle; - } - - public float getPopularity() { - return popularity; - } - - public String getPosterPath() { - return posterPath; - } - - public String getReleaseDate() { - return releaseDate; - } - - public String getTitle() { - return title; - } - - public boolean isAdult() { - return adult; - } - - public Collection getBelongsToCollection() { - return belongsToCollection; - } - - public int getBudget() { - return budget; - } - - public List getGenres() { - return genres; - } - - public String getHomepage() { - return homepage; - } - - public String getImdbID() { - return imdbID; - } - - public String getOverview() { - return overview; - } - - public List getProductionCompanies() { - return productionCompanies; - } - - public List getProductionCountries() { - return productionCountries; - } - - public int getRevenue() { - return revenue; - } - - public int getRuntime() { - return runtime; - } - - public List getSpokenLanguages() { - return spokenLanguages; - } - - public String getTagline() { - return tagline; - } - - public float getVoteAverage() { - return voteAverage; - } - - public int getVoteCount() { - return voteCount; - } - // - - // - public void setBackdropPath(String backdropPath) { - this.backdropPath = backdropPath; - } - - public void setId(int id) { - this.id = id; - } - - public void setOriginalTitle(String originalTitle) { - this.originalTitle = originalTitle; - } - - public void setPopularity(float popularity) { - this.popularity = popularity; - } - - public void setPosterPath(String posterPath) { - this.posterPath = posterPath; - } - - public void setReleaseDate(String releaseDate) { - this.releaseDate = releaseDate; - } - - public void setTitle(String title) { - this.title = title; - } - - public void setAdult(boolean adult) { - this.adult = adult; - } - - public void setBelongsToCollection(Collection belongsToCollection) { - this.belongsToCollection = belongsToCollection; - } - - public void setBudget(int budget) { - this.budget = budget; - } - - public void setGenres(List genres) { - this.genres = genres; - } - - public void setHomepage(String homepage) { - this.homepage = homepage; - } - - public void setImdbID(String imdbID) { - this.imdbID = imdbID; - } - - public void setOverview(String overview) { - this.overview = overview; - } - - public void setProductionCompanies(List productionCompanies) { - this.productionCompanies = productionCompanies; - } - - public void setProductionCountries(List productionCountries) { - this.productionCountries = productionCountries; - } - - public void setRevenue(int revenue) { - this.revenue = revenue; - } - - public void setRuntime(int runtime) { - this.runtime = runtime; - } - - public void setSpokenLanguages(List spokenLanguages) { - this.spokenLanguages = spokenLanguages; - } - - public void setTagline(String tagline) { - this.tagline = tagline; - } - - public void setVoteAverage(float voteAverage) { - this.voteAverage = voteAverage; - } - - public void setVoteCount(int voteCount) { - this.voteCount = voteCount; - } - // - - /** - * Handle unknown properties and print a message - * @param key - * @param value - */ - @JsonAnySetter - public void handleUnknown(String key, Object value) { - StringBuilder sb = new StringBuilder(); - sb.append("Unknown property: '").append(key); - sb.append("' value: '").append(value).append("'"); - LOGGER.warn(sb.toString()); - } - - // - @Override - public boolean equals(Object obj) { - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - final MovieDB other = (MovieDB) obj; - if ((this.backdropPath == null) ? (other.backdropPath != null) : !this.backdropPath.equals(other.backdropPath)) { - return false; - } - if (this.id != other.id) { - return false; - } - if ((this.originalTitle == null) ? (other.originalTitle != null) : !this.originalTitle.equals(other.originalTitle)) { - return false; - } - if (Float.floatToIntBits(this.popularity) != Float.floatToIntBits(other.popularity)) { - return false; - } - if ((this.posterPath == null) ? (other.posterPath != null) : !this.posterPath.equals(other.posterPath)) { - return false; - } - if ((this.releaseDate == null) ? (other.releaseDate != null) : !this.releaseDate.equals(other.releaseDate)) { - return false; - } - if ((this.title == null) ? (other.title != null) : !this.title.equals(other.title)) { - return false; - } - if (this.adult != other.adult) { - return false; - } - if (this.belongsToCollection != other.belongsToCollection && (this.belongsToCollection == null || !this.belongsToCollection.equals(other.belongsToCollection))) { - return false; - } - if (this.budget != other.budget) { - return false; - } - if (this.genres != other.genres && (this.genres == null || !this.genres.equals(other.genres))) { - return false; - } - if ((this.homepage == null) ? (other.homepage != null) : !this.homepage.equals(other.homepage)) { - return false; - } - if ((this.imdbID == null) ? (other.imdbID != null) : !this.imdbID.equals(other.imdbID)) { - return false; - } - if ((this.overview == null) ? (other.overview != null) : !this.overview.equals(other.overview)) { - return false; - } - if (this.productionCompanies != other.productionCompanies && (this.productionCompanies == null || !this.productionCompanies.equals(other.productionCompanies))) { - return false; - } - if (this.productionCountries != other.productionCountries && (this.productionCountries == null || !this.productionCountries.equals(other.productionCountries))) { - return false; - } - if (this.revenue != other.revenue) { - return false; - } - if (this.runtime != other.runtime) { - return false; - } - if (this.spokenLanguages != other.spokenLanguages && (this.spokenLanguages == null || !this.spokenLanguages.equals(other.spokenLanguages))) { - return false; - } - if ((this.tagline == null) ? (other.tagline != null) : !this.tagline.equals(other.tagline)) { - return false; - } - if (Float.floatToIntBits(this.voteAverage) != Float.floatToIntBits(other.voteAverage)) { - return false; - } - if (this.voteCount != other.voteCount) { - return false; - } - return true; - } - - @Override - public int hashCode() { - int hash = 3; - hash = 97 * hash + (this.backdropPath != null ? this.backdropPath.hashCode() : 0); - hash = 97 * hash + this.id; - hash = 97 * hash + (this.originalTitle != null ? this.originalTitle.hashCode() : 0); - hash = 97 * hash + Float.floatToIntBits(this.popularity); - hash = 97 * hash + (this.posterPath != null ? this.posterPath.hashCode() : 0); - hash = 97 * hash + (this.releaseDate != null ? this.releaseDate.hashCode() : 0); - hash = 97 * hash + (this.title != null ? this.title.hashCode() : 0); - hash = 97 * hash + (this.adult ? 1 : 0); - hash = 97 * hash + (this.belongsToCollection != null ? this.belongsToCollection.hashCode() : 0); - hash = 97 * hash + this.budget; - hash = 97 * hash + (this.genres != null ? this.genres.hashCode() : 0); - hash = 97 * hash + (this.homepage != null ? this.homepage.hashCode() : 0); - hash = 97 * hash + (this.imdbID != null ? this.imdbID.hashCode() : 0); - hash = 97 * hash + (this.overview != null ? this.overview.hashCode() : 0); - hash = 97 * hash + (this.productionCompanies != null ? this.productionCompanies.hashCode() : 0); - hash = 97 * hash + (this.productionCountries != null ? this.productionCountries.hashCode() : 0); - hash = 97 * hash + this.revenue; - hash = 97 * hash + this.runtime; - hash = 97 * hash + (this.spokenLanguages != null ? this.spokenLanguages.hashCode() : 0); - hash = 97 * hash + (this.tagline != null ? this.tagline.hashCode() : 0); - hash = 97 * hash + Float.floatToIntBits(this.voteAverage); - hash = 97 * hash + this.voteCount; - return hash; - } - // - - @Override - public String toString() { - StringBuilder sb = new StringBuilder("[MovieDB="); - sb.append("[backdropPath=").append(backdropPath); - sb.append("],[id=").append(id); - sb.append("],[originalTitle=").append(originalTitle); - sb.append("],[popularity=").append(popularity); - sb.append("],[posterPath=").append(posterPath); - sb.append("],[releaseDate=").append(releaseDate); - sb.append("],[title=").append(title); - sb.append("],[adult=").append(adult); - sb.append("],[belongsToCollection=").append(belongsToCollection); - sb.append("],[budget=").append(budget); - sb.append("],[genres=").append(genres); - sb.append("],[homepage=").append(homepage); - sb.append("],[imdbID=").append(imdbID); - sb.append("],[overview=").append(overview); - sb.append("],[productionCompanies=").append(productionCompanies); - sb.append("],[productionCountries=").append(productionCountries); - sb.append("],[revenue=").append(revenue); - sb.append("],[runtime=").append(runtime); - sb.append("],[spokenLanguages=").append(spokenLanguages); - sb.append("],[tagline=").append(tagline); - sb.append("],[voteAverage=").append(voteAverage); - sb.append("],[voteCount=").append(voteCount); - sb.append("]]"); - return sb.toString(); - } -} diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Person.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Person.java index a26b34845..0620be0fc 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Person.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Person.java @@ -12,8 +12,11 @@ */ package com.moviejukebox.themoviedb.model; +import java.util.ArrayList; +import java.util.List; import org.apache.log4j.Logger; import org.codehaus.jackson.annotate.JsonAnySetter; +import org.codehaus.jackson.annotate.JsonProperty; /** * @@ -31,25 +34,39 @@ public class Person { */ private static final String CAST_DEPARTMENT = "acting"; private static final String CAST_JOB = "actor"; + private static final String DEFAULT_STRING = ""; /* * Properties */ + @JsonProperty("id") private int id = -1; + @JsonProperty("name") private String name = ""; - private String profilePath = ""; - private PersonType personType; - private String department = ""; // Crew - private String job = ""; // Crew - private String character = ""; // Cast - private int order = -1; // Cast - - public enum PersonType { - - CAST, CREW - } + @JsonProperty("profile_path") + private String profilePath = DEFAULT_STRING; + private PersonType personType = PersonType.PERSON; + private String department = DEFAULT_STRING; // Crew + private String job = DEFAULT_STRING; // Crew + private String character = DEFAULT_STRING; // Cast + private int order = -1; // Cast + @JsonProperty("adult") + private boolean adult = false; // Person info + @JsonProperty("also_known_as") + private List aka = new ArrayList(); + @JsonProperty("biography") + private String biography = DEFAULT_STRING; + @JsonProperty("birthday") + private String birthday = DEFAULT_STRING; + @JsonProperty("deathday") + private String deathday = DEFAULT_STRING; + @JsonProperty("homepage") + private String homepage = DEFAULT_STRING; + @JsonProperty("place_of_birth") + private String birthplace = DEFAULT_STRING; /** * Add a crew member + * * @param id * @param name * @param profilePath @@ -69,6 +86,7 @@ public class Person { /** * Add a cast member + * * @param id * @param name * @param profilePath @@ -118,6 +136,34 @@ public class Person { public String getProfilePath() { return profilePath; } + + public boolean isAdult() { + return adult; + } + + public List getAka() { + return aka; + } + + public String getBiography() { + return biography; + } + + public String getBirthday() { + return birthday; + } + + public String getBirthplace() { + return birthplace; + } + + public String getDeathday() { + return deathday; + } + + public String getHomepage() { + return homepage; + } // // @@ -152,10 +198,39 @@ public class Person { public void setProfilePath(String profilePath) { this.profilePath = profilePath; } + + public void setAdult(boolean adult) { + this.adult = adult; + } + + public void setAka(List aka) { + this.aka = aka; + } + + public void setBiography(String biography) { + this.biography = biography; + } + + public void setBirthday(String birthday) { + this.birthday = birthday; + } + + public void setBirthplace(String birthplace) { + this.birthplace = birthplace; + } + + public void setDeathday(String deathday) { + this.deathday = deathday; + } + + public void setHomepage(String homepage) { + this.homepage = homepage; + } // /** * Handle unknown properties and print a message + * * @param key * @param value */ @@ -224,6 +299,13 @@ public class Person { sb.append("],[job=").append(job); sb.append("],[character=").append(character); sb.append("],[order=").append(order); + sb.append("],[adult=").append(adult); + sb.append("],[=aka").append(aka.toString()); + sb.append("],[biography=").append(biography); + sb.append("],[birthday=").append(birthday); + sb.append("],[deathday=").append(deathday); + sb.append("],[homepage=").append(homepage); + sb.append("],[birthplace=").append(birthplace); sb.append("]]"); return sb.toString(); } diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/PersonCredit.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/PersonCredit.java new file mode 100644 index 000000000..ab4528d64 --- /dev/null +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/PersonCredit.java @@ -0,0 +1,156 @@ +/* + * Copyright (c) 2004-2012 YAMJ Members + * http://code.google.com/p/moviejukebox/people/list + * + * Web: http://code.google.com/p/moviejukebox/ + * + * This software is licensed under a Creative Commons License + * See this page: http://code.google.com/p/moviejukebox/wiki/License + * + * For any reuse or distribution, you must make clear to others the + * license terms of this work. + */ +package com.moviejukebox.themoviedb.model; + +import org.apache.log4j.Logger; +import org.codehaus.jackson.annotate.JsonAnySetter; +import org.codehaus.jackson.annotate.JsonProperty; + +/** + * + * @author stuart.boston + */ +public class PersonCredit { + /* + * Logger + */ + + private static final Logger LOGGER = Logger.getLogger(PersonCredit.class); + private static final String DEFAULT_STRING = ""; + /* + * Properties + */ + @JsonProperty("id") + private int movieId = 0; + @JsonProperty("character") + private String character = DEFAULT_STRING; + @JsonProperty("original_title") + private String movieOriginalTitle = DEFAULT_STRING; + @JsonProperty("poster_path") + private String posterPath = DEFAULT_STRING; + @JsonProperty("release_date") + private String releaseDate = DEFAULT_STRING; + @JsonProperty("title") + private String movieTitle = DEFAULT_STRING; + @JsonProperty("department") + private String department = DEFAULT_STRING; + @JsonProperty("job") + private String job = DEFAULT_STRING; + private PersonType personType = PersonType.PERSON; + + // + public String getCharacter() { + return character; + } + + public String getDepartment() { + return department; + } + + public String getJob() { + return job; + } + + public int getMovieId() { + return movieId; + } + + public String getMovieOriginalTitle() { + return movieOriginalTitle; + } + + public String getMovieTitle() { + return movieTitle; + } + + public PersonType getPersonType() { + return personType; + } + + public String getPosterPath() { + return posterPath; + } + + public String getReleaseDate() { + return releaseDate; + } + // + + // + public void setCharacter(String character) { + this.character = character; + } + + public void setDepartment(String department) { + this.department = department; + } + + public void setJob(String job) { + this.job = job; + } + + public void setMovieId(int movieId) { + this.movieId = movieId; + } + + public void setMovieOriginalTitle(String movieOriginalTitle) { + this.movieOriginalTitle = movieOriginalTitle; + } + + public void setMovieTitle(String movieTitle) { + this.movieTitle = movieTitle; + } + + public void setPersonType(PersonType personType) { + this.personType = personType; + } + + public void setPosterPath(String posterPath) { + this.posterPath = posterPath; + } + + public void setReleaseDate(String releaseDate) { + this.releaseDate = releaseDate; + } + // + + /** + * Handle unknown properties and print a message + * + * @param key + * @param value + */ + @JsonAnySetter + public void handleUnknown(String key, Object value) { + StringBuilder sb = new StringBuilder(); + sb.append("Unknown property: '").append(key); + sb.append("' value: '").append(value).append("'"); + LOGGER.warn(sb.toString()); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("[PersonCredit="); + sb.append("[movieId=").append(movieId); + sb.append("],[personType=").append(personType); + sb.append("],[originalTitle=").append(movieOriginalTitle); + sb.append("],[movieTitle=").append(movieTitle); + sb.append("],[posterPath=").append(posterPath); + sb.append("],[releaseDate=").append(releaseDate); + sb.append("],[character=").append(character); + sb.append("],[department=").append(department); + sb.append("],[job=").append(job); + sb.append("]]"); + return sb.toString(); + } +} diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/PersonType.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/PersonType.java new file mode 100644 index 000000000..dd3bd1a1d --- /dev/null +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/PersonType.java @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2004-2012 YAMJ Members + * http://code.google.com/p/moviejukebox/people/list + * + * Web: http://code.google.com/p/moviejukebox/ + * + * This software is licensed under a Creative Commons License + * See this page: http://code.google.com/p/moviejukebox/wiki/License + * + * For any reuse or distribution, you must make clear to others the + * license terms of this work. + */ +package com.moviejukebox.themoviedb.model; + +/** + * + * @author stuart.boston + */ +public enum PersonType { + + CAST, // A member of the cast + CREW, // A member of the crew + PERSON // No specific type +} diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperMovieImages.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperImages.java similarity index 87% rename from themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperMovieImages.java rename to themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperImages.java index 3d163d4dc..033eca96f 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperMovieImages.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperImages.java @@ -22,12 +22,12 @@ import org.codehaus.jackson.annotate.JsonProperty; * * @author Stuart */ -public class WrapperMovieImages { +public class WrapperImages { /* * Logger */ - private static final Logger LOGGER = Logger.getLogger(WrapperMovieImages.class); + private static final Logger LOGGER = Logger.getLogger(WrapperImages.class); /* * Properties */ @@ -37,37 +37,48 @@ public class WrapperMovieImages { private List backdrops; @JsonProperty("posters") private List posters; + @JsonProperty("profiles") + private List profiles; // - public List getBackdrops() { - return backdrops; - } - public int getId() { return id; } + public List getBackdrops() { + return backdrops; + } + public List getPosters() { return posters; } + + public List getProfiles() { + return profiles; + } // // - public void setBackdrops(List backdrops) { - this.backdrops = backdrops; - } - public void setId(int id) { this.id = id; } + public void setBackdrops(List backdrops) { + this.backdrops = backdrops; + } + public void setPosters(List posters) { this.posters = posters; } + + public void setProfiles(List profiles) { + this.profiles = profiles; + } // /** * Handle unknown properties and print a message + * * @param key * @param value */ diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperPerson.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperPerson.java new file mode 100644 index 000000000..e6d4cc6a8 --- /dev/null +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperPerson.java @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2004-2012 YAMJ Members + * http://code.google.com/p/moviejukebox/people/list + * + * Web: http://code.google.com/p/moviejukebox/ + * + * This software is licensed under a Creative Commons License + * See this page: http://code.google.com/p/moviejukebox/wiki/License + * + * For any reuse or distribution, you must make clear to others the + * license terms of this work. + */ +package com.moviejukebox.themoviedb.wrapper; + +import com.moviejukebox.themoviedb.model.Person; +import java.util.List; +import org.apache.log4j.Logger; +import org.codehaus.jackson.annotate.JsonAnySetter; +import org.codehaus.jackson.annotate.JsonProperty; + +/** + * + * @author stuart.boston + */ +public class WrapperPerson { + /* + * Logger + */ + + private static final Logger LOGGER = Logger.getLogger(WrapperPerson.class); + /* + * Properties + */ + @JsonProperty("page") + private int page; + @JsonProperty("results") + private List results; + @JsonProperty("total_pages") + private int totalPages; + @JsonProperty("total_results") + private int totalResults; + + // + public int getPage() { + return page; + } + + public List getResults() { + return results; + } + + public int getTotalPages() { + return totalPages; + } + + public int getTotalResults() { + return totalResults; + } + // + + // + public void setPage(int page) { + this.page = page; + } + + public void setResults(List results) { + this.results = results; + } + + public void setTotalPages(int totalPages) { + this.totalPages = totalPages; + } + + public void setTotalResults(int totalResults) { + this.totalResults = totalResults; + } + // + + /** + * Handle unknown properties and print a message + * @param key + * @param value + */ + @JsonAnySetter + public void handleUnknown(String key, Object value) { + StringBuilder sb = new StringBuilder(); + sb.append("Unknown property: '").append(key); + sb.append("' value: '").append(value).append("'"); + LOGGER.warn(sb.toString()); + } +} diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperPersonCredits.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperPersonCredits.java new file mode 100644 index 000000000..034494b92 --- /dev/null +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperPersonCredits.java @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2004-2012 YAMJ Members + * http://code.google.com/p/moviejukebox/people/list + * + * Web: http://code.google.com/p/moviejukebox/ + * + * This software is licensed under a Creative Commons License + * See this page: http://code.google.com/p/moviejukebox/wiki/License + * + * For any reuse or distribution, you must make clear to others the + * license terms of this work. + */ +package com.moviejukebox.themoviedb.wrapper; + +import com.moviejukebox.themoviedb.model.PersonCredit; +import java.util.List; +import org.apache.log4j.Logger; +import org.codehaus.jackson.annotate.JsonAnySetter; +import org.codehaus.jackson.annotate.JsonProperty; + +/** + * + * @author stuart.boston + */ +public class WrapperPersonCredits { + /* + * Logger + */ + + private static final Logger LOGGER = Logger.getLogger(WrapperMovieCasts.class); + /* + * Properties + */ + @JsonProperty("id") + private int id; + @JsonProperty("cast") + private List cast; + @JsonProperty("crew") + private List crew; + + // + public List getCast() { + return cast; + } + + public List getCrew() { + return crew; + } + + public int getId() { + return id; + } + // + + // + public void setCast(List cast) { + this.cast = cast; + } + + public void setCrew(List crew) { + this.crew = crew; + } + + public void setId(int id) { + this.id = id; + } + // + + /** + * Handle unknown properties and print a message + * @param key + * @param value + */ + @JsonAnySetter + public void handleUnknown(String key, Object value) { + StringBuilder sb = new StringBuilder(); + sb.append("Unknown property: '").append(key); + sb.append("' value: '").append(value).append("'"); + LOGGER.warn(sb.toString()); + } +} diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperResultList.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperResultList.java index 8a2519fef..2badd7726 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperResultList.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperResultList.java @@ -12,7 +12,7 @@ */ package com.moviejukebox.themoviedb.wrapper; -import com.moviejukebox.themoviedb.model.MovieDB; +import com.moviejukebox.themoviedb.model.MovieDb; import java.util.List; import org.apache.log4j.Logger; import org.codehaus.jackson.annotate.JsonAnySetter; @@ -34,7 +34,7 @@ public class WrapperResultList { @JsonProperty("page") private int page; @JsonProperty("results") - private List results; + private List results; @JsonProperty("total_pages") private int totalPages; @JsonProperty("total_results") @@ -45,7 +45,7 @@ public class WrapperResultList { return page; } - public List getResults() { + public List getResults() { return results; } @@ -63,7 +63,7 @@ public class WrapperResultList { this.page = page; } - public void setResults(List results) { + public void setResults(List results) { this.results = results; } diff --git a/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java b/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java index fc85de573..c7e9a90ef 100644 --- a/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java +++ b/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java @@ -36,6 +36,7 @@ public class TheMovieDbTest { */ private static final int ID_BLADE_RUNNER = 78; private static final int ID_STAR_WARS_COLLECTION = 10; + private static final int ID_BRUCE_WILLIS = 62; public TheMovieDbTest() throws IOException { tmdb = new TheMovieDb(API_KEY); @@ -60,7 +61,7 @@ public class TheMovieDbTest { /** * Test of getConfiguration method, of class TheMovieDb. */ - @Test + //@Test public void testConfiguration() throws IOException { LOGGER.info("Test Configuration"); @@ -76,12 +77,12 @@ public class TheMovieDbTest { /** * Test of searchMovie method, of class TheMovieDb. */ - @Test + //@Test public void testSearchMovie() throws UnsupportedEncodingException { LOGGER.info("searchMovie"); // Try a movie with less than 1 page of results - List movieList = tmdb.searchMovie("Blade Runner", "", true); + List movieList = tmdb.searchMovie("Blade Runner", "", true); assertTrue("No movies found, should be at least 1", movieList.size() > 0); // Try a russian langugage movie @@ -96,18 +97,18 @@ public class TheMovieDbTest { /** * Test of getMovieInfo method, of class TheMovieDb. */ - @Test + //@Test public void testGetMovieInfo() { LOGGER.info("getMovieInfo"); String language = "en"; - MovieDB result = tmdb.getMovieInfo(ID_BLADE_RUNNER, language); + MovieDb result = tmdb.getMovieInfo(ID_BLADE_RUNNER, language); assertEquals("Incorrect movie information", "Blade Runner", result.getOriginalTitle()); } /** * Test of getMovieAlternativeTitles method, of class TheMovieDb. */ - @Test + //@Test public void testGetMovieAlternativeTitles() { LOGGER.info("getMovieAlternativeTitles"); String country = ""; @@ -123,7 +124,7 @@ public class TheMovieDbTest { /** * Test of getMovieCasts method, of class TheMovieDb. */ - @Test + //@Test public void testGetMovieCasts() { LOGGER.info("getMovieCasts"); List people = tmdb.getMovieCasts(ID_BLADE_RUNNER); @@ -145,13 +146,12 @@ public class TheMovieDbTest { } assertTrue("Couldn't find " + name1, foundName1); assertTrue("Couldn't find " + name2, foundName2); - } /** * Test of getMovieImages method, of class TheMovieDb. */ - @Test + //@Test public void testGetMovieImages() { LOGGER.info("getMovieImages"); String language = ""; @@ -162,7 +162,7 @@ public class TheMovieDbTest { /** * Test of getMovieKeywords method, of class TheMovieDb. */ - @Test + //@Test public void testGetMovieKeywords() { LOGGER.info("getMovieKeywords"); List result = tmdb.getMovieKeywords(ID_BLADE_RUNNER); @@ -172,7 +172,7 @@ public class TheMovieDbTest { /** * Test of getMovieReleaseInfo method, of class TheMovieDb. */ - @Test + //@Test public void testGetMovieReleaseInfo() { LOGGER.info("getMovieReleaseInfo"); List result = tmdb.getMovieReleaseInfo(ID_BLADE_RUNNER, ""); @@ -182,7 +182,7 @@ public class TheMovieDbTest { /** * Test of getMovieTrailers method, of class TheMovieDb. */ - @Test + //@Test public void testGetMovieTrailers() { LOGGER.info("getMovieTrailers"); List result = tmdb.getMovieTrailers(ID_BLADE_RUNNER, ""); @@ -192,7 +192,7 @@ public class TheMovieDbTest { /** * Test of getMovieTranslations method, of class TheMovieDb. */ - @Test + //@Test public void testGetMovieTranslations() { LOGGER.info("getMovieTranslations"); List result = tmdb.getMovieTranslations(ID_BLADE_RUNNER); @@ -202,7 +202,7 @@ public class TheMovieDbTest { /** * Test of getCollectionInfo method, of class TheMovieDb. */ - @Test + //@Test public void testGetCollectionInfo() { LOGGER.info("getCollectionInfo"); String language = ""; @@ -210,10 +210,10 @@ public class TheMovieDbTest { assertFalse("No collection information", result.getParts().isEmpty()); } - @Test + //@Test public void testCreateImageUrl() { LOGGER.info("createImageUrl"); - MovieDB movie = tmdb.getMovieInfo(ID_BLADE_RUNNER, ""); + MovieDb movie = tmdb.getMovieInfo(ID_BLADE_RUNNER, ""); String result = tmdb.createImageUrl(movie.getPosterPath(), "original").toString(); assertTrue("Error compiling image URL", !result.isEmpty()); } @@ -221,11 +221,84 @@ public class TheMovieDbTest { /** * Test of getMovieInfoImdb method, of class TheMovieDb. */ - @Test + //@Test public void testGetMovieInfoImdb() { LOGGER.info("getMovieInfoImdb"); - MovieDB result = tmdb.getMovieInfoImdb("tt0076759", "en-US"); + MovieDb result = tmdb.getMovieInfoImdb("tt0076759", "en-US"); assertTrue("Error getting the movie from IMDB ID", result.getId() == 11); } + /** + * Test of getApiKey method, of class TheMovieDb. + */ + //@Test + public void testGetApiKey() { + // Not required + } + + /** + * Test of getApiBase method, of class TheMovieDb. + */ + //@Test + public void testGetApiBase() { + // Not required + } + + /** + * Test of getConfiguration method, of class TheMovieDb. + */ + //@Test + public void testGetConfiguration() { + // Not required + } + + /** + * Test of searchPeople method, of class TheMovieDb. + */ + @Test + public void testSearchPeople() { + LOGGER.info("searchPeople"); + String personName = "Bruce Willis"; + boolean allResults = false; + List result = tmdb.searchPeople(personName, allResults); + assertTrue("Couldn't find the person", result.size() > 0); + } + + /** + * Test of getPersonInfo method, of class TheMovieDb. + */ + @Test + public void testGetPersonInfo() { + LOGGER.info("getPersonInfo"); + Person result = tmdb.getPersonInfo(ID_BRUCE_WILLIS); + assertTrue("Wrong actor returned", result.getId() == ID_BRUCE_WILLIS); + } + + /** + * Test of getPersonCredits method, of class TheMovieDb. + */ + @Test + public void testGetPersonCredits() { + LOGGER.info("getPersonCredits"); + + List people = tmdb.getPersonCredits(ID_BRUCE_WILLIS); + assertTrue("No cast information", people.size() > 0); + } + + /** + * Test of getPersonImages method, of class TheMovieDb. + */ + @Test + public void testGetPersonImages() { + LOGGER.info("getPersonImages"); + + List artwork = tmdb.getPersonImages(ID_BRUCE_WILLIS); + assertTrue("No cast information", artwork.size() > 0); + + for(Artwork a:artwork) { + LOGGER.info(" " + a.toString()); + } + + } + } From 19e73c6b1abe64b7670e32b0218bf99654f56821 Mon Sep 17 00:00:00 2001 From: Omertron Date: Fri, 27 Jan 2012 16:35:39 +0000 Subject: [PATCH 103/207] Added back MovieDb --- .../themoviedb/model/MovieDb.java | 407 ++++++++++++++++++ 1 file changed, 407 insertions(+) create mode 100644 themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/MovieDb.java diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/MovieDb.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/MovieDb.java new file mode 100644 index 000000000..e96e39277 --- /dev/null +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/MovieDb.java @@ -0,0 +1,407 @@ +/* + * Copyright (c) 2004-2012 YAMJ Members + * http://code.google.com/p/moviejukebox/people/list + * + * Web: http://code.google.com/p/moviejukebox/ + * + * This software is licensed under a Creative Commons License + * See this page: http://code.google.com/p/moviejukebox/wiki/License + * + * For any reuse or distribution, you must make clear to others the + * license terms of this work. + */ +package com.moviejukebox.themoviedb.model; + +import java.util.List; +import org.apache.log4j.Logger; +import org.codehaus.jackson.annotate.JsonAnySetter; +import org.codehaus.jackson.annotate.JsonProperty; + +/** + * Movie Bean + * @author stuart.boston + */ +public class MovieDb { + + /* + * Logger + */ + private static final Logger LOGGER = Logger.getLogger(MovieDb.class); + /* + * Properties + */ + @JsonProperty(("backdrop_path")) + private String backdropPath; + @JsonProperty(("id")) + private int id; + @JsonProperty(("original_title")) + private String originalTitle; + @JsonProperty(("popularity")) + private float popularity; + @JsonProperty(("poster_path")) + private String posterPath; + @JsonProperty(("release_date")) + private String releaseDate; + @JsonProperty(("title")) + private String title; + @JsonProperty("adult") + private boolean adult; + @JsonProperty("belongs_to_collection") + private Collection belongsToCollection; + @JsonProperty("budget") + private int budget; + @JsonProperty("genres") + private List genres; + @JsonProperty("homepage") + private String homepage; + @JsonProperty("imdb_id") + private String imdbID; + @JsonProperty("overview") + private String overview; + @JsonProperty("production_companies") + private List productionCompanies; + @JsonProperty("production_countries") + private List productionCountries; + @JsonProperty("revenue") + private int revenue; + @JsonProperty("runtime") + private int runtime; + @JsonProperty("spoken_languages") + private List spokenLanguages; + @JsonProperty("tagline") + private String tagline; + @JsonProperty("vote_average") + private float voteAverage; + @JsonProperty("vote_count") + private int voteCount; + + // + public String getBackdropPath() { + return backdropPath; + } + + public int getId() { + return id; + } + + public String getOriginalTitle() { + return originalTitle; + } + + public float getPopularity() { + return popularity; + } + + public String getPosterPath() { + return posterPath; + } + + public String getReleaseDate() { + return releaseDate; + } + + public String getTitle() { + return title; + } + + public boolean isAdult() { + return adult; + } + + public Collection getBelongsToCollection() { + return belongsToCollection; + } + + public int getBudget() { + return budget; + } + + public List getGenres() { + return genres; + } + + public String getHomepage() { + return homepage; + } + + public String getImdbID() { + return imdbID; + } + + public String getOverview() { + return overview; + } + + public List getProductionCompanies() { + return productionCompanies; + } + + public List getProductionCountries() { + return productionCountries; + } + + public int getRevenue() { + return revenue; + } + + public int getRuntime() { + return runtime; + } + + public List getSpokenLanguages() { + return spokenLanguages; + } + + public String getTagline() { + return tagline; + } + + public float getVoteAverage() { + return voteAverage; + } + + public int getVoteCount() { + return voteCount; + } + // + + // + public void setBackdropPath(String backdropPath) { + this.backdropPath = backdropPath; + } + + public void setId(int id) { + this.id = id; + } + + public void setOriginalTitle(String originalTitle) { + this.originalTitle = originalTitle; + } + + public void setPopularity(float popularity) { + this.popularity = popularity; + } + + public void setPosterPath(String posterPath) { + this.posterPath = posterPath; + } + + public void setReleaseDate(String releaseDate) { + this.releaseDate = releaseDate; + } + + public void setTitle(String title) { + this.title = title; + } + + public void setAdult(boolean adult) { + this.adult = adult; + } + + public void setBelongsToCollection(Collection belongsToCollection) { + this.belongsToCollection = belongsToCollection; + } + + public void setBudget(int budget) { + this.budget = budget; + } + + public void setGenres(List genres) { + this.genres = genres; + } + + public void setHomepage(String homepage) { + this.homepage = homepage; + } + + public void setImdbID(String imdbID) { + this.imdbID = imdbID; + } + + public void setOverview(String overview) { + this.overview = overview; + } + + public void setProductionCompanies(List productionCompanies) { + this.productionCompanies = productionCompanies; + } + + public void setProductionCountries(List productionCountries) { + this.productionCountries = productionCountries; + } + + public void setRevenue(int revenue) { + this.revenue = revenue; + } + + public void setRuntime(int runtime) { + this.runtime = runtime; + } + + public void setSpokenLanguages(List spokenLanguages) { + this.spokenLanguages = spokenLanguages; + } + + public void setTagline(String tagline) { + this.tagline = tagline; + } + + public void setVoteAverage(float voteAverage) { + this.voteAverage = voteAverage; + } + + public void setVoteCount(int voteCount) { + this.voteCount = voteCount; + } + // + + /** + * Handle unknown properties and print a message + * @param key + * @param value + */ + @JsonAnySetter + public void handleUnknown(String key, Object value) { + StringBuilder sb = new StringBuilder(); + sb.append("Unknown property: '").append(key); + sb.append("' value: '").append(value).append("'"); + LOGGER.warn(sb.toString()); + } + + // + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final MovieDb other = (MovieDb) obj; + if ((this.backdropPath == null) ? (other.backdropPath != null) : !this.backdropPath.equals(other.backdropPath)) { + return false; + } + if (this.id != other.id) { + return false; + } + if ((this.originalTitle == null) ? (other.originalTitle != null) : !this.originalTitle.equals(other.originalTitle)) { + return false; + } + if (Float.floatToIntBits(this.popularity) != Float.floatToIntBits(other.popularity)) { + return false; + } + if ((this.posterPath == null) ? (other.posterPath != null) : !this.posterPath.equals(other.posterPath)) { + return false; + } + if ((this.releaseDate == null) ? (other.releaseDate != null) : !this.releaseDate.equals(other.releaseDate)) { + return false; + } + if ((this.title == null) ? (other.title != null) : !this.title.equals(other.title)) { + return false; + } + if (this.adult != other.adult) { + return false; + } + if (this.belongsToCollection != other.belongsToCollection && (this.belongsToCollection == null || !this.belongsToCollection.equals(other.belongsToCollection))) { + return false; + } + if (this.budget != other.budget) { + return false; + } + if (this.genres != other.genres && (this.genres == null || !this.genres.equals(other.genres))) { + return false; + } + if ((this.homepage == null) ? (other.homepage != null) : !this.homepage.equals(other.homepage)) { + return false; + } + if ((this.imdbID == null) ? (other.imdbID != null) : !this.imdbID.equals(other.imdbID)) { + return false; + } + if ((this.overview == null) ? (other.overview != null) : !this.overview.equals(other.overview)) { + return false; + } + if (this.productionCompanies != other.productionCompanies && (this.productionCompanies == null || !this.productionCompanies.equals(other.productionCompanies))) { + return false; + } + if (this.productionCountries != other.productionCountries && (this.productionCountries == null || !this.productionCountries.equals(other.productionCountries))) { + return false; + } + if (this.revenue != other.revenue) { + return false; + } + if (this.runtime != other.runtime) { + return false; + } + if (this.spokenLanguages != other.spokenLanguages && (this.spokenLanguages == null || !this.spokenLanguages.equals(other.spokenLanguages))) { + return false; + } + if ((this.tagline == null) ? (other.tagline != null) : !this.tagline.equals(other.tagline)) { + return false; + } + if (Float.floatToIntBits(this.voteAverage) != Float.floatToIntBits(other.voteAverage)) { + return false; + } + if (this.voteCount != other.voteCount) { + return false; + } + return true; + } + + @Override + public int hashCode() { + int hash = 3; + hash = 97 * hash + (this.backdropPath != null ? this.backdropPath.hashCode() : 0); + hash = 97 * hash + this.id; + hash = 97 * hash + (this.originalTitle != null ? this.originalTitle.hashCode() : 0); + hash = 97 * hash + Float.floatToIntBits(this.popularity); + hash = 97 * hash + (this.posterPath != null ? this.posterPath.hashCode() : 0); + hash = 97 * hash + (this.releaseDate != null ? this.releaseDate.hashCode() : 0); + hash = 97 * hash + (this.title != null ? this.title.hashCode() : 0); + hash = 97 * hash + (this.adult ? 1 : 0); + hash = 97 * hash + (this.belongsToCollection != null ? this.belongsToCollection.hashCode() : 0); + hash = 97 * hash + this.budget; + hash = 97 * hash + (this.genres != null ? this.genres.hashCode() : 0); + hash = 97 * hash + (this.homepage != null ? this.homepage.hashCode() : 0); + hash = 97 * hash + (this.imdbID != null ? this.imdbID.hashCode() : 0); + hash = 97 * hash + (this.overview != null ? this.overview.hashCode() : 0); + hash = 97 * hash + (this.productionCompanies != null ? this.productionCompanies.hashCode() : 0); + hash = 97 * hash + (this.productionCountries != null ? this.productionCountries.hashCode() : 0); + hash = 97 * hash + this.revenue; + hash = 97 * hash + this.runtime; + hash = 97 * hash + (this.spokenLanguages != null ? this.spokenLanguages.hashCode() : 0); + hash = 97 * hash + (this.tagline != null ? this.tagline.hashCode() : 0); + hash = 97 * hash + Float.floatToIntBits(this.voteAverage); + hash = 97 * hash + this.voteCount; + return hash; + } + // + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("[MovieDB="); + sb.append("[backdropPath=").append(backdropPath); + sb.append("],[id=").append(id); + sb.append("],[originalTitle=").append(originalTitle); + sb.append("],[popularity=").append(popularity); + sb.append("],[posterPath=").append(posterPath); + sb.append("],[releaseDate=").append(releaseDate); + sb.append("],[title=").append(title); + sb.append("],[adult=").append(adult); + sb.append("],[belongsToCollection=").append(belongsToCollection); + sb.append("],[budget=").append(budget); + sb.append("],[genres=").append(genres); + sb.append("],[homepage=").append(homepage); + sb.append("],[imdbID=").append(imdbID); + sb.append("],[overview=").append(overview); + sb.append("],[productionCompanies=").append(productionCompanies); + sb.append("],[productionCountries=").append(productionCountries); + sb.append("],[revenue=").append(revenue); + sb.append("],[runtime=").append(runtime); + sb.append("],[spokenLanguages=").append(spokenLanguages); + sb.append("],[tagline=").append(tagline); + sb.append("],[voteAverage=").append(voteAverage); + sb.append("],[voteCount=").append(voteCount); + sb.append("]]"); + return sb.toString(); + } +} From 054dedc43488568f15576af0cd35aed57417d538 Mon Sep 17 00:00:00 2001 From: Omertron Date: Fri, 27 Jan 2012 19:01:06 +0000 Subject: [PATCH 104/207] Remove duplicate file --- .../themoviedb/TheMovieDBTest.java | 231 ------------------ 1 file changed, 231 deletions(-) delete mode 100644 themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDBTest.java diff --git a/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDBTest.java b/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDBTest.java deleted file mode 100644 index fc85de573..000000000 --- a/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDBTest.java +++ /dev/null @@ -1,231 +0,0 @@ -/* - * Copyright (c) 2004-2012 YAMJ Members - * http://code.google.com/p/moviejukebox/people/list - * - * Web: http://code.google.com/p/moviejukebox/ - * - * This software is licensed under a Creative Commons License - * See this page: http://code.google.com/p/moviejukebox/wiki/License - * - * For any reuse or distribution, you must make clear to others the - * license terms of this work. - */ -package com.moviejukebox.themoviedb; - -import com.moviejukebox.themoviedb.model.*; -import java.io.IOException; -import java.io.UnsupportedEncodingException; -import java.util.List; -import org.apache.commons.lang.StringUtils; -import org.apache.log4j.Logger; -import static org.junit.Assert.*; -import org.junit.*; - -/** - * Test cases for TheMovieDb API - * - * @author stuart.boston - */ -public class TheMovieDbTest { - - private static final Logger LOGGER = Logger.getLogger(TheMovieDbTest.class); - private static final String API_KEY = "5a1a77e2eba8984804586122754f969f"; - private static TheMovieDb tmdb; - /* - * Test data - */ - private static final int ID_BLADE_RUNNER = 78; - private static final int ID_STAR_WARS_COLLECTION = 10; - - public TheMovieDbTest() throws IOException { - tmdb = new TheMovieDb(API_KEY); - } - - @BeforeClass - public static void setUpClass() throws Exception { - } - - @AfterClass - public static void tearDownClass() throws Exception { - } - - @Before - public void setUp() { - } - - @After - public void tearDown() { - } - - /** - * Test of getConfiguration method, of class TheMovieDb. - */ - @Test - public void testConfiguration() throws IOException { - LOGGER.info("Test Configuration"); - - TmdbConfiguration tmdbConfig = tmdb.getConfiguration(); - assertNotNull("Configuration failed", tmdbConfig); - assertTrue("No base URL", StringUtils.isNotBlank(tmdbConfig.getBaseUrl())); - assertTrue("No backdrop sizes", tmdbConfig.getBackdropSizes().size() > 0); - assertTrue("No poster sizes", tmdbConfig.getPosterSizes().size() > 0); - assertTrue("No profile sizes", tmdbConfig.getProfileSizes().size() > 0); - LOGGER.info(tmdbConfig.toString()); - } - - /** - * Test of searchMovie method, of class TheMovieDb. - */ - @Test - public void testSearchMovie() throws UnsupportedEncodingException { - LOGGER.info("searchMovie"); - - // Try a movie with less than 1 page of results - List movieList = tmdb.searchMovie("Blade Runner", "", true); - assertTrue("No movies found, should be at least 1", movieList.size() > 0); - - // Try a russian langugage movie - movieList = tmdb.searchMovie("О чём говорят мужчины", "ru", true); - assertTrue("No movies found, should be at least 1", movieList.size() > 0); - - // Try a movie with more than 20 results - movieList = tmdb.searchMovie("Star Wars", "en", false); - assertTrue("Not enough movies found, should be 20", movieList.size() == 20); - } - - /** - * Test of getMovieInfo method, of class TheMovieDb. - */ - @Test - public void testGetMovieInfo() { - LOGGER.info("getMovieInfo"); - String language = "en"; - MovieDB result = tmdb.getMovieInfo(ID_BLADE_RUNNER, language); - assertEquals("Incorrect movie information", "Blade Runner", result.getOriginalTitle()); - } - - /** - * Test of getMovieAlternativeTitles method, of class TheMovieDb. - */ - @Test - public void testGetMovieAlternativeTitles() { - LOGGER.info("getMovieAlternativeTitles"); - String country = ""; - List results = tmdb.getMovieAlternativeTitles(ID_BLADE_RUNNER, country); - assertTrue("No alternative titles found", results.size() > 0); - - country = "US"; - results = tmdb.getMovieAlternativeTitles(ID_BLADE_RUNNER, country); - assertTrue("No alternative titles found", results.size() > 0); - - } - - /** - * Test of getMovieCasts method, of class TheMovieDb. - */ - @Test - public void testGetMovieCasts() { - LOGGER.info("getMovieCasts"); - List people = tmdb.getMovieCasts(ID_BLADE_RUNNER); - assertTrue("No cast information", people.size() > 0); - - String name1 = "Harrison Ford"; - String name2 = "Charles Knode"; - boolean foundName1 = Boolean.FALSE; - boolean foundName2 = Boolean.FALSE; - - for (Person person : people) { - if (!foundName1 && person.getName().equalsIgnoreCase(name1)) { - foundName1 = Boolean.TRUE; - } - - if (!foundName2 && person.getName().equalsIgnoreCase(name2)) { - foundName2 = Boolean.TRUE; - } - } - assertTrue("Couldn't find " + name1, foundName1); - assertTrue("Couldn't find " + name2, foundName2); - - } - - /** - * Test of getMovieImages method, of class TheMovieDb. - */ - @Test - public void testGetMovieImages() { - LOGGER.info("getMovieImages"); - String language = ""; - List result = tmdb.getMovieImages(ID_BLADE_RUNNER, language); - assertFalse("No artwork found", result.isEmpty()); - } - - /** - * Test of getMovieKeywords method, of class TheMovieDb. - */ - @Test - public void testGetMovieKeywords() { - LOGGER.info("getMovieKeywords"); - List result = tmdb.getMovieKeywords(ID_BLADE_RUNNER); - assertFalse("No keywords found", result.isEmpty()); - } - - /** - * Test of getMovieReleaseInfo method, of class TheMovieDb. - */ - @Test - public void testGetMovieReleaseInfo() { - LOGGER.info("getMovieReleaseInfo"); - List result = tmdb.getMovieReleaseInfo(ID_BLADE_RUNNER, ""); - assertFalse("Release information missing", result.isEmpty()); - } - - /** - * Test of getMovieTrailers method, of class TheMovieDb. - */ - @Test - public void testGetMovieTrailers() { - LOGGER.info("getMovieTrailers"); - List result = tmdb.getMovieTrailers(ID_BLADE_RUNNER, ""); - assertFalse("Movie trailers missing", result.isEmpty()); - } - - /** - * Test of getMovieTranslations method, of class TheMovieDb. - */ - @Test - public void testGetMovieTranslations() { - LOGGER.info("getMovieTranslations"); - List result = tmdb.getMovieTranslations(ID_BLADE_RUNNER); - assertFalse("No translations found", result.isEmpty()); - } - - /** - * Test of getCollectionInfo method, of class TheMovieDb. - */ - @Test - public void testGetCollectionInfo() { - LOGGER.info("getCollectionInfo"); - String language = ""; - CollectionInfo result = tmdb.getCollectionInfo(ID_STAR_WARS_COLLECTION, language); - assertFalse("No collection information", result.getParts().isEmpty()); - } - - @Test - public void testCreateImageUrl() { - LOGGER.info("createImageUrl"); - MovieDB movie = tmdb.getMovieInfo(ID_BLADE_RUNNER, ""); - String result = tmdb.createImageUrl(movie.getPosterPath(), "original").toString(); - assertTrue("Error compiling image URL", !result.isEmpty()); - } - - /** - * Test of getMovieInfoImdb method, of class TheMovieDb. - */ - @Test - public void testGetMovieInfoImdb() { - LOGGER.info("getMovieInfoImdb"); - MovieDB result = tmdb.getMovieInfoImdb("tt0076759", "en-US"); - assertTrue("Error getting the movie from IMDB ID", result.getId() == 11); - } - -} From 04be080e88b7f2a0e2c0d8188d0db1751fd05d0c Mon Sep 17 00:00:00 2001 From: Omertron Date: Fri, 27 Jan 2012 21:17:08 +0000 Subject: [PATCH 105/207] Added compare function for movies --- .../moviejukebox/themoviedb/TheMovieDb.java | 40 +++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java index e80336a47..22e619882 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java @@ -21,6 +21,7 @@ import java.net.MalformedURLException; import java.net.URL; import java.util.ArrayList; import java.util.List; +import org.apache.commons.lang.StringUtils; import org.apache.log4j.Logger; import org.codehaus.jackson.map.DeserializationConfig; import org.codehaus.jackson.map.ObjectMapper; @@ -465,4 +466,43 @@ public class TheMovieDb { return personImages; } } + + /** + * Compare the MovieDB object with a title & year + * @param moviedb The moviedb object to compare too + * @param title The title of the movie to compare + * @param year The year of the movie to compare + * @return True if there is a match, False otherwise. + */ + public static boolean compareMovies(MovieDb moviedb, String title, String year) { + if ((moviedb == null) || (StringUtils.isBlank(title))) { + return false; + } + + if (StringUtils.isNotBlank(year)) { + if (StringUtils.isNotBlank(moviedb.getReleaseDate())) { + // Compare with year + String movieYear = moviedb.getReleaseDate().substring(0, 4); + if (movieYear.equals(year)) { + if (moviedb.getOriginalTitle().equalsIgnoreCase(title)) { + return true; + } + + if (moviedb.getTitle().equalsIgnoreCase(title)) { + return true; + } + } + } + } else { + // Compare without year + if (moviedb.getOriginalTitle().equalsIgnoreCase(title)) { + return true; + } + + if (moviedb.getTitle().equalsIgnoreCase(title)) { + return true; + } + } + return false; + } } From acf43320a8d605d196e66c29190234250b2fc17c Mon Sep 17 00:00:00 2001 From: Omertron Date: Sun, 29 Jan 2012 22:08:39 +0000 Subject: [PATCH 106/207] Updated tests --- .../themoviedb/model/TmdbConfiguration.java | 10 +++++ .../themoviedb/TheMovieDbTest.java | 37 ++++++++----------- 2 files changed, 26 insertions(+), 21 deletions(-) diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/TmdbConfiguration.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/TmdbConfiguration.java index 7a25d1684..70a32c0c2 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/TmdbConfiguration.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/TmdbConfiguration.java @@ -13,6 +13,7 @@ package com.moviejukebox.themoviedb.model; import java.util.List; +import org.apache.commons.lang.StringUtils; import org.apache.log4j.Logger; import org.codehaus.jackson.annotate.JsonAnySetter; import org.codehaus.jackson.annotate.JsonProperty; @@ -94,6 +95,9 @@ public class TmdbConfiguration { * @return */ public boolean isValidPosterSize(String posterSize) { + if (StringUtils.isBlank(posterSize)) { + return false; + } return posterSizes.contains(posterSize); } @@ -103,6 +107,9 @@ public class TmdbConfiguration { * @return */ public boolean isValidBackdropSize(String backdropSize) { + if (StringUtils.isBlank(backdropSize)) { + return false; + } return backdropSizes.contains(backdropSize); } @@ -112,6 +119,9 @@ public class TmdbConfiguration { * @return */ public boolean isValidProfileSize(String profileSize) { + if (StringUtils.isBlank(profileSize)) { + return false; + } return profileSizes.contains(profileSize); } diff --git a/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java b/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java index c7e9a90ef..99b34ac9f 100644 --- a/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java +++ b/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java @@ -61,7 +61,7 @@ public class TheMovieDbTest { /** * Test of getConfiguration method, of class TheMovieDb. */ - //@Test + @Test public void testConfiguration() throws IOException { LOGGER.info("Test Configuration"); @@ -77,7 +77,7 @@ public class TheMovieDbTest { /** * Test of searchMovie method, of class TheMovieDb. */ - //@Test + @Test public void testSearchMovie() throws UnsupportedEncodingException { LOGGER.info("searchMovie"); @@ -97,7 +97,7 @@ public class TheMovieDbTest { /** * Test of getMovieInfo method, of class TheMovieDb. */ - //@Test + @Test public void testGetMovieInfo() { LOGGER.info("getMovieInfo"); String language = "en"; @@ -108,7 +108,7 @@ public class TheMovieDbTest { /** * Test of getMovieAlternativeTitles method, of class TheMovieDb. */ - //@Test + @Test public void testGetMovieAlternativeTitles() { LOGGER.info("getMovieAlternativeTitles"); String country = ""; @@ -124,7 +124,7 @@ public class TheMovieDbTest { /** * Test of getMovieCasts method, of class TheMovieDb. */ - //@Test + @Test public void testGetMovieCasts() { LOGGER.info("getMovieCasts"); List people = tmdb.getMovieCasts(ID_BLADE_RUNNER); @@ -151,7 +151,7 @@ public class TheMovieDbTest { /** * Test of getMovieImages method, of class TheMovieDb. */ - //@Test + @Test public void testGetMovieImages() { LOGGER.info("getMovieImages"); String language = ""; @@ -162,7 +162,7 @@ public class TheMovieDbTest { /** * Test of getMovieKeywords method, of class TheMovieDb. */ - //@Test + @Test public void testGetMovieKeywords() { LOGGER.info("getMovieKeywords"); List result = tmdb.getMovieKeywords(ID_BLADE_RUNNER); @@ -172,7 +172,7 @@ public class TheMovieDbTest { /** * Test of getMovieReleaseInfo method, of class TheMovieDb. */ - //@Test + @Test public void testGetMovieReleaseInfo() { LOGGER.info("getMovieReleaseInfo"); List result = tmdb.getMovieReleaseInfo(ID_BLADE_RUNNER, ""); @@ -182,7 +182,7 @@ public class TheMovieDbTest { /** * Test of getMovieTrailers method, of class TheMovieDb. */ - //@Test + @Test public void testGetMovieTrailers() { LOGGER.info("getMovieTrailers"); List result = tmdb.getMovieTrailers(ID_BLADE_RUNNER, ""); @@ -192,7 +192,7 @@ public class TheMovieDbTest { /** * Test of getMovieTranslations method, of class TheMovieDb. */ - //@Test + @Test public void testGetMovieTranslations() { LOGGER.info("getMovieTranslations"); List result = tmdb.getMovieTranslations(ID_BLADE_RUNNER); @@ -202,7 +202,7 @@ public class TheMovieDbTest { /** * Test of getCollectionInfo method, of class TheMovieDb. */ - //@Test + @Test public void testGetCollectionInfo() { LOGGER.info("getCollectionInfo"); String language = ""; @@ -210,7 +210,7 @@ public class TheMovieDbTest { assertFalse("No collection information", result.getParts().isEmpty()); } - //@Test + @Test public void testCreateImageUrl() { LOGGER.info("createImageUrl"); MovieDb movie = tmdb.getMovieInfo(ID_BLADE_RUNNER, ""); @@ -221,7 +221,7 @@ public class TheMovieDbTest { /** * Test of getMovieInfoImdb method, of class TheMovieDb. */ - //@Test + @Test public void testGetMovieInfoImdb() { LOGGER.info("getMovieInfoImdb"); MovieDb result = tmdb.getMovieInfoImdb("tt0076759", "en-US"); @@ -231,7 +231,7 @@ public class TheMovieDbTest { /** * Test of getApiKey method, of class TheMovieDb. */ - //@Test + @Test public void testGetApiKey() { // Not required } @@ -239,7 +239,7 @@ public class TheMovieDbTest { /** * Test of getApiBase method, of class TheMovieDb. */ - //@Test + @Test public void testGetApiBase() { // Not required } @@ -247,7 +247,7 @@ public class TheMovieDbTest { /** * Test of getConfiguration method, of class TheMovieDb. */ - //@Test + @Test public void testGetConfiguration() { // Not required } @@ -294,11 +294,6 @@ public class TheMovieDbTest { List artwork = tmdb.getPersonImages(ID_BRUCE_WILLIS); assertTrue("No cast information", artwork.size() > 0); - - for(Artwork a:artwork) { - LOGGER.info(" " + a.toString()); - } - } } From 9c7b339761089b19af42a9dacb9eb85deb3ef73c Mon Sep 17 00:00:00 2001 From: Omertron Date: Mon, 30 Jan 2012 09:56:51 +0000 Subject: [PATCH 107/207] Added Last Movie method Changed organisation of API key to be more thread safe --- .../moviejukebox/themoviedb/TheMovieDb.java | 76 +++++++----- .../themoviedb/model/MovieDb.java | 115 +++++------------- .../moviejukebox/themoviedb/tools/ApiUrl.java | 15 ++- 3 files changed, 86 insertions(+), 120 deletions(-) diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java index 22e619882..dc83eb73a 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java @@ -35,31 +35,30 @@ import org.codehaus.jackson.map.ObjectMapper; public class TheMovieDb { private static final Logger LOGGER = Logger.getLogger(TheMovieDb.class); - private static String apiKey; - private static TmdbConfiguration tmdbConfig; + private String apiKey; + private TmdbConfiguration tmdbConfig; /* - * TheMovieDb API URLs + * API Methods These are not set to static so that multiple instances of the + * API can co-exist */ - private static final String TMDB_API_BASE = "http://api.themoviedb.org/3/"; - /* - * API Methods - */ - private static final ApiUrl TMDB_CONFIG_URL = new ApiUrl("configuration"); - private static final ApiUrl TMDB_SEARCH_MOVIE = new ApiUrl("search/movie"); - private static final ApiUrl TMDB_SEARCH_PEOPLE = new ApiUrl("search/person"); - private static final ApiUrl TMDB_COLLECTION_INFO = new ApiUrl("collection/"); - private static final ApiUrl TMDB_MOVIE_INFO = new ApiUrl("movie/"); - private static final ApiUrl TMDB_MOVIE_ALT_TITLES = new ApiUrl("movie/", "/alternative_titles"); - private static final ApiUrl TMDB_MOVIE_CASTS = new ApiUrl("movie/", "/casts"); - private static final ApiUrl TMDB_MOVIE_IMAGES = new ApiUrl("movie/", "/images"); - private static final ApiUrl TMDB_MOVIE_KEYWORDS = new ApiUrl("movie/", "/keywords"); - private static final ApiUrl TMDB_MOVIE_RELEASE_INFO = new ApiUrl("movie/", "/releases"); - private static final ApiUrl TMDB_MOVIE_TRAILERS = new ApiUrl("movie/", "/trailers"); - private static final ApiUrl TMDB_MOVIE_TRANSLATIONS = new ApiUrl("movie/", "/translations"); - private static final ApiUrl TMDB_PERSON_INFO = new ApiUrl("person/"); - private static final ApiUrl TMDB_PERSON_CREDITS = new ApiUrl("person/", "/credits"); - private static final ApiUrl TMDB_PERSON_IMAGES = new ApiUrl("person/", "/images"); - private static final ApiUrl TMDB_LATEST_MOVIE = new ApiUrl("latest/movie"); + private final String BASE_MOVIE = "movie/"; + private final String BASE_PERSON = "person/"; + private final ApiUrl TMDB_CONFIG_URL = new ApiUrl(this, "configuration"); + private final ApiUrl TMDB_SEARCH_MOVIE = new ApiUrl(this, "search/movie"); + private final ApiUrl TMDB_SEARCH_PEOPLE = new ApiUrl(this, "search/person"); + private final ApiUrl TMDB_COLLECTION_INFO = new ApiUrl(this, "collection/"); + private final ApiUrl TMDB_MOVIE_INFO = new ApiUrl(this, BASE_MOVIE); + private final ApiUrl TMDB_MOVIE_ALT_TITLES = new ApiUrl(this, BASE_MOVIE, "/alternative_titles"); + private final ApiUrl TMDB_MOVIE_CASTS = new ApiUrl(this, BASE_MOVIE, "/casts"); + private final ApiUrl TMDB_MOVIE_IMAGES = new ApiUrl(this, BASE_MOVIE, "/images"); + private final ApiUrl TMDB_MOVIE_KEYWORDS = new ApiUrl(this, BASE_MOVIE, "/keywords"); + private final ApiUrl TMDB_MOVIE_RELEASE_INFO = new ApiUrl(this, BASE_MOVIE, "/releases"); + private final ApiUrl TMDB_MOVIE_TRAILERS = new ApiUrl(this, BASE_MOVIE, "/trailers"); + private final ApiUrl TMDB_MOVIE_TRANSLATIONS = new ApiUrl(this, BASE_MOVIE, "/translations"); + private final ApiUrl TMDB_PERSON_INFO = new ApiUrl(this, BASE_PERSON); + private final ApiUrl TMDB_PERSON_CREDITS = new ApiUrl(this, BASE_PERSON, "/credits"); + private final ApiUrl TMDB_PERSON_IMAGES = new ApiUrl(this, BASE_PERSON, "/images"); + private final ApiUrl TMDB_LATEST_MOVIE = new ApiUrl(this, "latest/movie"); /* * Jackson JSON configuration @@ -73,7 +72,7 @@ public class TheMovieDb { * @throws IOException */ public TheMovieDb(String apiKey) throws IOException { - TheMovieDb.apiKey = apiKey; + this.apiKey = apiKey; URL configUrl = TMDB_CONFIG_URL.getQueryUrl(""); mapper.configure(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE, true); tmdbConfig = mapper.readValue(configUrl, TmdbConfiguration.class); @@ -81,14 +80,10 @@ public class TheMovieDb { FilteringLayout.addApiKey(apiKey); } - public static String getApiKey() { + public String getApiKey() { return apiKey; } - public static String getApiBase() { - return TMDB_API_BASE; - } - /** * Search Movies This is a good starting point to start finding movies on * TMDb. The idea is to be a quick and light method so you can iterate @@ -467,12 +462,27 @@ public class TheMovieDb { } } + /** + * This method is used to retrieve the newest movie that was added to TMDb. + * @return + */ + public MovieDb getLatestMovie() { + try { + URL url = TMDB_LATEST_MOVIE.getIdUrl(""); + return mapper.readValue(url, MovieDb.class); + } catch (IOException ex) { + LOGGER.warn("Failed to get latest movie: " + ex.getMessage()); + return new MovieDb(); + } + } + /** * Compare the MovieDB object with a title & year - * @param moviedb The moviedb object to compare too - * @param title The title of the movie to compare - * @param year The year of the movie to compare - * @return True if there is a match, False otherwise. + * + * @param moviedb The moviedb object to compare too + * @param title The title of the movie to compare + * @param year The year of the movie to compare + * @return True if there is a match, False otherwise. */ public static boolean compareMovies(MovieDb moviedb, String title, String year) { if ((moviedb == null) || (StringUtils.isBlank(title))) { diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/MovieDb.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/MovieDb.java index e96e39277..21cb93075 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/MovieDb.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/MovieDb.java @@ -19,6 +19,7 @@ import org.codehaus.jackson.annotate.JsonProperty; /** * Movie Bean + * * @author stuart.boston */ public class MovieDb { @@ -257,6 +258,7 @@ public class MovieDb { /** * Handle unknown properties and print a message + * * @param key * @param value */ @@ -274,104 +276,51 @@ public class MovieDb { if (obj == null) { return false; } + if (getClass() != obj.getClass()) { return false; } + final MovieDb other = (MovieDb) obj; - if ((this.backdropPath == null) ? (other.backdropPath != null) : !this.backdropPath.equals(other.backdropPath)) { - return false; - } + if (this.id != other.id) { return false; } - if ((this.originalTitle == null) ? (other.originalTitle != null) : !this.originalTitle.equals(other.originalTitle)) { - return false; - } - if (Float.floatToIntBits(this.popularity) != Float.floatToIntBits(other.popularity)) { - return false; - } - if ((this.posterPath == null) ? (other.posterPath != null) : !this.posterPath.equals(other.posterPath)) { - return false; - } - if ((this.releaseDate == null) ? (other.releaseDate != null) : !this.releaseDate.equals(other.releaseDate)) { - return false; - } - if ((this.title == null) ? (other.title != null) : !this.title.equals(other.title)) { - return false; - } - if (this.adult != other.adult) { - return false; - } - if (this.belongsToCollection != other.belongsToCollection && (this.belongsToCollection == null || !this.belongsToCollection.equals(other.belongsToCollection))) { - return false; - } - if (this.budget != other.budget) { - return false; - } - if (this.genres != other.genres && (this.genres == null || !this.genres.equals(other.genres))) { - return false; - } - if ((this.homepage == null) ? (other.homepage != null) : !this.homepage.equals(other.homepage)) { - return false; - } - if ((this.imdbID == null) ? (other.imdbID != null) : !this.imdbID.equals(other.imdbID)) { - return false; - } - if ((this.overview == null) ? (other.overview != null) : !this.overview.equals(other.overview)) { - return false; - } - if (this.productionCompanies != other.productionCompanies && (this.productionCompanies == null || !this.productionCompanies.equals(other.productionCompanies))) { - return false; - } - if (this.productionCountries != other.productionCountries && (this.productionCountries == null || !this.productionCountries.equals(other.productionCountries))) { - return false; - } - if (this.revenue != other.revenue) { - return false; - } - if (this.runtime != other.runtime) { - return false; - } - if (this.spokenLanguages != other.spokenLanguages && (this.spokenLanguages == null || !this.spokenLanguages.equals(other.spokenLanguages))) { - return false; - } - if ((this.tagline == null) ? (other.tagline != null) : !this.tagline.equals(other.tagline)) { - return false; - } - if (Float.floatToIntBits(this.voteAverage) != Float.floatToIntBits(other.voteAverage)) { - return false; - } - if (this.voteCount != other.voteCount) { + + // Dirty way of checking that all the fields are the same + if (this.toString().equals(other.toString())) { return false; } + return true; } @Override public int hashCode() { int hash = 3; - hash = 97 * hash + (this.backdropPath != null ? this.backdropPath.hashCode() : 0); - hash = 97 * hash + this.id; - hash = 97 * hash + (this.originalTitle != null ? this.originalTitle.hashCode() : 0); - hash = 97 * hash + Float.floatToIntBits(this.popularity); - hash = 97 * hash + (this.posterPath != null ? this.posterPath.hashCode() : 0); - hash = 97 * hash + (this.releaseDate != null ? this.releaseDate.hashCode() : 0); - hash = 97 * hash + (this.title != null ? this.title.hashCode() : 0); - hash = 97 * hash + (this.adult ? 1 : 0); - hash = 97 * hash + (this.belongsToCollection != null ? this.belongsToCollection.hashCode() : 0); - hash = 97 * hash + this.budget; - hash = 97 * hash + (this.genres != null ? this.genres.hashCode() : 0); - hash = 97 * hash + (this.homepage != null ? this.homepage.hashCode() : 0); - hash = 97 * hash + (this.imdbID != null ? this.imdbID.hashCode() : 0); - hash = 97 * hash + (this.overview != null ? this.overview.hashCode() : 0); - hash = 97 * hash + (this.productionCompanies != null ? this.productionCompanies.hashCode() : 0); - hash = 97 * hash + (this.productionCountries != null ? this.productionCountries.hashCode() : 0); - hash = 97 * hash + this.revenue; - hash = 97 * hash + this.runtime; - hash = 97 * hash + (this.spokenLanguages != null ? this.spokenLanguages.hashCode() : 0); - hash = 97 * hash + (this.tagline != null ? this.tagline.hashCode() : 0); - hash = 97 * hash + Float.floatToIntBits(this.voteAverage); - hash = 97 * hash + this.voteCount; + int multiplier = 97; + hash = multiplier * hash + (this.backdropPath != null ? this.backdropPath.hashCode() : 0); + hash = multiplier * hash + this.id; + hash = multiplier * hash + (this.originalTitle != null ? this.originalTitle.hashCode() : 0); + hash = multiplier * hash + Float.floatToIntBits(this.popularity); + hash = multiplier * hash + (this.posterPath != null ? this.posterPath.hashCode() : 0); + hash = multiplier * hash + (this.releaseDate != null ? this.releaseDate.hashCode() : 0); + hash = multiplier * hash + (this.title != null ? this.title.hashCode() : 0); + hash = multiplier * hash + (this.adult ? 1 : 0); + hash = multiplier * hash + (this.belongsToCollection != null ? this.belongsToCollection.hashCode() : 0); + hash = multiplier * hash + this.budget; + hash = multiplier * hash + (this.genres != null ? this.genres.hashCode() : 0); + hash = multiplier * hash + (this.homepage != null ? this.homepage.hashCode() : 0); + hash = multiplier * hash + (this.imdbID != null ? this.imdbID.hashCode() : 0); + hash = multiplier * hash + (this.overview != null ? this.overview.hashCode() : 0); + hash = multiplier * hash + (this.productionCompanies != null ? this.productionCompanies.hashCode() : 0); + hash = multiplier * hash + (this.productionCountries != null ? this.productionCountries.hashCode() : 0); + hash = multiplier * hash + this.revenue; + hash = multiplier * hash + this.runtime; + hash = multiplier * hash + (this.spokenLanguages != null ? this.spokenLanguages.hashCode() : 0); + hash = multiplier * hash + (this.tagline != null ? this.tagline.hashCode() : 0); + hash = multiplier * hash + Float.floatToIntBits(this.voteAverage); + hash = multiplier * hash + this.voteCount; return hash; } // diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/ApiUrl.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/ApiUrl.java index 17ce7cffb..7d49c50a2 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/ApiUrl.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/ApiUrl.java @@ -31,6 +31,10 @@ public class ApiUrl { * Logger */ private static final Logger LOGGER = Logger.getLogger(ApiUrl.class); + /* + * TheMovieDb API Base URL + */ + private final String TMDB_API_BASE = "http://api.themoviedb.org/3/"; /* * Parameter configuration */ @@ -48,13 +52,15 @@ public class ApiUrl { */ private String method; private String submethod; + private TheMovieDb TMDb; // /** * Constructor for the simple API URL method without a sub-method * @param method */ - public ApiUrl(String method) { + public ApiUrl(TheMovieDb TMDb, String method) { + this.TMDb = TMDb; this.method = method; this.submethod = DEFAULT_STRING; } @@ -64,7 +70,8 @@ public class ApiUrl { * @param method * @param submethod */ - public ApiUrl(String method, String submethod) { + public ApiUrl(TheMovieDb TMDb, String method, String submethod) { + this.TMDb = TMDb; this.method = method; this.submethod = submethod; } @@ -81,7 +88,7 @@ public class ApiUrl { * @return */ private URL getFullUrl(String query, String movieId, String language, String country, int page) { - StringBuilder urlString = new StringBuilder(TheMovieDb.getApiBase()); + StringBuilder urlString = new StringBuilder(TMDB_API_BASE); // Get the start of the URL urlString.append(method); @@ -116,7 +123,7 @@ public class ApiUrl { urlString.append(DELIMITER_SUBSEQUENT); } urlString.append(PARAMETER_API_KEY); - urlString.append(TheMovieDb.getApiKey()); + urlString.append(TMDb.getApiKey()); // Append the language to the URL if (StringUtils.isNotBlank(language)) { From 20422642d03633db69ebc83006a873cab43fcb97 Mon Sep 17 00:00:00 2001 From: Omertron Date: Mon, 30 Jan 2012 12:10:29 +0000 Subject: [PATCH 108/207] Added Last Movie test --- .../moviejukebox/themoviedb/TheMovieDb.java | 1040 +++++++++-------- .../themoviedb/model/Collection.java | 340 +++--- .../themoviedb/model/PersonCrew.java | 295 +++-- .../themoviedb/model/Trailer.java | 265 +++-- .../moviejukebox/themoviedb/tools/ApiUrl.java | 496 ++++---- .../themoviedb/TheMovieDbTest.java | 616 +++++----- 6 files changed, 1531 insertions(+), 1521 deletions(-) diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java index dc83eb73a..984b61b36 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java @@ -1,518 +1,522 @@ -/* - * Copyright (c) 2004-2012 YAMJ Members - * http://code.google.com/p/moviejukebox/people/list - * - * Web: http://code.google.com/p/moviejukebox/ - * - * This software is licensed under a Creative Commons License - * See this page: http://code.google.com/p/moviejukebox/wiki/License - * - * For any reuse or distribution, you must make clear to others the - * license terms of this work. - */ -package com.moviejukebox.themoviedb; - -import com.moviejukebox.themoviedb.model.*; -import com.moviejukebox.themoviedb.tools.ApiUrl; -import com.moviejukebox.themoviedb.tools.FilteringLayout; -import com.moviejukebox.themoviedb.wrapper.*; -import java.io.IOException; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.ArrayList; -import java.util.List; -import org.apache.commons.lang.StringUtils; -import org.apache.log4j.Logger; -import org.codehaus.jackson.map.DeserializationConfig; -import org.codehaus.jackson.map.ObjectMapper; - -/** - * The MovieDb API. This is for version 3 of the API as specified here: - * http://help.themoviedb.org/kb/api/about-3 - * - * @author stuart.boston - */ -public class TheMovieDb { - - private static final Logger LOGGER = Logger.getLogger(TheMovieDb.class); - private String apiKey; - private TmdbConfiguration tmdbConfig; - /* - * API Methods These are not set to static so that multiple instances of the - * API can co-exist - */ - private final String BASE_MOVIE = "movie/"; - private final String BASE_PERSON = "person/"; - private final ApiUrl TMDB_CONFIG_URL = new ApiUrl(this, "configuration"); - private final ApiUrl TMDB_SEARCH_MOVIE = new ApiUrl(this, "search/movie"); - private final ApiUrl TMDB_SEARCH_PEOPLE = new ApiUrl(this, "search/person"); - private final ApiUrl TMDB_COLLECTION_INFO = new ApiUrl(this, "collection/"); - private final ApiUrl TMDB_MOVIE_INFO = new ApiUrl(this, BASE_MOVIE); - private final ApiUrl TMDB_MOVIE_ALT_TITLES = new ApiUrl(this, BASE_MOVIE, "/alternative_titles"); - private final ApiUrl TMDB_MOVIE_CASTS = new ApiUrl(this, BASE_MOVIE, "/casts"); - private final ApiUrl TMDB_MOVIE_IMAGES = new ApiUrl(this, BASE_MOVIE, "/images"); - private final ApiUrl TMDB_MOVIE_KEYWORDS = new ApiUrl(this, BASE_MOVIE, "/keywords"); - private final ApiUrl TMDB_MOVIE_RELEASE_INFO = new ApiUrl(this, BASE_MOVIE, "/releases"); - private final ApiUrl TMDB_MOVIE_TRAILERS = new ApiUrl(this, BASE_MOVIE, "/trailers"); - private final ApiUrl TMDB_MOVIE_TRANSLATIONS = new ApiUrl(this, BASE_MOVIE, "/translations"); - private final ApiUrl TMDB_PERSON_INFO = new ApiUrl(this, BASE_PERSON); - private final ApiUrl TMDB_PERSON_CREDITS = new ApiUrl(this, BASE_PERSON, "/credits"); - private final ApiUrl TMDB_PERSON_IMAGES = new ApiUrl(this, BASE_PERSON, "/images"); - private final ApiUrl TMDB_LATEST_MOVIE = new ApiUrl(this, "latest/movie"); - - /* - * Jackson JSON configuration - */ - private static ObjectMapper mapper = new ObjectMapper(); - - /** - * API for The Movie Db. - * - * @param apiKey - * @throws IOException - */ - public TheMovieDb(String apiKey) throws IOException { - this.apiKey = apiKey; - URL configUrl = TMDB_CONFIG_URL.getQueryUrl(""); - mapper.configure(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE, true); - tmdbConfig = mapper.readValue(configUrl, TmdbConfiguration.class); - mapper.configure(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE, false); - FilteringLayout.addApiKey(apiKey); - } - - public String getApiKey() { - return apiKey; - } - - /** - * Search Movies This is a good starting point to start finding movies on - * TMDb. The idea is to be a quick and light method so you can iterate - * through movies quickly. http://help.themoviedb.org/kb/api/search-movies - * TODO: Make the allResults work - */ - public List searchMovie(String movieName, String language, boolean allResults) { - try { - URL url = TMDB_SEARCH_MOVIE.getQueryUrl(movieName, language, 1); - WrapperResultList resultList = mapper.readValue(url, WrapperResultList.class); - return resultList.getResults(); - } catch (IOException ex) { - LOGGER.warn("Failed to find movie: " + ex.getMessage()); - return new ArrayList(); - } - } - - /** - * This method is used to retrieve all of the basic movie information. It - * will return the single highest rated poster and backdrop. - * - * @param movieId - * @param language - * @return - */ - public MovieDb getMovieInfo(int movieId, String language) { - try { - URL url = TMDB_MOVIE_INFO.getIdUrl(movieId, language); - return mapper.readValue(url, MovieDb.class); - } catch (IOException ex) { - LOGGER.warn("Failed to get movie info: " + ex.getMessage()); - } - return new MovieDb(); - } - - /** - * This method is used to retrieve all of the basic movie information. It - * will return the single highest rated poster and backdrop. - * - * @param movieId - * @param language - * @return - */ - public MovieDb getMovieInfoImdb(String imdbId, String language) { - try { - URL url = TMDB_MOVIE_INFO.getIdUrl(imdbId, language); - return mapper.readValue(url, MovieDb.class); - } catch (IOException ex) { - LOGGER.warn("Failed to get movie info: " + ex.getMessage()); - } - return new MovieDb(); - } - - /** - * This method is used to retrieve all of the alternative titles we have for - * a particular movie. - * - * @param movieId - * @param country - * @return - */ - public List getMovieAlternativeTitles(int movieId, String country) { - try { - URL url = TMDB_MOVIE_ALT_TITLES.getIdUrl(movieId, country); - WrapperAlternativeTitles at = mapper.readValue(url, WrapperAlternativeTitles.class); - return at.getTitles(); - } catch (IOException ex) { - LOGGER.warn("Failed to get movie alternative titles: " + ex.getMessage()); - } - return new ArrayList(); - } - - /** - * This method is used to retrieve all of the movie cast information. TODO: - * Add a function to enrich the data with the people methods - * - * @param movieId - * @return - */ - public List getMovieCasts(int movieId) { - List people = new ArrayList(); - - try { - URL url = TMDB_MOVIE_CASTS.getIdUrl(movieId); - WrapperMovieCasts mc = mapper.readValue(url, WrapperMovieCasts.class); - - // Add a cast member - for (PersonCast cast : mc.getCast()) { - Person person = new Person(); - person.addCast(cast.getId(), cast.getName(), cast.getProfilePath(), cast.getCharacter(), cast.getOrder()); - people.add(person); - } - - // Add a crew member - for (PersonCrew crew : mc.getCrew()) { - Person person = new Person(); - person.addCrew(crew.getId(), crew.getName(), crew.getProfilePath(), crew.getDepartment(), crew.getJob()); - people.add(person); - } - - return people; - } catch (IOException ex) { - LOGGER.warn("Failed to get movie casts: " + ex.getMessage()); - } - return people; - } - - /** - * This method should be used when you’re wanting to retrieve all of the - * images for a particular movie. - * - * @param movieId - * @param language - * @return - */ - public List getMovieImages(int movieId, String language) { - List artwork = new ArrayList(); - try { - URL url = TMDB_MOVIE_IMAGES.getIdUrl(movieId, language); - WrapperImages mi = mapper.readValue(url, WrapperImages.class); - - // Add all the posters to the list - for (Artwork poster : mi.getPosters()) { - poster.setArtworkType(ArtworkType.POSTER); - artwork.add(poster); - } - - // Add all the backdrops to the list - for (Artwork backdrop : mi.getBackdrops()) { - backdrop.setArtworkType(ArtworkType.BACKDROP); - artwork.add(backdrop); - } - - return artwork; - } catch (IOException ex) { - LOGGER.warn("Failed to get movie images: " + ex.getMessage()); - } - return artwork; - } - - /** - * This method is used to retrieve all of the keywords that have been added - * to a particular movie. Currently, only English keywords exist. - * - * @param movieId - * @return - */ - public List getMovieKeywords(int movieId) { - try { - URL url = TMDB_MOVIE_KEYWORDS.getIdUrl(movieId); - WrapperMovieKeywords mk = mapper.readValue(url, WrapperMovieKeywords.class); - return mk.getKeywords(); - } catch (IOException ex) { - LOGGER.warn("Failed to get movie keywords: " + ex.getMessage()); - } - return new ArrayList(); - } - - /** - * This method is used to retrieve all of the release and certification data - * we have for a specific movie. - * - * @param movieId - * @param language - * @return - */ - public List getMovieReleaseInfo(int movieId, String language) { - try { - URL url = TMDB_MOVIE_RELEASE_INFO.getIdUrl(movieId); - WrapperReleaseInfo ri = mapper.readValue(url, WrapperReleaseInfo.class); - return ri.getCountries(); - } catch (IOException ex) { - LOGGER.warn("Failed to get movie release information: " + ex.getMessage()); - } - return new ArrayList(); - } - - /** - * This method is used to retrieve all of the trailers for a particular - * movie. Supported sites are YouTube and QuickTime. - * - * @param movieId - * @param language - * @return - */ - public List getMovieTrailers(int movieId, String language) { - List trailers = new ArrayList(); - try { - URL url = TMDB_MOVIE_TRAILERS.getIdUrl(movieId); - WrapperTrailers wt = mapper.readValue(url, WrapperTrailers.class); - - // Add the trailer to the return list along with it's source - for (Trailer trailer : wt.getQuicktime()) { - trailer.setWebsite(Trailer.WEBSITE_QUICKTIME); - trailers.add(trailer); - } - - // Add the trailer to the return list along with it's source - for (Trailer trailer : wt.getYoutube()) { - trailer.setWebsite(Trailer.WEBSITE_YOUTUBE); - trailers.add(trailer); - } - return trailers; - } catch (IOException ex) { - LOGGER.warn("Failed to get movie trailers: " + ex.getMessage()); - } - return trailers; - } - - /** - * This method is used to retrieve a list of the available translations for - * a specific movie. - * - * @param movieId - * @return - */ - public List getMovieTranslations(int movieId) { - try { - URL url = TMDB_MOVIE_TRANSLATIONS.getIdUrl(movieId); - WrapperTranslations wt = mapper.readValue(url, WrapperTranslations.class); - return wt.getTranslations(); - } catch (IOException ex) { - LOGGER.warn("Failed to get movie tranlations: " + ex.getMessage()); - } - return new ArrayList(); - } - - /** - * This method is used to retrieve all of the basic information about a - * movie collection. You can get the ID needed for this method by making a - * getMovieInfo request for the belongs_to_collection. - * - * @param movieId - * @param language - * @return - */ - public CollectionInfo getCollectionInfo(int movieId, String language) { - try { - URL url = TMDB_COLLECTION_INFO.getIdUrl(movieId); - return mapper.readValue(url, CollectionInfo.class); - } catch (IOException ex) { - return new CollectionInfo(); - } - } - - /** - * Get the configuration information - * - * @return - */ - public TmdbConfiguration getConfiguration() { - return tmdbConfig; - } - - /** - * Generate the full image URL from the size and image path - * - * @param imagePath - * @param requiredSize - * @return - */ - public URL createImageUrl(String imagePath, String requiredSize) { - URL returnUrl = null; - StringBuilder sb; - - if (!tmdbConfig.isValidSize(requiredSize)) { - sb = new StringBuilder(); - sb.append(" - Invalid size requested: ").append(requiredSize); - LOGGER.warn(sb.toString()); - return returnUrl; - } - - try { - sb = new StringBuilder(tmdbConfig.getBaseUrl()); - sb.append(requiredSize); - sb.append(imagePath); - returnUrl = new URL(sb.toString()); - } catch (MalformedURLException ex) { - LOGGER.warn("Failed to create image URL: " + ex.getMessage()); - } - - return returnUrl; - } - - /** - * This is a good starting point to start finding people on TMDb. The idea - * is to be a quick and light method so you can iterate through people - * quickly. TODO: Fix allResults - */ - public List searchPeople(String personName, boolean allResults) { - - try { - URL url = TMDB_SEARCH_PEOPLE.getQueryUrl(personName, "", 1); - WrapperPerson resultList = mapper.readValue(url, WrapperPerson.class); - return resultList.getResults(); - } catch (IOException ex) { - LOGGER.warn("Failed to find person: " + ex.getMessage()); - return new ArrayList(); - } - } - - /** - * This method is used to retrieve all of the basic person information. It - * will return the single highest rated profile image. - * - * @param personId - * @return - */ - public Person getPersonInfo(int personId) { - try { - URL url = TMDB_PERSON_INFO.getIdUrl(personId); - return mapper.readValue(url, Person.class); - } catch (IOException ex) { - LOGGER.warn("Failed to get movie info: " + ex.getMessage()); - return new Person(); - } - } - - /** - * This method is used to retrieve all of the cast & crew information for - * the person. It will return the single highest rated poster for each movie - * record. - * - * @param personId - * @return - */ - public List getPersonCredits(int personId) { - List personCredits = new ArrayList(); - - try { - URL url = TMDB_PERSON_CREDITS.getIdUrl(personId); - WrapperPersonCredits pc = mapper.readValue(url, WrapperPersonCredits.class); - - // Add a cast member - for (PersonCredit cast : pc.getCast()) { - cast.setPersonType(PersonType.CAST); - personCredits.add(cast); - } - - // Add a crew member - for (PersonCredit crew : pc.getCrew()) { - crew.setPersonType(PersonType.CREW); - personCredits.add(crew); - } - - return personCredits; - } catch (IOException ex) { - LOGGER.warn("Failed to get person credits: " + ex.getMessage()); - return personCredits; - } - } - - /** - * This method is used to retrieve all of the profile images for a person. - * - * @param personId - * @return - */ - public List getPersonImages(int personId) { - List personImages = new ArrayList(); - - try { - URL url = TMDB_PERSON_IMAGES.getIdUrl(personId); - WrapperImages images = mapper.readValue(url, WrapperImages.class); - - // Update the image type - for (Artwork artwork : images.getProfiles()) { - artwork.setArtworkType(ArtworkType.PROFILE); - personImages.add(artwork); - } - - return personImages; - } catch (IOException ex) { - LOGGER.warn("Failed to get person images: " + ex.getMessage()); - return personImages; - } - } - - /** - * This method is used to retrieve the newest movie that was added to TMDb. - * @return - */ - public MovieDb getLatestMovie() { - try { - URL url = TMDB_LATEST_MOVIE.getIdUrl(""); - return mapper.readValue(url, MovieDb.class); - } catch (IOException ex) { - LOGGER.warn("Failed to get latest movie: " + ex.getMessage()); - return new MovieDb(); - } - } - - /** - * Compare the MovieDB object with a title & year - * - * @param moviedb The moviedb object to compare too - * @param title The title of the movie to compare - * @param year The year of the movie to compare - * @return True if there is a match, False otherwise. - */ - public static boolean compareMovies(MovieDb moviedb, String title, String year) { - if ((moviedb == null) || (StringUtils.isBlank(title))) { - return false; - } - - if (StringUtils.isNotBlank(year)) { - if (StringUtils.isNotBlank(moviedb.getReleaseDate())) { - // Compare with year - String movieYear = moviedb.getReleaseDate().substring(0, 4); - if (movieYear.equals(year)) { - if (moviedb.getOriginalTitle().equalsIgnoreCase(title)) { - return true; - } - - if (moviedb.getTitle().equalsIgnoreCase(title)) { - return true; - } - } - } - } else { - // Compare without year - if (moviedb.getOriginalTitle().equalsIgnoreCase(title)) { - return true; - } - - if (moviedb.getTitle().equalsIgnoreCase(title)) { - return true; - } - } - return false; - } -} +/* + * Copyright (c) 2004-2012 YAMJ Members + * http://code.google.com/p/moviejukebox/people/list + * + * Web: http://code.google.com/p/moviejukebox/ + * + * This software is licensed under a Creative Commons License + * See this page: http://code.google.com/p/moviejukebox/wiki/License + * + * For any reuse or distribution, you must make clear to others the + * license terms of this work. + */ +package com.moviejukebox.themoviedb; + +import com.moviejukebox.themoviedb.model.*; +import com.moviejukebox.themoviedb.tools.ApiUrl; +import com.moviejukebox.themoviedb.tools.FilteringLayout; +import com.moviejukebox.themoviedb.wrapper.*; +import java.io.IOException; +import java.net.MalformedURLException; +import java.net.URL; +import java.util.ArrayList; +import java.util.List; +import org.apache.commons.lang.StringUtils; +import org.apache.log4j.Logger; +import org.codehaus.jackson.map.DeserializationConfig; +import org.codehaus.jackson.map.ObjectMapper; + +/** + * The MovieDb API. This is for version 3 of the API as specified here: + * http://help.themoviedb.org/kb/api/about-3 + * + * @author stuart.boston + */ +public class TheMovieDb { + + private static final Logger LOGGER = Logger.getLogger(TheMovieDb.class); + private String apiKey; + private TmdbConfiguration tmdbConfig; + /* + * API Methods These are not set to static so that multiple instances of the + * API can co-exist + */ + private static final String BASE_MOVIE = "movie/"; + private static final String BASE_PERSON = "person/"; + private final ApiUrl tmdbConfigUrl = new ApiUrl(this, "configuration"); + private final ApiUrl tmdbSearchMovie = new ApiUrl(this, "search/movie"); + private final ApiUrl tmdbSearchPeople = new ApiUrl(this, "search/person"); + private final ApiUrl tmdbCollectionInfo = new ApiUrl(this, "collection/"); + private final ApiUrl tmdbMovieInfo = new ApiUrl(this, BASE_MOVIE); + private final ApiUrl tmdbMovieAltTitles = new ApiUrl(this, BASE_MOVIE, "/alternative_titles"); + private final ApiUrl tmdbMovieCasts = new ApiUrl(this, BASE_MOVIE, "/casts"); + private final ApiUrl tmdbMovieImages = new ApiUrl(this, BASE_MOVIE, "/images"); + private final ApiUrl tmdbMovieKeywords = new ApiUrl(this, BASE_MOVIE, "/keywords"); + private final ApiUrl tmdbMovieReleaseInfo = new ApiUrl(this, BASE_MOVIE, "/releases"); + private final ApiUrl tmdbMovieTrailers = new ApiUrl(this, BASE_MOVIE, "/trailers"); + private final ApiUrl tmdbMovieTranslations = new ApiUrl(this, BASE_MOVIE, "/translations"); + private final ApiUrl tmdbPersonInfo = new ApiUrl(this, BASE_PERSON); + private final ApiUrl tmdbPersonCredits = new ApiUrl(this, BASE_PERSON, "/credits"); + private final ApiUrl tmdbPersonImages = new ApiUrl(this, BASE_PERSON, "/images"); + private final ApiUrl tmdbLatestMovie = new ApiUrl(this, "latest/movie"); + + /* + * Jackson JSON configuration + */ + private static ObjectMapper mapper = new ObjectMapper(); + + /** + * API for The Movie Db. + * + * @param apiKey + * @throws IOException + */ + public TheMovieDb(String apiKey) throws IOException { + this.apiKey = apiKey; + URL configUrl = tmdbConfigUrl.getQueryUrl(""); + mapper.configure(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE, true); + tmdbConfig = mapper.readValue(configUrl, TmdbConfiguration.class); + mapper.configure(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE, false); + FilteringLayout.addApiKey(apiKey); + } + + /** + * Get the API key that is to be used + * @return + */ + public String getApiKey() { + return apiKey; + } + + /** + * Search Movies This is a good starting point to start finding movies on + * TMDb. The idea is to be a quick and light method so you can iterate + * through movies quickly. http://help.themoviedb.org/kb/api/search-movies + * TODO: Make the allResults work + */ + public List searchMovie(String movieName, String language, boolean allResults) { + try { + URL url = tmdbSearchMovie.getQueryUrl(movieName, language, 1); + WrapperResultList resultList = mapper.readValue(url, WrapperResultList.class); + return resultList.getResults(); + } catch (IOException ex) { + LOGGER.warn("Failed to find movie: " + ex.getMessage()); + return new ArrayList(); + } + } + + /** + * This method is used to retrieve all of the basic movie information. It + * will return the single highest rated poster and backdrop. + * + * @param movieId + * @param language + * @return + */ + public MovieDb getMovieInfo(int movieId, String language) { + try { + URL url = tmdbMovieInfo.getIdUrl(movieId, language); + return mapper.readValue(url, MovieDb.class); + } catch (IOException ex) { + LOGGER.warn("Failed to get movie info: " + ex.getMessage()); + } + return new MovieDb(); + } + + /** + * This method is used to retrieve all of the basic movie information. It + * will return the single highest rated poster and backdrop. + * + * @param movieId + * @param language + * @return + */ + public MovieDb getMovieInfoImdb(String imdbId, String language) { + try { + URL url = tmdbMovieInfo.getIdUrl(imdbId, language); + return mapper.readValue(url, MovieDb.class); + } catch (IOException ex) { + LOGGER.warn("Failed to get movie info: " + ex.getMessage()); + } + return new MovieDb(); + } + + /** + * This method is used to retrieve all of the alternative titles we have for + * a particular movie. + * + * @param movieId + * @param country + * @return + */ + public List getMovieAlternativeTitles(int movieId, String country) { + try { + URL url = tmdbMovieAltTitles.getIdUrl(movieId, country); + WrapperAlternativeTitles at = mapper.readValue(url, WrapperAlternativeTitles.class); + return at.getTitles(); + } catch (IOException ex) { + LOGGER.warn("Failed to get movie alternative titles: " + ex.getMessage()); + } + return new ArrayList(); + } + + /** + * This method is used to retrieve all of the movie cast information. TODO: + * Add a function to enrich the data with the people methods + * + * @param movieId + * @return + */ + public List getMovieCasts(int movieId) { + List people = new ArrayList(); + + try { + URL url = tmdbMovieCasts.getIdUrl(movieId); + WrapperMovieCasts mc = mapper.readValue(url, WrapperMovieCasts.class); + + // Add a cast member + for (PersonCast cast : mc.getCast()) { + Person person = new Person(); + person.addCast(cast.getId(), cast.getName(), cast.getProfilePath(), cast.getCharacter(), cast.getOrder()); + people.add(person); + } + + // Add a crew member + for (PersonCrew crew : mc.getCrew()) { + Person person = new Person(); + person.addCrew(crew.getId(), crew.getName(), crew.getProfilePath(), crew.getDepartment(), crew.getJob()); + people.add(person); + } + + return people; + } catch (IOException ex) { + LOGGER.warn("Failed to get movie casts: " + ex.getMessage()); + } + return people; + } + + /** + * This method should be used when you’re wanting to retrieve all of the + * images for a particular movie. + * + * @param movieId + * @param language + * @return + */ + public List getMovieImages(int movieId, String language) { + List artwork = new ArrayList(); + try { + URL url = tmdbMovieImages.getIdUrl(movieId, language); + WrapperImages mi = mapper.readValue(url, WrapperImages.class); + + // Add all the posters to the list + for (Artwork poster : mi.getPosters()) { + poster.setArtworkType(ArtworkType.POSTER); + artwork.add(poster); + } + + // Add all the backdrops to the list + for (Artwork backdrop : mi.getBackdrops()) { + backdrop.setArtworkType(ArtworkType.BACKDROP); + artwork.add(backdrop); + } + + return artwork; + } catch (IOException ex) { + LOGGER.warn("Failed to get movie images: " + ex.getMessage()); + } + return artwork; + } + + /** + * This method is used to retrieve all of the keywords that have been added + * to a particular movie. Currently, only English keywords exist. + * + * @param movieId + * @return + */ + public List getMovieKeywords(int movieId) { + try { + URL url = tmdbMovieKeywords.getIdUrl(movieId); + WrapperMovieKeywords mk = mapper.readValue(url, WrapperMovieKeywords.class); + return mk.getKeywords(); + } catch (IOException ex) { + LOGGER.warn("Failed to get movie keywords: " + ex.getMessage()); + } + return new ArrayList(); + } + + /** + * This method is used to retrieve all of the release and certification data + * we have for a specific movie. + * + * @param movieId + * @param language + * @return + */ + public List getMovieReleaseInfo(int movieId, String language) { + try { + URL url = tmdbMovieReleaseInfo.getIdUrl(movieId); + WrapperReleaseInfo ri = mapper.readValue(url, WrapperReleaseInfo.class); + return ri.getCountries(); + } catch (IOException ex) { + LOGGER.warn("Failed to get movie release information: " + ex.getMessage()); + } + return new ArrayList(); + } + + /** + * This method is used to retrieve all of the trailers for a particular + * movie. Supported sites are YouTube and QuickTime. + * + * @param movieId + * @param language + * @return + */ + public List getMovieTrailers(int movieId, String language) { + List trailers = new ArrayList(); + try { + URL url = tmdbMovieTrailers.getIdUrl(movieId); + WrapperTrailers wt = mapper.readValue(url, WrapperTrailers.class); + + // Add the trailer to the return list along with it's source + for (Trailer trailer : wt.getQuicktime()) { + trailer.setWebsite(Trailer.WEBSITE_QUICKTIME); + trailers.add(trailer); + } + + // Add the trailer to the return list along with it's source + for (Trailer trailer : wt.getYoutube()) { + trailer.setWebsite(Trailer.WEBSITE_YOUTUBE); + trailers.add(trailer); + } + return trailers; + } catch (IOException ex) { + LOGGER.warn("Failed to get movie trailers: " + ex.getMessage()); + } + return trailers; + } + + /** + * This method is used to retrieve a list of the available translations for + * a specific movie. + * + * @param movieId + * @return + */ + public List getMovieTranslations(int movieId) { + try { + URL url = tmdbMovieTranslations.getIdUrl(movieId); + WrapperTranslations wt = mapper.readValue(url, WrapperTranslations.class); + return wt.getTranslations(); + } catch (IOException ex) { + LOGGER.warn("Failed to get movie tranlations: " + ex.getMessage()); + } + return new ArrayList(); + } + + /** + * This method is used to retrieve all of the basic information about a + * movie collection. You can get the ID needed for this method by making a + * getMovieInfo request for the belongs_to_collection. + * + * @param movieId + * @param language + * @return + */ + public CollectionInfo getCollectionInfo(int movieId, String language) { + try { + URL url = tmdbCollectionInfo.getIdUrl(movieId); + return mapper.readValue(url, CollectionInfo.class); + } catch (IOException ex) { + return new CollectionInfo(); + } + } + + /** + * Get the configuration information + * + * @return + */ + public TmdbConfiguration getConfiguration() { + return tmdbConfig; + } + + /** + * Generate the full image URL from the size and image path + * + * @param imagePath + * @param requiredSize + * @return + */ + public URL createImageUrl(String imagePath, String requiredSize) { + URL returnUrl = null; + StringBuilder sb; + + if (!tmdbConfig.isValidSize(requiredSize)) { + sb = new StringBuilder(); + sb.append(" - Invalid size requested: ").append(requiredSize); + LOGGER.warn(sb.toString()); + return returnUrl; + } + + try { + sb = new StringBuilder(tmdbConfig.getBaseUrl()); + sb.append(requiredSize); + sb.append(imagePath); + returnUrl = new URL(sb.toString()); + } catch (MalformedURLException ex) { + LOGGER.warn("Failed to create image URL: " + ex.getMessage()); + } + + return returnUrl; + } + + /** + * This is a good starting point to start finding people on TMDb. The idea + * is to be a quick and light method so you can iterate through people + * quickly. TODO: Fix allResults + */ + public List searchPeople(String personName, boolean allResults) { + + try { + URL url = tmdbSearchPeople.getQueryUrl(personName, "", 1); + WrapperPerson resultList = mapper.readValue(url, WrapperPerson.class); + return resultList.getResults(); + } catch (IOException ex) { + LOGGER.warn("Failed to find person: " + ex.getMessage()); + return new ArrayList(); + } + } + + /** + * This method is used to retrieve all of the basic person information. It + * will return the single highest rated profile image. + * + * @param personId + * @return + */ + public Person getPersonInfo(int personId) { + try { + URL url = tmdbPersonInfo.getIdUrl(personId); + return mapper.readValue(url, Person.class); + } catch (IOException ex) { + LOGGER.warn("Failed to get movie info: " + ex.getMessage()); + return new Person(); + } + } + + /** + * This method is used to retrieve all of the cast & crew information for + * the person. It will return the single highest rated poster for each movie + * record. + * + * @param personId + * @return + */ + public List getPersonCredits(int personId) { + List personCredits = new ArrayList(); + + try { + URL url = tmdbPersonCredits.getIdUrl(personId); + WrapperPersonCredits pc = mapper.readValue(url, WrapperPersonCredits.class); + + // Add a cast member + for (PersonCredit cast : pc.getCast()) { + cast.setPersonType(PersonType.CAST); + personCredits.add(cast); + } + + // Add a crew member + for (PersonCredit crew : pc.getCrew()) { + crew.setPersonType(PersonType.CREW); + personCredits.add(crew); + } + + return personCredits; + } catch (IOException ex) { + LOGGER.warn("Failed to get person credits: " + ex.getMessage()); + return personCredits; + } + } + + /** + * This method is used to retrieve all of the profile images for a person. + * + * @param personId + * @return + */ + public List getPersonImages(int personId) { + List personImages = new ArrayList(); + + try { + URL url = tmdbPersonImages.getIdUrl(personId); + WrapperImages images = mapper.readValue(url, WrapperImages.class); + + // Update the image type + for (Artwork artwork : images.getProfiles()) { + artwork.setArtworkType(ArtworkType.PROFILE); + personImages.add(artwork); + } + + return personImages; + } catch (IOException ex) { + LOGGER.warn("Failed to get person images: " + ex.getMessage()); + return personImages; + } + } + + /** + * This method is used to retrieve the newest movie that was added to TMDb. + * @return + */ + public MovieDb getLatestMovie() { + try { + URL url = tmdbLatestMovie.getIdUrl(""); + return mapper.readValue(url, MovieDb.class); + } catch (IOException ex) { + LOGGER.warn("Failed to get latest movie: " + ex.getMessage()); + return new MovieDb(); + } + } + + /** + * Compare the MovieDB object with a title & year + * + * @param moviedb The moviedb object to compare too + * @param title The title of the movie to compare + * @param year The year of the movie to compare + * @return True if there is a match, False otherwise. + */ + public static boolean compareMovies(MovieDb moviedb, String title, String year) { + if ((moviedb == null) || (StringUtils.isBlank(title))) { + return false; + } + + if (StringUtils.isNotBlank(year)) { + if (StringUtils.isNotBlank(moviedb.getReleaseDate())) { + // Compare with year + String movieYear = moviedb.getReleaseDate().substring(0, 4); + if (movieYear.equals(year)) { + if (moviedb.getOriginalTitle().equalsIgnoreCase(title)) { + return true; + } + + if (moviedb.getTitle().equalsIgnoreCase(title)) { + return true; + } + } + } + } else { + // Compare without year + if (moviedb.getOriginalTitle().equalsIgnoreCase(title)) { + return true; + } + + if (moviedb.getTitle().equalsIgnoreCase(title)) { + return true; + } + } + return false; + } +} diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Collection.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Collection.java index 969710a71..4667edc08 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Collection.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Collection.java @@ -1,173 +1,167 @@ -/* - * Copyright (c) 2004-2012 YAMJ Members - * http://code.google.com/p/moviejukebox/people/list - * - * Web: http://code.google.com/p/moviejukebox/ - * - * This software is licensed under a Creative Commons License - * See this page: http://code.google.com/p/moviejukebox/wiki/License - * - * For any reuse or distribution, you must make clear to others the - * license terms of this work. - */ -package com.moviejukebox.themoviedb.model; - -import org.apache.commons.lang.StringUtils; -import org.apache.log4j.Logger; -import org.codehaus.jackson.annotate.JsonAnySetter; -import org.codehaus.jackson.annotate.JsonProperty; -import org.codehaus.jackson.map.annotate.JsonRootName; - -/** - * - * @author stuart.boston - */ -@JsonRootName("collection") -public class Collection { - - /* - * Logger - */ - private static final Logger LOGGER = Logger.getLogger(Collection.class); - /* - * Properties - */ - @JsonProperty("id") - private int id; - @JsonProperty("title") - private String title; - @JsonProperty("name") - private String name; - @JsonProperty("poster_path") - private String posterPath; - @JsonProperty("backdrop_path") - private String backdropPath; - @JsonProperty("release_date") - private String releaseDate; - - // - public String getBackdropPath() { - return backdropPath; - } - - public int getId() { - return id; - } - - public String getPosterPath() { - return posterPath; - } - - public String getReleaseDate() { - return releaseDate; - } - - public String getTitle() { - if (StringUtils.isBlank(title)) { - return name; - } - return title; - } - - public String getName() { - if (StringUtils.isBlank(name)) { - return title; - } - return name; - } - // - - // - public void setBackdropPath(String backdropPath) { - this.backdropPath = backdropPath; - } - - public void setId(int id) { - this.id = id; - } - - public void setPosterPath(String posterPath) { - this.posterPath = posterPath; - } - - public void setReleaseDate(String releaseDate) { - this.releaseDate = releaseDate; - } - - public void setTitle(String title) { - this.title = title; - } - - public void setName(String name) { - this.name = name; - } - // - - /** - * Handle unknown properties and print a message - * @param key - * @param value - */ - @JsonAnySetter - public void handleUnknown(String key, Object value) { - StringBuilder sb = new StringBuilder(); - sb.append("Unknown property: '").append(key); - sb.append("' value: '").append(value).append("'"); - LOGGER.warn(sb.toString()); - } - - @Override - public boolean equals(Object obj) { - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - final Collection other = (Collection) obj; - if ((this.backdropPath == null) ? (other.backdropPath != null) : !this.backdropPath.equals(other.backdropPath)) { - return false; - } - if (this.id != other.id) { - return false; - } - if ((this.title == null) ? (other.title != null) : !this.title.equals(other.title)) { - return false; - } - if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) { - return false; - } - if ((this.posterPath == null) ? (other.posterPath != null) : !this.posterPath.equals(other.posterPath)) { - return false; - } - if ((this.releaseDate == null) ? (other.releaseDate != null) : !this.releaseDate.equals(other.releaseDate)) { - return false; - } - return true; - } - - @Override - public int hashCode() { - int hash = 7; - hash = 19 * hash + (this.backdropPath != null ? this.backdropPath.hashCode() : 0); - hash = 19 * hash + this.id; - hash = 19 * hash + (this.title != null ? this.title.hashCode() : 0); - hash = 19 * hash + (this.name != null ? this.name.hashCode() : 0); - hash = 19 * hash + (this.posterPath != null ? this.posterPath.hashCode() : 0); - hash = 19 * hash + (this.releaseDate != null ? this.releaseDate.hashCode() : 0); - return hash; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder("[Collection="); - sb.append("[id=").append(id); - sb.append("],[title=").append(title); - sb.append("],[name=").append(name); - sb.append("],[posterPath=").append(posterPath); - sb.append("],[backdropPath=").append(backdropPath); - sb.append("],[releaseDate=").append(releaseDate); - sb.append("]]"); - return sb.toString(); - } -} +/* + * Copyright (c) 2004-2012 YAMJ Members + * http://code.google.com/p/moviejukebox/people/list + * + * Web: http://code.google.com/p/moviejukebox/ + * + * This software is licensed under a Creative Commons License + * See this page: http://code.google.com/p/moviejukebox/wiki/License + * + * For any reuse or distribution, you must make clear to others the + * license terms of this work. + */ +package com.moviejukebox.themoviedb.model; + +import org.apache.commons.lang.StringUtils; +import org.apache.log4j.Logger; +import org.codehaus.jackson.annotate.JsonAnySetter; +import org.codehaus.jackson.annotate.JsonProperty; +import org.codehaus.jackson.map.annotate.JsonRootName; + +/** + * + * @author stuart.boston + */ +@JsonRootName("collection") +public class Collection { + + /* + * Logger + */ + private static final Logger LOGGER = Logger.getLogger(Collection.class); + /* + * Properties + */ + @JsonProperty("id") + private int id; + @JsonProperty("title") + private String title; + @JsonProperty("name") + private String name; + @JsonProperty("poster_path") + private String posterPath; + @JsonProperty("backdrop_path") + private String backdropPath; + @JsonProperty("release_date") + private String releaseDate; + + // + public String getBackdropPath() { + return backdropPath; + } + + public int getId() { + return id; + } + + public String getPosterPath() { + return posterPath; + } + + public String getReleaseDate() { + return releaseDate; + } + + public String getTitle() { + if (StringUtils.isBlank(title)) { + return name; + } + return title; + } + + public String getName() { + if (StringUtils.isBlank(name)) { + return title; + } + return name; + } + // + + // + public void setBackdropPath(String backdropPath) { + this.backdropPath = backdropPath; + } + + public void setId(int id) { + this.id = id; + } + + public void setPosterPath(String posterPath) { + this.posterPath = posterPath; + } + + public void setReleaseDate(String releaseDate) { + this.releaseDate = releaseDate; + } + + public void setTitle(String title) { + this.title = title; + } + + public void setName(String name) { + this.name = name; + } + // + + /** + * Handle unknown properties and print a message + * @param key + * @param value + */ + @JsonAnySetter + public void handleUnknown(String key, Object value) { + StringBuilder sb = new StringBuilder(); + sb.append("Unknown property: '").append(key); + sb.append("' value: '").append(value).append("'"); + LOGGER.warn(sb.toString()); + } + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final Collection other = (Collection) obj; + if ((this.backdropPath == null) ? (other.backdropPath != null) : !this.backdropPath.equals(other.backdropPath)) { + return false; + } + if (this.id != other.id) { + return false; + } + if ((this.title == null) ? (other.title != null) : !this.title.equals(other.title)) { + return false; + } + if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) { + return false; + } + return true; + } + + @Override + public int hashCode() { + int hash = 7; + hash = 19 * hash + (this.backdropPath != null ? this.backdropPath.hashCode() : 0); + hash = 19 * hash + this.id; + hash = 19 * hash + (this.title != null ? this.title.hashCode() : 0); + hash = 19 * hash + (this.name != null ? this.name.hashCode() : 0); + hash = 19 * hash + (this.posterPath != null ? this.posterPath.hashCode() : 0); + hash = 19 * hash + (this.releaseDate != null ? this.releaseDate.hashCode() : 0); + return hash; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("[Collection="); + sb.append("[id=").append(id); + sb.append("],[title=").append(title); + sb.append("],[name=").append(name); + sb.append("],[posterPath=").append(posterPath); + sb.append("],[backdropPath=").append(backdropPath); + sb.append("],[releaseDate=").append(releaseDate); + sb.append("]]"); + return sb.toString(); + } +} diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/PersonCrew.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/PersonCrew.java index 117ec79b2..69456f3fa 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/PersonCrew.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/PersonCrew.java @@ -1,149 +1,146 @@ -/* - * Copyright (c) 2004-2012 YAMJ Members - * http://code.google.com/p/moviejukebox/people/list - * - * Web: http://code.google.com/p/moviejukebox/ - * - * This software is licensed under a Creative Commons License - * See this page: http://code.google.com/p/moviejukebox/wiki/License - * - * For any reuse or distribution, you must make clear to others the - * license terms of this work. - */ -package com.moviejukebox.themoviedb.model; - -import org.apache.log4j.Logger; -import org.codehaus.jackson.annotate.JsonAnySetter; -import org.codehaus.jackson.annotate.JsonProperty; - -/** - * - * @author Stuart - */ -public class PersonCrew { - /* - * Logger - */ - - private static final Logger LOGGER = Logger.getLogger(PersonCrew.class); - /* - * Properties - */ - @JsonProperty("id") - private int id; - @JsonProperty("department") - private String department; - @JsonProperty("job") - private String job; - @JsonProperty("name") - private String name; - @JsonProperty("profile_path") - private String profilePath; - - // - public String getDepartment() { - return department; - } - - public int getId() { - return id; - } - - public String getJob() { - return job; - } - - public String getName() { - return name; - } - - public String getProfilePath() { - return profilePath; - } - // - - // - public void setDepartment(String department) { - this.department = department; - } - - public void setId(int id) { - this.id = id; - } - - public void setJob(String job) { - this.job = job; - } - - public void setName(String name) { - this.name = name; - } - - public void setProfilePath(String profilePath) { - this.profilePath = profilePath; - } - // - - /** - * Handle unknown properties and print a message - * @param key - * @param value - */ - @JsonAnySetter - public void handleUnknown(String key, Object value) { - StringBuilder sb = new StringBuilder(); - sb.append("Unknown property: '").append(key); - sb.append("' value: '").append(value).append("'"); - LOGGER.warn(sb.toString()); - } - - @Override - public boolean equals(Object obj) { - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - final PersonCrew other = (PersonCrew) obj; - if (this.id != other.id) { - return false; - } - if ((this.department == null) ? (other.department != null) : !this.department.equals(other.department)) { - return false; - } - if ((this.job == null) ? (other.job != null) : !this.job.equals(other.job)) { - return false; - } - if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) { - return false; - } - if ((this.profilePath == null) ? (other.profilePath != null) : !this.profilePath.equals(other.profilePath)) { - return false; - } - return true; - } - - @Override - public int hashCode() { - int hash = 7; - hash = 59 * hash + this.id; - hash = 59 * hash + (this.department != null ? this.department.hashCode() : 0); - hash = 59 * hash + (this.job != null ? this.job.hashCode() : 0); - hash = 59 * hash + (this.name != null ? this.name.hashCode() : 0); - hash = 59 * hash + (this.profilePath != null ? this.profilePath.hashCode() : 0); - return hash; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder("[PersonCrew="); - sb.append("id=").append(id); - sb.append("],[department=").append(department); - sb.append("],[job=").append(job); - sb.append("],[name=").append(name); - sb.append("],[profilePath=").append(profilePath); - sb.append("]]"); - return sb.toString(); - } -} +/* + * Copyright (c) 2004-2012 YAMJ Members + * http://code.google.com/p/moviejukebox/people/list + * + * Web: http://code.google.com/p/moviejukebox/ + * + * This software is licensed under a Creative Commons License + * See this page: http://code.google.com/p/moviejukebox/wiki/License + * + * For any reuse or distribution, you must make clear to others the + * license terms of this work. + */ +package com.moviejukebox.themoviedb.model; + +import org.apache.log4j.Logger; +import org.codehaus.jackson.annotate.JsonAnySetter; +import org.codehaus.jackson.annotate.JsonProperty; + +/** + * + * @author Stuart + */ +public class PersonCrew { + /* + * Logger + */ + + private static final Logger LOGGER = Logger.getLogger(PersonCrew.class); + /* + * Properties + */ + @JsonProperty("id") + private int id; + @JsonProperty("department") + private String department; + @JsonProperty("job") + private String job; + @JsonProperty("name") + private String name; + @JsonProperty("profile_path") + private String profilePath; + + // + public String getDepartment() { + return department; + } + + public int getId() { + return id; + } + + public String getJob() { + return job; + } + + public String getName() { + return name; + } + + public String getProfilePath() { + return profilePath; + } + // + + // + public void setDepartment(String department) { + this.department = department; + } + + public void setId(int id) { + this.id = id; + } + + public void setJob(String job) { + this.job = job; + } + + public void setName(String name) { + this.name = name; + } + + public void setProfilePath(String profilePath) { + this.profilePath = profilePath; + } + // + + /** + * Handle unknown properties and print a message + * @param key + * @param value + */ + @JsonAnySetter + public void handleUnknown(String key, Object value) { + StringBuilder sb = new StringBuilder(); + sb.append("Unknown property: '").append(key); + sb.append("' value: '").append(value).append("'"); + LOGGER.warn(sb.toString()); + } + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final PersonCrew other = (PersonCrew) obj; + if (this.id != other.id) { + return false; + } + if ((this.department == null) ? (other.department != null) : !this.department.equals(other.department)) { + return false; + } + if ((this.job == null) ? (other.job != null) : !this.job.equals(other.job)) { + return false; + } + if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) { + return false; + } + return true; + } + + @Override + public int hashCode() { + int hash = 7; + hash = 59 * hash + this.id; + hash = 59 * hash + (this.department != null ? this.department.hashCode() : 0); + hash = 59 * hash + (this.job != null ? this.job.hashCode() : 0); + hash = 59 * hash + (this.name != null ? this.name.hashCode() : 0); + hash = 59 * hash + (this.profilePath != null ? this.profilePath.hashCode() : 0); + return hash; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("[PersonCrew="); + sb.append("id=").append(id); + sb.append("],[department=").append(department); + sb.append("],[job=").append(job); + sb.append("],[name=").append(name); + sb.append("],[profilePath=").append(profilePath); + sb.append("]]"); + return sb.toString(); + } +} diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Trailer.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Trailer.java index dfa07f5e3..3985fae3d 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Trailer.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Trailer.java @@ -1,134 +1,131 @@ -/* - * Copyright (c) 2004-2012 YAMJ Members - * http://code.google.com/p/moviejukebox/people/list - * - * Web: http://code.google.com/p/moviejukebox/ - * - * This software is licensed under a Creative Commons License - * See this page: http://code.google.com/p/moviejukebox/wiki/License - * - * For any reuse or distribution, you must make clear to others the - * license terms of this work. - */ -package com.moviejukebox.themoviedb.model; - -import org.apache.log4j.Logger; -import org.codehaus.jackson.annotate.JsonAnySetter; - -/** - * - * @author Stuart - */ -public class Trailer { - /* - * Logger - */ - - private static final Logger LOGGER = Logger.getLogger(Trailer.class); - /* - * Website sources - */ - public static final String WEBSITE_YOUTUBE = "youtube"; - public static final String WEBSITE_QUICKTIME = "quicktime"; - /* - * Properties - */ - private String name; - private String size; - private String source; - private String website; // The website of the trailer - - // - public String getName() { - return name; - } - - public String getSize() { - return size; - } - - public String getSource() { - return source; - } - - public String getWebsite() { - return website; - } - // - - // - public void setName(String name) { - this.name = name; - } - - public void setSize(String size) { - this.size = size; - } - - public void setSource(String source) { - this.source = source; - } - - public void setWebsite(String website) { - this.website = website; - } - // - - /** - * Handle unknown properties and print a message - * @param key - * @param value - */ - @JsonAnySetter - public void handleUnknown(String key, Object value) { - StringBuilder sb = new StringBuilder(); - sb.append("Unknown property: '").append(key); - sb.append("' value: '").append(value).append("'"); - LOGGER.warn(sb.toString()); - } - - @Override - public boolean equals(Object obj) { - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - final Trailer other = (Trailer) obj; - if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) { - return false; - } - if ((this.size == null) ? (other.size != null) : !this.size.equals(other.size)) { - return false; - } - if ((this.source == null) ? (other.source != null) : !this.source.equals(other.source)) { - return false; - } - if ((this.website == null) ? (other.website != null) : !this.website.equals(other.website)) { - return false; - } - return true; - } - - @Override - public int hashCode() { - int hash = 7; - hash = 61 * hash + (this.name != null ? this.name.hashCode() : 0); - hash = 61 * hash + (this.size != null ? this.size.hashCode() : 0); - hash = 61 * hash + (this.source != null ? this.source.hashCode() : 0); - hash = 61 * hash + (this.website != null ? this.website.hashCode() : 0); - return hash; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder("[Trailer="); - sb.append("name=").append(name); - sb.append("],[size=").append(size); - sb.append("],[source=").append(source); - sb.append("],[website=").append(website); - sb.append("]]"); - return sb.toString(); - } -} +/* + * Copyright (c) 2004-2012 YAMJ Members + * http://code.google.com/p/moviejukebox/people/list + * + * Web: http://code.google.com/p/moviejukebox/ + * + * This software is licensed under a Creative Commons License + * See this page: http://code.google.com/p/moviejukebox/wiki/License + * + * For any reuse or distribution, you must make clear to others the + * license terms of this work. + */ +package com.moviejukebox.themoviedb.model; + +import org.apache.log4j.Logger; +import org.codehaus.jackson.annotate.JsonAnySetter; + +/** + * + * @author Stuart + */ +public class Trailer { + /* + * Logger + */ + + private static final Logger LOGGER = Logger.getLogger(Trailer.class); + /* + * Website sources + */ + public static final String WEBSITE_YOUTUBE = "youtube"; + public static final String WEBSITE_QUICKTIME = "quicktime"; + /* + * Properties + */ + private String name; + private String size; + private String source; + private String website; // The website of the trailer + + // + public String getName() { + return name; + } + + public String getSize() { + return size; + } + + public String getSource() { + return source; + } + + public String getWebsite() { + return website; + } + // + + // + public void setName(String name) { + this.name = name; + } + + public void setSize(String size) { + this.size = size; + } + + public void setSource(String source) { + this.source = source; + } + + public void setWebsite(String website) { + this.website = website; + } + // + + /** + * Handle unknown properties and print a message + * @param key + * @param value + */ + @JsonAnySetter + public void handleUnknown(String key, Object value) { + StringBuilder sb = new StringBuilder(); + sb.append("Unknown property: '").append(key); + sb.append("' value: '").append(value).append("'"); + LOGGER.warn(sb.toString()); + } + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final Trailer other = (Trailer) obj; + if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) { + return false; + } + if ((this.size == null) ? (other.size != null) : !this.size.equals(other.size)) { + return false; + } + if ((this.source == null) ? (other.source != null) : !this.source.equals(other.source)) { + return false; + } + return true; + } + + @Override + public int hashCode() { + int hash = 7; + hash = 61 * hash + (this.name != null ? this.name.hashCode() : 0); + hash = 61 * hash + (this.size != null ? this.size.hashCode() : 0); + hash = 61 * hash + (this.source != null ? this.source.hashCode() : 0); + hash = 61 * hash + (this.website != null ? this.website.hashCode() : 0); + return hash; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("[Trailer="); + sb.append("name=").append(name); + sb.append("],[size=").append(size); + sb.append("],[source=").append(source); + sb.append("],[website=").append(website); + sb.append("]]"); + return sb.toString(); + } +} diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/ApiUrl.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/ApiUrl.java index 7d49c50a2..649816b88 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/ApiUrl.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/ApiUrl.java @@ -1,248 +1,248 @@ -/* - * Copyright (c) 2004-2012 YAMJ Members - * http://code.google.com/p/moviejukebox/people/list - * - * Web: http://code.google.com/p/moviejukebox/ - * - * This software is licensed under a Creative Commons License - * See this page: http://code.google.com/p/moviejukebox/wiki/License - * - * For any reuse or distribution, you must make clear to others the - * license terms of this work. - */ -package com.moviejukebox.themoviedb.tools; - -import com.moviejukebox.themoviedb.TheMovieDb; -import java.io.UnsupportedEncodingException; -import java.net.MalformedURLException; -import java.net.URL; -import java.net.URLEncoder; -import org.apache.commons.lang.StringUtils; -import org.apache.log4j.Logger; - -/** - * The API URL that is used to construct the API call - * - * @author Stuart - */ -public class ApiUrl { - - /* - * Logger - */ - private static final Logger LOGGER = Logger.getLogger(ApiUrl.class); - /* - * TheMovieDb API Base URL - */ - private final String TMDB_API_BASE = "http://api.themoviedb.org/3/"; - /* - * Parameter configuration - */ - private static final String DELIMITER_FIRST = "?"; - private static final String DELIMITER_SUBSEQUENT = "&"; - private static final String PARAMETER_API_KEY = "api_key="; // The API Key is always needed and always first - private static final String PARAMETER_QUERY = "query="; - private static final String PARAMETER_LANGUAGE = DELIMITER_SUBSEQUENT + "language="; - private static final String PARAMETER_COUNTRY = DELIMITER_SUBSEQUENT + "country="; - private static final String PARAMETER_PAGE = DELIMITER_SUBSEQUENT + "page="; - private static final String DEFAULT_STRING = ""; - private static final int DEFAULT_INT = -1; - /* - * Properties - */ - private String method; - private String submethod; - private TheMovieDb TMDb; - - // - /** - * Constructor for the simple API URL method without a sub-method - * @param method - */ - public ApiUrl(TheMovieDb TMDb, String method) { - this.TMDb = TMDb; - this.method = method; - this.submethod = DEFAULT_STRING; - } - - /** - * Constructor for the API URL with a sub-method - * @param method - * @param submethod - */ - public ApiUrl(TheMovieDb TMDb, String method, String submethod) { - this.TMDb = TMDb; - this.method = method; - this.submethod = submethod; - } - // - - /** - * Create the full URL with the API. - * - * @param query - * @param tmdbId - * @param language - * @param country - * @param page - * @return - */ - private URL getFullUrl(String query, String movieId, String language, String country, int page) { - StringBuilder urlString = new StringBuilder(TMDB_API_BASE); - - // Get the start of the URL - urlString.append(method); - - // Append the search term if required - if (StringUtils.isNotBlank(query)) { - urlString.append(DELIMITER_FIRST); - urlString.append(PARAMETER_QUERY); - - try { - urlString.append(URLEncoder.encode(query, "UTF-8")); - } catch (UnsupportedEncodingException ex) { - // If we can't encode it, try it raw - urlString.append(query); - } - } - - // Append the ID if provided - if (StringUtils.isNotBlank(movieId)) { - urlString.append(movieId); - } - - // Append the suffix of the API URL - urlString.append(submethod); - - // Append the key information - if (StringUtils.isBlank(query)) { - // This is the first parameter - urlString.append(DELIMITER_FIRST); - } else { - // The first parameter was the query - urlString.append(DELIMITER_SUBSEQUENT); - } - urlString.append(PARAMETER_API_KEY); - urlString.append(TMDb.getApiKey()); - - // Append the language to the URL - if (StringUtils.isNotBlank(language)) { - urlString.append(PARAMETER_LANGUAGE); - urlString.append(language); - } - - // Append the country to the URL - if (StringUtils.isNotBlank(country)) { - urlString.append(PARAMETER_COUNTRY); - urlString.append(country); - } - - // Append the page to the URL - if (page > DEFAULT_INT) { - urlString.append(PARAMETER_PAGE); - urlString.append(page); - } - - try { - LOGGER.trace("URL: " + urlString.toString()); - return new URL(urlString.toString()); - } catch (MalformedURLException ex) { - LOGGER.warn("Failed to create URL " + urlString.toString()); - return null; - } - } - - /** - * Create an URL using the query (string), language and page - * - * @param query - * @param language - * @param page - * @return - */ - public URL getQueryUrl(String query, String language, int page) { - return getFullUrl(query, DEFAULT_STRING, language, null, page); - } - - /** - * Create an URL using the query (string) - * @param query - * @return - */ - public URL getQueryUrl(String query) { - return getQueryUrl(query, DEFAULT_STRING, DEFAULT_INT); - } - - /** - * Create an URL using the query (string) and language - * @param query - * @param language - * @return - */ - public URL getQueryUrl(String query, String language) { - return getQueryUrl(query, language, DEFAULT_INT); - } - - /** - * Create an URL using the movie ID, language and country code - * - * @param movieId - * @param language - * @param country - * @return - */ - public URL getIdUrl(String movieId, String language, String country) { - return getFullUrl(DEFAULT_STRING, movieId, language, country, DEFAULT_INT); - } - - /** - * Create an URL using the movie ID and language - * @param movieId - * @param language - * @return - */ - public URL getIdUrl(String movieId, String language) { - return getIdUrl(movieId, language, DEFAULT_STRING); - } - - /** - * Create an URL using the movie ID - * @param movieId - * @return - */ - public URL getIdUrl(String movieId) { - return getIdUrl(movieId, DEFAULT_STRING, DEFAULT_STRING); - } - - /** - * Create an URL using the movie ID, language and country code - * - * @param movieId - * @param language - * @param country - * @return - */ - public URL getIdUrl(int movieId, String language, String country) { - return getIdUrl(String.valueOf(movieId), language, country); - } - - /** - * Create an URL using the movie ID and language - * @param movieId - * @param language - * @return - */ - public URL getIdUrl(int movieId, String language) { - return getIdUrl(String.valueOf(movieId), language, DEFAULT_STRING); - } - - /** - * Create an URL using the movie ID - * @param movieId - * @return - */ - public URL getIdUrl(int movieId) { - return getIdUrl(String.valueOf(movieId), DEFAULT_STRING, DEFAULT_STRING); - } - -} +/* + * Copyright (c) 2004-2012 YAMJ Members + * http://code.google.com/p/moviejukebox/people/list + * + * Web: http://code.google.com/p/moviejukebox/ + * + * This software is licensed under a Creative Commons License + * See this page: http://code.google.com/p/moviejukebox/wiki/License + * + * For any reuse or distribution, you must make clear to others the + * license terms of this work. + */ +package com.moviejukebox.themoviedb.tools; + +import com.moviejukebox.themoviedb.TheMovieDb; +import java.io.UnsupportedEncodingException; +import java.net.MalformedURLException; +import java.net.URL; +import java.net.URLEncoder; +import org.apache.commons.lang.StringUtils; +import org.apache.log4j.Logger; + +/** + * The API URL that is used to construct the API call + * + * @author Stuart + */ +public class ApiUrl { + + /* + * Logger + */ + private static final Logger LOGGER = Logger.getLogger(ApiUrl.class); + /* + * TheMovieDb API Base URL + */ + private static final String TMDB_API_BASE = "http://api.themoviedb.org/3/"; + /* + * Parameter configuration + */ + private static final String DELIMITER_FIRST = "?"; + private static final String DELIMITER_SUBSEQUENT = "&"; + private static final String PARAMETER_API_KEY = "api_key="; // The API Key is always needed and always first + private static final String PARAMETER_QUERY = "query="; + private static final String PARAMETER_LANGUAGE = DELIMITER_SUBSEQUENT + "language="; + private static final String PARAMETER_COUNTRY = DELIMITER_SUBSEQUENT + "country="; + private static final String PARAMETER_PAGE = DELIMITER_SUBSEQUENT + "page="; + private static final String DEFAULT_STRING = ""; + private static final int DEFAULT_INT = -1; + /* + * Properties + */ + private String method; + private String submethod; + private TheMovieDb tmdb; + + // + /** + * Constructor for the simple API URL method without a sub-method + * @param method + */ + public ApiUrl(TheMovieDb tmdb, String method) { + this.tmdb = tmdb; + this.method = method; + this.submethod = DEFAULT_STRING; + } + + /** + * Constructor for the API URL with a sub-method + * @param method + * @param submethod + */ + public ApiUrl(TheMovieDb tmdb, String method, String submethod) { + this.tmdb = tmdb; + this.method = method; + this.submethod = submethod; + } + // + + /** + * Create the full URL with the API. + * + * @param query + * @param tmdbId + * @param language + * @param country + * @param page + * @return + */ + private URL getFullUrl(String query, String movieId, String language, String country, int page) { + StringBuilder urlString = new StringBuilder(TMDB_API_BASE); + + // Get the start of the URL + urlString.append(method); + + // Append the search term if required + if (StringUtils.isNotBlank(query)) { + urlString.append(DELIMITER_FIRST); + urlString.append(PARAMETER_QUERY); + + try { + urlString.append(URLEncoder.encode(query, "UTF-8")); + } catch (UnsupportedEncodingException ex) { + // If we can't encode it, try it raw + urlString.append(query); + } + } + + // Append the ID if provided + if (StringUtils.isNotBlank(movieId)) { + urlString.append(movieId); + } + + // Append the suffix of the API URL + urlString.append(submethod); + + // Append the key information + if (StringUtils.isBlank(query)) { + // This is the first parameter + urlString.append(DELIMITER_FIRST); + } else { + // The first parameter was the query + urlString.append(DELIMITER_SUBSEQUENT); + } + urlString.append(PARAMETER_API_KEY); + urlString.append(tmdb.getApiKey()); + + // Append the language to the URL + if (StringUtils.isNotBlank(language)) { + urlString.append(PARAMETER_LANGUAGE); + urlString.append(language); + } + + // Append the country to the URL + if (StringUtils.isNotBlank(country)) { + urlString.append(PARAMETER_COUNTRY); + urlString.append(country); + } + + // Append the page to the URL + if (page > DEFAULT_INT) { + urlString.append(PARAMETER_PAGE); + urlString.append(page); + } + + try { + LOGGER.trace("URL: " + urlString.toString()); + return new URL(urlString.toString()); + } catch (MalformedURLException ex) { + LOGGER.warn("Failed to create URL " + urlString.toString()); + return null; + } + } + + /** + * Create an URL using the query (string), language and page + * + * @param query + * @param language + * @param page + * @return + */ + public URL getQueryUrl(String query, String language, int page) { + return getFullUrl(query, DEFAULT_STRING, language, null, page); + } + + /** + * Create an URL using the query (string) + * @param query + * @return + */ + public URL getQueryUrl(String query) { + return getQueryUrl(query, DEFAULT_STRING, DEFAULT_INT); + } + + /** + * Create an URL using the query (string) and language + * @param query + * @param language + * @return + */ + public URL getQueryUrl(String query, String language) { + return getQueryUrl(query, language, DEFAULT_INT); + } + + /** + * Create an URL using the movie ID, language and country code + * + * @param movieId + * @param language + * @param country + * @return + */ + public URL getIdUrl(String movieId, String language, String country) { + return getFullUrl(DEFAULT_STRING, movieId, language, country, DEFAULT_INT); + } + + /** + * Create an URL using the movie ID and language + * @param movieId + * @param language + * @return + */ + public URL getIdUrl(String movieId, String language) { + return getIdUrl(movieId, language, DEFAULT_STRING); + } + + /** + * Create an URL using the movie ID + * @param movieId + * @return + */ + public URL getIdUrl(String movieId) { + return getIdUrl(movieId, DEFAULT_STRING, DEFAULT_STRING); + } + + /** + * Create an URL using the movie ID, language and country code + * + * @param movieId + * @param language + * @param country + * @return + */ + public URL getIdUrl(int movieId, String language, String country) { + return getIdUrl(String.valueOf(movieId), language, country); + } + + /** + * Create an URL using the movie ID and language + * @param movieId + * @param language + * @return + */ + public URL getIdUrl(int movieId, String language) { + return getIdUrl(String.valueOf(movieId), language, DEFAULT_STRING); + } + + /** + * Create an URL using the movie ID + * @param movieId + * @return + */ + public URL getIdUrl(int movieId) { + return getIdUrl(String.valueOf(movieId), DEFAULT_STRING, DEFAULT_STRING); + } + +} diff --git a/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java b/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java index 99b34ac9f..a09e185cd 100644 --- a/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java +++ b/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java @@ -1,299 +1,317 @@ -/* - * Copyright (c) 2004-2012 YAMJ Members - * http://code.google.com/p/moviejukebox/people/list - * - * Web: http://code.google.com/p/moviejukebox/ - * - * This software is licensed under a Creative Commons License - * See this page: http://code.google.com/p/moviejukebox/wiki/License - * - * For any reuse or distribution, you must make clear to others the - * license terms of this work. - */ -package com.moviejukebox.themoviedb; - -import com.moviejukebox.themoviedb.model.*; -import java.io.IOException; -import java.io.UnsupportedEncodingException; -import java.util.List; -import org.apache.commons.lang.StringUtils; -import org.apache.log4j.Logger; -import static org.junit.Assert.*; -import org.junit.*; - -/** - * Test cases for TheMovieDb API - * - * @author stuart.boston - */ -public class TheMovieDbTest { - - private static final Logger LOGGER = Logger.getLogger(TheMovieDbTest.class); - private static final String API_KEY = "5a1a77e2eba8984804586122754f969f"; - private static TheMovieDb tmdb; - /* - * Test data - */ - private static final int ID_BLADE_RUNNER = 78; - private static final int ID_STAR_WARS_COLLECTION = 10; - private static final int ID_BRUCE_WILLIS = 62; - - public TheMovieDbTest() throws IOException { - tmdb = new TheMovieDb(API_KEY); - } - - @BeforeClass - public static void setUpClass() throws Exception { - } - - @AfterClass - public static void tearDownClass() throws Exception { - } - - @Before - public void setUp() { - } - - @After - public void tearDown() { - } - - /** - * Test of getConfiguration method, of class TheMovieDb. - */ - @Test - public void testConfiguration() throws IOException { - LOGGER.info("Test Configuration"); - - TmdbConfiguration tmdbConfig = tmdb.getConfiguration(); - assertNotNull("Configuration failed", tmdbConfig); - assertTrue("No base URL", StringUtils.isNotBlank(tmdbConfig.getBaseUrl())); - assertTrue("No backdrop sizes", tmdbConfig.getBackdropSizes().size() > 0); - assertTrue("No poster sizes", tmdbConfig.getPosterSizes().size() > 0); - assertTrue("No profile sizes", tmdbConfig.getProfileSizes().size() > 0); - LOGGER.info(tmdbConfig.toString()); - } - - /** - * Test of searchMovie method, of class TheMovieDb. - */ - @Test - public void testSearchMovie() throws UnsupportedEncodingException { - LOGGER.info("searchMovie"); - - // Try a movie with less than 1 page of results - List movieList = tmdb.searchMovie("Blade Runner", "", true); - assertTrue("No movies found, should be at least 1", movieList.size() > 0); - - // Try a russian langugage movie - movieList = tmdb.searchMovie("О чём говорят мужчины", "ru", true); - assertTrue("No movies found, should be at least 1", movieList.size() > 0); - - // Try a movie with more than 20 results - movieList = tmdb.searchMovie("Star Wars", "en", false); - assertTrue("Not enough movies found, should be 20", movieList.size() == 20); - } - - /** - * Test of getMovieInfo method, of class TheMovieDb. - */ - @Test - public void testGetMovieInfo() { - LOGGER.info("getMovieInfo"); - String language = "en"; - MovieDb result = tmdb.getMovieInfo(ID_BLADE_RUNNER, language); - assertEquals("Incorrect movie information", "Blade Runner", result.getOriginalTitle()); - } - - /** - * Test of getMovieAlternativeTitles method, of class TheMovieDb. - */ - @Test - public void testGetMovieAlternativeTitles() { - LOGGER.info("getMovieAlternativeTitles"); - String country = ""; - List results = tmdb.getMovieAlternativeTitles(ID_BLADE_RUNNER, country); - assertTrue("No alternative titles found", results.size() > 0); - - country = "US"; - results = tmdb.getMovieAlternativeTitles(ID_BLADE_RUNNER, country); - assertTrue("No alternative titles found", results.size() > 0); - - } - - /** - * Test of getMovieCasts method, of class TheMovieDb. - */ - @Test - public void testGetMovieCasts() { - LOGGER.info("getMovieCasts"); - List people = tmdb.getMovieCasts(ID_BLADE_RUNNER); - assertTrue("No cast information", people.size() > 0); - - String name1 = "Harrison Ford"; - String name2 = "Charles Knode"; - boolean foundName1 = Boolean.FALSE; - boolean foundName2 = Boolean.FALSE; - - for (Person person : people) { - if (!foundName1 && person.getName().equalsIgnoreCase(name1)) { - foundName1 = Boolean.TRUE; - } - - if (!foundName2 && person.getName().equalsIgnoreCase(name2)) { - foundName2 = Boolean.TRUE; - } - } - assertTrue("Couldn't find " + name1, foundName1); - assertTrue("Couldn't find " + name2, foundName2); - } - - /** - * Test of getMovieImages method, of class TheMovieDb. - */ - @Test - public void testGetMovieImages() { - LOGGER.info("getMovieImages"); - String language = ""; - List result = tmdb.getMovieImages(ID_BLADE_RUNNER, language); - assertFalse("No artwork found", result.isEmpty()); - } - - /** - * Test of getMovieKeywords method, of class TheMovieDb. - */ - @Test - public void testGetMovieKeywords() { - LOGGER.info("getMovieKeywords"); - List result = tmdb.getMovieKeywords(ID_BLADE_RUNNER); - assertFalse("No keywords found", result.isEmpty()); - } - - /** - * Test of getMovieReleaseInfo method, of class TheMovieDb. - */ - @Test - public void testGetMovieReleaseInfo() { - LOGGER.info("getMovieReleaseInfo"); - List result = tmdb.getMovieReleaseInfo(ID_BLADE_RUNNER, ""); - assertFalse("Release information missing", result.isEmpty()); - } - - /** - * Test of getMovieTrailers method, of class TheMovieDb. - */ - @Test - public void testGetMovieTrailers() { - LOGGER.info("getMovieTrailers"); - List result = tmdb.getMovieTrailers(ID_BLADE_RUNNER, ""); - assertFalse("Movie trailers missing", result.isEmpty()); - } - - /** - * Test of getMovieTranslations method, of class TheMovieDb. - */ - @Test - public void testGetMovieTranslations() { - LOGGER.info("getMovieTranslations"); - List result = tmdb.getMovieTranslations(ID_BLADE_RUNNER); - assertFalse("No translations found", result.isEmpty()); - } - - /** - * Test of getCollectionInfo method, of class TheMovieDb. - */ - @Test - public void testGetCollectionInfo() { - LOGGER.info("getCollectionInfo"); - String language = ""; - CollectionInfo result = tmdb.getCollectionInfo(ID_STAR_WARS_COLLECTION, language); - assertFalse("No collection information", result.getParts().isEmpty()); - } - - @Test - public void testCreateImageUrl() { - LOGGER.info("createImageUrl"); - MovieDb movie = tmdb.getMovieInfo(ID_BLADE_RUNNER, ""); - String result = tmdb.createImageUrl(movie.getPosterPath(), "original").toString(); - assertTrue("Error compiling image URL", !result.isEmpty()); - } - - /** - * Test of getMovieInfoImdb method, of class TheMovieDb. - */ - @Test - public void testGetMovieInfoImdb() { - LOGGER.info("getMovieInfoImdb"); - MovieDb result = tmdb.getMovieInfoImdb("tt0076759", "en-US"); - assertTrue("Error getting the movie from IMDB ID", result.getId() == 11); - } - - /** - * Test of getApiKey method, of class TheMovieDb. - */ - @Test - public void testGetApiKey() { - // Not required - } - - /** - * Test of getApiBase method, of class TheMovieDb. - */ - @Test - public void testGetApiBase() { - // Not required - } - - /** - * Test of getConfiguration method, of class TheMovieDb. - */ - @Test - public void testGetConfiguration() { - // Not required - } - - /** - * Test of searchPeople method, of class TheMovieDb. - */ - @Test - public void testSearchPeople() { - LOGGER.info("searchPeople"); - String personName = "Bruce Willis"; - boolean allResults = false; - List result = tmdb.searchPeople(personName, allResults); - assertTrue("Couldn't find the person", result.size() > 0); - } - - /** - * Test of getPersonInfo method, of class TheMovieDb. - */ - @Test - public void testGetPersonInfo() { - LOGGER.info("getPersonInfo"); - Person result = tmdb.getPersonInfo(ID_BRUCE_WILLIS); - assertTrue("Wrong actor returned", result.getId() == ID_BRUCE_WILLIS); - } - - /** - * Test of getPersonCredits method, of class TheMovieDb. - */ - @Test - public void testGetPersonCredits() { - LOGGER.info("getPersonCredits"); - - List people = tmdb.getPersonCredits(ID_BRUCE_WILLIS); - assertTrue("No cast information", people.size() > 0); - } - - /** - * Test of getPersonImages method, of class TheMovieDb. - */ - @Test - public void testGetPersonImages() { - LOGGER.info("getPersonImages"); - - List artwork = tmdb.getPersonImages(ID_BRUCE_WILLIS); - assertTrue("No cast information", artwork.size() > 0); - } - -} +/* + * Copyright (c) 2004-2012 YAMJ Members + * http://code.google.com/p/moviejukebox/people/list + * + * Web: http://code.google.com/p/moviejukebox/ + * + * This software is licensed under a Creative Commons License + * See this page: http://code.google.com/p/moviejukebox/wiki/License + * + * For any reuse or distribution, you must make clear to others the + * license terms of this work. + */ +package com.moviejukebox.themoviedb; + +import com.moviejukebox.themoviedb.model.*; +import java.io.IOException; +import java.io.UnsupportedEncodingException; +import java.util.List; +import org.apache.commons.lang.StringUtils; +import org.apache.log4j.Logger; +import static org.junit.Assert.*; +import org.junit.*; + +/** + * Test cases for TheMovieDb API + * + * @author stuart.boston + */ +public class TheMovieDbTest { + + private static final Logger LOGGER = Logger.getLogger(TheMovieDbTest.class); + private static final String API_KEY = "5a1a77e2eba8984804586122754f969f"; + private static TheMovieDb tmdb; + /* + * Test data + */ + private static final int ID_BLADE_RUNNER = 78; + private static final int ID_STAR_WARS_COLLECTION = 10; + private static final int ID_BRUCE_WILLIS = 62; + + public TheMovieDbTest() throws IOException { + tmdb = new TheMovieDb(API_KEY); + } + + @BeforeClass + public static void setUpClass() throws Exception { + } + + @AfterClass + public static void tearDownClass() throws Exception { + } + + @Before + public void setUp() { + } + + @After + public void tearDown() { + } + + /** + * Test of getConfiguration method, of class TheMovieDb. + */ + @Test + public void testConfiguration() throws IOException { + LOGGER.info("Test Configuration"); + + TmdbConfiguration tmdbConfig = tmdb.getConfiguration(); + assertNotNull("Configuration failed", tmdbConfig); + assertTrue("No base URL", StringUtils.isNotBlank(tmdbConfig.getBaseUrl())); + assertTrue("No backdrop sizes", tmdbConfig.getBackdropSizes().size() > 0); + assertTrue("No poster sizes", tmdbConfig.getPosterSizes().size() > 0); + assertTrue("No profile sizes", tmdbConfig.getProfileSizes().size() > 0); + LOGGER.info(tmdbConfig.toString()); + } + + /** + * Test of searchMovie method, of class TheMovieDb. + */ + @Test + public void testSearchMovie() throws UnsupportedEncodingException { + LOGGER.info("searchMovie"); + + // Try a movie with less than 1 page of results + List movieList = tmdb.searchMovie("Blade Runner", "", true); + assertTrue("No movies found, should be at least 1", movieList.size() > 0); + + // Try a russian langugage movie + movieList = tmdb.searchMovie("О чём говорят мужчины", "ru", true); + assertTrue("No movies found, should be at least 1", movieList.size() > 0); + + // Try a movie with more than 20 results + movieList = tmdb.searchMovie("Star Wars", "en", false); + assertTrue("Not enough movies found, should be 20", movieList.size() == 20); + } + + /** + * Test of getMovieInfo method, of class TheMovieDb. + */ + @Test + public void testGetMovieInfo() { + LOGGER.info("getMovieInfo"); + String language = "en"; + MovieDb result = tmdb.getMovieInfo(ID_BLADE_RUNNER, language); + assertEquals("Incorrect movie information", "Blade Runner", result.getOriginalTitle()); + } + + /** + * Test of getMovieAlternativeTitles method, of class TheMovieDb. + */ + @Test + public void testGetMovieAlternativeTitles() { + LOGGER.info("getMovieAlternativeTitles"); + String country = ""; + List results = tmdb.getMovieAlternativeTitles(ID_BLADE_RUNNER, country); + assertTrue("No alternative titles found", results.size() > 0); + + country = "US"; + results = tmdb.getMovieAlternativeTitles(ID_BLADE_RUNNER, country); + assertTrue("No alternative titles found", results.size() > 0); + + } + + /** + * Test of getMovieCasts method, of class TheMovieDb. + */ + @Test + public void testGetMovieCasts() { + LOGGER.info("getMovieCasts"); + List people = tmdb.getMovieCasts(ID_BLADE_RUNNER); + assertTrue("No cast information", people.size() > 0); + + String name1 = "Harrison Ford"; + String name2 = "Charles Knode"; + boolean foundName1 = Boolean.FALSE; + boolean foundName2 = Boolean.FALSE; + + for (Person person : people) { + if (!foundName1 && person.getName().equalsIgnoreCase(name1)) { + foundName1 = Boolean.TRUE; + } + + if (!foundName2 && person.getName().equalsIgnoreCase(name2)) { + foundName2 = Boolean.TRUE; + } + } + assertTrue("Couldn't find " + name1, foundName1); + assertTrue("Couldn't find " + name2, foundName2); + } + + /** + * Test of getMovieImages method, of class TheMovieDb. + */ + @Test + public void testGetMovieImages() { + LOGGER.info("getMovieImages"); + String language = ""; + List result = tmdb.getMovieImages(ID_BLADE_RUNNER, language); + assertFalse("No artwork found", result.isEmpty()); + } + + /** + * Test of getMovieKeywords method, of class TheMovieDb. + */ + @Test + public void testGetMovieKeywords() { + LOGGER.info("getMovieKeywords"); + List result = tmdb.getMovieKeywords(ID_BLADE_RUNNER); + assertFalse("No keywords found", result.isEmpty()); + } + + /** + * Test of getMovieReleaseInfo method, of class TheMovieDb. + */ + @Test + public void testGetMovieReleaseInfo() { + LOGGER.info("getMovieReleaseInfo"); + List result = tmdb.getMovieReleaseInfo(ID_BLADE_RUNNER, ""); + assertFalse("Release information missing", result.isEmpty()); + } + + /** + * Test of getMovieTrailers method, of class TheMovieDb. + */ + @Test + public void testGetMovieTrailers() { + LOGGER.info("getMovieTrailers"); + List result = tmdb.getMovieTrailers(ID_BLADE_RUNNER, ""); + assertFalse("Movie trailers missing", result.isEmpty()); + } + + /** + * Test of getMovieTranslations method, of class TheMovieDb. + */ + @Test + public void testGetMovieTranslations() { + LOGGER.info("getMovieTranslations"); + List result = tmdb.getMovieTranslations(ID_BLADE_RUNNER); + assertFalse("No translations found", result.isEmpty()); + } + + /** + * Test of getCollectionInfo method, of class TheMovieDb. + */ + @Test + public void testGetCollectionInfo() { + LOGGER.info("getCollectionInfo"); + String language = ""; + CollectionInfo result = tmdb.getCollectionInfo(ID_STAR_WARS_COLLECTION, language); + assertFalse("No collection information", result.getParts().isEmpty()); + } + + @Test + public void testCreateImageUrl() { + LOGGER.info("createImageUrl"); + MovieDb movie = tmdb.getMovieInfo(ID_BLADE_RUNNER, ""); + String result = tmdb.createImageUrl(movie.getPosterPath(), "original").toString(); + assertTrue("Error compiling image URL", !result.isEmpty()); + } + + /** + * Test of getMovieInfoImdb method, of class TheMovieDb. + */ + @Test + public void testGetMovieInfoImdb() { + LOGGER.info("getMovieInfoImdb"); + MovieDb result = tmdb.getMovieInfoImdb("tt0076759", "en-US"); + assertTrue("Error getting the movie from IMDB ID", result.getId() == 11); + } + + /** + * Test of getApiKey method, of class TheMovieDb. + */ + @Test + public void testGetApiKey() { + // Not required + } + + /** + * Test of getApiBase method, of class TheMovieDb. + */ + @Test + public void testGetApiBase() { + // Not required + } + + /** + * Test of getConfiguration method, of class TheMovieDb. + */ + @Test + public void testGetConfiguration() { + // Not required + } + + /** + * Test of searchPeople method, of class TheMovieDb. + */ + @Test + public void testSearchPeople() { + LOGGER.info("searchPeople"); + String personName = "Bruce Willis"; + boolean allResults = false; + List result = tmdb.searchPeople(personName, allResults); + assertTrue("Couldn't find the person", result.size() > 0); + } + + /** + * Test of getPersonInfo method, of class TheMovieDb. + */ + @Test + public void testGetPersonInfo() { + LOGGER.info("getPersonInfo"); + Person result = tmdb.getPersonInfo(ID_BRUCE_WILLIS); + assertTrue("Wrong actor returned", result.getId() == ID_BRUCE_WILLIS); + } + + /** + * Test of getPersonCredits method, of class TheMovieDb. + */ + @Test + public void testGetPersonCredits() { + LOGGER.info("getPersonCredits"); + + List people = tmdb.getPersonCredits(ID_BRUCE_WILLIS); + assertTrue("No cast information", people.size() > 0); + } + + /** + * Test of getPersonImages method, of class TheMovieDb. + */ + @Test + public void testGetPersonImages() { + LOGGER.info("getPersonImages"); + + List artwork = tmdb.getPersonImages(ID_BRUCE_WILLIS); + assertTrue("No cast information", artwork.size() > 0); + } + + /** + * Test of getLatestMovie method, of class TheMovieDb. + */ + @Test + public void testGetLatestMovie() { + LOGGER.info("getLatestMovie"); + MovieDb result = tmdb.getLatestMovie(); + LOGGER.info(result.toString()); + assertTrue("No latest movie found", result.getId() > 0); +} + + /** + * Test of compareMovies method, of class TheMovieDb. + */ + @Test + public void testCompareMovies() { + // Not required + } +} From bbcecbc85f22d691063fe75cd87b0e5e802a172c Mon Sep 17 00:00:00 2001 From: Omertron Date: Tue, 31 Jan 2012 21:59:29 +0000 Subject: [PATCH 109/207] Added wrapper class for config to remove dependency on runtime settings --- .../moviejukebox/themoviedb/TheMovieDb.java | 6 +- .../themoviedb/model/TmdbConfiguration.java | 14 +++-- .../themoviedb/wrapper/WrapperConfig.java | 57 +++++++++++++++++++ 3 files changed, 68 insertions(+), 9 deletions(-) create mode 100644 themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperConfig.java diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java index 984b61b36..d82f955b1 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java @@ -23,7 +23,6 @@ import java.util.ArrayList; import java.util.List; import org.apache.commons.lang.StringUtils; import org.apache.log4j.Logger; -import org.codehaus.jackson.map.DeserializationConfig; import org.codehaus.jackson.map.ObjectMapper; /** @@ -74,9 +73,8 @@ public class TheMovieDb { public TheMovieDb(String apiKey) throws IOException { this.apiKey = apiKey; URL configUrl = tmdbConfigUrl.getQueryUrl(""); - mapper.configure(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE, true); - tmdbConfig = mapper.readValue(configUrl, TmdbConfiguration.class); - mapper.configure(DeserializationConfig.Feature.UNWRAP_ROOT_VALUE, false); + WrapperConfig wc = mapper.readValue(configUrl, WrapperConfig.class); + tmdbConfig = wc.getTmdbConfiguration(); FilteringLayout.addApiKey(apiKey); } diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/TmdbConfiguration.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/TmdbConfiguration.java index 70a32c0c2..38b24e99d 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/TmdbConfiguration.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/TmdbConfiguration.java @@ -17,13 +17,11 @@ import org.apache.commons.lang.StringUtils; import org.apache.log4j.Logger; import org.codehaus.jackson.annotate.JsonAnySetter; import org.codehaus.jackson.annotate.JsonProperty; -import org.codehaus.jackson.map.annotate.JsonRootName; /** * * @author stuart.boston */ -@JsonRootName("images") public class TmdbConfiguration { /* @@ -80,6 +78,7 @@ public class TmdbConfiguration { /** * Copy the data from the passed object to this one + * * @param config */ public void clone(TmdbConfiguration config) { @@ -91,11 +90,12 @@ public class TmdbConfiguration { /** * Check that the poster size is valid + * * @param posterSize * @return */ public boolean isValidPosterSize(String posterSize) { - if (StringUtils.isBlank(posterSize)) { + if (StringUtils.isBlank(posterSize) || posterSizes.isEmpty()) { return false; } return posterSizes.contains(posterSize); @@ -103,11 +103,12 @@ public class TmdbConfiguration { /** * Check that the backdrop size is valid + * * @param backdropSize * @return */ public boolean isValidBackdropSize(String backdropSize) { - if (StringUtils.isBlank(backdropSize)) { + if (StringUtils.isBlank(backdropSize) || backdropSizes.isEmpty()) { return false; } return backdropSizes.contains(backdropSize); @@ -115,11 +116,12 @@ public class TmdbConfiguration { /** * Check that the profile size is valid + * * @param profileSize * @return */ public boolean isValidProfileSize(String profileSize) { - if (StringUtils.isBlank(profileSize)) { + if (StringUtils.isBlank(profileSize) || profileSizes.isEmpty()) { return false; } return profileSizes.contains(profileSize); @@ -127,6 +129,7 @@ public class TmdbConfiguration { /** * Check to see if the size is valid for any of the images types + * * @param sizeToCheck * @return */ @@ -136,6 +139,7 @@ public class TmdbConfiguration { /** * Handle unknown properties and print a message + * * @param key * @param value */ diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperConfig.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperConfig.java new file mode 100644 index 000000000..7da6e21de --- /dev/null +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperConfig.java @@ -0,0 +1,57 @@ +/* + * Copyright (c) 2004-2012 YAMJ Members + * http://code.google.com/p/moviejukebox/people/list + * + * Web: http://code.google.com/p/moviejukebox/ + * + * This software is licensed under a Creative Commons License + * See this page: http://code.google.com/p/moviejukebox/wiki/License + * + * For any reuse or distribution, you must make clear to others the + * license terms of this work. + */ +package com.moviejukebox.themoviedb.wrapper; + +import com.moviejukebox.themoviedb.model.TmdbConfiguration; +import org.apache.log4j.Logger; +import org.codehaus.jackson.annotate.JsonAnySetter; +import org.codehaus.jackson.annotate.JsonProperty; + +/** + * + * @author Stuart + */ +public class WrapperConfig { + /* + * Logger + */ + + private static final Logger LOGGER = Logger.getLogger(WrapperConfig.class); + /* + * Properties + */ + @JsonProperty("images") + private TmdbConfiguration tmdbConfiguration; + + public TmdbConfiguration getTmdbConfiguration() { + return tmdbConfiguration; + } + + public void setTmdbConfiguration(TmdbConfiguration tmdbConfiguration) { + this.tmdbConfiguration = tmdbConfiguration; + } + + /** + * Handle unknown properties and print a message + * @param key + * @param value + */ + @JsonAnySetter + public void handleUnknown(String key, Object value) { + StringBuilder sb = new StringBuilder(); + sb.append("Unknown property: '").append(key); + sb.append("' value: '").append(value).append("'"); + LOGGER.warn(sb.toString()); + } + +} From 2867e14bc4f363c77fe1105c953d572297a4f0e9 Mon Sep 17 00:00:00 2001 From: Omertron Date: Fri, 3 Feb 2012 21:57:52 +0000 Subject: [PATCH 110/207] Changed revenue and budget from int to long --- .../themoviedb/model/MovieDb.java | 51 +++++-------------- 1 file changed, 14 insertions(+), 37 deletions(-) diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/MovieDb.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/MovieDb.java index 21cb93075..3dca1cf35 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/MovieDb.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/MovieDb.java @@ -50,7 +50,7 @@ public class MovieDb { @JsonProperty("belongs_to_collection") private Collection belongsToCollection; @JsonProperty("budget") - private int budget; + private long budget; @JsonProperty("genres") private List genres; @JsonProperty("homepage") @@ -64,7 +64,7 @@ public class MovieDb { @JsonProperty("production_countries") private List productionCountries; @JsonProperty("revenue") - private int revenue; + private long revenue; @JsonProperty("runtime") private int runtime; @JsonProperty("spoken_languages") @@ -113,7 +113,7 @@ public class MovieDb { return belongsToCollection; } - public int getBudget() { + public long getBudget() { return budget; } @@ -141,7 +141,7 @@ public class MovieDb { return productionCountries; } - public int getRevenue() { + public long getRevenue() { return revenue; } @@ -203,7 +203,7 @@ public class MovieDb { this.belongsToCollection = belongsToCollection; } - public void setBudget(int budget) { + public void setBudget(long budget) { this.budget = budget; } @@ -231,7 +231,7 @@ public class MovieDb { this.productionCountries = productionCountries; } - public void setRevenue(int revenue) { + public void setRevenue(long revenue) { this.revenue = revenue; } @@ -276,51 +276,28 @@ public class MovieDb { if (obj == null) { return false; } - if (getClass() != obj.getClass()) { return false; } - final MovieDb other = (MovieDb) obj; - if (this.id != other.id) { return false; } - - // Dirty way of checking that all the fields are the same - if (this.toString().equals(other.toString())) { + if ((this.imdbID == null) ? (other.imdbID != null) : !this.imdbID.equals(other.imdbID)) { + return false; + } + if (this.runtime != other.runtime) { return false; } - return true; } @Override public int hashCode() { - int hash = 3; - int multiplier = 97; - hash = multiplier * hash + (this.backdropPath != null ? this.backdropPath.hashCode() : 0); - hash = multiplier * hash + this.id; - hash = multiplier * hash + (this.originalTitle != null ? this.originalTitle.hashCode() : 0); - hash = multiplier * hash + Float.floatToIntBits(this.popularity); - hash = multiplier * hash + (this.posterPath != null ? this.posterPath.hashCode() : 0); - hash = multiplier * hash + (this.releaseDate != null ? this.releaseDate.hashCode() : 0); - hash = multiplier * hash + (this.title != null ? this.title.hashCode() : 0); - hash = multiplier * hash + (this.adult ? 1 : 0); - hash = multiplier * hash + (this.belongsToCollection != null ? this.belongsToCollection.hashCode() : 0); - hash = multiplier * hash + this.budget; - hash = multiplier * hash + (this.genres != null ? this.genres.hashCode() : 0); - hash = multiplier * hash + (this.homepage != null ? this.homepage.hashCode() : 0); - hash = multiplier * hash + (this.imdbID != null ? this.imdbID.hashCode() : 0); - hash = multiplier * hash + (this.overview != null ? this.overview.hashCode() : 0); - hash = multiplier * hash + (this.productionCompanies != null ? this.productionCompanies.hashCode() : 0); - hash = multiplier * hash + (this.productionCountries != null ? this.productionCountries.hashCode() : 0); - hash = multiplier * hash + this.revenue; - hash = multiplier * hash + this.runtime; - hash = multiplier * hash + (this.spokenLanguages != null ? this.spokenLanguages.hashCode() : 0); - hash = multiplier * hash + (this.tagline != null ? this.tagline.hashCode() : 0); - hash = multiplier * hash + Float.floatToIntBits(this.voteAverage); - hash = multiplier * hash + this.voteCount; + int hash = 5; + hash = 89 * hash + this.id; + hash = 89 * hash + (this.imdbID != null ? this.imdbID.hashCode() : 0); + hash = 89 * hash + this.runtime; return hash; } // From 7c6238d749fe281873551e5fb2bc197c497d7a6c Mon Sep 17 00:00:00 2001 From: Omertron Date: Sat, 4 Feb 2012 11:54:43 +0000 Subject: [PATCH 111/207] Fix issue with movieCompare --- .../moviejukebox/themoviedb/TheMovieDb.java | 41 ++++++++++--------- 1 file changed, 21 insertions(+), 20 deletions(-) diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java index d82f955b1..5e5e64e1d 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java @@ -80,6 +80,7 @@ public class TheMovieDb { /** * Get the API key that is to be used + * * @return */ public String getApiKey() { @@ -466,6 +467,7 @@ public class TheMovieDb { /** * This method is used to retrieve the newest movie that was added to TMDb. + * * @return */ public MovieDb getLatestMovie() { @@ -491,30 +493,29 @@ public class TheMovieDb { return false; } - if (StringUtils.isNotBlank(year)) { - if (StringUtils.isNotBlank(moviedb.getReleaseDate())) { - // Compare with year - String movieYear = moviedb.getReleaseDate().substring(0, 4); - if (movieYear.equals(year)) { - if (moviedb.getOriginalTitle().equalsIgnoreCase(title)) { - return true; - } + if (StringUtils.isNotBlank(year) && !year.equalsIgnoreCase("UNKNOWN") && StringUtils.isNotBlank(moviedb.getReleaseDate())) { + // Compare with year + String movieYear = moviedb.getReleaseDate().substring(0, 4); + if (movieYear.equals(year)) { + if (moviedb.getOriginalTitle().equalsIgnoreCase(title)) { + return true; + } - if (moviedb.getTitle().equalsIgnoreCase(title)) { - return true; - } + if (moviedb.getTitle().equalsIgnoreCase(title)) { + return true; } } - } else { - // Compare without year - if (moviedb.getOriginalTitle().equalsIgnoreCase(title)) { - return true; - } - - if (moviedb.getTitle().equalsIgnoreCase(title)) { - return true; - } } + + // Compare without year + if (moviedb.getOriginalTitle().equalsIgnoreCase(title)) { + return true; + } + + if (moviedb.getTitle().equalsIgnoreCase(title)) { + return true; + } + return false; } } From 7de94e43a7305d40f945981501494b35362ffe20 Mon Sep 17 00:00:00 2001 From: Omertron Date: Sat, 4 Feb 2012 14:37:53 +0000 Subject: [PATCH 112/207] Added proxy functionality --- themoviedbapi/pom.xml | 15 +- .../moviejukebox/themoviedb/TheMovieDb.java | 75 +++-- .../themoviedb/model/Collection.java | 2 +- .../themoviedb/model/TmdbConfiguration.java | 2 +- .../moviejukebox/themoviedb/tools/ApiUrl.java | 2 +- .../themoviedb/tools/WebBrowser.java | 261 ++++++++++++++++++ .../themoviedb/TheMovieDbTest.java | 2 +- 7 files changed, 333 insertions(+), 26 deletions(-) create mode 100644 themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/WebBrowser.java diff --git a/themoviedbapi/pom.xml b/themoviedbapi/pom.xml index 22362ab20..847499fe4 100644 --- a/themoviedbapi/pom.xml +++ b/themoviedbapi/pom.xml @@ -39,11 +39,6 @@ junit junit - - commons-lang - commons-lang - 2.6 - log4j log4j @@ -59,6 +54,16 @@ jackson-mapper-lgpl 1.9.4 + + commons-codec + commons-codec + 1.6 + + + org.apache.commons + commons-lang3 + 3.1 + diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java index 5e5e64e1d..cb3df50b8 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java @@ -15,13 +15,14 @@ package com.moviejukebox.themoviedb; import com.moviejukebox.themoviedb.model.*; import com.moviejukebox.themoviedb.tools.ApiUrl; import com.moviejukebox.themoviedb.tools.FilteringLayout; +import com.moviejukebox.themoviedb.tools.WebBrowser; import com.moviejukebox.themoviedb.wrapper.*; import java.io.IOException; import java.net.MalformedURLException; import java.net.URL; import java.util.ArrayList; import java.util.List; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; import org.apache.log4j.Logger; import org.codehaus.jackson.map.ObjectMapper; @@ -87,6 +88,30 @@ public class TheMovieDb { return apiKey; } + /** + * Set the proxy information + * @param host + * @param port + * @param username + * @param password + */ + public void setProxy(String host, String port, String username, String password) { + WebBrowser.setProxyHost(host); + WebBrowser.setProxyPort(port); + WebBrowser.setProxyUsername(username); + WebBrowser.setProxyPassword(password); + } + + /** + * Set the connection and read time out values + * @param connect + * @param read + */ + public void setTimeout(int connect, int read) { + WebBrowser.setWebTimeoutConnect(connect); + WebBrowser.setWebTimeoutRead(read); + } + /** * Search Movies This is a good starting point to start finding movies on * TMDb. The idea is to be a quick and light method so you can iterate @@ -96,7 +121,8 @@ public class TheMovieDb { public List searchMovie(String movieName, String language, boolean allResults) { try { URL url = tmdbSearchMovie.getQueryUrl(movieName, language, 1); - WrapperResultList resultList = mapper.readValue(url, WrapperResultList.class); + String webPage = WebBrowser.request(url); + WrapperResultList resultList = mapper.readValue(webPage, WrapperResultList.class); return resultList.getResults(); } catch (IOException ex) { LOGGER.warn("Failed to find movie: " + ex.getMessage()); @@ -115,7 +141,8 @@ public class TheMovieDb { public MovieDb getMovieInfo(int movieId, String language) { try { URL url = tmdbMovieInfo.getIdUrl(movieId, language); - return mapper.readValue(url, MovieDb.class); + String webPage = WebBrowser.request(url); + return mapper.readValue(webPage, MovieDb.class); } catch (IOException ex) { LOGGER.warn("Failed to get movie info: " + ex.getMessage()); } @@ -133,7 +160,8 @@ public class TheMovieDb { public MovieDb getMovieInfoImdb(String imdbId, String language) { try { URL url = tmdbMovieInfo.getIdUrl(imdbId, language); - return mapper.readValue(url, MovieDb.class); + String webPage = WebBrowser.request(url); + return mapper.readValue(webPage, MovieDb.class); } catch (IOException ex) { LOGGER.warn("Failed to get movie info: " + ex.getMessage()); } @@ -151,7 +179,8 @@ public class TheMovieDb { public List getMovieAlternativeTitles(int movieId, String country) { try { URL url = tmdbMovieAltTitles.getIdUrl(movieId, country); - WrapperAlternativeTitles at = mapper.readValue(url, WrapperAlternativeTitles.class); + String webPage = WebBrowser.request(url); + WrapperAlternativeTitles at = mapper.readValue(webPage, WrapperAlternativeTitles.class); return at.getTitles(); } catch (IOException ex) { LOGGER.warn("Failed to get movie alternative titles: " + ex.getMessage()); @@ -171,7 +200,8 @@ public class TheMovieDb { try { URL url = tmdbMovieCasts.getIdUrl(movieId); - WrapperMovieCasts mc = mapper.readValue(url, WrapperMovieCasts.class); + String webPage = WebBrowser.request(url); + WrapperMovieCasts mc = mapper.readValue(webPage, WrapperMovieCasts.class); // Add a cast member for (PersonCast cast : mc.getCast()) { @@ -206,7 +236,8 @@ public class TheMovieDb { List artwork = new ArrayList(); try { URL url = tmdbMovieImages.getIdUrl(movieId, language); - WrapperImages mi = mapper.readValue(url, WrapperImages.class); + String webPage = WebBrowser.request(url); + WrapperImages mi = mapper.readValue(webPage, WrapperImages.class); // Add all the posters to the list for (Artwork poster : mi.getPosters()) { @@ -237,7 +268,8 @@ public class TheMovieDb { public List getMovieKeywords(int movieId) { try { URL url = tmdbMovieKeywords.getIdUrl(movieId); - WrapperMovieKeywords mk = mapper.readValue(url, WrapperMovieKeywords.class); + String webPage = WebBrowser.request(url); + WrapperMovieKeywords mk = mapper.readValue(webPage, WrapperMovieKeywords.class); return mk.getKeywords(); } catch (IOException ex) { LOGGER.warn("Failed to get movie keywords: " + ex.getMessage()); @@ -256,7 +288,8 @@ public class TheMovieDb { public List getMovieReleaseInfo(int movieId, String language) { try { URL url = tmdbMovieReleaseInfo.getIdUrl(movieId); - WrapperReleaseInfo ri = mapper.readValue(url, WrapperReleaseInfo.class); + String webPage = WebBrowser.request(url); + WrapperReleaseInfo ri = mapper.readValue(webPage, WrapperReleaseInfo.class); return ri.getCountries(); } catch (IOException ex) { LOGGER.warn("Failed to get movie release information: " + ex.getMessage()); @@ -276,7 +309,8 @@ public class TheMovieDb { List trailers = new ArrayList(); try { URL url = tmdbMovieTrailers.getIdUrl(movieId); - WrapperTrailers wt = mapper.readValue(url, WrapperTrailers.class); + String webPage = WebBrowser.request(url); + WrapperTrailers wt = mapper.readValue(webPage, WrapperTrailers.class); // Add the trailer to the return list along with it's source for (Trailer trailer : wt.getQuicktime()) { @@ -306,7 +340,8 @@ public class TheMovieDb { public List getMovieTranslations(int movieId) { try { URL url = tmdbMovieTranslations.getIdUrl(movieId); - WrapperTranslations wt = mapper.readValue(url, WrapperTranslations.class); + String webPage = WebBrowser.request(url); + WrapperTranslations wt = mapper.readValue(webPage, WrapperTranslations.class); return wt.getTranslations(); } catch (IOException ex) { LOGGER.warn("Failed to get movie tranlations: " + ex.getMessage()); @@ -326,7 +361,8 @@ public class TheMovieDb { public CollectionInfo getCollectionInfo(int movieId, String language) { try { URL url = tmdbCollectionInfo.getIdUrl(movieId); - return mapper.readValue(url, CollectionInfo.class); + String webPage = WebBrowser.request(url); + return mapper.readValue(webPage, CollectionInfo.class); } catch (IOException ex) { return new CollectionInfo(); } @@ -380,7 +416,8 @@ public class TheMovieDb { try { URL url = tmdbSearchPeople.getQueryUrl(personName, "", 1); - WrapperPerson resultList = mapper.readValue(url, WrapperPerson.class); + String webPage = WebBrowser.request(url); + WrapperPerson resultList = mapper.readValue(webPage, WrapperPerson.class); return resultList.getResults(); } catch (IOException ex) { LOGGER.warn("Failed to find person: " + ex.getMessage()); @@ -398,7 +435,8 @@ public class TheMovieDb { public Person getPersonInfo(int personId) { try { URL url = tmdbPersonInfo.getIdUrl(personId); - return mapper.readValue(url, Person.class); + String webPage = WebBrowser.request(url); + return mapper.readValue(webPage, Person.class); } catch (IOException ex) { LOGGER.warn("Failed to get movie info: " + ex.getMessage()); return new Person(); @@ -418,7 +456,8 @@ public class TheMovieDb { try { URL url = tmdbPersonCredits.getIdUrl(personId); - WrapperPersonCredits pc = mapper.readValue(url, WrapperPersonCredits.class); + String webPage = WebBrowser.request(url); + WrapperPersonCredits pc = mapper.readValue(webPage, WrapperPersonCredits.class); // Add a cast member for (PersonCredit cast : pc.getCast()) { @@ -450,7 +489,8 @@ public class TheMovieDb { try { URL url = tmdbPersonImages.getIdUrl(personId); - WrapperImages images = mapper.readValue(url, WrapperImages.class); + String webPage = WebBrowser.request(url); + WrapperImages images = mapper.readValue(webPage, WrapperImages.class); // Update the image type for (Artwork artwork : images.getProfiles()) { @@ -473,7 +513,8 @@ public class TheMovieDb { public MovieDb getLatestMovie() { try { URL url = tmdbLatestMovie.getIdUrl(""); - return mapper.readValue(url, MovieDb.class); + String webPage = WebBrowser.request(url); + return mapper.readValue(webPage, MovieDb.class); } catch (IOException ex) { LOGGER.warn("Failed to get latest movie: " + ex.getMessage()); return new MovieDb(); diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Collection.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Collection.java index 4667edc08..bd22f3478 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Collection.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Collection.java @@ -12,7 +12,7 @@ */ package com.moviejukebox.themoviedb.model; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; import org.apache.log4j.Logger; import org.codehaus.jackson.annotate.JsonAnySetter; import org.codehaus.jackson.annotate.JsonProperty; diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/TmdbConfiguration.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/TmdbConfiguration.java index 38b24e99d..e71ba8f4a 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/TmdbConfiguration.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/TmdbConfiguration.java @@ -13,7 +13,7 @@ package com.moviejukebox.themoviedb.model; import java.util.List; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; import org.apache.log4j.Logger; import org.codehaus.jackson.annotate.JsonAnySetter; import org.codehaus.jackson.annotate.JsonProperty; diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/ApiUrl.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/ApiUrl.java index 649816b88..f26c0688b 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/ApiUrl.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/ApiUrl.java @@ -17,7 +17,7 @@ import java.io.UnsupportedEncodingException; import java.net.MalformedURLException; import java.net.URL; import java.net.URLEncoder; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; import org.apache.log4j.Logger; /** diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/WebBrowser.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/WebBrowser.java new file mode 100644 index 000000000..9574be267 --- /dev/null +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/WebBrowser.java @@ -0,0 +1,261 @@ +/* + * Copyright (c) 2004-2012 YAMJ Members + * http://code.google.com/p/moviejukebox/people/list + * + * Web: http://code.google.com/p/moviejukebox/ + * + * This software is licensed under a Creative Commons License + * See this page: http://code.google.com/p/moviejukebox/wiki/License + * + * For any reuse or distribution, you must make clear to others the + * license terms of this work. + */ +package com.moviejukebox.themoviedb.tools; + +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.StringWriter; +import java.net.HttpURLConnection; +import java.net.URL; +import java.net.URLConnection; +import java.nio.charset.Charset; +import java.nio.charset.UnsupportedCharsetException; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import org.apache.commons.codec.binary.Base64; + +/** + * Web browser with simple cookies support + */ +public final class WebBrowser { + + private static Map browserProperties = new HashMap(); + private static Map> cookies = new HashMap>(); + private static String proxyHost = null; + private static String proxyPort = null; + private static String proxyUsername = null; + private static String proxyPassword = null; + private static String proxyEncodedPassword = null; + private static int webTimeoutConnect = 25000; // 25 second timeout + private static int webTimeoutRead = 90000; // 90 second timeout + + // Hide the constructor + protected WebBrowser() { + // prevents calls from subclass + throw new UnsupportedOperationException(); + } + + /** + * Populate the browser properties + */ + private static void populateBrowserProperties() { + if (browserProperties.isEmpty()) { + browserProperties.put("User-Agent", "Mozilla/5.25 Netscape/5.0 (Windows; I; Win95)"); + } + } + + public static String request(String url) throws IOException { + return request(new URL(url)); + } + + public static URLConnection openProxiedConnection(URL url) throws IOException { + if (proxyHost != null) { + System.getProperties().put("proxySet", "true"); + System.getProperties().put("proxyHost", proxyHost); + System.getProperties().put("proxyPort", proxyPort); + } + + URLConnection cnx = url.openConnection(); + + if (proxyUsername != null) { + cnx.setRequestProperty("Proxy-Authorization", proxyEncodedPassword); + } + + return cnx; + } + + public static String request(URL url) throws IOException { + StringWriter content = null; + + try { + content = new StringWriter(); + + BufferedReader in = null; + URLConnection cnx = null; + try { + cnx = openProxiedConnection(url); + + sendHeader(cnx); + readHeader(cnx); + + in = new BufferedReader(new InputStreamReader(cnx.getInputStream(), getCharset(cnx))); + String line; + while ((line = in.readLine()) != null) { + content.write(line); + } + } finally { + if (in != null) { + in.close(); + } + if (cnx != null && cnx instanceof HttpURLConnection) { + ((HttpURLConnection) cnx).disconnect(); + } + } + return content.toString(); + } finally { + if (content != null) { + content.close(); + } + } + } + + private static void sendHeader(URLConnection cnx) { + populateBrowserProperties(); + + // send browser properties + for (Map.Entry browserProperty : browserProperties.entrySet()) { + cnx.setRequestProperty(browserProperty.getKey(), browserProperty.getValue()); + } + // send cookies + String cookieHeader = createCookieHeader(cnx); + if (!cookieHeader.isEmpty()) { + cnx.setRequestProperty("Cookie", cookieHeader); + } + } + + private static String createCookieHeader(URLConnection cnx) { + String host = cnx.getURL().getHost(); + StringBuilder cookiesHeader = new StringBuilder(); + for (Map.Entry> domainCookies : cookies.entrySet()) { + if (host.endsWith(domainCookies.getKey())) { + for (Map.Entry cookie : domainCookies.getValue().entrySet()) { + cookiesHeader.append(cookie.getKey()); + cookiesHeader.append("="); + cookiesHeader.append(cookie.getValue()); + cookiesHeader.append(";"); + } + } + } + if (cookiesHeader.length() > 0) { + // remove last ; char + cookiesHeader.deleteCharAt(cookiesHeader.length() - 1); + } + return cookiesHeader.toString(); + } + + private static void readHeader(URLConnection cnx) { + // read new cookies and update our cookies + for (Map.Entry> header : cnx.getHeaderFields().entrySet()) { + if ("Set-Cookie".equals(header.getKey())) { + for (String cookieHeader : header.getValue()) { + String[] cookieElements = cookieHeader.split(" *; *"); + if (cookieElements.length >= 1) { + String[] firstElem = cookieElements[0].split(" *= *"); + String cookieName = firstElem[0]; + String cookieValue = firstElem.length > 1 ? firstElem[1] : null; + String cookieDomain = null; + // find cookie domain + for (int i = 1; i < cookieElements.length; i++) { + String[] cookieElement = cookieElements[i].split(" *= *"); + if ("domain".equals(cookieElement[0])) { + cookieDomain = cookieElement.length > 1 ? cookieElement[1] : null; + break; + } + } + if (cookieDomain == null) { + // if domain isn't set take current host + cookieDomain = cnx.getURL().getHost(); + } + Map domainCookies = cookies.get(cookieDomain); + if (domainCookies == null) { + domainCookies = new HashMap(); + cookies.put(cookieDomain, domainCookies); + } + // add or replace cookie + domainCookies.put(cookieName, cookieValue); + } + } + } + } + } + + private static Charset getCharset(URLConnection cnx) { + Charset charset = null; + // content type will be string like "text/html; charset=UTF-8" or "text/html" + String contentType = cnx.getContentType(); + if (contentType != null) { + // changed 'charset' to 'harset' in regexp because some sites send 'Charset' + Matcher m = Pattern.compile("harset *=[ '\"]*([^ ;'\"]+)[ ;'\"]*").matcher(contentType); + if (m.find()) { + String encoding = m.group(1); + try { + charset = Charset.forName(encoding); + } catch (UnsupportedCharsetException e) { + // there will be used default charset + } + } + } + if (charset == null) { + charset = Charset.defaultCharset(); + } + + return charset; + } + + public static String getProxyHost() { + return proxyHost; + } + + public static void setProxyHost(String myProxyHost) { + WebBrowser.proxyHost = myProxyHost; + } + + public static String getProxyPort() { + return proxyPort; + } + + public static void setProxyPort(String myProxyPort) { + WebBrowser.proxyPort = myProxyPort; + } + + public static String getProxyUsername() { + return proxyUsername; + } + + public static void setProxyUsername(String myProxyUsername) { + WebBrowser.proxyUsername = myProxyUsername; + } + + public static String getProxyPassword() { + return proxyPassword; + } + + public static void setProxyPassword(String myProxyPassword) { + WebBrowser.proxyPassword = myProxyPassword; + + if (proxyUsername != null) { + proxyEncodedPassword = proxyUsername + ":" + proxyPassword; + proxyEncodedPassword = "Basic " + new String(Base64.encodeBase64((proxyUsername + ":" + proxyPassword).getBytes())); + } + } + + public static int getWebTimeoutConnect() { + return webTimeoutConnect; + } + + public static int getWebTimeoutRead() { + return webTimeoutRead; + } + + public static void setWebTimeoutConnect(int webTimeoutConnect) { + WebBrowser.webTimeoutConnect = webTimeoutConnect; + } + + public static void setWebTimeoutRead(int webTimeoutRead) { + WebBrowser.webTimeoutRead = webTimeoutRead; + } +} diff --git a/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java b/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java index a09e185cd..1c7c06b4c 100644 --- a/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java +++ b/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java @@ -16,7 +16,7 @@ import com.moviejukebox.themoviedb.model.*; import java.io.IOException; import java.io.UnsupportedEncodingException; import java.util.List; -import org.apache.commons.lang.StringUtils; +import org.apache.commons.lang3.StringUtils; import org.apache.log4j.Logger; import static org.junit.Assert.*; import org.junit.*; From d2249076828a9a276c4a574c6f829fc9178b7183 Mon Sep 17 00:00:00 2001 From: Omertron Date: Wed, 29 Feb 2012 21:46:17 +0000 Subject: [PATCH 113/207] [maven-release-plugin] prepare release themoviedbapi-3.0 --- themoviedbapi/pom.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/themoviedbapi/pom.xml b/themoviedbapi/pom.xml index 847499fe4..0e7cf5571 100644 --- a/themoviedbapi/pom.xml +++ b/themoviedbapi/pom.xml @@ -8,7 +8,7 @@ com.moviejukebox themoviedbapi - 3.0-SNAPSHOT + 3.0 API-The MovieDB @@ -22,9 +22,9 @@ - scm:svn:http://themoviedbapi.googlecode.com/svn/trunk/themoviedbapi - scm:svn:https://themoviedbapi.googlecode.com/svn/trunk/themoviedbapi - http://code.google.com/p/themoviedbapi/source/browse/trunk/themoviedbapi + scm:svn:http://themoviedbapi.googlecode.com/svn/tags/themoviedbapi-3.0 + scm:svn:https://themoviedbapi.googlecode.com/svn/tags/themoviedbapi-3.0 + http://code.google.com/p/themoviedbapi/source/browse/tags/themoviedbapi-3.0 From 59820cf8e3d4db8106d32bbf382e9f06b73aff11 Mon Sep 17 00:00:00 2001 From: Omertron Date: Wed, 29 Feb 2012 21:46:26 +0000 Subject: [PATCH 114/207] [maven-release-plugin] prepare for next development iteration --- themoviedbapi/pom.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/themoviedbapi/pom.xml b/themoviedbapi/pom.xml index 0e7cf5571..8d8431ff9 100644 --- a/themoviedbapi/pom.xml +++ b/themoviedbapi/pom.xml @@ -8,7 +8,7 @@ com.moviejukebox themoviedbapi - 3.0 + 3.1-SNAPSHOT API-The MovieDB @@ -22,9 +22,9 @@ - scm:svn:http://themoviedbapi.googlecode.com/svn/tags/themoviedbapi-3.0 - scm:svn:https://themoviedbapi.googlecode.com/svn/tags/themoviedbapi-3.0 - http://code.google.com/p/themoviedbapi/source/browse/tags/themoviedbapi-3.0 + scm:svn:http://themoviedbapi.googlecode.com/svn/trunk/themoviedbapi + scm:svn:https://themoviedbapi.googlecode.com/svn/trunk/themoviedbapi + http://code.google.com/p/themoviedbapi/source/browse/trunk/themoviedbapi From 5dadce92c9decd0c5360f98f323a66b943227e64 Mon Sep 17 00:00:00 2001 From: Omertron Date: Sun, 18 Mar 2012 14:59:23 +0000 Subject: [PATCH 115/207] Update to Jackson --- themoviedbapi/pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/themoviedbapi/pom.xml b/themoviedbapi/pom.xml index 8d8431ff9..2317b707a 100644 --- a/themoviedbapi/pom.xml +++ b/themoviedbapi/pom.xml @@ -47,12 +47,12 @@ org.codehaus.jackson jackson-core-lgpl - 1.9.4 + 1.9.5 org.codehaus.jackson jackson-mapper-lgpl - 1.9.4 + 1.9.5 commons-codec From f43b0d7e94015b2f58f129678f088e4992b6febc Mon Sep 17 00:00:00 2001 From: Omertron Date: Mon, 19 Mar 2012 19:58:19 +0000 Subject: [PATCH 116/207] Use proxy for config call --- .../src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java index cb3df50b8..76059d7e6 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java @@ -74,7 +74,8 @@ public class TheMovieDb { public TheMovieDb(String apiKey) throws IOException { this.apiKey = apiKey; URL configUrl = tmdbConfigUrl.getQueryUrl(""); - WrapperConfig wc = mapper.readValue(configUrl, WrapperConfig.class); + String webPage = WebBrowser.request(configUrl); + WrapperConfig wc = mapper.readValue(webPage, WrapperConfig.class); tmdbConfig = wc.getTmdbConfiguration(); FilteringLayout.addApiKey(apiKey); } From 04c22ed42befa803b41303d538219e96315dfafe Mon Sep 17 00:00:00 2001 From: Omertron Date: Tue, 20 Mar 2012 09:02:36 +0000 Subject: [PATCH 117/207] [maven-release-plugin] prepare release themoviedbapi-3.1 --- themoviedbapi/pom.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/themoviedbapi/pom.xml b/themoviedbapi/pom.xml index 2317b707a..6ed59363f 100644 --- a/themoviedbapi/pom.xml +++ b/themoviedbapi/pom.xml @@ -8,7 +8,7 @@ com.moviejukebox themoviedbapi - 3.1-SNAPSHOT + 3.1 API-The MovieDB @@ -22,9 +22,9 @@ - scm:svn:http://themoviedbapi.googlecode.com/svn/trunk/themoviedbapi - scm:svn:https://themoviedbapi.googlecode.com/svn/trunk/themoviedbapi - http://code.google.com/p/themoviedbapi/source/browse/trunk/themoviedbapi + scm:svn:http://themoviedbapi.googlecode.com/svn/tags/themoviedbapi-3.1 + scm:svn:https://themoviedbapi.googlecode.com/svn/tags/themoviedbapi-3.1 + http://code.google.com/p/themoviedbapi/source/browse/tags/themoviedbapi-3.1 From c61d718b45658750c0e6cda0888b2d1742c282a9 Mon Sep 17 00:00:00 2001 From: Omertron Date: Tue, 20 Mar 2012 09:02:45 +0000 Subject: [PATCH 118/207] [maven-release-plugin] prepare for next development iteration --- themoviedbapi/pom.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/themoviedbapi/pom.xml b/themoviedbapi/pom.xml index 6ed59363f..3a7adc6fe 100644 --- a/themoviedbapi/pom.xml +++ b/themoviedbapi/pom.xml @@ -8,7 +8,7 @@ com.moviejukebox themoviedbapi - 3.1 + 3.2-SNAPSHOT API-The MovieDB @@ -22,9 +22,9 @@ - scm:svn:http://themoviedbapi.googlecode.com/svn/tags/themoviedbapi-3.1 - scm:svn:https://themoviedbapi.googlecode.com/svn/tags/themoviedbapi-3.1 - http://code.google.com/p/themoviedbapi/source/browse/tags/themoviedbapi-3.1 + scm:svn:http://themoviedbapi.googlecode.com/svn/trunk/themoviedbapi + scm:svn:https://themoviedbapi.googlecode.com/svn/trunk/themoviedbapi + http://code.google.com/p/themoviedbapi/source/browse/trunk/themoviedbapi From 6667b4679ad014c7ca7b3cd859371d23d88cf3e0 Mon Sep 17 00:00:00 2001 From: Omertron Date: Mon, 26 Mar 2012 20:27:30 +0000 Subject: [PATCH 119/207] Added exception information --- .../themoviedb/MovieDbException.java | 31 +++ .../moviejukebox/themoviedb/TheMovieDb.java | 209 ++++++++++-------- .../themoviedb/tools/WebBrowser.java | 52 +++-- .../themoviedb/TheMovieDbTest.java | 37 ++-- 4 files changed, 203 insertions(+), 126 deletions(-) create mode 100644 themoviedbapi/src/main/java/com/moviejukebox/themoviedb/MovieDbException.java diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/MovieDbException.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/MovieDbException.java new file mode 100644 index 000000000..fcd9a938d --- /dev/null +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/MovieDbException.java @@ -0,0 +1,31 @@ +package com.moviejukebox.themoviedb; + +public class MovieDbException extends Exception { + + private static final long serialVersionUID = -8952129102483143278L; + + public enum MovieDbExceptionType { + + UNKNOWN_CAUSE, INVALID_URL, HTTP_404_ERROR, MOVIE_ID_NOT_FOUND, MAPPING_FAILED, CONNECTION_ERROR; + } + private final MovieDbExceptionType exceptionType; + private final String response; + + public MovieDbException(final MovieDbExceptionType exceptionType, + final String response) { + + super(); + this.exceptionType = exceptionType; + this.response = response; + } + + public MovieDbExceptionType getExceptionType() { + + return exceptionType; + } + + public String getResponse() { + + return response; + } +} diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java index 76059d7e6..e4b7e0b15 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java @@ -12,6 +12,7 @@ */ package com.moviejukebox.themoviedb; +import com.moviejukebox.themoviedb.MovieDbException.MovieDbExceptionType; import com.moviejukebox.themoviedb.model.*; import com.moviejukebox.themoviedb.tools.ApiUrl; import com.moviejukebox.themoviedb.tools.FilteringLayout; @@ -71,13 +72,18 @@ public class TheMovieDb { * @param apiKey * @throws IOException */ - public TheMovieDb(String apiKey) throws IOException { + public TheMovieDb(String apiKey) throws MovieDbException { this.apiKey = apiKey; URL configUrl = tmdbConfigUrl.getQueryUrl(""); String webPage = WebBrowser.request(configUrl); - WrapperConfig wc = mapper.readValue(webPage, WrapperConfig.class); - tmdbConfig = wc.getTmdbConfiguration(); FilteringLayout.addApiKey(apiKey); + + try { + WrapperConfig wc = mapper.readValue(webPage, WrapperConfig.class); + tmdbConfig = wc.getTmdbConfiguration(); + } catch (IOException error) { + throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, "Failed to read configuration"); + } } /** @@ -90,11 +96,12 @@ public class TheMovieDb { } /** - * Set the proxy information + * Set the proxy information + * * @param host * @param port * @param username - * @param password + * @param password */ public void setProxy(String host, String port, String username, String password) { WebBrowser.setProxyHost(host); @@ -105,8 +112,9 @@ public class TheMovieDb { /** * Set the connection and read time out values + * * @param connect - * @param read + * @param read */ public void setTimeout(int connect, int read) { WebBrowser.setWebTimeoutConnect(connect); @@ -119,15 +127,16 @@ public class TheMovieDb { * through movies quickly. http://help.themoviedb.org/kb/api/search-movies * TODO: Make the allResults work */ - public List searchMovie(String movieName, String language, boolean allResults) { + public List searchMovie(String movieName, String language, boolean allResults) throws MovieDbException { + + URL url = tmdbSearchMovie.getQueryUrl(movieName, language, 1); + String webPage = WebBrowser.request(url); try { - URL url = tmdbSearchMovie.getQueryUrl(movieName, language, 1); - String webPage = WebBrowser.request(url); WrapperResultList resultList = mapper.readValue(webPage, WrapperResultList.class); return resultList.getResults(); - } catch (IOException ex) { - LOGGER.warn("Failed to find movie: " + ex.getMessage()); - return new ArrayList(); + } catch (IOException error) { + LOGGER.warn("Failed to find movie: " + error.getMessage()); + throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage); } } @@ -139,15 +148,16 @@ public class TheMovieDb { * @param language * @return */ - public MovieDb getMovieInfo(int movieId, String language) { + public MovieDb getMovieInfo(int movieId, String language) throws MovieDbException { + + URL url = tmdbMovieInfo.getIdUrl(movieId, language); + String webPage = WebBrowser.request(url); try { - URL url = tmdbMovieInfo.getIdUrl(movieId, language); - String webPage = WebBrowser.request(url); return mapper.readValue(webPage, MovieDb.class); - } catch (IOException ex) { - LOGGER.warn("Failed to get movie info: " + ex.getMessage()); + } catch (IOException error) { + LOGGER.warn("Failed to get movie info: " + error.getMessage()); + throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage); } - return new MovieDb(); } /** @@ -158,15 +168,16 @@ public class TheMovieDb { * @param language * @return */ - public MovieDb getMovieInfoImdb(String imdbId, String language) { + public MovieDb getMovieInfoImdb(String imdbId, String language) throws MovieDbException { + + URL url = tmdbMovieInfo.getIdUrl(imdbId, language); + String webPage = WebBrowser.request(url); try { - URL url = tmdbMovieInfo.getIdUrl(imdbId, language); - String webPage = WebBrowser.request(url); return mapper.readValue(webPage, MovieDb.class); - } catch (IOException ex) { - LOGGER.warn("Failed to get movie info: " + ex.getMessage()); + } catch (IOException error) { + LOGGER.warn("Failed to get movie info: " + error.getMessage()); + throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage); } - return new MovieDb(); } /** @@ -177,16 +188,17 @@ public class TheMovieDb { * @param country * @return */ - public List getMovieAlternativeTitles(int movieId, String country) { + public List getMovieAlternativeTitles(int movieId, String country) throws MovieDbException { + + URL url = tmdbMovieAltTitles.getIdUrl(movieId, country); + String webPage = WebBrowser.request(url); try { - URL url = tmdbMovieAltTitles.getIdUrl(movieId, country); - String webPage = WebBrowser.request(url); WrapperAlternativeTitles at = mapper.readValue(webPage, WrapperAlternativeTitles.class); return at.getTitles(); - } catch (IOException ex) { - LOGGER.warn("Failed to get movie alternative titles: " + ex.getMessage()); + } catch (IOException error) { + LOGGER.warn("Failed to get movie alternative titles: " + error.getMessage()); + throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage); } - return new ArrayList(); } /** @@ -196,12 +208,13 @@ public class TheMovieDb { * @param movieId * @return */ - public List getMovieCasts(int movieId) { + public List getMovieCasts(int movieId) throws MovieDbException { + List people = new ArrayList(); + URL url = tmdbMovieCasts.getIdUrl(movieId); + String webPage = WebBrowser.request(url); try { - URL url = tmdbMovieCasts.getIdUrl(movieId); - String webPage = WebBrowser.request(url); WrapperMovieCasts mc = mapper.readValue(webPage, WrapperMovieCasts.class); // Add a cast member @@ -219,10 +232,10 @@ public class TheMovieDb { } return people; - } catch (IOException ex) { - LOGGER.warn("Failed to get movie casts: " + ex.getMessage()); + } catch (IOException error) { + LOGGER.warn("Failed to get movie casts: " + error.getMessage()); + throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage); } - return people; } /** @@ -233,11 +246,12 @@ public class TheMovieDb { * @param language * @return */ - public List getMovieImages(int movieId, String language) { + public List getMovieImages(int movieId, String language) throws MovieDbException { + List artwork = new ArrayList(); + URL url = tmdbMovieImages.getIdUrl(movieId, language); + String webPage = WebBrowser.request(url); try { - URL url = tmdbMovieImages.getIdUrl(movieId, language); - String webPage = WebBrowser.request(url); WrapperImages mi = mapper.readValue(webPage, WrapperImages.class); // Add all the posters to the list @@ -253,10 +267,10 @@ public class TheMovieDb { } return artwork; - } catch (IOException ex) { - LOGGER.warn("Failed to get movie images: " + ex.getMessage()); + } catch (IOException error) { + LOGGER.warn("Failed to get movie images: " + error.getMessage()); + throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage); } - return artwork; } /** @@ -266,16 +280,18 @@ public class TheMovieDb { * @param movieId * @return */ - public List getMovieKeywords(int movieId) { + public List getMovieKeywords(int movieId) throws MovieDbException { + + URL url = tmdbMovieKeywords.getIdUrl(movieId); + String webPage = WebBrowser.request(url); + try { - URL url = tmdbMovieKeywords.getIdUrl(movieId); - String webPage = WebBrowser.request(url); WrapperMovieKeywords mk = mapper.readValue(webPage, WrapperMovieKeywords.class); return mk.getKeywords(); } catch (IOException ex) { LOGGER.warn("Failed to get movie keywords: " + ex.getMessage()); + throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage); } - return new ArrayList(); } /** @@ -286,16 +302,18 @@ public class TheMovieDb { * @param language * @return */ - public List getMovieReleaseInfo(int movieId, String language) { + public List getMovieReleaseInfo(int movieId, String language) throws MovieDbException { + + URL url = tmdbMovieReleaseInfo.getIdUrl(movieId); + String webPage = WebBrowser.request(url); + try { - URL url = tmdbMovieReleaseInfo.getIdUrl(movieId); - String webPage = WebBrowser.request(url); WrapperReleaseInfo ri = mapper.readValue(webPage, WrapperReleaseInfo.class); return ri.getCountries(); } catch (IOException ex) { LOGGER.warn("Failed to get movie release information: " + ex.getMessage()); + throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage); } - return new ArrayList(); } /** @@ -306,11 +324,13 @@ public class TheMovieDb { * @param language * @return */ - public List getMovieTrailers(int movieId, String language) { + public List getMovieTrailers(int movieId, String language) throws MovieDbException { + List trailers = new ArrayList(); + URL url = tmdbMovieTrailers.getIdUrl(movieId, language); + String webPage = WebBrowser.request(url); + try { - URL url = tmdbMovieTrailers.getIdUrl(movieId); - String webPage = WebBrowser.request(url); WrapperTrailers wt = mapper.readValue(webPage, WrapperTrailers.class); // Add the trailer to the return list along with it's source @@ -318,7 +338,6 @@ public class TheMovieDb { trailer.setWebsite(Trailer.WEBSITE_QUICKTIME); trailers.add(trailer); } - // Add the trailer to the return list along with it's source for (Trailer trailer : wt.getYoutube()) { trailer.setWebsite(Trailer.WEBSITE_YOUTUBE); @@ -327,8 +346,8 @@ public class TheMovieDb { return trailers; } catch (IOException ex) { LOGGER.warn("Failed to get movie trailers: " + ex.getMessage()); + throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage); } - return trailers; } /** @@ -338,16 +357,18 @@ public class TheMovieDb { * @param movieId * @return */ - public List getMovieTranslations(int movieId) { + public List getMovieTranslations(int movieId) throws MovieDbException { + + URL url = tmdbMovieTranslations.getIdUrl(movieId); + String webPage = WebBrowser.request(url); + try { - URL url = tmdbMovieTranslations.getIdUrl(movieId); - String webPage = WebBrowser.request(url); WrapperTranslations wt = mapper.readValue(webPage, WrapperTranslations.class); return wt.getTranslations(); } catch (IOException ex) { LOGGER.warn("Failed to get movie tranlations: " + ex.getMessage()); + throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage); } - return new ArrayList(); } /** @@ -359,13 +380,16 @@ public class TheMovieDb { * @param language * @return */ - public CollectionInfo getCollectionInfo(int movieId, String language) { + public CollectionInfo getCollectionInfo(int movieId, String language) throws MovieDbException { + + URL url = tmdbCollectionInfo.getIdUrl(movieId); + String webPage = WebBrowser.request(url); + try { - URL url = tmdbCollectionInfo.getIdUrl(movieId); - String webPage = WebBrowser.request(url); return mapper.readValue(webPage, CollectionInfo.class); } catch (IOException ex) { - return new CollectionInfo(); + LOGGER.warn("Failed to get movie tranlations: " + ex.getMessage()); + throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage); } } @@ -385,7 +409,7 @@ public class TheMovieDb { * @param requiredSize * @return */ - public URL createImageUrl(String imagePath, String requiredSize) { + public URL createImageUrl(String imagePath, String requiredSize) throws MovieDbException { URL returnUrl = null; StringBuilder sb; @@ -400,12 +424,11 @@ public class TheMovieDb { sb = new StringBuilder(tmdbConfig.getBaseUrl()); sb.append(requiredSize); sb.append(imagePath); - returnUrl = new URL(sb.toString()); + return (new URL(sb.toString())); } catch (MalformedURLException ex) { LOGGER.warn("Failed to create image URL: " + ex.getMessage()); + throw new MovieDbException(MovieDbExceptionType.INVALID_URL, returnUrl.toString()); } - - return returnUrl; } /** @@ -413,16 +436,17 @@ public class TheMovieDb { * is to be a quick and light method so you can iterate through people * quickly. TODO: Fix allResults */ - public List searchPeople(String personName, boolean allResults) { + public List searchPeople(String personName, boolean allResults) throws MovieDbException { + + URL url = tmdbSearchPeople.getQueryUrl(personName, "", 1); + String webPage = WebBrowser.request(url); try { - URL url = tmdbSearchPeople.getQueryUrl(personName, "", 1); - String webPage = WebBrowser.request(url); WrapperPerson resultList = mapper.readValue(webPage, WrapperPerson.class); return resultList.getResults(); } catch (IOException ex) { LOGGER.warn("Failed to find person: " + ex.getMessage()); - return new ArrayList(); + throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage); } } @@ -433,14 +457,16 @@ public class TheMovieDb { * @param personId * @return */ - public Person getPersonInfo(int personId) { + public Person getPersonInfo(int personId) throws MovieDbException { + + URL url = tmdbPersonInfo.getIdUrl(personId); + String webPage = WebBrowser.request(url); + try { - URL url = tmdbPersonInfo.getIdUrl(personId); - String webPage = WebBrowser.request(url); return mapper.readValue(webPage, Person.class); } catch (IOException ex) { LOGGER.warn("Failed to get movie info: " + ex.getMessage()); - return new Person(); + throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage); } } @@ -452,12 +478,14 @@ public class TheMovieDb { * @param personId * @return */ - public List getPersonCredits(int personId) { + public List getPersonCredits(int personId) throws MovieDbException { + List personCredits = new ArrayList(); + URL url = tmdbPersonCredits.getIdUrl(personId); + String webPage = WebBrowser.request(url); + try { - URL url = tmdbPersonCredits.getIdUrl(personId); - String webPage = WebBrowser.request(url); WrapperPersonCredits pc = mapper.readValue(webPage, WrapperPersonCredits.class); // Add a cast member @@ -465,17 +493,15 @@ public class TheMovieDb { cast.setPersonType(PersonType.CAST); personCredits.add(cast); } - // Add a crew member for (PersonCredit crew : pc.getCrew()) { crew.setPersonType(PersonType.CREW); personCredits.add(crew); } - return personCredits; } catch (IOException ex) { LOGGER.warn("Failed to get person credits: " + ex.getMessage()); - return personCredits; + throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage); } } @@ -485,12 +511,14 @@ public class TheMovieDb { * @param personId * @return */ - public List getPersonImages(int personId) { + public List getPersonImages(int personId) throws MovieDbException { + List personImages = new ArrayList(); + URL url = tmdbPersonImages.getIdUrl(personId); + String webPage = WebBrowser.request(url); + try { - URL url = tmdbPersonImages.getIdUrl(personId); - String webPage = WebBrowser.request(url); WrapperImages images = mapper.readValue(webPage, WrapperImages.class); // Update the image type @@ -498,11 +526,10 @@ public class TheMovieDb { artwork.setArtworkType(ArtworkType.PROFILE); personImages.add(artwork); } - return personImages; } catch (IOException ex) { LOGGER.warn("Failed to get person images: " + ex.getMessage()); - return personImages; + throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage); } } @@ -511,14 +538,16 @@ public class TheMovieDb { * * @return */ - public MovieDb getLatestMovie() { + public MovieDb getLatestMovie() throws MovieDbException { + + URL url = tmdbLatestMovie.getIdUrl(""); + String webPage = WebBrowser.request(url); + try { - URL url = tmdbLatestMovie.getIdUrl(""); - String webPage = WebBrowser.request(url); return mapper.readValue(webPage, MovieDb.class); } catch (IOException ex) { LOGGER.warn("Failed to get latest movie: " + ex.getMessage()); - return new MovieDb(); + throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage); } } diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/WebBrowser.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/WebBrowser.java index 9574be267..809458dec 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/WebBrowser.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/WebBrowser.java @@ -12,11 +12,13 @@ */ package com.moviejukebox.themoviedb.tools; +import com.moviejukebox.themoviedb.MovieDbException; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.StringWriter; import java.net.HttpURLConnection; +import java.net.MalformedURLException; import java.net.URL; import java.net.URLConnection; import java.nio.charset.Charset; @@ -27,12 +29,14 @@ import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; import org.apache.commons.codec.binary.Base64; +import org.apache.log4j.Logger; /** * Web browser with simple cookies support */ public final class WebBrowser { + private static final Logger LOGGER = Logger.getLogger(WebBrowser.class); private static Map browserProperties = new HashMap(); private static Map> cookies = new HashMap>(); private static String proxyHost = null; @@ -58,27 +62,35 @@ public final class WebBrowser { } } - public static String request(String url) throws IOException { - return request(new URL(url)); + public static String request(String url) throws MovieDbException { + try { + return request(new URL(url)); + } catch (MalformedURLException ex) { + throw new MovieDbException(MovieDbException.MovieDbExceptionType.INVALID_URL, null); + } } - public static URLConnection openProxiedConnection(URL url) throws IOException { - if (proxyHost != null) { - System.getProperties().put("proxySet", "true"); - System.getProperties().put("proxyHost", proxyHost); - System.getProperties().put("proxyPort", proxyPort); + public static URLConnection openProxiedConnection(URL url) throws MovieDbException { + try { + if (proxyHost != null) { + System.getProperties().put("proxySet", "true"); + System.getProperties().put("proxyHost", proxyHost); + System.getProperties().put("proxyPort", proxyPort); + } + + URLConnection cnx = url.openConnection(); + + if (proxyUsername != null) { + cnx.setRequestProperty("Proxy-Authorization", proxyEncodedPassword); + } + + return cnx; + } catch (IOException ex) { + throw new MovieDbException(MovieDbException.MovieDbExceptionType.INVALID_URL, null); } - - URLConnection cnx = url.openConnection(); - - if (proxyUsername != null) { - cnx.setRequestProperty("Proxy-Authorization", proxyEncodedPassword); - } - - return cnx; } - public static String request(URL url) throws IOException { + public static String request(URL url) throws MovieDbException { StringWriter content = null; try { @@ -106,9 +118,15 @@ public final class WebBrowser { } } return content.toString(); + } catch (IOException error) { + throw new MovieDbException(MovieDbException.MovieDbExceptionType.CONNECTION_ERROR, null); } finally { if (content != null) { - content.close(); + try { + content.close(); + } catch (IOException ex) { + LOGGER.debug("Failed to close connection: " + ex.getMessage()); + } } } } diff --git a/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java b/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java index 1c7c06b4c..7a8fc4a5e 100644 --- a/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java +++ b/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java @@ -14,7 +14,6 @@ package com.moviejukebox.themoviedb; import com.moviejukebox.themoviedb.model.*; import java.io.IOException; -import java.io.UnsupportedEncodingException; import java.util.List; import org.apache.commons.lang3.StringUtils; import org.apache.log4j.Logger; @@ -38,7 +37,7 @@ public class TheMovieDbTest { private static final int ID_STAR_WARS_COLLECTION = 10; private static final int ID_BRUCE_WILLIS = 62; - public TheMovieDbTest() throws IOException { + public TheMovieDbTest() throws MovieDbException { tmdb = new TheMovieDb(API_KEY); } @@ -78,7 +77,7 @@ public class TheMovieDbTest { * Test of searchMovie method, of class TheMovieDb. */ @Test - public void testSearchMovie() throws UnsupportedEncodingException { + public void testSearchMovie() throws MovieDbException { LOGGER.info("searchMovie"); // Try a movie with less than 1 page of results @@ -98,7 +97,7 @@ public class TheMovieDbTest { * Test of getMovieInfo method, of class TheMovieDb. */ @Test - public void testGetMovieInfo() { + public void testGetMovieInfo() throws MovieDbException { LOGGER.info("getMovieInfo"); String language = "en"; MovieDb result = tmdb.getMovieInfo(ID_BLADE_RUNNER, language); @@ -109,7 +108,7 @@ public class TheMovieDbTest { * Test of getMovieAlternativeTitles method, of class TheMovieDb. */ @Test - public void testGetMovieAlternativeTitles() { + public void testGetMovieAlternativeTitles() throws MovieDbException { LOGGER.info("getMovieAlternativeTitles"); String country = ""; List results = tmdb.getMovieAlternativeTitles(ID_BLADE_RUNNER, country); @@ -125,7 +124,7 @@ public class TheMovieDbTest { * Test of getMovieCasts method, of class TheMovieDb. */ @Test - public void testGetMovieCasts() { + public void testGetMovieCasts() throws MovieDbException { LOGGER.info("getMovieCasts"); List people = tmdb.getMovieCasts(ID_BLADE_RUNNER); assertTrue("No cast information", people.size() > 0); @@ -152,7 +151,7 @@ public class TheMovieDbTest { * Test of getMovieImages method, of class TheMovieDb. */ @Test - public void testGetMovieImages() { + public void testGetMovieImages() throws MovieDbException { LOGGER.info("getMovieImages"); String language = ""; List result = tmdb.getMovieImages(ID_BLADE_RUNNER, language); @@ -163,7 +162,7 @@ public class TheMovieDbTest { * Test of getMovieKeywords method, of class TheMovieDb. */ @Test - public void testGetMovieKeywords() { + public void testGetMovieKeywords() throws MovieDbException { LOGGER.info("getMovieKeywords"); List result = tmdb.getMovieKeywords(ID_BLADE_RUNNER); assertFalse("No keywords found", result.isEmpty()); @@ -173,7 +172,7 @@ public class TheMovieDbTest { * Test of getMovieReleaseInfo method, of class TheMovieDb. */ @Test - public void testGetMovieReleaseInfo() { + public void testGetMovieReleaseInfo() throws MovieDbException { LOGGER.info("getMovieReleaseInfo"); List result = tmdb.getMovieReleaseInfo(ID_BLADE_RUNNER, ""); assertFalse("Release information missing", result.isEmpty()); @@ -183,7 +182,7 @@ public class TheMovieDbTest { * Test of getMovieTrailers method, of class TheMovieDb. */ @Test - public void testGetMovieTrailers() { + public void testGetMovieTrailers() throws MovieDbException { LOGGER.info("getMovieTrailers"); List result = tmdb.getMovieTrailers(ID_BLADE_RUNNER, ""); assertFalse("Movie trailers missing", result.isEmpty()); @@ -193,7 +192,7 @@ public class TheMovieDbTest { * Test of getMovieTranslations method, of class TheMovieDb. */ @Test - public void testGetMovieTranslations() { + public void testGetMovieTranslations() throws MovieDbException { LOGGER.info("getMovieTranslations"); List result = tmdb.getMovieTranslations(ID_BLADE_RUNNER); assertFalse("No translations found", result.isEmpty()); @@ -203,7 +202,7 @@ public class TheMovieDbTest { * Test of getCollectionInfo method, of class TheMovieDb. */ @Test - public void testGetCollectionInfo() { + public void testGetCollectionInfo() throws MovieDbException { LOGGER.info("getCollectionInfo"); String language = ""; CollectionInfo result = tmdb.getCollectionInfo(ID_STAR_WARS_COLLECTION, language); @@ -211,7 +210,7 @@ public class TheMovieDbTest { } @Test - public void testCreateImageUrl() { + public void testCreateImageUrl() throws MovieDbException { LOGGER.info("createImageUrl"); MovieDb movie = tmdb.getMovieInfo(ID_BLADE_RUNNER, ""); String result = tmdb.createImageUrl(movie.getPosterPath(), "original").toString(); @@ -222,7 +221,7 @@ public class TheMovieDbTest { * Test of getMovieInfoImdb method, of class TheMovieDb. */ @Test - public void testGetMovieInfoImdb() { + public void testGetMovieInfoImdb() throws MovieDbException { LOGGER.info("getMovieInfoImdb"); MovieDb result = tmdb.getMovieInfoImdb("tt0076759", "en-US"); assertTrue("Error getting the movie from IMDB ID", result.getId() == 11); @@ -256,7 +255,7 @@ public class TheMovieDbTest { * Test of searchPeople method, of class TheMovieDb. */ @Test - public void testSearchPeople() { + public void testSearchPeople() throws MovieDbException { LOGGER.info("searchPeople"); String personName = "Bruce Willis"; boolean allResults = false; @@ -268,7 +267,7 @@ public class TheMovieDbTest { * Test of getPersonInfo method, of class TheMovieDb. */ @Test - public void testGetPersonInfo() { + public void testGetPersonInfo() throws MovieDbException { LOGGER.info("getPersonInfo"); Person result = tmdb.getPersonInfo(ID_BRUCE_WILLIS); assertTrue("Wrong actor returned", result.getId() == ID_BRUCE_WILLIS); @@ -278,7 +277,7 @@ public class TheMovieDbTest { * Test of getPersonCredits method, of class TheMovieDb. */ @Test - public void testGetPersonCredits() { + public void testGetPersonCredits() throws MovieDbException { LOGGER.info("getPersonCredits"); List people = tmdb.getPersonCredits(ID_BRUCE_WILLIS); @@ -289,7 +288,7 @@ public class TheMovieDbTest { * Test of getPersonImages method, of class TheMovieDb. */ @Test - public void testGetPersonImages() { + public void testGetPersonImages() throws MovieDbException { LOGGER.info("getPersonImages"); List artwork = tmdb.getPersonImages(ID_BRUCE_WILLIS); @@ -300,7 +299,7 @@ public class TheMovieDbTest { * Test of getLatestMovie method, of class TheMovieDb. */ @Test - public void testGetLatestMovie() { + public void testGetLatestMovie() throws MovieDbException { LOGGER.info("getLatestMovie"); MovieDb result = tmdb.getLatestMovie(); LOGGER.info(result.toString()); From 9080343a8433ee06aa725b8aefc9ca8b4ab4dea2 Mon Sep 17 00:00:00 2001 From: Omertron Date: Tue, 27 Mar 2012 10:47:32 +0000 Subject: [PATCH 120/207] Corrected width in Artwork to be an int not string --- .../com/moviejukebox/themoviedb/model/Artwork.java | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Artwork.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Artwork.java index e739de0c1..90d4e81ce 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Artwork.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Artwork.java @@ -39,7 +39,7 @@ public class Artwork { @JsonProperty("iso_639_1") private String language; @JsonProperty("width") - private String width; + private int width; @JsonProperty("vote_average") private float voteAverage; @JsonProperty("vote_count") @@ -67,7 +67,7 @@ public class Artwork { return language; } - public String getWidth() { + public int getWidth() { return width; } @@ -101,7 +101,7 @@ public class Artwork { this.language = language; } - public void setWidth(String width) { + public void setWidth(int width) { this.width = width; } @@ -149,7 +149,7 @@ public class Artwork { if ((this.language == null) ? (other.language != null) : !this.language.equals(other.language)) { return false; } - if ((this.width == null) ? (other.width != null) : !this.width.equals(other.width)) { + if (this.width != other.width) { return false; } if (this.artworkType != other.artworkType) { @@ -165,7 +165,7 @@ public class Artwork { hash = 71 * hash + (this.filePath != null ? this.filePath.hashCode() : 0); hash = 71 * hash + this.height; hash = 71 * hash + (this.language != null ? this.language.hashCode() : 0); - hash = 71 * hash + (this.width != null ? this.width.hashCode() : 0); + hash = 71 * hash + this.width; hash = 71 * hash + (this.artworkType != null ? this.artworkType.hashCode() : 0); return hash; } From d7352384bdf657522a8a82ca68a5bfcc52b39060 Mon Sep 17 00:00:00 2001 From: Omertron Date: Tue, 27 Mar 2012 10:52:56 +0000 Subject: [PATCH 121/207] Fix getMovieAlternativeTitles not using the country correctly --- .../src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java | 2 +- .../main/java/com/moviejukebox/themoviedb/tools/ApiUrl.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java index e4b7e0b15..ea97a9872 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java @@ -190,7 +190,7 @@ public class TheMovieDb { */ public List getMovieAlternativeTitles(int movieId, String country) throws MovieDbException { - URL url = tmdbMovieAltTitles.getIdUrl(movieId, country); + URL url = tmdbMovieAltTitles.getIdUrl(movieId, ApiUrl.DEFAULT_STRING, country); String webPage = WebBrowser.request(url); try { WrapperAlternativeTitles at = mapper.readValue(webPage, WrapperAlternativeTitles.class); diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/ApiUrl.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/ApiUrl.java index f26c0688b..232a46185 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/ApiUrl.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/ApiUrl.java @@ -45,8 +45,8 @@ public class ApiUrl { private static final String PARAMETER_LANGUAGE = DELIMITER_SUBSEQUENT + "language="; private static final String PARAMETER_COUNTRY = DELIMITER_SUBSEQUENT + "country="; private static final String PARAMETER_PAGE = DELIMITER_SUBSEQUENT + "page="; - private static final String DEFAULT_STRING = ""; - private static final int DEFAULT_INT = -1; + public static final String DEFAULT_STRING = ""; + public static final int DEFAULT_INT = -1; /* * Properties */ From 183125bd3cab7be5a826092100f892dbf072e989 Mon Sep 17 00:00:00 2001 From: Omertron Date: Sat, 31 Mar 2012 08:39:08 +0000 Subject: [PATCH 122/207] Fixes issue 14 --- .../themoviedb/model/TmdbConfiguration.java | 46 +++++++++++++++---- 1 file changed, 37 insertions(+), 9 deletions(-) diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/TmdbConfiguration.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/TmdbConfiguration.java index e71ba8f4a..61eacf9d6 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/TmdbConfiguration.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/TmdbConfiguration.java @@ -39,42 +39,52 @@ public class TmdbConfiguration { private List backdropSizes; @JsonProperty("profile_sizes") private List profileSizes; + @JsonProperty("logo_sizes") + private List logoSizes; // //GEN-BEGIN:getterMethods public List getBackdropSizes() { return backdropSizes; } - + public String getBaseUrl() { return baseUrl; } - + public List getPosterSizes() { return posterSizes; } - + public List getProfileSizes() { return profileSizes; } + + public List getLogoSizes() { + return logoSizes; + } // // //GEN-BEGIN:setterMethods public void setBackdropSizes(List backdropSizes) { this.backdropSizes = backdropSizes; } - + public void setBaseUrl(String baseUrl) { this.baseUrl = baseUrl; } - + public void setPosterSizes(List posterSizes) { this.posterSizes = posterSizes; } - + public void setProfileSizes(List profileSizes) { this.profileSizes = profileSizes; } -// + + public void setLogoSizes(List logoSizes) { + this.logoSizes = logoSizes; + } + // /** * Copy the data from the passed object to this one @@ -86,6 +96,7 @@ public class TmdbConfiguration { baseUrl = config.getBaseUrl(); posterSizes = config.getPosterSizes(); profileSizes = config.getProfileSizes(); + logoSizes = config.getLogoSizes(); } /** @@ -127,6 +138,19 @@ public class TmdbConfiguration { return profileSizes.contains(profileSize); } + /** + * Check that the logo size is valid + * + * @param logoSize + * @return + */ + public boolean isValidLogoSize(String logoSize) { + if (StringUtils.isBlank(logoSize) || logoSizes.isEmpty()) { + return false; + } + return logoSizes.contains(logoSize); + } + /** * Check to see if the size is valid for any of the images types * @@ -134,7 +158,10 @@ public class TmdbConfiguration { * @return */ public boolean isValidSize(String sizeToCheck) { - return (isValidPosterSize(sizeToCheck) || isValidBackdropSize(sizeToCheck) || isValidProfileSize(sizeToCheck)); + return (isValidPosterSize(sizeToCheck) + || isValidBackdropSize(sizeToCheck) + || isValidProfileSize(sizeToCheck) + || isValidLogoSize(sizeToCheck)); } /** @@ -150,7 +177,7 @@ public class TmdbConfiguration { sb.append("' value: '").append(value).append("'"); LOGGER.warn(sb.toString()); } - + @Override public String toString() { StringBuilder sb = new StringBuilder("[ImageConfiguration="); @@ -158,6 +185,7 @@ public class TmdbConfiguration { sb.append("],[posterSizes=").append(posterSizes.toString()); sb.append("],[backdropSizes=").append(backdropSizes.toString()); sb.append("],[profileSizes=").append(profileSizes.toString()); + sb.append("],[logoSizes=").append(logoSizes.toString()); sb.append(("]]")); return sb.toString(); } From 398b5b0916f5553f76d3481725995329729fc8b5 Mon Sep 17 00:00:00 2001 From: Omertron Date: Sun, 1 Apr 2012 08:42:59 +0000 Subject: [PATCH 123/207] fixes issue 15 --- .../com/moviejukebox/themoviedb/TheMovieDb.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java index ea97a9872..a806b6a54 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java @@ -44,10 +44,15 @@ public class TheMovieDb { */ private static final String BASE_MOVIE = "movie/"; private static final String BASE_PERSON = "person/"; + + // Configuration URL private final ApiUrl tmdbConfigUrl = new ApiUrl(this, "configuration"); + // Search URLS private final ApiUrl tmdbSearchMovie = new ApiUrl(this, "search/movie"); private final ApiUrl tmdbSearchPeople = new ApiUrl(this, "search/person"); + // Collections private final ApiUrl tmdbCollectionInfo = new ApiUrl(this, "collection/"); + // Movie Info private final ApiUrl tmdbMovieInfo = new ApiUrl(this, BASE_MOVIE); private final ApiUrl tmdbMovieAltTitles = new ApiUrl(this, BASE_MOVIE, "/alternative_titles"); private final ApiUrl tmdbMovieCasts = new ApiUrl(this, BASE_MOVIE, "/casts"); @@ -56,11 +61,21 @@ public class TheMovieDb { private final ApiUrl tmdbMovieReleaseInfo = new ApiUrl(this, BASE_MOVIE, "/releases"); private final ApiUrl tmdbMovieTrailers = new ApiUrl(this, BASE_MOVIE, "/trailers"); private final ApiUrl tmdbMovieTranslations = new ApiUrl(this, BASE_MOVIE, "/translations"); + // Person Info private final ApiUrl tmdbPersonInfo = new ApiUrl(this, BASE_PERSON); private final ApiUrl tmdbPersonCredits = new ApiUrl(this, BASE_PERSON, "/credits"); private final ApiUrl tmdbPersonImages = new ApiUrl(this, BASE_PERSON, "/images"); + // Misc Movie + // - Movie Add Rating - Issue 9 + // - Latest Movie private final ApiUrl tmdbLatestMovie = new ApiUrl(this, "latest/movie"); - + // - Now Playing Movies + // - Populate Movie List + // - Top Rated Movies + // Company Info + // - Company Info + // - Company Movies + /* * Jackson JSON configuration */ From c8385c51cc50d158146a20bb29b4cbc2e5f3a73f Mon Sep 17 00:00:00 2001 From: Omertron Date: Sun, 1 Apr 2012 09:02:18 +0000 Subject: [PATCH 124/207] fixes issue 11 --- .../moviejukebox/themoviedb/TheMovieDb.java | 35 +++++++++++++++---- .../moviejukebox/themoviedb/tools/ApiUrl.java | 2 +- .../themoviedb/TheMovieDbTest.java | 32 +++++++++++++++-- 3 files changed, 59 insertions(+), 10 deletions(-) diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java index a806b6a54..a34775eac 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java @@ -44,7 +44,6 @@ public class TheMovieDb { */ private static final String BASE_MOVIE = "movie/"; private static final String BASE_PERSON = "person/"; - // Configuration URL private final ApiUrl tmdbConfigUrl = new ApiUrl(this, "configuration"); // Search URLS @@ -65,17 +64,16 @@ public class TheMovieDb { private final ApiUrl tmdbPersonInfo = new ApiUrl(this, BASE_PERSON); private final ApiUrl tmdbPersonCredits = new ApiUrl(this, BASE_PERSON, "/credits"); private final ApiUrl tmdbPersonImages = new ApiUrl(this, BASE_PERSON, "/images"); - // Misc Movie - // - Movie Add Rating - Issue 9 - // - Latest Movie + /* + * Misc Movie - Movie Add Rating - Issue 9 + */ private final ApiUrl tmdbLatestMovie = new ApiUrl(this, "latest/movie"); - // - Now Playing Movies + private final ApiUrl tmdbNowPlaying = new ApiUrl(this, "movie/now-playing"); // - Populate Movie List // - Top Rated Movies // Company Info // - Company Info // - Company Movies - /* * Jackson JSON configuration */ @@ -566,6 +564,31 @@ public class TheMovieDb { } } + /** + * This method is used to retrieve the movies currently in theatres. This is + * a curated list that will normally contain 100 movies. The default + * response will return 20 movies. + * + * @return + * @throws MovieDbException + */ + public List getNowPlayingMovies(String language) throws MovieDbException { + URL url = tmdbNowPlaying.getIdUrl("", language); + String webPage = WebBrowser.request(url); + + try { + WrapperResultList resultList = mapper.readValue(webPage, WrapperResultList.class); + return resultList.getResults(); + } catch (IOException ex) { + LOGGER.warn("Failed to get latest movie: " + ex.getMessage()); + throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage); + } + } + + public List getNowPlayingMovies() throws MovieDbException { + return getNowPlayingMovies(""); + } + /** * Compare the MovieDB object with a title & year * diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/ApiUrl.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/ApiUrl.java index 232a46185..a7f920cc5 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/ApiUrl.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/ApiUrl.java @@ -147,7 +147,7 @@ public class ApiUrl { LOGGER.trace("URL: " + urlString.toString()); return new URL(urlString.toString()); } catch (MalformedURLException ex) { - LOGGER.warn("Failed to create URL " + urlString.toString()); + LOGGER.warn("Failed to create URL " + urlString.toString() + " - " + ex.toString()); return null; } } diff --git a/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java b/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java index 7a8fc4a5e..f89df73ce 100644 --- a/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java +++ b/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java @@ -77,7 +77,7 @@ public class TheMovieDbTest { * Test of searchMovie method, of class TheMovieDb. */ @Test - public void testSearchMovie() throws MovieDbException { + public void testSearchMovie() throws MovieDbException { LOGGER.info("searchMovie"); // Try a movie with less than 1 page of results @@ -302,9 +302,9 @@ public class TheMovieDbTest { public void testGetLatestMovie() throws MovieDbException { LOGGER.info("getLatestMovie"); MovieDb result = tmdb.getLatestMovie(); - LOGGER.info(result.toString()); + assertTrue("No latest movie found", result != null); assertTrue("No latest movie found", result.getId() > 0); -} + } /** * Test of compareMovies method, of class TheMovieDb. @@ -313,4 +313,30 @@ public class TheMovieDbTest { public void testCompareMovies() { // Not required } + + /** + * Test of setProxy method, of class TheMovieDb. + */ + @Test + public void testSetProxy() { + // Not required + } + + /** + * Test of setTimeout method, of class TheMovieDb. + */ + @Test + public void testSetTimeout() { + // Not required + } + + /** + * Test of getNowPlayingMovies method, of class TheMovieDb. + */ + @Test + public void testGetNowPlayingMovies() throws Exception { + LOGGER.info("getNowPlayingMovies"); + List results = tmdb.getNowPlayingMovies(); + assertTrue("No now playing movies foind", !results.isEmpty()); + } } From ad31df723c335d9e2fd9d180ee5c14591a6aaf37 Mon Sep 17 00:00:00 2001 From: Omertron Date: Sun, 1 Apr 2012 09:08:03 +0000 Subject: [PATCH 125/207] Caught new image exception error --- .../themoviedb/MovieDbException.java | 2 +- .../moviejukebox/themoviedb/TheMovieDb.java | 18 ++++++------------ 2 files changed, 7 insertions(+), 13 deletions(-) diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/MovieDbException.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/MovieDbException.java index fcd9a938d..832203c04 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/MovieDbException.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/MovieDbException.java @@ -6,7 +6,7 @@ public class MovieDbException extends Exception { public enum MovieDbExceptionType { - UNKNOWN_CAUSE, INVALID_URL, HTTP_404_ERROR, MOVIE_ID_NOT_FOUND, MAPPING_FAILED, CONNECTION_ERROR; + UNKNOWN_CAUSE, INVALID_URL, HTTP_404_ERROR, MOVIE_ID_NOT_FOUND, MAPPING_FAILED, CONNECTION_ERROR, INVALID_IMAGE; } private final MovieDbExceptionType exceptionType; private final String response; diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java index a34775eac..e15b25023 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java @@ -423,24 +423,18 @@ public class TheMovieDb { * @return */ public URL createImageUrl(String imagePath, String requiredSize) throws MovieDbException { - URL returnUrl = null; - StringBuilder sb; - if (!tmdbConfig.isValidSize(requiredSize)) { - sb = new StringBuilder(); - sb.append(" - Invalid size requested: ").append(requiredSize); - LOGGER.warn(sb.toString()); - return returnUrl; + throw new MovieDbException(MovieDbExceptionType.INVALID_IMAGE, requiredSize); } + StringBuilder sb = new StringBuilder(tmdbConfig.getBaseUrl()); + sb.append(requiredSize); + sb.append(imagePath); try { - sb = new StringBuilder(tmdbConfig.getBaseUrl()); - sb.append(requiredSize); - sb.append(imagePath); return (new URL(sb.toString())); } catch (MalformedURLException ex) { LOGGER.warn("Failed to create image URL: " + ex.getMessage()); - throw new MovieDbException(MovieDbExceptionType.INVALID_URL, returnUrl.toString()); + throw new MovieDbException(MovieDbExceptionType.INVALID_URL, sb.toString()); } } @@ -584,7 +578,7 @@ public class TheMovieDb { throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage); } } - + public List getNowPlayingMovies() throws MovieDbException { return getNowPlayingMovies(""); } From 065c75f0fc950062f294d2869157ee8f9bae7993 Mon Sep 17 00:00:00 2001 From: Omertron Date: Sun, 1 Apr 2012 09:47:13 +0000 Subject: [PATCH 126/207] Ensure stack trace is preserved through exception --- .../themoviedb/MovieDbException.java | 10 ++- .../moviejukebox/themoviedb/TheMovieDb.java | 64 +++++++++---------- .../themoviedb/tools/WebBrowser.java | 8 +-- 3 files changed, 43 insertions(+), 39 deletions(-) diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/MovieDbException.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/MovieDbException.java index 832203c04..8ee4d839e 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/MovieDbException.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/MovieDbException.java @@ -11,14 +11,18 @@ public class MovieDbException extends Exception { private final MovieDbExceptionType exceptionType; private final String response; - public MovieDbException(final MovieDbExceptionType exceptionType, - final String response) { - + public MovieDbException(final MovieDbExceptionType exceptionType, final String response) { super(); this.exceptionType = exceptionType; this.response = response; } + public MovieDbException(final MovieDbExceptionType exceptionType, final String response, Throwable cause) { + super(cause); + this.exceptionType = exceptionType; + this.response = response; + } + public MovieDbExceptionType getExceptionType() { return exceptionType; diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java index e15b25023..34e113594 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java @@ -94,8 +94,8 @@ public class TheMovieDb { try { WrapperConfig wc = mapper.readValue(webPage, WrapperConfig.class); tmdbConfig = wc.getTmdbConfiguration(); - } catch (IOException error) { - throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, "Failed to read configuration"); + } catch (IOException ex) { + throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, "Failed to read configuration", ex); } } @@ -147,9 +147,9 @@ public class TheMovieDb { try { WrapperResultList resultList = mapper.readValue(webPage, WrapperResultList.class); return resultList.getResults(); - } catch (IOException error) { - LOGGER.warn("Failed to find movie: " + error.getMessage()); - throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage); + } catch (IOException ex) { + LOGGER.warn("Failed to find movie: " + ex.getMessage()); + throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage, ex); } } @@ -167,9 +167,9 @@ public class TheMovieDb { String webPage = WebBrowser.request(url); try { return mapper.readValue(webPage, MovieDb.class); - } catch (IOException error) { - LOGGER.warn("Failed to get movie info: " + error.getMessage()); - throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage); + } catch (IOException ex) { + LOGGER.warn("Failed to get movie info: " + ex.getMessage()); + throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage, ex); } } @@ -187,9 +187,9 @@ public class TheMovieDb { String webPage = WebBrowser.request(url); try { return mapper.readValue(webPage, MovieDb.class); - } catch (IOException error) { - LOGGER.warn("Failed to get movie info: " + error.getMessage()); - throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage); + } catch (IOException ex) { + LOGGER.warn("Failed to get movie info: " + ex.getMessage()); + throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage, ex); } } @@ -208,9 +208,9 @@ public class TheMovieDb { try { WrapperAlternativeTitles at = mapper.readValue(webPage, WrapperAlternativeTitles.class); return at.getTitles(); - } catch (IOException error) { - LOGGER.warn("Failed to get movie alternative titles: " + error.getMessage()); - throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage); + } catch (IOException ex) { + LOGGER.warn("Failed to get movie alternative titles: " + ex.getMessage()); + throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage, ex); } } @@ -245,9 +245,9 @@ public class TheMovieDb { } return people; - } catch (IOException error) { - LOGGER.warn("Failed to get movie casts: " + error.getMessage()); - throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage); + } catch (IOException ex) { + LOGGER.warn("Failed to get movie casts: " + ex.getMessage()); + throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage, ex); } } @@ -280,9 +280,9 @@ public class TheMovieDb { } return artwork; - } catch (IOException error) { - LOGGER.warn("Failed to get movie images: " + error.getMessage()); - throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage); + } catch (IOException ex) { + LOGGER.warn("Failed to get movie images: " + ex.getMessage()); + throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage, ex); } } @@ -303,7 +303,7 @@ public class TheMovieDb { return mk.getKeywords(); } catch (IOException ex) { LOGGER.warn("Failed to get movie keywords: " + ex.getMessage()); - throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage); + throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage, ex); } } @@ -325,7 +325,7 @@ public class TheMovieDb { return ri.getCountries(); } catch (IOException ex) { LOGGER.warn("Failed to get movie release information: " + ex.getMessage()); - throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage); + throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage, ex); } } @@ -359,7 +359,7 @@ public class TheMovieDb { return trailers; } catch (IOException ex) { LOGGER.warn("Failed to get movie trailers: " + ex.getMessage()); - throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage); + throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage, ex); } } @@ -380,7 +380,7 @@ public class TheMovieDb { return wt.getTranslations(); } catch (IOException ex) { LOGGER.warn("Failed to get movie tranlations: " + ex.getMessage()); - throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage); + throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage, ex); } } @@ -402,7 +402,7 @@ public class TheMovieDb { return mapper.readValue(webPage, CollectionInfo.class); } catch (IOException ex) { LOGGER.warn("Failed to get movie tranlations: " + ex.getMessage()); - throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage); + throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage, ex); } } @@ -434,7 +434,7 @@ public class TheMovieDb { return (new URL(sb.toString())); } catch (MalformedURLException ex) { LOGGER.warn("Failed to create image URL: " + ex.getMessage()); - throw new MovieDbException(MovieDbExceptionType.INVALID_URL, sb.toString()); + throw new MovieDbException(MovieDbExceptionType.INVALID_URL, sb.toString(), ex); } } @@ -453,7 +453,7 @@ public class TheMovieDb { return resultList.getResults(); } catch (IOException ex) { LOGGER.warn("Failed to find person: " + ex.getMessage()); - throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage); + throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage, ex); } } @@ -473,7 +473,7 @@ public class TheMovieDb { return mapper.readValue(webPage, Person.class); } catch (IOException ex) { LOGGER.warn("Failed to get movie info: " + ex.getMessage()); - throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage); + throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage, ex); } } @@ -508,7 +508,7 @@ public class TheMovieDb { return personCredits; } catch (IOException ex) { LOGGER.warn("Failed to get person credits: " + ex.getMessage()); - throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage); + throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage, ex); } } @@ -536,7 +536,7 @@ public class TheMovieDb { return personImages; } catch (IOException ex) { LOGGER.warn("Failed to get person images: " + ex.getMessage()); - throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage); + throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage, ex); } } @@ -554,7 +554,7 @@ public class TheMovieDb { return mapper.readValue(webPage, MovieDb.class); } catch (IOException ex) { LOGGER.warn("Failed to get latest movie: " + ex.getMessage()); - throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage); + throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage, ex); } } @@ -575,7 +575,7 @@ public class TheMovieDb { return resultList.getResults(); } catch (IOException ex) { LOGGER.warn("Failed to get latest movie: " + ex.getMessage()); - throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage); + throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage, ex); } } diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/WebBrowser.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/WebBrowser.java index 809458dec..e9d70fbb6 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/WebBrowser.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/WebBrowser.java @@ -66,7 +66,7 @@ public final class WebBrowser { try { return request(new URL(url)); } catch (MalformedURLException ex) { - throw new MovieDbException(MovieDbException.MovieDbExceptionType.INVALID_URL, null); + throw new MovieDbException(MovieDbException.MovieDbExceptionType.INVALID_URL, null, ex); } } @@ -86,7 +86,7 @@ public final class WebBrowser { return cnx; } catch (IOException ex) { - throw new MovieDbException(MovieDbException.MovieDbExceptionType.INVALID_URL, null); + throw new MovieDbException(MovieDbException.MovieDbExceptionType.INVALID_URL, null, ex); } } @@ -118,8 +118,8 @@ public final class WebBrowser { } } return content.toString(); - } catch (IOException error) { - throw new MovieDbException(MovieDbException.MovieDbExceptionType.CONNECTION_ERROR, null); + } catch (IOException ex) { + throw new MovieDbException(MovieDbException.MovieDbExceptionType.CONNECTION_ERROR, null, ex); } finally { if (content != null) { try { From ae4af481793d5cef6c6886a9a62545d926d1ae11 Mon Sep 17 00:00:00 2001 From: Omertron Date: Sun, 1 Apr 2012 10:03:50 +0000 Subject: [PATCH 127/207] Tidy up javadoc --- .../themoviedb/MovieDbException.java | 6 +-- .../moviejukebox/themoviedb/TheMovieDb.java | 43 +++++++++++++++++-- 2 files changed, 42 insertions(+), 7 deletions(-) diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/MovieDbException.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/MovieDbException.java index 8ee4d839e..f57b7c169 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/MovieDbException.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/MovieDbException.java @@ -5,9 +5,9 @@ public class MovieDbException extends Exception { private static final long serialVersionUID = -8952129102483143278L; public enum MovieDbExceptionType { - UNKNOWN_CAUSE, INVALID_URL, HTTP_404_ERROR, MOVIE_ID_NOT_FOUND, MAPPING_FAILED, CONNECTION_ERROR, INVALID_IMAGE; } + private final MovieDbExceptionType exceptionType; private final String response; @@ -17,19 +17,17 @@ public class MovieDbException extends Exception { this.response = response; } - public MovieDbException(final MovieDbExceptionType exceptionType, final String response, Throwable cause) { + public MovieDbException(final MovieDbExceptionType exceptionType, final String response, final Throwable cause) { super(cause); this.exceptionType = exceptionType; this.response = response; } public MovieDbExceptionType getExceptionType() { - return exceptionType; } public String getResponse() { - return response; } } diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java index 34e113594..6f100e49c 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java @@ -83,7 +83,7 @@ public class TheMovieDb { * API for The Movie Db. * * @param apiKey - * @throws IOException + * @throws MovieDbException */ public TheMovieDb(String apiKey) throws MovieDbException { this.apiKey = apiKey; @@ -138,7 +138,14 @@ public class TheMovieDb { * Search Movies This is a good starting point to start finding movies on * TMDb. The idea is to be a quick and light method so you can iterate * through movies quickly. http://help.themoviedb.org/kb/api/search-movies + * * TODO: Make the allResults work + * + * @param movieName + * @param language + * @param allResults + * @return + * @throws MovieDbException */ public List searchMovie(String movieName, String language, boolean allResults) throws MovieDbException { @@ -160,6 +167,7 @@ public class TheMovieDb { * @param movieId * @param language * @return + * @throws MovieDbException */ public MovieDb getMovieInfo(int movieId, String language) throws MovieDbException { @@ -177,9 +185,10 @@ public class TheMovieDb { * This method is used to retrieve all of the basic movie information. It * will return the single highest rated poster and backdrop. * - * @param movieId + * @param imdbId * @param language * @return + * @throws MovieDbException */ public MovieDb getMovieInfoImdb(String imdbId, String language) throws MovieDbException { @@ -200,6 +209,7 @@ public class TheMovieDb { * @param movieId * @param country * @return + * @throws MovieDbException */ public List getMovieAlternativeTitles(int movieId, String country) throws MovieDbException { @@ -220,6 +230,7 @@ public class TheMovieDb { * * @param movieId * @return + * @throws MovieDbException */ public List getMovieCasts(int movieId) throws MovieDbException { @@ -258,6 +269,7 @@ public class TheMovieDb { * @param movieId * @param language * @return + * @throws MovieDbException */ public List getMovieImages(int movieId, String language) throws MovieDbException { @@ -292,6 +304,7 @@ public class TheMovieDb { * * @param movieId * @return + * @throws MovieDbException */ public List getMovieKeywords(int movieId) throws MovieDbException { @@ -314,6 +327,7 @@ public class TheMovieDb { * @param movieId * @param language * @return + * @throws MovieDbException */ public List getMovieReleaseInfo(int movieId, String language) throws MovieDbException { @@ -336,6 +350,7 @@ public class TheMovieDb { * @param movieId * @param language * @return + * @throws MovieDbException */ public List getMovieTrailers(int movieId, String language) throws MovieDbException { @@ -369,6 +384,7 @@ public class TheMovieDb { * * @param movieId * @return + * @throws MovieDbException */ public List getMovieTranslations(int movieId) throws MovieDbException { @@ -392,6 +408,7 @@ public class TheMovieDb { * @param movieId * @param language * @return + * @throws MovieDbException */ public CollectionInfo getCollectionInfo(int movieId, String language) throws MovieDbException { @@ -421,6 +438,7 @@ public class TheMovieDb { * @param imagePath * @param requiredSize * @return + * @throws MovieDbException */ public URL createImageUrl(String imagePath, String requiredSize) throws MovieDbException { if (!tmdbConfig.isValidSize(requiredSize)) { @@ -441,7 +459,14 @@ public class TheMovieDb { /** * This is a good starting point to start finding people on TMDb. The idea * is to be a quick and light method so you can iterate through people - * quickly. TODO: Fix allResults + * quickly. + * + * TODO: Fix allResults + * + * @param personName + * @param allResults + * @return + * @throws MovieDbException */ public List searchPeople(String personName, boolean allResults) throws MovieDbException { @@ -463,6 +488,7 @@ public class TheMovieDb { * * @param personId * @return + * @throws MovieDbException */ public Person getPersonInfo(int personId) throws MovieDbException { @@ -484,6 +510,7 @@ public class TheMovieDb { * * @param personId * @return + * @throws MovieDbException */ public List getPersonCredits(int personId) throws MovieDbException { @@ -517,6 +544,7 @@ public class TheMovieDb { * * @param personId * @return + * @throws MovieDbException */ public List getPersonImages(int personId) throws MovieDbException { @@ -563,6 +591,7 @@ public class TheMovieDb { * a curated list that will normally contain 100 movies. The default * response will return 20 movies. * + * @param language * @return * @throws MovieDbException */ @@ -579,6 +608,14 @@ public class TheMovieDb { } } + /** + * This method is used to retrieve the movies currently in theatres. This is + * a curated list that will normally contain 100 movies. The default + * response will return 20 movies. + * + * @return + * @throws MovieDbException + */ public List getNowPlayingMovies() throws MovieDbException { return getNowPlayingMovies(""); } From 43c9660a74b03477e33b67cf5960ac0f929afa77 Mon Sep 17 00:00:00 2001 From: Omertron Date: Sun, 1 Apr 2012 10:11:23 +0000 Subject: [PATCH 128/207] fixes issue 13 --- .../moviejukebox/themoviedb/TheMovieDb.java | 109 +++++++++--------- .../themoviedb/TheMovieDbTest.java | 16 ++- 2 files changed, 68 insertions(+), 57 deletions(-) diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java index 6f100e49c..54c3bf0d4 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java @@ -39,8 +39,8 @@ public class TheMovieDb { private String apiKey; private TmdbConfiguration tmdbConfig; /* - * API Methods These are not set to static so that multiple instances of the - * API can co-exist + * API Methods: These are not set to static so that multiple instances of + * the API can co-exist */ private static final String BASE_MOVIE = "movie/"; private static final String BASE_PERSON = "person/"; @@ -69,7 +69,7 @@ public class TheMovieDb { */ private final ApiUrl tmdbLatestMovie = new ApiUrl(this, "latest/movie"); private final ApiUrl tmdbNowPlaying = new ApiUrl(this, "movie/now-playing"); - // - Populate Movie List + private final ApiUrl tmdbPopularMovieList = new ApiUrl(this, "movie/popular"); // - Top Rated Movies // Company Info // - Company Info @@ -134,6 +134,45 @@ public class TheMovieDb { WebBrowser.setWebTimeoutRead(read); } + /** + * Compare the MovieDB object with a title & year + * + * @param moviedb The moviedb object to compare too + * @param title The title of the movie to compare + * @param year The year of the movie to compare + * @return True if there is a match, False otherwise. + */ + public static boolean compareMovies(MovieDb moviedb, String title, String year) { + if ((moviedb == null) || (StringUtils.isBlank(title))) { + return false; + } + + if (StringUtils.isNotBlank(year) && !year.equalsIgnoreCase("UNKNOWN") && StringUtils.isNotBlank(moviedb.getReleaseDate())) { + // Compare with year + String movieYear = moviedb.getReleaseDate().substring(0, 4); + if (movieYear.equals(year)) { + if (moviedb.getOriginalTitle().equalsIgnoreCase(title)) { + return true; + } + + if (moviedb.getTitle().equalsIgnoreCase(title)) { + return true; + } + } + } + + // Compare without year + if (moviedb.getOriginalTitle().equalsIgnoreCase(title)) { + return true; + } + + if (moviedb.getTitle().equalsIgnoreCase(title)) { + return true; + } + + return false; + } + /** * Search Movies This is a good starting point to start finding movies on * TMDb. The idea is to be a quick and light method so you can iterate @@ -488,7 +527,7 @@ public class TheMovieDb { * * @param personId * @return - * @throws MovieDbException + * @throws MovieDbException */ public Person getPersonInfo(int personId) throws MovieDbException { @@ -510,7 +549,7 @@ public class TheMovieDb { * * @param personId * @return - * @throws MovieDbException + * @throws MovieDbException */ public List getPersonCredits(int personId) throws MovieDbException { @@ -544,7 +583,7 @@ public class TheMovieDb { * * @param personId * @return - * @throws MovieDbException + * @throws MovieDbException */ public List getPersonImages(int personId) throws MovieDbException { @@ -603,59 +642,21 @@ public class TheMovieDb { WrapperResultList resultList = mapper.readValue(webPage, WrapperResultList.class); return resultList.getResults(); } catch (IOException ex) { - LOGGER.warn("Failed to get latest movie: " + ex.getMessage()); + LOGGER.warn("Failed to get now playing movies: " + ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage, ex); } } - /** - * This method is used to retrieve the movies currently in theatres. This is - * a curated list that will normally contain 100 movies. The default - * response will return 20 movies. - * - * @return - * @throws MovieDbException - */ - public List getNowPlayingMovies() throws MovieDbException { - return getNowPlayingMovies(""); - } + public List getPopularMovieList(String language) throws MovieDbException { + URL url = tmdbPopularMovieList.getIdUrl("", language); + String webPage = WebBrowser.request(url); - /** - * Compare the MovieDB object with a title & year - * - * @param moviedb The moviedb object to compare too - * @param title The title of the movie to compare - * @param year The year of the movie to compare - * @return True if there is a match, False otherwise. - */ - public static boolean compareMovies(MovieDb moviedb, String title, String year) { - if ((moviedb == null) || (StringUtils.isBlank(title))) { - return false; + try { + WrapperResultList resultList = mapper.readValue(webPage, WrapperResultList.class); + return resultList.getResults(); + } catch (IOException ex) { + LOGGER.warn("Failed to get popular movie list: " + ex.getMessage()); + throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage, ex); } - - if (StringUtils.isNotBlank(year) && !year.equalsIgnoreCase("UNKNOWN") && StringUtils.isNotBlank(moviedb.getReleaseDate())) { - // Compare with year - String movieYear = moviedb.getReleaseDate().substring(0, 4); - if (movieYear.equals(year)) { - if (moviedb.getOriginalTitle().equalsIgnoreCase(title)) { - return true; - } - - if (moviedb.getTitle().equalsIgnoreCase(title)) { - return true; - } - } - } - - // Compare without year - if (moviedb.getOriginalTitle().equalsIgnoreCase(title)) { - return true; - } - - if (moviedb.getTitle().equalsIgnoreCase(title)) { - return true; - } - - return false; } } diff --git a/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java b/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java index f89df73ce..20d835b3f 100644 --- a/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java +++ b/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java @@ -334,9 +334,19 @@ public class TheMovieDbTest { * Test of getNowPlayingMovies method, of class TheMovieDb. */ @Test - public void testGetNowPlayingMovies() throws Exception { + public void testGetNowPlayingMovies() throws MovieDbException { LOGGER.info("getNowPlayingMovies"); - List results = tmdb.getNowPlayingMovies(); - assertTrue("No now playing movies foind", !results.isEmpty()); + List results = tmdb.getNowPlayingMovies(""); + assertTrue("No now playing movies found", !results.isEmpty()); + } + + /** + * Test of getPopularMovieList method, of class TheMovieDb. + */ + @Test + public void testGetPopularMovieList() throws MovieDbException { + LOGGER.info("getPopularMovieList"); + List results = tmdb.getPopularMovieList(""); + assertTrue("No popular movies found", !results.isEmpty()); } } From 485d6d96307f5a857b6b70de446af562c0d1dbd2 Mon Sep 17 00:00:00 2001 From: Omertron Date: Sun, 1 Apr 2012 10:20:20 +0000 Subject: [PATCH 129/207] fixes issue 12 --- .../moviejukebox/themoviedb/TheMovieDb.java | 42 +++++++++++++++++-- .../themoviedb/TheMovieDbTest.java | 10 +++++ 2 files changed, 48 insertions(+), 4 deletions(-) diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java index 54c3bf0d4..ad5f8cf50 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java @@ -64,13 +64,12 @@ public class TheMovieDb { private final ApiUrl tmdbPersonInfo = new ApiUrl(this, BASE_PERSON); private final ApiUrl tmdbPersonCredits = new ApiUrl(this, BASE_PERSON, "/credits"); private final ApiUrl tmdbPersonImages = new ApiUrl(this, BASE_PERSON, "/images"); - /* - * Misc Movie - Movie Add Rating - Issue 9 - */ + // Misc Movie + // Movie Add Rating - See issue 9 private final ApiUrl tmdbLatestMovie = new ApiUrl(this, "latest/movie"); private final ApiUrl tmdbNowPlaying = new ApiUrl(this, "movie/now-playing"); private final ApiUrl tmdbPopularMovieList = new ApiUrl(this, "movie/popular"); - // - Top Rated Movies + private final ApiUrl tmdbTopRatedMovies = new ApiUrl(this, "movie/top-rated"); // Company Info // - Company Info // - Company Movies @@ -630,6 +629,8 @@ public class TheMovieDb { * a curated list that will normally contain 100 movies. The default * response will return 20 movies. * + * TODO: Implement more than 20 movies + * * @param language * @return * @throws MovieDbException @@ -647,6 +648,16 @@ public class TheMovieDb { } } + /** + * This method is used to retrieve the daily movie popularity list. This + * list is updated daily. The default response will return 20 movies. + * + * TODO: Implement more than 20 movies + * + * @param language + * @return + * @throws MovieDbException + */ public List getPopularMovieList(String language) throws MovieDbException { URL url = tmdbPopularMovieList.getIdUrl("", language); String webPage = WebBrowser.request(url); @@ -659,4 +670,27 @@ public class TheMovieDb { throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage, ex); } } + + /** + * This method is used to retrieve the top rated movies that have over 10 + * votes on TMDb. The default response will return 20 movies. + * + * TODO: Implement more than 20 movies + * + * @param language + * @return + * @throws MovieDbException + */ + public List getTopRatedMovies(String language) throws MovieDbException { + URL url = tmdbTopRatedMovies.getIdUrl("", language); + String webPage = WebBrowser.request(url); + + try { + WrapperResultList resultList = mapper.readValue(webPage, WrapperResultList.class); + return resultList.getResults(); + } catch (IOException ex) { + LOGGER.warn("Failed to get top rated movies: " + ex.getMessage()); + throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage, ex); + } + } } diff --git a/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java b/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java index 20d835b3f..d18d42b35 100644 --- a/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java +++ b/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java @@ -349,4 +349,14 @@ public class TheMovieDbTest { List results = tmdb.getPopularMovieList(""); assertTrue("No popular movies found", !results.isEmpty()); } + + /** + * Test of getTopRatedMovies method, of class TheMovieDb. + */ + @Test + public void testGetTopRatedMovies() throws MovieDbException { + LOGGER.info("getTopRatedMovies"); + List results = tmdb.getTopRatedMovies(""); + assertTrue("No top rated movies found", !results.isEmpty()); + } } From 62832a83689d60a6deb91af1012bdf95ffbffa13 Mon Sep 17 00:00:00 2001 From: Omertron Date: Sun, 1 Apr 2012 11:10:42 +0000 Subject: [PATCH 130/207] fixes issue 16 fixes issue 17 --- .../moviejukebox/themoviedb/TheMovieDb.java | 60 ++++++++- .../themoviedb/model/Company.java | 115 ++++++++++++++++++ .../wrapper/WrapperCompanyMovies.java | 110 +++++++++++++++++ .../themoviedb/TheMovieDbTest.java | 69 +++++++---- 4 files changed, 325 insertions(+), 29 deletions(-) create mode 100644 themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Company.java create mode 100644 themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperCompanyMovies.java diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java index ad5f8cf50..843216eb0 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java @@ -44,6 +44,7 @@ public class TheMovieDb { */ private static final String BASE_MOVIE = "movie/"; private static final String BASE_PERSON = "person/"; + private static final String BASE_COMPANY = "company/"; // Configuration URL private final ApiUrl tmdbConfigUrl = new ApiUrl(this, "configuration"); // Search URLS @@ -71,8 +72,8 @@ public class TheMovieDb { private final ApiUrl tmdbPopularMovieList = new ApiUrl(this, "movie/popular"); private final ApiUrl tmdbTopRatedMovies = new ApiUrl(this, "movie/top-rated"); // Company Info - // - Company Info - // - Company Movies + private final ApiUrl tmdbCompanyInfo = new ApiUrl(this, BASE_COMPANY); + private final ApiUrl tmdbCompanyMovies = new ApiUrl(this, BASE_COMPANY, "/movies"); /* * Jackson JSON configuration */ @@ -632,10 +633,11 @@ public class TheMovieDb { * TODO: Implement more than 20 movies * * @param language + * @param allResults * @return * @throws MovieDbException */ - public List getNowPlayingMovies(String language) throws MovieDbException { + public List getNowPlayingMovies(String language, boolean allResults) throws MovieDbException { URL url = tmdbNowPlaying.getIdUrl("", language); String webPage = WebBrowser.request(url); @@ -655,10 +657,11 @@ public class TheMovieDb { * TODO: Implement more than 20 movies * * @param language + * @param allResults * @return * @throws MovieDbException */ - public List getPopularMovieList(String language) throws MovieDbException { + public List getPopularMovieList(String language, boolean allResults) throws MovieDbException { URL url = tmdbPopularMovieList.getIdUrl("", language); String webPage = WebBrowser.request(url); @@ -678,10 +681,11 @@ public class TheMovieDb { * TODO: Implement more than 20 movies * * @param language + * @param allResults * @return * @throws MovieDbException */ - public List getTopRatedMovies(String language) throws MovieDbException { + public List getTopRatedMovies(String language, boolean allResults) throws MovieDbException { URL url = tmdbTopRatedMovies.getIdUrl("", language); String webPage = WebBrowser.request(url); @@ -693,4 +697,50 @@ public class TheMovieDb { throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage, ex); } } + + /** + * This method is used to retrieve the basic information about a production + * company on TMDb. + * + * @param companyId + * @return + * @throws MovieDbException + */ + public Company getCompanyInfo(int companyId) throws MovieDbException { + URL url = tmdbCompanyInfo.getIdUrl(companyId); + String webPage = WebBrowser.request(url); + + try { + return mapper.readValue(webPage, Company.class); + } catch (IOException ex) { + LOGGER.warn("Failed to get company information: " + ex.getMessage()); + throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage, ex); + } + } + + /** + * This method is used to retrieve the movies associated with a company. + * These movies are returned in order of most recently released to oldest. + * The default response will return 20 movies per page. + * + * TODO: Implement more than 20 movies + * + * @param companyId + * @param language + * @param allResults + * @return + * @throws MovieDbException + */ + public List getCompanyMovies(int companyId, String language, boolean allResults) throws MovieDbException { + URL url = tmdbCompanyMovies.getIdUrl(companyId, language); + String webPage = WebBrowser.request(url); + + try { + WrapperCompanyMovies resultList = mapper.readValue(webPage, WrapperCompanyMovies.class); + return resultList.getResults(); + } catch (IOException ex) { + LOGGER.warn("Failed to get company movies: " + ex.getMessage()); + throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage, ex); + } + } } diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Company.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Company.java new file mode 100644 index 000000000..b9cf34965 --- /dev/null +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Company.java @@ -0,0 +1,115 @@ +/* + * Copyright (c) 2004-2012 YAMJ Members + * http://code.google.com/p/moviejukebox/people/list + * + * Web: http://code.google.com/p/moviejukebox/ + * + * This software is licensed under a Creative Commons License + * See this page: http://code.google.com/p/moviejukebox/wiki/License + * + * For any reuse or distribution, you must make clear to others the + * license terms of this work. + */ +package com.moviejukebox.themoviedb.model; + +import org.apache.log4j.Logger; +import org.codehaus.jackson.annotate.JsonAnySetter; +import org.codehaus.jackson.annotate.JsonProperty; + +/** + * + * @author Stuart + */ +public class Company { + // Logger + private static final Logger LOGGER = Logger.getLogger(Company.class); + // Properties + @JsonProperty("id") + private int companyId; + @JsonProperty("name") + private String name; + @JsonProperty("description") + private String description; + @JsonProperty("headquarters") + private String headquarters; + @JsonProperty("homepage") + private String homepage; + @JsonProperty("logo_path") + private String logoPath; + @JsonProperty("parent_company") + private String parentCompany; + + // + public int getCompanyId() { + return companyId; + } + + public String getDescription() { + return description; + } + + public String getHeadquarters() { + return headquarters; + } + + public String getHomepage() { + return homepage; + } + + public String getLogoPath() { + return logoPath; + } + + public String getName() { + return name; + } + + public String getParentCompany() { + return parentCompany; + } + // + + // + public void setCompanyId(int companyId) { + this.companyId = companyId; + } + + public void setDescription(String description) { + this.description = description; + } + + public void setHeadquarters(String headquarters) { + this.headquarters = headquarters; + } + + public void setHomepage(String homepage) { + this.homepage = homepage; + } + + public void setLogoPath(String logoPath) { + this.logoPath = logoPath; + } + + public void setName(String name) { + this.name = name; + } + + public void setParentCompany(String parentCompany) { + this.parentCompany = parentCompany; + } + // + + /** + * Handle unknown properties and print a message + * + * @param key + * @param value + */ + @JsonAnySetter + public void handleUnknown(String key, Object value) { + StringBuilder sb = new StringBuilder(); + sb.append("Unknown property: '").append(key); + sb.append("' value: '").append(value).append("'"); + LOGGER.warn(sb.toString()); + } +} diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperCompanyMovies.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperCompanyMovies.java new file mode 100644 index 000000000..0bdd4bee0 --- /dev/null +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperCompanyMovies.java @@ -0,0 +1,110 @@ +/* + * Copyright (c) 2004-2012 YAMJ Members + * http://code.google.com/p/moviejukebox/people/list + * + * Web: http://code.google.com/p/moviejukebox/ + * + * This software is licensed under a Creative Commons License + * See this page: http://code.google.com/p/moviejukebox/wiki/License + * + * For any reuse or distribution, you must make clear to others the + * license terms of this work. + */ +package com.moviejukebox.themoviedb.wrapper; + +import com.moviejukebox.themoviedb.model.MovieDb; +import java.util.List; +import org.apache.log4j.Logger; +import org.codehaus.jackson.annotate.JsonAnySetter; +import org.codehaus.jackson.annotate.JsonProperty; + +/** + * + * @author stuart.boston + */ +public class WrapperCompanyMovies { + // Loggers + private static final Logger LOGGER = Logger.getLogger(WrapperCompanyMovies.class); + /* + * Properties + */ + @JsonProperty("id") + private int companyId; + @JsonProperty("page") + private int page; + @JsonProperty("results") + private List results; + @JsonProperty("total_pages") + private int totalPages; + @JsonProperty("total_results") + private int totalResults; + + // + public int getCompanyId() { + return companyId; + } + + public int getPage() { + return page; + } + + public List getResults() { + return results; + } + + public int getTotalPages() { + return totalPages; + } + + public int getTotalResults() { + return totalResults; + } + // + + // + public void setCompanyId(int companyId) { + this.companyId = companyId; + } + + public void setPage(int page) { + this.page = page; + } + + public void setResults(List results) { + this.results = results; + } + + public void setTotalPages(int totalPages) { + this.totalPages = totalPages; + } + + public void setTotalResults(int totalResults) { + this.totalResults = totalResults; + } + // + + /** + * Handle unknown properties and print a message + * @param key + * @param value + */ + @JsonAnySetter + public void handleUnknown(String key, Object value) { + StringBuilder sb = new StringBuilder(); + sb.append("Unknown property: '").append(key); + sb.append("' value: '").append(value).append("'"); + LOGGER.warn(sb.toString()); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("[ResultList=["); + sb.append("[companyId=").append(companyId); + sb.append("],[page=").append(page); + sb.append("],[pageResults=").append(results.size()); + sb.append("],[totalPages=").append(totalPages); + sb.append("],[totalResults=").append(totalResults); + sb.append("]]"); + return sb.toString(); + } +} diff --git a/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java b/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java index d18d42b35..79e479611 100644 --- a/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java +++ b/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java @@ -27,15 +27,16 @@ import org.junit.*; */ public class TheMovieDbTest { + // Logger private static final Logger LOGGER = Logger.getLogger(TheMovieDbTest.class); + // API Key private static final String API_KEY = "5a1a77e2eba8984804586122754f969f"; private static TheMovieDb tmdb; - /* - * Test data - */ - private static final int ID_BLADE_RUNNER = 78; - private static final int ID_STAR_WARS_COLLECTION = 10; - private static final int ID_BRUCE_WILLIS = 62; + // Test data + private static final int ID_MOVIE_BLADE_RUNNER = 78; + private static final int ID_MOVIE_STAR_WARS_COLLECTION = 10; + private static final int ID_PERSON_BRUCE_WILLIS = 62; + private static final int ID_COMPANY_LUCASFILM = 1; public TheMovieDbTest() throws MovieDbException { tmdb = new TheMovieDb(API_KEY); @@ -100,7 +101,7 @@ public class TheMovieDbTest { public void testGetMovieInfo() throws MovieDbException { LOGGER.info("getMovieInfo"); String language = "en"; - MovieDb result = tmdb.getMovieInfo(ID_BLADE_RUNNER, language); + MovieDb result = tmdb.getMovieInfo(ID_MOVIE_BLADE_RUNNER, language); assertEquals("Incorrect movie information", "Blade Runner", result.getOriginalTitle()); } @@ -111,11 +112,11 @@ public class TheMovieDbTest { public void testGetMovieAlternativeTitles() throws MovieDbException { LOGGER.info("getMovieAlternativeTitles"); String country = ""; - List results = tmdb.getMovieAlternativeTitles(ID_BLADE_RUNNER, country); + List results = tmdb.getMovieAlternativeTitles(ID_MOVIE_BLADE_RUNNER, country); assertTrue("No alternative titles found", results.size() > 0); country = "US"; - results = tmdb.getMovieAlternativeTitles(ID_BLADE_RUNNER, country); + results = tmdb.getMovieAlternativeTitles(ID_MOVIE_BLADE_RUNNER, country); assertTrue("No alternative titles found", results.size() > 0); } @@ -126,7 +127,7 @@ public class TheMovieDbTest { @Test public void testGetMovieCasts() throws MovieDbException { LOGGER.info("getMovieCasts"); - List people = tmdb.getMovieCasts(ID_BLADE_RUNNER); + List people = tmdb.getMovieCasts(ID_MOVIE_BLADE_RUNNER); assertTrue("No cast information", people.size() > 0); String name1 = "Harrison Ford"; @@ -154,7 +155,7 @@ public class TheMovieDbTest { public void testGetMovieImages() throws MovieDbException { LOGGER.info("getMovieImages"); String language = ""; - List result = tmdb.getMovieImages(ID_BLADE_RUNNER, language); + List result = tmdb.getMovieImages(ID_MOVIE_BLADE_RUNNER, language); assertFalse("No artwork found", result.isEmpty()); } @@ -164,7 +165,7 @@ public class TheMovieDbTest { @Test public void testGetMovieKeywords() throws MovieDbException { LOGGER.info("getMovieKeywords"); - List result = tmdb.getMovieKeywords(ID_BLADE_RUNNER); + List result = tmdb.getMovieKeywords(ID_MOVIE_BLADE_RUNNER); assertFalse("No keywords found", result.isEmpty()); } @@ -174,7 +175,7 @@ public class TheMovieDbTest { @Test public void testGetMovieReleaseInfo() throws MovieDbException { LOGGER.info("getMovieReleaseInfo"); - List result = tmdb.getMovieReleaseInfo(ID_BLADE_RUNNER, ""); + List result = tmdb.getMovieReleaseInfo(ID_MOVIE_BLADE_RUNNER, ""); assertFalse("Release information missing", result.isEmpty()); } @@ -184,7 +185,7 @@ public class TheMovieDbTest { @Test public void testGetMovieTrailers() throws MovieDbException { LOGGER.info("getMovieTrailers"); - List result = tmdb.getMovieTrailers(ID_BLADE_RUNNER, ""); + List result = tmdb.getMovieTrailers(ID_MOVIE_BLADE_RUNNER, ""); assertFalse("Movie trailers missing", result.isEmpty()); } @@ -194,7 +195,7 @@ public class TheMovieDbTest { @Test public void testGetMovieTranslations() throws MovieDbException { LOGGER.info("getMovieTranslations"); - List result = tmdb.getMovieTranslations(ID_BLADE_RUNNER); + List result = tmdb.getMovieTranslations(ID_MOVIE_BLADE_RUNNER); assertFalse("No translations found", result.isEmpty()); } @@ -205,14 +206,14 @@ public class TheMovieDbTest { public void testGetCollectionInfo() throws MovieDbException { LOGGER.info("getCollectionInfo"); String language = ""; - CollectionInfo result = tmdb.getCollectionInfo(ID_STAR_WARS_COLLECTION, language); + CollectionInfo result = tmdb.getCollectionInfo(ID_MOVIE_STAR_WARS_COLLECTION, language); assertFalse("No collection information", result.getParts().isEmpty()); } @Test public void testCreateImageUrl() throws MovieDbException { LOGGER.info("createImageUrl"); - MovieDb movie = tmdb.getMovieInfo(ID_BLADE_RUNNER, ""); + MovieDb movie = tmdb.getMovieInfo(ID_MOVIE_BLADE_RUNNER, ""); String result = tmdb.createImageUrl(movie.getPosterPath(), "original").toString(); assertTrue("Error compiling image URL", !result.isEmpty()); } @@ -269,8 +270,8 @@ public class TheMovieDbTest { @Test public void testGetPersonInfo() throws MovieDbException { LOGGER.info("getPersonInfo"); - Person result = tmdb.getPersonInfo(ID_BRUCE_WILLIS); - assertTrue("Wrong actor returned", result.getId() == ID_BRUCE_WILLIS); + Person result = tmdb.getPersonInfo(ID_PERSON_BRUCE_WILLIS); + assertTrue("Wrong actor returned", result.getId() == ID_PERSON_BRUCE_WILLIS); } /** @@ -280,7 +281,7 @@ public class TheMovieDbTest { public void testGetPersonCredits() throws MovieDbException { LOGGER.info("getPersonCredits"); - List people = tmdb.getPersonCredits(ID_BRUCE_WILLIS); + List people = tmdb.getPersonCredits(ID_PERSON_BRUCE_WILLIS); assertTrue("No cast information", people.size() > 0); } @@ -291,7 +292,7 @@ public class TheMovieDbTest { public void testGetPersonImages() throws MovieDbException { LOGGER.info("getPersonImages"); - List artwork = tmdb.getPersonImages(ID_BRUCE_WILLIS); + List artwork = tmdb.getPersonImages(ID_PERSON_BRUCE_WILLIS); assertTrue("No cast information", artwork.size() > 0); } @@ -336,7 +337,7 @@ public class TheMovieDbTest { @Test public void testGetNowPlayingMovies() throws MovieDbException { LOGGER.info("getNowPlayingMovies"); - List results = tmdb.getNowPlayingMovies(""); + List results = tmdb.getNowPlayingMovies("", true); assertTrue("No now playing movies found", !results.isEmpty()); } @@ -346,7 +347,7 @@ public class TheMovieDbTest { @Test public void testGetPopularMovieList() throws MovieDbException { LOGGER.info("getPopularMovieList"); - List results = tmdb.getPopularMovieList(""); + List results = tmdb.getPopularMovieList("", true); assertTrue("No popular movies found", !results.isEmpty()); } @@ -356,7 +357,27 @@ public class TheMovieDbTest { @Test public void testGetTopRatedMovies() throws MovieDbException { LOGGER.info("getTopRatedMovies"); - List results = tmdb.getTopRatedMovies(""); + List results = tmdb.getTopRatedMovies("", true); assertTrue("No top rated movies found", !results.isEmpty()); } + + /** + * Test of getCompanyInfo method, of class TheMovieDb. + */ + @Test + public void testGetCompanyInfo() throws Exception { + LOGGER.info("getCompanyInfo"); + Company company = tmdb.getCompanyInfo(ID_COMPANY_LUCASFILM); + assertTrue("No company information found", company.getCompanyId() > 0); + } + + /** + * Test of getCompanyMovies method, of class TheMovieDb. + */ + @Test + public void testGetCompanyMovies() throws Exception { + LOGGER.info("getCompanyMovies"); + List results = tmdb.getCompanyMovies(ID_COMPANY_LUCASFILM, "", true); + assertTrue("No company movies found", !results.isEmpty()); + } } From 62cc9679e4204ba49e0ad86d9a83e3fb57b54f2d Mon Sep 17 00:00:00 2001 From: Omertron Date: Sat, 7 Apr 2012 08:58:31 +0000 Subject: [PATCH 131/207] Added version information method --- .../moviejukebox/themoviedb/TheMovieDb.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java index 843216eb0..65c143ae6 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java @@ -99,6 +99,25 @@ public class TheMovieDb { } } + /** + * Output the API version information to the debug log + */ + public static void showVersion() { + String apiTitle = TheMovieDb.class.getPackage().getSpecificationTitle(); + + if (StringUtils.isNotBlank(apiTitle)) { + String apiVersion = TheMovieDb.class.getPackage().getSpecificationVersion(); + String apiRevision = TheMovieDb.class.getPackage().getImplementationVersion(); + StringBuilder sv = new StringBuilder(); + sv.append(apiTitle).append(" "); + sv.append(apiVersion).append(" r"); + sv.append(apiRevision); + LOGGER.debug(sv.toString()); + } else { + LOGGER.debug("API-TheMovieDb version/revision information not available"); + } + } + /** * Get the API key that is to be used * From e9126adf497558893f97cad4cb9ebb21dc7c88e4 Mon Sep 17 00:00:00 2001 From: Omertron Date: Thu, 19 Apr 2012 20:37:34 +0000 Subject: [PATCH 132/207] Updated pom versions --- themoviedbapi/pom.xml | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/themoviedbapi/pom.xml b/themoviedbapi/pom.xml index 3a7adc6fe..2064402e1 100644 --- a/themoviedbapi/pom.xml +++ b/themoviedbapi/pom.xml @@ -6,6 +6,11 @@ oss-parent 7 + + + 3.0.3 + + com.moviejukebox themoviedbapi 3.2-SNAPSHOT @@ -47,12 +52,12 @@ org.codehaus.jackson jackson-core-lgpl - 1.9.5 + 1.9.6 org.codehaus.jackson jackson-mapper-lgpl - 1.9.5 + 1.9.6 commons-codec @@ -121,17 +126,17 @@ org.apache.maven.plugins maven-gpg-plugin - 1.2 + 1.4 org.apache.maven.plugins maven-jar-plugin - 2.3.1 + 2.4 org.apache.maven.plugins maven-surefire-plugin - 2.8 + 2.12 org.codehaus.mojo @@ -141,22 +146,22 @@ org.codehaus.mojo build-helper-maven-plugin - 1.5 + 1.7 org.apache.maven.plugins maven-antrun-plugin - 1.6 + 1.7 org.apache.maven.plugins maven-assembly-plugin - 2.2.1 + 2.3 org.codehaus.mojo versions-maven-plugin - 1.2 + 1.3.1 From d4fa1f694db7b3381d2b479467a20e8c683bf30b Mon Sep 17 00:00:00 2001 From: Omertron Date: Tue, 3 Jul 2012 12:40:26 +0000 Subject: [PATCH 133/207] Added "adult" flag to PersonCredit --- .../moviejukebox/themoviedb/model/PersonCredit.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/PersonCredit.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/PersonCredit.java index ab4528d64..c741fdf39 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/PersonCredit.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/PersonCredit.java @@ -46,6 +46,8 @@ public class PersonCredit { private String department = DEFAULT_STRING; @JsonProperty("job") private String job = DEFAULT_STRING; + @JsonProperty("adult") + private String adult = DEFAULT_STRING; private PersonType personType = PersonType.PERSON; // @@ -84,6 +86,10 @@ public class PersonCredit { public String getReleaseDate() { return releaseDate; } + + public String getAdult() { + return adult; + } // // @@ -122,6 +128,10 @@ public class PersonCredit { public void setReleaseDate(String releaseDate) { this.releaseDate = releaseDate; } + + public void setAdult(String adult) { + this.adult = adult; + } // /** @@ -150,6 +160,7 @@ public class PersonCredit { sb.append("],[character=").append(character); sb.append("],[department=").append(department); sb.append("],[job=").append(job); + sb.append("],[adult=").append(adult); sb.append("]]"); return sb.toString(); } From 0a46fe35c9844b85608f537f1996c75542829be2 Mon Sep 17 00:00:00 2001 From: Omertron Date: Tue, 3 Jul 2012 14:21:39 +0000 Subject: [PATCH 134/207] Added 4 new methods: - searchCompanies - getGenreList - getGenreMovies - getSimilarMovies --- themoviedbapi/pom.xml | 16 +- .../moviejukebox/themoviedb/TheMovieDb.java | 278 +++++++++++++----- .../themoviedb/model/Company.java | 48 +-- .../moviejukebox/themoviedb/model/Genre.java | 2 +- .../themoviedb/wrapper/WrapperCompany.java | 91 ++++++ .../themoviedb/wrapper/WrapperGenres.java | 59 ++++ .../themoviedb/wrapper/WrapperResultList.java | 12 + .../themoviedb/TheMovieDbTest.java | 51 +++- 8 files changed, 446 insertions(+), 111 deletions(-) create mode 100644 themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperCompany.java create mode 100644 themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperGenres.java diff --git a/themoviedbapi/pom.xml b/themoviedbapi/pom.xml index 2064402e1..12bb18451 100644 --- a/themoviedbapi/pom.xml +++ b/themoviedbapi/pom.xml @@ -6,7 +6,7 @@ oss-parent 7 - + 3.0.3 @@ -33,7 +33,7 @@ - true + false UTF-8 UTF-8 zip @@ -47,17 +47,17 @@ log4j log4j - 1.2.16 + 1.2.17 org.codehaus.jackson jackson-core-lgpl - 1.9.6 + 1.9.7 org.codehaus.jackson jackson-mapper-lgpl - 1.9.6 + 1.9.7 commons-codec @@ -116,12 +116,12 @@ org.apache.maven.plugins maven-clean-plugin - 2.4.1 + 2.5 org.apache.maven.plugins maven-compiler-plugin - 2.3.2 + 2.5.1 org.apache.maven.plugins @@ -141,7 +141,7 @@ org.codehaus.mojo buildnumber-maven-plugin - 1.0 + 1.1 org.codehaus.mojo diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java index 65c143ae6..bfaa5f21e 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java @@ -28,8 +28,9 @@ import org.apache.log4j.Logger; import org.codehaus.jackson.map.ObjectMapper; /** - * The MovieDb API. This is for version 3 of the API as specified here: - * http://help.themoviedb.org/kb/api/about-3 + * The MovieDb API + * + * This is for version 3 of the API as specified here: http://help.themoviedb.org/kb/api/about-3 * * @author stuart.boston */ @@ -45,12 +46,14 @@ public class TheMovieDb { private static final String BASE_MOVIE = "movie/"; private static final String BASE_PERSON = "person/"; private static final String BASE_COMPANY = "company/"; + private static final String BASE_GENRE = "genre/"; // Configuration URL private final ApiUrl tmdbConfigUrl = new ApiUrl(this, "configuration"); // Search URLS private final ApiUrl tmdbSearchMovie = new ApiUrl(this, "search/movie"); private final ApiUrl tmdbSearchPeople = new ApiUrl(this, "search/person"); - // Collections + private final ApiUrl tmdbSearchCompanies = new ApiUrl(this, "search/company"); + // Collections private final ApiUrl tmdbCollectionInfo = new ApiUrl(this, "collection/"); // Movie Info private final ApiUrl tmdbMovieInfo = new ApiUrl(this, BASE_MOVIE); @@ -61,12 +64,13 @@ public class TheMovieDb { private final ApiUrl tmdbMovieReleaseInfo = new ApiUrl(this, BASE_MOVIE, "/releases"); private final ApiUrl tmdbMovieTrailers = new ApiUrl(this, BASE_MOVIE, "/trailers"); private final ApiUrl tmdbMovieTranslations = new ApiUrl(this, BASE_MOVIE, "/translations"); + private final ApiUrl tmdbMovieSimilarMovies = new ApiUrl(this, BASE_MOVIE, "/similar_movies"); // Person Info private final ApiUrl tmdbPersonInfo = new ApiUrl(this, BASE_PERSON); private final ApiUrl tmdbPersonCredits = new ApiUrl(this, BASE_PERSON, "/credits"); private final ApiUrl tmdbPersonImages = new ApiUrl(this, BASE_PERSON, "/images"); // Misc Movie - // Movie Add Rating - See issue 9 + // Movie Add Rating - See issue 9 http://code.google.com/p/themoviedbapi/issues/detail?id=9 private final ApiUrl tmdbLatestMovie = new ApiUrl(this, "latest/movie"); private final ApiUrl tmdbNowPlaying = new ApiUrl(this, "movie/now-playing"); private final ApiUrl tmdbPopularMovieList = new ApiUrl(this, "movie/popular"); @@ -74,6 +78,10 @@ public class TheMovieDb { // Company Info private final ApiUrl tmdbCompanyInfo = new ApiUrl(this, BASE_COMPANY); private final ApiUrl tmdbCompanyMovies = new ApiUrl(this, BASE_COMPANY, "/movies"); + // Genre Info + private final ApiUrl tmdbGenreList = new ApiUrl(this, "genre/list"); + private final ApiUrl tmdbGenreMovies = new ApiUrl(this, BASE_GENRE, "/movies"); + /* * Jackson JSON configuration */ @@ -193,9 +201,11 @@ public class TheMovieDb { } /** - * Search Movies This is a good starting point to start finding movies on - * TMDb. The idea is to be a quick and light method so you can iterate - * through movies quickly. http://help.themoviedb.org/kb/api/search-movies + * Search Movies This is a good starting point to start finding movies on TMDb. + * + * The idea is to be a quick and light method so you can iterate through movies quickly. + * + * http://help.themoviedb.org/kb/api/search-movies * * TODO: Make the allResults work * @@ -210,8 +220,8 @@ public class TheMovieDb { URL url = tmdbSearchMovie.getQueryUrl(movieName, language, 1); String webPage = WebBrowser.request(url); try { - WrapperResultList resultList = mapper.readValue(webPage, WrapperResultList.class); - return resultList.getResults(); + WrapperResultList wrapper = mapper.readValue(webPage, WrapperResultList.class); + return wrapper.getResults(); } catch (IOException ex) { LOGGER.warn("Failed to find movie: " + ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage, ex); @@ -219,8 +229,9 @@ public class TheMovieDb { } /** - * This method is used to retrieve all of the basic movie information. It - * will return the single highest rated poster and backdrop. + * This method is used to retrieve all of the basic movie information. + * + * It will return the single highest rated poster and backdrop. * * @param movieId * @param language @@ -240,8 +251,9 @@ public class TheMovieDb { } /** - * This method is used to retrieve all of the basic movie information. It - * will return the single highest rated poster and backdrop. + * This method is used to retrieve all of the basic movie information. + * + * It will return the single highest rated poster and backdrop. * * @param imdbId * @param language @@ -261,8 +273,7 @@ public class TheMovieDb { } /** - * This method is used to retrieve all of the alternative titles we have for - * a particular movie. + * This method is used to retrieve all of the alternative titles we have for a particular movie. * * @param movieId * @param country @@ -274,8 +285,8 @@ public class TheMovieDb { URL url = tmdbMovieAltTitles.getIdUrl(movieId, ApiUrl.DEFAULT_STRING, country); String webPage = WebBrowser.request(url); try { - WrapperAlternativeTitles at = mapper.readValue(webPage, WrapperAlternativeTitles.class); - return at.getTitles(); + WrapperAlternativeTitles wrapper = mapper.readValue(webPage, WrapperAlternativeTitles.class); + return wrapper.getTitles(); } catch (IOException ex) { LOGGER.warn("Failed to get movie alternative titles: " + ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage, ex); @@ -283,8 +294,9 @@ public class TheMovieDb { } /** - * This method is used to retrieve all of the movie cast information. TODO: - * Add a function to enrich the data with the people methods + * This method is used to retrieve all of the movie cast information. + * + * TODO: Add a function to enrich the data with the people methods * * @param movieId * @return @@ -297,17 +309,17 @@ public class TheMovieDb { URL url = tmdbMovieCasts.getIdUrl(movieId); String webPage = WebBrowser.request(url); try { - WrapperMovieCasts mc = mapper.readValue(webPage, WrapperMovieCasts.class); + WrapperMovieCasts wrapper = mapper.readValue(webPage, WrapperMovieCasts.class); // Add a cast member - for (PersonCast cast : mc.getCast()) { + for (PersonCast cast : wrapper.getCast()) { Person person = new Person(); person.addCast(cast.getId(), cast.getName(), cast.getProfilePath(), cast.getCharacter(), cast.getOrder()); people.add(person); } // Add a crew member - for (PersonCrew crew : mc.getCrew()) { + for (PersonCrew crew : wrapper.getCrew()) { Person person = new Person(); person.addCrew(crew.getId(), crew.getName(), crew.getProfilePath(), crew.getDepartment(), crew.getJob()); people.add(person); @@ -321,8 +333,7 @@ public class TheMovieDb { } /** - * This method should be used when you’re wanting to retrieve all of the - * images for a particular movie. + * This method should be used when you’re wanting to retrieve all of the images for a particular movie. * * @param movieId * @param language @@ -335,16 +346,16 @@ public class TheMovieDb { URL url = tmdbMovieImages.getIdUrl(movieId, language); String webPage = WebBrowser.request(url); try { - WrapperImages mi = mapper.readValue(webPage, WrapperImages.class); + WrapperImages wrapper = mapper.readValue(webPage, WrapperImages.class); // Add all the posters to the list - for (Artwork poster : mi.getPosters()) { + for (Artwork poster : wrapper.getPosters()) { poster.setArtworkType(ArtworkType.POSTER); artwork.add(poster); } // Add all the backdrops to the list - for (Artwork backdrop : mi.getBackdrops()) { + for (Artwork backdrop : wrapper.getBackdrops()) { backdrop.setArtworkType(ArtworkType.BACKDROP); artwork.add(backdrop); } @@ -357,8 +368,9 @@ public class TheMovieDb { } /** - * This method is used to retrieve all of the keywords that have been added - * to a particular movie. Currently, only English keywords exist. + * This method is used to retrieve all of the keywords that have been added to a particular movie. + * + * Currently, only English keywords exist. * * @param movieId * @return @@ -370,8 +382,8 @@ public class TheMovieDb { String webPage = WebBrowser.request(url); try { - WrapperMovieKeywords mk = mapper.readValue(webPage, WrapperMovieKeywords.class); - return mk.getKeywords(); + WrapperMovieKeywords wrapper = mapper.readValue(webPage, WrapperMovieKeywords.class); + return wrapper.getKeywords(); } catch (IOException ex) { LOGGER.warn("Failed to get movie keywords: " + ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage, ex); @@ -379,8 +391,7 @@ public class TheMovieDb { } /** - * This method is used to retrieve all of the release and certification data - * we have for a specific movie. + * This method is used to retrieve all of the release and certification data we have for a specific movie. * * @param movieId * @param language @@ -393,8 +404,8 @@ public class TheMovieDb { String webPage = WebBrowser.request(url); try { - WrapperReleaseInfo ri = mapper.readValue(webPage, WrapperReleaseInfo.class); - return ri.getCountries(); + WrapperReleaseInfo wrapper = mapper.readValue(webPage, WrapperReleaseInfo.class); + return wrapper.getCountries(); } catch (IOException ex) { LOGGER.warn("Failed to get movie release information: " + ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage, ex); @@ -402,8 +413,9 @@ public class TheMovieDb { } /** - * This method is used to retrieve all of the trailers for a particular - * movie. Supported sites are YouTube and QuickTime. + * This method is used to retrieve all of the trailers for a particular movie. + * + * Supported sites are YouTube and QuickTime. * * @param movieId * @param language @@ -417,15 +429,15 @@ public class TheMovieDb { String webPage = WebBrowser.request(url); try { - WrapperTrailers wt = mapper.readValue(webPage, WrapperTrailers.class); + WrapperTrailers wrapper = mapper.readValue(webPage, WrapperTrailers.class); // Add the trailer to the return list along with it's source - for (Trailer trailer : wt.getQuicktime()) { + for (Trailer trailer : wrapper.getQuicktime()) { trailer.setWebsite(Trailer.WEBSITE_QUICKTIME); trailers.add(trailer); } // Add the trailer to the return list along with it's source - for (Trailer trailer : wt.getYoutube()) { + for (Trailer trailer : wrapper.getYoutube()) { trailer.setWebsite(Trailer.WEBSITE_YOUTUBE); trailers.add(trailer); } @@ -437,8 +449,7 @@ public class TheMovieDb { } /** - * This method is used to retrieve a list of the available translations for - * a specific movie. + * This method is used to retrieve a list of the available translations for a specific movie. * * @param movieId * @return @@ -450,8 +461,8 @@ public class TheMovieDb { String webPage = WebBrowser.request(url); try { - WrapperTranslations wt = mapper.readValue(webPage, WrapperTranslations.class); - return wt.getTranslations(); + WrapperTranslations wrapper = mapper.readValue(webPage, WrapperTranslations.class); + return wrapper.getTranslations(); } catch (IOException ex) { LOGGER.warn("Failed to get movie tranlations: " + ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage, ex); @@ -459,9 +470,9 @@ public class TheMovieDb { } /** - * This method is used to retrieve all of the basic information about a - * movie collection. You can get the ID needed for this method by making a - * getMovieInfo request for the belongs_to_collection. + * This method is used to retrieve all of the basic information about a movie collection. + * + * You can get the ID needed for this method by making a getMovieInfo request for the belongs_to_collection. * * @param movieId * @param language @@ -515,9 +526,9 @@ public class TheMovieDb { } /** - * This is a good starting point to start finding people on TMDb. The idea - * is to be a quick and light method so you can iterate through people - * quickly. + * This is a good starting point to start finding people on TMDb. + * + * The idea is to be a quick and light method so you can iterate through people quickly. * * TODO: Fix allResults * @@ -532,8 +543,8 @@ public class TheMovieDb { String webPage = WebBrowser.request(url); try { - WrapperPerson resultList = mapper.readValue(webPage, WrapperPerson.class); - return resultList.getResults(); + WrapperPerson wrapper = mapper.readValue(webPage, WrapperPerson.class); + return wrapper.getResults(); } catch (IOException ex) { LOGGER.warn("Failed to find person: " + ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage, ex); @@ -541,8 +552,9 @@ public class TheMovieDb { } /** - * This method is used to retrieve all of the basic person information. It - * will return the single highest rated profile image. + * This method is used to retrieve all of the basic person information. + * + * It will return the single highest rated profile image. * * @param personId * @return @@ -562,9 +574,9 @@ public class TheMovieDb { } /** - * This method is used to retrieve all of the cast & crew information for - * the person. It will return the single highest rated poster for each movie - * record. + * This method is used to retrieve all of the cast & crew information for the person. + * + * It will return the single highest rated poster for each movie record. * * @param personId * @return @@ -578,15 +590,15 @@ public class TheMovieDb { String webPage = WebBrowser.request(url); try { - WrapperPersonCredits pc = mapper.readValue(webPage, WrapperPersonCredits.class); + WrapperPersonCredits wrapper = mapper.readValue(webPage, WrapperPersonCredits.class); // Add a cast member - for (PersonCredit cast : pc.getCast()) { + for (PersonCredit cast : wrapper.getCast()) { cast.setPersonType(PersonType.CAST); personCredits.add(cast); } // Add a crew member - for (PersonCredit crew : pc.getCrew()) { + for (PersonCredit crew : wrapper.getCrew()) { crew.setPersonType(PersonType.CREW); personCredits.add(crew); } @@ -612,10 +624,10 @@ public class TheMovieDb { String webPage = WebBrowser.request(url); try { - WrapperImages images = mapper.readValue(webPage, WrapperImages.class); + WrapperImages wrapper = mapper.readValue(webPage, WrapperImages.class); // Update the image type - for (Artwork artwork : images.getProfiles()) { + for (Artwork artwork : wrapper.getProfiles()) { artwork.setArtworkType(ArtworkType.PROFILE); personImages.add(artwork); } @@ -645,9 +657,9 @@ public class TheMovieDb { } /** - * This method is used to retrieve the movies currently in theatres. This is - * a curated list that will normally contain 100 movies. The default - * response will return 20 movies. + * This method is used to retrieve the movies currently in theatres. + * + * This is a curated list that will normally contain 100 movies. The default response will return 20 movies. * * TODO: Implement more than 20 movies * @@ -661,8 +673,8 @@ public class TheMovieDb { String webPage = WebBrowser.request(url); try { - WrapperResultList resultList = mapper.readValue(webPage, WrapperResultList.class); - return resultList.getResults(); + WrapperResultList wrapper = mapper.readValue(webPage, WrapperResultList.class); + return wrapper.getResults(); } catch (IOException ex) { LOGGER.warn("Failed to get now playing movies: " + ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage, ex); @@ -670,8 +682,9 @@ public class TheMovieDb { } /** - * This method is used to retrieve the daily movie popularity list. This - * list is updated daily. The default response will return 20 movies. + * This method is used to retrieve the daily movie popularity list. + * + * This list is updated daily. The default response will return 20 movies. * * TODO: Implement more than 20 movies * @@ -685,8 +698,8 @@ public class TheMovieDb { String webPage = WebBrowser.request(url); try { - WrapperResultList resultList = mapper.readValue(webPage, WrapperResultList.class); - return resultList.getResults(); + WrapperResultList wrapper = mapper.readValue(webPage, WrapperResultList.class); + return wrapper.getResults(); } catch (IOException ex) { LOGGER.warn("Failed to get popular movie list: " + ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage, ex); @@ -694,8 +707,9 @@ public class TheMovieDb { } /** - * This method is used to retrieve the top rated movies that have over 10 - * votes on TMDb. The default response will return 20 movies. + * This method is used to retrieve the top rated movies that have over 10 votes on TMDb. + * + * The default response will return 20 movies. * * TODO: Implement more than 20 movies * @@ -709,8 +723,8 @@ public class TheMovieDb { String webPage = WebBrowser.request(url); try { - WrapperResultList resultList = mapper.readValue(webPage, WrapperResultList.class); - return resultList.getResults(); + WrapperResultList wrapper = mapper.readValue(webPage, WrapperResultList.class); + return wrapper.getResults(); } catch (IOException ex) { LOGGER.warn("Failed to get top rated movies: " + ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage, ex); @@ -718,8 +732,7 @@ public class TheMovieDb { } /** - * This method is used to retrieve the basic information about a production - * company on TMDb. + * This method is used to retrieve the basic information about a production company on TMDb. * * @param companyId * @return @@ -739,8 +752,9 @@ public class TheMovieDb { /** * This method is used to retrieve the movies associated with a company. - * These movies are returned in order of most recently released to oldest. - * The default response will return 20 movies per page. + * + * These movies are returned in order of most recently released to oldest. The default response will return 20 + * movies per page. * * TODO: Implement more than 20 movies * @@ -755,11 +769,113 @@ public class TheMovieDb { String webPage = WebBrowser.request(url); try { - WrapperCompanyMovies resultList = mapper.readValue(webPage, WrapperCompanyMovies.class); - return resultList.getResults(); + WrapperCompanyMovies wrapper = mapper.readValue(webPage, WrapperCompanyMovies.class); + return wrapper.getResults(); } catch (IOException ex) { LOGGER.warn("Failed to get company movies: " + ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage, ex); } } + + /** + * Search Companies. + * + * You can use this method to search for production companies that are part of TMDb. The company IDs will map to + * those returned on movie calls. + * + * http://help.themoviedb.org/kb/api/search-companies + * + * TODO: Make the allResults work + * + * @param companyName + * @param language + * @param allResults + * @return + * @throws MovieDbException + */ + public List searchCompanies(String companyName, String language, boolean allResults) throws MovieDbException { + + URL url = tmdbSearchCompanies.getQueryUrl(companyName, language, 1); + String webPage = WebBrowser.request(url); + try { + WrapperCompany wrapper = mapper.readValue(webPage, WrapperCompany.class); + return wrapper.getResults(); + } catch (IOException ex) { + LOGGER.warn("Failed to find company: " + ex.getMessage()); + throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage, ex); + } + } + + /** + * The similar movies method will let you retrieve the similar movies for a particular movie. + * + * This data is created dynamically but with the help of users votes on TMDb. + * + * The data is much better with movies that have more keywords + * + * @param movieId + * @param language + * @param allResults + * @return + * @throws MovieDbException + */ + public List getSimilarMovies(int movieId, String language, boolean allResults) throws MovieDbException { + + URL url = tmdbMovieSimilarMovies.getIdUrl(movieId, language); + String webPage = WebBrowser.request(url); + + try { + WrapperResultList wrapper = mapper.readValue(webPage, WrapperResultList.class); + return wrapper.getResults(); + } catch (IOException ex) { + LOGGER.warn("Failed to get similar movies: " + ex.getMessage()); + throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage, ex); + } + } + + /** + * You can use this method to retrieve the list of genres used on TMDb. + * + * These IDs will correspond to those found in movie calls. + * + * @param language + * @return + */ + public List getGenreList(String language) throws MovieDbException { + URL url = tmdbGenreList.getQueryUrl("", language); + String webPage = WebBrowser.request(url); + + try { + WrapperGenres wrapper = mapper.readValue(webPage, WrapperGenres.class); + return wrapper.getGenres(); + } catch (IOException ex) { + LOGGER.warn("Failed to get genre list: " + ex.getMessage()); + throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage, ex); + } + } + + /** + * Get a list of movies per genre. + * + * It is important to understand that only movies with more than 10 votes get listed. + * + * This prevents movies from 1 10/10 rating from being listed first and for the first 5 pages. + * + * @param genreId + * @param language + * @param allResults + * @return + */ + public List getGenreMovies(int genreId, String language, boolean allResults) throws MovieDbException { + URL url = tmdbGenreMovies.getIdUrl(genreId, language); + String webPage = WebBrowser.request(url); + + try { + WrapperResultList wrapper = mapper.readValue(webPage, WrapperResultList.class); + return wrapper.getResults(); + } catch (IOException ex) { + LOGGER.warn("Failed to get genre movie list: " + ex.getMessage()); + throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage, ex); + } + } } diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Company.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Company.java index b9cf34965..fe4281d29 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Company.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Company.java @@ -17,53 +17,56 @@ import org.codehaus.jackson.annotate.JsonAnySetter; import org.codehaus.jackson.annotate.JsonProperty; /** + * Company information * * @author Stuart */ public class Company { // Logger + private static final Logger LOGGER = Logger.getLogger(Company.class); + private static final String DEFAULT_STRING = ""; // Properties @JsonProperty("id") - private int companyId; + private int companyId = 0; @JsonProperty("name") - private String name; + private String name = DEFAULT_STRING; @JsonProperty("description") - private String description; + private String description = DEFAULT_STRING; @JsonProperty("headquarters") - private String headquarters; + private String headquarters = DEFAULT_STRING; @JsonProperty("homepage") - private String homepage; + private String homepage = DEFAULT_STRING; @JsonProperty("logo_path") - private String logoPath; + private String logoPath = DEFAULT_STRING; @JsonProperty("parent_company") - private String parentCompany; + private String parentCompany = DEFAULT_STRING; // public int getCompanyId() { return companyId; } - + public String getDescription() { return description; } - + public String getHeadquarters() { return headquarters; } - + public String getHomepage() { return homepage; } - + public String getLogoPath() { return logoPath; } - + public String getName() { return name; } - + public String getParentCompany() { return parentCompany; } @@ -73,32 +76,32 @@ public class Company { public void setCompanyId(int companyId) { this.companyId = companyId; } - + public void setDescription(String description) { this.description = description; } - + public void setHeadquarters(String headquarters) { this.headquarters = headquarters; } - + public void setHomepage(String homepage) { this.homepage = homepage; } - + public void setLogoPath(String logoPath) { this.logoPath = logoPath; } - + public void setName(String name) { this.name = name; } - + public void setParentCompany(String parentCompany) { this.parentCompany = parentCompany; } // - + /** * Handle unknown properties and print a message * @@ -112,4 +115,9 @@ public class Company { sb.append("' value: '").append(value).append("'"); LOGGER.warn(sb.toString()); } + + @Override + public String toString() { + return "Company{" + "companyId=" + companyId + ", name=" + name + ", description=" + description + ", headquarters=" + headquarters + ", homepage=" + homepage + ", logoPath=" + logoPath + ", parentCompany=" + parentCompany + '}'; + } } diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Genre.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Genre.java index c0454277e..199656f25 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Genre.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Genre.java @@ -98,7 +98,7 @@ public class Genre { @Override public String toString() { StringBuilder sb = new StringBuilder("[Genre="); - sb.append("id=").append(id); + sb.append("[id=").append(id); sb.append("],[name=").append(name); sb.append("]]"); return sb.toString(); diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperCompany.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperCompany.java new file mode 100644 index 000000000..5b14bd678 --- /dev/null +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperCompany.java @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2004-2012 YAMJ Members + * http://code.google.com/p/moviejukebox/people/list + * + * Web: http://code.google.com/p/moviejukebox/ + * + * This software is licensed under a Creative Commons License + * See this page: http://code.google.com/p/moviejukebox/wiki/License + * + * For any reuse or distribution, you must make clear to others the + * license terms of this work. + */ +package com.moviejukebox.themoviedb.wrapper; + +import com.moviejukebox.themoviedb.model.Company; +import java.util.List; +import org.apache.log4j.Logger; +import org.codehaus.jackson.annotate.JsonAnySetter; +import org.codehaus.jackson.annotate.JsonProperty; + +/** + * + * @author stuart.boston + */ +public class WrapperCompany { + /* + * Logger + */ + + private static final Logger LOGGER = Logger.getLogger(WrapperCompany.class); + /* + * Properties + */ + @JsonProperty("page") + private int page; + @JsonProperty("results") + private List results; + @JsonProperty("total_pages") + private int totalPages; + @JsonProperty("total_results") + private int totalResults; + + // + public int getPage() { + return page; + } + + public List getResults() { + return results; + } + + public int getTotalPages() { + return totalPages; + } + + public int getTotalResults() { + return totalResults; + } + // + + // + public void setPage(int page) { + this.page = page; + } + + public void setResults(List results) { + this.results = results; + } + + public void setTotalPages(int totalPages) { + this.totalPages = totalPages; + } + + public void setTotalResults(int totalResults) { + this.totalResults = totalResults; + } + // + + /** + * Handle unknown properties and print a message + * @param key + * @param value + */ + @JsonAnySetter + public void handleUnknown(String key, Object value) { + StringBuilder sb = new StringBuilder(); + sb.append("Unknown property: '").append(key); + sb.append("' value: '").append(value).append("'"); + LOGGER.warn(sb.toString()); + } +} diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperGenres.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperGenres.java new file mode 100644 index 000000000..e6dff9b87 --- /dev/null +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperGenres.java @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2004-2012 YAMJ Members + * http://code.google.com/p/moviejukebox/people/list + * + * Web: http://code.google.com/p/moviejukebox/ + * + * This software is licensed under a Creative Commons License + * See this page: http://code.google.com/p/moviejukebox/wiki/License + * + * For any reuse or distribution, you must make clear to others the + * license terms of this work. + */ +package com.moviejukebox.themoviedb.wrapper; + +import com.moviejukebox.themoviedb.model.Genre; +import java.util.List; +import org.apache.log4j.Logger; +import org.codehaus.jackson.annotate.JsonAnySetter; +import org.codehaus.jackson.annotate.JsonProperty; + +/** + * Wrapper class for the Genres searches + * + * @author Stuart + */ +public class WrapperGenres { + /* + * Logger + */ + + private static final Logger LOGGER = Logger.getLogger(WrapperGenres.class); + /* + * Properties + */ + @JsonProperty("genres") + private List genres; + + public List getGenres() { + return genres; + } + + public void setGenres(List genres) { + this.genres = genres; + } + + /** + * Handle unknown properties and print a message + * + * @param key + * @param value + */ + @JsonAnySetter + public void handleUnknown(String key, Object value) { + StringBuilder sb = new StringBuilder(); + sb.append("Unknown property: '").append(key); + sb.append("' value: '").append(value).append("'"); + LOGGER.warn(sb.toString()); + } +} diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperResultList.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperResultList.java index 2badd7726..e44c987f3 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperResultList.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperResultList.java @@ -39,6 +39,8 @@ public class WrapperResultList { private int totalPages; @JsonProperty("total_results") private int totalResults; + @JsonProperty("id") + private int id; // public int getPage() { @@ -56,6 +58,10 @@ public class WrapperResultList { public int getTotalResults() { return totalResults; } + + public int getId() { + return id; + } // // @@ -74,10 +80,15 @@ public class WrapperResultList { public void setTotalResults(int totalResults) { this.totalResults = totalResults; } + + public void setId(int id) { + this.id = id; + } // /** * Handle unknown properties and print a message + * * @param key * @param value */ @@ -96,6 +107,7 @@ public class WrapperResultList { sb.append("],[pageResults=").append(results.size()); sb.append("],[totalPages=").append(totalPages); sb.append("],[totalResults=").append(totalResults); + sb.append("],[id=").append(id); sb.append("]]"); return sb.toString(); } diff --git a/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java b/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java index 79e479611..9df436f85 100644 --- a/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java +++ b/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java @@ -17,8 +17,8 @@ import java.io.IOException; import java.util.List; import org.apache.commons.lang3.StringUtils; import org.apache.log4j.Logger; -import static org.junit.Assert.*; import org.junit.*; +import static org.junit.Assert.*; /** * Test cases for TheMovieDb API @@ -37,6 +37,8 @@ public class TheMovieDbTest { private static final int ID_MOVIE_STAR_WARS_COLLECTION = 10; private static final int ID_PERSON_BRUCE_WILLIS = 62; private static final int ID_COMPANY_LUCASFILM = 1; + private static final String COMPANY_NAME = "Marvel Studios"; + private static final int ID_GENRE_ACTION = 28; public TheMovieDbTest() throws MovieDbException { tmdb = new TheMovieDb(API_KEY); @@ -380,4 +382,51 @@ public class TheMovieDbTest { List results = tmdb.getCompanyMovies(ID_COMPANY_LUCASFILM, "", true); assertTrue("No company movies found", !results.isEmpty()); } + + /** + * Test of showVersion method, of class TheMovieDb. + */ + @Test + public void testShowVersion() { + // Not required + } + + /** + * Test of searchCompanies method, of class TheMovieDb. + */ + @Test + public void testSearchCompanies() throws Exception { + LOGGER.info("searchCompanies"); + List results = tmdb.searchCompanies(COMPANY_NAME, "", true); + assertTrue("No company information found", !results.isEmpty()); + } + + /** + * Test of getSimilarMovies method, of class TheMovieDb. + */ + @Test + public void testGetSimilarMovies() throws Exception { + LOGGER.info("getSimilarMovies"); + List results = tmdb.getSimilarMovies(ID_MOVIE_BLADE_RUNNER, "", true); + assertTrue("No similar movies found", !results.isEmpty()); + } + /** + * Test of getGenreList method, of class TheMovieDb. + */ + @Test + public void testGetGenreList() throws MovieDbException { + LOGGER.info("getGenreList"); + List results = tmdb.getGenreList(""); + assertTrue("No genres found", !results.isEmpty()); + } + + /** + * Test of getGenreMovies method, of class TheMovieDb. + */ + @Test + public void testGetGenreMovies() throws MovieDbException { + LOGGER.info("getGenreMovies"); + List results = tmdb.getGenreMovies(ID_GENRE_ACTION, "", true); + assertTrue("No genre movies found", !results.isEmpty()); + } } From 0bd864e3b0012f92c8e6172f04184d846c26515a Mon Sep 17 00:00:00 2001 From: Omertron Date: Tue, 3 Jul 2012 14:25:36 +0000 Subject: [PATCH 135/207] Renamed "WrapperResultList" to "WrapperMovie" in line with other wrapper classes. --- .../moviejukebox/themoviedb/TheMovieDb.java | 24 +++++++++---------- ...apperResultList.java => WrapperMovie.java} | 16 ++++++------- .../themoviedb/TheMovieDbTest.java | 8 +++---- 3 files changed, 24 insertions(+), 24 deletions(-) rename themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/{WrapperResultList.java => WrapperMovie.java} (89%) diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java index bfaa5f21e..09ddd411c 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java @@ -220,8 +220,8 @@ public class TheMovieDb { URL url = tmdbSearchMovie.getQueryUrl(movieName, language, 1); String webPage = WebBrowser.request(url); try { - WrapperResultList wrapper = mapper.readValue(webPage, WrapperResultList.class); - return wrapper.getResults(); + WrapperMovie wrapper = mapper.readValue(webPage, WrapperMovie.class); + return wrapper.getMovies(); } catch (IOException ex) { LOGGER.warn("Failed to find movie: " + ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage, ex); @@ -673,8 +673,8 @@ public class TheMovieDb { String webPage = WebBrowser.request(url); try { - WrapperResultList wrapper = mapper.readValue(webPage, WrapperResultList.class); - return wrapper.getResults(); + WrapperMovie wrapper = mapper.readValue(webPage, WrapperMovie.class); + return wrapper.getMovies(); } catch (IOException ex) { LOGGER.warn("Failed to get now playing movies: " + ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage, ex); @@ -698,8 +698,8 @@ public class TheMovieDb { String webPage = WebBrowser.request(url); try { - WrapperResultList wrapper = mapper.readValue(webPage, WrapperResultList.class); - return wrapper.getResults(); + WrapperMovie wrapper = mapper.readValue(webPage, WrapperMovie.class); + return wrapper.getMovies(); } catch (IOException ex) { LOGGER.warn("Failed to get popular movie list: " + ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage, ex); @@ -723,8 +723,8 @@ public class TheMovieDb { String webPage = WebBrowser.request(url); try { - WrapperResultList wrapper = mapper.readValue(webPage, WrapperResultList.class); - return wrapper.getResults(); + WrapperMovie wrapper = mapper.readValue(webPage, WrapperMovie.class); + return wrapper.getMovies(); } catch (IOException ex) { LOGGER.warn("Failed to get top rated movies: " + ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage, ex); @@ -825,8 +825,8 @@ public class TheMovieDb { String webPage = WebBrowser.request(url); try { - WrapperResultList wrapper = mapper.readValue(webPage, WrapperResultList.class); - return wrapper.getResults(); + WrapperMovie wrapper = mapper.readValue(webPage, WrapperMovie.class); + return wrapper.getMovies(); } catch (IOException ex) { LOGGER.warn("Failed to get similar movies: " + ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage, ex); @@ -871,8 +871,8 @@ public class TheMovieDb { String webPage = WebBrowser.request(url); try { - WrapperResultList wrapper = mapper.readValue(webPage, WrapperResultList.class); - return wrapper.getResults(); + WrapperMovie wrapper = mapper.readValue(webPage, WrapperMovie.class); + return wrapper.getMovies(); } catch (IOException ex) { LOGGER.warn("Failed to get genre movie list: " + ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage, ex); diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperResultList.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperMovie.java similarity index 89% rename from themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperResultList.java rename to themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperMovie.java index e44c987f3..2f1331ed8 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperResultList.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperMovie.java @@ -22,19 +22,19 @@ import org.codehaus.jackson.annotate.JsonProperty; * * @author stuart.boston */ -public class WrapperResultList { +public class WrapperMovie { /* * Logger */ - private static final Logger LOGGER = Logger.getLogger(WrapperResultList.class); + private static final Logger LOGGER = Logger.getLogger(WrapperMovie.class); /* * Properties */ @JsonProperty("page") private int page; @JsonProperty("results") - private List results; + private List movies; @JsonProperty("total_pages") private int totalPages; @JsonProperty("total_results") @@ -47,8 +47,8 @@ public class WrapperResultList { return page; } - public List getResults() { - return results; + public List getMovies() { + return movies; } public int getTotalPages() { @@ -69,8 +69,8 @@ public class WrapperResultList { this.page = page; } - public void setResults(List results) { - this.results = results; + public void setMovies(List results) { + this.movies = results; } public void setTotalPages(int totalPages) { @@ -104,7 +104,7 @@ public class WrapperResultList { public String toString() { StringBuilder sb = new StringBuilder("[ResultList=["); sb.append("[page=").append(page); - sb.append("],[pageResults=").append(results.size()); + sb.append("],[pageResults=").append(movies.size()); sb.append("],[totalPages=").append(totalPages); sb.append("],[totalResults=").append(totalResults); sb.append("],[id=").append(id); diff --git a/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java b/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java index 9df436f85..170a0edb5 100644 --- a/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java +++ b/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java @@ -367,7 +367,7 @@ public class TheMovieDbTest { * Test of getCompanyInfo method, of class TheMovieDb. */ @Test - public void testGetCompanyInfo() throws Exception { + public void testGetCompanyInfo() throws MovieDbException { LOGGER.info("getCompanyInfo"); Company company = tmdb.getCompanyInfo(ID_COMPANY_LUCASFILM); assertTrue("No company information found", company.getCompanyId() > 0); @@ -377,7 +377,7 @@ public class TheMovieDbTest { * Test of getCompanyMovies method, of class TheMovieDb. */ @Test - public void testGetCompanyMovies() throws Exception { + public void testGetCompanyMovies() throws MovieDbException { LOGGER.info("getCompanyMovies"); List results = tmdb.getCompanyMovies(ID_COMPANY_LUCASFILM, "", true); assertTrue("No company movies found", !results.isEmpty()); @@ -395,7 +395,7 @@ public class TheMovieDbTest { * Test of searchCompanies method, of class TheMovieDb. */ @Test - public void testSearchCompanies() throws Exception { + public void testSearchCompanies() throws MovieDbException { LOGGER.info("searchCompanies"); List results = tmdb.searchCompanies(COMPANY_NAME, "", true); assertTrue("No company information found", !results.isEmpty()); @@ -405,7 +405,7 @@ public class TheMovieDbTest { * Test of getSimilarMovies method, of class TheMovieDb. */ @Test - public void testGetSimilarMovies() throws Exception { + public void testGetSimilarMovies() throws MovieDbException { LOGGER.info("getSimilarMovies"); List results = tmdb.getSimilarMovies(ID_MOVIE_BLADE_RUNNER, "", true); assertTrue("No similar movies found", !results.isEmpty()); From 619432fd6fb5f19460933485b0d4058543692465 Mon Sep 17 00:00:00 2001 From: Omertron Date: Tue, 3 Jul 2012 14:27:31 +0000 Subject: [PATCH 136/207] Updated webbrowser to remove redundant check --- .../java/com/moviejukebox/themoviedb/tools/WebBrowser.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/WebBrowser.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/WebBrowser.java index e9d70fbb6..b76783064 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/WebBrowser.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/WebBrowser.java @@ -113,7 +113,8 @@ public final class WebBrowser { if (in != null) { in.close(); } - if (cnx != null && cnx instanceof HttpURLConnection) { + + if (cnx instanceof HttpURLConnection) { ((HttpURLConnection) cnx).disconnect(); } } From 15190173a2b0cb694e1ebb16f4286d24e232b30d Mon Sep 17 00:00:00 2001 From: Omertron Date: Tue, 3 Jul 2012 20:52:34 +0000 Subject: [PATCH 137/207] Updated POM --- .../.settings/org.eclipse.jdt.core.prefs | 6 -- .../.settings/org.maven.ide.eclipse.prefs | 8 -- themoviedbapi/pom.xml | 83 +++---------------- 3 files changed, 13 insertions(+), 84 deletions(-) delete mode 100644 themoviedbapi/.settings/org.eclipse.jdt.core.prefs delete mode 100644 themoviedbapi/.settings/org.maven.ide.eclipse.prefs diff --git a/themoviedbapi/.settings/org.eclipse.jdt.core.prefs b/themoviedbapi/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 483d704da..000000000 --- a/themoviedbapi/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,6 +0,0 @@ -#Sat Jan 29 22:13:58 CET 2011 -eclipse.preferences.version=1 -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -org.eclipse.jdt.core.compiler.compliance=1.6 -org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning -org.eclipse.jdt.core.compiler.source=1.6 diff --git a/themoviedbapi/.settings/org.maven.ide.eclipse.prefs b/themoviedbapi/.settings/org.maven.ide.eclipse.prefs deleted file mode 100644 index 341107664..000000000 --- a/themoviedbapi/.settings/org.maven.ide.eclipse.prefs +++ /dev/null @@ -1,8 +0,0 @@ -#Sat Jan 29 22:13:55 CET 2011 -activeProfiles= -eclipse.preferences.version=1 -fullBuildGoals=process-test-resources -resolveWorkspaceProjects=true -resourceFilterGoals=process-resources resources\:testResources -skipCompilerPlugin=true -version=1 diff --git a/themoviedbapi/pom.xml b/themoviedbapi/pom.xml index 12bb18451..2f0d1e77e 100644 --- a/themoviedbapi/pom.xml +++ b/themoviedbapi/pom.xml @@ -43,6 +43,8 @@ junit junit + 4.10 + test log4j @@ -52,12 +54,12 @@ org.codehaus.jackson jackson-core-lgpl - 1.9.7 + 1.9.8 org.codehaus.jackson jackson-mapper-lgpl - 1.9.7 + 1.9.8 commons-codec @@ -71,17 +73,6 @@ - - - - junit - junit - 4.10 - test - - - - release-sign-artifacts @@ -111,65 +102,11 @@ - - - - org.apache.maven.plugins - maven-clean-plugin - 2.5 - - - org.apache.maven.plugins - maven-compiler-plugin - 2.5.1 - - - org.apache.maven.plugins - maven-gpg-plugin - 1.4 - - - org.apache.maven.plugins - maven-jar-plugin - 2.4 - - - org.apache.maven.plugins - maven-surefire-plugin - 2.12 - - - org.codehaus.mojo - buildnumber-maven-plugin - 1.1 - - - org.codehaus.mojo - build-helper-maven-plugin - 1.7 - - - org.apache.maven.plugins - maven-antrun-plugin - 1.7 - - - org.apache.maven.plugins - maven-assembly-plugin - 2.3 - - - org.codehaus.mojo - versions-maven-plugin - 1.3.1 - - - - org.codehaus.mojo buildnumber-maven-plugin + 1.1 true 0000 @@ -188,18 +125,20 @@ org.apache.maven.plugins maven-compiler-plugin + 2.5.1 1.6 1.6 true true - + org.apache.maven.plugins maven-jar-plugin + 2.4 @@ -212,10 +151,11 @@ - + org.apache.maven.plugins maven-surefire-plugin + 2.12 ${skipTests} @@ -224,6 +164,7 @@ org.apache.maven.plugins maven-antrun-plugin + 1.7 create-version-txt @@ -251,6 +192,7 @@ org.apache.maven.plugins maven-assembly-plugin + 2.3 distro-assembly @@ -269,6 +211,7 @@ org.codehaus.mojo versions-maven-plugin + 1.3.1 From cb1a4bf079b056a559a557eb9a2c1b9539f4dad0 Mon Sep 17 00:00:00 2001 From: Omertron Date: Sun, 26 Aug 2012 21:28:18 +0000 Subject: [PATCH 138/207] Fixes issue 19 Added serialization to model classes --- .../themoviedb/model/AlternativeTitle.java | 6 +++- .../themoviedb/model/Artwork.java | 5 +++- .../themoviedb/model/Collection.java | 5 +++- .../themoviedb/model/CollectionInfo.java | 5 +++- .../themoviedb/model/Company.java | 6 ++-- .../moviejukebox/themoviedb/model/Genre.java | 5 +++- .../themoviedb/model/Keyword.java | 7 ++++- .../themoviedb/model/Language.java | 5 +++- .../themoviedb/model/MovieDb.java | 4 ++- .../moviejukebox/themoviedb/model/Person.java | 7 +++-- .../themoviedb/model/PersonCast.java | 8 ++++-- .../themoviedb/model/PersonCredit.java | 7 +++-- .../themoviedb/model/PersonCrew.java | 8 ++++-- .../themoviedb/model/ProductionCompany.java | 8 ++++-- .../themoviedb/model/ProductionCountry.java | 8 ++++-- .../themoviedb/model/ReleaseInfo.java | 8 ++++-- .../themoviedb/model/StatusCode.java | 8 ++++-- .../themoviedb/model/TmdbConfiguration.java | 28 ++++++++++--------- .../themoviedb/model/Trailer.java | 8 ++++-- .../themoviedb/model/Translation.java | 8 ++++-- 20 files changed, 111 insertions(+), 43 deletions(-) diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/AlternativeTitle.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/AlternativeTitle.java index 1ae6dc978..557b09fd1 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/AlternativeTitle.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/AlternativeTitle.java @@ -12,6 +12,7 @@ */ package com.moviejukebox.themoviedb.model; +import java.io.Serializable; import org.apache.log4j.Logger; import org.codehaus.jackson.annotate.JsonAnySetter; import org.codehaus.jackson.annotate.JsonProperty; @@ -20,7 +21,9 @@ import org.codehaus.jackson.annotate.JsonProperty; * * @author Stuart */ -public class AlternativeTitle { +public class AlternativeTitle implements Serializable { + + private static final long serialVersionUID = 1L; /* * Logger @@ -56,6 +59,7 @@ public class AlternativeTitle { /** * Handle unknown properties and print a message + * * @param key * @param value */ diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Artwork.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Artwork.java index 90d4e81ce..9dd1d200c 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Artwork.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Artwork.java @@ -12,6 +12,7 @@ */ package com.moviejukebox.themoviedb.model; +import java.io.Serializable; import org.apache.log4j.Logger; import org.codehaus.jackson.annotate.JsonAnySetter; import org.codehaus.jackson.annotate.JsonProperty; @@ -21,7 +22,9 @@ import org.codehaus.jackson.annotate.JsonProperty; * * @author Stuart */ -public class Artwork { +public class Artwork implements Serializable { + + private static final long serialVersionUID = 1L; /* * Logger diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Collection.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Collection.java index bd22f3478..0eeddaf10 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Collection.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Collection.java @@ -12,6 +12,7 @@ */ package com.moviejukebox.themoviedb.model; +import java.io.Serializable; import org.apache.commons.lang3.StringUtils; import org.apache.log4j.Logger; import org.codehaus.jackson.annotate.JsonAnySetter; @@ -23,8 +24,9 @@ import org.codehaus.jackson.map.annotate.JsonRootName; * @author stuart.boston */ @JsonRootName("collection") -public class Collection { +public class Collection implements Serializable { + private static final long serialVersionUID = 1L; /* * Logger */ @@ -105,6 +107,7 @@ public class Collection { /** * Handle unknown properties and print a message + * * @param key * @param value */ diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/CollectionInfo.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/CollectionInfo.java index fa6bd0a03..ca3fdcd82 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/CollectionInfo.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/CollectionInfo.java @@ -12,6 +12,7 @@ */ package com.moviejukebox.themoviedb.model; +import java.io.Serializable; import java.util.ArrayList; import java.util.List; import org.apache.log4j.Logger; @@ -22,8 +23,9 @@ import org.codehaus.jackson.annotate.JsonProperty; * * @author Stuart */ -public class CollectionInfo { +public class CollectionInfo implements Serializable { + private static final long serialVersionUID = 1L; /* * Logger */ @@ -88,6 +90,7 @@ public class CollectionInfo { /** * Handle unknown properties and print a message + * * @param key * @param value */ diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Company.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Company.java index fe4281d29..9c4a3675c 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Company.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Company.java @@ -12,6 +12,7 @@ */ package com.moviejukebox.themoviedb.model; +import java.io.Serializable; import org.apache.log4j.Logger; import org.codehaus.jackson.annotate.JsonAnySetter; import org.codehaus.jackson.annotate.JsonProperty; @@ -21,9 +22,10 @@ import org.codehaus.jackson.annotate.JsonProperty; * * @author Stuart */ -public class Company { - // Logger +public class Company implements Serializable { + private static final long serialVersionUID = 1L; + // Logger private static final Logger LOGGER = Logger.getLogger(Company.class); private static final String DEFAULT_STRING = ""; // Properties diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Genre.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Genre.java index 199656f25..9cfd58b0d 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Genre.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Genre.java @@ -12,6 +12,7 @@ */ package com.moviejukebox.themoviedb.model; +import java.io.Serializable; import org.apache.log4j.Logger; import org.codehaus.jackson.annotate.JsonAnySetter; import org.codehaus.jackson.annotate.JsonProperty; @@ -22,8 +23,9 @@ import org.codehaus.jackson.map.annotate.JsonRootName; * @author stuart.boston */ @JsonRootName("genre") -public class Genre { +public class Genre implements Serializable { + private static final long serialVersionUID = 1L; /* * Logger */ @@ -58,6 +60,7 @@ public class Genre { /** * Handle unknown properties and print a message + * * @param key * @param value */ diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Keyword.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Keyword.java index 7de0e3ea9..73122cd9d 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Keyword.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Keyword.java @@ -12,6 +12,8 @@ */ package com.moviejukebox.themoviedb.model; +import java.io.Serializable; +import javax.imageio.spi.ServiceRegistry; import org.apache.log4j.Logger; import org.codehaus.jackson.annotate.JsonAnySetter; import org.codehaus.jackson.annotate.JsonProperty; @@ -22,7 +24,9 @@ import org.codehaus.jackson.map.annotate.JsonRootName; * @author stuart.boston */ @JsonRootName("keyword") -public class Keyword { +public class Keyword implements Serializable { + + private static final long serialVersionUID = 1L; /* * Logger @@ -58,6 +62,7 @@ public class Keyword { /** * Handle unknown properties and print a message + * * @param key * @param value */ diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Language.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Language.java index 012601e85..279839c14 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Language.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Language.java @@ -12,6 +12,7 @@ */ package com.moviejukebox.themoviedb.model; +import java.io.Serializable; import org.apache.log4j.Logger; import org.codehaus.jackson.annotate.JsonAnySetter; import org.codehaus.jackson.annotate.JsonProperty; @@ -22,8 +23,9 @@ import org.codehaus.jackson.map.annotate.JsonRootName; * @author stuart.boston */ @JsonRootName("spoken_language") -public class Language { +public class Language implements Serializable { + private static final long serialVersionUID = 1L; /* * Logger */ @@ -58,6 +60,7 @@ public class Language { /** * Handle unknown properties and print a message + * * @param key * @param value */ diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/MovieDb.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/MovieDb.java index 3dca1cf35..fb0bc4c81 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/MovieDb.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/MovieDb.java @@ -12,6 +12,7 @@ */ package com.moviejukebox.themoviedb.model; +import java.io.Serializable; import java.util.List; import org.apache.log4j.Logger; import org.codehaus.jackson.annotate.JsonAnySetter; @@ -22,8 +23,9 @@ import org.codehaus.jackson.annotate.JsonProperty; * * @author stuart.boston */ -public class MovieDb { +public class MovieDb implements Serializable { + private static final long serialVersionUID = 1L; /* * Logger */ diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Person.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Person.java index 0620be0fc..c69a0f2ab 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Person.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Person.java @@ -12,6 +12,7 @@ */ package com.moviejukebox.themoviedb.model; +import java.io.Serializable; import java.util.ArrayList; import java.util.List; import org.apache.log4j.Logger; @@ -22,11 +23,13 @@ import org.codehaus.jackson.annotate.JsonProperty; * * @author stuart.boston */ -public class Person { +public class Person implements Serializable { + + private static final long serialVersionUID = 1L; + /* * Logger */ - private static final Logger LOGGER = Logger.getLogger(Person.class); /* diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/PersonCast.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/PersonCast.java index 2d8ae21cf..ef3b3e1a1 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/PersonCast.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/PersonCast.java @@ -12,6 +12,7 @@ */ package com.moviejukebox.themoviedb.model; +import java.io.Serializable; import org.apache.log4j.Logger; import org.codehaus.jackson.annotate.JsonAnySetter; import org.codehaus.jackson.annotate.JsonProperty; @@ -20,11 +21,13 @@ import org.codehaus.jackson.annotate.JsonProperty; * * @author Stuart */ -public class PersonCast { +public class PersonCast implements Serializable { + + private static final long serialVersionUID = 1L; + /* * Logger */ - private static final Logger LOGGER = Logger.getLogger(PersonCast.class); /* * Properties @@ -86,6 +89,7 @@ public class PersonCast { /** * Handle unknown properties and print a message + * * @param key * @param value */ diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/PersonCredit.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/PersonCredit.java index c741fdf39..27e06e3ec 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/PersonCredit.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/PersonCredit.java @@ -12,6 +12,7 @@ */ package com.moviejukebox.themoviedb.model; +import java.io.Serializable; import org.apache.log4j.Logger; import org.codehaus.jackson.annotate.JsonAnySetter; import org.codehaus.jackson.annotate.JsonProperty; @@ -20,11 +21,13 @@ import org.codehaus.jackson.annotate.JsonProperty; * * @author stuart.boston */ -public class PersonCredit { +public class PersonCredit implements Serializable { + + private static final long serialVersionUID = 1L; + /* * Logger */ - private static final Logger LOGGER = Logger.getLogger(PersonCredit.class); private static final String DEFAULT_STRING = ""; /* diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/PersonCrew.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/PersonCrew.java index 69456f3fa..2d704fe4c 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/PersonCrew.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/PersonCrew.java @@ -12,6 +12,7 @@ */ package com.moviejukebox.themoviedb.model; +import java.io.Serializable; import org.apache.log4j.Logger; import org.codehaus.jackson.annotate.JsonAnySetter; import org.codehaus.jackson.annotate.JsonProperty; @@ -20,11 +21,13 @@ import org.codehaus.jackson.annotate.JsonProperty; * * @author Stuart */ -public class PersonCrew { +public class PersonCrew implements Serializable { + + private static final long serialVersionUID = 1L; + /* * Logger */ - private static final Logger LOGGER = Logger.getLogger(PersonCrew.class); /* * Properties @@ -86,6 +89,7 @@ public class PersonCrew { /** * Handle unknown properties and print a message + * * @param key * @param value */ diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/ProductionCompany.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/ProductionCompany.java index 85fae5795..28da81bf4 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/ProductionCompany.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/ProductionCompany.java @@ -12,6 +12,7 @@ */ package com.moviejukebox.themoviedb.model; +import java.io.Serializable; import org.apache.log4j.Logger; import org.codehaus.jackson.annotate.JsonAnySetter; import org.codehaus.jackson.annotate.JsonProperty; @@ -22,11 +23,13 @@ import org.codehaus.jackson.map.annotate.JsonRootName; * @author stuart.boston */ @JsonRootName("production_company") -public class ProductionCompany { +public class ProductionCompany implements Serializable { + + private static final long serialVersionUID = 1L; + /* * Logger */ - private static final Logger LOGGER = Logger.getLogger(ProductionCompany.class); /* * Properties @@ -58,6 +61,7 @@ public class ProductionCompany { /** * Handle unknown properties and print a message + * * @param key * @param value */ diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/ProductionCountry.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/ProductionCountry.java index cc0556466..4dc6b63c4 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/ProductionCountry.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/ProductionCountry.java @@ -12,6 +12,7 @@ */ package com.moviejukebox.themoviedb.model; +import java.io.Serializable; import org.apache.log4j.Logger; import org.codehaus.jackson.annotate.JsonAnySetter; import org.codehaus.jackson.annotate.JsonProperty; @@ -22,11 +23,13 @@ import org.codehaus.jackson.map.annotate.JsonRootName; * @author stuart.boston */ @JsonRootName("production_country") -public class ProductionCountry { +public class ProductionCountry implements Serializable { + + private static final long serialVersionUID = 1L; + /* * Logger */ - private static final Logger LOGGER = Logger.getLogger(ProductionCountry.class); /* * Properties @@ -58,6 +61,7 @@ public class ProductionCountry { /** * Handle unknown properties and print a message + * * @param key * @param value */ diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/ReleaseInfo.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/ReleaseInfo.java index 5e4735de9..0f85bed17 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/ReleaseInfo.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/ReleaseInfo.java @@ -12,6 +12,7 @@ */ package com.moviejukebox.themoviedb.model; +import java.io.Serializable; import org.apache.log4j.Logger; import org.codehaus.jackson.annotate.JsonAnySetter; import org.codehaus.jackson.annotate.JsonProperty; @@ -20,11 +21,13 @@ import org.codehaus.jackson.annotate.JsonProperty; * * @author Stuart */ -public class ReleaseInfo { +public class ReleaseInfo implements Serializable { + + private static final long serialVersionUID = 1L; + /* * Logger */ - private static final Logger LOGGER = Logger.getLogger(ReleaseInfo.class); /* * Properties @@ -66,6 +69,7 @@ public class ReleaseInfo { /** * Handle unknown properties and print a message + * * @param key * @param value */ diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/StatusCode.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/StatusCode.java index bfad70828..082efe537 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/StatusCode.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/StatusCode.java @@ -12,6 +12,7 @@ */ package com.moviejukebox.themoviedb.model; +import java.io.Serializable; import org.apache.log4j.Logger; import org.codehaus.jackson.annotate.JsonAnySetter; import org.codehaus.jackson.annotate.JsonProperty; @@ -20,11 +21,13 @@ import org.codehaus.jackson.annotate.JsonProperty; * * @author Stuart */ -public class StatusCode { +public class StatusCode implements Serializable { + + private static final long serialVersionUID = 1L; + /* * Logger */ - private static final Logger LOGGER = Logger.getLogger(StatusCode.class); /* * Properties @@ -56,6 +59,7 @@ public class StatusCode { /** * Handle unknown properties and print a message + * * @param key * @param value */ diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/TmdbConfiguration.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/TmdbConfiguration.java index 61eacf9d6..40d3f5f74 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/TmdbConfiguration.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/TmdbConfiguration.java @@ -12,6 +12,7 @@ */ package com.moviejukebox.themoviedb.model; +import java.io.Serializable; import java.util.List; import org.apache.commons.lang3.StringUtils; import org.apache.log4j.Logger; @@ -22,8 +23,9 @@ import org.codehaus.jackson.annotate.JsonProperty; * * @author stuart.boston */ -public class TmdbConfiguration { +public class TmdbConfiguration implements Serializable { + private static final long serialVersionUID = 1L; /* * Logger */ @@ -46,19 +48,19 @@ public class TmdbConfiguration { public List getBackdropSizes() { return backdropSizes; } - + public String getBaseUrl() { return baseUrl; } - + public List getPosterSizes() { return posterSizes; } - + public List getProfileSizes() { return profileSizes; } - + public List getLogoSizes() { return logoSizes; } @@ -68,19 +70,19 @@ public class TmdbConfiguration { public void setBackdropSizes(List backdropSizes) { this.backdropSizes = backdropSizes; } - + public void setBaseUrl(String baseUrl) { this.baseUrl = baseUrl; } - + public void setPosterSizes(List posterSizes) { this.posterSizes = posterSizes; } - + public void setProfileSizes(List profileSizes) { this.profileSizes = profileSizes; } - + public void setLogoSizes(List logoSizes) { this.logoSizes = logoSizes; } @@ -158,9 +160,9 @@ public class TmdbConfiguration { * @return */ public boolean isValidSize(String sizeToCheck) { - return (isValidPosterSize(sizeToCheck) - || isValidBackdropSize(sizeToCheck) - || isValidProfileSize(sizeToCheck) + return (isValidPosterSize(sizeToCheck) + || isValidBackdropSize(sizeToCheck) + || isValidProfileSize(sizeToCheck) || isValidLogoSize(sizeToCheck)); } @@ -177,7 +179,7 @@ public class TmdbConfiguration { sb.append("' value: '").append(value).append("'"); LOGGER.warn(sb.toString()); } - + @Override public String toString() { StringBuilder sb = new StringBuilder("[ImageConfiguration="); diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Trailer.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Trailer.java index 3985fae3d..2da366121 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Trailer.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Trailer.java @@ -12,6 +12,7 @@ */ package com.moviejukebox.themoviedb.model; +import java.io.Serializable; import org.apache.log4j.Logger; import org.codehaus.jackson.annotate.JsonAnySetter; @@ -19,11 +20,13 @@ import org.codehaus.jackson.annotate.JsonAnySetter; * * @author Stuart */ -public class Trailer { +public class Trailer implements Serializable { + + private static final long serialVersionUID = 1L; + /* * Logger */ - private static final Logger LOGGER = Logger.getLogger(Trailer.class); /* * Website sources @@ -76,6 +79,7 @@ public class Trailer { /** * Handle unknown properties and print a message + * * @param key * @param value */ diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Translation.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Translation.java index 7f1af5c0c..dbee8f1d2 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Translation.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Translation.java @@ -12,6 +12,7 @@ */ package com.moviejukebox.themoviedb.model; +import java.io.Serializable; import org.apache.log4j.Logger; import org.codehaus.jackson.annotate.JsonAnySetter; import org.codehaus.jackson.annotate.JsonProperty; @@ -20,11 +21,13 @@ import org.codehaus.jackson.annotate.JsonProperty; * * @author Stuart */ -public class Translation { +public class Translation implements Serializable { + + private static final long serialVersionUID = 1L; + /* * Logger */ - private static final Logger LOGGER = Logger.getLogger(Translation.class); /* * Properties @@ -66,6 +69,7 @@ public class Translation { /** * Handle unknown properties and print a message + * * @param key * @param value */ From bf4e8c27564f9c4348008d345c71fec0cb66a2d7 Mon Sep 17 00:00:00 2001 From: Omertron Date: Tue, 28 Aug 2012 08:52:38 +0000 Subject: [PATCH 139/207] Fixed test error. --- .../test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java b/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java index 170a0edb5..98e38a027 100644 --- a/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java +++ b/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java @@ -93,7 +93,7 @@ public class TheMovieDbTest { // Try a movie with more than 20 results movieList = tmdb.searchMovie("Star Wars", "en", false); - assertTrue("Not enough movies found, should be 20", movieList.size() == 20); + assertTrue("Not enough movies found, should be over 15, found " + movieList.size(), movieList.size() >= 15); } /** @@ -410,6 +410,7 @@ public class TheMovieDbTest { List results = tmdb.getSimilarMovies(ID_MOVIE_BLADE_RUNNER, "", true); assertTrue("No similar movies found", !results.isEmpty()); } + /** * Test of getGenreList method, of class TheMovieDb. */ From f4d4bd6c98e376454cfd35efdcd9d5e9b6392c4b Mon Sep 17 00:00:00 2001 From: Omertron Date: Tue, 28 Aug 2012 19:07:04 +0000 Subject: [PATCH 140/207] Updated POM versions --- themoviedbapi/pom.xml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/themoviedbapi/pom.xml b/themoviedbapi/pom.xml index 2f0d1e77e..068913152 100644 --- a/themoviedbapi/pom.xml +++ b/themoviedbapi/pom.xml @@ -54,12 +54,12 @@ org.codehaus.jackson jackson-core-lgpl - 1.9.8 + 1.9.9 org.codehaus.jackson jackson-mapper-lgpl - 1.9.8 + 1.9.9 commons-codec From bb8fdc79ab4dea64ef141351172c4e120f44b911 Mon Sep 17 00:00:00 2001 From: Omertron Date: Tue, 25 Sep 2012 09:03:22 +0000 Subject: [PATCH 141/207] Updated POM versions --- themoviedbapi/pom.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/themoviedbapi/pom.xml b/themoviedbapi/pom.xml index 068913152..ea0be4308 100644 --- a/themoviedbapi/pom.xml +++ b/themoviedbapi/pom.xml @@ -54,17 +54,17 @@ org.codehaus.jackson jackson-core-lgpl - 1.9.9 + 1.9.10 org.codehaus.jackson jackson-mapper-lgpl - 1.9.9 + 1.9.10 commons-codec commons-codec - 1.6 + 1.7 org.apache.commons @@ -155,7 +155,7 @@ org.apache.maven.plugins maven-surefire-plugin - 2.12 + 2.12.3 ${skipTests} From 8bba5c4a272a8b2fdad1454858f60335e199f159 Mon Sep 17 00:00:00 2001 From: Omertron Date: Tue, 25 Sep 2012 09:06:22 +0000 Subject: [PATCH 142/207] [maven-release-plugin] prepare release themoviedbapi-3.2 --- themoviedbapi/pom.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/themoviedbapi/pom.xml b/themoviedbapi/pom.xml index ea0be4308..b57e61706 100644 --- a/themoviedbapi/pom.xml +++ b/themoviedbapi/pom.xml @@ -13,7 +13,7 @@ com.moviejukebox themoviedbapi - 3.2-SNAPSHOT + 3.2 API-The MovieDB @@ -27,9 +27,9 @@ - scm:svn:http://themoviedbapi.googlecode.com/svn/trunk/themoviedbapi - scm:svn:https://themoviedbapi.googlecode.com/svn/trunk/themoviedbapi - http://code.google.com/p/themoviedbapi/source/browse/trunk/themoviedbapi + scm:svn:http://themoviedbapi.googlecode.com/svn/tags/themoviedbapi-3.2 + scm:svn:https://themoviedbapi.googlecode.com/svn/tags/themoviedbapi-3.2 + http://code.google.com/p/themoviedbapi/source/browse/tags/themoviedbapi-3.2 From 8dad337d8d3e45be7181337df760151683e1b25f Mon Sep 17 00:00:00 2001 From: Omertron Date: Tue, 25 Sep 2012 09:06:36 +0000 Subject: [PATCH 143/207] [maven-release-plugin] prepare for next development iteration --- themoviedbapi/pom.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/themoviedbapi/pom.xml b/themoviedbapi/pom.xml index b57e61706..b98ef871c 100644 --- a/themoviedbapi/pom.xml +++ b/themoviedbapi/pom.xml @@ -13,7 +13,7 @@ com.moviejukebox themoviedbapi - 3.2 + 3.3-SNAPSHOT API-The MovieDB @@ -27,9 +27,9 @@ - scm:svn:http://themoviedbapi.googlecode.com/svn/tags/themoviedbapi-3.2 - scm:svn:https://themoviedbapi.googlecode.com/svn/tags/themoviedbapi-3.2 - http://code.google.com/p/themoviedbapi/source/browse/tags/themoviedbapi-3.2 + scm:svn:http://themoviedbapi.googlecode.com/svn/trunk/themoviedbapi + scm:svn:https://themoviedbapi.googlecode.com/svn/trunk/themoviedbapi + http://code.google.com/p/themoviedbapi/source/browse/trunk/themoviedbapi From 2c605dbe7e927204a532eeb5779900c85e2e3e9d Mon Sep 17 00:00:00 2001 From: Omertron Date: Tue, 25 Sep 2012 13:34:30 +0000 Subject: [PATCH 144/207] Added some new methods --- .../moviejukebox/themoviedb/TheMovieDb.java | 302 +++++++++++------- 1 file changed, 182 insertions(+), 120 deletions(-) diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java index 09ddd411c..fe6a21e86 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java @@ -30,7 +30,8 @@ import org.codehaus.jackson.map.ObjectMapper; /** * The MovieDb API * - * This is for version 3 of the API as specified here: http://help.themoviedb.org/kb/api/about-3 + * This is for version 3 of the API as specified here: + * http://help.themoviedb.org/kb/api/about-3 * * @author stuart.boston */ @@ -40,22 +41,33 @@ public class TheMovieDb { private String apiKey; private TmdbConfiguration tmdbConfig; /* - * API Methods: These are not set to static so that multiple instances of + * API Methods + * + * These are not set to static so that multiple instances of * the API can co-exist + * + * TODO: See issue 9 http://code.google.com/p/themoviedbapi/issues/detail?id=9 */ private static final String BASE_MOVIE = "movie/"; private static final String BASE_PERSON = "person/"; private static final String BASE_COMPANY = "company/"; private static final String BASE_GENRE = "genre/"; - // Configuration URL + private static final String BASE_AUTH = "authentication/"; + private static final String BASE_COLLECTION = "collection/"; + private static final String BASE_ACCOUNT = "account/"; + // Configuration private final ApiUrl tmdbConfigUrl = new ApiUrl(this, "configuration"); - // Search URLS - private final ApiUrl tmdbSearchMovie = new ApiUrl(this, "search/movie"); - private final ApiUrl tmdbSearchPeople = new ApiUrl(this, "search/person"); - private final ApiUrl tmdbSearchCompanies = new ApiUrl(this, "search/company"); - // Collections - private final ApiUrl tmdbCollectionInfo = new ApiUrl(this, "collection/"); - // Movie Info + // Authentication + private final ApiUrl tmdbAuthToken = new ApiUrl(this, BASE_AUTH, "token/new"); + private final ApiUrl tmdbAuthSession = new ApiUrl(this, BASE_AUTH, "session/new"); + // Account + private final ApiUrl tmdbAccount = new ApiUrl(this, BASE_ACCOUNT); + private final ApiUrl tmdbFavouriteMovies = new ApiUrl(this, BASE_ACCOUNT, "/favorite_movies"); + private final ApiUrl tmdbPostFavourite = new ApiUrl(this, BASE_ACCOUNT, "/favorite"); + private final ApiUrl tmdbRatedMovies = new ApiUrl(this, BASE_ACCOUNT, "/rated_movies"); + private final ApiUrl tmdbMovieWatchList = new ApiUrl(this, BASE_ACCOUNT, "/movie_watchlist"); + private final ApiUrl tmdbPostMovieWatchList = new ApiUrl(this, BASE_ACCOUNT, "/movie_watchlist"); + // Movies private final ApiUrl tmdbMovieInfo = new ApiUrl(this, BASE_MOVIE); private final ApiUrl tmdbMovieAltTitles = new ApiUrl(this, BASE_MOVIE, "/alternative_titles"); private final ApiUrl tmdbMovieCasts = new ApiUrl(this, BASE_MOVIE, "/casts"); @@ -65,22 +77,29 @@ public class TheMovieDb { private final ApiUrl tmdbMovieTrailers = new ApiUrl(this, BASE_MOVIE, "/trailers"); private final ApiUrl tmdbMovieTranslations = new ApiUrl(this, BASE_MOVIE, "/translations"); private final ApiUrl tmdbMovieSimilarMovies = new ApiUrl(this, BASE_MOVIE, "/similar_movies"); - // Person Info + private final ApiUrl tmdbLatestMovie = new ApiUrl(this, BASE_MOVIE, "/latest"); + private final ApiUrl tmdbUpcoming = new ApiUrl(this, BASE_MOVIE, "/upcoming"); + private final ApiUrl tmdbNowPlaying = new ApiUrl(this, BASE_MOVIE, "/now-playing"); + private final ApiUrl tmdbPopularMovieList = new ApiUrl(this, BASE_MOVIE, "/popular"); + private final ApiUrl tmdbTopRatedMovies = new ApiUrl(this, BASE_MOVIE, "/top-rated"); + private final ApiUrl tmdbPostRating = new ApiUrl(this, BASE_MOVIE, "/rating"); + // Collections + private final ApiUrl tmdbCollectionInfo = new ApiUrl(this, BASE_COLLECTION); + private final ApiUrl tmdbCollectionImages = new ApiUrl(this, BASE_COLLECTION, "/images"); + // People private final ApiUrl tmdbPersonInfo = new ApiUrl(this, BASE_PERSON); private final ApiUrl tmdbPersonCredits = new ApiUrl(this, BASE_PERSON, "/credits"); private final ApiUrl tmdbPersonImages = new ApiUrl(this, BASE_PERSON, "/images"); - // Misc Movie - // Movie Add Rating - See issue 9 http://code.google.com/p/themoviedbapi/issues/detail?id=9 - private final ApiUrl tmdbLatestMovie = new ApiUrl(this, "latest/movie"); - private final ApiUrl tmdbNowPlaying = new ApiUrl(this, "movie/now-playing"); - private final ApiUrl tmdbPopularMovieList = new ApiUrl(this, "movie/popular"); - private final ApiUrl tmdbTopRatedMovies = new ApiUrl(this, "movie/top-rated"); - // Company Info + // Companies private final ApiUrl tmdbCompanyInfo = new ApiUrl(this, BASE_COMPANY); private final ApiUrl tmdbCompanyMovies = new ApiUrl(this, BASE_COMPANY, "/movies"); - // Genre Info - private final ApiUrl tmdbGenreList = new ApiUrl(this, "genre/list"); + // Genres + private final ApiUrl tmdbGenreList = new ApiUrl(this, BASE_GENRE, "/list"); private final ApiUrl tmdbGenreMovies = new ApiUrl(this, BASE_GENRE, "/movies"); + // Search + private final ApiUrl tmdbSearchMovie = new ApiUrl(this, "search/movie"); + private final ApiUrl tmdbSearchPeople = new ApiUrl(this, "search/person"); + private final ApiUrl tmdbSearchCompanies = new ApiUrl(this, "search/company"); /* * Jackson JSON configuration @@ -96,11 +115,11 @@ public class TheMovieDb { public TheMovieDb(String apiKey) throws MovieDbException { this.apiKey = apiKey; URL configUrl = tmdbConfigUrl.getQueryUrl(""); - String webPage = WebBrowser.request(configUrl); + String webpage = WebBrowser.request(configUrl); FilteringLayout.addApiKey(apiKey); try { - WrapperConfig wc = mapper.readValue(webPage, WrapperConfig.class); + WrapperConfig wc = mapper.readValue(webpage, WrapperConfig.class); tmdbConfig = wc.getTmdbConfiguration(); } catch (IOException ex) { throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, "Failed to read configuration", ex); @@ -201,9 +220,11 @@ public class TheMovieDb { } /** - * Search Movies This is a good starting point to start finding movies on TMDb. + * Search Movies This is a good starting point to start finding movies on + * TMDb. * - * The idea is to be a quick and light method so you can iterate through movies quickly. + * The idea is to be a quick and light method so you can iterate through + * movies quickly. * * http://help.themoviedb.org/kb/api/search-movies * @@ -218,13 +239,13 @@ public class TheMovieDb { public List searchMovie(String movieName, String language, boolean allResults) throws MovieDbException { URL url = tmdbSearchMovie.getQueryUrl(movieName, language, 1); - String webPage = WebBrowser.request(url); + String webpage = WebBrowser.request(url); try { - WrapperMovie wrapper = mapper.readValue(webPage, WrapperMovie.class); + WrapperMovie wrapper = mapper.readValue(webpage, WrapperMovie.class); return wrapper.getMovies(); } catch (IOException ex) { LOGGER.warn("Failed to find movie: " + ex.getMessage()); - throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage, ex); + throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } @@ -241,12 +262,12 @@ public class TheMovieDb { public MovieDb getMovieInfo(int movieId, String language) throws MovieDbException { URL url = tmdbMovieInfo.getIdUrl(movieId, language); - String webPage = WebBrowser.request(url); + String webpage = WebBrowser.request(url); try { - return mapper.readValue(webPage, MovieDb.class); + return mapper.readValue(webpage, MovieDb.class); } catch (IOException ex) { LOGGER.warn("Failed to get movie info: " + ex.getMessage()); - throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage, ex); + throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } @@ -263,17 +284,18 @@ public class TheMovieDb { public MovieDb getMovieInfoImdb(String imdbId, String language) throws MovieDbException { URL url = tmdbMovieInfo.getIdUrl(imdbId, language); - String webPage = WebBrowser.request(url); + String webpage = WebBrowser.request(url); try { - return mapper.readValue(webPage, MovieDb.class); + return mapper.readValue(webpage, MovieDb.class); } catch (IOException ex) { LOGGER.warn("Failed to get movie info: " + ex.getMessage()); - throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage, ex); + throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } /** - * This method is used to retrieve all of the alternative titles we have for a particular movie. + * This method is used to retrieve all of the alternative titles we have for + * a particular movie. * * @param movieId * @param country @@ -283,13 +305,13 @@ public class TheMovieDb { public List getMovieAlternativeTitles(int movieId, String country) throws MovieDbException { URL url = tmdbMovieAltTitles.getIdUrl(movieId, ApiUrl.DEFAULT_STRING, country); - String webPage = WebBrowser.request(url); + String webpage = WebBrowser.request(url); try { - WrapperAlternativeTitles wrapper = mapper.readValue(webPage, WrapperAlternativeTitles.class); + WrapperAlternativeTitles wrapper = mapper.readValue(webpage, WrapperAlternativeTitles.class); return wrapper.getTitles(); } catch (IOException ex) { LOGGER.warn("Failed to get movie alternative titles: " + ex.getMessage()); - throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage, ex); + throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } @@ -307,9 +329,9 @@ public class TheMovieDb { List people = new ArrayList(); URL url = tmdbMovieCasts.getIdUrl(movieId); - String webPage = WebBrowser.request(url); + String webpage = WebBrowser.request(url); try { - WrapperMovieCasts wrapper = mapper.readValue(webPage, WrapperMovieCasts.class); + WrapperMovieCasts wrapper = mapper.readValue(webpage, WrapperMovieCasts.class); // Add a cast member for (PersonCast cast : wrapper.getCast()) { @@ -328,12 +350,13 @@ public class TheMovieDb { return people; } catch (IOException ex) { LOGGER.warn("Failed to get movie casts: " + ex.getMessage()); - throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage, ex); + throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } /** - * This method should be used when you’re wanting to retrieve all of the images for a particular movie. + * This method should be used when you’re wanting to retrieve all of the + * images for a particular movie. * * @param movieId * @param language @@ -344,9 +367,9 @@ public class TheMovieDb { List artwork = new ArrayList(); URL url = tmdbMovieImages.getIdUrl(movieId, language); - String webPage = WebBrowser.request(url); + String webpage = WebBrowser.request(url); try { - WrapperImages wrapper = mapper.readValue(webPage, WrapperImages.class); + WrapperImages wrapper = mapper.readValue(webpage, WrapperImages.class); // Add all the posters to the list for (Artwork poster : wrapper.getPosters()) { @@ -363,12 +386,13 @@ public class TheMovieDb { return artwork; } catch (IOException ex) { LOGGER.warn("Failed to get movie images: " + ex.getMessage()); - throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage, ex); + throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } /** - * This method is used to retrieve all of the keywords that have been added to a particular movie. + * This method is used to retrieve all of the keywords that have been added + * to a particular movie. * * Currently, only English keywords exist. * @@ -379,19 +403,20 @@ public class TheMovieDb { public List getMovieKeywords(int movieId) throws MovieDbException { URL url = tmdbMovieKeywords.getIdUrl(movieId); - String webPage = WebBrowser.request(url); + String webpage = WebBrowser.request(url); try { - WrapperMovieKeywords wrapper = mapper.readValue(webPage, WrapperMovieKeywords.class); + WrapperMovieKeywords wrapper = mapper.readValue(webpage, WrapperMovieKeywords.class); return wrapper.getKeywords(); } catch (IOException ex) { LOGGER.warn("Failed to get movie keywords: " + ex.getMessage()); - throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage, ex); + throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } /** - * This method is used to retrieve all of the release and certification data we have for a specific movie. + * This method is used to retrieve all of the release and certification data + * we have for a specific movie. * * @param movieId * @param language @@ -401,19 +426,20 @@ public class TheMovieDb { public List getMovieReleaseInfo(int movieId, String language) throws MovieDbException { URL url = tmdbMovieReleaseInfo.getIdUrl(movieId); - String webPage = WebBrowser.request(url); + String webpage = WebBrowser.request(url); try { - WrapperReleaseInfo wrapper = mapper.readValue(webPage, WrapperReleaseInfo.class); + WrapperReleaseInfo wrapper = mapper.readValue(webpage, WrapperReleaseInfo.class); return wrapper.getCountries(); } catch (IOException ex) { LOGGER.warn("Failed to get movie release information: " + ex.getMessage()); - throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage, ex); + throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } /** - * This method is used to retrieve all of the trailers for a particular movie. + * This method is used to retrieve all of the trailers for a particular + * movie. * * Supported sites are YouTube and QuickTime. * @@ -426,10 +452,10 @@ public class TheMovieDb { List trailers = new ArrayList(); URL url = tmdbMovieTrailers.getIdUrl(movieId, language); - String webPage = WebBrowser.request(url); + String webpage = WebBrowser.request(url); try { - WrapperTrailers wrapper = mapper.readValue(webPage, WrapperTrailers.class); + WrapperTrailers wrapper = mapper.readValue(webpage, WrapperTrailers.class); // Add the trailer to the return list along with it's source for (Trailer trailer : wrapper.getQuicktime()) { @@ -444,12 +470,13 @@ public class TheMovieDb { return trailers; } catch (IOException ex) { LOGGER.warn("Failed to get movie trailers: " + ex.getMessage()); - throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage, ex); + throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } /** - * This method is used to retrieve a list of the available translations for a specific movie. + * This method is used to retrieve a list of the available translations for + * a specific movie. * * @param movieId * @return @@ -458,21 +485,23 @@ public class TheMovieDb { public List getMovieTranslations(int movieId) throws MovieDbException { URL url = tmdbMovieTranslations.getIdUrl(movieId); - String webPage = WebBrowser.request(url); + String webpage = WebBrowser.request(url); try { - WrapperTranslations wrapper = mapper.readValue(webPage, WrapperTranslations.class); + WrapperTranslations wrapper = mapper.readValue(webpage, WrapperTranslations.class); return wrapper.getTranslations(); } catch (IOException ex) { LOGGER.warn("Failed to get movie tranlations: " + ex.getMessage()); - throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage, ex); + throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } /** - * This method is used to retrieve all of the basic information about a movie collection. + * This method is used to retrieve all of the basic information about a + * movie collection. * - * You can get the ID needed for this method by making a getMovieInfo request for the belongs_to_collection. + * You can get the ID needed for this method by making a getMovieInfo + * request for the belongs_to_collection. * * @param movieId * @param language @@ -482,13 +511,13 @@ public class TheMovieDb { public CollectionInfo getCollectionInfo(int movieId, String language) throws MovieDbException { URL url = tmdbCollectionInfo.getIdUrl(movieId); - String webPage = WebBrowser.request(url); + String webpage = WebBrowser.request(url); try { - return mapper.readValue(webPage, CollectionInfo.class); + return mapper.readValue(webpage, CollectionInfo.class); } catch (IOException ex) { LOGGER.warn("Failed to get movie tranlations: " + ex.getMessage()); - throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage, ex); + throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } @@ -528,7 +557,8 @@ public class TheMovieDb { /** * This is a good starting point to start finding people on TMDb. * - * The idea is to be a quick and light method so you can iterate through people quickly. + * The idea is to be a quick and light method so you can iterate through + * people quickly. * * TODO: Fix allResults * @@ -540,14 +570,14 @@ public class TheMovieDb { public List searchPeople(String personName, boolean allResults) throws MovieDbException { URL url = tmdbSearchPeople.getQueryUrl(personName, "", 1); - String webPage = WebBrowser.request(url); + String webpage = WebBrowser.request(url); try { - WrapperPerson wrapper = mapper.readValue(webPage, WrapperPerson.class); + WrapperPerson wrapper = mapper.readValue(webpage, WrapperPerson.class); return wrapper.getResults(); } catch (IOException ex) { LOGGER.warn("Failed to find person: " + ex.getMessage()); - throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage, ex); + throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } @@ -563,18 +593,19 @@ public class TheMovieDb { public Person getPersonInfo(int personId) throws MovieDbException { URL url = tmdbPersonInfo.getIdUrl(personId); - String webPage = WebBrowser.request(url); + String webpage = WebBrowser.request(url); try { - return mapper.readValue(webPage, Person.class); + return mapper.readValue(webpage, Person.class); } catch (IOException ex) { LOGGER.warn("Failed to get movie info: " + ex.getMessage()); - throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage, ex); + throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } /** - * This method is used to retrieve all of the cast & crew information for the person. + * This method is used to retrieve all of the cast & crew information for + * the person. * * It will return the single highest rated poster for each movie record. * @@ -587,10 +618,10 @@ public class TheMovieDb { List personCredits = new ArrayList(); URL url = tmdbPersonCredits.getIdUrl(personId); - String webPage = WebBrowser.request(url); + String webpage = WebBrowser.request(url); try { - WrapperPersonCredits wrapper = mapper.readValue(webPage, WrapperPersonCredits.class); + WrapperPersonCredits wrapper = mapper.readValue(webpage, WrapperPersonCredits.class); // Add a cast member for (PersonCredit cast : wrapper.getCast()) { @@ -605,7 +636,7 @@ public class TheMovieDb { return personCredits; } catch (IOException ex) { LOGGER.warn("Failed to get person credits: " + ex.getMessage()); - throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage, ex); + throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } @@ -621,10 +652,10 @@ public class TheMovieDb { List personImages = new ArrayList(); URL url = tmdbPersonImages.getIdUrl(personId); - String webPage = WebBrowser.request(url); + String webpage = WebBrowser.request(url); try { - WrapperImages wrapper = mapper.readValue(webPage, WrapperImages.class); + WrapperImages wrapper = mapper.readValue(webpage, WrapperImages.class); // Update the image type for (Artwork artwork : wrapper.getProfiles()) { @@ -634,7 +665,7 @@ public class TheMovieDb { return personImages; } catch (IOException ex) { LOGGER.warn("Failed to get person images: " + ex.getMessage()); - throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage, ex); + throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } @@ -646,20 +677,45 @@ public class TheMovieDb { public MovieDb getLatestMovie() throws MovieDbException { URL url = tmdbLatestMovie.getIdUrl(""); - String webPage = WebBrowser.request(url); + String webpage = WebBrowser.request(url); try { - return mapper.readValue(webPage, MovieDb.class); + return mapper.readValue(webpage, MovieDb.class); } catch (IOException ex) { LOGGER.warn("Failed to get latest movie: " + ex.getMessage()); - throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage, ex); + throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } + /** + * Get the list of upcoming movies. + * + * This list refreshes every day. + * + * The maximum number of items this list will include is 100. + * + * @return + * @throws MovieDbException + */ + public List getUpcoming(String language) throws MovieDbException { + URL url = tmdbUpcoming.getIdUrl("", language); + String webpage = WebBrowser.request(url); + + try { + WrapperMovie wrapper = mapper.readValue(webpage, WrapperMovie.class); + return wrapper.getMovies(); + } catch (IOException ex) { + LOGGER.warn("Failed to get upcoming movies: " + ex.getMessage()); + throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); + } + + } + /** * This method is used to retrieve the movies currently in theatres. * - * This is a curated list that will normally contain 100 movies. The default response will return 20 movies. + * This is a curated list that will normally contain 100 movies. The default + * response will return 20 movies. * * TODO: Implement more than 20 movies * @@ -670,14 +726,14 @@ public class TheMovieDb { */ public List getNowPlayingMovies(String language, boolean allResults) throws MovieDbException { URL url = tmdbNowPlaying.getIdUrl("", language); - String webPage = WebBrowser.request(url); + String webpage = WebBrowser.request(url); try { - WrapperMovie wrapper = mapper.readValue(webPage, WrapperMovie.class); + WrapperMovie wrapper = mapper.readValue(webpage, WrapperMovie.class); return wrapper.getMovies(); } catch (IOException ex) { LOGGER.warn("Failed to get now playing movies: " + ex.getMessage()); - throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage, ex); + throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } @@ -695,19 +751,20 @@ public class TheMovieDb { */ public List getPopularMovieList(String language, boolean allResults) throws MovieDbException { URL url = tmdbPopularMovieList.getIdUrl("", language); - String webPage = WebBrowser.request(url); + String webpage = WebBrowser.request(url); try { - WrapperMovie wrapper = mapper.readValue(webPage, WrapperMovie.class); + WrapperMovie wrapper = mapper.readValue(webpage, WrapperMovie.class); return wrapper.getMovies(); } catch (IOException ex) { LOGGER.warn("Failed to get popular movie list: " + ex.getMessage()); - throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage, ex); + throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } /** - * This method is used to retrieve the top rated movies that have over 10 votes on TMDb. + * This method is used to retrieve the top rated movies that have over 10 + * votes on TMDb. * * The default response will return 20 movies. * @@ -720,19 +777,20 @@ public class TheMovieDb { */ public List getTopRatedMovies(String language, boolean allResults) throws MovieDbException { URL url = tmdbTopRatedMovies.getIdUrl("", language); - String webPage = WebBrowser.request(url); + String webpage = WebBrowser.request(url); try { - WrapperMovie wrapper = mapper.readValue(webPage, WrapperMovie.class); + WrapperMovie wrapper = mapper.readValue(webpage, WrapperMovie.class); return wrapper.getMovies(); } catch (IOException ex) { LOGGER.warn("Failed to get top rated movies: " + ex.getMessage()); - throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage, ex); + throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } /** - * This method is used to retrieve the basic information about a production company on TMDb. + * This method is used to retrieve the basic information about a production + * company on TMDb. * * @param companyId * @return @@ -740,21 +798,21 @@ public class TheMovieDb { */ public Company getCompanyInfo(int companyId) throws MovieDbException { URL url = tmdbCompanyInfo.getIdUrl(companyId); - String webPage = WebBrowser.request(url); + String webpage = WebBrowser.request(url); try { - return mapper.readValue(webPage, Company.class); + return mapper.readValue(webpage, Company.class); } catch (IOException ex) { LOGGER.warn("Failed to get company information: " + ex.getMessage()); - throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage, ex); + throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } /** * This method is used to retrieve the movies associated with a company. * - * These movies are returned in order of most recently released to oldest. The default response will return 20 - * movies per page. + * These movies are returned in order of most recently released to oldest. + * The default response will return 20 movies per page. * * TODO: Implement more than 20 movies * @@ -766,22 +824,22 @@ public class TheMovieDb { */ public List getCompanyMovies(int companyId, String language, boolean allResults) throws MovieDbException { URL url = tmdbCompanyMovies.getIdUrl(companyId, language); - String webPage = WebBrowser.request(url); + String webpage = WebBrowser.request(url); try { - WrapperCompanyMovies wrapper = mapper.readValue(webPage, WrapperCompanyMovies.class); + WrapperCompanyMovies wrapper = mapper.readValue(webpage, WrapperCompanyMovies.class); return wrapper.getResults(); } catch (IOException ex) { LOGGER.warn("Failed to get company movies: " + ex.getMessage()); - throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage, ex); + throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } /** * Search Companies. * - * You can use this method to search for production companies that are part of TMDb. The company IDs will map to - * those returned on movie calls. + * You can use this method to search for production companies that are part + * of TMDb. The company IDs will map to those returned on movie calls. * * http://help.themoviedb.org/kb/api/search-companies * @@ -796,20 +854,22 @@ public class TheMovieDb { public List searchCompanies(String companyName, String language, boolean allResults) throws MovieDbException { URL url = tmdbSearchCompanies.getQueryUrl(companyName, language, 1); - String webPage = WebBrowser.request(url); + String webpage = WebBrowser.request(url); try { - WrapperCompany wrapper = mapper.readValue(webPage, WrapperCompany.class); + WrapperCompany wrapper = mapper.readValue(webpage, WrapperCompany.class); return wrapper.getResults(); } catch (IOException ex) { LOGGER.warn("Failed to find company: " + ex.getMessage()); - throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage, ex); + throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } /** - * The similar movies method will let you retrieve the similar movies for a particular movie. + * The similar movies method will let you retrieve the similar movies for a + * particular movie. * - * This data is created dynamically but with the help of users votes on TMDb. + * This data is created dynamically but with the help of users votes on + * TMDb. * * The data is much better with movies that have more keywords * @@ -822,14 +882,14 @@ public class TheMovieDb { public List getSimilarMovies(int movieId, String language, boolean allResults) throws MovieDbException { URL url = tmdbMovieSimilarMovies.getIdUrl(movieId, language); - String webPage = WebBrowser.request(url); + String webpage = WebBrowser.request(url); try { - WrapperMovie wrapper = mapper.readValue(webPage, WrapperMovie.class); + WrapperMovie wrapper = mapper.readValue(webpage, WrapperMovie.class); return wrapper.getMovies(); } catch (IOException ex) { LOGGER.warn("Failed to get similar movies: " + ex.getMessage()); - throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage, ex); + throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } @@ -843,23 +903,25 @@ public class TheMovieDb { */ public List getGenreList(String language) throws MovieDbException { URL url = tmdbGenreList.getQueryUrl("", language); - String webPage = WebBrowser.request(url); + String webpage = WebBrowser.request(url); try { - WrapperGenres wrapper = mapper.readValue(webPage, WrapperGenres.class); + WrapperGenres wrapper = mapper.readValue(webpage, WrapperGenres.class); return wrapper.getGenres(); } catch (IOException ex) { LOGGER.warn("Failed to get genre list: " + ex.getMessage()); - throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage, ex); + throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } /** * Get a list of movies per genre. * - * It is important to understand that only movies with more than 10 votes get listed. + * It is important to understand that only movies with more than 10 votes + * get listed. * - * This prevents movies from 1 10/10 rating from being listed first and for the first 5 pages. + * This prevents movies from 1 10/10 rating from being listed first and for + * the first 5 pages. * * @param genreId * @param language @@ -868,14 +930,14 @@ public class TheMovieDb { */ public List getGenreMovies(int genreId, String language, boolean allResults) throws MovieDbException { URL url = tmdbGenreMovies.getIdUrl(genreId, language); - String webPage = WebBrowser.request(url); + String webpage = WebBrowser.request(url); try { - WrapperMovie wrapper = mapper.readValue(webPage, WrapperMovie.class); + WrapperMovie wrapper = mapper.readValue(webpage, WrapperMovie.class); return wrapper.getMovies(); } catch (IOException ex) { LOGGER.warn("Failed to get genre movie list: " + ex.getMessage()); - throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webPage, ex); + throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } } From ac0aa98a05364cf8bb9a60b39fe0e9b2367e22c7 Mon Sep 17 00:00:00 2001 From: Omertron Date: Wed, 26 Sep 2012 11:52:01 +0000 Subject: [PATCH 145/207] Added Token models Update keyword model --- .../themoviedb/model/Keyword.java | 1 - .../themoviedb/model/TokenAuthorisation.java | 81 +++++++++++++++++ .../themoviedb/model/TokenSession.java | 91 +++++++++++++++++++ 3 files changed, 172 insertions(+), 1 deletion(-) create mode 100644 themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/TokenAuthorisation.java create mode 100644 themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/TokenSession.java diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Keyword.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Keyword.java index 73122cd9d..93422debc 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Keyword.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Keyword.java @@ -13,7 +13,6 @@ package com.moviejukebox.themoviedb.model; import java.io.Serializable; -import javax.imageio.spi.ServiceRegistry; import org.apache.log4j.Logger; import org.codehaus.jackson.annotate.JsonAnySetter; import org.codehaus.jackson.annotate.JsonProperty; diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/TokenAuthorisation.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/TokenAuthorisation.java new file mode 100644 index 000000000..07543972f --- /dev/null +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/TokenAuthorisation.java @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2004-2012 YAMJ Members + * http://code.google.com/p/moviejukebox/people/list + * + * Web: http://code.google.com/p/moviejukebox/ + * + * This software is licensed under a Creative Commons License + * See this page: http://code.google.com/p/moviejukebox/wiki/License + * + * For any reuse or distribution, you must make clear to others the + * license terms of this work. + */ +package com.moviejukebox.themoviedb.model; + +import org.apache.log4j.Logger; +import org.codehaus.jackson.annotate.JsonAnySetter; +import org.codehaus.jackson.annotate.JsonProperty; + +public class TokenAuthorisation { + /* + * Logger + */ + private static final Logger LOGGER = Logger.getLogger(TokenAuthorisation.class); + /* + * Properties + */ + @JsonProperty("expires_at") + private String expires; + @JsonProperty("request_token") + private String requestToken; + @JsonProperty("success") + private Boolean success; + + // + public String getExpires() { + return expires; + } + + public String getRequestToken() { + return requestToken; + } + + public Boolean getSuccess() { + return success; + } + // + + // + public void setExpires(String expires) { + this.expires = expires; + } + + public void setRequestToken(String requestToken) { + this.requestToken = requestToken; + } + + public void setSuccess(Boolean success) { + this.success = success; + } + // + + /** + * Handle unknown properties and print a message + * + * @param key + * @param value + */ + @JsonAnySetter + public void handleUnknown(String key, Object value) { + StringBuilder sb = new StringBuilder(); + sb.append("Unknown property: '").append(key); + sb.append("' value: '").append(value).append("'"); + LOGGER.warn(sb.toString()); + } + + @Override + public String toString() { + return "TokenAuthorisation{" + "expires=" + expires + ", requestToken=" + requestToken + ", success=" + success + '}'; + } + +} diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/TokenSession.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/TokenSession.java new file mode 100644 index 000000000..1e6ff9b1b --- /dev/null +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/TokenSession.java @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2004-2012 YAMJ Members + * http://code.google.com/p/moviejukebox/people/list + * + * Web: http://code.google.com/p/moviejukebox/ + * + * This software is licensed under a Creative Commons License + * See this page: http://code.google.com/p/moviejukebox/wiki/License + * + * For any reuse or distribution, you must make clear to others the + * license terms of this work. + */ +package com.moviejukebox.themoviedb.model; + +import org.apache.log4j.Logger; +import org.codehaus.jackson.annotate.JsonAnySetter; +import org.codehaus.jackson.annotate.JsonProperty; + +public class TokenSession { + /* + * Logger + */ + private static final Logger LOGGER = Logger.getLogger(TokenSession.class); + /* + * Properties + */ + @JsonProperty("session_id") + private String sessionId; + @JsonProperty("success") + private Boolean success; + @JsonProperty("status_code") + private String statusCode; + @JsonProperty("status_message") + private String statusMessage; + + // + public String getSessionId() { + return sessionId; + } + + public Boolean getSuccess() { + return success; + } + + public String getStatusCode() { + return statusCode; + } + + public String getStatusMessage() { + return statusMessage; + } + // + + // + public void setSessionId(String sessionId) { + this.sessionId = sessionId; + } + + public void setSuccess(Boolean success) { + this.success = success; + } + + public void setStatusCode(String statusCode) { + this.statusCode = statusCode; + } + + public void setStatusMessage(String statusMessage) { + this.statusMessage = statusMessage; + } + // + + /** + * Handle unknown properties and print a message + * + * @param key + * @param value + */ + @JsonAnySetter + public void handleUnknown(String key, Object value) { + StringBuilder sb = new StringBuilder(); + sb.append("Unknown property: '").append(key); + sb.append("' value: '").append(value).append("'"); + LOGGER.warn(sb.toString()); + } + + @Override + public String toString() { + return "TokenSession{" + "sessionId=" + sessionId + ", success=" + success + ", statusCode=" + statusCode + ", statusMessage=" + statusMessage + '}'; + } + +} From 658d39cefb3c65112e8553beee3f46dd0cda29e5 Mon Sep 17 00:00:00 2001 From: Omertron Date: Wed, 26 Sep 2012 19:33:21 +0000 Subject: [PATCH 146/207] Updated methods with new TheMovieDb functionality --- .../themoviedb/MovieDbException.java | 6 +- .../moviejukebox/themoviedb/TheMovieDb.java | 1459 +++++++++++------ .../moviejukebox/themoviedb/tools/ApiUrl.java | 205 +-- .../themoviedb/tools/FilteringLayout.java | 23 +- .../themoviedb/TheMovieDbTest.java | 85 +- 5 files changed, 1111 insertions(+), 667 deletions(-) diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/MovieDbException.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/MovieDbException.java index f57b7c169..e48762399 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/MovieDbException.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/MovieDbException.java @@ -5,9 +5,9 @@ public class MovieDbException extends Exception { private static final long serialVersionUID = -8952129102483143278L; public enum MovieDbExceptionType { - UNKNOWN_CAUSE, INVALID_URL, HTTP_404_ERROR, MOVIE_ID_NOT_FOUND, MAPPING_FAILED, CONNECTION_ERROR, INVALID_IMAGE; + UNKNOWN_CAUSE, INVALID_URL, HTTP_404_ERROR, MOVIE_ID_NOT_FOUND, MAPPING_FAILED, CONNECTION_ERROR, INVALID_IMAGE, AUTHORISATION_FAILURE; } - + private final MovieDbExceptionType exceptionType; private final String response; @@ -22,7 +22,7 @@ public class MovieDbException extends Exception { this.exceptionType = exceptionType; this.response = response; } - + public MovieDbExceptionType getExceptionType() { return exceptionType; } diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java index fe6a21e86..2cab9faa7 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java @@ -30,8 +30,7 @@ import org.codehaus.jackson.map.ObjectMapper; /** * The MovieDb API * - * This is for version 3 of the API as specified here: - * http://help.themoviedb.org/kb/api/about-3 + * This is for version 3 of the API as specified here: http://help.themoviedb.org/kb/api/about-3 * * @author stuart.boston */ @@ -55,11 +54,12 @@ public class TheMovieDb { private static final String BASE_AUTH = "authentication/"; private static final String BASE_COLLECTION = "collection/"; private static final String BASE_ACCOUNT = "account/"; + private static final String BASE_SEARCH = "search/"; // Configuration private final ApiUrl tmdbConfigUrl = new ApiUrl(this, "configuration"); // Authentication - private final ApiUrl tmdbAuthToken = new ApiUrl(this, BASE_AUTH, "token/new"); - private final ApiUrl tmdbAuthSession = new ApiUrl(this, BASE_AUTH, "session/new"); + private final ApiUrl tmdbAuthorisationToken = new ApiUrl(this, BASE_AUTH, "token/new"); + private final ApiUrl tmdbAuthorisationSession = new ApiUrl(this, BASE_AUTH, "session/new"); // Account private final ApiUrl tmdbAccount = new ApiUrl(this, BASE_ACCOUNT); private final ApiUrl tmdbFavouriteMovies = new ApiUrl(this, BASE_ACCOUNT, "/favorite_movies"); @@ -78,10 +78,10 @@ public class TheMovieDb { private final ApiUrl tmdbMovieTranslations = new ApiUrl(this, BASE_MOVIE, "/translations"); private final ApiUrl tmdbMovieSimilarMovies = new ApiUrl(this, BASE_MOVIE, "/similar_movies"); private final ApiUrl tmdbLatestMovie = new ApiUrl(this, BASE_MOVIE, "/latest"); - private final ApiUrl tmdbUpcoming = new ApiUrl(this, BASE_MOVIE, "/upcoming"); - private final ApiUrl tmdbNowPlaying = new ApiUrl(this, BASE_MOVIE, "/now-playing"); - private final ApiUrl tmdbPopularMovieList = new ApiUrl(this, BASE_MOVIE, "/popular"); - private final ApiUrl tmdbTopRatedMovies = new ApiUrl(this, BASE_MOVIE, "/top-rated"); + private final ApiUrl tmdbUpcoming = new ApiUrl(this, BASE_MOVIE, "upcoming"); + private final ApiUrl tmdbNowPlaying = new ApiUrl(this, BASE_MOVIE, "now-playing"); + private final ApiUrl tmdbPopularMovieList = new ApiUrl(this, BASE_MOVIE, "popular"); + private final ApiUrl tmdbTopRatedMovies = new ApiUrl(this, BASE_MOVIE, "top-rated"); private final ApiUrl tmdbPostRating = new ApiUrl(this, BASE_MOVIE, "/rating"); // Collections private final ApiUrl tmdbCollectionInfo = new ApiUrl(this, BASE_COLLECTION); @@ -97,9 +97,9 @@ public class TheMovieDb { private final ApiUrl tmdbGenreList = new ApiUrl(this, BASE_GENRE, "/list"); private final ApiUrl tmdbGenreMovies = new ApiUrl(this, BASE_GENRE, "/movies"); // Search - private final ApiUrl tmdbSearchMovie = new ApiUrl(this, "search/movie"); - private final ApiUrl tmdbSearchPeople = new ApiUrl(this, "search/person"); - private final ApiUrl tmdbSearchCompanies = new ApiUrl(this, "search/company"); + private final ApiUrl tmdbSearchMovie = new ApiUrl(this, BASE_SEARCH, "movie"); + private final ApiUrl tmdbSearchPeople = new ApiUrl(this, BASE_SEARCH, "person"); + private final ApiUrl tmdbSearchCompanies = new ApiUrl(this, BASE_SEARCH, "company"); /* * Jackson JSON configuration @@ -114,9 +114,9 @@ public class TheMovieDb { */ public TheMovieDb(String apiKey) throws MovieDbException { this.apiKey = apiKey; - URL configUrl = tmdbConfigUrl.getQueryUrl(""); + URL configUrl = tmdbConfigUrl.buildUrl(); String webpage = WebBrowser.request(configUrl); - FilteringLayout.addApiKey(apiKey); + FilteringLayout.addReplacementString(apiKey); try { WrapperConfig wc = mapper.readValue(webpage, WrapperConfig.class); @@ -219,308 +219,7 @@ public class TheMovieDb { return false; } - /** - * Search Movies This is a good starting point to start finding movies on - * TMDb. - * - * The idea is to be a quick and light method so you can iterate through - * movies quickly. - * - * http://help.themoviedb.org/kb/api/search-movies - * - * TODO: Make the allResults work - * - * @param movieName - * @param language - * @param allResults - * @return - * @throws MovieDbException - */ - public List searchMovie(String movieName, String language, boolean allResults) throws MovieDbException { - - URL url = tmdbSearchMovie.getQueryUrl(movieName, language, 1); - String webpage = WebBrowser.request(url); - try { - WrapperMovie wrapper = mapper.readValue(webpage, WrapperMovie.class); - return wrapper.getMovies(); - } catch (IOException ex) { - LOGGER.warn("Failed to find movie: " + ex.getMessage()); - throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); - } - } - - /** - * This method is used to retrieve all of the basic movie information. - * - * It will return the single highest rated poster and backdrop. - * - * @param movieId - * @param language - * @return - * @throws MovieDbException - */ - public MovieDb getMovieInfo(int movieId, String language) throws MovieDbException { - - URL url = tmdbMovieInfo.getIdUrl(movieId, language); - String webpage = WebBrowser.request(url); - try { - return mapper.readValue(webpage, MovieDb.class); - } catch (IOException ex) { - LOGGER.warn("Failed to get movie info: " + ex.getMessage()); - throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); - } - } - - /** - * This method is used to retrieve all of the basic movie information. - * - * It will return the single highest rated poster and backdrop. - * - * @param imdbId - * @param language - * @return - * @throws MovieDbException - */ - public MovieDb getMovieInfoImdb(String imdbId, String language) throws MovieDbException { - - URL url = tmdbMovieInfo.getIdUrl(imdbId, language); - String webpage = WebBrowser.request(url); - try { - return mapper.readValue(webpage, MovieDb.class); - } catch (IOException ex) { - LOGGER.warn("Failed to get movie info: " + ex.getMessage()); - throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); - } - } - - /** - * This method is used to retrieve all of the alternative titles we have for - * a particular movie. - * - * @param movieId - * @param country - * @return - * @throws MovieDbException - */ - public List getMovieAlternativeTitles(int movieId, String country) throws MovieDbException { - - URL url = tmdbMovieAltTitles.getIdUrl(movieId, ApiUrl.DEFAULT_STRING, country); - String webpage = WebBrowser.request(url); - try { - WrapperAlternativeTitles wrapper = mapper.readValue(webpage, WrapperAlternativeTitles.class); - return wrapper.getTitles(); - } catch (IOException ex) { - LOGGER.warn("Failed to get movie alternative titles: " + ex.getMessage()); - throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); - } - } - - /** - * This method is used to retrieve all of the movie cast information. - * - * TODO: Add a function to enrich the data with the people methods - * - * @param movieId - * @return - * @throws MovieDbException - */ - public List getMovieCasts(int movieId) throws MovieDbException { - - List people = new ArrayList(); - - URL url = tmdbMovieCasts.getIdUrl(movieId); - String webpage = WebBrowser.request(url); - try { - WrapperMovieCasts wrapper = mapper.readValue(webpage, WrapperMovieCasts.class); - - // Add a cast member - for (PersonCast cast : wrapper.getCast()) { - Person person = new Person(); - person.addCast(cast.getId(), cast.getName(), cast.getProfilePath(), cast.getCharacter(), cast.getOrder()); - people.add(person); - } - - // Add a crew member - for (PersonCrew crew : wrapper.getCrew()) { - Person person = new Person(); - person.addCrew(crew.getId(), crew.getName(), crew.getProfilePath(), crew.getDepartment(), crew.getJob()); - people.add(person); - } - - return people; - } catch (IOException ex) { - LOGGER.warn("Failed to get movie casts: " + ex.getMessage()); - throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); - } - } - - /** - * This method should be used when you’re wanting to retrieve all of the - * images for a particular movie. - * - * @param movieId - * @param language - * @return - * @throws MovieDbException - */ - public List getMovieImages(int movieId, String language) throws MovieDbException { - - List artwork = new ArrayList(); - URL url = tmdbMovieImages.getIdUrl(movieId, language); - String webpage = WebBrowser.request(url); - try { - WrapperImages wrapper = mapper.readValue(webpage, WrapperImages.class); - - // Add all the posters to the list - for (Artwork poster : wrapper.getPosters()) { - poster.setArtworkType(ArtworkType.POSTER); - artwork.add(poster); - } - - // Add all the backdrops to the list - for (Artwork backdrop : wrapper.getBackdrops()) { - backdrop.setArtworkType(ArtworkType.BACKDROP); - artwork.add(backdrop); - } - - return artwork; - } catch (IOException ex) { - LOGGER.warn("Failed to get movie images: " + ex.getMessage()); - throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); - } - } - - /** - * This method is used to retrieve all of the keywords that have been added - * to a particular movie. - * - * Currently, only English keywords exist. - * - * @param movieId - * @return - * @throws MovieDbException - */ - public List getMovieKeywords(int movieId) throws MovieDbException { - - URL url = tmdbMovieKeywords.getIdUrl(movieId); - String webpage = WebBrowser.request(url); - - try { - WrapperMovieKeywords wrapper = mapper.readValue(webpage, WrapperMovieKeywords.class); - return wrapper.getKeywords(); - } catch (IOException ex) { - LOGGER.warn("Failed to get movie keywords: " + ex.getMessage()); - throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); - } - } - - /** - * This method is used to retrieve all of the release and certification data - * we have for a specific movie. - * - * @param movieId - * @param language - * @return - * @throws MovieDbException - */ - public List getMovieReleaseInfo(int movieId, String language) throws MovieDbException { - - URL url = tmdbMovieReleaseInfo.getIdUrl(movieId); - String webpage = WebBrowser.request(url); - - try { - WrapperReleaseInfo wrapper = mapper.readValue(webpage, WrapperReleaseInfo.class); - return wrapper.getCountries(); - } catch (IOException ex) { - LOGGER.warn("Failed to get movie release information: " + ex.getMessage()); - throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); - } - } - - /** - * This method is used to retrieve all of the trailers for a particular - * movie. - * - * Supported sites are YouTube and QuickTime. - * - * @param movieId - * @param language - * @return - * @throws MovieDbException - */ - public List getMovieTrailers(int movieId, String language) throws MovieDbException { - - List trailers = new ArrayList(); - URL url = tmdbMovieTrailers.getIdUrl(movieId, language); - String webpage = WebBrowser.request(url); - - try { - WrapperTrailers wrapper = mapper.readValue(webpage, WrapperTrailers.class); - - // Add the trailer to the return list along with it's source - for (Trailer trailer : wrapper.getQuicktime()) { - trailer.setWebsite(Trailer.WEBSITE_QUICKTIME); - trailers.add(trailer); - } - // Add the trailer to the return list along with it's source - for (Trailer trailer : wrapper.getYoutube()) { - trailer.setWebsite(Trailer.WEBSITE_YOUTUBE); - trailers.add(trailer); - } - return trailers; - } catch (IOException ex) { - LOGGER.warn("Failed to get movie trailers: " + ex.getMessage()); - throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); - } - } - - /** - * This method is used to retrieve a list of the available translations for - * a specific movie. - * - * @param movieId - * @return - * @throws MovieDbException - */ - public List getMovieTranslations(int movieId) throws MovieDbException { - - URL url = tmdbMovieTranslations.getIdUrl(movieId); - String webpage = WebBrowser.request(url); - - try { - WrapperTranslations wrapper = mapper.readValue(webpage, WrapperTranslations.class); - return wrapper.getTranslations(); - } catch (IOException ex) { - LOGGER.warn("Failed to get movie tranlations: " + ex.getMessage()); - throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); - } - } - - /** - * This method is used to retrieve all of the basic information about a - * movie collection. - * - * You can get the ID needed for this method by making a getMovieInfo - * request for the belongs_to_collection. - * - * @param movieId - * @param language - * @return - * @throws MovieDbException - */ - public CollectionInfo getCollectionInfo(int movieId, String language) throws MovieDbException { - - URL url = tmdbCollectionInfo.getIdUrl(movieId); - String webpage = WebBrowser.request(url); - - try { - return mapper.readValue(webpage, CollectionInfo.class); - } catch (IOException ex) { - LOGGER.warn("Failed to get movie tranlations: " + ex.getMessage()); - throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); - } - } - + // /** * Get the configuration information * @@ -554,33 +253,626 @@ public class TheMovieDb { } } + // + // + // /** - * This is a good starting point to start finding people on TMDb. + * This method is used to generate a valid request token for user based authentication. * - * The idea is to be a quick and light method so you can iterate through - * people quickly. + * A request token is required in order to request a session id. * - * TODO: Fix allResults + * You can generate any number of request tokens but they will expire after 60 minutes. + * + * As soon as a valid session id has been created the token will be destroyed. * - * @param personName - * @param allResults * @return * @throws MovieDbException */ - public List searchPeople(String personName, boolean allResults) throws MovieDbException { - - URL url = tmdbSearchPeople.getQueryUrl(personName, "", 1); + public TokenAuthorisation getAuthorisationToken() throws MovieDbException { + URL url = tmdbAuthorisationToken.buildUrl(); String webpage = WebBrowser.request(url); try { - WrapperPerson wrapper = mapper.readValue(webpage, WrapperPerson.class); - return wrapper.getResults(); + return mapper.readValue(webpage, TokenAuthorisation.class); } catch (IOException ex) { - LOGGER.warn("Failed to find person: " + ex.getMessage()); + LOGGER.warn("Failed to get Authorisation Token: " + ex.getMessage()); + throw new MovieDbException(MovieDbExceptionType.AUTHORISATION_FAILURE, webpage, ex); + } + } + + /** + * This method is used to generate a session id for user based authentication. + * + * A session id is required in order to use any of the write methods. + * + * @param token + * @return + * @throws MovieDbException + */ + public TokenSession getSessionToken(TokenAuthorisation token) throws MovieDbException { + if (!token.getSuccess()) { + LOGGER.warn("Authorisation token was not successful!"); + throw new MovieDbException(MovieDbExceptionType.AUTHORISATION_FAILURE, "Authorisation token was not successful!"); + } + + tmdbAuthorisationSession.addArgument(ApiUrl.PARAM_TOKEN, token.getRequestToken()); + URL url = tmdbAuthorisationSession.buildUrl(); + String webpage = WebBrowser.request(url); + + try { + return mapper.readValue(webpage, TokenSession.class); + } catch (IOException ex) { + LOGGER.warn("Failed to get Session Token: " + ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } + // + // + // + // + // + // + /** + * This method is used to retrieve all of the basic movie information. + * + * It will return the single highest rated poster and backdrop. + * + * @param movieId + * @param language + * @return + * @throws MovieDbException + */ + public MovieDb getMovieInfo(int movieId, String language) throws MovieDbException { + + tmdbMovieInfo.addArgument(ApiUrl.PARAM_ID, movieId); + + if (StringUtils.isNotBlank(language)) { + tmdbMovieInfo.addArgument(ApiUrl.PARAM_LANGUAGE, language); + } + + URL url = tmdbMovieInfo.buildUrl(); + String webpage = WebBrowser.request(url); + try { + return mapper.readValue(webpage, MovieDb.class); + } catch (IOException ex) { + LOGGER.warn("Failed to get movie info: " + ex.getMessage()); + throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); + } + } + + /** + * This method is used to retrieve all of the basic movie information. + * + * It will return the single highest rated poster and backdrop. + * + * @param imdbId + * @param language + * @return + * @throws MovieDbException + */ + public MovieDb getMovieInfoImdb(String imdbId, String language) throws MovieDbException { + + tmdbMovieInfo.addArgument(ApiUrl.PARAM_ID, imdbId); + + if (StringUtils.isNotBlank(language)) { + tmdbMovieInfo.addArgument(ApiUrl.PARAM_LANGUAGE, language); + } + + URL url = tmdbMovieInfo.buildUrl(); + String webpage = WebBrowser.request(url); + try { + return mapper.readValue(webpage, MovieDb.class); + } catch (IOException ex) { + LOGGER.warn("Failed to get movie info: " + ex.getMessage()); + throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); + } + } + + /** + * This method is used to retrieve all of the alternative titles we have for a particular movie. + * + * @param movieId + * @param country + * @return + * @throws MovieDbException + */ + public List getMovieAlternativeTitles(int movieId, String country) throws MovieDbException { + tmdbMovieAltTitles.addArgument(ApiUrl.PARAM_ID, movieId); + + if (StringUtils.isNotBlank(country)) { + tmdbMovieAltTitles.addArgument(ApiUrl.PARAM_COUNTRY, country); + } + + URL url = tmdbMovieAltTitles.buildUrl(); + String webpage = WebBrowser.request(url); + try { + WrapperAlternativeTitles wrapper = mapper.readValue(webpage, WrapperAlternativeTitles.class); + return wrapper.getTitles(); + } catch (IOException ex) { + LOGGER.warn("Failed to get movie alternative titles: " + ex.getMessage()); + throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); + } + } + + /** + * Get the cast information for a specific movie id. + * + * TODO: Add a function to enrich the data with the people methods + * + * @param movieId + * @return + * @throws MovieDbException + */ + public List getMovieCasts(int movieId) throws MovieDbException { + List people = new ArrayList(); + + tmdbMovieCasts.addArgument(ApiUrl.PARAM_ID, movieId); + URL url = tmdbMovieCasts.buildUrl(); + String webpage = WebBrowser.request(url); + + try { + WrapperMovieCasts wrapper = mapper.readValue(webpage, WrapperMovieCasts.class); + + // Add a cast member + for (PersonCast cast : wrapper.getCast()) { + Person person = new Person(); + person.addCast(cast.getId(), cast.getName(), cast.getProfilePath(), cast.getCharacter(), cast.getOrder()); + people.add(person); + } + + // Add a crew member + for (PersonCrew crew : wrapper.getCrew()) { + Person person = new Person(); + person.addCrew(crew.getId(), crew.getName(), crew.getProfilePath(), crew.getDepartment(), crew.getJob()); + people.add(person); + } + + return people; + } catch (IOException ex) { + LOGGER.warn("Failed to get movie casts: " + ex.getMessage()); + throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); + } + } + + /** + * This method should be used when you’re wanting to retrieve all of the images for a particular movie. + * + * @param movieId + * @param language + * @return + * @throws MovieDbException + */ + public List getMovieImages(int movieId, String language) throws MovieDbException { + + tmdbMovieImages.addArgument(ApiUrl.PARAM_ID, movieId); + + if (StringUtils.isNotBlank(language)) { + tmdbMovieImages.addArgument(ApiUrl.PARAM_LANGUAGE, language); + } + + List artwork = new ArrayList(); + URL url = tmdbMovieImages.buildUrl(); + String webpage = WebBrowser.request(url); + try { + WrapperImages wrapper = mapper.readValue(webpage, WrapperImages.class); + + // Add all the posters to the list + for (Artwork poster : wrapper.getPosters()) { + poster.setArtworkType(ArtworkType.POSTER); + artwork.add(poster); + } + + // Add all the backdrops to the list + for (Artwork backdrop : wrapper.getBackdrops()) { + backdrop.setArtworkType(ArtworkType.BACKDROP); + artwork.add(backdrop); + } + + return artwork; + } catch (IOException ex) { + LOGGER.warn("Failed to get movie images: " + ex.getMessage()); + throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); + } + } + + /** + * This method is used to retrieve all of the keywords that have been added to a particular movie. + * + * Currently, only English keywords exist. + * + * @param movieId + * @return + * @throws MovieDbException + */ + public List getMovieKeywords(int movieId) throws MovieDbException { + + tmdbMovieKeywords.addArgument(ApiUrl.PARAM_ID, movieId); + + URL url = tmdbMovieKeywords.buildUrl(); + String webpage = WebBrowser.request(url); + + try { + WrapperMovieKeywords wrapper = mapper.readValue(webpage, WrapperMovieKeywords.class); + return wrapper.getKeywords(); + } catch (IOException ex) { + LOGGER.warn("Failed to get movie keywords: " + ex.getMessage()); + throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); + } + } + + /** + * This method is used to retrieve all of the release and certification data we have for a specific movie. + * + * @param movieId + * @param language + * @return + * @throws MovieDbException + */ + public List getMovieReleaseInfo(int movieId, String language) throws MovieDbException { + + tmdbMovieReleaseInfo.addArgument(ApiUrl.PARAM_ID, movieId); + tmdbMovieReleaseInfo.addArgument(ApiUrl.PARAM_LANGUAGE, language); + + URL url = tmdbMovieReleaseInfo.buildUrl(); + String webpage = WebBrowser.request(url); + + try { + WrapperReleaseInfo wrapper = mapper.readValue(webpage, WrapperReleaseInfo.class); + return wrapper.getCountries(); + } catch (IOException ex) { + LOGGER.warn("Failed to get movie release information: " + ex.getMessage()); + throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); + } + } + + /** + * This method is used to retrieve all of the trailers for a particular movie. + * + * Supported sites are YouTube and QuickTime. + * + * @param movieId + * @param language + * @return + * @throws MovieDbException + */ + public List getMovieTrailers(int movieId, String language) throws MovieDbException { + + List trailers = new ArrayList(); + + tmdbMovieTrailers.addArgument(ApiUrl.PARAM_ID, movieId); + + if (StringUtils.isNotBlank(language)) { + tmdbMovieTrailers.addArgument(ApiUrl.PARAM_LANGUAGE, language); + } + + URL url = tmdbMovieTrailers.buildUrl(); + String webpage = WebBrowser.request(url); + + try { + WrapperTrailers wrapper = mapper.readValue(webpage, WrapperTrailers.class); + + // Add the trailer to the return list along with it's source + for (Trailer trailer : wrapper.getQuicktime()) { + trailer.setWebsite(Trailer.WEBSITE_QUICKTIME); + trailers.add(trailer); + } + // Add the trailer to the return list along with it's source + for (Trailer trailer : wrapper.getYoutube()) { + trailer.setWebsite(Trailer.WEBSITE_YOUTUBE); + trailers.add(trailer); + } + return trailers; + } catch (IOException ex) { + LOGGER.warn("Failed to get movie trailers: " + ex.getMessage()); + throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); + } + } + + /** + * This method is used to retrieve a list of the available translations for a specific movie. + * + * @param movieId + * @return + * @throws MovieDbException + */ + public List getMovieTranslations(int movieId) throws MovieDbException { + + tmdbMovieTranslations.addArgument(ApiUrl.PARAM_ID, movieId); + URL url = tmdbMovieTranslations.buildUrl(); + String webpage = WebBrowser.request(url); + + try { + WrapperTranslations wrapper = mapper.readValue(webpage, WrapperTranslations.class); + return wrapper.getTranslations(); + } catch (IOException ex) { + LOGGER.warn("Failed to get movie tranlations: " + ex.getMessage()); + throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); + } + } + + /** + * The similar movies method will let you retrieve the similar movies for a particular movie. + * + * This data is created dynamically but with the help of users votes on TMDb. + * + * The data is much better with movies that have more keywords + * + * @param movieId + * @param language + * @param allResults + * @return + * @throws MovieDbException + */ + public List getSimilarMovies(int movieId, String language, int page) throws MovieDbException { + tmdbMovieSimilarMovies.addArgument(ApiUrl.PARAM_ID, movieId); + + if (StringUtils.isNotBlank(language)) { + tmdbMovieSimilarMovies.addArgument(ApiUrl.PARAM_LANGUAGE, language); + } + + if (page > 0) { + tmdbMovieSimilarMovies.addArgument(ApiUrl.PARAM_PAGE, page); + } + + URL url = tmdbMovieSimilarMovies.buildUrl(); + String webpage = WebBrowser.request(url); + + try { + WrapperMovie wrapper = mapper.readValue(webpage, WrapperMovie.class); + return wrapper.getMovies(); + } catch (IOException ex) { + LOGGER.warn("Failed to get similar movies: " + ex.getMessage()); + throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); + } + } + + /** + * This method is used to retrieve the newest movie that was added to TMDb. + * + * @return + */ + public MovieDb getLatestMovie() throws MovieDbException { + + URL url = tmdbLatestMovie.buildUrl(); + String webpage = WebBrowser.request(url); + + try { + return mapper.readValue(webpage, MovieDb.class); + } catch (IOException ex) { + LOGGER.warn("Failed to get latest movie: " + ex.getMessage()); + throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); + } + } + + /** + * Get the list of upcoming movies. + * + * This list refreshes every day. + * + * The maximum number of items this list will include is 100. + * + * @return + * @throws MovieDbException + */ + public List getUpcoming(String language, int page) throws MovieDbException { + if (StringUtils.isNotBlank(language)) { + tmdbUpcoming.addArgument(ApiUrl.PARAM_LANGUAGE, language); + } + + if (page > 0) { + tmdbUpcoming.addArgument(ApiUrl.PARAM_PAGE, page); + } + + URL url = tmdbUpcoming.buildUrl(); + String webpage = WebBrowser.request(url); + + try { + WrapperMovie wrapper = mapper.readValue(webpage, WrapperMovie.class); + return wrapper.getMovies(); + } catch (IOException ex) { + LOGGER.warn("Failed to get upcoming movies: " + ex.getMessage()); + throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); + } + + } + + /** + * This method is used to retrieve the movies currently in theatres. + * + * This is a curated list that will normally contain 100 movies. The default response will return 20 movies. + * + * TODO: Implement more than 20 movies + * + * @param language + * @param allResults + * @return + * @throws MovieDbException + */ + public List getNowPlayingMovies(String language, int page) throws MovieDbException { + + if (StringUtils.isNotBlank(language)) { + tmdbNowPlaying.addArgument(ApiUrl.PARAM_LANGUAGE, language); + } + + if (page > 0) { + tmdbNowPlaying.addArgument(ApiUrl.PARAM_PAGE, page); + } + + URL url = tmdbNowPlaying.buildUrl(); + String webpage = WebBrowser.request(url); + + try { + WrapperMovie wrapper = mapper.readValue(webpage, WrapperMovie.class); + return wrapper.getMovies(); + } catch (IOException ex) { + LOGGER.warn("Failed to get now playing movies: " + ex.getMessage()); + throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); + } + } + + /** + * This method is used to retrieve the daily movie popularity list. + * + * This list is updated daily. The default response will return 20 movies. + * + * TODO: Implement more than 20 movies + * + * @param language + * @param allResults + * @return + * @throws MovieDbException + */ + public List getPopularMovieList(String language, int page) throws MovieDbException { + if (StringUtils.isNotBlank(language)) { + tmdbPopularMovieList.addArgument(ApiUrl.PARAM_LANGUAGE, language); + } + + if (page > 0) { + tmdbPopularMovieList.addArgument(ApiUrl.PARAM_PAGE, page); + } + + URL url = tmdbPopularMovieList.buildUrl(); + String webpage = WebBrowser.request(url); + + try { + WrapperMovie wrapper = mapper.readValue(webpage, WrapperMovie.class); + return wrapper.getMovies(); + } catch (IOException ex) { + LOGGER.warn("Failed to get popular movie list: " + ex.getMessage()); + throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); + } + } + + /** + * This method is used to retrieve the top rated movies that have over 10 votes on TMDb. + * + * The default response will return 20 movies. + * + * TODO: Implement more than 20 movies + * + * @param language + * @param allResults + * @return + * @throws MovieDbException + */ + public List getTopRatedMovies(String language, int page) throws MovieDbException { + if (StringUtils.isNotBlank(language)) { + tmdbTopRatedMovies.addArgument(ApiUrl.PARAM_LANGUAGE, language); + } + + if (page > 0) { + tmdbTopRatedMovies.addArgument(ApiUrl.PARAM_PAGE, page); + } + + URL url = tmdbTopRatedMovies.buildUrl(); + String webpage = WebBrowser.request(url); + + try { + WrapperMovie wrapper = mapper.readValue(webpage, WrapperMovie.class); + return wrapper.getMovies(); + } catch (IOException ex) { + LOGGER.warn("Failed to get top rated movies: " + ex.getMessage()); + throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); + } + } + + /** + * This method lets users rate a movie. + * + * A valid session id is required. + * + * @param sessionId + * @param rating + * @return + * @throws MovieDbException + */ + public boolean postMovieRating(String sessionId, String rating) throws MovieDbException { + + tmdbPostRating.addArgument(ApiUrl.PARAM_SESSION, sessionId); + tmdbPostRating.addArgument(ApiUrl.PARAM_VALUE, rating); + + throw new MovieDbException(MovieDbExceptionType.UNKNOWN_CAUSE, "Not implemented yet"); + } + + // + // + // + /** + * This method is used to retrieve all of the basic information about a movie collection. + * + * You can get the ID needed for this method by making a getMovieInfo request for the belongs_to_collection. + * + * @param collectionId + * @param language + * @return + * @throws MovieDbException + */ + public CollectionInfo getCollectionInfo(int collectionId, String language) throws MovieDbException { + + tmdbCollectionInfo.addArgument(ApiUrl.PARAM_ID, collectionId); + + if (StringUtils.isNotBlank(language)) { + tmdbCollectionInfo.addArgument(ApiUrl.PARAM_LANGUAGE, language); + } + + URL url = tmdbCollectionInfo.buildUrl(); + String webpage = WebBrowser.request(url); + + try { + return mapper.readValue(webpage, CollectionInfo.class); + } catch (IOException ex) { + LOGGER.warn("Failed to get collection information: " + ex.getMessage()); + throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); + } + } + + /** + * Get all of the images for a particular collection by collection id. + * + * @param collectionId + * @param language + * @return + * @throws MovieDbException + */ + public List getCollectionImages(int collectionId, String language) throws MovieDbException { + List artwork = new ArrayList(); + + tmdbCollectionImages.addArgument(ApiUrl.PARAM_ID, collectionId); + + if (StringUtils.isNotBlank(language)) { + tmdbCollectionImages.addArgument(ApiUrl.PARAM_LANGUAGE, language); + } + + URL url = tmdbCollectionImages.buildUrl(); + String webpage = WebBrowser.request(url); + + try { + WrapperImages wrapper = mapper.readValue(webpage, WrapperImages.class); + + // Add all the posters to the list + for (Artwork poster : wrapper.getPosters()) { + poster.setArtworkType(ArtworkType.POSTER); + artwork.add(poster); + } + + // Add all the backdrops to the list + for (Artwork backdrop : wrapper.getBackdrops()) { + backdrop.setArtworkType(ArtworkType.BACKDROP); + artwork.add(backdrop); + } + + return artwork; + } catch (IOException ex) { + LOGGER.warn("Failed to get collection images: " + ex.getMessage()); + throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); + } + + } + + // + // + // /** * This method is used to retrieve all of the basic person information. * @@ -592,7 +884,9 @@ public class TheMovieDb { */ public Person getPersonInfo(int personId) throws MovieDbException { - URL url = tmdbPersonInfo.getIdUrl(personId); + tmdbPersonInfo.addArgument(ApiUrl.PARAM_ID, personId); + + URL url = tmdbPersonInfo.buildUrl(); String webpage = WebBrowser.request(url); try { @@ -604,8 +898,7 @@ public class TheMovieDb { } /** - * This method is used to retrieve all of the cast & crew information for - * the person. + * This method is used to retrieve all of the cast & crew information for the person. * * It will return the single highest rated poster for each movie record. * @@ -617,7 +910,9 @@ public class TheMovieDb { List personCredits = new ArrayList(); - URL url = tmdbPersonCredits.getIdUrl(personId); + tmdbPersonCredits.addArgument(ApiUrl.PARAM_ID, personId); + + URL url = tmdbPersonCredits.buildUrl(); String webpage = WebBrowser.request(url); try { @@ -651,7 +946,9 @@ public class TheMovieDb { List personImages = new ArrayList(); - URL url = tmdbPersonImages.getIdUrl(personId); + tmdbPersonImages.addArgument(ApiUrl.PARAM_ID, personId); + + URL url = tmdbPersonImages.buildUrl(); String webpage = WebBrowser.request(url); try { @@ -669,135 +966,21 @@ public class TheMovieDb { } } + // + // + // /** - * This method is used to retrieve the newest movie that was added to TMDb. - * - * @return - */ - public MovieDb getLatestMovie() throws MovieDbException { - - URL url = tmdbLatestMovie.getIdUrl(""); - String webpage = WebBrowser.request(url); - - try { - return mapper.readValue(webpage, MovieDb.class); - } catch (IOException ex) { - LOGGER.warn("Failed to get latest movie: " + ex.getMessage()); - throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); - } - } - - /** - * Get the list of upcoming movies. - * - * This list refreshes every day. - * - * The maximum number of items this list will include is 100. - * - * @return - * @throws MovieDbException - */ - public List getUpcoming(String language) throws MovieDbException { - URL url = tmdbUpcoming.getIdUrl("", language); - String webpage = WebBrowser.request(url); - - try { - WrapperMovie wrapper = mapper.readValue(webpage, WrapperMovie.class); - return wrapper.getMovies(); - } catch (IOException ex) { - LOGGER.warn("Failed to get upcoming movies: " + ex.getMessage()); - throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); - } - - } - - /** - * This method is used to retrieve the movies currently in theatres. - * - * This is a curated list that will normally contain 100 movies. The default - * response will return 20 movies. - * - * TODO: Implement more than 20 movies - * - * @param language - * @param allResults - * @return - * @throws MovieDbException - */ - public List getNowPlayingMovies(String language, boolean allResults) throws MovieDbException { - URL url = tmdbNowPlaying.getIdUrl("", language); - String webpage = WebBrowser.request(url); - - try { - WrapperMovie wrapper = mapper.readValue(webpage, WrapperMovie.class); - return wrapper.getMovies(); - } catch (IOException ex) { - LOGGER.warn("Failed to get now playing movies: " + ex.getMessage()); - throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); - } - } - - /** - * This method is used to retrieve the daily movie popularity list. - * - * This list is updated daily. The default response will return 20 movies. - * - * TODO: Implement more than 20 movies - * - * @param language - * @param allResults - * @return - * @throws MovieDbException - */ - public List getPopularMovieList(String language, boolean allResults) throws MovieDbException { - URL url = tmdbPopularMovieList.getIdUrl("", language); - String webpage = WebBrowser.request(url); - - try { - WrapperMovie wrapper = mapper.readValue(webpage, WrapperMovie.class); - return wrapper.getMovies(); - } catch (IOException ex) { - LOGGER.warn("Failed to get popular movie list: " + ex.getMessage()); - throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); - } - } - - /** - * This method is used to retrieve the top rated movies that have over 10 - * votes on TMDb. - * - * The default response will return 20 movies. - * - * TODO: Implement more than 20 movies - * - * @param language - * @param allResults - * @return - * @throws MovieDbException - */ - public List getTopRatedMovies(String language, boolean allResults) throws MovieDbException { - URL url = tmdbTopRatedMovies.getIdUrl("", language); - String webpage = WebBrowser.request(url); - - try { - WrapperMovie wrapper = mapper.readValue(webpage, WrapperMovie.class); - return wrapper.getMovies(); - } catch (IOException ex) { - LOGGER.warn("Failed to get top rated movies: " + ex.getMessage()); - throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); - } - } - - /** - * This method is used to retrieve the basic information about a production - * company on TMDb. + * This method is used to retrieve the basic information about a production company on TMDb. * * @param companyId * @return * @throws MovieDbException */ public Company getCompanyInfo(int companyId) throws MovieDbException { - URL url = tmdbCompanyInfo.getIdUrl(companyId); + + tmdbCompanyInfo.addArgument(ApiUrl.PARAM_ID, companyId); + + URL url = tmdbCompanyInfo.buildUrl(); String webpage = WebBrowser.request(url); try { @@ -811,8 +994,8 @@ public class TheMovieDb { /** * This method is used to retrieve the movies associated with a company. * - * These movies are returned in order of most recently released to oldest. - * The default response will return 20 movies per page. + * These movies are returned in order of most recently released to oldest. The default response will return 20 + * movies per page. * * TODO: Implement more than 20 movies * @@ -822,8 +1005,19 @@ public class TheMovieDb { * @return * @throws MovieDbException */ - public List getCompanyMovies(int companyId, String language, boolean allResults) throws MovieDbException { - URL url = tmdbCompanyMovies.getIdUrl(companyId, language); + public List getCompanyMovies(int companyId, String language, int page) throws MovieDbException { + + tmdbCompanyMovies.addArgument(ApiUrl.PARAM_ID, companyId); + + if (StringUtils.isNotBlank(language)) { + tmdbCompanyMovies.addArgument(ApiUrl.PARAM_LANGUAGE, language); + } + + if (page > 0) { + tmdbCompanyMovies.addArgument(ApiUrl.PARAM_PAGE, page); + } + + URL url = tmdbCompanyMovies.buildUrl(); String webpage = WebBrowser.request(url); try { @@ -835,64 +1029,9 @@ public class TheMovieDb { } } - /** - * Search Companies. - * - * You can use this method to search for production companies that are part - * of TMDb. The company IDs will map to those returned on movie calls. - * - * http://help.themoviedb.org/kb/api/search-companies - * - * TODO: Make the allResults work - * - * @param companyName - * @param language - * @param allResults - * @return - * @throws MovieDbException - */ - public List searchCompanies(String companyName, String language, boolean allResults) throws MovieDbException { - - URL url = tmdbSearchCompanies.getQueryUrl(companyName, language, 1); - String webpage = WebBrowser.request(url); - try { - WrapperCompany wrapper = mapper.readValue(webpage, WrapperCompany.class); - return wrapper.getResults(); - } catch (IOException ex) { - LOGGER.warn("Failed to find company: " + ex.getMessage()); - throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); - } - } - - /** - * The similar movies method will let you retrieve the similar movies for a - * particular movie. - * - * This data is created dynamically but with the help of users votes on - * TMDb. - * - * The data is much better with movies that have more keywords - * - * @param movieId - * @param language - * @param allResults - * @return - * @throws MovieDbException - */ - public List getSimilarMovies(int movieId, String language, boolean allResults) throws MovieDbException { - - URL url = tmdbMovieSimilarMovies.getIdUrl(movieId, language); - String webpage = WebBrowser.request(url); - - try { - WrapperMovie wrapper = mapper.readValue(webpage, WrapperMovie.class); - return wrapper.getMovies(); - } catch (IOException ex) { - LOGGER.warn("Failed to get similar movies: " + ex.getMessage()); - throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); - } - } - + // + // + // /** * You can use this method to retrieve the list of genres used on TMDb. * @@ -902,7 +1041,9 @@ public class TheMovieDb { * @return */ public List getGenreList(String language) throws MovieDbException { - URL url = tmdbGenreList.getQueryUrl("", language); + tmdbGenreList.addArgument(ApiUrl.PARAM_LANGUAGE, language); + + URL url = tmdbGenreList.buildUrl(); String webpage = WebBrowser.request(url); try { @@ -917,19 +1058,28 @@ public class TheMovieDb { /** * Get a list of movies per genre. * - * It is important to understand that only movies with more than 10 votes - * get listed. + * It is important to understand that only movies with more than 10 votes get listed. * - * This prevents movies from 1 10/10 rating from being listed first and for - * the first 5 pages. + * This prevents movies from 1 10/10 rating from being listed first and for the first 5 pages. * * @param genreId * @param language * @param allResults * @return */ - public List getGenreMovies(int genreId, String language, boolean allResults) throws MovieDbException { - URL url = tmdbGenreMovies.getIdUrl(genreId, language); + public List getGenreMovies(int genreId, String language, int page) throws MovieDbException { + + tmdbGenreMovies.addArgument(ApiUrl.PARAM_ID, genreId); + + if (StringUtils.isNotBlank(language)) { + tmdbGenreMovies.addArgument(ApiUrl.PARAM_LANGUAGE, language); + } + + if (page > 0) { + tmdbGenreMovies.addArgument(ApiUrl.PARAM_PAGE, page); + } + + URL url = tmdbGenreMovies.buildUrl(); String webpage = WebBrowser.request(url); try { @@ -940,4 +1090,267 @@ public class TheMovieDb { throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } + // + // + // + + /** + * Search Movies This is a good starting point to start finding movies on TMDb. + * + * @param movieName + * @param searchYear Limit the search to the provided year. Zero (0) will get all years + * @param language The language to include. Can be blank/null. + * @param includeAdult true or false to include adult titles in the search + * @param page The page of results to return. 0 to get the default (first page) + * @return + * @throws MovieDbException + */ + public List searchMovie(String movieName, int searchYear, String language, boolean includeAdult, int page) throws MovieDbException { + if (StringUtils.isNotBlank(movieName)) { + tmdbSearchMovie.addArgument(ApiUrl.PARAM_QUERY, movieName); + } + + if (searchYear > 0) { + tmdbSearchMovie.addArgument(ApiUrl.PARAM_YEAR, Integer.toString(searchYear)); + } + + if (StringUtils.isNotBlank(language)) { + tmdbSearchMovie.addArgument(ApiUrl.PARAM_LANGUAGE, language); + } + + tmdbSearchMovie.addArgument(ApiUrl.PARAM_ADULT, Boolean.toString(includeAdult)); + + if (page > 0) { + tmdbSearchMovie.addArgument(ApiUrl.PARAM_PAGE, Integer.toString(page)); + } + + URL url = tmdbSearchMovie.buildUrl(); + LOGGER.info(url.toString()); + + String webpage = WebBrowser.request(url); + try { + WrapperMovie wrapper = mapper.readValue(webpage, WrapperMovie.class); + return wrapper.getMovies(); + } catch (IOException ex) { + LOGGER.warn("Failed to find movie: " + ex.getMessage()); + throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); + } + + } + + /** + * Search Companies. + * + * You can use this method to search for production companies that are part of TMDb. The company IDs will map to + * those returned on movie calls. + * + * http://help.themoviedb.org/kb/api/search-companies + * + * @param companyName + * @param page + * @return + * @throws MovieDbException + */ + public List searchCompanies(String companyName, int page) throws MovieDbException { + tmdbSearchCompanies.addArgument(ApiUrl.PARAM_QUERY, companyName); + + if (page > 0) { + tmdbSearchCompanies.addArgument(ApiUrl.PARAM_PAGE, page); + } + + URL url = tmdbSearchCompanies.buildUrl(); + String webpage = WebBrowser.request(url); + try { + WrapperCompany wrapper = mapper.readValue(webpage, WrapperCompany.class); + return wrapper.getResults(); + } catch (IOException ex) { + LOGGER.warn("Failed to find company: " + ex.getMessage()); + throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); + } + } + + /** + * This is a good starting point to start finding people on TMDb. + * + * The idea is to be a quick and light method so you can iterate through people quickly. + * + * TODO: Fix allResults + * + * @param personName + * @param allResults + * @return + * @throws MovieDbException + */ + public List searchPeople(String personName, boolean includeAdult, int page) throws MovieDbException { + tmdbSearchPeople.addArgument(ApiUrl.PARAM_QUERY, personName); + tmdbSearchPeople.addArgument(ApiUrl.PARAM_ADULT, includeAdult); + + if (page > 0) { + tmdbSearchPeople.addArgument(ApiUrl.PARAM_PAGE, page); + } + + URL url = tmdbSearchPeople.buildUrl(); + String webpage = WebBrowser.request(url); + + try { + WrapperPerson wrapper = mapper.readValue(webpage, WrapperPerson.class); + return wrapper.getResults(); + } catch (IOException ex) { + LOGGER.warn("Failed to find person: " + ex.getMessage()); + throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); + } + } + + // + // + /* + * Deprecated Functions. + * + * Will be removed in next version: 3.3 + */ + // + /** + * This interface will be deprecated in the next version + * + * @param movieName + * @param language + * @param allResults + * @return + * @throws MovieDbException + * @deprecated + */ + @Deprecated + public List searchMovie(String movieName, String language, boolean allResults) throws MovieDbException { + return searchMovie(movieName, 0, language, allResults, 0); + } + + /** + * This interface will be deprecated in the next version + * + * @param companyName + * @param language + * @param allResults + * @return + * @throws MovieDbException + * @deprecated + */ + @Deprecated + public List searchCompanies(String companyName, String language, boolean allResults) throws MovieDbException { + return searchCompanies(companyName, 0); + } + + /** + * This interface will be deprecated in the next version + * + * @param personName + * @param allResults + * @return + * @throws MovieDbException + * @deprecated + */ + @Deprecated + public List searchPeople(String personName, boolean allResults) throws MovieDbException { + return searchPeople(personName, allResults, 0); + } + + /** + * This interface will be deprecated in the next version + * + * @param movieId + * @param language + * @param allResults + * @return + * @throws MovieDbException + * @deprecated + */ + @Deprecated + public List getSimilarMovies(int movieId, String language, boolean allResults) throws MovieDbException { + return getSimilarMovies(movieId, language, 0); + } + + /** + * This interface will be deprecated in the next version + * + * @param language + * @return + * @throws MovieDbException + * @deprecated + */ + @Deprecated + public List getUpcoming(String language) throws MovieDbException { + return getUpcoming(language, 0); + } + + /** + * This interface will be deprecated in the next version + * + * @param language + * @param allResults + * @return + * @throws MovieDbException + * @deprecated + */ + @Deprecated + public List getNowPlayingMovies(String language, boolean allResults) throws MovieDbException { + return getNowPlayingMovies(language, 0); + } + + /** + * This interface will be deprecated in the next version + * + * @param language + * @param allResults + * @return + * @throws MovieDbException + * @deprecated + */ + @Deprecated + public List getPopularMovieList(String language, boolean allResults) throws MovieDbException { + return getPopularMovieList(language, 0); + } + + /** + * This interface will be deprecated in the next version + * + * @param language + * @param allResults + * @return + * @throws MovieDbException + * @deprecated + */ + @Deprecated + public List getTopRatedMovies(String language, boolean allResults) throws MovieDbException { + return getTopRatedMovies(language, 0); + } + + /** + * This interface will be deprecated in the next version + * + * @param companyId + * @param language + * @param allResults + * @return + * @throws MovieDbException + * @deprecated + */ + @Deprecated + public List getCompanyMovies(int companyId, String language, boolean allResults) throws MovieDbException { + return getCompanyMovies(companyId, language, 0); + } + + /** + * This interface will be deprecated in the next version + * + * @param genreId + * @param language + * @param allResults + * @return + * @throws MovieDbException + * @deprecated + */ + @Deprecated + public List getGenreMovies(int genreId, String language, boolean allResults) throws MovieDbException { + return getGenreMovies(genreId, language, 0); + } + // } diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/ApiUrl.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/ApiUrl.java index a7f920cc5..d940b5885 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/ApiUrl.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/ApiUrl.java @@ -17,7 +17,8 @@ import java.io.UnsupportedEncodingException; import java.net.MalformedURLException; import java.net.URL; import java.net.URLEncoder; -import org.apache.commons.lang3.StringUtils; +import java.util.HashMap; +import java.util.Map; import org.apache.log4j.Logger; /** @@ -35,28 +36,42 @@ public class ApiUrl { * TheMovieDb API Base URL */ private static final String TMDB_API_BASE = "http://api.themoviedb.org/3/"; +// private static final String TMDB_API_BASE = "http://private-3aa3-themoviedb.apiary.io/3/"; /* * Parameter configuration */ private static final String DELIMITER_FIRST = "?"; private static final String DELIMITER_SUBSEQUENT = "&"; - private static final String PARAMETER_API_KEY = "api_key="; // The API Key is always needed and always first - private static final String PARAMETER_QUERY = "query="; - private static final String PARAMETER_LANGUAGE = DELIMITER_SUBSEQUENT + "language="; - private static final String PARAMETER_COUNTRY = DELIMITER_SUBSEQUENT + "country="; - private static final String PARAMETER_PAGE = DELIMITER_SUBSEQUENT + "page="; - public static final String DEFAULT_STRING = ""; - public static final int DEFAULT_INT = -1; + private static final String DEFAULT_STRING = ""; /* * Properties */ + private TheMovieDb tmdb; private String method; private String submethod; - private TheMovieDb tmdb; + private Map arguments = new HashMap(); + /* + * API Parameters + */ + public static final String PARAM_ADULT = "include_adult="; + public static final String PARAM_API_KEY = "api_key="; + public static final String PARAM_COUNTRY = "country="; + public static final String PARAM_FAVORITE = "favorite="; + public static final String PARAM_ID = "id="; + public static final String PARAM_LANGUAGE = "language="; +// public static final String PARAM_MOVIE_ID = "movie_id="; + public static final String PARAM_MOVIE_WATCHLIST = "movie_watchlist="; + public static final String PARAM_PAGE = "page="; + public static final String PARAM_QUERY = "query="; + public static final String PARAM_SESSION = "session_id="; + public static final String PARAM_TOKEN = "request_token="; + public static final String PARAM_VALUE = "value="; + public static final String PARAM_YEAR = "year="; // /** * Constructor for the simple API URL method without a sub-method + * * @param method */ public ApiUrl(TheMovieDb tmdb, String method) { @@ -67,6 +82,7 @@ public class ApiUrl { /** * Constructor for the API URL with a sub-method + * * @param method * @param submethod */ @@ -78,69 +94,58 @@ public class ApiUrl { // /** - * Create the full URL with the API. + * Build the URL from the pre-created arguments. * - * @param query - * @param tmdbId - * @param language - * @param country - * @param page * @return */ - private URL getFullUrl(String query, String movieId, String language, String country, int page) { + public URL buildUrl() { StringBuilder urlString = new StringBuilder(TMDB_API_BASE); // Get the start of the URL urlString.append(method); - // Append the search term if required - if (StringUtils.isNotBlank(query)) { - urlString.append(DELIMITER_FIRST); - urlString.append(PARAMETER_QUERY); + // We have either a queury, or a direct request + if (arguments.containsKey(PARAM_QUERY)) { + // Append the suffix of the API URL + urlString.append(submethod); + + // Append the key information + urlString.append(DELIMITER_FIRST).append(PARAM_API_KEY); + urlString.append(tmdb.getApiKey()); + + // Append the search term + urlString.append(DELIMITER_SUBSEQUENT); + urlString.append(PARAM_QUERY); + + String query = arguments.get(PARAM_QUERY); try { urlString.append(URLEncoder.encode(query, "UTF-8")); } catch (UnsupportedEncodingException ex) { + LOGGER.trace("Unable to encode query: '" + query + "' trying raw."); // If we can't encode it, try it raw urlString.append(query); } - } - // Append the ID if provided - if (StringUtils.isNotBlank(movieId)) { - urlString.append(movieId); - } - - // Append the suffix of the API URL - urlString.append(submethod); - - // Append the key information - if (StringUtils.isBlank(query)) { - // This is the first parameter - urlString.append(DELIMITER_FIRST); + arguments.remove(PARAM_QUERY); } else { - // The first parameter was the query - urlString.append(DELIMITER_SUBSEQUENT); - } - urlString.append(PARAMETER_API_KEY); - urlString.append(tmdb.getApiKey()); + // Append the ID if provided + if (arguments.containsKey(PARAM_ID)) { + urlString.append(arguments.get(PARAM_ID)); + arguments.remove(PARAM_ID); + } - // Append the language to the URL - if (StringUtils.isNotBlank(language)) { - urlString.append(PARAMETER_LANGUAGE); - urlString.append(language); + // Append the suffix of the API URL + urlString.append(submethod); + + // Append the key information + urlString.append(DELIMITER_FIRST).append(PARAM_API_KEY); + urlString.append(tmdb.getApiKey()); } - // Append the country to the URL - if (StringUtils.isNotBlank(country)) { - urlString.append(PARAMETER_COUNTRY); - urlString.append(country); - } - - // Append the page to the URL - if (page > DEFAULT_INT) { - urlString.append(PARAMETER_PAGE); - urlString.append(page); + for (Map.Entry argEntry : arguments.entrySet()) { + urlString.append(DELIMITER_SUBSEQUENT).append(argEntry.getKey()); + urlString.append(argEntry.getValue()); } try { @@ -149,100 +154,54 @@ public class ApiUrl { } catch (MalformedURLException ex) { LOGGER.warn("Failed to create URL " + urlString.toString() + " - " + ex.toString()); return null; + } finally { + arguments.clear(); } } /** - * Create an URL using the query (string), language and page + * Add arguments individually * - * @param query - * @param language - * @param page - * @return + * @param key + * @param value */ - public URL getQueryUrl(String query, String language, int page) { - return getFullUrl(query, DEFAULT_STRING, language, null, page); + public void addArgument(String key, String value) { + arguments.put(key, value); } /** - * Create an URL using the query (string) - * @param query - * @return - */ - public URL getQueryUrl(String query) { - return getQueryUrl(query, DEFAULT_STRING, DEFAULT_INT); - } - - /** - * Create an URL using the query (string) and language - * @param query - * @param language - * @return - */ - public URL getQueryUrl(String query, String language) { - return getQueryUrl(query, language, DEFAULT_INT); - } - - /** - * Create an URL using the movie ID, language and country code + * Add arguments individually * - * @param movieId - * @param language - * @param country - * @return + * @param key + * @param value */ - public URL getIdUrl(String movieId, String language, String country) { - return getFullUrl(DEFAULT_STRING, movieId, language, country, DEFAULT_INT); + public void addArgument(String key, int value) { + arguments.put(key, Integer.toString(value)); } /** - * Create an URL using the movie ID and language - * @param movieId - * @param language - * @return - */ - public URL getIdUrl(String movieId, String language) { - return getIdUrl(movieId, language, DEFAULT_STRING); - } - - /** - * Create an URL using the movie ID - * @param movieId - * @return - */ - public URL getIdUrl(String movieId) { - return getIdUrl(movieId, DEFAULT_STRING, DEFAULT_STRING); - } - - /** - * Create an URL using the movie ID, language and country code + * Add arguments individually * - * @param movieId - * @param language - * @param country - * @return + * @param key + * @param value */ - public URL getIdUrl(int movieId, String language, String country) { - return getIdUrl(String.valueOf(movieId), language, country); + public void addArgument(String key, boolean value) { + arguments.put(key, Boolean.toString(value)); } /** - * Create an URL using the movie ID and language - * @param movieId - * @param language - * @return + * Clear the arguments */ - public URL getIdUrl(int movieId, String language) { - return getIdUrl(String.valueOf(movieId), language, DEFAULT_STRING); + public void clearArguments() { + arguments.clear(); } /** - * Create an URL using the movie ID - * @param movieId - * @return + * Set the arguments directly + * + * @param args */ - public URL getIdUrl(int movieId) { - return getIdUrl(String.valueOf(movieId), DEFAULT_STRING, DEFAULT_STRING); + public void setArguments(Map args) { + arguments.putAll(args); } - } diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/FilteringLayout.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/FilteringLayout.java index f63079ea1..bd59bcad9 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/FilteringLayout.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/FilteringLayout.java @@ -20,18 +20,27 @@ import org.apache.log4j.spi.LoggingEvent; /** * Log4J Filtering routine to remove API keys from the output + * * @author Stuart.Boston * */ public class FilteringLayout extends PatternLayout { - private static Pattern apiKeys = Pattern.compile("DO_NOT_MATCH"); - public static void addApiKey(String apiKey) { - apiKeys = Pattern.compile(apiKey); + private static final String REPLACEMENT = "[APIKEY]"; + private static Pattern replacementPattern = Pattern.compile("DO_NOT_MATCH"); + + /** + * Add the string to replace in the log output + * + * @param replacementString + */ + public static void addReplacementString(String replacementString) { + replacementPattern = Pattern.compile(replacementString); } /** * Extend the format to remove the API_KEYS from the output + * * @param event * @return */ @@ -40,12 +49,12 @@ public class FilteringLayout extends PatternLayout { if (event.getMessage() instanceof String) { String message = event.getRenderedMessage(); - Matcher matcher = apiKeys.matcher(message); + Matcher matcher = replacementPattern.matcher(message); if (matcher.find()) { - String maskedMessage = matcher.replaceAll("[APIKEY]"); + String maskedMessage = matcher.replaceAll(REPLACEMENT); - Throwable throwable = event.getThrowableInformation() != null ? - event.getThrowableInformation().getThrowable() : null; + Throwable throwable = event.getThrowableInformation() != null + ? event.getThrowableInformation().getThrowable() : null; LoggingEvent maskedEvent = new LoggingEvent(event.fqnOfCategoryClass, Logger.getLogger(event.getLoggerName()), event.timeStamp, diff --git a/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java b/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java index 98e38a027..963fcee2e 100644 --- a/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java +++ b/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java @@ -13,9 +13,11 @@ package com.moviejukebox.themoviedb; import com.moviejukebox.themoviedb.model.*; +import com.moviejukebox.themoviedb.tools.FilteringLayout; import java.io.IOException; import java.util.List; import org.apache.commons.lang3.StringUtils; +import org.apache.log4j.Level; import org.apache.log4j.Logger; import org.junit.*; import static org.junit.Assert.*; @@ -46,6 +48,10 @@ public class TheMovieDbTest { @BeforeClass public static void setUpClass() throws Exception { + // Set the logger level to TRACE + Logger.getRootLogger().setLevel(Level.TRACE); + // Show the version of the API + TheMovieDb.showVersion(); } @AfterClass @@ -54,6 +60,8 @@ public class TheMovieDbTest { @Before public void setUp() { + // Make sure the filter isn't applied to the test output + FilteringLayout.addReplacementString("DO_NOT_MATCH"); } @After @@ -76,6 +84,14 @@ public class TheMovieDbTest { LOGGER.info(tmdbConfig.toString()); } + /** + * Test of showVersion method, of class TheMovieDb. + */ + @Test + public void testShowVersion() { + // Not required + } + /** * Test of searchMovie method, of class TheMovieDb. */ @@ -84,15 +100,16 @@ public class TheMovieDbTest { LOGGER.info("searchMovie"); // Try a movie with less than 1 page of results - List movieList = tmdb.searchMovie("Blade Runner", "", true); + List movieList = tmdb.searchMovie("Blade Runner", 0, "", true, 0); +// List movieList = tmdb.searchMovie("Blade Runner", "", true); assertTrue("No movies found, should be at least 1", movieList.size() > 0); // Try a russian langugage movie - movieList = tmdb.searchMovie("О чём говорят мужчины", "ru", true); + movieList = tmdb.searchMovie("О чём говорят мужчины", 0, "ru", true, 0); assertTrue("No movies found, should be at least 1", movieList.size() > 0); // Try a movie with more than 20 results - movieList = tmdb.searchMovie("Star Wars", "en", false); + movieList = tmdb.searchMovie("Star Wars", 0, "en", false, 0); assertTrue("Not enough movies found, should be over 15, found " + movieList.size(), movieList.size() >= 15); } @@ -212,6 +229,10 @@ public class TheMovieDbTest { assertFalse("No collection information", result.getParts().isEmpty()); } + /** + * Test of createImageUrl method, of class TheMovieDb. + * @throws MovieDbException + */ @Test public void testCreateImageUrl() throws MovieDbException { LOGGER.info("createImageUrl"); @@ -383,14 +404,6 @@ public class TheMovieDbTest { assertTrue("No company movies found", !results.isEmpty()); } - /** - * Test of showVersion method, of class TheMovieDb. - */ - @Test - public void testShowVersion() { - // Not required - } - /** * Test of searchCompanies method, of class TheMovieDb. */ @@ -430,4 +443,54 @@ public class TheMovieDbTest { List results = tmdb.getGenreMovies(ID_GENRE_ACTION, "", true); assertTrue("No genre movies found", !results.isEmpty()); } + + /** + * Test of getUpcoming method, of class TheMovieDb. + */ + @Test + public void testGetUpcoming() throws Exception { + LOGGER.info("getUpcoming"); + List results = tmdb.getUpcoming(""); + assertTrue("No upcoming movies found", !results.isEmpty()); + } + + /** + * Test of getCollectionImages method, of class TheMovieDb. + */ + @Test + public void testGetCollectionImages() throws Exception { + LOGGER.info("getCollectionImages"); + String language = ""; + List result = tmdb.getCollectionImages(ID_MOVIE_STAR_WARS_COLLECTION, language); + assertFalse("No artwork found", result.isEmpty()); + } + + /** + * Test of getAuthorisationToken method, of class TheMovieDb. + */ +// @Test + public void testGetAuthorisationToken() throws Exception { + LOGGER.info("getAuthorisationToken"); + TokenAuthorisation result = tmdb.getAuthorisationToken(); + assertFalse("Token is null", result == null); + assertTrue("Token is not valid", result.getSuccess()); + LOGGER.info(result.toString()); + } + + /** + * Test of getSessionToken method, of class TheMovieDb. + */ +// @Test + public void testGetSessionToken() throws Exception { + LOGGER.info("getSessionToken"); + TokenAuthorisation token = tmdb.getAuthorisationToken(); + assertFalse("Token is null", token == null); + assertTrue("Token is not valid", token.getSuccess()); + LOGGER.info(token.toString()); + + TokenSession result = tmdb.getSessionToken(token); + assertFalse("Session token is null", result == null); + assertTrue("Session token is not valid", result.getSuccess()); + LOGGER.info(result.toString()); + } } From c41e82134c24db2987e3ee4c1d48a47d60cc40dd Mon Sep 17 00:00:00 2001 From: Omertron Date: Wed, 26 Sep 2012 20:37:05 +0000 Subject: [PATCH 147/207] Tidied up functions --- .../moviejukebox/themoviedb/TheMovieDb.java | 280 +++++++++--------- 1 file changed, 141 insertions(+), 139 deletions(-) diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java index 2cab9faa7..0bc97afb6 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java @@ -15,6 +15,7 @@ package com.moviejukebox.themoviedb; import com.moviejukebox.themoviedb.MovieDbException.MovieDbExceptionType; import com.moviejukebox.themoviedb.model.*; import com.moviejukebox.themoviedb.tools.ApiUrl; +import static com.moviejukebox.themoviedb.tools.ApiUrl.*; import com.moviejukebox.themoviedb.tools.FilteringLayout; import com.moviejukebox.themoviedb.tools.WebBrowser; import com.moviejukebox.themoviedb.wrapper.*; @@ -53,54 +54,17 @@ public class TheMovieDb { private static final String BASE_GENRE = "genre/"; private static final String BASE_AUTH = "authentication/"; private static final String BASE_COLLECTION = "collection/"; - private static final String BASE_ACCOUNT = "account/"; +// private static final String BASE_ACCOUNT = "account/"; private static final String BASE_SEARCH = "search/"; - // Configuration - private final ApiUrl tmdbConfigUrl = new ApiUrl(this, "configuration"); - // Authentication - private final ApiUrl tmdbAuthorisationToken = new ApiUrl(this, BASE_AUTH, "token/new"); - private final ApiUrl tmdbAuthorisationSession = new ApiUrl(this, BASE_AUTH, "session/new"); // Account - private final ApiUrl tmdbAccount = new ApiUrl(this, BASE_ACCOUNT); - private final ApiUrl tmdbFavouriteMovies = new ApiUrl(this, BASE_ACCOUNT, "/favorite_movies"); - private final ApiUrl tmdbPostFavourite = new ApiUrl(this, BASE_ACCOUNT, "/favorite"); - private final ApiUrl tmdbRatedMovies = new ApiUrl(this, BASE_ACCOUNT, "/rated_movies"); - private final ApiUrl tmdbMovieWatchList = new ApiUrl(this, BASE_ACCOUNT, "/movie_watchlist"); - private final ApiUrl tmdbPostMovieWatchList = new ApiUrl(this, BASE_ACCOUNT, "/movie_watchlist"); - // Movies - private final ApiUrl tmdbMovieInfo = new ApiUrl(this, BASE_MOVIE); - private final ApiUrl tmdbMovieAltTitles = new ApiUrl(this, BASE_MOVIE, "/alternative_titles"); - private final ApiUrl tmdbMovieCasts = new ApiUrl(this, BASE_MOVIE, "/casts"); - private final ApiUrl tmdbMovieImages = new ApiUrl(this, BASE_MOVIE, "/images"); - private final ApiUrl tmdbMovieKeywords = new ApiUrl(this, BASE_MOVIE, "/keywords"); - private final ApiUrl tmdbMovieReleaseInfo = new ApiUrl(this, BASE_MOVIE, "/releases"); - private final ApiUrl tmdbMovieTrailers = new ApiUrl(this, BASE_MOVIE, "/trailers"); - private final ApiUrl tmdbMovieTranslations = new ApiUrl(this, BASE_MOVIE, "/translations"); - private final ApiUrl tmdbMovieSimilarMovies = new ApiUrl(this, BASE_MOVIE, "/similar_movies"); - private final ApiUrl tmdbLatestMovie = new ApiUrl(this, BASE_MOVIE, "/latest"); - private final ApiUrl tmdbUpcoming = new ApiUrl(this, BASE_MOVIE, "upcoming"); - private final ApiUrl tmdbNowPlaying = new ApiUrl(this, BASE_MOVIE, "now-playing"); - private final ApiUrl tmdbPopularMovieList = new ApiUrl(this, BASE_MOVIE, "popular"); - private final ApiUrl tmdbTopRatedMovies = new ApiUrl(this, BASE_MOVIE, "top-rated"); - private final ApiUrl tmdbPostRating = new ApiUrl(this, BASE_MOVIE, "/rating"); - // Collections - private final ApiUrl tmdbCollectionInfo = new ApiUrl(this, BASE_COLLECTION); - private final ApiUrl tmdbCollectionImages = new ApiUrl(this, BASE_COLLECTION, "/images"); - // People - private final ApiUrl tmdbPersonInfo = new ApiUrl(this, BASE_PERSON); - private final ApiUrl tmdbPersonCredits = new ApiUrl(this, BASE_PERSON, "/credits"); - private final ApiUrl tmdbPersonImages = new ApiUrl(this, BASE_PERSON, "/images"); - // Companies - private final ApiUrl tmdbCompanyInfo = new ApiUrl(this, BASE_COMPANY); - private final ApiUrl tmdbCompanyMovies = new ApiUrl(this, BASE_COMPANY, "/movies"); - // Genres - private final ApiUrl tmdbGenreList = new ApiUrl(this, BASE_GENRE, "/list"); - private final ApiUrl tmdbGenreMovies = new ApiUrl(this, BASE_GENRE, "/movies"); - // Search - private final ApiUrl tmdbSearchMovie = new ApiUrl(this, BASE_SEARCH, "movie"); - private final ApiUrl tmdbSearchPeople = new ApiUrl(this, BASE_SEARCH, "person"); - private final ApiUrl tmdbSearchCompanies = new ApiUrl(this, BASE_SEARCH, "company"); - + /* + private final ApiUrl tmdbAccount = new ApiUrl(this, BASE_ACCOUNT); + private final ApiUrl tmdbFavouriteMovies = new ApiUrl(this, BASE_ACCOUNT, "/favorite_movies"); + private final ApiUrl tmdbPostFavourite = new ApiUrl(this, BASE_ACCOUNT, "/favorite"); + private final ApiUrl tmdbRatedMovies = new ApiUrl(this, BASE_ACCOUNT, "/rated_movies"); + private final ApiUrl tmdbMovieWatchList = new ApiUrl(this, BASE_ACCOUNT, "/movie_watchlist"); + private final ApiUrl tmdbPostMovieWatchList = new ApiUrl(this, BASE_ACCOUNT, "/movie_watchlist"); + */ /* * Jackson JSON configuration */ @@ -114,7 +78,8 @@ public class TheMovieDb { */ public TheMovieDb(String apiKey) throws MovieDbException { this.apiKey = apiKey; - URL configUrl = tmdbConfigUrl.buildUrl(); + ApiUrl apiUrl = new ApiUrl(this, "configuration"); + URL configUrl = apiUrl.buildUrl(); String webpage = WebBrowser.request(configUrl); FilteringLayout.addReplacementString(apiKey); @@ -193,7 +158,7 @@ public class TheMovieDb { return false; } - if (StringUtils.isNotBlank(year) && !year.equalsIgnoreCase("UNKNOWN") && StringUtils.isNotBlank(moviedb.getReleaseDate())) { + if (isValidYear(year) && isValidYear(moviedb.getReleaseDate())) { // Compare with year String movieYear = moviedb.getReleaseDate().substring(0, 4); if (movieYear.equals(year)) { @@ -219,6 +184,16 @@ public class TheMovieDb { return false; } + /** + * Check the year is not blank or UNKNOWN + * + * @param year + * @return + */ + private static boolean isValidYear(String year) { + return (StringUtils.isNotBlank(year) && !year.equals("UNKNOWN")); + } + // /** * Get the configuration information @@ -269,7 +244,9 @@ public class TheMovieDb { * @throws MovieDbException */ public TokenAuthorisation getAuthorisationToken() throws MovieDbException { - URL url = tmdbAuthorisationToken.buildUrl(); + ApiUrl apiUrl = new ApiUrl(this, BASE_AUTH, "token/new"); + + URL url = apiUrl.buildUrl(); String webpage = WebBrowser.request(url); try { @@ -290,13 +267,15 @@ public class TheMovieDb { * @throws MovieDbException */ public TokenSession getSessionToken(TokenAuthorisation token) throws MovieDbException { + ApiUrl apiUrl = new ApiUrl(this, BASE_AUTH, "session/new"); + if (!token.getSuccess()) { LOGGER.warn("Authorisation token was not successful!"); throw new MovieDbException(MovieDbExceptionType.AUTHORISATION_FAILURE, "Authorisation token was not successful!"); } - tmdbAuthorisationSession.addArgument(ApiUrl.PARAM_TOKEN, token.getRequestToken()); - URL url = tmdbAuthorisationSession.buildUrl(); + apiUrl.addArgument(PARAM_TOKEN, token.getRequestToken()); + URL url = apiUrl.buildUrl(); String webpage = WebBrowser.request(url); try { @@ -324,14 +303,15 @@ public class TheMovieDb { * @throws MovieDbException */ public MovieDb getMovieInfo(int movieId, String language) throws MovieDbException { + ApiUrl apiUrl = new ApiUrl(this, BASE_MOVIE); - tmdbMovieInfo.addArgument(ApiUrl.PARAM_ID, movieId); + apiUrl.addArgument(PARAM_ID, movieId); if (StringUtils.isNotBlank(language)) { - tmdbMovieInfo.addArgument(ApiUrl.PARAM_LANGUAGE, language); + apiUrl.addArgument(PARAM_LANGUAGE, language); } - URL url = tmdbMovieInfo.buildUrl(); + URL url = apiUrl.buildUrl(); String webpage = WebBrowser.request(url); try { return mapper.readValue(webpage, MovieDb.class); @@ -352,14 +332,15 @@ public class TheMovieDb { * @throws MovieDbException */ public MovieDb getMovieInfoImdb(String imdbId, String language) throws MovieDbException { + ApiUrl apiUrl = new ApiUrl(this, BASE_MOVIE); - tmdbMovieInfo.addArgument(ApiUrl.PARAM_ID, imdbId); + apiUrl.addArgument(PARAM_ID, imdbId); if (StringUtils.isNotBlank(language)) { - tmdbMovieInfo.addArgument(ApiUrl.PARAM_LANGUAGE, language); + apiUrl.addArgument(PARAM_LANGUAGE, language); } - URL url = tmdbMovieInfo.buildUrl(); + URL url = apiUrl.buildUrl(); String webpage = WebBrowser.request(url); try { return mapper.readValue(webpage, MovieDb.class); @@ -378,13 +359,14 @@ public class TheMovieDb { * @throws MovieDbException */ public List getMovieAlternativeTitles(int movieId, String country) throws MovieDbException { - tmdbMovieAltTitles.addArgument(ApiUrl.PARAM_ID, movieId); + ApiUrl apiUrl = new ApiUrl(this, BASE_MOVIE, "/alternative_titles"); + apiUrl.addArgument(PARAM_ID, movieId); if (StringUtils.isNotBlank(country)) { - tmdbMovieAltTitles.addArgument(ApiUrl.PARAM_COUNTRY, country); + apiUrl.addArgument(PARAM_COUNTRY, country); } - URL url = tmdbMovieAltTitles.buildUrl(); + URL url = apiUrl.buildUrl(); String webpage = WebBrowser.request(url); try { WrapperAlternativeTitles wrapper = mapper.readValue(webpage, WrapperAlternativeTitles.class); @@ -407,8 +389,9 @@ public class TheMovieDb { public List getMovieCasts(int movieId) throws MovieDbException { List people = new ArrayList(); - tmdbMovieCasts.addArgument(ApiUrl.PARAM_ID, movieId); - URL url = tmdbMovieCasts.buildUrl(); + ApiUrl apiUrl = new ApiUrl(this, BASE_MOVIE, "/casts"); + apiUrl.addArgument(PARAM_ID, movieId); + URL url = apiUrl.buildUrl(); String webpage = WebBrowser.request(url); try { @@ -444,15 +427,15 @@ public class TheMovieDb { * @throws MovieDbException */ public List getMovieImages(int movieId, String language) throws MovieDbException { - - tmdbMovieImages.addArgument(ApiUrl.PARAM_ID, movieId); + ApiUrl apiUrl = new ApiUrl(this, BASE_MOVIE, "/images"); + apiUrl.addArgument(PARAM_ID, movieId); if (StringUtils.isNotBlank(language)) { - tmdbMovieImages.addArgument(ApiUrl.PARAM_LANGUAGE, language); + apiUrl.addArgument(PARAM_LANGUAGE, language); } List artwork = new ArrayList(); - URL url = tmdbMovieImages.buildUrl(); + URL url = apiUrl.buildUrl(); String webpage = WebBrowser.request(url); try { WrapperImages wrapper = mapper.readValue(webpage, WrapperImages.class); @@ -486,10 +469,10 @@ public class TheMovieDb { * @throws MovieDbException */ public List getMovieKeywords(int movieId) throws MovieDbException { + ApiUrl apiUrl = new ApiUrl(this, BASE_MOVIE, "/keywords"); + apiUrl.addArgument(PARAM_ID, movieId); - tmdbMovieKeywords.addArgument(ApiUrl.PARAM_ID, movieId); - - URL url = tmdbMovieKeywords.buildUrl(); + URL url = apiUrl.buildUrl(); String webpage = WebBrowser.request(url); try { @@ -510,11 +493,11 @@ public class TheMovieDb { * @throws MovieDbException */ public List getMovieReleaseInfo(int movieId, String language) throws MovieDbException { + ApiUrl apiUrl = new ApiUrl(this, BASE_MOVIE, "/releases"); + apiUrl.addArgument(PARAM_ID, movieId); + apiUrl.addArgument(PARAM_LANGUAGE, language); - tmdbMovieReleaseInfo.addArgument(ApiUrl.PARAM_ID, movieId); - tmdbMovieReleaseInfo.addArgument(ApiUrl.PARAM_LANGUAGE, language); - - URL url = tmdbMovieReleaseInfo.buildUrl(); + URL url = apiUrl.buildUrl(); String webpage = WebBrowser.request(url); try { @@ -537,16 +520,16 @@ public class TheMovieDb { * @throws MovieDbException */ public List getMovieTrailers(int movieId, String language) throws MovieDbException { - List trailers = new ArrayList(); - tmdbMovieTrailers.addArgument(ApiUrl.PARAM_ID, movieId); + ApiUrl apiUrl = new ApiUrl(this, BASE_MOVIE, "/trailers"); + apiUrl.addArgument(PARAM_ID, movieId); if (StringUtils.isNotBlank(language)) { - tmdbMovieTrailers.addArgument(ApiUrl.PARAM_LANGUAGE, language); + apiUrl.addArgument(PARAM_LANGUAGE, language); } - URL url = tmdbMovieTrailers.buildUrl(); + URL url = apiUrl.buildUrl(); String webpage = WebBrowser.request(url); try { @@ -577,9 +560,10 @@ public class TheMovieDb { * @throws MovieDbException */ public List getMovieTranslations(int movieId) throws MovieDbException { + ApiUrl apiUrl = new ApiUrl(this, BASE_MOVIE, "/translations"); + apiUrl.addArgument(PARAM_ID, movieId); - tmdbMovieTranslations.addArgument(ApiUrl.PARAM_ID, movieId); - URL url = tmdbMovieTranslations.buildUrl(); + URL url = apiUrl.buildUrl(); String webpage = WebBrowser.request(url); try { @@ -605,17 +589,18 @@ public class TheMovieDb { * @throws MovieDbException */ public List getSimilarMovies(int movieId, String language, int page) throws MovieDbException { - tmdbMovieSimilarMovies.addArgument(ApiUrl.PARAM_ID, movieId); + ApiUrl apiUrl = new ApiUrl(this, BASE_MOVIE, "/similar_movies"); + apiUrl.addArgument(PARAM_ID, movieId); if (StringUtils.isNotBlank(language)) { - tmdbMovieSimilarMovies.addArgument(ApiUrl.PARAM_LANGUAGE, language); + apiUrl.addArgument(PARAM_LANGUAGE, language); } if (page > 0) { - tmdbMovieSimilarMovies.addArgument(ApiUrl.PARAM_PAGE, page); + apiUrl.addArgument(PARAM_PAGE, page); } - URL url = tmdbMovieSimilarMovies.buildUrl(); + URL url = apiUrl.buildUrl(); String webpage = WebBrowser.request(url); try { @@ -633,8 +618,8 @@ public class TheMovieDb { * @return */ public MovieDb getLatestMovie() throws MovieDbException { - - URL url = tmdbLatestMovie.buildUrl(); + ApiUrl apiUrl = new ApiUrl(this, BASE_MOVIE, "/latest"); + URL url = apiUrl.buildUrl(); String webpage = WebBrowser.request(url); try { @@ -656,15 +641,17 @@ public class TheMovieDb { * @throws MovieDbException */ public List getUpcoming(String language, int page) throws MovieDbException { + ApiUrl apiUrl = new ApiUrl(this, BASE_MOVIE, "upcoming"); + if (StringUtils.isNotBlank(language)) { - tmdbUpcoming.addArgument(ApiUrl.PARAM_LANGUAGE, language); + apiUrl.addArgument(PARAM_LANGUAGE, language); } if (page > 0) { - tmdbUpcoming.addArgument(ApiUrl.PARAM_PAGE, page); + apiUrl.addArgument(PARAM_PAGE, page); } - URL url = tmdbUpcoming.buildUrl(); + URL url = apiUrl.buildUrl(); String webpage = WebBrowser.request(url); try { @@ -690,16 +677,17 @@ public class TheMovieDb { * @throws MovieDbException */ public List getNowPlayingMovies(String language, int page) throws MovieDbException { + ApiUrl apiUrl = new ApiUrl(this, BASE_MOVIE, "now-playing"); if (StringUtils.isNotBlank(language)) { - tmdbNowPlaying.addArgument(ApiUrl.PARAM_LANGUAGE, language); + apiUrl.addArgument(PARAM_LANGUAGE, language); } if (page > 0) { - tmdbNowPlaying.addArgument(ApiUrl.PARAM_PAGE, page); + apiUrl.addArgument(PARAM_PAGE, page); } - URL url = tmdbNowPlaying.buildUrl(); + URL url = apiUrl.buildUrl(); String webpage = WebBrowser.request(url); try { @@ -724,15 +712,17 @@ public class TheMovieDb { * @throws MovieDbException */ public List getPopularMovieList(String language, int page) throws MovieDbException { + ApiUrl apiUrl = new ApiUrl(this, BASE_MOVIE, "popular"); + if (StringUtils.isNotBlank(language)) { - tmdbPopularMovieList.addArgument(ApiUrl.PARAM_LANGUAGE, language); + apiUrl.addArgument(PARAM_LANGUAGE, language); } if (page > 0) { - tmdbPopularMovieList.addArgument(ApiUrl.PARAM_PAGE, page); + apiUrl.addArgument(PARAM_PAGE, page); } - URL url = tmdbPopularMovieList.buildUrl(); + URL url = apiUrl.buildUrl(); String webpage = WebBrowser.request(url); try { @@ -757,15 +747,17 @@ public class TheMovieDb { * @throws MovieDbException */ public List getTopRatedMovies(String language, int page) throws MovieDbException { + ApiUrl apiUrl = new ApiUrl(this, BASE_MOVIE, "top-rated"); + if (StringUtils.isNotBlank(language)) { - tmdbTopRatedMovies.addArgument(ApiUrl.PARAM_LANGUAGE, language); + apiUrl.addArgument(PARAM_LANGUAGE, language); } if (page > 0) { - tmdbTopRatedMovies.addArgument(ApiUrl.PARAM_PAGE, page); + apiUrl.addArgument(PARAM_PAGE, page); } - URL url = tmdbTopRatedMovies.buildUrl(); + URL url = apiUrl.buildUrl(); String webpage = WebBrowser.request(url); try { @@ -788,9 +780,10 @@ public class TheMovieDb { * @throws MovieDbException */ public boolean postMovieRating(String sessionId, String rating) throws MovieDbException { + ApiUrl apiUrl = new ApiUrl(this, BASE_MOVIE, "/rating"); - tmdbPostRating.addArgument(ApiUrl.PARAM_SESSION, sessionId); - tmdbPostRating.addArgument(ApiUrl.PARAM_VALUE, rating); + apiUrl.addArgument(PARAM_SESSION, sessionId); + apiUrl.addArgument(PARAM_VALUE, rating); throw new MovieDbException(MovieDbExceptionType.UNKNOWN_CAUSE, "Not implemented yet"); } @@ -809,14 +802,14 @@ public class TheMovieDb { * @throws MovieDbException */ public CollectionInfo getCollectionInfo(int collectionId, String language) throws MovieDbException { - - tmdbCollectionInfo.addArgument(ApiUrl.PARAM_ID, collectionId); + ApiUrl apiUrl = new ApiUrl(this, BASE_COLLECTION); + apiUrl.addArgument(PARAM_ID, collectionId); if (StringUtils.isNotBlank(language)) { - tmdbCollectionInfo.addArgument(ApiUrl.PARAM_LANGUAGE, language); + apiUrl.addArgument(PARAM_LANGUAGE, language); } - URL url = tmdbCollectionInfo.buildUrl(); + URL url = apiUrl.buildUrl(); String webpage = WebBrowser.request(url); try { @@ -837,14 +830,14 @@ public class TheMovieDb { */ public List getCollectionImages(int collectionId, String language) throws MovieDbException { List artwork = new ArrayList(); - - tmdbCollectionImages.addArgument(ApiUrl.PARAM_ID, collectionId); + ApiUrl apiUrl = new ApiUrl(this, BASE_COLLECTION, "/images"); + apiUrl.addArgument(PARAM_ID, collectionId); if (StringUtils.isNotBlank(language)) { - tmdbCollectionImages.addArgument(ApiUrl.PARAM_LANGUAGE, language); + apiUrl.addArgument(PARAM_LANGUAGE, language); } - URL url = tmdbCollectionImages.buildUrl(); + URL url = apiUrl.buildUrl(); String webpage = WebBrowser.request(url); try { @@ -883,10 +876,11 @@ public class TheMovieDb { * @throws MovieDbException */ public Person getPersonInfo(int personId) throws MovieDbException { + ApiUrl apiUrl = new ApiUrl(this, BASE_PERSON); - tmdbPersonInfo.addArgument(ApiUrl.PARAM_ID, personId); + apiUrl.addArgument(PARAM_ID, personId); - URL url = tmdbPersonInfo.buildUrl(); + URL url = apiUrl.buildUrl(); String webpage = WebBrowser.request(url); try { @@ -907,12 +901,13 @@ public class TheMovieDb { * @throws MovieDbException */ public List getPersonCredits(int personId) throws MovieDbException { + ApiUrl apiUrl = new ApiUrl(this, BASE_PERSON, "/credits"); List personCredits = new ArrayList(); - tmdbPersonCredits.addArgument(ApiUrl.PARAM_ID, personId); + apiUrl.addArgument(PARAM_ID, personId); - URL url = tmdbPersonCredits.buildUrl(); + URL url = apiUrl.buildUrl(); String webpage = WebBrowser.request(url); try { @@ -943,12 +938,13 @@ public class TheMovieDb { * @throws MovieDbException */ public List getPersonImages(int personId) throws MovieDbException { + ApiUrl apiUrl = new ApiUrl(this, BASE_PERSON, "/images"); List personImages = new ArrayList(); - tmdbPersonImages.addArgument(ApiUrl.PARAM_ID, personId); + apiUrl.addArgument(PARAM_ID, personId); - URL url = tmdbPersonImages.buildUrl(); + URL url = apiUrl.buildUrl(); String webpage = WebBrowser.request(url); try { @@ -977,10 +973,11 @@ public class TheMovieDb { * @throws MovieDbException */ public Company getCompanyInfo(int companyId) throws MovieDbException { + ApiUrl apiUrl = new ApiUrl(this, BASE_COMPANY); - tmdbCompanyInfo.addArgument(ApiUrl.PARAM_ID, companyId); + apiUrl.addArgument(PARAM_ID, companyId); - URL url = tmdbCompanyInfo.buildUrl(); + URL url = apiUrl.buildUrl(); String webpage = WebBrowser.request(url); try { @@ -1006,18 +1003,19 @@ public class TheMovieDb { * @throws MovieDbException */ public List getCompanyMovies(int companyId, String language, int page) throws MovieDbException { + ApiUrl apiUrl = new ApiUrl(this, BASE_COMPANY, "/movies"); - tmdbCompanyMovies.addArgument(ApiUrl.PARAM_ID, companyId); + apiUrl.addArgument(PARAM_ID, companyId); if (StringUtils.isNotBlank(language)) { - tmdbCompanyMovies.addArgument(ApiUrl.PARAM_LANGUAGE, language); + apiUrl.addArgument(PARAM_LANGUAGE, language); } if (page > 0) { - tmdbCompanyMovies.addArgument(ApiUrl.PARAM_PAGE, page); + apiUrl.addArgument(PARAM_PAGE, page); } - URL url = tmdbCompanyMovies.buildUrl(); + URL url = apiUrl.buildUrl(); String webpage = WebBrowser.request(url); try { @@ -1041,9 +1039,10 @@ public class TheMovieDb { * @return */ public List getGenreList(String language) throws MovieDbException { - tmdbGenreList.addArgument(ApiUrl.PARAM_LANGUAGE, language); + ApiUrl apiUrl = new ApiUrl(this, BASE_GENRE, "/list"); + apiUrl.addArgument(PARAM_LANGUAGE, language); - URL url = tmdbGenreList.buildUrl(); + URL url = apiUrl.buildUrl(); String webpage = WebBrowser.request(url); try { @@ -1068,18 +1067,18 @@ public class TheMovieDb { * @return */ public List getGenreMovies(int genreId, String language, int page) throws MovieDbException { - - tmdbGenreMovies.addArgument(ApiUrl.PARAM_ID, genreId); + ApiUrl apiUrl = new ApiUrl(this, BASE_GENRE, "/movies"); + apiUrl.addArgument(PARAM_ID, genreId); if (StringUtils.isNotBlank(language)) { - tmdbGenreMovies.addArgument(ApiUrl.PARAM_LANGUAGE, language); + apiUrl.addArgument(PARAM_LANGUAGE, language); } if (page > 0) { - tmdbGenreMovies.addArgument(ApiUrl.PARAM_PAGE, page); + apiUrl.addArgument(PARAM_PAGE, page); } - URL url = tmdbGenreMovies.buildUrl(); + URL url = apiUrl.buildUrl(); String webpage = WebBrowser.request(url); try { @@ -1106,25 +1105,26 @@ public class TheMovieDb { * @throws MovieDbException */ public List searchMovie(String movieName, int searchYear, String language, boolean includeAdult, int page) throws MovieDbException { + ApiUrl apiUrl = new ApiUrl(this, BASE_SEARCH, "movie"); if (StringUtils.isNotBlank(movieName)) { - tmdbSearchMovie.addArgument(ApiUrl.PARAM_QUERY, movieName); + apiUrl.addArgument(PARAM_QUERY, movieName); } if (searchYear > 0) { - tmdbSearchMovie.addArgument(ApiUrl.PARAM_YEAR, Integer.toString(searchYear)); + apiUrl.addArgument(PARAM_YEAR, Integer.toString(searchYear)); } if (StringUtils.isNotBlank(language)) { - tmdbSearchMovie.addArgument(ApiUrl.PARAM_LANGUAGE, language); + apiUrl.addArgument(PARAM_LANGUAGE, language); } - tmdbSearchMovie.addArgument(ApiUrl.PARAM_ADULT, Boolean.toString(includeAdult)); + apiUrl.addArgument(PARAM_ADULT, Boolean.toString(includeAdult)); if (page > 0) { - tmdbSearchMovie.addArgument(ApiUrl.PARAM_PAGE, Integer.toString(page)); + apiUrl.addArgument(PARAM_PAGE, Integer.toString(page)); } - URL url = tmdbSearchMovie.buildUrl(); + URL url = apiUrl.buildUrl(); LOGGER.info(url.toString()); String webpage = WebBrowser.request(url); @@ -1152,13 +1152,14 @@ public class TheMovieDb { * @throws MovieDbException */ public List searchCompanies(String companyName, int page) throws MovieDbException { - tmdbSearchCompanies.addArgument(ApiUrl.PARAM_QUERY, companyName); + ApiUrl apiUrl = new ApiUrl(this, BASE_SEARCH, "company"); + apiUrl.addArgument(PARAM_QUERY, companyName); if (page > 0) { - tmdbSearchCompanies.addArgument(ApiUrl.PARAM_PAGE, page); + apiUrl.addArgument(PARAM_PAGE, page); } - URL url = tmdbSearchCompanies.buildUrl(); + URL url = apiUrl.buildUrl(); String webpage = WebBrowser.request(url); try { WrapperCompany wrapper = mapper.readValue(webpage, WrapperCompany.class); @@ -1182,14 +1183,15 @@ public class TheMovieDb { * @throws MovieDbException */ public List searchPeople(String personName, boolean includeAdult, int page) throws MovieDbException { - tmdbSearchPeople.addArgument(ApiUrl.PARAM_QUERY, personName); - tmdbSearchPeople.addArgument(ApiUrl.PARAM_ADULT, includeAdult); + ApiUrl apiUrl = new ApiUrl(this, BASE_SEARCH, "person"); + apiUrl.addArgument(PARAM_QUERY, personName); + apiUrl.addArgument(PARAM_ADULT, includeAdult); if (page > 0) { - tmdbSearchPeople.addArgument(ApiUrl.PARAM_PAGE, page); + apiUrl.addArgument(PARAM_PAGE, page); } - URL url = tmdbSearchPeople.buildUrl(); + URL url = apiUrl.buildUrl(); String webpage = WebBrowser.request(url); try { From 7d71a143b05f4ccc3710ab6f1e04dab25b09f8e2 Mon Sep 17 00:00:00 2001 From: Omertron Date: Sun, 21 Oct 2012 20:01:34 +0000 Subject: [PATCH 148/207] Added status to MovieDb object --- .../com/moviejukebox/themoviedb/model/MovieDb.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/MovieDb.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/MovieDb.java index fb0bc4c81..4d07c47d3 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/MovieDb.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/MovieDb.java @@ -77,6 +77,8 @@ public class MovieDb implements Serializable { private float voteAverage; @JsonProperty("vote_count") private int voteCount; + @JsonProperty("status") + private String status; // public String getBackdropPath() { @@ -166,6 +168,10 @@ public class MovieDb implements Serializable { public int getVoteCount() { return voteCount; } + + public String getStatus() { + return status; + } // // @@ -256,6 +262,11 @@ public class MovieDb implements Serializable { public void setVoteCount(int voteCount) { this.voteCount = voteCount; } + + public void setStatus(String status) { + this.status = status; + } + // /** @@ -329,6 +340,7 @@ public class MovieDb implements Serializable { sb.append("],[tagline=").append(tagline); sb.append("],[voteAverage=").append(voteAverage); sb.append("],[voteCount=").append(voteCount); + sb.append("],[status=").append(status); sb.append("]]"); return sb.toString(); } From a25cc744d73560ef15d2c93ec16007843d4159b4 Mon Sep 17 00:00:00 2001 From: Omertron Date: Tue, 23 Oct 2012 12:23:04 +0000 Subject: [PATCH 149/207] Removed debug message --- .../src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java | 1 - 1 file changed, 1 deletion(-) diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java index 0bc97afb6..b4a9903fa 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java @@ -1125,7 +1125,6 @@ public class TheMovieDb { } URL url = apiUrl.buildUrl(); - LOGGER.info(url.toString()); String webpage = WebBrowser.request(url); try { From 95bf1af07e4d8e0e1f7bbbd444c39877270297b7 Mon Sep 17 00:00:00 2001 From: Omertron Date: Wed, 24 Oct 2012 20:58:22 +0000 Subject: [PATCH 150/207] Change missing attribute message to TRACE level --- .../themoviedb/model/AlternativeTitle.java | 2 +- .../com/moviejukebox/themoviedb/model/Artwork.java | 2 +- .../moviejukebox/themoviedb/model/Collection.java | 2 +- .../themoviedb/model/CollectionInfo.java | 2 +- .../com/moviejukebox/themoviedb/model/Company.java | 2 +- .../com/moviejukebox/themoviedb/model/Genre.java | 2 +- .../com/moviejukebox/themoviedb/model/Keyword.java | 2 +- .../moviejukebox/themoviedb/model/Language.java | 2 +- .../com/moviejukebox/themoviedb/model/MovieDb.java | 2 +- .../com/moviejukebox/themoviedb/model/Person.java | 2 +- .../moviejukebox/themoviedb/model/PersonCast.java | 14 +++++++++++++- .../themoviedb/model/PersonCredit.java | 2 +- .../moviejukebox/themoviedb/model/PersonCrew.java | 2 +- .../themoviedb/model/ProductionCompany.java | 2 +- .../themoviedb/model/ProductionCountry.java | 2 +- .../moviejukebox/themoviedb/model/ReleaseInfo.java | 2 +- .../moviejukebox/themoviedb/model/StatusCode.java | 2 +- .../themoviedb/model/TmdbConfiguration.java | 2 +- .../themoviedb/model/TokenAuthorisation.java | 2 +- .../themoviedb/model/TokenSession.java | 2 +- .../com/moviejukebox/themoviedb/model/Trailer.java | 2 +- .../moviejukebox/themoviedb/model/Translation.java | 2 +- .../wrapper/WrapperAlternativeTitles.java | 2 +- .../themoviedb/wrapper/WrapperCompany.java | 2 +- .../themoviedb/wrapper/WrapperCompanyMovies.java | 2 +- .../themoviedb/wrapper/WrapperConfig.java | 2 +- .../themoviedb/wrapper/WrapperGenres.java | 2 +- .../themoviedb/wrapper/WrapperImages.java | 2 +- .../themoviedb/wrapper/WrapperMovie.java | 2 +- .../themoviedb/wrapper/WrapperMovieCasts.java | 2 +- .../themoviedb/wrapper/WrapperMovieKeywords.java | 2 +- .../themoviedb/wrapper/WrapperPerson.java | 2 +- .../themoviedb/wrapper/WrapperPersonCredits.java | 2 +- .../themoviedb/wrapper/WrapperReleaseInfo.java | 2 +- .../themoviedb/wrapper/WrapperTrailers.java | 2 +- .../themoviedb/wrapper/WrapperTranslations.java | 2 +- 36 files changed, 48 insertions(+), 36 deletions(-) diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/AlternativeTitle.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/AlternativeTitle.java index 557b09fd1..5a47b033b 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/AlternativeTitle.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/AlternativeTitle.java @@ -68,7 +68,7 @@ public class AlternativeTitle implements Serializable { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - LOGGER.warn(sb.toString()); + LOGGER.trace(sb.toString()); } @Override diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Artwork.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Artwork.java index 9dd1d200c..cb1a67edd 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Artwork.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Artwork.java @@ -128,7 +128,7 @@ public class Artwork implements Serializable { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - LOGGER.warn(sb.toString()); + LOGGER.trace(sb.toString()); } @Override diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Collection.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Collection.java index 0eeddaf10..cb52c61d0 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Collection.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Collection.java @@ -116,7 +116,7 @@ public class Collection implements Serializable { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - LOGGER.warn(sb.toString()); + LOGGER.trace(sb.toString()); } @Override diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/CollectionInfo.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/CollectionInfo.java index ca3fdcd82..065000d9b 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/CollectionInfo.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/CollectionInfo.java @@ -99,7 +99,7 @@ public class CollectionInfo implements Serializable { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - LOGGER.warn(sb.toString()); + LOGGER.trace(sb.toString()); } @Override diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Company.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Company.java index 9c4a3675c..8e3a6e592 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Company.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Company.java @@ -115,7 +115,7 @@ public class Company implements Serializable { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - LOGGER.warn(sb.toString()); + LOGGER.trace(sb.toString()); } @Override diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Genre.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Genre.java index 9cfd58b0d..05134b615 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Genre.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Genre.java @@ -69,7 +69,7 @@ public class Genre implements Serializable { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - LOGGER.warn(sb.toString()); + LOGGER.trace(sb.toString()); } @Override diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Keyword.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Keyword.java index 93422debc..d1ed3fb06 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Keyword.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Keyword.java @@ -70,7 +70,7 @@ public class Keyword implements Serializable { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - LOGGER.warn(sb.toString()); + LOGGER.trace(sb.toString()); } @Override diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Language.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Language.java index 279839c14..ef1caeb64 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Language.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Language.java @@ -69,7 +69,7 @@ public class Language implements Serializable { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - LOGGER.warn(sb.toString()); + LOGGER.trace(sb.toString()); } @Override diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/MovieDb.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/MovieDb.java index 4d07c47d3..23beddb79 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/MovieDb.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/MovieDb.java @@ -280,7 +280,7 @@ public class MovieDb implements Serializable { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - LOGGER.warn(sb.toString()); + LOGGER.trace(sb.toString()); } // diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Person.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Person.java index c69a0f2ab..ce0a11ac6 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Person.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Person.java @@ -242,7 +242,7 @@ public class Person implements Serializable { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - LOGGER.warn(sb.toString()); + LOGGER.trace(sb.toString()); } @Override diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/PersonCast.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/PersonCast.java index ef3b3e1a1..de25decaf 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/PersonCast.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/PersonCast.java @@ -42,6 +42,8 @@ public class PersonCast implements Serializable { private int order; @JsonProperty("profile_path") private String profilePath; + @JsonProperty("cast_id") + private int castId; // public String getCharacter() { @@ -63,6 +65,11 @@ public class PersonCast implements Serializable { public String getProfilePath() { return profilePath; } + + public int getCastId() { + return castId; + } + // // @@ -85,6 +92,11 @@ public class PersonCast implements Serializable { public void setProfilePath(String profilePath) { this.profilePath = profilePath; } + + public void setCastId(int castId) { + this.castId = castId; + } + // /** @@ -98,7 +110,7 @@ public class PersonCast implements Serializable { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - LOGGER.warn(sb.toString()); + LOGGER.trace(sb.toString()); } @Override diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/PersonCredit.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/PersonCredit.java index 27e06e3ec..e622db30a 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/PersonCredit.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/PersonCredit.java @@ -148,7 +148,7 @@ public class PersonCredit implements Serializable { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - LOGGER.warn(sb.toString()); + LOGGER.trace(sb.toString()); } @Override diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/PersonCrew.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/PersonCrew.java index 2d704fe4c..86aa54c8d 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/PersonCrew.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/PersonCrew.java @@ -98,7 +98,7 @@ public class PersonCrew implements Serializable { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - LOGGER.warn(sb.toString()); + LOGGER.trace(sb.toString()); } @Override diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/ProductionCompany.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/ProductionCompany.java index 28da81bf4..cd3be8618 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/ProductionCompany.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/ProductionCompany.java @@ -70,7 +70,7 @@ public class ProductionCompany implements Serializable { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - LOGGER.warn(sb.toString()); + LOGGER.trace(sb.toString()); } @Override diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/ProductionCountry.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/ProductionCountry.java index 4dc6b63c4..fb389e5a4 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/ProductionCountry.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/ProductionCountry.java @@ -70,7 +70,7 @@ public class ProductionCountry implements Serializable { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - LOGGER.warn(sb.toString()); + LOGGER.trace(sb.toString()); } @Override diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/ReleaseInfo.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/ReleaseInfo.java index 0f85bed17..aee789515 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/ReleaseInfo.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/ReleaseInfo.java @@ -78,7 +78,7 @@ public class ReleaseInfo implements Serializable { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - LOGGER.warn(sb.toString()); + LOGGER.trace(sb.toString()); } @Override diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/StatusCode.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/StatusCode.java index 082efe537..71112bbfa 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/StatusCode.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/StatusCode.java @@ -68,7 +68,7 @@ public class StatusCode implements Serializable { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - LOGGER.warn(sb.toString()); + LOGGER.trace(sb.toString()); } @Override diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/TmdbConfiguration.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/TmdbConfiguration.java index 40d3f5f74..cea898a49 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/TmdbConfiguration.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/TmdbConfiguration.java @@ -177,7 +177,7 @@ public class TmdbConfiguration implements Serializable { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - LOGGER.warn(sb.toString()); + LOGGER.trace(sb.toString()); } @Override diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/TokenAuthorisation.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/TokenAuthorisation.java index 07543972f..8407b811c 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/TokenAuthorisation.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/TokenAuthorisation.java @@ -70,7 +70,7 @@ public class TokenAuthorisation { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - LOGGER.warn(sb.toString()); + LOGGER.trace(sb.toString()); } @Override diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/TokenSession.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/TokenSession.java index 1e6ff9b1b..d3542ec30 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/TokenSession.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/TokenSession.java @@ -80,7 +80,7 @@ public class TokenSession { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - LOGGER.warn(sb.toString()); + LOGGER.trace(sb.toString()); } @Override diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Trailer.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Trailer.java index 2da366121..91967612f 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Trailer.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Trailer.java @@ -88,7 +88,7 @@ public class Trailer implements Serializable { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - LOGGER.warn(sb.toString()); + LOGGER.trace(sb.toString()); } @Override diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Translation.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Translation.java index dbee8f1d2..d3b5dcf5b 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Translation.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Translation.java @@ -78,7 +78,7 @@ public class Translation implements Serializable { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - LOGGER.warn(sb.toString()); + LOGGER.trace(sb.toString()); } @Override diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperAlternativeTitles.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperAlternativeTitles.java index fd0669dbd..a0fce3344 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperAlternativeTitles.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperAlternativeTitles.java @@ -62,6 +62,6 @@ public class WrapperAlternativeTitles { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - LOGGER.warn(sb.toString()); + LOGGER.trace(sb.toString()); } } diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperCompany.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperCompany.java index 5b14bd678..668a02056 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperCompany.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperCompany.java @@ -86,6 +86,6 @@ public class WrapperCompany { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - LOGGER.warn(sb.toString()); + LOGGER.trace(sb.toString()); } } diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperCompanyMovies.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperCompanyMovies.java index 0bdd4bee0..215ce051f 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperCompanyMovies.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperCompanyMovies.java @@ -93,7 +93,7 @@ public class WrapperCompanyMovies { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - LOGGER.warn(sb.toString()); + LOGGER.trace(sb.toString()); } @Override diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperConfig.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperConfig.java index 7da6e21de..20836c988 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperConfig.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperConfig.java @@ -51,7 +51,7 @@ public class WrapperConfig { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - LOGGER.warn(sb.toString()); + LOGGER.trace(sb.toString()); } } diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperGenres.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperGenres.java index e6dff9b87..ce263ee09 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperGenres.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperGenres.java @@ -54,6 +54,6 @@ public class WrapperGenres { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - LOGGER.warn(sb.toString()); + LOGGER.trace(sb.toString()); } } diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperImages.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperImages.java index 033eca96f..3ff66174b 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperImages.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperImages.java @@ -87,6 +87,6 @@ public class WrapperImages { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - LOGGER.warn(sb.toString()); + LOGGER.trace(sb.toString()); } } diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperMovie.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperMovie.java index 2f1331ed8..24a2dd74a 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperMovie.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperMovie.java @@ -97,7 +97,7 @@ public class WrapperMovie { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - LOGGER.warn(sb.toString()); + LOGGER.trace(sb.toString()); } @Override diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperMovieCasts.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperMovieCasts.java index 763918df5..337050bc7 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperMovieCasts.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperMovieCasts.java @@ -77,6 +77,6 @@ public class WrapperMovieCasts { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - LOGGER.warn(sb.toString()); + LOGGER.trace(sb.toString()); } } diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperMovieKeywords.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperMovieKeywords.java index df6c10f83..3b7ca0898 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperMovieKeywords.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperMovieKeywords.java @@ -66,6 +66,6 @@ public class WrapperMovieKeywords { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - LOGGER.warn(sb.toString()); + LOGGER.trace(sb.toString()); } } diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperPerson.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperPerson.java index e6d4cc6a8..474ff404d 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperPerson.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperPerson.java @@ -86,6 +86,6 @@ public class WrapperPerson { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - LOGGER.warn(sb.toString()); + LOGGER.trace(sb.toString()); } } diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperPersonCredits.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperPersonCredits.java index 034494b92..78e4169d9 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperPersonCredits.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperPersonCredits.java @@ -76,6 +76,6 @@ public class WrapperPersonCredits { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - LOGGER.warn(sb.toString()); + LOGGER.trace(sb.toString()); } } diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperReleaseInfo.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperReleaseInfo.java index 08123fd83..247228399 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperReleaseInfo.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperReleaseInfo.java @@ -66,6 +66,6 @@ public class WrapperReleaseInfo { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - LOGGER.warn(sb.toString()); + LOGGER.trace(sb.toString()); } } diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperTrailers.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperTrailers.java index e6447dffb..de8fabd17 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperTrailers.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperTrailers.java @@ -76,6 +76,6 @@ public class WrapperTrailers { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - LOGGER.warn(sb.toString()); + LOGGER.trace(sb.toString()); } } diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperTranslations.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperTranslations.java index a270ea572..c0e3417e6 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperTranslations.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperTranslations.java @@ -63,6 +63,6 @@ public class WrapperTranslations { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - LOGGER.warn(sb.toString()); + LOGGER.trace(sb.toString()); } } From 25cfa62e38e769ec2c8a9c84fbce60cd159a5af2 Mon Sep 17 00:00:00 2001 From: Omertron Date: Wed, 31 Oct 2012 11:39:00 +0000 Subject: [PATCH 151/207] Update Jackson JSON processor to v2.x --- themoviedbapi/pom.xml | 25 ++++++++++++++----- .../moviejukebox/themoviedb/TheMovieDb.java | 2 +- .../themoviedb/model/AlternativeTitle.java | 4 +-- .../themoviedb/model/Artwork.java | 4 +-- .../themoviedb/model/Collection.java | 6 ++--- .../themoviedb/model/CollectionInfo.java | 4 +-- .../themoviedb/model/Company.java | 4 +-- .../moviejukebox/themoviedb/model/Genre.java | 6 ++--- .../themoviedb/model/Keyword.java | 6 ++--- .../themoviedb/model/Language.java | 6 ++--- .../themoviedb/model/MovieDb.java | 4 +-- .../moviejukebox/themoviedb/model/Person.java | 4 +-- .../themoviedb/model/PersonCast.java | 6 ++--- .../themoviedb/model/PersonCredit.java | 4 +-- .../themoviedb/model/PersonCrew.java | 4 +-- .../themoviedb/model/ProductionCompany.java | 6 ++--- .../themoviedb/model/ProductionCountry.java | 6 ++--- .../themoviedb/model/ReleaseInfo.java | 4 +-- .../themoviedb/model/StatusCode.java | 4 +-- .../themoviedb/model/TmdbConfiguration.java | 4 +-- .../themoviedb/model/TokenAuthorisation.java | 4 +-- .../themoviedb/model/TokenSession.java | 4 +-- .../themoviedb/model/Trailer.java | 2 +- .../themoviedb/model/Translation.java | 4 +-- .../wrapper/WrapperAlternativeTitles.java | 4 +-- .../themoviedb/wrapper/WrapperCompany.java | 4 +-- .../wrapper/WrapperCompanyMovies.java | 4 +-- .../themoviedb/wrapper/WrapperConfig.java | 6 ++--- .../themoviedb/wrapper/WrapperGenres.java | 4 +-- .../themoviedb/wrapper/WrapperImages.java | 4 +-- .../themoviedb/wrapper/WrapperMovie.java | 4 +-- .../themoviedb/wrapper/WrapperMovieCasts.java | 4 +-- .../wrapper/WrapperMovieKeywords.java | 4 +-- .../themoviedb/wrapper/WrapperPerson.java | 4 +-- .../wrapper/WrapperPersonCredits.java | 4 +-- .../wrapper/WrapperReleaseInfo.java | 4 +-- .../themoviedb/wrapper/WrapperTrailers.java | 4 +-- .../wrapper/WrapperTranslations.java | 2 +- 38 files changed, 98 insertions(+), 85 deletions(-) diff --git a/themoviedbapi/pom.xml b/themoviedbapi/pom.xml index b98ef871c..90577519b 100644 --- a/themoviedbapi/pom.xml +++ b/themoviedbapi/pom.xml @@ -40,37 +40,50 @@ + junit junit 4.10 test + log4j log4j 1.2.17 + - org.codehaus.jackson - jackson-core-lgpl - 1.9.10 + com.fasterxml.jackson.core + jackson-core + 2.1.0 + - org.codehaus.jackson - jackson-mapper-lgpl - 1.9.10 + com.fasterxml.jackson.core + jackson-annotations + 2.1.0 + + + com.fasterxml.jackson.core + jackson-databind + 2.1.0 + + commons-codec commons-codec 1.7 + org.apache.commons commons-lang3 3.1 + diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java index b4a9903fa..488db554a 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java @@ -12,6 +12,7 @@ */ package com.moviejukebox.themoviedb; +import com.fasterxml.jackson.databind.ObjectMapper; import com.moviejukebox.themoviedb.MovieDbException.MovieDbExceptionType; import com.moviejukebox.themoviedb.model.*; import com.moviejukebox.themoviedb.tools.ApiUrl; @@ -26,7 +27,6 @@ import java.util.ArrayList; import java.util.List; import org.apache.commons.lang3.StringUtils; import org.apache.log4j.Logger; -import org.codehaus.jackson.map.ObjectMapper; /** * The MovieDb API diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/AlternativeTitle.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/AlternativeTitle.java index 5a47b033b..420ec6160 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/AlternativeTitle.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/AlternativeTitle.java @@ -12,10 +12,10 @@ */ package com.moviejukebox.themoviedb.model; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonProperty; import java.io.Serializable; import org.apache.log4j.Logger; -import org.codehaus.jackson.annotate.JsonAnySetter; -import org.codehaus.jackson.annotate.JsonProperty; /** * diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Artwork.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Artwork.java index cb1a67edd..ee94787ce 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Artwork.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Artwork.java @@ -12,10 +12,10 @@ */ package com.moviejukebox.themoviedb.model; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonProperty; import java.io.Serializable; import org.apache.log4j.Logger; -import org.codehaus.jackson.annotate.JsonAnySetter; -import org.codehaus.jackson.annotate.JsonProperty; /** * The artwork type information diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Collection.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Collection.java index cb52c61d0..be77b9d6a 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Collection.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Collection.java @@ -12,12 +12,12 @@ */ package com.moviejukebox.themoviedb.model; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; import java.io.Serializable; import org.apache.commons.lang3.StringUtils; import org.apache.log4j.Logger; -import org.codehaus.jackson.annotate.JsonAnySetter; -import org.codehaus.jackson.annotate.JsonProperty; -import org.codehaus.jackson.map.annotate.JsonRootName; /** * diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/CollectionInfo.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/CollectionInfo.java index 065000d9b..a49ea08fa 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/CollectionInfo.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/CollectionInfo.java @@ -12,12 +12,12 @@ */ package com.moviejukebox.themoviedb.model; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonProperty; import java.io.Serializable; import java.util.ArrayList; import java.util.List; import org.apache.log4j.Logger; -import org.codehaus.jackson.annotate.JsonAnySetter; -import org.codehaus.jackson.annotate.JsonProperty; /** * diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Company.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Company.java index 8e3a6e592..539e3a387 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Company.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Company.java @@ -12,10 +12,10 @@ */ package com.moviejukebox.themoviedb.model; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonProperty; import java.io.Serializable; import org.apache.log4j.Logger; -import org.codehaus.jackson.annotate.JsonAnySetter; -import org.codehaus.jackson.annotate.JsonProperty; /** * Company information diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Genre.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Genre.java index 05134b615..1aeb44730 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Genre.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Genre.java @@ -12,11 +12,11 @@ */ package com.moviejukebox.themoviedb.model; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; import java.io.Serializable; import org.apache.log4j.Logger; -import org.codehaus.jackson.annotate.JsonAnySetter; -import org.codehaus.jackson.annotate.JsonProperty; -import org.codehaus.jackson.map.annotate.JsonRootName; /** * diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Keyword.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Keyword.java index d1ed3fb06..0f5b72f75 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Keyword.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Keyword.java @@ -12,11 +12,11 @@ */ package com.moviejukebox.themoviedb.model; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; import java.io.Serializable; import org.apache.log4j.Logger; -import org.codehaus.jackson.annotate.JsonAnySetter; -import org.codehaus.jackson.annotate.JsonProperty; -import org.codehaus.jackson.map.annotate.JsonRootName; /** * diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Language.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Language.java index ef1caeb64..d05ded99e 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Language.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Language.java @@ -12,11 +12,11 @@ */ package com.moviejukebox.themoviedb.model; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; import java.io.Serializable; import org.apache.log4j.Logger; -import org.codehaus.jackson.annotate.JsonAnySetter; -import org.codehaus.jackson.annotate.JsonProperty; -import org.codehaus.jackson.map.annotate.JsonRootName; /** * diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/MovieDb.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/MovieDb.java index 23beddb79..15a4c8d99 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/MovieDb.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/MovieDb.java @@ -12,11 +12,11 @@ */ package com.moviejukebox.themoviedb.model; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonProperty; import java.io.Serializable; import java.util.List; import org.apache.log4j.Logger; -import org.codehaus.jackson.annotate.JsonAnySetter; -import org.codehaus.jackson.annotate.JsonProperty; /** * Movie Bean diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Person.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Person.java index ce0a11ac6..f38c3b260 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Person.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Person.java @@ -12,12 +12,12 @@ */ package com.moviejukebox.themoviedb.model; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonProperty; import java.io.Serializable; import java.util.ArrayList; import java.util.List; import org.apache.log4j.Logger; -import org.codehaus.jackson.annotate.JsonAnySetter; -import org.codehaus.jackson.annotate.JsonProperty; /** * diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/PersonCast.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/PersonCast.java index de25decaf..5a13b3889 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/PersonCast.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/PersonCast.java @@ -12,10 +12,10 @@ */ package com.moviejukebox.themoviedb.model; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonProperty; import java.io.Serializable; import org.apache.log4j.Logger; -import org.codehaus.jackson.annotate.JsonAnySetter; -import org.codehaus.jackson.annotate.JsonProperty; /** * @@ -96,7 +96,7 @@ public class PersonCast implements Serializable { public void setCastId(int castId) { this.castId = castId; } - + // /** diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/PersonCredit.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/PersonCredit.java index e622db30a..e4060445f 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/PersonCredit.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/PersonCredit.java @@ -12,10 +12,10 @@ */ package com.moviejukebox.themoviedb.model; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonProperty; import java.io.Serializable; import org.apache.log4j.Logger; -import org.codehaus.jackson.annotate.JsonAnySetter; -import org.codehaus.jackson.annotate.JsonProperty; /** * diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/PersonCrew.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/PersonCrew.java index 86aa54c8d..d7f545951 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/PersonCrew.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/PersonCrew.java @@ -12,10 +12,10 @@ */ package com.moviejukebox.themoviedb.model; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonProperty; import java.io.Serializable; import org.apache.log4j.Logger; -import org.codehaus.jackson.annotate.JsonAnySetter; -import org.codehaus.jackson.annotate.JsonProperty; /** * diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/ProductionCompany.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/ProductionCompany.java index cd3be8618..33785f817 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/ProductionCompany.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/ProductionCompany.java @@ -12,11 +12,11 @@ */ package com.moviejukebox.themoviedb.model; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; import java.io.Serializable; import org.apache.log4j.Logger; -import org.codehaus.jackson.annotate.JsonAnySetter; -import org.codehaus.jackson.annotate.JsonProperty; -import org.codehaus.jackson.map.annotate.JsonRootName; /** * diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/ProductionCountry.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/ProductionCountry.java index fb389e5a4..f435c6cc7 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/ProductionCountry.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/ProductionCountry.java @@ -12,11 +12,11 @@ */ package com.moviejukebox.themoviedb.model; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; import java.io.Serializable; import org.apache.log4j.Logger; -import org.codehaus.jackson.annotate.JsonAnySetter; -import org.codehaus.jackson.annotate.JsonProperty; -import org.codehaus.jackson.map.annotate.JsonRootName; /** * diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/ReleaseInfo.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/ReleaseInfo.java index aee789515..b6b040049 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/ReleaseInfo.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/ReleaseInfo.java @@ -12,10 +12,10 @@ */ package com.moviejukebox.themoviedb.model; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonProperty; import java.io.Serializable; import org.apache.log4j.Logger; -import org.codehaus.jackson.annotate.JsonAnySetter; -import org.codehaus.jackson.annotate.JsonProperty; /** * diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/StatusCode.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/StatusCode.java index 71112bbfa..9452b3ff8 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/StatusCode.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/StatusCode.java @@ -12,10 +12,10 @@ */ package com.moviejukebox.themoviedb.model; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonProperty; import java.io.Serializable; import org.apache.log4j.Logger; -import org.codehaus.jackson.annotate.JsonAnySetter; -import org.codehaus.jackson.annotate.JsonProperty; /** * diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/TmdbConfiguration.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/TmdbConfiguration.java index cea898a49..ff45215b5 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/TmdbConfiguration.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/TmdbConfiguration.java @@ -12,12 +12,12 @@ */ package com.moviejukebox.themoviedb.model; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonProperty; import java.io.Serializable; import java.util.List; import org.apache.commons.lang3.StringUtils; import org.apache.log4j.Logger; -import org.codehaus.jackson.annotate.JsonAnySetter; -import org.codehaus.jackson.annotate.JsonProperty; /** * diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/TokenAuthorisation.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/TokenAuthorisation.java index 8407b811c..579cc0ce5 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/TokenAuthorisation.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/TokenAuthorisation.java @@ -12,9 +12,9 @@ */ package com.moviejukebox.themoviedb.model; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonProperty; import org.apache.log4j.Logger; -import org.codehaus.jackson.annotate.JsonAnySetter; -import org.codehaus.jackson.annotate.JsonProperty; public class TokenAuthorisation { /* diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/TokenSession.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/TokenSession.java index d3542ec30..f20d3c043 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/TokenSession.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/TokenSession.java @@ -12,9 +12,9 @@ */ package com.moviejukebox.themoviedb.model; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonProperty; import org.apache.log4j.Logger; -import org.codehaus.jackson.annotate.JsonAnySetter; -import org.codehaus.jackson.annotate.JsonProperty; public class TokenSession { /* diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Trailer.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Trailer.java index 91967612f..009693e08 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Trailer.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Trailer.java @@ -12,9 +12,9 @@ */ package com.moviejukebox.themoviedb.model; +import com.fasterxml.jackson.annotation.JsonAnySetter; import java.io.Serializable; import org.apache.log4j.Logger; -import org.codehaus.jackson.annotate.JsonAnySetter; /** * diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Translation.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Translation.java index d3b5dcf5b..ec76728a6 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Translation.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Translation.java @@ -12,10 +12,10 @@ */ package com.moviejukebox.themoviedb.model; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonProperty; import java.io.Serializable; import org.apache.log4j.Logger; -import org.codehaus.jackson.annotate.JsonAnySetter; -import org.codehaus.jackson.annotate.JsonProperty; /** * diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperAlternativeTitles.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperAlternativeTitles.java index a0fce3344..869615093 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperAlternativeTitles.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperAlternativeTitles.java @@ -12,11 +12,11 @@ */ package com.moviejukebox.themoviedb.wrapper; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonProperty; import com.moviejukebox.themoviedb.model.AlternativeTitle; import java.util.List; import org.apache.log4j.Logger; -import org.codehaus.jackson.annotate.JsonAnySetter; -import org.codehaus.jackson.annotate.JsonProperty; /** * diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperCompany.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperCompany.java index 668a02056..8065b8965 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperCompany.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperCompany.java @@ -12,11 +12,11 @@ */ package com.moviejukebox.themoviedb.wrapper; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonProperty; import com.moviejukebox.themoviedb.model.Company; import java.util.List; import org.apache.log4j.Logger; -import org.codehaus.jackson.annotate.JsonAnySetter; -import org.codehaus.jackson.annotate.JsonProperty; /** * diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperCompanyMovies.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperCompanyMovies.java index 215ce051f..467c9980c 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperCompanyMovies.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperCompanyMovies.java @@ -12,11 +12,11 @@ */ package com.moviejukebox.themoviedb.wrapper; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonProperty; import com.moviejukebox.themoviedb.model.MovieDb; import java.util.List; import org.apache.log4j.Logger; -import org.codehaus.jackson.annotate.JsonAnySetter; -import org.codehaus.jackson.annotate.JsonProperty; /** * diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperConfig.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperConfig.java index 20836c988..01d12a795 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperConfig.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperConfig.java @@ -12,10 +12,10 @@ */ package com.moviejukebox.themoviedb.wrapper; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonProperty; import com.moviejukebox.themoviedb.model.TmdbConfiguration; import org.apache.log4j.Logger; -import org.codehaus.jackson.annotate.JsonAnySetter; -import org.codehaus.jackson.annotate.JsonProperty; /** * @@ -40,7 +40,7 @@ public class WrapperConfig { public void setTmdbConfiguration(TmdbConfiguration tmdbConfiguration) { this.tmdbConfiguration = tmdbConfiguration; } - + /** * Handle unknown properties and print a message * @param key diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperGenres.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperGenres.java index ce263ee09..986a1adfa 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperGenres.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperGenres.java @@ -12,11 +12,11 @@ */ package com.moviejukebox.themoviedb.wrapper; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonProperty; import com.moviejukebox.themoviedb.model.Genre; import java.util.List; import org.apache.log4j.Logger; -import org.codehaus.jackson.annotate.JsonAnySetter; -import org.codehaus.jackson.annotate.JsonProperty; /** * Wrapper class for the Genres searches diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperImages.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperImages.java index 3ff66174b..cdbe36cf2 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperImages.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperImages.java @@ -12,11 +12,11 @@ */ package com.moviejukebox.themoviedb.wrapper; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonProperty; import com.moviejukebox.themoviedb.model.Artwork; import java.util.List; import org.apache.log4j.Logger; -import org.codehaus.jackson.annotate.JsonAnySetter; -import org.codehaus.jackson.annotate.JsonProperty; /** * diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperMovie.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperMovie.java index 24a2dd74a..40ff5fbf1 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperMovie.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperMovie.java @@ -12,11 +12,11 @@ */ package com.moviejukebox.themoviedb.wrapper; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonProperty; import com.moviejukebox.themoviedb.model.MovieDb; import java.util.List; import org.apache.log4j.Logger; -import org.codehaus.jackson.annotate.JsonAnySetter; -import org.codehaus.jackson.annotate.JsonProperty; /** * diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperMovieCasts.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperMovieCasts.java index 337050bc7..c327dfc8b 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperMovieCasts.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperMovieCasts.java @@ -12,12 +12,12 @@ */ package com.moviejukebox.themoviedb.wrapper; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonProperty; import com.moviejukebox.themoviedb.model.PersonCast; import com.moviejukebox.themoviedb.model.PersonCrew; import java.util.List; import org.apache.log4j.Logger; -import org.codehaus.jackson.annotate.JsonAnySetter; -import org.codehaus.jackson.annotate.JsonProperty; /** * diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperMovieKeywords.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperMovieKeywords.java index 3b7ca0898..182bdce2c 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperMovieKeywords.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperMovieKeywords.java @@ -12,11 +12,11 @@ */ package com.moviejukebox.themoviedb.wrapper; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonProperty; import com.moviejukebox.themoviedb.model.Keyword; import java.util.List; import org.apache.log4j.Logger; -import org.codehaus.jackson.annotate.JsonAnySetter; -import org.codehaus.jackson.annotate.JsonProperty; /** * diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperPerson.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperPerson.java index 474ff404d..a20adc6e8 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperPerson.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperPerson.java @@ -12,11 +12,11 @@ */ package com.moviejukebox.themoviedb.wrapper; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonProperty; import com.moviejukebox.themoviedb.model.Person; import java.util.List; import org.apache.log4j.Logger; -import org.codehaus.jackson.annotate.JsonAnySetter; -import org.codehaus.jackson.annotate.JsonProperty; /** * diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperPersonCredits.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperPersonCredits.java index 78e4169d9..c2a612030 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperPersonCredits.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperPersonCredits.java @@ -12,11 +12,11 @@ */ package com.moviejukebox.themoviedb.wrapper; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonProperty; import com.moviejukebox.themoviedb.model.PersonCredit; import java.util.List; import org.apache.log4j.Logger; -import org.codehaus.jackson.annotate.JsonAnySetter; -import org.codehaus.jackson.annotate.JsonProperty; /** * diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperReleaseInfo.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperReleaseInfo.java index 247228399..8e9621f39 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperReleaseInfo.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperReleaseInfo.java @@ -12,11 +12,11 @@ */ package com.moviejukebox.themoviedb.wrapper; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonProperty; import com.moviejukebox.themoviedb.model.ReleaseInfo; import java.util.List; import org.apache.log4j.Logger; -import org.codehaus.jackson.annotate.JsonAnySetter; -import org.codehaus.jackson.annotate.JsonProperty; /** * diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperTrailers.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperTrailers.java index de8fabd17..3b746bbff 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperTrailers.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperTrailers.java @@ -12,11 +12,11 @@ */ package com.moviejukebox.themoviedb.wrapper; +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonProperty; import com.moviejukebox.themoviedb.model.Trailer; import java.util.List; import org.apache.log4j.Logger; -import org.codehaus.jackson.annotate.JsonAnySetter; -import org.codehaus.jackson.annotate.JsonProperty; /** * diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperTranslations.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperTranslations.java index c0e3417e6..6a4e8d560 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperTranslations.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperTranslations.java @@ -12,10 +12,10 @@ */ package com.moviejukebox.themoviedb.wrapper; +import com.fasterxml.jackson.annotation.JsonAnySetter; import com.moviejukebox.themoviedb.model.Translation; import java.util.List; import org.apache.log4j.Logger; -import org.codehaus.jackson.annotate.JsonAnySetter; /** * From e1b117e5aac83199549606d56444dc23db2d597e Mon Sep 17 00:00:00 2001 From: Omertron Date: Thu, 1 Nov 2012 09:14:06 +0000 Subject: [PATCH 152/207] Updated licence information --- themoviedbapi/LICENCE.txt | 26 +++++++++++++++++++ themoviedbapi/readme.txt | 2 +- .../themoviedb/MovieDbException.java | 9 +++++++ .../moviejukebox/themoviedb/TheMovieDb.java | 7 ++--- .../themoviedb/model/AlternativeTitle.java | 7 ++--- .../themoviedb/model/Artwork.java | 7 ++--- .../themoviedb/model/ArtworkType.java | 7 ++--- .../themoviedb/model/Collection.java | 7 ++--- .../themoviedb/model/CollectionInfo.java | 7 ++--- .../themoviedb/model/Company.java | 7 ++--- .../moviejukebox/themoviedb/model/Genre.java | 7 ++--- .../themoviedb/model/Keyword.java | 7 ++--- .../themoviedb/model/Language.java | 7 ++--- .../themoviedb/model/MovieDb.java | 7 ++--- .../moviejukebox/themoviedb/model/Person.java | 7 ++--- .../themoviedb/model/PersonCast.java | 7 ++--- .../themoviedb/model/PersonCredit.java | 7 ++--- .../themoviedb/model/PersonCrew.java | 7 ++--- .../themoviedb/model/PersonType.java | 7 ++--- .../themoviedb/model/ProductionCompany.java | 7 ++--- .../themoviedb/model/ProductionCountry.java | 7 ++--- .../themoviedb/model/ReleaseInfo.java | 7 ++--- .../themoviedb/model/StatusCode.java | 7 ++--- .../themoviedb/model/TmdbConfiguration.java | 7 ++--- .../themoviedb/model/TokenAuthorisation.java | 7 ++--- .../themoviedb/model/TokenSession.java | 7 ++--- .../themoviedb/model/Trailer.java | 7 ++--- .../themoviedb/model/Translation.java | 7 ++--- .../moviejukebox/themoviedb/tools/ApiUrl.java | 7 ++--- .../themoviedb/tools/FilteringLayout.java | 7 ++--- .../themoviedb/tools/WebBrowser.java | 9 +++---- .../wrapper/WrapperAlternativeTitles.java | 7 ++--- .../themoviedb/wrapper/WrapperCompany.java | 7 ++--- .../wrapper/WrapperCompanyMovies.java | 7 ++--- .../themoviedb/wrapper/WrapperConfig.java | 7 ++--- .../themoviedb/wrapper/WrapperGenres.java | 7 ++--- .../themoviedb/wrapper/WrapperImages.java | 7 ++--- .../themoviedb/wrapper/WrapperMovie.java | 7 ++--- .../themoviedb/wrapper/WrapperMovieCasts.java | 7 ++--- .../wrapper/WrapperMovieKeywords.java | 7 ++--- .../themoviedb/wrapper/WrapperPerson.java | 7 ++--- .../wrapper/WrapperPersonCredits.java | 7 ++--- .../wrapper/WrapperReleaseInfo.java | 7 ++--- .../themoviedb/wrapper/WrapperTrailers.java | 7 ++--- .../wrapper/WrapperTranslations.java | 7 ++--- .../themoviedb/TheMovieDbTest.java | 7 ++--- 46 files changed, 123 insertions(+), 217 deletions(-) create mode 100644 themoviedbapi/LICENCE.txt diff --git a/themoviedbapi/LICENCE.txt b/themoviedbapi/LICENCE.txt new file mode 100644 index 000000000..503b3abfd --- /dev/null +++ b/themoviedbapi/LICENCE.txt @@ -0,0 +1,26 @@ +This work is licensed under a Creative Commons License. + +You are free to: + Share — to copy, distribute and transmit the work + Remix — to adapt the work + +Under the following conditions: + Attribution. + You must attribute the work in the manner specified by the author or + licensor (but not in any way that suggests that they endorse you or + your use of the work). + Noncommercial. + You may not use this work for commercial purposes. + +For any reuse or distribution, you must make clear to others the license terms +of this work. + +Any of the above conditions can be waived if you get permission from the +copyright holder. + +Nothing in this license impairs or restricts the author's moral rights. + +http://creativecommons.org/licenses/by-nc/3.0/ + +The full license can be found here: +http://creativecommons.org/licenses/by-nc/3.0/legalcode \ No newline at end of file diff --git a/themoviedbapi/readme.txt b/themoviedbapi/readme.txt index f481fb77c..fa139d184 100644 --- a/themoviedbapi/readme.txt +++ b/themoviedbapi/readme.txt @@ -1,4 +1,4 @@ -Author: Stuart.Boston AT Gmail DOT com (Omertron) +Author: Stuart Boston (Omertron AT Gmail DOT com) Originally written for use by YetAnotherMovieJukebox (YAMJ) http://code.google.com/p/moviejukebox/ But anyone can feel free to use it for other projects as well. diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/MovieDbException.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/MovieDbException.java index e48762399..1f9a95aa0 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/MovieDbException.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/MovieDbException.java @@ -1,3 +1,12 @@ +/* + * Copyright (c) 2004-2012 Stuart Boston + * + * This software is licensed under a Creative Commons License + * See the LICENCE.txt file included in this package + * + * For any reuse or distribution, you must make clear to others the + * license terms of this work. + */ package com.moviejukebox.themoviedb; public class MovieDbException extends Exception { diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java index 488db554a..49c48abc3 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java @@ -1,11 +1,8 @@ /* - * Copyright (c) 2004-2012 YAMJ Members - * http://code.google.com/p/moviejukebox/people/list - * - * Web: http://code.google.com/p/moviejukebox/ + * Copyright (c) 2004-2012 Stuart Boston * * This software is licensed under a Creative Commons License - * See this page: http://code.google.com/p/moviejukebox/wiki/License + * See the LICENCE.txt file included in this package * * For any reuse or distribution, you must make clear to others the * license terms of this work. diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/AlternativeTitle.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/AlternativeTitle.java index 420ec6160..c57c564bf 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/AlternativeTitle.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/AlternativeTitle.java @@ -1,11 +1,8 @@ /* - * Copyright (c) 2004-2012 YAMJ Members - * http://code.google.com/p/moviejukebox/people/list - * - * Web: http://code.google.com/p/moviejukebox/ + * Copyright (c) 2004-2012 Stuart Boston * * This software is licensed under a Creative Commons License - * See this page: http://code.google.com/p/moviejukebox/wiki/License + * See the LICENCE.txt file included in this package * * For any reuse or distribution, you must make clear to others the * license terms of this work. diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Artwork.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Artwork.java index ee94787ce..391bb468b 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Artwork.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Artwork.java @@ -1,11 +1,8 @@ /* - * Copyright (c) 2004-2012 YAMJ Members - * http://code.google.com/p/moviejukebox/people/list - * - * Web: http://code.google.com/p/moviejukebox/ + * Copyright (c) 2004-2012 Stuart Boston * * This software is licensed under a Creative Commons License - * See this page: http://code.google.com/p/moviejukebox/wiki/License + * See the LICENCE.txt file included in this package * * For any reuse or distribution, you must make clear to others the * license terms of this work. diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/ArtworkType.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/ArtworkType.java index 9e952d85d..e454b0b6e 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/ArtworkType.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/ArtworkType.java @@ -1,11 +1,8 @@ /* - * Copyright (c) 2004-2012 YAMJ Members - * http://code.google.com/p/moviejukebox/people/list - * - * Web: http://code.google.com/p/moviejukebox/ + * Copyright (c) 2004-2012 Stuart Boston * * This software is licensed under a Creative Commons License - * See this page: http://code.google.com/p/moviejukebox/wiki/License + * See the LICENCE.txt file included in this package * * For any reuse or distribution, you must make clear to others the * license terms of this work. diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Collection.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Collection.java index be77b9d6a..f3ac281a9 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Collection.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Collection.java @@ -1,11 +1,8 @@ /* - * Copyright (c) 2004-2012 YAMJ Members - * http://code.google.com/p/moviejukebox/people/list - * - * Web: http://code.google.com/p/moviejukebox/ + * Copyright (c) 2004-2012 Stuart Boston * * This software is licensed under a Creative Commons License - * See this page: http://code.google.com/p/moviejukebox/wiki/License + * See the LICENCE.txt file included in this package * * For any reuse or distribution, you must make clear to others the * license terms of this work. diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/CollectionInfo.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/CollectionInfo.java index a49ea08fa..0edf12770 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/CollectionInfo.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/CollectionInfo.java @@ -1,11 +1,8 @@ /* - * Copyright (c) 2004-2012 YAMJ Members - * http://code.google.com/p/moviejukebox/people/list - * - * Web: http://code.google.com/p/moviejukebox/ + * Copyright (c) 2004-2012 Stuart Boston * * This software is licensed under a Creative Commons License - * See this page: http://code.google.com/p/moviejukebox/wiki/License + * See the LICENCE.txt file included in this package * * For any reuse or distribution, you must make clear to others the * license terms of this work. diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Company.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Company.java index 539e3a387..3cd07bbc8 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Company.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Company.java @@ -1,11 +1,8 @@ /* - * Copyright (c) 2004-2012 YAMJ Members - * http://code.google.com/p/moviejukebox/people/list - * - * Web: http://code.google.com/p/moviejukebox/ + * Copyright (c) 2004-2012 Stuart Boston * * This software is licensed under a Creative Commons License - * See this page: http://code.google.com/p/moviejukebox/wiki/License + * See the LICENCE.txt file included in this package * * For any reuse or distribution, you must make clear to others the * license terms of this work. diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Genre.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Genre.java index 1aeb44730..b0da30e3e 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Genre.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Genre.java @@ -1,11 +1,8 @@ /* - * Copyright (c) 2004-2012 YAMJ Members - * http://code.google.com/p/moviejukebox/people/list - * - * Web: http://code.google.com/p/moviejukebox/ + * Copyright (c) 2004-2012 Stuart Boston * * This software is licensed under a Creative Commons License - * See this page: http://code.google.com/p/moviejukebox/wiki/License + * See the LICENCE.txt file included in this package * * For any reuse or distribution, you must make clear to others the * license terms of this work. diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Keyword.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Keyword.java index 0f5b72f75..f0dd79045 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Keyword.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Keyword.java @@ -1,11 +1,8 @@ /* - * Copyright (c) 2004-2012 YAMJ Members - * http://code.google.com/p/moviejukebox/people/list - * - * Web: http://code.google.com/p/moviejukebox/ + * Copyright (c) 2004-2012 Stuart Boston * * This software is licensed under a Creative Commons License - * See this page: http://code.google.com/p/moviejukebox/wiki/License + * See the LICENCE.txt file included in this package * * For any reuse or distribution, you must make clear to others the * license terms of this work. diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Language.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Language.java index d05ded99e..c81dc339c 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Language.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Language.java @@ -1,11 +1,8 @@ /* - * Copyright (c) 2004-2012 YAMJ Members - * http://code.google.com/p/moviejukebox/people/list - * - * Web: http://code.google.com/p/moviejukebox/ + * Copyright (c) 2004-2012 Stuart Boston * * This software is licensed under a Creative Commons License - * See this page: http://code.google.com/p/moviejukebox/wiki/License + * See the LICENCE.txt file included in this package * * For any reuse or distribution, you must make clear to others the * license terms of this work. diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/MovieDb.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/MovieDb.java index 15a4c8d99..7dedb1c82 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/MovieDb.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/MovieDb.java @@ -1,11 +1,8 @@ /* - * Copyright (c) 2004-2012 YAMJ Members - * http://code.google.com/p/moviejukebox/people/list - * - * Web: http://code.google.com/p/moviejukebox/ + * Copyright (c) 2004-2012 Stuart Boston * * This software is licensed under a Creative Commons License - * See this page: http://code.google.com/p/moviejukebox/wiki/License + * See the LICENCE.txt file included in this package * * For any reuse or distribution, you must make clear to others the * license terms of this work. diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Person.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Person.java index f38c3b260..771dba51c 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Person.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Person.java @@ -1,11 +1,8 @@ /* - * Copyright (c) 2004-2012 YAMJ Members - * http://code.google.com/p/moviejukebox/people/list - * - * Web: http://code.google.com/p/moviejukebox/ + * Copyright (c) 2004-2012 Stuart Boston * * This software is licensed under a Creative Commons License - * See this page: http://code.google.com/p/moviejukebox/wiki/License + * See the LICENCE.txt file included in this package * * For any reuse or distribution, you must make clear to others the * license terms of this work. diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/PersonCast.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/PersonCast.java index 5a13b3889..9b04b7012 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/PersonCast.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/PersonCast.java @@ -1,11 +1,8 @@ /* - * Copyright (c) 2004-2012 YAMJ Members - * http://code.google.com/p/moviejukebox/people/list - * - * Web: http://code.google.com/p/moviejukebox/ + * Copyright (c) 2004-2012 Stuart Boston * * This software is licensed under a Creative Commons License - * See this page: http://code.google.com/p/moviejukebox/wiki/License + * See the LICENCE.txt file included in this package * * For any reuse or distribution, you must make clear to others the * license terms of this work. diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/PersonCredit.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/PersonCredit.java index e4060445f..1698140d5 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/PersonCredit.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/PersonCredit.java @@ -1,11 +1,8 @@ /* - * Copyright (c) 2004-2012 YAMJ Members - * http://code.google.com/p/moviejukebox/people/list - * - * Web: http://code.google.com/p/moviejukebox/ + * Copyright (c) 2004-2012 Stuart Boston * * This software is licensed under a Creative Commons License - * See this page: http://code.google.com/p/moviejukebox/wiki/License + * See the LICENCE.txt file included in this package * * For any reuse or distribution, you must make clear to others the * license terms of this work. diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/PersonCrew.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/PersonCrew.java index d7f545951..d6f69bbd2 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/PersonCrew.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/PersonCrew.java @@ -1,11 +1,8 @@ /* - * Copyright (c) 2004-2012 YAMJ Members - * http://code.google.com/p/moviejukebox/people/list - * - * Web: http://code.google.com/p/moviejukebox/ + * Copyright (c) 2004-2012 Stuart Boston * * This software is licensed under a Creative Commons License - * See this page: http://code.google.com/p/moviejukebox/wiki/License + * See the LICENCE.txt file included in this package * * For any reuse or distribution, you must make clear to others the * license terms of this work. diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/PersonType.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/PersonType.java index dd3bd1a1d..40bf83222 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/PersonType.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/PersonType.java @@ -1,11 +1,8 @@ /* - * Copyright (c) 2004-2012 YAMJ Members - * http://code.google.com/p/moviejukebox/people/list - * - * Web: http://code.google.com/p/moviejukebox/ + * Copyright (c) 2004-2012 Stuart Boston * * This software is licensed under a Creative Commons License - * See this page: http://code.google.com/p/moviejukebox/wiki/License + * See the LICENCE.txt file included in this package * * For any reuse or distribution, you must make clear to others the * license terms of this work. diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/ProductionCompany.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/ProductionCompany.java index 33785f817..93b10247e 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/ProductionCompany.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/ProductionCompany.java @@ -1,11 +1,8 @@ /* - * Copyright (c) 2004-2012 YAMJ Members - * http://code.google.com/p/moviejukebox/people/list - * - * Web: http://code.google.com/p/moviejukebox/ + * Copyright (c) 2004-2012 Stuart Boston * * This software is licensed under a Creative Commons License - * See this page: http://code.google.com/p/moviejukebox/wiki/License + * See the LICENCE.txt file included in this package * * For any reuse or distribution, you must make clear to others the * license terms of this work. diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/ProductionCountry.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/ProductionCountry.java index f435c6cc7..001d4d289 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/ProductionCountry.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/ProductionCountry.java @@ -1,11 +1,8 @@ /* - * Copyright (c) 2004-2012 YAMJ Members - * http://code.google.com/p/moviejukebox/people/list - * - * Web: http://code.google.com/p/moviejukebox/ + * Copyright (c) 2004-2012 Stuart Boston * * This software is licensed under a Creative Commons License - * See this page: http://code.google.com/p/moviejukebox/wiki/License + * See the LICENCE.txt file included in this package * * For any reuse or distribution, you must make clear to others the * license terms of this work. diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/ReleaseInfo.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/ReleaseInfo.java index b6b040049..0edd1dc10 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/ReleaseInfo.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/ReleaseInfo.java @@ -1,11 +1,8 @@ /* - * Copyright (c) 2004-2012 YAMJ Members - * http://code.google.com/p/moviejukebox/people/list - * - * Web: http://code.google.com/p/moviejukebox/ + * Copyright (c) 2004-2012 Stuart Boston * * This software is licensed under a Creative Commons License - * See this page: http://code.google.com/p/moviejukebox/wiki/License + * See the LICENCE.txt file included in this package * * For any reuse or distribution, you must make clear to others the * license terms of this work. diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/StatusCode.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/StatusCode.java index 9452b3ff8..33c73a091 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/StatusCode.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/StatusCode.java @@ -1,11 +1,8 @@ /* - * Copyright (c) 2004-2012 YAMJ Members - * http://code.google.com/p/moviejukebox/people/list - * - * Web: http://code.google.com/p/moviejukebox/ + * Copyright (c) 2004-2012 Stuart Boston * * This software is licensed under a Creative Commons License - * See this page: http://code.google.com/p/moviejukebox/wiki/License + * See the LICENCE.txt file included in this package * * For any reuse or distribution, you must make clear to others the * license terms of this work. diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/TmdbConfiguration.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/TmdbConfiguration.java index ff45215b5..7aac0b47a 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/TmdbConfiguration.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/TmdbConfiguration.java @@ -1,11 +1,8 @@ /* - * Copyright (c) 2004-2012 YAMJ Members - * http://code.google.com/p/moviejukebox/people/list - * - * Web: http://code.google.com/p/moviejukebox/ + * Copyright (c) 2004-2012 Stuart Boston * * This software is licensed under a Creative Commons License - * See this page: http://code.google.com/p/moviejukebox/wiki/License + * See the LICENCE.txt file included in this package * * For any reuse or distribution, you must make clear to others the * license terms of this work. diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/TokenAuthorisation.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/TokenAuthorisation.java index 579cc0ce5..d8c3fb063 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/TokenAuthorisation.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/TokenAuthorisation.java @@ -1,11 +1,8 @@ /* - * Copyright (c) 2004-2012 YAMJ Members - * http://code.google.com/p/moviejukebox/people/list - * - * Web: http://code.google.com/p/moviejukebox/ + * Copyright (c) 2004-2012 Stuart Boston * * This software is licensed under a Creative Commons License - * See this page: http://code.google.com/p/moviejukebox/wiki/License + * See the LICENCE.txt file included in this package * * For any reuse or distribution, you must make clear to others the * license terms of this work. diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/TokenSession.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/TokenSession.java index f20d3c043..a540af287 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/TokenSession.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/TokenSession.java @@ -1,11 +1,8 @@ /* - * Copyright (c) 2004-2012 YAMJ Members - * http://code.google.com/p/moviejukebox/people/list - * - * Web: http://code.google.com/p/moviejukebox/ + * Copyright (c) 2004-2012 Stuart Boston * * This software is licensed under a Creative Commons License - * See this page: http://code.google.com/p/moviejukebox/wiki/License + * See the LICENCE.txt file included in this package * * For any reuse or distribution, you must make clear to others the * license terms of this work. diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Trailer.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Trailer.java index 009693e08..9d716caf6 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Trailer.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Trailer.java @@ -1,11 +1,8 @@ /* - * Copyright (c) 2004-2012 YAMJ Members - * http://code.google.com/p/moviejukebox/people/list - * - * Web: http://code.google.com/p/moviejukebox/ + * Copyright (c) 2004-2012 Stuart Boston * * This software is licensed under a Creative Commons License - * See this page: http://code.google.com/p/moviejukebox/wiki/License + * See the LICENCE.txt file included in this package * * For any reuse or distribution, you must make clear to others the * license terms of this work. diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Translation.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Translation.java index ec76728a6..66f6c769a 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Translation.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Translation.java @@ -1,11 +1,8 @@ /* - * Copyright (c) 2004-2012 YAMJ Members - * http://code.google.com/p/moviejukebox/people/list - * - * Web: http://code.google.com/p/moviejukebox/ + * Copyright (c) 2004-2012 Stuart Boston * * This software is licensed under a Creative Commons License - * See this page: http://code.google.com/p/moviejukebox/wiki/License + * See the LICENCE.txt file included in this package * * For any reuse or distribution, you must make clear to others the * license terms of this work. diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/ApiUrl.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/ApiUrl.java index d940b5885..c89e05631 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/ApiUrl.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/ApiUrl.java @@ -1,11 +1,8 @@ /* - * Copyright (c) 2004-2012 YAMJ Members - * http://code.google.com/p/moviejukebox/people/list - * - * Web: http://code.google.com/p/moviejukebox/ + * Copyright (c) 2004-2012 Stuart Boston * * This software is licensed under a Creative Commons License - * See this page: http://code.google.com/p/moviejukebox/wiki/License + * See the LICENCE.txt file included in this package * * For any reuse or distribution, you must make clear to others the * license terms of this work. diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/FilteringLayout.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/FilteringLayout.java index bd59bcad9..6cf8126ff 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/FilteringLayout.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/FilteringLayout.java @@ -1,11 +1,8 @@ /* - * Copyright (c) 2004-2012 YAMJ Members - * http://code.google.com/p/moviejukebox/people/list - * - * Web: http://code.google.com/p/moviejukebox/ + * Copyright (c) 2004-2012 Stuart Boston * * This software is licensed under a Creative Commons License - * See this page: http://code.google.com/p/moviejukebox/wiki/License + * See the LICENCE.txt file included in this package * * For any reuse or distribution, you must make clear to others the * license terms of this work. diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/WebBrowser.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/WebBrowser.java index b76783064..0df2cfa1b 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/WebBrowser.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/WebBrowser.java @@ -1,11 +1,8 @@ /* - * Copyright (c) 2004-2012 YAMJ Members - * http://code.google.com/p/moviejukebox/people/list - * - * Web: http://code.google.com/p/moviejukebox/ + * Copyright (c) 2004-2012 Stuart Boston * * This software is licensed under a Creative Commons License - * See this page: http://code.google.com/p/moviejukebox/wiki/License + * See the LICENCE.txt file included in this package * * For any reuse or distribution, you must make clear to others the * license terms of this work. @@ -113,7 +110,7 @@ public final class WebBrowser { if (in != null) { in.close(); } - + if (cnx instanceof HttpURLConnection) { ((HttpURLConnection) cnx).disconnect(); } diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperAlternativeTitles.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperAlternativeTitles.java index 869615093..50af41663 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperAlternativeTitles.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperAlternativeTitles.java @@ -1,11 +1,8 @@ /* - * Copyright (c) 2004-2012 YAMJ Members - * http://code.google.com/p/moviejukebox/people/list - * - * Web: http://code.google.com/p/moviejukebox/ + * Copyright (c) 2004-2012 Stuart Boston * * This software is licensed under a Creative Commons License - * See this page: http://code.google.com/p/moviejukebox/wiki/License + * See the LICENCE.txt file included in this package * * For any reuse or distribution, you must make clear to others the * license terms of this work. diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperCompany.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperCompany.java index 8065b8965..62b96140d 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperCompany.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperCompany.java @@ -1,11 +1,8 @@ /* - * Copyright (c) 2004-2012 YAMJ Members - * http://code.google.com/p/moviejukebox/people/list - * - * Web: http://code.google.com/p/moviejukebox/ + * Copyright (c) 2004-2012 Stuart Boston * * This software is licensed under a Creative Commons License - * See this page: http://code.google.com/p/moviejukebox/wiki/License + * See the LICENCE.txt file included in this package * * For any reuse or distribution, you must make clear to others the * license terms of this work. diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperCompanyMovies.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperCompanyMovies.java index 467c9980c..bc286db9b 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperCompanyMovies.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperCompanyMovies.java @@ -1,11 +1,8 @@ /* - * Copyright (c) 2004-2012 YAMJ Members - * http://code.google.com/p/moviejukebox/people/list - * - * Web: http://code.google.com/p/moviejukebox/ + * Copyright (c) 2004-2012 Stuart Boston * * This software is licensed under a Creative Commons License - * See this page: http://code.google.com/p/moviejukebox/wiki/License + * See the LICENCE.txt file included in this package * * For any reuse or distribution, you must make clear to others the * license terms of this work. diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperConfig.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperConfig.java index 01d12a795..aea884cd0 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperConfig.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperConfig.java @@ -1,11 +1,8 @@ /* - * Copyright (c) 2004-2012 YAMJ Members - * http://code.google.com/p/moviejukebox/people/list - * - * Web: http://code.google.com/p/moviejukebox/ + * Copyright (c) 2004-2012 Stuart Boston * * This software is licensed under a Creative Commons License - * See this page: http://code.google.com/p/moviejukebox/wiki/License + * See the LICENCE.txt file included in this package * * For any reuse or distribution, you must make clear to others the * license terms of this work. diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperGenres.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperGenres.java index 986a1adfa..f4608455c 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperGenres.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperGenres.java @@ -1,11 +1,8 @@ /* - * Copyright (c) 2004-2012 YAMJ Members - * http://code.google.com/p/moviejukebox/people/list - * - * Web: http://code.google.com/p/moviejukebox/ + * Copyright (c) 2004-2012 Stuart Boston * * This software is licensed under a Creative Commons License - * See this page: http://code.google.com/p/moviejukebox/wiki/License + * See the LICENCE.txt file included in this package * * For any reuse or distribution, you must make clear to others the * license terms of this work. diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperImages.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperImages.java index cdbe36cf2..98edbbfda 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperImages.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperImages.java @@ -1,11 +1,8 @@ /* - * Copyright (c) 2004-2012 YAMJ Members - * http://code.google.com/p/moviejukebox/people/list - * - * Web: http://code.google.com/p/moviejukebox/ + * Copyright (c) 2004-2012 Stuart Boston * * This software is licensed under a Creative Commons License - * See this page: http://code.google.com/p/moviejukebox/wiki/License + * See the LICENCE.txt file included in this package * * For any reuse or distribution, you must make clear to others the * license terms of this work. diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperMovie.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperMovie.java index 40ff5fbf1..2ae8cd5e9 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperMovie.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperMovie.java @@ -1,11 +1,8 @@ /* - * Copyright (c) 2004-2012 YAMJ Members - * http://code.google.com/p/moviejukebox/people/list - * - * Web: http://code.google.com/p/moviejukebox/ + * Copyright (c) 2004-2012 Stuart Boston * * This software is licensed under a Creative Commons License - * See this page: http://code.google.com/p/moviejukebox/wiki/License + * See the LICENCE.txt file included in this package * * For any reuse or distribution, you must make clear to others the * license terms of this work. diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperMovieCasts.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperMovieCasts.java index c327dfc8b..03acee9b6 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperMovieCasts.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperMovieCasts.java @@ -1,11 +1,8 @@ /* - * Copyright (c) 2004-2012 YAMJ Members - * http://code.google.com/p/moviejukebox/people/list - * - * Web: http://code.google.com/p/moviejukebox/ + * Copyright (c) 2004-2012 Stuart Boston * * This software is licensed under a Creative Commons License - * See this page: http://code.google.com/p/moviejukebox/wiki/License + * See the LICENCE.txt file included in this package * * For any reuse or distribution, you must make clear to others the * license terms of this work. diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperMovieKeywords.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperMovieKeywords.java index 182bdce2c..abec165f5 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperMovieKeywords.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperMovieKeywords.java @@ -1,11 +1,8 @@ /* - * Copyright (c) 2004-2012 YAMJ Members - * http://code.google.com/p/moviejukebox/people/list - * - * Web: http://code.google.com/p/moviejukebox/ + * Copyright (c) 2004-2012 Stuart Boston * * This software is licensed under a Creative Commons License - * See this page: http://code.google.com/p/moviejukebox/wiki/License + * See the LICENCE.txt file included in this package * * For any reuse or distribution, you must make clear to others the * license terms of this work. diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperPerson.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperPerson.java index a20adc6e8..81514b7ca 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperPerson.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperPerson.java @@ -1,11 +1,8 @@ /* - * Copyright (c) 2004-2012 YAMJ Members - * http://code.google.com/p/moviejukebox/people/list - * - * Web: http://code.google.com/p/moviejukebox/ + * Copyright (c) 2004-2012 Stuart Boston * * This software is licensed under a Creative Commons License - * See this page: http://code.google.com/p/moviejukebox/wiki/License + * See the LICENCE.txt file included in this package * * For any reuse or distribution, you must make clear to others the * license terms of this work. diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperPersonCredits.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperPersonCredits.java index c2a612030..4b4cf4cf6 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperPersonCredits.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperPersonCredits.java @@ -1,11 +1,8 @@ /* - * Copyright (c) 2004-2012 YAMJ Members - * http://code.google.com/p/moviejukebox/people/list - * - * Web: http://code.google.com/p/moviejukebox/ + * Copyright (c) 2004-2012 Stuart Boston * * This software is licensed under a Creative Commons License - * See this page: http://code.google.com/p/moviejukebox/wiki/License + * See the LICENCE.txt file included in this package * * For any reuse or distribution, you must make clear to others the * license terms of this work. diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperReleaseInfo.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperReleaseInfo.java index 8e9621f39..8d55e9ea7 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperReleaseInfo.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperReleaseInfo.java @@ -1,11 +1,8 @@ /* - * Copyright (c) 2004-2012 YAMJ Members - * http://code.google.com/p/moviejukebox/people/list - * - * Web: http://code.google.com/p/moviejukebox/ + * Copyright (c) 2004-2012 Stuart Boston * * This software is licensed under a Creative Commons License - * See this page: http://code.google.com/p/moviejukebox/wiki/License + * See the LICENCE.txt file included in this package * * For any reuse or distribution, you must make clear to others the * license terms of this work. diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperTrailers.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperTrailers.java index 3b746bbff..dde4b774a 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperTrailers.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperTrailers.java @@ -1,11 +1,8 @@ /* - * Copyright (c) 2004-2012 YAMJ Members - * http://code.google.com/p/moviejukebox/people/list - * - * Web: http://code.google.com/p/moviejukebox/ + * Copyright (c) 2004-2012 Stuart Boston * * This software is licensed under a Creative Commons License - * See this page: http://code.google.com/p/moviejukebox/wiki/License + * See the LICENCE.txt file included in this package * * For any reuse or distribution, you must make clear to others the * license terms of this work. diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperTranslations.java b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperTranslations.java index 6a4e8d560..ff15f1a85 100644 --- a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperTranslations.java +++ b/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperTranslations.java @@ -1,11 +1,8 @@ /* - * Copyright (c) 2004-2012 YAMJ Members - * http://code.google.com/p/moviejukebox/people/list - * - * Web: http://code.google.com/p/moviejukebox/ + * Copyright (c) 2004-2012 Stuart Boston * * This software is licensed under a Creative Commons License - * See this page: http://code.google.com/p/moviejukebox/wiki/License + * See the LICENCE.txt file included in this package * * For any reuse or distribution, you must make clear to others the * license terms of this work. diff --git a/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java b/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java index 963fcee2e..a9305b742 100644 --- a/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java +++ b/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java @@ -1,11 +1,8 @@ /* - * Copyright (c) 2004-2012 YAMJ Members - * http://code.google.com/p/moviejukebox/people/list - * - * Web: http://code.google.com/p/moviejukebox/ + * Copyright (c) 2004-2012 Stuart Boston * * This software is licensed under a Creative Commons License - * See this page: http://code.google.com/p/moviejukebox/wiki/License + * See the LICENCE.txt file included in this package * * For any reuse or distribution, you must make clear to others the * license terms of this work. From 887a2412486c9450c006f332dc13960ac30cf0d6 Mon Sep 17 00:00:00 2001 From: Omertron Date: Thu, 1 Nov 2012 12:49:05 +0100 Subject: [PATCH 153/207] Moving from Google Code --- .gitignore | 7 ++++++ themoviedbapi/LICENCE.txt => LICENCE.txt | 0 themoviedbapi/pom.xml => pom.xml | 0 themoviedbapi/readme.txt => readme.txt | 0 .../themoviedb/MovieDbException.java | 0 .../moviejukebox/themoviedb/TheMovieDb.java | 0 .../themoviedb/model/AlternativeTitle.java | 0 .../themoviedb/model/Artwork.java | 0 .../themoviedb/model/ArtworkType.java | 0 .../themoviedb/model/Collection.java | 0 .../themoviedb/model/CollectionInfo.java | 0 .../themoviedb/model/Company.java | 0 .../moviejukebox/themoviedb/model/Genre.java | 0 .../themoviedb/model/Keyword.java | 0 .../themoviedb/model/Language.java | 0 .../themoviedb/model/MovieDb.java | 0 .../moviejukebox/themoviedb/model/Person.java | 0 .../themoviedb/model/PersonCast.java | 0 .../themoviedb/model/PersonCredit.java | 0 .../themoviedb/model/PersonCrew.java | 0 .../themoviedb/model/PersonType.java | 0 .../themoviedb/model/ProductionCompany.java | 0 .../themoviedb/model/ProductionCountry.java | 0 .../themoviedb/model/ReleaseInfo.java | 0 .../themoviedb/model/StatusCode.java | 0 .../themoviedb/model/TmdbConfiguration.java | 0 .../themoviedb/model/TokenAuthorisation.java | 0 .../themoviedb/model/TokenSession.java | 0 .../themoviedb/model/Trailer.java | 0 .../themoviedb/model/Translation.java | 0 .../moviejukebox/themoviedb/tools/ApiUrl.java | 0 .../themoviedb/tools/FilteringLayout.java | 0 .../themoviedb/tools/WebBrowser.java | 0 .../wrapper/WrapperAlternativeTitles.java | 0 .../themoviedb/wrapper/WrapperCompany.java | 0 .../wrapper/WrapperCompanyMovies.java | 0 .../themoviedb/wrapper/WrapperConfig.java | 0 .../themoviedb/wrapper/WrapperGenres.java | 0 .../themoviedb/wrapper/WrapperImages.java | 0 .../themoviedb/wrapper/WrapperMovie.java | 0 .../themoviedb/wrapper/WrapperMovieCasts.java | 0 .../wrapper/WrapperMovieKeywords.java | 0 .../themoviedb/wrapper/WrapperPerson.java | 0 .../wrapper/WrapperPersonCredits.java | 0 .../wrapper/WrapperReleaseInfo.java | 0 .../themoviedb/wrapper/WrapperTrailers.java | 0 .../wrapper/WrapperTranslations.java | 0 .../src => src}/main/resources/bin.xml | 0 .../main/resources/log4j.properties | 0 .../themoviedb/TheMovieDbTest.java | 0 themoviedbapi/.classpath | 11 --------- themoviedbapi/.project | 23 ------------------- 52 files changed, 7 insertions(+), 34 deletions(-) create mode 100644 .gitignore rename themoviedbapi/LICENCE.txt => LICENCE.txt (100%) rename themoviedbapi/pom.xml => pom.xml (100%) rename themoviedbapi/readme.txt => readme.txt (100%) rename {themoviedbapi/src => src}/main/java/com/moviejukebox/themoviedb/MovieDbException.java (100%) rename {themoviedbapi/src => src}/main/java/com/moviejukebox/themoviedb/TheMovieDb.java (100%) rename {themoviedbapi/src => src}/main/java/com/moviejukebox/themoviedb/model/AlternativeTitle.java (100%) rename {themoviedbapi/src => src}/main/java/com/moviejukebox/themoviedb/model/Artwork.java (100%) rename {themoviedbapi/src => src}/main/java/com/moviejukebox/themoviedb/model/ArtworkType.java (100%) rename {themoviedbapi/src => src}/main/java/com/moviejukebox/themoviedb/model/Collection.java (100%) rename {themoviedbapi/src => src}/main/java/com/moviejukebox/themoviedb/model/CollectionInfo.java (100%) rename {themoviedbapi/src => src}/main/java/com/moviejukebox/themoviedb/model/Company.java (100%) rename {themoviedbapi/src => src}/main/java/com/moviejukebox/themoviedb/model/Genre.java (100%) rename {themoviedbapi/src => src}/main/java/com/moviejukebox/themoviedb/model/Keyword.java (100%) rename {themoviedbapi/src => src}/main/java/com/moviejukebox/themoviedb/model/Language.java (100%) rename {themoviedbapi/src => src}/main/java/com/moviejukebox/themoviedb/model/MovieDb.java (100%) rename {themoviedbapi/src => src}/main/java/com/moviejukebox/themoviedb/model/Person.java (100%) rename {themoviedbapi/src => src}/main/java/com/moviejukebox/themoviedb/model/PersonCast.java (100%) rename {themoviedbapi/src => src}/main/java/com/moviejukebox/themoviedb/model/PersonCredit.java (100%) rename {themoviedbapi/src => src}/main/java/com/moviejukebox/themoviedb/model/PersonCrew.java (100%) rename {themoviedbapi/src => src}/main/java/com/moviejukebox/themoviedb/model/PersonType.java (100%) rename {themoviedbapi/src => src}/main/java/com/moviejukebox/themoviedb/model/ProductionCompany.java (100%) rename {themoviedbapi/src => src}/main/java/com/moviejukebox/themoviedb/model/ProductionCountry.java (100%) rename {themoviedbapi/src => src}/main/java/com/moviejukebox/themoviedb/model/ReleaseInfo.java (100%) rename {themoviedbapi/src => src}/main/java/com/moviejukebox/themoviedb/model/StatusCode.java (100%) rename {themoviedbapi/src => src}/main/java/com/moviejukebox/themoviedb/model/TmdbConfiguration.java (100%) rename {themoviedbapi/src => src}/main/java/com/moviejukebox/themoviedb/model/TokenAuthorisation.java (100%) rename {themoviedbapi/src => src}/main/java/com/moviejukebox/themoviedb/model/TokenSession.java (100%) rename {themoviedbapi/src => src}/main/java/com/moviejukebox/themoviedb/model/Trailer.java (100%) rename {themoviedbapi/src => src}/main/java/com/moviejukebox/themoviedb/model/Translation.java (100%) rename {themoviedbapi/src => src}/main/java/com/moviejukebox/themoviedb/tools/ApiUrl.java (100%) rename {themoviedbapi/src => src}/main/java/com/moviejukebox/themoviedb/tools/FilteringLayout.java (100%) rename {themoviedbapi/src => src}/main/java/com/moviejukebox/themoviedb/tools/WebBrowser.java (100%) rename {themoviedbapi/src => src}/main/java/com/moviejukebox/themoviedb/wrapper/WrapperAlternativeTitles.java (100%) rename {themoviedbapi/src => src}/main/java/com/moviejukebox/themoviedb/wrapper/WrapperCompany.java (100%) rename {themoviedbapi/src => src}/main/java/com/moviejukebox/themoviedb/wrapper/WrapperCompanyMovies.java (100%) rename {themoviedbapi/src => src}/main/java/com/moviejukebox/themoviedb/wrapper/WrapperConfig.java (100%) rename {themoviedbapi/src => src}/main/java/com/moviejukebox/themoviedb/wrapper/WrapperGenres.java (100%) rename {themoviedbapi/src => src}/main/java/com/moviejukebox/themoviedb/wrapper/WrapperImages.java (100%) rename {themoviedbapi/src => src}/main/java/com/moviejukebox/themoviedb/wrapper/WrapperMovie.java (100%) rename {themoviedbapi/src => src}/main/java/com/moviejukebox/themoviedb/wrapper/WrapperMovieCasts.java (100%) rename {themoviedbapi/src => src}/main/java/com/moviejukebox/themoviedb/wrapper/WrapperMovieKeywords.java (100%) rename {themoviedbapi/src => src}/main/java/com/moviejukebox/themoviedb/wrapper/WrapperPerson.java (100%) rename {themoviedbapi/src => src}/main/java/com/moviejukebox/themoviedb/wrapper/WrapperPersonCredits.java (100%) rename {themoviedbapi/src => src}/main/java/com/moviejukebox/themoviedb/wrapper/WrapperReleaseInfo.java (100%) rename {themoviedbapi/src => src}/main/java/com/moviejukebox/themoviedb/wrapper/WrapperTrailers.java (100%) rename {themoviedbapi/src => src}/main/java/com/moviejukebox/themoviedb/wrapper/WrapperTranslations.java (100%) rename {themoviedbapi/src => src}/main/resources/bin.xml (100%) rename {themoviedbapi/src => src}/main/resources/log4j.properties (100%) rename {themoviedbapi/src => src}/test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java (100%) delete mode 100644 themoviedbapi/.classpath delete mode 100644 themoviedbapi/.project diff --git a/.gitignore b/.gitignore new file mode 100644 index 000000000..94015f85f --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +*.class + +# Package Files # +*.jar +*.war +*.ear + diff --git a/themoviedbapi/LICENCE.txt b/LICENCE.txt similarity index 100% rename from themoviedbapi/LICENCE.txt rename to LICENCE.txt diff --git a/themoviedbapi/pom.xml b/pom.xml similarity index 100% rename from themoviedbapi/pom.xml rename to pom.xml diff --git a/themoviedbapi/readme.txt b/readme.txt similarity index 100% rename from themoviedbapi/readme.txt rename to readme.txt diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/MovieDbException.java b/src/main/java/com/moviejukebox/themoviedb/MovieDbException.java similarity index 100% rename from themoviedbapi/src/main/java/com/moviejukebox/themoviedb/MovieDbException.java rename to src/main/java/com/moviejukebox/themoviedb/MovieDbException.java diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java b/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java similarity index 100% rename from themoviedbapi/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java rename to src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/AlternativeTitle.java b/src/main/java/com/moviejukebox/themoviedb/model/AlternativeTitle.java similarity index 100% rename from themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/AlternativeTitle.java rename to src/main/java/com/moviejukebox/themoviedb/model/AlternativeTitle.java diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Artwork.java b/src/main/java/com/moviejukebox/themoviedb/model/Artwork.java similarity index 100% rename from themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Artwork.java rename to src/main/java/com/moviejukebox/themoviedb/model/Artwork.java diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/ArtworkType.java b/src/main/java/com/moviejukebox/themoviedb/model/ArtworkType.java similarity index 100% rename from themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/ArtworkType.java rename to src/main/java/com/moviejukebox/themoviedb/model/ArtworkType.java diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Collection.java b/src/main/java/com/moviejukebox/themoviedb/model/Collection.java similarity index 100% rename from themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Collection.java rename to src/main/java/com/moviejukebox/themoviedb/model/Collection.java diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/CollectionInfo.java b/src/main/java/com/moviejukebox/themoviedb/model/CollectionInfo.java similarity index 100% rename from themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/CollectionInfo.java rename to src/main/java/com/moviejukebox/themoviedb/model/CollectionInfo.java diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Company.java b/src/main/java/com/moviejukebox/themoviedb/model/Company.java similarity index 100% rename from themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Company.java rename to src/main/java/com/moviejukebox/themoviedb/model/Company.java diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Genre.java b/src/main/java/com/moviejukebox/themoviedb/model/Genre.java similarity index 100% rename from themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Genre.java rename to src/main/java/com/moviejukebox/themoviedb/model/Genre.java diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Keyword.java b/src/main/java/com/moviejukebox/themoviedb/model/Keyword.java similarity index 100% rename from themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Keyword.java rename to src/main/java/com/moviejukebox/themoviedb/model/Keyword.java diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Language.java b/src/main/java/com/moviejukebox/themoviedb/model/Language.java similarity index 100% rename from themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Language.java rename to src/main/java/com/moviejukebox/themoviedb/model/Language.java diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/MovieDb.java b/src/main/java/com/moviejukebox/themoviedb/model/MovieDb.java similarity index 100% rename from themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/MovieDb.java rename to src/main/java/com/moviejukebox/themoviedb/model/MovieDb.java diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Person.java b/src/main/java/com/moviejukebox/themoviedb/model/Person.java similarity index 100% rename from themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Person.java rename to src/main/java/com/moviejukebox/themoviedb/model/Person.java diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/PersonCast.java b/src/main/java/com/moviejukebox/themoviedb/model/PersonCast.java similarity index 100% rename from themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/PersonCast.java rename to src/main/java/com/moviejukebox/themoviedb/model/PersonCast.java diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/PersonCredit.java b/src/main/java/com/moviejukebox/themoviedb/model/PersonCredit.java similarity index 100% rename from themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/PersonCredit.java rename to src/main/java/com/moviejukebox/themoviedb/model/PersonCredit.java diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/PersonCrew.java b/src/main/java/com/moviejukebox/themoviedb/model/PersonCrew.java similarity index 100% rename from themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/PersonCrew.java rename to src/main/java/com/moviejukebox/themoviedb/model/PersonCrew.java diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/PersonType.java b/src/main/java/com/moviejukebox/themoviedb/model/PersonType.java similarity index 100% rename from themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/PersonType.java rename to src/main/java/com/moviejukebox/themoviedb/model/PersonType.java diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/ProductionCompany.java b/src/main/java/com/moviejukebox/themoviedb/model/ProductionCompany.java similarity index 100% rename from themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/ProductionCompany.java rename to src/main/java/com/moviejukebox/themoviedb/model/ProductionCompany.java diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/ProductionCountry.java b/src/main/java/com/moviejukebox/themoviedb/model/ProductionCountry.java similarity index 100% rename from themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/ProductionCountry.java rename to src/main/java/com/moviejukebox/themoviedb/model/ProductionCountry.java diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/ReleaseInfo.java b/src/main/java/com/moviejukebox/themoviedb/model/ReleaseInfo.java similarity index 100% rename from themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/ReleaseInfo.java rename to src/main/java/com/moviejukebox/themoviedb/model/ReleaseInfo.java diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/StatusCode.java b/src/main/java/com/moviejukebox/themoviedb/model/StatusCode.java similarity index 100% rename from themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/StatusCode.java rename to src/main/java/com/moviejukebox/themoviedb/model/StatusCode.java diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/TmdbConfiguration.java b/src/main/java/com/moviejukebox/themoviedb/model/TmdbConfiguration.java similarity index 100% rename from themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/TmdbConfiguration.java rename to src/main/java/com/moviejukebox/themoviedb/model/TmdbConfiguration.java diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/TokenAuthorisation.java b/src/main/java/com/moviejukebox/themoviedb/model/TokenAuthorisation.java similarity index 100% rename from themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/TokenAuthorisation.java rename to src/main/java/com/moviejukebox/themoviedb/model/TokenAuthorisation.java diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/TokenSession.java b/src/main/java/com/moviejukebox/themoviedb/model/TokenSession.java similarity index 100% rename from themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/TokenSession.java rename to src/main/java/com/moviejukebox/themoviedb/model/TokenSession.java diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Trailer.java b/src/main/java/com/moviejukebox/themoviedb/model/Trailer.java similarity index 100% rename from themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Trailer.java rename to src/main/java/com/moviejukebox/themoviedb/model/Trailer.java diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Translation.java b/src/main/java/com/moviejukebox/themoviedb/model/Translation.java similarity index 100% rename from themoviedbapi/src/main/java/com/moviejukebox/themoviedb/model/Translation.java rename to src/main/java/com/moviejukebox/themoviedb/model/Translation.java diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/ApiUrl.java b/src/main/java/com/moviejukebox/themoviedb/tools/ApiUrl.java similarity index 100% rename from themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/ApiUrl.java rename to src/main/java/com/moviejukebox/themoviedb/tools/ApiUrl.java diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/FilteringLayout.java b/src/main/java/com/moviejukebox/themoviedb/tools/FilteringLayout.java similarity index 100% rename from themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/FilteringLayout.java rename to src/main/java/com/moviejukebox/themoviedb/tools/FilteringLayout.java diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/WebBrowser.java b/src/main/java/com/moviejukebox/themoviedb/tools/WebBrowser.java similarity index 100% rename from themoviedbapi/src/main/java/com/moviejukebox/themoviedb/tools/WebBrowser.java rename to src/main/java/com/moviejukebox/themoviedb/tools/WebBrowser.java diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperAlternativeTitles.java b/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperAlternativeTitles.java similarity index 100% rename from themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperAlternativeTitles.java rename to src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperAlternativeTitles.java diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperCompany.java b/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperCompany.java similarity index 100% rename from themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperCompany.java rename to src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperCompany.java diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperCompanyMovies.java b/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperCompanyMovies.java similarity index 100% rename from themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperCompanyMovies.java rename to src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperCompanyMovies.java diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperConfig.java b/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperConfig.java similarity index 100% rename from themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperConfig.java rename to src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperConfig.java diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperGenres.java b/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperGenres.java similarity index 100% rename from themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperGenres.java rename to src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperGenres.java diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperImages.java b/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperImages.java similarity index 100% rename from themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperImages.java rename to src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperImages.java diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperMovie.java b/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperMovie.java similarity index 100% rename from themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperMovie.java rename to src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperMovie.java diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperMovieCasts.java b/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperMovieCasts.java similarity index 100% rename from themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperMovieCasts.java rename to src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperMovieCasts.java diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperMovieKeywords.java b/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperMovieKeywords.java similarity index 100% rename from themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperMovieKeywords.java rename to src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperMovieKeywords.java diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperPerson.java b/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperPerson.java similarity index 100% rename from themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperPerson.java rename to src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperPerson.java diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperPersonCredits.java b/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperPersonCredits.java similarity index 100% rename from themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperPersonCredits.java rename to src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperPersonCredits.java diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperReleaseInfo.java b/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperReleaseInfo.java similarity index 100% rename from themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperReleaseInfo.java rename to src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperReleaseInfo.java diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperTrailers.java b/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperTrailers.java similarity index 100% rename from themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperTrailers.java rename to src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperTrailers.java diff --git a/themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperTranslations.java b/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperTranslations.java similarity index 100% rename from themoviedbapi/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperTranslations.java rename to src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperTranslations.java diff --git a/themoviedbapi/src/main/resources/bin.xml b/src/main/resources/bin.xml similarity index 100% rename from themoviedbapi/src/main/resources/bin.xml rename to src/main/resources/bin.xml diff --git a/themoviedbapi/src/main/resources/log4j.properties b/src/main/resources/log4j.properties similarity index 100% rename from themoviedbapi/src/main/resources/log4j.properties rename to src/main/resources/log4j.properties diff --git a/themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java b/src/test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java similarity index 100% rename from themoviedbapi/src/test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java rename to src/test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java diff --git a/themoviedbapi/.classpath b/themoviedbapi/.classpath deleted file mode 100644 index 691a73b87..000000000 --- a/themoviedbapi/.classpath +++ /dev/null @@ -1,11 +0,0 @@ - - - - - - - - - - - diff --git a/themoviedbapi/.project b/themoviedbapi/.project deleted file mode 100644 index 58de97bb0..000000000 --- a/themoviedbapi/.project +++ /dev/null @@ -1,23 +0,0 @@ - - - API-TheMovieDb - - - - - - org.eclipse.jdt.core.javabuilder - - - - - org.maven.ide.eclipse.maven2Builder - - - - - - org.maven.ide.eclipse.maven2Nature - org.eclipse.jdt.core.javanature - - From e5e6b1d08eb30463f693a98e45eb1e1ee69cb976 Mon Sep 17 00:00:00 2001 From: Stuart Boston Date: Thu, 1 Nov 2012 14:35:47 +0000 Subject: [PATCH 154/207] Updated project structure --- .gitignore | 15 +-- pom.xml | 30 ++--- .../themoviedbapi}/MovieDbException.java | 2 +- .../themoviedbapi/TheMovieDbApi.java} | 59 +++++++--- .../model/AlternativeTitle.java | 2 +- .../themoviedbapi}/model/Artwork.java | 2 +- .../themoviedbapi}/model/ArtworkType.java | 2 +- .../themoviedbapi}/model/Collection.java | 2 +- .../themoviedbapi}/model/CollectionInfo.java | 2 +- .../themoviedbapi}/model/Company.java | 2 +- .../themoviedbapi}/model/Genre.java | 2 +- .../themoviedbapi}/model/Keyword.java | 2 +- .../themoviedbapi}/model/Language.java | 2 +- .../themoviedbapi}/model/MovieDb.java | 2 +- .../themoviedbapi}/model/Person.java | 2 +- .../themoviedbapi}/model/PersonCast.java | 2 +- .../themoviedbapi}/model/PersonCredit.java | 2 +- .../themoviedbapi}/model/PersonCrew.java | 2 +- .../themoviedbapi}/model/PersonType.java | 2 +- .../model/ProductionCompany.java | 2 +- .../model/ProductionCountry.java | 2 +- .../themoviedbapi}/model/ReleaseInfo.java | 2 +- .../themoviedbapi}/model/StatusCode.java | 2 +- .../model/TmdbConfiguration.java | 2 +- .../model/TokenAuthorisation.java | 2 +- .../themoviedbapi}/model/TokenSession.java | 2 +- .../themoviedbapi}/model/Trailer.java | 2 +- .../themoviedbapi}/model/Translation.java | 2 +- .../themoviedbapi}/tools/ApiUrl.java | 12 +- .../themoviedbapi}/tools/FilteringLayout.java | 2 +- .../themoviedbapi}/tools/WebBrowser.java | 4 +- .../wrapper/WrapperAlternativeTitles.java | 4 +- .../wrapper/WrapperCompany.java | 4 +- .../wrapper/WrapperCompanyMovies.java | 4 +- .../themoviedbapi}/wrapper/WrapperConfig.java | 4 +- .../themoviedbapi}/wrapper/WrapperGenres.java | 4 +- .../themoviedbapi}/wrapper/WrapperImages.java | 4 +- .../themoviedbapi}/wrapper/WrapperMovie.java | 4 +- .../wrapper/WrapperMovieCasts.java | 6 +- .../wrapper/WrapperMovieKeywords.java | 4 +- .../themoviedbapi}/wrapper/WrapperPerson.java | 4 +- .../wrapper/WrapperPersonCredits.java | 4 +- .../wrapper/WrapperReleaseInfo.java | 4 +- .../wrapper/WrapperTrailers.java | 4 +- .../wrapper/WrapperTranslations.java | 4 +- src/main/resources/log4j.properties | 2 +- .../themoviedbapi/TheMovieDbApiTest.java} | 110 ++++++++++-------- 47 files changed, 195 insertions(+), 147 deletions(-) rename src/main/java/com/{moviejukebox/themoviedb => omertron/themoviedbapi}/MovieDbException.java (94%) rename src/main/java/com/{moviejukebox/themoviedb/TheMovieDb.java => omertron/themoviedbapi/TheMovieDbApi.java} (91%) rename src/main/java/com/{moviejukebox/themoviedb => omertron/themoviedbapi}/model/AlternativeTitle.java (98%) rename src/main/java/com/{moviejukebox/themoviedb => omertron/themoviedbapi}/model/Artwork.java (99%) rename src/main/java/com/{moviejukebox/themoviedb => omertron/themoviedbapi}/model/ArtworkType.java (88%) rename src/main/java/com/{moviejukebox/themoviedb => omertron/themoviedbapi}/model/Collection.java (95%) rename src/main/java/com/{moviejukebox/themoviedb => omertron/themoviedbapi}/model/CollectionInfo.java (98%) rename src/main/java/com/{moviejukebox/themoviedb => omertron/themoviedbapi}/model/Company.java (95%) rename src/main/java/com/{moviejukebox/themoviedb => omertron/themoviedbapi}/model/Genre.java (98%) rename src/main/java/com/{moviejukebox/themoviedb => omertron/themoviedbapi}/model/Keyword.java (98%) rename src/main/java/com/{moviejukebox/themoviedb => omertron/themoviedbapi}/model/Language.java (98%) rename src/main/java/com/{moviejukebox/themoviedb => omertron/themoviedbapi}/model/MovieDb.java (99%) rename src/main/java/com/{moviejukebox/themoviedb => omertron/themoviedbapi}/model/Person.java (99%) rename src/main/java/com/{moviejukebox/themoviedb => omertron/themoviedbapi}/model/PersonCast.java (98%) rename src/main/java/com/{moviejukebox/themoviedb => omertron/themoviedbapi}/model/PersonCredit.java (95%) rename src/main/java/com/{moviejukebox/themoviedb => omertron/themoviedbapi}/model/PersonCrew.java (95%) rename src/main/java/com/{moviejukebox/themoviedb => omertron/themoviedbapi}/model/PersonType.java (87%) rename src/main/java/com/{moviejukebox/themoviedb => omertron/themoviedbapi}/model/ProductionCompany.java (98%) rename src/main/java/com/{moviejukebox/themoviedb => omertron/themoviedbapi}/model/ProductionCountry.java (98%) rename src/main/java/com/{moviejukebox/themoviedb => omertron/themoviedbapi}/model/ReleaseInfo.java (98%) rename src/main/java/com/{moviejukebox/themoviedb => omertron/themoviedbapi}/model/StatusCode.java (97%) rename src/main/java/com/{moviejukebox/themoviedb => omertron/themoviedbapi}/model/TmdbConfiguration.java (99%) rename src/main/java/com/{moviejukebox/themoviedb => omertron/themoviedbapi}/model/TokenAuthorisation.java (94%) rename src/main/java/com/{moviejukebox/themoviedb => omertron/themoviedbapi}/model/TokenSession.java (94%) rename src/main/java/com/{moviejukebox/themoviedb => omertron/themoviedbapi}/model/Trailer.java (95%) rename src/main/java/com/{moviejukebox/themoviedb => omertron/themoviedbapi}/model/Translation.java (98%) rename src/main/java/com/{moviejukebox/themoviedb => omertron/themoviedbapi}/tools/ApiUrl.java (92%) rename src/main/java/com/{moviejukebox/themoviedb => omertron/themoviedbapi}/tools/FilteringLayout.java (94%) rename src/main/java/com/{moviejukebox/themoviedb => omertron/themoviedbapi}/tools/WebBrowser.java (96%) rename src/main/java/com/{moviejukebox/themoviedb => omertron/themoviedbapi}/wrapper/WrapperAlternativeTitles.java (93%) rename src/main/java/com/{moviejukebox/themoviedb => omertron/themoviedbapi}/wrapper/WrapperCompany.java (91%) rename src/main/java/com/{moviejukebox/themoviedb => omertron/themoviedbapi}/wrapper/WrapperCompanyMovies.java (96%) rename src/main/java/com/{moviejukebox/themoviedb => omertron/themoviedbapi}/wrapper/WrapperConfig.java (89%) rename src/main/java/com/{moviejukebox/themoviedb => omertron/themoviedbapi}/wrapper/WrapperGenres.java (93%) rename src/main/java/com/{moviejukebox/themoviedb => omertron/themoviedbapi}/wrapper/WrapperImages.java (95%) rename src/main/java/com/{moviejukebox/themoviedb => omertron/themoviedbapi}/wrapper/WrapperMovie.java (96%) rename src/main/java/com/{moviejukebox/themoviedb => omertron/themoviedbapi}/wrapper/WrapperMovieCasts.java (92%) rename src/main/java/com/{moviejukebox/themoviedb => omertron/themoviedbapi}/wrapper/WrapperMovieKeywords.java (94%) rename src/main/java/com/{moviejukebox/themoviedb => omertron/themoviedbapi}/wrapper/WrapperPerson.java (91%) rename src/main/java/com/{moviejukebox/themoviedb => omertron/themoviedbapi}/wrapper/WrapperPersonCredits.java (91%) rename src/main/java/com/{moviejukebox/themoviedb => omertron/themoviedbapi}/wrapper/WrapperReleaseInfo.java (94%) rename src/main/java/com/{moviejukebox/themoviedb => omertron/themoviedbapi}/wrapper/WrapperTrailers.java (95%) rename src/main/java/com/{moviejukebox/themoviedb => omertron/themoviedbapi}/wrapper/WrapperTranslations.java (94%) rename src/test/java/com/{moviejukebox/themoviedb/TheMovieDbTest.java => omertron/themoviedbapi/TheMovieDbApiTest.java} (77%) diff --git a/.gitignore b/.gitignore index 94015f85f..81aa2479a 100644 --- a/.gitignore +++ b/.gitignore @@ -1,7 +1,8 @@ -*.class - -# Package Files # -*.jar -*.war -*.ear - +*.class + +# Package Files # +*.jar +*.war +*.ear + +/target/ \ No newline at end of file diff --git a/pom.xml b/pom.xml index 90577519b..47711d840 100644 --- a/pom.xml +++ b/pom.xml @@ -1,6 +1,6 @@ - 4.0.0 + org.sonatype.oss oss-parent @@ -11,14 +11,23 @@ 3.0.3 - com.moviejukebox + com.omertron themoviedbapi 3.3-SNAPSHOT API-The MovieDB + jar + API for the TheMovieDb.org website + + + false + UTF-8 + UTF-8 + zip + - Google Code - http://code.google.com/p/themoviedbapi/issues/list + GitHub + https://github.com/Omertron/api-themoviedb/issues @@ -27,18 +36,11 @@ - scm:svn:http://themoviedbapi.googlecode.com/svn/trunk/themoviedbapi - scm:svn:https://themoviedbapi.googlecode.com/svn/trunk/themoviedbapi - http://code.google.com/p/themoviedbapi/source/browse/trunk/themoviedbapi + scm:git:git@github.com:Omertron/api-themoviedb.git + scm:git:git@github.com:Omertron/api-themoviedb.git + scm:git:git@github.com:Omertron/api-themoviedb.git - - false - UTF-8 - UTF-8 - zip - - diff --git a/src/main/java/com/moviejukebox/themoviedb/MovieDbException.java b/src/main/java/com/omertron/themoviedbapi/MovieDbException.java similarity index 94% rename from src/main/java/com/moviejukebox/themoviedb/MovieDbException.java rename to src/main/java/com/omertron/themoviedbapi/MovieDbException.java index 1f9a95aa0..a0c8fb0d9 100644 --- a/src/main/java/com/moviejukebox/themoviedb/MovieDbException.java +++ b/src/main/java/com/omertron/themoviedbapi/MovieDbException.java @@ -7,7 +7,7 @@ * For any reuse or distribution, you must make clear to others the * license terms of this work. */ -package com.moviejukebox.themoviedb; +package com.omertron.themoviedbapi; public class MovieDbException extends Exception { diff --git a/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java b/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java similarity index 91% rename from src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java rename to src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java index 49c48abc3..6e0896f78 100644 --- a/src/main/java/com/moviejukebox/themoviedb/TheMovieDb.java +++ b/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java @@ -7,16 +7,47 @@ * For any reuse or distribution, you must make clear to others the * license terms of this work. */ -package com.moviejukebox.themoviedb; +package com.omertron.themoviedbapi; import com.fasterxml.jackson.databind.ObjectMapper; -import com.moviejukebox.themoviedb.MovieDbException.MovieDbExceptionType; -import com.moviejukebox.themoviedb.model.*; -import com.moviejukebox.themoviedb.tools.ApiUrl; -import static com.moviejukebox.themoviedb.tools.ApiUrl.*; -import com.moviejukebox.themoviedb.tools.FilteringLayout; -import com.moviejukebox.themoviedb.tools.WebBrowser; -import com.moviejukebox.themoviedb.wrapper.*; +import com.omertron.themoviedbapi.MovieDbException.MovieDbExceptionType; +import com.omertron.themoviedbapi.model.AlternativeTitle; +import com.omertron.themoviedbapi.model.Artwork; +import com.omertron.themoviedbapi.model.ArtworkType; +import com.omertron.themoviedbapi.model.CollectionInfo; +import com.omertron.themoviedbapi.model.Company; +import com.omertron.themoviedbapi.model.Genre; +import com.omertron.themoviedbapi.model.Keyword; +import com.omertron.themoviedbapi.model.MovieDb; +import com.omertron.themoviedbapi.model.Person; +import com.omertron.themoviedbapi.model.PersonCast; +import com.omertron.themoviedbapi.model.PersonCredit; +import com.omertron.themoviedbapi.model.PersonCrew; +import com.omertron.themoviedbapi.model.PersonType; +import com.omertron.themoviedbapi.model.ReleaseInfo; +import com.omertron.themoviedbapi.model.TmdbConfiguration; +import com.omertron.themoviedbapi.model.TokenAuthorisation; +import com.omertron.themoviedbapi.model.TokenSession; +import com.omertron.themoviedbapi.model.Trailer; +import com.omertron.themoviedbapi.model.Translation; +import com.omertron.themoviedbapi.tools.ApiUrl; +import static com.omertron.themoviedbapi.tools.ApiUrl.*; +import com.omertron.themoviedbapi.tools.FilteringLayout; +import com.omertron.themoviedbapi.tools.WebBrowser; +import com.omertron.themoviedbapi.wrapper.WrapperAlternativeTitles; +import com.omertron.themoviedbapi.wrapper.WrapperCompany; +import com.omertron.themoviedbapi.wrapper.WrapperCompanyMovies; +import com.omertron.themoviedbapi.wrapper.WrapperConfig; +import com.omertron.themoviedbapi.wrapper.WrapperGenres; +import com.omertron.themoviedbapi.wrapper.WrapperImages; +import com.omertron.themoviedbapi.wrapper.WrapperMovie; +import com.omertron.themoviedbapi.wrapper.WrapperMovieCasts; +import com.omertron.themoviedbapi.wrapper.WrapperMovieKeywords; +import com.omertron.themoviedbapi.wrapper.WrapperPerson; +import com.omertron.themoviedbapi.wrapper.WrapperPersonCredits; +import com.omertron.themoviedbapi.wrapper.WrapperReleaseInfo; +import com.omertron.themoviedbapi.wrapper.WrapperTrailers; +import com.omertron.themoviedbapi.wrapper.WrapperTranslations; import java.io.IOException; import java.net.MalformedURLException; import java.net.URL; @@ -32,9 +63,9 @@ import org.apache.log4j.Logger; * * @author stuart.boston */ -public class TheMovieDb { +public class TheMovieDbApi { - private static final Logger LOGGER = Logger.getLogger(TheMovieDb.class); + private static final Logger LOGGER = Logger.getLogger(TheMovieDbApi.class); private String apiKey; private TmdbConfiguration tmdbConfig; /* @@ -73,7 +104,7 @@ public class TheMovieDb { * @param apiKey * @throws MovieDbException */ - public TheMovieDb(String apiKey) throws MovieDbException { + public TheMovieDbApi(String apiKey) throws MovieDbException { this.apiKey = apiKey; ApiUrl apiUrl = new ApiUrl(this, "configuration"); URL configUrl = apiUrl.buildUrl(); @@ -92,11 +123,11 @@ public class TheMovieDb { * Output the API version information to the debug log */ public static void showVersion() { - String apiTitle = TheMovieDb.class.getPackage().getSpecificationTitle(); + String apiTitle = TheMovieDbApi.class.getPackage().getSpecificationTitle(); if (StringUtils.isNotBlank(apiTitle)) { - String apiVersion = TheMovieDb.class.getPackage().getSpecificationVersion(); - String apiRevision = TheMovieDb.class.getPackage().getImplementationVersion(); + String apiVersion = TheMovieDbApi.class.getPackage().getSpecificationVersion(); + String apiRevision = TheMovieDbApi.class.getPackage().getImplementationVersion(); StringBuilder sv = new StringBuilder(); sv.append(apiTitle).append(" "); sv.append(apiVersion).append(" r"); diff --git a/src/main/java/com/moviejukebox/themoviedb/model/AlternativeTitle.java b/src/main/java/com/omertron/themoviedbapi/model/AlternativeTitle.java similarity index 98% rename from src/main/java/com/moviejukebox/themoviedb/model/AlternativeTitle.java rename to src/main/java/com/omertron/themoviedbapi/model/AlternativeTitle.java index c57c564bf..6829a2946 100644 --- a/src/main/java/com/moviejukebox/themoviedb/model/AlternativeTitle.java +++ b/src/main/java/com/omertron/themoviedbapi/model/AlternativeTitle.java @@ -7,7 +7,7 @@ * For any reuse or distribution, you must make clear to others the * license terms of this work. */ -package com.moviejukebox.themoviedb.model; +package com.omertron.themoviedbapi.model; import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/src/main/java/com/moviejukebox/themoviedb/model/Artwork.java b/src/main/java/com/omertron/themoviedbapi/model/Artwork.java similarity index 99% rename from src/main/java/com/moviejukebox/themoviedb/model/Artwork.java rename to src/main/java/com/omertron/themoviedbapi/model/Artwork.java index 391bb468b..74b8257b1 100644 --- a/src/main/java/com/moviejukebox/themoviedb/model/Artwork.java +++ b/src/main/java/com/omertron/themoviedbapi/model/Artwork.java @@ -7,7 +7,7 @@ * For any reuse or distribution, you must make clear to others the * license terms of this work. */ -package com.moviejukebox.themoviedb.model; +package com.omertron.themoviedbapi.model; import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/src/main/java/com/moviejukebox/themoviedb/model/ArtworkType.java b/src/main/java/com/omertron/themoviedbapi/model/ArtworkType.java similarity index 88% rename from src/main/java/com/moviejukebox/themoviedb/model/ArtworkType.java rename to src/main/java/com/omertron/themoviedbapi/model/ArtworkType.java index e454b0b6e..cdf404ab7 100644 --- a/src/main/java/com/moviejukebox/themoviedb/model/ArtworkType.java +++ b/src/main/java/com/omertron/themoviedbapi/model/ArtworkType.java @@ -7,7 +7,7 @@ * For any reuse or distribution, you must make clear to others the * license terms of this work. */ -package com.moviejukebox.themoviedb.model; +package com.omertron.themoviedbapi.model; /** * ArtworkType enum List of the artwork types that are available diff --git a/src/main/java/com/moviejukebox/themoviedb/model/Collection.java b/src/main/java/com/omertron/themoviedbapi/model/Collection.java similarity index 95% rename from src/main/java/com/moviejukebox/themoviedb/model/Collection.java rename to src/main/java/com/omertron/themoviedbapi/model/Collection.java index f3ac281a9..e14c3b6cd 100644 --- a/src/main/java/com/moviejukebox/themoviedb/model/Collection.java +++ b/src/main/java/com/omertron/themoviedbapi/model/Collection.java @@ -7,7 +7,7 @@ * For any reuse or distribution, you must make clear to others the * license terms of this work. */ -package com.moviejukebox.themoviedb.model; +package com.omertron.themoviedbapi.model; import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/src/main/java/com/moviejukebox/themoviedb/model/CollectionInfo.java b/src/main/java/com/omertron/themoviedbapi/model/CollectionInfo.java similarity index 98% rename from src/main/java/com/moviejukebox/themoviedb/model/CollectionInfo.java rename to src/main/java/com/omertron/themoviedbapi/model/CollectionInfo.java index 0edf12770..d128d8aa5 100644 --- a/src/main/java/com/moviejukebox/themoviedb/model/CollectionInfo.java +++ b/src/main/java/com/omertron/themoviedbapi/model/CollectionInfo.java @@ -7,7 +7,7 @@ * For any reuse or distribution, you must make clear to others the * license terms of this work. */ -package com.moviejukebox.themoviedb.model; +package com.omertron.themoviedbapi.model; import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/src/main/java/com/moviejukebox/themoviedb/model/Company.java b/src/main/java/com/omertron/themoviedbapi/model/Company.java similarity index 95% rename from src/main/java/com/moviejukebox/themoviedb/model/Company.java rename to src/main/java/com/omertron/themoviedbapi/model/Company.java index 3cd07bbc8..aa66958d4 100644 --- a/src/main/java/com/moviejukebox/themoviedb/model/Company.java +++ b/src/main/java/com/omertron/themoviedbapi/model/Company.java @@ -7,7 +7,7 @@ * For any reuse or distribution, you must make clear to others the * license terms of this work. */ -package com.moviejukebox.themoviedb.model; +package com.omertron.themoviedbapi.model; import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/src/main/java/com/moviejukebox/themoviedb/model/Genre.java b/src/main/java/com/omertron/themoviedbapi/model/Genre.java similarity index 98% rename from src/main/java/com/moviejukebox/themoviedb/model/Genre.java rename to src/main/java/com/omertron/themoviedbapi/model/Genre.java index b0da30e3e..50efcbcce 100644 --- a/src/main/java/com/moviejukebox/themoviedb/model/Genre.java +++ b/src/main/java/com/omertron/themoviedbapi/model/Genre.java @@ -7,7 +7,7 @@ * For any reuse or distribution, you must make clear to others the * license terms of this work. */ -package com.moviejukebox.themoviedb.model; +package com.omertron.themoviedbapi.model; import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/src/main/java/com/moviejukebox/themoviedb/model/Keyword.java b/src/main/java/com/omertron/themoviedbapi/model/Keyword.java similarity index 98% rename from src/main/java/com/moviejukebox/themoviedb/model/Keyword.java rename to src/main/java/com/omertron/themoviedbapi/model/Keyword.java index f0dd79045..d07205d52 100644 --- a/src/main/java/com/moviejukebox/themoviedb/model/Keyword.java +++ b/src/main/java/com/omertron/themoviedbapi/model/Keyword.java @@ -7,7 +7,7 @@ * For any reuse or distribution, you must make clear to others the * license terms of this work. */ -package com.moviejukebox.themoviedb.model; +package com.omertron.themoviedbapi.model; import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/src/main/java/com/moviejukebox/themoviedb/model/Language.java b/src/main/java/com/omertron/themoviedbapi/model/Language.java similarity index 98% rename from src/main/java/com/moviejukebox/themoviedb/model/Language.java rename to src/main/java/com/omertron/themoviedbapi/model/Language.java index c81dc339c..4fd96f5a6 100644 --- a/src/main/java/com/moviejukebox/themoviedb/model/Language.java +++ b/src/main/java/com/omertron/themoviedbapi/model/Language.java @@ -7,7 +7,7 @@ * For any reuse or distribution, you must make clear to others the * license terms of this work. */ -package com.moviejukebox.themoviedb.model; +package com.omertron.themoviedbapi.model; import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/src/main/java/com/moviejukebox/themoviedb/model/MovieDb.java b/src/main/java/com/omertron/themoviedbapi/model/MovieDb.java similarity index 99% rename from src/main/java/com/moviejukebox/themoviedb/model/MovieDb.java rename to src/main/java/com/omertron/themoviedbapi/model/MovieDb.java index 7dedb1c82..e8afcdc05 100644 --- a/src/main/java/com/moviejukebox/themoviedb/model/MovieDb.java +++ b/src/main/java/com/omertron/themoviedbapi/model/MovieDb.java @@ -7,7 +7,7 @@ * For any reuse or distribution, you must make clear to others the * license terms of this work. */ -package com.moviejukebox.themoviedb.model; +package com.omertron.themoviedbapi.model; import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/src/main/java/com/moviejukebox/themoviedb/model/Person.java b/src/main/java/com/omertron/themoviedbapi/model/Person.java similarity index 99% rename from src/main/java/com/moviejukebox/themoviedb/model/Person.java rename to src/main/java/com/omertron/themoviedbapi/model/Person.java index 771dba51c..93331588f 100644 --- a/src/main/java/com/moviejukebox/themoviedb/model/Person.java +++ b/src/main/java/com/omertron/themoviedbapi/model/Person.java @@ -7,7 +7,7 @@ * For any reuse or distribution, you must make clear to others the * license terms of this work. */ -package com.moviejukebox.themoviedb.model; +package com.omertron.themoviedbapi.model; import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/src/main/java/com/moviejukebox/themoviedb/model/PersonCast.java b/src/main/java/com/omertron/themoviedbapi/model/PersonCast.java similarity index 98% rename from src/main/java/com/moviejukebox/themoviedb/model/PersonCast.java rename to src/main/java/com/omertron/themoviedbapi/model/PersonCast.java index 9b04b7012..bc5af7057 100644 --- a/src/main/java/com/moviejukebox/themoviedb/model/PersonCast.java +++ b/src/main/java/com/omertron/themoviedbapi/model/PersonCast.java @@ -7,7 +7,7 @@ * For any reuse or distribution, you must make clear to others the * license terms of this work. */ -package com.moviejukebox.themoviedb.model; +package com.omertron.themoviedbapi.model; import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/src/main/java/com/moviejukebox/themoviedb/model/PersonCredit.java b/src/main/java/com/omertron/themoviedbapi/model/PersonCredit.java similarity index 95% rename from src/main/java/com/moviejukebox/themoviedb/model/PersonCredit.java rename to src/main/java/com/omertron/themoviedbapi/model/PersonCredit.java index 1698140d5..26e19bbd5 100644 --- a/src/main/java/com/moviejukebox/themoviedb/model/PersonCredit.java +++ b/src/main/java/com/omertron/themoviedbapi/model/PersonCredit.java @@ -7,7 +7,7 @@ * For any reuse or distribution, you must make clear to others the * license terms of this work. */ -package com.moviejukebox.themoviedb.model; +package com.omertron.themoviedbapi.model; import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/src/main/java/com/moviejukebox/themoviedb/model/PersonCrew.java b/src/main/java/com/omertron/themoviedbapi/model/PersonCrew.java similarity index 95% rename from src/main/java/com/moviejukebox/themoviedb/model/PersonCrew.java rename to src/main/java/com/omertron/themoviedbapi/model/PersonCrew.java index d6f69bbd2..ddb5dce05 100644 --- a/src/main/java/com/moviejukebox/themoviedb/model/PersonCrew.java +++ b/src/main/java/com/omertron/themoviedbapi/model/PersonCrew.java @@ -7,7 +7,7 @@ * For any reuse or distribution, you must make clear to others the * license terms of this work. */ -package com.moviejukebox.themoviedb.model; +package com.omertron.themoviedbapi.model; import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/src/main/java/com/moviejukebox/themoviedb/model/PersonType.java b/src/main/java/com/omertron/themoviedbapi/model/PersonType.java similarity index 87% rename from src/main/java/com/moviejukebox/themoviedb/model/PersonType.java rename to src/main/java/com/omertron/themoviedbapi/model/PersonType.java index 40bf83222..2847fd72b 100644 --- a/src/main/java/com/moviejukebox/themoviedb/model/PersonType.java +++ b/src/main/java/com/omertron/themoviedbapi/model/PersonType.java @@ -7,7 +7,7 @@ * For any reuse or distribution, you must make clear to others the * license terms of this work. */ -package com.moviejukebox.themoviedb.model; +package com.omertron.themoviedbapi.model; /** * diff --git a/src/main/java/com/moviejukebox/themoviedb/model/ProductionCompany.java b/src/main/java/com/omertron/themoviedbapi/model/ProductionCompany.java similarity index 98% rename from src/main/java/com/moviejukebox/themoviedb/model/ProductionCompany.java rename to src/main/java/com/omertron/themoviedbapi/model/ProductionCompany.java index 93b10247e..f75481b7b 100644 --- a/src/main/java/com/moviejukebox/themoviedb/model/ProductionCompany.java +++ b/src/main/java/com/omertron/themoviedbapi/model/ProductionCompany.java @@ -7,7 +7,7 @@ * For any reuse or distribution, you must make clear to others the * license terms of this work. */ -package com.moviejukebox.themoviedb.model; +package com.omertron.themoviedbapi.model; import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/src/main/java/com/moviejukebox/themoviedb/model/ProductionCountry.java b/src/main/java/com/omertron/themoviedbapi/model/ProductionCountry.java similarity index 98% rename from src/main/java/com/moviejukebox/themoviedb/model/ProductionCountry.java rename to src/main/java/com/omertron/themoviedbapi/model/ProductionCountry.java index 001d4d289..5374b5ab7 100644 --- a/src/main/java/com/moviejukebox/themoviedb/model/ProductionCountry.java +++ b/src/main/java/com/omertron/themoviedbapi/model/ProductionCountry.java @@ -7,7 +7,7 @@ * For any reuse or distribution, you must make clear to others the * license terms of this work. */ -package com.moviejukebox.themoviedb.model; +package com.omertron.themoviedbapi.model; import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/src/main/java/com/moviejukebox/themoviedb/model/ReleaseInfo.java b/src/main/java/com/omertron/themoviedbapi/model/ReleaseInfo.java similarity index 98% rename from src/main/java/com/moviejukebox/themoviedb/model/ReleaseInfo.java rename to src/main/java/com/omertron/themoviedbapi/model/ReleaseInfo.java index 0edd1dc10..052600445 100644 --- a/src/main/java/com/moviejukebox/themoviedb/model/ReleaseInfo.java +++ b/src/main/java/com/omertron/themoviedbapi/model/ReleaseInfo.java @@ -7,7 +7,7 @@ * For any reuse or distribution, you must make clear to others the * license terms of this work. */ -package com.moviejukebox.themoviedb.model; +package com.omertron.themoviedbapi.model; import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/src/main/java/com/moviejukebox/themoviedb/model/StatusCode.java b/src/main/java/com/omertron/themoviedbapi/model/StatusCode.java similarity index 97% rename from src/main/java/com/moviejukebox/themoviedb/model/StatusCode.java rename to src/main/java/com/omertron/themoviedbapi/model/StatusCode.java index 33c73a091..c6e247613 100644 --- a/src/main/java/com/moviejukebox/themoviedb/model/StatusCode.java +++ b/src/main/java/com/omertron/themoviedbapi/model/StatusCode.java @@ -7,7 +7,7 @@ * For any reuse or distribution, you must make clear to others the * license terms of this work. */ -package com.moviejukebox.themoviedb.model; +package com.omertron.themoviedbapi.model; import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/src/main/java/com/moviejukebox/themoviedb/model/TmdbConfiguration.java b/src/main/java/com/omertron/themoviedbapi/model/TmdbConfiguration.java similarity index 99% rename from src/main/java/com/moviejukebox/themoviedb/model/TmdbConfiguration.java rename to src/main/java/com/omertron/themoviedbapi/model/TmdbConfiguration.java index 7aac0b47a..d427759b7 100644 --- a/src/main/java/com/moviejukebox/themoviedb/model/TmdbConfiguration.java +++ b/src/main/java/com/omertron/themoviedbapi/model/TmdbConfiguration.java @@ -7,7 +7,7 @@ * For any reuse or distribution, you must make clear to others the * license terms of this work. */ -package com.moviejukebox.themoviedb.model; +package com.omertron.themoviedbapi.model; import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/src/main/java/com/moviejukebox/themoviedb/model/TokenAuthorisation.java b/src/main/java/com/omertron/themoviedbapi/model/TokenAuthorisation.java similarity index 94% rename from src/main/java/com/moviejukebox/themoviedb/model/TokenAuthorisation.java rename to src/main/java/com/omertron/themoviedbapi/model/TokenAuthorisation.java index d8c3fb063..e175ce344 100644 --- a/src/main/java/com/moviejukebox/themoviedb/model/TokenAuthorisation.java +++ b/src/main/java/com/omertron/themoviedbapi/model/TokenAuthorisation.java @@ -7,7 +7,7 @@ * For any reuse or distribution, you must make clear to others the * license terms of this work. */ -package com.moviejukebox.themoviedb.model; +package com.omertron.themoviedbapi.model; import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/src/main/java/com/moviejukebox/themoviedb/model/TokenSession.java b/src/main/java/com/omertron/themoviedbapi/model/TokenSession.java similarity index 94% rename from src/main/java/com/moviejukebox/themoviedb/model/TokenSession.java rename to src/main/java/com/omertron/themoviedbapi/model/TokenSession.java index a540af287..c52f9f304 100644 --- a/src/main/java/com/moviejukebox/themoviedb/model/TokenSession.java +++ b/src/main/java/com/omertron/themoviedbapi/model/TokenSession.java @@ -7,7 +7,7 @@ * For any reuse or distribution, you must make clear to others the * license terms of this work. */ -package com.moviejukebox.themoviedb.model; +package com.omertron.themoviedbapi.model; import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/src/main/java/com/moviejukebox/themoviedb/model/Trailer.java b/src/main/java/com/omertron/themoviedbapi/model/Trailer.java similarity index 95% rename from src/main/java/com/moviejukebox/themoviedb/model/Trailer.java rename to src/main/java/com/omertron/themoviedbapi/model/Trailer.java index 9d716caf6..9b582c4ae 100644 --- a/src/main/java/com/moviejukebox/themoviedb/model/Trailer.java +++ b/src/main/java/com/omertron/themoviedbapi/model/Trailer.java @@ -7,7 +7,7 @@ * For any reuse or distribution, you must make clear to others the * license terms of this work. */ -package com.moviejukebox.themoviedb.model; +package com.omertron.themoviedbapi.model; import com.fasterxml.jackson.annotation.JsonAnySetter; import java.io.Serializable; diff --git a/src/main/java/com/moviejukebox/themoviedb/model/Translation.java b/src/main/java/com/omertron/themoviedbapi/model/Translation.java similarity index 98% rename from src/main/java/com/moviejukebox/themoviedb/model/Translation.java rename to src/main/java/com/omertron/themoviedbapi/model/Translation.java index 66f6c769a..ce3036da4 100644 --- a/src/main/java/com/moviejukebox/themoviedb/model/Translation.java +++ b/src/main/java/com/omertron/themoviedbapi/model/Translation.java @@ -7,7 +7,7 @@ * For any reuse or distribution, you must make clear to others the * license terms of this work. */ -package com.moviejukebox.themoviedb.model; +package com.omertron.themoviedbapi.model; import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonProperty; diff --git a/src/main/java/com/moviejukebox/themoviedb/tools/ApiUrl.java b/src/main/java/com/omertron/themoviedbapi/tools/ApiUrl.java similarity index 92% rename from src/main/java/com/moviejukebox/themoviedb/tools/ApiUrl.java rename to src/main/java/com/omertron/themoviedbapi/tools/ApiUrl.java index c89e05631..504ccd9c5 100644 --- a/src/main/java/com/moviejukebox/themoviedb/tools/ApiUrl.java +++ b/src/main/java/com/omertron/themoviedbapi/tools/ApiUrl.java @@ -7,9 +7,9 @@ * For any reuse or distribution, you must make clear to others the * license terms of this work. */ -package com.moviejukebox.themoviedb.tools; +package com.omertron.themoviedbapi.tools; -import com.moviejukebox.themoviedb.TheMovieDb; +import com.omertron.themoviedbapi.TheMovieDbApi; import java.io.UnsupportedEncodingException; import java.net.MalformedURLException; import java.net.URL; @@ -30,7 +30,7 @@ public class ApiUrl { */ private static final Logger LOGGER = Logger.getLogger(ApiUrl.class); /* - * TheMovieDb API Base URL + * TheMovieDbApi API Base URL */ private static final String TMDB_API_BASE = "http://api.themoviedb.org/3/"; // private static final String TMDB_API_BASE = "http://private-3aa3-themoviedb.apiary.io/3/"; @@ -43,7 +43,7 @@ public class ApiUrl { /* * Properties */ - private TheMovieDb tmdb; + private TheMovieDbApi tmdb; private String method; private String submethod; private Map arguments = new HashMap(); @@ -71,7 +71,7 @@ public class ApiUrl { * * @param method */ - public ApiUrl(TheMovieDb tmdb, String method) { + public ApiUrl(TheMovieDbApi tmdb, String method) { this.tmdb = tmdb; this.method = method; this.submethod = DEFAULT_STRING; @@ -83,7 +83,7 @@ public class ApiUrl { * @param method * @param submethod */ - public ApiUrl(TheMovieDb tmdb, String method, String submethod) { + public ApiUrl(TheMovieDbApi tmdb, String method, String submethod) { this.tmdb = tmdb; this.method = method; this.submethod = submethod; diff --git a/src/main/java/com/moviejukebox/themoviedb/tools/FilteringLayout.java b/src/main/java/com/omertron/themoviedbapi/tools/FilteringLayout.java similarity index 94% rename from src/main/java/com/moviejukebox/themoviedb/tools/FilteringLayout.java rename to src/main/java/com/omertron/themoviedbapi/tools/FilteringLayout.java index 6cf8126ff..6f71fe814 100644 --- a/src/main/java/com/moviejukebox/themoviedb/tools/FilteringLayout.java +++ b/src/main/java/com/omertron/themoviedbapi/tools/FilteringLayout.java @@ -7,7 +7,7 @@ * For any reuse or distribution, you must make clear to others the * license terms of this work. */ -package com.moviejukebox.themoviedb.tools; +package com.omertron.themoviedbapi.tools; import java.util.regex.Matcher; import java.util.regex.Pattern; diff --git a/src/main/java/com/moviejukebox/themoviedb/tools/WebBrowser.java b/src/main/java/com/omertron/themoviedbapi/tools/WebBrowser.java similarity index 96% rename from src/main/java/com/moviejukebox/themoviedb/tools/WebBrowser.java rename to src/main/java/com/omertron/themoviedbapi/tools/WebBrowser.java index 0df2cfa1b..801266505 100644 --- a/src/main/java/com/moviejukebox/themoviedb/tools/WebBrowser.java +++ b/src/main/java/com/omertron/themoviedbapi/tools/WebBrowser.java @@ -7,9 +7,9 @@ * For any reuse or distribution, you must make clear to others the * license terms of this work. */ -package com.moviejukebox.themoviedb.tools; +package com.omertron.themoviedbapi.tools; -import com.moviejukebox.themoviedb.MovieDbException; +import com.omertron.themoviedbapi.MovieDbException; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; diff --git a/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperAlternativeTitles.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperAlternativeTitles.java similarity index 93% rename from src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperAlternativeTitles.java rename to src/main/java/com/omertron/themoviedbapi/wrapper/WrapperAlternativeTitles.java index 50af41663..dd6de968d 100644 --- a/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperAlternativeTitles.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperAlternativeTitles.java @@ -7,11 +7,11 @@ * For any reuse or distribution, you must make clear to others the * license terms of this work. */ -package com.moviejukebox.themoviedb.wrapper; +package com.omertron.themoviedbapi.wrapper; import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonProperty; -import com.moviejukebox.themoviedb.model.AlternativeTitle; +import com.omertron.themoviedbapi.model.AlternativeTitle; import java.util.List; import org.apache.log4j.Logger; diff --git a/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperCompany.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperCompany.java similarity index 91% rename from src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperCompany.java rename to src/main/java/com/omertron/themoviedbapi/wrapper/WrapperCompany.java index 62b96140d..dc5f5ef5e 100644 --- a/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperCompany.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperCompany.java @@ -7,11 +7,11 @@ * For any reuse or distribution, you must make clear to others the * license terms of this work. */ -package com.moviejukebox.themoviedb.wrapper; +package com.omertron.themoviedbapi.wrapper; import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonProperty; -import com.moviejukebox.themoviedb.model.Company; +import com.omertron.themoviedbapi.model.Company; import java.util.List; import org.apache.log4j.Logger; diff --git a/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperCompanyMovies.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperCompanyMovies.java similarity index 96% rename from src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperCompanyMovies.java rename to src/main/java/com/omertron/themoviedbapi/wrapper/WrapperCompanyMovies.java index bc286db9b..52456eb8f 100644 --- a/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperCompanyMovies.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperCompanyMovies.java @@ -7,11 +7,11 @@ * For any reuse or distribution, you must make clear to others the * license terms of this work. */ -package com.moviejukebox.themoviedb.wrapper; +package com.omertron.themoviedbapi.wrapper; import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonProperty; -import com.moviejukebox.themoviedb.model.MovieDb; +import com.omertron.themoviedbapi.model.MovieDb; import java.util.List; import org.apache.log4j.Logger; diff --git a/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperConfig.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperConfig.java similarity index 89% rename from src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperConfig.java rename to src/main/java/com/omertron/themoviedbapi/wrapper/WrapperConfig.java index aea884cd0..db4bca4e2 100644 --- a/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperConfig.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperConfig.java @@ -7,11 +7,11 @@ * For any reuse or distribution, you must make clear to others the * license terms of this work. */ -package com.moviejukebox.themoviedb.wrapper; +package com.omertron.themoviedbapi.wrapper; import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonProperty; -import com.moviejukebox.themoviedb.model.TmdbConfiguration; +import com.omertron.themoviedbapi.model.TmdbConfiguration; import org.apache.log4j.Logger; /** diff --git a/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperGenres.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperGenres.java similarity index 93% rename from src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperGenres.java rename to src/main/java/com/omertron/themoviedbapi/wrapper/WrapperGenres.java index f4608455c..0afb0606b 100644 --- a/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperGenres.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperGenres.java @@ -7,11 +7,11 @@ * For any reuse or distribution, you must make clear to others the * license terms of this work. */ -package com.moviejukebox.themoviedb.wrapper; +package com.omertron.themoviedbapi.wrapper; import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonProperty; -import com.moviejukebox.themoviedb.model.Genre; +import com.omertron.themoviedbapi.model.Genre; import java.util.List; import org.apache.log4j.Logger; diff --git a/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperImages.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperImages.java similarity index 95% rename from src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperImages.java rename to src/main/java/com/omertron/themoviedbapi/wrapper/WrapperImages.java index 98edbbfda..2a4a41220 100644 --- a/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperImages.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperImages.java @@ -7,11 +7,11 @@ * For any reuse or distribution, you must make clear to others the * license terms of this work. */ -package com.moviejukebox.themoviedb.wrapper; +package com.omertron.themoviedbapi.wrapper; import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonProperty; -import com.moviejukebox.themoviedb.model.Artwork; +import com.omertron.themoviedbapi.model.Artwork; import java.util.List; import org.apache.log4j.Logger; diff --git a/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperMovie.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovie.java similarity index 96% rename from src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperMovie.java rename to src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovie.java index 2ae8cd5e9..753aff599 100644 --- a/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperMovie.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovie.java @@ -7,11 +7,11 @@ * For any reuse or distribution, you must make clear to others the * license terms of this work. */ -package com.moviejukebox.themoviedb.wrapper; +package com.omertron.themoviedbapi.wrapper; import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonProperty; -import com.moviejukebox.themoviedb.model.MovieDb; +import com.omertron.themoviedbapi.model.MovieDb; import java.util.List; import org.apache.log4j.Logger; diff --git a/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperMovieCasts.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovieCasts.java similarity index 92% rename from src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperMovieCasts.java rename to src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovieCasts.java index 03acee9b6..45d78e0ef 100644 --- a/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperMovieCasts.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovieCasts.java @@ -7,12 +7,12 @@ * For any reuse or distribution, you must make clear to others the * license terms of this work. */ -package com.moviejukebox.themoviedb.wrapper; +package com.omertron.themoviedbapi.wrapper; import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonProperty; -import com.moviejukebox.themoviedb.model.PersonCast; -import com.moviejukebox.themoviedb.model.PersonCrew; +import com.omertron.themoviedbapi.model.PersonCast; +import com.omertron.themoviedbapi.model.PersonCrew; import java.util.List; import org.apache.log4j.Logger; diff --git a/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperMovieKeywords.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovieKeywords.java similarity index 94% rename from src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperMovieKeywords.java rename to src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovieKeywords.java index abec165f5..944d2efa3 100644 --- a/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperMovieKeywords.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovieKeywords.java @@ -7,11 +7,11 @@ * For any reuse or distribution, you must make clear to others the * license terms of this work. */ -package com.moviejukebox.themoviedb.wrapper; +package com.omertron.themoviedbapi.wrapper; import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonProperty; -import com.moviejukebox.themoviedb.model.Keyword; +import com.omertron.themoviedbapi.model.Keyword; import java.util.List; import org.apache.log4j.Logger; diff --git a/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperPerson.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperPerson.java similarity index 91% rename from src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperPerson.java rename to src/main/java/com/omertron/themoviedbapi/wrapper/WrapperPerson.java index 81514b7ca..65a825742 100644 --- a/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperPerson.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperPerson.java @@ -7,11 +7,11 @@ * For any reuse or distribution, you must make clear to others the * license terms of this work. */ -package com.moviejukebox.themoviedb.wrapper; +package com.omertron.themoviedbapi.wrapper; import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonProperty; -import com.moviejukebox.themoviedb.model.Person; +import com.omertron.themoviedbapi.model.Person; import java.util.List; import org.apache.log4j.Logger; diff --git a/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperPersonCredits.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperPersonCredits.java similarity index 91% rename from src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperPersonCredits.java rename to src/main/java/com/omertron/themoviedbapi/wrapper/WrapperPersonCredits.java index 4b4cf4cf6..5de86fb38 100644 --- a/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperPersonCredits.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperPersonCredits.java @@ -7,11 +7,11 @@ * For any reuse or distribution, you must make clear to others the * license terms of this work. */ -package com.moviejukebox.themoviedb.wrapper; +package com.omertron.themoviedbapi.wrapper; import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonProperty; -import com.moviejukebox.themoviedb.model.PersonCredit; +import com.omertron.themoviedbapi.model.PersonCredit; import java.util.List; import org.apache.log4j.Logger; diff --git a/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperReleaseInfo.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperReleaseInfo.java similarity index 94% rename from src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperReleaseInfo.java rename to src/main/java/com/omertron/themoviedbapi/wrapper/WrapperReleaseInfo.java index 8d55e9ea7..f534e3920 100644 --- a/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperReleaseInfo.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperReleaseInfo.java @@ -7,11 +7,11 @@ * For any reuse or distribution, you must make clear to others the * license terms of this work. */ -package com.moviejukebox.themoviedb.wrapper; +package com.omertron.themoviedbapi.wrapper; import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonProperty; -import com.moviejukebox.themoviedb.model.ReleaseInfo; +import com.omertron.themoviedbapi.model.ReleaseInfo; import java.util.List; import org.apache.log4j.Logger; diff --git a/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperTrailers.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperTrailers.java similarity index 95% rename from src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperTrailers.java rename to src/main/java/com/omertron/themoviedbapi/wrapper/WrapperTrailers.java index dde4b774a..a2b3a72e3 100644 --- a/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperTrailers.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperTrailers.java @@ -7,11 +7,11 @@ * For any reuse or distribution, you must make clear to others the * license terms of this work. */ -package com.moviejukebox.themoviedb.wrapper; +package com.omertron.themoviedbapi.wrapper; import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonProperty; -import com.moviejukebox.themoviedb.model.Trailer; +import com.omertron.themoviedbapi.model.Trailer; import java.util.List; import org.apache.log4j.Logger; diff --git a/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperTranslations.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperTranslations.java similarity index 94% rename from src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperTranslations.java rename to src/main/java/com/omertron/themoviedbapi/wrapper/WrapperTranslations.java index ff15f1a85..7b9780628 100644 --- a/src/main/java/com/moviejukebox/themoviedb/wrapper/WrapperTranslations.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperTranslations.java @@ -7,10 +7,10 @@ * For any reuse or distribution, you must make clear to others the * license terms of this work. */ -package com.moviejukebox.themoviedb.wrapper; +package com.omertron.themoviedbapi.wrapper; import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.moviejukebox.themoviedb.model.Translation; +import com.omertron.themoviedbapi.model.Translation; import java.util.List; import org.apache.log4j.Logger; diff --git a/src/main/resources/log4j.properties b/src/main/resources/log4j.properties index 26b472d1e..be8e13285 100644 --- a/src/main/resources/log4j.properties +++ b/src/main/resources/log4j.properties @@ -1,6 +1,6 @@ log4j.rootLogger=DEBUG, CONSOLE log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender -log4j.appender.CONSOLE.layout=com.moviejukebox.themoviedb.tools.FilteringLayout +log4j.appender.CONSOLE.layout=com.omertron.themoviedbapi.tools.FilteringLayout #log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout log4j.appender.CONSOLE.layout.ConversionPattern=[TheMovieDB API-%C{1}] %m%n #log4j.appender.CONSOLE.Threshold=DEBUG diff --git a/src/test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java b/src/test/java/com/omertron/themoviedbapi/TheMovieDbApiTest.java similarity index 77% rename from src/test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java rename to src/test/java/com/omertron/themoviedbapi/TheMovieDbApiTest.java index a9305b742..e9f827fd8 100644 --- a/src/test/java/com/moviejukebox/themoviedb/TheMovieDbTest.java +++ b/src/test/java/com/omertron/themoviedbapi/TheMovieDbApiTest.java @@ -7,10 +7,24 @@ * For any reuse or distribution, you must make clear to others the * license terms of this work. */ -package com.moviejukebox.themoviedb; +package com.omertron.themoviedbapi; -import com.moviejukebox.themoviedb.model.*; -import com.moviejukebox.themoviedb.tools.FilteringLayout; +import com.omertron.themoviedbapi.model.AlternativeTitle; +import com.omertron.themoviedbapi.model.Artwork; +import com.omertron.themoviedbapi.model.CollectionInfo; +import com.omertron.themoviedbapi.model.Company; +import com.omertron.themoviedbapi.model.Genre; +import com.omertron.themoviedbapi.model.Keyword; +import com.omertron.themoviedbapi.model.MovieDb; +import com.omertron.themoviedbapi.model.Person; +import com.omertron.themoviedbapi.model.PersonCredit; +import com.omertron.themoviedbapi.model.ReleaseInfo; +import com.omertron.themoviedbapi.model.TmdbConfiguration; +import com.omertron.themoviedbapi.model.TokenAuthorisation; +import com.omertron.themoviedbapi.model.TokenSession; +import com.omertron.themoviedbapi.model.Trailer; +import com.omertron.themoviedbapi.model.Translation; +import com.omertron.themoviedbapi.tools.FilteringLayout; import java.io.IOException; import java.util.List; import org.apache.commons.lang3.StringUtils; @@ -20,17 +34,17 @@ import org.junit.*; import static org.junit.Assert.*; /** - * Test cases for TheMovieDb API + * Test cases for TheMovieDbApi API * * @author stuart.boston */ -public class TheMovieDbTest { +public class TheMovieDbApiTest { // Logger - private static final Logger LOGGER = Logger.getLogger(TheMovieDbTest.class); + private static final Logger LOGGER = Logger.getLogger(TheMovieDbApiTest.class); // API Key private static final String API_KEY = "5a1a77e2eba8984804586122754f969f"; - private static TheMovieDb tmdb; + private static TheMovieDbApi tmdb; // Test data private static final int ID_MOVIE_BLADE_RUNNER = 78; private static final int ID_MOVIE_STAR_WARS_COLLECTION = 10; @@ -39,8 +53,8 @@ public class TheMovieDbTest { private static final String COMPANY_NAME = "Marvel Studios"; private static final int ID_GENRE_ACTION = 28; - public TheMovieDbTest() throws MovieDbException { - tmdb = new TheMovieDb(API_KEY); + public TheMovieDbApiTest() throws MovieDbException { + tmdb = new TheMovieDbApi(API_KEY); } @BeforeClass @@ -48,7 +62,7 @@ public class TheMovieDbTest { // Set the logger level to TRACE Logger.getRootLogger().setLevel(Level.TRACE); // Show the version of the API - TheMovieDb.showVersion(); + TheMovieDbApi.showVersion(); } @AfterClass @@ -66,7 +80,7 @@ public class TheMovieDbTest { } /** - * Test of getConfiguration method, of class TheMovieDb. + * Test of getConfiguration method, of class TheMovieDbApi. */ @Test public void testConfiguration() throws IOException { @@ -82,7 +96,7 @@ public class TheMovieDbTest { } /** - * Test of showVersion method, of class TheMovieDb. + * Test of showVersion method, of class TheMovieDbApi. */ @Test public void testShowVersion() { @@ -90,7 +104,7 @@ public class TheMovieDbTest { } /** - * Test of searchMovie method, of class TheMovieDb. + * Test of searchMovie method, of class TheMovieDbApi. */ @Test public void testSearchMovie() throws MovieDbException { @@ -111,7 +125,7 @@ public class TheMovieDbTest { } /** - * Test of getMovieInfo method, of class TheMovieDb. + * Test of getMovieInfo method, of class TheMovieDbApi. */ @Test public void testGetMovieInfo() throws MovieDbException { @@ -122,7 +136,7 @@ public class TheMovieDbTest { } /** - * Test of getMovieAlternativeTitles method, of class TheMovieDb. + * Test of getMovieAlternativeTitles method, of class TheMovieDbApi. */ @Test public void testGetMovieAlternativeTitles() throws MovieDbException { @@ -138,7 +152,7 @@ public class TheMovieDbTest { } /** - * Test of getMovieCasts method, of class TheMovieDb. + * Test of getMovieCasts method, of class TheMovieDbApi. */ @Test public void testGetMovieCasts() throws MovieDbException { @@ -165,7 +179,7 @@ public class TheMovieDbTest { } /** - * Test of getMovieImages method, of class TheMovieDb. + * Test of getMovieImages method, of class TheMovieDbApi. */ @Test public void testGetMovieImages() throws MovieDbException { @@ -176,7 +190,7 @@ public class TheMovieDbTest { } /** - * Test of getMovieKeywords method, of class TheMovieDb. + * Test of getMovieKeywords method, of class TheMovieDbApi. */ @Test public void testGetMovieKeywords() throws MovieDbException { @@ -186,7 +200,7 @@ public class TheMovieDbTest { } /** - * Test of getMovieReleaseInfo method, of class TheMovieDb. + * Test of getMovieReleaseInfo method, of class TheMovieDbApi. */ @Test public void testGetMovieReleaseInfo() throws MovieDbException { @@ -196,7 +210,7 @@ public class TheMovieDbTest { } /** - * Test of getMovieTrailers method, of class TheMovieDb. + * Test of getMovieTrailers method, of class TheMovieDbApi. */ @Test public void testGetMovieTrailers() throws MovieDbException { @@ -206,7 +220,7 @@ public class TheMovieDbTest { } /** - * Test of getMovieTranslations method, of class TheMovieDb. + * Test of getMovieTranslations method, of class TheMovieDbApi. */ @Test public void testGetMovieTranslations() throws MovieDbException { @@ -216,7 +230,7 @@ public class TheMovieDbTest { } /** - * Test of getCollectionInfo method, of class TheMovieDb. + * Test of getCollectionInfo method, of class TheMovieDbApi. */ @Test public void testGetCollectionInfo() throws MovieDbException { @@ -227,7 +241,7 @@ public class TheMovieDbTest { } /** - * Test of createImageUrl method, of class TheMovieDb. + * Test of createImageUrl method, of class TheMovieDbApi. * @throws MovieDbException */ @Test @@ -239,7 +253,7 @@ public class TheMovieDbTest { } /** - * Test of getMovieInfoImdb method, of class TheMovieDb. + * Test of getMovieInfoImdb method, of class TheMovieDbApi. */ @Test public void testGetMovieInfoImdb() throws MovieDbException { @@ -249,7 +263,7 @@ public class TheMovieDbTest { } /** - * Test of getApiKey method, of class TheMovieDb. + * Test of getApiKey method, of class TheMovieDbApi. */ @Test public void testGetApiKey() { @@ -257,7 +271,7 @@ public class TheMovieDbTest { } /** - * Test of getApiBase method, of class TheMovieDb. + * Test of getApiBase method, of class TheMovieDbApi. */ @Test public void testGetApiBase() { @@ -265,7 +279,7 @@ public class TheMovieDbTest { } /** - * Test of getConfiguration method, of class TheMovieDb. + * Test of getConfiguration method, of class TheMovieDbApi. */ @Test public void testGetConfiguration() { @@ -273,7 +287,7 @@ public class TheMovieDbTest { } /** - * Test of searchPeople method, of class TheMovieDb. + * Test of searchPeople method, of class TheMovieDbApi. */ @Test public void testSearchPeople() throws MovieDbException { @@ -285,7 +299,7 @@ public class TheMovieDbTest { } /** - * Test of getPersonInfo method, of class TheMovieDb. + * Test of getPersonInfo method, of class TheMovieDbApi. */ @Test public void testGetPersonInfo() throws MovieDbException { @@ -295,7 +309,7 @@ public class TheMovieDbTest { } /** - * Test of getPersonCredits method, of class TheMovieDb. + * Test of getPersonCredits method, of class TheMovieDbApi. */ @Test public void testGetPersonCredits() throws MovieDbException { @@ -306,7 +320,7 @@ public class TheMovieDbTest { } /** - * Test of getPersonImages method, of class TheMovieDb. + * Test of getPersonImages method, of class TheMovieDbApi. */ @Test public void testGetPersonImages() throws MovieDbException { @@ -317,7 +331,7 @@ public class TheMovieDbTest { } /** - * Test of getLatestMovie method, of class TheMovieDb. + * Test of getLatestMovie method, of class TheMovieDbApi. */ @Test public void testGetLatestMovie() throws MovieDbException { @@ -328,7 +342,7 @@ public class TheMovieDbTest { } /** - * Test of compareMovies method, of class TheMovieDb. + * Test of compareMovies method, of class TheMovieDbApi. */ @Test public void testCompareMovies() { @@ -336,7 +350,7 @@ public class TheMovieDbTest { } /** - * Test of setProxy method, of class TheMovieDb. + * Test of setProxy method, of class TheMovieDbApi. */ @Test public void testSetProxy() { @@ -344,7 +358,7 @@ public class TheMovieDbTest { } /** - * Test of setTimeout method, of class TheMovieDb. + * Test of setTimeout method, of class TheMovieDbApi. */ @Test public void testSetTimeout() { @@ -352,7 +366,7 @@ public class TheMovieDbTest { } /** - * Test of getNowPlayingMovies method, of class TheMovieDb. + * Test of getNowPlayingMovies method, of class TheMovieDbApi. */ @Test public void testGetNowPlayingMovies() throws MovieDbException { @@ -362,7 +376,7 @@ public class TheMovieDbTest { } /** - * Test of getPopularMovieList method, of class TheMovieDb. + * Test of getPopularMovieList method, of class TheMovieDbApi. */ @Test public void testGetPopularMovieList() throws MovieDbException { @@ -372,7 +386,7 @@ public class TheMovieDbTest { } /** - * Test of getTopRatedMovies method, of class TheMovieDb. + * Test of getTopRatedMovies method, of class TheMovieDbApi. */ @Test public void testGetTopRatedMovies() throws MovieDbException { @@ -382,7 +396,7 @@ public class TheMovieDbTest { } /** - * Test of getCompanyInfo method, of class TheMovieDb. + * Test of getCompanyInfo method, of class TheMovieDbApi. */ @Test public void testGetCompanyInfo() throws MovieDbException { @@ -392,7 +406,7 @@ public class TheMovieDbTest { } /** - * Test of getCompanyMovies method, of class TheMovieDb. + * Test of getCompanyMovies method, of class TheMovieDbApi. */ @Test public void testGetCompanyMovies() throws MovieDbException { @@ -402,7 +416,7 @@ public class TheMovieDbTest { } /** - * Test of searchCompanies method, of class TheMovieDb. + * Test of searchCompanies method, of class TheMovieDbApi. */ @Test public void testSearchCompanies() throws MovieDbException { @@ -412,7 +426,7 @@ public class TheMovieDbTest { } /** - * Test of getSimilarMovies method, of class TheMovieDb. + * Test of getSimilarMovies method, of class TheMovieDbApi. */ @Test public void testGetSimilarMovies() throws MovieDbException { @@ -422,7 +436,7 @@ public class TheMovieDbTest { } /** - * Test of getGenreList method, of class TheMovieDb. + * Test of getGenreList method, of class TheMovieDbApi. */ @Test public void testGetGenreList() throws MovieDbException { @@ -432,7 +446,7 @@ public class TheMovieDbTest { } /** - * Test of getGenreMovies method, of class TheMovieDb. + * Test of getGenreMovies method, of class TheMovieDbApi. */ @Test public void testGetGenreMovies() throws MovieDbException { @@ -442,7 +456,7 @@ public class TheMovieDbTest { } /** - * Test of getUpcoming method, of class TheMovieDb. + * Test of getUpcoming method, of class TheMovieDbApi. */ @Test public void testGetUpcoming() throws Exception { @@ -452,7 +466,7 @@ public class TheMovieDbTest { } /** - * Test of getCollectionImages method, of class TheMovieDb. + * Test of getCollectionImages method, of class TheMovieDbApi. */ @Test public void testGetCollectionImages() throws Exception { @@ -463,7 +477,7 @@ public class TheMovieDbTest { } /** - * Test of getAuthorisationToken method, of class TheMovieDb. + * Test of getAuthorisationToken method, of class TheMovieDbApi. */ // @Test public void testGetAuthorisationToken() throws Exception { @@ -475,7 +489,7 @@ public class TheMovieDbTest { } /** - * Test of getSessionToken method, of class TheMovieDb. + * Test of getSessionToken method, of class TheMovieDbApi. */ // @Test public void testGetSessionToken() throws Exception { From 52d8d35ed80d48b97718870a2bf23129d7493787 Mon Sep 17 00:00:00 2001 From: Omertron <> Date: Sat, 24 Nov 2012 09:03:18 +0000 Subject: [PATCH 155/207] Removed showVersion method (not working with git) Normalised logger naming --- .../omertron/themoviedbapi/TheMovieDbApi.java | 83 +++++++------------ .../themoviedbapi/model/AlternativeTitle.java | 4 +- .../omertron/themoviedbapi/model/Artwork.java | 4 +- .../themoviedbapi/model/Collection.java | 4 +- .../themoviedbapi/model/CollectionInfo.java | 4 +- .../omertron/themoviedbapi/model/Company.java | 4 +- .../omertron/themoviedbapi/model/Genre.java | 4 +- .../omertron/themoviedbapi/model/Keyword.java | 4 +- .../themoviedbapi/model/Language.java | 4 +- .../omertron/themoviedbapi/model/MovieDb.java | 4 +- .../omertron/themoviedbapi/model/Person.java | 4 +- .../themoviedbapi/model/PersonCast.java | 4 +- .../themoviedbapi/model/PersonCredit.java | 4 +- .../themoviedbapi/model/PersonCrew.java | 4 +- .../model/ProductionCompany.java | 4 +- .../model/ProductionCountry.java | 4 +- .../themoviedbapi/model/ReleaseInfo.java | 4 +- .../themoviedbapi/model/StatusCode.java | 4 +- .../model/TmdbConfiguration.java | 4 +- .../model/TokenAuthorisation.java | 4 +- .../themoviedbapi/model/TokenSession.java | 4 +- .../omertron/themoviedbapi/model/Trailer.java | 4 +- .../themoviedbapi/model/Translation.java | 4 +- .../omertron/themoviedbapi/tools/ApiUrl.java | 8 +- .../themoviedbapi/tools/WebBrowser.java | 4 +- .../wrapper/WrapperAlternativeTitles.java | 4 +- .../themoviedbapi/wrapper/WrapperCompany.java | 4 +- .../wrapper/WrapperCompanyMovies.java | 4 +- .../themoviedbapi/wrapper/WrapperConfig.java | 4 +- .../themoviedbapi/wrapper/WrapperGenres.java | 4 +- .../themoviedbapi/wrapper/WrapperImages.java | 4 +- .../themoviedbapi/wrapper/WrapperMovie.java | 4 +- .../wrapper/WrapperMovieCasts.java | 4 +- .../wrapper/WrapperMovieKeywords.java | 4 +- .../themoviedbapi/wrapper/WrapperPerson.java | 4 +- .../wrapper/WrapperPersonCredits.java | 4 +- .../wrapper/WrapperReleaseInfo.java | 4 +- .../wrapper/WrapperTrailers.java | 4 +- .../wrapper/WrapperTranslations.java | 4 +- .../themoviedbapi/TheMovieDbApiTest.java | 82 ++++++++---------- 40 files changed, 146 insertions(+), 175 deletions(-) diff --git a/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java b/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java index 6e0896f78..9a4888b22 100644 --- a/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java +++ b/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java @@ -65,7 +65,7 @@ import org.apache.log4j.Logger; */ public class TheMovieDbApi { - private static final Logger LOGGER = Logger.getLogger(TheMovieDbApi.class); + private static final Logger logger = Logger.getLogger(TheMovieDbApi.class); private String apiKey; private TmdbConfiguration tmdbConfig; /* @@ -119,25 +119,6 @@ public class TheMovieDbApi { } } - /** - * Output the API version information to the debug log - */ - public static void showVersion() { - String apiTitle = TheMovieDbApi.class.getPackage().getSpecificationTitle(); - - if (StringUtils.isNotBlank(apiTitle)) { - String apiVersion = TheMovieDbApi.class.getPackage().getSpecificationVersion(); - String apiRevision = TheMovieDbApi.class.getPackage().getImplementationVersion(); - StringBuilder sv = new StringBuilder(); - sv.append(apiTitle).append(" "); - sv.append(apiVersion).append(" r"); - sv.append(apiRevision); - LOGGER.debug(sv.toString()); - } else { - LOGGER.debug("API-TheMovieDb version/revision information not available"); - } - } - /** * Get the API key that is to be used * @@ -251,7 +232,7 @@ public class TheMovieDbApi { try { return (new URL(sb.toString())); } catch (MalformedURLException ex) { - LOGGER.warn("Failed to create image URL: " + ex.getMessage()); + logger.warn("Failed to create image URL: " + ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.INVALID_URL, sb.toString(), ex); } } @@ -280,7 +261,7 @@ public class TheMovieDbApi { try { return mapper.readValue(webpage, TokenAuthorisation.class); } catch (IOException ex) { - LOGGER.warn("Failed to get Authorisation Token: " + ex.getMessage()); + logger.warn("Failed to get Authorisation Token: " + ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.AUTHORISATION_FAILURE, webpage, ex); } } @@ -298,7 +279,7 @@ public class TheMovieDbApi { ApiUrl apiUrl = new ApiUrl(this, BASE_AUTH, "session/new"); if (!token.getSuccess()) { - LOGGER.warn("Authorisation token was not successful!"); + logger.warn("Authorisation token was not successful!"); throw new MovieDbException(MovieDbExceptionType.AUTHORISATION_FAILURE, "Authorisation token was not successful!"); } @@ -309,7 +290,7 @@ public class TheMovieDbApi { try { return mapper.readValue(webpage, TokenSession.class); } catch (IOException ex) { - LOGGER.warn("Failed to get Session Token: " + ex.getMessage()); + logger.warn("Failed to get Session Token: " + ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } @@ -344,7 +325,7 @@ public class TheMovieDbApi { try { return mapper.readValue(webpage, MovieDb.class); } catch (IOException ex) { - LOGGER.warn("Failed to get movie info: " + ex.getMessage()); + logger.warn("Failed to get movie info: " + ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } @@ -373,7 +354,7 @@ public class TheMovieDbApi { try { return mapper.readValue(webpage, MovieDb.class); } catch (IOException ex) { - LOGGER.warn("Failed to get movie info: " + ex.getMessage()); + logger.warn("Failed to get movie info: " + ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } @@ -400,7 +381,7 @@ public class TheMovieDbApi { WrapperAlternativeTitles wrapper = mapper.readValue(webpage, WrapperAlternativeTitles.class); return wrapper.getTitles(); } catch (IOException ex) { - LOGGER.warn("Failed to get movie alternative titles: " + ex.getMessage()); + logger.warn("Failed to get movie alternative titles: " + ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } @@ -441,7 +422,7 @@ public class TheMovieDbApi { return people; } catch (IOException ex) { - LOGGER.warn("Failed to get movie casts: " + ex.getMessage()); + logger.warn("Failed to get movie casts: " + ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } @@ -482,7 +463,7 @@ public class TheMovieDbApi { return artwork; } catch (IOException ex) { - LOGGER.warn("Failed to get movie images: " + ex.getMessage()); + logger.warn("Failed to get movie images: " + ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } @@ -507,7 +488,7 @@ public class TheMovieDbApi { WrapperMovieKeywords wrapper = mapper.readValue(webpage, WrapperMovieKeywords.class); return wrapper.getKeywords(); } catch (IOException ex) { - LOGGER.warn("Failed to get movie keywords: " + ex.getMessage()); + logger.warn("Failed to get movie keywords: " + ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } @@ -532,7 +513,7 @@ public class TheMovieDbApi { WrapperReleaseInfo wrapper = mapper.readValue(webpage, WrapperReleaseInfo.class); return wrapper.getCountries(); } catch (IOException ex) { - LOGGER.warn("Failed to get movie release information: " + ex.getMessage()); + logger.warn("Failed to get movie release information: " + ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } @@ -575,7 +556,7 @@ public class TheMovieDbApi { } return trailers; } catch (IOException ex) { - LOGGER.warn("Failed to get movie trailers: " + ex.getMessage()); + logger.warn("Failed to get movie trailers: " + ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } @@ -598,7 +579,7 @@ public class TheMovieDbApi { WrapperTranslations wrapper = mapper.readValue(webpage, WrapperTranslations.class); return wrapper.getTranslations(); } catch (IOException ex) { - LOGGER.warn("Failed to get movie tranlations: " + ex.getMessage()); + logger.warn("Failed to get movie tranlations: " + ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } @@ -635,7 +616,7 @@ public class TheMovieDbApi { WrapperMovie wrapper = mapper.readValue(webpage, WrapperMovie.class); return wrapper.getMovies(); } catch (IOException ex) { - LOGGER.warn("Failed to get similar movies: " + ex.getMessage()); + logger.warn("Failed to get similar movies: " + ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } @@ -653,7 +634,7 @@ public class TheMovieDbApi { try { return mapper.readValue(webpage, MovieDb.class); } catch (IOException ex) { - LOGGER.warn("Failed to get latest movie: " + ex.getMessage()); + logger.warn("Failed to get latest movie: " + ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } @@ -686,7 +667,7 @@ public class TheMovieDbApi { WrapperMovie wrapper = mapper.readValue(webpage, WrapperMovie.class); return wrapper.getMovies(); } catch (IOException ex) { - LOGGER.warn("Failed to get upcoming movies: " + ex.getMessage()); + logger.warn("Failed to get upcoming movies: " + ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } @@ -722,7 +703,7 @@ public class TheMovieDbApi { WrapperMovie wrapper = mapper.readValue(webpage, WrapperMovie.class); return wrapper.getMovies(); } catch (IOException ex) { - LOGGER.warn("Failed to get now playing movies: " + ex.getMessage()); + logger.warn("Failed to get now playing movies: " + ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } @@ -757,7 +738,7 @@ public class TheMovieDbApi { WrapperMovie wrapper = mapper.readValue(webpage, WrapperMovie.class); return wrapper.getMovies(); } catch (IOException ex) { - LOGGER.warn("Failed to get popular movie list: " + ex.getMessage()); + logger.warn("Failed to get popular movie list: " + ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } @@ -792,7 +773,7 @@ public class TheMovieDbApi { WrapperMovie wrapper = mapper.readValue(webpage, WrapperMovie.class); return wrapper.getMovies(); } catch (IOException ex) { - LOGGER.warn("Failed to get top rated movies: " + ex.getMessage()); + logger.warn("Failed to get top rated movies: " + ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } @@ -843,7 +824,7 @@ public class TheMovieDbApi { try { return mapper.readValue(webpage, CollectionInfo.class); } catch (IOException ex) { - LOGGER.warn("Failed to get collection information: " + ex.getMessage()); + logger.warn("Failed to get collection information: " + ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } @@ -885,7 +866,7 @@ public class TheMovieDbApi { return artwork; } catch (IOException ex) { - LOGGER.warn("Failed to get collection images: " + ex.getMessage()); + logger.warn("Failed to get collection images: " + ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } @@ -914,7 +895,7 @@ public class TheMovieDbApi { try { return mapper.readValue(webpage, Person.class); } catch (IOException ex) { - LOGGER.warn("Failed to get movie info: " + ex.getMessage()); + logger.warn("Failed to get movie info: " + ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } @@ -953,7 +934,7 @@ public class TheMovieDbApi { } return personCredits; } catch (IOException ex) { - LOGGER.warn("Failed to get person credits: " + ex.getMessage()); + logger.warn("Failed to get person credits: " + ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } @@ -985,7 +966,7 @@ public class TheMovieDbApi { } return personImages; } catch (IOException ex) { - LOGGER.warn("Failed to get person images: " + ex.getMessage()); + logger.warn("Failed to get person images: " + ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } @@ -1011,7 +992,7 @@ public class TheMovieDbApi { try { return mapper.readValue(webpage, Company.class); } catch (IOException ex) { - LOGGER.warn("Failed to get company information: " + ex.getMessage()); + logger.warn("Failed to get company information: " + ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } @@ -1050,7 +1031,7 @@ public class TheMovieDbApi { WrapperCompanyMovies wrapper = mapper.readValue(webpage, WrapperCompanyMovies.class); return wrapper.getResults(); } catch (IOException ex) { - LOGGER.warn("Failed to get company movies: " + ex.getMessage()); + logger.warn("Failed to get company movies: " + ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } @@ -1077,7 +1058,7 @@ public class TheMovieDbApi { WrapperGenres wrapper = mapper.readValue(webpage, WrapperGenres.class); return wrapper.getGenres(); } catch (IOException ex) { - LOGGER.warn("Failed to get genre list: " + ex.getMessage()); + logger.warn("Failed to get genre list: " + ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } @@ -1113,7 +1094,7 @@ public class TheMovieDbApi { WrapperMovie wrapper = mapper.readValue(webpage, WrapperMovie.class); return wrapper.getMovies(); } catch (IOException ex) { - LOGGER.warn("Failed to get genre movie list: " + ex.getMessage()); + logger.warn("Failed to get genre movie list: " + ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } @@ -1159,7 +1140,7 @@ public class TheMovieDbApi { WrapperMovie wrapper = mapper.readValue(webpage, WrapperMovie.class); return wrapper.getMovies(); } catch (IOException ex) { - LOGGER.warn("Failed to find movie: " + ex.getMessage()); + logger.warn("Failed to find movie: " + ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } @@ -1192,7 +1173,7 @@ public class TheMovieDbApi { WrapperCompany wrapper = mapper.readValue(webpage, WrapperCompany.class); return wrapper.getResults(); } catch (IOException ex) { - LOGGER.warn("Failed to find company: " + ex.getMessage()); + logger.warn("Failed to find company: " + ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } @@ -1225,7 +1206,7 @@ public class TheMovieDbApi { WrapperPerson wrapper = mapper.readValue(webpage, WrapperPerson.class); return wrapper.getResults(); } catch (IOException ex) { - LOGGER.warn("Failed to find person: " + ex.getMessage()); + logger.warn("Failed to find person: " + ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } diff --git a/src/main/java/com/omertron/themoviedbapi/model/AlternativeTitle.java b/src/main/java/com/omertron/themoviedbapi/model/AlternativeTitle.java index 6829a2946..9f923e4a5 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/AlternativeTitle.java +++ b/src/main/java/com/omertron/themoviedbapi/model/AlternativeTitle.java @@ -25,7 +25,7 @@ public class AlternativeTitle implements Serializable { /* * Logger */ - private static final Logger LOGGER = Logger.getLogger(AlternativeTitle.class); + private static final Logger logger = Logger.getLogger(AlternativeTitle.class); /* * Properties */ @@ -65,7 +65,7 @@ public class AlternativeTitle implements Serializable { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - LOGGER.trace(sb.toString()); + logger.trace(sb.toString()); } @Override diff --git a/src/main/java/com/omertron/themoviedbapi/model/Artwork.java b/src/main/java/com/omertron/themoviedbapi/model/Artwork.java index 74b8257b1..97f38bc9f 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/Artwork.java +++ b/src/main/java/com/omertron/themoviedbapi/model/Artwork.java @@ -26,7 +26,7 @@ public class Artwork implements Serializable { /* * Logger */ - private static final Logger LOGGER = Logger.getLogger(Artwork.class); + private static final Logger logger = Logger.getLogger(Artwork.class); /* * Properties */ @@ -125,7 +125,7 @@ public class Artwork implements Serializable { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - LOGGER.trace(sb.toString()); + logger.trace(sb.toString()); } @Override diff --git a/src/main/java/com/omertron/themoviedbapi/model/Collection.java b/src/main/java/com/omertron/themoviedbapi/model/Collection.java index e14c3b6cd..8128aff58 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/Collection.java +++ b/src/main/java/com/omertron/themoviedbapi/model/Collection.java @@ -27,7 +27,7 @@ public class Collection implements Serializable { /* * Logger */ - private static final Logger LOGGER = Logger.getLogger(Collection.class); + private static final Logger logger = Logger.getLogger(Collection.class); /* * Properties */ @@ -113,7 +113,7 @@ public class Collection implements Serializable { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - LOGGER.trace(sb.toString()); + logger.trace(sb.toString()); } @Override diff --git a/src/main/java/com/omertron/themoviedbapi/model/CollectionInfo.java b/src/main/java/com/omertron/themoviedbapi/model/CollectionInfo.java index d128d8aa5..cc35886a7 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/CollectionInfo.java +++ b/src/main/java/com/omertron/themoviedbapi/model/CollectionInfo.java @@ -26,7 +26,7 @@ public class CollectionInfo implements Serializable { /* * Logger */ - private static final Logger LOGGER = Logger.getLogger(CollectionInfo.class); + private static final Logger logger = Logger.getLogger(CollectionInfo.class); /* * Properties */ @@ -96,7 +96,7 @@ public class CollectionInfo implements Serializable { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - LOGGER.trace(sb.toString()); + logger.trace(sb.toString()); } @Override diff --git a/src/main/java/com/omertron/themoviedbapi/model/Company.java b/src/main/java/com/omertron/themoviedbapi/model/Company.java index aa66958d4..f2c5f5da6 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/Company.java +++ b/src/main/java/com/omertron/themoviedbapi/model/Company.java @@ -23,7 +23,7 @@ public class Company implements Serializable { private static final long serialVersionUID = 1L; // Logger - private static final Logger LOGGER = Logger.getLogger(Company.class); + private static final Logger logger = Logger.getLogger(Company.class); private static final String DEFAULT_STRING = ""; // Properties @JsonProperty("id") @@ -112,7 +112,7 @@ public class Company implements Serializable { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - LOGGER.trace(sb.toString()); + logger.trace(sb.toString()); } @Override diff --git a/src/main/java/com/omertron/themoviedbapi/model/Genre.java b/src/main/java/com/omertron/themoviedbapi/model/Genre.java index 50efcbcce..72b3fbc13 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/Genre.java +++ b/src/main/java/com/omertron/themoviedbapi/model/Genre.java @@ -26,7 +26,7 @@ public class Genre implements Serializable { /* * Logger */ - private static final Logger LOGGER = Logger.getLogger(Genre.class); + private static final Logger logger = Logger.getLogger(Genre.class); /* * Properties */ @@ -66,7 +66,7 @@ public class Genre implements Serializable { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - LOGGER.trace(sb.toString()); + logger.trace(sb.toString()); } @Override diff --git a/src/main/java/com/omertron/themoviedbapi/model/Keyword.java b/src/main/java/com/omertron/themoviedbapi/model/Keyword.java index d07205d52..3fdd662bf 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/Keyword.java +++ b/src/main/java/com/omertron/themoviedbapi/model/Keyword.java @@ -27,7 +27,7 @@ public class Keyword implements Serializable { /* * Logger */ - private static final Logger LOGGER = Logger.getLogger(Keyword.class); + private static final Logger logger = Logger.getLogger(Keyword.class); /* * Properties */ @@ -67,7 +67,7 @@ public class Keyword implements Serializable { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - LOGGER.trace(sb.toString()); + logger.trace(sb.toString()); } @Override diff --git a/src/main/java/com/omertron/themoviedbapi/model/Language.java b/src/main/java/com/omertron/themoviedbapi/model/Language.java index 4fd96f5a6..5018e16fb 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/Language.java +++ b/src/main/java/com/omertron/themoviedbapi/model/Language.java @@ -26,7 +26,7 @@ public class Language implements Serializable { /* * Logger */ - private static final Logger LOGGER = Logger.getLogger(Language.class); + private static final Logger logger = Logger.getLogger(Language.class); /* * Properties */ @@ -66,7 +66,7 @@ public class Language implements Serializable { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - LOGGER.trace(sb.toString()); + logger.trace(sb.toString()); } @Override diff --git a/src/main/java/com/omertron/themoviedbapi/model/MovieDb.java b/src/main/java/com/omertron/themoviedbapi/model/MovieDb.java index e8afcdc05..ee180a386 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/MovieDb.java +++ b/src/main/java/com/omertron/themoviedbapi/model/MovieDb.java @@ -26,7 +26,7 @@ public class MovieDb implements Serializable { /* * Logger */ - private static final Logger LOGGER = Logger.getLogger(MovieDb.class); + private static final Logger logger = Logger.getLogger(MovieDb.class); /* * Properties */ @@ -277,7 +277,7 @@ public class MovieDb implements Serializable { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - LOGGER.trace(sb.toString()); + logger.trace(sb.toString()); } // diff --git a/src/main/java/com/omertron/themoviedbapi/model/Person.java b/src/main/java/com/omertron/themoviedbapi/model/Person.java index 93331588f..f41a3cd37 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/Person.java +++ b/src/main/java/com/omertron/themoviedbapi/model/Person.java @@ -27,7 +27,7 @@ public class Person implements Serializable { /* * Logger */ - private static final Logger LOGGER = Logger.getLogger(Person.class); + private static final Logger logger = Logger.getLogger(Person.class); /* * Static fields for default cast information @@ -239,7 +239,7 @@ public class Person implements Serializable { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - LOGGER.trace(sb.toString()); + logger.trace(sb.toString()); } @Override diff --git a/src/main/java/com/omertron/themoviedbapi/model/PersonCast.java b/src/main/java/com/omertron/themoviedbapi/model/PersonCast.java index bc5af7057..3cec57180 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/PersonCast.java +++ b/src/main/java/com/omertron/themoviedbapi/model/PersonCast.java @@ -25,7 +25,7 @@ public class PersonCast implements Serializable { /* * Logger */ - private static final Logger LOGGER = Logger.getLogger(PersonCast.class); + private static final Logger logger = Logger.getLogger(PersonCast.class); /* * Properties */ @@ -107,7 +107,7 @@ public class PersonCast implements Serializable { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - LOGGER.trace(sb.toString()); + logger.trace(sb.toString()); } @Override diff --git a/src/main/java/com/omertron/themoviedbapi/model/PersonCredit.java b/src/main/java/com/omertron/themoviedbapi/model/PersonCredit.java index 26e19bbd5..ecdd2aa07 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/PersonCredit.java +++ b/src/main/java/com/omertron/themoviedbapi/model/PersonCredit.java @@ -25,7 +25,7 @@ public class PersonCredit implements Serializable { /* * Logger */ - private static final Logger LOGGER = Logger.getLogger(PersonCredit.class); + private static final Logger logger = Logger.getLogger(PersonCredit.class); private static final String DEFAULT_STRING = ""; /* * Properties @@ -145,7 +145,7 @@ public class PersonCredit implements Serializable { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - LOGGER.trace(sb.toString()); + logger.trace(sb.toString()); } @Override diff --git a/src/main/java/com/omertron/themoviedbapi/model/PersonCrew.java b/src/main/java/com/omertron/themoviedbapi/model/PersonCrew.java index ddb5dce05..7263dfa2c 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/PersonCrew.java +++ b/src/main/java/com/omertron/themoviedbapi/model/PersonCrew.java @@ -25,7 +25,7 @@ public class PersonCrew implements Serializable { /* * Logger */ - private static final Logger LOGGER = Logger.getLogger(PersonCrew.class); + private static final Logger logger = Logger.getLogger(PersonCrew.class); /* * Properties */ @@ -95,7 +95,7 @@ public class PersonCrew implements Serializable { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - LOGGER.trace(sb.toString()); + logger.trace(sb.toString()); } @Override diff --git a/src/main/java/com/omertron/themoviedbapi/model/ProductionCompany.java b/src/main/java/com/omertron/themoviedbapi/model/ProductionCompany.java index f75481b7b..9df40c878 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/ProductionCompany.java +++ b/src/main/java/com/omertron/themoviedbapi/model/ProductionCompany.java @@ -27,7 +27,7 @@ public class ProductionCompany implements Serializable { /* * Logger */ - private static final Logger LOGGER = Logger.getLogger(ProductionCompany.class); + private static final Logger logger = Logger.getLogger(ProductionCompany.class); /* * Properties */ @@ -67,7 +67,7 @@ public class ProductionCompany implements Serializable { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - LOGGER.trace(sb.toString()); + logger.trace(sb.toString()); } @Override diff --git a/src/main/java/com/omertron/themoviedbapi/model/ProductionCountry.java b/src/main/java/com/omertron/themoviedbapi/model/ProductionCountry.java index 5374b5ab7..c1e4b5aae 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/ProductionCountry.java +++ b/src/main/java/com/omertron/themoviedbapi/model/ProductionCountry.java @@ -27,7 +27,7 @@ public class ProductionCountry implements Serializable { /* * Logger */ - private static final Logger LOGGER = Logger.getLogger(ProductionCountry.class); + private static final Logger logger = Logger.getLogger(ProductionCountry.class); /* * Properties */ @@ -67,7 +67,7 @@ public class ProductionCountry implements Serializable { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - LOGGER.trace(sb.toString()); + logger.trace(sb.toString()); } @Override diff --git a/src/main/java/com/omertron/themoviedbapi/model/ReleaseInfo.java b/src/main/java/com/omertron/themoviedbapi/model/ReleaseInfo.java index 052600445..7bf8faae1 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/ReleaseInfo.java +++ b/src/main/java/com/omertron/themoviedbapi/model/ReleaseInfo.java @@ -25,7 +25,7 @@ public class ReleaseInfo implements Serializable { /* * Logger */ - private static final Logger LOGGER = Logger.getLogger(ReleaseInfo.class); + private static final Logger logger = Logger.getLogger(ReleaseInfo.class); /* * Properties */ @@ -75,7 +75,7 @@ public class ReleaseInfo implements Serializable { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - LOGGER.trace(sb.toString()); + logger.trace(sb.toString()); } @Override diff --git a/src/main/java/com/omertron/themoviedbapi/model/StatusCode.java b/src/main/java/com/omertron/themoviedbapi/model/StatusCode.java index c6e247613..5f6e255b0 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/StatusCode.java +++ b/src/main/java/com/omertron/themoviedbapi/model/StatusCode.java @@ -25,7 +25,7 @@ public class StatusCode implements Serializable { /* * Logger */ - private static final Logger LOGGER = Logger.getLogger(StatusCode.class); + private static final Logger logger = Logger.getLogger(StatusCode.class); /* * Properties */ @@ -65,7 +65,7 @@ public class StatusCode implements Serializable { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - LOGGER.trace(sb.toString()); + logger.trace(sb.toString()); } @Override diff --git a/src/main/java/com/omertron/themoviedbapi/model/TmdbConfiguration.java b/src/main/java/com/omertron/themoviedbapi/model/TmdbConfiguration.java index d427759b7..3a9b6c6fc 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/TmdbConfiguration.java +++ b/src/main/java/com/omertron/themoviedbapi/model/TmdbConfiguration.java @@ -26,7 +26,7 @@ public class TmdbConfiguration implements Serializable { /* * Logger */ - private static final Logger LOGGER = Logger.getLogger(TmdbConfiguration.class); + private static final Logger logger = Logger.getLogger(TmdbConfiguration.class); /* * Properties */ @@ -174,7 +174,7 @@ public class TmdbConfiguration implements Serializable { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - LOGGER.trace(sb.toString()); + logger.trace(sb.toString()); } @Override diff --git a/src/main/java/com/omertron/themoviedbapi/model/TokenAuthorisation.java b/src/main/java/com/omertron/themoviedbapi/model/TokenAuthorisation.java index e175ce344..66dedc73c 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/TokenAuthorisation.java +++ b/src/main/java/com/omertron/themoviedbapi/model/TokenAuthorisation.java @@ -17,7 +17,7 @@ public class TokenAuthorisation { /* * Logger */ - private static final Logger LOGGER = Logger.getLogger(TokenAuthorisation.class); + private static final Logger logger = Logger.getLogger(TokenAuthorisation.class); /* * Properties */ @@ -67,7 +67,7 @@ public class TokenAuthorisation { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - LOGGER.trace(sb.toString()); + logger.trace(sb.toString()); } @Override diff --git a/src/main/java/com/omertron/themoviedbapi/model/TokenSession.java b/src/main/java/com/omertron/themoviedbapi/model/TokenSession.java index c52f9f304..81b10f23a 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/TokenSession.java +++ b/src/main/java/com/omertron/themoviedbapi/model/TokenSession.java @@ -17,7 +17,7 @@ public class TokenSession { /* * Logger */ - private static final Logger LOGGER = Logger.getLogger(TokenSession.class); + private static final Logger logger = Logger.getLogger(TokenSession.class); /* * Properties */ @@ -77,7 +77,7 @@ public class TokenSession { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - LOGGER.trace(sb.toString()); + logger.trace(sb.toString()); } @Override diff --git a/src/main/java/com/omertron/themoviedbapi/model/Trailer.java b/src/main/java/com/omertron/themoviedbapi/model/Trailer.java index 9b582c4ae..fbb6f6c59 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/Trailer.java +++ b/src/main/java/com/omertron/themoviedbapi/model/Trailer.java @@ -24,7 +24,7 @@ public class Trailer implements Serializable { /* * Logger */ - private static final Logger LOGGER = Logger.getLogger(Trailer.class); + private static final Logger logger = Logger.getLogger(Trailer.class); /* * Website sources */ @@ -85,7 +85,7 @@ public class Trailer implements Serializable { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - LOGGER.trace(sb.toString()); + logger.trace(sb.toString()); } @Override diff --git a/src/main/java/com/omertron/themoviedbapi/model/Translation.java b/src/main/java/com/omertron/themoviedbapi/model/Translation.java index ce3036da4..989faa1f5 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/Translation.java +++ b/src/main/java/com/omertron/themoviedbapi/model/Translation.java @@ -25,7 +25,7 @@ public class Translation implements Serializable { /* * Logger */ - private static final Logger LOGGER = Logger.getLogger(Translation.class); + private static final Logger logger = Logger.getLogger(Translation.class); /* * Properties */ @@ -75,7 +75,7 @@ public class Translation implements Serializable { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - LOGGER.trace(sb.toString()); + logger.trace(sb.toString()); } @Override diff --git a/src/main/java/com/omertron/themoviedbapi/tools/ApiUrl.java b/src/main/java/com/omertron/themoviedbapi/tools/ApiUrl.java index 504ccd9c5..e812efa47 100644 --- a/src/main/java/com/omertron/themoviedbapi/tools/ApiUrl.java +++ b/src/main/java/com/omertron/themoviedbapi/tools/ApiUrl.java @@ -28,7 +28,7 @@ public class ApiUrl { /* * Logger */ - private static final Logger LOGGER = Logger.getLogger(ApiUrl.class); + private static final Logger logger = Logger.getLogger(ApiUrl.class); /* * TheMovieDbApi API Base URL */ @@ -119,7 +119,7 @@ public class ApiUrl { try { urlString.append(URLEncoder.encode(query, "UTF-8")); } catch (UnsupportedEncodingException ex) { - LOGGER.trace("Unable to encode query: '" + query + "' trying raw."); + logger.trace("Unable to encode query: '" + query + "' trying raw."); // If we can't encode it, try it raw urlString.append(query); } @@ -146,10 +146,10 @@ public class ApiUrl { } try { - LOGGER.trace("URL: " + urlString.toString()); + logger.trace("URL: " + urlString.toString()); return new URL(urlString.toString()); } catch (MalformedURLException ex) { - LOGGER.warn("Failed to create URL " + urlString.toString() + " - " + ex.toString()); + logger.warn("Failed to create URL " + urlString.toString() + " - " + ex.toString()); return null; } finally { arguments.clear(); diff --git a/src/main/java/com/omertron/themoviedbapi/tools/WebBrowser.java b/src/main/java/com/omertron/themoviedbapi/tools/WebBrowser.java index 801266505..88b29301d 100644 --- a/src/main/java/com/omertron/themoviedbapi/tools/WebBrowser.java +++ b/src/main/java/com/omertron/themoviedbapi/tools/WebBrowser.java @@ -33,7 +33,7 @@ import org.apache.log4j.Logger; */ public final class WebBrowser { - private static final Logger LOGGER = Logger.getLogger(WebBrowser.class); + private static final Logger logger = Logger.getLogger(WebBrowser.class); private static Map browserProperties = new HashMap(); private static Map> cookies = new HashMap>(); private static String proxyHost = null; @@ -123,7 +123,7 @@ public final class WebBrowser { try { content.close(); } catch (IOException ex) { - LOGGER.debug("Failed to close connection: " + ex.getMessage()); + logger.debug("Failed to close connection: " + ex.getMessage()); } } } diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperAlternativeTitles.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperAlternativeTitles.java index dd6de968d..7029fd60b 100644 --- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperAlternativeTitles.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperAlternativeTitles.java @@ -24,7 +24,7 @@ public class WrapperAlternativeTitles { * Logger */ - private static final Logger LOGGER = Logger.getLogger(WrapperAlternativeTitles.class); + private static final Logger logger = Logger.getLogger(WrapperAlternativeTitles.class); /* * Properties */ @@ -59,6 +59,6 @@ public class WrapperAlternativeTitles { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - LOGGER.trace(sb.toString()); + logger.trace(sb.toString()); } } diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperCompany.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperCompany.java index dc5f5ef5e..73188e1f1 100644 --- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperCompany.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperCompany.java @@ -24,7 +24,7 @@ public class WrapperCompany { * Logger */ - private static final Logger LOGGER = Logger.getLogger(WrapperCompany.class); + private static final Logger logger = Logger.getLogger(WrapperCompany.class); /* * Properties */ @@ -83,6 +83,6 @@ public class WrapperCompany { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - LOGGER.trace(sb.toString()); + logger.trace(sb.toString()); } } diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperCompanyMovies.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperCompanyMovies.java index 52456eb8f..fd766bf2e 100644 --- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperCompanyMovies.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperCompanyMovies.java @@ -21,7 +21,7 @@ import org.apache.log4j.Logger; */ public class WrapperCompanyMovies { // Loggers - private static final Logger LOGGER = Logger.getLogger(WrapperCompanyMovies.class); + private static final Logger logger = Logger.getLogger(WrapperCompanyMovies.class); /* * Properties */ @@ -90,7 +90,7 @@ public class WrapperCompanyMovies { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - LOGGER.trace(sb.toString()); + logger.trace(sb.toString()); } @Override diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperConfig.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperConfig.java index db4bca4e2..b04823d8b 100644 --- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperConfig.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperConfig.java @@ -23,7 +23,7 @@ public class WrapperConfig { * Logger */ - private static final Logger LOGGER = Logger.getLogger(WrapperConfig.class); + private static final Logger logger = Logger.getLogger(WrapperConfig.class); /* * Properties */ @@ -48,7 +48,7 @@ public class WrapperConfig { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - LOGGER.trace(sb.toString()); + logger.trace(sb.toString()); } } diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperGenres.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperGenres.java index 0afb0606b..6ed74e32a 100644 --- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperGenres.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperGenres.java @@ -25,7 +25,7 @@ public class WrapperGenres { * Logger */ - private static final Logger LOGGER = Logger.getLogger(WrapperGenres.class); + private static final Logger logger = Logger.getLogger(WrapperGenres.class); /* * Properties */ @@ -51,6 +51,6 @@ public class WrapperGenres { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - LOGGER.trace(sb.toString()); + logger.trace(sb.toString()); } } diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperImages.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperImages.java index 2a4a41220..590983df3 100644 --- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperImages.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperImages.java @@ -24,7 +24,7 @@ public class WrapperImages { * Logger */ - private static final Logger LOGGER = Logger.getLogger(WrapperImages.class); + private static final Logger logger = Logger.getLogger(WrapperImages.class); /* * Properties */ @@ -84,6 +84,6 @@ public class WrapperImages { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - LOGGER.trace(sb.toString()); + logger.trace(sb.toString()); } } diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovie.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovie.java index 753aff599..f95293280 100644 --- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovie.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovie.java @@ -24,7 +24,7 @@ public class WrapperMovie { * Logger */ - private static final Logger LOGGER = Logger.getLogger(WrapperMovie.class); + private static final Logger logger = Logger.getLogger(WrapperMovie.class); /* * Properties */ @@ -94,7 +94,7 @@ public class WrapperMovie { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - LOGGER.trace(sb.toString()); + logger.trace(sb.toString()); } @Override diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovieCasts.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovieCasts.java index 45d78e0ef..979435994 100644 --- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovieCasts.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovieCasts.java @@ -25,7 +25,7 @@ public class WrapperMovieCasts { * Logger */ - private static final Logger LOGGER = Logger.getLogger(WrapperMovieCasts.class); + private static final Logger logger = Logger.getLogger(WrapperMovieCasts.class); /* * Properties */ @@ -74,6 +74,6 @@ public class WrapperMovieCasts { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - LOGGER.trace(sb.toString()); + logger.trace(sb.toString()); } } diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovieKeywords.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovieKeywords.java index 944d2efa3..aa635c6c8 100644 --- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovieKeywords.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovieKeywords.java @@ -24,7 +24,7 @@ public class WrapperMovieKeywords { * Logger */ - private static final Logger LOGGER = Logger.getLogger(WrapperMovieKeywords.class); + private static final Logger logger = Logger.getLogger(WrapperMovieKeywords.class); /* * Properties */ @@ -63,6 +63,6 @@ public class WrapperMovieKeywords { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - LOGGER.trace(sb.toString()); + logger.trace(sb.toString()); } } diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperPerson.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperPerson.java index 65a825742..28e427c18 100644 --- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperPerson.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperPerson.java @@ -24,7 +24,7 @@ public class WrapperPerson { * Logger */ - private static final Logger LOGGER = Logger.getLogger(WrapperPerson.class); + private static final Logger logger = Logger.getLogger(WrapperPerson.class); /* * Properties */ @@ -83,6 +83,6 @@ public class WrapperPerson { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - LOGGER.trace(sb.toString()); + logger.trace(sb.toString()); } } diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperPersonCredits.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperPersonCredits.java index 5de86fb38..08e25d147 100644 --- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperPersonCredits.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperPersonCredits.java @@ -24,7 +24,7 @@ public class WrapperPersonCredits { * Logger */ - private static final Logger LOGGER = Logger.getLogger(WrapperMovieCasts.class); + private static final Logger logger = Logger.getLogger(WrapperMovieCasts.class); /* * Properties */ @@ -73,6 +73,6 @@ public class WrapperPersonCredits { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - LOGGER.trace(sb.toString()); + logger.trace(sb.toString()); } } diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperReleaseInfo.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperReleaseInfo.java index f534e3920..3cf6497b1 100644 --- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperReleaseInfo.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperReleaseInfo.java @@ -24,7 +24,7 @@ public class WrapperReleaseInfo { * Logger */ - private static final Logger LOGGER = Logger.getLogger(WrapperReleaseInfo.class); + private static final Logger logger = Logger.getLogger(WrapperReleaseInfo.class); /* * Properties */ @@ -63,6 +63,6 @@ public class WrapperReleaseInfo { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - LOGGER.trace(sb.toString()); + logger.trace(sb.toString()); } } diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperTrailers.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperTrailers.java index a2b3a72e3..d4349aee7 100644 --- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperTrailers.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperTrailers.java @@ -24,7 +24,7 @@ public class WrapperTrailers { * Logger */ - private static final Logger LOGGER = Logger.getLogger(WrapperTrailers.class); + private static final Logger logger = Logger.getLogger(WrapperTrailers.class); /* * Properties */ @@ -73,6 +73,6 @@ public class WrapperTrailers { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - LOGGER.trace(sb.toString()); + logger.trace(sb.toString()); } } diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperTranslations.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperTranslations.java index 7b9780628..63e620dcc 100644 --- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperTranslations.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperTranslations.java @@ -23,7 +23,7 @@ public class WrapperTranslations { * Logger */ - private static final Logger LOGGER = Logger.getLogger(WrapperTranslations.class); + private static final Logger logger = Logger.getLogger(WrapperTranslations.class); /* * Properties */ @@ -60,6 +60,6 @@ public class WrapperTranslations { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - LOGGER.trace(sb.toString()); + logger.trace(sb.toString()); } } diff --git a/src/test/java/com/omertron/themoviedbapi/TheMovieDbApiTest.java b/src/test/java/com/omertron/themoviedbapi/TheMovieDbApiTest.java index e9f827fd8..28e084b24 100644 --- a/src/test/java/com/omertron/themoviedbapi/TheMovieDbApiTest.java +++ b/src/test/java/com/omertron/themoviedbapi/TheMovieDbApiTest.java @@ -41,7 +41,7 @@ import static org.junit.Assert.*; public class TheMovieDbApiTest { // Logger - private static final Logger LOGGER = Logger.getLogger(TheMovieDbApiTest.class); + private static final Logger logger = Logger.getLogger(TheMovieDbApiTest.class); // API Key private static final String API_KEY = "5a1a77e2eba8984804586122754f969f"; private static TheMovieDbApi tmdb; @@ -61,8 +61,6 @@ public class TheMovieDbApiTest { public static void setUpClass() throws Exception { // Set the logger level to TRACE Logger.getRootLogger().setLevel(Level.TRACE); - // Show the version of the API - TheMovieDbApi.showVersion(); } @AfterClass @@ -84,7 +82,7 @@ public class TheMovieDbApiTest { */ @Test public void testConfiguration() throws IOException { - LOGGER.info("Test Configuration"); + logger.info("Test Configuration"); TmdbConfiguration tmdbConfig = tmdb.getConfiguration(); assertNotNull("Configuration failed", tmdbConfig); @@ -92,15 +90,7 @@ public class TheMovieDbApiTest { assertTrue("No backdrop sizes", tmdbConfig.getBackdropSizes().size() > 0); assertTrue("No poster sizes", tmdbConfig.getPosterSizes().size() > 0); assertTrue("No profile sizes", tmdbConfig.getProfileSizes().size() > 0); - LOGGER.info(tmdbConfig.toString()); - } - - /** - * Test of showVersion method, of class TheMovieDbApi. - */ - @Test - public void testShowVersion() { - // Not required + logger.info(tmdbConfig.toString()); } /** @@ -108,7 +98,7 @@ public class TheMovieDbApiTest { */ @Test public void testSearchMovie() throws MovieDbException { - LOGGER.info("searchMovie"); + logger.info("searchMovie"); // Try a movie with less than 1 page of results List movieList = tmdb.searchMovie("Blade Runner", 0, "", true, 0); @@ -129,7 +119,7 @@ public class TheMovieDbApiTest { */ @Test public void testGetMovieInfo() throws MovieDbException { - LOGGER.info("getMovieInfo"); + logger.info("getMovieInfo"); String language = "en"; MovieDb result = tmdb.getMovieInfo(ID_MOVIE_BLADE_RUNNER, language); assertEquals("Incorrect movie information", "Blade Runner", result.getOriginalTitle()); @@ -140,7 +130,7 @@ public class TheMovieDbApiTest { */ @Test public void testGetMovieAlternativeTitles() throws MovieDbException { - LOGGER.info("getMovieAlternativeTitles"); + logger.info("getMovieAlternativeTitles"); String country = ""; List results = tmdb.getMovieAlternativeTitles(ID_MOVIE_BLADE_RUNNER, country); assertTrue("No alternative titles found", results.size() > 0); @@ -156,7 +146,7 @@ public class TheMovieDbApiTest { */ @Test public void testGetMovieCasts() throws MovieDbException { - LOGGER.info("getMovieCasts"); + logger.info("getMovieCasts"); List people = tmdb.getMovieCasts(ID_MOVIE_BLADE_RUNNER); assertTrue("No cast information", people.size() > 0); @@ -183,7 +173,7 @@ public class TheMovieDbApiTest { */ @Test public void testGetMovieImages() throws MovieDbException { - LOGGER.info("getMovieImages"); + logger.info("getMovieImages"); String language = ""; List result = tmdb.getMovieImages(ID_MOVIE_BLADE_RUNNER, language); assertFalse("No artwork found", result.isEmpty()); @@ -194,7 +184,7 @@ public class TheMovieDbApiTest { */ @Test public void testGetMovieKeywords() throws MovieDbException { - LOGGER.info("getMovieKeywords"); + logger.info("getMovieKeywords"); List result = tmdb.getMovieKeywords(ID_MOVIE_BLADE_RUNNER); assertFalse("No keywords found", result.isEmpty()); } @@ -204,7 +194,7 @@ public class TheMovieDbApiTest { */ @Test public void testGetMovieReleaseInfo() throws MovieDbException { - LOGGER.info("getMovieReleaseInfo"); + logger.info("getMovieReleaseInfo"); List result = tmdb.getMovieReleaseInfo(ID_MOVIE_BLADE_RUNNER, ""); assertFalse("Release information missing", result.isEmpty()); } @@ -214,7 +204,7 @@ public class TheMovieDbApiTest { */ @Test public void testGetMovieTrailers() throws MovieDbException { - LOGGER.info("getMovieTrailers"); + logger.info("getMovieTrailers"); List result = tmdb.getMovieTrailers(ID_MOVIE_BLADE_RUNNER, ""); assertFalse("Movie trailers missing", result.isEmpty()); } @@ -224,7 +214,7 @@ public class TheMovieDbApiTest { */ @Test public void testGetMovieTranslations() throws MovieDbException { - LOGGER.info("getMovieTranslations"); + logger.info("getMovieTranslations"); List result = tmdb.getMovieTranslations(ID_MOVIE_BLADE_RUNNER); assertFalse("No translations found", result.isEmpty()); } @@ -234,7 +224,7 @@ public class TheMovieDbApiTest { */ @Test public void testGetCollectionInfo() throws MovieDbException { - LOGGER.info("getCollectionInfo"); + logger.info("getCollectionInfo"); String language = ""; CollectionInfo result = tmdb.getCollectionInfo(ID_MOVIE_STAR_WARS_COLLECTION, language); assertFalse("No collection information", result.getParts().isEmpty()); @@ -246,7 +236,7 @@ public class TheMovieDbApiTest { */ @Test public void testCreateImageUrl() throws MovieDbException { - LOGGER.info("createImageUrl"); + logger.info("createImageUrl"); MovieDb movie = tmdb.getMovieInfo(ID_MOVIE_BLADE_RUNNER, ""); String result = tmdb.createImageUrl(movie.getPosterPath(), "original").toString(); assertTrue("Error compiling image URL", !result.isEmpty()); @@ -257,7 +247,7 @@ public class TheMovieDbApiTest { */ @Test public void testGetMovieInfoImdb() throws MovieDbException { - LOGGER.info("getMovieInfoImdb"); + logger.info("getMovieInfoImdb"); MovieDb result = tmdb.getMovieInfoImdb("tt0076759", "en-US"); assertTrue("Error getting the movie from IMDB ID", result.getId() == 11); } @@ -291,7 +281,7 @@ public class TheMovieDbApiTest { */ @Test public void testSearchPeople() throws MovieDbException { - LOGGER.info("searchPeople"); + logger.info("searchPeople"); String personName = "Bruce Willis"; boolean allResults = false; List result = tmdb.searchPeople(personName, allResults); @@ -303,7 +293,7 @@ public class TheMovieDbApiTest { */ @Test public void testGetPersonInfo() throws MovieDbException { - LOGGER.info("getPersonInfo"); + logger.info("getPersonInfo"); Person result = tmdb.getPersonInfo(ID_PERSON_BRUCE_WILLIS); assertTrue("Wrong actor returned", result.getId() == ID_PERSON_BRUCE_WILLIS); } @@ -313,7 +303,7 @@ public class TheMovieDbApiTest { */ @Test public void testGetPersonCredits() throws MovieDbException { - LOGGER.info("getPersonCredits"); + logger.info("getPersonCredits"); List people = tmdb.getPersonCredits(ID_PERSON_BRUCE_WILLIS); assertTrue("No cast information", people.size() > 0); @@ -324,7 +314,7 @@ public class TheMovieDbApiTest { */ @Test public void testGetPersonImages() throws MovieDbException { - LOGGER.info("getPersonImages"); + logger.info("getPersonImages"); List artwork = tmdb.getPersonImages(ID_PERSON_BRUCE_WILLIS); assertTrue("No cast information", artwork.size() > 0); @@ -335,7 +325,7 @@ public class TheMovieDbApiTest { */ @Test public void testGetLatestMovie() throws MovieDbException { - LOGGER.info("getLatestMovie"); + logger.info("getLatestMovie"); MovieDb result = tmdb.getLatestMovie(); assertTrue("No latest movie found", result != null); assertTrue("No latest movie found", result.getId() > 0); @@ -370,7 +360,7 @@ public class TheMovieDbApiTest { */ @Test public void testGetNowPlayingMovies() throws MovieDbException { - LOGGER.info("getNowPlayingMovies"); + logger.info("getNowPlayingMovies"); List results = tmdb.getNowPlayingMovies("", true); assertTrue("No now playing movies found", !results.isEmpty()); } @@ -380,7 +370,7 @@ public class TheMovieDbApiTest { */ @Test public void testGetPopularMovieList() throws MovieDbException { - LOGGER.info("getPopularMovieList"); + logger.info("getPopularMovieList"); List results = tmdb.getPopularMovieList("", true); assertTrue("No popular movies found", !results.isEmpty()); } @@ -390,7 +380,7 @@ public class TheMovieDbApiTest { */ @Test public void testGetTopRatedMovies() throws MovieDbException { - LOGGER.info("getTopRatedMovies"); + logger.info("getTopRatedMovies"); List results = tmdb.getTopRatedMovies("", true); assertTrue("No top rated movies found", !results.isEmpty()); } @@ -400,7 +390,7 @@ public class TheMovieDbApiTest { */ @Test public void testGetCompanyInfo() throws MovieDbException { - LOGGER.info("getCompanyInfo"); + logger.info("getCompanyInfo"); Company company = tmdb.getCompanyInfo(ID_COMPANY_LUCASFILM); assertTrue("No company information found", company.getCompanyId() > 0); } @@ -410,7 +400,7 @@ public class TheMovieDbApiTest { */ @Test public void testGetCompanyMovies() throws MovieDbException { - LOGGER.info("getCompanyMovies"); + logger.info("getCompanyMovies"); List results = tmdb.getCompanyMovies(ID_COMPANY_LUCASFILM, "", true); assertTrue("No company movies found", !results.isEmpty()); } @@ -420,7 +410,7 @@ public class TheMovieDbApiTest { */ @Test public void testSearchCompanies() throws MovieDbException { - LOGGER.info("searchCompanies"); + logger.info("searchCompanies"); List results = tmdb.searchCompanies(COMPANY_NAME, "", true); assertTrue("No company information found", !results.isEmpty()); } @@ -430,7 +420,7 @@ public class TheMovieDbApiTest { */ @Test public void testGetSimilarMovies() throws MovieDbException { - LOGGER.info("getSimilarMovies"); + logger.info("getSimilarMovies"); List results = tmdb.getSimilarMovies(ID_MOVIE_BLADE_RUNNER, "", true); assertTrue("No similar movies found", !results.isEmpty()); } @@ -440,7 +430,7 @@ public class TheMovieDbApiTest { */ @Test public void testGetGenreList() throws MovieDbException { - LOGGER.info("getGenreList"); + logger.info("getGenreList"); List results = tmdb.getGenreList(""); assertTrue("No genres found", !results.isEmpty()); } @@ -450,7 +440,7 @@ public class TheMovieDbApiTest { */ @Test public void testGetGenreMovies() throws MovieDbException { - LOGGER.info("getGenreMovies"); + logger.info("getGenreMovies"); List results = tmdb.getGenreMovies(ID_GENRE_ACTION, "", true); assertTrue("No genre movies found", !results.isEmpty()); } @@ -460,7 +450,7 @@ public class TheMovieDbApiTest { */ @Test public void testGetUpcoming() throws Exception { - LOGGER.info("getUpcoming"); + logger.info("getUpcoming"); List results = tmdb.getUpcoming(""); assertTrue("No upcoming movies found", !results.isEmpty()); } @@ -470,7 +460,7 @@ public class TheMovieDbApiTest { */ @Test public void testGetCollectionImages() throws Exception { - LOGGER.info("getCollectionImages"); + logger.info("getCollectionImages"); String language = ""; List result = tmdb.getCollectionImages(ID_MOVIE_STAR_WARS_COLLECTION, language); assertFalse("No artwork found", result.isEmpty()); @@ -481,11 +471,11 @@ public class TheMovieDbApiTest { */ // @Test public void testGetAuthorisationToken() throws Exception { - LOGGER.info("getAuthorisationToken"); + logger.info("getAuthorisationToken"); TokenAuthorisation result = tmdb.getAuthorisationToken(); assertFalse("Token is null", result == null); assertTrue("Token is not valid", result.getSuccess()); - LOGGER.info(result.toString()); + logger.info(result.toString()); } /** @@ -493,15 +483,15 @@ public class TheMovieDbApiTest { */ // @Test public void testGetSessionToken() throws Exception { - LOGGER.info("getSessionToken"); + logger.info("getSessionToken"); TokenAuthorisation token = tmdb.getAuthorisationToken(); assertFalse("Token is null", token == null); assertTrue("Token is not valid", token.getSuccess()); - LOGGER.info(token.toString()); + logger.info(token.toString()); TokenSession result = tmdb.getSessionToken(token); assertFalse("Session token is null", result == null); assertTrue("Session token is not valid", result.getSuccess()); - LOGGER.info(result.toString()); + logger.info(result.toString()); } } From d78b106023c8b91e5dcdbf5db18e574fafe7ef19 Mon Sep 17 00:00:00 2001 From: Stuart Boston Date: Fri, 14 Dec 2012 08:54:45 +0000 Subject: [PATCH 156/207] Updated Configuration with SecureBaseUrl --- .../themoviedbapi/model/TmdbConfiguration.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/omertron/themoviedbapi/model/TmdbConfiguration.java b/src/main/java/com/omertron/themoviedbapi/model/TmdbConfiguration.java index 3a9b6c6fc..e3a3fc6d2 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/TmdbConfiguration.java +++ b/src/main/java/com/omertron/themoviedbapi/model/TmdbConfiguration.java @@ -32,6 +32,8 @@ public class TmdbConfiguration implements Serializable { */ @JsonProperty("base_url") private String baseUrl; + @JsonProperty("secure_base_url") + private String secureBaseUrl; @JsonProperty("poster_sizes") private List posterSizes; @JsonProperty("backdrop_sizes") @@ -61,8 +63,12 @@ public class TmdbConfiguration implements Serializable { public List getLogoSizes() { return logoSizes; } - // + public String getSecureBaseUrl() { + return secureBaseUrl; + } + + // // //GEN-BEGIN:setterMethods public void setBackdropSizes(List backdropSizes) { this.backdropSizes = backdropSizes; @@ -83,6 +89,10 @@ public class TmdbConfiguration implements Serializable { public void setLogoSizes(List logoSizes) { this.logoSizes = logoSizes; } + + public void setSecureBaseUrl(String secureBaseUrl) { + this.secureBaseUrl = secureBaseUrl; + } // /** From bf0e61af039eaa20cd1e08babe311ecfe2974a33 Mon Sep 17 00:00:00 2001 From: Stuart Boston Date: Fri, 14 Dec 2012 09:12:42 +0000 Subject: [PATCH 157/207] Updated Configuration with ChangeKeys --- .../themoviedbapi/wrapper/WrapperConfig.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperConfig.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperConfig.java index b04823d8b..dd2126095 100644 --- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperConfig.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperConfig.java @@ -12,6 +12,8 @@ package com.omertron.themoviedbapi.wrapper; import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonProperty; import com.omertron.themoviedbapi.model.TmdbConfiguration; +import java.util.Collections; +import java.util.List; import org.apache.log4j.Logger; /** @@ -29,6 +31,8 @@ public class WrapperConfig { */ @JsonProperty("images") private TmdbConfiguration tmdbConfiguration; + @JsonProperty("change_keys") + private List changeKeys = Collections.EMPTY_LIST; public TmdbConfiguration getTmdbConfiguration() { return tmdbConfiguration; @@ -38,8 +42,17 @@ public class WrapperConfig { this.tmdbConfiguration = tmdbConfiguration; } + public List getChangeKeys() { + return changeKeys; + } + + public void setChangeKeys(List changeKeys) { + this.changeKeys = changeKeys; + } + /** * Handle unknown properties and print a message + * * @param key * @param value */ @@ -50,5 +63,4 @@ public class WrapperConfig { sb.append("' value: '").append(value).append("'"); logger.trace(sb.toString()); } - } From 3972984f268fb323c777fb40d05f6523a55e94d2 Mon Sep 17 00:00:00 2001 From: Omertron <> Date: Fri, 14 Dec 2012 22:15:37 +0000 Subject: [PATCH 158/207] Update licence to GPL --- LICENCE.txt | 660 +++++++++++++++++- .../themoviedbapi/MovieDbException.java | 18 +- .../omertron/themoviedbapi/TheMovieDbApi.java | 18 +- .../themoviedbapi/model/AlternativeTitle.java | 18 +- .../omertron/themoviedbapi/model/Artwork.java | 18 +- .../themoviedbapi/model/ArtworkType.java | 18 +- .../themoviedbapi/model/Collection.java | 18 +- .../themoviedbapi/model/CollectionInfo.java | 18 +- .../omertron/themoviedbapi/model/Company.java | 18 +- .../omertron/themoviedbapi/model/Genre.java | 18 +- .../omertron/themoviedbapi/model/Keyword.java | 18 +- .../themoviedbapi/model/Language.java | 18 +- .../omertron/themoviedbapi/model/MovieDb.java | 18 +- .../omertron/themoviedbapi/model/Person.java | 18 +- .../themoviedbapi/model/PersonCast.java | 18 +- .../themoviedbapi/model/PersonCredit.java | 18 +- .../themoviedbapi/model/PersonCrew.java | 18 +- .../themoviedbapi/model/PersonType.java | 18 +- .../model/ProductionCompany.java | 18 +- .../model/ProductionCountry.java | 18 +- .../themoviedbapi/model/ReleaseInfo.java | 18 +- .../themoviedbapi/model/StatusCode.java | 18 +- .../model/TmdbConfiguration.java | 18 +- .../model/TokenAuthorisation.java | 18 +- .../themoviedbapi/model/TokenSession.java | 18 +- .../omertron/themoviedbapi/model/Trailer.java | 18 +- .../themoviedbapi/model/Translation.java | 18 +- .../omertron/themoviedbapi/tools/ApiUrl.java | 18 +- .../themoviedbapi/tools/FilteringLayout.java | 18 +- .../themoviedbapi/tools/WebBrowser.java | 18 +- .../wrapper/WrapperAlternativeTitles.java | 18 +- .../themoviedbapi/wrapper/WrapperCompany.java | 18 +- .../wrapper/WrapperCompanyMovies.java | 18 +- .../themoviedbapi/wrapper/WrapperConfig.java | 18 +- .../themoviedbapi/wrapper/WrapperGenres.java | 18 +- .../themoviedbapi/wrapper/WrapperImages.java | 18 +- .../themoviedbapi/wrapper/WrapperMovie.java | 18 +- .../wrapper/WrapperMovieCasts.java | 18 +- .../wrapper/WrapperMovieKeywords.java | 18 +- .../themoviedbapi/wrapper/WrapperPerson.java | 18 +- .../wrapper/WrapperPersonCredits.java | 18 +- .../wrapper/WrapperReleaseInfo.java | 18 +- .../wrapper/WrapperTrailers.java | 18 +- .../wrapper/WrapperTranslations.java | 18 +- .../themoviedbapi/TheMovieDbApiTest.java | 18 +- 45 files changed, 1257 insertions(+), 195 deletions(-) diff --git a/LICENCE.txt b/LICENCE.txt index 503b3abfd..5ec82a48a 100644 --- a/LICENCE.txt +++ b/LICENCE.txt @@ -1,26 +1,648 @@ -This work is licensed under a Creative Commons License. + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 -You are free to: - Share — to copy, distribute and transmit the work - Remix — to adapt the work + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. -Under the following conditions: - Attribution. - You must attribute the work in the manner specified by the author or - licensor (but not in any way that suggests that they endorse you or - your use of the work). - Noncommercial. - You may not use this work for commercial purposes. + Preamble -For any reuse or distribution, you must make clear to others the license terms -of this work. + The GNU General Public License is a free, copyleft license for +software and other kinds of works. -Any of the above conditions can be waived if you get permission from the -copyright holder. + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. -Nothing in this license impairs or restricts the author's moral rights. + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. -http://creativecommons.org/licenses/by-nc/3.0/ + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. -The full license can be found here: -http://creativecommons.org/licenses/by-nc/3.0/legalcode \ No newline at end of file + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . diff --git a/src/main/java/com/omertron/themoviedbapi/MovieDbException.java b/src/main/java/com/omertron/themoviedbapi/MovieDbException.java index a0c8fb0d9..90bba1a66 100644 --- a/src/main/java/com/omertron/themoviedbapi/MovieDbException.java +++ b/src/main/java/com/omertron/themoviedbapi/MovieDbException.java @@ -1,11 +1,21 @@ /* * Copyright (c) 2004-2012 Stuart Boston * - * This software is licensed under a Creative Commons License - * See the LICENCE.txt file included in this package + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . * - * For any reuse or distribution, you must make clear to others the - * license terms of this work. */ package com.omertron.themoviedbapi; diff --git a/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java b/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java index 9a4888b22..b49a3dd54 100644 --- a/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java +++ b/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java @@ -1,11 +1,21 @@ /* * Copyright (c) 2004-2012 Stuart Boston * - * This software is licensed under a Creative Commons License - * See the LICENCE.txt file included in this package + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . * - * For any reuse or distribution, you must make clear to others the - * license terms of this work. */ package com.omertron.themoviedbapi; diff --git a/src/main/java/com/omertron/themoviedbapi/model/AlternativeTitle.java b/src/main/java/com/omertron/themoviedbapi/model/AlternativeTitle.java index 9f923e4a5..9dd3f4366 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/AlternativeTitle.java +++ b/src/main/java/com/omertron/themoviedbapi/model/AlternativeTitle.java @@ -1,11 +1,21 @@ /* * Copyright (c) 2004-2012 Stuart Boston * - * This software is licensed under a Creative Commons License - * See the LICENCE.txt file included in this package + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . * - * For any reuse or distribution, you must make clear to others the - * license terms of this work. */ package com.omertron.themoviedbapi.model; diff --git a/src/main/java/com/omertron/themoviedbapi/model/Artwork.java b/src/main/java/com/omertron/themoviedbapi/model/Artwork.java index 97f38bc9f..ceb82e93c 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/Artwork.java +++ b/src/main/java/com/omertron/themoviedbapi/model/Artwork.java @@ -1,11 +1,21 @@ /* * Copyright (c) 2004-2012 Stuart Boston * - * This software is licensed under a Creative Commons License - * See the LICENCE.txt file included in this package + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . * - * For any reuse or distribution, you must make clear to others the - * license terms of this work. */ package com.omertron.themoviedbapi.model; diff --git a/src/main/java/com/omertron/themoviedbapi/model/ArtworkType.java b/src/main/java/com/omertron/themoviedbapi/model/ArtworkType.java index cdf404ab7..963caae66 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/ArtworkType.java +++ b/src/main/java/com/omertron/themoviedbapi/model/ArtworkType.java @@ -1,11 +1,21 @@ /* * Copyright (c) 2004-2012 Stuart Boston * - * This software is licensed under a Creative Commons License - * See the LICENCE.txt file included in this package + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . * - * For any reuse or distribution, you must make clear to others the - * license terms of this work. */ package com.omertron.themoviedbapi.model; diff --git a/src/main/java/com/omertron/themoviedbapi/model/Collection.java b/src/main/java/com/omertron/themoviedbapi/model/Collection.java index 8128aff58..10b47b668 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/Collection.java +++ b/src/main/java/com/omertron/themoviedbapi/model/Collection.java @@ -1,11 +1,21 @@ /* * Copyright (c) 2004-2012 Stuart Boston * - * This software is licensed under a Creative Commons License - * See the LICENCE.txt file included in this package + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . * - * For any reuse or distribution, you must make clear to others the - * license terms of this work. */ package com.omertron.themoviedbapi.model; diff --git a/src/main/java/com/omertron/themoviedbapi/model/CollectionInfo.java b/src/main/java/com/omertron/themoviedbapi/model/CollectionInfo.java index cc35886a7..5b46377b9 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/CollectionInfo.java +++ b/src/main/java/com/omertron/themoviedbapi/model/CollectionInfo.java @@ -1,11 +1,21 @@ /* * Copyright (c) 2004-2012 Stuart Boston * - * This software is licensed under a Creative Commons License - * See the LICENCE.txt file included in this package + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . * - * For any reuse or distribution, you must make clear to others the - * license terms of this work. */ package com.omertron.themoviedbapi.model; diff --git a/src/main/java/com/omertron/themoviedbapi/model/Company.java b/src/main/java/com/omertron/themoviedbapi/model/Company.java index f2c5f5da6..90377892d 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/Company.java +++ b/src/main/java/com/omertron/themoviedbapi/model/Company.java @@ -1,11 +1,21 @@ /* * Copyright (c) 2004-2012 Stuart Boston * - * This software is licensed under a Creative Commons License - * See the LICENCE.txt file included in this package + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . * - * For any reuse or distribution, you must make clear to others the - * license terms of this work. */ package com.omertron.themoviedbapi.model; diff --git a/src/main/java/com/omertron/themoviedbapi/model/Genre.java b/src/main/java/com/omertron/themoviedbapi/model/Genre.java index 72b3fbc13..d2d051b3b 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/Genre.java +++ b/src/main/java/com/omertron/themoviedbapi/model/Genre.java @@ -1,11 +1,21 @@ /* * Copyright (c) 2004-2012 Stuart Boston * - * This software is licensed under a Creative Commons License - * See the LICENCE.txt file included in this package + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . * - * For any reuse or distribution, you must make clear to others the - * license terms of this work. */ package com.omertron.themoviedbapi.model; diff --git a/src/main/java/com/omertron/themoviedbapi/model/Keyword.java b/src/main/java/com/omertron/themoviedbapi/model/Keyword.java index 3fdd662bf..9a6f83bb0 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/Keyword.java +++ b/src/main/java/com/omertron/themoviedbapi/model/Keyword.java @@ -1,11 +1,21 @@ /* * Copyright (c) 2004-2012 Stuart Boston * - * This software is licensed under a Creative Commons License - * See the LICENCE.txt file included in this package + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . * - * For any reuse or distribution, you must make clear to others the - * license terms of this work. */ package com.omertron.themoviedbapi.model; diff --git a/src/main/java/com/omertron/themoviedbapi/model/Language.java b/src/main/java/com/omertron/themoviedbapi/model/Language.java index 5018e16fb..38468370c 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/Language.java +++ b/src/main/java/com/omertron/themoviedbapi/model/Language.java @@ -1,11 +1,21 @@ /* * Copyright (c) 2004-2012 Stuart Boston * - * This software is licensed under a Creative Commons License - * See the LICENCE.txt file included in this package + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . * - * For any reuse or distribution, you must make clear to others the - * license terms of this work. */ package com.omertron.themoviedbapi.model; diff --git a/src/main/java/com/omertron/themoviedbapi/model/MovieDb.java b/src/main/java/com/omertron/themoviedbapi/model/MovieDb.java index ee180a386..a45ec8ff6 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/MovieDb.java +++ b/src/main/java/com/omertron/themoviedbapi/model/MovieDb.java @@ -1,11 +1,21 @@ /* * Copyright (c) 2004-2012 Stuart Boston * - * This software is licensed under a Creative Commons License - * See the LICENCE.txt file included in this package + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . * - * For any reuse or distribution, you must make clear to others the - * license terms of this work. */ package com.omertron.themoviedbapi.model; diff --git a/src/main/java/com/omertron/themoviedbapi/model/Person.java b/src/main/java/com/omertron/themoviedbapi/model/Person.java index f41a3cd37..f333c6e8e 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/Person.java +++ b/src/main/java/com/omertron/themoviedbapi/model/Person.java @@ -1,11 +1,21 @@ /* * Copyright (c) 2004-2012 Stuart Boston * - * This software is licensed under a Creative Commons License - * See the LICENCE.txt file included in this package + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . * - * For any reuse or distribution, you must make clear to others the - * license terms of this work. */ package com.omertron.themoviedbapi.model; diff --git a/src/main/java/com/omertron/themoviedbapi/model/PersonCast.java b/src/main/java/com/omertron/themoviedbapi/model/PersonCast.java index 3cec57180..1f114bbba 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/PersonCast.java +++ b/src/main/java/com/omertron/themoviedbapi/model/PersonCast.java @@ -1,11 +1,21 @@ /* * Copyright (c) 2004-2012 Stuart Boston * - * This software is licensed under a Creative Commons License - * See the LICENCE.txt file included in this package + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . * - * For any reuse or distribution, you must make clear to others the - * license terms of this work. */ package com.omertron.themoviedbapi.model; diff --git a/src/main/java/com/omertron/themoviedbapi/model/PersonCredit.java b/src/main/java/com/omertron/themoviedbapi/model/PersonCredit.java index ecdd2aa07..93cdb8f9c 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/PersonCredit.java +++ b/src/main/java/com/omertron/themoviedbapi/model/PersonCredit.java @@ -1,11 +1,21 @@ /* * Copyright (c) 2004-2012 Stuart Boston * - * This software is licensed under a Creative Commons License - * See the LICENCE.txt file included in this package + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . * - * For any reuse or distribution, you must make clear to others the - * license terms of this work. */ package com.omertron.themoviedbapi.model; diff --git a/src/main/java/com/omertron/themoviedbapi/model/PersonCrew.java b/src/main/java/com/omertron/themoviedbapi/model/PersonCrew.java index 7263dfa2c..a8a2ced7c 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/PersonCrew.java +++ b/src/main/java/com/omertron/themoviedbapi/model/PersonCrew.java @@ -1,11 +1,21 @@ /* * Copyright (c) 2004-2012 Stuart Boston * - * This software is licensed under a Creative Commons License - * See the LICENCE.txt file included in this package + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . * - * For any reuse or distribution, you must make clear to others the - * license terms of this work. */ package com.omertron.themoviedbapi.model; diff --git a/src/main/java/com/omertron/themoviedbapi/model/PersonType.java b/src/main/java/com/omertron/themoviedbapi/model/PersonType.java index 2847fd72b..8e438b579 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/PersonType.java +++ b/src/main/java/com/omertron/themoviedbapi/model/PersonType.java @@ -1,11 +1,21 @@ /* * Copyright (c) 2004-2012 Stuart Boston * - * This software is licensed under a Creative Commons License - * See the LICENCE.txt file included in this package + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . * - * For any reuse or distribution, you must make clear to others the - * license terms of this work. */ package com.omertron.themoviedbapi.model; diff --git a/src/main/java/com/omertron/themoviedbapi/model/ProductionCompany.java b/src/main/java/com/omertron/themoviedbapi/model/ProductionCompany.java index 9df40c878..508bc8460 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/ProductionCompany.java +++ b/src/main/java/com/omertron/themoviedbapi/model/ProductionCompany.java @@ -1,11 +1,21 @@ /* * Copyright (c) 2004-2012 Stuart Boston * - * This software is licensed under a Creative Commons License - * See the LICENCE.txt file included in this package + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . * - * For any reuse or distribution, you must make clear to others the - * license terms of this work. */ package com.omertron.themoviedbapi.model; diff --git a/src/main/java/com/omertron/themoviedbapi/model/ProductionCountry.java b/src/main/java/com/omertron/themoviedbapi/model/ProductionCountry.java index c1e4b5aae..688bd6973 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/ProductionCountry.java +++ b/src/main/java/com/omertron/themoviedbapi/model/ProductionCountry.java @@ -1,11 +1,21 @@ /* * Copyright (c) 2004-2012 Stuart Boston * - * This software is licensed under a Creative Commons License - * See the LICENCE.txt file included in this package + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . * - * For any reuse or distribution, you must make clear to others the - * license terms of this work. */ package com.omertron.themoviedbapi.model; diff --git a/src/main/java/com/omertron/themoviedbapi/model/ReleaseInfo.java b/src/main/java/com/omertron/themoviedbapi/model/ReleaseInfo.java index 7bf8faae1..20e318539 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/ReleaseInfo.java +++ b/src/main/java/com/omertron/themoviedbapi/model/ReleaseInfo.java @@ -1,11 +1,21 @@ /* * Copyright (c) 2004-2012 Stuart Boston * - * This software is licensed under a Creative Commons License - * See the LICENCE.txt file included in this package + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . * - * For any reuse or distribution, you must make clear to others the - * license terms of this work. */ package com.omertron.themoviedbapi.model; diff --git a/src/main/java/com/omertron/themoviedbapi/model/StatusCode.java b/src/main/java/com/omertron/themoviedbapi/model/StatusCode.java index 5f6e255b0..a5ee08263 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/StatusCode.java +++ b/src/main/java/com/omertron/themoviedbapi/model/StatusCode.java @@ -1,11 +1,21 @@ /* * Copyright (c) 2004-2012 Stuart Boston * - * This software is licensed under a Creative Commons License - * See the LICENCE.txt file included in this package + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . * - * For any reuse or distribution, you must make clear to others the - * license terms of this work. */ package com.omertron.themoviedbapi.model; diff --git a/src/main/java/com/omertron/themoviedbapi/model/TmdbConfiguration.java b/src/main/java/com/omertron/themoviedbapi/model/TmdbConfiguration.java index e3a3fc6d2..2f2e013f9 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/TmdbConfiguration.java +++ b/src/main/java/com/omertron/themoviedbapi/model/TmdbConfiguration.java @@ -1,11 +1,21 @@ /* * Copyright (c) 2004-2012 Stuart Boston * - * This software is licensed under a Creative Commons License - * See the LICENCE.txt file included in this package + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . * - * For any reuse or distribution, you must make clear to others the - * license terms of this work. */ package com.omertron.themoviedbapi.model; diff --git a/src/main/java/com/omertron/themoviedbapi/model/TokenAuthorisation.java b/src/main/java/com/omertron/themoviedbapi/model/TokenAuthorisation.java index 66dedc73c..aeabb0df9 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/TokenAuthorisation.java +++ b/src/main/java/com/omertron/themoviedbapi/model/TokenAuthorisation.java @@ -1,11 +1,21 @@ /* * Copyright (c) 2004-2012 Stuart Boston * - * This software is licensed under a Creative Commons License - * See the LICENCE.txt file included in this package + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . * - * For any reuse or distribution, you must make clear to others the - * license terms of this work. */ package com.omertron.themoviedbapi.model; diff --git a/src/main/java/com/omertron/themoviedbapi/model/TokenSession.java b/src/main/java/com/omertron/themoviedbapi/model/TokenSession.java index 81b10f23a..5dfd38a0d 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/TokenSession.java +++ b/src/main/java/com/omertron/themoviedbapi/model/TokenSession.java @@ -1,11 +1,21 @@ /* * Copyright (c) 2004-2012 Stuart Boston * - * This software is licensed under a Creative Commons License - * See the LICENCE.txt file included in this package + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . * - * For any reuse or distribution, you must make clear to others the - * license terms of this work. */ package com.omertron.themoviedbapi.model; diff --git a/src/main/java/com/omertron/themoviedbapi/model/Trailer.java b/src/main/java/com/omertron/themoviedbapi/model/Trailer.java index fbb6f6c59..98f7ab164 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/Trailer.java +++ b/src/main/java/com/omertron/themoviedbapi/model/Trailer.java @@ -1,11 +1,21 @@ /* * Copyright (c) 2004-2012 Stuart Boston * - * This software is licensed under a Creative Commons License - * See the LICENCE.txt file included in this package + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . * - * For any reuse or distribution, you must make clear to others the - * license terms of this work. */ package com.omertron.themoviedbapi.model; diff --git a/src/main/java/com/omertron/themoviedbapi/model/Translation.java b/src/main/java/com/omertron/themoviedbapi/model/Translation.java index 989faa1f5..1bdf9dfb1 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/Translation.java +++ b/src/main/java/com/omertron/themoviedbapi/model/Translation.java @@ -1,11 +1,21 @@ /* * Copyright (c) 2004-2012 Stuart Boston * - * This software is licensed under a Creative Commons License - * See the LICENCE.txt file included in this package + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . * - * For any reuse or distribution, you must make clear to others the - * license terms of this work. */ package com.omertron.themoviedbapi.model; diff --git a/src/main/java/com/omertron/themoviedbapi/tools/ApiUrl.java b/src/main/java/com/omertron/themoviedbapi/tools/ApiUrl.java index e812efa47..1759028d1 100644 --- a/src/main/java/com/omertron/themoviedbapi/tools/ApiUrl.java +++ b/src/main/java/com/omertron/themoviedbapi/tools/ApiUrl.java @@ -1,11 +1,21 @@ /* * Copyright (c) 2004-2012 Stuart Boston * - * This software is licensed under a Creative Commons License - * See the LICENCE.txt file included in this package + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . * - * For any reuse or distribution, you must make clear to others the - * license terms of this work. */ package com.omertron.themoviedbapi.tools; diff --git a/src/main/java/com/omertron/themoviedbapi/tools/FilteringLayout.java b/src/main/java/com/omertron/themoviedbapi/tools/FilteringLayout.java index 6f71fe814..d8a29817f 100644 --- a/src/main/java/com/omertron/themoviedbapi/tools/FilteringLayout.java +++ b/src/main/java/com/omertron/themoviedbapi/tools/FilteringLayout.java @@ -1,11 +1,21 @@ /* * Copyright (c) 2004-2012 Stuart Boston * - * This software is licensed under a Creative Commons License - * See the LICENCE.txt file included in this package + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . * - * For any reuse or distribution, you must make clear to others the - * license terms of this work. */ package com.omertron.themoviedbapi.tools; diff --git a/src/main/java/com/omertron/themoviedbapi/tools/WebBrowser.java b/src/main/java/com/omertron/themoviedbapi/tools/WebBrowser.java index 88b29301d..10b470bab 100644 --- a/src/main/java/com/omertron/themoviedbapi/tools/WebBrowser.java +++ b/src/main/java/com/omertron/themoviedbapi/tools/WebBrowser.java @@ -1,11 +1,21 @@ /* * Copyright (c) 2004-2012 Stuart Boston * - * This software is licensed under a Creative Commons License - * See the LICENCE.txt file included in this package + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . * - * For any reuse or distribution, you must make clear to others the - * license terms of this work. */ package com.omertron.themoviedbapi.tools; diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperAlternativeTitles.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperAlternativeTitles.java index 7029fd60b..9c60a0a54 100644 --- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperAlternativeTitles.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperAlternativeTitles.java @@ -1,11 +1,21 @@ /* * Copyright (c) 2004-2012 Stuart Boston * - * This software is licensed under a Creative Commons License - * See the LICENCE.txt file included in this package + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . * - * For any reuse or distribution, you must make clear to others the - * license terms of this work. */ package com.omertron.themoviedbapi.wrapper; diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperCompany.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperCompany.java index 73188e1f1..9ea1d6ed2 100644 --- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperCompany.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperCompany.java @@ -1,11 +1,21 @@ /* * Copyright (c) 2004-2012 Stuart Boston * - * This software is licensed under a Creative Commons License - * See the LICENCE.txt file included in this package + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . * - * For any reuse or distribution, you must make clear to others the - * license terms of this work. */ package com.omertron.themoviedbapi.wrapper; diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperCompanyMovies.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperCompanyMovies.java index fd766bf2e..c77306355 100644 --- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperCompanyMovies.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperCompanyMovies.java @@ -1,11 +1,21 @@ /* * Copyright (c) 2004-2012 Stuart Boston * - * This software is licensed under a Creative Commons License - * See the LICENCE.txt file included in this package + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . * - * For any reuse or distribution, you must make clear to others the - * license terms of this work. */ package com.omertron.themoviedbapi.wrapper; diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperConfig.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperConfig.java index dd2126095..0c94af6c7 100644 --- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperConfig.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperConfig.java @@ -1,11 +1,21 @@ /* * Copyright (c) 2004-2012 Stuart Boston * - * This software is licensed under a Creative Commons License - * See the LICENCE.txt file included in this package + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . * - * For any reuse or distribution, you must make clear to others the - * license terms of this work. */ package com.omertron.themoviedbapi.wrapper; diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperGenres.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperGenres.java index 6ed74e32a..0360c660c 100644 --- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperGenres.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperGenres.java @@ -1,11 +1,21 @@ /* * Copyright (c) 2004-2012 Stuart Boston * - * This software is licensed under a Creative Commons License - * See the LICENCE.txt file included in this package + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . * - * For any reuse or distribution, you must make clear to others the - * license terms of this work. */ package com.omertron.themoviedbapi.wrapper; diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperImages.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperImages.java index 590983df3..fba5d669e 100644 --- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperImages.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperImages.java @@ -1,11 +1,21 @@ /* * Copyright (c) 2004-2012 Stuart Boston * - * This software is licensed under a Creative Commons License - * See the LICENCE.txt file included in this package + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . * - * For any reuse or distribution, you must make clear to others the - * license terms of this work. */ package com.omertron.themoviedbapi.wrapper; diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovie.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovie.java index f95293280..5c1f3f503 100644 --- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovie.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovie.java @@ -1,11 +1,21 @@ /* * Copyright (c) 2004-2012 Stuart Boston * - * This software is licensed under a Creative Commons License - * See the LICENCE.txt file included in this package + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . * - * For any reuse or distribution, you must make clear to others the - * license terms of this work. */ package com.omertron.themoviedbapi.wrapper; diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovieCasts.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovieCasts.java index 979435994..b7396c774 100644 --- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovieCasts.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovieCasts.java @@ -1,11 +1,21 @@ /* * Copyright (c) 2004-2012 Stuart Boston * - * This software is licensed under a Creative Commons License - * See the LICENCE.txt file included in this package + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . * - * For any reuse or distribution, you must make clear to others the - * license terms of this work. */ package com.omertron.themoviedbapi.wrapper; diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovieKeywords.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovieKeywords.java index aa635c6c8..660322d64 100644 --- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovieKeywords.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovieKeywords.java @@ -1,11 +1,21 @@ /* * Copyright (c) 2004-2012 Stuart Boston * - * This software is licensed under a Creative Commons License - * See the LICENCE.txt file included in this package + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . * - * For any reuse or distribution, you must make clear to others the - * license terms of this work. */ package com.omertron.themoviedbapi.wrapper; diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperPerson.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperPerson.java index 28e427c18..15617f917 100644 --- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperPerson.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperPerson.java @@ -1,11 +1,21 @@ /* * Copyright (c) 2004-2012 Stuart Boston * - * This software is licensed under a Creative Commons License - * See the LICENCE.txt file included in this package + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . * - * For any reuse or distribution, you must make clear to others the - * license terms of this work. */ package com.omertron.themoviedbapi.wrapper; diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperPersonCredits.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperPersonCredits.java index 08e25d147..4b7072233 100644 --- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperPersonCredits.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperPersonCredits.java @@ -1,11 +1,21 @@ /* * Copyright (c) 2004-2012 Stuart Boston * - * This software is licensed under a Creative Commons License - * See the LICENCE.txt file included in this package + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . * - * For any reuse or distribution, you must make clear to others the - * license terms of this work. */ package com.omertron.themoviedbapi.wrapper; diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperReleaseInfo.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperReleaseInfo.java index 3cf6497b1..a353af470 100644 --- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperReleaseInfo.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperReleaseInfo.java @@ -1,11 +1,21 @@ /* * Copyright (c) 2004-2012 Stuart Boston * - * This software is licensed under a Creative Commons License - * See the LICENCE.txt file included in this package + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . * - * For any reuse or distribution, you must make clear to others the - * license terms of this work. */ package com.omertron.themoviedbapi.wrapper; diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperTrailers.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperTrailers.java index d4349aee7..a37aa0926 100644 --- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperTrailers.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperTrailers.java @@ -1,11 +1,21 @@ /* * Copyright (c) 2004-2012 Stuart Boston * - * This software is licensed under a Creative Commons License - * See the LICENCE.txt file included in this package + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . * - * For any reuse or distribution, you must make clear to others the - * license terms of this work. */ package com.omertron.themoviedbapi.wrapper; diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperTranslations.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperTranslations.java index 63e620dcc..e7c70d2f9 100644 --- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperTranslations.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperTranslations.java @@ -1,11 +1,21 @@ /* * Copyright (c) 2004-2012 Stuart Boston * - * This software is licensed under a Creative Commons License - * See the LICENCE.txt file included in this package + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . * - * For any reuse or distribution, you must make clear to others the - * license terms of this work. */ package com.omertron.themoviedbapi.wrapper; diff --git a/src/test/java/com/omertron/themoviedbapi/TheMovieDbApiTest.java b/src/test/java/com/omertron/themoviedbapi/TheMovieDbApiTest.java index 28e084b24..bc00ac44f 100644 --- a/src/test/java/com/omertron/themoviedbapi/TheMovieDbApiTest.java +++ b/src/test/java/com/omertron/themoviedbapi/TheMovieDbApiTest.java @@ -1,11 +1,21 @@ /* * Copyright (c) 2004-2012 Stuart Boston * - * This software is licensed under a Creative Commons License - * See the LICENCE.txt file included in this package + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . * - * For any reuse or distribution, you must make clear to others the - * license terms of this work. */ package com.omertron.themoviedbapi; From 35ad6df906dcb58ae616eeba1c672b0ab6ca74cd Mon Sep 17 00:00:00 2001 From: Omertron Date: Mon, 17 Dec 2012 12:28:21 +0100 Subject: [PATCH 159/207] Updated POM versions --- pom.xml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pom.xml b/pom.xml index 47711d840..ddd073c21 100644 --- a/pom.xml +++ b/pom.xml @@ -46,7 +46,7 @@ junit junit - 4.10 + 4.11 test @@ -59,19 +59,19 @@ com.fasterxml.jackson.core jackson-core - 2.1.0 + 2.1.2 com.fasterxml.jackson.core jackson-annotations - 2.1.0 + 2.1.2 com.fasterxml.jackson.core jackson-databind - 2.1.0 + 2.1.2 From 4dc8ca609db466406992a73a8fe9bc5493eacd6f Mon Sep 17 00:00:00 2001 From: Omertron Date: Mon, 17 Dec 2012 13:26:49 +0100 Subject: [PATCH 160/207] [maven-release-plugin] prepare release themoviedbapi-3.3 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index ddd073c21..86df0bb0b 100644 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,7 @@ com.omertron themoviedbapi - 3.3-SNAPSHOT + 3.3 API-The MovieDB jar API for the TheMovieDb.org website From 6a82fa589684a8d62de83c24d04d1c07104cb485 Mon Sep 17 00:00:00 2001 From: Omertron Date: Mon, 17 Dec 2012 13:26:59 +0100 Subject: [PATCH 161/207] [maven-release-plugin] prepare for next development iteration --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 86df0bb0b..d9e80e5c9 100644 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,7 @@ com.omertron themoviedbapi - 3.3 + 3.4-SNAPSHOT API-The MovieDB jar API for the TheMovieDb.org website From 83fadff5f146fdc553f972280699cb3da6ec3faf Mon Sep 17 00:00:00 2001 From: Omertron Date: Mon, 17 Dec 2012 13:50:35 +0100 Subject: [PATCH 162/207] [maven-release-plugin] prepare release themoviedbapi-3.3 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index d9e80e5c9..86df0bb0b 100644 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,7 @@ com.omertron themoviedbapi - 3.4-SNAPSHOT + 3.3 API-The MovieDB jar API for the TheMovieDb.org website From 1605a71528122259ea5d2885b3d652395638c7b6 Mon Sep 17 00:00:00 2001 From: Omertron Date: Mon, 17 Dec 2012 13:51:03 +0100 Subject: [PATCH 163/207] [maven-release-plugin] prepare for next development iteration --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 86df0bb0b..d9e80e5c9 100644 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,7 @@ com.omertron themoviedbapi - 3.3 + 3.4-SNAPSHOT API-The MovieDB jar API for the TheMovieDb.org website From e7ec580ea22575e21f838378e9b9fe8c14662dc6 Mon Sep 17 00:00:00 2001 From: Omertron <> Date: Mon, 17 Dec 2012 22:03:12 +0000 Subject: [PATCH 164/207] Add Levenshtein Difference for movie compare --- .../omertron/themoviedbapi/TheMovieDbApi.java | 39 +++++++++++++------ 1 file changed, 28 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java b/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java index b49a3dd54..3a89e695b 100644 --- a/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java +++ b/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java @@ -164,43 +164,60 @@ public class TheMovieDbApi { WebBrowser.setWebTimeoutRead(read); } + public static boolean compareMovies(MovieDb moviedb, String title, String year) { + return compareMovies(moviedb, title, year, 0); + } + /** * Compare the MovieDB object with a title & year * * @param moviedb The moviedb object to compare too * @param title The title of the movie to compare * @param year The year of the movie to compare + * @param maxDistance The Levenshtein Distance between the two titles. 0 = exact match * @return True if there is a match, False otherwise. */ - public static boolean compareMovies(MovieDb moviedb, String title, String year) { + public static boolean compareMovies(MovieDb moviedb, String title, String year, int maxDistance) { if ((moviedb == null) || (StringUtils.isBlank(title))) { - return false; + return Boolean.FALSE; } if (isValidYear(year) && isValidYear(moviedb.getReleaseDate())) { // Compare with year String movieYear = moviedb.getReleaseDate().substring(0, 4); if (movieYear.equals(year)) { - if (moviedb.getOriginalTitle().equalsIgnoreCase(title)) { - return true; + if (compareDistance(moviedb.getOriginalTitle(), title, maxDistance)) { + return Boolean.TRUE; } - if (moviedb.getTitle().equalsIgnoreCase(title)) { - return true; + if (compareDistance(moviedb.getTitle(), title, maxDistance)) { + return Boolean.TRUE; } } } // Compare without year - if (moviedb.getOriginalTitle().equalsIgnoreCase(title)) { - return true; + if (compareDistance(moviedb.getOriginalTitle(), title, maxDistance)) { + return Boolean.TRUE; } - if (moviedb.getTitle().equalsIgnoreCase(title)) { - return true; + if (compareDistance(moviedb.getTitle(), title, maxDistance)) { + return Boolean.TRUE; } - return false; + return Boolean.FALSE; + } + + /** + * Compare the Levenshtein Distance between the two strings + * + * @param title1 + * @param title2 + * @param distance + * @return + */ + private static boolean compareDistance(String title1, String title2, int distance) { + return (StringUtils.getLevenshteinDistance(title1, title2) <= distance); } /** From 902db42094585b425592fd5c593af74dc0e938ed Mon Sep 17 00:00:00 2001 From: Stuart Boston Date: Tue, 18 Dec 2012 15:29:05 +0000 Subject: [PATCH 165/207] Added Get Guest Session method --- .../omertron/themoviedbapi/TheMovieDbApi.java | 119 +++++++++++++----- .../themoviedbapi/model/TokenSession.java | 25 +++- .../themoviedbapi/TheMovieDbApiTest.java | 16 ++- 3 files changed, 126 insertions(+), 34 deletions(-) diff --git a/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java b/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java index 3a89e695b..9213f5573 100644 --- a/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java +++ b/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java @@ -69,7 +69,8 @@ import org.apache.log4j.Logger; /** * The MovieDb API * - * This is for version 3 of the API as specified here: http://help.themoviedb.org/kb/api/about-3 + * This is for version 3 of the API as specified here: + * http://help.themoviedb.org/kb/api/about-3 * * @author stuart.boston */ @@ -174,7 +175,8 @@ public class TheMovieDbApi { * @param moviedb The moviedb object to compare too * @param title The title of the movie to compare * @param year The year of the movie to compare - * @param maxDistance The Levenshtein Distance between the two titles. 0 = exact match + * @param maxDistance The Levenshtein Distance between the two titles. 0 = + * exact match * @return True if there is a match, False otherwise. */ public static boolean compareMovies(MovieDb moviedb, String title, String year, int maxDistance) { @@ -268,13 +270,16 @@ public class TheMovieDbApi { // // /** - * This method is used to generate a valid request token for user based authentication. + * This method is used to generate a valid request token for user based + * authentication. * * A request token is required in order to request a session id. * - * You can generate any number of request tokens but they will expire after 60 minutes. + * You can generate any number of request tokens but they will expire after + * 60 minutes. * - * As soon as a valid session id has been created the token will be destroyed. + * As soon as a valid session id has been created the token will be + * destroyed. * * @return * @throws MovieDbException @@ -294,7 +299,8 @@ public class TheMovieDbApi { } /** - * This method is used to generate a session id for user based authentication. + * This method is used to generate a session id for user based + * authentication. * * A session id is required in order to use any of the write methods. * @@ -322,6 +328,39 @@ public class TheMovieDbApi { } } + /** + * This method is used to generate a guest session id. + * + * A guest session can be used to rate movies without having a registered + * TMDb user account. + * + * You should only generate a single guest session per user (or device) as + * you will be able to attach the ratings to a TMDb user account in the + * future. + * + * There are also IP limits in place so you should always make sure it's the + * end user doing the guest session actions. + * + * If a guest session is not used for the first time within 24 hours, it + * will be automatically discarded. + * + * @return + * @throws MovieDbException + */ + public TokenSession getGuestSessionToken() throws MovieDbException { + ApiUrl apiUrl = new ApiUrl(this, BASE_AUTH, "guest_session/new"); + + URL url = apiUrl.buildUrl(); + String webpage = WebBrowser.request(url); + + try { + return mapper.readValue(webpage, TokenSession.class); + } catch (IOException ex) { + logger.warn("Failed to get Session Token: " + ex.getMessage()); + throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); + } + } + // // // @@ -387,7 +426,8 @@ public class TheMovieDbApi { } /** - * This method is used to retrieve all of the alternative titles we have for a particular movie. + * This method is used to retrieve all of the alternative titles we have for + * a particular movie. * * @param movieId * @param country @@ -455,7 +495,8 @@ public class TheMovieDbApi { } /** - * This method should be used when you’re wanting to retrieve all of the images for a particular movie. + * This method should be used when you’re wanting to retrieve all of the + * images for a particular movie. * * @param movieId * @param language @@ -496,7 +537,8 @@ public class TheMovieDbApi { } /** - * This method is used to retrieve all of the keywords that have been added to a particular movie. + * This method is used to retrieve all of the keywords that have been added + * to a particular movie. * * Currently, only English keywords exist. * @@ -521,7 +563,8 @@ public class TheMovieDbApi { } /** - * This method is used to retrieve all of the release and certification data we have for a specific movie. + * This method is used to retrieve all of the release and certification data + * we have for a specific movie. * * @param movieId * @param language @@ -546,7 +589,8 @@ public class TheMovieDbApi { } /** - * This method is used to retrieve all of the trailers for a particular movie. + * This method is used to retrieve all of the trailers for a particular + * movie. * * Supported sites are YouTube and QuickTime. * @@ -589,7 +633,8 @@ public class TheMovieDbApi { } /** - * This method is used to retrieve a list of the available translations for a specific movie. + * This method is used to retrieve a list of the available translations for + * a specific movie. * * @param movieId * @return @@ -612,9 +657,11 @@ public class TheMovieDbApi { } /** - * The similar movies method will let you retrieve the similar movies for a particular movie. + * The similar movies method will let you retrieve the similar movies for a + * particular movie. * - * This data is created dynamically but with the help of users votes on TMDb. + * This data is created dynamically but with the help of users votes on + * TMDb. * * The data is much better with movies that have more keywords * @@ -703,7 +750,8 @@ public class TheMovieDbApi { /** * This method is used to retrieve the movies currently in theatres. * - * This is a curated list that will normally contain 100 movies. The default response will return 20 movies. + * This is a curated list that will normally contain 100 movies. The default + * response will return 20 movies. * * TODO: Implement more than 20 movies * @@ -771,7 +819,8 @@ public class TheMovieDbApi { } /** - * This method is used to retrieve the top rated movies that have over 10 votes on TMDb. + * This method is used to retrieve the top rated movies that have over 10 + * votes on TMDb. * * The default response will return 20 movies. * @@ -828,9 +877,11 @@ public class TheMovieDbApi { // // /** - * This method is used to retrieve all of the basic information about a movie collection. + * This method is used to retrieve all of the basic information about a + * movie collection. * - * You can get the ID needed for this method by making a getMovieInfo request for the belongs_to_collection. + * You can get the ID needed for this method by making a getMovieInfo + * request for the belongs_to_collection. * * @param collectionId * @param language @@ -928,7 +979,8 @@ public class TheMovieDbApi { } /** - * This method is used to retrieve all of the cast & crew information for the person. + * This method is used to retrieve all of the cast & crew information for + * the person. * * It will return the single highest rated poster for each movie record. * @@ -1002,7 +1054,8 @@ public class TheMovieDbApi { // // /** - * This method is used to retrieve the basic information about a production company on TMDb. + * This method is used to retrieve the basic information about a production + * company on TMDb. * * @param companyId * @return @@ -1027,8 +1080,8 @@ public class TheMovieDbApi { /** * This method is used to retrieve the movies associated with a company. * - * These movies are returned in order of most recently released to oldest. The default response will return 20 - * movies per page. + * These movies are returned in order of most recently released to oldest. + * The default response will return 20 movies per page. * * TODO: Implement more than 20 movies * @@ -1093,9 +1146,11 @@ public class TheMovieDbApi { /** * Get a list of movies per genre. * - * It is important to understand that only movies with more than 10 votes get listed. + * It is important to understand that only movies with more than 10 votes + * get listed. * - * This prevents movies from 1 10/10 rating from being listed first and for the first 5 pages. + * This prevents movies from 1 10/10 rating from being listed first and for + * the first 5 pages. * * @param genreId * @param language @@ -1130,13 +1185,16 @@ public class TheMovieDbApi { // /** - * Search Movies This is a good starting point to start finding movies on TMDb. + * Search Movies This is a good starting point to start finding movies on + * TMDb. * * @param movieName - * @param searchYear Limit the search to the provided year. Zero (0) will get all years + * @param searchYear Limit the search to the provided year. Zero (0) will + * get all years * @param language The language to include. Can be blank/null. * @param includeAdult true or false to include adult titles in the search - * @param page The page of results to return. 0 to get the default (first page) + * @param page The page of results to return. 0 to get the default (first + * page) * @return * @throws MovieDbException */ @@ -1176,8 +1234,8 @@ public class TheMovieDbApi { /** * Search Companies. * - * You can use this method to search for production companies that are part of TMDb. The company IDs will map to - * those returned on movie calls. + * You can use this method to search for production companies that are part + * of TMDb. The company IDs will map to those returned on movie calls. * * http://help.themoviedb.org/kb/api/search-companies * @@ -1208,7 +1266,8 @@ public class TheMovieDbApi { /** * This is a good starting point to start finding people on TMDb. * - * The idea is to be a quick and light method so you can iterate through people quickly. + * The idea is to be a quick and light method so you can iterate through + * people quickly. * * TODO: Fix allResults * diff --git a/src/main/java/com/omertron/themoviedbapi/model/TokenSession.java b/src/main/java/com/omertron/themoviedbapi/model/TokenSession.java index 5dfd38a0d..6863afd03 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/TokenSession.java +++ b/src/main/java/com/omertron/themoviedbapi/model/TokenSession.java @@ -27,6 +27,7 @@ public class TokenSession { /* * Logger */ + private static final Logger logger = Logger.getLogger(TokenSession.class); /* * Properties @@ -39,6 +40,10 @@ public class TokenSession { private String statusCode; @JsonProperty("status_message") private String statusMessage; + @JsonProperty("guest_session_id") + private String guestSessionId; + @JsonProperty("expires_at") + private String expiresAt; // public String getSessionId() { @@ -56,6 +61,14 @@ public class TokenSession { public String getStatusMessage() { return statusMessage; } + + public String getGuestSessionId() { + return guestSessionId; + } + + public String getExpiresAt() { + return expiresAt; + } // // @@ -74,6 +87,15 @@ public class TokenSession { public void setStatusMessage(String statusMessage) { this.statusMessage = statusMessage; } + + public void setGuestSessionId(String guestSessionId) { + this.guestSessionId = guestSessionId; + } + + public void setExpiresAt(String expiresAt) { + this.expiresAt = expiresAt; + } + // /** @@ -92,7 +114,6 @@ public class TokenSession { @Override public String toString() { - return "TokenSession{" + "sessionId=" + sessionId + ", success=" + success + ", statusCode=" + statusCode + ", statusMessage=" + statusMessage + '}'; + return "TokenSession{" + "sessionId=" + sessionId + ", success=" + success + ", statusCode=" + statusCode + ", statusMessage=" + statusMessage + ", guestSessionId=" + guestSessionId + ", expiresAt=" + expiresAt + '}'; } - } diff --git a/src/test/java/com/omertron/themoviedbapi/TheMovieDbApiTest.java b/src/test/java/com/omertron/themoviedbapi/TheMovieDbApiTest.java index bc00ac44f..c16c870a5 100644 --- a/src/test/java/com/omertron/themoviedbapi/TheMovieDbApiTest.java +++ b/src/test/java/com/omertron/themoviedbapi/TheMovieDbApiTest.java @@ -242,6 +242,7 @@ public class TheMovieDbApiTest { /** * Test of createImageUrl method, of class TheMovieDbApi. + * * @throws MovieDbException */ @Test @@ -479,7 +480,7 @@ public class TheMovieDbApiTest { /** * Test of getAuthorisationToken method, of class TheMovieDbApi. */ -// @Test + @Test public void testGetAuthorisationToken() throws Exception { logger.info("getAuthorisationToken"); TokenAuthorisation result = tmdb.getAuthorisationToken(); @@ -491,7 +492,7 @@ public class TheMovieDbApiTest { /** * Test of getSessionToken method, of class TheMovieDbApi. */ -// @Test + @Test public void testGetSessionToken() throws Exception { logger.info("getSessionToken"); TokenAuthorisation token = tmdb.getAuthorisationToken(); @@ -504,4 +505,15 @@ public class TheMovieDbApiTest { assertTrue("Session token is not valid", result.getSuccess()); logger.info(result.toString()); } + + /** + * Test of getGuestSessionToken method, of class TheMovieDbApi. + */ + @Test + public void testGetGuestSessionToken() throws Exception { + logger.info("getGuestSessionToken"); + TokenSession result = tmdb.getGuestSessionToken(); + + assertTrue("Failed to get guest session", result.getSuccess()); + } } From 608c0a9b05ab0fedb826188c23530cd7381c893d Mon Sep 17 00:00:00 2001 From: Stuart Boston Date: Tue, 18 Dec 2012 16:07:10 +0000 Subject: [PATCH 166/207] Added getMovieLists method --- .../omertron/themoviedbapi/TheMovieDbApi.java | 34 +++++ .../themoviedbapi/model/MovieList.java | 137 ++++++++++++++++++ .../wrapper/WrapperMovieList.java | 110 ++++++++++++++ .../themoviedbapi/TheMovieDbApiTest.java | 86 ++++++----- 4 files changed, 329 insertions(+), 38 deletions(-) create mode 100644 src/main/java/com/omertron/themoviedbapi/model/MovieList.java create mode 100644 src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovieList.java diff --git a/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java b/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java index 9213f5573..d8da1c629 100644 --- a/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java +++ b/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java @@ -19,6 +19,8 @@ */ package com.omertron.themoviedbapi; +import com.fasterxml.jackson.core.JsonParseException; +import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.omertron.themoviedbapi.MovieDbException.MovieDbExceptionType; import com.omertron.themoviedbapi.model.AlternativeTitle; @@ -29,6 +31,7 @@ import com.omertron.themoviedbapi.model.Company; import com.omertron.themoviedbapi.model.Genre; import com.omertron.themoviedbapi.model.Keyword; import com.omertron.themoviedbapi.model.MovieDb; +import com.omertron.themoviedbapi.model.MovieList; import com.omertron.themoviedbapi.model.Person; import com.omertron.themoviedbapi.model.PersonCast; import com.omertron.themoviedbapi.model.PersonCredit; @@ -53,6 +56,7 @@ import com.omertron.themoviedbapi.wrapper.WrapperImages; import com.omertron.themoviedbapi.wrapper.WrapperMovie; import com.omertron.themoviedbapi.wrapper.WrapperMovieCasts; import com.omertron.themoviedbapi.wrapper.WrapperMovieKeywords; +import com.omertron.themoviedbapi.wrapper.WrapperMovieList; import com.omertron.themoviedbapi.wrapper.WrapperPerson; import com.omertron.themoviedbapi.wrapper.WrapperPersonCredits; import com.omertron.themoviedbapi.wrapper.WrapperReleaseInfo; @@ -63,6 +67,7 @@ import java.net.MalformedURLException; import java.net.URL; import java.util.ArrayList; import java.util.List; +import java.util.logging.Level; import org.apache.commons.lang3.StringUtils; import org.apache.log4j.Logger; @@ -695,6 +700,35 @@ public class TheMovieDbApi { } } + //lists + public List getMovieLists(int movieId, String language, int page) throws MovieDbException { + ApiUrl apiUrl = new ApiUrl(this, BASE_MOVIE, "/lists"); + apiUrl.addArgument(PARAM_ID, movieId); + + if (StringUtils.isNotBlank(language)) { + apiUrl.addArgument(PARAM_LANGUAGE, language); + } + + if (page > 0) { + apiUrl.addArgument(PARAM_PAGE, page); + } + + URL url = apiUrl.buildUrl(); + String webpage = WebBrowser.request(url); + + try { + WrapperMovieList wrapper = mapper.readValue(webpage, WrapperMovieList.class); + return wrapper.getMovieList(); + } catch (IOException ex) { + logger.warn("Failed to get movie lists: " + ex.getMessage()); + throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); + } + } + + //changes + public void getMovieChanges() throws MovieDbException { + } + /** * This method is used to retrieve the newest movie that was added to TMDb. * diff --git a/src/main/java/com/omertron/themoviedbapi/model/MovieList.java b/src/main/java/com/omertron/themoviedbapi/model/MovieList.java new file mode 100644 index 000000000..29f2fac3b --- /dev/null +++ b/src/main/java/com/omertron/themoviedbapi/model/MovieList.java @@ -0,0 +1,137 @@ +/* + * Copyright (c) 2004-2012 Stuart Boston + * + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . + * + */ +package com.omertron.themoviedbapi.model; + +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import org.apache.log4j.Logger; + +/** + * + * @author Stuart + */ +public class MovieList implements Serializable { + + private static final long serialVersionUID = 1L; + + /* + * Logger + */ + private static final Logger logger = Logger.getLogger(MovieList.class); + /* + * Properties + */ + @JsonProperty("description") + private String description; + @JsonProperty("favorite_count") + private int favoriteCount; + @JsonProperty("id") + private String id; + @JsonProperty("item_count") + private int itemCount; + @JsonProperty("iso_639_1") + private String language; + @JsonProperty("name") + private String name; + @JsonProperty("poster_path") + private String posterPath; + + // + public String getDescription() { + return description; + } + + public int getFavoriteCount() { + return favoriteCount; + } + + public String getId() { + return id; + } + + public int getItemCount() { + return itemCount; + } + + public String getLanguage() { + return language; + } + + public String getName() { + return name; + } + + public String getPosterPath() { + return posterPath; + } + + // + + // + public void setDescription(String description) { + this.description = description; + } + + public void setFavoriteCount(int favoriteCount) { + this.favoriteCount = favoriteCount; + } + + public void setId(String id) { + this.id = id; + } + + public void setItemCount(int itemCount) { + this.itemCount = itemCount; + } + + public void setLanguage(String language) { + this.language = language; + } + + public void setName(String name) { + this.name = name; + } + + public void setPosterPath(String posterPath) { + this.posterPath = posterPath; + } + + // + + /** + * Handle unknown properties and print a message + * + * @param key + * @param value + */ + @JsonAnySetter + public void handleUnknown(String key, Object value) { + StringBuilder sb = new StringBuilder(); + sb.append("Unknown property: '").append(key); + sb.append("' value: '").append(value).append("'"); + logger.trace(sb.toString()); + } + + @Override + public String toString() { + return "MovieList{" + "description=" + description + ", favoriteCount=" + favoriteCount + ", id=" + id + ", itemCount=" + itemCount + ", language=" + language + ", name=" + name + ", posterPath=" + posterPath + '}'; + } +} diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovieList.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovieList.java new file mode 100644 index 000000000..80f025b31 --- /dev/null +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovieList.java @@ -0,0 +1,110 @@ +/* + * Copyright (c) 2004-2012 Stuart Boston + * + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . + * + */ +package com.omertron.themoviedbapi.wrapper; + +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.omertron.themoviedbapi.model.AlternativeTitle; +import com.omertron.themoviedbapi.model.MovieList; +import java.util.List; +import org.apache.log4j.Logger; + +/** + * + * @author Stuart + */ +public class WrapperMovieList { + /* + * Logger + */ + + private static final Logger logger = Logger.getLogger(WrapperMovieList.class); + /* + * Properties + */ + @JsonProperty("id") + private int id; + @JsonProperty("page") + private int page; + @JsonProperty("results") + private List movieList; + @JsonProperty("total_pages") + private int totalPages; + @JsonProperty("total_results") + private int totalResults; + + // + public int getId() { + return id; + } + + public int getPage() { + return page; + } + + public List getMovieList() { + return movieList; + } + + public int getTotalPages() { + return totalPages; + } + + public int getTotalResults() { + return totalResults; + } + // + + // + public void setId(int id) { + this.id = id; + } + + public void setPage(int page) { + this.page = page; + } + + public void setMovieList(List movieList) { + this.movieList = movieList; + } + + public void setTotalPages(int totalPages) { + this.totalPages = totalPages; + } + + public void setTotalResults(int totalResults) { + this.totalResults = totalResults; + } + // + + /** + * Handle unknown properties and print a message + * + * @param key + * @param value + */ + @JsonAnySetter + public void handleUnknown(String key, Object value) { + StringBuilder sb = new StringBuilder(); + sb.append("Unknown property: '").append(key); + sb.append("' value: '").append(value).append("'"); + logger.trace(sb.toString()); + } +} diff --git a/src/test/java/com/omertron/themoviedbapi/TheMovieDbApiTest.java b/src/test/java/com/omertron/themoviedbapi/TheMovieDbApiTest.java index c16c870a5..79f55cd87 100644 --- a/src/test/java/com/omertron/themoviedbapi/TheMovieDbApiTest.java +++ b/src/test/java/com/omertron/themoviedbapi/TheMovieDbApiTest.java @@ -26,6 +26,7 @@ import com.omertron.themoviedbapi.model.Company; import com.omertron.themoviedbapi.model.Genre; import com.omertron.themoviedbapi.model.Keyword; import com.omertron.themoviedbapi.model.MovieDb; +import com.omertron.themoviedbapi.model.MovieList; import com.omertron.themoviedbapi.model.Person; import com.omertron.themoviedbapi.model.PersonCredit; import com.omertron.themoviedbapi.model.ReleaseInfo; @@ -90,7 +91,7 @@ public class TheMovieDbApiTest { /** * Test of getConfiguration method, of class TheMovieDbApi. */ - @Test + //@Test public void testConfiguration() throws IOException { logger.info("Test Configuration"); @@ -106,7 +107,7 @@ public class TheMovieDbApiTest { /** * Test of searchMovie method, of class TheMovieDbApi. */ - @Test + //@Test public void testSearchMovie() throws MovieDbException { logger.info("searchMovie"); @@ -127,7 +128,7 @@ public class TheMovieDbApiTest { /** * Test of getMovieInfo method, of class TheMovieDbApi. */ - @Test + //@Test public void testGetMovieInfo() throws MovieDbException { logger.info("getMovieInfo"); String language = "en"; @@ -138,7 +139,7 @@ public class TheMovieDbApiTest { /** * Test of getMovieAlternativeTitles method, of class TheMovieDbApi. */ - @Test + //@Test public void testGetMovieAlternativeTitles() throws MovieDbException { logger.info("getMovieAlternativeTitles"); String country = ""; @@ -154,7 +155,7 @@ public class TheMovieDbApiTest { /** * Test of getMovieCasts method, of class TheMovieDbApi. */ - @Test + //@Test public void testGetMovieCasts() throws MovieDbException { logger.info("getMovieCasts"); List people = tmdb.getMovieCasts(ID_MOVIE_BLADE_RUNNER); @@ -181,7 +182,7 @@ public class TheMovieDbApiTest { /** * Test of getMovieImages method, of class TheMovieDbApi. */ - @Test + //@Test public void testGetMovieImages() throws MovieDbException { logger.info("getMovieImages"); String language = ""; @@ -192,7 +193,7 @@ public class TheMovieDbApiTest { /** * Test of getMovieKeywords method, of class TheMovieDbApi. */ - @Test + //@Test public void testGetMovieKeywords() throws MovieDbException { logger.info("getMovieKeywords"); List result = tmdb.getMovieKeywords(ID_MOVIE_BLADE_RUNNER); @@ -202,7 +203,7 @@ public class TheMovieDbApiTest { /** * Test of getMovieReleaseInfo method, of class TheMovieDbApi. */ - @Test + //@Test public void testGetMovieReleaseInfo() throws MovieDbException { logger.info("getMovieReleaseInfo"); List result = tmdb.getMovieReleaseInfo(ID_MOVIE_BLADE_RUNNER, ""); @@ -212,7 +213,7 @@ public class TheMovieDbApiTest { /** * Test of getMovieTrailers method, of class TheMovieDbApi. */ - @Test + //@Test public void testGetMovieTrailers() throws MovieDbException { logger.info("getMovieTrailers"); List result = tmdb.getMovieTrailers(ID_MOVIE_BLADE_RUNNER, ""); @@ -222,7 +223,7 @@ public class TheMovieDbApiTest { /** * Test of getMovieTranslations method, of class TheMovieDbApi. */ - @Test + //@Test public void testGetMovieTranslations() throws MovieDbException { logger.info("getMovieTranslations"); List result = tmdb.getMovieTranslations(ID_MOVIE_BLADE_RUNNER); @@ -232,7 +233,7 @@ public class TheMovieDbApiTest { /** * Test of getCollectionInfo method, of class TheMovieDbApi. */ - @Test + //@Test public void testGetCollectionInfo() throws MovieDbException { logger.info("getCollectionInfo"); String language = ""; @@ -245,7 +246,7 @@ public class TheMovieDbApiTest { * * @throws MovieDbException */ - @Test + //@Test public void testCreateImageUrl() throws MovieDbException { logger.info("createImageUrl"); MovieDb movie = tmdb.getMovieInfo(ID_MOVIE_BLADE_RUNNER, ""); @@ -256,7 +257,7 @@ public class TheMovieDbApiTest { /** * Test of getMovieInfoImdb method, of class TheMovieDbApi. */ - @Test + //@Test public void testGetMovieInfoImdb() throws MovieDbException { logger.info("getMovieInfoImdb"); MovieDb result = tmdb.getMovieInfoImdb("tt0076759", "en-US"); @@ -266,7 +267,7 @@ public class TheMovieDbApiTest { /** * Test of getApiKey method, of class TheMovieDbApi. */ - @Test + //@Test public void testGetApiKey() { // Not required } @@ -274,7 +275,7 @@ public class TheMovieDbApiTest { /** * Test of getApiBase method, of class TheMovieDbApi. */ - @Test + //@Test public void testGetApiBase() { // Not required } @@ -282,7 +283,7 @@ public class TheMovieDbApiTest { /** * Test of getConfiguration method, of class TheMovieDbApi. */ - @Test + //@Test public void testGetConfiguration() { // Not required } @@ -290,7 +291,7 @@ public class TheMovieDbApiTest { /** * Test of searchPeople method, of class TheMovieDbApi. */ - @Test + //@Test public void testSearchPeople() throws MovieDbException { logger.info("searchPeople"); String personName = "Bruce Willis"; @@ -302,7 +303,7 @@ public class TheMovieDbApiTest { /** * Test of getPersonInfo method, of class TheMovieDbApi. */ - @Test + //@Test public void testGetPersonInfo() throws MovieDbException { logger.info("getPersonInfo"); Person result = tmdb.getPersonInfo(ID_PERSON_BRUCE_WILLIS); @@ -312,7 +313,7 @@ public class TheMovieDbApiTest { /** * Test of getPersonCredits method, of class TheMovieDbApi. */ - @Test + //@Test public void testGetPersonCredits() throws MovieDbException { logger.info("getPersonCredits"); @@ -323,7 +324,7 @@ public class TheMovieDbApiTest { /** * Test of getPersonImages method, of class TheMovieDbApi. */ - @Test + //@Test public void testGetPersonImages() throws MovieDbException { logger.info("getPersonImages"); @@ -334,7 +335,7 @@ public class TheMovieDbApiTest { /** * Test of getLatestMovie method, of class TheMovieDbApi. */ - @Test + //@Test public void testGetLatestMovie() throws MovieDbException { logger.info("getLatestMovie"); MovieDb result = tmdb.getLatestMovie(); @@ -345,7 +346,7 @@ public class TheMovieDbApiTest { /** * Test of compareMovies method, of class TheMovieDbApi. */ - @Test + //@Test public void testCompareMovies() { // Not required } @@ -353,7 +354,7 @@ public class TheMovieDbApiTest { /** * Test of setProxy method, of class TheMovieDbApi. */ - @Test + //@Test public void testSetProxy() { // Not required } @@ -361,7 +362,7 @@ public class TheMovieDbApiTest { /** * Test of setTimeout method, of class TheMovieDbApi. */ - @Test + //@Test public void testSetTimeout() { // Not required } @@ -369,7 +370,7 @@ public class TheMovieDbApiTest { /** * Test of getNowPlayingMovies method, of class TheMovieDbApi. */ - @Test + //@Test public void testGetNowPlayingMovies() throws MovieDbException { logger.info("getNowPlayingMovies"); List results = tmdb.getNowPlayingMovies("", true); @@ -379,7 +380,7 @@ public class TheMovieDbApiTest { /** * Test of getPopularMovieList method, of class TheMovieDbApi. */ - @Test + //@Test public void testGetPopularMovieList() throws MovieDbException { logger.info("getPopularMovieList"); List results = tmdb.getPopularMovieList("", true); @@ -389,7 +390,7 @@ public class TheMovieDbApiTest { /** * Test of getTopRatedMovies method, of class TheMovieDbApi. */ - @Test + //@Test public void testGetTopRatedMovies() throws MovieDbException { logger.info("getTopRatedMovies"); List results = tmdb.getTopRatedMovies("", true); @@ -399,7 +400,7 @@ public class TheMovieDbApiTest { /** * Test of getCompanyInfo method, of class TheMovieDbApi. */ - @Test + //@Test public void testGetCompanyInfo() throws MovieDbException { logger.info("getCompanyInfo"); Company company = tmdb.getCompanyInfo(ID_COMPANY_LUCASFILM); @@ -409,7 +410,7 @@ public class TheMovieDbApiTest { /** * Test of getCompanyMovies method, of class TheMovieDbApi. */ - @Test + //@Test public void testGetCompanyMovies() throws MovieDbException { logger.info("getCompanyMovies"); List results = tmdb.getCompanyMovies(ID_COMPANY_LUCASFILM, "", true); @@ -419,7 +420,7 @@ public class TheMovieDbApiTest { /** * Test of searchCompanies method, of class TheMovieDbApi. */ - @Test + //@Test public void testSearchCompanies() throws MovieDbException { logger.info("searchCompanies"); List results = tmdb.searchCompanies(COMPANY_NAME, "", true); @@ -429,7 +430,7 @@ public class TheMovieDbApiTest { /** * Test of getSimilarMovies method, of class TheMovieDbApi. */ - @Test + //@Test public void testGetSimilarMovies() throws MovieDbException { logger.info("getSimilarMovies"); List results = tmdb.getSimilarMovies(ID_MOVIE_BLADE_RUNNER, "", true); @@ -439,7 +440,7 @@ public class TheMovieDbApiTest { /** * Test of getGenreList method, of class TheMovieDbApi. */ - @Test + //@Test public void testGetGenreList() throws MovieDbException { logger.info("getGenreList"); List results = tmdb.getGenreList(""); @@ -449,7 +450,7 @@ public class TheMovieDbApiTest { /** * Test of getGenreMovies method, of class TheMovieDbApi. */ - @Test + //@Test public void testGetGenreMovies() throws MovieDbException { logger.info("getGenreMovies"); List results = tmdb.getGenreMovies(ID_GENRE_ACTION, "", true); @@ -459,7 +460,7 @@ public class TheMovieDbApiTest { /** * Test of getUpcoming method, of class TheMovieDbApi. */ - @Test + //@Test public void testGetUpcoming() throws Exception { logger.info("getUpcoming"); List results = tmdb.getUpcoming(""); @@ -469,7 +470,7 @@ public class TheMovieDbApiTest { /** * Test of getCollectionImages method, of class TheMovieDbApi. */ - @Test + //@Test public void testGetCollectionImages() throws Exception { logger.info("getCollectionImages"); String language = ""; @@ -480,7 +481,7 @@ public class TheMovieDbApiTest { /** * Test of getAuthorisationToken method, of class TheMovieDbApi. */ - @Test + //@Test public void testGetAuthorisationToken() throws Exception { logger.info("getAuthorisationToken"); TokenAuthorisation result = tmdb.getAuthorisationToken(); @@ -492,7 +493,7 @@ public class TheMovieDbApiTest { /** * Test of getSessionToken method, of class TheMovieDbApi. */ - @Test + //@Test public void testGetSessionToken() throws Exception { logger.info("getSessionToken"); TokenAuthorisation token = tmdb.getAuthorisationToken(); @@ -509,11 +510,20 @@ public class TheMovieDbApiTest { /** * Test of getGuestSessionToken method, of class TheMovieDbApi. */ - @Test + //@Test public void testGetGuestSessionToken() throws Exception { logger.info("getGuestSessionToken"); TokenSession result = tmdb.getGuestSessionToken(); assertTrue("Failed to get guest session", result.getSuccess()); } + + @Test + public void testGetMovieLists() throws Exception { + logger.info("getMovieLists"); + String language = "en"; + List results = tmdb.getMovieLists(ID_MOVIE_BLADE_RUNNER, language, 0); + assertNotNull("No results found", results); + assertTrue("No results found", results.size() > 0); + } } From 46cd35f908e9d5fb3885811c0c4594fcd7eaf011 Mon Sep 17 00:00:00 2001 From: Stuart Boston Date: Wed, 19 Dec 2012 15:56:45 +0000 Subject: [PATCH 167/207] Added getMovieChanges method --- .../omertron/themoviedbapi/TheMovieDbApi.java | 61 ++++++++- .../omertron/themoviedbapi/model/Artwork.java | 12 ++ .../themoviedbapi/model/ChangeItem.java | 121 +++++++++++++++++ .../themoviedbapi/model/ChangeValue.java | 127 ++++++++++++++++++ .../themoviedbapi/model/MovieChanges.java | 81 +++++++++++ .../themoviedbapi/wrapper/WrapperChanges.java | 69 ++++++++++ .../themoviedbapi/TheMovieDbApiTest.java | 104 ++++++++------ 7 files changed, 528 insertions(+), 47 deletions(-) create mode 100644 src/main/java/com/omertron/themoviedbapi/model/ChangeItem.java create mode 100644 src/main/java/com/omertron/themoviedbapi/model/ChangeValue.java create mode 100644 src/main/java/com/omertron/themoviedbapi/model/MovieChanges.java create mode 100644 src/main/java/com/omertron/themoviedbapi/wrapper/WrapperChanges.java diff --git a/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java b/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java index d8da1c629..9037db925 100644 --- a/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java +++ b/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java @@ -19,8 +19,6 @@ */ package com.omertron.themoviedbapi; -import com.fasterxml.jackson.core.JsonParseException; -import com.fasterxml.jackson.databind.JsonMappingException; import com.fasterxml.jackson.databind.ObjectMapper; import com.omertron.themoviedbapi.MovieDbException.MovieDbExceptionType; import com.omertron.themoviedbapi.model.AlternativeTitle; @@ -30,6 +28,7 @@ import com.omertron.themoviedbapi.model.CollectionInfo; import com.omertron.themoviedbapi.model.Company; import com.omertron.themoviedbapi.model.Genre; import com.omertron.themoviedbapi.model.Keyword; +import com.omertron.themoviedbapi.model.MovieChanges; import com.omertron.themoviedbapi.model.MovieDb; import com.omertron.themoviedbapi.model.MovieList; import com.omertron.themoviedbapi.model.Person; @@ -48,6 +47,7 @@ import static com.omertron.themoviedbapi.tools.ApiUrl.*; import com.omertron.themoviedbapi.tools.FilteringLayout; import com.omertron.themoviedbapi.tools.WebBrowser; import com.omertron.themoviedbapi.wrapper.WrapperAlternativeTitles; +import com.omertron.themoviedbapi.wrapper.WrapperChanges; import com.omertron.themoviedbapi.wrapper.WrapperCompany; import com.omertron.themoviedbapi.wrapper.WrapperCompanyMovies; import com.omertron.themoviedbapi.wrapper.WrapperConfig; @@ -67,7 +67,6 @@ import java.net.MalformedURLException; import java.net.URL; import java.util.ArrayList; import java.util.List; -import java.util.logging.Level; import org.apache.commons.lang3.StringUtils; import org.apache.log4j.Logger; @@ -700,7 +699,15 @@ public class TheMovieDbApi { } } - //lists + /** + * Get the lists that the movie belongs to + * + * @param movieId + * @param language + * @param page + * @return + * @throws MovieDbException + */ public List getMovieLists(int movieId, String language, int page) throws MovieDbException { ApiUrl apiUrl = new ApiUrl(this, BASE_MOVIE, "/lists"); apiUrl.addArgument(PARAM_ID, movieId); @@ -725,8 +732,50 @@ public class TheMovieDbApi { } } - //changes - public void getMovieChanges() throws MovieDbException { + /** + * Get the changes for a specific movie id. + * + * Changes are grouped by key, and ordered by date in descending order. + * + * By default, only the last 24 hours of changes are returned. + * + * The maximum number of days that can be returned in a single request is + * 14. + * + * The language is present on fields that are translatable. + * + * TODO: DOES NOT WORK AT THE MOMENT. This is due to the "value" item + * changing type in the ChangeItem + * + * @param movieId + * @param startDate the start date of the changes, optional + * @param endDate the end date of the changes, optional + * @throws MovieDbException + */ + @Deprecated + public List getMovieChanges(int movieId, String startDate, String endDate) throws MovieDbException { + ApiUrl apiUrl = new ApiUrl(this, BASE_MOVIE, "/changes"); + apiUrl.addArgument(PARAM_ID, movieId); + + if (StringUtils.isNotBlank(startDate)) { + apiUrl.addArgument("start_date", startDate); + } + + if (StringUtils.isNotBlank(endDate)) { + apiUrl.addArgument("end_date", endDate); + } + + URL url = apiUrl.buildUrl(); + String webpage = WebBrowser.request(url); + + try { + WrapperChanges wrapper = mapper.readValue(webpage, WrapperChanges.class); + return wrapper.getChanges(); + } catch (IOException ex) { + logger.warn("Failed to get movie changes: " + ex.getMessage()); + throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); + } + } /** diff --git a/src/main/java/com/omertron/themoviedbapi/model/Artwork.java b/src/main/java/com/omertron/themoviedbapi/model/Artwork.java index ceb82e93c..dd9b30a13 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/Artwork.java +++ b/src/main/java/com/omertron/themoviedbapi/model/Artwork.java @@ -54,6 +54,8 @@ public class Artwork implements Serializable { private float voteAverage; @JsonProperty("vote_count") private int voteCount; + @JsonProperty("flag") + private String flag; private ArtworkType artworkType = ArtworkType.POSTER; // @@ -88,6 +90,11 @@ public class Artwork implements Serializable { public int getVoteCount() { return voteCount; } + + public String getFlag() { + return flag; + } + // // @@ -122,6 +129,11 @@ public class Artwork implements Serializable { public void setVoteCount(int voteCount) { this.voteCount = voteCount; } + + public void setFlag(String flag) { + this.flag = flag; + } + // /** diff --git a/src/main/java/com/omertron/themoviedbapi/model/ChangeItem.java b/src/main/java/com/omertron/themoviedbapi/model/ChangeItem.java new file mode 100644 index 000000000..09cc9fd17 --- /dev/null +++ b/src/main/java/com/omertron/themoviedbapi/model/ChangeItem.java @@ -0,0 +1,121 @@ +/* + * Copyright (c) 2004-2012 Stuart Boston + * + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . + * + */ +package com.omertron.themoviedbapi.model; + +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonProperty; +import org.apache.log4j.Logger; + +public class ChangeItem { + + private static final long serialVersionUID = 1L; + + /* + * Logger + */ + private static final Logger logger = Logger.getLogger(MovieChanges.class); + /* + * Properties + */ + @JsonProperty("id") + private String id; + @JsonProperty("action") + private String action; + @JsonProperty("time") + private String time; + @JsonProperty("value") + private ChangeValue value; + @JsonProperty("original_value") + private ChangeValue originalValue; + @JsonProperty("iso_639_1") + private String language; + + // + public String getId() { + return id; + } + + public String getAction() { + return action; + } + + public String getTime() { + return time; + } + + public ChangeValue getValue() { + return value; + } + + public ChangeValue getOriginalValue() { + return originalValue; + } + + public String getLanguage() { + return language; + } + // + + // + public void setId(String id) { + this.id = id; + } + + public void setAction(String action) { + this.action = action; + } + + public void setTime(String time) { + this.time = time; + } + + public void setValue(ChangeValue value) { + this.value = value; + } + + public void setOriginalValue(ChangeValue originalValue) { + this.originalValue = originalValue; + } + + public void setLanguage(String language) { + this.language = language; + } + + // + + @Override + public String toString() { + return "ChangeItem{" + "id=" + id + ", action=" + action + ", time=" + time + ", value=" + value + '}'; + } + + /** + * Handle unknown properties and print a message + * + * @param key + * @param value + */ + @JsonAnySetter + public void handleUnknown(String key, Object value) { + StringBuilder sb = new StringBuilder(); + sb.append("Unknown property: '").append(key); + sb.append("' value: '").append(value).append("'"); + logger.trace(sb.toString()); + } +} diff --git a/src/main/java/com/omertron/themoviedbapi/model/ChangeValue.java b/src/main/java/com/omertron/themoviedbapi/model/ChangeValue.java new file mode 100644 index 000000000..a1120d773 --- /dev/null +++ b/src/main/java/com/omertron/themoviedbapi/model/ChangeValue.java @@ -0,0 +1,127 @@ +/* + * Copyright (c) 2004-2012 Stuart Boston + * + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . + * + */ +package com.omertron.themoviedbapi.model; + +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonProperty; +import org.apache.log4j.Logger; + +public class ChangeValue { + + private static final long serialVersionUID = 1L; + + /* + * Logger + */ + private static final Logger logger = Logger.getLogger(MovieChanges.class); + /* + * Properties + */ + @JsonProperty("poster") + private Artwork poster; + @JsonProperty("backdrop") + private Artwork backdrop; + @JsonProperty("title") + private String title; + @JsonProperty("iso_3166_1") + private String language; + @JsonProperty("site") + private String site; + @JsonProperty("name") + private String name; + @JsonProperty("id") + private int id; + + // + public Artwork getPoster() { + return poster; + } + + public Artwork getBackdrop() { + return backdrop; + } + + public String getTitle() { + return title; + } + + public String getLanguage() { + return language; + } + + public String getSite() { + return site; + } + + public String getName() { + return name; + } + + public int getId() { + return id; + } + // + + // + public void setPoster(Artwork poster) { + this.poster = poster; + } + + public void setBackdrop(Artwork backdrop) { + this.backdrop = backdrop; + backdrop.setArtworkType(ArtworkType.BACKDROP); + } + + public void setTitle(String title) { + this.title = title; + } + + public void setLanguage(String language) { + this.language = language; + } + + public void setSite(String site) { + this.site = site; + } + + public void setName(String name) { + this.name = name; + } + + public void setId(int id) { + this.id = id; + } + + // + + /** + * Handle unknown properties and print a message + * + * @param key + * @param value + */ + @JsonAnySetter + public void handleUnknown(String key, Object value) { + StringBuilder sb = new StringBuilder(); + sb.append("Unknown property: '").append(key); + sb.append("' value: '").append(value).append("'"); + logger.trace(sb.toString()); + } +} diff --git a/src/main/java/com/omertron/themoviedbapi/model/MovieChanges.java b/src/main/java/com/omertron/themoviedbapi/model/MovieChanges.java new file mode 100644 index 000000000..93f21588d --- /dev/null +++ b/src/main/java/com/omertron/themoviedbapi/model/MovieChanges.java @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2004-2012 Stuart Boston + * + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . + * + */ +package com.omertron.themoviedbapi.model; + +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import java.util.List; +import org.apache.log4j.Logger; + +/** + * + * @author Stuart + */ +public class MovieChanges implements Serializable { + + private static final long serialVersionUID = 1L; + + /* + * Logger + */ + private static final Logger logger = Logger.getLogger(MovieChanges.class); + /* + * Properties + */ + @JsonProperty("key") + private String key; + @JsonProperty("items") + private List items; + + // + public String getKey() { + return key; + } + + public List getItems() { + return items; + } + // + + // + public void setKey(String key) { + this.key = key; + } + + public void setItems(List items) { + this.items = items; + } + // + + /** + * Handle unknown properties and print a message + * + * @param key + * @param value + */ + @JsonAnySetter + public void handleUnknown(String key, Object value) { + StringBuilder sb = new StringBuilder(); + sb.append("Unknown property: '").append(key); + sb.append("' value: '").append(value).append("'"); + logger.trace(sb.toString()); + } +} diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperChanges.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperChanges.java new file mode 100644 index 000000000..69a217463 --- /dev/null +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperChanges.java @@ -0,0 +1,69 @@ +/* + * Copyright (c) 2004-2012 Stuart Boston + * + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . + * + */ +package com.omertron.themoviedbapi.wrapper; + +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.omertron.themoviedbapi.model.MovieChanges; +import java.util.List; +import org.apache.log4j.Logger; + +/** + * + * @author stuart.boston + */ +public class WrapperChanges { + /* + * Logger + */ + + private static final Logger logger = Logger.getLogger(WrapperChanges.class); + /* + * Properties + */ + @JsonProperty("changes") + private List changes; + + // + public List getChanges() { + return changes; + } + // + + // + public void setChanges(List changes) { + this.changes = changes; + } + // + + /** + * Handle unknown properties and print a message + * + * @param key + * @param value + */ + @JsonAnySetter + public void handleUnknown(String key, Object value) { + StringBuilder sb = new StringBuilder(); + sb.append("Unknown property: '").append(key); + sb.append("' value: '").append(value).append("'"); + logger.trace(sb.toString()); + } +} diff --git a/src/test/java/com/omertron/themoviedbapi/TheMovieDbApiTest.java b/src/test/java/com/omertron/themoviedbapi/TheMovieDbApiTest.java index 79f55cd87..7e9f30123 100644 --- a/src/test/java/com/omertron/themoviedbapi/TheMovieDbApiTest.java +++ b/src/test/java/com/omertron/themoviedbapi/TheMovieDbApiTest.java @@ -25,6 +25,7 @@ import com.omertron.themoviedbapi.model.CollectionInfo; import com.omertron.themoviedbapi.model.Company; import com.omertron.themoviedbapi.model.Genre; import com.omertron.themoviedbapi.model.Keyword; +import com.omertron.themoviedbapi.model.MovieChanges; import com.omertron.themoviedbapi.model.MovieDb; import com.omertron.themoviedbapi.model.MovieList; import com.omertron.themoviedbapi.model.Person; @@ -37,6 +38,7 @@ import com.omertron.themoviedbapi.model.Trailer; import com.omertron.themoviedbapi.model.Translation; import com.omertron.themoviedbapi.tools.FilteringLayout; import java.io.IOException; +import java.util.Collections; import java.util.List; import org.apache.commons.lang3.StringUtils; import org.apache.log4j.Level; @@ -91,7 +93,7 @@ public class TheMovieDbApiTest { /** * Test of getConfiguration method, of class TheMovieDbApi. */ - //@Test + @Test public void testConfiguration() throws IOException { logger.info("Test Configuration"); @@ -107,7 +109,7 @@ public class TheMovieDbApiTest { /** * Test of searchMovie method, of class TheMovieDbApi. */ - //@Test + @Test public void testSearchMovie() throws MovieDbException { logger.info("searchMovie"); @@ -128,7 +130,7 @@ public class TheMovieDbApiTest { /** * Test of getMovieInfo method, of class TheMovieDbApi. */ - //@Test + @Test public void testGetMovieInfo() throws MovieDbException { logger.info("getMovieInfo"); String language = "en"; @@ -139,7 +141,7 @@ public class TheMovieDbApiTest { /** * Test of getMovieAlternativeTitles method, of class TheMovieDbApi. */ - //@Test + @Test public void testGetMovieAlternativeTitles() throws MovieDbException { logger.info("getMovieAlternativeTitles"); String country = ""; @@ -155,7 +157,7 @@ public class TheMovieDbApiTest { /** * Test of getMovieCasts method, of class TheMovieDbApi. */ - //@Test + @Test public void testGetMovieCasts() throws MovieDbException { logger.info("getMovieCasts"); List people = tmdb.getMovieCasts(ID_MOVIE_BLADE_RUNNER); @@ -182,7 +184,7 @@ public class TheMovieDbApiTest { /** * Test of getMovieImages method, of class TheMovieDbApi. */ - //@Test + @Test public void testGetMovieImages() throws MovieDbException { logger.info("getMovieImages"); String language = ""; @@ -193,7 +195,7 @@ public class TheMovieDbApiTest { /** * Test of getMovieKeywords method, of class TheMovieDbApi. */ - //@Test + @Test public void testGetMovieKeywords() throws MovieDbException { logger.info("getMovieKeywords"); List result = tmdb.getMovieKeywords(ID_MOVIE_BLADE_RUNNER); @@ -203,7 +205,7 @@ public class TheMovieDbApiTest { /** * Test of getMovieReleaseInfo method, of class TheMovieDbApi. */ - //@Test + @Test public void testGetMovieReleaseInfo() throws MovieDbException { logger.info("getMovieReleaseInfo"); List result = tmdb.getMovieReleaseInfo(ID_MOVIE_BLADE_RUNNER, ""); @@ -213,7 +215,7 @@ public class TheMovieDbApiTest { /** * Test of getMovieTrailers method, of class TheMovieDbApi. */ - //@Test + @Test public void testGetMovieTrailers() throws MovieDbException { logger.info("getMovieTrailers"); List result = tmdb.getMovieTrailers(ID_MOVIE_BLADE_RUNNER, ""); @@ -223,7 +225,7 @@ public class TheMovieDbApiTest { /** * Test of getMovieTranslations method, of class TheMovieDbApi. */ - //@Test + @Test public void testGetMovieTranslations() throws MovieDbException { logger.info("getMovieTranslations"); List result = tmdb.getMovieTranslations(ID_MOVIE_BLADE_RUNNER); @@ -233,7 +235,7 @@ public class TheMovieDbApiTest { /** * Test of getCollectionInfo method, of class TheMovieDbApi. */ - //@Test + @Test public void testGetCollectionInfo() throws MovieDbException { logger.info("getCollectionInfo"); String language = ""; @@ -246,7 +248,7 @@ public class TheMovieDbApiTest { * * @throws MovieDbException */ - //@Test + @Test public void testCreateImageUrl() throws MovieDbException { logger.info("createImageUrl"); MovieDb movie = tmdb.getMovieInfo(ID_MOVIE_BLADE_RUNNER, ""); @@ -257,7 +259,7 @@ public class TheMovieDbApiTest { /** * Test of getMovieInfoImdb method, of class TheMovieDbApi. */ - //@Test + @Test public void testGetMovieInfoImdb() throws MovieDbException { logger.info("getMovieInfoImdb"); MovieDb result = tmdb.getMovieInfoImdb("tt0076759", "en-US"); @@ -267,7 +269,7 @@ public class TheMovieDbApiTest { /** * Test of getApiKey method, of class TheMovieDbApi. */ - //@Test + @Test public void testGetApiKey() { // Not required } @@ -275,7 +277,7 @@ public class TheMovieDbApiTest { /** * Test of getApiBase method, of class TheMovieDbApi. */ - //@Test + @Test public void testGetApiBase() { // Not required } @@ -283,7 +285,7 @@ public class TheMovieDbApiTest { /** * Test of getConfiguration method, of class TheMovieDbApi. */ - //@Test + @Test public void testGetConfiguration() { // Not required } @@ -291,7 +293,7 @@ public class TheMovieDbApiTest { /** * Test of searchPeople method, of class TheMovieDbApi. */ - //@Test + @Test public void testSearchPeople() throws MovieDbException { logger.info("searchPeople"); String personName = "Bruce Willis"; @@ -303,7 +305,7 @@ public class TheMovieDbApiTest { /** * Test of getPersonInfo method, of class TheMovieDbApi. */ - //@Test + @Test public void testGetPersonInfo() throws MovieDbException { logger.info("getPersonInfo"); Person result = tmdb.getPersonInfo(ID_PERSON_BRUCE_WILLIS); @@ -313,7 +315,7 @@ public class TheMovieDbApiTest { /** * Test of getPersonCredits method, of class TheMovieDbApi. */ - //@Test + @Test public void testGetPersonCredits() throws MovieDbException { logger.info("getPersonCredits"); @@ -324,7 +326,7 @@ public class TheMovieDbApiTest { /** * Test of getPersonImages method, of class TheMovieDbApi. */ - //@Test + @Test public void testGetPersonImages() throws MovieDbException { logger.info("getPersonImages"); @@ -335,7 +337,7 @@ public class TheMovieDbApiTest { /** * Test of getLatestMovie method, of class TheMovieDbApi. */ - //@Test + @Test public void testGetLatestMovie() throws MovieDbException { logger.info("getLatestMovie"); MovieDb result = tmdb.getLatestMovie(); @@ -346,7 +348,7 @@ public class TheMovieDbApiTest { /** * Test of compareMovies method, of class TheMovieDbApi. */ - //@Test + @Test public void testCompareMovies() { // Not required } @@ -354,7 +356,7 @@ public class TheMovieDbApiTest { /** * Test of setProxy method, of class TheMovieDbApi. */ - //@Test + @Test public void testSetProxy() { // Not required } @@ -362,7 +364,7 @@ public class TheMovieDbApiTest { /** * Test of setTimeout method, of class TheMovieDbApi. */ - //@Test + @Test public void testSetTimeout() { // Not required } @@ -370,37 +372,37 @@ public class TheMovieDbApiTest { /** * Test of getNowPlayingMovies method, of class TheMovieDbApi. */ - //@Test + @Test public void testGetNowPlayingMovies() throws MovieDbException { logger.info("getNowPlayingMovies"); - List results = tmdb.getNowPlayingMovies("", true); + List results = tmdb.getNowPlayingMovies("", 0); assertTrue("No now playing movies found", !results.isEmpty()); } /** * Test of getPopularMovieList method, of class TheMovieDbApi. */ - //@Test + @Test public void testGetPopularMovieList() throws MovieDbException { logger.info("getPopularMovieList"); - List results = tmdb.getPopularMovieList("", true); + List results = tmdb.getPopularMovieList("", 0); assertTrue("No popular movies found", !results.isEmpty()); } /** * Test of getTopRatedMovies method, of class TheMovieDbApi. */ - //@Test + @Test public void testGetTopRatedMovies() throws MovieDbException { logger.info("getTopRatedMovies"); - List results = tmdb.getTopRatedMovies("", true); + List results = tmdb.getTopRatedMovies("", 0); assertTrue("No top rated movies found", !results.isEmpty()); } /** * Test of getCompanyInfo method, of class TheMovieDbApi. */ - //@Test + @Test public void testGetCompanyInfo() throws MovieDbException { logger.info("getCompanyInfo"); Company company = tmdb.getCompanyInfo(ID_COMPANY_LUCASFILM); @@ -410,7 +412,7 @@ public class TheMovieDbApiTest { /** * Test of getCompanyMovies method, of class TheMovieDbApi. */ - //@Test + @Test public void testGetCompanyMovies() throws MovieDbException { logger.info("getCompanyMovies"); List results = tmdb.getCompanyMovies(ID_COMPANY_LUCASFILM, "", true); @@ -420,7 +422,7 @@ public class TheMovieDbApiTest { /** * Test of searchCompanies method, of class TheMovieDbApi. */ - //@Test + @Test public void testSearchCompanies() throws MovieDbException { logger.info("searchCompanies"); List results = tmdb.searchCompanies(COMPANY_NAME, "", true); @@ -430,7 +432,7 @@ public class TheMovieDbApiTest { /** * Test of getSimilarMovies method, of class TheMovieDbApi. */ - //@Test + @Test public void testGetSimilarMovies() throws MovieDbException { logger.info("getSimilarMovies"); List results = tmdb.getSimilarMovies(ID_MOVIE_BLADE_RUNNER, "", true); @@ -440,7 +442,7 @@ public class TheMovieDbApiTest { /** * Test of getGenreList method, of class TheMovieDbApi. */ - //@Test + @Test public void testGetGenreList() throws MovieDbException { logger.info("getGenreList"); List results = tmdb.getGenreList(""); @@ -450,7 +452,7 @@ public class TheMovieDbApiTest { /** * Test of getGenreMovies method, of class TheMovieDbApi. */ - //@Test + @Test public void testGetGenreMovies() throws MovieDbException { logger.info("getGenreMovies"); List results = tmdb.getGenreMovies(ID_GENRE_ACTION, "", true); @@ -460,7 +462,7 @@ public class TheMovieDbApiTest { /** * Test of getUpcoming method, of class TheMovieDbApi. */ - //@Test + @Test public void testGetUpcoming() throws Exception { logger.info("getUpcoming"); List results = tmdb.getUpcoming(""); @@ -470,7 +472,7 @@ public class TheMovieDbApiTest { /** * Test of getCollectionImages method, of class TheMovieDbApi. */ - //@Test + @Test public void testGetCollectionImages() throws Exception { logger.info("getCollectionImages"); String language = ""; @@ -481,7 +483,7 @@ public class TheMovieDbApiTest { /** * Test of getAuthorisationToken method, of class TheMovieDbApi. */ - //@Test + @Test public void testGetAuthorisationToken() throws Exception { logger.info("getAuthorisationToken"); TokenAuthorisation result = tmdb.getAuthorisationToken(); @@ -493,7 +495,7 @@ public class TheMovieDbApiTest { /** * Test of getSessionToken method, of class TheMovieDbApi. */ - //@Test + @Test public void testGetSessionToken() throws Exception { logger.info("getSessionToken"); TokenAuthorisation token = tmdb.getAuthorisationToken(); @@ -510,7 +512,7 @@ public class TheMovieDbApiTest { /** * Test of getGuestSessionToken method, of class TheMovieDbApi. */ - //@Test + @Test public void testGetGuestSessionToken() throws Exception { logger.info("getGuestSessionToken"); TokenSession result = tmdb.getGuestSessionToken(); @@ -526,4 +528,24 @@ public class TheMovieDbApiTest { assertNotNull("No results found", results); assertTrue("No results found", results.size() > 0); } + +// Do not test this until it is fixed +// @Test + public void testGetMovieChanges() throws Exception { + logger.info("getMovieChanges"); + + String language = ""; + String startDate = ""; + String endDate = null; + List results = Collections.EMPTY_LIST; + + List movieList = tmdb.getPopularMovieList(language, 0); + for (MovieDb movie : movieList) { + results = tmdb.getMovieChanges(movie.getId(), startDate, endDate); + logger.info(movie.getTitle() + " has " + results.size() + " changes."); + } + + assertNotNull("No results found", results); + assertTrue("No results found", results.size() > 0); + } } From af0b65758656cebac054a406d00fe2dc5600d531 Mon Sep 17 00:00:00 2001 From: Stuart Boston Date: Wed, 19 Dec 2012 16:00:57 +0000 Subject: [PATCH 168/207] Remove deprecated functions --- .../omertron/themoviedbapi/TheMovieDbApi.java | 151 ------------------ .../themoviedbapi/TheMovieDbApiTest.java | 14 +- 2 files changed, 7 insertions(+), 158 deletions(-) diff --git a/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java b/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java index 9037db925..416221a12 100644 --- a/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java +++ b/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java @@ -1381,155 +1381,4 @@ public class TheMovieDbApi { } // - // - /* - * Deprecated Functions. - * - * Will be removed in next version: 3.3 - */ - // - /** - * This interface will be deprecated in the next version - * - * @param movieName - * @param language - * @param allResults - * @return - * @throws MovieDbException - * @deprecated - */ - @Deprecated - public List searchMovie(String movieName, String language, boolean allResults) throws MovieDbException { - return searchMovie(movieName, 0, language, allResults, 0); - } - - /** - * This interface will be deprecated in the next version - * - * @param companyName - * @param language - * @param allResults - * @return - * @throws MovieDbException - * @deprecated - */ - @Deprecated - public List searchCompanies(String companyName, String language, boolean allResults) throws MovieDbException { - return searchCompanies(companyName, 0); - } - - /** - * This interface will be deprecated in the next version - * - * @param personName - * @param allResults - * @return - * @throws MovieDbException - * @deprecated - */ - @Deprecated - public List searchPeople(String personName, boolean allResults) throws MovieDbException { - return searchPeople(personName, allResults, 0); - } - - /** - * This interface will be deprecated in the next version - * - * @param movieId - * @param language - * @param allResults - * @return - * @throws MovieDbException - * @deprecated - */ - @Deprecated - public List getSimilarMovies(int movieId, String language, boolean allResults) throws MovieDbException { - return getSimilarMovies(movieId, language, 0); - } - - /** - * This interface will be deprecated in the next version - * - * @param language - * @return - * @throws MovieDbException - * @deprecated - */ - @Deprecated - public List getUpcoming(String language) throws MovieDbException { - return getUpcoming(language, 0); - } - - /** - * This interface will be deprecated in the next version - * - * @param language - * @param allResults - * @return - * @throws MovieDbException - * @deprecated - */ - @Deprecated - public List getNowPlayingMovies(String language, boolean allResults) throws MovieDbException { - return getNowPlayingMovies(language, 0); - } - - /** - * This interface will be deprecated in the next version - * - * @param language - * @param allResults - * @return - * @throws MovieDbException - * @deprecated - */ - @Deprecated - public List getPopularMovieList(String language, boolean allResults) throws MovieDbException { - return getPopularMovieList(language, 0); - } - - /** - * This interface will be deprecated in the next version - * - * @param language - * @param allResults - * @return - * @throws MovieDbException - * @deprecated - */ - @Deprecated - public List getTopRatedMovies(String language, boolean allResults) throws MovieDbException { - return getTopRatedMovies(language, 0); - } - - /** - * This interface will be deprecated in the next version - * - * @param companyId - * @param language - * @param allResults - * @return - * @throws MovieDbException - * @deprecated - */ - @Deprecated - public List getCompanyMovies(int companyId, String language, boolean allResults) throws MovieDbException { - return getCompanyMovies(companyId, language, 0); - } - - /** - * This interface will be deprecated in the next version - * - * @param genreId - * @param language - * @param allResults - * @return - * @throws MovieDbException - * @deprecated - */ - @Deprecated - public List getGenreMovies(int genreId, String language, boolean allResults) throws MovieDbException { - return getGenreMovies(genreId, language, 0); - } - // } diff --git a/src/test/java/com/omertron/themoviedbapi/TheMovieDbApiTest.java b/src/test/java/com/omertron/themoviedbapi/TheMovieDbApiTest.java index 7e9f30123..44b1b9e0b 100644 --- a/src/test/java/com/omertron/themoviedbapi/TheMovieDbApiTest.java +++ b/src/test/java/com/omertron/themoviedbapi/TheMovieDbApiTest.java @@ -297,8 +297,8 @@ public class TheMovieDbApiTest { public void testSearchPeople() throws MovieDbException { logger.info("searchPeople"); String personName = "Bruce Willis"; - boolean allResults = false; - List result = tmdb.searchPeople(personName, allResults); + boolean includeAdult = false; + List result = tmdb.searchPeople(personName, includeAdult, 0); assertTrue("Couldn't find the person", result.size() > 0); } @@ -415,7 +415,7 @@ public class TheMovieDbApiTest { @Test public void testGetCompanyMovies() throws MovieDbException { logger.info("getCompanyMovies"); - List results = tmdb.getCompanyMovies(ID_COMPANY_LUCASFILM, "", true); + List results = tmdb.getCompanyMovies(ID_COMPANY_LUCASFILM, "", 0); assertTrue("No company movies found", !results.isEmpty()); } @@ -425,7 +425,7 @@ public class TheMovieDbApiTest { @Test public void testSearchCompanies() throws MovieDbException { logger.info("searchCompanies"); - List results = tmdb.searchCompanies(COMPANY_NAME, "", true); + List results = tmdb.searchCompanies(COMPANY_NAME, 0); assertTrue("No company information found", !results.isEmpty()); } @@ -435,7 +435,7 @@ public class TheMovieDbApiTest { @Test public void testGetSimilarMovies() throws MovieDbException { logger.info("getSimilarMovies"); - List results = tmdb.getSimilarMovies(ID_MOVIE_BLADE_RUNNER, "", true); + List results = tmdb.getSimilarMovies(ID_MOVIE_BLADE_RUNNER, "", 0); assertTrue("No similar movies found", !results.isEmpty()); } @@ -455,7 +455,7 @@ public class TheMovieDbApiTest { @Test public void testGetGenreMovies() throws MovieDbException { logger.info("getGenreMovies"); - List results = tmdb.getGenreMovies(ID_GENRE_ACTION, "", true); + List results = tmdb.getGenreMovies(ID_GENRE_ACTION, "", 0); assertTrue("No genre movies found", !results.isEmpty()); } @@ -465,7 +465,7 @@ public class TheMovieDbApiTest { @Test public void testGetUpcoming() throws Exception { logger.info("getUpcoming"); - List results = tmdb.getUpcoming(""); + List results = tmdb.getUpcoming("", 0); assertTrue("No upcoming movies found", !results.isEmpty()); } From 44a60ba78626f733d80da6864b17c3d831484e33 Mon Sep 17 00:00:00 2001 From: Omertron <> Date: Wed, 19 Dec 2012 21:46:37 +0000 Subject: [PATCH 169/207] Add get person latest method --- .../omertron/themoviedbapi/TheMovieDbApi.java | 155 ++++++++++-------- .../themoviedbapi/TheMovieDbApiTest.java | 10 ++ 2 files changed, 95 insertions(+), 70 deletions(-) diff --git a/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java b/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java index 416221a12..54a138d7e 100644 --- a/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java +++ b/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java @@ -73,8 +73,7 @@ import org.apache.log4j.Logger; /** * The MovieDb API * - * This is for version 3 of the API as specified here: - * http://help.themoviedb.org/kb/api/about-3 + * This is for version 3 of the API as specified here: http://help.themoviedb.org/kb/api/about-3 * * @author stuart.boston */ @@ -169,6 +168,14 @@ public class TheMovieDbApi { WebBrowser.setWebTimeoutRead(read); } + /** + * Compare the MovieDB object with a title & year + * + * @param moviedb The moviedb object to compare too + * @param title The title of the movie to compare + * @param year The year of the movie to compare exact match + * @return True if there is a match, False otherwise. + */ public static boolean compareMovies(MovieDb moviedb, String title, String year) { return compareMovies(moviedb, title, year, 0); } @@ -179,8 +186,7 @@ public class TheMovieDbApi { * @param moviedb The moviedb object to compare too * @param title The title of the movie to compare * @param year The year of the movie to compare - * @param maxDistance The Levenshtein Distance between the two titles. 0 = - * exact match + * @param maxDistance The Levenshtein Distance between the two titles. 0 = exact match * @return True if there is a match, False otherwise. */ public static boolean compareMovies(MovieDb moviedb, String title, String year, int maxDistance) { @@ -274,16 +280,13 @@ public class TheMovieDbApi { // // /** - * This method is used to generate a valid request token for user based - * authentication. + * This method is used to generate a valid request token for user based authentication. * * A request token is required in order to request a session id. * - * You can generate any number of request tokens but they will expire after - * 60 minutes. + * You can generate any number of request tokens but they will expire after 60 minutes. * - * As soon as a valid session id has been created the token will be - * destroyed. + * As soon as a valid session id has been created the token will be destroyed. * * @return * @throws MovieDbException @@ -303,8 +306,7 @@ public class TheMovieDbApi { } /** - * This method is used to generate a session id for user based - * authentication. + * This method is used to generate a session id for user based authentication. * * A session id is required in order to use any of the write methods. * @@ -335,18 +337,15 @@ public class TheMovieDbApi { /** * This method is used to generate a guest session id. * - * A guest session can be used to rate movies without having a registered - * TMDb user account. + * A guest session can be used to rate movies without having a registered TMDb user account. * - * You should only generate a single guest session per user (or device) as - * you will be able to attach the ratings to a TMDb user account in the - * future. + * You should only generate a single guest session per user (or device) as you will be able to attach the ratings to + * a TMDb user account in the future. * - * There are also IP limits in place so you should always make sure it's the - * end user doing the guest session actions. + * There are also IP limits in place so you should always make sure it's the end user doing the guest session + * actions. * - * If a guest session is not used for the first time within 24 hours, it - * will be automatically discarded. + * If a guest session is not used for the first time within 24 hours, it will be automatically discarded. * * @return * @throws MovieDbException @@ -430,8 +429,7 @@ public class TheMovieDbApi { } /** - * This method is used to retrieve all of the alternative titles we have for - * a particular movie. + * This method is used to retrieve all of the alternative titles we have for a particular movie. * * @param movieId * @param country @@ -499,8 +497,7 @@ public class TheMovieDbApi { } /** - * This method should be used when you’re wanting to retrieve all of the - * images for a particular movie. + * This method should be used when you’re wanting to retrieve all of the images for a particular movie. * * @param movieId * @param language @@ -541,8 +538,7 @@ public class TheMovieDbApi { } /** - * This method is used to retrieve all of the keywords that have been added - * to a particular movie. + * This method is used to retrieve all of the keywords that have been added to a particular movie. * * Currently, only English keywords exist. * @@ -567,8 +563,7 @@ public class TheMovieDbApi { } /** - * This method is used to retrieve all of the release and certification data - * we have for a specific movie. + * This method is used to retrieve all of the release and certification data we have for a specific movie. * * @param movieId * @param language @@ -593,8 +588,7 @@ public class TheMovieDbApi { } /** - * This method is used to retrieve all of the trailers for a particular - * movie. + * This method is used to retrieve all of the trailers for a particular movie. * * Supported sites are YouTube and QuickTime. * @@ -637,8 +631,7 @@ public class TheMovieDbApi { } /** - * This method is used to retrieve a list of the available translations for - * a specific movie. + * This method is used to retrieve a list of the available translations for a specific movie. * * @param movieId * @return @@ -661,11 +654,9 @@ public class TheMovieDbApi { } /** - * The similar movies method will let you retrieve the similar movies for a - * particular movie. + * The similar movies method will let you retrieve the similar movies for a particular movie. * - * This data is created dynamically but with the help of users votes on - * TMDb. + * This data is created dynamically but with the help of users votes on TMDb. * * The data is much better with movies that have more keywords * @@ -739,13 +730,11 @@ public class TheMovieDbApi { * * By default, only the last 24 hours of changes are returned. * - * The maximum number of days that can be returned in a single request is - * 14. + * The maximum number of days that can be returned in a single request is 14. * * The language is present on fields that are translatable. * - * TODO: DOES NOT WORK AT THE MOMENT. This is due to the "value" item - * changing type in the ChangeItem + * TODO: DOES NOT WORK AT THE MOMENT. This is due to the "value" item changing type in the ChangeItem * * @param movieId * @param startDate the start date of the changes, optional @@ -833,8 +822,7 @@ public class TheMovieDbApi { /** * This method is used to retrieve the movies currently in theatres. * - * This is a curated list that will normally contain 100 movies. The default - * response will return 20 movies. + * This is a curated list that will normally contain 100 movies. The default response will return 20 movies. * * TODO: Implement more than 20 movies * @@ -902,8 +890,7 @@ public class TheMovieDbApi { } /** - * This method is used to retrieve the top rated movies that have over 10 - * votes on TMDb. + * This method is used to retrieve the top rated movies that have over 10 votes on TMDb. * * The default response will return 20 movies. * @@ -960,11 +947,9 @@ public class TheMovieDbApi { // // /** - * This method is used to retrieve all of the basic information about a - * movie collection. + * This method is used to retrieve all of the basic information about a movie collection. * - * You can get the ID needed for this method by making a getMovieInfo - * request for the belongs_to_collection. + * You can get the ID needed for this method by making a getMovieInfo request for the belongs_to_collection. * * @param collectionId * @param language @@ -1062,8 +1047,7 @@ public class TheMovieDbApi { } /** - * This method is used to retrieve all of the cast & crew information for - * the person. + * This method is used to retrieve all of the cast & crew information for the person. * * It will return the single highest rated poster for each movie record. * @@ -1133,12 +1117,50 @@ public class TheMovieDbApi { } } + /** + * Get the changes for a specific person id. + * + * Changes are grouped by key, and ordered by date in descending order. + * + * By default, only the last 24 hours of changes are returned. + * + * The maximum number of days that can be returned in a single request is 14. + * + * The language is present on fields that are translatable. + * + * @param personId + * @param startDate + * @param endDate + * @throws MovieDbException + */ + public void getPersonChanges(int personId, String startDate, String endDate) throws MovieDbException { + throw new MovieDbException(MovieDbExceptionType.UNKNOWN_CAUSE, "Not implemented yet"); + } + + /** + * Get the latest person id. + * + * @return + * @throws MovieDbException + */ + public Person getPersonLatest() throws MovieDbException { + ApiUrl apiUrl = new ApiUrl(this, BASE_PERSON, "/latest"); + URL url = apiUrl.buildUrl(); + String webpage = WebBrowser.request(url); + + try { + return mapper.readValue(webpage, Person.class); + } catch (IOException ex) { + logger.warn("Failed to get latest person: " + ex.getMessage()); + throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); + } + } + // // // /** - * This method is used to retrieve the basic information about a production - * company on TMDb. + * This method is used to retrieve the basic information about a production company on TMDb. * * @param companyId * @return @@ -1163,8 +1185,8 @@ public class TheMovieDbApi { /** * This method is used to retrieve the movies associated with a company. * - * These movies are returned in order of most recently released to oldest. - * The default response will return 20 movies per page. + * These movies are returned in order of most recently released to oldest. The default response will return 20 + * movies per page. * * TODO: Implement more than 20 movies * @@ -1229,11 +1251,9 @@ public class TheMovieDbApi { /** * Get a list of movies per genre. * - * It is important to understand that only movies with more than 10 votes - * get listed. + * It is important to understand that only movies with more than 10 votes get listed. * - * This prevents movies from 1 10/10 rating from being listed first and for - * the first 5 pages. + * This prevents movies from 1 10/10 rating from being listed first and for the first 5 pages. * * @param genreId * @param language @@ -1268,16 +1288,13 @@ public class TheMovieDbApi { // /** - * Search Movies This is a good starting point to start finding movies on - * TMDb. + * Search Movies This is a good starting point to start finding movies on TMDb. * * @param movieName - * @param searchYear Limit the search to the provided year. Zero (0) will - * get all years + * @param searchYear Limit the search to the provided year. Zero (0) will get all years * @param language The language to include. Can be blank/null. * @param includeAdult true or false to include adult titles in the search - * @param page The page of results to return. 0 to get the default (first - * page) + * @param page The page of results to return. 0 to get the default (first page) * @return * @throws MovieDbException */ @@ -1317,8 +1334,8 @@ public class TheMovieDbApi { /** * Search Companies. * - * You can use this method to search for production companies that are part - * of TMDb. The company IDs will map to those returned on movie calls. + * You can use this method to search for production companies that are part of TMDb. The company IDs will map to + * those returned on movie calls. * * http://help.themoviedb.org/kb/api/search-companies * @@ -1349,8 +1366,7 @@ public class TheMovieDbApi { /** * This is a good starting point to start finding people on TMDb. * - * The idea is to be a quick and light method so you can iterate through - * people quickly. + * The idea is to be a quick and light method so you can iterate through people quickly. * * TODO: Fix allResults * @@ -1379,6 +1395,5 @@ public class TheMovieDbApi { throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } - // } diff --git a/src/test/java/com/omertron/themoviedbapi/TheMovieDbApiTest.java b/src/test/java/com/omertron/themoviedbapi/TheMovieDbApiTest.java index 44b1b9e0b..c6634503a 100644 --- a/src/test/java/com/omertron/themoviedbapi/TheMovieDbApiTest.java +++ b/src/test/java/com/omertron/themoviedbapi/TheMovieDbApiTest.java @@ -548,4 +548,14 @@ public class TheMovieDbApiTest { assertNotNull("No results found", results); assertTrue("No results found", results.size() > 0); } + + @Test + public void testGetPersonLatest() throws Exception { + logger.info("getPersonLatest"); + + Person result = tmdb.getPersonLatest(); + + assertNotNull("No results found", result); + assertTrue("No results found", StringUtils.isNotBlank(result.getName())); + } } From 1009e2598e240cdd8ccccb3bbb4c127e1dafa45e Mon Sep 17 00:00:00 2001 From: Stuart Boston Date: Thu, 20 Dec 2012 12:46:57 +0000 Subject: [PATCH 170/207] Removed test for authentication as requires a HTTP session --- .../java/com/omertron/themoviedbapi/TheMovieDbApiTest.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/test/java/com/omertron/themoviedbapi/TheMovieDbApiTest.java b/src/test/java/com/omertron/themoviedbapi/TheMovieDbApiTest.java index c6634503a..3ef0e6e28 100644 --- a/src/test/java/com/omertron/themoviedbapi/TheMovieDbApiTest.java +++ b/src/test/java/com/omertron/themoviedbapi/TheMovieDbApiTest.java @@ -495,7 +495,8 @@ public class TheMovieDbApiTest { /** * Test of getSessionToken method, of class TheMovieDbApi. */ - @Test +// Cannot be tested without a HTTP authorisation: http://help.themoviedb.org/kb/api/user-authentication +// @Test public void testGetSessionToken() throws Exception { logger.info("getSessionToken"); TokenAuthorisation token = tmdb.getAuthorisationToken(); From 44d63fbf762c5c6ddfed762f5fceac7ee3bdd5b5 Mon Sep 17 00:00:00 2001 From: Omertron <> Date: Mon, 24 Dec 2012 22:35:31 +0000 Subject: [PATCH 171/207] Added new searches --- .../omertron/themoviedbapi/TheMovieDbApi.java | 105 +++++++++++++-- .../themoviedbapi/model/MovieList.java | 8 ++ .../wrapper/WrapperCollection.java | 100 ++++++++++++++ .../themoviedbapi/TheMovieDbApiTest.java | 122 ++++++++++++------ 4 files changed, 281 insertions(+), 54 deletions(-) create mode 100644 src/main/java/com/omertron/themoviedbapi/wrapper/WrapperCollection.java diff --git a/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java b/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java index 54a138d7e..2aec5a543 100644 --- a/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java +++ b/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java @@ -24,6 +24,7 @@ import com.omertron.themoviedbapi.MovieDbException.MovieDbExceptionType; import com.omertron.themoviedbapi.model.AlternativeTitle; import com.omertron.themoviedbapi.model.Artwork; import com.omertron.themoviedbapi.model.ArtworkType; +import com.omertron.themoviedbapi.model.Collection; import com.omertron.themoviedbapi.model.CollectionInfo; import com.omertron.themoviedbapi.model.Company; import com.omertron.themoviedbapi.model.Genre; @@ -48,6 +49,7 @@ import com.omertron.themoviedbapi.tools.FilteringLayout; import com.omertron.themoviedbapi.tools.WebBrowser; import com.omertron.themoviedbapi.wrapper.WrapperAlternativeTitles; import com.omertron.themoviedbapi.wrapper.WrapperChanges; +import com.omertron.themoviedbapi.wrapper.WrapperCollection; import com.omertron.themoviedbapi.wrapper.WrapperCompany; import com.omertron.themoviedbapi.wrapper.WrapperCompanyMovies; import com.omertron.themoviedbapi.wrapper.WrapperConfig; @@ -1332,33 +1334,37 @@ public class TheMovieDbApi { } /** - * Search Companies. + * Search for collections by name. * - * You can use this method to search for production companies that are part of TMDb. The company IDs will map to - * those returned on movie calls. - * - * http://help.themoviedb.org/kb/api/search-companies - * - * @param companyName + * @param query + * @param language * @param page * @return * @throws MovieDbException */ - public List searchCompanies(String companyName, int page) throws MovieDbException { - ApiUrl apiUrl = new ApiUrl(this, BASE_SEARCH, "company"); - apiUrl.addArgument(PARAM_QUERY, companyName); + public List searchCollection(String query, String language, int page) throws MovieDbException { + ApiUrl apiUrl = new ApiUrl(this, BASE_SEARCH, "collections"); + + if (StringUtils.isNotBlank(query)) { + apiUrl.addArgument(PARAM_QUERY, query); + } + + if (StringUtils.isNotBlank(language)) { + apiUrl.addArgument(PARAM_LANGUAGE, language); + } if (page > 0) { - apiUrl.addArgument(PARAM_PAGE, page); + apiUrl.addArgument(PARAM_PAGE, Integer.toString(page)); } URL url = apiUrl.buildUrl(); + String webpage = WebBrowser.request(url); try { - WrapperCompany wrapper = mapper.readValue(webpage, WrapperCompany.class); + WrapperCollection wrapper = mapper.readValue(webpage, WrapperCollection.class); return wrapper.getResults(); } catch (IOException ex) { - logger.warn("Failed to find company: " + ex.getMessage()); + logger.warn("Failed to find collection: " + ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } @@ -1395,5 +1401,78 @@ public class TheMovieDbApi { throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } + + /** + * Search for lists by name and description. + * + * @param query + * @param language + * @param page + * @throws MovieDbException + */ + public List searchList(String query, String language, int page) throws MovieDbException { + ApiUrl apiUrl = new ApiUrl(this, BASE_SEARCH, "list"); + + if (StringUtils.isNotBlank(query)) { + apiUrl.addArgument(PARAM_QUERY, query); + } + + if (StringUtils.isNotBlank(language)) { + apiUrl.addArgument(PARAM_LANGUAGE, language); + } + + if (page > 0) { + apiUrl.addArgument(PARAM_PAGE, Integer.toString(page)); + } + + URL url = apiUrl.buildUrl(); + + String webpage = WebBrowser.request(url); + try { + WrapperMovieList wrapper = mapper.readValue(webpage, WrapperMovieList.class); + return wrapper.getMovieList(); + } catch (IOException ex) { + logger.warn("Failed to find list: " + ex.getMessage()); + throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); + } + } + + /** + * Search Companies. + * + * You can use this method to search for production companies that are part of TMDb. The company IDs will map to + * those returned on movie calls. + * + * http://help.themoviedb.org/kb/api/search-companies + * + * @param companyName + * @param page + * @return + * @throws MovieDbException + */ + public List searchCompanies(String companyName, int page) throws MovieDbException { + ApiUrl apiUrl = new ApiUrl(this, BASE_SEARCH, "company"); + apiUrl.addArgument(PARAM_QUERY, companyName); + + if (page > 0) { + apiUrl.addArgument(PARAM_PAGE, page); + } + + URL url = apiUrl.buildUrl(); + String webpage = WebBrowser.request(url); + try { + WrapperCompany wrapper = mapper.readValue(webpage, WrapperCompany.class); + return wrapper.getResults(); + } catch (IOException ex) { + logger.warn("Failed to find company: " + ex.getMessage()); + throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); + } + } + + public void searchKeyword() { + } // + // + // List Functions + // Keywords Functions } diff --git a/src/main/java/com/omertron/themoviedbapi/model/MovieList.java b/src/main/java/com/omertron/themoviedbapi/model/MovieList.java index 29f2fac3b..540ba3a3e 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/MovieList.java +++ b/src/main/java/com/omertron/themoviedbapi/model/MovieList.java @@ -53,6 +53,8 @@ public class MovieList implements Serializable { private String name; @JsonProperty("poster_path") private String posterPath; + @JsonProperty("list_type") + private String listType; // public String getDescription() { @@ -83,6 +85,9 @@ public class MovieList implements Serializable { return posterPath; } + public String getListType() { + return listType; + } // // @@ -114,6 +119,9 @@ public class MovieList implements Serializable { this.posterPath = posterPath; } + public void setListType(String listType) { + this.listType = listType; + } // /** diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperCollection.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperCollection.java new file mode 100644 index 000000000..f7b2a49ce --- /dev/null +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperCollection.java @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2004-2012 Stuart Boston + * + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . + * + */ +package com.omertron.themoviedbapi.wrapper; + +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.omertron.themoviedbapi.model.Collection; +import com.omertron.themoviedbapi.model.MovieChanges; +import java.util.List; +import org.apache.log4j.Logger; + +/** + * + * @author stuart.boston + */ +public class WrapperCollection { + /* + * Logger + */ + + private static final Logger logger = Logger.getLogger(WrapperCollection.class); + /* + * Properties + */ + @JsonProperty("page") + private int page; + @JsonProperty("results") + private List results; + @JsonProperty("total_pages") + private int totalPages; + @JsonProperty("total_results") + private int totalResults; + + // + public int getPage() { + return page; + } + + public List getResults() { + return results; + } + + public int getTotalPages() { + return totalPages; + } + + public int getTotalResults() { + return totalResults; + } + // + + // + public void setPage(int page) { + this.page = page; + } + + public void setResults(List results) { + this.results = results; + } + + public void setTotalPages(int totalPages) { + this.totalPages = totalPages; + } + + public void setTotalResults(int totalResults) { + this.totalResults = totalResults; + } + // + + /** + * Handle unknown properties and print a message + * + * @param key + * @param value + */ + @JsonAnySetter + public void handleUnknown(String key, Object value) { + StringBuilder sb = new StringBuilder(); + sb.append("Unknown property: '").append(key); + sb.append("' value: '").append(value).append("'"); + logger.trace(sb.toString()); + } +} diff --git a/src/test/java/com/omertron/themoviedbapi/TheMovieDbApiTest.java b/src/test/java/com/omertron/themoviedbapi/TheMovieDbApiTest.java index 3ef0e6e28..a16718099 100644 --- a/src/test/java/com/omertron/themoviedbapi/TheMovieDbApiTest.java +++ b/src/test/java/com/omertron/themoviedbapi/TheMovieDbApiTest.java @@ -21,6 +21,7 @@ package com.omertron.themoviedbapi; import com.omertron.themoviedbapi.model.AlternativeTitle; import com.omertron.themoviedbapi.model.Artwork; +import com.omertron.themoviedbapi.model.Collection; import com.omertron.themoviedbapi.model.CollectionInfo; import com.omertron.themoviedbapi.model.Company; import com.omertron.themoviedbapi.model.Genre; @@ -93,7 +94,7 @@ public class TheMovieDbApiTest { /** * Test of getConfiguration method, of class TheMovieDbApi. */ - @Test + //@Test public void testConfiguration() throws IOException { logger.info("Test Configuration"); @@ -109,7 +110,7 @@ public class TheMovieDbApiTest { /** * Test of searchMovie method, of class TheMovieDbApi. */ - @Test + //@Test public void testSearchMovie() throws MovieDbException { logger.info("searchMovie"); @@ -130,7 +131,7 @@ public class TheMovieDbApiTest { /** * Test of getMovieInfo method, of class TheMovieDbApi. */ - @Test + //@Test public void testGetMovieInfo() throws MovieDbException { logger.info("getMovieInfo"); String language = "en"; @@ -141,7 +142,7 @@ public class TheMovieDbApiTest { /** * Test of getMovieAlternativeTitles method, of class TheMovieDbApi. */ - @Test + //@Test public void testGetMovieAlternativeTitles() throws MovieDbException { logger.info("getMovieAlternativeTitles"); String country = ""; @@ -157,7 +158,7 @@ public class TheMovieDbApiTest { /** * Test of getMovieCasts method, of class TheMovieDbApi. */ - @Test + //@Test public void testGetMovieCasts() throws MovieDbException { logger.info("getMovieCasts"); List people = tmdb.getMovieCasts(ID_MOVIE_BLADE_RUNNER); @@ -184,7 +185,7 @@ public class TheMovieDbApiTest { /** * Test of getMovieImages method, of class TheMovieDbApi. */ - @Test + //@Test public void testGetMovieImages() throws MovieDbException { logger.info("getMovieImages"); String language = ""; @@ -195,7 +196,7 @@ public class TheMovieDbApiTest { /** * Test of getMovieKeywords method, of class TheMovieDbApi. */ - @Test + //@Test public void testGetMovieKeywords() throws MovieDbException { logger.info("getMovieKeywords"); List result = tmdb.getMovieKeywords(ID_MOVIE_BLADE_RUNNER); @@ -205,7 +206,7 @@ public class TheMovieDbApiTest { /** * Test of getMovieReleaseInfo method, of class TheMovieDbApi. */ - @Test + //@Test public void testGetMovieReleaseInfo() throws MovieDbException { logger.info("getMovieReleaseInfo"); List result = tmdb.getMovieReleaseInfo(ID_MOVIE_BLADE_RUNNER, ""); @@ -215,7 +216,7 @@ public class TheMovieDbApiTest { /** * Test of getMovieTrailers method, of class TheMovieDbApi. */ - @Test + //@Test public void testGetMovieTrailers() throws MovieDbException { logger.info("getMovieTrailers"); List result = tmdb.getMovieTrailers(ID_MOVIE_BLADE_RUNNER, ""); @@ -225,7 +226,7 @@ public class TheMovieDbApiTest { /** * Test of getMovieTranslations method, of class TheMovieDbApi. */ - @Test + //@Test public void testGetMovieTranslations() throws MovieDbException { logger.info("getMovieTranslations"); List result = tmdb.getMovieTranslations(ID_MOVIE_BLADE_RUNNER); @@ -235,7 +236,7 @@ public class TheMovieDbApiTest { /** * Test of getCollectionInfo method, of class TheMovieDbApi. */ - @Test + //@Test public void testGetCollectionInfo() throws MovieDbException { logger.info("getCollectionInfo"); String language = ""; @@ -248,7 +249,7 @@ public class TheMovieDbApiTest { * * @throws MovieDbException */ - @Test + //@Test public void testCreateImageUrl() throws MovieDbException { logger.info("createImageUrl"); MovieDb movie = tmdb.getMovieInfo(ID_MOVIE_BLADE_RUNNER, ""); @@ -259,7 +260,7 @@ public class TheMovieDbApiTest { /** * Test of getMovieInfoImdb method, of class TheMovieDbApi. */ - @Test + //@Test public void testGetMovieInfoImdb() throws MovieDbException { logger.info("getMovieInfoImdb"); MovieDb result = tmdb.getMovieInfoImdb("tt0076759", "en-US"); @@ -269,7 +270,7 @@ public class TheMovieDbApiTest { /** * Test of getApiKey method, of class TheMovieDbApi. */ - @Test + //@Test public void testGetApiKey() { // Not required } @@ -277,7 +278,7 @@ public class TheMovieDbApiTest { /** * Test of getApiBase method, of class TheMovieDbApi. */ - @Test + //@Test public void testGetApiBase() { // Not required } @@ -285,7 +286,7 @@ public class TheMovieDbApiTest { /** * Test of getConfiguration method, of class TheMovieDbApi. */ - @Test + //@Test public void testGetConfiguration() { // Not required } @@ -293,7 +294,7 @@ public class TheMovieDbApiTest { /** * Test of searchPeople method, of class TheMovieDbApi. */ - @Test + //@Test public void testSearchPeople() throws MovieDbException { logger.info("searchPeople"); String personName = "Bruce Willis"; @@ -305,7 +306,7 @@ public class TheMovieDbApiTest { /** * Test of getPersonInfo method, of class TheMovieDbApi. */ - @Test + //@Test public void testGetPersonInfo() throws MovieDbException { logger.info("getPersonInfo"); Person result = tmdb.getPersonInfo(ID_PERSON_BRUCE_WILLIS); @@ -315,7 +316,7 @@ public class TheMovieDbApiTest { /** * Test of getPersonCredits method, of class TheMovieDbApi. */ - @Test + //@Test public void testGetPersonCredits() throws MovieDbException { logger.info("getPersonCredits"); @@ -326,7 +327,7 @@ public class TheMovieDbApiTest { /** * Test of getPersonImages method, of class TheMovieDbApi. */ - @Test + //@Test public void testGetPersonImages() throws MovieDbException { logger.info("getPersonImages"); @@ -337,7 +338,7 @@ public class TheMovieDbApiTest { /** * Test of getLatestMovie method, of class TheMovieDbApi. */ - @Test + //@Test public void testGetLatestMovie() throws MovieDbException { logger.info("getLatestMovie"); MovieDb result = tmdb.getLatestMovie(); @@ -348,7 +349,7 @@ public class TheMovieDbApiTest { /** * Test of compareMovies method, of class TheMovieDbApi. */ - @Test + //@Test public void testCompareMovies() { // Not required } @@ -356,7 +357,7 @@ public class TheMovieDbApiTest { /** * Test of setProxy method, of class TheMovieDbApi. */ - @Test + //@Test public void testSetProxy() { // Not required } @@ -364,7 +365,7 @@ public class TheMovieDbApiTest { /** * Test of setTimeout method, of class TheMovieDbApi. */ - @Test + //@Test public void testSetTimeout() { // Not required } @@ -372,7 +373,7 @@ public class TheMovieDbApiTest { /** * Test of getNowPlayingMovies method, of class TheMovieDbApi. */ - @Test + //@Test public void testGetNowPlayingMovies() throws MovieDbException { logger.info("getNowPlayingMovies"); List results = tmdb.getNowPlayingMovies("", 0); @@ -382,7 +383,7 @@ public class TheMovieDbApiTest { /** * Test of getPopularMovieList method, of class TheMovieDbApi. */ - @Test + //@Test public void testGetPopularMovieList() throws MovieDbException { logger.info("getPopularMovieList"); List results = tmdb.getPopularMovieList("", 0); @@ -392,7 +393,7 @@ public class TheMovieDbApiTest { /** * Test of getTopRatedMovies method, of class TheMovieDbApi. */ - @Test + //@Test public void testGetTopRatedMovies() throws MovieDbException { logger.info("getTopRatedMovies"); List results = tmdb.getTopRatedMovies("", 0); @@ -402,7 +403,7 @@ public class TheMovieDbApiTest { /** * Test of getCompanyInfo method, of class TheMovieDbApi. */ - @Test + //@Test public void testGetCompanyInfo() throws MovieDbException { logger.info("getCompanyInfo"); Company company = tmdb.getCompanyInfo(ID_COMPANY_LUCASFILM); @@ -412,7 +413,7 @@ public class TheMovieDbApiTest { /** * Test of getCompanyMovies method, of class TheMovieDbApi. */ - @Test + //@Test public void testGetCompanyMovies() throws MovieDbException { logger.info("getCompanyMovies"); List results = tmdb.getCompanyMovies(ID_COMPANY_LUCASFILM, "", 0); @@ -422,7 +423,7 @@ public class TheMovieDbApiTest { /** * Test of searchCompanies method, of class TheMovieDbApi. */ - @Test + //@Test public void testSearchCompanies() throws MovieDbException { logger.info("searchCompanies"); List results = tmdb.searchCompanies(COMPANY_NAME, 0); @@ -432,7 +433,7 @@ public class TheMovieDbApiTest { /** * Test of getSimilarMovies method, of class TheMovieDbApi. */ - @Test + //@Test public void testGetSimilarMovies() throws MovieDbException { logger.info("getSimilarMovies"); List results = tmdb.getSimilarMovies(ID_MOVIE_BLADE_RUNNER, "", 0); @@ -442,7 +443,7 @@ public class TheMovieDbApiTest { /** * Test of getGenreList method, of class TheMovieDbApi. */ - @Test + //@Test public void testGetGenreList() throws MovieDbException { logger.info("getGenreList"); List results = tmdb.getGenreList(""); @@ -452,7 +453,7 @@ public class TheMovieDbApiTest { /** * Test of getGenreMovies method, of class TheMovieDbApi. */ - @Test + //@Test public void testGetGenreMovies() throws MovieDbException { logger.info("getGenreMovies"); List results = tmdb.getGenreMovies(ID_GENRE_ACTION, "", 0); @@ -462,7 +463,7 @@ public class TheMovieDbApiTest { /** * Test of getUpcoming method, of class TheMovieDbApi. */ - @Test + //@Test public void testGetUpcoming() throws Exception { logger.info("getUpcoming"); List results = tmdb.getUpcoming("", 0); @@ -472,7 +473,7 @@ public class TheMovieDbApiTest { /** * Test of getCollectionImages method, of class TheMovieDbApi. */ - @Test + //@Test public void testGetCollectionImages() throws Exception { logger.info("getCollectionImages"); String language = ""; @@ -483,7 +484,7 @@ public class TheMovieDbApiTest { /** * Test of getAuthorisationToken method, of class TheMovieDbApi. */ - @Test + //@Test public void testGetAuthorisationToken() throws Exception { logger.info("getAuthorisationToken"); TokenAuthorisation result = tmdb.getAuthorisationToken(); @@ -496,7 +497,7 @@ public class TheMovieDbApiTest { * Test of getSessionToken method, of class TheMovieDbApi. */ // Cannot be tested without a HTTP authorisation: http://help.themoviedb.org/kb/api/user-authentication -// @Test +// //@Test public void testGetSessionToken() throws Exception { logger.info("getSessionToken"); TokenAuthorisation token = tmdb.getAuthorisationToken(); @@ -513,7 +514,7 @@ public class TheMovieDbApiTest { /** * Test of getGuestSessionToken method, of class TheMovieDbApi. */ - @Test + //@Test public void testGetGuestSessionToken() throws Exception { logger.info("getGuestSessionToken"); TokenSession result = tmdb.getGuestSessionToken(); @@ -521,7 +522,7 @@ public class TheMovieDbApiTest { assertTrue("Failed to get guest session", result.getSuccess()); } - @Test + //@Test public void testGetMovieLists() throws Exception { logger.info("getMovieLists"); String language = "en"; @@ -531,7 +532,6 @@ public class TheMovieDbApiTest { } // Do not test this until it is fixed -// @Test public void testGetMovieChanges() throws Exception { logger.info("getMovieChanges"); @@ -550,7 +550,7 @@ public class TheMovieDbApiTest { assertTrue("No results found", results.size() > 0); } - @Test + //@Test public void testGetPersonLatest() throws Exception { logger.info("getPersonLatest"); @@ -559,4 +559,44 @@ public class TheMovieDbApiTest { assertNotNull("No results found", result); assertTrue("No results found", StringUtils.isNotBlank(result.getName())); } + + /** + * Test of searchCollection method, of class TheMovieDbApi. + */ + //@Test + public void testSearchCollection() throws Exception { + logger.info("searchCollection"); + String query = "batman"; + String language = ""; + int page = 0; + List result = tmdb.searchCollection(query, language, page); + assertFalse("No collections found", result == null); + assertTrue("No collections found", result.size() > 0); + } + + /** + * Test of searchList method, of class TheMovieDbApi. + */ + //@Test + public void testSearchList() throws Exception { + System.out.println("searchList"); + String query = "watch"; + String language = ""; + int page = 0; + List result = tmdb.searchList(query, language, page); + assertFalse("No lists found", result == null); + assertTrue("No lists found", result.size() > 0); + } + + /** + * Test of searchKeyword method, of class TheMovieDbApi. + */ + @Test + public void testSearchKeyword() { + System.out.println("searchKeyword"); + TheMovieDbApi instance = null; + instance.searchKeyword(); + // TODO review the generated test code and remove the default call to fail. + fail("The test case is a prototype."); + } } From 7034be468165527604436d0ab116b1f7cd442c30 Mon Sep 17 00:00:00 2001 From: Omertron <> Date: Thu, 27 Dec 2012 21:50:28 +0000 Subject: [PATCH 172/207] Added keyword search --- .../omertron/themoviedbapi/TheMovieDbApi.java | 30 +++++- .../wrapper/WrapperKeywords.java | 100 ++++++++++++++++++ 2 files changed, 129 insertions(+), 1 deletion(-) create mode 100644 src/main/java/com/omertron/themoviedbapi/wrapper/WrapperKeywords.java diff --git a/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java b/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java index 2aec5a543..f405916c9 100644 --- a/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java +++ b/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java @@ -55,6 +55,7 @@ import com.omertron.themoviedbapi.wrapper.WrapperCompanyMovies; import com.omertron.themoviedbapi.wrapper.WrapperConfig; import com.omertron.themoviedbapi.wrapper.WrapperGenres; import com.omertron.themoviedbapi.wrapper.WrapperImages; +import com.omertron.themoviedbapi.wrapper.WrapperKeywords; import com.omertron.themoviedbapi.wrapper.WrapperMovie; import com.omertron.themoviedbapi.wrapper.WrapperMovieCasts; import com.omertron.themoviedbapi.wrapper.WrapperMovieKeywords; @@ -1469,7 +1470,34 @@ public class TheMovieDbApi { } } - public void searchKeyword() { + /** + * Search for keywords by name + * + * @param query + * @param page + * @throws MovieDbException + */ + public List searchKeyword(String query, int page) throws MovieDbException { + ApiUrl apiUrl = new ApiUrl(this, BASE_SEARCH, "keyword"); + + if (StringUtils.isNotBlank(query)) { + apiUrl.addArgument(PARAM_QUERY, query); + } + + if (page > 0) { + apiUrl.addArgument(PARAM_PAGE, Integer.toString(page)); + } + + URL url = apiUrl.buildUrl(); + + String webpage = WebBrowser.request(url); + try { + WrapperKeywords wrapper = mapper.readValue(webpage, WrapperKeywords.class); + return wrapper.getResults(); + } catch (IOException ex) { + logger.warn("Failed to find keyword: " + ex.getMessage()); + throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); + } } // // diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperKeywords.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperKeywords.java new file mode 100644 index 000000000..06714f0b9 --- /dev/null +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperKeywords.java @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2004-2012 Stuart Boston + * + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . + * + */ +package com.omertron.themoviedbapi.wrapper; + +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.omertron.themoviedbapi.model.Collection; +import com.omertron.themoviedbapi.model.Keyword; +import java.util.List; +import org.apache.log4j.Logger; + +/** + * + * @author stuart.boston + */ +public class WrapperKeywords { + /* + * Logger + */ + + private static final Logger logger = Logger.getLogger(WrapperKeywords.class); + /* + * Properties + */ + @JsonProperty("page") + private int page; + @JsonProperty("results") + private List results; + @JsonProperty("total_pages") + private int totalPages; + @JsonProperty("total_results") + private int totalResults; + + // + public int getPage() { + return page; + } + + public List getResults() { + return results; + } + + public int getTotalPages() { + return totalPages; + } + + public int getTotalResults() { + return totalResults; + } + // + + // + public void setPage(int page) { + this.page = page; + } + + public void setResults(List results) { + this.results = results; + } + + public void setTotalPages(int totalPages) { + this.totalPages = totalPages; + } + + public void setTotalResults(int totalResults) { + this.totalResults = totalResults; + } + // + + /** + * Handle unknown properties and print a message + * + * @param key + * @param value + */ + @JsonAnySetter + public void handleUnknown(String key, Object value) { + StringBuilder sb = new StringBuilder(); + sb.append("Unknown property: '").append(key); + sb.append("' value: '").append(value).append("'"); + logger.trace(sb.toString()); + } +} From 55b9760c3490613814260ddfb7455a186940bb3b Mon Sep 17 00:00:00 2001 From: Omertron <> Date: Thu, 27 Dec 2012 21:50:48 +0000 Subject: [PATCH 173/207] Updated test cases --- .../themoviedbapi/TheMovieDbApiTest.java | 98 +++++++++---------- 1 file changed, 49 insertions(+), 49 deletions(-) diff --git a/src/test/java/com/omertron/themoviedbapi/TheMovieDbApiTest.java b/src/test/java/com/omertron/themoviedbapi/TheMovieDbApiTest.java index a16718099..583524e1d 100644 --- a/src/test/java/com/omertron/themoviedbapi/TheMovieDbApiTest.java +++ b/src/test/java/com/omertron/themoviedbapi/TheMovieDbApiTest.java @@ -94,7 +94,7 @@ public class TheMovieDbApiTest { /** * Test of getConfiguration method, of class TheMovieDbApi. */ - //@Test + @Test public void testConfiguration() throws IOException { logger.info("Test Configuration"); @@ -110,7 +110,7 @@ public class TheMovieDbApiTest { /** * Test of searchMovie method, of class TheMovieDbApi. */ - //@Test + @Test public void testSearchMovie() throws MovieDbException { logger.info("searchMovie"); @@ -131,7 +131,7 @@ public class TheMovieDbApiTest { /** * Test of getMovieInfo method, of class TheMovieDbApi. */ - //@Test + @Test public void testGetMovieInfo() throws MovieDbException { logger.info("getMovieInfo"); String language = "en"; @@ -142,7 +142,7 @@ public class TheMovieDbApiTest { /** * Test of getMovieAlternativeTitles method, of class TheMovieDbApi. */ - //@Test + @Test public void testGetMovieAlternativeTitles() throws MovieDbException { logger.info("getMovieAlternativeTitles"); String country = ""; @@ -158,7 +158,7 @@ public class TheMovieDbApiTest { /** * Test of getMovieCasts method, of class TheMovieDbApi. */ - //@Test + @Test public void testGetMovieCasts() throws MovieDbException { logger.info("getMovieCasts"); List people = tmdb.getMovieCasts(ID_MOVIE_BLADE_RUNNER); @@ -185,7 +185,7 @@ public class TheMovieDbApiTest { /** * Test of getMovieImages method, of class TheMovieDbApi. */ - //@Test + @Test public void testGetMovieImages() throws MovieDbException { logger.info("getMovieImages"); String language = ""; @@ -196,7 +196,7 @@ public class TheMovieDbApiTest { /** * Test of getMovieKeywords method, of class TheMovieDbApi. */ - //@Test + @Test public void testGetMovieKeywords() throws MovieDbException { logger.info("getMovieKeywords"); List result = tmdb.getMovieKeywords(ID_MOVIE_BLADE_RUNNER); @@ -206,7 +206,7 @@ public class TheMovieDbApiTest { /** * Test of getMovieReleaseInfo method, of class TheMovieDbApi. */ - //@Test + @Test public void testGetMovieReleaseInfo() throws MovieDbException { logger.info("getMovieReleaseInfo"); List result = tmdb.getMovieReleaseInfo(ID_MOVIE_BLADE_RUNNER, ""); @@ -216,7 +216,7 @@ public class TheMovieDbApiTest { /** * Test of getMovieTrailers method, of class TheMovieDbApi. */ - //@Test + @Test public void testGetMovieTrailers() throws MovieDbException { logger.info("getMovieTrailers"); List result = tmdb.getMovieTrailers(ID_MOVIE_BLADE_RUNNER, ""); @@ -226,7 +226,7 @@ public class TheMovieDbApiTest { /** * Test of getMovieTranslations method, of class TheMovieDbApi. */ - //@Test + @Test public void testGetMovieTranslations() throws MovieDbException { logger.info("getMovieTranslations"); List result = tmdb.getMovieTranslations(ID_MOVIE_BLADE_RUNNER); @@ -236,7 +236,7 @@ public class TheMovieDbApiTest { /** * Test of getCollectionInfo method, of class TheMovieDbApi. */ - //@Test + @Test public void testGetCollectionInfo() throws MovieDbException { logger.info("getCollectionInfo"); String language = ""; @@ -249,7 +249,7 @@ public class TheMovieDbApiTest { * * @throws MovieDbException */ - //@Test + @Test public void testCreateImageUrl() throws MovieDbException { logger.info("createImageUrl"); MovieDb movie = tmdb.getMovieInfo(ID_MOVIE_BLADE_RUNNER, ""); @@ -260,7 +260,7 @@ public class TheMovieDbApiTest { /** * Test of getMovieInfoImdb method, of class TheMovieDbApi. */ - //@Test + @Test public void testGetMovieInfoImdb() throws MovieDbException { logger.info("getMovieInfoImdb"); MovieDb result = tmdb.getMovieInfoImdb("tt0076759", "en-US"); @@ -270,7 +270,7 @@ public class TheMovieDbApiTest { /** * Test of getApiKey method, of class TheMovieDbApi. */ - //@Test + @Test public void testGetApiKey() { // Not required } @@ -278,7 +278,7 @@ public class TheMovieDbApiTest { /** * Test of getApiBase method, of class TheMovieDbApi. */ - //@Test + @Test public void testGetApiBase() { // Not required } @@ -286,7 +286,7 @@ public class TheMovieDbApiTest { /** * Test of getConfiguration method, of class TheMovieDbApi. */ - //@Test + @Test public void testGetConfiguration() { // Not required } @@ -294,7 +294,7 @@ public class TheMovieDbApiTest { /** * Test of searchPeople method, of class TheMovieDbApi. */ - //@Test + @Test public void testSearchPeople() throws MovieDbException { logger.info("searchPeople"); String personName = "Bruce Willis"; @@ -306,7 +306,7 @@ public class TheMovieDbApiTest { /** * Test of getPersonInfo method, of class TheMovieDbApi. */ - //@Test + @Test public void testGetPersonInfo() throws MovieDbException { logger.info("getPersonInfo"); Person result = tmdb.getPersonInfo(ID_PERSON_BRUCE_WILLIS); @@ -316,7 +316,7 @@ public class TheMovieDbApiTest { /** * Test of getPersonCredits method, of class TheMovieDbApi. */ - //@Test + @Test public void testGetPersonCredits() throws MovieDbException { logger.info("getPersonCredits"); @@ -327,7 +327,7 @@ public class TheMovieDbApiTest { /** * Test of getPersonImages method, of class TheMovieDbApi. */ - //@Test + @Test public void testGetPersonImages() throws MovieDbException { logger.info("getPersonImages"); @@ -338,7 +338,7 @@ public class TheMovieDbApiTest { /** * Test of getLatestMovie method, of class TheMovieDbApi. */ - //@Test + @Test public void testGetLatestMovie() throws MovieDbException { logger.info("getLatestMovie"); MovieDb result = tmdb.getLatestMovie(); @@ -349,7 +349,7 @@ public class TheMovieDbApiTest { /** * Test of compareMovies method, of class TheMovieDbApi. */ - //@Test + @Test public void testCompareMovies() { // Not required } @@ -357,7 +357,7 @@ public class TheMovieDbApiTest { /** * Test of setProxy method, of class TheMovieDbApi. */ - //@Test + @Test public void testSetProxy() { // Not required } @@ -365,7 +365,7 @@ public class TheMovieDbApiTest { /** * Test of setTimeout method, of class TheMovieDbApi. */ - //@Test + @Test public void testSetTimeout() { // Not required } @@ -373,7 +373,7 @@ public class TheMovieDbApiTest { /** * Test of getNowPlayingMovies method, of class TheMovieDbApi. */ - //@Test + @Test public void testGetNowPlayingMovies() throws MovieDbException { logger.info("getNowPlayingMovies"); List results = tmdb.getNowPlayingMovies("", 0); @@ -383,7 +383,7 @@ public class TheMovieDbApiTest { /** * Test of getPopularMovieList method, of class TheMovieDbApi. */ - //@Test + @Test public void testGetPopularMovieList() throws MovieDbException { logger.info("getPopularMovieList"); List results = tmdb.getPopularMovieList("", 0); @@ -393,7 +393,7 @@ public class TheMovieDbApiTest { /** * Test of getTopRatedMovies method, of class TheMovieDbApi. */ - //@Test + @Test public void testGetTopRatedMovies() throws MovieDbException { logger.info("getTopRatedMovies"); List results = tmdb.getTopRatedMovies("", 0); @@ -403,7 +403,7 @@ public class TheMovieDbApiTest { /** * Test of getCompanyInfo method, of class TheMovieDbApi. */ - //@Test + @Test public void testGetCompanyInfo() throws MovieDbException { logger.info("getCompanyInfo"); Company company = tmdb.getCompanyInfo(ID_COMPANY_LUCASFILM); @@ -413,7 +413,7 @@ public class TheMovieDbApiTest { /** * Test of getCompanyMovies method, of class TheMovieDbApi. */ - //@Test + @Test public void testGetCompanyMovies() throws MovieDbException { logger.info("getCompanyMovies"); List results = tmdb.getCompanyMovies(ID_COMPANY_LUCASFILM, "", 0); @@ -423,7 +423,7 @@ public class TheMovieDbApiTest { /** * Test of searchCompanies method, of class TheMovieDbApi. */ - //@Test + @Test public void testSearchCompanies() throws MovieDbException { logger.info("searchCompanies"); List results = tmdb.searchCompanies(COMPANY_NAME, 0); @@ -433,7 +433,7 @@ public class TheMovieDbApiTest { /** * Test of getSimilarMovies method, of class TheMovieDbApi. */ - //@Test + @Test public void testGetSimilarMovies() throws MovieDbException { logger.info("getSimilarMovies"); List results = tmdb.getSimilarMovies(ID_MOVIE_BLADE_RUNNER, "", 0); @@ -443,7 +443,7 @@ public class TheMovieDbApiTest { /** * Test of getGenreList method, of class TheMovieDbApi. */ - //@Test + @Test public void testGetGenreList() throws MovieDbException { logger.info("getGenreList"); List results = tmdb.getGenreList(""); @@ -453,7 +453,7 @@ public class TheMovieDbApiTest { /** * Test of getGenreMovies method, of class TheMovieDbApi. */ - //@Test + @Test public void testGetGenreMovies() throws MovieDbException { logger.info("getGenreMovies"); List results = tmdb.getGenreMovies(ID_GENRE_ACTION, "", 0); @@ -463,7 +463,7 @@ public class TheMovieDbApiTest { /** * Test of getUpcoming method, of class TheMovieDbApi. */ - //@Test + @Test public void testGetUpcoming() throws Exception { logger.info("getUpcoming"); List results = tmdb.getUpcoming("", 0); @@ -473,7 +473,7 @@ public class TheMovieDbApiTest { /** * Test of getCollectionImages method, of class TheMovieDbApi. */ - //@Test + @Test public void testGetCollectionImages() throws Exception { logger.info("getCollectionImages"); String language = ""; @@ -484,7 +484,7 @@ public class TheMovieDbApiTest { /** * Test of getAuthorisationToken method, of class TheMovieDbApi. */ - //@Test + @Test public void testGetAuthorisationToken() throws Exception { logger.info("getAuthorisationToken"); TokenAuthorisation result = tmdb.getAuthorisationToken(); @@ -497,7 +497,6 @@ public class TheMovieDbApiTest { * Test of getSessionToken method, of class TheMovieDbApi. */ // Cannot be tested without a HTTP authorisation: http://help.themoviedb.org/kb/api/user-authentication -// //@Test public void testGetSessionToken() throws Exception { logger.info("getSessionToken"); TokenAuthorisation token = tmdb.getAuthorisationToken(); @@ -514,7 +513,7 @@ public class TheMovieDbApiTest { /** * Test of getGuestSessionToken method, of class TheMovieDbApi. */ - //@Test + @Test public void testGetGuestSessionToken() throws Exception { logger.info("getGuestSessionToken"); TokenSession result = tmdb.getGuestSessionToken(); @@ -522,7 +521,7 @@ public class TheMovieDbApiTest { assertTrue("Failed to get guest session", result.getSuccess()); } - //@Test + @Test public void testGetMovieLists() throws Exception { logger.info("getMovieLists"); String language = "en"; @@ -550,7 +549,7 @@ public class TheMovieDbApiTest { assertTrue("No results found", results.size() > 0); } - //@Test + @Test public void testGetPersonLatest() throws Exception { logger.info("getPersonLatest"); @@ -563,7 +562,7 @@ public class TheMovieDbApiTest { /** * Test of searchCollection method, of class TheMovieDbApi. */ - //@Test + @Test public void testSearchCollection() throws Exception { logger.info("searchCollection"); String query = "batman"; @@ -577,9 +576,9 @@ public class TheMovieDbApiTest { /** * Test of searchList method, of class TheMovieDbApi. */ - //@Test + @Test public void testSearchList() throws Exception { - System.out.println("searchList"); + logger.info("searchList"); String query = "watch"; String language = ""; int page = 0; @@ -592,11 +591,12 @@ public class TheMovieDbApiTest { * Test of searchKeyword method, of class TheMovieDbApi. */ @Test - public void testSearchKeyword() { - System.out.println("searchKeyword"); - TheMovieDbApi instance = null; - instance.searchKeyword(); - // TODO review the generated test code and remove the default call to fail. - fail("The test case is a prototype."); + public void testSearchKeyword() throws Exception { + logger.info("searchKeyword"); + String query = "action"; + int page = 0; + List result = tmdb.searchKeyword(query, page); + assertFalse("No keywords found", result == null); + assertTrue("No keywords found", result.size() > 0); } } From 3029bf408692a9c249077848c552343dded9839a Mon Sep 17 00:00:00 2001 From: Omertron <> Date: Tue, 1 Jan 2013 07:28:38 +0000 Subject: [PATCH 174/207] Updated copyright date --- src/main/java/com/omertron/themoviedbapi/MovieDbException.java | 2 +- src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java | 2 +- .../java/com/omertron/themoviedbapi/model/AlternativeTitle.java | 2 +- src/main/java/com/omertron/themoviedbapi/model/Artwork.java | 2 +- src/main/java/com/omertron/themoviedbapi/model/ArtworkType.java | 2 +- src/main/java/com/omertron/themoviedbapi/model/ChangeItem.java | 2 +- src/main/java/com/omertron/themoviedbapi/model/ChangeValue.java | 2 +- src/main/java/com/omertron/themoviedbapi/model/Collection.java | 2 +- .../java/com/omertron/themoviedbapi/model/CollectionInfo.java | 2 +- src/main/java/com/omertron/themoviedbapi/model/Company.java | 2 +- src/main/java/com/omertron/themoviedbapi/model/Genre.java | 2 +- src/main/java/com/omertron/themoviedbapi/model/Keyword.java | 2 +- src/main/java/com/omertron/themoviedbapi/model/Language.java | 2 +- .../java/com/omertron/themoviedbapi/model/MovieChanges.java | 2 +- src/main/java/com/omertron/themoviedbapi/model/MovieDb.java | 2 +- src/main/java/com/omertron/themoviedbapi/model/MovieList.java | 2 +- src/main/java/com/omertron/themoviedbapi/model/Person.java | 2 +- src/main/java/com/omertron/themoviedbapi/model/PersonCast.java | 2 +- .../java/com/omertron/themoviedbapi/model/PersonCredit.java | 2 +- src/main/java/com/omertron/themoviedbapi/model/PersonCrew.java | 2 +- src/main/java/com/omertron/themoviedbapi/model/PersonType.java | 2 +- .../com/omertron/themoviedbapi/model/ProductionCompany.java | 2 +- .../com/omertron/themoviedbapi/model/ProductionCountry.java | 2 +- src/main/java/com/omertron/themoviedbapi/model/ReleaseInfo.java | 2 +- src/main/java/com/omertron/themoviedbapi/model/StatusCode.java | 2 +- .../com/omertron/themoviedbapi/model/TmdbConfiguration.java | 2 +- .../com/omertron/themoviedbapi/model/TokenAuthorisation.java | 2 +- .../java/com/omertron/themoviedbapi/model/TokenSession.java | 2 +- src/main/java/com/omertron/themoviedbapi/model/Trailer.java | 2 +- src/main/java/com/omertron/themoviedbapi/model/Translation.java | 2 +- src/main/java/com/omertron/themoviedbapi/tools/ApiUrl.java | 2 +- .../java/com/omertron/themoviedbapi/tools/FilteringLayout.java | 2 +- src/main/java/com/omertron/themoviedbapi/tools/WebBrowser.java | 2 +- .../themoviedbapi/wrapper/WrapperAlternativeTitles.java | 2 +- .../java/com/omertron/themoviedbapi/wrapper/WrapperChanges.java | 2 +- .../com/omertron/themoviedbapi/wrapper/WrapperCollection.java | 2 +- .../java/com/omertron/themoviedbapi/wrapper/WrapperCompany.java | 2 +- .../omertron/themoviedbapi/wrapper/WrapperCompanyMovies.java | 2 +- .../java/com/omertron/themoviedbapi/wrapper/WrapperConfig.java | 2 +- .../java/com/omertron/themoviedbapi/wrapper/WrapperGenres.java | 2 +- .../java/com/omertron/themoviedbapi/wrapper/WrapperImages.java | 2 +- .../com/omertron/themoviedbapi/wrapper/WrapperKeywords.java | 2 +- .../java/com/omertron/themoviedbapi/wrapper/WrapperMovie.java | 2 +- .../com/omertron/themoviedbapi/wrapper/WrapperMovieCasts.java | 2 +- .../omertron/themoviedbapi/wrapper/WrapperMovieKeywords.java | 2 +- .../com/omertron/themoviedbapi/wrapper/WrapperMovieList.java | 2 +- .../java/com/omertron/themoviedbapi/wrapper/WrapperPerson.java | 2 +- .../omertron/themoviedbapi/wrapper/WrapperPersonCredits.java | 2 +- .../com/omertron/themoviedbapi/wrapper/WrapperReleaseInfo.java | 2 +- .../com/omertron/themoviedbapi/wrapper/WrapperTrailers.java | 2 +- .../com/omertron/themoviedbapi/wrapper/WrapperTranslations.java | 2 +- src/test/java/com/omertron/themoviedbapi/TheMovieDbApiTest.java | 2 +- 52 files changed, 52 insertions(+), 52 deletions(-) diff --git a/src/main/java/com/omertron/themoviedbapi/MovieDbException.java b/src/main/java/com/omertron/themoviedbapi/MovieDbException.java index 90bba1a66..59930a6fd 100644 --- a/src/main/java/com/omertron/themoviedbapi/MovieDbException.java +++ b/src/main/java/com/omertron/themoviedbapi/MovieDbException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2012 Stuart Boston + * Copyright (c) 2004-2013 Stuart Boston * * This file is part of TheMovieDB API. * diff --git a/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java b/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java index f405916c9..38e277d86 100644 --- a/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java +++ b/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2012 Stuart Boston + * Copyright (c) 2004-2013 Stuart Boston * * This file is part of TheMovieDB API. * diff --git a/src/main/java/com/omertron/themoviedbapi/model/AlternativeTitle.java b/src/main/java/com/omertron/themoviedbapi/model/AlternativeTitle.java index 9dd3f4366..5a4ea1652 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/AlternativeTitle.java +++ b/src/main/java/com/omertron/themoviedbapi/model/AlternativeTitle.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2012 Stuart Boston + * Copyright (c) 2004-2013 Stuart Boston * * This file is part of TheMovieDB API. * diff --git a/src/main/java/com/omertron/themoviedbapi/model/Artwork.java b/src/main/java/com/omertron/themoviedbapi/model/Artwork.java index dd9b30a13..1cee537ab 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/Artwork.java +++ b/src/main/java/com/omertron/themoviedbapi/model/Artwork.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2012 Stuart Boston + * Copyright (c) 2004-2013 Stuart Boston * * This file is part of TheMovieDB API. * diff --git a/src/main/java/com/omertron/themoviedbapi/model/ArtworkType.java b/src/main/java/com/omertron/themoviedbapi/model/ArtworkType.java index 963caae66..383c35a33 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/ArtworkType.java +++ b/src/main/java/com/omertron/themoviedbapi/model/ArtworkType.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2012 Stuart Boston + * Copyright (c) 2004-2013 Stuart Boston * * This file is part of TheMovieDB API. * diff --git a/src/main/java/com/omertron/themoviedbapi/model/ChangeItem.java b/src/main/java/com/omertron/themoviedbapi/model/ChangeItem.java index 09cc9fd17..9f065a544 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/ChangeItem.java +++ b/src/main/java/com/omertron/themoviedbapi/model/ChangeItem.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2012 Stuart Boston + * Copyright (c) 2004-2013 Stuart Boston * * This file is part of TheMovieDB API. * diff --git a/src/main/java/com/omertron/themoviedbapi/model/ChangeValue.java b/src/main/java/com/omertron/themoviedbapi/model/ChangeValue.java index a1120d773..f9e7b9d29 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/ChangeValue.java +++ b/src/main/java/com/omertron/themoviedbapi/model/ChangeValue.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2012 Stuart Boston + * Copyright (c) 2004-2013 Stuart Boston * * This file is part of TheMovieDB API. * diff --git a/src/main/java/com/omertron/themoviedbapi/model/Collection.java b/src/main/java/com/omertron/themoviedbapi/model/Collection.java index 10b47b668..19a018c29 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/Collection.java +++ b/src/main/java/com/omertron/themoviedbapi/model/Collection.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2012 Stuart Boston + * Copyright (c) 2004-2013 Stuart Boston * * This file is part of TheMovieDB API. * diff --git a/src/main/java/com/omertron/themoviedbapi/model/CollectionInfo.java b/src/main/java/com/omertron/themoviedbapi/model/CollectionInfo.java index 5b46377b9..1c7e5dbb0 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/CollectionInfo.java +++ b/src/main/java/com/omertron/themoviedbapi/model/CollectionInfo.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2012 Stuart Boston + * Copyright (c) 2004-2013 Stuart Boston * * This file is part of TheMovieDB API. * diff --git a/src/main/java/com/omertron/themoviedbapi/model/Company.java b/src/main/java/com/omertron/themoviedbapi/model/Company.java index 90377892d..036ec9284 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/Company.java +++ b/src/main/java/com/omertron/themoviedbapi/model/Company.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2012 Stuart Boston + * Copyright (c) 2004-2013 Stuart Boston * * This file is part of TheMovieDB API. * diff --git a/src/main/java/com/omertron/themoviedbapi/model/Genre.java b/src/main/java/com/omertron/themoviedbapi/model/Genre.java index d2d051b3b..1d66a304c 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/Genre.java +++ b/src/main/java/com/omertron/themoviedbapi/model/Genre.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2012 Stuart Boston + * Copyright (c) 2004-2013 Stuart Boston * * This file is part of TheMovieDB API. * diff --git a/src/main/java/com/omertron/themoviedbapi/model/Keyword.java b/src/main/java/com/omertron/themoviedbapi/model/Keyword.java index 9a6f83bb0..c0d427e15 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/Keyword.java +++ b/src/main/java/com/omertron/themoviedbapi/model/Keyword.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2012 Stuart Boston + * Copyright (c) 2004-2013 Stuart Boston * * This file is part of TheMovieDB API. * diff --git a/src/main/java/com/omertron/themoviedbapi/model/Language.java b/src/main/java/com/omertron/themoviedbapi/model/Language.java index 38468370c..6bc47fb80 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/Language.java +++ b/src/main/java/com/omertron/themoviedbapi/model/Language.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2012 Stuart Boston + * Copyright (c) 2004-2013 Stuart Boston * * This file is part of TheMovieDB API. * diff --git a/src/main/java/com/omertron/themoviedbapi/model/MovieChanges.java b/src/main/java/com/omertron/themoviedbapi/model/MovieChanges.java index 93f21588d..4c5f76bbf 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/MovieChanges.java +++ b/src/main/java/com/omertron/themoviedbapi/model/MovieChanges.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2012 Stuart Boston + * Copyright (c) 2004-2013 Stuart Boston * * This file is part of TheMovieDB API. * diff --git a/src/main/java/com/omertron/themoviedbapi/model/MovieDb.java b/src/main/java/com/omertron/themoviedbapi/model/MovieDb.java index a45ec8ff6..8b4b4f30a 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/MovieDb.java +++ b/src/main/java/com/omertron/themoviedbapi/model/MovieDb.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2012 Stuart Boston + * Copyright (c) 2004-2013 Stuart Boston * * This file is part of TheMovieDB API. * diff --git a/src/main/java/com/omertron/themoviedbapi/model/MovieList.java b/src/main/java/com/omertron/themoviedbapi/model/MovieList.java index 540ba3a3e..0695a9c37 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/MovieList.java +++ b/src/main/java/com/omertron/themoviedbapi/model/MovieList.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2012 Stuart Boston + * Copyright (c) 2004-2013 Stuart Boston * * This file is part of TheMovieDB API. * diff --git a/src/main/java/com/omertron/themoviedbapi/model/Person.java b/src/main/java/com/omertron/themoviedbapi/model/Person.java index f333c6e8e..5f8fe967e 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/Person.java +++ b/src/main/java/com/omertron/themoviedbapi/model/Person.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2012 Stuart Boston + * Copyright (c) 2004-2013 Stuart Boston * * This file is part of TheMovieDB API. * diff --git a/src/main/java/com/omertron/themoviedbapi/model/PersonCast.java b/src/main/java/com/omertron/themoviedbapi/model/PersonCast.java index 1f114bbba..c4cdb5f04 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/PersonCast.java +++ b/src/main/java/com/omertron/themoviedbapi/model/PersonCast.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2012 Stuart Boston + * Copyright (c) 2004-2013 Stuart Boston * * This file is part of TheMovieDB API. * diff --git a/src/main/java/com/omertron/themoviedbapi/model/PersonCredit.java b/src/main/java/com/omertron/themoviedbapi/model/PersonCredit.java index 93cdb8f9c..e20c93783 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/PersonCredit.java +++ b/src/main/java/com/omertron/themoviedbapi/model/PersonCredit.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2012 Stuart Boston + * Copyright (c) 2004-2013 Stuart Boston * * This file is part of TheMovieDB API. * diff --git a/src/main/java/com/omertron/themoviedbapi/model/PersonCrew.java b/src/main/java/com/omertron/themoviedbapi/model/PersonCrew.java index a8a2ced7c..be4c04fa9 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/PersonCrew.java +++ b/src/main/java/com/omertron/themoviedbapi/model/PersonCrew.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2012 Stuart Boston + * Copyright (c) 2004-2013 Stuart Boston * * This file is part of TheMovieDB API. * diff --git a/src/main/java/com/omertron/themoviedbapi/model/PersonType.java b/src/main/java/com/omertron/themoviedbapi/model/PersonType.java index 8e438b579..1145578f8 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/PersonType.java +++ b/src/main/java/com/omertron/themoviedbapi/model/PersonType.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2012 Stuart Boston + * Copyright (c) 2004-2013 Stuart Boston * * This file is part of TheMovieDB API. * diff --git a/src/main/java/com/omertron/themoviedbapi/model/ProductionCompany.java b/src/main/java/com/omertron/themoviedbapi/model/ProductionCompany.java index 508bc8460..5f50e6cee 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/ProductionCompany.java +++ b/src/main/java/com/omertron/themoviedbapi/model/ProductionCompany.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2012 Stuart Boston + * Copyright (c) 2004-2013 Stuart Boston * * This file is part of TheMovieDB API. * diff --git a/src/main/java/com/omertron/themoviedbapi/model/ProductionCountry.java b/src/main/java/com/omertron/themoviedbapi/model/ProductionCountry.java index 688bd6973..bae5b7335 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/ProductionCountry.java +++ b/src/main/java/com/omertron/themoviedbapi/model/ProductionCountry.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2012 Stuart Boston + * Copyright (c) 2004-2013 Stuart Boston * * This file is part of TheMovieDB API. * diff --git a/src/main/java/com/omertron/themoviedbapi/model/ReleaseInfo.java b/src/main/java/com/omertron/themoviedbapi/model/ReleaseInfo.java index 20e318539..2a5be9662 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/ReleaseInfo.java +++ b/src/main/java/com/omertron/themoviedbapi/model/ReleaseInfo.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2012 Stuart Boston + * Copyright (c) 2004-2013 Stuart Boston * * This file is part of TheMovieDB API. * diff --git a/src/main/java/com/omertron/themoviedbapi/model/StatusCode.java b/src/main/java/com/omertron/themoviedbapi/model/StatusCode.java index a5ee08263..8e7318715 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/StatusCode.java +++ b/src/main/java/com/omertron/themoviedbapi/model/StatusCode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2012 Stuart Boston + * Copyright (c) 2004-2013 Stuart Boston * * This file is part of TheMovieDB API. * diff --git a/src/main/java/com/omertron/themoviedbapi/model/TmdbConfiguration.java b/src/main/java/com/omertron/themoviedbapi/model/TmdbConfiguration.java index 2f2e013f9..c1f0bb009 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/TmdbConfiguration.java +++ b/src/main/java/com/omertron/themoviedbapi/model/TmdbConfiguration.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2012 Stuart Boston + * Copyright (c) 2004-2013 Stuart Boston * * This file is part of TheMovieDB API. * diff --git a/src/main/java/com/omertron/themoviedbapi/model/TokenAuthorisation.java b/src/main/java/com/omertron/themoviedbapi/model/TokenAuthorisation.java index aeabb0df9..a0d7734f6 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/TokenAuthorisation.java +++ b/src/main/java/com/omertron/themoviedbapi/model/TokenAuthorisation.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2012 Stuart Boston + * Copyright (c) 2004-2013 Stuart Boston * * This file is part of TheMovieDB API. * diff --git a/src/main/java/com/omertron/themoviedbapi/model/TokenSession.java b/src/main/java/com/omertron/themoviedbapi/model/TokenSession.java index 6863afd03..4142cc816 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/TokenSession.java +++ b/src/main/java/com/omertron/themoviedbapi/model/TokenSession.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2012 Stuart Boston + * Copyright (c) 2004-2013 Stuart Boston * * This file is part of TheMovieDB API. * diff --git a/src/main/java/com/omertron/themoviedbapi/model/Trailer.java b/src/main/java/com/omertron/themoviedbapi/model/Trailer.java index 98f7ab164..008862dce 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/Trailer.java +++ b/src/main/java/com/omertron/themoviedbapi/model/Trailer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2012 Stuart Boston + * Copyright (c) 2004-2013 Stuart Boston * * This file is part of TheMovieDB API. * diff --git a/src/main/java/com/omertron/themoviedbapi/model/Translation.java b/src/main/java/com/omertron/themoviedbapi/model/Translation.java index 1bdf9dfb1..986ac28e3 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/Translation.java +++ b/src/main/java/com/omertron/themoviedbapi/model/Translation.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2012 Stuart Boston + * Copyright (c) 2004-2013 Stuart Boston * * This file is part of TheMovieDB API. * diff --git a/src/main/java/com/omertron/themoviedbapi/tools/ApiUrl.java b/src/main/java/com/omertron/themoviedbapi/tools/ApiUrl.java index 1759028d1..ec2021951 100644 --- a/src/main/java/com/omertron/themoviedbapi/tools/ApiUrl.java +++ b/src/main/java/com/omertron/themoviedbapi/tools/ApiUrl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2012 Stuart Boston + * Copyright (c) 2004-2013 Stuart Boston * * This file is part of TheMovieDB API. * diff --git a/src/main/java/com/omertron/themoviedbapi/tools/FilteringLayout.java b/src/main/java/com/omertron/themoviedbapi/tools/FilteringLayout.java index d8a29817f..b45d9c47b 100644 --- a/src/main/java/com/omertron/themoviedbapi/tools/FilteringLayout.java +++ b/src/main/java/com/omertron/themoviedbapi/tools/FilteringLayout.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2012 Stuart Boston + * Copyright (c) 2004-2013 Stuart Boston * * This file is part of TheMovieDB API. * diff --git a/src/main/java/com/omertron/themoviedbapi/tools/WebBrowser.java b/src/main/java/com/omertron/themoviedbapi/tools/WebBrowser.java index 10b470bab..d17f94e5e 100644 --- a/src/main/java/com/omertron/themoviedbapi/tools/WebBrowser.java +++ b/src/main/java/com/omertron/themoviedbapi/tools/WebBrowser.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2012 Stuart Boston + * Copyright (c) 2004-2013 Stuart Boston * * This file is part of TheMovieDB API. * diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperAlternativeTitles.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperAlternativeTitles.java index 9c60a0a54..08436c8a4 100644 --- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperAlternativeTitles.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperAlternativeTitles.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2012 Stuart Boston + * Copyright (c) 2004-2013 Stuart Boston * * This file is part of TheMovieDB API. * diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperChanges.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperChanges.java index 69a217463..d15d862e7 100644 --- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperChanges.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperChanges.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2012 Stuart Boston + * Copyright (c) 2004-2013 Stuart Boston * * This file is part of TheMovieDB API. * diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperCollection.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperCollection.java index f7b2a49ce..6cc493b2d 100644 --- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperCollection.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperCollection.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2012 Stuart Boston + * Copyright (c) 2004-2013 Stuart Boston * * This file is part of TheMovieDB API. * diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperCompany.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperCompany.java index 9ea1d6ed2..bb076f7ac 100644 --- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperCompany.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperCompany.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2012 Stuart Boston + * Copyright (c) 2004-2013 Stuart Boston * * This file is part of TheMovieDB API. * diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperCompanyMovies.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperCompanyMovies.java index c77306355..0aee40c4f 100644 --- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperCompanyMovies.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperCompanyMovies.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2012 Stuart Boston + * Copyright (c) 2004-2013 Stuart Boston * * This file is part of TheMovieDB API. * diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperConfig.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperConfig.java index 0c94af6c7..88da08c7d 100644 --- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperConfig.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperConfig.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2012 Stuart Boston + * Copyright (c) 2004-2013 Stuart Boston * * This file is part of TheMovieDB API. * diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperGenres.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperGenres.java index 0360c660c..eafecb9e4 100644 --- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperGenres.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperGenres.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2012 Stuart Boston + * Copyright (c) 2004-2013 Stuart Boston * * This file is part of TheMovieDB API. * diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperImages.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperImages.java index fba5d669e..089f68a16 100644 --- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperImages.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperImages.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2012 Stuart Boston + * Copyright (c) 2004-2013 Stuart Boston * * This file is part of TheMovieDB API. * diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperKeywords.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperKeywords.java index 06714f0b9..b10833a25 100644 --- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperKeywords.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperKeywords.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2012 Stuart Boston + * Copyright (c) 2004-2013 Stuart Boston * * This file is part of TheMovieDB API. * diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovie.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovie.java index 5c1f3f503..7fd99fae9 100644 --- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovie.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovie.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2012 Stuart Boston + * Copyright (c) 2004-2013 Stuart Boston * * This file is part of TheMovieDB API. * diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovieCasts.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovieCasts.java index b7396c774..350d45ef4 100644 --- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovieCasts.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovieCasts.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2012 Stuart Boston + * Copyright (c) 2004-2013 Stuart Boston * * This file is part of TheMovieDB API. * diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovieKeywords.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovieKeywords.java index 660322d64..ef920be4d 100644 --- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovieKeywords.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovieKeywords.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2012 Stuart Boston + * Copyright (c) 2004-2013 Stuart Boston * * This file is part of TheMovieDB API. * diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovieList.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovieList.java index 80f025b31..a080dab10 100644 --- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovieList.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovieList.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2012 Stuart Boston + * Copyright (c) 2004-2013 Stuart Boston * * This file is part of TheMovieDB API. * diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperPerson.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperPerson.java index 15617f917..cde1e8f6e 100644 --- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperPerson.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperPerson.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2012 Stuart Boston + * Copyright (c) 2004-2013 Stuart Boston * * This file is part of TheMovieDB API. * diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperPersonCredits.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperPersonCredits.java index 4b7072233..82d47cae9 100644 --- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperPersonCredits.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperPersonCredits.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2012 Stuart Boston + * Copyright (c) 2004-2013 Stuart Boston * * This file is part of TheMovieDB API. * diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperReleaseInfo.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperReleaseInfo.java index a353af470..26cfa455a 100644 --- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperReleaseInfo.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperReleaseInfo.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2012 Stuart Boston + * Copyright (c) 2004-2013 Stuart Boston * * This file is part of TheMovieDB API. * diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperTrailers.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperTrailers.java index a37aa0926..08a0453ad 100644 --- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperTrailers.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperTrailers.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2012 Stuart Boston + * Copyright (c) 2004-2013 Stuart Boston * * This file is part of TheMovieDB API. * diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperTranslations.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperTranslations.java index e7c70d2f9..00b2487e7 100644 --- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperTranslations.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperTranslations.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2012 Stuart Boston + * Copyright (c) 2004-2013 Stuart Boston * * This file is part of TheMovieDB API. * diff --git a/src/test/java/com/omertron/themoviedbapi/TheMovieDbApiTest.java b/src/test/java/com/omertron/themoviedbapi/TheMovieDbApiTest.java index 583524e1d..225a10550 100644 --- a/src/test/java/com/omertron/themoviedbapi/TheMovieDbApiTest.java +++ b/src/test/java/com/omertron/themoviedbapi/TheMovieDbApiTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004-2012 Stuart Boston + * Copyright (c) 2004-2013 Stuart Boston * * This file is part of TheMovieDB API. * From 0f8731ffe508f60d13c4d5669b2df7d5cb80755a Mon Sep 17 00:00:00 2001 From: Omertron <> Date: Mon, 14 Jan 2013 19:52:07 +0000 Subject: [PATCH 175/207] Added accept for JSON to WebBrowser --- src/main/java/com/omertron/themoviedbapi/tools/WebBrowser.java | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main/java/com/omertron/themoviedbapi/tools/WebBrowser.java b/src/main/java/com/omertron/themoviedbapi/tools/WebBrowser.java index d17f94e5e..dc5afd59e 100644 --- a/src/main/java/com/omertron/themoviedbapi/tools/WebBrowser.java +++ b/src/main/java/com/omertron/themoviedbapi/tools/WebBrowser.java @@ -66,6 +66,7 @@ public final class WebBrowser { private static void populateBrowserProperties() { if (browserProperties.isEmpty()) { browserProperties.put("User-Agent", "Mozilla/5.25 Netscape/5.0 (Windows; I; Win95)"); + browserProperties.put("Accept", "application/json"); } } From 505b8c06dc8b3e7c6c69bc193adc9e463715def5 Mon Sep 17 00:00:00 2001 From: Omertron <> Date: Mon, 14 Jan 2013 20:15:20 +0000 Subject: [PATCH 176/207] Removed revision line from version.txt --- pom.xml | 476 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 238 insertions(+), 238 deletions(-) diff --git a/pom.xml b/pom.xml index d9e80e5c9..7f2eab836 100644 --- a/pom.xml +++ b/pom.xml @@ -1,238 +1,238 @@ - - 4.0.0 - - - org.sonatype.oss - oss-parent - 7 - - - - 3.0.3 - - - com.omertron - themoviedbapi - 3.4-SNAPSHOT - API-The MovieDB - jar - API for the TheMovieDb.org website - - - false - UTF-8 - UTF-8 - zip - - - - GitHub - https://github.com/Omertron/api-themoviedb/issues - - - - Hudson CI - http://jenkins.omertron.com/job/API-TheMovieDb/ - - - - scm:git:git@github.com:Omertron/api-themoviedb.git - scm:git:git@github.com:Omertron/api-themoviedb.git - scm:git:git@github.com:Omertron/api-themoviedb.git - - - - - - junit - junit - 4.11 - test - - - - log4j - log4j - 1.2.17 - - - - com.fasterxml.jackson.core - jackson-core - 2.1.2 - - - - com.fasterxml.jackson.core - jackson-annotations - 2.1.2 - - - - com.fasterxml.jackson.core - jackson-databind - 2.1.2 - - - - commons-codec - commons-codec - 1.7 - - - - org.apache.commons - commons-lang3 - 3.1 - - - - - - - release-sign-artifacts - - - performRelease - true - - - - - - maven-gpg-plugin - - - sign-artifacts - verify - - sign - - - - - - - - - - - - - org.codehaus.mojo - buildnumber-maven-plugin - 1.1 - - true - 0000 - {0,date,yyyy-MM-dd HH:mm:ss} - - - - validate - - create - - - - - - - org.apache.maven.plugins - maven-compiler-plugin - 2.5.1 - - 1.6 - 1.6 - true - true - - - - - - org.apache.maven.plugins - maven-jar-plugin - 2.4 - - - - ${project.name} - ${project.version} - ${buildNumber} - ${timestamp} - - - - - - - - org.apache.maven.plugins - maven-surefire-plugin - 2.12.3 - - ${skipTests} - - - - - org.apache.maven.plugins - maven-antrun-plugin - 1.7 - - - create-version-txt - generate-resources - - - - - - - - Writing version file: ${version_file} - ${header_line} - ${build_date_line} - ${version_line} - ${revision_line} - - - - run - - - - - - org.apache.maven.plugins - maven-assembly-plugin - 2.3 - - - distro-assembly - package - - single - - - - src/main/resources/bin.xml - - - - - - - org.codehaus.mojo - versions-maven-plugin - 1.3.1 - - - - ${project.artifactId}-${project.version}-r${buildNumber} - - - - - + + 4.0.0 + + + org.sonatype.oss + oss-parent + 7 + + + + 3.0.3 + + + com.omertron + themoviedbapi + 3.4-SNAPSHOT + API-The MovieDB + jar + API for the TheMovieDb.org website + + + false + UTF-8 + UTF-8 + zip + + + + GitHub + https://github.com/Omertron/api-themoviedb/issues + + + + Hudson CI + http://jenkins.omertron.com/job/API-TheMovieDb/ + + + + scm:git:git@github.com:Omertron/api-themoviedb.git + scm:git:git@github.com:Omertron/api-themoviedb.git + scm:git:git@github.com:Omertron/api-themoviedb.git + + + + + + junit + junit + 4.11 + test + + + + log4j + log4j + 1.2.17 + + + + com.fasterxml.jackson.core + jackson-core + 2.1.2 + + + + com.fasterxml.jackson.core + jackson-annotations + 2.1.2 + + + + com.fasterxml.jackson.core + jackson-databind + 2.1.2 + + + + commons-codec + commons-codec + 1.7 + + + + org.apache.commons + commons-lang3 + 3.1 + + + + + + + release-sign-artifacts + + + performRelease + true + + + + + + maven-gpg-plugin + + + sign-artifacts + verify + + sign + + + + + + + + + + + + + org.codehaus.mojo + buildnumber-maven-plugin + 1.1 + + true + 0000 + {0,date,yyyy-MM-dd HH:mm:ss} + + + + validate + + create + + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 2.5.1 + + 1.6 + 1.6 + true + true + + + + + + org.apache.maven.plugins + maven-jar-plugin + 2.4 + + + + ${project.name} + ${project.version} + ${buildNumber} + ${timestamp} + + + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.12.3 + + ${skipTests} + + + + + org.apache.maven.plugins + maven-antrun-plugin + 1.7 + + + create-version-txt + generate-resources + + + + + + + + Writing version file: ${version_file} + ${header_line} + ${build_date_line} + ${version_line} + + + + + run + + + + + + org.apache.maven.plugins + maven-assembly-plugin + 2.3 + + + distro-assembly + package + + single + + + + src/main/resources/bin.xml + + + + + + + org.codehaus.mojo + versions-maven-plugin + 1.3.1 + + + + ${project.artifactId}-${project.version}-r${buildNumber} + + + + + From 50488f98b7532afaedf30fb66559db9be9744593 Mon Sep 17 00:00:00 2001 From: Stuart Boston Date: Mon, 28 Jan 2013 13:16:33 +0000 Subject: [PATCH 177/207] Added automatic site documentation to POM --- pom.xml | 182 ++++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 125 insertions(+), 57 deletions(-) diff --git a/pom.xml b/pom.xml index 7f2eab836..940192a4c 100644 --- a/pom.xml +++ b/pom.xml @@ -14,16 +14,47 @@ com.omertron themoviedbapi 3.4-SNAPSHOT - API-The MovieDB jar - API for the TheMovieDb.org website - - false - UTF-8 - UTF-8 - zip - + API-The MovieDB + API for the TheMovieDb.org website + https://github.com/Omertron/api-themoviedb + 2012 + + + + Stuart Boston + omertron@gmail.com + omertron + http://omertron.com + 0 + + developer + + + + + + + GNU General Public License v3+ + http://www.gnu.org/licenses/gpl-3.0-standalone.html + repo + + + + + scm:git:git@github.com:Omertron/api-themoviedb.git + scm:git:git@github.com:Omertron/api-themoviedb.git + scm:git:git@github.com:Omertron/api-themoviedb.git + + + + + github-project-site + GitHub Project Pages + gitsite:git@github.com/Omertron/api-themoviedb.git + + GitHub @@ -35,88 +66,55 @@ http://jenkins.omertron.com/job/API-TheMovieDb/ - - scm:git:git@github.com:Omertron/api-themoviedb.git - scm:git:git@github.com:Omertron/api-themoviedb.git - scm:git:git@github.com:Omertron/api-themoviedb.git - + + false + UTF-8 + UTF-8 + zip + - junit junit 4.11 test - log4j log4j 1.2.17 - com.fasterxml.jackson.core jackson-core 2.1.2 - com.fasterxml.jackson.core jackson-annotations 2.1.2 - com.fasterxml.jackson.core jackson-databind 2.1.2 - commons-codec commons-codec 1.7 - org.apache.commons commons-lang3 3.1 - - - - release-sign-artifacts - - - performRelease - true - - - - - - maven-gpg-plugin - - - sign-artifacts - verify - - sign - - - - - - - - - + ${project.artifactId}-${project.version}-r${buildNumber} + org.codehaus.mojo @@ -136,7 +134,6 @@ - org.apache.maven.plugins maven-compiler-plugin @@ -149,7 +146,6 @@ - org.apache.maven.plugins maven-jar-plugin @@ -165,17 +161,15 @@ - - org.apache.maven.plugins maven-surefire-plugin 2.12.3 + ${skipTests} - org.apache.maven.plugins maven-antrun-plugin @@ -228,11 +222,85 @@ versions-maven-plugin 1.3.1 + + org.apache.maven.plugins + maven-site-plugin + 3.2 + + + + org.apache.maven.plugins + maven-project-info-reports-plugin + 2.2 + + index + scm + issue-tracking + help + dependency-convergence + summary + dependency-management + dependencies + license + modules + + + + org.apache.maven.plugins + maven-javadoc-plugin + 2.9 + + + + - ${project.artifactId}-${project.version}-r${buildNumber} - - + + + org.apache.maven.scm + maven-scm-provider-gitexe + 1.4 + + + org.apache.maven.scm + maven-scm-manager-plexus + 1.4 + + + org.kathrynhuxtable.maven.wagon + wagon-gitsite + 0.3.1 + + + + + + release-sign-artifacts + + + performRelease + true + + + + + + maven-gpg-plugin + + + sign-artifacts + verify + + sign + + + + + + + + + From e59f724466d1be4425ab2dacfe6cf9fba454e061 Mon Sep 17 00:00:00 2001 From: Stuart Boston Date: Mon, 28 Jan 2013 13:47:05 +0000 Subject: [PATCH 179/207] Updated README --- README.md | 16 ++++++++++++++++ readme.txt | 9 --------- 2 files changed, 16 insertions(+), 9 deletions(-) create mode 100644 README.md delete mode 100644 readme.txt diff --git a/README.md b/README.md new file mode 100644 index 000000000..0cbf3b66a --- /dev/null +++ b/README.md @@ -0,0 +1,16 @@ +The Movie DB API +================ + +Author: Stuart Boston (Omertron AT Gmail DOT com) + +This API uses the TheMovieDB.org API as specified here http://api.themoviedb.org/ + +Originally written for use by YetAnotherMovieJukebox (YAMJ) http://code.google.com/p/moviejukebox/ +But anyone can feel free to use it for other projects as well. + +TheMovieDB.org is an excellent open database for movie and film content. I encourage you to check it out and contribute to keep it growing. +http://www.themoviedb.org + +Project Documentation +--------------------- +The automatically generated documentation can be found [HERE](http://omertron.github.com/api-themoviedb/) diff --git a/readme.txt b/readme.txt deleted file mode 100644 index fa139d184..000000000 --- a/readme.txt +++ /dev/null @@ -1,9 +0,0 @@ -Author: Stuart Boston (Omertron AT Gmail DOT com) - -Originally written for use by YetAnotherMovieJukebox (YAMJ) http://code.google.com/p/moviejukebox/ -But anyone can feel free to use it for other projects as well. - -This uses TheMovieDB.org API as specified here http://api.themoviedb.org/ -TheMovieDB.org is an excellent open database for movie and film content. I encourage you to check it -out and contribute to keep it growing. -http://www.themoviedb.org \ No newline at end of file From 1d91a557eb251ba81a11e7faf2fc08a7d6282c41 Mon Sep 17 00:00:00 2001 From: Stuart Boston Date: Mon, 28 Jan 2013 14:48:55 +0000 Subject: [PATCH 180/207] Updated POM Versions --- pom.xml | 35 ++++++++++++++++++++++++++++++----- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/pom.xml b/pom.xml index 940192a4c..c000d6d7c 100644 --- a/pom.xml +++ b/pom.xml @@ -119,7 +119,7 @@ org.codehaus.mojo buildnumber-maven-plugin - 1.1 + 1.2 true 0000 @@ -137,7 +137,7 @@ org.apache.maven.plugins maven-compiler-plugin - 2.5.1 + 3.0 1.6 1.6 @@ -164,7 +164,7 @@ org.apache.maven.plugins maven-surefire-plugin - 2.12.3 + 2.13 ${skipTests} @@ -201,7 +201,7 @@ org.apache.maven.plugins maven-assembly-plugin - 2.3 + 2.4 distro-assembly @@ -220,7 +220,7 @@ org.codehaus.mojo versions-maven-plugin - 1.3.1 + 2.0 org.apache.maven.plugins @@ -253,6 +253,31 @@ + + org.apache.maven.plugins + maven-clean-plugin + 2.5 + + + org.apache.maven.plugins + maven-deploy-plugin + 2.7 + + + org.apache.maven.plugins + maven-gpg-plugin + 1.4 + + + org.apache.maven.plugins + maven-install-plugin + 2.4 + + + org.apache.maven.plugins + maven-resources-plugin + 2.6 + From d3af326a7768a17b173da23099ec74ded01f7a1f Mon Sep 17 00:00:00 2001 From: Stuart Boston Date: Mon, 28 Jan 2013 21:05:10 +0000 Subject: [PATCH 181/207] removed blank @return's from javadoc --- .../omertron/themoviedbapi/TheMovieDbApi.java | 57 +++---------------- .../model/TmdbConfiguration.java | 5 -- .../omertron/themoviedbapi/tools/ApiUrl.java | 2 - .../themoviedbapi/tools/FilteringLayout.java | 1 - 4 files changed, 8 insertions(+), 57 deletions(-) diff --git a/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java b/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java index 38e277d86..c1515b5fb 100644 --- a/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java +++ b/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java @@ -139,7 +139,6 @@ public class TheMovieDbApi { /** * Get the API key that is to be used * - * @return */ public String getApiKey() { return apiKey; @@ -229,7 +228,6 @@ public class TheMovieDbApi { * @param title1 * @param title2 * @param distance - * @return */ private static boolean compareDistance(String title1, String title2, int distance) { return (StringUtils.getLevenshteinDistance(title1, title2) <= distance); @@ -239,7 +237,6 @@ public class TheMovieDbApi { * Check the year is not blank or UNKNOWN * * @param year - * @return */ private static boolean isValidYear(String year) { return (StringUtils.isNotBlank(year) && !year.equals("UNKNOWN")); @@ -248,8 +245,6 @@ public class TheMovieDbApi { // /** * Get the configuration information - * - * @return */ public TmdbConfiguration getConfiguration() { return tmdbConfig; @@ -260,7 +255,6 @@ public class TheMovieDbApi { * * @param imagePath * @param requiredSize - * @return * @throws MovieDbException */ public URL createImageUrl(String imagePath, String requiredSize) throws MovieDbException { @@ -291,7 +285,6 @@ public class TheMovieDbApi { * * As soon as a valid session id has been created the token will be destroyed. * - * @return * @throws MovieDbException */ public TokenAuthorisation getAuthorisationToken() throws MovieDbException { @@ -314,7 +307,6 @@ public class TheMovieDbApi { * A session id is required in order to use any of the write methods. * * @param token - * @return * @throws MovieDbException */ public TokenSession getSessionToken(TokenAuthorisation token) throws MovieDbException { @@ -350,7 +342,6 @@ public class TheMovieDbApi { * * If a guest session is not used for the first time within 24 hours, it will be automatically discarded. * - * @return * @throws MovieDbException */ public TokenSession getGuestSessionToken() throws MovieDbException { @@ -380,7 +371,6 @@ public class TheMovieDbApi { * * @param movieId * @param language - * @return * @throws MovieDbException */ public MovieDb getMovieInfo(int movieId, String language) throws MovieDbException { @@ -409,7 +399,6 @@ public class TheMovieDbApi { * * @param imdbId * @param language - * @return * @throws MovieDbException */ public MovieDb getMovieInfoImdb(String imdbId, String language) throws MovieDbException { @@ -436,7 +425,6 @@ public class TheMovieDbApi { * * @param movieId * @param country - * @return * @throws MovieDbException */ public List getMovieAlternativeTitles(int movieId, String country) throws MovieDbException { @@ -464,7 +452,6 @@ public class TheMovieDbApi { * TODO: Add a function to enrich the data with the people methods * * @param movieId - * @return * @throws MovieDbException */ public List getMovieCasts(int movieId) throws MovieDbException { @@ -504,7 +491,6 @@ public class TheMovieDbApi { * * @param movieId * @param language - * @return * @throws MovieDbException */ public List getMovieImages(int movieId, String language) throws MovieDbException { @@ -546,7 +532,6 @@ public class TheMovieDbApi { * Currently, only English keywords exist. * * @param movieId - * @return * @throws MovieDbException */ public List getMovieKeywords(int movieId) throws MovieDbException { @@ -570,7 +555,6 @@ public class TheMovieDbApi { * * @param movieId * @param language - * @return * @throws MovieDbException */ public List getMovieReleaseInfo(int movieId, String language) throws MovieDbException { @@ -597,7 +581,6 @@ public class TheMovieDbApi { * * @param movieId * @param language - * @return * @throws MovieDbException */ public List getMovieTrailers(int movieId, String language) throws MovieDbException { @@ -637,7 +620,6 @@ public class TheMovieDbApi { * This method is used to retrieve a list of the available translations for a specific movie. * * @param movieId - * @return * @throws MovieDbException */ public List getMovieTranslations(int movieId) throws MovieDbException { @@ -665,8 +647,7 @@ public class TheMovieDbApi { * * @param movieId * @param language - * @param allResults - * @return + * @param page * @throws MovieDbException */ public List getSimilarMovies(int movieId, String language, int page) throws MovieDbException { @@ -699,7 +680,6 @@ public class TheMovieDbApi { * @param movieId * @param language * @param page - * @return * @throws MovieDbException */ public List getMovieLists(int movieId, String language, int page) throws MovieDbException { @@ -773,7 +753,6 @@ public class TheMovieDbApi { /** * This method is used to retrieve the newest movie that was added to TMDb. * - * @return */ public MovieDb getLatestMovie() throws MovieDbException { ApiUrl apiUrl = new ApiUrl(this, BASE_MOVIE, "/latest"); @@ -795,7 +774,6 @@ public class TheMovieDbApi { * * The maximum number of items this list will include is 100. * - * @return * @throws MovieDbException */ public List getUpcoming(String language, int page) throws MovieDbException { @@ -830,8 +808,7 @@ public class TheMovieDbApi { * TODO: Implement more than 20 movies * * @param language - * @param allResults - * @return + * @param page * @throws MovieDbException */ public List getNowPlayingMovies(String language, int page) throws MovieDbException { @@ -865,8 +842,7 @@ public class TheMovieDbApi { * TODO: Implement more than 20 movies * * @param language - * @param allResults - * @return + * @param page * @throws MovieDbException */ public List getPopularMovieList(String language, int page) throws MovieDbException { @@ -900,8 +876,7 @@ public class TheMovieDbApi { * TODO: Implement more than 20 movies * * @param language - * @param allResults - * @return + * @param page * @throws MovieDbException */ public List getTopRatedMovies(String language, int page) throws MovieDbException { @@ -934,7 +909,6 @@ public class TheMovieDbApi { * * @param sessionId * @param rating - * @return * @throws MovieDbException */ public boolean postMovieRating(String sessionId, String rating) throws MovieDbException { @@ -956,7 +930,6 @@ public class TheMovieDbApi { * * @param collectionId * @param language - * @return * @throws MovieDbException */ public CollectionInfo getCollectionInfo(int collectionId, String language) throws MovieDbException { @@ -983,7 +956,6 @@ public class TheMovieDbApi { * * @param collectionId * @param language - * @return * @throws MovieDbException */ public List getCollectionImages(int collectionId, String language) throws MovieDbException { @@ -1030,7 +1002,6 @@ public class TheMovieDbApi { * It will return the single highest rated profile image. * * @param personId - * @return * @throws MovieDbException */ public Person getPersonInfo(int personId) throws MovieDbException { @@ -1055,7 +1026,6 @@ public class TheMovieDbApi { * It will return the single highest rated poster for each movie record. * * @param personId - * @return * @throws MovieDbException */ public List getPersonCredits(int personId) throws MovieDbException { @@ -1092,7 +1062,6 @@ public class TheMovieDbApi { * This method is used to retrieve all of the profile images for a person. * * @param personId - * @return * @throws MovieDbException */ public List getPersonImages(int personId) throws MovieDbException { @@ -1143,7 +1112,6 @@ public class TheMovieDbApi { /** * Get the latest person id. * - * @return * @throws MovieDbException */ public Person getPersonLatest() throws MovieDbException { @@ -1166,7 +1134,6 @@ public class TheMovieDbApi { * This method is used to retrieve the basic information about a production company on TMDb. * * @param companyId - * @return * @throws MovieDbException */ public Company getCompanyInfo(int companyId) throws MovieDbException { @@ -1195,8 +1162,7 @@ public class TheMovieDbApi { * * @param companyId * @param language - * @param allResults - * @return + * @param page * @throws MovieDbException */ public List getCompanyMovies(int companyId, String language, int page) throws MovieDbException { @@ -1233,7 +1199,6 @@ public class TheMovieDbApi { * These IDs will correspond to those found in movie calls. * * @param language - * @return */ public List getGenreList(String language) throws MovieDbException { ApiUrl apiUrl = new ApiUrl(this, BASE_GENRE, "/list"); @@ -1260,8 +1225,7 @@ public class TheMovieDbApi { * * @param genreId * @param language - * @param allResults - * @return + * @param page */ public List getGenreMovies(int genreId, String language, int page) throws MovieDbException { ApiUrl apiUrl = new ApiUrl(this, BASE_GENRE, "/movies"); @@ -1298,7 +1262,6 @@ public class TheMovieDbApi { * @param language The language to include. Can be blank/null. * @param includeAdult true or false to include adult titles in the search * @param page The page of results to return. 0 to get the default (first page) - * @return * @throws MovieDbException */ public List searchMovie(String movieName, int searchYear, String language, boolean includeAdult, int page) throws MovieDbException { @@ -1340,7 +1303,6 @@ public class TheMovieDbApi { * @param query * @param language * @param page - * @return * @throws MovieDbException */ public List searchCollection(String query, String language, int page) throws MovieDbException { @@ -1375,11 +1337,9 @@ public class TheMovieDbApi { * * The idea is to be a quick and light method so you can iterate through people quickly. * - * TODO: Fix allResults - * * @param personName - * @param allResults - * @return + * @param includeAdult + * @param page * @throws MovieDbException */ public List searchPeople(String personName, boolean includeAdult, int page) throws MovieDbException { @@ -1448,7 +1408,6 @@ public class TheMovieDbApi { * * @param companyName * @param page - * @return * @throws MovieDbException */ public List searchCompanies(String companyName, int page) throws MovieDbException { diff --git a/src/main/java/com/omertron/themoviedbapi/model/TmdbConfiguration.java b/src/main/java/com/omertron/themoviedbapi/model/TmdbConfiguration.java index c1f0bb009..9355e62f6 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/TmdbConfiguration.java +++ b/src/main/java/com/omertron/themoviedbapi/model/TmdbConfiguration.java @@ -122,7 +122,6 @@ public class TmdbConfiguration implements Serializable { * Check that the poster size is valid * * @param posterSize - * @return */ public boolean isValidPosterSize(String posterSize) { if (StringUtils.isBlank(posterSize) || posterSizes.isEmpty()) { @@ -135,7 +134,6 @@ public class TmdbConfiguration implements Serializable { * Check that the backdrop size is valid * * @param backdropSize - * @return */ public boolean isValidBackdropSize(String backdropSize) { if (StringUtils.isBlank(backdropSize) || backdropSizes.isEmpty()) { @@ -148,7 +146,6 @@ public class TmdbConfiguration implements Serializable { * Check that the profile size is valid * * @param profileSize - * @return */ public boolean isValidProfileSize(String profileSize) { if (StringUtils.isBlank(profileSize) || profileSizes.isEmpty()) { @@ -161,7 +158,6 @@ public class TmdbConfiguration implements Serializable { * Check that the logo size is valid * * @param logoSize - * @return */ public boolean isValidLogoSize(String logoSize) { if (StringUtils.isBlank(logoSize) || logoSizes.isEmpty()) { @@ -174,7 +170,6 @@ public class TmdbConfiguration implements Serializable { * Check to see if the size is valid for any of the images types * * @param sizeToCheck - * @return */ public boolean isValidSize(String sizeToCheck) { return (isValidPosterSize(sizeToCheck) diff --git a/src/main/java/com/omertron/themoviedbapi/tools/ApiUrl.java b/src/main/java/com/omertron/themoviedbapi/tools/ApiUrl.java index ec2021951..abe5d1f2c 100644 --- a/src/main/java/com/omertron/themoviedbapi/tools/ApiUrl.java +++ b/src/main/java/com/omertron/themoviedbapi/tools/ApiUrl.java @@ -102,8 +102,6 @@ public class ApiUrl { /** * Build the URL from the pre-created arguments. - * - * @return */ public URL buildUrl() { StringBuilder urlString = new StringBuilder(TMDB_API_BASE); diff --git a/src/main/java/com/omertron/themoviedbapi/tools/FilteringLayout.java b/src/main/java/com/omertron/themoviedbapi/tools/FilteringLayout.java index b45d9c47b..ccdb8975a 100644 --- a/src/main/java/com/omertron/themoviedbapi/tools/FilteringLayout.java +++ b/src/main/java/com/omertron/themoviedbapi/tools/FilteringLayout.java @@ -49,7 +49,6 @@ public class FilteringLayout extends PatternLayout { * Extend the format to remove the API_KEYS from the output * * @param event - * @return */ @Override public String format(LoggingEvent event) { From deb9eb66424d70ee176ad5bc1c4875f0bea3d856 Mon Sep 17 00:00:00 2001 From: Omertron <> Date: Tue, 29 Jan 2013 20:42:14 +0000 Subject: [PATCH 182/207] Renamed log4j properties file --- src/main/resources/{log4j.properties => log4j-example.properties} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename src/main/resources/{log4j.properties => log4j-example.properties} (100%) diff --git a/src/main/resources/log4j.properties b/src/main/resources/log4j-example.properties similarity index 100% rename from src/main/resources/log4j.properties rename to src/main/resources/log4j-example.properties From 47faecc207f6a5e3f283561ed3ce4a3347dcd982 Mon Sep 17 00:00:00 2001 From: Omertron <> Date: Tue, 29 Jan 2013 20:48:50 +0000 Subject: [PATCH 183/207] Updated exception details --- .../themoviedbapi/MovieDbException.java | 35 +++++++++++++++++-- 1 file changed, 33 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/omertron/themoviedbapi/MovieDbException.java b/src/main/java/com/omertron/themoviedbapi/MovieDbException.java index 59930a6fd..f781b5112 100644 --- a/src/main/java/com/omertron/themoviedbapi/MovieDbException.java +++ b/src/main/java/com/omertron/themoviedbapi/MovieDbException.java @@ -21,10 +21,41 @@ package com.omertron.themoviedbapi; public class MovieDbException extends Exception { - private static final long serialVersionUID = -8952129102483143278L; + private static final long serialVersionUID = 1L; public enum MovieDbExceptionType { - UNKNOWN_CAUSE, INVALID_URL, HTTP_404_ERROR, MOVIE_ID_NOT_FOUND, MAPPING_FAILED, CONNECTION_ERROR, INVALID_IMAGE, AUTHORISATION_FAILURE; + /* + * Unknown error occured + */ + UNKNOWN_CAUSE, + /* + * URL is invalid + */ + INVALID_URL, + /* + * Page not found + */ + HTTP_404_ERROR, + /* + * The movie id was not found + */ + MOVIE_ID_NOT_FOUND, + /* + * Mapping failed from target to internal onbjects + */ + MAPPING_FAILED, + /* + * Error connecting to the service + */ + CONNECTION_ERROR, + /* + * Image was invalid + */ + INVALID_IMAGE, + /* + * Autorisation rejected + */ + AUTHORISATION_FAILURE; } private final MovieDbExceptionType exceptionType; From f27f6f35fe63a1ef07786fc7921082c8327562b8 Mon Sep 17 00:00:00 2001 From: Omertron <> Date: Tue, 29 Jan 2013 21:05:12 +0000 Subject: [PATCH 184/207] Updated Javadoc --- src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java b/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java index c1515b5fb..3172aac00 100644 --- a/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java +++ b/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java @@ -75,7 +75,7 @@ import org.apache.log4j.Logger; /** * The MovieDb API - * + *

* This is for version 3 of the API as specified here: http://help.themoviedb.org/kb/api/about-3 * * @author stuart.boston @@ -90,8 +90,6 @@ public class TheMovieDbApi { * * These are not set to static so that multiple instances of * the API can co-exist - * - * TODO: See issue 9 http://code.google.com/p/themoviedbapi/issues/detail?id=9 */ private static final String BASE_MOVIE = "movie/"; private static final String BASE_PERSON = "person/"; From c275e71ab42271851ca331beb819fef85e470a19 Mon Sep 17 00:00:00 2001 From: Omertron <> Date: Sat, 2 Feb 2013 15:49:23 +0000 Subject: [PATCH 185/207] Added Keyword and List functions --- .../omertron/themoviedbapi/TheMovieDbApi.java | 153 ++++++++++++------ .../themoviedbapi/model/MovieDbList.java | 150 +++++++++++++++++ .../themoviedbapi/TheMovieDbApiTest.java | 64 ++++++++ 3 files changed, 314 insertions(+), 53 deletions(-) create mode 100644 src/main/java/com/omertron/themoviedbapi/model/MovieDbList.java diff --git a/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java b/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java index 3172aac00..f0369814d 100644 --- a/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java +++ b/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java @@ -21,50 +21,12 @@ package com.omertron.themoviedbapi; import com.fasterxml.jackson.databind.ObjectMapper; import com.omertron.themoviedbapi.MovieDbException.MovieDbExceptionType; -import com.omertron.themoviedbapi.model.AlternativeTitle; -import com.omertron.themoviedbapi.model.Artwork; -import com.omertron.themoviedbapi.model.ArtworkType; -import com.omertron.themoviedbapi.model.Collection; -import com.omertron.themoviedbapi.model.CollectionInfo; -import com.omertron.themoviedbapi.model.Company; -import com.omertron.themoviedbapi.model.Genre; -import com.omertron.themoviedbapi.model.Keyword; -import com.omertron.themoviedbapi.model.MovieChanges; -import com.omertron.themoviedbapi.model.MovieDb; -import com.omertron.themoviedbapi.model.MovieList; -import com.omertron.themoviedbapi.model.Person; -import com.omertron.themoviedbapi.model.PersonCast; -import com.omertron.themoviedbapi.model.PersonCredit; -import com.omertron.themoviedbapi.model.PersonCrew; -import com.omertron.themoviedbapi.model.PersonType; -import com.omertron.themoviedbapi.model.ReleaseInfo; -import com.omertron.themoviedbapi.model.TmdbConfiguration; -import com.omertron.themoviedbapi.model.TokenAuthorisation; -import com.omertron.themoviedbapi.model.TokenSession; -import com.omertron.themoviedbapi.model.Trailer; -import com.omertron.themoviedbapi.model.Translation; +import com.omertron.themoviedbapi.model.*; import com.omertron.themoviedbapi.tools.ApiUrl; import static com.omertron.themoviedbapi.tools.ApiUrl.*; import com.omertron.themoviedbapi.tools.FilteringLayout; import com.omertron.themoviedbapi.tools.WebBrowser; -import com.omertron.themoviedbapi.wrapper.WrapperAlternativeTitles; -import com.omertron.themoviedbapi.wrapper.WrapperChanges; -import com.omertron.themoviedbapi.wrapper.WrapperCollection; -import com.omertron.themoviedbapi.wrapper.WrapperCompany; -import com.omertron.themoviedbapi.wrapper.WrapperCompanyMovies; -import com.omertron.themoviedbapi.wrapper.WrapperConfig; -import com.omertron.themoviedbapi.wrapper.WrapperGenres; -import com.omertron.themoviedbapi.wrapper.WrapperImages; -import com.omertron.themoviedbapi.wrapper.WrapperKeywords; -import com.omertron.themoviedbapi.wrapper.WrapperMovie; -import com.omertron.themoviedbapi.wrapper.WrapperMovieCasts; -import com.omertron.themoviedbapi.wrapper.WrapperMovieKeywords; -import com.omertron.themoviedbapi.wrapper.WrapperMovieList; -import com.omertron.themoviedbapi.wrapper.WrapperPerson; -import com.omertron.themoviedbapi.wrapper.WrapperPersonCredits; -import com.omertron.themoviedbapi.wrapper.WrapperReleaseInfo; -import com.omertron.themoviedbapi.wrapper.WrapperTrailers; -import com.omertron.themoviedbapi.wrapper.WrapperTranslations; +import com.omertron.themoviedbapi.wrapper.*; import java.io.IOException; import java.net.MalformedURLException; import java.net.URL; @@ -74,9 +36,7 @@ import org.apache.commons.lang3.StringUtils; import org.apache.log4j.Logger; /** - * The MovieDb API - *

- * This is for version 3 of the API as specified here: http://help.themoviedb.org/kb/api/about-3 + * The MovieDb API

This is for version 3 of the API as specified here: http://help.themoviedb.org/kb/api/about-3 * * @author stuart.boston */ @@ -99,6 +59,8 @@ public class TheMovieDbApi { private static final String BASE_COLLECTION = "collection/"; // private static final String BASE_ACCOUNT = "account/"; private static final String BASE_SEARCH = "search/"; + private static final String BASE_LIST = "list/"; + private static final String BASE_KEYWORD = "keyword/"; // Account /* private final ApiUrl tmdbAccount = new ApiUrl(this, BASE_ACCOUNT); @@ -332,11 +294,10 @@ public class TheMovieDbApi { * * A guest session can be used to rate movies without having a registered TMDb user account. * - * You should only generate a single guest session per user (or device) as you will be able to attach the ratings to - * a TMDb user account in the future. + * You should only generate a single guest session per user (or device) as you will be able to attach the ratings to a TMDb user + * account in the future. * - * There are also IP limits in place so you should always make sure it's the end user doing the guest session - * actions. + * There are also IP limits in place so you should always make sure it's the end user doing the guest session actions. * * If a guest session is not used for the first time within 24 hours, it will be automatically discarded. * @@ -1153,8 +1114,7 @@ public class TheMovieDbApi { /** * This method is used to retrieve the movies associated with a company. * - * These movies are returned in order of most recently released to oldest. The default response will return 20 - * movies per page. + * These movies are returned in order of most recently released to oldest. The default response will return 20 movies per page. * * TODO: Implement more than 20 movies * @@ -1399,8 +1359,8 @@ public class TheMovieDbApi { /** * Search Companies. * - * You can use this method to search for production companies that are part of TMDb. The company IDs will map to - * those returned on movie calls. + * You can use this method to search for production companies that are part of TMDb. The company IDs will map to those returned + * on movie calls. * * http://help.themoviedb.org/kb/api/search-companies * @@ -1458,6 +1418,93 @@ public class TheMovieDbApi { } // // - // List Functions - // Keywords Functions + // + + /** + * Get a list by its ID + * + * @param listId + * @return The list and its items + * @throws MovieDbException + */ + public MovieDbList getList(String listId) throws MovieDbException { + ApiUrl apiUrl = new ApiUrl(this, BASE_LIST); + apiUrl.addArgument(PARAM_ID, listId); + + URL url = apiUrl.buildUrl(); + String webpage = WebBrowser.request(url); + + try { + MovieDbList movieDbList = mapper.readValue(webpage, MovieDbList.class); + return movieDbList; + } catch (IOException ex) { + logger.warn("Failed to get list: " + ex.getMessage()); + throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); + } + } + // + // + // + + /** + * Get the basic information for a specific keyword id. + * + * @param keywordId + * @return + * @throws MovieDbException + */ + public Keyword getKeyword(String keywordId) throws MovieDbException { + ApiUrl apiUrl = new ApiUrl(this, BASE_KEYWORD); + apiUrl.addArgument(PARAM_ID, keywordId); + + URL url = apiUrl.buildUrl(); + String webpage = WebBrowser.request(url); + + try { + Keyword keyword = mapper.readValue(webpage, Keyword.class); + return keyword; + } catch (IOException ex) { + logger.warn("Failed to get keyword: " + ex.getMessage()); + throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); + } + + } + + /** + * Get the list of movies for a particular keyword by id. + * + * @param keywordId + * @param language + * @param page + * @return List of movies with the keyword + * @throws MovieDbException + */ + public List getKeywordMovies(String keywordId, String language, int page) throws MovieDbException { + ApiUrl apiUrl = new ApiUrl(this, BASE_KEYWORD, "/movies"); + apiUrl.addArgument(PARAM_ID, keywordId); + + if (StringUtils.isNotBlank(language)) { + apiUrl.addArgument(PARAM_LANGUAGE, language); + } + + if (page > 0) { + apiUrl.addArgument(PARAM_PAGE, page); + } + + URL url = apiUrl.buildUrl(); + String webpage = WebBrowser.request(url); + + try { + WrapperMovieList wrapper = mapper.readValue(webpage, WrapperMovieList.class); + return wrapper.getMovieList(); + } catch (IOException ex) { + logger.warn("Failed to get top rated movies: " + ex.getMessage()); + throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); + } + + } + // + // + // + // } diff --git a/src/main/java/com/omertron/themoviedbapi/model/MovieDbList.java b/src/main/java/com/omertron/themoviedbapi/model/MovieDbList.java new file mode 100644 index 000000000..464f341b2 --- /dev/null +++ b/src/main/java/com/omertron/themoviedbapi/model/MovieDbList.java @@ -0,0 +1,150 @@ +/* + * Copyright (c) 2004-2013 Stuart Boston + * + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . + * + */ +package com.omertron.themoviedbapi.model; + +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.util.Collections; +import java.util.List; +import org.apache.log4j.Logger; + +/** + * Wrapper for the MovieDbList function + * @author stuart.boston + */ +public class MovieDbList { + /* + * Logger + */ + + private static final Logger logger = Logger.getLogger(MovieDbList.class); + /* + * Properties + */ + @JsonProperty("id") + private String id; + @JsonProperty("created_by") + private String createdBy; + @JsonProperty("description") + private String description; + @JsonProperty("favorite_count") + private int favoriteCount; + @JsonProperty("items") + private List items = Collections.EMPTY_LIST; + @JsonProperty("item_count") + private int itemCount; + @JsonProperty("iso_639_1") + private String language; + @JsonProperty("name") + private String name; + @JsonProperty("poster_path") + private String posterPath; + + // + public String getId() { + return id; + } + + public String getCreatedBy() { + return createdBy; + } + + public String getDescription() { + return description; + } + + public int getFavoriteCount() { + return favoriteCount; + } + + public List getItems() { + return items; + } + + public int getItemCount() { + return itemCount; + } + + public String getLanguage() { + return language; + } + + public String getName() { + return name; + } + + public String getPosterPath() { + return posterPath; + } + // + + // + public void setId(String id) { + this.id = id; + } + + public void setCreatedBy(String createdBy) { + this.createdBy = createdBy; + } + + public void setDescription(String description) { + this.description = description; + } + + public void setFavoriteCount(int favoriteCount) { + this.favoriteCount = favoriteCount; + } + + public void setItems(List items) { + this.items = items; + } + + public void setItemCount(int itemCount) { + this.itemCount = itemCount; + } + + public void setLanguage(String language) { + this.language = language; + } + + public void setName(String name) { + this.name = name; + } + + public void setPosterPath(String posterPath) { + this.posterPath = posterPath; + } + // + + /** + * Handle unknown properties and print a message + * + * @param key + * @param value + */ + @JsonAnySetter + public void handleUnknown(String key, Object value) { + StringBuilder sb = new StringBuilder(); + sb.append("Unknown property: '").append(key); + sb.append("' value: '").append(value).append("'"); + logger.trace(sb.toString()); + } + +} diff --git a/src/test/java/com/omertron/themoviedbapi/TheMovieDbApiTest.java b/src/test/java/com/omertron/themoviedbapi/TheMovieDbApiTest.java index 225a10550..8ba56b03d 100644 --- a/src/test/java/com/omertron/themoviedbapi/TheMovieDbApiTest.java +++ b/src/test/java/com/omertron/themoviedbapi/TheMovieDbApiTest.java @@ -28,6 +28,7 @@ import com.omertron.themoviedbapi.model.Genre; import com.omertron.themoviedbapi.model.Keyword; import com.omertron.themoviedbapi.model.MovieChanges; import com.omertron.themoviedbapi.model.MovieDb; +import com.omertron.themoviedbapi.model.MovieDbList; import com.omertron.themoviedbapi.model.MovieList; import com.omertron.themoviedbapi.model.Person; import com.omertron.themoviedbapi.model.PersonCredit; @@ -66,6 +67,7 @@ public class TheMovieDbApiTest { private static final int ID_COMPANY_LUCASFILM = 1; private static final String COMPANY_NAME = "Marvel Studios"; private static final int ID_GENRE_ACTION = 28; + private static final String ID_KEYWORD = "1721"; public TheMovieDbApiTest() throws MovieDbException { tmdb = new TheMovieDbApi(API_KEY); @@ -599,4 +601,66 @@ public class TheMovieDbApiTest { assertFalse("No keywords found", result == null); assertTrue("No keywords found", result.size() > 0); } + + /** + * Test of postMovieRating method, of class TheMovieDbApi. + */ + @Test + public void testPostMovieRating() throws Exception { + logger.info("postMovieRating"); + String sessionId = ""; + String rating = ""; + boolean expResult = false; + boolean result = tmdb.postMovieRating(sessionId, rating); + assertEquals(expResult, result); + // TODO review the generated test code and remove the default call to fail. + fail("The test case is a prototype."); + } + + /** + * Test of getPersonChanges method, of class TheMovieDbApi. + */ + @Test + public void testGetPersonChanges() throws Exception { + logger.info("getPersonChanges"); + int personId = 0; + String startDate = ""; + String endDate = ""; + tmdb.getPersonChanges(personId, startDate, endDate); + // TODO review the generated test code and remove the default call to fail. + fail("The test case is a prototype."); + } + + /** + * Test of getList method, of class TheMovieDbApi. + */ + @Test + public void testGetList() throws Exception { + logger.info("getList"); + String listId = "509ec17b19c2950a0600050d"; + MovieDbList result = tmdb.getList(listId); + assertFalse("List not found", result.getItems().isEmpty()); + } + + /** + * Test of getKeyword method, of class TheMovieDbApi. + */ + @Test + public void testGetKeyword() throws Exception { + logger.info("getKeyword"); + Keyword result = tmdb.getKeyword(ID_KEYWORD); + assertEquals("fight", result.getName()); + } + + /** + * Test of getKeywordMovies method, of class TheMovieDbApi. + */ + @Test + public void testGetKeywordMovies() throws Exception { + logger.info("getKeywordMovies"); + String language = ""; + int page = 0; + List result = tmdb.getKeywordMovies(ID_KEYWORD, language, page); + assertFalse("No keyword movies found", result.isEmpty()); + } } From 857071676b2fa3a9e222a737416839a7baf12db9 Mon Sep 17 00:00:00 2001 From: Omertron <> Date: Sun, 3 Feb 2013 10:51:22 +0000 Subject: [PATCH 186/207] Updated test cases --- .../themoviedbapi/TheMovieDbApiTest.java | 37 ++++++++++--------- 1 file changed, 19 insertions(+), 18 deletions(-) diff --git a/src/test/java/com/omertron/themoviedbapi/TheMovieDbApiTest.java b/src/test/java/com/omertron/themoviedbapi/TheMovieDbApiTest.java index 8ba56b03d..77318fb90 100644 --- a/src/test/java/com/omertron/themoviedbapi/TheMovieDbApiTest.java +++ b/src/test/java/com/omertron/themoviedbapi/TheMovieDbApiTest.java @@ -43,6 +43,7 @@ import java.io.IOException; import java.util.Collections; import java.util.List; import org.apache.commons.lang3.StringUtils; +import org.apache.log4j.BasicConfigurator; import org.apache.log4j.Level; import org.apache.log4j.Logger; import org.junit.*; @@ -68,6 +69,9 @@ public class TheMovieDbApiTest { private static final String COMPANY_NAME = "Marvel Studios"; private static final int ID_GENRE_ACTION = 28; private static final String ID_KEYWORD = "1721"; + // Languages + private static final String LANGUAGE_DEFAULT = ""; + private static final String LANGUAGE_ENGLISH = "en"; public TheMovieDbApiTest() throws MovieDbException { tmdb = new TheMovieDbApi(API_KEY); @@ -75,6 +79,7 @@ public class TheMovieDbApiTest { @BeforeClass public static void setUpClass() throws Exception { + BasicConfigurator.configure(); // Set the logger level to TRACE Logger.getRootLogger().setLevel(Level.TRACE); } @@ -378,7 +383,7 @@ public class TheMovieDbApiTest { @Test public void testGetNowPlayingMovies() throws MovieDbException { logger.info("getNowPlayingMovies"); - List results = tmdb.getNowPlayingMovies("", 0); + List results = tmdb.getNowPlayingMovies(LANGUAGE_DEFAULT, 0); assertTrue("No now playing movies found", !results.isEmpty()); } @@ -388,7 +393,7 @@ public class TheMovieDbApiTest { @Test public void testGetPopularMovieList() throws MovieDbException { logger.info("getPopularMovieList"); - List results = tmdb.getPopularMovieList("", 0); + List results = tmdb.getPopularMovieList(LANGUAGE_DEFAULT, 0); assertTrue("No popular movies found", !results.isEmpty()); } @@ -398,7 +403,7 @@ public class TheMovieDbApiTest { @Test public void testGetTopRatedMovies() throws MovieDbException { logger.info("getTopRatedMovies"); - List results = tmdb.getTopRatedMovies("", 0); + List results = tmdb.getTopRatedMovies(LANGUAGE_DEFAULT, 0); assertTrue("No top rated movies found", !results.isEmpty()); } @@ -418,7 +423,7 @@ public class TheMovieDbApiTest { @Test public void testGetCompanyMovies() throws MovieDbException { logger.info("getCompanyMovies"); - List results = tmdb.getCompanyMovies(ID_COMPANY_LUCASFILM, "", 0); + List results = tmdb.getCompanyMovies(ID_COMPANY_LUCASFILM, LANGUAGE_DEFAULT, 0); assertTrue("No company movies found", !results.isEmpty()); } @@ -438,7 +443,7 @@ public class TheMovieDbApiTest { @Test public void testGetSimilarMovies() throws MovieDbException { logger.info("getSimilarMovies"); - List results = tmdb.getSimilarMovies(ID_MOVIE_BLADE_RUNNER, "", 0); + List results = tmdb.getSimilarMovies(ID_MOVIE_BLADE_RUNNER, LANGUAGE_DEFAULT, 0); assertTrue("No similar movies found", !results.isEmpty()); } @@ -448,7 +453,7 @@ public class TheMovieDbApiTest { @Test public void testGetGenreList() throws MovieDbException { logger.info("getGenreList"); - List results = tmdb.getGenreList(""); + List results = tmdb.getGenreList(LANGUAGE_DEFAULT); assertTrue("No genres found", !results.isEmpty()); } @@ -458,7 +463,7 @@ public class TheMovieDbApiTest { @Test public void testGetGenreMovies() throws MovieDbException { logger.info("getGenreMovies"); - List results = tmdb.getGenreMovies(ID_GENRE_ACTION, "", 0); + List results = tmdb.getGenreMovies(ID_GENRE_ACTION, LANGUAGE_DEFAULT, 0); assertTrue("No genre movies found", !results.isEmpty()); } @@ -468,7 +473,7 @@ public class TheMovieDbApiTest { @Test public void testGetUpcoming() throws Exception { logger.info("getUpcoming"); - List results = tmdb.getUpcoming("", 0); + List results = tmdb.getUpcoming(LANGUAGE_DEFAULT, 0); assertTrue("No upcoming movies found", !results.isEmpty()); } @@ -478,8 +483,7 @@ public class TheMovieDbApiTest { @Test public void testGetCollectionImages() throws Exception { logger.info("getCollectionImages"); - String language = ""; - List result = tmdb.getCollectionImages(ID_MOVIE_STAR_WARS_COLLECTION, language); + List result = tmdb.getCollectionImages(ID_MOVIE_STAR_WARS_COLLECTION, LANGUAGE_DEFAULT); assertFalse("No artwork found", result.isEmpty()); } @@ -536,12 +540,12 @@ public class TheMovieDbApiTest { public void testGetMovieChanges() throws Exception { logger.info("getMovieChanges"); - String language = ""; String startDate = ""; String endDate = null; List results = Collections.EMPTY_LIST; - List movieList = tmdb.getPopularMovieList(language, 0); + // Get some popular movies + List movieList = tmdb.getPopularMovieList(LANGUAGE_DEFAULT, 0); for (MovieDb movie : movieList) { results = tmdb.getMovieChanges(movie.getId(), startDate, endDate); logger.info(movie.getTitle() + " has " + results.size() + " changes."); @@ -568,9 +572,8 @@ public class TheMovieDbApiTest { public void testSearchCollection() throws Exception { logger.info("searchCollection"); String query = "batman"; - String language = ""; int page = 0; - List result = tmdb.searchCollection(query, language, page); + List result = tmdb.searchCollection(query, LANGUAGE_DEFAULT, page); assertFalse("No collections found", result == null); assertTrue("No collections found", result.size() > 0); } @@ -582,9 +585,8 @@ public class TheMovieDbApiTest { public void testSearchList() throws Exception { logger.info("searchList"); String query = "watch"; - String language = ""; int page = 0; - List result = tmdb.searchList(query, language, page); + List result = tmdb.searchList(query, LANGUAGE_DEFAULT, page); assertFalse("No lists found", result == null); assertTrue("No lists found", result.size() > 0); } @@ -658,9 +660,8 @@ public class TheMovieDbApiTest { @Test public void testGetKeywordMovies() throws Exception { logger.info("getKeywordMovies"); - String language = ""; int page = 0; - List result = tmdb.getKeywordMovies(ID_KEYWORD, language, page); + List result = tmdb.getKeywordMovies(ID_KEYWORD, LANGUAGE_DEFAULT, page); assertFalse("No keyword movies found", result.isEmpty()); } } From 596cde76210a02828daedd6145bb3357817768e4 Mon Sep 17 00:00:00 2001 From: Omertron <> Date: Sun, 3 Feb 2013 19:24:46 +0000 Subject: [PATCH 187/207] Removed Apiary URL --- src/main/java/com/omertron/themoviedbapi/tools/ApiUrl.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/omertron/themoviedbapi/tools/ApiUrl.java b/src/main/java/com/omertron/themoviedbapi/tools/ApiUrl.java index abe5d1f2c..9bde3a03f 100644 --- a/src/main/java/com/omertron/themoviedbapi/tools/ApiUrl.java +++ b/src/main/java/com/omertron/themoviedbapi/tools/ApiUrl.java @@ -43,7 +43,6 @@ public class ApiUrl { * TheMovieDbApi API Base URL */ private static final String TMDB_API_BASE = "http://api.themoviedb.org/3/"; -// private static final String TMDB_API_BASE = "http://private-3aa3-themoviedb.apiary.io/3/"; /* * Parameter configuration */ From 1e45b87508b35902bf1e45045f4ddcec692aab71 Mon Sep 17 00:00:00 2001 From: Omertron <> Date: Sun, 3 Feb 2013 19:25:23 +0000 Subject: [PATCH 188/207] Refactored to use a base class --- .../themoviedbapi/wrapper/WrapperBase.java | 105 ++++++++++++++++++ .../wrapper/WrapperCollection.java | 57 +--------- .../themoviedbapi/wrapper/WrapperCompany.java | 55 +-------- .../wrapper/WrapperCompanyMovies.java | 73 ++---------- .../themoviedbapi/wrapper/WrapperImages.java | 34 +----- .../wrapper/WrapperKeywords.java | 57 +--------- .../themoviedbapi/wrapper/WrapperMovie.java | 81 ++------------ .../wrapper/WrapperMovieList.java | 68 +----------- .../themoviedbapi/wrapper/WrapperPerson.java | 55 +-------- .../wrapper/WrapperPersonCredits.java | 47 ++------ .../wrapper/WrapperTranslations.java | 3 + 11 files changed, 157 insertions(+), 478 deletions(-) create mode 100644 src/main/java/com/omertron/themoviedbapi/wrapper/WrapperBase.java diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperBase.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperBase.java new file mode 100644 index 000000000..a43a972d0 --- /dev/null +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperBase.java @@ -0,0 +1,105 @@ +/* + * Copyright (c) 2004-2013 Stuart Boston + * + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . + * + */ +package com.omertron.themoviedbapi.wrapper; + +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.omertron.themoviedbapi.model.AlternativeTitle; +import com.omertron.themoviedbapi.model.MovieList; +import java.util.List; +import org.apache.log4j.Logger; + +/** + * Base class for the wrappers + * + * @author Stuart + */ +public class WrapperBase { + /* + * Logger - set but the sub-classes + */ + + private Logger logger; + /* + * Properties + */ + @JsonProperty("id") + private int id; + @JsonProperty("page") + private int page; + @JsonProperty("total_pages") + private int totalPages; + @JsonProperty("total_results") + private int totalResults; + + public WrapperBase(Logger logger) { + this.logger = logger; + } + + // + public int getId() { + return id; + } + + public int getPage() { + return page; + } + + public int getTotalPages() { + return totalPages; + } + + public int getTotalResults() { + return totalResults; + } + // + + // + public void setId(int id) { + this.id = id; + } + + public void setPage(int page) { + this.page = page; + } + + public void setTotalPages(int totalPages) { + this.totalPages = totalPages; + } + + public void setTotalResults(int totalResults) { + this.totalResults = totalResults; + } + // + + /** + * Handle unknown properties and print a message + * + * @param key + * @param value + */ + @JsonAnySetter + public void handleUnknown(String key, Object value) { + StringBuilder sb = new StringBuilder(); + sb.append("Unknown property: '").append(key); + sb.append("' value: '").append(value).append("'"); + logger.trace(sb.toString()); + } +} diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperCollection.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperCollection.java index 6cc493b2d..39a6115d8 100644 --- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperCollection.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperCollection.java @@ -19,10 +19,8 @@ */ package com.omertron.themoviedbapi.wrapper; -import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonProperty; import com.omertron.themoviedbapi.model.Collection; -import com.omertron.themoviedbapi.model.MovieChanges; import java.util.List; import org.apache.log4j.Logger; @@ -30,71 +28,22 @@ import org.apache.log4j.Logger; * * @author stuart.boston */ -public class WrapperCollection { - /* - * Logger - */ - - private static final Logger logger = Logger.getLogger(WrapperCollection.class); +public class WrapperCollection extends WrapperBase { /* * Properties */ - @JsonProperty("page") - private int page; @JsonProperty("results") private List results; - @JsonProperty("total_pages") - private int totalPages; - @JsonProperty("total_results") - private int totalResults; - // - public int getPage() { - return page; + public WrapperCollection() { + super(Logger.getLogger(WrapperCollection.class)); } public List getResults() { return results; } - public int getTotalPages() { - return totalPages; - } - - public int getTotalResults() { - return totalResults; - } - // - - // - public void setPage(int page) { - this.page = page; - } - public void setResults(List results) { this.results = results; } - - public void setTotalPages(int totalPages) { - this.totalPages = totalPages; - } - - public void setTotalResults(int totalResults) { - this.totalResults = totalResults; - } - // - - /** - * Handle unknown properties and print a message - * - * @param key - * @param value - */ - @JsonAnySetter - public void handleUnknown(String key, Object value) { - StringBuilder sb = new StringBuilder(); - sb.append("Unknown property: '").append(key); - sb.append("' value: '").append(value).append("'"); - logger.trace(sb.toString()); - } } diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperCompany.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperCompany.java index bb076f7ac..760985d65 100644 --- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperCompany.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperCompany.java @@ -19,7 +19,6 @@ */ package com.omertron.themoviedbapi.wrapper; -import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonProperty; import com.omertron.themoviedbapi.model.Company; import java.util.List; @@ -29,70 +28,22 @@ import org.apache.log4j.Logger; * * @author stuart.boston */ -public class WrapperCompany { - /* - * Logger - */ - - private static final Logger logger = Logger.getLogger(WrapperCompany.class); +public class WrapperCompany extends WrapperBase{ /* * Properties */ - @JsonProperty("page") - private int page; @JsonProperty("results") private List results; - @JsonProperty("total_pages") - private int totalPages; - @JsonProperty("total_results") - private int totalResults; - // - public int getPage() { - return page; + public WrapperCompany() { + super(Logger.getLogger(WrapperCompany.class)); } public List getResults() { return results; } - public int getTotalPages() { - return totalPages; - } - - public int getTotalResults() { - return totalResults; - } - // - - // - public void setPage(int page) { - this.page = page; - } - public void setResults(List results) { this.results = results; } - - public void setTotalPages(int totalPages) { - this.totalPages = totalPages; - } - - public void setTotalResults(int totalResults) { - this.totalResults = totalResults; - } - // - - /** - * Handle unknown properties and print a message - * @param key - * @param value - */ - @JsonAnySetter - public void handleUnknown(String key, Object value) { - StringBuilder sb = new StringBuilder(); - sb.append("Unknown property: '").append(key); - sb.append("' value: '").append(value).append("'"); - logger.trace(sb.toString()); - } } diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperCompanyMovies.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperCompanyMovies.java index 0aee40c4f..25b3d8ccf 100644 --- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperCompanyMovies.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperCompanyMovies.java @@ -19,7 +19,6 @@ */ package com.omertron.themoviedbapi.wrapper; -import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonProperty; import com.omertron.themoviedbapi.model.MovieDb; import java.util.List; @@ -29,88 +28,34 @@ import org.apache.log4j.Logger; * * @author stuart.boston */ -public class WrapperCompanyMovies { - // Loggers - private static final Logger logger = Logger.getLogger(WrapperCompanyMovies.class); +public class WrapperCompanyMovies extends WrapperBase { /* * Properties */ - @JsonProperty("id") - private int companyId; - @JsonProperty("page") - private int page; + @JsonProperty("results") private List results; - @JsonProperty("total_pages") - private int totalPages; - @JsonProperty("total_results") - private int totalResults; - // - public int getCompanyId() { - return companyId; - } - - public int getPage() { - return page; + public WrapperCompanyMovies() { + super(Logger.getLogger(WrapperCompanyMovies.class)); } public List getResults() { return results; } - public int getTotalPages() { - return totalPages; - } - - public int getTotalResults() { - return totalResults; - } - // - - // - public void setCompanyId(int companyId) { - this.companyId = companyId; - } - - public void setPage(int page) { - this.page = page; - } - public void setResults(List results) { this.results = results; } - public void setTotalPages(int totalPages) { - this.totalPages = totalPages; - } - - public void setTotalResults(int totalResults) { - this.totalResults = totalResults; - } - // - - /** - * Handle unknown properties and print a message - * @param key - * @param value - */ - @JsonAnySetter - public void handleUnknown(String key, Object value) { - StringBuilder sb = new StringBuilder(); - sb.append("Unknown property: '").append(key); - sb.append("' value: '").append(value).append("'"); - logger.trace(sb.toString()); - } - @Override public String toString() { StringBuilder sb = new StringBuilder("[ResultList=["); - sb.append("[companyId=").append(companyId); - sb.append("],[page=").append(page); - sb.append("],[pageResults=").append(results.size()); - sb.append("],[totalPages=").append(totalPages); - sb.append("],[totalResults=").append(totalResults); + sb.append("[companyId=").append(getId()); + sb.append("],[page=").append(getPage()); + sb.append("],[pageResults=").append(getResults().size()); + sb.append("],[totalPages=").append(getTotalPages()); + sb.append("],[totalResults=").append(getTotalResults()); sb.append("]]"); return sb.toString(); } diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperImages.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperImages.java index 089f68a16..adaaebae0 100644 --- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperImages.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperImages.java @@ -19,7 +19,6 @@ */ package com.omertron.themoviedbapi.wrapper; -import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonProperty; import com.omertron.themoviedbapi.model.Artwork; import java.util.List; @@ -29,17 +28,10 @@ import org.apache.log4j.Logger; * * @author Stuart */ -public class WrapperImages { - /* - * Logger - */ - - private static final Logger logger = Logger.getLogger(WrapperImages.class); +public class WrapperImages extends WrapperBase { /* * Properties */ - @JsonProperty("id") - private int id; @JsonProperty("backdrops") private List backdrops; @JsonProperty("posters") @@ -47,11 +39,11 @@ public class WrapperImages { @JsonProperty("profiles") private List profiles; - // - public int getId() { - return id; + public WrapperImages() { + super(Logger.getLogger(WrapperImages.class)); } + // public List getBackdrops() { return backdrops; } @@ -66,10 +58,6 @@ public class WrapperImages { // // - public void setId(int id) { - this.id = id; - } - public void setBackdrops(List backdrops) { this.backdrops = backdrops; } @@ -82,18 +70,4 @@ public class WrapperImages { this.profiles = profiles; } // - - /** - * Handle unknown properties and print a message - * - * @param key - * @param value - */ - @JsonAnySetter - public void handleUnknown(String key, Object value) { - StringBuilder sb = new StringBuilder(); - sb.append("Unknown property: '").append(key); - sb.append("' value: '").append(value).append("'"); - logger.trace(sb.toString()); - } } diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperKeywords.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperKeywords.java index b10833a25..7d23a6e20 100644 --- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperKeywords.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperKeywords.java @@ -19,9 +19,7 @@ */ package com.omertron.themoviedbapi.wrapper; -import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonProperty; -import com.omertron.themoviedbapi.model.Collection; import com.omertron.themoviedbapi.model.Keyword; import java.util.List; import org.apache.log4j.Logger; @@ -30,71 +28,22 @@ import org.apache.log4j.Logger; * * @author stuart.boston */ -public class WrapperKeywords { - /* - * Logger - */ - - private static final Logger logger = Logger.getLogger(WrapperKeywords.class); +public class WrapperKeywords extends WrapperBase { /* * Properties */ - @JsonProperty("page") - private int page; @JsonProperty("results") private List results; - @JsonProperty("total_pages") - private int totalPages; - @JsonProperty("total_results") - private int totalResults; - // - public int getPage() { - return page; + public WrapperKeywords() { + super(Logger.getLogger(WrapperKeywords.class)); } public List getResults() { return results; } - public int getTotalPages() { - return totalPages; - } - - public int getTotalResults() { - return totalResults; - } - // - - // - public void setPage(int page) { - this.page = page; - } - public void setResults(List results) { this.results = results; } - - public void setTotalPages(int totalPages) { - this.totalPages = totalPages; - } - - public void setTotalResults(int totalResults) { - this.totalResults = totalResults; - } - // - - /** - * Handle unknown properties and print a message - * - * @param key - * @param value - */ - @JsonAnySetter - public void handleUnknown(String key, Object value) { - StringBuilder sb = new StringBuilder(); - sb.append("Unknown property: '").append(key); - sb.append("' value: '").append(value).append("'"); - logger.trace(sb.toString()); - } } diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovie.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovie.java index 7fd99fae9..ac99dea49 100644 --- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovie.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovie.java @@ -19,7 +19,6 @@ */ package com.omertron.themoviedbapi.wrapper; -import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonProperty; import com.omertron.themoviedbapi.model.MovieDb; import java.util.List; @@ -29,92 +28,34 @@ import org.apache.log4j.Logger; * * @author stuart.boston */ -public class WrapperMovie { - /* - * Logger - */ - - private static final Logger logger = Logger.getLogger(WrapperMovie.class); +public class WrapperMovie extends WrapperBase { /* * Properties */ - @JsonProperty("page") - private int page; + @JsonProperty("results") private List movies; - @JsonProperty("total_pages") - private int totalPages; - @JsonProperty("total_results") - private int totalResults; - @JsonProperty("id") - private int id; - // - public int getPage() { - return page; + public WrapperMovie() { + super(Logger.getLogger(WrapperMovie.class)); } public List getMovies() { return movies; } - public int getTotalPages() { - return totalPages; - } - - public int getTotalResults() { - return totalResults; - } - - public int getId() { - return id; - } - // - - // - public void setPage(int page) { - this.page = page; - } - - public void setMovies(List results) { - this.movies = results; - } - - public void setTotalPages(int totalPages) { - this.totalPages = totalPages; - } - - public void setTotalResults(int totalResults) { - this.totalResults = totalResults; - } - - public void setId(int id) { - this.id = id; - } - // - - /** - * Handle unknown properties and print a message - * - * @param key - * @param value - */ - @JsonAnySetter - public void handleUnknown(String key, Object value) { - StringBuilder sb = new StringBuilder(); - sb.append("Unknown property: '").append(key); - sb.append("' value: '").append(value).append("'"); - logger.trace(sb.toString()); + public void setMovies(List movies) { + this.movies = movies; } @Override public String toString() { StringBuilder sb = new StringBuilder("[ResultList=["); - sb.append("[page=").append(page); - sb.append("],[pageResults=").append(movies.size()); - sb.append("],[totalPages=").append(totalPages); - sb.append("],[totalResults=").append(totalResults); - sb.append("],[id=").append(id); + sb.append("[page=").append(getPage()); + sb.append("],[pageResults=").append(getMovies().size()); + sb.append("],[totalPages=").append(getTotalPages()); + sb.append("],[totalResults=").append(getTotalResults()); + sb.append("],[id=").append(getId()); sb.append("]]"); return sb.toString(); } diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovieList.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovieList.java index a080dab10..f05ed67da 100644 --- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovieList.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovieList.java @@ -19,9 +19,7 @@ */ package com.omertron.themoviedbapi.wrapper; -import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonProperty; -import com.omertron.themoviedbapi.model.AlternativeTitle; import com.omertron.themoviedbapi.model.MovieList; import java.util.List; import org.apache.log4j.Logger; @@ -30,81 +28,23 @@ import org.apache.log4j.Logger; * * @author Stuart */ -public class WrapperMovieList { - /* - * Logger - */ - - private static final Logger logger = Logger.getLogger(WrapperMovieList.class); +public class WrapperMovieList extends WrapperBase { /* * Properties */ - @JsonProperty("id") - private int id; - @JsonProperty("page") - private int page; + @JsonProperty("results") private List movieList; - @JsonProperty("total_pages") - private int totalPages; - @JsonProperty("total_results") - private int totalResults; - // - public int getId() { - return id; - } - - public int getPage() { - return page; + public WrapperMovieList() { + super(Logger.getLogger(WrapperMovieList.class)); } public List getMovieList() { return movieList; } - public int getTotalPages() { - return totalPages; - } - - public int getTotalResults() { - return totalResults; - } - // - - // - public void setId(int id) { - this.id = id; - } - - public void setPage(int page) { - this.page = page; - } - public void setMovieList(List movieList) { this.movieList = movieList; } - - public void setTotalPages(int totalPages) { - this.totalPages = totalPages; - } - - public void setTotalResults(int totalResults) { - this.totalResults = totalResults; - } - // - - /** - * Handle unknown properties and print a message - * - * @param key - * @param value - */ - @JsonAnySetter - public void handleUnknown(String key, Object value) { - StringBuilder sb = new StringBuilder(); - sb.append("Unknown property: '").append(key); - sb.append("' value: '").append(value).append("'"); - logger.trace(sb.toString()); - } } diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperPerson.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperPerson.java index cde1e8f6e..7e33aff4c 100644 --- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperPerson.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperPerson.java @@ -19,7 +19,6 @@ */ package com.omertron.themoviedbapi.wrapper; -import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonProperty; import com.omertron.themoviedbapi.model.Person; import java.util.List; @@ -29,70 +28,22 @@ import org.apache.log4j.Logger; * * @author stuart.boston */ -public class WrapperPerson { - /* - * Logger - */ - - private static final Logger logger = Logger.getLogger(WrapperPerson.class); +public class WrapperPerson extends WrapperBase { /* * Properties */ - @JsonProperty("page") - private int page; @JsonProperty("results") private List results; - @JsonProperty("total_pages") - private int totalPages; - @JsonProperty("total_results") - private int totalResults; - // - public int getPage() { - return page; + public WrapperPerson() { + super(Logger.getLogger(WrapperPerson.class)); } public List getResults() { return results; } - public int getTotalPages() { - return totalPages; - } - - public int getTotalResults() { - return totalResults; - } - // - - // - public void setPage(int page) { - this.page = page; - } - public void setResults(List results) { this.results = results; } - - public void setTotalPages(int totalPages) { - this.totalPages = totalPages; - } - - public void setTotalResults(int totalResults) { - this.totalResults = totalResults; - } - // - - /** - * Handle unknown properties and print a message - * @param key - * @param value - */ - @JsonAnySetter - public void handleUnknown(String key, Object value) { - StringBuilder sb = new StringBuilder(); - sb.append("Unknown property: '").append(key); - sb.append("' value: '").append(value).append("'"); - logger.trace(sb.toString()); - } } diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperPersonCredits.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperPersonCredits.java index 82d47cae9..65a2b509d 100644 --- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperPersonCredits.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperPersonCredits.java @@ -19,7 +19,6 @@ */ package com.omertron.themoviedbapi.wrapper; -import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonProperty; import com.omertron.themoviedbapi.model.PersonCredit; import java.util.List; @@ -29,60 +28,32 @@ import org.apache.log4j.Logger; * * @author stuart.boston */ -public class WrapperPersonCredits { - /* - * Logger - */ - - private static final Logger logger = Logger.getLogger(WrapperMovieCasts.class); +public class WrapperPersonCredits extends WrapperBase{ /* * Properties */ - @JsonProperty("id") - private int id; @JsonProperty("cast") private List cast; @JsonProperty("crew") private List crew; - // + public WrapperPersonCredits() { + super(Logger.getLogger(WrapperMovieCasts.class)); + } + public List getCast() { return cast; } + public void setCast(List cast) { + this.cast = cast; + } + public List getCrew() { return crew; } - public int getId() { - return id; - } - // - - // - public void setCast(List cast) { - this.cast = cast; - } - public void setCrew(List crew) { this.crew = crew; } - - public void setId(int id) { - this.id = id; - } - // - - /** - * Handle unknown properties and print a message - * @param key - * @param value - */ - @JsonAnySetter - public void handleUnknown(String key, Object value) { - StringBuilder sb = new StringBuilder(); - sb.append("Unknown property: '").append(key); - sb.append("' value: '").append(value).append("'"); - logger.trace(sb.toString()); - } } diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperTranslations.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperTranslations.java index 00b2487e7..466d52ca3 100644 --- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperTranslations.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperTranslations.java @@ -20,6 +20,7 @@ package com.omertron.themoviedbapi.wrapper; import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonProperty; import com.omertron.themoviedbapi.model.Translation; import java.util.List; import org.apache.log4j.Logger; @@ -37,7 +38,9 @@ public class WrapperTranslations { /* * Properties */ + @JsonProperty("id") private int id; + @JsonProperty("translations") private List translations; // From f17702626121c4c39dd6d7ea6198dd7b92152a48 Mon Sep 17 00:00:00 2001 From: Omertron <> Date: Sun, 3 Feb 2013 21:09:41 +0000 Subject: [PATCH 189/207] Added keyword searches --- .../omertron/themoviedbapi/TheMovieDbApi.java | 15 +- .../themoviedbapi/model/KeywordMovie.java | 145 ++++++++++++++++++ .../omertron/themoviedbapi/model/MovieDb.java | 15 +- .../wrapper/WrapperKeywordMovies.java | 50 ++++++ .../themoviedbapi/TheMovieDbApiTest.java | 25 +-- 5 files changed, 229 insertions(+), 21 deletions(-) create mode 100644 src/main/java/com/omertron/themoviedbapi/model/KeywordMovie.java create mode 100644 src/main/java/com/omertron/themoviedbapi/wrapper/WrapperKeywordMovies.java diff --git a/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java b/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java index f0369814d..9163820fa 100644 --- a/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java +++ b/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java @@ -1479,7 +1479,7 @@ public class TheMovieDbApi { * @return List of movies with the keyword * @throws MovieDbException */ - public List getKeywordMovies(String keywordId, String language, int page) throws MovieDbException { + public List getKeywordMovies(String keywordId, String language, int page) throws MovieDbException { ApiUrl apiUrl = new ApiUrl(this, BASE_KEYWORD, "/movies"); apiUrl.addArgument(PARAM_ID, keywordId); @@ -1495,8 +1495,8 @@ public class TheMovieDbApi { String webpage = WebBrowser.request(url); try { - WrapperMovieList wrapper = mapper.readValue(webpage, WrapperMovieList.class); - return wrapper.getMovieList(); + WrapperKeywordMovies wrapper = mapper.readValue(webpage, WrapperKeywordMovies.class); + return wrapper.getResults(); } catch (IOException ex) { logger.warn("Failed to get top rated movies: " + ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); @@ -1506,5 +1506,14 @@ public class TheMovieDbApi { // // // + + public void getMovieChangesList(int page, String startDate, String endDate) throws MovieDbException { + throw new MovieDbException(MovieDbExceptionType.UNKNOWN_CAUSE, "Not implemented yet"); + } + + public void getPersonChangesList(int page, String startDate, String endDate) throws MovieDbException { + throw new MovieDbException(MovieDbExceptionType.UNKNOWN_CAUSE, "Not implemented yet"); + } + // } diff --git a/src/main/java/com/omertron/themoviedbapi/model/KeywordMovie.java b/src/main/java/com/omertron/themoviedbapi/model/KeywordMovie.java new file mode 100644 index 000000000..75ffaeb42 --- /dev/null +++ b/src/main/java/com/omertron/themoviedbapi/model/KeywordMovie.java @@ -0,0 +1,145 @@ +/* + * Copyright (c) 2004-2013 Stuart Boston + * + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . + * + */ +package com.omertron.themoviedbapi.model; + +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import org.apache.log4j.Logger; + +/** + * + * @author Stuart + */ +public class KeywordMovie implements Serializable { + + private static final long serialVersionUID = 1L; + + /* + * Logger + */ + private static final Logger logger = Logger.getLogger(KeywordMovie.class); + /* + * Properties + */ + @JsonProperty("id") + private String id; + @JsonProperty("backdrop_path") + private String backdropPath; + @JsonProperty("original_title") + private String originalTitle; + @JsonProperty("release_date") + private String releaseDate; + @JsonProperty("poster_path") + private String posterPath; + @JsonProperty("title") + private String title; + @JsonProperty("vote_average") + private float voteAverage; + @JsonProperty("vote_count") + private double voteCount; + + // + public static long getSerialVersionUID() { + return serialVersionUID; + } + + public String getBackdropPath() { + return backdropPath; + } + + public String getId() { + return id; + } + + public String getOriginalTitle() { + return originalTitle; + } + + public String getReleaseDate() { + return releaseDate; + } + + public String getPosterPath() { + return posterPath; + } + + public String getTitle() { + return title; + } + + public float getVoteAverage() { + return voteAverage; + } + + public double getVoteCount() { + return voteCount; + } + // + + // + public void setBackdropPath(String backdropPath) { + this.backdropPath = backdropPath; + } + + public void setId(String id) { + this.id = id; + } + + public void setOriginalTitle(String originalTitle) { + this.originalTitle = originalTitle; + } + + public void setReleaseDate(String releaseDate) { + this.releaseDate = releaseDate; + } + + public void setPosterPath(String posterPath) { + this.posterPath = posterPath; + } + + public void setTitle(String title) { + this.title = title; + } + + public void setVoteAverage(float voteAverage) { + this.voteAverage = voteAverage; + } + + public void setVoteCount(double voteCount) { + this.voteCount = voteCount; + } + // + + /** + * Handle unknown properties and print a message + * + * @param key + * @param value + */ + @JsonAnySetter + public void handleUnknown(String key, Object value) { + StringBuilder sb = new StringBuilder(); + sb.append("Unknown property: '").append(key); + sb.append("' value: '").append(value).append("'"); + logger.trace(sb.toString()); + } + +} diff --git a/src/main/java/com/omertron/themoviedbapi/model/MovieDb.java b/src/main/java/com/omertron/themoviedbapi/model/MovieDb.java index 8b4b4f30a..481800b8c 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/MovieDb.java +++ b/src/main/java/com/omertron/themoviedbapi/model/MovieDb.java @@ -40,19 +40,19 @@ public class MovieDb implements Serializable { /* * Properties */ - @JsonProperty(("backdrop_path")) + @JsonProperty("backdrop_path") private String backdropPath; - @JsonProperty(("id")) + @JsonProperty("id") private int id; - @JsonProperty(("original_title")) + @JsonProperty("original_title") private String originalTitle; - @JsonProperty(("popularity")) + @JsonProperty("popularity") private float popularity; - @JsonProperty(("poster_path")) + @JsonProperty("poster_path") private String posterPath; - @JsonProperty(("release_date")) + @JsonProperty("release_date") private String releaseDate; - @JsonProperty(("title")) + @JsonProperty("title") private String title; @JsonProperty("adult") private boolean adult; @@ -275,7 +275,6 @@ public class MovieDb implements Serializable { } // - /** * Handle unknown properties and print a message * diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperKeywordMovies.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperKeywordMovies.java new file mode 100644 index 000000000..56d6daab1 --- /dev/null +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperKeywordMovies.java @@ -0,0 +1,50 @@ +/* + * Copyright (c) 2004-2013 Stuart Boston + * + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . + * + */ +package com.omertron.themoviedbapi.wrapper; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.omertron.themoviedbapi.model.Keyword; +import com.omertron.themoviedbapi.model.KeywordMovie; +import java.util.List; +import org.apache.log4j.Logger; + +/** + * + * @author stuart.boston + */ +public class WrapperKeywordMovies extends WrapperBase { + /* + * Properties + */ + @JsonProperty("results") + private List results; + + public WrapperKeywordMovies() { + super(Logger.getLogger(WrapperKeywordMovies.class)); + } + + public List getResults() { + return results; + } + + public void setResults(List results) { + this.results = results; + } +} diff --git a/src/test/java/com/omertron/themoviedbapi/TheMovieDbApiTest.java b/src/test/java/com/omertron/themoviedbapi/TheMovieDbApiTest.java index 77318fb90..d80057355 100644 --- a/src/test/java/com/omertron/themoviedbapi/TheMovieDbApiTest.java +++ b/src/test/java/com/omertron/themoviedbapi/TheMovieDbApiTest.java @@ -26,6 +26,7 @@ import com.omertron.themoviedbapi.model.CollectionInfo; import com.omertron.themoviedbapi.model.Company; import com.omertron.themoviedbapi.model.Genre; import com.omertron.themoviedbapi.model.Keyword; +import com.omertron.themoviedbapi.model.KeywordMovie; import com.omertron.themoviedbapi.model.MovieChanges; import com.omertron.themoviedbapi.model.MovieDb; import com.omertron.themoviedbapi.model.MovieDbList; @@ -74,7 +75,6 @@ public class TheMovieDbApiTest { private static final String LANGUAGE_ENGLISH = "en"; public TheMovieDbApiTest() throws MovieDbException { - tmdb = new TheMovieDbApi(API_KEY); } @BeforeClass @@ -82,6 +82,7 @@ public class TheMovieDbApiTest { BasicConfigurator.configure(); // Set the logger level to TRACE Logger.getRootLogger().setLevel(Level.TRACE); + tmdb = new TheMovieDbApi(API_KEY); } @AfterClass @@ -501,8 +502,9 @@ public class TheMovieDbApiTest { /** * Test of getSessionToken method, of class TheMovieDbApi. + * + * TODO: Cannot be tested without a HTTP authorisation: http://help.themoviedb.org/kb/api/user-authentication */ -// Cannot be tested without a HTTP authorisation: http://help.themoviedb.org/kb/api/user-authentication public void testGetSessionToken() throws Exception { logger.info("getSessionToken"); TokenAuthorisation token = tmdb.getAuthorisationToken(); @@ -536,7 +538,11 @@ public class TheMovieDbApiTest { assertTrue("No results found", results.size() > 0); } -// Do not test this until it is fixed + /** + * Test of getMovieChanges method,of class TheMovieDbApi + * + * TODO: Do not test this until it is fixed + */ public void testGetMovieChanges() throws Exception { logger.info("getMovieChanges"); @@ -606,8 +612,9 @@ public class TheMovieDbApiTest { /** * Test of postMovieRating method, of class TheMovieDbApi. + * + * TODO: Cannot be tested without a HTTP authorisation: http://help.themoviedb.org/kb/api/user-authentication */ - @Test public void testPostMovieRating() throws Exception { logger.info("postMovieRating"); String sessionId = ""; @@ -621,16 +628,14 @@ public class TheMovieDbApiTest { /** * Test of getPersonChanges method, of class TheMovieDbApi. + * + * TODO: Fix the method before testing */ - @Test public void testGetPersonChanges() throws Exception { logger.info("getPersonChanges"); - int personId = 0; String startDate = ""; String endDate = ""; - tmdb.getPersonChanges(personId, startDate, endDate); - // TODO review the generated test code and remove the default call to fail. - fail("The test case is a prototype."); + tmdb.getPersonChanges(ID_PERSON_BRUCE_WILLIS, startDate, endDate); } /** @@ -661,7 +666,7 @@ public class TheMovieDbApiTest { public void testGetKeywordMovies() throws Exception { logger.info("getKeywordMovies"); int page = 0; - List result = tmdb.getKeywordMovies(ID_KEYWORD, LANGUAGE_DEFAULT, page); + List result = tmdb.getKeywordMovies(ID_KEYWORD, LANGUAGE_DEFAULT, page); assertFalse("No keyword movies found", result.isEmpty()); } } From a7498c5c69fd5bf40893030b13da8d156a81ff8b Mon Sep 17 00:00:00 2001 From: Stuart Boston Date: Mon, 4 Feb 2013 16:04:47 +0000 Subject: [PATCH 190/207] Removed unnecessary locals --- .../java/com/omertron/themoviedbapi/TheMovieDbApi.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java b/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java index 9163820fa..c7ead62c9 100644 --- a/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java +++ b/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java @@ -1435,8 +1435,7 @@ public class TheMovieDbApi { String webpage = WebBrowser.request(url); try { - MovieDbList movieDbList = mapper.readValue(webpage, MovieDbList.class); - return movieDbList; + return mapper.readValue(webpage, MovieDbList.class); } catch (IOException ex) { logger.warn("Failed to get list: " + ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); @@ -1461,8 +1460,7 @@ public class TheMovieDbApi { String webpage = WebBrowser.request(url); try { - Keyword keyword = mapper.readValue(webpage, Keyword.class); - return keyword; + return mapper.readValue(webpage, Keyword.class); } catch (IOException ex) { logger.warn("Failed to get keyword: " + ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); @@ -1514,6 +1512,5 @@ public class TheMovieDbApi { public void getPersonChangesList(int page, String startDate, String endDate) throws MovieDbException { throw new MovieDbException(MovieDbExceptionType.UNKNOWN_CAUSE, "Not implemented yet"); } - // } From 618406b45944bfc401bbdf5ce1f4347d2b7bd510 Mon Sep 17 00:00:00 2001 From: Stuart Boston Date: Mon, 4 Feb 2013 16:15:10 +0000 Subject: [PATCH 191/207] Removed unused imports --- .../java/com/omertron/themoviedbapi/wrapper/WrapperBase.java | 3 --- .../omertron/themoviedbapi/wrapper/WrapperKeywordMovies.java | 1 - 2 files changed, 4 deletions(-) diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperBase.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperBase.java index a43a972d0..912554e45 100644 --- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperBase.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperBase.java @@ -21,9 +21,6 @@ package com.omertron.themoviedbapi.wrapper; import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonProperty; -import com.omertron.themoviedbapi.model.AlternativeTitle; -import com.omertron.themoviedbapi.model.MovieList; -import java.util.List; import org.apache.log4j.Logger; /** diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperKeywordMovies.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperKeywordMovies.java index 56d6daab1..5778f4ef8 100644 --- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperKeywordMovies.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperKeywordMovies.java @@ -20,7 +20,6 @@ package com.omertron.themoviedbapi.wrapper; import com.fasterxml.jackson.annotation.JsonProperty; -import com.omertron.themoviedbapi.model.Keyword; import com.omertron.themoviedbapi.model.KeywordMovie; import java.util.List; import org.apache.log4j.Logger; From 1b62ae2ff88fe990bc4b653b25a3a77d1e18d895 Mon Sep 17 00:00:00 2001 From: Omertron <> Date: Sun, 24 Feb 2013 18:58:27 +0000 Subject: [PATCH 192/207] Removed Log4J dependency and switched to SLF4J --- pom.xml | 16 +- .../omertron/themoviedbapi/TheMovieDbApi.java | 89 ++- .../themoviedbapi/model/AlternativeTitle.java | 231 +++--- .../omertron/themoviedbapi/model/Artwork.java | 415 +++++----- .../themoviedbapi/model/ChangeItem.java | 7 +- .../themoviedbapi/model/ChangeValue.java | 7 +- .../themoviedbapi/model/Collection.java | 7 +- .../themoviedbapi/model/CollectionInfo.java | 247 +++--- .../omertron/themoviedbapi/model/Company.java | 7 +- .../omertron/themoviedbapi/model/Genre.java | 233 +++--- .../omertron/themoviedbapi/model/Keyword.java | 235 +++--- .../themoviedbapi/model/KeywordMovie.java | 291 +++---- .../themoviedbapi/model/Language.java | 233 +++--- .../themoviedbapi/model/MovieChanges.java | 163 ++-- .../omertron/themoviedbapi/model/MovieDb.java | 707 +++++++++--------- .../themoviedbapi/model/MovieDbList.java | 7 +- .../themoviedbapi/model/MovieList.java | 291 +++---- .../omertron/themoviedbapi/model/Person.java | 645 ++++++++-------- .../themoviedbapi/model/PersonCast.java | 345 ++++----- .../themoviedbapi/model/PersonCredit.java | 7 +- .../themoviedbapi/model/PersonCrew.java | 7 +- .../model/ProductionCompany.java | 235 +++--- .../model/ProductionCountry.java | 235 +++--- .../themoviedbapi/model/ReleaseInfo.java | 261 +++---- .../themoviedbapi/model/StatusCode.java | 177 ++--- .../model/TmdbConfiguration.java | 413 +++++----- .../model/TokenAuthorisation.java | 7 +- .../themoviedbapi/model/TokenSession.java | 7 +- .../omertron/themoviedbapi/model/Trailer.java | 7 +- .../themoviedbapi/model/Translation.java | 261 +++---- .../omertron/themoviedbapi/tools/ApiUrl.java | 11 +- .../themoviedbapi/tools/FilteringLayout.java | 74 -- .../themoviedbapi/tools/WebBrowser.java | 7 +- .../wrapper/WrapperAlternativeTitles.java | 149 ++-- .../themoviedbapi/wrapper/WrapperBase.java | 205 ++--- .../themoviedbapi/wrapper/WrapperChanges.java | 7 +- .../wrapper/WrapperCollection.java | 5 +- .../themoviedbapi/wrapper/WrapperCompany.java | 5 +- .../wrapper/WrapperCompanyMovies.java | 125 ++-- .../themoviedbapi/wrapper/WrapperConfig.java | 7 +- .../themoviedbapi/wrapper/WrapperGenres.java | 133 ++-- .../themoviedbapi/wrapper/WrapperImages.java | 147 ++-- .../wrapper/WrapperKeywordMovies.java | 5 +- .../wrapper/WrapperKeywords.java | 5 +- .../themoviedbapi/wrapper/WrapperMovie.java | 125 ++-- .../wrapper/WrapperMovieCasts.java | 179 ++--- .../wrapper/WrapperMovieKeywords.java | 157 ++-- .../wrapper/WrapperMovieList.java | 101 +-- .../themoviedbapi/wrapper/WrapperPerson.java | 5 +- .../wrapper/WrapperPersonCredits.java | 5 +- .../wrapper/WrapperReleaseInfo.java | 157 ++-- .../wrapper/WrapperTrailers.java | 177 ++--- .../wrapper/WrapperTranslations.java | 157 ++-- src/main/resources/log4j-example.properties | 7 - .../themoviedbapi/TheMovieDbApiTest.java | 113 ++- 55 files changed, 3915 insertions(+), 3946 deletions(-) delete mode 100644 src/main/java/com/omertron/themoviedbapi/tools/FilteringLayout.java delete mode 100644 src/main/resources/log4j-example.properties diff --git a/pom.xml b/pom.xml index c000d6d7c..9234cb8eb 100644 --- a/pom.xml +++ b/pom.xml @@ -80,11 +80,6 @@ 4.11 test - - log4j - log4j - 1.2.17 - com.fasterxml.jackson.core jackson-core @@ -110,6 +105,17 @@ commons-lang3 3.1 + + org.slf4j + slf4j-api + 1.7.2 + + + org.slf4j + slf4j-jdk14 + 1.7.2 + test + diff --git a/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java b/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java index c7ead62c9..78b73e8d0 100644 --- a/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java +++ b/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java @@ -24,7 +24,6 @@ import com.omertron.themoviedbapi.MovieDbException.MovieDbExceptionType; import com.omertron.themoviedbapi.model.*; import com.omertron.themoviedbapi.tools.ApiUrl; import static com.omertron.themoviedbapi.tools.ApiUrl.*; -import com.omertron.themoviedbapi.tools.FilteringLayout; import com.omertron.themoviedbapi.tools.WebBrowser; import com.omertron.themoviedbapi.wrapper.*; import java.io.IOException; @@ -33,7 +32,8 @@ import java.net.URL; import java.util.ArrayList; import java.util.List; import org.apache.commons.lang3.StringUtils; -import org.apache.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * The MovieDb API

This is for version 3 of the API as specified here: http://help.themoviedb.org/kb/api/about-3 @@ -42,7 +42,7 @@ import org.apache.log4j.Logger; */ public class TheMovieDbApi { - private static final Logger logger = Logger.getLogger(TheMovieDbApi.class); + private static final Logger LOG = LoggerFactory.getLogger(TheMovieDbApi.class); private String apiKey; private TmdbConfiguration tmdbConfig; /* @@ -86,7 +86,6 @@ public class TheMovieDbApi { ApiUrl apiUrl = new ApiUrl(this, "configuration"); URL configUrl = apiUrl.buildUrl(); String webpage = WebBrowser.request(configUrl); - FilteringLayout.addReplacementString(apiKey); try { WrapperConfig wc = mapper.readValue(webpage, WrapperConfig.class); @@ -228,7 +227,7 @@ public class TheMovieDbApi { try { return (new URL(sb.toString())); } catch (MalformedURLException ex) { - logger.warn("Failed to create image URL: " + ex.getMessage()); + LOG.warn("Failed to create image URL: " + ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.INVALID_URL, sb.toString(), ex); } } @@ -256,7 +255,7 @@ public class TheMovieDbApi { try { return mapper.readValue(webpage, TokenAuthorisation.class); } catch (IOException ex) { - logger.warn("Failed to get Authorisation Token: " + ex.getMessage()); + LOG.warn("Failed to get Authorisation Token: " + ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.AUTHORISATION_FAILURE, webpage, ex); } } @@ -273,7 +272,7 @@ public class TheMovieDbApi { ApiUrl apiUrl = new ApiUrl(this, BASE_AUTH, "session/new"); if (!token.getSuccess()) { - logger.warn("Authorisation token was not successful!"); + LOG.warn("Authorisation token was not successful!"); throw new MovieDbException(MovieDbExceptionType.AUTHORISATION_FAILURE, "Authorisation token was not successful!"); } @@ -284,7 +283,7 @@ public class TheMovieDbApi { try { return mapper.readValue(webpage, TokenSession.class); } catch (IOException ex) { - logger.warn("Failed to get Session Token: " + ex.getMessage()); + LOG.warn("Failed to get Session Token: " + ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } @@ -312,7 +311,7 @@ public class TheMovieDbApi { try { return mapper.readValue(webpage, TokenSession.class); } catch (IOException ex) { - logger.warn("Failed to get Session Token: " + ex.getMessage()); + LOG.warn("Failed to get Session Token: " + ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } @@ -346,7 +345,7 @@ public class TheMovieDbApi { try { return mapper.readValue(webpage, MovieDb.class); } catch (IOException ex) { - logger.warn("Failed to get movie info: " + ex.getMessage()); + LOG.warn("Failed to get movie info: " + ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } @@ -374,7 +373,7 @@ public class TheMovieDbApi { try { return mapper.readValue(webpage, MovieDb.class); } catch (IOException ex) { - logger.warn("Failed to get movie info: " + ex.getMessage()); + LOG.warn("Failed to get movie info: " + ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } @@ -400,7 +399,7 @@ public class TheMovieDbApi { WrapperAlternativeTitles wrapper = mapper.readValue(webpage, WrapperAlternativeTitles.class); return wrapper.getTitles(); } catch (IOException ex) { - logger.warn("Failed to get movie alternative titles: " + ex.getMessage()); + LOG.warn("Failed to get movie alternative titles: " + ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } @@ -440,7 +439,7 @@ public class TheMovieDbApi { return people; } catch (IOException ex) { - logger.warn("Failed to get movie casts: " + ex.getMessage()); + LOG.warn("Failed to get movie casts: " + ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } @@ -480,7 +479,7 @@ public class TheMovieDbApi { return artwork; } catch (IOException ex) { - logger.warn("Failed to get movie images: " + ex.getMessage()); + LOG.warn("Failed to get movie images: " + ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } @@ -504,7 +503,7 @@ public class TheMovieDbApi { WrapperMovieKeywords wrapper = mapper.readValue(webpage, WrapperMovieKeywords.class); return wrapper.getKeywords(); } catch (IOException ex) { - logger.warn("Failed to get movie keywords: " + ex.getMessage()); + LOG.warn("Failed to get movie keywords: " + ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } @@ -528,7 +527,7 @@ public class TheMovieDbApi { WrapperReleaseInfo wrapper = mapper.readValue(webpage, WrapperReleaseInfo.class); return wrapper.getCountries(); } catch (IOException ex) { - logger.warn("Failed to get movie release information: " + ex.getMessage()); + LOG.warn("Failed to get movie release information: " + ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } @@ -570,7 +569,7 @@ public class TheMovieDbApi { } return trailers; } catch (IOException ex) { - logger.warn("Failed to get movie trailers: " + ex.getMessage()); + LOG.warn("Failed to get movie trailers: " + ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } @@ -592,7 +591,7 @@ public class TheMovieDbApi { WrapperTranslations wrapper = mapper.readValue(webpage, WrapperTranslations.class); return wrapper.getTranslations(); } catch (IOException ex) { - logger.warn("Failed to get movie tranlations: " + ex.getMessage()); + LOG.warn("Failed to get movie tranlations: " + ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } @@ -628,7 +627,7 @@ public class TheMovieDbApi { WrapperMovie wrapper = mapper.readValue(webpage, WrapperMovie.class); return wrapper.getMovies(); } catch (IOException ex) { - logger.warn("Failed to get similar movies: " + ex.getMessage()); + LOG.warn("Failed to get similar movies: " + ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } @@ -660,7 +659,7 @@ public class TheMovieDbApi { WrapperMovieList wrapper = mapper.readValue(webpage, WrapperMovieList.class); return wrapper.getMovieList(); } catch (IOException ex) { - logger.warn("Failed to get movie lists: " + ex.getMessage()); + LOG.warn("Failed to get movie lists: " + ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } @@ -703,7 +702,7 @@ public class TheMovieDbApi { WrapperChanges wrapper = mapper.readValue(webpage, WrapperChanges.class); return wrapper.getChanges(); } catch (IOException ex) { - logger.warn("Failed to get movie changes: " + ex.getMessage()); + LOG.warn("Failed to get movie changes: " + ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } @@ -721,7 +720,7 @@ public class TheMovieDbApi { try { return mapper.readValue(webpage, MovieDb.class); } catch (IOException ex) { - logger.warn("Failed to get latest movie: " + ex.getMessage()); + LOG.warn("Failed to get latest movie: " + ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } @@ -753,7 +752,7 @@ public class TheMovieDbApi { WrapperMovie wrapper = mapper.readValue(webpage, WrapperMovie.class); return wrapper.getMovies(); } catch (IOException ex) { - logger.warn("Failed to get upcoming movies: " + ex.getMessage()); + LOG.warn("Failed to get upcoming movies: " + ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } @@ -788,7 +787,7 @@ public class TheMovieDbApi { WrapperMovie wrapper = mapper.readValue(webpage, WrapperMovie.class); return wrapper.getMovies(); } catch (IOException ex) { - logger.warn("Failed to get now playing movies: " + ex.getMessage()); + LOG.warn("Failed to get now playing movies: " + ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } @@ -822,7 +821,7 @@ public class TheMovieDbApi { WrapperMovie wrapper = mapper.readValue(webpage, WrapperMovie.class); return wrapper.getMovies(); } catch (IOException ex) { - logger.warn("Failed to get popular movie list: " + ex.getMessage()); + LOG.warn("Failed to get popular movie list: " + ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } @@ -856,7 +855,7 @@ public class TheMovieDbApi { WrapperMovie wrapper = mapper.readValue(webpage, WrapperMovie.class); return wrapper.getMovies(); } catch (IOException ex) { - logger.warn("Failed to get top rated movies: " + ex.getMessage()); + LOG.warn("Failed to get top rated movies: " + ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } @@ -905,7 +904,7 @@ public class TheMovieDbApi { try { return mapper.readValue(webpage, CollectionInfo.class); } catch (IOException ex) { - logger.warn("Failed to get collection information: " + ex.getMessage()); + LOG.warn("Failed to get collection information: " + ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } @@ -946,7 +945,7 @@ public class TheMovieDbApi { return artwork; } catch (IOException ex) { - logger.warn("Failed to get collection images: " + ex.getMessage()); + LOG.warn("Failed to get collection images: " + ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } @@ -974,7 +973,7 @@ public class TheMovieDbApi { try { return mapper.readValue(webpage, Person.class); } catch (IOException ex) { - logger.warn("Failed to get movie info: " + ex.getMessage()); + LOG.warn("Failed to get movie info: " + ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } @@ -1012,7 +1011,7 @@ public class TheMovieDbApi { } return personCredits; } catch (IOException ex) { - logger.warn("Failed to get person credits: " + ex.getMessage()); + LOG.warn("Failed to get person credits: " + ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } @@ -1043,7 +1042,7 @@ public class TheMovieDbApi { } return personImages; } catch (IOException ex) { - logger.warn("Failed to get person images: " + ex.getMessage()); + LOG.warn("Failed to get person images: " + ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } @@ -1081,7 +1080,7 @@ public class TheMovieDbApi { try { return mapper.readValue(webpage, Person.class); } catch (IOException ex) { - logger.warn("Failed to get latest person: " + ex.getMessage()); + LOG.warn("Failed to get latest person: " + ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } @@ -1106,7 +1105,7 @@ public class TheMovieDbApi { try { return mapper.readValue(webpage, Company.class); } catch (IOException ex) { - logger.warn("Failed to get company information: " + ex.getMessage()); + LOG.warn("Failed to get company information: " + ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } @@ -1143,7 +1142,7 @@ public class TheMovieDbApi { WrapperCompanyMovies wrapper = mapper.readValue(webpage, WrapperCompanyMovies.class); return wrapper.getResults(); } catch (IOException ex) { - logger.warn("Failed to get company movies: " + ex.getMessage()); + LOG.warn("Failed to get company movies: " + ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } @@ -1169,7 +1168,7 @@ public class TheMovieDbApi { WrapperGenres wrapper = mapper.readValue(webpage, WrapperGenres.class); return wrapper.getGenres(); } catch (IOException ex) { - logger.warn("Failed to get genre list: " + ex.getMessage()); + LOG.warn("Failed to get genre list: " + ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } @@ -1204,7 +1203,7 @@ public class TheMovieDbApi { WrapperMovie wrapper = mapper.readValue(webpage, WrapperMovie.class); return wrapper.getMovies(); } catch (IOException ex) { - logger.warn("Failed to get genre movie list: " + ex.getMessage()); + LOG.warn("Failed to get genre movie list: " + ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } @@ -1249,7 +1248,7 @@ public class TheMovieDbApi { WrapperMovie wrapper = mapper.readValue(webpage, WrapperMovie.class); return wrapper.getMovies(); } catch (IOException ex) { - logger.warn("Failed to find movie: " + ex.getMessage()); + LOG.warn("Failed to find movie: " + ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } @@ -1285,7 +1284,7 @@ public class TheMovieDbApi { WrapperCollection wrapper = mapper.readValue(webpage, WrapperCollection.class); return wrapper.getResults(); } catch (IOException ex) { - logger.warn("Failed to find collection: " + ex.getMessage()); + LOG.warn("Failed to find collection: " + ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } @@ -1316,7 +1315,7 @@ public class TheMovieDbApi { WrapperPerson wrapper = mapper.readValue(webpage, WrapperPerson.class); return wrapper.getResults(); } catch (IOException ex) { - logger.warn("Failed to find person: " + ex.getMessage()); + LOG.warn("Failed to find person: " + ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } @@ -1351,7 +1350,7 @@ public class TheMovieDbApi { WrapperMovieList wrapper = mapper.readValue(webpage, WrapperMovieList.class); return wrapper.getMovieList(); } catch (IOException ex) { - logger.warn("Failed to find list: " + ex.getMessage()); + LOG.warn("Failed to find list: " + ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } @@ -1382,7 +1381,7 @@ public class TheMovieDbApi { WrapperCompany wrapper = mapper.readValue(webpage, WrapperCompany.class); return wrapper.getResults(); } catch (IOException ex) { - logger.warn("Failed to find company: " + ex.getMessage()); + LOG.warn("Failed to find company: " + ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } @@ -1412,7 +1411,7 @@ public class TheMovieDbApi { WrapperKeywords wrapper = mapper.readValue(webpage, WrapperKeywords.class); return wrapper.getResults(); } catch (IOException ex) { - logger.warn("Failed to find keyword: " + ex.getMessage()); + LOG.warn("Failed to find keyword: " + ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } @@ -1437,7 +1436,7 @@ public class TheMovieDbApi { try { return mapper.readValue(webpage, MovieDbList.class); } catch (IOException ex) { - logger.warn("Failed to get list: " + ex.getMessage()); + LOG.warn("Failed to get list: " + ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } @@ -1462,7 +1461,7 @@ public class TheMovieDbApi { try { return mapper.readValue(webpage, Keyword.class); } catch (IOException ex) { - logger.warn("Failed to get keyword: " + ex.getMessage()); + LOG.warn("Failed to get keyword: " + ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } @@ -1496,7 +1495,7 @@ public class TheMovieDbApi { WrapperKeywordMovies wrapper = mapper.readValue(webpage, WrapperKeywordMovies.class); return wrapper.getResults(); } catch (IOException ex) { - logger.warn("Failed to get top rated movies: " + ex.getMessage()); + LOG.warn("Failed to get top rated movies: " + ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } diff --git a/src/main/java/com/omertron/themoviedbapi/model/AlternativeTitle.java b/src/main/java/com/omertron/themoviedbapi/model/AlternativeTitle.java index 5a4ea1652..fc390e926 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/AlternativeTitle.java +++ b/src/main/java/com/omertron/themoviedbapi/model/AlternativeTitle.java @@ -1,115 +1,116 @@ -/* - * Copyright (c) 2004-2013 Stuart Boston - * - * This file is part of TheMovieDB API. - * - * TheMovieDB API is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * any later version. - * - * TheMovieDB API is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with TheMovieDB API. If not, see . - * - */ -package com.omertron.themoviedbapi.model; - -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonProperty; -import java.io.Serializable; -import org.apache.log4j.Logger; - -/** - * - * @author Stuart - */ -public class AlternativeTitle implements Serializable { - - private static final long serialVersionUID = 1L; - - /* - * Logger - */ - private static final Logger logger = Logger.getLogger(AlternativeTitle.class); - /* - * Properties - */ - @JsonProperty("iso_3166_1") - private String country; - @JsonProperty("title") - private String title; - - // - public String getCountry() { - return country; - } - - public String getTitle() { - return title; - } - // - - // - public void setCountry(String country) { - this.country = country; - } - - public void setTitle(String title) { - this.title = title; - } - // - - /** - * Handle unknown properties and print a message - * - * @param key - * @param value - */ - @JsonAnySetter - public void handleUnknown(String key, Object value) { - StringBuilder sb = new StringBuilder(); - sb.append("Unknown property: '").append(key); - sb.append("' value: '").append(value).append("'"); - logger.trace(sb.toString()); - } - - @Override - public boolean equals(Object obj) { - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - final AlternativeTitle other = (AlternativeTitle) obj; - if ((this.country == null) ? (other.country != null) : !this.country.equals(other.country)) { - return false; - } - if ((this.title == null) ? (other.title != null) : !this.title.equals(other.title)) { - return false; - } - return true; - } - - @Override - public int hashCode() { - int hash = 7; - hash = 89 * hash + (this.country != null ? this.country.hashCode() : 0); - hash = 89 * hash + (this.title != null ? this.title.hashCode() : 0); - return hash; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder("[AlternativeTitle="); - sb.append("[country=").append(country); - sb.append("],[title=").append(title); - sb.append("]]"); - return sb.toString(); - } -} +/* + * Copyright (c) 2004-2013 Stuart Boston + * + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . + * + */ +package com.omertron.themoviedbapi.model; + +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * + * @author Stuart + */ +public class AlternativeTitle implements Serializable { + + private static final long serialVersionUID = 1L; + + /* + * Logger + */ + private static final Logger LOG = LoggerFactory.getLogger(AlternativeTitle.class); + /* + * Properties + */ + @JsonProperty("iso_3166_1") + private String country; + @JsonProperty("title") + private String title; + + // + public String getCountry() { + return country; + } + + public String getTitle() { + return title; + } + // + + // + public void setCountry(String country) { + this.country = country; + } + + public void setTitle(String title) { + this.title = title; + } + // + + /** + * Handle unknown properties and print a message + * + * @param key + * @param value + */ + @JsonAnySetter + public void handleUnknown(String key, Object value) { + StringBuilder sb = new StringBuilder(); + sb.append("Unknown property: '").append(key); + sb.append("' value: '").append(value).append("'"); + LOG.trace(sb.toString()); + } + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final AlternativeTitle other = (AlternativeTitle) obj; + if ((this.country == null) ? (other.country != null) : !this.country.equals(other.country)) { + return false; + } + if ((this.title == null) ? (other.title != null) : !this.title.equals(other.title)) { + return false; + } + return true; + } + + @Override + public int hashCode() { + int hash = 7; + hash = 89 * hash + (this.country != null ? this.country.hashCode() : 0); + hash = 89 * hash + (this.title != null ? this.title.hashCode() : 0); + return hash; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("[AlternativeTitle="); + sb.append("[country=").append(country); + sb.append("],[title=").append(title); + sb.append("]]"); + return sb.toString(); + } +} diff --git a/src/main/java/com/omertron/themoviedbapi/model/Artwork.java b/src/main/java/com/omertron/themoviedbapi/model/Artwork.java index 1cee537ab..0c689a577 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/Artwork.java +++ b/src/main/java/com/omertron/themoviedbapi/model/Artwork.java @@ -1,207 +1,208 @@ -/* - * Copyright (c) 2004-2013 Stuart Boston - * - * This file is part of TheMovieDB API. - * - * TheMovieDB API is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * any later version. - * - * TheMovieDB API is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with TheMovieDB API. If not, see . - * - */ -package com.omertron.themoviedbapi.model; - -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonProperty; -import java.io.Serializable; -import org.apache.log4j.Logger; - -/** - * The artwork type information - * - * @author Stuart - */ -public class Artwork implements Serializable { - - private static final long serialVersionUID = 1L; - - /* - * Logger - */ - private static final Logger logger = Logger.getLogger(Artwork.class); - /* - * Properties - */ - @JsonProperty("aspect_ratio") - private float aspectRatio; - @JsonProperty("file_path") - private String filePath; - @JsonProperty("height") - private int height; - @JsonProperty("iso_639_1") - private String language; - @JsonProperty("width") - private int width; - @JsonProperty("vote_average") - private float voteAverage; - @JsonProperty("vote_count") - private int voteCount; - @JsonProperty("flag") - private String flag; - private ArtworkType artworkType = ArtworkType.POSTER; - - // - public ArtworkType getArtworkType() { - return artworkType; - } - - public float getAspectRatio() { - return aspectRatio; - } - - public String getFilePath() { - return filePath; - } - - public int getHeight() { - return height; - } - - public String getLanguage() { - return language; - } - - public int getWidth() { - return width; - } - - public float getVoteAverage() { - return voteAverage; - } - - public int getVoteCount() { - return voteCount; - } - - public String getFlag() { - return flag; - } - - // - - // - public void setArtworkType(ArtworkType artworkType) { - this.artworkType = artworkType; - } - - public void setAspectRatio(float aspectRatio) { - this.aspectRatio = aspectRatio; - } - - public void setFilePath(String filePath) { - this.filePath = filePath; - } - - public void setHeight(int height) { - this.height = height; - } - - public void setLanguage(String language) { - this.language = language; - } - - public void setWidth(int width) { - this.width = width; - } - - public void setVoteAverage(float voteAverage) { - this.voteAverage = voteAverage; - } - - public void setVoteCount(int voteCount) { - this.voteCount = voteCount; - } - - public void setFlag(String flag) { - this.flag = flag; - } - - // - - /** - * Handle unknown properties and print a message - * - * @param key - * @param value - */ - @JsonAnySetter - public void handleUnknown(String key, Object value) { - StringBuilder sb = new StringBuilder(); - sb.append("Unknown property: '").append(key); - sb.append("' value: '").append(value).append("'"); - logger.trace(sb.toString()); - } - - @Override - public boolean equals(Object obj) { - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - final Artwork other = (Artwork) obj; - if (Float.floatToIntBits(this.aspectRatio) != Float.floatToIntBits(other.aspectRatio)) { - return false; - } - if ((this.filePath == null) ? (other.filePath != null) : !this.filePath.equals(other.filePath)) { - return false; - } - if (this.height != other.height) { - return false; - } - if ((this.language == null) ? (other.language != null) : !this.language.equals(other.language)) { - return false; - } - if (this.width != other.width) { - return false; - } - if (this.artworkType != other.artworkType) { - return false; - } - return true; - } - - @Override - public int hashCode() { - int hash = 3; - hash = 71 * hash + Float.floatToIntBits(this.aspectRatio); - hash = 71 * hash + (this.filePath != null ? this.filePath.hashCode() : 0); - hash = 71 * hash + this.height; - hash = 71 * hash + (this.language != null ? this.language.hashCode() : 0); - hash = 71 * hash + this.width; - hash = 71 * hash + (this.artworkType != null ? this.artworkType.hashCode() : 0); - return hash; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder("[Artwork="); - sb.append("[aspectRatio=").append(aspectRatio); - sb.append("],[filePath=").append(filePath); - sb.append("],[height=").append(height); - sb.append("],[language=").append(language); - sb.append("],[width=").append(width); - sb.append("],[artworkType=").append(artworkType); - sb.append("]]"); - return sb.toString(); - } -} +/* + * Copyright (c) 2004-2013 Stuart Boston + * + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . + * + */ +package com.omertron.themoviedbapi.model; + +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * The artwork type information + * + * @author Stuart + */ +public class Artwork implements Serializable { + + private static final long serialVersionUID = 1L; + + /* + * Logger + */ + private static final Logger LOG = LoggerFactory.getLogger(Artwork.class); + /* + * Properties + */ + @JsonProperty("aspect_ratio") + private float aspectRatio; + @JsonProperty("file_path") + private String filePath; + @JsonProperty("height") + private int height; + @JsonProperty("iso_639_1") + private String language; + @JsonProperty("width") + private int width; + @JsonProperty("vote_average") + private float voteAverage; + @JsonProperty("vote_count") + private int voteCount; + @JsonProperty("flag") + private String flag; + private ArtworkType artworkType = ArtworkType.POSTER; + + // + public ArtworkType getArtworkType() { + return artworkType; + } + + public float getAspectRatio() { + return aspectRatio; + } + + public String getFilePath() { + return filePath; + } + + public int getHeight() { + return height; + } + + public String getLanguage() { + return language; + } + + public int getWidth() { + return width; + } + + public float getVoteAverage() { + return voteAverage; + } + + public int getVoteCount() { + return voteCount; + } + + public String getFlag() { + return flag; + } + + // + + // + public void setArtworkType(ArtworkType artworkType) { + this.artworkType = artworkType; + } + + public void setAspectRatio(float aspectRatio) { + this.aspectRatio = aspectRatio; + } + + public void setFilePath(String filePath) { + this.filePath = filePath; + } + + public void setHeight(int height) { + this.height = height; + } + + public void setLanguage(String language) { + this.language = language; + } + + public void setWidth(int width) { + this.width = width; + } + + public void setVoteAverage(float voteAverage) { + this.voteAverage = voteAverage; + } + + public void setVoteCount(int voteCount) { + this.voteCount = voteCount; + } + + public void setFlag(String flag) { + this.flag = flag; + } + + // + + /** + * Handle unknown properties and print a message + * + * @param key + * @param value + */ + @JsonAnySetter + public void handleUnknown(String key, Object value) { + StringBuilder sb = new StringBuilder(); + sb.append("Unknown property: '").append(key); + sb.append("' value: '").append(value).append("'"); + LOG.trace(sb.toString()); + } + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final Artwork other = (Artwork) obj; + if (Float.floatToIntBits(this.aspectRatio) != Float.floatToIntBits(other.aspectRatio)) { + return false; + } + if ((this.filePath == null) ? (other.filePath != null) : !this.filePath.equals(other.filePath)) { + return false; + } + if (this.height != other.height) { + return false; + } + if ((this.language == null) ? (other.language != null) : !this.language.equals(other.language)) { + return false; + } + if (this.width != other.width) { + return false; + } + if (this.artworkType != other.artworkType) { + return false; + } + return true; + } + + @Override + public int hashCode() { + int hash = 3; + hash = 71 * hash + Float.floatToIntBits(this.aspectRatio); + hash = 71 * hash + (this.filePath != null ? this.filePath.hashCode() : 0); + hash = 71 * hash + this.height; + hash = 71 * hash + (this.language != null ? this.language.hashCode() : 0); + hash = 71 * hash + this.width; + hash = 71 * hash + (this.artworkType != null ? this.artworkType.hashCode() : 0); + return hash; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("[Artwork="); + sb.append("[aspectRatio=").append(aspectRatio); + sb.append("],[filePath=").append(filePath); + sb.append("],[height=").append(height); + sb.append("],[language=").append(language); + sb.append("],[width=").append(width); + sb.append("],[artworkType=").append(artworkType); + sb.append("]]"); + return sb.toString(); + } +} diff --git a/src/main/java/com/omertron/themoviedbapi/model/ChangeItem.java b/src/main/java/com/omertron/themoviedbapi/model/ChangeItem.java index 9f065a544..a064a7712 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/ChangeItem.java +++ b/src/main/java/com/omertron/themoviedbapi/model/ChangeItem.java @@ -21,7 +21,8 @@ package com.omertron.themoviedbapi.model; import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonProperty; -import org.apache.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class ChangeItem { @@ -30,7 +31,7 @@ public class ChangeItem { /* * Logger */ - private static final Logger logger = Logger.getLogger(MovieChanges.class); + private static final Logger LOG = LoggerFactory.getLogger(MovieChanges.class); /* * Properties */ @@ -116,6 +117,6 @@ public class ChangeItem { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - logger.trace(sb.toString()); + LOG.trace(sb.toString()); } } diff --git a/src/main/java/com/omertron/themoviedbapi/model/ChangeValue.java b/src/main/java/com/omertron/themoviedbapi/model/ChangeValue.java index f9e7b9d29..b3cd2ff90 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/ChangeValue.java +++ b/src/main/java/com/omertron/themoviedbapi/model/ChangeValue.java @@ -21,7 +21,8 @@ package com.omertron.themoviedbapi.model; import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonProperty; -import org.apache.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class ChangeValue { @@ -30,7 +31,7 @@ public class ChangeValue { /* * Logger */ - private static final Logger logger = Logger.getLogger(MovieChanges.class); + private static final Logger LOG = LoggerFactory.getLogger(MovieChanges.class); /* * Properties */ @@ -122,6 +123,6 @@ public class ChangeValue { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - logger.trace(sb.toString()); + LOG.trace(sb.toString()); } } diff --git a/src/main/java/com/omertron/themoviedbapi/model/Collection.java b/src/main/java/com/omertron/themoviedbapi/model/Collection.java index 19a018c29..7df3b9647 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/Collection.java +++ b/src/main/java/com/omertron/themoviedbapi/model/Collection.java @@ -24,7 +24,8 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonRootName; import java.io.Serializable; import org.apache.commons.lang3.StringUtils; -import org.apache.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * @@ -37,7 +38,7 @@ public class Collection implements Serializable { /* * Logger */ - private static final Logger logger = Logger.getLogger(Collection.class); + private static final Logger LOG = LoggerFactory.getLogger(Collection.class); /* * Properties */ @@ -123,7 +124,7 @@ public class Collection implements Serializable { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - logger.trace(sb.toString()); + LOG.trace(sb.toString()); } @Override diff --git a/src/main/java/com/omertron/themoviedbapi/model/CollectionInfo.java b/src/main/java/com/omertron/themoviedbapi/model/CollectionInfo.java index 1c7e5dbb0..91a1fd475 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/CollectionInfo.java +++ b/src/main/java/com/omertron/themoviedbapi/model/CollectionInfo.java @@ -1,123 +1,124 @@ -/* - * Copyright (c) 2004-2013 Stuart Boston - * - * This file is part of TheMovieDB API. - * - * TheMovieDB API is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * any later version. - * - * TheMovieDB API is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with TheMovieDB API. If not, see . - * - */ -package com.omertron.themoviedbapi.model; - -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonProperty; -import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; -import org.apache.log4j.Logger; - -/** - * - * @author Stuart - */ -public class CollectionInfo implements Serializable { - - private static final long serialVersionUID = 1L; - /* - * Logger - */ - private static final Logger logger = Logger.getLogger(CollectionInfo.class); - /* - * Properties - */ - @JsonProperty("id") - private int id; - @JsonProperty("name") - private String name; - @JsonProperty("poster_path") - private String posterPath; - @JsonProperty("backdrop_path") - private String backdropPath; - @JsonProperty("parts") - private List parts = new ArrayList(); - - // - public String getBackdropPath() { - return backdropPath; - } - - public int getId() { - return id; - } - - public String getName() { - return name; - } - - public List getParts() { - return parts; - } - - public String getPosterPath() { - return posterPath; - } - // - - // - public void setBackdropPath(String backdropPath) { - this.backdropPath = backdropPath; - } - - public void setId(int id) { - this.id = id; - } - - public void setName(String name) { - this.name = name; - } - - public void setParts(List parts) { - this.parts = parts; - } - - public void setPosterPath(String posterPath) { - this.posterPath = posterPath; - } - // - - /** - * Handle unknown properties and print a message - * - * @param key - * @param value - */ - @JsonAnySetter - public void handleUnknown(String key, Object value) { - StringBuilder sb = new StringBuilder(); - sb.append("Unknown property: '").append(key); - sb.append("' value: '").append(value).append("'"); - logger.trace(sb.toString()); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder("[CollectionInfo="); - sb.append("[id=").append(id); - sb.append("],[name=").append(name); - sb.append("],[posterPath=").append(posterPath); - sb.append("],[backdropPath=").append(backdropPath); - sb.append("],[# of parts=").append(parts.size()); - sb.append("]]"); - return sb.toString(); - } -} +/* + * Copyright (c) 2004-2013 Stuart Boston + * + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . + * + */ +package com.omertron.themoviedbapi.model; + +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * + * @author Stuart + */ +public class CollectionInfo implements Serializable { + + private static final long serialVersionUID = 1L; + /* + * Logger + */ + private static final Logger LOG = LoggerFactory.getLogger(CollectionInfo.class); + /* + * Properties + */ + @JsonProperty("id") + private int id; + @JsonProperty("name") + private String name; + @JsonProperty("poster_path") + private String posterPath; + @JsonProperty("backdrop_path") + private String backdropPath; + @JsonProperty("parts") + private List parts = new ArrayList(); + + // + public String getBackdropPath() { + return backdropPath; + } + + public int getId() { + return id; + } + + public String getName() { + return name; + } + + public List getParts() { + return parts; + } + + public String getPosterPath() { + return posterPath; + } + // + + // + public void setBackdropPath(String backdropPath) { + this.backdropPath = backdropPath; + } + + public void setId(int id) { + this.id = id; + } + + public void setName(String name) { + this.name = name; + } + + public void setParts(List parts) { + this.parts = parts; + } + + public void setPosterPath(String posterPath) { + this.posterPath = posterPath; + } + // + + /** + * Handle unknown properties and print a message + * + * @param key + * @param value + */ + @JsonAnySetter + public void handleUnknown(String key, Object value) { + StringBuilder sb = new StringBuilder(); + sb.append("Unknown property: '").append(key); + sb.append("' value: '").append(value).append("'"); + LOG.trace(sb.toString()); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("[CollectionInfo="); + sb.append("[id=").append(id); + sb.append("],[name=").append(name); + sb.append("],[posterPath=").append(posterPath); + sb.append("],[backdropPath=").append(backdropPath); + sb.append("],[# of parts=").append(parts.size()); + sb.append("]]"); + return sb.toString(); + } +} diff --git a/src/main/java/com/omertron/themoviedbapi/model/Company.java b/src/main/java/com/omertron/themoviedbapi/model/Company.java index 036ec9284..47d9ccce2 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/Company.java +++ b/src/main/java/com/omertron/themoviedbapi/model/Company.java @@ -22,7 +22,8 @@ package com.omertron.themoviedbapi.model; import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonProperty; import java.io.Serializable; -import org.apache.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Company information @@ -33,7 +34,7 @@ public class Company implements Serializable { private static final long serialVersionUID = 1L; // Logger - private static final Logger logger = Logger.getLogger(Company.class); + private static final Logger LOG = LoggerFactory.getLogger(Company.class); private static final String DEFAULT_STRING = ""; // Properties @JsonProperty("id") @@ -122,7 +123,7 @@ public class Company implements Serializable { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - logger.trace(sb.toString()); + LOG.trace(sb.toString()); } @Override diff --git a/src/main/java/com/omertron/themoviedbapi/model/Genre.java b/src/main/java/com/omertron/themoviedbapi/model/Genre.java index 1d66a304c..2679c65c5 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/Genre.java +++ b/src/main/java/com/omertron/themoviedbapi/model/Genre.java @@ -1,116 +1,117 @@ -/* - * Copyright (c) 2004-2013 Stuart Boston - * - * This file is part of TheMovieDB API. - * - * TheMovieDB API is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * any later version. - * - * TheMovieDB API is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with TheMovieDB API. If not, see . - * - */ -package com.omertron.themoviedbapi.model; - -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonRootName; -import java.io.Serializable; -import org.apache.log4j.Logger; - -/** - * - * @author stuart.boston - */ -@JsonRootName("genre") -public class Genre implements Serializable { - - private static final long serialVersionUID = 1L; - /* - * Logger - */ - private static final Logger logger = Logger.getLogger(Genre.class); - /* - * Properties - */ - @JsonProperty("id") - private int id; - @JsonProperty("name") - private String name; - - // - public int getId() { - return id; - } - - public String getName() { - return name; - } - // - - // - public void setId(int id) { - this.id = id; - } - - public void setName(String name) { - this.name = name; - } - // - - /** - * Handle unknown properties and print a message - * - * @param key - * @param value - */ - @JsonAnySetter - public void handleUnknown(String key, Object value) { - StringBuilder sb = new StringBuilder(); - sb.append("Unknown property: '").append(key); - sb.append("' value: '").append(value).append("'"); - logger.trace(sb.toString()); - } - - @Override - public boolean equals(Object obj) { - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - final Genre other = (Genre) obj; - if (this.id != other.id) { - return false; - } - if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) { - return false; - } - return true; - } - - @Override - public int hashCode() { - int hash = 5; - hash = 53 * hash + this.id; - hash = 53 * hash + (this.name != null ? this.name.hashCode() : 0); - return hash; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder("[Genre="); - sb.append("[id=").append(id); - sb.append("],[name=").append(name); - sb.append("]]"); - return sb.toString(); - } -} +/* + * Copyright (c) 2004-2013 Stuart Boston + * + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . + * + */ +package com.omertron.themoviedbapi.model; + +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; +import java.io.Serializable; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * + * @author stuart.boston + */ +@JsonRootName("genre") +public class Genre implements Serializable { + + private static final long serialVersionUID = 1L; + /* + * Logger + */ + private static final Logger LOG = LoggerFactory.getLogger(Genre.class); + /* + * Properties + */ + @JsonProperty("id") + private int id; + @JsonProperty("name") + private String name; + + // + public int getId() { + return id; + } + + public String getName() { + return name; + } + // + + // + public void setId(int id) { + this.id = id; + } + + public void setName(String name) { + this.name = name; + } + // + + /** + * Handle unknown properties and print a message + * + * @param key + * @param value + */ + @JsonAnySetter + public void handleUnknown(String key, Object value) { + StringBuilder sb = new StringBuilder(); + sb.append("Unknown property: '").append(key); + sb.append("' value: '").append(value).append("'"); + LOG.trace(sb.toString()); + } + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final Genre other = (Genre) obj; + if (this.id != other.id) { + return false; + } + if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) { + return false; + } + return true; + } + + @Override + public int hashCode() { + int hash = 5; + hash = 53 * hash + this.id; + hash = 53 * hash + (this.name != null ? this.name.hashCode() : 0); + return hash; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("[Genre="); + sb.append("[id=").append(id); + sb.append("],[name=").append(name); + sb.append("]]"); + return sb.toString(); + } +} diff --git a/src/main/java/com/omertron/themoviedbapi/model/Keyword.java b/src/main/java/com/omertron/themoviedbapi/model/Keyword.java index c0d427e15..f5169c85c 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/Keyword.java +++ b/src/main/java/com/omertron/themoviedbapi/model/Keyword.java @@ -1,117 +1,118 @@ -/* - * Copyright (c) 2004-2013 Stuart Boston - * - * This file is part of TheMovieDB API. - * - * TheMovieDB API is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * any later version. - * - * TheMovieDB API is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with TheMovieDB API. If not, see . - * - */ -package com.omertron.themoviedbapi.model; - -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonRootName; -import java.io.Serializable; -import org.apache.log4j.Logger; - -/** - * - * @author stuart.boston - */ -@JsonRootName("keyword") -public class Keyword implements Serializable { - - private static final long serialVersionUID = 1L; - - /* - * Logger - */ - private static final Logger logger = Logger.getLogger(Keyword.class); - /* - * Properties - */ - @JsonProperty("id") - private int id; - @JsonProperty("name") - private String name; - - // - public int getId() { - return id; - } - - public String getName() { - return name; - } - // - - // - public void setId(int id) { - this.id = id; - } - - public void setName(String name) { - this.name = name; - } - // - - /** - * Handle unknown properties and print a message - * - * @param key - * @param value - */ - @JsonAnySetter - public void handleUnknown(String key, Object value) { - StringBuilder sb = new StringBuilder(); - sb.append("Unknown property: '").append(key); - sb.append("' value: '").append(value).append("'"); - logger.trace(sb.toString()); - } - - @Override - public boolean equals(Object obj) { - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - final Keyword other = (Keyword) obj; - if (this.id != other.id) { - return false; - } - if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) { - return false; - } - return true; - } - - @Override - public int hashCode() { - int hash = 3; - hash = 83 * hash + this.id; - hash = 83 * hash + (this.name != null ? this.name.hashCode() : 0); - return hash; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder("[Keyword="); - sb.append("[id=").append(id); - sb.append("],[name=").append(name); - sb.append("]]"); - return sb.toString(); - } -} +/* + * Copyright (c) 2004-2013 Stuart Boston + * + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . + * + */ +package com.omertron.themoviedbapi.model; + +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; +import java.io.Serializable; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * + * @author stuart.boston + */ +@JsonRootName("keyword") +public class Keyword implements Serializable { + + private static final long serialVersionUID = 1L; + + /* + * Logger + */ + private static final Logger LOG = LoggerFactory.getLogger(Keyword.class); + /* + * Properties + */ + @JsonProperty("id") + private int id; + @JsonProperty("name") + private String name; + + // + public int getId() { + return id; + } + + public String getName() { + return name; + } + // + + // + public void setId(int id) { + this.id = id; + } + + public void setName(String name) { + this.name = name; + } + // + + /** + * Handle unknown properties and print a message + * + * @param key + * @param value + */ + @JsonAnySetter + public void handleUnknown(String key, Object value) { + StringBuilder sb = new StringBuilder(); + sb.append("Unknown property: '").append(key); + sb.append("' value: '").append(value).append("'"); + LOG.trace(sb.toString()); + } + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final Keyword other = (Keyword) obj; + if (this.id != other.id) { + return false; + } + if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) { + return false; + } + return true; + } + + @Override + public int hashCode() { + int hash = 3; + hash = 83 * hash + this.id; + hash = 83 * hash + (this.name != null ? this.name.hashCode() : 0); + return hash; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("[Keyword="); + sb.append("[id=").append(id); + sb.append("],[name=").append(name); + sb.append("]]"); + return sb.toString(); + } +} diff --git a/src/main/java/com/omertron/themoviedbapi/model/KeywordMovie.java b/src/main/java/com/omertron/themoviedbapi/model/KeywordMovie.java index 75ffaeb42..bb97e0509 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/KeywordMovie.java +++ b/src/main/java/com/omertron/themoviedbapi/model/KeywordMovie.java @@ -1,145 +1,146 @@ -/* - * Copyright (c) 2004-2013 Stuart Boston - * - * This file is part of TheMovieDB API. - * - * TheMovieDB API is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * any later version. - * - * TheMovieDB API is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with TheMovieDB API. If not, see . - * - */ -package com.omertron.themoviedbapi.model; - -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonProperty; -import java.io.Serializable; -import org.apache.log4j.Logger; - -/** - * - * @author Stuart - */ -public class KeywordMovie implements Serializable { - - private static final long serialVersionUID = 1L; - - /* - * Logger - */ - private static final Logger logger = Logger.getLogger(KeywordMovie.class); - /* - * Properties - */ - @JsonProperty("id") - private String id; - @JsonProperty("backdrop_path") - private String backdropPath; - @JsonProperty("original_title") - private String originalTitle; - @JsonProperty("release_date") - private String releaseDate; - @JsonProperty("poster_path") - private String posterPath; - @JsonProperty("title") - private String title; - @JsonProperty("vote_average") - private float voteAverage; - @JsonProperty("vote_count") - private double voteCount; - - // - public static long getSerialVersionUID() { - return serialVersionUID; - } - - public String getBackdropPath() { - return backdropPath; - } - - public String getId() { - return id; - } - - public String getOriginalTitle() { - return originalTitle; - } - - public String getReleaseDate() { - return releaseDate; - } - - public String getPosterPath() { - return posterPath; - } - - public String getTitle() { - return title; - } - - public float getVoteAverage() { - return voteAverage; - } - - public double getVoteCount() { - return voteCount; - } - // - - // - public void setBackdropPath(String backdropPath) { - this.backdropPath = backdropPath; - } - - public void setId(String id) { - this.id = id; - } - - public void setOriginalTitle(String originalTitle) { - this.originalTitle = originalTitle; - } - - public void setReleaseDate(String releaseDate) { - this.releaseDate = releaseDate; - } - - public void setPosterPath(String posterPath) { - this.posterPath = posterPath; - } - - public void setTitle(String title) { - this.title = title; - } - - public void setVoteAverage(float voteAverage) { - this.voteAverage = voteAverage; - } - - public void setVoteCount(double voteCount) { - this.voteCount = voteCount; - } - // - - /** - * Handle unknown properties and print a message - * - * @param key - * @param value - */ - @JsonAnySetter - public void handleUnknown(String key, Object value) { - StringBuilder sb = new StringBuilder(); - sb.append("Unknown property: '").append(key); - sb.append("' value: '").append(value).append("'"); - logger.trace(sb.toString()); - } - -} +/* + * Copyright (c) 2004-2013 Stuart Boston + * + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . + * + */ +package com.omertron.themoviedbapi.model; + +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * + * @author Stuart + */ +public class KeywordMovie implements Serializable { + + private static final long serialVersionUID = 1L; + + /* + * Logger + */ + private static final Logger LOG = LoggerFactory.getLogger(KeywordMovie.class); + /* + * Properties + */ + @JsonProperty("id") + private String id; + @JsonProperty("backdrop_path") + private String backdropPath; + @JsonProperty("original_title") + private String originalTitle; + @JsonProperty("release_date") + private String releaseDate; + @JsonProperty("poster_path") + private String posterPath; + @JsonProperty("title") + private String title; + @JsonProperty("vote_average") + private float voteAverage; + @JsonProperty("vote_count") + private double voteCount; + + // + public static long getSerialVersionUID() { + return serialVersionUID; + } + + public String getBackdropPath() { + return backdropPath; + } + + public String getId() { + return id; + } + + public String getOriginalTitle() { + return originalTitle; + } + + public String getReleaseDate() { + return releaseDate; + } + + public String getPosterPath() { + return posterPath; + } + + public String getTitle() { + return title; + } + + public float getVoteAverage() { + return voteAverage; + } + + public double getVoteCount() { + return voteCount; + } + // + + // + public void setBackdropPath(String backdropPath) { + this.backdropPath = backdropPath; + } + + public void setId(String id) { + this.id = id; + } + + public void setOriginalTitle(String originalTitle) { + this.originalTitle = originalTitle; + } + + public void setReleaseDate(String releaseDate) { + this.releaseDate = releaseDate; + } + + public void setPosterPath(String posterPath) { + this.posterPath = posterPath; + } + + public void setTitle(String title) { + this.title = title; + } + + public void setVoteAverage(float voteAverage) { + this.voteAverage = voteAverage; + } + + public void setVoteCount(double voteCount) { + this.voteCount = voteCount; + } + // + + /** + * Handle unknown properties and print a message + * + * @param key + * @param value + */ + @JsonAnySetter + public void handleUnknown(String key, Object value) { + StringBuilder sb = new StringBuilder(); + sb.append("Unknown property: '").append(key); + sb.append("' value: '").append(value).append("'"); + LOG.trace(sb.toString()); + } + +} diff --git a/src/main/java/com/omertron/themoviedbapi/model/Language.java b/src/main/java/com/omertron/themoviedbapi/model/Language.java index 6bc47fb80..71bd87720 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/Language.java +++ b/src/main/java/com/omertron/themoviedbapi/model/Language.java @@ -1,116 +1,117 @@ -/* - * Copyright (c) 2004-2013 Stuart Boston - * - * This file is part of TheMovieDB API. - * - * TheMovieDB API is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * any later version. - * - * TheMovieDB API is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with TheMovieDB API. If not, see . - * - */ -package com.omertron.themoviedbapi.model; - -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonRootName; -import java.io.Serializable; -import org.apache.log4j.Logger; - -/** - * - * @author stuart.boston - */ -@JsonRootName("spoken_language") -public class Language implements Serializable { - - private static final long serialVersionUID = 1L; - /* - * Logger - */ - private static final Logger logger = Logger.getLogger(Language.class); - /* - * Properties - */ - @JsonProperty("iso_639_1") - private String isoCode; - @JsonProperty("name") - private String name; - - // - public String getIsoCode() { - return isoCode; - } - - public String getName() { - return name; - } - // - - // - public void setIsoCode(String isoCode) { - this.isoCode = isoCode; - } - - public void setName(String name) { - this.name = name; - } - // - - /** - * Handle unknown properties and print a message - * - * @param key - * @param value - */ - @JsonAnySetter - public void handleUnknown(String key, Object value) { - StringBuilder sb = new StringBuilder(); - sb.append("Unknown property: '").append(key); - sb.append("' value: '").append(value).append("'"); - logger.trace(sb.toString()); - } - - @Override - public boolean equals(Object obj) { - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - final Language other = (Language) obj; - if ((this.isoCode == null) ? (other.isoCode != null) : !this.isoCode.equals(other.isoCode)) { - return false; - } - if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) { - return false; - } - return true; - } - - @Override - public int hashCode() { - int hash = 7; - hash = 71 * hash + (this.isoCode != null ? this.isoCode.hashCode() : 0); - hash = 71 * hash + (this.name != null ? this.name.hashCode() : 0); - return hash; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder("[Language="); - sb.append("isoCode=").append(isoCode); - sb.append(", name=").append(name); - sb.append("]]"); - return sb.toString(); - } -} +/* + * Copyright (c) 2004-2013 Stuart Boston + * + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . + * + */ +package com.omertron.themoviedbapi.model; + +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; +import java.io.Serializable; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * + * @author stuart.boston + */ +@JsonRootName("spoken_language") +public class Language implements Serializable { + + private static final long serialVersionUID = 1L; + /* + * Logger + */ + private static final Logger LOG = LoggerFactory.getLogger(Language.class); + /* + * Properties + */ + @JsonProperty("iso_639_1") + private String isoCode; + @JsonProperty("name") + private String name; + + // + public String getIsoCode() { + return isoCode; + } + + public String getName() { + return name; + } + // + + // + public void setIsoCode(String isoCode) { + this.isoCode = isoCode; + } + + public void setName(String name) { + this.name = name; + } + // + + /** + * Handle unknown properties and print a message + * + * @param key + * @param value + */ + @JsonAnySetter + public void handleUnknown(String key, Object value) { + StringBuilder sb = new StringBuilder(); + sb.append("Unknown property: '").append(key); + sb.append("' value: '").append(value).append("'"); + LOG.trace(sb.toString()); + } + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final Language other = (Language) obj; + if ((this.isoCode == null) ? (other.isoCode != null) : !this.isoCode.equals(other.isoCode)) { + return false; + } + if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) { + return false; + } + return true; + } + + @Override + public int hashCode() { + int hash = 7; + hash = 71 * hash + (this.isoCode != null ? this.isoCode.hashCode() : 0); + hash = 71 * hash + (this.name != null ? this.name.hashCode() : 0); + return hash; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("[Language="); + sb.append("isoCode=").append(isoCode); + sb.append(", name=").append(name); + sb.append("]]"); + return sb.toString(); + } +} diff --git a/src/main/java/com/omertron/themoviedbapi/model/MovieChanges.java b/src/main/java/com/omertron/themoviedbapi/model/MovieChanges.java index 4c5f76bbf..b6e13f14b 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/MovieChanges.java +++ b/src/main/java/com/omertron/themoviedbapi/model/MovieChanges.java @@ -1,81 +1,82 @@ -/* - * Copyright (c) 2004-2013 Stuart Boston - * - * This file is part of TheMovieDB API. - * - * TheMovieDB API is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * any later version. - * - * TheMovieDB API is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with TheMovieDB API. If not, see . - * - */ -package com.omertron.themoviedbapi.model; - -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonProperty; -import java.io.Serializable; -import java.util.List; -import org.apache.log4j.Logger; - -/** - * - * @author Stuart - */ -public class MovieChanges implements Serializable { - - private static final long serialVersionUID = 1L; - - /* - * Logger - */ - private static final Logger logger = Logger.getLogger(MovieChanges.class); - /* - * Properties - */ - @JsonProperty("key") - private String key; - @JsonProperty("items") - private List items; - - // - public String getKey() { - return key; - } - - public List getItems() { - return items; - } - // - - // - public void setKey(String key) { - this.key = key; - } - - public void setItems(List items) { - this.items = items; - } - // - - /** - * Handle unknown properties and print a message - * - * @param key - * @param value - */ - @JsonAnySetter - public void handleUnknown(String key, Object value) { - StringBuilder sb = new StringBuilder(); - sb.append("Unknown property: '").append(key); - sb.append("' value: '").append(value).append("'"); - logger.trace(sb.toString()); - } -} +/* + * Copyright (c) 2004-2013 Stuart Boston + * + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . + * + */ +package com.omertron.themoviedbapi.model; + +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import java.util.List; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * + * @author Stuart + */ +public class MovieChanges implements Serializable { + + private static final long serialVersionUID = 1L; + + /* + * Logger + */ + private static final Logger LOG = LoggerFactory.getLogger(MovieChanges.class); + /* + * Properties + */ + @JsonProperty("key") + private String key; + @JsonProperty("items") + private List items; + + // + public String getKey() { + return key; + } + + public List getItems() { + return items; + } + // + + // + public void setKey(String key) { + this.key = key; + } + + public void setItems(List items) { + this.items = items; + } + // + + /** + * Handle unknown properties and print a message + * + * @param key + * @param value + */ + @JsonAnySetter + public void handleUnknown(String key, Object value) { + StringBuilder sb = new StringBuilder(); + sb.append("Unknown property: '").append(key); + sb.append("' value: '").append(value).append("'"); + LOG.trace(sb.toString()); + } +} diff --git a/src/main/java/com/omertron/themoviedbapi/model/MovieDb.java b/src/main/java/com/omertron/themoviedbapi/model/MovieDb.java index 481800b8c..e61d05a97 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/MovieDb.java +++ b/src/main/java/com/omertron/themoviedbapi/model/MovieDb.java @@ -1,353 +1,354 @@ -/* - * Copyright (c) 2004-2013 Stuart Boston - * - * This file is part of TheMovieDB API. - * - * TheMovieDB API is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * any later version. - * - * TheMovieDB API is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with TheMovieDB API. If not, see . - * - */ -package com.omertron.themoviedbapi.model; - -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonProperty; -import java.io.Serializable; -import java.util.List; -import org.apache.log4j.Logger; - -/** - * Movie Bean - * - * @author stuart.boston - */ -public class MovieDb implements Serializable { - - private static final long serialVersionUID = 1L; - /* - * Logger - */ - private static final Logger logger = Logger.getLogger(MovieDb.class); - /* - * Properties - */ - @JsonProperty("backdrop_path") - private String backdropPath; - @JsonProperty("id") - private int id; - @JsonProperty("original_title") - private String originalTitle; - @JsonProperty("popularity") - private float popularity; - @JsonProperty("poster_path") - private String posterPath; - @JsonProperty("release_date") - private String releaseDate; - @JsonProperty("title") - private String title; - @JsonProperty("adult") - private boolean adult; - @JsonProperty("belongs_to_collection") - private Collection belongsToCollection; - @JsonProperty("budget") - private long budget; - @JsonProperty("genres") - private List genres; - @JsonProperty("homepage") - private String homepage; - @JsonProperty("imdb_id") - private String imdbID; - @JsonProperty("overview") - private String overview; - @JsonProperty("production_companies") - private List productionCompanies; - @JsonProperty("production_countries") - private List productionCountries; - @JsonProperty("revenue") - private long revenue; - @JsonProperty("runtime") - private int runtime; - @JsonProperty("spoken_languages") - private List spokenLanguages; - @JsonProperty("tagline") - private String tagline; - @JsonProperty("vote_average") - private float voteAverage; - @JsonProperty("vote_count") - private int voteCount; - @JsonProperty("status") - private String status; - - // - public String getBackdropPath() { - return backdropPath; - } - - public int getId() { - return id; - } - - public String getOriginalTitle() { - return originalTitle; - } - - public float getPopularity() { - return popularity; - } - - public String getPosterPath() { - return posterPath; - } - - public String getReleaseDate() { - return releaseDate; - } - - public String getTitle() { - return title; - } - - public boolean isAdult() { - return adult; - } - - public Collection getBelongsToCollection() { - return belongsToCollection; - } - - public long getBudget() { - return budget; - } - - public List getGenres() { - return genres; - } - - public String getHomepage() { - return homepage; - } - - public String getImdbID() { - return imdbID; - } - - public String getOverview() { - return overview; - } - - public List getProductionCompanies() { - return productionCompanies; - } - - public List getProductionCountries() { - return productionCountries; - } - - public long getRevenue() { - return revenue; - } - - public int getRuntime() { - return runtime; - } - - public List getSpokenLanguages() { - return spokenLanguages; - } - - public String getTagline() { - return tagline; - } - - public float getVoteAverage() { - return voteAverage; - } - - public int getVoteCount() { - return voteCount; - } - - public String getStatus() { - return status; - } - // - - // - public void setBackdropPath(String backdropPath) { - this.backdropPath = backdropPath; - } - - public void setId(int id) { - this.id = id; - } - - public void setOriginalTitle(String originalTitle) { - this.originalTitle = originalTitle; - } - - public void setPopularity(float popularity) { - this.popularity = popularity; - } - - public void setPosterPath(String posterPath) { - this.posterPath = posterPath; - } - - public void setReleaseDate(String releaseDate) { - this.releaseDate = releaseDate; - } - - public void setTitle(String title) { - this.title = title; - } - - public void setAdult(boolean adult) { - this.adult = adult; - } - - public void setBelongsToCollection(Collection belongsToCollection) { - this.belongsToCollection = belongsToCollection; - } - - public void setBudget(long budget) { - this.budget = budget; - } - - public void setGenres(List genres) { - this.genres = genres; - } - - public void setHomepage(String homepage) { - this.homepage = homepage; - } - - public void setImdbID(String imdbID) { - this.imdbID = imdbID; - } - - public void setOverview(String overview) { - this.overview = overview; - } - - public void setProductionCompanies(List productionCompanies) { - this.productionCompanies = productionCompanies; - } - - public void setProductionCountries(List productionCountries) { - this.productionCountries = productionCountries; - } - - public void setRevenue(long revenue) { - this.revenue = revenue; - } - - public void setRuntime(int runtime) { - this.runtime = runtime; - } - - public void setSpokenLanguages(List spokenLanguages) { - this.spokenLanguages = spokenLanguages; - } - - public void setTagline(String tagline) { - this.tagline = tagline; - } - - public void setVoteAverage(float voteAverage) { - this.voteAverage = voteAverage; - } - - public void setVoteCount(int voteCount) { - this.voteCount = voteCount; - } - - public void setStatus(String status) { - this.status = status; - } - - // - /** - * Handle unknown properties and print a message - * - * @param key - * @param value - */ - @JsonAnySetter - public void handleUnknown(String key, Object value) { - StringBuilder sb = new StringBuilder(); - sb.append("Unknown property: '").append(key); - sb.append("' value: '").append(value).append("'"); - logger.trace(sb.toString()); - } - - // - @Override - public boolean equals(Object obj) { - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - final MovieDb other = (MovieDb) obj; - if (this.id != other.id) { - return false; - } - if ((this.imdbID == null) ? (other.imdbID != null) : !this.imdbID.equals(other.imdbID)) { - return false; - } - if (this.runtime != other.runtime) { - return false; - } - return true; - } - - @Override - public int hashCode() { - int hash = 5; - hash = 89 * hash + this.id; - hash = 89 * hash + (this.imdbID != null ? this.imdbID.hashCode() : 0); - hash = 89 * hash + this.runtime; - return hash; - } - // - - @Override - public String toString() { - StringBuilder sb = new StringBuilder("[MovieDB="); - sb.append("[backdropPath=").append(backdropPath); - sb.append("],[id=").append(id); - sb.append("],[originalTitle=").append(originalTitle); - sb.append("],[popularity=").append(popularity); - sb.append("],[posterPath=").append(posterPath); - sb.append("],[releaseDate=").append(releaseDate); - sb.append("],[title=").append(title); - sb.append("],[adult=").append(adult); - sb.append("],[belongsToCollection=").append(belongsToCollection); - sb.append("],[budget=").append(budget); - sb.append("],[genres=").append(genres); - sb.append("],[homepage=").append(homepage); - sb.append("],[imdbID=").append(imdbID); - sb.append("],[overview=").append(overview); - sb.append("],[productionCompanies=").append(productionCompanies); - sb.append("],[productionCountries=").append(productionCountries); - sb.append("],[revenue=").append(revenue); - sb.append("],[runtime=").append(runtime); - sb.append("],[spokenLanguages=").append(spokenLanguages); - sb.append("],[tagline=").append(tagline); - sb.append("],[voteAverage=").append(voteAverage); - sb.append("],[voteCount=").append(voteCount); - sb.append("],[status=").append(status); - sb.append("]]"); - return sb.toString(); - } -} +/* + * Copyright (c) 2004-2013 Stuart Boston + * + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . + * + */ +package com.omertron.themoviedbapi.model; + +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import java.util.List; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Movie Bean + * + * @author stuart.boston + */ +public class MovieDb implements Serializable { + + private static final long serialVersionUID = 1L; + /* + * Logger + */ + private static final Logger LOG = LoggerFactory.getLogger(MovieDb.class); + /* + * Properties + */ + @JsonProperty("backdrop_path") + private String backdropPath; + @JsonProperty("id") + private int id; + @JsonProperty("original_title") + private String originalTitle; + @JsonProperty("popularity") + private float popularity; + @JsonProperty("poster_path") + private String posterPath; + @JsonProperty("release_date") + private String releaseDate; + @JsonProperty("title") + private String title; + @JsonProperty("adult") + private boolean adult; + @JsonProperty("belongs_to_collection") + private Collection belongsToCollection; + @JsonProperty("budget") + private long budget; + @JsonProperty("genres") + private List genres; + @JsonProperty("homepage") + private String homepage; + @JsonProperty("imdb_id") + private String imdbID; + @JsonProperty("overview") + private String overview; + @JsonProperty("production_companies") + private List productionCompanies; + @JsonProperty("production_countries") + private List productionCountries; + @JsonProperty("revenue") + private long revenue; + @JsonProperty("runtime") + private int runtime; + @JsonProperty("spoken_languages") + private List spokenLanguages; + @JsonProperty("tagline") + private String tagline; + @JsonProperty("vote_average") + private float voteAverage; + @JsonProperty("vote_count") + private int voteCount; + @JsonProperty("status") + private String status; + + // + public String getBackdropPath() { + return backdropPath; + } + + public int getId() { + return id; + } + + public String getOriginalTitle() { + return originalTitle; + } + + public float getPopularity() { + return popularity; + } + + public String getPosterPath() { + return posterPath; + } + + public String getReleaseDate() { + return releaseDate; + } + + public String getTitle() { + return title; + } + + public boolean isAdult() { + return adult; + } + + public Collection getBelongsToCollection() { + return belongsToCollection; + } + + public long getBudget() { + return budget; + } + + public List getGenres() { + return genres; + } + + public String getHomepage() { + return homepage; + } + + public String getImdbID() { + return imdbID; + } + + public String getOverview() { + return overview; + } + + public List getProductionCompanies() { + return productionCompanies; + } + + public List getProductionCountries() { + return productionCountries; + } + + public long getRevenue() { + return revenue; + } + + public int getRuntime() { + return runtime; + } + + public List getSpokenLanguages() { + return spokenLanguages; + } + + public String getTagline() { + return tagline; + } + + public float getVoteAverage() { + return voteAverage; + } + + public int getVoteCount() { + return voteCount; + } + + public String getStatus() { + return status; + } + // + + // + public void setBackdropPath(String backdropPath) { + this.backdropPath = backdropPath; + } + + public void setId(int id) { + this.id = id; + } + + public void setOriginalTitle(String originalTitle) { + this.originalTitle = originalTitle; + } + + public void setPopularity(float popularity) { + this.popularity = popularity; + } + + public void setPosterPath(String posterPath) { + this.posterPath = posterPath; + } + + public void setReleaseDate(String releaseDate) { + this.releaseDate = releaseDate; + } + + public void setTitle(String title) { + this.title = title; + } + + public void setAdult(boolean adult) { + this.adult = adult; + } + + public void setBelongsToCollection(Collection belongsToCollection) { + this.belongsToCollection = belongsToCollection; + } + + public void setBudget(long budget) { + this.budget = budget; + } + + public void setGenres(List genres) { + this.genres = genres; + } + + public void setHomepage(String homepage) { + this.homepage = homepage; + } + + public void setImdbID(String imdbID) { + this.imdbID = imdbID; + } + + public void setOverview(String overview) { + this.overview = overview; + } + + public void setProductionCompanies(List productionCompanies) { + this.productionCompanies = productionCompanies; + } + + public void setProductionCountries(List productionCountries) { + this.productionCountries = productionCountries; + } + + public void setRevenue(long revenue) { + this.revenue = revenue; + } + + public void setRuntime(int runtime) { + this.runtime = runtime; + } + + public void setSpokenLanguages(List spokenLanguages) { + this.spokenLanguages = spokenLanguages; + } + + public void setTagline(String tagline) { + this.tagline = tagline; + } + + public void setVoteAverage(float voteAverage) { + this.voteAverage = voteAverage; + } + + public void setVoteCount(int voteCount) { + this.voteCount = voteCount; + } + + public void setStatus(String status) { + this.status = status; + } + + // + /** + * Handle unknown properties and print a message + * + * @param key + * @param value + */ + @JsonAnySetter + public void handleUnknown(String key, Object value) { + StringBuilder sb = new StringBuilder(); + sb.append("Unknown property: '").append(key); + sb.append("' value: '").append(value).append("'"); + LOG.trace(sb.toString()); + } + + // + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final MovieDb other = (MovieDb) obj; + if (this.id != other.id) { + return false; + } + if ((this.imdbID == null) ? (other.imdbID != null) : !this.imdbID.equals(other.imdbID)) { + return false; + } + if (this.runtime != other.runtime) { + return false; + } + return true; + } + + @Override + public int hashCode() { + int hash = 5; + hash = 89 * hash + this.id; + hash = 89 * hash + (this.imdbID != null ? this.imdbID.hashCode() : 0); + hash = 89 * hash + this.runtime; + return hash; + } + // + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("[MovieDB="); + sb.append("[backdropPath=").append(backdropPath); + sb.append("],[id=").append(id); + sb.append("],[originalTitle=").append(originalTitle); + sb.append("],[popularity=").append(popularity); + sb.append("],[posterPath=").append(posterPath); + sb.append("],[releaseDate=").append(releaseDate); + sb.append("],[title=").append(title); + sb.append("],[adult=").append(adult); + sb.append("],[belongsToCollection=").append(belongsToCollection); + sb.append("],[budget=").append(budget); + sb.append("],[genres=").append(genres); + sb.append("],[homepage=").append(homepage); + sb.append("],[imdbID=").append(imdbID); + sb.append("],[overview=").append(overview); + sb.append("],[productionCompanies=").append(productionCompanies); + sb.append("],[productionCountries=").append(productionCountries); + sb.append("],[revenue=").append(revenue); + sb.append("],[runtime=").append(runtime); + sb.append("],[spokenLanguages=").append(spokenLanguages); + sb.append("],[tagline=").append(tagline); + sb.append("],[voteAverage=").append(voteAverage); + sb.append("],[voteCount=").append(voteCount); + sb.append("],[status=").append(status); + sb.append("]]"); + return sb.toString(); + } +} diff --git a/src/main/java/com/omertron/themoviedbapi/model/MovieDbList.java b/src/main/java/com/omertron/themoviedbapi/model/MovieDbList.java index 464f341b2..d3c51c1b4 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/MovieDbList.java +++ b/src/main/java/com/omertron/themoviedbapi/model/MovieDbList.java @@ -23,7 +23,8 @@ import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonProperty; import java.util.Collections; import java.util.List; -import org.apache.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Wrapper for the MovieDbList function @@ -34,7 +35,7 @@ public class MovieDbList { * Logger */ - private static final Logger logger = Logger.getLogger(MovieDbList.class); + private static final Logger LOG = LoggerFactory.getLogger(MovieDbList.class); /* * Properties */ @@ -144,7 +145,7 @@ public class MovieDbList { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - logger.trace(sb.toString()); + LOG.trace(sb.toString()); } } diff --git a/src/main/java/com/omertron/themoviedbapi/model/MovieList.java b/src/main/java/com/omertron/themoviedbapi/model/MovieList.java index 0695a9c37..747cbe020 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/MovieList.java +++ b/src/main/java/com/omertron/themoviedbapi/model/MovieList.java @@ -1,145 +1,146 @@ -/* - * Copyright (c) 2004-2013 Stuart Boston - * - * This file is part of TheMovieDB API. - * - * TheMovieDB API is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * any later version. - * - * TheMovieDB API is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with TheMovieDB API. If not, see . - * - */ -package com.omertron.themoviedbapi.model; - -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonProperty; -import java.io.Serializable; -import org.apache.log4j.Logger; - -/** - * - * @author Stuart - */ -public class MovieList implements Serializable { - - private static final long serialVersionUID = 1L; - - /* - * Logger - */ - private static final Logger logger = Logger.getLogger(MovieList.class); - /* - * Properties - */ - @JsonProperty("description") - private String description; - @JsonProperty("favorite_count") - private int favoriteCount; - @JsonProperty("id") - private String id; - @JsonProperty("item_count") - private int itemCount; - @JsonProperty("iso_639_1") - private String language; - @JsonProperty("name") - private String name; - @JsonProperty("poster_path") - private String posterPath; - @JsonProperty("list_type") - private String listType; - - // - public String getDescription() { - return description; - } - - public int getFavoriteCount() { - return favoriteCount; - } - - public String getId() { - return id; - } - - public int getItemCount() { - return itemCount; - } - - public String getLanguage() { - return language; - } - - public String getName() { - return name; - } - - public String getPosterPath() { - return posterPath; - } - - public String getListType() { - return listType; - } - // - - // - public void setDescription(String description) { - this.description = description; - } - - public void setFavoriteCount(int favoriteCount) { - this.favoriteCount = favoriteCount; - } - - public void setId(String id) { - this.id = id; - } - - public void setItemCount(int itemCount) { - this.itemCount = itemCount; - } - - public void setLanguage(String language) { - this.language = language; - } - - public void setName(String name) { - this.name = name; - } - - public void setPosterPath(String posterPath) { - this.posterPath = posterPath; - } - - public void setListType(String listType) { - this.listType = listType; - } - // - - /** - * Handle unknown properties and print a message - * - * @param key - * @param value - */ - @JsonAnySetter - public void handleUnknown(String key, Object value) { - StringBuilder sb = new StringBuilder(); - sb.append("Unknown property: '").append(key); - sb.append("' value: '").append(value).append("'"); - logger.trace(sb.toString()); - } - - @Override - public String toString() { - return "MovieList{" + "description=" + description + ", favoriteCount=" + favoriteCount + ", id=" + id + ", itemCount=" + itemCount + ", language=" + language + ", name=" + name + ", posterPath=" + posterPath + '}'; - } -} +/* + * Copyright (c) 2004-2013 Stuart Boston + * + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . + * + */ +package com.omertron.themoviedbapi.model; + +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * + * @author Stuart + */ +public class MovieList implements Serializable { + + private static final long serialVersionUID = 1L; + + /* + * Logger + */ + private static final Logger LOG = LoggerFactory.getLogger(MovieList.class); + /* + * Properties + */ + @JsonProperty("description") + private String description; + @JsonProperty("favorite_count") + private int favoriteCount; + @JsonProperty("id") + private String id; + @JsonProperty("item_count") + private int itemCount; + @JsonProperty("iso_639_1") + private String language; + @JsonProperty("name") + private String name; + @JsonProperty("poster_path") + private String posterPath; + @JsonProperty("list_type") + private String listType; + + // + public String getDescription() { + return description; + } + + public int getFavoriteCount() { + return favoriteCount; + } + + public String getId() { + return id; + } + + public int getItemCount() { + return itemCount; + } + + public String getLanguage() { + return language; + } + + public String getName() { + return name; + } + + public String getPosterPath() { + return posterPath; + } + + public String getListType() { + return listType; + } + // + + // + public void setDescription(String description) { + this.description = description; + } + + public void setFavoriteCount(int favoriteCount) { + this.favoriteCount = favoriteCount; + } + + public void setId(String id) { + this.id = id; + } + + public void setItemCount(int itemCount) { + this.itemCount = itemCount; + } + + public void setLanguage(String language) { + this.language = language; + } + + public void setName(String name) { + this.name = name; + } + + public void setPosterPath(String posterPath) { + this.posterPath = posterPath; + } + + public void setListType(String listType) { + this.listType = listType; + } + // + + /** + * Handle unknown properties and print a message + * + * @param key + * @param value + */ + @JsonAnySetter + public void handleUnknown(String key, Object value) { + StringBuilder sb = new StringBuilder(); + sb.append("Unknown property: '").append(key); + sb.append("' value: '").append(value).append("'"); + LOG.trace(sb.toString()); + } + + @Override + public String toString() { + return "MovieList{" + "description=" + description + ", favoriteCount=" + favoriteCount + ", id=" + id + ", itemCount=" + itemCount + ", language=" + language + ", name=" + name + ", posterPath=" + posterPath + '}'; + } +} diff --git a/src/main/java/com/omertron/themoviedbapi/model/Person.java b/src/main/java/com/omertron/themoviedbapi/model/Person.java index 5f8fe967e..b008202c4 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/Person.java +++ b/src/main/java/com/omertron/themoviedbapi/model/Person.java @@ -1,322 +1,323 @@ -/* - * Copyright (c) 2004-2013 Stuart Boston - * - * This file is part of TheMovieDB API. - * - * TheMovieDB API is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * any later version. - * - * TheMovieDB API is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with TheMovieDB API. If not, see . - * - */ -package com.omertron.themoviedbapi.model; - -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonProperty; -import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; -import org.apache.log4j.Logger; - -/** - * - * @author stuart.boston - */ -public class Person implements Serializable { - - private static final long serialVersionUID = 1L; - - /* - * Logger - */ - private static final Logger logger = Logger.getLogger(Person.class); - - /* - * Static fields for default cast information - */ - private static final String CAST_DEPARTMENT = "acting"; - private static final String CAST_JOB = "actor"; - private static final String DEFAULT_STRING = ""; - /* - * Properties - */ - @JsonProperty("id") - private int id = -1; - @JsonProperty("name") - private String name = ""; - @JsonProperty("profile_path") - private String profilePath = DEFAULT_STRING; - private PersonType personType = PersonType.PERSON; - private String department = DEFAULT_STRING; // Crew - private String job = DEFAULT_STRING; // Crew - private String character = DEFAULT_STRING; // Cast - private int order = -1; // Cast - @JsonProperty("adult") - private boolean adult = false; // Person info - @JsonProperty("also_known_as") - private List aka = new ArrayList(); - @JsonProperty("biography") - private String biography = DEFAULT_STRING; - @JsonProperty("birthday") - private String birthday = DEFAULT_STRING; - @JsonProperty("deathday") - private String deathday = DEFAULT_STRING; - @JsonProperty("homepage") - private String homepage = DEFAULT_STRING; - @JsonProperty("place_of_birth") - private String birthplace = DEFAULT_STRING; - - /** - * Add a crew member - * - * @param id - * @param name - * @param profilePath - * @param department - * @param job - */ - public void addCrew(int id, String name, String profilePath, String department, String job) { - this.personType = PersonType.CREW; - this.id = id; - this.name = name; - this.profilePath = profilePath; - this.department = department; - this.job = job; - this.character = ""; - this.order = -1; - } - - /** - * Add a cast member - * - * @param id - * @param name - * @param profilePath - * @param character - * @param order - */ - public void addCast(int id, String name, String profilePath, String character, int order) { - this.personType = PersonType.CAST; - this.id = id; - this.name = name; - this.profilePath = profilePath; - this.character = character; - this.order = order; - this.department = CAST_DEPARTMENT; - this.job = CAST_JOB; - } - - // - public String getCharacter() { - return character; - } - - public String getDepartment() { - return department; - } - - public int getId() { - return id; - } - - public String getJob() { - return job; - } - - public String getName() { - return name; - } - - public int getOrder() { - return order; - } - - public PersonType getPersonType() { - return personType; - } - - public String getProfilePath() { - return profilePath; - } - - public boolean isAdult() { - return adult; - } - - public List getAka() { - return aka; - } - - public String getBiography() { - return biography; - } - - public String getBirthday() { - return birthday; - } - - public String getBirthplace() { - return birthplace; - } - - public String getDeathday() { - return deathday; - } - - public String getHomepage() { - return homepage; - } - // - - // - public void setCharacter(String character) { - this.character = character; - } - - public void setDepartment(String department) { - this.department = department; - } - - public void setId(int id) { - this.id = id; - } - - public void setJob(String job) { - this.job = job; - } - - public void setName(String name) { - this.name = name; - } - - public void setOrder(int order) { - this.order = order; - } - - public void setPersonType(PersonType personType) { - this.personType = personType; - } - - public void setProfilePath(String profilePath) { - this.profilePath = profilePath; - } - - public void setAdult(boolean adult) { - this.adult = adult; - } - - public void setAka(List aka) { - this.aka = aka; - } - - public void setBiography(String biography) { - this.biography = biography; - } - - public void setBirthday(String birthday) { - this.birthday = birthday; - } - - public void setBirthplace(String birthplace) { - this.birthplace = birthplace; - } - - public void setDeathday(String deathday) { - this.deathday = deathday; - } - - public void setHomepage(String homepage) { - this.homepage = homepage; - } - // - - /** - * Handle unknown properties and print a message - * - * @param key - * @param value - */ - @JsonAnySetter - public void handleUnknown(String key, Object value) { - StringBuilder sb = new StringBuilder(); - sb.append("Unknown property: '").append(key); - sb.append("' value: '").append(value).append("'"); - logger.trace(sb.toString()); - } - - @Override - public boolean equals(Object obj) { - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - final Person other = (Person) obj; - if (this.id != other.id) { - return false; - } - if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) { - return false; - } - if ((this.profilePath == null) ? (other.profilePath != null) : !this.profilePath.equals(other.profilePath)) { - return false; - } - if (this.personType != other.personType) { - return false; - } - if ((this.department == null) ? (other.department != null) : !this.department.equals(other.department)) { - return false; - } - if ((this.job == null) ? (other.job != null) : !this.job.equals(other.job)) { - return false; - } - if ((this.character == null) ? (other.character != null) : !this.character.equals(other.character)) { - return false; - } - return true; - } - - @Override - public int hashCode() { - int hash = 3; - hash = 37 * hash + this.id; - hash = 37 * hash + (this.name != null ? this.name.hashCode() : 0); - hash = 37 * hash + (this.profilePath != null ? this.profilePath.hashCode() : 0); - hash = 37 * hash + (this.personType != null ? this.personType.hashCode() : 0); - hash = 37 * hash + (this.department != null ? this.department.hashCode() : 0); - hash = 37 * hash + (this.job != null ? this.job.hashCode() : 0); - hash = 37 * hash + (this.character != null ? this.character.hashCode() : 0); - return hash; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder("[Person="); - sb.append("[id=").append(id); - sb.append("],[name=").append(name); - sb.append("],[profilePath=").append(profilePath); - sb.append("],[personType=").append(personType); - sb.append("],[department=").append(department); - sb.append("],[job=").append(job); - sb.append("],[character=").append(character); - sb.append("],[order=").append(order); - sb.append("],[adult=").append(adult); - sb.append("],[=aka").append(aka.toString()); - sb.append("],[biography=").append(biography); - sb.append("],[birthday=").append(birthday); - sb.append("],[deathday=").append(deathday); - sb.append("],[homepage=").append(homepage); - sb.append("],[birthplace=").append(birthplace); - sb.append("]]"); - return sb.toString(); - } -} +/* + * Copyright (c) 2004-2013 Stuart Boston + * + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . + * + */ +package com.omertron.themoviedbapi.model; + +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import java.util.ArrayList; +import java.util.List; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * + * @author stuart.boston + */ +public class Person implements Serializable { + + private static final long serialVersionUID = 1L; + + /* + * Logger + */ + private static final Logger LOG = LoggerFactory.getLogger(Person.class); + + /* + * Static fields for default cast information + */ + private static final String CAST_DEPARTMENT = "acting"; + private static final String CAST_JOB = "actor"; + private static final String DEFAULT_STRING = ""; + /* + * Properties + */ + @JsonProperty("id") + private int id = -1; + @JsonProperty("name") + private String name = ""; + @JsonProperty("profile_path") + private String profilePath = DEFAULT_STRING; + private PersonType personType = PersonType.PERSON; + private String department = DEFAULT_STRING; // Crew + private String job = DEFAULT_STRING; // Crew + private String character = DEFAULT_STRING; // Cast + private int order = -1; // Cast + @JsonProperty("adult") + private boolean adult = false; // Person info + @JsonProperty("also_known_as") + private List aka = new ArrayList(); + @JsonProperty("biography") + private String biography = DEFAULT_STRING; + @JsonProperty("birthday") + private String birthday = DEFAULT_STRING; + @JsonProperty("deathday") + private String deathday = DEFAULT_STRING; + @JsonProperty("homepage") + private String homepage = DEFAULT_STRING; + @JsonProperty("place_of_birth") + private String birthplace = DEFAULT_STRING; + + /** + * Add a crew member + * + * @param id + * @param name + * @param profilePath + * @param department + * @param job + */ + public void addCrew(int id, String name, String profilePath, String department, String job) { + this.personType = PersonType.CREW; + this.id = id; + this.name = name; + this.profilePath = profilePath; + this.department = department; + this.job = job; + this.character = ""; + this.order = -1; + } + + /** + * Add a cast member + * + * @param id + * @param name + * @param profilePath + * @param character + * @param order + */ + public void addCast(int id, String name, String profilePath, String character, int order) { + this.personType = PersonType.CAST; + this.id = id; + this.name = name; + this.profilePath = profilePath; + this.character = character; + this.order = order; + this.department = CAST_DEPARTMENT; + this.job = CAST_JOB; + } + + // + public String getCharacter() { + return character; + } + + public String getDepartment() { + return department; + } + + public int getId() { + return id; + } + + public String getJob() { + return job; + } + + public String getName() { + return name; + } + + public int getOrder() { + return order; + } + + public PersonType getPersonType() { + return personType; + } + + public String getProfilePath() { + return profilePath; + } + + public boolean isAdult() { + return adult; + } + + public List getAka() { + return aka; + } + + public String getBiography() { + return biography; + } + + public String getBirthday() { + return birthday; + } + + public String getBirthplace() { + return birthplace; + } + + public String getDeathday() { + return deathday; + } + + public String getHomepage() { + return homepage; + } + // + + // + public void setCharacter(String character) { + this.character = character; + } + + public void setDepartment(String department) { + this.department = department; + } + + public void setId(int id) { + this.id = id; + } + + public void setJob(String job) { + this.job = job; + } + + public void setName(String name) { + this.name = name; + } + + public void setOrder(int order) { + this.order = order; + } + + public void setPersonType(PersonType personType) { + this.personType = personType; + } + + public void setProfilePath(String profilePath) { + this.profilePath = profilePath; + } + + public void setAdult(boolean adult) { + this.adult = adult; + } + + public void setAka(List aka) { + this.aka = aka; + } + + public void setBiography(String biography) { + this.biography = biography; + } + + public void setBirthday(String birthday) { + this.birthday = birthday; + } + + public void setBirthplace(String birthplace) { + this.birthplace = birthplace; + } + + public void setDeathday(String deathday) { + this.deathday = deathday; + } + + public void setHomepage(String homepage) { + this.homepage = homepage; + } + // + + /** + * Handle unknown properties and print a message + * + * @param key + * @param value + */ + @JsonAnySetter + public void handleUnknown(String key, Object value) { + StringBuilder sb = new StringBuilder(); + sb.append("Unknown property: '").append(key); + sb.append("' value: '").append(value).append("'"); + LOG.trace(sb.toString()); + } + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final Person other = (Person) obj; + if (this.id != other.id) { + return false; + } + if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) { + return false; + } + if ((this.profilePath == null) ? (other.profilePath != null) : !this.profilePath.equals(other.profilePath)) { + return false; + } + if (this.personType != other.personType) { + return false; + } + if ((this.department == null) ? (other.department != null) : !this.department.equals(other.department)) { + return false; + } + if ((this.job == null) ? (other.job != null) : !this.job.equals(other.job)) { + return false; + } + if ((this.character == null) ? (other.character != null) : !this.character.equals(other.character)) { + return false; + } + return true; + } + + @Override + public int hashCode() { + int hash = 3; + hash = 37 * hash + this.id; + hash = 37 * hash + (this.name != null ? this.name.hashCode() : 0); + hash = 37 * hash + (this.profilePath != null ? this.profilePath.hashCode() : 0); + hash = 37 * hash + (this.personType != null ? this.personType.hashCode() : 0); + hash = 37 * hash + (this.department != null ? this.department.hashCode() : 0); + hash = 37 * hash + (this.job != null ? this.job.hashCode() : 0); + hash = 37 * hash + (this.character != null ? this.character.hashCode() : 0); + return hash; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("[Person="); + sb.append("[id=").append(id); + sb.append("],[name=").append(name); + sb.append("],[profilePath=").append(profilePath); + sb.append("],[personType=").append(personType); + sb.append("],[department=").append(department); + sb.append("],[job=").append(job); + sb.append("],[character=").append(character); + sb.append("],[order=").append(order); + sb.append("],[adult=").append(adult); + sb.append("],[=aka").append(aka.toString()); + sb.append("],[biography=").append(biography); + sb.append("],[birthday=").append(birthday); + sb.append("],[deathday=").append(deathday); + sb.append("],[homepage=").append(homepage); + sb.append("],[birthplace=").append(birthplace); + sb.append("]]"); + return sb.toString(); + } +} diff --git a/src/main/java/com/omertron/themoviedbapi/model/PersonCast.java b/src/main/java/com/omertron/themoviedbapi/model/PersonCast.java index c4cdb5f04..0f26edaa2 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/PersonCast.java +++ b/src/main/java/com/omertron/themoviedbapi/model/PersonCast.java @@ -1,172 +1,173 @@ -/* - * Copyright (c) 2004-2013 Stuart Boston - * - * This file is part of TheMovieDB API. - * - * TheMovieDB API is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * any later version. - * - * TheMovieDB API is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with TheMovieDB API. If not, see . - * - */ -package com.omertron.themoviedbapi.model; - -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonProperty; -import java.io.Serializable; -import org.apache.log4j.Logger; - -/** - * - * @author Stuart - */ -public class PersonCast implements Serializable { - - private static final long serialVersionUID = 1L; - - /* - * Logger - */ - private static final Logger logger = Logger.getLogger(PersonCast.class); - /* - * Properties - */ - @JsonProperty("id") - private int id; - @JsonProperty("character") - private String character; - @JsonProperty("name") - private String name; - @JsonProperty("order") - private int order; - @JsonProperty("profile_path") - private String profilePath; - @JsonProperty("cast_id") - private int castId; - - // - public String getCharacter() { - return character; - } - - public int getId() { - return id; - } - - public String getName() { - return name; - } - - public int getOrder() { - return order; - } - - public String getProfilePath() { - return profilePath; - } - - public int getCastId() { - return castId; - } - - // - - // - public void setCharacter(String character) { - this.character = character; - } - - public void setId(int id) { - this.id = id; - } - - public void setName(String name) { - this.name = name; - } - - public void setOrder(int order) { - this.order = order; - } - - public void setProfilePath(String profilePath) { - this.profilePath = profilePath; - } - - public void setCastId(int castId) { - this.castId = castId; - } - - // - - /** - * Handle unknown properties and print a message - * - * @param key - * @param value - */ - @JsonAnySetter - public void handleUnknown(String key, Object value) { - StringBuilder sb = new StringBuilder(); - sb.append("Unknown property: '").append(key); - sb.append("' value: '").append(value).append("'"); - logger.trace(sb.toString()); - } - - @Override - public boolean equals(Object obj) { - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - final PersonCast other = (PersonCast) obj; - if (this.id != other.id) { - return false; - } - if ((this.character == null) ? (other.character != null) : !this.character.equals(other.character)) { - return false; - } - if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) { - return false; - } - if (this.order != other.order) { - return false; - } - if ((this.profilePath == null) ? (other.profilePath != null) : !this.profilePath.equals(other.profilePath)) { - return false; - } - return true; - } - - @Override - public int hashCode() { - int hash = 7; - hash = 41 * hash + this.id; - hash = 41 * hash + (this.character != null ? this.character.hashCode() : 0); - hash = 41 * hash + (this.name != null ? this.name.hashCode() : 0); - hash = 41 * hash + this.order; - hash = 41 * hash + (this.profilePath != null ? this.profilePath.hashCode() : 0); - return hash; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder("[PersonCast="); - sb.append("id=").append(id); - sb.append("],[character=").append(character); - sb.append("],[name=").append(name); - sb.append("],[order=").append(order); - sb.append("],[profilePath=").append(profilePath); - sb.append("]]"); - return sb.toString(); - } -} +/* + * Copyright (c) 2004-2013 Stuart Boston + * + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . + * + */ +package com.omertron.themoviedbapi.model; + +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * + * @author Stuart + */ +public class PersonCast implements Serializable { + + private static final long serialVersionUID = 1L; + + /* + * Logger + */ + private static final Logger LOG = LoggerFactory.getLogger(PersonCast.class); + /* + * Properties + */ + @JsonProperty("id") + private int id; + @JsonProperty("character") + private String character; + @JsonProperty("name") + private String name; + @JsonProperty("order") + private int order; + @JsonProperty("profile_path") + private String profilePath; + @JsonProperty("cast_id") + private int castId; + + // + public String getCharacter() { + return character; + } + + public int getId() { + return id; + } + + public String getName() { + return name; + } + + public int getOrder() { + return order; + } + + public String getProfilePath() { + return profilePath; + } + + public int getCastId() { + return castId; + } + + // + + // + public void setCharacter(String character) { + this.character = character; + } + + public void setId(int id) { + this.id = id; + } + + public void setName(String name) { + this.name = name; + } + + public void setOrder(int order) { + this.order = order; + } + + public void setProfilePath(String profilePath) { + this.profilePath = profilePath; + } + + public void setCastId(int castId) { + this.castId = castId; + } + + // + + /** + * Handle unknown properties and print a message + * + * @param key + * @param value + */ + @JsonAnySetter + public void handleUnknown(String key, Object value) { + StringBuilder sb = new StringBuilder(); + sb.append("Unknown property: '").append(key); + sb.append("' value: '").append(value).append("'"); + LOG.trace(sb.toString()); + } + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final PersonCast other = (PersonCast) obj; + if (this.id != other.id) { + return false; + } + if ((this.character == null) ? (other.character != null) : !this.character.equals(other.character)) { + return false; + } + if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) { + return false; + } + if (this.order != other.order) { + return false; + } + if ((this.profilePath == null) ? (other.profilePath != null) : !this.profilePath.equals(other.profilePath)) { + return false; + } + return true; + } + + @Override + public int hashCode() { + int hash = 7; + hash = 41 * hash + this.id; + hash = 41 * hash + (this.character != null ? this.character.hashCode() : 0); + hash = 41 * hash + (this.name != null ? this.name.hashCode() : 0); + hash = 41 * hash + this.order; + hash = 41 * hash + (this.profilePath != null ? this.profilePath.hashCode() : 0); + return hash; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("[PersonCast="); + sb.append("id=").append(id); + sb.append("],[character=").append(character); + sb.append("],[name=").append(name); + sb.append("],[order=").append(order); + sb.append("],[profilePath=").append(profilePath); + sb.append("]]"); + return sb.toString(); + } +} diff --git a/src/main/java/com/omertron/themoviedbapi/model/PersonCredit.java b/src/main/java/com/omertron/themoviedbapi/model/PersonCredit.java index e20c93783..a17c6551c 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/PersonCredit.java +++ b/src/main/java/com/omertron/themoviedbapi/model/PersonCredit.java @@ -22,7 +22,8 @@ package com.omertron.themoviedbapi.model; import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonProperty; import java.io.Serializable; -import org.apache.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * @@ -35,7 +36,7 @@ public class PersonCredit implements Serializable { /* * Logger */ - private static final Logger logger = Logger.getLogger(PersonCredit.class); + private static final Logger LOG = LoggerFactory.getLogger(PersonCredit.class); private static final String DEFAULT_STRING = ""; /* * Properties @@ -155,7 +156,7 @@ public class PersonCredit implements Serializable { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - logger.trace(sb.toString()); + LOG.trace(sb.toString()); } @Override diff --git a/src/main/java/com/omertron/themoviedbapi/model/PersonCrew.java b/src/main/java/com/omertron/themoviedbapi/model/PersonCrew.java index be4c04fa9..f69c27166 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/PersonCrew.java +++ b/src/main/java/com/omertron/themoviedbapi/model/PersonCrew.java @@ -22,7 +22,8 @@ package com.omertron.themoviedbapi.model; import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonProperty; import java.io.Serializable; -import org.apache.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * @@ -35,7 +36,7 @@ public class PersonCrew implements Serializable { /* * Logger */ - private static final Logger logger = Logger.getLogger(PersonCrew.class); + private static final Logger LOG = LoggerFactory.getLogger(PersonCrew.class); /* * Properties */ @@ -105,7 +106,7 @@ public class PersonCrew implements Serializable { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - logger.trace(sb.toString()); + LOG.trace(sb.toString()); } @Override diff --git a/src/main/java/com/omertron/themoviedbapi/model/ProductionCompany.java b/src/main/java/com/omertron/themoviedbapi/model/ProductionCompany.java index 5f50e6cee..15f62ee55 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/ProductionCompany.java +++ b/src/main/java/com/omertron/themoviedbapi/model/ProductionCompany.java @@ -1,117 +1,118 @@ -/* - * Copyright (c) 2004-2013 Stuart Boston - * - * This file is part of TheMovieDB API. - * - * TheMovieDB API is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * any later version. - * - * TheMovieDB API is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with TheMovieDB API. If not, see . - * - */ -package com.omertron.themoviedbapi.model; - -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonRootName; -import java.io.Serializable; -import org.apache.log4j.Logger; - -/** - * - * @author stuart.boston - */ -@JsonRootName("production_company") -public class ProductionCompany implements Serializable { - - private static final long serialVersionUID = 1L; - - /* - * Logger - */ - private static final Logger logger = Logger.getLogger(ProductionCompany.class); - /* - * Properties - */ - @JsonProperty("id") - private int id; - @JsonProperty("name") - private String name; - - // - public int getId() { - return id; - } - - public String getName() { - return name; - } - // - - // - public void setId(int id) { - this.id = id; - } - - public void setName(String name) { - this.name = name; - } - // - - /** - * Handle unknown properties and print a message - * - * @param key - * @param value - */ - @JsonAnySetter - public void handleUnknown(String key, Object value) { - StringBuilder sb = new StringBuilder(); - sb.append("Unknown property: '").append(key); - sb.append("' value: '").append(value).append("'"); - logger.trace(sb.toString()); - } - - @Override - public boolean equals(Object obj) { - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - final ProductionCompany other = (ProductionCompany) obj; - if (this.id != other.id) { - return false; - } - if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) { - return false; - } - return true; - } - - @Override - public int hashCode() { - int hash = 5; - hash = 37 * hash + this.id; - hash = 37 * hash + (this.name != null ? this.name.hashCode() : 0); - return hash; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder("[ProductionCompany="); - sb.append("[id=").append(id); - sb.append("],[name=").append(name); - sb.append("]]"); - return sb.toString(); - } -} +/* + * Copyright (c) 2004-2013 Stuart Boston + * + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . + * + */ +package com.omertron.themoviedbapi.model; + +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; +import java.io.Serializable; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * + * @author stuart.boston + */ +@JsonRootName("production_company") +public class ProductionCompany implements Serializable { + + private static final long serialVersionUID = 1L; + + /* + * Logger + */ + private static final Logger LOG = LoggerFactory.getLogger(ProductionCompany.class); + /* + * Properties + */ + @JsonProperty("id") + private int id; + @JsonProperty("name") + private String name; + + // + public int getId() { + return id; + } + + public String getName() { + return name; + } + // + + // + public void setId(int id) { + this.id = id; + } + + public void setName(String name) { + this.name = name; + } + // + + /** + * Handle unknown properties and print a message + * + * @param key + * @param value + */ + @JsonAnySetter + public void handleUnknown(String key, Object value) { + StringBuilder sb = new StringBuilder(); + sb.append("Unknown property: '").append(key); + sb.append("' value: '").append(value).append("'"); + LOG.trace(sb.toString()); + } + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final ProductionCompany other = (ProductionCompany) obj; + if (this.id != other.id) { + return false; + } + if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) { + return false; + } + return true; + } + + @Override + public int hashCode() { + int hash = 5; + hash = 37 * hash + this.id; + hash = 37 * hash + (this.name != null ? this.name.hashCode() : 0); + return hash; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("[ProductionCompany="); + sb.append("[id=").append(id); + sb.append("],[name=").append(name); + sb.append("]]"); + return sb.toString(); + } +} diff --git a/src/main/java/com/omertron/themoviedbapi/model/ProductionCountry.java b/src/main/java/com/omertron/themoviedbapi/model/ProductionCountry.java index bae5b7335..cc1063f16 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/ProductionCountry.java +++ b/src/main/java/com/omertron/themoviedbapi/model/ProductionCountry.java @@ -1,117 +1,118 @@ -/* - * Copyright (c) 2004-2013 Stuart Boston - * - * This file is part of TheMovieDB API. - * - * TheMovieDB API is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * any later version. - * - * TheMovieDB API is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with TheMovieDB API. If not, see . - * - */ -package com.omertron.themoviedbapi.model; - -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.fasterxml.jackson.annotation.JsonRootName; -import java.io.Serializable; -import org.apache.log4j.Logger; - -/** - * - * @author stuart.boston - */ -@JsonRootName("production_country") -public class ProductionCountry implements Serializable { - - private static final long serialVersionUID = 1L; - - /* - * Logger - */ - private static final Logger logger = Logger.getLogger(ProductionCountry.class); - /* - * Properties - */ - @JsonProperty("iso_3166_1") - private String isoCode; - @JsonProperty("name") - private String name; - - // - public String getIsoCode() { - return isoCode; - } - - public String getName() { - return name; - } - // - - // - public void setIsoCode(String isoCode) { - this.isoCode = isoCode; - } - - public void setName(String name) { - this.name = name; - } - // - - /** - * Handle unknown properties and print a message - * - * @param key - * @param value - */ - @JsonAnySetter - public void handleUnknown(String key, Object value) { - StringBuilder sb = new StringBuilder(); - sb.append("Unknown property: '").append(key); - sb.append("' value: '").append(value).append("'"); - logger.trace(sb.toString()); - } - - @Override - public boolean equals(Object obj) { - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - final ProductionCountry other = (ProductionCountry) obj; - if ((this.isoCode == null) ? (other.isoCode != null) : !this.isoCode.equals(other.isoCode)) { - return false; - } - if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) { - return false; - } - return true; - } - - @Override - public int hashCode() { - int hash = 7; - hash = 47 * hash + (this.isoCode != null ? this.isoCode.hashCode() : 0); - hash = 47 * hash + (this.name != null ? this.name.hashCode() : 0); - return hash; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder("[ProductionCountry="); - sb.append("[isoCode=").append(isoCode); - sb.append("],[name=").append(name); - sb.append("]]"); - return sb.toString(); - } -} +/* + * Copyright (c) 2004-2013 Stuart Boston + * + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . + * + */ +package com.omertron.themoviedbapi.model; + +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.annotation.JsonRootName; +import java.io.Serializable; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * + * @author stuart.boston + */ +@JsonRootName("production_country") +public class ProductionCountry implements Serializable { + + private static final long serialVersionUID = 1L; + + /* + * Logger + */ + private static final Logger LOG = LoggerFactory.getLogger(ProductionCountry.class); + /* + * Properties + */ + @JsonProperty("iso_3166_1") + private String isoCode; + @JsonProperty("name") + private String name; + + // + public String getIsoCode() { + return isoCode; + } + + public String getName() { + return name; + } + // + + // + public void setIsoCode(String isoCode) { + this.isoCode = isoCode; + } + + public void setName(String name) { + this.name = name; + } + // + + /** + * Handle unknown properties and print a message + * + * @param key + * @param value + */ + @JsonAnySetter + public void handleUnknown(String key, Object value) { + StringBuilder sb = new StringBuilder(); + sb.append("Unknown property: '").append(key); + sb.append("' value: '").append(value).append("'"); + LOG.trace(sb.toString()); + } + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final ProductionCountry other = (ProductionCountry) obj; + if ((this.isoCode == null) ? (other.isoCode != null) : !this.isoCode.equals(other.isoCode)) { + return false; + } + if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) { + return false; + } + return true; + } + + @Override + public int hashCode() { + int hash = 7; + hash = 47 * hash + (this.isoCode != null ? this.isoCode.hashCode() : 0); + hash = 47 * hash + (this.name != null ? this.name.hashCode() : 0); + return hash; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("[ProductionCountry="); + sb.append("[isoCode=").append(isoCode); + sb.append("],[name=").append(name); + sb.append("]]"); + return sb.toString(); + } +} diff --git a/src/main/java/com/omertron/themoviedbapi/model/ReleaseInfo.java b/src/main/java/com/omertron/themoviedbapi/model/ReleaseInfo.java index 2a5be9662..22a91c4bc 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/ReleaseInfo.java +++ b/src/main/java/com/omertron/themoviedbapi/model/ReleaseInfo.java @@ -1,130 +1,131 @@ -/* - * Copyright (c) 2004-2013 Stuart Boston - * - * This file is part of TheMovieDB API. - * - * TheMovieDB API is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * any later version. - * - * TheMovieDB API is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with TheMovieDB API. If not, see . - * - */ -package com.omertron.themoviedbapi.model; - -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonProperty; -import java.io.Serializable; -import org.apache.log4j.Logger; - -/** - * - * @author Stuart - */ -public class ReleaseInfo implements Serializable { - - private static final long serialVersionUID = 1L; - - /* - * Logger - */ - private static final Logger logger = Logger.getLogger(ReleaseInfo.class); - /* - * Properties - */ - @JsonProperty("iso_3166_1") - private String country; - @JsonProperty("certification") - private String certification; - @JsonProperty("release_date") - private String releaseDate; - - // - public String getCertification() { - return certification; - } - - public String getCountry() { - return country; - } - - public String getReleaseDate() { - return releaseDate; - } - // - - // - public void setCertification(String certification) { - this.certification = certification; - } - - public void setCountry(String country) { - this.country = country; - } - - public void setReleaseDate(String releaseDate) { - this.releaseDate = releaseDate; - } - // - - /** - * Handle unknown properties and print a message - * - * @param key - * @param value - */ - @JsonAnySetter - public void handleUnknown(String key, Object value) { - StringBuilder sb = new StringBuilder(); - sb.append("Unknown property: '").append(key); - sb.append("' value: '").append(value).append("'"); - logger.trace(sb.toString()); - } - - @Override - public boolean equals(Object obj) { - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - final ReleaseInfo other = (ReleaseInfo) obj; - if ((this.country == null) ? (other.country != null) : !this.country.equals(other.country)) { - return false; - } - if ((this.certification == null) ? (other.certification != null) : !this.certification.equals(other.certification)) { - return false; - } - if ((this.releaseDate == null) ? (other.releaseDate != null) : !this.releaseDate.equals(other.releaseDate)) { - return false; - } - return true; - } - - @Override - public int hashCode() { - int hash = 3; - hash = 89 * hash + (this.country != null ? this.country.hashCode() : 0); - hash = 89 * hash + (this.certification != null ? this.certification.hashCode() : 0); - hash = 89 * hash + (this.releaseDate != null ? this.releaseDate.hashCode() : 0); - return hash; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder("[ReleaseInfo="); - sb.append("[country=").append(country); - sb.append("],[certification=").append(certification); - sb.append("],[releaseDate=").append(releaseDate); - sb.append("]]"); - return sb.toString(); - } -} +/* + * Copyright (c) 2004-2013 Stuart Boston + * + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . + * + */ +package com.omertron.themoviedbapi.model; + +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * + * @author Stuart + */ +public class ReleaseInfo implements Serializable { + + private static final long serialVersionUID = 1L; + + /* + * Logger + */ + private static final Logger LOG = LoggerFactory.getLogger(ReleaseInfo.class); + /* + * Properties + */ + @JsonProperty("iso_3166_1") + private String country; + @JsonProperty("certification") + private String certification; + @JsonProperty("release_date") + private String releaseDate; + + // + public String getCertification() { + return certification; + } + + public String getCountry() { + return country; + } + + public String getReleaseDate() { + return releaseDate; + } + // + + // + public void setCertification(String certification) { + this.certification = certification; + } + + public void setCountry(String country) { + this.country = country; + } + + public void setReleaseDate(String releaseDate) { + this.releaseDate = releaseDate; + } + // + + /** + * Handle unknown properties and print a message + * + * @param key + * @param value + */ + @JsonAnySetter + public void handleUnknown(String key, Object value) { + StringBuilder sb = new StringBuilder(); + sb.append("Unknown property: '").append(key); + sb.append("' value: '").append(value).append("'"); + LOG.trace(sb.toString()); + } + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final ReleaseInfo other = (ReleaseInfo) obj; + if ((this.country == null) ? (other.country != null) : !this.country.equals(other.country)) { + return false; + } + if ((this.certification == null) ? (other.certification != null) : !this.certification.equals(other.certification)) { + return false; + } + if ((this.releaseDate == null) ? (other.releaseDate != null) : !this.releaseDate.equals(other.releaseDate)) { + return false; + } + return true; + } + + @Override + public int hashCode() { + int hash = 3; + hash = 89 * hash + (this.country != null ? this.country.hashCode() : 0); + hash = 89 * hash + (this.certification != null ? this.certification.hashCode() : 0); + hash = 89 * hash + (this.releaseDate != null ? this.releaseDate.hashCode() : 0); + return hash; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("[ReleaseInfo="); + sb.append("[country=").append(country); + sb.append("],[certification=").append(certification); + sb.append("],[releaseDate=").append(releaseDate); + sb.append("]]"); + return sb.toString(); + } +} diff --git a/src/main/java/com/omertron/themoviedbapi/model/StatusCode.java b/src/main/java/com/omertron/themoviedbapi/model/StatusCode.java index 8e7318715..9a0f3423b 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/StatusCode.java +++ b/src/main/java/com/omertron/themoviedbapi/model/StatusCode.java @@ -1,88 +1,89 @@ -/* - * Copyright (c) 2004-2013 Stuart Boston - * - * This file is part of TheMovieDB API. - * - * TheMovieDB API is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * any later version. - * - * TheMovieDB API is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with TheMovieDB API. If not, see . - * - */ -package com.omertron.themoviedbapi.model; - -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonProperty; -import java.io.Serializable; -import org.apache.log4j.Logger; - -/** - * - * @author Stuart - */ -public class StatusCode implements Serializable { - - private static final long serialVersionUID = 1L; - - /* - * Logger - */ - private static final Logger logger = Logger.getLogger(StatusCode.class); - /* - * Properties - */ - @JsonProperty("status_code") - private int statusCode; - @JsonProperty("status_message") - private String statusMessage; - - // - public int getStatusCode() { - return statusCode; - } - - public void setStatusCode(int statusCode) { - this.statusCode = statusCode; - } - // - - // - public String getStatusMessage() { - return statusMessage; - } - - public void setStatusMessage(String statusMessage) { - this.statusMessage = statusMessage; - } - // - - /** - * Handle unknown properties and print a message - * - * @param key - * @param value - */ - @JsonAnySetter - public void handleUnknown(String key, Object value) { - StringBuilder sb = new StringBuilder(); - sb.append("Unknown property: '").append(key); - sb.append("' value: '").append(value).append("'"); - logger.trace(sb.toString()); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder(); - sb.append("Status Code: ").append(statusCode); - sb.append(", Message: ").append(statusMessage); - return sb.toString(); - } -} +/* + * Copyright (c) 2004-2013 Stuart Boston + * + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . + * + */ +package com.omertron.themoviedbapi.model; + +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * + * @author Stuart + */ +public class StatusCode implements Serializable { + + private static final long serialVersionUID = 1L; + + /* + * Logger + */ + private static final Logger LOG = LoggerFactory.getLogger(StatusCode.class); + /* + * Properties + */ + @JsonProperty("status_code") + private int statusCode; + @JsonProperty("status_message") + private String statusMessage; + + // + public int getStatusCode() { + return statusCode; + } + + public void setStatusCode(int statusCode) { + this.statusCode = statusCode; + } + // + + // + public String getStatusMessage() { + return statusMessage; + } + + public void setStatusMessage(String statusMessage) { + this.statusMessage = statusMessage; + } + // + + /** + * Handle unknown properties and print a message + * + * @param key + * @param value + */ + @JsonAnySetter + public void handleUnknown(String key, Object value) { + StringBuilder sb = new StringBuilder(); + sb.append("Unknown property: '").append(key); + sb.append("' value: '").append(value).append("'"); + LOG.trace(sb.toString()); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("Status Code: ").append(statusCode); + sb.append(", Message: ").append(statusMessage); + return sb.toString(); + } +} diff --git a/src/main/java/com/omertron/themoviedbapi/model/TmdbConfiguration.java b/src/main/java/com/omertron/themoviedbapi/model/TmdbConfiguration.java index 9355e62f6..469f9f1a0 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/TmdbConfiguration.java +++ b/src/main/java/com/omertron/themoviedbapi/model/TmdbConfiguration.java @@ -1,206 +1,207 @@ -/* - * Copyright (c) 2004-2013 Stuart Boston - * - * This file is part of TheMovieDB API. - * - * TheMovieDB API is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * any later version. - * - * TheMovieDB API is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with TheMovieDB API. If not, see . - * - */ -package com.omertron.themoviedbapi.model; - -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonProperty; -import java.io.Serializable; -import java.util.List; -import org.apache.commons.lang3.StringUtils; -import org.apache.log4j.Logger; - -/** - * - * @author stuart.boston - */ -public class TmdbConfiguration implements Serializable { - - private static final long serialVersionUID = 1L; - /* - * Logger - */ - private static final Logger logger = Logger.getLogger(TmdbConfiguration.class); - /* - * Properties - */ - @JsonProperty("base_url") - private String baseUrl; - @JsonProperty("secure_base_url") - private String secureBaseUrl; - @JsonProperty("poster_sizes") - private List posterSizes; - @JsonProperty("backdrop_sizes") - private List backdropSizes; - @JsonProperty("profile_sizes") - private List profileSizes; - @JsonProperty("logo_sizes") - private List logoSizes; - - // //GEN-BEGIN:getterMethods - public List getBackdropSizes() { - return backdropSizes; - } - - public String getBaseUrl() { - return baseUrl; - } - - public List getPosterSizes() { - return posterSizes; - } - - public List getProfileSizes() { - return profileSizes; - } - - public List getLogoSizes() { - return logoSizes; - } - - public String getSecureBaseUrl() { - return secureBaseUrl; - } - - // - // //GEN-BEGIN:setterMethods - public void setBackdropSizes(List backdropSizes) { - this.backdropSizes = backdropSizes; - } - - public void setBaseUrl(String baseUrl) { - this.baseUrl = baseUrl; - } - - public void setPosterSizes(List posterSizes) { - this.posterSizes = posterSizes; - } - - public void setProfileSizes(List profileSizes) { - this.profileSizes = profileSizes; - } - - public void setLogoSizes(List logoSizes) { - this.logoSizes = logoSizes; - } - - public void setSecureBaseUrl(String secureBaseUrl) { - this.secureBaseUrl = secureBaseUrl; - } - // - - /** - * Copy the data from the passed object to this one - * - * @param config - */ - public void clone(TmdbConfiguration config) { - backdropSizes = config.getBackdropSizes(); - baseUrl = config.getBaseUrl(); - posterSizes = config.getPosterSizes(); - profileSizes = config.getProfileSizes(); - logoSizes = config.getLogoSizes(); - } - - /** - * Check that the poster size is valid - * - * @param posterSize - */ - public boolean isValidPosterSize(String posterSize) { - if (StringUtils.isBlank(posterSize) || posterSizes.isEmpty()) { - return false; - } - return posterSizes.contains(posterSize); - } - - /** - * Check that the backdrop size is valid - * - * @param backdropSize - */ - public boolean isValidBackdropSize(String backdropSize) { - if (StringUtils.isBlank(backdropSize) || backdropSizes.isEmpty()) { - return false; - } - return backdropSizes.contains(backdropSize); - } - - /** - * Check that the profile size is valid - * - * @param profileSize - */ - public boolean isValidProfileSize(String profileSize) { - if (StringUtils.isBlank(profileSize) || profileSizes.isEmpty()) { - return false; - } - return profileSizes.contains(profileSize); - } - - /** - * Check that the logo size is valid - * - * @param logoSize - */ - public boolean isValidLogoSize(String logoSize) { - if (StringUtils.isBlank(logoSize) || logoSizes.isEmpty()) { - return false; - } - return logoSizes.contains(logoSize); - } - - /** - * Check to see if the size is valid for any of the images types - * - * @param sizeToCheck - */ - public boolean isValidSize(String sizeToCheck) { - return (isValidPosterSize(sizeToCheck) - || isValidBackdropSize(sizeToCheck) - || isValidProfileSize(sizeToCheck) - || isValidLogoSize(sizeToCheck)); - } - - /** - * Handle unknown properties and print a message - * - * @param key - * @param value - */ - @JsonAnySetter - public void handleUnknown(String key, Object value) { - StringBuilder sb = new StringBuilder(); - sb.append("Unknown property: '").append(key); - sb.append("' value: '").append(value).append("'"); - logger.trace(sb.toString()); - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder("[ImageConfiguration="); - sb.append("[baseUrl=").append(baseUrl); - sb.append("],[posterSizes=").append(posterSizes.toString()); - sb.append("],[backdropSizes=").append(backdropSizes.toString()); - sb.append("],[profileSizes=").append(profileSizes.toString()); - sb.append("],[logoSizes=").append(logoSizes.toString()); - sb.append(("]]")); - return sb.toString(); - } -} +/* + * Copyright (c) 2004-2013 Stuart Boston + * + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . + * + */ +package com.omertron.themoviedbapi.model; + +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import java.util.List; +import org.apache.commons.lang3.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * + * @author stuart.boston + */ +public class TmdbConfiguration implements Serializable { + + private static final long serialVersionUID = 1L; + /* + * Logger + */ + private static final Logger LOG = LoggerFactory.getLogger(TmdbConfiguration.class); + /* + * Properties + */ + @JsonProperty("base_url") + private String baseUrl; + @JsonProperty("secure_base_url") + private String secureBaseUrl; + @JsonProperty("poster_sizes") + private List posterSizes; + @JsonProperty("backdrop_sizes") + private List backdropSizes; + @JsonProperty("profile_sizes") + private List profileSizes; + @JsonProperty("logo_sizes") + private List logoSizes; + + // //GEN-BEGIN:getterMethods + public List getBackdropSizes() { + return backdropSizes; + } + + public String getBaseUrl() { + return baseUrl; + } + + public List getPosterSizes() { + return posterSizes; + } + + public List getProfileSizes() { + return profileSizes; + } + + public List getLogoSizes() { + return logoSizes; + } + + public String getSecureBaseUrl() { + return secureBaseUrl; + } + + // + // //GEN-BEGIN:setterMethods + public void setBackdropSizes(List backdropSizes) { + this.backdropSizes = backdropSizes; + } + + public void setBaseUrl(String baseUrl) { + this.baseUrl = baseUrl; + } + + public void setPosterSizes(List posterSizes) { + this.posterSizes = posterSizes; + } + + public void setProfileSizes(List profileSizes) { + this.profileSizes = profileSizes; + } + + public void setLogoSizes(List logoSizes) { + this.logoSizes = logoSizes; + } + + public void setSecureBaseUrl(String secureBaseUrl) { + this.secureBaseUrl = secureBaseUrl; + } + // + + /** + * Copy the data from the passed object to this one + * + * @param config + */ + public void clone(TmdbConfiguration config) { + backdropSizes = config.getBackdropSizes(); + baseUrl = config.getBaseUrl(); + posterSizes = config.getPosterSizes(); + profileSizes = config.getProfileSizes(); + logoSizes = config.getLogoSizes(); + } + + /** + * Check that the poster size is valid + * + * @param posterSize + */ + public boolean isValidPosterSize(String posterSize) { + if (StringUtils.isBlank(posterSize) || posterSizes.isEmpty()) { + return false; + } + return posterSizes.contains(posterSize); + } + + /** + * Check that the backdrop size is valid + * + * @param backdropSize + */ + public boolean isValidBackdropSize(String backdropSize) { + if (StringUtils.isBlank(backdropSize) || backdropSizes.isEmpty()) { + return false; + } + return backdropSizes.contains(backdropSize); + } + + /** + * Check that the profile size is valid + * + * @param profileSize + */ + public boolean isValidProfileSize(String profileSize) { + if (StringUtils.isBlank(profileSize) || profileSizes.isEmpty()) { + return false; + } + return profileSizes.contains(profileSize); + } + + /** + * Check that the logo size is valid + * + * @param logoSize + */ + public boolean isValidLogoSize(String logoSize) { + if (StringUtils.isBlank(logoSize) || logoSizes.isEmpty()) { + return false; + } + return logoSizes.contains(logoSize); + } + + /** + * Check to see if the size is valid for any of the images types + * + * @param sizeToCheck + */ + public boolean isValidSize(String sizeToCheck) { + return (isValidPosterSize(sizeToCheck) + || isValidBackdropSize(sizeToCheck) + || isValidProfileSize(sizeToCheck) + || isValidLogoSize(sizeToCheck)); + } + + /** + * Handle unknown properties and print a message + * + * @param key + * @param value + */ + @JsonAnySetter + public void handleUnknown(String key, Object value) { + StringBuilder sb = new StringBuilder(); + sb.append("Unknown property: '").append(key); + sb.append("' value: '").append(value).append("'"); + LOG.trace(sb.toString()); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("[ImageConfiguration="); + sb.append("[baseUrl=").append(baseUrl); + sb.append("],[posterSizes=").append(posterSizes.toString()); + sb.append("],[backdropSizes=").append(backdropSizes.toString()); + sb.append("],[profileSizes=").append(profileSizes.toString()); + sb.append("],[logoSizes=").append(logoSizes.toString()); + sb.append(("]]")); + return sb.toString(); + } +} diff --git a/src/main/java/com/omertron/themoviedbapi/model/TokenAuthorisation.java b/src/main/java/com/omertron/themoviedbapi/model/TokenAuthorisation.java index a0d7734f6..cebbd2d4d 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/TokenAuthorisation.java +++ b/src/main/java/com/omertron/themoviedbapi/model/TokenAuthorisation.java @@ -21,13 +21,14 @@ package com.omertron.themoviedbapi.model; import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonProperty; -import org.apache.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class TokenAuthorisation { /* * Logger */ - private static final Logger logger = Logger.getLogger(TokenAuthorisation.class); + private static final Logger LOG = LoggerFactory.getLogger(TokenAuthorisation.class); /* * Properties */ @@ -77,7 +78,7 @@ public class TokenAuthorisation { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - logger.trace(sb.toString()); + LOG.trace(sb.toString()); } @Override diff --git a/src/main/java/com/omertron/themoviedbapi/model/TokenSession.java b/src/main/java/com/omertron/themoviedbapi/model/TokenSession.java index 4142cc816..5ba745392 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/TokenSession.java +++ b/src/main/java/com/omertron/themoviedbapi/model/TokenSession.java @@ -21,14 +21,15 @@ package com.omertron.themoviedbapi.model; import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonProperty; -import org.apache.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; public class TokenSession { /* * Logger */ - private static final Logger logger = Logger.getLogger(TokenSession.class); + private static final Logger LOG = LoggerFactory.getLogger(TokenSession.class); /* * Properties */ @@ -109,7 +110,7 @@ public class TokenSession { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - logger.trace(sb.toString()); + LOG.trace(sb.toString()); } @Override diff --git a/src/main/java/com/omertron/themoviedbapi/model/Trailer.java b/src/main/java/com/omertron/themoviedbapi/model/Trailer.java index 008862dce..e38112d7a 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/Trailer.java +++ b/src/main/java/com/omertron/themoviedbapi/model/Trailer.java @@ -21,7 +21,8 @@ package com.omertron.themoviedbapi.model; import com.fasterxml.jackson.annotation.JsonAnySetter; import java.io.Serializable; -import org.apache.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * @@ -34,7 +35,7 @@ public class Trailer implements Serializable { /* * Logger */ - private static final Logger logger = Logger.getLogger(Trailer.class); + private static final Logger LOG = LoggerFactory.getLogger(Trailer.class); /* * Website sources */ @@ -95,7 +96,7 @@ public class Trailer implements Serializable { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - logger.trace(sb.toString()); + LOG.trace(sb.toString()); } @Override diff --git a/src/main/java/com/omertron/themoviedbapi/model/Translation.java b/src/main/java/com/omertron/themoviedbapi/model/Translation.java index 986ac28e3..315c069cd 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/Translation.java +++ b/src/main/java/com/omertron/themoviedbapi/model/Translation.java @@ -1,130 +1,131 @@ -/* - * Copyright (c) 2004-2013 Stuart Boston - * - * This file is part of TheMovieDB API. - * - * TheMovieDB API is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * any later version. - * - * TheMovieDB API is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with TheMovieDB API. If not, see . - * - */ -package com.omertron.themoviedbapi.model; - -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonProperty; -import java.io.Serializable; -import org.apache.log4j.Logger; - -/** - * - * @author Stuart - */ -public class Translation implements Serializable { - - private static final long serialVersionUID = 1L; - - /* - * Logger - */ - private static final Logger logger = Logger.getLogger(Translation.class); - /* - * Properties - */ - @JsonProperty("english_name") - private String englishName; - @JsonProperty("iso_639_1") - private String isoCode; - @JsonProperty("name") - private String name; - - // - public String getEnglishName() { - return englishName; - } - - public String getIsoCode() { - return isoCode; - } - - public String getName() { - return name; - } - // - - // - public void setEnglishName(String englishName) { - this.englishName = englishName; - } - - public void setIsoCode(String isoCode) { - this.isoCode = isoCode; - } - - public void setName(String name) { - this.name = name; - } - // - - /** - * Handle unknown properties and print a message - * - * @param key - * @param value - */ - @JsonAnySetter - public void handleUnknown(String key, Object value) { - StringBuilder sb = new StringBuilder(); - sb.append("Unknown property: '").append(key); - sb.append("' value: '").append(value).append("'"); - logger.trace(sb.toString()); - } - - @Override - public boolean equals(Object obj) { - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - final Translation other = (Translation) obj; - if ((this.englishName == null) ? (other.englishName != null) : !this.englishName.equals(other.englishName)) { - return false; - } - if ((this.isoCode == null) ? (other.isoCode != null) : !this.isoCode.equals(other.isoCode)) { - return false; - } - if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) { - return false; - } - return true; - } - - @Override - public int hashCode() { - int hash = 3; - hash = 29 * hash + (this.englishName != null ? this.englishName.hashCode() : 0); - hash = 29 * hash + (this.isoCode != null ? this.isoCode.hashCode() : 0); - hash = 29 * hash + (this.name != null ? this.name.hashCode() : 0); - return hash; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder("[Translation="); - sb.append("[englishName=").append(englishName); - sb.append("],[isoCode=").append(isoCode); - sb.append("],[name=").append(name); - sb.append("]]"); - return sb.toString(); - } -} +/* + * Copyright (c) 2004-2013 Stuart Boston + * + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . + * + */ +package com.omertron.themoviedbapi.model; + +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonProperty; +import java.io.Serializable; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * + * @author Stuart + */ +public class Translation implements Serializable { + + private static final long serialVersionUID = 1L; + + /* + * Logger + */ + private static final Logger LOG = LoggerFactory.getLogger(Translation.class); + /* + * Properties + */ + @JsonProperty("english_name") + private String englishName; + @JsonProperty("iso_639_1") + private String isoCode; + @JsonProperty("name") + private String name; + + // + public String getEnglishName() { + return englishName; + } + + public String getIsoCode() { + return isoCode; + } + + public String getName() { + return name; + } + // + + // + public void setEnglishName(String englishName) { + this.englishName = englishName; + } + + public void setIsoCode(String isoCode) { + this.isoCode = isoCode; + } + + public void setName(String name) { + this.name = name; + } + // + + /** + * Handle unknown properties and print a message + * + * @param key + * @param value + */ + @JsonAnySetter + public void handleUnknown(String key, Object value) { + StringBuilder sb = new StringBuilder(); + sb.append("Unknown property: '").append(key); + sb.append("' value: '").append(value).append("'"); + LOG.trace(sb.toString()); + } + + @Override + public boolean equals(Object obj) { + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + final Translation other = (Translation) obj; + if ((this.englishName == null) ? (other.englishName != null) : !this.englishName.equals(other.englishName)) { + return false; + } + if ((this.isoCode == null) ? (other.isoCode != null) : !this.isoCode.equals(other.isoCode)) { + return false; + } + if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) { + return false; + } + return true; + } + + @Override + public int hashCode() { + int hash = 3; + hash = 29 * hash + (this.englishName != null ? this.englishName.hashCode() : 0); + hash = 29 * hash + (this.isoCode != null ? this.isoCode.hashCode() : 0); + hash = 29 * hash + (this.name != null ? this.name.hashCode() : 0); + return hash; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("[Translation="); + sb.append("[englishName=").append(englishName); + sb.append("],[isoCode=").append(isoCode); + sb.append("],[name=").append(name); + sb.append("]]"); + return sb.toString(); + } +} diff --git a/src/main/java/com/omertron/themoviedbapi/tools/ApiUrl.java b/src/main/java/com/omertron/themoviedbapi/tools/ApiUrl.java index 9bde3a03f..a3d28833e 100644 --- a/src/main/java/com/omertron/themoviedbapi/tools/ApiUrl.java +++ b/src/main/java/com/omertron/themoviedbapi/tools/ApiUrl.java @@ -26,7 +26,8 @@ import java.net.URL; import java.net.URLEncoder; import java.util.HashMap; import java.util.Map; -import org.apache.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * The API URL that is used to construct the API call @@ -38,7 +39,7 @@ public class ApiUrl { /* * Logger */ - private static final Logger logger = Logger.getLogger(ApiUrl.class); + private static final Logger LOG = LoggerFactory.getLogger(ApiUrl.class); /* * TheMovieDbApi API Base URL */ @@ -126,7 +127,7 @@ public class ApiUrl { try { urlString.append(URLEncoder.encode(query, "UTF-8")); } catch (UnsupportedEncodingException ex) { - logger.trace("Unable to encode query: '" + query + "' trying raw."); + LOG.trace("Unable to encode query: '" + query + "' trying raw."); // If we can't encode it, try it raw urlString.append(query); } @@ -153,10 +154,10 @@ public class ApiUrl { } try { - logger.trace("URL: " + urlString.toString()); + LOG.trace("URL: " + urlString.toString()); return new URL(urlString.toString()); } catch (MalformedURLException ex) { - logger.warn("Failed to create URL " + urlString.toString() + " - " + ex.toString()); + LOG.warn("Failed to create URL " + urlString.toString() + " - " + ex.toString()); return null; } finally { arguments.clear(); diff --git a/src/main/java/com/omertron/themoviedbapi/tools/FilteringLayout.java b/src/main/java/com/omertron/themoviedbapi/tools/FilteringLayout.java deleted file mode 100644 index ccdb8975a..000000000 --- a/src/main/java/com/omertron/themoviedbapi/tools/FilteringLayout.java +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (c) 2004-2013 Stuart Boston - * - * This file is part of TheMovieDB API. - * - * TheMovieDB API is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * any later version. - * - * TheMovieDB API is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with TheMovieDB API. If not, see . - * - */ -package com.omertron.themoviedbapi.tools; - -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import org.apache.log4j.Logger; -import org.apache.log4j.PatternLayout; -import org.apache.log4j.spi.LoggingEvent; - -/** - * Log4J Filtering routine to remove API keys from the output - * - * @author Stuart.Boston - * - */ -public class FilteringLayout extends PatternLayout { - - private static final String REPLACEMENT = "[APIKEY]"; - private static Pattern replacementPattern = Pattern.compile("DO_NOT_MATCH"); - - /** - * Add the string to replace in the log output - * - * @param replacementString - */ - public static void addReplacementString(String replacementString) { - replacementPattern = Pattern.compile(replacementString); - } - - /** - * Extend the format to remove the API_KEYS from the output - * - * @param event - */ - @Override - public String format(LoggingEvent event) { - if (event.getMessage() instanceof String) { - String message = event.getRenderedMessage(); - - Matcher matcher = replacementPattern.matcher(message); - if (matcher.find()) { - String maskedMessage = matcher.replaceAll(REPLACEMENT); - - Throwable throwable = event.getThrowableInformation() != null - ? event.getThrowableInformation().getThrowable() : null; - - LoggingEvent maskedEvent = new LoggingEvent(event.fqnOfCategoryClass, - Logger.getLogger(event.getLoggerName()), event.timeStamp, - event.getLevel(), maskedMessage, throwable); - - return super.format(maskedEvent); - } - } - return super.format(event); - } -} diff --git a/src/main/java/com/omertron/themoviedbapi/tools/WebBrowser.java b/src/main/java/com/omertron/themoviedbapi/tools/WebBrowser.java index dc5afd59e..0f0cfa52f 100644 --- a/src/main/java/com/omertron/themoviedbapi/tools/WebBrowser.java +++ b/src/main/java/com/omertron/themoviedbapi/tools/WebBrowser.java @@ -36,14 +36,15 @@ import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; import org.apache.commons.codec.binary.Base64; -import org.apache.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Web browser with simple cookies support */ public final class WebBrowser { - private static final Logger logger = Logger.getLogger(WebBrowser.class); + private static final Logger LOG = LoggerFactory.getLogger(WebBrowser.class); private static Map browserProperties = new HashMap(); private static Map> cookies = new HashMap>(); private static String proxyHost = null; @@ -134,7 +135,7 @@ public final class WebBrowser { try { content.close(); } catch (IOException ex) { - logger.debug("Failed to close connection: " + ex.getMessage()); + LOG.debug("Failed to close connection: " + ex.getMessage()); } } } diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperAlternativeTitles.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperAlternativeTitles.java index 08436c8a4..0c639606e 100644 --- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperAlternativeTitles.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperAlternativeTitles.java @@ -1,74 +1,75 @@ -/* - * Copyright (c) 2004-2013 Stuart Boston - * - * This file is part of TheMovieDB API. - * - * TheMovieDB API is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * any later version. - * - * TheMovieDB API is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with TheMovieDB API. If not, see . - * - */ -package com.omertron.themoviedbapi.wrapper; - -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.omertron.themoviedbapi.model.AlternativeTitle; -import java.util.List; -import org.apache.log4j.Logger; - -/** - * - * @author Stuart - */ -public class WrapperAlternativeTitles { - /* - * Logger - */ - - private static final Logger logger = Logger.getLogger(WrapperAlternativeTitles.class); - /* - * Properties - */ - @JsonProperty("id") - private int id; - @JsonProperty("titles") - private List titles; - - public int getId() { - return id; - } - - public List getTitles() { - return titles; - } - - public void setId(int id) { - this.id = id; - } - - public void setTitles(List titles) { - this.titles = titles; - } - - /** - * Handle unknown properties and print a message - * @param key - * @param value - */ - @JsonAnySetter - public void handleUnknown(String key, Object value) { - StringBuilder sb = new StringBuilder(); - sb.append("Unknown property: '").append(key); - sb.append("' value: '").append(value).append("'"); - logger.trace(sb.toString()); - } -} +/* + * Copyright (c) 2004-2013 Stuart Boston + * + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . + * + */ +package com.omertron.themoviedbapi.wrapper; + +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.omertron.themoviedbapi.model.AlternativeTitle; +import java.util.List; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * + * @author Stuart + */ +public class WrapperAlternativeTitles { + /* + * Logger + */ + + private static final Logger LOG = LoggerFactory.getLogger(WrapperAlternativeTitles.class); + /* + * Properties + */ + @JsonProperty("id") + private int id; + @JsonProperty("titles") + private List titles; + + public int getId() { + return id; + } + + public List getTitles() { + return titles; + } + + public void setId(int id) { + this.id = id; + } + + public void setTitles(List titles) { + this.titles = titles; + } + + /** + * Handle unknown properties and print a message + * @param key + * @param value + */ + @JsonAnySetter + public void handleUnknown(String key, Object value) { + StringBuilder sb = new StringBuilder(); + sb.append("Unknown property: '").append(key); + sb.append("' value: '").append(value).append("'"); + LOG.trace(sb.toString()); + } +} diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperBase.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperBase.java index 912554e45..50b9c0960 100644 --- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperBase.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperBase.java @@ -1,102 +1,103 @@ -/* - * Copyright (c) 2004-2013 Stuart Boston - * - * This file is part of TheMovieDB API. - * - * TheMovieDB API is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * any later version. - * - * TheMovieDB API is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with TheMovieDB API. If not, see . - * - */ -package com.omertron.themoviedbapi.wrapper; - -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonProperty; -import org.apache.log4j.Logger; - -/** - * Base class for the wrappers - * - * @author Stuart - */ -public class WrapperBase { - /* - * Logger - set but the sub-classes - */ - - private Logger logger; - /* - * Properties - */ - @JsonProperty("id") - private int id; - @JsonProperty("page") - private int page; - @JsonProperty("total_pages") - private int totalPages; - @JsonProperty("total_results") - private int totalResults; - - public WrapperBase(Logger logger) { - this.logger = logger; - } - - // - public int getId() { - return id; - } - - public int getPage() { - return page; - } - - public int getTotalPages() { - return totalPages; - } - - public int getTotalResults() { - return totalResults; - } - // - - // - public void setId(int id) { - this.id = id; - } - - public void setPage(int page) { - this.page = page; - } - - public void setTotalPages(int totalPages) { - this.totalPages = totalPages; - } - - public void setTotalResults(int totalResults) { - this.totalResults = totalResults; - } - // - - /** - * Handle unknown properties and print a message - * - * @param key - * @param value - */ - @JsonAnySetter - public void handleUnknown(String key, Object value) { - StringBuilder sb = new StringBuilder(); - sb.append("Unknown property: '").append(key); - sb.append("' value: '").append(value).append("'"); - logger.trace(sb.toString()); - } -} +/* + * Copyright (c) 2004-2013 Stuart Boston + * + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . + * + */ +package com.omertron.themoviedbapi.wrapper; + +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonProperty; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Base class for the wrappers + * + * @author Stuart + */ +public class WrapperBase { + /* + * Logger - set but the sub-classes + */ + + private Logger LOG; + /* + * Properties + */ + @JsonProperty("id") + private int id; + @JsonProperty("page") + private int page; + @JsonProperty("total_pages") + private int totalPages; + @JsonProperty("total_results") + private int totalResults; + + public WrapperBase(Logger LOG) { + this.LOG = LOG; + } + + // + public int getId() { + return id; + } + + public int getPage() { + return page; + } + + public int getTotalPages() { + return totalPages; + } + + public int getTotalResults() { + return totalResults; + } + // + + // + public void setId(int id) { + this.id = id; + } + + public void setPage(int page) { + this.page = page; + } + + public void setTotalPages(int totalPages) { + this.totalPages = totalPages; + } + + public void setTotalResults(int totalResults) { + this.totalResults = totalResults; + } + // + + /** + * Handle unknown properties and print a message + * + * @param key + * @param value + */ + @JsonAnySetter + public void handleUnknown(String key, Object value) { + StringBuilder sb = new StringBuilder(); + sb.append("Unknown property: '").append(key); + sb.append("' value: '").append(value).append("'"); + LOG.trace(sb.toString()); + } +} diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperChanges.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperChanges.java index d15d862e7..6ee334390 100644 --- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperChanges.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperChanges.java @@ -23,7 +23,8 @@ import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonProperty; import com.omertron.themoviedbapi.model.MovieChanges; import java.util.List; -import org.apache.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * @@ -34,7 +35,7 @@ public class WrapperChanges { * Logger */ - private static final Logger logger = Logger.getLogger(WrapperChanges.class); + private static final Logger LOG = LoggerFactory.getLogger(WrapperChanges.class); /* * Properties */ @@ -64,6 +65,6 @@ public class WrapperChanges { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - logger.trace(sb.toString()); + LOG.trace(sb.toString()); } } diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperCollection.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperCollection.java index 39a6115d8..450f47f9a 100644 --- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperCollection.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperCollection.java @@ -22,7 +22,8 @@ package com.omertron.themoviedbapi.wrapper; import com.fasterxml.jackson.annotation.JsonProperty; import com.omertron.themoviedbapi.model.Collection; import java.util.List; -import org.apache.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * @@ -36,7 +37,7 @@ public class WrapperCollection extends WrapperBase { private List results; public WrapperCollection() { - super(Logger.getLogger(WrapperCollection.class)); + super(LoggerFactory.getLogger(WrapperCollection.class)); } public List getResults() { diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperCompany.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperCompany.java index 760985d65..57a60c6ec 100644 --- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperCompany.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperCompany.java @@ -22,7 +22,8 @@ package com.omertron.themoviedbapi.wrapper; import com.fasterxml.jackson.annotation.JsonProperty; import com.omertron.themoviedbapi.model.Company; import java.util.List; -import org.apache.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * @@ -36,7 +37,7 @@ public class WrapperCompany extends WrapperBase{ private List results; public WrapperCompany() { - super(Logger.getLogger(WrapperCompany.class)); + super(LoggerFactory.getLogger(WrapperCompany.class)); } public List getResults() { diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperCompanyMovies.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperCompanyMovies.java index 25b3d8ccf..250ce3e12 100644 --- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperCompanyMovies.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperCompanyMovies.java @@ -1,62 +1,63 @@ -/* - * Copyright (c) 2004-2013 Stuart Boston - * - * This file is part of TheMovieDB API. - * - * TheMovieDB API is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * any later version. - * - * TheMovieDB API is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with TheMovieDB API. If not, see . - * - */ -package com.omertron.themoviedbapi.wrapper; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.omertron.themoviedbapi.model.MovieDb; -import java.util.List; -import org.apache.log4j.Logger; - -/** - * - * @author stuart.boston - */ -public class WrapperCompanyMovies extends WrapperBase { - /* - * Properties - */ - - @JsonProperty("results") - private List results; - - public WrapperCompanyMovies() { - super(Logger.getLogger(WrapperCompanyMovies.class)); - } - - public List getResults() { - return results; - } - - public void setResults(List results) { - this.results = results; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder("[ResultList=["); - sb.append("[companyId=").append(getId()); - sb.append("],[page=").append(getPage()); - sb.append("],[pageResults=").append(getResults().size()); - sb.append("],[totalPages=").append(getTotalPages()); - sb.append("],[totalResults=").append(getTotalResults()); - sb.append("]]"); - return sb.toString(); - } -} +/* + * Copyright (c) 2004-2013 Stuart Boston + * + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . + * + */ +package com.omertron.themoviedbapi.wrapper; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.omertron.themoviedbapi.model.MovieDb; +import java.util.List; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * + * @author stuart.boston + */ +public class WrapperCompanyMovies extends WrapperBase { + /* + * Properties + */ + + @JsonProperty("results") + private List results; + + public WrapperCompanyMovies() { + super(LoggerFactory.getLogger(WrapperCompanyMovies.class)); + } + + public List getResults() { + return results; + } + + public void setResults(List results) { + this.results = results; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("[ResultList=["); + sb.append("[companyId=").append(getId()); + sb.append("],[page=").append(getPage()); + sb.append("],[pageResults=").append(getResults().size()); + sb.append("],[totalPages=").append(getTotalPages()); + sb.append("],[totalResults=").append(getTotalResults()); + sb.append("]]"); + return sb.toString(); + } +} diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperConfig.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperConfig.java index 88da08c7d..25bceede1 100644 --- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperConfig.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperConfig.java @@ -24,7 +24,8 @@ import com.fasterxml.jackson.annotation.JsonProperty; import com.omertron.themoviedbapi.model.TmdbConfiguration; import java.util.Collections; import java.util.List; -import org.apache.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * @@ -35,7 +36,7 @@ public class WrapperConfig { * Logger */ - private static final Logger logger = Logger.getLogger(WrapperConfig.class); + private static final Logger LOG = LoggerFactory.getLogger(WrapperConfig.class); /* * Properties */ @@ -71,6 +72,6 @@ public class WrapperConfig { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - logger.trace(sb.toString()); + LOG.trace(sb.toString()); } } diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperGenres.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperGenres.java index eafecb9e4..fba87f307 100644 --- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperGenres.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperGenres.java @@ -1,66 +1,67 @@ -/* - * Copyright (c) 2004-2013 Stuart Boston - * - * This file is part of TheMovieDB API. - * - * TheMovieDB API is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * any later version. - * - * TheMovieDB API is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with TheMovieDB API. If not, see . - * - */ -package com.omertron.themoviedbapi.wrapper; - -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.omertron.themoviedbapi.model.Genre; -import java.util.List; -import org.apache.log4j.Logger; - -/** - * Wrapper class for the Genres searches - * - * @author Stuart - */ -public class WrapperGenres { - /* - * Logger - */ - - private static final Logger logger = Logger.getLogger(WrapperGenres.class); - /* - * Properties - */ - @JsonProperty("genres") - private List genres; - - public List getGenres() { - return genres; - } - - public void setGenres(List genres) { - this.genres = genres; - } - - /** - * Handle unknown properties and print a message - * - * @param key - * @param value - */ - @JsonAnySetter - public void handleUnknown(String key, Object value) { - StringBuilder sb = new StringBuilder(); - sb.append("Unknown property: '").append(key); - sb.append("' value: '").append(value).append("'"); - logger.trace(sb.toString()); - } -} +/* + * Copyright (c) 2004-2013 Stuart Boston + * + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . + * + */ +package com.omertron.themoviedbapi.wrapper; + +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.omertron.themoviedbapi.model.Genre; +import java.util.List; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * Wrapper class for the Genres searches + * + * @author Stuart + */ +public class WrapperGenres { + /* + * Logger + */ + + private static final Logger LOG = LoggerFactory.getLogger(WrapperGenres.class); + /* + * Properties + */ + @JsonProperty("genres") + private List genres; + + public List getGenres() { + return genres; + } + + public void setGenres(List genres) { + this.genres = genres; + } + + /** + * Handle unknown properties and print a message + * + * @param key + * @param value + */ + @JsonAnySetter + public void handleUnknown(String key, Object value) { + StringBuilder sb = new StringBuilder(); + sb.append("Unknown property: '").append(key); + sb.append("' value: '").append(value).append("'"); + LOG.trace(sb.toString()); + } +} diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperImages.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperImages.java index adaaebae0..51670bf8d 100644 --- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperImages.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperImages.java @@ -1,73 +1,74 @@ -/* - * Copyright (c) 2004-2013 Stuart Boston - * - * This file is part of TheMovieDB API. - * - * TheMovieDB API is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * any later version. - * - * TheMovieDB API is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with TheMovieDB API. If not, see . - * - */ -package com.omertron.themoviedbapi.wrapper; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.omertron.themoviedbapi.model.Artwork; -import java.util.List; -import org.apache.log4j.Logger; - -/** - * - * @author Stuart - */ -public class WrapperImages extends WrapperBase { - /* - * Properties - */ - @JsonProperty("backdrops") - private List backdrops; - @JsonProperty("posters") - private List posters; - @JsonProperty("profiles") - private List profiles; - - public WrapperImages() { - super(Logger.getLogger(WrapperImages.class)); - } - - // - public List getBackdrops() { - return backdrops; - } - - public List getPosters() { - return posters; - } - - public List getProfiles() { - return profiles; - } - // - - // - public void setBackdrops(List backdrops) { - this.backdrops = backdrops; - } - - public void setPosters(List posters) { - this.posters = posters; - } - - public void setProfiles(List profiles) { - this.profiles = profiles; - } - // -} +/* + * Copyright (c) 2004-2013 Stuart Boston + * + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . + * + */ +package com.omertron.themoviedbapi.wrapper; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.omertron.themoviedbapi.model.Artwork; +import java.util.List; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * + * @author Stuart + */ +public class WrapperImages extends WrapperBase { + /* + * Properties + */ + @JsonProperty("backdrops") + private List backdrops; + @JsonProperty("posters") + private List posters; + @JsonProperty("profiles") + private List profiles; + + public WrapperImages() { + super(LoggerFactory.getLogger(WrapperImages.class)); + } + + // + public List getBackdrops() { + return backdrops; + } + + public List getPosters() { + return posters; + } + + public List getProfiles() { + return profiles; + } + // + + // + public void setBackdrops(List backdrops) { + this.backdrops = backdrops; + } + + public void setPosters(List posters) { + this.posters = posters; + } + + public void setProfiles(List profiles) { + this.profiles = profiles; + } + // +} diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperKeywordMovies.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperKeywordMovies.java index 5778f4ef8..70713b380 100644 --- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperKeywordMovies.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperKeywordMovies.java @@ -22,7 +22,8 @@ package com.omertron.themoviedbapi.wrapper; import com.fasterxml.jackson.annotation.JsonProperty; import com.omertron.themoviedbapi.model.KeywordMovie; import java.util.List; -import org.apache.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * @@ -36,7 +37,7 @@ public class WrapperKeywordMovies extends WrapperBase { private List results; public WrapperKeywordMovies() { - super(Logger.getLogger(WrapperKeywordMovies.class)); + super(LoggerFactory.getLogger(WrapperKeywordMovies.class)); } public List getResults() { diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperKeywords.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperKeywords.java index 7d23a6e20..5a245b7f3 100644 --- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperKeywords.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperKeywords.java @@ -22,7 +22,8 @@ package com.omertron.themoviedbapi.wrapper; import com.fasterxml.jackson.annotation.JsonProperty; import com.omertron.themoviedbapi.model.Keyword; import java.util.List; -import org.apache.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * @@ -36,7 +37,7 @@ public class WrapperKeywords extends WrapperBase { private List results; public WrapperKeywords() { - super(Logger.getLogger(WrapperKeywords.class)); + super(LoggerFactory.getLogger(WrapperKeywords.class)); } public List getResults() { diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovie.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovie.java index ac99dea49..0f812e0b3 100644 --- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovie.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovie.java @@ -1,62 +1,63 @@ -/* - * Copyright (c) 2004-2013 Stuart Boston - * - * This file is part of TheMovieDB API. - * - * TheMovieDB API is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * any later version. - * - * TheMovieDB API is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with TheMovieDB API. If not, see . - * - */ -package com.omertron.themoviedbapi.wrapper; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.omertron.themoviedbapi.model.MovieDb; -import java.util.List; -import org.apache.log4j.Logger; - -/** - * - * @author stuart.boston - */ -public class WrapperMovie extends WrapperBase { - /* - * Properties - */ - - @JsonProperty("results") - private List movies; - - public WrapperMovie() { - super(Logger.getLogger(WrapperMovie.class)); - } - - public List getMovies() { - return movies; - } - - public void setMovies(List movies) { - this.movies = movies; - } - - @Override - public String toString() { - StringBuilder sb = new StringBuilder("[ResultList=["); - sb.append("[page=").append(getPage()); - sb.append("],[pageResults=").append(getMovies().size()); - sb.append("],[totalPages=").append(getTotalPages()); - sb.append("],[totalResults=").append(getTotalResults()); - sb.append("],[id=").append(getId()); - sb.append("]]"); - return sb.toString(); - } -} +/* + * Copyright (c) 2004-2013 Stuart Boston + * + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . + * + */ +package com.omertron.themoviedbapi.wrapper; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.omertron.themoviedbapi.model.MovieDb; +import java.util.List; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * + * @author stuart.boston + */ +public class WrapperMovie extends WrapperBase { + /* + * Properties + */ + + @JsonProperty("results") + private List movies; + + public WrapperMovie() { + super(LoggerFactory.getLogger(WrapperMovie.class)); + } + + public List getMovies() { + return movies; + } + + public void setMovies(List movies) { + this.movies = movies; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder("[ResultList=["); + sb.append("[page=").append(getPage()); + sb.append("],[pageResults=").append(getMovies().size()); + sb.append("],[totalPages=").append(getTotalPages()); + sb.append("],[totalResults=").append(getTotalResults()); + sb.append("],[id=").append(getId()); + sb.append("]]"); + return sb.toString(); + } +} diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovieCasts.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovieCasts.java index 350d45ef4..b0db38e1e 100644 --- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovieCasts.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovieCasts.java @@ -1,89 +1,90 @@ -/* - * Copyright (c) 2004-2013 Stuart Boston - * - * This file is part of TheMovieDB API. - * - * TheMovieDB API is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * any later version. - * - * TheMovieDB API is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with TheMovieDB API. If not, see . - * - */ -package com.omertron.themoviedbapi.wrapper; - -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.omertron.themoviedbapi.model.PersonCast; -import com.omertron.themoviedbapi.model.PersonCrew; -import java.util.List; -import org.apache.log4j.Logger; - -/** - * - * @author Stuart - */ -public class WrapperMovieCasts { - /* - * Logger - */ - - private static final Logger logger = Logger.getLogger(WrapperMovieCasts.class); - /* - * Properties - */ - @JsonProperty("id") - private int id; - @JsonProperty("cast") - private List cast; - @JsonProperty("crew") - private List crew; - - // - public List getCast() { - return cast; - } - - public List getCrew() { - return crew; - } - - public int getId() { - return id; - } - // - - // - public void setCast(List cast) { - this.cast = cast; - } - - public void setCrew(List crew) { - this.crew = crew; - } - - public void setId(int id) { - this.id = id; - } - // - - /** - * Handle unknown properties and print a message - * @param key - * @param value - */ - @JsonAnySetter - public void handleUnknown(String key, Object value) { - StringBuilder sb = new StringBuilder(); - sb.append("Unknown property: '").append(key); - sb.append("' value: '").append(value).append("'"); - logger.trace(sb.toString()); - } -} +/* + * Copyright (c) 2004-2013 Stuart Boston + * + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . + * + */ +package com.omertron.themoviedbapi.wrapper; + +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.omertron.themoviedbapi.model.PersonCast; +import com.omertron.themoviedbapi.model.PersonCrew; +import java.util.List; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * + * @author Stuart + */ +public class WrapperMovieCasts { + /* + * Logger + */ + + private static final Logger LOG = LoggerFactory.getLogger(WrapperMovieCasts.class); + /* + * Properties + */ + @JsonProperty("id") + private int id; + @JsonProperty("cast") + private List cast; + @JsonProperty("crew") + private List crew; + + // + public List getCast() { + return cast; + } + + public List getCrew() { + return crew; + } + + public int getId() { + return id; + } + // + + // + public void setCast(List cast) { + this.cast = cast; + } + + public void setCrew(List crew) { + this.crew = crew; + } + + public void setId(int id) { + this.id = id; + } + // + + /** + * Handle unknown properties and print a message + * @param key + * @param value + */ + @JsonAnySetter + public void handleUnknown(String key, Object value) { + StringBuilder sb = new StringBuilder(); + sb.append("Unknown property: '").append(key); + sb.append("' value: '").append(value).append("'"); + LOG.trace(sb.toString()); + } +} diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovieKeywords.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovieKeywords.java index ef920be4d..acbb80f86 100644 --- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovieKeywords.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovieKeywords.java @@ -1,78 +1,79 @@ -/* - * Copyright (c) 2004-2013 Stuart Boston - * - * This file is part of TheMovieDB API. - * - * TheMovieDB API is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * any later version. - * - * TheMovieDB API is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with TheMovieDB API. If not, see . - * - */ -package com.omertron.themoviedbapi.wrapper; - -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.omertron.themoviedbapi.model.Keyword; -import java.util.List; -import org.apache.log4j.Logger; - -/** - * - * @author Stuart - */ -public class WrapperMovieKeywords { - /* - * Logger - */ - - private static final Logger logger = Logger.getLogger(WrapperMovieKeywords.class); - /* - * Properties - */ - @JsonProperty("id") - private int id; - @JsonProperty("keywords") - private List keywords; - - // - public int getId() { - return id; - } - - public List getKeywords() { - return keywords; - } - // - - // - public void setId(int id) { - this.id = id; - } - - public void setKeywords(List keywords) { - this.keywords = keywords; - } - // - - /** - * Handle unknown properties and print a message - * @param key - * @param value - */ - @JsonAnySetter - public void handleUnknown(String key, Object value) { - StringBuilder sb = new StringBuilder(); - sb.append("Unknown property: '").append(key); - sb.append("' value: '").append(value).append("'"); - logger.trace(sb.toString()); - } -} +/* + * Copyright (c) 2004-2013 Stuart Boston + * + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . + * + */ +package com.omertron.themoviedbapi.wrapper; + +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.omertron.themoviedbapi.model.Keyword; +import java.util.List; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * + * @author Stuart + */ +public class WrapperMovieKeywords { + /* + * Logger + */ + + private static final Logger LOG = LoggerFactory.getLogger(WrapperMovieKeywords.class); + /* + * Properties + */ + @JsonProperty("id") + private int id; + @JsonProperty("keywords") + private List keywords; + + // + public int getId() { + return id; + } + + public List getKeywords() { + return keywords; + } + // + + // + public void setId(int id) { + this.id = id; + } + + public void setKeywords(List keywords) { + this.keywords = keywords; + } + // + + /** + * Handle unknown properties and print a message + * @param key + * @param value + */ + @JsonAnySetter + public void handleUnknown(String key, Object value) { + StringBuilder sb = new StringBuilder(); + sb.append("Unknown property: '").append(key); + sb.append("' value: '").append(value).append("'"); + LOG.trace(sb.toString()); + } +} diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovieList.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovieList.java index f05ed67da..658b249f4 100644 --- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovieList.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovieList.java @@ -1,50 +1,51 @@ -/* - * Copyright (c) 2004-2013 Stuart Boston - * - * This file is part of TheMovieDB API. - * - * TheMovieDB API is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * any later version. - * - * TheMovieDB API is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with TheMovieDB API. If not, see . - * - */ -package com.omertron.themoviedbapi.wrapper; - -import com.fasterxml.jackson.annotation.JsonProperty; -import com.omertron.themoviedbapi.model.MovieList; -import java.util.List; -import org.apache.log4j.Logger; - -/** - * - * @author Stuart - */ -public class WrapperMovieList extends WrapperBase { - /* - * Properties - */ - - @JsonProperty("results") - private List movieList; - - public WrapperMovieList() { - super(Logger.getLogger(WrapperMovieList.class)); - } - - public List getMovieList() { - return movieList; - } - - public void setMovieList(List movieList) { - this.movieList = movieList; - } -} +/* + * Copyright (c) 2004-2013 Stuart Boston + * + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . + * + */ +package com.omertron.themoviedbapi.wrapper; + +import com.fasterxml.jackson.annotation.JsonProperty; +import com.omertron.themoviedbapi.model.MovieList; +import java.util.List; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * + * @author Stuart + */ +public class WrapperMovieList extends WrapperBase { + /* + * Properties + */ + + @JsonProperty("results") + private List movieList; + + public WrapperMovieList() { + super(LoggerFactory.getLogger(WrapperMovieList.class)); + } + + public List getMovieList() { + return movieList; + } + + public void setMovieList(List movieList) { + this.movieList = movieList; + } +} diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperPerson.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperPerson.java index 7e33aff4c..22ef9f7fc 100644 --- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperPerson.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperPerson.java @@ -22,7 +22,8 @@ package com.omertron.themoviedbapi.wrapper; import com.fasterxml.jackson.annotation.JsonProperty; import com.omertron.themoviedbapi.model.Person; import java.util.List; -import org.apache.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * @@ -36,7 +37,7 @@ public class WrapperPerson extends WrapperBase { private List results; public WrapperPerson() { - super(Logger.getLogger(WrapperPerson.class)); + super(LoggerFactory.getLogger(WrapperPerson.class)); } public List getResults() { diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperPersonCredits.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperPersonCredits.java index 65a2b509d..ac9bd01f7 100644 --- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperPersonCredits.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperPersonCredits.java @@ -22,7 +22,8 @@ package com.omertron.themoviedbapi.wrapper; import com.fasterxml.jackson.annotation.JsonProperty; import com.omertron.themoviedbapi.model.PersonCredit; import java.util.List; -import org.apache.log4j.Logger; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * @@ -38,7 +39,7 @@ public class WrapperPersonCredits extends WrapperBase{ private List crew; public WrapperPersonCredits() { - super(Logger.getLogger(WrapperMovieCasts.class)); + super(LoggerFactory.getLogger(WrapperMovieCasts.class)); } public List getCast() { diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperReleaseInfo.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperReleaseInfo.java index 26cfa455a..093a7be3d 100644 --- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperReleaseInfo.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperReleaseInfo.java @@ -1,78 +1,79 @@ -/* - * Copyright (c) 2004-2013 Stuart Boston - * - * This file is part of TheMovieDB API. - * - * TheMovieDB API is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * any later version. - * - * TheMovieDB API is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with TheMovieDB API. If not, see . - * - */ -package com.omertron.themoviedbapi.wrapper; - -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.omertron.themoviedbapi.model.ReleaseInfo; -import java.util.List; -import org.apache.log4j.Logger; - -/** - * - * @author Stuart - */ -public class WrapperReleaseInfo { - /* - * Logger - */ - - private static final Logger logger = Logger.getLogger(WrapperReleaseInfo.class); - /* - * Properties - */ - @JsonProperty("id") - private int id; - @JsonProperty("countries") - private List countries; - - // - public List getCountries() { - return countries; - } - - public int getId() { - return id; - } - // - - // - public void setCountries(List countries) { - this.countries = countries; - } - - public void setId(int id) { - this.id = id; - } - // - - /** - * Handle unknown properties and print a message - * @param key - * @param value - */ - @JsonAnySetter - public void handleUnknown(String key, Object value) { - StringBuilder sb = new StringBuilder(); - sb.append("Unknown property: '").append(key); - sb.append("' value: '").append(value).append("'"); - logger.trace(sb.toString()); - } -} +/* + * Copyright (c) 2004-2013 Stuart Boston + * + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . + * + */ +package com.omertron.themoviedbapi.wrapper; + +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.omertron.themoviedbapi.model.ReleaseInfo; +import java.util.List; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * + * @author Stuart + */ +public class WrapperReleaseInfo { + /* + * Logger + */ + + private static final Logger LOG = LoggerFactory.getLogger(WrapperReleaseInfo.class); + /* + * Properties + */ + @JsonProperty("id") + private int id; + @JsonProperty("countries") + private List countries; + + // + public List getCountries() { + return countries; + } + + public int getId() { + return id; + } + // + + // + public void setCountries(List countries) { + this.countries = countries; + } + + public void setId(int id) { + this.id = id; + } + // + + /** + * Handle unknown properties and print a message + * @param key + * @param value + */ + @JsonAnySetter + public void handleUnknown(String key, Object value) { + StringBuilder sb = new StringBuilder(); + sb.append("Unknown property: '").append(key); + sb.append("' value: '").append(value).append("'"); + LOG.trace(sb.toString()); + } +} diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperTrailers.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperTrailers.java index 08a0453ad..bdfa09ca4 100644 --- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperTrailers.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperTrailers.java @@ -1,88 +1,89 @@ -/* - * Copyright (c) 2004-2013 Stuart Boston - * - * This file is part of TheMovieDB API. - * - * TheMovieDB API is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * any later version. - * - * TheMovieDB API is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with TheMovieDB API. If not, see . - * - */ -package com.omertron.themoviedbapi.wrapper; - -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.omertron.themoviedbapi.model.Trailer; -import java.util.List; -import org.apache.log4j.Logger; - -/** - * - * @author Stuart - */ -public class WrapperTrailers { - /* - * Logger - */ - - private static final Logger logger = Logger.getLogger(WrapperTrailers.class); - /* - * Properties - */ - @JsonProperty("id") - private int id; - @JsonProperty("quicktime") - private List quicktime; - @JsonProperty("youtube") - private List youtube; - - // - public int getId() { - return id; - } - - public List getQuicktime() { - return quicktime; - } - - public List getYoutube() { - return youtube; - } - // - - // - public void setId(int id) { - this.id = id; - } - - public void setQuicktime(List quicktime) { - this.quicktime = quicktime; - } - - public void setYoutube(List youtube) { - this.youtube = youtube; - } - // - - /** - * Handle unknown properties and print a message - * @param key - * @param value - */ - @JsonAnySetter - public void handleUnknown(String key, Object value) { - StringBuilder sb = new StringBuilder(); - sb.append("Unknown property: '").append(key); - sb.append("' value: '").append(value).append("'"); - logger.trace(sb.toString()); - } -} +/* + * Copyright (c) 2004-2013 Stuart Boston + * + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . + * + */ +package com.omertron.themoviedbapi.wrapper; + +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.omertron.themoviedbapi.model.Trailer; +import java.util.List; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * + * @author Stuart + */ +public class WrapperTrailers { + /* + * Logger + */ + + private static final Logger LOG = LoggerFactory.getLogger(WrapperTrailers.class); + /* + * Properties + */ + @JsonProperty("id") + private int id; + @JsonProperty("quicktime") + private List quicktime; + @JsonProperty("youtube") + private List youtube; + + // + public int getId() { + return id; + } + + public List getQuicktime() { + return quicktime; + } + + public List getYoutube() { + return youtube; + } + // + + // + public void setId(int id) { + this.id = id; + } + + public void setQuicktime(List quicktime) { + this.quicktime = quicktime; + } + + public void setYoutube(List youtube) { + this.youtube = youtube; + } + // + + /** + * Handle unknown properties and print a message + * @param key + * @param value + */ + @JsonAnySetter + public void handleUnknown(String key, Object value) { + StringBuilder sb = new StringBuilder(); + sb.append("Unknown property: '").append(key); + sb.append("' value: '").append(value).append("'"); + LOG.trace(sb.toString()); + } +} diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperTranslations.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperTranslations.java index 466d52ca3..4edf633e2 100644 --- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperTranslations.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperTranslations.java @@ -1,78 +1,79 @@ -/* - * Copyright (c) 2004-2013 Stuart Boston - * - * This file is part of TheMovieDB API. - * - * TheMovieDB API is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * any later version. - * - * TheMovieDB API is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with TheMovieDB API. If not, see . - * - */ -package com.omertron.themoviedbapi.wrapper; - -import com.fasterxml.jackson.annotation.JsonAnySetter; -import com.fasterxml.jackson.annotation.JsonProperty; -import com.omertron.themoviedbapi.model.Translation; -import java.util.List; -import org.apache.log4j.Logger; - -/** - * - * @author Stuart - */ -public class WrapperTranslations { - /* - * Logger - */ - - private static final Logger logger = Logger.getLogger(WrapperTranslations.class); - /* - * Properties - */ - @JsonProperty("id") - private int id; - @JsonProperty("translations") - private List translations; - - // - public void setId(int id) { - this.id = id; - } - - public void setTranslations(List translations) { - this.translations = translations; - } - // - - // - public int getId() { - return id; - } - - public List getTranslations() { - return translations; - } - // - - /** - * Handle unknown properties and print a message - * @param key - * @param value - */ - @JsonAnySetter - public void handleUnknown(String key, Object value) { - StringBuilder sb = new StringBuilder(); - sb.append("Unknown property: '").append(key); - sb.append("' value: '").append(value).append("'"); - logger.trace(sb.toString()); - } -} +/* + * Copyright (c) 2004-2013 Stuart Boston + * + * This file is part of TheMovieDB API. + * + * TheMovieDB API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * TheMovieDB API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with TheMovieDB API. If not, see . + * + */ +package com.omertron.themoviedbapi.wrapper; + +import com.fasterxml.jackson.annotation.JsonAnySetter; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.omertron.themoviedbapi.model.Translation; +import java.util.List; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +/** + * + * @author Stuart + */ +public class WrapperTranslations { + /* + * Logger + */ + + private static final Logger LOG = LoggerFactory.getLogger(WrapperTranslations.class); + /* + * Properties + */ + @JsonProperty("id") + private int id; + @JsonProperty("translations") + private List translations; + + // + public void setId(int id) { + this.id = id; + } + + public void setTranslations(List translations) { + this.translations = translations; + } + // + + // + public int getId() { + return id; + } + + public List getTranslations() { + return translations; + } + // + + /** + * Handle unknown properties and print a message + * @param key + * @param value + */ + @JsonAnySetter + public void handleUnknown(String key, Object value) { + StringBuilder sb = new StringBuilder(); + sb.append("Unknown property: '").append(key); + sb.append("' value: '").append(value).append("'"); + LOG.trace(sb.toString()); + } +} diff --git a/src/main/resources/log4j-example.properties b/src/main/resources/log4j-example.properties deleted file mode 100644 index be8e13285..000000000 --- a/src/main/resources/log4j-example.properties +++ /dev/null @@ -1,7 +0,0 @@ -log4j.rootLogger=DEBUG, CONSOLE -log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender -log4j.appender.CONSOLE.layout=com.omertron.themoviedbapi.tools.FilteringLayout -#log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout -log4j.appender.CONSOLE.layout.ConversionPattern=[TheMovieDB API-%C{1}] %m%n -#log4j.appender.CONSOLE.Threshold=DEBUG -log4j.appender.CONSOLE.Encoding=UTF-8 diff --git a/src/test/java/com/omertron/themoviedbapi/TheMovieDbApiTest.java b/src/test/java/com/omertron/themoviedbapi/TheMovieDbApiTest.java index d80057355..13ab6c8d0 100644 --- a/src/test/java/com/omertron/themoviedbapi/TheMovieDbApiTest.java +++ b/src/test/java/com/omertron/themoviedbapi/TheMovieDbApiTest.java @@ -39,14 +39,12 @@ import com.omertron.themoviedbapi.model.TokenAuthorisation; import com.omertron.themoviedbapi.model.TokenSession; import com.omertron.themoviedbapi.model.Trailer; import com.omertron.themoviedbapi.model.Translation; -import com.omertron.themoviedbapi.tools.FilteringLayout; import java.io.IOException; import java.util.Collections; import java.util.List; +import java.util.logging.Level; +import java.util.logging.Logger; import org.apache.commons.lang3.StringUtils; -import org.apache.log4j.BasicConfigurator; -import org.apache.log4j.Level; -import org.apache.log4j.Logger; import org.junit.*; import static org.junit.Assert.*; @@ -58,7 +56,7 @@ import static org.junit.Assert.*; public class TheMovieDbApiTest { // Logger - private static final Logger logger = Logger.getLogger(TheMovieDbApiTest.class); + private static final Logger LOG = Logger.getLogger(TheMovieDbApiTest.class.getSimpleName()); // API Key private static final String API_KEY = "5a1a77e2eba8984804586122754f969f"; private static TheMovieDbApi tmdb; @@ -79,9 +77,8 @@ public class TheMovieDbApiTest { @BeforeClass public static void setUpClass() throws Exception { - BasicConfigurator.configure(); - // Set the logger level to TRACE - Logger.getRootLogger().setLevel(Level.TRACE); + // Set the LOG level to ALL + LOG.setLevel(Level.ALL); tmdb = new TheMovieDbApi(API_KEY); } @@ -91,8 +88,6 @@ public class TheMovieDbApiTest { @Before public void setUp() { - // Make sure the filter isn't applied to the test output - FilteringLayout.addReplacementString("DO_NOT_MATCH"); } @After @@ -104,7 +99,7 @@ public class TheMovieDbApiTest { */ @Test public void testConfiguration() throws IOException { - logger.info("Test Configuration"); + LOG.info("Test Configuration"); TmdbConfiguration tmdbConfig = tmdb.getConfiguration(); assertNotNull("Configuration failed", tmdbConfig); @@ -112,7 +107,7 @@ public class TheMovieDbApiTest { assertTrue("No backdrop sizes", tmdbConfig.getBackdropSizes().size() > 0); assertTrue("No poster sizes", tmdbConfig.getPosterSizes().size() > 0); assertTrue("No profile sizes", tmdbConfig.getProfileSizes().size() > 0); - logger.info(tmdbConfig.toString()); + LOG.info(tmdbConfig.toString()); } /** @@ -120,7 +115,7 @@ public class TheMovieDbApiTest { */ @Test public void testSearchMovie() throws MovieDbException { - logger.info("searchMovie"); + LOG.info("searchMovie"); // Try a movie with less than 1 page of results List movieList = tmdb.searchMovie("Blade Runner", 0, "", true, 0); @@ -128,7 +123,7 @@ public class TheMovieDbApiTest { assertTrue("No movies found, should be at least 1", movieList.size() > 0); // Try a russian langugage movie - movieList = tmdb.searchMovie("О чём говорят мужчины", 0, "ru", true, 0); + movieList = tmdb.searchMovie("О чём говор�?т мужчины", 0, "ru", true, 0); assertTrue("No movies found, should be at least 1", movieList.size() > 0); // Try a movie with more than 20 results @@ -141,7 +136,7 @@ public class TheMovieDbApiTest { */ @Test public void testGetMovieInfo() throws MovieDbException { - logger.info("getMovieInfo"); + LOG.info("getMovieInfo"); String language = "en"; MovieDb result = tmdb.getMovieInfo(ID_MOVIE_BLADE_RUNNER, language); assertEquals("Incorrect movie information", "Blade Runner", result.getOriginalTitle()); @@ -152,7 +147,7 @@ public class TheMovieDbApiTest { */ @Test public void testGetMovieAlternativeTitles() throws MovieDbException { - logger.info("getMovieAlternativeTitles"); + LOG.info("getMovieAlternativeTitles"); String country = ""; List results = tmdb.getMovieAlternativeTitles(ID_MOVIE_BLADE_RUNNER, country); assertTrue("No alternative titles found", results.size() > 0); @@ -168,7 +163,7 @@ public class TheMovieDbApiTest { */ @Test public void testGetMovieCasts() throws MovieDbException { - logger.info("getMovieCasts"); + LOG.info("getMovieCasts"); List people = tmdb.getMovieCasts(ID_MOVIE_BLADE_RUNNER); assertTrue("No cast information", people.size() > 0); @@ -195,7 +190,7 @@ public class TheMovieDbApiTest { */ @Test public void testGetMovieImages() throws MovieDbException { - logger.info("getMovieImages"); + LOG.info("getMovieImages"); String language = ""; List result = tmdb.getMovieImages(ID_MOVIE_BLADE_RUNNER, language); assertFalse("No artwork found", result.isEmpty()); @@ -206,7 +201,7 @@ public class TheMovieDbApiTest { */ @Test public void testGetMovieKeywords() throws MovieDbException { - logger.info("getMovieKeywords"); + LOG.info("getMovieKeywords"); List result = tmdb.getMovieKeywords(ID_MOVIE_BLADE_RUNNER); assertFalse("No keywords found", result.isEmpty()); } @@ -216,7 +211,7 @@ public class TheMovieDbApiTest { */ @Test public void testGetMovieReleaseInfo() throws MovieDbException { - logger.info("getMovieReleaseInfo"); + LOG.info("getMovieReleaseInfo"); List result = tmdb.getMovieReleaseInfo(ID_MOVIE_BLADE_RUNNER, ""); assertFalse("Release information missing", result.isEmpty()); } @@ -226,7 +221,7 @@ public class TheMovieDbApiTest { */ @Test public void testGetMovieTrailers() throws MovieDbException { - logger.info("getMovieTrailers"); + LOG.info("getMovieTrailers"); List result = tmdb.getMovieTrailers(ID_MOVIE_BLADE_RUNNER, ""); assertFalse("Movie trailers missing", result.isEmpty()); } @@ -236,7 +231,7 @@ public class TheMovieDbApiTest { */ @Test public void testGetMovieTranslations() throws MovieDbException { - logger.info("getMovieTranslations"); + LOG.info("getMovieTranslations"); List result = tmdb.getMovieTranslations(ID_MOVIE_BLADE_RUNNER); assertFalse("No translations found", result.isEmpty()); } @@ -246,7 +241,7 @@ public class TheMovieDbApiTest { */ @Test public void testGetCollectionInfo() throws MovieDbException { - logger.info("getCollectionInfo"); + LOG.info("getCollectionInfo"); String language = ""; CollectionInfo result = tmdb.getCollectionInfo(ID_MOVIE_STAR_WARS_COLLECTION, language); assertFalse("No collection information", result.getParts().isEmpty()); @@ -259,7 +254,7 @@ public class TheMovieDbApiTest { */ @Test public void testCreateImageUrl() throws MovieDbException { - logger.info("createImageUrl"); + LOG.info("createImageUrl"); MovieDb movie = tmdb.getMovieInfo(ID_MOVIE_BLADE_RUNNER, ""); String result = tmdb.createImageUrl(movie.getPosterPath(), "original").toString(); assertTrue("Error compiling image URL", !result.isEmpty()); @@ -270,7 +265,7 @@ public class TheMovieDbApiTest { */ @Test public void testGetMovieInfoImdb() throws MovieDbException { - logger.info("getMovieInfoImdb"); + LOG.info("getMovieInfoImdb"); MovieDb result = tmdb.getMovieInfoImdb("tt0076759", "en-US"); assertTrue("Error getting the movie from IMDB ID", result.getId() == 11); } @@ -304,7 +299,7 @@ public class TheMovieDbApiTest { */ @Test public void testSearchPeople() throws MovieDbException { - logger.info("searchPeople"); + LOG.info("searchPeople"); String personName = "Bruce Willis"; boolean includeAdult = false; List result = tmdb.searchPeople(personName, includeAdult, 0); @@ -316,7 +311,7 @@ public class TheMovieDbApiTest { */ @Test public void testGetPersonInfo() throws MovieDbException { - logger.info("getPersonInfo"); + LOG.info("getPersonInfo"); Person result = tmdb.getPersonInfo(ID_PERSON_BRUCE_WILLIS); assertTrue("Wrong actor returned", result.getId() == ID_PERSON_BRUCE_WILLIS); } @@ -326,7 +321,7 @@ public class TheMovieDbApiTest { */ @Test public void testGetPersonCredits() throws MovieDbException { - logger.info("getPersonCredits"); + LOG.info("getPersonCredits"); List people = tmdb.getPersonCredits(ID_PERSON_BRUCE_WILLIS); assertTrue("No cast information", people.size() > 0); @@ -337,7 +332,7 @@ public class TheMovieDbApiTest { */ @Test public void testGetPersonImages() throws MovieDbException { - logger.info("getPersonImages"); + LOG.info("getPersonImages"); List artwork = tmdb.getPersonImages(ID_PERSON_BRUCE_WILLIS); assertTrue("No cast information", artwork.size() > 0); @@ -348,7 +343,7 @@ public class TheMovieDbApiTest { */ @Test public void testGetLatestMovie() throws MovieDbException { - logger.info("getLatestMovie"); + LOG.info("getLatestMovie"); MovieDb result = tmdb.getLatestMovie(); assertTrue("No latest movie found", result != null); assertTrue("No latest movie found", result.getId() > 0); @@ -383,7 +378,7 @@ public class TheMovieDbApiTest { */ @Test public void testGetNowPlayingMovies() throws MovieDbException { - logger.info("getNowPlayingMovies"); + LOG.info("getNowPlayingMovies"); List results = tmdb.getNowPlayingMovies(LANGUAGE_DEFAULT, 0); assertTrue("No now playing movies found", !results.isEmpty()); } @@ -393,7 +388,7 @@ public class TheMovieDbApiTest { */ @Test public void testGetPopularMovieList() throws MovieDbException { - logger.info("getPopularMovieList"); + LOG.info("getPopularMovieList"); List results = tmdb.getPopularMovieList(LANGUAGE_DEFAULT, 0); assertTrue("No popular movies found", !results.isEmpty()); } @@ -403,7 +398,7 @@ public class TheMovieDbApiTest { */ @Test public void testGetTopRatedMovies() throws MovieDbException { - logger.info("getTopRatedMovies"); + LOG.info("getTopRatedMovies"); List results = tmdb.getTopRatedMovies(LANGUAGE_DEFAULT, 0); assertTrue("No top rated movies found", !results.isEmpty()); } @@ -413,7 +408,7 @@ public class TheMovieDbApiTest { */ @Test public void testGetCompanyInfo() throws MovieDbException { - logger.info("getCompanyInfo"); + LOG.info("getCompanyInfo"); Company company = tmdb.getCompanyInfo(ID_COMPANY_LUCASFILM); assertTrue("No company information found", company.getCompanyId() > 0); } @@ -423,7 +418,7 @@ public class TheMovieDbApiTest { */ @Test public void testGetCompanyMovies() throws MovieDbException { - logger.info("getCompanyMovies"); + LOG.info("getCompanyMovies"); List results = tmdb.getCompanyMovies(ID_COMPANY_LUCASFILM, LANGUAGE_DEFAULT, 0); assertTrue("No company movies found", !results.isEmpty()); } @@ -433,7 +428,7 @@ public class TheMovieDbApiTest { */ @Test public void testSearchCompanies() throws MovieDbException { - logger.info("searchCompanies"); + LOG.info("searchCompanies"); List results = tmdb.searchCompanies(COMPANY_NAME, 0); assertTrue("No company information found", !results.isEmpty()); } @@ -443,7 +438,7 @@ public class TheMovieDbApiTest { */ @Test public void testGetSimilarMovies() throws MovieDbException { - logger.info("getSimilarMovies"); + LOG.info("getSimilarMovies"); List results = tmdb.getSimilarMovies(ID_MOVIE_BLADE_RUNNER, LANGUAGE_DEFAULT, 0); assertTrue("No similar movies found", !results.isEmpty()); } @@ -453,7 +448,7 @@ public class TheMovieDbApiTest { */ @Test public void testGetGenreList() throws MovieDbException { - logger.info("getGenreList"); + LOG.info("getGenreList"); List results = tmdb.getGenreList(LANGUAGE_DEFAULT); assertTrue("No genres found", !results.isEmpty()); } @@ -463,7 +458,7 @@ public class TheMovieDbApiTest { */ @Test public void testGetGenreMovies() throws MovieDbException { - logger.info("getGenreMovies"); + LOG.info("getGenreMovies"); List results = tmdb.getGenreMovies(ID_GENRE_ACTION, LANGUAGE_DEFAULT, 0); assertTrue("No genre movies found", !results.isEmpty()); } @@ -473,7 +468,7 @@ public class TheMovieDbApiTest { */ @Test public void testGetUpcoming() throws Exception { - logger.info("getUpcoming"); + LOG.info("getUpcoming"); List results = tmdb.getUpcoming(LANGUAGE_DEFAULT, 0); assertTrue("No upcoming movies found", !results.isEmpty()); } @@ -483,7 +478,7 @@ public class TheMovieDbApiTest { */ @Test public void testGetCollectionImages() throws Exception { - logger.info("getCollectionImages"); + LOG.info("getCollectionImages"); List result = tmdb.getCollectionImages(ID_MOVIE_STAR_WARS_COLLECTION, LANGUAGE_DEFAULT); assertFalse("No artwork found", result.isEmpty()); } @@ -493,11 +488,11 @@ public class TheMovieDbApiTest { */ @Test public void testGetAuthorisationToken() throws Exception { - logger.info("getAuthorisationToken"); + LOG.info("getAuthorisationToken"); TokenAuthorisation result = tmdb.getAuthorisationToken(); assertFalse("Token is null", result == null); assertTrue("Token is not valid", result.getSuccess()); - logger.info(result.toString()); + LOG.info(result.toString()); } /** @@ -506,16 +501,16 @@ public class TheMovieDbApiTest { * TODO: Cannot be tested without a HTTP authorisation: http://help.themoviedb.org/kb/api/user-authentication */ public void testGetSessionToken() throws Exception { - logger.info("getSessionToken"); + LOG.info("getSessionToken"); TokenAuthorisation token = tmdb.getAuthorisationToken(); assertFalse("Token is null", token == null); assertTrue("Token is not valid", token.getSuccess()); - logger.info(token.toString()); + LOG.info(token.toString()); TokenSession result = tmdb.getSessionToken(token); assertFalse("Session token is null", result == null); assertTrue("Session token is not valid", result.getSuccess()); - logger.info(result.toString()); + LOG.info(result.toString()); } /** @@ -523,7 +518,7 @@ public class TheMovieDbApiTest { */ @Test public void testGetGuestSessionToken() throws Exception { - logger.info("getGuestSessionToken"); + LOG.info("getGuestSessionToken"); TokenSession result = tmdb.getGuestSessionToken(); assertTrue("Failed to get guest session", result.getSuccess()); @@ -531,7 +526,7 @@ public class TheMovieDbApiTest { @Test public void testGetMovieLists() throws Exception { - logger.info("getMovieLists"); + LOG.info("getMovieLists"); String language = "en"; List results = tmdb.getMovieLists(ID_MOVIE_BLADE_RUNNER, language, 0); assertNotNull("No results found", results); @@ -544,7 +539,7 @@ public class TheMovieDbApiTest { * TODO: Do not test this until it is fixed */ public void testGetMovieChanges() throws Exception { - logger.info("getMovieChanges"); + LOG.info("getMovieChanges"); String startDate = ""; String endDate = null; @@ -554,7 +549,7 @@ public class TheMovieDbApiTest { List movieList = tmdb.getPopularMovieList(LANGUAGE_DEFAULT, 0); for (MovieDb movie : movieList) { results = tmdb.getMovieChanges(movie.getId(), startDate, endDate); - logger.info(movie.getTitle() + " has " + results.size() + " changes."); + LOG.log(Level.INFO, "{0} has {1} changes.", new Object[]{movie.getTitle(), results.size()}); } assertNotNull("No results found", results); @@ -563,7 +558,7 @@ public class TheMovieDbApiTest { @Test public void testGetPersonLatest() throws Exception { - logger.info("getPersonLatest"); + LOG.info("getPersonLatest"); Person result = tmdb.getPersonLatest(); @@ -576,7 +571,7 @@ public class TheMovieDbApiTest { */ @Test public void testSearchCollection() throws Exception { - logger.info("searchCollection"); + LOG.info("searchCollection"); String query = "batman"; int page = 0; List result = tmdb.searchCollection(query, LANGUAGE_DEFAULT, page); @@ -589,7 +584,7 @@ public class TheMovieDbApiTest { */ @Test public void testSearchList() throws Exception { - logger.info("searchList"); + LOG.info("searchList"); String query = "watch"; int page = 0; List result = tmdb.searchList(query, LANGUAGE_DEFAULT, page); @@ -602,7 +597,7 @@ public class TheMovieDbApiTest { */ @Test public void testSearchKeyword() throws Exception { - logger.info("searchKeyword"); + LOG.info("searchKeyword"); String query = "action"; int page = 0; List result = tmdb.searchKeyword(query, page); @@ -616,7 +611,7 @@ public class TheMovieDbApiTest { * TODO: Cannot be tested without a HTTP authorisation: http://help.themoviedb.org/kb/api/user-authentication */ public void testPostMovieRating() throws Exception { - logger.info("postMovieRating"); + LOG.info("postMovieRating"); String sessionId = ""; String rating = ""; boolean expResult = false; @@ -632,7 +627,7 @@ public class TheMovieDbApiTest { * TODO: Fix the method before testing */ public void testGetPersonChanges() throws Exception { - logger.info("getPersonChanges"); + LOG.info("getPersonChanges"); String startDate = ""; String endDate = ""; tmdb.getPersonChanges(ID_PERSON_BRUCE_WILLIS, startDate, endDate); @@ -643,7 +638,7 @@ public class TheMovieDbApiTest { */ @Test public void testGetList() throws Exception { - logger.info("getList"); + LOG.info("getList"); String listId = "509ec17b19c2950a0600050d"; MovieDbList result = tmdb.getList(listId); assertFalse("List not found", result.getItems().isEmpty()); @@ -654,7 +649,7 @@ public class TheMovieDbApiTest { */ @Test public void testGetKeyword() throws Exception { - logger.info("getKeyword"); + LOG.info("getKeyword"); Keyword result = tmdb.getKeyword(ID_KEYWORD); assertEquals("fight", result.getName()); } @@ -664,7 +659,7 @@ public class TheMovieDbApiTest { */ @Test public void testGetKeywordMovies() throws Exception { - logger.info("getKeywordMovies"); + LOG.info("getKeywordMovies"); int page = 0; List result = tmdb.getKeywordMovies(ID_KEYWORD, LANGUAGE_DEFAULT, page); assertFalse("No keyword movies found", result.isEmpty()); From de67805b0cacd0fb8333eb5e7e0d303cbce2eb7c Mon Sep 17 00:00:00 2001 From: Stuart Boston Date: Sun, 24 Feb 2013 19:52:57 +0000 Subject: [PATCH 193/207] Updated README with logging information --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 0cbf3b66a..56c5ec377 100644 --- a/README.md +++ b/README.md @@ -11,6 +11,11 @@ But anyone can feel free to use it for other projects as well. TheMovieDB.org is an excellent open database for movie and film content. I encourage you to check it out and contribute to keep it growing. http://www.themoviedb.org +Project Logging +--------------- +This project uses SLF4J (http://www.slf4j.org) to abstract the logging in the project. +To use the logging in your own project you should add one of the bindings listed [HERE](http://www.slf4j.org/manual.html#swapping) + Project Documentation --------------------- The automatically generated documentation can be found [HERE](http://omertron.github.com/api-themoviedb/) From 160b478c112df158b24c1d5b41ddcf3fda28e5bf Mon Sep 17 00:00:00 2001 From: Stuart Boston Date: Mon, 25 Feb 2013 08:30:14 +0000 Subject: [PATCH 194/207] Updated LOG messages --- .../omertron/themoviedbapi/TheMovieDbApi.java | 80 +++++++++---------- 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java b/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java index 78b73e8d0..1016cd4b6 100644 --- a/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java +++ b/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java @@ -227,7 +227,7 @@ public class TheMovieDbApi { try { return (new URL(sb.toString())); } catch (MalformedURLException ex) { - LOG.warn("Failed to create image URL: " + ex.getMessage()); + LOG.warn("Failed to create image URL: {}", ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.INVALID_URL, sb.toString(), ex); } } @@ -255,7 +255,7 @@ public class TheMovieDbApi { try { return mapper.readValue(webpage, TokenAuthorisation.class); } catch (IOException ex) { - LOG.warn("Failed to get Authorisation Token: " + ex.getMessage()); + LOG.warn("Failed to get Authorisation Token: {}", ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.AUTHORISATION_FAILURE, webpage, ex); } } @@ -283,7 +283,7 @@ public class TheMovieDbApi { try { return mapper.readValue(webpage, TokenSession.class); } catch (IOException ex) { - LOG.warn("Failed to get Session Token: " + ex.getMessage()); + LOG.warn("Failed to get Session Token: {}", ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } @@ -311,7 +311,7 @@ public class TheMovieDbApi { try { return mapper.readValue(webpage, TokenSession.class); } catch (IOException ex) { - LOG.warn("Failed to get Session Token: " + ex.getMessage()); + LOG.warn("Failed to get Session Token: {}", ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } @@ -345,7 +345,7 @@ public class TheMovieDbApi { try { return mapper.readValue(webpage, MovieDb.class); } catch (IOException ex) { - LOG.warn("Failed to get movie info: " + ex.getMessage()); + LOG.warn("Failed to get movie info: {}", ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } @@ -373,7 +373,7 @@ public class TheMovieDbApi { try { return mapper.readValue(webpage, MovieDb.class); } catch (IOException ex) { - LOG.warn("Failed to get movie info: " + ex.getMessage()); + LOG.warn("Failed to get movie info: {}", ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } @@ -399,7 +399,7 @@ public class TheMovieDbApi { WrapperAlternativeTitles wrapper = mapper.readValue(webpage, WrapperAlternativeTitles.class); return wrapper.getTitles(); } catch (IOException ex) { - LOG.warn("Failed to get movie alternative titles: " + ex.getMessage()); + LOG.warn("Failed to get movie alternative titles: {}", ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } @@ -439,7 +439,7 @@ public class TheMovieDbApi { return people; } catch (IOException ex) { - LOG.warn("Failed to get movie casts: " + ex.getMessage()); + LOG.warn("Failed to get movie casts: {}", ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } @@ -479,7 +479,7 @@ public class TheMovieDbApi { return artwork; } catch (IOException ex) { - LOG.warn("Failed to get movie images: " + ex.getMessage()); + LOG.warn("Failed to get movie images: {}", ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } @@ -503,7 +503,7 @@ public class TheMovieDbApi { WrapperMovieKeywords wrapper = mapper.readValue(webpage, WrapperMovieKeywords.class); return wrapper.getKeywords(); } catch (IOException ex) { - LOG.warn("Failed to get movie keywords: " + ex.getMessage()); + LOG.warn("Failed to get movie keywords: {}", ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } @@ -527,7 +527,7 @@ public class TheMovieDbApi { WrapperReleaseInfo wrapper = mapper.readValue(webpage, WrapperReleaseInfo.class); return wrapper.getCountries(); } catch (IOException ex) { - LOG.warn("Failed to get movie release information: " + ex.getMessage()); + LOG.warn("Failed to get movie release information: {}", ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } @@ -569,7 +569,7 @@ public class TheMovieDbApi { } return trailers; } catch (IOException ex) { - LOG.warn("Failed to get movie trailers: " + ex.getMessage()); + LOG.warn("Failed to get movie trailers: {}", ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } @@ -591,7 +591,7 @@ public class TheMovieDbApi { WrapperTranslations wrapper = mapper.readValue(webpage, WrapperTranslations.class); return wrapper.getTranslations(); } catch (IOException ex) { - LOG.warn("Failed to get movie tranlations: " + ex.getMessage()); + LOG.warn("Failed to get movie tranlations: {}", ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } @@ -627,7 +627,7 @@ public class TheMovieDbApi { WrapperMovie wrapper = mapper.readValue(webpage, WrapperMovie.class); return wrapper.getMovies(); } catch (IOException ex) { - LOG.warn("Failed to get similar movies: " + ex.getMessage()); + LOG.warn("Failed to get similar movies: {}", ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } @@ -659,7 +659,7 @@ public class TheMovieDbApi { WrapperMovieList wrapper = mapper.readValue(webpage, WrapperMovieList.class); return wrapper.getMovieList(); } catch (IOException ex) { - LOG.warn("Failed to get movie lists: " + ex.getMessage()); + LOG.warn("Failed to get movie lists: {}", ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } @@ -702,7 +702,7 @@ public class TheMovieDbApi { WrapperChanges wrapper = mapper.readValue(webpage, WrapperChanges.class); return wrapper.getChanges(); } catch (IOException ex) { - LOG.warn("Failed to get movie changes: " + ex.getMessage()); + LOG.warn("Failed to get movie changes: {}", ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } @@ -720,7 +720,7 @@ public class TheMovieDbApi { try { return mapper.readValue(webpage, MovieDb.class); } catch (IOException ex) { - LOG.warn("Failed to get latest movie: " + ex.getMessage()); + LOG.warn("Failed to get latest movie: {}", ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } @@ -752,7 +752,7 @@ public class TheMovieDbApi { WrapperMovie wrapper = mapper.readValue(webpage, WrapperMovie.class); return wrapper.getMovies(); } catch (IOException ex) { - LOG.warn("Failed to get upcoming movies: " + ex.getMessage()); + LOG.warn("Failed to get upcoming movies: {}", ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } @@ -787,7 +787,7 @@ public class TheMovieDbApi { WrapperMovie wrapper = mapper.readValue(webpage, WrapperMovie.class); return wrapper.getMovies(); } catch (IOException ex) { - LOG.warn("Failed to get now playing movies: " + ex.getMessage()); + LOG.warn("Failed to get now playing movies: {}", ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } @@ -821,7 +821,7 @@ public class TheMovieDbApi { WrapperMovie wrapper = mapper.readValue(webpage, WrapperMovie.class); return wrapper.getMovies(); } catch (IOException ex) { - LOG.warn("Failed to get popular movie list: " + ex.getMessage()); + LOG.warn("Failed to get popular movie list: {}", ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } @@ -855,7 +855,7 @@ public class TheMovieDbApi { WrapperMovie wrapper = mapper.readValue(webpage, WrapperMovie.class); return wrapper.getMovies(); } catch (IOException ex) { - LOG.warn("Failed to get top rated movies: " + ex.getMessage()); + LOG.warn("Failed to get top rated movies: {}", ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } @@ -904,7 +904,7 @@ public class TheMovieDbApi { try { return mapper.readValue(webpage, CollectionInfo.class); } catch (IOException ex) { - LOG.warn("Failed to get collection information: " + ex.getMessage()); + LOG.warn("Failed to get collection information: {}", ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } @@ -945,7 +945,7 @@ public class TheMovieDbApi { return artwork; } catch (IOException ex) { - LOG.warn("Failed to get collection images: " + ex.getMessage()); + LOG.warn("Failed to get collection images: {}", ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } @@ -973,7 +973,7 @@ public class TheMovieDbApi { try { return mapper.readValue(webpage, Person.class); } catch (IOException ex) { - LOG.warn("Failed to get movie info: " + ex.getMessage()); + LOG.warn("Failed to get movie info: {}", ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } @@ -1011,7 +1011,7 @@ public class TheMovieDbApi { } return personCredits; } catch (IOException ex) { - LOG.warn("Failed to get person credits: " + ex.getMessage()); + LOG.warn("Failed to get person credits: {}", ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } @@ -1042,7 +1042,7 @@ public class TheMovieDbApi { } return personImages; } catch (IOException ex) { - LOG.warn("Failed to get person images: " + ex.getMessage()); + LOG.warn("Failed to get person images: {}", ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } @@ -1080,7 +1080,7 @@ public class TheMovieDbApi { try { return mapper.readValue(webpage, Person.class); } catch (IOException ex) { - LOG.warn("Failed to get latest person: " + ex.getMessage()); + LOG.warn("Failed to get latest person: {}", ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } @@ -1105,7 +1105,7 @@ public class TheMovieDbApi { try { return mapper.readValue(webpage, Company.class); } catch (IOException ex) { - LOG.warn("Failed to get company information: " + ex.getMessage()); + LOG.warn("Failed to get company information: {}", ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } @@ -1142,7 +1142,7 @@ public class TheMovieDbApi { WrapperCompanyMovies wrapper = mapper.readValue(webpage, WrapperCompanyMovies.class); return wrapper.getResults(); } catch (IOException ex) { - LOG.warn("Failed to get company movies: " + ex.getMessage()); + LOG.warn("Failed to get company movies: {}", ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } @@ -1168,7 +1168,7 @@ public class TheMovieDbApi { WrapperGenres wrapper = mapper.readValue(webpage, WrapperGenres.class); return wrapper.getGenres(); } catch (IOException ex) { - LOG.warn("Failed to get genre list: " + ex.getMessage()); + LOG.warn("Failed to get genre list: {}", ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } @@ -1203,7 +1203,7 @@ public class TheMovieDbApi { WrapperMovie wrapper = mapper.readValue(webpage, WrapperMovie.class); return wrapper.getMovies(); } catch (IOException ex) { - LOG.warn("Failed to get genre movie list: " + ex.getMessage()); + LOG.warn("Failed to get genre movie list: {}", ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } @@ -1248,7 +1248,7 @@ public class TheMovieDbApi { WrapperMovie wrapper = mapper.readValue(webpage, WrapperMovie.class); return wrapper.getMovies(); } catch (IOException ex) { - LOG.warn("Failed to find movie: " + ex.getMessage()); + LOG.warn("Failed to find movie: {}", ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } @@ -1284,7 +1284,7 @@ public class TheMovieDbApi { WrapperCollection wrapper = mapper.readValue(webpage, WrapperCollection.class); return wrapper.getResults(); } catch (IOException ex) { - LOG.warn("Failed to find collection: " + ex.getMessage()); + LOG.warn("Failed to find collection: {}", ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } @@ -1315,7 +1315,7 @@ public class TheMovieDbApi { WrapperPerson wrapper = mapper.readValue(webpage, WrapperPerson.class); return wrapper.getResults(); } catch (IOException ex) { - LOG.warn("Failed to find person: " + ex.getMessage()); + LOG.warn("Failed to find person: {}", ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } @@ -1350,7 +1350,7 @@ public class TheMovieDbApi { WrapperMovieList wrapper = mapper.readValue(webpage, WrapperMovieList.class); return wrapper.getMovieList(); } catch (IOException ex) { - LOG.warn("Failed to find list: " + ex.getMessage()); + LOG.warn("Failed to find list: {}", ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } @@ -1381,7 +1381,7 @@ public class TheMovieDbApi { WrapperCompany wrapper = mapper.readValue(webpage, WrapperCompany.class); return wrapper.getResults(); } catch (IOException ex) { - LOG.warn("Failed to find company: " + ex.getMessage()); + LOG.warn("Failed to find company: {}", ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } @@ -1411,7 +1411,7 @@ public class TheMovieDbApi { WrapperKeywords wrapper = mapper.readValue(webpage, WrapperKeywords.class); return wrapper.getResults(); } catch (IOException ex) { - LOG.warn("Failed to find keyword: " + ex.getMessage()); + LOG.warn("Failed to find keyword: {}", ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } @@ -1436,7 +1436,7 @@ public class TheMovieDbApi { try { return mapper.readValue(webpage, MovieDbList.class); } catch (IOException ex) { - LOG.warn("Failed to get list: " + ex.getMessage()); + LOG.warn("Failed to get list: {}", ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } } @@ -1461,7 +1461,7 @@ public class TheMovieDbApi { try { return mapper.readValue(webpage, Keyword.class); } catch (IOException ex) { - LOG.warn("Failed to get keyword: " + ex.getMessage()); + LOG.warn("Failed to get keyword: {}", ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } @@ -1495,7 +1495,7 @@ public class TheMovieDbApi { WrapperKeywordMovies wrapper = mapper.readValue(webpage, WrapperKeywordMovies.class); return wrapper.getResults(); } catch (IOException ex) { - LOG.warn("Failed to get top rated movies: " + ex.getMessage()); + LOG.warn("Failed to get top rated movies: {}", ex.getMessage()); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); } From 40567c3059ce571b38f6ac3be21745a5102a5855 Mon Sep 17 00:00:00 2001 From: Stuart Boston Date: Mon, 25 Feb 2013 08:41:24 +0000 Subject: [PATCH 195/207] Added example Jackson Replacement code --- JacksonReplacement/JsonAnySetter.java | 12 +++++ JacksonReplacement/JsonProperty.java | 12 +++++ JacksonReplacement/JsonRootName.java | 12 +++++ JacksonReplacement/ObjectMapper.java | 69 +++++++++++++++++++++++++++ JacksonReplacement/README.md | 6 +++ 5 files changed, 111 insertions(+) create mode 100644 JacksonReplacement/JsonAnySetter.java create mode 100644 JacksonReplacement/JsonProperty.java create mode 100644 JacksonReplacement/JsonRootName.java create mode 100644 JacksonReplacement/ObjectMapper.java create mode 100644 JacksonReplacement/README.md diff --git a/JacksonReplacement/JsonAnySetter.java b/JacksonReplacement/JsonAnySetter.java new file mode 100644 index 000000000..2bee382de --- /dev/null +++ b/JacksonReplacement/JsonAnySetter.java @@ -0,0 +1,12 @@ +package com.darylbeattie.movies.util; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target(value=ElementType.METHOD) +@Retention(value=RetentionPolicy.RUNTIME) +public @interface JsonAnySetter { + +} diff --git a/JacksonReplacement/JsonProperty.java b/JacksonReplacement/JsonProperty.java new file mode 100644 index 000000000..77be4f498 --- /dev/null +++ b/JacksonReplacement/JsonProperty.java @@ -0,0 +1,12 @@ +package com.darylbeattie.movies.util; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER}) +@Retention(RetentionPolicy.RUNTIME) +public @interface JsonProperty { + String value() default ""; +} diff --git a/JacksonReplacement/JsonRootName.java b/JacksonReplacement/JsonRootName.java new file mode 100644 index 000000000..4f5450dfa --- /dev/null +++ b/JacksonReplacement/JsonRootName.java @@ -0,0 +1,12 @@ +package com.darylbeattie.movies.util; + +import java.lang.annotation.ElementType; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.lang.annotation.Target; + +@Target(ElementType.TYPE) +@Retention(RetentionPolicy.RUNTIME) +public @interface JsonRootName { + String value() default ""; +} diff --git a/JacksonReplacement/ObjectMapper.java b/JacksonReplacement/ObjectMapper.java new file mode 100644 index 000000000..2150c721d --- /dev/null +++ b/JacksonReplacement/ObjectMapper.java @@ -0,0 +1,69 @@ +package com.darylbeattie.movies.util; + +import java.io.IOException; +import java.lang.annotation.Annotation; +import java.lang.reflect.Field; +import java.lang.reflect.ParameterizedType; +import java.util.List; + +import org.json.JSONArray; +import org.json.JSONObject; + +public class ObjectMapper { + + /** + * This takes a JSON string and creates (and populates) an object of the given class + * with the data from that JSON string. It mimics the method signature of the jackson + * JSON API, so that we don't have to import the jackson library into this application. + * + * @param jsonString The JSON string to parse. + * @param objClass The class of object we want to create. + * @return The instantiation of that class, populated with data from the JSON object. + * @throws IOException If there was any kind of issue. + */ + public T readValue(String jsonString, Class objClass) throws IOException { + try { + return readValue(new JSONObject(jsonString), objClass); + } + catch (IOException ioe) { + throw ioe; + } + catch (Exception e) { + e.printStackTrace(); + throw new IOException(e); + } + } + + @SuppressWarnings("unchecked") + public T readValue(JSONObject json, Class objClass) throws IOException { + try { + //TODO Iterate through json object values and call the JsonAnySetter method on the unknown ones. + T obj = objClass.newInstance(); + for (Field f : objClass.getFields()) { + Annotation a = f.getAnnotation(JsonProperty.class); + if (List.class.equals(f.getType()) && (json.optJSONArray(((JsonProperty) a).value()) != null)) { // It's a list. + JSONArray jsonArray = json.optJSONArray(((JsonProperty) a).value()); + ParameterizedType listType = (ParameterizedType) f.getGenericType(); + Class subObj = (Class) listType.getActualTypeArguments()[0]; + List subObjList = ((Class>) f.getType()).newInstance(); + for (int i = 0; i < jsonArray.length(); i++) { + subObjList.add((R) readValue(jsonArray.getJSONObject(i), subObj)); + } + f.set(obj, subObjList); + } + else if (a != null) { + f.set(obj, json.opt(((JsonProperty) a).value())); + } + } + return obj; + } + catch (IOException ioe) { + throw ioe; + } + catch (Exception e) { + e.printStackTrace(); + throw new IOException(e); + } + } + +} \ No newline at end of file diff --git a/JacksonReplacement/README.md b/JacksonReplacement/README.md new file mode 100644 index 000000000..71bdb8a7d --- /dev/null +++ b/JacksonReplacement/README.md @@ -0,0 +1,6 @@ +Jackson Library Replacement +=========================== + +These files are provided by Darren Beattie as an example of how to replace the Jackson libraries with native libraries inside Android. + +They are provided without warrantee and if you modify them or find them useful, please let me know. From a0fca9e69aea49c302077777c1ec08f678136ee9 Mon Sep 17 00:00:00 2001 From: Stuart Boston Date: Mon, 25 Feb 2013 08:45:54 +0000 Subject: [PATCH 196/207] Fixed Russian test name --- .../java/com/omertron/themoviedbapi/TheMovieDbApiTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/java/com/omertron/themoviedbapi/TheMovieDbApiTest.java b/src/test/java/com/omertron/themoviedbapi/TheMovieDbApiTest.java index 13ab6c8d0..b323bcb18 100644 --- a/src/test/java/com/omertron/themoviedbapi/TheMovieDbApiTest.java +++ b/src/test/java/com/omertron/themoviedbapi/TheMovieDbApiTest.java @@ -123,8 +123,8 @@ public class TheMovieDbApiTest { assertTrue("No movies found, should be at least 1", movieList.size() > 0); // Try a russian langugage movie - movieList = tmdb.searchMovie("О чём говор�?т мужчины", 0, "ru", true, 0); - assertTrue("No movies found, should be at least 1", movieList.size() > 0); + movieList = tmdb.searchMovie("О чём говорят мужчины", 0, "ru", true, 0); + assertTrue("No 'RU' movies found, should be at least 1", movieList.size() > 0); // Try a movie with more than 20 results movieList = tmdb.searchMovie("Star Wars", 0, "en", false, 0); From 03c6e1917a1744e99f39eb4738e1be4c7117a0c1 Mon Sep 17 00:00:00 2001 From: Stuart Boston Date: Mon, 25 Feb 2013 08:46:52 +0000 Subject: [PATCH 197/207] Added Russian literal --- .../java/com/omertron/themoviedbapi/TheMovieDbApiTest.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/test/java/com/omertron/themoviedbapi/TheMovieDbApiTest.java b/src/test/java/com/omertron/themoviedbapi/TheMovieDbApiTest.java index b323bcb18..91721625a 100644 --- a/src/test/java/com/omertron/themoviedbapi/TheMovieDbApiTest.java +++ b/src/test/java/com/omertron/themoviedbapi/TheMovieDbApiTest.java @@ -71,6 +71,7 @@ public class TheMovieDbApiTest { // Languages private static final String LANGUAGE_DEFAULT = ""; private static final String LANGUAGE_ENGLISH = "en"; + private static final String LANGUAGE_RUSSIAN = "ru"; public TheMovieDbApiTest() throws MovieDbException { } @@ -123,7 +124,7 @@ public class TheMovieDbApiTest { assertTrue("No movies found, should be at least 1", movieList.size() > 0); // Try a russian langugage movie - movieList = tmdb.searchMovie("О чём говорят мужчины", 0, "ru", true, 0); + movieList = tmdb.searchMovie("О чём говорят мужчины", 0, LANGUAGE_RUSSIAN, true, 0); assertTrue("No 'RU' movies found, should be at least 1", movieList.size() > 0); // Try a movie with more than 20 results From 9e9f0b5c9e9476433bf351150b59fb514375d585 Mon Sep 17 00:00:00 2001 From: Stuart Boston Date: Mon, 25 Feb 2013 08:57:26 +0000 Subject: [PATCH 198/207] Optimised logging output --- src/main/java/com/omertron/themoviedbapi/tools/ApiUrl.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/omertron/themoviedbapi/tools/ApiUrl.java b/src/main/java/com/omertron/themoviedbapi/tools/ApiUrl.java index a3d28833e..c952f7651 100644 --- a/src/main/java/com/omertron/themoviedbapi/tools/ApiUrl.java +++ b/src/main/java/com/omertron/themoviedbapi/tools/ApiUrl.java @@ -154,10 +154,10 @@ public class ApiUrl { } try { - LOG.trace("URL: " + urlString.toString()); + LOG.trace("URL: {}", urlString.toString()); return new URL(urlString.toString()); } catch (MalformedURLException ex) { - LOG.warn("Failed to create URL " + urlString.toString() + " - " + ex.toString()); + LOG.warn("Failed to create URL {} - {}", urlString.toString(), ex.toString()); return null; } finally { arguments.clear(); From 9e6a290f63c2e81e33a96daa2064dcad6dee5acf Mon Sep 17 00:00:00 2001 From: Stuart Boston Date: Mon, 25 Feb 2013 09:32:03 +0000 Subject: [PATCH 199/207] Added English literal to test cases --- .../com/omertron/themoviedbapi/TheMovieDbApiTest.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/test/java/com/omertron/themoviedbapi/TheMovieDbApiTest.java b/src/test/java/com/omertron/themoviedbapi/TheMovieDbApiTest.java index 91721625a..8f1860790 100644 --- a/src/test/java/com/omertron/themoviedbapi/TheMovieDbApiTest.java +++ b/src/test/java/com/omertron/themoviedbapi/TheMovieDbApiTest.java @@ -128,7 +128,7 @@ public class TheMovieDbApiTest { assertTrue("No 'RU' movies found, should be at least 1", movieList.size() > 0); // Try a movie with more than 20 results - movieList = tmdb.searchMovie("Star Wars", 0, "en", false, 0); + movieList = tmdb.searchMovie("Star Wars", 0, LANGUAGE_ENGLISH, false, 0); assertTrue("Not enough movies found, should be over 15, found " + movieList.size(), movieList.size() >= 15); } @@ -138,8 +138,7 @@ public class TheMovieDbApiTest { @Test public void testGetMovieInfo() throws MovieDbException { LOG.info("getMovieInfo"); - String language = "en"; - MovieDb result = tmdb.getMovieInfo(ID_MOVIE_BLADE_RUNNER, language); + MovieDb result = tmdb.getMovieInfo(ID_MOVIE_BLADE_RUNNER, LANGUAGE_ENGLISH); assertEquals("Incorrect movie information", "Blade Runner", result.getOriginalTitle()); } @@ -528,8 +527,7 @@ public class TheMovieDbApiTest { @Test public void testGetMovieLists() throws Exception { LOG.info("getMovieLists"); - String language = "en"; - List results = tmdb.getMovieLists(ID_MOVIE_BLADE_RUNNER, language, 0); + List results = tmdb.getMovieLists(ID_MOVIE_BLADE_RUNNER, LANGUAGE_ENGLISH, 0); assertNotNull("No results found", results); assertTrue("No results found", results.size() > 0); } From e17db7a15b57fc99cbeaa13178c9b0476879c337 Mon Sep 17 00:00:00 2001 From: Stuart Boston Date: Mon, 25 Feb 2013 12:56:09 +0000 Subject: [PATCH 200/207] Tidied up test class --- .../omertron/themoviedbapi/TestLogger.java | 72 +++++++++++++++++++ .../themoviedbapi/TheMovieDbApiTest.java | 11 ++- 2 files changed, 77 insertions(+), 6 deletions(-) create mode 100644 src/test/java/com/omertron/themoviedbapi/TestLogger.java diff --git a/src/test/java/com/omertron/themoviedbapi/TestLogger.java b/src/test/java/com/omertron/themoviedbapi/TestLogger.java new file mode 100644 index 000000000..bd7a4cc5e --- /dev/null +++ b/src/test/java/com/omertron/themoviedbapi/TestLogger.java @@ -0,0 +1,72 @@ +/* + * Copyright (c) 2004-2013 Stuart Boston + * + * This file is part of the FanartTV API. + * + * The FanartTV API is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * any later version. + * + * The FanartTV API is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with the FanartTV API. If not, see . + * + */ +package com.omertron.themoviedbapi; + +import java.io.ByteArrayInputStream; +import java.io.IOException; +import java.io.InputStream; +import java.util.logging.LogManager; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class TestLogger { + + private static final Logger LOG = LoggerFactory.getLogger(TestLogger.class); + private static final String CRLF = "\n"; + + private TestLogger() { + throw new UnsupportedOperationException("Class can not be instantiated"); + } + + /** + * Configure the logger with a simple in-memory file for the required log level + * + * @param level The logging level required + * @return True if successful + */ + public static boolean Configure(String level) { + StringBuilder config = new StringBuilder("handlers = java.util.logging.ConsoleHandler\n"); + config.append(".level = ").append(level).append(CRLF); + config.append("java.util.logging.ConsoleHandler.level = ").append(level).append(CRLF); + // Only works with Java 7 or later + config.append("java.util.logging.SimpleFormatter.format = [%1$tc %4$s] %2$s - %5$s %6$s%n").append(CRLF); + // Exclude http logging + config.append("sun.net.www.protocol.http.HttpURLConnection.level = OFF").append(CRLF); + + InputStream ins = new ByteArrayInputStream(config.toString().getBytes()); + try { + LogManager.getLogManager().readConfiguration(ins); + } catch (IOException e) { + LOG.warn("Failed to configure log manager due to an IO problem", e); + return Boolean.FALSE; + } + LOG.debug("Logger initialized to '{}' level", level); + return Boolean.TRUE; + } + + /** + * Set the logging level to "ALL" + * + * @return True if successful + */ + public static boolean Configure() { + return Configure("ALL"); + } +} diff --git a/src/test/java/com/omertron/themoviedbapi/TheMovieDbApiTest.java b/src/test/java/com/omertron/themoviedbapi/TheMovieDbApiTest.java index 8f1860790..c39f911b0 100644 --- a/src/test/java/com/omertron/themoviedbapi/TheMovieDbApiTest.java +++ b/src/test/java/com/omertron/themoviedbapi/TheMovieDbApiTest.java @@ -42,11 +42,11 @@ import com.omertron.themoviedbapi.model.Translation; import java.io.IOException; import java.util.Collections; import java.util.List; -import java.util.logging.Level; -import java.util.logging.Logger; import org.apache.commons.lang3.StringUtils; import org.junit.*; import static org.junit.Assert.*; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Test cases for TheMovieDbApi API @@ -56,7 +56,7 @@ import static org.junit.Assert.*; public class TheMovieDbApiTest { // Logger - private static final Logger LOG = Logger.getLogger(TheMovieDbApiTest.class.getSimpleName()); + private static final Logger LOG = LoggerFactory.getLogger(TheMovieDbApiTest.class); // API Key private static final String API_KEY = "5a1a77e2eba8984804586122754f969f"; private static TheMovieDbApi tmdb; @@ -78,9 +78,8 @@ public class TheMovieDbApiTest { @BeforeClass public static void setUpClass() throws Exception { - // Set the LOG level to ALL - LOG.setLevel(Level.ALL); tmdb = new TheMovieDbApi(API_KEY); + TestLogger.Configure(); } @AfterClass @@ -548,7 +547,7 @@ public class TheMovieDbApiTest { List movieList = tmdb.getPopularMovieList(LANGUAGE_DEFAULT, 0); for (MovieDb movie : movieList) { results = tmdb.getMovieChanges(movie.getId(), startDate, endDate); - LOG.log(Level.INFO, "{0} has {1} changes.", new Object[]{movie.getTitle(), results.size()}); + LOG.info("{} has {} changes.", new Object[]{movie.getTitle(), results.size()}); } assertNotNull("No results found", results); From bea972520b60e0f6aa888764f0b5f0c5430c246f Mon Sep 17 00:00:00 2001 From: Stuart Boston Date: Wed, 27 Feb 2013 08:54:52 +0000 Subject: [PATCH 201/207] Removed unused imports --- .../wrapper/WrapperAlternativeTitles.java | 1 + .../omertron/themoviedbapi/wrapper/WrapperBase.java | 11 +++++------ .../themoviedbapi/wrapper/WrapperCollection.java | 2 +- .../themoviedbapi/wrapper/WrapperCompany.java | 4 ++-- .../themoviedbapi/wrapper/WrapperCompanyMovies.java | 1 - .../omertron/themoviedbapi/wrapper/WrapperImages.java | 2 +- .../themoviedbapi/wrapper/WrapperKeywordMovies.java | 2 +- .../themoviedbapi/wrapper/WrapperKeywords.java | 2 +- .../omertron/themoviedbapi/wrapper/WrapperMovie.java | 1 - .../themoviedbapi/wrapper/WrapperMovieCasts.java | 1 + .../themoviedbapi/wrapper/WrapperMovieKeywords.java | 1 + .../themoviedbapi/wrapper/WrapperMovieList.java | 1 - .../omertron/themoviedbapi/wrapper/WrapperPerson.java | 2 +- .../themoviedbapi/wrapper/WrapperPersonCredits.java | 4 ++-- .../themoviedbapi/wrapper/WrapperReleaseInfo.java | 1 + .../themoviedbapi/wrapper/WrapperTrailers.java | 1 + .../themoviedbapi/wrapper/WrapperTranslations.java | 1 + 17 files changed, 20 insertions(+), 18 deletions(-) diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperAlternativeTitles.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperAlternativeTitles.java index 0c639606e..d615e39f1 100644 --- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperAlternativeTitles.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperAlternativeTitles.java @@ -62,6 +62,7 @@ public class WrapperAlternativeTitles { /** * Handle unknown properties and print a message + * * @param key * @param value */ diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperBase.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperBase.java index 50b9c0960..196dd7efa 100644 --- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperBase.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperBase.java @@ -22,7 +22,6 @@ package com.omertron.themoviedbapi.wrapper; import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonProperty; import org.slf4j.Logger; -import org.slf4j.LoggerFactory; /** * Base class for the wrappers @@ -31,10 +30,10 @@ import org.slf4j.LoggerFactory; */ public class WrapperBase { /* - * Logger - set but the sub-classes + * Logger - set by the sub-classes */ - private Logger LOG; + private Logger log; /* * Properties */ @@ -47,8 +46,8 @@ public class WrapperBase { @JsonProperty("total_results") private int totalResults; - public WrapperBase(Logger LOG) { - this.LOG = LOG; + public WrapperBase(Logger logger) { + this.log = logger; } // @@ -98,6 +97,6 @@ public class WrapperBase { StringBuilder sb = new StringBuilder(); sb.append("Unknown property: '").append(key); sb.append("' value: '").append(value).append("'"); - LOG.trace(sb.toString()); + log.trace(sb.toString()); } } diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperCollection.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperCollection.java index 450f47f9a..dfc95042e 100644 --- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperCollection.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperCollection.java @@ -22,7 +22,6 @@ package com.omertron.themoviedbapi.wrapper; import com.fasterxml.jackson.annotation.JsonProperty; import com.omertron.themoviedbapi.model.Collection; import java.util.List; -import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** @@ -33,6 +32,7 @@ public class WrapperCollection extends WrapperBase { /* * Properties */ + @JsonProperty("results") private List results; diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperCompany.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperCompany.java index 57a60c6ec..0b56611d4 100644 --- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperCompany.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperCompany.java @@ -22,17 +22,17 @@ package com.omertron.themoviedbapi.wrapper; import com.fasterxml.jackson.annotation.JsonProperty; import com.omertron.themoviedbapi.model.Company; import java.util.List; -import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** * * @author stuart.boston */ -public class WrapperCompany extends WrapperBase{ +public class WrapperCompany extends WrapperBase { /* * Properties */ + @JsonProperty("results") private List results; diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperCompanyMovies.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperCompanyMovies.java index 250ce3e12..9f7e8f0a4 100644 --- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperCompanyMovies.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperCompanyMovies.java @@ -22,7 +22,6 @@ package com.omertron.themoviedbapi.wrapper; import com.fasterxml.jackson.annotation.JsonProperty; import com.omertron.themoviedbapi.model.MovieDb; import java.util.List; -import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperImages.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperImages.java index 51670bf8d..a6fbaa172 100644 --- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperImages.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperImages.java @@ -22,7 +22,6 @@ package com.omertron.themoviedbapi.wrapper; import com.fasterxml.jackson.annotation.JsonProperty; import com.omertron.themoviedbapi.model.Artwork; import java.util.List; -import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** @@ -33,6 +32,7 @@ public class WrapperImages extends WrapperBase { /* * Properties */ + @JsonProperty("backdrops") private List backdrops; @JsonProperty("posters") diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperKeywordMovies.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperKeywordMovies.java index 70713b380..f116b11da 100644 --- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperKeywordMovies.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperKeywordMovies.java @@ -22,7 +22,6 @@ package com.omertron.themoviedbapi.wrapper; import com.fasterxml.jackson.annotation.JsonProperty; import com.omertron.themoviedbapi.model.KeywordMovie; import java.util.List; -import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** @@ -33,6 +32,7 @@ public class WrapperKeywordMovies extends WrapperBase { /* * Properties */ + @JsonProperty("results") private List results; diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperKeywords.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperKeywords.java index 5a245b7f3..85016c045 100644 --- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperKeywords.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperKeywords.java @@ -22,7 +22,6 @@ package com.omertron.themoviedbapi.wrapper; import com.fasterxml.jackson.annotation.JsonProperty; import com.omertron.themoviedbapi.model.Keyword; import java.util.List; -import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** @@ -33,6 +32,7 @@ public class WrapperKeywords extends WrapperBase { /* * Properties */ + @JsonProperty("results") private List results; diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovie.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovie.java index 0f812e0b3..94f2abbb7 100644 --- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovie.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovie.java @@ -22,7 +22,6 @@ package com.omertron.themoviedbapi.wrapper; import com.fasterxml.jackson.annotation.JsonProperty; import com.omertron.themoviedbapi.model.MovieDb; import java.util.List; -import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovieCasts.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovieCasts.java index b0db38e1e..30183409c 100644 --- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovieCasts.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovieCasts.java @@ -77,6 +77,7 @@ public class WrapperMovieCasts { /** * Handle unknown properties and print a message + * * @param key * @param value */ diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovieKeywords.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovieKeywords.java index acbb80f86..d7da5bf23 100644 --- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovieKeywords.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovieKeywords.java @@ -66,6 +66,7 @@ public class WrapperMovieKeywords { /** * Handle unknown properties and print a message + * * @param key * @param value */ diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovieList.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovieList.java index 658b249f4..3dec844fb 100644 --- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovieList.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperMovieList.java @@ -22,7 +22,6 @@ package com.omertron.themoviedbapi.wrapper; import com.fasterxml.jackson.annotation.JsonProperty; import com.omertron.themoviedbapi.model.MovieList; import java.util.List; -import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperPerson.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperPerson.java index 22ef9f7fc..70d5ab6ac 100644 --- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperPerson.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperPerson.java @@ -22,7 +22,6 @@ package com.omertron.themoviedbapi.wrapper; import com.fasterxml.jackson.annotation.JsonProperty; import com.omertron.themoviedbapi.model.Person; import java.util.List; -import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** @@ -33,6 +32,7 @@ public class WrapperPerson extends WrapperBase { /* * Properties */ + @JsonProperty("results") private List results; diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperPersonCredits.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperPersonCredits.java index ac9bd01f7..2ba1dec94 100644 --- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperPersonCredits.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperPersonCredits.java @@ -22,17 +22,17 @@ package com.omertron.themoviedbapi.wrapper; import com.fasterxml.jackson.annotation.JsonProperty; import com.omertron.themoviedbapi.model.PersonCredit; import java.util.List; -import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** * * @author stuart.boston */ -public class WrapperPersonCredits extends WrapperBase{ +public class WrapperPersonCredits extends WrapperBase { /* * Properties */ + @JsonProperty("cast") private List cast; @JsonProperty("crew") diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperReleaseInfo.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperReleaseInfo.java index 093a7be3d..caf4b59b7 100644 --- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperReleaseInfo.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperReleaseInfo.java @@ -66,6 +66,7 @@ public class WrapperReleaseInfo { /** * Handle unknown properties and print a message + * * @param key * @param value */ diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperTrailers.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperTrailers.java index bdfa09ca4..0f19e69bc 100644 --- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperTrailers.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperTrailers.java @@ -76,6 +76,7 @@ public class WrapperTrailers { /** * Handle unknown properties and print a message + * * @param key * @param value */ diff --git a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperTranslations.java b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperTranslations.java index 4edf633e2..507cc0bc9 100644 --- a/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperTranslations.java +++ b/src/main/java/com/omertron/themoviedbapi/wrapper/WrapperTranslations.java @@ -66,6 +66,7 @@ public class WrapperTranslations { /** * Handle unknown properties and print a message + * * @param key * @param value */ From d2972ac9274daa216b509283e3d0c7bd92fe692b Mon Sep 17 00:00:00 2001 From: Stuart Boston Date: Thu, 7 Mar 2013 15:32:10 +0000 Subject: [PATCH 202/207] Added IMDB_ID and POPULARITY to Person --- .../omertron/themoviedbapi/model/Person.java | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/main/java/com/omertron/themoviedbapi/model/Person.java b/src/main/java/com/omertron/themoviedbapi/model/Person.java index b008202c4..a80bd4b8b 100644 --- a/src/main/java/com/omertron/themoviedbapi/model/Person.java +++ b/src/main/java/com/omertron/themoviedbapi/model/Person.java @@ -74,6 +74,10 @@ public class Person implements Serializable { private String homepage = DEFAULT_STRING; @JsonProperty("place_of_birth") private String birthplace = DEFAULT_STRING; + @JsonProperty("imdb_id") + private String imdbId = DEFAULT_STRING; + @JsonProperty("popularity") + private float popularity = 0.0f; /** * Add a crew member @@ -175,6 +179,14 @@ public class Person implements Serializable { public String getHomepage() { return homepage; } + + public String getImdbId() { + return imdbId; + } + + public float getPopularity() { + return popularity; + } // // @@ -237,6 +249,14 @@ public class Person implements Serializable { public void setHomepage(String homepage) { this.homepage = homepage; } + + public void setImdbId(String imdbId) { + this.imdbId = imdbId; + } + + public void setPopularity(float popularity) { + this.popularity = popularity; + } // /** From 3085018cf046638cc5dfaaa821763f6acdf76277 Mon Sep 17 00:00:00 2001 From: Stuart Boston Date: Mon, 18 Mar 2013 12:36:26 +0000 Subject: [PATCH 203/207] Added "Include All Movies" to getGenreMovies Old method will be deprecated at some point --- .../java/com/omertron/themoviedbapi/TheMovieDbApi.java | 9 ++++++++- .../java/com/omertron/themoviedbapi/tools/ApiUrl.java | 1 + 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java b/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java index 1016cd4b6..4c75f5c67 100644 --- a/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java +++ b/src/main/java/com/omertron/themoviedbapi/TheMovieDbApi.java @@ -1173,6 +1173,11 @@ public class TheMovieDbApi { } } + @Deprecated + public List getGenreMovies(int genreId, String language, int page) throws MovieDbException { + return getGenreMovies(genreId, language, page, Boolean.TRUE); + } + /** * Get a list of movies per genre. * @@ -1184,7 +1189,7 @@ public class TheMovieDbApi { * @param language * @param page */ - public List getGenreMovies(int genreId, String language, int page) throws MovieDbException { + public List getGenreMovies(int genreId, String language, int page, boolean includeAllMovies) throws MovieDbException { ApiUrl apiUrl = new ApiUrl(this, BASE_GENRE, "/movies"); apiUrl.addArgument(PARAM_ID, genreId); @@ -1196,6 +1201,8 @@ public class TheMovieDbApi { apiUrl.addArgument(PARAM_PAGE, page); } + apiUrl.addArgument(PARAM_INCLUDE_ALL_MOVIES, includeAllMovies); + URL url = apiUrl.buildUrl(); String webpage = WebBrowser.request(url); diff --git a/src/main/java/com/omertron/themoviedbapi/tools/ApiUrl.java b/src/main/java/com/omertron/themoviedbapi/tools/ApiUrl.java index c952f7651..b443ff122 100644 --- a/src/main/java/com/omertron/themoviedbapi/tools/ApiUrl.java +++ b/src/main/java/com/omertron/themoviedbapi/tools/ApiUrl.java @@ -66,6 +66,7 @@ public class ApiUrl { public static final String PARAM_FAVORITE = "favorite="; public static final String PARAM_ID = "id="; public static final String PARAM_LANGUAGE = "language="; + public static final String PARAM_INCLUDE_ALL_MOVIES = "include_all_movies="; // public static final String PARAM_MOVIE_ID = "movie_id="; public static final String PARAM_MOVIE_WATCHLIST = "movie_watchlist="; public static final String PARAM_PAGE = "page="; From bf8730c1eec4cfa171b3c0e772f7fcd5288cac4a Mon Sep 17 00:00:00 2001 From: Stuart Boston Date: Mon, 18 Mar 2013 12:37:24 +0000 Subject: [PATCH 204/207] Updated test case for getGenreMovies --- src/test/java/com/omertron/themoviedbapi/TheMovieDbApiTest.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/java/com/omertron/themoviedbapi/TheMovieDbApiTest.java b/src/test/java/com/omertron/themoviedbapi/TheMovieDbApiTest.java index c39f911b0..31453f7a4 100644 --- a/src/test/java/com/omertron/themoviedbapi/TheMovieDbApiTest.java +++ b/src/test/java/com/omertron/themoviedbapi/TheMovieDbApiTest.java @@ -458,7 +458,7 @@ public class TheMovieDbApiTest { @Test public void testGetGenreMovies() throws MovieDbException { LOG.info("getGenreMovies"); - List results = tmdb.getGenreMovies(ID_GENRE_ACTION, LANGUAGE_DEFAULT, 0); + List results = tmdb.getGenreMovies(ID_GENRE_ACTION, LANGUAGE_DEFAULT, 0, Boolean.TRUE); assertTrue("No genre movies found", !results.isEmpty()); } From 7de82cdba86a74fd35e99d584b70bb7e0cb3c638 Mon Sep 17 00:00:00 2001 From: Omertron Date: Mon, 18 Mar 2013 13:42:56 +0100 Subject: [PATCH 205/207] Updated POM versions --- pom.xml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pom.xml b/pom.xml index 9234cb8eb..7c285edfe 100644 --- a/pom.xml +++ b/pom.xml @@ -83,17 +83,17 @@ com.fasterxml.jackson.core jackson-core - 2.1.2 + 2.1.4 com.fasterxml.jackson.core jackson-annotations - 2.1.2 + 2.1.4 com.fasterxml.jackson.core jackson-databind - 2.1.2 + 2.1.4 commons-codec @@ -108,12 +108,12 @@ org.slf4j slf4j-api - 1.7.2 + 1.7.3 org.slf4j slf4j-jdk14 - 1.7.2 + 1.7.3 test From 4c2463b14ae5bde6ec55c7a47868f89ea3638090 Mon Sep 17 00:00:00 2001 From: Omertron Date: Mon, 18 Mar 2013 13:45:45 +0100 Subject: [PATCH 206/207] [maven-release-plugin] prepare release themoviedbapi-3.4 --- pom.xml | 674 ++++++++++++++++++++++++++++---------------------------- 1 file changed, 337 insertions(+), 337 deletions(-) diff --git a/pom.xml b/pom.xml index 7c285edfe..f24d00064 100644 --- a/pom.xml +++ b/pom.xml @@ -1,337 +1,337 @@ - - 4.0.0 - - - org.sonatype.oss - oss-parent - 7 - - - - 3.0.3 - - - com.omertron - themoviedbapi - 3.4-SNAPSHOT - jar - - API-The MovieDB - API for the TheMovieDb.org website - https://github.com/Omertron/api-themoviedb - 2012 - - - - Stuart Boston - omertron@gmail.com - omertron - http://omertron.com - 0 - - developer - - - - - - - GNU General Public License v3+ - http://www.gnu.org/licenses/gpl-3.0-standalone.html - repo - - - - - scm:git:git@github.com:Omertron/api-themoviedb.git - scm:git:git@github.com:Omertron/api-themoviedb.git - scm:git:git@github.com:Omertron/api-themoviedb.git - - - - - github-project-site - GitHub Project Pages - gitsite:git@github.com/Omertron/api-themoviedb.git - - - - - GitHub - https://github.com/Omertron/api-themoviedb/issues - - - - Hudson CI - http://jenkins.omertron.com/job/API-TheMovieDb/ - - - - false - UTF-8 - UTF-8 - zip - - - - - junit - junit - 4.11 - test - - - com.fasterxml.jackson.core - jackson-core - 2.1.4 - - - com.fasterxml.jackson.core - jackson-annotations - 2.1.4 - - - com.fasterxml.jackson.core - jackson-databind - 2.1.4 - - - commons-codec - commons-codec - 1.7 - - - org.apache.commons - commons-lang3 - 3.1 - - - org.slf4j - slf4j-api - 1.7.3 - - - org.slf4j - slf4j-jdk14 - 1.7.3 - test - - - - - ${project.artifactId}-${project.version}-r${buildNumber} - - - - org.codehaus.mojo - buildnumber-maven-plugin - 1.2 - - true - 0000 - {0,date,yyyy-MM-dd HH:mm:ss} - - - - validate - - create - - - - - - org.apache.maven.plugins - maven-compiler-plugin - 3.0 - - 1.6 - 1.6 - true - true - - - - - org.apache.maven.plugins - maven-jar-plugin - 2.4 - - - - ${project.name} - ${project.version} - ${buildNumber} - ${timestamp} - - - - - - org.apache.maven.plugins - maven-surefire-plugin - 2.13 - - - ${skipTests} - - - - org.apache.maven.plugins - maven-antrun-plugin - 1.7 - - - create-version-txt - generate-resources - - - - - - - - Writing version file: ${version_file} - ${header_line} - ${build_date_line} - ${version_line} - - - - - run - - - - - - org.apache.maven.plugins - maven-assembly-plugin - 2.4 - - - distro-assembly - package - - single - - - - src/main/resources/bin.xml - - - - - - - org.codehaus.mojo - versions-maven-plugin - 2.0 - - - org.apache.maven.plugins - maven-site-plugin - 3.2 - - - - org.apache.maven.plugins - maven-project-info-reports-plugin - 2.2 - - index - scm - issue-tracking - help - dependency-convergence - summary - dependency-management - dependencies - license - modules - - - - org.apache.maven.plugins - maven-javadoc-plugin - 2.9 - - - - - - org.apache.maven.plugins - maven-clean-plugin - 2.5 - - - org.apache.maven.plugins - maven-deploy-plugin - 2.7 - - - org.apache.maven.plugins - maven-gpg-plugin - 1.4 - - - org.apache.maven.plugins - maven-install-plugin - 2.4 - - - org.apache.maven.plugins - maven-resources-plugin - 2.6 - - - - - - org.apache.maven.scm - maven-scm-provider-gitexe - 1.4 - - - org.apache.maven.scm - maven-scm-manager-plexus - 1.4 - - - org.kathrynhuxtable.maven.wagon - wagon-gitsite - 0.3.1 - - - - - - - - release-sign-artifacts - - - performRelease - true - - - - - - maven-gpg-plugin - - - sign-artifacts - verify - - sign - - - - - - - - - - + + 4.0.0 + + + org.sonatype.oss + oss-parent + 7 + + + + 3.0.3 + + + com.omertron + themoviedbapi + 3.4 + jar + + API-The MovieDB + API for the TheMovieDb.org website + https://github.com/Omertron/api-themoviedb + 2012 + + + + Stuart Boston + omertron@gmail.com + omertron + http://omertron.com + 0 + + developer + + + + + + + GNU General Public License v3+ + http://www.gnu.org/licenses/gpl-3.0-standalone.html + repo + + + + + scm:git:git@github.com:Omertron/api-themoviedb.git + scm:git:git@github.com:Omertron/api-themoviedb.git + scm:git:git@github.com:Omertron/api-themoviedb.git + + + + + github-project-site + GitHub Project Pages + gitsite:git@github.com/Omertron/api-themoviedb.git + + + + + GitHub + https://github.com/Omertron/api-themoviedb/issues + + + + Hudson CI + http://jenkins.omertron.com/job/API-TheMovieDb/ + + + + false + UTF-8 + UTF-8 + zip + + + + + junit + junit + 4.11 + test + + + com.fasterxml.jackson.core + jackson-core + 2.1.4 + + + com.fasterxml.jackson.core + jackson-annotations + 2.1.4 + + + com.fasterxml.jackson.core + jackson-databind + 2.1.4 + + + commons-codec + commons-codec + 1.7 + + + org.apache.commons + commons-lang3 + 3.1 + + + org.slf4j + slf4j-api + 1.7.3 + + + org.slf4j + slf4j-jdk14 + 1.7.3 + test + + + + + ${project.artifactId}-${project.version}-r${buildNumber} + + + + org.codehaus.mojo + buildnumber-maven-plugin + 1.2 + + true + 0000 + {0,date,yyyy-MM-dd HH:mm:ss} + + + + validate + + create + + + + + + org.apache.maven.plugins + maven-compiler-plugin + 3.0 + + 1.6 + 1.6 + true + true + + + + + org.apache.maven.plugins + maven-jar-plugin + 2.4 + + + + ${project.name} + ${project.version} + ${buildNumber} + ${timestamp} + + + + + + org.apache.maven.plugins + maven-surefire-plugin + 2.13 + + + ${skipTests} + + + + org.apache.maven.plugins + maven-antrun-plugin + 1.7 + + + create-version-txt + generate-resources + + + + + + + + Writing version file: ${version_file} + ${header_line} + ${build_date_line} + ${version_line} + + + + + run + + + + + + org.apache.maven.plugins + maven-assembly-plugin + 2.4 + + + distro-assembly + package + + single + + + + src/main/resources/bin.xml + + + + + + + org.codehaus.mojo + versions-maven-plugin + 2.0 + + + org.apache.maven.plugins + maven-site-plugin + 3.2 + + + + org.apache.maven.plugins + maven-project-info-reports-plugin + 2.2 + + index + scm + issue-tracking + help + dependency-convergence + summary + dependency-management + dependencies + license + modules + + + + org.apache.maven.plugins + maven-javadoc-plugin + 2.9 + + + + + + org.apache.maven.plugins + maven-clean-plugin + 2.5 + + + org.apache.maven.plugins + maven-deploy-plugin + 2.7 + + + org.apache.maven.plugins + maven-gpg-plugin + 1.4 + + + org.apache.maven.plugins + maven-install-plugin + 2.4 + + + org.apache.maven.plugins + maven-resources-plugin + 2.6 + + + + + + org.apache.maven.scm + maven-scm-provider-gitexe + 1.4 + + + org.apache.maven.scm + maven-scm-manager-plexus + 1.4 + + + org.kathrynhuxtable.maven.wagon + wagon-gitsite + 0.3.1 + + + + + + + + release-sign-artifacts + + + performRelease + true + + + + + + maven-gpg-plugin + + + sign-artifacts + verify + + sign + + + + + + + + + + From 98a1b5d1b92f914c657c6500fb8f4acd617a4409 Mon Sep 17 00:00:00 2001 From: Omertron Date: Mon, 18 Mar 2013 13:45:57 +0100 Subject: [PATCH 207/207] [maven-release-plugin] prepare for next development iteration --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index f24d00064..e4a00f5e5 100644 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,7 @@ com.omertron themoviedbapi - 3.4 + 3.5-SNAPSHOT jar API-The MovieDB