25 Commits

Author SHA1 Message Date
Omertron 8068b9ac45 [maven-release-plugin] prepare release themoviedbapi-3.7 2013-08-23 10:21:30 +02:00
Omertron a25da9aa2f Reset version 2013-08-23 10:18:48 +02:00
Omertron 7a30ab831c Updated POM versions 2013-08-23 10:13:04 +02:00
Stuart Boston f64786e506 Update tests 2013-08-22 21:32:35 +01:00
Stuart Boston a57e7eeb37 Add toString methods 2013-08-22 21:32:26 +01:00
Stuart Boston 00bdfaf6a7 Add missing properties to MovieDbList
Tidy up other code
2013-08-22 13:13:25 +01:00
Stuart Boston 064117e66d Remove unused imports 2013-08-20 21:22:32 +01:00
Stuart Boston a520c75773 Remove duplicate literals 2013-08-20 21:12:26 +01:00
Stuart Boston 259eb81f32 Remove unused fields 2013-08-20 21:12:11 +01:00
Stuart Boston 8bfe7dcc1b WebBrowser: Throw MovieDbException 2013-08-20 21:11:34 +01:00
Stuart Boston ac57816b1d Merge pull request #6 from holgerbrandl/master
"List" and "Account" implemenation
2013-08-20 20:47:24 +01:00
Stuart Boston 073331cddb Close output stream 2013-08-20 13:18:06 +01:00
Stuart Boston 0ef278e19d Merge branch 'master' of https://github.com/Omertron/api-themoviedb 2013-08-20 09:01:28 +01:00
Stuart Boston d6e02bf1df Merge pull request #5 from holgerbrandl/master
implemented method to post movie ratings
2013-08-20 00:51:52 -07:00
holger fbdf744dc6 implemented method to post movie ratings 2013-08-19 14:28:28 +02:00
Stuart Boston 8478865141 Change ToString style to "short prefix" 2013-07-25 12:52:24 +01:00
Stuart Boston a98eac75dc Add dates to the wrapper where needed 2013-07-24 17:06:30 +01:00
Stuart Boston 9a237042f0 Change ToString style to "Simple" 2013-07-24 16:47:50 +01:00
Stuart Boston bb57c16fe8 Trim the string values for person to remove extra spaces 2013-07-22 13:43:54 +01:00
Stuart Boston 72186feaf9 Fixes issue #4 Company parent correctly de-serialised now 2013-07-15 09:16:16 +01:00
Stuart Boston 20349013cc Updated API-Common version 2013-06-26 16:31:47 +01:00
Stuart Boston c8e33abd59 Merge branch 'master' of https://github.com/Omertron/api-themoviedb 2013-06-26 16:30:42 +01:00
Stuart Boston 940b6a007f Revert "Updated API-Common version"
This reverts commit 822ac2a5d2.
2013-06-26 16:29:46 +01:00
Stuart Boston 822ac2a5d2 Updated API-Common version 2013-06-26 16:24:24 +01:00
Omertron f2593b2754 [maven-release-plugin] prepare for next development iteration 2013-06-26 14:31:33 +02:00
43 changed files with 5577 additions and 5614 deletions
+4 -4
View File
@@ -13,7 +13,7 @@
<groupId>com.omertron</groupId> <groupId>com.omertron</groupId>
<artifactId>themoviedbapi</artifactId> <artifactId>themoviedbapi</artifactId>
<version>3.6</version> <version>3.7</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>API-The MovieDB</name> <name>API-The MovieDB</name>
@@ -85,17 +85,17 @@
<dependency> <dependency>
<groupId>com.fasterxml.jackson.core</groupId> <groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId> <artifactId>jackson-core</artifactId>
<version>2.2.2</version> <version>2.2.3</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.fasterxml.jackson.core</groupId> <groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId> <artifactId>jackson-annotations</artifactId>
<version>2.2.2</version> <version>2.2.3</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.fasterxml.jackson.core</groupId> <groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId> <artifactId>jackson-databind</artifactId>
<version>2.2.2</version> <version>2.2.3</version>
</dependency> </dependency>
<!--LOGGING--> <!--LOGGING-->
<dependency> <dependency>
@@ -19,7 +19,6 @@
*/ */
package com.omertron.themoviedbapi; package com.omertron.themoviedbapi;
import static com.omertron.themoviedbapi.tools.ApiUrl.*;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.omertron.themoviedbapi.MovieDbException.MovieDbExceptionType; import com.omertron.themoviedbapi.MovieDbException.MovieDbExceptionType;
import com.omertron.themoviedbapi.model.*; import com.omertron.themoviedbapi.model.*;
@@ -28,19 +27,23 @@ import com.omertron.themoviedbapi.results.TmdbResultsMap;
import com.omertron.themoviedbapi.tools.ApiUrl; import com.omertron.themoviedbapi.tools.ApiUrl;
import com.omertron.themoviedbapi.tools.WebBrowser; import com.omertron.themoviedbapi.tools.WebBrowser;
import com.omertron.themoviedbapi.wrapper.*; import com.omertron.themoviedbapi.wrapper.*;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.http.client.methods.HttpGet; import org.apache.http.client.methods.HttpGet;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.yamj.api.common.http.CommonHttpClient; import org.yamj.api.common.http.CommonHttpClient;
import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import static com.omertron.themoviedbapi.tools.ApiUrl.*;
/** /**
* The MovieDb API <p> This is for version 3 of the API as specified here: http://help.themoviedb.org/kb/api/about-3 * The MovieDb API <p> This is for version 3 of the API as specified here: http://help.themoviedb.org/kb/api/about-3
* *
@@ -49,6 +52,7 @@ import org.yamj.api.common.http.CommonHttpClient;
public class TheMovieDbApi { public class TheMovieDbApi {
private static final Logger LOG = LoggerFactory.getLogger(TheMovieDbApi.class); private static final Logger LOG = LoggerFactory.getLogger(TheMovieDbApi.class);
private static final String FAILED_KEYWORD = "Failed to get keyword: {}";
private String apiKey; private String apiKey;
private CommonHttpClient httpClient; private CommonHttpClient httpClient;
private TmdbConfiguration tmdbConfig; private TmdbConfiguration tmdbConfig;
@@ -59,7 +63,7 @@ public class TheMovieDbApi {
private static final String BASE_GENRE = "genre/"; private static final String BASE_GENRE = "genre/";
private static final String BASE_AUTH = "authentication/"; private static final String BASE_AUTH = "authentication/";
private static final String BASE_COLLECTION = "collection/"; 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/"; private static final String BASE_SEARCH = "search/";
private static final String BASE_LIST = "list/"; private static final String BASE_LIST = "list/";
private static final String BASE_KEYWORD = "keyword/"; private static final String BASE_KEYWORD = "keyword/";
@@ -350,13 +354,106 @@ public class TheMovieDbApi {
throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex);
} }
} }
//</editor-fold>
/**
* Get the basic information for an account. You will need to have a valid session id.
*
*
* @throws MovieDbException
*/
public Account getAccount(String sessionId) throws MovieDbException {
ApiUrl apiUrl = new ApiUrl(apiKey, BASE_ACCOUNT.replace("/", ""));
apiUrl.addArgument(PARAM_SESSION, sessionId);
URL url = apiUrl.buildUrl();
String webpage = requestWebPage(url);
try {
return mapper.readValue(webpage, Account.class);
} catch (IOException ex) {
LOG.warn("Failed to get Session Token: {}", ex.getMessage());
throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex);
}
}
public List<MovieDb> getFavoriteMovies(String sessionId, int accountId) throws MovieDbException {
ApiUrl apiUrl = new ApiUrl(apiKey, BASE_ACCOUNT, accountId + "/favorite_movies");
apiUrl.addArgument(PARAM_SESSION, sessionId);
URL url = apiUrl.buildUrl();
String webpage = WebBrowser.request(url);
try {
return mapper.readValue(webpage, WrapperMovie.class).getMovies();
} catch (IOException ex) {
LOG.warn(FAILED_KEYWORD, ex.getMessage());
throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex);
}
}
public StatusCode changeFavoriteStatus(String sessionId, int accountId, Integer movieId, boolean isFavorite) throws MovieDbException {
ApiUrl apiUrl = new ApiUrl(apiKey, BASE_ACCOUNT, accountId + "/favorite");
apiUrl.addArgument(PARAM_SESSION, sessionId);
HashMap<String, Object> body = new HashMap<String, Object>();
body.put("movie_id", movieId);
body.put("favorite", isFavorite);
String jsonBody = WebBrowser.convertToJson(body);
URL url = apiUrl.buildUrl();
String webpage = WebBrowser.request(url, jsonBody);
try {
return mapper.readValue(webpage, StatusCode.class);
} catch (IOException ex) {
LOG.warn(FAILED_KEYWORD, ex.getMessage());
throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex);
}
}
/**
* Add a movie to an account's watch list.
*/
public StatusCode addToWatchList(String sessionId, int accountId, Integer movieId) throws MovieDbException {
return modifyWatchList(sessionId, accountId, movieId, true);
}
/**
* Remove a movie from an account's watch list.
*/
public StatusCode removeFromWatchList(String sessionId, int accountId, Integer movieId) throws MovieDbException {
return modifyWatchList(sessionId, accountId, movieId, false);
}
private StatusCode modifyWatchList(String sessionId, int accountId, Integer movieId, boolean add) throws MovieDbException {
ApiUrl apiUrl = new ApiUrl(apiKey, BASE_ACCOUNT, accountId + "/movie_watchlist");
apiUrl.addArgument(PARAM_SESSION, sessionId);
HashMap<String, Object> body = new HashMap<String, Object>();
body.put("movie_id", movieId);
body.put("movie_watchlist", add);
String jsonBody = WebBrowser.convertToJson(body);
URL url = apiUrl.buildUrl();
String webpage = WebBrowser.request(url, jsonBody);
try {
return mapper.readValue(webpage, StatusCode.class);
} catch (IOException ex) {
LOG.warn(FAILED_KEYWORD, ex.getMessage());
throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex);
}
}
//<editor-fold defaultstate="collapsed" desc="Account Functions"> //<editor-fold defaultstate="collapsed" desc="Account Functions">
// No account functions // No account functions
//</editor-fold> //</editor-fold>
// //
//<editor-fold defaultstate="collapsed" desc="Movie Functions"> //<editor-fold defaultstate="collapsed" desc="Movie Functions">
/** /**
* This method is used to retrieve all of the basic movie information. * This method is used to retrieve all of the basic movie information.
* *
@@ -933,22 +1030,54 @@ public class TheMovieDbApi {
} }
} }
public List<MovieDb> getRatedMovies(String sessionId, int accountId) throws MovieDbException {
ApiUrl apiUrl = new ApiUrl(apiKey, BASE_ACCOUNT, accountId + "/rated_movies");
apiUrl.addArgument(PARAM_SESSION, sessionId);
URL url = apiUrl.buildUrl();
String webpage = WebBrowser.request(url);
try {
return mapper.readValue(webpage, WrapperMovie.class).getMovies();
} catch (IOException ex) {
LOG.warn(FAILED_KEYWORD, ex.getMessage());
throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex);
}
}
/** /**
* This method lets users rate a movie. * This method lets users rate a movie.
* *
* A valid session id is required. * A valid session id is required.
* *
* @param sessionId * @param sessionId
* @param movieId
* @param rating * @param rating
* @throws MovieDbException * @throws MovieDbException
*/ */
public boolean postMovieRating(String sessionId, String rating) throws MovieDbException { public boolean postMovieRating(String sessionId, Integer movieId, Integer rating) throws MovieDbException {
ApiUrl apiUrl = new ApiUrl(apiKey, BASE_MOVIE, "/rating"); ApiUrl apiUrl = new ApiUrl(apiKey, BASE_MOVIE, movieId + "/rating");
apiUrl.addArgument(PARAM_SESSION, sessionId); apiUrl.addArgument(PARAM_SESSION, sessionId);
apiUrl.addArgument(PARAM_VALUE, rating);
throw new MovieDbException(MovieDbExceptionType.UNKNOWN_CAUSE, "Not implemented yet"); if (rating < 0 || rating > 10) {
throw new MovieDbException(MovieDbExceptionType.UNKNOWN_CAUSE, "Rating out of range");
}
String jsonBody = WebBrowser.convertToJson(Collections.singletonMap("value", rating));
LOG.info("Body: {}", jsonBody);
URL url = apiUrl.buildUrl();
String webpage = WebBrowser.request(url, jsonBody);
try {
StatusCode status = mapper.readValue(webpage, StatusCode.class);
LOG.info("Status: {}", status);
int code = status.getStatusCode();
return code == 12;
} catch (IOException ex) {
LOG.warn(FAILED_KEYWORD, ex.getMessage());
throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex);
}
} }
//</editor-fold> //</editor-fold>
@@ -1541,6 +1670,157 @@ public class TheMovieDbApi {
throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex);
} }
} }
/**
* Get all lists of a given user
*
* @return The lists
* @throws MovieDbException
*/
public List<MovieDbList> getUserLists(String sessionId, int accountID) throws MovieDbException {
ApiUrl apiUrl = new ApiUrl(apiKey, BASE_ACCOUNT, accountID + "/lists");
apiUrl.addArgument(PARAM_SESSION, sessionId);
URL url = apiUrl.buildUrl();
String webpage = requestWebPage(url);
try {
return mapper.readValue(webpage, WrapperMovieDbList.class).getLists();
} catch (IOException ex) {
LOG.warn("Failed to get lists: {}", ex.getMessage());
throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex);
}
}
/**
* This method lets users create a new list. A valid session id is required.
*
* @return The list id
* @throws MovieDbException
*/
public String createList(String sessionId, String name, String description) throws MovieDbException {
ApiUrl apiUrl = new ApiUrl(apiKey, "list");
apiUrl.addArgument(PARAM_SESSION, sessionId);
HashMap<String, String> body = new HashMap<String, String>();
body.put("name", StringUtils.trimToEmpty(name));
body.put("description", StringUtils.trimToEmpty(description));
String jsonBody = WebBrowser.convertToJson(body);
URL url = apiUrl.buildUrl();
String webpage = WebBrowser.request(url, jsonBody);
try {
return mapper.readValue(webpage, MovieDbListStatus.class).getListId();
} catch (IOException ex) {
LOG.warn(FAILED_KEYWORD, ex.getMessage());
throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex);
}
}
/**
* Check to see if a movie ID is already added to a list.
*
* @return true if the movie is on the list
* @throws MovieDbException
*/
public boolean isMovieOnList(String listId, Integer movieId) throws MovieDbException {
ApiUrl apiUrl = new ApiUrl(apiKey, BASE_LIST, listId + "/item_status");
apiUrl.addArgument("movie_id", movieId);
URL url = apiUrl.buildUrl();
String webpage = WebBrowser.request(url);
try {
return mapper.readValue(webpage, ListItemStatus.class).isItemPresent();
} catch (IOException ex) {
LOG.warn(FAILED_KEYWORD, ex.getMessage());
throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex);
}
}
/**
* This method lets users add new movies to a list that they created. A valid session id is required.
*
* @return true if the movie is on the list
* @throws MovieDbException
*/
public StatusCode addMovieToList(String sessionId, String listId, Integer movieId) throws MovieDbException {
return modifyMovieList(sessionId, listId, movieId, "/add_item");
}
/**
* This method lets users remove movies from a list that they created. A valid session id is required.
*
* @return true if the movie is on the list
* @throws MovieDbException
*/
public StatusCode removeMovieFromList(String sessionId, String listId, Integer movieId) throws MovieDbException {
return modifyMovieList(sessionId, listId, movieId, "/remove_item");
}
private StatusCode modifyMovieList(String sessionId, String listId, Integer movieId, String operation) throws MovieDbException {
ApiUrl apiUrl = new ApiUrl(apiKey, BASE_LIST, listId + operation);
apiUrl.addArgument(PARAM_SESSION, sessionId);
String jsonBody = WebBrowser.convertToJson(Collections.singletonMap("media_id", movieId + ""));
URL url = apiUrl.buildUrl();
String webpage = WebBrowser.request(url, jsonBody);
try {
return mapper.readValue(webpage, StatusCode.class);
} catch (IOException ex) {
LOG.warn(FAILED_KEYWORD, ex.getMessage());
throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex);
}
}
/**
* Get the list of movies on an accounts watchlist.
*
* @return The watchlist of the user
* @throws MovieDbException
*/
public List<MovieDb> getWatchList(String sessionId, int accountId) throws MovieDbException {
ApiUrl apiUrl = new ApiUrl(apiKey, BASE_ACCOUNT, accountId + "/movie_watchlist");
apiUrl.addArgument(PARAM_SESSION, sessionId);
URL url = apiUrl.buildUrl();
String webpage = WebBrowser.request(url);
try {
return mapper.readValue(webpage, WrapperMovie.class).getMovies();
} catch (IOException ex) {
LOG.warn(FAILED_KEYWORD, ex.getMessage());
throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex);
}
}
/**
* This method lets users delete a list that they created. A valid session id is required.
*
* @throws MovieDbException
*/
public StatusCode deleteMovieList(String sessionId, String listId) throws MovieDbException {
ApiUrl apiUrl = new ApiUrl(apiKey, BASE_LIST, listId);
apiUrl.addArgument(PARAM_SESSION, sessionId);
URL url = apiUrl.buildUrl();
String webpage = WebBrowser.request(url, null, true);
try {
return mapper.readValue(webpage, StatusCode.class);
} catch (IOException ex) {
LOG.warn(FAILED_KEYWORD, ex.getMessage());
throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex);
}
}
//</editor-fold> //</editor-fold>
//<editor-fold defaultstate="collapsed" desc="Keyword Functions"> //<editor-fold defaultstate="collapsed" desc="Keyword Functions">
@@ -1561,7 +1841,7 @@ public class TheMovieDbApi {
try { try {
return mapper.readValue(webpage, Keyword.class); return mapper.readValue(webpage, Keyword.class);
} catch (IOException ex) { } catch (IOException ex) {
LOG.warn("Failed to get keyword: {}", ex.getMessage()); LOG.warn(FAILED_KEYWORD, ex.getMessage());
throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex); throw new MovieDbException(MovieDbExceptionType.MAPPING_FAILED, webpage, ex);
} }
@@ -0,0 +1,58 @@
/*
* 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;private either version 3 of the License;private or
* any later version.
*
* TheMovieDB API is distributed in the hope that it will be useful;private
* 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;private see <http://www.gnu.org/licenses/>.
*
*/
package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.Serializable;
/**
* @author Holger Brandl
*/
public abstract class AbstractJsonMapping implements Serializable {
private static Logger getLogger(Class<?> aClass) {
return LoggerFactory.getLogger(aClass);
}
/**
* 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("'");
getLogger(this.getClass()).warn(sb.toString());
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.SIMPLE_STYLE);
}
}
@@ -0,0 +1,66 @@
/*
* 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;private either version 3 of the License;private or
* any later version.
*
* TheMovieDB API is distributed in the hope that it will be useful;private
* 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;private see <http://www.gnu.org/licenses/>.
*
*/
package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonProperty;
public class Account extends AbstractJsonMapping {
@JsonProperty("id")
private int id;
@JsonProperty("name")
private String name;
@JsonProperty("username")
private String userName;
@JsonProperty("include_adult")
private boolean includeAdult;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public boolean isIncludeAdult() {
return includeAdult;
}
public void setIncludeAdult(boolean includeAdult) {
this.includeAdult = includeAdult;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
}
@@ -19,26 +19,17 @@
*/ */
package com.omertron.themoviedbapi.model; package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import java.io.Serializable; import java.io.Serializable;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
*
* @author Stuart * @author Stuart
*/ */
public class AlternativeTitle implements Serializable { public class AlternativeTitle implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/*
* Logger
*/
private static final Logger LOG = LoggerFactory.getLogger(AlternativeTitle.class);
/* /*
* Properties * Properties
*/ */
@@ -67,20 +58,6 @@ public class AlternativeTitle implements Serializable {
} }
// </editor-fold> // </editor-fold>
/**
* 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 @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (obj == null) { if (obj == null) {
@@ -106,9 +83,4 @@ public class AlternativeTitle implements Serializable {
hash = 89 * hash + (this.title != null ? this.title.hashCode() : 0); hash = 89 * hash + (this.title != null ? this.title.hashCode() : 0);
return hash; return hash;
} }
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.DEFAULT_STYLE);
}
} }
@@ -19,27 +19,17 @@
*/ */
package com.omertron.themoviedbapi.model; package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import java.io.Serializable;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* The artwork type information * The artwork type information
* *
* @author Stuart * @author Stuart
*/ */
public class Artwork implements Serializable { public class Artwork extends AbstractJsonMapping {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/*
* Logger
*/
private static final Logger LOG = LoggerFactory.getLogger(Artwork.class);
/* /*
* Properties * Properties
*/ */
@@ -97,7 +87,6 @@ public class Artwork implements Serializable {
public String getFlag() { public String getFlag() {
return flag; return flag;
} }
// </editor-fold> // </editor-fold>
// <editor-fold defaultstate="collapsed" desc="Setter methods"> // <editor-fold defaultstate="collapsed" desc="Setter methods">
@@ -133,26 +122,11 @@ public class Artwork implements Serializable {
this.voteCount = voteCount; this.voteCount = voteCount;
} }
public void setFlag(String flag) { public void setFlag(String flag) {
this.flag = flag; this.flag = flag;
} }
// </editor-fold> // </editor-fold>
/**
* 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 @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (obj == null) { if (obj == null) {
@@ -194,9 +168,4 @@ public class Artwork implements Serializable {
hash = 71 * hash + (this.artworkType != null ? this.artworkType.hashCode() : 0); hash = 71 * hash + (this.artworkType != null ? this.artworkType.hashCode() : 0);
return hash; return hash;
} }
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.DEFAULT_STYLE);
}
} }
@@ -1,14 +1,13 @@
package com.omertron.themoviedbapi.model; package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
public class ChangeKeyItem { public class ChangeKeyItem {
@@ -44,9 +43,4 @@ public class ChangeKeyItem {
public void setNewItems(String name, Object value) { public void setNewItems(String name, Object value) {
this.newItems.put(name, value); this.newItems.put(name, value);
} }
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.DEFAULT_STYLE);
}
} }
@@ -1,14 +1,13 @@
package com.omertron.themoviedbapi.model; package com.omertron.themoviedbapi.model;
import java.util.HashMap;
import java.util.Map;
import com.fasterxml.jackson.annotation.JsonAnyGetter; import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
public class ChangedItem { import java.util.HashMap;
import java.util.Map;
public class ChangedItem extends AbstractJsonMapping {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@JsonProperty("id") @JsonProperty("id")
@@ -72,9 +71,4 @@ public class ChangedItem {
public void setNewItems(String name, Object value) { public void setNewItems(String name, Object value) {
this.newItems.put(name, value); this.newItems.put(name, value);
} }
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.DEFAULT_STYLE);
}
} }
@@ -19,28 +19,18 @@
*/ */
package com.omertron.themoviedbapi.model; package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonRootName; import com.fasterxml.jackson.annotation.JsonRootName;
import java.io.Serializable;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
*
* @author stuart.boston * @author stuart.boston
*/ */
@JsonRootName("collection") @JsonRootName("collection")
public class Collection implements Serializable { public class Collection extends AbstractJsonMapping {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/*
* Logger
*/
private static final Logger LOG = LoggerFactory.getLogger(Collection.class);
/* /*
* Properties * Properties
*/ */
@@ -87,9 +77,7 @@ public class Collection implements Serializable {
} }
return name; return name;
} }
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="Setter methods">
public void setBackdropPath(String backdropPath) { public void setBackdropPath(String backdropPath) {
this.backdropPath = backdropPath; this.backdropPath = backdropPath;
} }
@@ -113,21 +101,6 @@ public class Collection implements Serializable {
public void setName(String name) { public void setName(String name) {
this.name = name; this.name = name;
} }
//</editor-fold>
/**
* 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 @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
@@ -164,9 +137,4 @@ public class Collection implements Serializable {
hash = 19 * hash + (this.releaseDate != null ? this.releaseDate.hashCode() : 0); hash = 19 * hash + (this.releaseDate != null ? this.releaseDate.hashCode() : 0);
return hash; return hash;
} }
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.DEFAULT_STYLE);
}
} }
@@ -19,27 +19,18 @@
*/ */
package com.omertron.themoviedbapi.model; package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
*
* @author Stuart * @author Stuart
*/ */
public class CollectionInfo implements Serializable { public class CollectionInfo extends AbstractJsonMapping {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/*
* Logger
*/
private static final Logger LOG = LoggerFactory.getLogger(CollectionInfo.class);
/* /*
* Properties * Properties
*/ */
@@ -80,9 +71,7 @@ public class CollectionInfo implements Serializable {
public String getPosterPath() { public String getPosterPath() {
return posterPath; return posterPath;
} }
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="Setter methods">
public void setBackdropPath(String backdropPath) { public void setBackdropPath(String backdropPath) {
this.backdropPath = backdropPath; this.backdropPath = backdropPath;
} }
@@ -106,24 +95,4 @@ public class CollectionInfo implements Serializable {
public void setPosterPath(String posterPath) { public void setPosterPath(String posterPath) {
this.posterPath = posterPath; this.posterPath = posterPath;
} }
//</editor-fold>
/**
* 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 ToStringBuilder.reflectionToString(this, ToStringStyle.DEFAULT_STYLE);
}
} }
@@ -19,24 +19,16 @@
*/ */
package com.omertron.themoviedbapi.model; package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import java.io.Serializable;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* Company information * Company information
* *
* @author Stuart * @author Stuart
*/ */
public class Company implements Serializable { public class Company extends AbstractJsonMapping {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
// Logger
private static final Logger LOG = LoggerFactory.getLogger(Company.class);
private static final String DEFAULT_STRING = ""; private static final String DEFAULT_STRING = "";
// Properties // Properties
@JsonProperty("id") @JsonProperty("id")
@@ -52,7 +44,7 @@ public class Company implements Serializable {
@JsonProperty("logo_path") @JsonProperty("logo_path")
private String logoPath = DEFAULT_STRING; private String logoPath = DEFAULT_STRING;
@JsonProperty("parent_company") @JsonProperty("parent_company")
private String parentCompany = DEFAULT_STRING; private Company parentCompany = null;
//<editor-fold defaultstate="collapsed" desc="Getter Methods"> //<editor-fold defaultstate="collapsed" desc="Getter Methods">
public int getCompanyId() { public int getCompanyId() {
@@ -79,12 +71,10 @@ public class Company implements Serializable {
return name; return name;
} }
public String getParentCompany() { public Company getParentCompany() {
return parentCompany; return parentCompany;
} }
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="Setter Methods">
public void setCompanyId(int companyId) { public void setCompanyId(int companyId) {
this.companyId = companyId; this.companyId = companyId;
} }
@@ -109,27 +99,15 @@ public class Company implements Serializable {
this.name = name; this.name = name;
} }
public void setParentCompany(String parentCompany) { public void setParentCompany(Company parentCompany) {
this.parentCompany = parentCompany; this.parentCompany = parentCompany;
} }
//</editor-fold>
/** public void setParentCompany(int id, String name, String logoPath) {
* Handle unknown properties and print a message Company parent = new Company();
* parent.setCompanyId(companyId);
* @param key parent.setName(name);
* @param value parent.setLogoPath(logoPath);
*/ this.parentCompany = parent;
@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 ToStringBuilder.reflectionToString(this, ToStringStyle.DEFAULT_STYLE);
} }
} }
@@ -19,14 +19,16 @@
*/ */
package com.omertron.themoviedbapi.model; package com.omertron.themoviedbapi.model;
import org.apache.commons.lang3.StringUtils;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import static com.omertron.themoviedbapi.tools.ApiUrl.*; import static com.omertron.themoviedbapi.tools.ApiUrl.*;
import org.apache.commons.lang3.StringUtils;
/** /**
* Generate a discover object for use in the MovieDbApi * Generate a discover object for use in the MovieDbApi
* * <p/>
* This allows you to just add the search components you are concerned with * This allows you to just add the search components you are concerned with
* *
* @author stuart.boston * @author stuart.boston
@@ -49,7 +51,7 @@ public class Discover {
/** /**
* Get the parameters * Get the parameters
* * <p/>
* This will be used to construct the URL in the API * This will be used to construct the URL in the API
* *
* @return * @return
@@ -160,11 +162,11 @@ public class Discover {
/** /**
* Only include movies with the specified genres. * Only include movies with the specified genres.
* * <p/>
* Expected value is an integer (the id of a genre). * Expected value is an integer (the id of a genre).
* * <p/>
* Multiple values can be specified. * Multiple values can be specified.
* * <p/>
* Comma separated indicates an 'AND' query, while a pipe (|) separated value indicates an 'OR' * Comma separated indicates an 'AND' query, while a pipe (|) separated value indicates an 'OR'
* *
* @param withGenres * @param withGenres
@@ -178,7 +180,7 @@ public class Discover {
/** /**
* The minimum release to include. * The minimum release to include.
* * <p/>
* Expected format is YYYY-MM-DD. * Expected format is YYYY-MM-DD.
* *
* @param releaseDateGte * @param releaseDateGte
@@ -192,7 +194,7 @@ public class Discover {
/** /**
* The maximum release to include. * The maximum release to include.
* * <p/>
* Expected format is YYYY-MM-DD. * Expected format is YYYY-MM-DD.
* *
* @param releaseDateLte * @param releaseDateLte
@@ -206,9 +208,9 @@ public class Discover {
/** /**
* Only include movies with certifications for a specific country. * Only include movies with certifications for a specific country.
* * <p/>
* When this value is specified, 'certificationLte' is required. * When this value is specified, 'certificationLte' is required.
* * <p/>
* A ISO 3166-1 is expected * A ISO 3166-1 is expected
* *
* @param certificationCountry * @param certificationCountry
@@ -222,7 +224,7 @@ public class Discover {
/** /**
* Only include movies with this certification and lower. * Only include movies with this certification and lower.
* * <p/>
* Expected value is a valid certification for the specified 'certificationCountry'. * Expected value is a valid certification for the specified 'certificationCountry'.
* *
* @param certificationLte * @param certificationLte
@@ -236,9 +238,9 @@ public class Discover {
/** /**
* Filter movies to include a specific company. * Filter movies to include a specific company.
* * <p/>
* Expected value is an integer (the id of a company). * Expected value is an integer (the id of a company).
* * <p/>
* They can be comma separated to indicate an 'AND' query * They can be comma separated to indicate an 'AND' query
* *
* @param withCompanies * @param withCompanies
@@ -19,27 +19,16 @@
*/ */
package com.omertron.themoviedbapi.model; package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonRootName; import com.fasterxml.jackson.annotation.JsonRootName;
import java.io.Serializable;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
*
* @author stuart.boston * @author stuart.boston
*/ */
@JsonRootName("genre") @JsonRootName("genre")
public class Genre implements Serializable { public class Genre extends AbstractJsonMapping {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/*
* Logger
*/
private static final Logger LOG = LoggerFactory.getLogger(Genre.class);
/* /*
* Properties * Properties
*/ */
@@ -56,9 +45,7 @@ public class Genre implements Serializable {
public String getName() { public String getName() {
return name; return name;
} }
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="Setter methods">
public void setId(int id) { public void setId(int id) {
this.id = id; this.id = id;
} }
@@ -66,21 +53,6 @@ public class Genre implements Serializable {
public void setName(String name) { public void setName(String name) {
this.name = name; this.name = name;
} }
//</editor-fold>
/**
* 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 @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
@@ -107,9 +79,4 @@ public class Genre implements Serializable {
hash = 53 * hash + (this.name != null ? this.name.hashCode() : 0); hash = 53 * hash + (this.name != null ? this.name.hashCode() : 0);
return hash; return hash;
} }
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.DEFAULT_STYLE);
}
} }
@@ -19,19 +19,13 @@
*/ */
package com.omertron.themoviedbapi.model; package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List; import java.util.List;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class JobDepartment { public class JobDepartment {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
// Logger
private static final Logger LOG = LoggerFactory.getLogger(JobDepartment.class);
// Properties // Properties
@JsonProperty("department") @JsonProperty("department")
private String department; private String department;
@@ -46,7 +40,6 @@ public class JobDepartment {
public List<String> getJobs() { public List<String> getJobs() {
return jobs; return jobs;
} }
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="Setters"> //<editor-fold defaultstate="collapsed" desc="Setters">
public void setDepartment(String department) { public void setDepartment(String department) {
@@ -56,24 +49,4 @@ public class JobDepartment {
public void setJobs(List<String> jobs) { public void setJobs(List<String> jobs) {
this.jobs = jobs; this.jobs = jobs;
} }
//</editor-fold>
/**
* 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 ToStringBuilder.reflectionToString(this, ToStringStyle.DEFAULT_STYLE);
}
} }
@@ -19,28 +19,17 @@
*/ */
package com.omertron.themoviedbapi.model; package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonRootName; import com.fasterxml.jackson.annotation.JsonRootName;
import java.io.Serializable;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
*
* @author stuart.boston * @author stuart.boston
*/ */
@JsonRootName("keyword") @JsonRootName("keyword")
public class Keyword implements Serializable { public class Keyword extends AbstractJsonMapping {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/*
* Logger
*/
private static final Logger LOG = LoggerFactory.getLogger(Keyword.class);
/* /*
* Properties * Properties
*/ */
@@ -57,9 +46,7 @@ public class Keyword implements Serializable {
public String getName() { public String getName() {
return name; return name;
} }
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="Setter methods">
public void setId(int id) { public void setId(int id) {
this.id = id; this.id = id;
} }
@@ -67,21 +54,6 @@ public class Keyword implements Serializable {
public void setName(String name) { public void setName(String name) {
this.name = name; this.name = name;
} }
//</editor-fold>
/**
* 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 @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
@@ -108,9 +80,4 @@ public class Keyword implements Serializable {
hash = 83 * hash + (this.name != null ? this.name.hashCode() : 0); hash = 83 * hash + (this.name != null ? this.name.hashCode() : 0);
return hash; return hash;
} }
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.DEFAULT_STYLE);
}
} }
@@ -19,26 +19,15 @@
*/ */
package com.omertron.themoviedbapi.model; package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import java.io.Serializable;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
*
* @author Stuart * @author Stuart
*/ */
public class KeywordMovie implements Serializable { public class KeywordMovie extends AbstractJsonMapping {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/*
* Logger
*/
private static final Logger LOG = LoggerFactory.getLogger(KeywordMovie.class);
/* /*
* Properties * Properties
*/ */
@@ -150,23 +139,4 @@ public class KeywordMovie implements Serializable {
this.popularity = popularity; this.popularity = popularity;
} }
// </editor-fold> // </editor-fold>
/**
* 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 ToStringBuilder.reflectionToString(this, ToStringStyle.DEFAULT_STYLE);
}
} }
@@ -19,27 +19,16 @@
*/ */
package com.omertron.themoviedbapi.model; package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonRootName; import com.fasterxml.jackson.annotation.JsonRootName;
import java.io.Serializable;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
*
* @author stuart.boston * @author stuart.boston
*/ */
@JsonRootName("spoken_language") @JsonRootName("spoken_language")
public class Language implements Serializable { public class Language extends AbstractJsonMapping {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/*
* Logger
*/
private static final Logger LOG = LoggerFactory.getLogger(Language.class);
/* /*
* Properties * Properties
*/ */
@@ -56,9 +45,7 @@ public class Language implements Serializable {
public String getName() { public String getName() {
return name; return name;
} }
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="Setter methods">
public void setIsoCode(String isoCode) { public void setIsoCode(String isoCode) {
this.isoCode = isoCode; this.isoCode = isoCode;
} }
@@ -66,21 +53,6 @@ public class Language implements Serializable {
public void setName(String name) { public void setName(String name) {
this.name = name; this.name = name;
} }
//</editor-fold>
/**
* 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 @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
@@ -107,9 +79,4 @@ public class Language implements Serializable {
hash = 71 * hash + (this.name != null ? this.name.hashCode() : 0); hash = 71 * hash + (this.name != null ? this.name.hashCode() : 0);
return hash; return hash;
} }
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.DEFAULT_STYLE);
}
} }
@@ -0,0 +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 <http://www.gnu.org/licenses/>.
*
*/
package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
* @author Holger Brandl
*/
public class ListItemStatus extends AbstractJsonMapping {
private static final long serialVersionUID = 1L;
@JsonProperty("status_code")
private int statusCode;
@JsonProperty("item_present")
private boolean itemPresent;
public int getStatusCode() {
return statusCode;
}
public void setStatusCode(int statusCode) {
this.statusCode = statusCode;
}
public boolean isItemPresent() {
return itemPresent;
}
public void setItemPresent(boolean itemPresent) {
this.itemPresent = itemPresent;
}
}
@@ -19,37 +19,19 @@
*/ */
package com.omertron.themoviedbapi.model; package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.omertron.themoviedbapi.wrapper.WrapperAlternativeTitles; import com.omertron.themoviedbapi.wrapper.*;
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.WrapperReleaseInfo;
import com.omertron.themoviedbapi.wrapper.WrapperReviews;
import com.omertron.themoviedbapi.wrapper.WrapperTrailers;
import com.omertron.themoviedbapi.wrapper.WrapperTranslations;
import java.io.Serializable;
import java.util.List; import java.util.List;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* Movie Bean * Movie Bean
* *
* @author stuart.boston * @author stuart.boston
*/ */
public class MovieDb implements Serializable { public class MovieDb extends AbstractJsonMapping {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/*
* Logger
*/
private static final Logger LOG = LoggerFactory.getLogger(MovieDb.class);
/* /*
* Properties * Properties
*/ */
@@ -93,6 +75,8 @@ public class MovieDb implements Serializable {
private List<Language> spokenLanguages; private List<Language> spokenLanguages;
@JsonProperty("tagline") @JsonProperty("tagline")
private String tagline; private String tagline;
@JsonProperty("rating")
private float userRating;
@JsonProperty("vote_average") @JsonProperty("vote_average")
private float voteAverage; private float voteAverage;
@JsonProperty("vote_count") @JsonProperty("vote_count")
@@ -213,6 +197,10 @@ public class MovieDb implements Serializable {
public String getStatus() { public String getStatus() {
return status; return status;
} }
public float getUserRating() {
return userRating;
}
// </editor-fold> // </editor-fold>
// <editor-fold defaultstate="collapsed" desc="Setter methods"> // <editor-fold defaultstate="collapsed" desc="Setter methods">
@@ -308,6 +296,9 @@ public class MovieDb implements Serializable {
this.status = status; this.status = status;
} }
public void setUserRating(float userRating) {
this.userRating = userRating;
}
// </editor-fold> // </editor-fold>
//<editor-fold defaultstate="collapsed" desc="AppendToResponse Getters"> //<editor-fold defaultstate="collapsed" desc="AppendToResponse Getters">
@@ -354,7 +345,7 @@ public class MovieDb implements Serializable {
public List<Reviews> getReviews() { public List<Reviews> getReviews() {
return reviews.getReviews(); return reviews.getReviews();
} }
//</editor-fold> // </editor-fold>
//<editor-fold defaultstate="collapsed" desc="AppendToResponse Setters"> //<editor-fold defaultstate="collapsed" desc="AppendToResponse Setters">
public void setAlternativeTitles(WrapperAlternativeTitles alternativeTitles) { public void setAlternativeTitles(WrapperAlternativeTitles alternativeTitles) {
@@ -396,22 +387,7 @@ public class MovieDb implements Serializable {
public void setReviews(WrapperReviews reviews) { public void setReviews(WrapperReviews reviews) {
this.reviews = reviews; this.reviews = reviews;
} }
// </editor-fold>
//</editor-fold>
/**
* 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());
}
//<editor-fold defaultstate="collapsed" desc="Equals and HashCode"> //<editor-fold defaultstate="collapsed" desc="Equals and HashCode">
@Override @Override
@@ -443,10 +419,5 @@ public class MovieDb implements Serializable {
hash = 89 * hash + this.runtime; hash = 89 * hash + this.runtime;
return hash; return hash;
} }
//</editor-fold> // </editor-fold>
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.DEFAULT_STYLE);
}
} }
@@ -19,26 +19,18 @@
*/ */
package com.omertron.themoviedbapi.model; package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* Wrapper for the MovieDbList function * Wrapper for the MovieDbList function
* *
* @author stuart.boston * @author stuart.boston
*/ */
public class MovieDbList { public class MovieDbList extends AbstractJsonMapping {
/*
* Logger
*/
private static final Logger LOG = LoggerFactory.getLogger(MovieDbList.class);
/* /*
* Properties * Properties
*/ */
@@ -60,6 +52,10 @@ public class MovieDbList {
private String name; private String name;
@JsonProperty("poster_path") @JsonProperty("poster_path")
private String posterPath; private String posterPath;
@JsonProperty("status_code")
private String statusCode;
@JsonProperty("status_message")
private String statusMessage;
//<editor-fold defaultstate="collapsed" desc="Getter Methods"> //<editor-fold defaultstate="collapsed" desc="Getter Methods">
public String getId() { public String getId() {
@@ -97,6 +93,14 @@ public class MovieDbList {
public String getPosterPath() { public String getPosterPath() {
return posterPath; return posterPath;
} }
public String getStatusCode() {
return statusCode;
}
public String getStatusMessage() {
return statusMessage;
}
//</editor-fold> //</editor-fold>
//<editor-fold defaultstate="collapsed" desc="Setter Methods"> //<editor-fold defaultstate="collapsed" desc="Setter Methods">
@@ -135,24 +139,13 @@ public class MovieDbList {
public void setPosterPath(String posterPath) { public void setPosterPath(String posterPath) {
this.posterPath = posterPath; this.posterPath = posterPath;
} }
public void setStatusCode(String statusCode) {
this.statusCode = statusCode;
}
public void setStatusMessage(String statusMessage) {
this.statusMessage = statusMessage;
}
//</editor-fold> //</editor-fold>
/**
* 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 ToStringBuilder.reflectionToString(this, ToStringStyle.DEFAULT_STYLE);
}
} }
@@ -0,0 +1,36 @@
/*
* 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;private either version 3 of the License;private or
* any later version.
*
* TheMovieDB API is distributed in the hope that it will be useful;private
* 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;private see <http://www.gnu.org/licenses/>.
*
*/
package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonProperty;
public class MovieDbListStatus extends StatusCode {
@JsonProperty("list_id")
private String listId;
public String getListId() {
return listId;
}
public void setListId(String listId) {
this.listId = listId;
}
}
@@ -19,26 +19,15 @@
*/ */
package com.omertron.themoviedbapi.model; package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import java.io.Serializable;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
*
* @author Stuart * @author Stuart
*/ */
public class MovieList implements Serializable { public class MovieList extends AbstractJsonMapping {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/*
* Logger
*/
private static final Logger LOG = LoggerFactory.getLogger(MovieList.class);
/* /*
* Properties * Properties
*/ */
@@ -126,23 +115,4 @@ public class MovieList implements Serializable {
this.listType = listType; this.listType = listType;
} }
// </editor-fold> // </editor-fold>
/**
* 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 ToStringBuilder.reflectionToString(this, ToStringStyle.DEFAULT_STYLE);
}
} }
@@ -19,29 +19,19 @@
*/ */
package com.omertron.themoviedbapi.model; package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import java.io.Serializable; import org.apache.commons.lang3.StringUtils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
*
* @author stuart.boston * @author stuart.boston
*/ */
public class Person implements Serializable { public class Person extends AbstractJsonMapping {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/*
* Logger
*/
private static final Logger LOG = LoggerFactory.getLogger(Person.class);
/* /*
* Static fields for default cast information * Static fields for default cast information
*/ */
@@ -91,14 +81,14 @@ public class Person implements Serializable {
* @param job * @param job
*/ */
public void addCrew(int id, String name, String profilePath, String department, String job) { public void addCrew(int id, String name, String profilePath, String department, String job) {
this.personType = PersonType.CREW; setPersonType(PersonType.CREW);
this.id = id; setId(id);
this.name = name; setName(name);
this.profilePath = profilePath; setProfilePath(profilePath);
this.department = department; setDepartment(department);
this.job = job; setJob(job);
this.character = ""; setCharacter("");
this.order = -1; setOrder(-1);
} }
/** /**
@@ -111,14 +101,14 @@ public class Person implements Serializable {
* @param order * @param order
*/ */
public void addCast(int id, String name, String profilePath, String character, int order) { public void addCast(int id, String name, String profilePath, String character, int order) {
this.personType = PersonType.CAST; setPersonType(PersonType.CAST);
this.id = id; setId(id);
this.name = name; setName(name);
this.profilePath = profilePath; setProfilePath(profilePath);
this.character = character; setCharacter(character);
this.order = order; setOrder(order);
this.department = CAST_DEPARTMENT; setDepartment(CAST_DEPARTMENT);
this.job = CAST_JOB; setJob(CAST_JOB);
} }
// <editor-fold defaultstate="collapsed" desc="Getter methods"> // <editor-fold defaultstate="collapsed" desc="Getter methods">
@@ -205,11 +195,11 @@ public class Person implements Serializable {
} }
public void setJob(String job) { public void setJob(String job) {
this.job = job; this.job = StringUtils.trimToEmpty(job);
} }
public void setName(String name) { public void setName(String name) {
this.name = name; this.name = StringUtils.trimToEmpty(name);
} }
public void setOrder(int order) { public void setOrder(int order) {
@@ -221,7 +211,7 @@ public class Person implements Serializable {
} }
public void setProfilePath(String profilePath) { public void setProfilePath(String profilePath) {
this.profilePath = profilePath; this.profilePath = StringUtils.trimToEmpty(profilePath);
} }
public void setAdult(boolean adult) { public void setAdult(boolean adult) {
@@ -233,27 +223,27 @@ public class Person implements Serializable {
} }
public void setBiography(String biography) { public void setBiography(String biography) {
this.biography = biography; this.biography = StringUtils.trimToEmpty(biography);
} }
public void setBirthday(String birthday) { public void setBirthday(String birthday) {
this.birthday = birthday; this.birthday = StringUtils.trimToEmpty(birthday);
} }
public void setBirthplace(String birthplace) { public void setBirthplace(String birthplace) {
this.birthplace = birthplace; this.birthplace = StringUtils.trimToEmpty(birthplace);
} }
public void setDeathday(String deathday) { public void setDeathday(String deathday) {
this.deathday = deathday; this.deathday = StringUtils.trimToEmpty(deathday);
} }
public void setHomepage(String homepage) { public void setHomepage(String homepage) {
this.homepage = homepage; this.homepage = StringUtils.trimToEmpty(homepage);
} }
public void setImdbId(String imdbId) { public void setImdbId(String imdbId) {
this.imdbId = imdbId; this.imdbId = StringUtils.trimToEmpty(imdbId);
} }
public void setPopularity(float popularity) { public void setPopularity(float popularity) {
@@ -261,20 +251,6 @@ public class Person implements Serializable {
} }
// </editor-fold> // </editor-fold>
/**
* 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 @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (obj == null) { if (obj == null) {
@@ -320,9 +296,4 @@ public class Person implements Serializable {
hash = 37 * hash + (this.character != null ? this.character.hashCode() : 0); hash = 37 * hash + (this.character != null ? this.character.hashCode() : 0);
return hash; return hash;
} }
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.DEFAULT_STYLE);
}
} }
@@ -19,26 +19,16 @@
*/ */
package com.omertron.themoviedbapi.model; package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import java.io.Serializable; import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
*
* @author Stuart * @author Stuart
*/ */
public class PersonCast implements Serializable { public class PersonCast extends AbstractJsonMapping {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/*
* Logger
*/
private static final Logger LOG = LoggerFactory.getLogger(PersonCast.class);
/* /*
* Properties * Properties
*/ */
@@ -80,11 +70,8 @@ public class PersonCast implements Serializable {
return castId; return castId;
} }
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="Setter methods">
public void setCharacter(String character) { public void setCharacter(String character) {
this.character = character; this.character = StringUtils.trimToEmpty(character);
} }
public void setId(int id) { public void setId(int id) {
@@ -92,7 +79,7 @@ public class PersonCast implements Serializable {
} }
public void setName(String name) { public void setName(String name) {
this.name = name; this.name = StringUtils.trimToEmpty(name);
} }
public void setOrder(int order) { public void setOrder(int order) {
@@ -100,29 +87,13 @@ public class PersonCast implements Serializable {
} }
public void setProfilePath(String profilePath) { public void setProfilePath(String profilePath) {
this.profilePath = profilePath; this.profilePath = StringUtils.trimToEmpty(profilePath);
} }
public void setCastId(int castId) { public void setCastId(int castId) {
this.castId = castId; this.castId = castId;
} }
//</editor-fold>
/**
* 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 @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (obj == null) { if (obj == null) {
@@ -160,9 +131,4 @@ public class PersonCast implements Serializable {
hash = 41 * hash + (this.profilePath != null ? this.profilePath.hashCode() : 0); hash = 41 * hash + (this.profilePath != null ? this.profilePath.hashCode() : 0);
return hash; return hash;
} }
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.DEFAULT_STYLE);
}
} }
@@ -19,26 +19,15 @@
*/ */
package com.omertron.themoviedbapi.model; package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import java.io.Serializable; import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
*
* @author stuart.boston * @author stuart.boston
*/ */
public class PersonCredit implements Serializable { public class PersonCredit extends AbstractJsonMapping {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/*
* Logger
*/
private static final Logger LOG = LoggerFactory.getLogger(PersonCredit.class);
private static final String DEFAULT_STRING = ""; private static final String DEFAULT_STRING = "";
/* /*
* Properties * Properties
@@ -103,19 +92,17 @@ public class PersonCredit implements Serializable {
public String getAdult() { public String getAdult() {
return adult; return adult;
} }
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="Setter Methods">
public void setCharacter(String character) { public void setCharacter(String character) {
this.character = character; this.character = StringUtils.trimToEmpty(character);
} }
public void setDepartment(String department) { public void setDepartment(String department) {
this.department = department; this.department = StringUtils.trimToEmpty(department);
} }
public void setJob(String job) { public void setJob(String job) {
this.job = job; this.job = StringUtils.trimToEmpty(job);
} }
public void setMovieId(int movieId) { public void setMovieId(int movieId) {
@@ -123,11 +110,11 @@ public class PersonCredit implements Serializable {
} }
public void setMovieOriginalTitle(String movieOriginalTitle) { public void setMovieOriginalTitle(String movieOriginalTitle) {
this.movieOriginalTitle = movieOriginalTitle; this.movieOriginalTitle = StringUtils.trimToEmpty(movieOriginalTitle);
} }
public void setMovieTitle(String movieTitle) { public void setMovieTitle(String movieTitle) {
this.movieTitle = movieTitle; this.movieTitle = StringUtils.trimToEmpty(movieTitle);
} }
public void setPersonType(PersonType personType) { public void setPersonType(PersonType personType) {
@@ -135,34 +122,14 @@ public class PersonCredit implements Serializable {
} }
public void setPosterPath(String posterPath) { public void setPosterPath(String posterPath) {
this.posterPath = posterPath; this.posterPath = StringUtils.trimToEmpty(posterPath);
} }
public void setReleaseDate(String releaseDate) { public void setReleaseDate(String releaseDate) {
this.releaseDate = releaseDate; this.releaseDate = StringUtils.trimToEmpty(releaseDate);
} }
public void setAdult(String adult) { public void setAdult(String adult) {
this.adult = adult; this.adult = StringUtils.trimToEmpty(adult);
}
//</editor-fold>
/**
* 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 ToStringBuilder.reflectionToString(this, ToStringStyle.DEFAULT_STYLE);
} }
} }
@@ -19,26 +19,16 @@
*/ */
package com.omertron.themoviedbapi.model; package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import java.io.Serializable; import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
*
* @author Stuart * @author Stuart
*/ */
public class PersonCrew implements Serializable { public class PersonCrew extends AbstractJsonMapping {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/*
* Logger
*/
private static final Logger LOG = LoggerFactory.getLogger(PersonCrew.class);
/* /*
* Properties * Properties
*/ */
@@ -73,11 +63,9 @@ public class PersonCrew implements Serializable {
public String getProfilePath() { public String getProfilePath() {
return profilePath; return profilePath;
} }
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="Setter methods">
public void setDepartment(String department) { public void setDepartment(String department) {
this.department = department; this.department = StringUtils.trimToEmpty(department);
} }
public void setId(int id) { public void setId(int id) {
@@ -85,30 +73,15 @@ public class PersonCrew implements Serializable {
} }
public void setJob(String job) { public void setJob(String job) {
this.job = job; this.job = StringUtils.trimToEmpty(job);
} }
public void setName(String name) { public void setName(String name) {
this.name = name; this.name = StringUtils.trimToEmpty(name);
} }
public void setProfilePath(String profilePath) { public void setProfilePath(String profilePath) {
this.profilePath = profilePath; this.profilePath = StringUtils.trimToEmpty(profilePath);
}
//</editor-fold>
/**
* 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 @Override
@@ -145,9 +118,4 @@ public class PersonCrew implements Serializable {
hash = 59 * hash + (this.profilePath != null ? this.profilePath.hashCode() : 0); hash = 59 * hash + (this.profilePath != null ? this.profilePath.hashCode() : 0);
return hash; return hash;
} }
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.DEFAULT_STYLE);
}
} }
@@ -20,12 +20,11 @@
package com.omertron.themoviedbapi.model; package com.omertron.themoviedbapi.model;
/** /**
*
* @author stuart.boston * @author stuart.boston
*/ */
public enum PersonType { public enum PersonType {
CAST, // A member of the cast CAST, // A member of the cast
CREW, // A member of the crew CREW, // A member of the crew
PERSON // No specific type PERSON // No specific type
} }
@@ -19,28 +19,17 @@
*/ */
package com.omertron.themoviedbapi.model; package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonRootName; import com.fasterxml.jackson.annotation.JsonRootName;
import java.io.Serializable;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
*
* @author stuart.boston * @author stuart.boston
*/ */
@JsonRootName("production_company") @JsonRootName("production_company")
public class ProductionCompany implements Serializable { public class ProductionCompany extends AbstractJsonMapping {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/*
* Logger
*/
private static final Logger LOG = LoggerFactory.getLogger(ProductionCompany.class);
/* /*
* Properties * Properties
*/ */
@@ -57,9 +46,7 @@ public class ProductionCompany implements Serializable {
public String getName() { public String getName() {
return name; return name;
} }
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="Setter methods">
public void setId(int id) { public void setId(int id) {
this.id = id; this.id = id;
} }
@@ -67,21 +54,6 @@ public class ProductionCompany implements Serializable {
public void setName(String name) { public void setName(String name) {
this.name = name; this.name = name;
} }
//</editor-fold>
/**
* 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 @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
@@ -108,9 +80,4 @@ public class ProductionCompany implements Serializable {
hash = 37 * hash + (this.name != null ? this.name.hashCode() : 0); hash = 37 * hash + (this.name != null ? this.name.hashCode() : 0);
return hash; return hash;
} }
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.DEFAULT_STYLE);
}
} }
@@ -19,28 +19,17 @@
*/ */
package com.omertron.themoviedbapi.model; package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonRootName; import com.fasterxml.jackson.annotation.JsonRootName;
import java.io.Serializable;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
*
* @author stuart.boston * @author stuart.boston
*/ */
@JsonRootName("production_country") @JsonRootName("production_country")
public class ProductionCountry implements Serializable { public class ProductionCountry extends AbstractJsonMapping {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/*
* Logger
*/
private static final Logger LOG = LoggerFactory.getLogger(ProductionCountry.class);
/* /*
* Properties * Properties
*/ */
@@ -57,9 +46,7 @@ public class ProductionCountry implements Serializable {
public String getName() { public String getName() {
return name; return name;
} }
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="Setter methods">
public void setIsoCode(String isoCode) { public void setIsoCode(String isoCode) {
this.isoCode = isoCode; this.isoCode = isoCode;
} }
@@ -67,21 +54,6 @@ public class ProductionCountry implements Serializable {
public void setName(String name) { public void setName(String name) {
this.name = name; this.name = name;
} }
//</editor-fold>
/**
* 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 @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
@@ -108,9 +80,4 @@ public class ProductionCountry implements Serializable {
hash = 47 * hash + (this.name != null ? this.name.hashCode() : 0); hash = 47 * hash + (this.name != null ? this.name.hashCode() : 0);
return hash; return hash;
} }
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.DEFAULT_STYLE);
}
} }
@@ -19,26 +19,15 @@
*/ */
package com.omertron.themoviedbapi.model; package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import java.io.Serializable;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
*
* @author Stuart * @author Stuart
*/ */
public class ReleaseInfo implements Serializable { public class ReleaseInfo extends AbstractJsonMapping {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/*
* Logger
*/
private static final Logger LOG = LoggerFactory.getLogger(ReleaseInfo.class);
/* /*
* Properties * Properties
*/ */
@@ -61,9 +50,7 @@ public class ReleaseInfo implements Serializable {
public String getReleaseDate() { public String getReleaseDate() {
return releaseDate; return releaseDate;
} }
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="Setter methods">
public void setCertification(String certification) { public void setCertification(String certification) {
this.certification = certification; this.certification = certification;
} }
@@ -75,21 +62,6 @@ public class ReleaseInfo implements Serializable {
public void setReleaseDate(String releaseDate) { public void setReleaseDate(String releaseDate) {
this.releaseDate = releaseDate; this.releaseDate = releaseDate;
} }
//</editor-fold>
/**
* 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 @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
@@ -120,9 +92,4 @@ public class ReleaseInfo implements Serializable {
hash = 89 * hash + (this.releaseDate != null ? this.releaseDate.hashCode() : 0); hash = 89 * hash + (this.releaseDate != null ? this.releaseDate.hashCode() : 0);
return hash; return hash;
} }
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.DEFAULT_STYLE);
}
} }
@@ -19,26 +19,15 @@
*/ */
package com.omertron.themoviedbapi.model; package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import java.io.Serializable;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
*
* @author Stuart * @author Stuart
*/ */
public class Reviews implements Serializable { public class Reviews extends AbstractJsonMapping {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/*
* Logger
*/
private static final Logger LOG = LoggerFactory.getLogger(Reviews.class);
/* /*
* Properties * Properties
*/ */
@@ -86,23 +75,4 @@ public class Reviews implements Serializable {
this.url = url; this.url = url;
} }
// </editor-fold> // </editor-fold>
/**
* 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 ToStringBuilder.reflectionToString(this, ToStringStyle.DEFAULT_STYLE);
}
} }
@@ -19,26 +19,15 @@
*/ */
package com.omertron.themoviedbapi.model; package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import java.io.Serializable;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
*
* @author Stuart * @author Stuart
*/ */
public class StatusCode implements Serializable { public class StatusCode extends AbstractJsonMapping {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/*
* Logger
*/
private static final Logger LOG = LoggerFactory.getLogger(StatusCode.class);
/* /*
* Properties * Properties
*/ */
@@ -55,9 +44,7 @@ public class StatusCode implements Serializable {
public void setStatusCode(int statusCode) { public void setStatusCode(int statusCode) {
this.statusCode = statusCode; this.statusCode = statusCode;
} }
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="Setter methods">
public String getStatusMessage() { public String getStatusMessage() {
return statusMessage; return statusMessage;
} }
@@ -65,24 +52,4 @@ public class StatusCode implements Serializable {
public void setStatusMessage(String statusMessage) { public void setStatusMessage(String statusMessage) {
this.statusMessage = statusMessage; this.statusMessage = statusMessage;
} }
//</editor-fold>
/**
* 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 ToStringBuilder.reflectionToString(this, ToStringStyle.DEFAULT_STYLE);
}
} }
@@ -19,27 +19,17 @@
*/ */
package com.omertron.themoviedbapi.model; package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import java.io.Serializable;
import java.util.List;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle; import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
*
* @author stuart.boston * @author stuart.boston
*/ */
public class TmdbConfiguration implements Serializable { public class TmdbConfiguration extends AbstractJsonMapping {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/*
* Logger
*/
private static final Logger LOG = LoggerFactory.getLogger(TmdbConfiguration.class);
/* /*
* Properties * Properties
*/ */
@@ -180,23 +170,4 @@ public class TmdbConfiguration implements Serializable {
|| isValidProfileSize(sizeToCheck) || isValidProfileSize(sizeToCheck)
|| isValidLogoSize(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() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.DEFAULT_STYLE);
}
} }
@@ -19,18 +19,12 @@
*/ */
package com.omertron.themoviedbapi.model; package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle; import org.apache.commons.lang3.builder.ToStringStyle;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class TokenAuthorisation { public class TokenAuthorisation {
/*
* Logger
*/
private static final Logger LOG = LoggerFactory.getLogger(TokenAuthorisation.class);
/* /*
* Properties * Properties
*/ */
@@ -69,23 +63,8 @@ public class TokenAuthorisation {
} }
// </editor-fold> // </editor-fold>
/**
* 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 @Override
public String toString() { public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.DEFAULT_STYLE); return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
} }
} }
@@ -19,19 +19,12 @@
*/ */
package com.omertron.themoviedbapi.model; package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle; import org.apache.commons.lang3.builder.ToStringStyle;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class TokenSession { public class TokenSession {
/*
* Logger
*/
private static final Logger LOG = LoggerFactory.getLogger(TokenSession.class);
/* /*
* Properties * Properties
*/ */
@@ -98,25 +91,10 @@ public class TokenSession {
public void setExpiresAt(String expiresAt) { public void setExpiresAt(String expiresAt) {
this.expiresAt = expiresAt; this.expiresAt = expiresAt;
} }
// </editor-fold> // </editor-fold>
/**
* 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 @Override
public String toString() { public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.DEFAULT_STYLE); return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
} }
} }
@@ -19,25 +19,13 @@
*/ */
package com.omertron.themoviedbapi.model; package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import java.io.Serializable;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
*
* @author Stuart * @author Stuart
*/ */
public class Trailer implements Serializable { public class Trailer extends AbstractJsonMapping {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/*
* Logger
*/
private static final Logger LOG = LoggerFactory.getLogger(Trailer.class);
/* /*
* Website sources * Website sources
*/ */
@@ -67,9 +55,7 @@ public class Trailer implements Serializable {
public String getWebsite() { public String getWebsite() {
return website; return website;
} }
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="Setter methods">
public void setName(String name) { public void setName(String name) {
this.name = name; this.name = name;
} }
@@ -85,21 +71,6 @@ public class Trailer implements Serializable {
public void setWebsite(String website) { public void setWebsite(String website) {
this.website = website; this.website = website;
} }
//</editor-fold>
/**
* 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 @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
@@ -131,9 +102,4 @@ public class Trailer implements Serializable {
hash = 61 * hash + (this.website != null ? this.website.hashCode() : 0); hash = 61 * hash + (this.website != null ? this.website.hashCode() : 0);
return hash; return hash;
} }
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.DEFAULT_STYLE);
}
} }
@@ -19,26 +19,17 @@
*/ */
package com.omertron.themoviedbapi.model; package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import java.io.Serializable;
import org.apache.commons.lang3.builder.ToStringBuilder; import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle; import org.apache.commons.lang3.builder.ToStringStyle;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
*
* @author Stuart * @author Stuart
*/ */
public class Translation implements Serializable { public class Translation extends AbstractJsonMapping {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/*
* Logger
*/
private static final Logger LOG = LoggerFactory.getLogger(Translation.class);
/* /*
* Properties * Properties
*/ */
@@ -61,9 +52,7 @@ public class Translation implements Serializable {
public String getName() { public String getName() {
return name; return name;
} }
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="Setter methods">
public void setEnglishName(String englishName) { public void setEnglishName(String englishName) {
this.englishName = englishName; this.englishName = englishName;
} }
@@ -75,21 +64,6 @@ public class Translation implements Serializable {
public void setName(String name) { public void setName(String name) {
this.name = name; this.name = name;
} }
//</editor-fold>
/**
* 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 @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
@@ -123,6 +97,6 @@ public class Translation implements Serializable {
@Override @Override
public String toString() { public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.DEFAULT_STYLE); return ToStringBuilder.reflectionToString(this, ToStringStyle.SIMPLE_STYLE);
} }
} }
@@ -19,11 +19,14 @@
*/ */
package com.omertron.themoviedbapi.tools; package com.omertron.themoviedbapi.tools;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.omertron.themoviedbapi.MovieDbException; import com.omertron.themoviedbapi.MovieDbException;
import java.io.BufferedReader; import org.apache.commons.codec.binary.Base64;
import java.io.IOException; import org.slf4j.Logger;
import java.io.InputStreamReader; import org.slf4j.LoggerFactory;
import java.io.StringWriter;
import java.io.*;
import java.net.HttpURLConnection; import java.net.HttpURLConnection;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.net.URL; import java.net.URL;
@@ -35,9 +38,6 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import org.apache.commons.codec.binary.Base64;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* Web browser with simple cookies support * Web browser with simple cookies support
@@ -68,6 +68,7 @@ public final class WebBrowser {
if (browserProperties.isEmpty()) { if (browserProperties.isEmpty()) {
browserProperties.put("User-Agent", "Mozilla/5.25 Netscape/5.0 (Windows; I; Win95)"); browserProperties.put("User-Agent", "Mozilla/5.25 Netscape/5.0 (Windows; I; Win95)");
browserProperties.put("Accept", "application/json"); browserProperties.put("Accept", "application/json");
browserProperties.put("Content-type", "application/json");
} }
} }
@@ -100,25 +101,59 @@ public final class WebBrowser {
} }
public static String request(URL url) throws MovieDbException { public static String request(URL url) throws MovieDbException {
return request(url, null);
}
public static String request(URL url, String jsonBody) throws MovieDbException {
return request(url, jsonBody, false);
}
public static String request(URL url, String jsonBody, boolean isDeleteRequest) throws MovieDbException {
StringWriter content = null; StringWriter content = null;
try { try {
content = new StringWriter(); content = new StringWriter();
BufferedReader in = null; BufferedReader in = null;
URLConnection cnx = null; HttpURLConnection cnx = null;
OutputStreamWriter wr = null;
try { try {
cnx = openProxiedConnection(url); cnx = (HttpURLConnection) openProxiedConnection(url);
if (isDeleteRequest) {
cnx.setDoOutput(true);
cnx.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
cnx.setRequestMethod("DELETE");
}
sendHeader(cnx); sendHeader(cnx);
if (jsonBody != null) {
cnx.setDoOutput(true);
wr = new OutputStreamWriter(cnx.getOutputStream());
wr.write(jsonBody);
}
readHeader(cnx); readHeader(cnx);
in = new BufferedReader(new InputStreamReader(cnx.getInputStream(), getCharset(cnx))); // http://stackoverflow.com/questions/4633048/httpurlconnection-reading-response-content-on-403-error
if (cnx.getResponseCode() >= 400) {
in = new BufferedReader(new InputStreamReader(cnx.getErrorStream(), getCharset(cnx)));
} else {
in = new BufferedReader(new InputStreamReader(cnx.getInputStream(), getCharset(cnx)));
}
String line; String line;
while ((line = in.readLine()) != null) { while ((line = in.readLine()) != null) {
content.write(line); content.write(line);
} }
} finally { } finally {
if (wr != null) {
wr.flush();
wr.close();
}
if (in != null) { if (in != null) {
in.close(); in.close();
} }
@@ -286,4 +321,15 @@ public final class WebBrowser {
public static void setWebTimeoutRead(int webTimeoutRead) { public static void setWebTimeoutRead(int webTimeoutRead) {
WebBrowser.webTimeoutRead = webTimeoutRead; WebBrowser.webTimeoutRead = webTimeoutRead;
} }
/**
* Use Jackson to convert Map to JSON string.
*/
public static String convertToJson(Map<String, ?> map) throws MovieDbException {
try {
return new ObjectMapper().writeValueAsString(map);
} catch (JsonProcessingException jpe) {
throw new MovieDbException(MovieDbException.MovieDbExceptionType.MAPPING_FAILED, "JSON conversion failed", jpe);
}
}
} }
@@ -26,7 +26,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
* *
* @author Stuart * @author Stuart
*/ */
public class AbstractWrapperAll extends AbstractWrapperId implements IWrapperId, IWrapperPages { public class AbstractWrapperAll extends AbstractWrapperId implements IWrapperId, IWrapperPages, IWrapperDates {
/* /*
* Properties * Properties
*/ */
@@ -37,6 +37,8 @@ public class AbstractWrapperAll extends AbstractWrapperId implements IWrapperId,
private int totalPages; private int totalPages;
@JsonProperty("total_results") @JsonProperty("total_results")
private int totalResults; private int totalResults;
@JsonProperty("dates")
private ResultDates dates = new ResultDates();
public AbstractWrapperAll(Class classToLog) { public AbstractWrapperAll(Class classToLog) {
super(classToLog); super(classToLog);
@@ -57,6 +59,11 @@ public class AbstractWrapperAll extends AbstractWrapperId implements IWrapperId,
return totalResults; return totalResults;
} }
@Override
public ResultDates getDates() {
return dates;
}
@Override @Override
public void setPage(int page) { public void setPage(int page) {
this.page = page; this.page = page;
@@ -71,4 +78,9 @@ public class AbstractWrapperAll extends AbstractWrapperId implements IWrapperId,
public void setTotalResults(int totalResults) { public void setTotalResults(int totalResults) {
this.totalResults = totalResults; this.totalResults = totalResults;
} }
@Override
public void setDates(ResultDates dates) {
this.dates = dates;
}
} }
@@ -0,0 +1,27 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*
*/
package com.omertron.themoviedbapi.wrapper;
public interface IWrapperDates {
ResultDates getDates();
void setDates(ResultDates dates);
}
@@ -0,0 +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 <http://www.gnu.org/licenses/>.
*
*/
package com.omertron.themoviedbapi.wrapper;
import com.omertron.themoviedbapi.model.*;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.io.Serializable;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
*
* @author Stuart
*/
public class ResultDates implements Serializable {
private static final long serialVersionUID = 1L;
/*
* Logger
*/
private static final Logger LOG = LoggerFactory.getLogger(ResultDates.class);
/*
* Properties
*/
@JsonProperty("minimum")
private String minimum = "";
@JsonProperty("maximum")
private String maximum = "";
// <editor-fold defaultstate="collapsed" desc="Getter methods">
public String getMinimum() {
return minimum;
}
public String getMaximum() {
return maximum;
}
// </editor-fold>
// <editor-fold defaultstate="collapsed" desc="Setter methods">
public void setMinimum(String minimum) {
this.minimum = minimum;
}
public void setMaximum(String maximum) {
this.maximum = maximum;
}
// </editor-fold>
/**
* 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 ToStringBuilder.reflectionToString(this, ToStringStyle.SIMPLE_STYLE);
}
}
@@ -0,0 +1,25 @@
package com.omertron.themoviedbapi.wrapper;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.omertron.themoviedbapi.model.MovieDbList;
import java.util.List;
public class WrapperMovieDbList extends AbstractWrapperAll {
@JsonProperty("results")
private List<MovieDbList> lists;
public WrapperMovieDbList() {
super(WrapperMovieDbList.class);
}
public List<MovieDbList> getLists() {
return lists;
}
public void setLists(List<MovieDbList> lists) {
this.lists = lists;
}
}
@@ -19,39 +19,20 @@
*/ */
package com.omertron.themoviedbapi; package com.omertron.themoviedbapi;
import com.omertron.themoviedbapi.model.AlternativeTitle; import com.omertron.themoviedbapi.model.*;
import com.omertron.themoviedbapi.model.Artwork;
import com.omertron.themoviedbapi.model.ChangedItem;
import com.omertron.themoviedbapi.model.Collection;
import com.omertron.themoviedbapi.model.CollectionInfo;
import com.omertron.themoviedbapi.model.Company;
import com.omertron.themoviedbapi.model.Discover;
import com.omertron.themoviedbapi.model.Genre;
import com.omertron.themoviedbapi.model.JobDepartment;
import com.omertron.themoviedbapi.model.Keyword;
import com.omertron.themoviedbapi.model.KeywordMovie;
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;
import com.omertron.themoviedbapi.model.ReleaseInfo;
import com.omertron.themoviedbapi.model.Reviews;
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.results.TmdbResultsList; import com.omertron.themoviedbapi.results.TmdbResultsList;
import com.omertron.themoviedbapi.results.TmdbResultsMap; import com.omertron.themoviedbapi.results.TmdbResultsMap;
import java.io.IOException;
import java.util.List;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.junit.*; import org.junit.*;
import static org.junit.Assert.*;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import java.io.IOException;
import java.util.List;
import java.util.Random;
import static org.junit.Assert.*;
/** /**
* Test cases for TheMovieDbApi API * Test cases for TheMovieDbApi API
* *
@@ -69,7 +50,7 @@ public class TheMovieDbApiTest {
private static final int ID_MOVIE_THE_AVENGERS = 24428; private static final int ID_MOVIE_THE_AVENGERS = 24428;
private static final int ID_COLLECTION_STAR_WARS = 10; private static final int ID_COLLECTION_STAR_WARS = 10;
private static final int ID_PERSON_BRUCE_WILLIS = 62; private static final int ID_PERSON_BRUCE_WILLIS = 62;
private static final int ID_COMPANY_LUCASFILM = 1; private static final int ID_COMPANY = 2;
private static final String COMPANY_NAME = "Marvel Studios"; private static final String COMPANY_NAME = "Marvel Studios";
private static final int ID_GENRE_ACTION = 28; private static final int ID_GENRE_ACTION = 28;
private static final String ID_KEYWORD = "1721"; private static final String ID_KEYWORD = "1721";
@@ -77,6 +58,9 @@ public class TheMovieDbApiTest {
private static final String LANGUAGE_DEFAULT = ""; private static final String LANGUAGE_DEFAULT = "";
private static final String LANGUAGE_ENGLISH = "en"; private static final String LANGUAGE_ENGLISH = "en";
private static final String LANGUAGE_RUSSIAN = "ru"; private static final String LANGUAGE_RUSSIAN = "ru";
// session and account id of test users named 'apitests'
private static final String SESSION_ID_APITESTS = "63c85deb39337e29b69d78265eb28d639cbd6f72";
private static final int ACCOUNT_ID_APITESTS = 6065849;
public TheMovieDbApiTest() throws MovieDbException { public TheMovieDbApiTest() throws MovieDbException {
} }
@@ -115,6 +99,51 @@ public class TheMovieDbApiTest {
LOG.info(tmdbConfig.toString()); LOG.info(tmdbConfig.toString());
} }
@Test
public void testAccount() throws MovieDbException {
Account account = tmdb.getAccount(SESSION_ID_APITESTS);
// Make sure properties are extracted correctly
assertEquals(account.getUserName(), "apitests");
assertEquals(account.getId(), ACCOUNT_ID_APITESTS);
}
@Ignore("Session required")
public void testWatchList() throws MovieDbException {
// make sure it's empty (because it's just a test account
Assert.assertTrue(tmdb.getWatchList(SESSION_ID_APITESTS, ACCOUNT_ID_APITESTS).isEmpty());
// add a movie
tmdb.addToWatchList(SESSION_ID_APITESTS, ACCOUNT_ID_APITESTS, 550);
List<MovieDb> watchList = tmdb.getWatchList(SESSION_ID_APITESTS, ACCOUNT_ID_APITESTS);
assertNotNull("Empty watch list returned", watchList);
assertEquals("Watchlist wrong size", 1, watchList.size());
// clean up again
tmdb.removeFromWatchList(SESSION_ID_APITESTS, ACCOUNT_ID_APITESTS, 550);
Assert.assertTrue(tmdb.getWatchList(SESSION_ID_APITESTS, ACCOUNT_ID_APITESTS).isEmpty());
}
@Ignore("Session required")
public void testFavorites() throws MovieDbException {
// make sure it's empty (because it's just a test account
Assert.assertTrue(tmdb.getFavoriteMovies(SESSION_ID_APITESTS, ACCOUNT_ID_APITESTS).isEmpty());
// add a movie
tmdb.changeFavoriteStatus(SESSION_ID_APITESTS, ACCOUNT_ID_APITESTS, 550, true);
List<MovieDb> watchList = tmdb.getFavoriteMovies(SESSION_ID_APITESTS, ACCOUNT_ID_APITESTS);
assertNotNull("Empty watch list returned", watchList);
assertEquals("Watchlist wrong size", 1, watchList.size());
// clean up again
tmdb.changeFavoriteStatus(SESSION_ID_APITESTS, ACCOUNT_ID_APITESTS, 550, false);
Assert.assertTrue(tmdb.getFavoriteMovies(SESSION_ID_APITESTS, ACCOUNT_ID_APITESTS).isEmpty());
}
/** /**
* Test of searchMovie method, of class TheMovieDbApi. * Test of searchMovie method, of class TheMovieDbApi.
*/ */
@@ -413,8 +442,9 @@ public class TheMovieDbApiTest {
@Test @Test
public void testGetCompanyInfo() throws MovieDbException { public void testGetCompanyInfo() throws MovieDbException {
LOG.info("getCompanyInfo"); LOG.info("getCompanyInfo");
Company company = tmdb.getCompanyInfo(ID_COMPANY_LUCASFILM); Company company = tmdb.getCompanyInfo(ID_COMPANY);
assertTrue("No company information found", company.getCompanyId() > 0); assertTrue("No company information found", company.getCompanyId() > 0);
assertNotNull("No parent company found", company.getParentCompany());
} }
/** /**
@@ -423,7 +453,7 @@ public class TheMovieDbApiTest {
@Test @Test
public void testGetCompanyMovies() throws MovieDbException { public void testGetCompanyMovies() throws MovieDbException {
LOG.info("getCompanyMovies"); LOG.info("getCompanyMovies");
TmdbResultsList<MovieDb> result = tmdb.getCompanyMovies(ID_COMPANY_LUCASFILM, LANGUAGE_DEFAULT, 0); TmdbResultsList<MovieDb> result = tmdb.getCompanyMovies(ID_COMPANY, LANGUAGE_DEFAULT, 0);
assertTrue("No company movies found", !result.getResults().isEmpty()); assertTrue("No company movies found", !result.getResults().isEmpty());
} }
@@ -504,12 +534,13 @@ public class TheMovieDbApiTest {
* *
* TODO: Cannot be tested without a HTTP authorisation: http://help.themoviedb.org/kb/api/user-authentication * TODO: Cannot be tested without a HTTP authorisation: http://help.themoviedb.org/kb/api/user-authentication
*/ */
@Ignore("Session required")
public void testGetSessionToken() throws Exception { public void testGetSessionToken() throws Exception {
LOG.info("getSessionToken"); LOG.info("getSessionToken");
TokenAuthorisation token = tmdb.getAuthorisationToken(); TokenAuthorisation token = tmdb.getAuthorisationToken();
assertFalse("Token is null", token == null); assertFalse("Token is null", token == null);
assertTrue("Token is not valid", token.getSuccess()); assertTrue("Token is not valid", token.getSuccess());
LOG.info(token.toString()); LOG.info("Token: {}", token.toString());
TokenSession result = tmdb.getSessionToken(token); TokenSession result = tmdb.getSessionToken(token);
assertFalse("Session token is null", result == null); assertFalse("Session token is null", result == null);
@@ -612,16 +643,57 @@ public class TheMovieDbApiTest {
* *
* TODO: Cannot be tested without a HTTP authorisation: http://help.themoviedb.org/kb/api/user-authentication * TODO: Cannot be tested without a HTTP authorisation: http://help.themoviedb.org/kb/api/user-authentication
*/ */
@Ignore("Not ready yet") @Ignore("Session required")
public void testPostMovieRating() throws Exception { public void testMovieRating() throws Exception {
LOG.info("postMovieRating"); LOG.info("postMovieRating");
String sessionId = ""; Integer movieID = 68724;
String rating = ""; Integer rating = new Random().nextInt(10) + 1;
boolean expResult = false;
boolean result = tmdb.postMovieRating(sessionId, rating); boolean wasPosted = tmdb.postMovieRating(SESSION_ID_APITESTS, movieID, rating);
assertEquals(expResult, result);
// TODO review the generated test code and remove the default call to fail. assertNotNull(wasPosted);
fail("The test case is a prototype."); assertTrue(wasPosted);
// get all rated movies
List<MovieDb> ratedMovies = tmdb.getRatedMovies(SESSION_ID_APITESTS, ACCOUNT_ID_APITESTS);
assertTrue(ratedMovies.size() > 0);
// make sure that we find the movie and it is rated correctly
boolean foundMovie = false;
for (MovieDb movie : ratedMovies) {
if (movie.getId() == movieID) {
assertEquals(movie.getUserRating(), (float) rating, 0);
foundMovie = true;
}
}
assertTrue(foundMovie);
}
@Ignore("Session required")
public void testMovieLists() throws Exception {
Integer movieID = 68724;
// use a random name to avoid that we clash we leftovers of incomplete test runs
String name = "test list " + new Random().nextInt(100);
// create the list
String listId = tmdb.createList(SESSION_ID_APITESTS, name, "api testing only");
// add a movie, and test that it is on the list now
tmdb.addMovieToList(SESSION_ID_APITESTS, listId, movieID);
MovieDbList list = tmdb.getList(listId);
assertNotNull("Movie list returned was null", list);
assertEquals("Unexpected number of items returned", 1, list.getItemCount());
assertEquals((int) movieID, list.getItems().get(0).getId());
// now remove the movie
tmdb.removeMovieFromList(SESSION_ID_APITESTS, listId, movieID);
assertEquals(tmdb.getList(listId).getItemCount(), 0);
// delete the test list
StatusCode statusCode = tmdb.deleteMovieList(SESSION_ID_APITESTS, listId);
assertEquals(statusCode.getStatusCode(), 13);
} }
/** /**