35 Commits

Author SHA1 Message Date
Omertron 67b4efe77c [maven-release-plugin] prepare release themoviedbapi-3.9 2013-12-22 17:28:15 +01:00
Omertron 917c3bb029 Rollback partial release 2013-12-22 17:26:52 +01:00
Omertron 68cbc9b54b [maven-release-plugin] prepare release themoviedbapi-3.9 2013-12-22 16:29:04 +01:00
Stuart Boston e2f1008d01 Updated POM 2013-12-15 08:23:40 +00:00
Stuart Boston 51b202df2d Fix issue #14
Correct URL for collections
2013-12-14 19:07:37 +00:00
stuart.boston d84582d336 Update error message 2013-12-03 14:25:41 +00:00
Stuart Boston 121838598d Change port to integer 2013-11-27 10:46:17 +00:00
Stuart Boston cd09cf8dfe Add PersonCredit comparator 2013-11-24 17:44:07 +00:00
Stuart Boston 3a53039b3e Updated Results to get the size of the results when not populated by the wrapper 2013-11-22 14:38:50 +00:00
Stuart Boston f7b37a1eb9 Update dependency versions 2013-11-17 19:47:05 +00:00
Stuart Boston 52c19f98d4 Remove inline comments 2013-11-17 19:46:45 +00:00
Omertron 796459b816 [maven-release-plugin] prepare for next development iteration 2013-11-07 11:06:04 +01:00
Omertron eaf5849a43 [maven-release-plugin] prepare release themoviedbapi-3.8 2013-11-07 11:05:57 +01:00
Stuart Boston 231f60624b Tidy up log error messages 2013-11-07 09:52:21 +00:00
Stuart Boston 3b1855d75c Remove unused imports 2013-11-07 09:50:06 +00:00
Stuart Boston 0cfa4d0dd4 Update README.md 2013-11-07 08:44:29 +00:00
Stuart Boston 971ee44375 Remove unused comments 2013-11-01 12:47:52 +00:00
Stuart Boston 359a0d56a3 Added "type" to Trailer 2013-11-01 12:29:55 +00:00
Stuart Boston 8eea8c796a Update handlerUnknown code
Output the class that caused the unknown issue
2013-11-01 12:28:53 +00:00
Stuart Boston 82e9c5b06f Trim test logging message 2013-11-01 12:26:15 +00:00
Stuart Boston 57691ed17f Remove unused imports 2013-10-29 15:56:00 +00:00
Stuart Boston b705a85566 Add badges 2013-10-22 16:04:43 +01:00
Stuart Boston db4f3e6f80 Minor updates 2013-10-22 13:44:42 +01:00
Stuart Boston 9eed62c8d7 Updated javadoc 2013-10-22 12:03:25 +01:00
Stuart Boston 51e5166233 Throw MovieDbException if movie ID not found
Rather than pass a seemingly valid object back to the caller, this
change will throw a "MOVIE_ID_NOT_FOUND" exception to the caller.
Affects getMovieInfo and getMovieInfoImdb methods
Fixes #8
2013-10-02 09:15:50 +01:00
Stuart Boston dd5176d6c6 Add gitattributes file
Update line endings
2013-10-01 14:10:54 +01:00
Stuart Boston 6448542fb4 Merge pull request #7 from fcojean/master
Implemented MovieChangesList
2013-09-26 11:37:19 +01:00
Stuart Boston 1ac805bed3 Add missing Serializable 2013-09-25 09:58:24 +01:00
Stuart Boston 2ef41457d0 Change logging for abstract wrapper 2013-09-25 09:48:47 +01:00
Stuart Boston d3338cc106 Remove unused imports 2013-09-25 09:38:30 +01:00
Stuart Boston 2c5569d53d Add language and country to account information 2013-09-25 09:33:44 +01:00
Stuart Boston 546a1e0d93 Update README.md 2013-09-20 10:43:35 +01:00
Stuart Boston 3b503e78ef Add exceptions for unknown request types 2013-09-08 11:10:21 +01:00
Stuart Boston 4cb0314c56 Use pooling client for requests 2013-09-08 10:36:54 +01:00
Omertron 95b3a4dd36 [maven-release-plugin] prepare for next development iteration 2013-08-23 10:22:03 +02:00
82 changed files with 2251 additions and 1747 deletions
+22
View File
@@ -0,0 +1,22 @@
# Auto detect text files and perform LF normalization
* text=auto
# Custom for Visual Studio
*.cs diff=csharp
*.sln merge=union
*.csproj merge=union
*.vbproj merge=union
*.fsproj merge=union
*.dbproj merge=union
# Standard to msysgit
*.doc diff=astextplain
*.DOC diff=astextplain
*.docx diff=astextplain
*.DOCX diff=astextplain
*.dot diff=astextplain
*.DOT diff=astextplain
*.pdf diff=astextplain
*.PDF diff=astextplain
*.rtf diff=astextplain
*.RTF diff=astextplain
+9 -9
View File
@@ -1,9 +1,9 @@
*.class
# Package Files #
*.jar
*.war
*.ear
/target/
/nbactions.xml
*.class
# Package Files #
*.jar
*.war
*.ear
/target/
/nbactions.xml
+12 -12
View File
@@ -1,12 +1,12 @@
package com.darylbeattie.movies.util;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target(value=ElementType.METHOD)
@Retention(value=RetentionPolicy.RUNTIME)
public @interface JsonAnySetter {
}
package com.darylbeattie.movies.util;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target(value=ElementType.METHOD)
@Retention(value=RetentionPolicy.RUNTIME)
public @interface JsonAnySetter {
}
+12 -12
View File
@@ -1,12 +1,12 @@
package com.darylbeattie.movies.util;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER})
@Retention(RetentionPolicy.RUNTIME)
public @interface JsonProperty {
String value() default "";
}
package com.darylbeattie.movies.util;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER})
@Retention(RetentionPolicy.RUNTIME)
public @interface JsonProperty {
String value() default "";
}
+12 -12
View File
@@ -1,12 +1,12 @@
package com.darylbeattie.movies.util;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
public @interface JsonRootName {
String value() default "";
}
package com.darylbeattie.movies.util;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
public @interface JsonRootName {
String value() default "";
}
+68 -68
View File
@@ -1,69 +1,69 @@
package com.darylbeattie.movies.util;
import java.io.IOException;
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.lang.reflect.ParameterizedType;
import java.util.List;
import org.json.JSONArray;
import org.json.JSONObject;
public class ObjectMapper {
/**
* This takes a JSON string and creates (and populates) an object of the given class
* with the data from that JSON string. It mimics the method signature of the jackson
* JSON API, so that we don't have to import the jackson library into this application.
*
* @param jsonString The JSON string to parse.
* @param objClass The class of object we want to create.
* @return The instantiation of that class, populated with data from the JSON object.
* @throws IOException If there was any kind of issue.
*/
public <T> T readValue(String jsonString, Class<T> objClass) throws IOException {
try {
return readValue(new JSONObject(jsonString), objClass);
}
catch (IOException ioe) {
throw ioe;
}
catch (Exception e) {
e.printStackTrace();
throw new IOException(e);
}
}
@SuppressWarnings("unchecked")
public <T, R> T readValue(JSONObject json, Class<T> objClass) throws IOException {
try {
//TODO Iterate through json object values and call the JsonAnySetter method on the unknown ones.
T obj = objClass.newInstance();
for (Field f : objClass.getFields()) {
Annotation a = f.getAnnotation(JsonProperty.class);
if (List.class.equals(f.getType()) && (json.optJSONArray(((JsonProperty) a).value()) != null)) { // It's a list.
JSONArray jsonArray = json.optJSONArray(((JsonProperty) a).value());
ParameterizedType listType = (ParameterizedType) f.getGenericType();
Class<?> subObj = (Class<?>) listType.getActualTypeArguments()[0];
List<R> subObjList = ((Class<List<R>>) f.getType()).newInstance();
for (int i = 0; i < jsonArray.length(); i++) {
subObjList.add((R) readValue(jsonArray.getJSONObject(i), subObj));
}
f.set(obj, subObjList);
}
else if (a != null) {
f.set(obj, json.opt(((JsonProperty) a).value()));
}
}
return obj;
}
catch (IOException ioe) {
throw ioe;
}
catch (Exception e) {
e.printStackTrace();
throw new IOException(e);
}
}
package com.darylbeattie.movies.util;
import java.io.IOException;
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.lang.reflect.ParameterizedType;
import java.util.List;
import org.json.JSONArray;
import org.json.JSONObject;
public class ObjectMapper {
/**
* This takes a JSON string and creates (and populates) an object of the given class
* with the data from that JSON string. It mimics the method signature of the jackson
* JSON API, so that we don't have to import the jackson library into this application.
*
* @param jsonString The JSON string to parse.
* @param objClass The class of object we want to create.
* @return The instantiation of that class, populated with data from the JSON object.
* @throws IOException If there was any kind of issue.
*/
public <T> T readValue(String jsonString, Class<T> objClass) throws IOException {
try {
return readValue(new JSONObject(jsonString), objClass);
}
catch (IOException ioe) {
throw ioe;
}
catch (Exception e) {
e.printStackTrace();
throw new IOException(e);
}
}
@SuppressWarnings("unchecked")
public <T, R> T readValue(JSONObject json, Class<T> objClass) throws IOException {
try {
//TODO Iterate through json object values and call the JsonAnySetter method on the unknown ones.
T obj = objClass.newInstance();
for (Field f : objClass.getFields()) {
Annotation a = f.getAnnotation(JsonProperty.class);
if (List.class.equals(f.getType()) && (json.optJSONArray(((JsonProperty) a).value()) != null)) { // It's a list.
JSONArray jsonArray = json.optJSONArray(((JsonProperty) a).value());
ParameterizedType listType = (ParameterizedType) f.getGenericType();
Class<?> subObj = (Class<?>) listType.getActualTypeArguments()[0];
List<R> subObjList = ((Class<List<R>>) f.getType()).newInstance();
for (int i = 0; i < jsonArray.length(); i++) {
subObjList.add((R) readValue(jsonArray.getJSONObject(i), subObj));
}
f.set(obj, subObjList);
}
else if (a != null) {
f.set(obj, json.opt(((JsonProperty) a).value()));
}
}
return obj;
}
catch (IOException ioe) {
throw ioe;
}
catch (Exception e) {
e.printStackTrace();
throw new IOException(e);
}
}
}
+6 -6
View File
@@ -1,6 +1,6 @@
Jackson Library Replacement
===========================
These files are provided by Darren Beattie as an example of how to replace the Jackson libraries with native libraries inside Android.
They are provided without warrantee and if you modify them or find them useful, please let me know.
Jackson Library Replacement
===========================
These files are provided by Darren Beattie as an example of how to replace the Jackson libraries with native libraries inside Android.
They are provided without warrantee and if you modify them or find them useful, please let me know.
+648 -648
View File
File diff suppressed because it is too large Load Diff
+18 -1
View File
@@ -8,9 +8,26 @@ This API uses the [TheMovieDB.org API](http://api.themoviedb.org/)
Originally written for use by Yet Another Movie Jukebox [(YAMJ)](http://code.google.com/p/moviejukebox/)
But anyone can use it for other projects as well.
[![Flattr this git repo](http://api.flattr.com/button/flattr-badge-large.png)](https://flattr.com/submit/auto?user_id=Omertron&url=https://github.com/Omertron/api-themoviedb&title=TheMovieDB API&language=&tags=github&category=software)
[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/Omertron/api-themoviedb/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
***
TMDB TV Support
===============
TheMovieDb has recently added TV shows to their site.
I am working on an update to this API to support that, but it will require a re-write of the API to support the new models and ensure that it is simple to understand.
Therefore TV support will be added to *v4.0* of the API, major version change because of the large change to the API. I will release a stable version of 3.9 in the next week before releaseing 4.0 SNAPSHOT.
If you are interested in the current level of TV support checkout the `tv` branch where all the changes are being done.
***
### TheMovieDB.org
This is an excellent open database for movie and film content.
This is an excellent open database for movie and film content.
I *strongly* encourage you to check it out and contribute to keep it growing.
+13 -11
View File
@@ -13,7 +13,7 @@
<groupId>com.omertron</groupId>
<artifactId>themoviedbapi</artifactId>
<version>3.7</version>
<version>3.9</version>
<packaging>jar</packaging>
<name>API-The MovieDB</name>
@@ -71,6 +71,8 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<distribution.format>zip</distribution.format>
<version.jackson>2.3.0</version.jackson>
<version.slf4j>1.7.5</version.slf4j>
</properties>
<dependencies>
@@ -85,35 +87,35 @@
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.2.3</version>
<version>${version.jackson}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.2.3</version>
<version>${version.jackson}</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.2.3</version>
<version>${version.jackson}</version>
</dependency>
<!--LOGGING-->
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
<version>1.7.5</version>
<version>${version.slf4j}</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-jdk14</artifactId>
<version>1.7.5</version>
<version>${version.slf4j}</version>
<scope>test</scope>
</dependency>
<!--COMMON HTTP TOOLS-->
<dependency>
<groupId>org.yamj</groupId>
<artifactId>api-common</artifactId>
<version>1.0</version>
<version>1.1</version>
</dependency>
</dependencies>
@@ -174,7 +176,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.14.1</version>
<version>2.16</version>
<configuration>
<!-- To skip tests by default -->
<skipTests>${skipTests}</skipTests>
@@ -233,7 +235,7 @@
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
<version>2.0</version>
<version>2.1</version>
</plugin>
<plugin>
@@ -277,7 +279,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.7</version>
<version>2.8.1</version>
</plugin>
<plugin>
@@ -289,7 +291,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>2.4</version>
<version>2.5.1</version>
</plugin>
<plugin>
@@ -1,87 +1,87 @@
/*
* 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;
public class MovieDbException extends Exception {
private static final long serialVersionUID = 1L;
public enum MovieDbExceptionType {
/*
* Unknown error occured
*/
UNKNOWN_CAUSE,
/*
* URL is invalid
*/
INVALID_URL,
/*
* Page not found
*/
HTTP_404_ERROR,
/*
* The movie id was not found
*/
MOVIE_ID_NOT_FOUND,
/*
* Mapping failed from target to internal onbjects
*/
MAPPING_FAILED,
/*
* Error connecting to the service
*/
CONNECTION_ERROR,
/*
* Image was invalid
*/
INVALID_IMAGE,
/*
* Autorisation rejected
*/
AUTHORISATION_FAILURE,
/*
* Service Unavailable, usually temporary
*/
HTTP_503_ERROR;
}
private final MovieDbExceptionType exceptionType;
private final String response;
public MovieDbException(final MovieDbExceptionType exceptionType, final String response) {
super();
this.exceptionType = exceptionType;
this.response = response;
}
public MovieDbException(final MovieDbExceptionType exceptionType, final String response, final Throwable cause) {
super(cause);
this.exceptionType = exceptionType;
this.response = response;
}
public MovieDbExceptionType getExceptionType() {
return exceptionType;
}
public String getResponse() {
return response;
}
}
/*
* 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;
public class MovieDbException extends Exception {
private static final long serialVersionUID = 1L;
public enum MovieDbExceptionType {
/*
* Unknown error occured
*/
UNKNOWN_CAUSE,
/*
* URL is invalid
*/
INVALID_URL,
/*
* Page not found
*/
HTTP_404_ERROR,
/*
* The movie id was not found
*/
MOVIE_ID_NOT_FOUND,
/*
* Mapping failed from target to internal onbjects
*/
MAPPING_FAILED,
/*
* Error connecting to the service
*/
CONNECTION_ERROR,
/*
* Image was invalid
*/
INVALID_IMAGE,
/*
* Autorisation rejected
*/
AUTHORISATION_FAILURE,
/*
* Service Unavailable, usually temporary
*/
HTTP_503_ERROR;
}
private final MovieDbExceptionType exceptionType;
private final String response;
public MovieDbException(final MovieDbExceptionType exceptionType, final String response) {
super();
this.exceptionType = exceptionType;
this.response = response;
}
public MovieDbException(final MovieDbExceptionType exceptionType, final String response, final Throwable cause) {
super(cause);
this.exceptionType = exceptionType;
this.response = response;
}
public MovieDbExceptionType getExceptionType() {
return exceptionType;
}
public String getResponse() {
return response;
}
}
File diff suppressed because it is too large Load Diff
@@ -28,12 +28,24 @@ import org.slf4j.LoggerFactory;
import java.io.Serializable;
/**
* @author Holger Brandl
* Abstract class to handle any unknown properties by outputting a log message
*
* @author stuart.boston
*/
public abstract class AbstractJsonMapping implements Serializable {
private static Logger getLogger(Class<?> aClass) {
return LoggerFactory.getLogger(aClass);
private Logger log = null;
/**
* Return the current logger.
*
* @return
*/
private Logger getLogger() {
if (log == null) {
log = LoggerFactory.getLogger(this.getClass());
}
return log;
}
/**
@@ -43,16 +55,16 @@ public abstract class AbstractJsonMapping implements Serializable {
* @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("'");
protected void handleUnknown(String key, Object value) {
StringBuilder unknown = new StringBuilder(this.getClass().getSimpleName());
unknown.append(": Unknown property='").append(key);
unknown.append("' value='").append(value).append("'");
getLogger(this.getClass()).warn(sb.toString());
getLogger().trace(unknown.toString());
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.SIMPLE_STYLE);
return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
}
}
@@ -31,6 +31,10 @@ public class Account extends AbstractJsonMapping {
private String userName;
@JsonProperty("include_adult")
private boolean includeAdult;
@JsonProperty("iso_639_1")
private String language;
@JsonProperty("iso_3166_1")
private String country;
public int getId() {
return id;
@@ -63,4 +67,20 @@ public class Account extends AbstractJsonMapping {
public void setUserName(String userName) {
this.userName = userName;
}
public String getLanguage() {
return language;
}
public void setLanguage(String language) {
this.language = language;
}
public String getCountry() {
return country;
}
public void setCountry(String country) {
this.country = country;
}
}
@@ -30,9 +30,6 @@ public class Artwork extends AbstractJsonMapping {
private static final long serialVersionUID = 1L;
/*
* Properties
*/
@JsonProperty("aspect_ratio")
private float aspectRatio;
@JsonProperty("file_path")
@@ -51,7 +48,6 @@ public class Artwork extends AbstractJsonMapping {
private String flag;
private ArtworkType artworkType = ArtworkType.POSTER;
// <editor-fold defaultstate="collapsed" desc="Getter methods">
public ArtworkType getArtworkType() {
return artworkType;
}
@@ -87,9 +83,7 @@ public class Artwork extends AbstractJsonMapping {
public String getFlag() {
return flag;
}
// </editor-fold>
// <editor-fold defaultstate="collapsed" desc="Setter methods">
public void setArtworkType(ArtworkType artworkType) {
this.artworkType = artworkType;
}
@@ -125,7 +119,6 @@ public class Artwork extends AbstractJsonMapping {
public void setFlag(String flag) {
this.flag = flag;
}
// </editor-fold>
@Override
public boolean equals(Object obj) {
@@ -1,30 +1,33 @@
/*
* 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;
/**
* ArtworkType enum List of the artwork types that are available
*/
public enum ArtworkType {
POSTER, // Poster artwork
BACKDROP, // Fanart/backdrop
PROFILE // Person image
}
/*
* 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;
/**
* ArtworkType enum List of the artwork types that are available
*/
public enum ArtworkType {
// Poster artwork
POSTER,
// Fanart/backdrop
BACKDROP,
// Person image
PROFILE
}
@@ -16,7 +16,7 @@ public class ChangeKeyItem {
private String key;
@JsonProperty("items")
private List<ChangedItem> changedItems = new ArrayList<ChangedItem>();
private Map<String, Object> newItems = new HashMap<String, Object>();
private final Map<String, Object> newItems = new HashMap<String, Object>();
public String getKey() {
return key;
@@ -20,7 +20,7 @@ public class ChangedItem extends AbstractJsonMapping {
private String language;
@JsonProperty("value")
private Object value;
private Map<String, Object> newItems = new HashMap<String, Object>();
private final Map<String, Object> newItems = new HashMap<String, Object>();
public String getId() {
return id;
@@ -0,0 +1,48 @@
/*
* 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;
public class ChangedMovie extends AbstractJsonMapping {
private static final long serialVersionUID = 1L;
@JsonProperty("id")
private String id;
@JsonProperty("adult")
private boolean adult;
public String getId() {
return id;
}
public boolean isAdult() {
return adult;
}
public void setId(String id) {
this.id = id;
}
public void setAdult(boolean adult) {
this.adult = adult;
}
}
@@ -47,7 +47,6 @@ public class Collection extends AbstractJsonMapping {
@JsonProperty("release_date")
private String releaseDate;
//<editor-fold defaultstate="collapsed" desc="Getter methods">
public String getBackdropPath() {
return backdropPath;
}
@@ -47,7 +47,6 @@ public class CollectionInfo extends AbstractJsonMapping {
@JsonProperty("parts")
private List<Collection> parts = new ArrayList<Collection>();
//<editor-fold defaultstate="collapsed" desc="Getter methods">
public String getBackdropPath() {
return backdropPath;
}
@@ -46,7 +46,6 @@ public class Company extends AbstractJsonMapping {
@JsonProperty("parent_company")
private Company parentCompany = null;
//<editor-fold defaultstate="collapsed" desc="Getter Methods">
public int getCompanyId() {
return companyId;
}
@@ -35,7 +35,7 @@ import static com.omertron.themoviedbapi.tools.ApiUrl.*;
*/
public class Discover {
private Map<String, String> params = new HashMap<String, String>();
private final Map<String, String> params = new HashMap<String, String>();
private static final String PARAM_PRIMARY_RELEASE_YEAR = "primary_release_year=";
private static final String PARAM_VOTE_COUNT_GTE = "vote_count.gte=";
private static final String PARAM_VOTE_AVERAGE_GTE = "vote_average.gte=";
@@ -64,6 +64,7 @@ public class Discover {
* Minimum value is 1 if included.
*
* @param page
* @return
*/
public Discover page(int page) {
if (page > 0) {
@@ -76,6 +77,7 @@ public class Discover {
* ISO 639-1 code
*
* @param language
* @return
*/
public Discover language(String language) {
if (StringUtils.isNotBlank(language)) {
@@ -94,6 +96,7 @@ public class Discover {
* popularity.asc
*
* @param sortBy
* @return
*/
public Discover sortBy(String sortBy) {
if (StringUtils.isNotBlank(sortBy)) {
@@ -106,6 +109,7 @@ public class Discover {
* Toggle the inclusion of adult titles
*
* @param includeAdult
* @return
*/
public Discover includeAdult(boolean includeAdult) {
params.put(PARAM_ADULT, String.valueOf(includeAdult));
@@ -116,6 +120,7 @@ public class Discover {
* Filter the results release dates to matches that include this value.
*
* @param year
* @return
*/
public Discover year(int year) {
if (checkYear(year)) {
@@ -128,6 +133,7 @@ public class Discover {
* Filter the results so that only the primary release date year has this value
*
* @param primaryReleaseYear
* @return
*/
public Discover primaryReleaseYear(int primaryReleaseYear) {
if (checkYear(primaryReleaseYear)) {
@@ -140,6 +146,7 @@ public class Discover {
* Only include movies that are equal to, or have a vote count higher than this value
*
* @param voteCountGte
* @return
*/
public Discover voteCountGte(int voteCountGte) {
if (voteCountGte > 0) {
@@ -152,6 +159,7 @@ public class Discover {
* Only include movies that are equal to, or have a higher average rating than this value
*
* @param voteAverageGte
* @return
*/
public Discover voteAverageGte(float voteAverageGte) {
if (voteAverageGte > 0) {
@@ -170,6 +178,7 @@ public class Discover {
* Comma separated indicates an 'AND' query, while a pipe (|) separated value indicates an 'OR'
*
* @param withGenres
* @return
*/
public Discover withGenres(String withGenres) {
if (StringUtils.isNotBlank(withGenres)) {
@@ -184,6 +193,7 @@ public class Discover {
* Expected format is YYYY-MM-DD.
*
* @param releaseDateGte
* @return
*/
public Discover releaseDateGte(String releaseDateGte) {
if (StringUtils.isNotBlank(releaseDateGte)) {
@@ -198,6 +208,7 @@ public class Discover {
* Expected format is YYYY-MM-DD.
*
* @param releaseDateLte
* @return
*/
public Discover releaseDateLte(String releaseDateLte) {
if (StringUtils.isNotBlank(releaseDateLte)) {
@@ -214,6 +225,7 @@ public class Discover {
* A ISO 3166-1 is expected
*
* @param certificationCountry
* @return
*/
public Discover certificationCountry(String certificationCountry) {
if (StringUtils.isNotBlank(certificationCountry)) {
@@ -228,6 +240,7 @@ public class Discover {
* Expected value is a valid certification for the specified 'certificationCountry'.
*
* @param certificationLte
* @return
*/
public Discover certificationLte(String certificationLte) {
if (StringUtils.isNotBlank(certificationLte)) {
@@ -244,6 +257,7 @@ public class Discover {
* They can be comma separated to indicate an 'AND' query
*
* @param withCompanies
* @return
*/
public Discover withCompanies(String withCompanies) {
if (StringUtils.isNotBlank(withCompanies)) {
@@ -37,7 +37,6 @@ public class Genre extends AbstractJsonMapping {
@JsonProperty("name")
private String name;
//<editor-fold defaultstate="collapsed" desc="Getter methods">
public int getId() {
return id;
}
@@ -23,7 +23,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;
public class JobDepartment {
public class JobDepartment extends AbstractJsonMapping {
private static final long serialVersionUID = 1L;
// Properties
@@ -32,7 +32,6 @@ public class JobDepartment {
@JsonProperty("job_list")
private List<String> jobs;
//<editor-fold defaultstate="collapsed" desc="Getters">
public String getDepartment() {
return department;
}
@@ -41,7 +40,6 @@ public class JobDepartment {
return jobs;
}
//<editor-fold defaultstate="collapsed" desc="Setters">
public void setDepartment(String department) {
this.department = department;
}
@@ -38,7 +38,6 @@ public class Keyword extends AbstractJsonMapping {
@JsonProperty("name")
private String name;
//<editor-fold defaultstate="collapsed" desc="Getter methods">
public int getId() {
return id;
}
@@ -52,7 +52,6 @@ public class KeywordMovie extends AbstractJsonMapping {
@JsonProperty("popularity")
private float popularity;
// <editor-fold defaultstate="collapsed" desc="Getter methods">
public static long getSerialVersionUID() {
return serialVersionUID;
}
@@ -96,9 +95,7 @@ public class KeywordMovie extends AbstractJsonMapping {
public float getPopularity() {
return popularity;
}
// </editor-fold>
// <editor-fold defaultstate="collapsed" desc="Setter methods">
public void setBackdropPath(String backdropPath) {
this.backdropPath = backdropPath;
}
@@ -138,5 +135,4 @@ public class KeywordMovie extends AbstractJsonMapping {
public void setPopularity(float popularity) {
this.popularity = popularity;
}
// </editor-fold>
}
@@ -37,7 +37,6 @@ public class Language extends AbstractJsonMapping {
@JsonProperty("name")
private String name;
//<editor-fold defaultstate="collapsed" desc="Getter methods">
public String getIsoCode() {
return isoCode;
}
@@ -32,9 +32,6 @@ import java.util.List;
public class MovieDb extends AbstractJsonMapping {
private static final long serialVersionUID = 1L;
/*
* Properties
*/
@JsonProperty("backdrop_path")
private String backdropPath;
@JsonProperty("id")
@@ -31,9 +31,6 @@ import java.util.List;
*/
public class MovieDbList extends AbstractJsonMapping {
/*
* Properties
*/
@JsonProperty("id")
private String id;
@JsonProperty("created_by")
@@ -57,7 +54,6 @@ public class MovieDbList extends AbstractJsonMapping {
@JsonProperty("status_message")
private String statusMessage;
//<editor-fold defaultstate="collapsed" desc="Getter Methods">
public String getId() {
return id;
}
@@ -101,9 +97,7 @@ public class MovieDbList extends AbstractJsonMapping {
public String getStatusMessage() {
return statusMessage;
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="Setter Methods">
public void setId(String id) {
this.id = id;
}
@@ -147,5 +141,4 @@ public class MovieDbList extends AbstractJsonMapping {
public void setStatusMessage(String statusMessage) {
this.statusMessage = statusMessage;
}
//</editor-fold>
}
@@ -28,9 +28,6 @@ public class MovieList extends AbstractJsonMapping {
private static final long serialVersionUID = 1L;
/*
* Properties
*/
@JsonProperty("description")
private String description;
@JsonProperty("favorite_count")
@@ -48,7 +45,6 @@ public class MovieList extends AbstractJsonMapping {
@JsonProperty("list_type")
private String listType;
// <editor-fold defaultstate="collapsed" desc="Getter methods">
public String getDescription() {
return description;
}
@@ -80,9 +76,7 @@ public class MovieList extends AbstractJsonMapping {
public String getListType() {
return listType;
}
// </editor-fold>
// <editor-fold defaultstate="collapsed" desc="Setter methods">
public void setDescription(String description) {
this.description = description;
}
@@ -114,5 +108,4 @@ public class MovieList extends AbstractJsonMapping {
public void setListType(String listType) {
this.listType = listType;
}
// </editor-fold>
}
@@ -48,12 +48,17 @@ public class Person extends AbstractJsonMapping {
@JsonProperty("profile_path")
private String profilePath = DEFAULT_STRING;
private PersonType personType = PersonType.PERSON;
private String department = DEFAULT_STRING; // Crew
private String job = DEFAULT_STRING; // Crew
private String character = DEFAULT_STRING; // Cast
private int order = -1; // Cast
// Crew
private String department = DEFAULT_STRING;
// Crew
private String job = DEFAULT_STRING;
// Cast
private String character = DEFAULT_STRING;
// Cast
private int order = -1;
@JsonProperty("adult")
private boolean adult = false; // Person info
// Person info
private boolean adult = false;
@JsonProperty("also_known_as")
private List<String> aka = new ArrayList<String>();
@JsonProperty("biography")
@@ -111,7 +116,6 @@ public class Person extends AbstractJsonMapping {
setJob(CAST_JOB);
}
// <editor-fold defaultstate="collapsed" desc="Getter methods">
public String getCharacter() {
return character;
}
@@ -179,9 +183,7 @@ public class Person extends AbstractJsonMapping {
public float getPopularity() {
return popularity;
}
// </editor-fold>
// <editor-fold defaultstate="collapsed" desc="Setter methods">
public void setCharacter(String character) {
this.character = character;
}
@@ -249,7 +251,6 @@ public class Person extends AbstractJsonMapping {
public void setPopularity(float popularity) {
this.popularity = popularity;
}
// </editor-fold>
@Override
public boolean equals(Object obj) {
@@ -45,7 +45,6 @@ public class PersonCast extends AbstractJsonMapping {
@JsonProperty("cast_id")
private int castId;
//<editor-fold defaultstate="collapsed" desc="Getter methods">
public String getCharacter() {
return character;
}
@@ -52,7 +52,6 @@ public class PersonCredit extends AbstractJsonMapping {
private String adult = DEFAULT_STRING;
private PersonType personType = PersonType.PERSON;
//<editor-fold defaultstate="collapsed" desc="Getter Methods">
public String getCharacter() {
return character;
}
@@ -43,7 +43,6 @@ public class PersonCrew extends AbstractJsonMapping {
@JsonProperty("profile_path")
private String profilePath;
//<editor-fold defaultstate="collapsed" desc="Getter methods">
public String getDepartment() {
return department;
}
@@ -1,30 +1,33 @@
/*
* 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;
/**
* @author stuart.boston
*/
public enum PersonType {
CAST, // A member of the cast
CREW, // A member of the crew
PERSON // No specific type
}
/*
* 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;
/**
* @author stuart.boston
*/
public enum PersonType {
// A member of the cast
CAST,
// A member of the crew
CREW,
// No specific type
PERSON
}
@@ -38,7 +38,6 @@ public class ProductionCompany extends AbstractJsonMapping {
@JsonProperty("name")
private String name;
//<editor-fold defaultstate="collapsed" desc="Getter methods">
public int getId() {
return id;
}
@@ -38,7 +38,6 @@ public class ProductionCountry extends AbstractJsonMapping {
@JsonProperty("name")
private String name;
//<editor-fold defaultstate="collapsed" desc="Getter methods">
public String getIsoCode() {
return isoCode;
}
@@ -38,7 +38,6 @@ public class ReleaseInfo extends AbstractJsonMapping {
@JsonProperty("release_date")
private String releaseDate;
//<editor-fold defaultstate="collapsed" desc="Getter methods">
public String getCertification() {
return certification;
}
@@ -40,7 +40,6 @@ public class Reviews extends AbstractJsonMapping {
@JsonProperty("url")
private String url;
// <editor-fold defaultstate="collapsed" desc="Getter methods">
public String getId() {
return id;
}
@@ -56,9 +55,7 @@ public class Reviews extends AbstractJsonMapping {
public String getUrl() {
return url;
}
// </editor-fold>
// <editor-fold defaultstate="collapsed" desc="Setter methods">
public void setId(String id) {
this.id = id;
}
@@ -74,5 +71,4 @@ public class Reviews extends AbstractJsonMapping {
public void setUrl(String url) {
this.url = url;
}
// </editor-fold>
}
@@ -36,7 +36,6 @@ public class StatusCode extends AbstractJsonMapping {
@JsonProperty("status_message")
private String statusMessage;
//<editor-fold defaultstate="collapsed" desc="Getter methods">
public int getStatusCode() {
return statusCode;
}
@@ -46,7 +46,6 @@ public class TmdbConfiguration extends AbstractJsonMapping {
@JsonProperty("logo_sizes")
private List<String> logoSizes;
// <editor-fold defaultstate="collapsed" desc="Getter methods">//GEN-BEGIN:getterMethods
public List<String> getBackdropSizes() {
return backdropSizes;
}
@@ -71,8 +70,6 @@ public class TmdbConfiguration extends AbstractJsonMapping {
return secureBaseUrl;
}
// </editor-fold>
// <editor-fold defaultstate="collapsed" desc="Setter methods">//GEN-BEGIN:setterMethods
public void setBackdropSizes(List<String> backdropSizes) {
this.backdropSizes = backdropSizes;
}
@@ -96,7 +93,6 @@ public class TmdbConfiguration extends AbstractJsonMapping {
public void setSecureBaseUrl(String secureBaseUrl) {
this.secureBaseUrl = secureBaseUrl;
}
// </editor-fold>
/**
* Copy the data from the passed object to this one
@@ -115,6 +111,7 @@ public class TmdbConfiguration extends AbstractJsonMapping {
* Check that the poster size is valid
*
* @param posterSize
* @return
*/
public boolean isValidPosterSize(String posterSize) {
if (StringUtils.isBlank(posterSize) || posterSizes.isEmpty()) {
@@ -127,6 +124,7 @@ public class TmdbConfiguration extends AbstractJsonMapping {
* Check that the backdrop size is valid
*
* @param backdropSize
* @return
*/
public boolean isValidBackdropSize(String backdropSize) {
if (StringUtils.isBlank(backdropSize) || backdropSizes.isEmpty()) {
@@ -139,6 +137,7 @@ public class TmdbConfiguration extends AbstractJsonMapping {
* Check that the profile size is valid
*
* @param profileSize
* @return
*/
public boolean isValidProfileSize(String profileSize) {
if (StringUtils.isBlank(profileSize) || profileSizes.isEmpty()) {
@@ -151,6 +150,7 @@ public class TmdbConfiguration extends AbstractJsonMapping {
* Check that the logo size is valid
*
* @param logoSize
* @return
*/
public boolean isValidLogoSize(String logoSize) {
if (StringUtils.isBlank(logoSize) || logoSizes.isEmpty()) {
@@ -163,6 +163,7 @@ public class TmdbConfiguration extends AbstractJsonMapping {
* Check to see if the size is valid for any of the images types
*
* @param sizeToCheck
* @return
*/
public boolean isValidSize(String sizeToCheck) {
return (isValidPosterSize(sizeToCheck)
@@ -20,10 +20,8 @@
package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
public class TokenAuthorisation {
public class TokenAuthorisation extends AbstractJsonMapping {
/*
* Properties
@@ -35,7 +33,6 @@ public class TokenAuthorisation {
@JsonProperty("success")
private Boolean success;
// <editor-fold defaultstate="collapsed" desc="Getter methods">
public String getExpires() {
return expires;
}
@@ -47,9 +44,7 @@ public class TokenAuthorisation {
public Boolean getSuccess() {
return success;
}
// </editor-fold>
// <editor-fold defaultstate="collapsed" desc="Setter methods">
public void setExpires(String expires) {
this.expires = expires;
}
@@ -61,10 +56,4 @@ public class TokenAuthorisation {
public void setSuccess(Boolean success) {
this.success = success;
}
// </editor-fold>
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
}
}
@@ -20,10 +20,8 @@
package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
public class TokenSession {
public class TokenSession extends AbstractJsonMapping {
/*
* Properties
@@ -41,7 +39,6 @@ public class TokenSession {
@JsonProperty("expires_at")
private String expiresAt;
// <editor-fold defaultstate="collapsed" desc="Getter methods">
public String getSessionId() {
return sessionId;
}
@@ -65,9 +62,7 @@ public class TokenSession {
public String getExpiresAt() {
return expiresAt;
}
// </editor-fold>
// <editor-fold defaultstate="collapsed" desc="Setter methods">
public void setSessionId(String sessionId) {
this.sessionId = sessionId;
}
@@ -91,10 +86,4 @@ public class TokenSession {
public void setExpiresAt(String expiresAt) {
this.expiresAt = expiresAt;
}
// </editor-fold>
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
}
}
@@ -37,9 +37,10 @@ public class Trailer extends AbstractJsonMapping {
private String name;
private String size;
private String source;
private String website; // The website of the trailer
// The website of the trailer
private String website;
private String type;
//<editor-fold defaultstate="collapsed" desc="Getter methods">
public String getName() {
return name;
}
@@ -56,6 +57,10 @@ public class Trailer extends AbstractJsonMapping {
return website;
}
public String getType() {
return type;
}
public void setName(String name) {
this.name = name;
}
@@ -72,6 +77,10 @@ public class Trailer extends AbstractJsonMapping {
this.website = website;
}
public void setType(String type) {
this.type = type;
}
@Override
public boolean equals(Object obj) {
if (obj == null) {
@@ -40,7 +40,6 @@ public class Translation extends AbstractJsonMapping {
@JsonProperty("name")
private String name;
//<editor-fold defaultstate="collapsed" desc="Getter methods">
public String getEnglishName() {
return englishName;
}
@@ -0,0 +1,98 @@
/*
* 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.comparator;
import com.omertron.themoviedbapi.model.PersonCredit;
import java.io.Serializable;
import java.util.Comparator;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.commons.lang3.StringUtils;
/**
* Compare two PersonCredits by date
*
* @author stuart.boston
*/
public class PersonCreditDateComparator implements Comparator<PersonCredit>, Serializable {
private static final long serialVersionUID = 1L;
private static final Pattern YEAR_PATTERN = Pattern.compile("(?:.*?)(\\d{4})(?:.*?)");
private final boolean ascending;
public PersonCreditDateComparator() {
this.ascending = Boolean.FALSE;
}
public PersonCreditDateComparator(boolean ascending) {
this.ascending = ascending;
}
@Override
public int compare(PersonCredit pc1, PersonCredit pc2) {
return compare(pc1, pc2, ascending);
}
/**
* Compare two PersonCredits based on the respective years
*
* @param pc1
* @param pc2
* @param ascending
* @return
*/
public int compare(PersonCredit pc1, PersonCredit pc2, boolean ascending) {
boolean valid1 = StringUtils.isNotBlank(pc1.getReleaseDate());
boolean valid2 = StringUtils.isNotBlank(pc2.getReleaseDate());
if (!valid1 && !valid2) {
return 0;
}
if (!valid1) {
return ascending ? -1 : 1;
}
if (!valid2) {
return ascending ? 1 : -1;
}
int year1 = extractYear(pc1.getReleaseDate());
int year2 = extractYear(pc2.getReleaseDate());
return ascending ? (year1 - year2) : (year2 - year1);
}
/**
* locate a 4 digit year in a date string
*
* @param date
* @return
*/
private static int extractYear(String date) {
int year = 0;
Matcher m = YEAR_PATTERN.matcher(date);
if (m.find()) {
year = Integer.valueOf(m.group(1)).intValue();
}
// Give up and return 0
return year;
}
}
@@ -30,7 +30,7 @@ import org.apache.commons.lang3.builder.ToStringStyle;
*
* @author Stuart
*/
public abstract class TmdbResults {
public abstract class AbstractResults {
private int id = 0;
private int page = 0;
@@ -100,6 +100,6 @@ public abstract class TmdbResults {
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.DEFAULT_STYLE);
return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
}
}
@@ -1,50 +1,59 @@
/*
* 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.results;
import java.util.ArrayList;
import java.util.List;
/**
* List of the results from TheMovieDb
*
* @author Stuart
* @param <T>
*/
public final class TmdbResultsList<T> extends TmdbResults {
private List<T> results;
public TmdbResultsList(List<T> resultList) {
if (resultList != null) {
results = new ArrayList<T>(resultList);
} else {
results = new ArrayList<T>(0);
}
}
public List<T> getResults() {
return results;
}
public void setResults(List<T> results) {
this.results = results;
}
}
/*
* 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.results;
import java.util.ArrayList;
import java.util.List;
/**
* List of the results from TheMovieDb
*
* @author Stuart
* @param <T>
*/
public final class TmdbResultsList<T> extends AbstractResults {
private List<T> results;
public TmdbResultsList(List<T> resultList) {
if (resultList != null) {
results = new ArrayList<T>(resultList);
} else {
results = new ArrayList<T>(0);
}
}
public List<T> getResults() {
return results;
}
public void setResults(List<T> results) {
this.results = results;
}
@Override
public int getTotalResults() {
if (super.getTotalResults() == 0) {
return results.size();
} else {
return super.getTotalResults();
}
}
}
@@ -29,7 +29,7 @@ import java.util.Map;
* @param <K>
* @param <V>
*/
public final class TmdbResultsMap<K, V> extends TmdbResults {
public final class TmdbResultsMap<K, V> extends AbstractResults {
private Map<K, V> results;
@@ -44,4 +44,13 @@ public final class TmdbResultsMap<K, V> extends TmdbResults {
public void setResults(Map<K, V> results) {
this.results = results;
}
@Override
public int getTotalResults() {
if (super.getTotalResults() == 0) {
return results.size();
} else {
return super.getTotalResults();
}
}
}
@@ -1,253 +1,257 @@
/*
* 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.tools;
import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLEncoder;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* The API URL that is used to construct the API call
*
* @author Stuart
*/
public class ApiUrl {
/*
* Logger
*/
private static final Logger LOG = LoggerFactory.getLogger(ApiUrl.class);
/*
* TheMovieDbApi API Base URL
*/
private static final String TMDB_API_BASE = "http://api.themoviedb.org/3/";
/*
* Parameter configuration
*/
private static final String DELIMITER_FIRST = "?";
private static final String DELIMITER_SUBSEQUENT = "&";
private static final String DEFAULT_STRING = "";
/*
* Properties
*/
private String apiKey;
private String method;
private String submethod;
private Map<String, String> arguments = new HashMap<String, String>();
/*
* API Parameters
*/
public static final String PARAM_ADULT = "include_adult=";
public static final String PARAM_API_KEY = "api_key=";
public static final String PARAM_COUNTRY = "country=";
public static final String PARAM_FAVORITE = "favorite=";
public static final String PARAM_ID = "id=";
public static final String PARAM_LANGUAGE = "language=";
public static final String PARAM_INCLUDE_ALL_MOVIES = "include_all_movies=";
public static final String PARAM_MOVIE_WATCHLIST = "movie_watchlist=";
public static final String PARAM_PAGE = "page=";
public static final String PARAM_QUERY = "query=";
public static final String PARAM_SESSION = "session_id=";
public static final String PARAM_TOKEN = "request_token=";
public static final String PARAM_VALUE = "value=";
public static final String PARAM_YEAR = "year=";
public static final String PARAM_START_DATE="start_date=";
public static final String PARAM_END_DATE="end_date=";
private static final String APPEND_TO_RESPONSE = "append_to_response=";
//<editor-fold defaultstate="collapsed" desc="Constructor Methods">
/**
* Constructor for the simple API URL method without a sub-method
*
* @param method
*/
public ApiUrl(String apiKey, String method) {
this.apiKey = apiKey;
this.method = method;
this.submethod = DEFAULT_STRING;
}
/**
* Constructor for the API URL with a sub-method
*
* @param method
* @param submethod
*/
public ApiUrl(String apiKey, String method, String submethod) {
this.apiKey = apiKey;
this.method = method;
this.submethod = submethod;
}
//</editor-fold>
/**
* Build the URL from the pre-created arguments.
*/
public URL buildUrl() {
StringBuilder urlString = new StringBuilder(TMDB_API_BASE);
// Get the start of the URL
urlString.append(method);
// We have either a queury, or a direct request
if (arguments.containsKey(PARAM_QUERY)) {
// Append the suffix of the API URL
if(StringUtils.endsWith(urlString, "/") && submethod.startsWith("/")) {
urlString.deleteCharAt(urlString.length()-1);
}
urlString.append(submethod);
// Append the key information
urlString.append(DELIMITER_FIRST).append(PARAM_API_KEY);
urlString.append(apiKey);
// Append the search term
urlString.append(DELIMITER_SUBSEQUENT);
urlString.append(PARAM_QUERY);
String query = arguments.get(PARAM_QUERY);
try {
urlString.append(URLEncoder.encode(query, "UTF-8"));
} catch (UnsupportedEncodingException ex) {
LOG.trace("Unable to encode query: '{}' trying raw.", query);
// If we can't encode it, try it raw
urlString.append(query);
}
// Remove the query from the arguments so it is not added later
arguments.remove(PARAM_QUERY);
} else {
// Append the ID if provided
if (arguments.containsKey(PARAM_ID)) {
urlString.append(arguments.get(PARAM_ID));
arguments.remove(PARAM_ID);
}
// Append the suffix of the API URL
if(StringUtils.endsWith(urlString, "/") && submethod.startsWith("/")) {
urlString.deleteCharAt(urlString.length()-1);
}
urlString.append(submethod);
// Append the key information
urlString.append(DELIMITER_FIRST).append(PARAM_API_KEY);
urlString.append(apiKey);
}
for (Map.Entry<String, String> argEntry : arguments.entrySet()) {
urlString.append(DELIMITER_SUBSEQUENT).append(argEntry.getKey());
urlString.append(argEntry.getValue());
}
try {
LOG.trace("URL: {}", urlString.toString());
return new URL(urlString.toString());
} catch (MalformedURLException ex) {
LOG.warn("Failed to create URL {} - {}", urlString.toString(), ex.toString());
return null;
} finally {
arguments.clear();
}
}
/**
* Add arguments individually
*
* @param key
* @param value
*/
public void addArgument(String key, String value) {
arguments.put(key, value);
}
/**
* Add arguments individually
*
* @param key
* @param value
*/
public void addArgument(String key, int value) {
arguments.put(key, Integer.toString(value));
}
/**
* Add arguments individually
*
* @param key
* @param value
*/
public void addArgument(String key, boolean value) {
arguments.put(key, Boolean.toString(value));
}
/**
* Add arguments individually
*
* @param key
* @param value
*/
public void addArgument(String key, float value) {
arguments.put(key, Float.toString(value));
}
/**
* Clear the arguments
*/
public void clearArguments() {
arguments.clear();
}
/**
* Set the arguments directly
*
* @param args
*/
public void setArguments(Map<String, String> args) {
arguments.putAll(args);
}
/**
* Append any optional parameters to the URL
*
* @param appendToResponse
*/
public void appendToResponse(String[] appendToResponse) {
if (appendToResponse.length > 0) {
StringBuilder sb = new StringBuilder();
boolean first = Boolean.TRUE;
for (String append : appendToResponse) {
if (first) {
first = Boolean.FALSE;
} else {
sb.append(",");
}
sb.append(append);
}
addArgument(APPEND_TO_RESPONSE, sb.toString());
}
}
}
/*
* Copyright (c) 2004-2013 Stuart Boston
*
* This file is part of TheMovieDB API.
*
* TheMovieDB API is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* TheMovieDB API is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>.
*
*/
package com.omertron.themoviedbapi.tools;
import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLEncoder;
import java.util.HashMap;
import java.util.Map;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* The API URL that is used to construct the API call
*
* @author Stuart
*/
public class ApiUrl {
/*
* Logger
*/
private static final Logger LOG = LoggerFactory.getLogger(ApiUrl.class);
/*
* TheMovieDbApi API Base URL
*/
private static final String TMDB_API_BASE = "http://api.themoviedb.org/3/";
/*
* Parameter configuration
*/
private static final String DELIMITER_FIRST = "?";
private static final String DELIMITER_SUBSEQUENT = "&";
private static final String DEFAULT_STRING = "";
/*
* Properties
*/
private final String apiKey;
private final String method;
private final String submethod;
private final Map<String, String> arguments = new HashMap<String, String>();
/*
* API Parameters
*/
public static final String PARAM_ADULT = "include_adult=";
public static final String PARAM_API_KEY = "api_key=";
public static final String PARAM_COUNTRY = "country=";
public static final String PARAM_FAVORITE = "favorite=";
public static final String PARAM_ID = "id=";
public static final String PARAM_LANGUAGE = "language=";
public static final String PARAM_INCLUDE_ALL_MOVIES = "include_all_movies=";
public static final String PARAM_MOVIE_WATCHLIST = "movie_watchlist=";
public static final String PARAM_PAGE = "page=";
public static final String PARAM_QUERY = "query=";
public static final String PARAM_SESSION = "session_id=";
public static final String PARAM_TOKEN = "request_token=";
public static final String PARAM_VALUE = "value=";
public static final String PARAM_YEAR = "year=";
public static final String PARAM_START_DATE = "start_date=";
public static final String PARAM_END_DATE = "end_date=";
private static final String APPEND_TO_RESPONSE = "append_to_response=";
//<editor-fold defaultstate="collapsed" desc="Constructor Methods">
/**
* Constructor for the simple API URL method without a sub-method
*
* @param apiKey
* @param method
*/
public ApiUrl(String apiKey, String method) {
this.apiKey = apiKey;
this.method = method;
this.submethod = DEFAULT_STRING;
}
/**
* Constructor for the API URL with a sub-method
*
* @param apiKey
* @param method
* @param submethod
*/
public ApiUrl(String apiKey, String method, String submethod) {
this.apiKey = apiKey;
this.method = method;
this.submethod = submethod;
}
//</editor-fold>
/**
* Build the URL from the pre-created arguments.
*
* @return
*/
public URL buildUrl() {
StringBuilder urlString = new StringBuilder(TMDB_API_BASE);
// Get the start of the URL
urlString.append(method);
// We have either a queury, or a direct request
if (arguments.containsKey(PARAM_QUERY)) {
// Append the suffix of the API URL
if (StringUtils.endsWith(urlString, "/") && submethod.startsWith("/")) {
urlString.deleteCharAt(urlString.length() - 1);
}
urlString.append(submethod);
// Append the key information
urlString.append(DELIMITER_FIRST).append(PARAM_API_KEY);
urlString.append(apiKey);
// Append the search term
urlString.append(DELIMITER_SUBSEQUENT);
urlString.append(PARAM_QUERY);
String query = arguments.get(PARAM_QUERY);
try {
urlString.append(URLEncoder.encode(query, "UTF-8"));
} catch (UnsupportedEncodingException ex) {
LOG.trace("Unable to encode query: '{}' trying raw.", query);
// If we can't encode it, try it raw
urlString.append(query);
}
// Remove the query from the arguments so it is not added later
arguments.remove(PARAM_QUERY);
} else {
// Append the ID if provided
if (arguments.containsKey(PARAM_ID)) {
urlString.append(arguments.get(PARAM_ID));
arguments.remove(PARAM_ID);
}
// Append the suffix of the API URL
if (StringUtils.endsWith(urlString, "/") && submethod.startsWith("/")) {
urlString.deleteCharAt(urlString.length() - 1);
}
urlString.append(submethod);
// Append the key information
urlString.append(DELIMITER_FIRST).append(PARAM_API_KEY);
urlString.append(apiKey);
}
for (Map.Entry<String, String> argEntry : arguments.entrySet()) {
urlString.append(DELIMITER_SUBSEQUENT).append(argEntry.getKey());
urlString.append(argEntry.getValue());
}
try {
LOG.trace("URL: {}", urlString.toString());
return new URL(urlString.toString());
} catch (MalformedURLException ex) {
LOG.warn("Failed to create URL {} - {}", urlString.toString(), ex.toString());
return null;
} finally {
arguments.clear();
}
}
/**
* Add arguments individually
*
* @param key
* @param value
*/
public void addArgument(String key, String value) {
arguments.put(key, value);
}
/**
* Add arguments individually
*
* @param key
* @param value
*/
public void addArgument(String key, int value) {
arguments.put(key, Integer.toString(value));
}
/**
* Add arguments individually
*
* @param key
* @param value
*/
public void addArgument(String key, boolean value) {
arguments.put(key, Boolean.toString(value));
}
/**
* Add arguments individually
*
* @param key
* @param value
*/
public void addArgument(String key, float value) {
arguments.put(key, Float.toString(value));
}
/**
* Clear the arguments
*/
public void clearArguments() {
arguments.clear();
}
/**
* Set the arguments directly
*
* @param args
*/
public void setArguments(Map<String, String> args) {
arguments.putAll(args);
}
/**
* Append any optional parameters to the URL
*
* @param appendToResponse
*/
public void appendToResponse(String[] appendToResponse) {
if (appendToResponse.length > 0) {
StringBuilder sb = new StringBuilder();
boolean first = Boolean.TRUE;
for (String append : appendToResponse) {
if (first) {
first = Boolean.FALSE;
} else {
sb.append(",");
}
sb.append(append);
}
addArgument(APPEND_TO_RESPONSE, sb.toString());
}
}
}
@@ -19,8 +19,6 @@
*/
package com.omertron.themoviedbapi.tools;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.omertron.themoviedbapi.MovieDbException;
import org.apache.commons.codec.binary.Base64;
import org.slf4j.Logger;
@@ -38,6 +36,7 @@ import java.util.List;
import java.util.Map;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.commons.lang3.StringUtils;
/**
* Web browser with simple cookies support
@@ -45,15 +44,17 @@ import java.util.regex.Pattern;
public final class WebBrowser {
private static final Logger LOG = LoggerFactory.getLogger(WebBrowser.class);
private static Map<String, String> browserProperties = new HashMap<String, String>();
private static Map<String, Map<String, String>> cookies = new HashMap<String, Map<String, String>>();
private static final Map<String, String> BROWSER_PROPERTIES = new HashMap<String, String>();
private static final Map<String, Map<String, String>> COOKIES = new HashMap<String, Map<String, String>>();
private static String proxyHost = null;
private static String proxyPort = null;
private static int proxyPort = 0;
private static String proxyUsername = null;
private static String proxyPassword = null;
private static String proxyEncodedPassword = null;
private static int webTimeoutConnect = 25000; // 25 second timeout
private static int webTimeoutRead = 90000; // 90 second timeout
// 25 second timeout
private static int webTimeoutConnect = 25000;
// 90 second timeout
private static int webTimeoutRead = 90000;
// Hide the constructor
protected WebBrowser() {
@@ -65,10 +66,10 @@ public final class WebBrowser {
* Populate the browser properties
*/
private static void populateBrowserProperties() {
if (browserProperties.isEmpty()) {
browserProperties.put("User-Agent", "Mozilla/5.25 Netscape/5.0 (Windows; I; Win95)");
browserProperties.put("Accept", "application/json");
browserProperties.put("Content-type", "application/json");
if (BROWSER_PROPERTIES.isEmpty()) {
BROWSER_PROPERTIES.put("User-Agent", "Mozilla/5.25 Netscape/5.0 (Windows; I; Win95)");
BROWSER_PROPERTIES.put("Accept", "application/json");
BROWSER_PROPERTIES.put("Content-type", "application/json");
}
}
@@ -101,11 +102,11 @@ public final class WebBrowser {
}
public static String request(URL url) throws MovieDbException {
return request(url, null);
return request(url, null, Boolean.FALSE);
}
public static String request(URL url, String jsonBody) throws MovieDbException {
return request(url, jsonBody, false);
return request(url, jsonBody, Boolean.FALSE);
}
public static String request(URL url, String jsonBody, boolean isDeleteRequest) throws MovieDbException {
@@ -129,7 +130,7 @@ public final class WebBrowser {
sendHeader(cnx);
if (jsonBody != null) {
if (StringUtils.isNotBlank(jsonBody)) {
cnx.setDoOutput(true);
wr = new OutputStreamWriter(cnx.getOutputStream());
wr.write(jsonBody);
@@ -180,7 +181,7 @@ public final class WebBrowser {
populateBrowserProperties();
// send browser properties
for (Map.Entry<String, String> browserProperty : browserProperties.entrySet()) {
for (Map.Entry<String, String> browserProperty : BROWSER_PROPERTIES.entrySet()) {
cnx.setRequestProperty(browserProperty.getKey(), browserProperty.getValue());
}
// send cookies
@@ -193,7 +194,7 @@ public final class WebBrowser {
private static String createCookieHeader(URLConnection cnx) {
String host = cnx.getURL().getHost();
StringBuilder cookiesHeader = new StringBuilder();
for (Map.Entry<String, Map<String, String>> domainCookies : cookies.entrySet()) {
for (Map.Entry<String, Map<String, String>> domainCookies : COOKIES.entrySet()) {
if (host.endsWith(domainCookies.getKey())) {
for (Map.Entry<String, String> cookie : domainCookies.getValue().entrySet()) {
cookiesHeader.append(cookie.getKey());
@@ -233,10 +234,10 @@ public final class WebBrowser {
// if domain isn't set take current host
cookieDomain = cnx.getURL().getHost();
}
Map<String, String> domainCookies = cookies.get(cookieDomain);
Map<String, String> domainCookies = COOKIES.get(cookieDomain);
if (domainCookies == null) {
domainCookies = new HashMap<String, String>();
cookies.put(cookieDomain, domainCookies);
COOKIES.put(cookieDomain, domainCookies);
}
// add or replace cookie
domainCookies.put(cookieName, cookieValue);
@@ -277,11 +278,11 @@ public final class WebBrowser {
WebBrowser.proxyHost = myProxyHost;
}
public static String getProxyPort() {
public static int getProxyPort() {
return proxyPort;
}
public static void setProxyPort(String myProxyPort) {
public static void setProxyPort(int myProxyPort) {
WebBrowser.proxyPort = myProxyPort;
}
@@ -321,15 +322,4 @@ public final class WebBrowser {
public static void setWebTimeoutRead(int 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);
}
}
}
@@ -19,23 +19,16 @@
*/
package com.omertron.themoviedbapi.wrapper;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.omertron.themoviedbapi.model.AbstractJsonMapping;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.EnumSet;
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 abstract class AbstractWrapper {
public abstract class AbstractWrapper extends AbstractJsonMapping implements Serializable {
private Logger log;
public AbstractWrapper(Class classToLog) {
this.log = LoggerFactory.getLogger(classToLog);
}
private static final long serialVersionUID = 1L;
/**
* Get a list of the enums passed
@@ -52,23 +45,4 @@ public abstract class AbstractWrapper {
return new ArrayList<E>(EnumSet.allOf(clz));
}
}
/**
* 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);
}
}
@@ -27,9 +27,6 @@ import com.fasterxml.jackson.annotation.JsonProperty;
* @author Stuart
*/
public class AbstractWrapperAll extends AbstractWrapperId implements IWrapperId, IWrapperPages, IWrapperDates {
/*
* Properties
*/
@JsonProperty("page")
private int page;
@@ -40,10 +37,6 @@ public class AbstractWrapperAll extends AbstractWrapperId implements IWrapperId,
@JsonProperty("dates")
private ResultDates dates = new ResultDates();
public AbstractWrapperAll(Class classToLog) {
super(classToLog);
}
@Override
public int getPage() {
return page;
@@ -1,50 +1,44 @@
/*
* 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.fasterxml.jackson.annotation.JsonProperty;
/**
* Base class for the wrappers
*
* @author Stuart
*/
public class AbstractWrapperId extends AbstractWrapper implements IWrapperId {
/*
* Properties
*/
@JsonProperty("id")
private int id;
public AbstractWrapperId(Class classToLog) {
super(classToLog);
}
@Override
public int getId() {
return id;
}
@Override
public void setId(int id) {
this.id = id;
}
}
/*
* 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.fasterxml.jackson.annotation.JsonProperty;
/**
* Base class for the wrappers
*
* @author Stuart
*/
public class AbstractWrapperId extends AbstractWrapper implements IWrapperId {
private static final long serialVersionUID = 1L;
@JsonProperty("id")
private int id;
@Override
public int getId() {
return id;
}
@Override
public void setId(int id) {
this.id = id;
}
}
@@ -19,7 +19,6 @@
*/
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;
@@ -21,21 +21,19 @@ package com.omertron.themoviedbapi.wrapper;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.omertron.themoviedbapi.model.AlternativeTitle;
import java.io.Serializable;
import java.util.List;
/**
*
* @author Stuart
*/
public class WrapperAlternativeTitles extends AbstractWrapperId {
public class WrapperAlternativeTitles extends AbstractWrapperId implements Serializable {
private static final long serialVersionUID = 1L;
@JsonProperty("titles")
private List<AlternativeTitle> titles;
public WrapperAlternativeTitles() {
super(WrapperAlternativeTitles.class);
}
public List<AlternativeTitle> getTitles() {
return titles;
}
@@ -15,7 +15,7 @@ public class WrapperChanges {
@JsonProperty("changes")
private List<ChangeKeyItem> changedItems = new ArrayList<ChangeKeyItem>();
private Map<String, Object> newItems = new HashMap<String, Object>();
private final Map<String, Object> newItems = new HashMap<String, Object>();
public List<ChangeKeyItem> getChangedItems() {
return changedItems;
@@ -32,10 +32,6 @@ public class WrapperCollection extends AbstractWrapperAll {
@JsonProperty("results")
private List<Collection> results;
public WrapperCollection() {
super(WrapperCollection.class);
}
public List<Collection> getResults() {
return results;
}
@@ -32,10 +32,6 @@ public class WrapperCompany extends AbstractWrapperAll {
@JsonProperty("results")
private List<Company> results;
public WrapperCompany() {
super(WrapperCompany.class);
}
public List<Company> getResults() {
return results;
}
@@ -32,10 +32,6 @@ public class WrapperCompanyMovies extends AbstractWrapperAll {
@JsonProperty("results")
private List<MovieDb> results;
public WrapperCompanyMovies() {
super(WrapperCompanyMovies.class);
}
public List<MovieDb> getResults() {
return results;
}
@@ -35,10 +35,6 @@ public class WrapperConfig extends AbstractWrapper {
@JsonProperty("change_keys")
private List<String> changeKeys = Collections.EMPTY_LIST;
public WrapperConfig() {
super(WrapperConfig.class);
}
public TmdbConfiguration getTmdbConfiguration() {
return tmdbConfiguration;
}
@@ -33,10 +33,6 @@ public class WrapperGenres extends AbstractWrapper {
@JsonProperty("genres")
private List<Genre> genres;
public WrapperGenres() {
super(WrapperGenres.class);
}
public List<Genre> getGenres() {
return genres;
}
@@ -22,6 +22,7 @@ package com.omertron.themoviedbapi.wrapper;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.omertron.themoviedbapi.model.Artwork;
import com.omertron.themoviedbapi.model.ArtworkType;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
@@ -31,8 +32,9 @@ import java.util.List;
*
* @author Stuart
*/
public class WrapperImages extends AbstractWrapperAll {
public class WrapperImages extends AbstractWrapperAll implements Serializable {
private static final long serialVersionUID = 1L;
@JsonProperty("backdrops")
private List<Artwork> backdrops = Collections.EMPTY_LIST;
@JsonProperty("posters")
@@ -40,10 +42,6 @@ public class WrapperImages extends AbstractWrapperAll {
@JsonProperty("profiles")
private List<Artwork> profiles = Collections.EMPTY_LIST;
public WrapperImages() {
super(WrapperImages.class);
}
public List<Artwork> getBackdrops() {
return backdrops;
}
@@ -73,6 +71,7 @@ public class WrapperImages extends AbstractWrapperAll {
*
* Leaving the parameters blank will return all types
*
* @param artworkList
* @return
*/
public List<Artwork> getAll(ArtworkType... artworkList) {
@@ -32,10 +32,6 @@ public class WrapperJobList extends AbstractWrapper {
@JsonProperty("jobs")
private List<JobDepartment> jobs;
public WrapperJobList() {
super(WrapperJobList.class);
}
public List<JobDepartment> getJobs() {
return jobs;
}
@@ -32,10 +32,6 @@ public class WrapperKeywordMovies extends AbstractWrapperAll {
@JsonProperty("results")
private List<KeywordMovie> results;
public WrapperKeywordMovies() {
super(WrapperKeywordMovies.class);
}
public List<KeywordMovie> getResults() {
return results;
}
@@ -32,10 +32,6 @@ public class WrapperKeywords extends AbstractWrapperAll {
@JsonProperty("results")
private List<Keyword> results;
public WrapperKeywords() {
super(WrapperKeywords.class);
}
public List<Keyword> getResults() {
return results;
}
@@ -21,21 +21,19 @@ package com.omertron.themoviedbapi.wrapper;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.omertron.themoviedbapi.model.MovieDb;
import java.io.Serializable;
import java.util.List;
/**
*
* @author stuart.boston
*/
public class WrapperMovie extends AbstractWrapperAll {
public class WrapperMovie extends AbstractWrapperAll implements Serializable {
private static final long serialVersionUID = 1L;
@JsonProperty("results")
private List<MovieDb> movies;
public WrapperMovie() {
super(WrapperMovie.class);
}
public List<MovieDb> getMovies() {
return movies;
}
@@ -23,6 +23,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import com.omertron.themoviedbapi.model.Person;
import com.omertron.themoviedbapi.model.PersonCast;
import com.omertron.themoviedbapi.model.PersonCrew;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
@@ -30,17 +31,14 @@ import java.util.List;
*
* @author Stuart
*/
public class WrapperMovieCasts extends AbstractWrapperId {
public class WrapperMovieCasts extends AbstractWrapperId implements Serializable {
private static final long serialVersionUID = 1L;
@JsonProperty("cast")
private List<PersonCast> cast;
@JsonProperty("crew")
private List<PersonCrew> crew;
public WrapperMovieCasts() {
super(WrapperMovieCasts.class);
}
public List<PersonCast> getCast() {
return cast;
}
@@ -0,0 +1,39 @@
/*
* 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 java.util.List;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.omertron.themoviedbapi.model.ChangedMovie;
public class WrapperMovieChanges extends AbstractWrapperAll {
@JsonProperty("results")
private List<ChangedMovie> results;
public List<ChangedMovie> getResults() {
return results;
}
public void setResults(List<ChangedMovie> results) {
this.results = results;
}
}
@@ -11,10 +11,6 @@ public class WrapperMovieDbList extends AbstractWrapperAll {
@JsonProperty("results")
private List<MovieDbList> lists;
public WrapperMovieDbList() {
super(WrapperMovieDbList.class);
}
public List<MovieDbList> getLists() {
return lists;
}
@@ -21,21 +21,19 @@ package com.omertron.themoviedbapi.wrapper;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.omertron.themoviedbapi.model.Keyword;
import java.io.Serializable;
import java.util.List;
/**
*
* @author Stuart
*/
public class WrapperMovieKeywords extends AbstractWrapperId {
public class WrapperMovieKeywords extends AbstractWrapperId implements Serializable {
private static final long serialVersionUID = 1L;
@JsonProperty("keywords")
private List<Keyword> keywords;
public WrapperMovieKeywords() {
super(WrapperMovieKeywords.class);
}
public List<Keyword> getKeywords() {
return keywords;
}
@@ -21,21 +21,19 @@ package com.omertron.themoviedbapi.wrapper;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.omertron.themoviedbapi.model.MovieList;
import java.io.Serializable;
import java.util.List;
/**
*
* @author Stuart
*/
public class WrapperMovieList extends AbstractWrapperAll {
public class WrapperMovieList extends AbstractWrapperAll implements Serializable {
private static final long serialVersionUID = 1L;
@JsonProperty("results")
private List<MovieList> movieList;
public WrapperMovieList() {
super(WrapperMovieList.class);
}
public List<MovieList> getMovieList() {
return movieList;
}
@@ -32,10 +32,6 @@ public class WrapperPerson extends AbstractWrapperAll {
@JsonProperty("results")
private List<Person> results;
public WrapperPerson() {
super(WrapperPerson.class);
}
public List<Person> getResults() {
return results;
}
@@ -36,10 +36,6 @@ public class WrapperPersonCredits extends AbstractWrapperAll {
@JsonProperty("crew")
private List<PersonCredit> crew;
public WrapperPersonCredits() {
super(WrapperMovieCasts.class);
}
public List<PersonCredit> getCast() {
return cast;
}
@@ -32,10 +32,6 @@ public class WrapperPersonList extends AbstractWrapperAll {
@JsonProperty("results")
private List<Person> personList;
public WrapperPersonList() {
super(WrapperPersonList.class);
}
public List<Person> getPersonList() {
return personList;
}
@@ -21,21 +21,19 @@ package com.omertron.themoviedbapi.wrapper;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.omertron.themoviedbapi.model.ReleaseInfo;
import java.io.Serializable;
import java.util.List;
/**
*
* @author Stuart
*/
public class WrapperReleaseInfo extends AbstractWrapperId {
public class WrapperReleaseInfo extends AbstractWrapperId implements Serializable {
private static final long serialVersionUID = 1L;
@JsonProperty("countries")
private List<ReleaseInfo> countries;
public WrapperReleaseInfo() {
super(WrapperReleaseInfo.class);
}
public List<ReleaseInfo> getCountries() {
return countries;
}
@@ -21,21 +21,19 @@ package com.omertron.themoviedbapi.wrapper;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.omertron.themoviedbapi.model.Reviews;
import java.io.Serializable;
import java.util.List;
/**
*
* @author stuart.boston
*/
public class WrapperReviews extends AbstractWrapperAll {
public class WrapperReviews extends AbstractWrapperAll implements Serializable {
private static final long serialVersionUID = 1L;
@JsonProperty("results")
private List<Reviews> reviews;
public WrapperReviews() {
super(WrapperReviews.class);
}
public List<Reviews> getReviews() {
return reviews;
}
@@ -21,6 +21,7 @@ package com.omertron.themoviedbapi.wrapper;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.omertron.themoviedbapi.model.Trailer;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
@@ -28,17 +29,14 @@ import java.util.List;
*
* @author Stuart
*/
public class WrapperTrailers extends AbstractWrapperId {
public class WrapperTrailers extends AbstractWrapperId implements Serializable {
private static final long serialVersionUID = 1L;
@JsonProperty("quicktime")
private List<Trailer> quicktime;
@JsonProperty("youtube")
private List<Trailer> youtube;
public WrapperTrailers() {
super(WrapperTrailers.class);
}
public List<Trailer> getQuicktime() {
return quicktime;
}
@@ -21,21 +21,19 @@ package com.omertron.themoviedbapi.wrapper;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.omertron.themoviedbapi.model.Translation;
import java.io.Serializable;
import java.util.List;
/**
*
* @author Stuart
*/
public class WrapperTranslations extends AbstractWrapperId {
public class WrapperTranslations extends AbstractWrapperId implements Serializable {
private static final long serialVersionUID = 1L;
@JsonProperty("translations")
private List<Translation> translations;
public WrapperTranslations() {
super(WrapperTranslations.class);
}
public void setTranslations(List<Translation> translations) {
this.translations = translations;
}
@@ -1,72 +1,72 @@
/*
* Copyright (c) 2004-2013 Stuart Boston
*
* This file is part of the FanartTV API.
*
* The FanartTV API is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* The FanartTV API is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the FanartTV API. If not, see <http://www.gnu.org/licenses/>.
*
*/
package com.omertron.themoviedbapi;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.logging.LogManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class TestLogger {
private static final Logger LOG = LoggerFactory.getLogger(TestLogger.class);
private static final String CRLF = "\n";
private TestLogger() {
throw new UnsupportedOperationException("Class can not be instantiated");
}
/**
* Configure the logger with a simple in-memory file for the required log level
*
* @param level The logging level required
* @return True if successful
*/
public static boolean Configure(String level) {
StringBuilder config = new StringBuilder("handlers = java.util.logging.ConsoleHandler\n");
config.append(".level = ").append(level).append(CRLF);
config.append("java.util.logging.ConsoleHandler.level = ").append(level).append(CRLF);
// Only works with Java 7 or later
config.append("java.util.logging.SimpleFormatter.format = [%1$tc %4$s] %2$s - %5$s %6$s%n").append(CRLF);
// Exclude http logging
config.append("sun.net.www.protocol.http.HttpURLConnection.level = OFF").append(CRLF);
InputStream ins = new ByteArrayInputStream(config.toString().getBytes());
try {
LogManager.getLogManager().readConfiguration(ins);
} catch (IOException e) {
LOG.warn("Failed to configure log manager due to an IO problem", e);
return Boolean.FALSE;
}
LOG.debug("Logger initialized to '{}' level", level);
return Boolean.TRUE;
}
/**
* Set the logging level to "ALL"
*
* @return True if successful
*/
public static boolean Configure() {
return Configure("ALL");
}
}
/*
* Copyright (c) 2004-2013 Stuart Boston
*
* This file is part of the FanartTV API.
*
* The FanartTV API is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* The FanartTV API is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the FanartTV API. If not, see <http://www.gnu.org/licenses/>.
*
*/
package com.omertron.themoviedbapi;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.logging.LogManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class TestLogger {
private static final Logger LOG = LoggerFactory.getLogger(TestLogger.class);
private static final String CRLF = "\n";
private TestLogger() {
throw new UnsupportedOperationException("Class can not be instantiated");
}
/**
* Configure the logger with a simple in-memory file for the required log level
*
* @param level The logging level required
* @return True if successful
*/
public static boolean Configure(String level) {
StringBuilder config = new StringBuilder("handlers = java.util.logging.ConsoleHandler\n");
config.append(".level = ").append(level).append(CRLF);
config.append("java.util.logging.ConsoleHandler.level = ").append(level).append(CRLF);
// Only works with Java 7 or later
config.append("java.util.logging.SimpleFormatter.format = [%1$tH:%1$tM:%1$tS %4$6s] %2$s - %5$s %6$s%n").append(CRLF);
// Exclude http logging
config.append("sun.net.www.protocol.http.HttpURLConnection.level = OFF").append(CRLF);
InputStream ins = new ByteArrayInputStream(config.toString().getBytes());
try {
LogManager.getLogManager().readConfiguration(ins);
} catch (IOException e) {
LOG.warn("Failed to configure log manager due to an IO problem", e);
return Boolean.FALSE;
}
LOG.debug("Logger initialized to '{}' level", level);
return Boolean.TRUE;
}
/**
* Set the logging level to "ALL"
*
* @return True if successful
*/
public static boolean Configure() {
return Configure("ALL");
}
}
@@ -19,19 +19,54 @@
*/
package com.omertron.themoviedbapi;
import com.omertron.themoviedbapi.model.*;
import com.omertron.themoviedbapi.results.TmdbResultsList;
import com.omertron.themoviedbapi.results.TmdbResultsMap;
import org.apache.commons.lang3.StringUtils;
import org.junit.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.io.IOException;
import java.util.List;
import java.util.Random;
import static org.junit.Assert.*;
import org.apache.commons.lang3.StringUtils;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Ignore;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.omertron.themoviedbapi.model.Account;
import com.omertron.themoviedbapi.model.AlternativeTitle;
import com.omertron.themoviedbapi.model.Artwork;
import com.omertron.themoviedbapi.model.ChangedItem;
import com.omertron.themoviedbapi.model.ChangedMovie;
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.StatusCode;
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.TmdbResultsMap;
/**
* Test cases for TheMovieDbApi API
@@ -87,7 +122,7 @@ public class TheMovieDbApiTest {
* Test of getConfiguration method, of class TheMovieDbApi.
*/
@Test
public void testConfiguration() throws IOException {
public void testConfiguration() {
LOG.info("Test Configuration");
TmdbConfiguration tmdbConfig = tmdb.getConfiguration();
@@ -146,6 +181,8 @@ public class TheMovieDbApiTest {
/**
* Test of searchMovie method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/
@Test
public void testSearchMovie() throws MovieDbException {
@@ -167,6 +204,8 @@ public class TheMovieDbApiTest {
/**
* Test of getMovieInfo method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/
@Test
public void testGetMovieInfo() throws MovieDbException {
@@ -177,6 +216,8 @@ public class TheMovieDbApiTest {
/**
* Test of getMovieAlternativeTitles method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/
@Test
public void testGetMovieAlternativeTitles() throws MovieDbException {
@@ -193,6 +234,8 @@ public class TheMovieDbApiTest {
/**
* Test of getMovieCasts method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/
@Test
public void testGetMovieCasts() throws MovieDbException {
@@ -220,6 +263,8 @@ public class TheMovieDbApiTest {
/**
* Test of getMovieImages method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/
@Test
public void testGetMovieImages() throws MovieDbException {
@@ -231,6 +276,8 @@ public class TheMovieDbApiTest {
/**
* Test of getMovieKeywords method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/
@Test
public void testGetMovieKeywords() throws MovieDbException {
@@ -241,6 +288,8 @@ public class TheMovieDbApiTest {
/**
* Test of getMovieReleaseInfo method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/
@Test
public void testGetMovieReleaseInfo() throws MovieDbException {
@@ -251,6 +300,8 @@ public class TheMovieDbApiTest {
/**
* Test of getMovieTrailers method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/
@Test
public void testGetMovieTrailers() throws MovieDbException {
@@ -261,6 +312,8 @@ public class TheMovieDbApiTest {
/**
* Test of getMovieTranslations method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/
@Test
public void testGetMovieTranslations() throws MovieDbException {
@@ -271,6 +324,8 @@ public class TheMovieDbApiTest {
/**
* Test of getCollectionInfo method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/
@Test
public void testGetCollectionInfo() throws MovieDbException {
@@ -295,6 +350,8 @@ public class TheMovieDbApiTest {
/**
* Test of getMovieInfoImdb method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/
@Test
public void testGetMovieInfoImdb() throws MovieDbException {
@@ -305,6 +362,7 @@ public class TheMovieDbApiTest {
/**
* Test of getApiKey method, of class TheMovieDbApi.
*
*/
@Test
public void testGetApiKey() {
@@ -313,6 +371,7 @@ public class TheMovieDbApiTest {
/**
* Test of getApiBase method, of class TheMovieDbApi.
*
*/
@Test
public void testGetApiBase() {
@@ -321,6 +380,7 @@ public class TheMovieDbApiTest {
/**
* Test of getConfiguration method, of class TheMovieDbApi.
*
*/
@Test
public void testGetConfiguration() {
@@ -329,6 +389,8 @@ public class TheMovieDbApiTest {
/**
* Test of searchPeople method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/
@Test
public void testSearchPeople() throws MovieDbException {
@@ -341,6 +403,8 @@ public class TheMovieDbApiTest {
/**
* Test of getPersonInfo method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/
@Test
public void testGetPersonInfo() throws MovieDbException {
@@ -351,6 +415,8 @@ public class TheMovieDbApiTest {
/**
* Test of getPersonCredits method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/
@Test
public void testGetPersonCredits() throws MovieDbException {
@@ -362,6 +428,8 @@ public class TheMovieDbApiTest {
/**
* Test of getPersonImages method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/
@Test
public void testGetPersonImages() throws MovieDbException {
@@ -373,6 +441,8 @@ public class TheMovieDbApiTest {
/**
* Test of getLatestMovie method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/
@Test
public void testGetLatestMovie() throws MovieDbException {
@@ -384,6 +454,7 @@ public class TheMovieDbApiTest {
/**
* Test of compareMovies method, of class TheMovieDbApi.
*
*/
@Test
public void testCompareMovies() {
@@ -392,6 +463,7 @@ public class TheMovieDbApiTest {
/**
* Test of setProxy method, of class TheMovieDbApi.
*
*/
@Test
public void testSetProxy() {
@@ -400,6 +472,7 @@ public class TheMovieDbApiTest {
/**
* Test of setTimeout method, of class TheMovieDbApi.
*
*/
@Test
public void testSetTimeout() {
@@ -408,6 +481,8 @@ public class TheMovieDbApiTest {
/**
* Test of getNowPlayingMovies method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/
@Test
public void testGetNowPlayingMovies() throws MovieDbException {
@@ -418,6 +493,8 @@ public class TheMovieDbApiTest {
/**
* Test of getPopularMovieList method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/
@Test
public void testGetPopularMovieList() throws MovieDbException {
@@ -428,6 +505,8 @@ public class TheMovieDbApiTest {
/**
* Test of getTopRatedMovies method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/
@Test
public void testGetTopRatedMovies() throws MovieDbException {
@@ -438,6 +517,8 @@ public class TheMovieDbApiTest {
/**
* Test of getCompanyInfo method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/
@Test
public void testGetCompanyInfo() throws MovieDbException {
@@ -449,6 +530,8 @@ public class TheMovieDbApiTest {
/**
* Test of getCompanyMovies method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/
@Test
public void testGetCompanyMovies() throws MovieDbException {
@@ -459,6 +542,8 @@ public class TheMovieDbApiTest {
/**
* Test of searchCompanies method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/
@Test
public void testSearchCompanies() throws MovieDbException {
@@ -469,6 +554,8 @@ public class TheMovieDbApiTest {
/**
* Test of getSimilarMovies method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/
@Test
public void testGetSimilarMovies() throws MovieDbException {
@@ -479,6 +566,8 @@ public class TheMovieDbApiTest {
/**
* Test of getGenreList method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/
@Test
public void testGetGenreList() throws MovieDbException {
@@ -489,6 +578,8 @@ public class TheMovieDbApiTest {
/**
* Test of getGenreMovies method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/
@Test
public void testGetGenreMovies() throws MovieDbException {
@@ -499,6 +590,8 @@ public class TheMovieDbApiTest {
/**
* Test of getUpcoming method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/
@Test
public void testGetUpcoming() throws Exception {
@@ -509,6 +602,8 @@ public class TheMovieDbApiTest {
/**
* Test of getCollectionImages method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/
@Test
public void testGetCollectionImages() throws Exception {
@@ -519,6 +614,8 @@ public class TheMovieDbApiTest {
/**
* Test of getAuthorisationToken method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/
@Test
public void testGetAuthorisationToken() throws Exception {
@@ -533,6 +630,8 @@ public class TheMovieDbApiTest {
* Test of getSessionToken method, of class TheMovieDbApi.
*
* TODO: Cannot be tested without a HTTP authorisation: http://help.themoviedb.org/kb/api/user-authentication
*
* @throws MovieDbException
*/
@Ignore("Session required")
public void testGetSessionToken() throws Exception {
@@ -550,6 +649,8 @@ public class TheMovieDbApiTest {
/**
* Test of getGuestSessionToken method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/
@Ignore("Not ready yet")
public void testGetGuestSessionToken() throws Exception {
@@ -571,6 +672,8 @@ public class TheMovieDbApiTest {
* Test of getMovieChanges method,of class TheMovieDbApi
*
* TODO: Do not test this until it is fixed
*
* @throws MovieDbException
*/
@Ignore("Do not test this until it is fixed")
public void testGetMovieChanges() throws Exception {
@@ -601,6 +704,8 @@ public class TheMovieDbApiTest {
/**
* Test of searchCollection method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/
@Test
public void testSearchCollection() throws Exception {
@@ -614,6 +719,8 @@ public class TheMovieDbApiTest {
/**
* Test of searchList method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/
@Test
public void testSearchList() throws Exception {
@@ -627,6 +734,8 @@ public class TheMovieDbApiTest {
/**
* Test of searchKeyword method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/
@Test
public void testSearchKeyword() throws Exception {
@@ -642,6 +751,8 @@ public class TheMovieDbApiTest {
* Test of postMovieRating method, of class TheMovieDbApi.
*
* TODO: Cannot be tested without a HTTP authorisation: http://help.themoviedb.org/kb/api/user-authentication
*
* @throws MovieDbException
*/
@Ignore("Session required")
public void testMovieRating() throws Exception {
@@ -655,7 +766,6 @@ public class TheMovieDbApiTest {
assertTrue(wasPosted);
// get all rated movies
List<MovieDb> ratedMovies = tmdb.getRatedMovies(SESSION_ID_APITESTS, ACCOUNT_ID_APITESTS);
assertTrue(ratedMovies.size() > 0);
@@ -699,6 +809,7 @@ public class TheMovieDbApiTest {
/**
* Test of getPersonChanges method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/
@Ignore("Not ready yet")
public void testGetPersonChanges() throws Exception {
@@ -710,6 +821,8 @@ public class TheMovieDbApiTest {
/**
* Test of getList method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/
@Test
public void testGetList() throws Exception {
@@ -721,6 +834,8 @@ public class TheMovieDbApiTest {
/**
* Test of getKeyword method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/
@Test
public void testGetKeyword() throws Exception {
@@ -731,6 +846,8 @@ public class TheMovieDbApiTest {
/**
* Test of getKeywordMovies method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/
@Test
public void testGetKeywordMovies() throws Exception {
@@ -742,6 +859,8 @@ public class TheMovieDbApiTest {
/**
* Test of getReviews method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/
@Test
public void testGetReviews() throws Exception {
@@ -754,6 +873,7 @@ public class TheMovieDbApiTest {
/**
* Test of compareMovies method, of class TheMovieDbApi.
*
*/
@Ignore("Not required")
public void testCompareMovies_3args() {
@@ -761,6 +881,7 @@ public class TheMovieDbApiTest {
/**
* Test of compareMovies method, of class TheMovieDbApi.
*
*/
@Ignore("Not required")
public void testCompareMovies_4args() {
@@ -768,13 +889,16 @@ public class TheMovieDbApiTest {
/**
* Test of getPersonPopular method, of class TheMovieDbApi.
*
*/
@Ignore("Not required")
public void testGetPersonPopular_0args() throws Exception {
public void testGetPersonPopular_0args() {
}
/**
* Test of getPersonPopular method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/
@Test
public void testGetPersonPopular_int() throws Exception {
@@ -786,6 +910,8 @@ public class TheMovieDbApiTest {
/**
* Test of getGenreMovies method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/
@Ignore("Not required")
public void testGetGenreMovies_3args() throws Exception {
@@ -793,6 +919,8 @@ public class TheMovieDbApiTest {
/**
* Test of getGenreMovies method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/
@Ignore("Not required")
public void testGetGenreMovies_4args() throws Exception {
@@ -800,20 +928,23 @@ public class TheMovieDbApiTest {
/**
* Test of getMovieChangesList method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/
@Ignore("Not ready yet")
@Test
public void testGetMovieChangesList() throws Exception {
LOG.info("getMovieChangesList");
int page = 0;
String startDate = "";
String endDate = "";
tmdb.getMovieChangesList(page, startDate, endDate);
// TODO review the generated test code and remove the default call to fail.
fail("The test case is a prototype.");
TmdbResultsList<ChangedMovie> result = tmdb.getMovieChangesList(page, startDate, endDate);
assertFalse("No movie changes.", result.getResults().isEmpty());
}
/**
* Test of getPersonChangesList method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/
@Ignore("Not ready yet")
public void testGetPersonChangesList() throws Exception {
@@ -828,6 +959,8 @@ public class TheMovieDbApiTest {
/**
* Test of getJobs method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/
@Test
public void testGetJobs() throws Exception {
@@ -838,6 +971,8 @@ public class TheMovieDbApiTest {
/**
* Test of getDiscover method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/
@Ignore("Not required")
public void testGetDiscover_14args() throws Exception {
@@ -845,6 +980,8 @@ public class TheMovieDbApiTest {
/**
* Test of getDiscover method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/
@Test
public void testGetDiscover_Discover() throws Exception {