40 Commits

Author SHA1 Message Date
Omertron cbc2121a87 [maven-release-plugin] prepare release themoviedbapi-4.1 2016-01-08 10:49:54 +00:00
Stuart Boston d1e1454134 Catch connection issues
Fixes #28
2015-11-08 19:42:53 +00:00
Stuart Boston 80414b7c2a Update main API 2015-11-08 19:06:24 +00:00
Stuart Boston 3bfbc1c0a7 Revert version of surefire
v2.19 does not allow individual tests to be run
2015-11-08 19:04:59 +00:00
Stuart Boston 463032bc05 Updated TV methods
Changed some methods for TVInfo
2015-11-08 19:04:15 +00:00
Stuart Boston c04f330d54 Add setter for genre ids
Used in the similar TV ATR
2015-11-08 16:43:46 +00:00
Stuart Boston e95b76c44a Replace tabs with spaces 2015-11-05 20:43:56 +00:00
Stuart Boston d8e56616e8 Update api-common version 2015-11-05 20:33:38 +00:00
Stuart Boston a47c55ee7e Update POM versions 2015-11-04 22:04:13 +00:00
Stuart Boston 4134594de5 Revert "Add more information to CollectionInfo"
This reverts commit b5b84cc962.
2015-08-29 21:23:08 +01:00
Stuart Boston 64ca72c182 Update POM versions 2015-08-25 20:53:38 +01:00
Stuart Boston d21bf07f1d Check for null AppendToResponse
Fix #26
2015-08-25 15:06:39 +01:00
Stuart Boston b5b84cc962 Add more information to CollectionInfo 2015-08-25 14:47:15 +01:00
Stuart Boston 2837424c09 Fix long conversion issue 2015-06-01 15:59:26 +01:00
Stuart Boston c8310935aa More diamond interfaces 2015-06-01 12:53:48 +01:00
Stuart Boston 50171a7da5 Remove unused method 2015-06-01 11:52:46 +01:00
Stuart Boston f512fc0754 Sonar fixes 2015-06-01 11:51:27 +01:00
Stuart Boston 06da84c2ac Use Diamond interface 2015-06-01 11:38:36 +01:00
Stuart Boston c3569f0140 Revert "Use diamond interface"
This reverts commit 4f9d74c9f7.
2015-06-01 11:38:11 +01:00
Stuart Boston 4f9d74c9f7 Use diamond interface 2015-06-01 11:37:54 +01:00
Stuart Boston 0aab56a044 Code tidy up 2015-05-31 17:18:28 +01:00
Stuart Boston 87f973955e Combined Credits Fix
Swap combined credits for tv & movie credits
2015-05-31 17:16:57 +01:00
Stuart Boston 64e88fa9f3 Added ID to ListItemStatus 2015-05-30 19:10:09 +01:00
Stuart Boston fb0e14cd21 Updated Tests 2015-05-30 19:09:53 +01:00
Stuart Boston 8451a4630b Serializable account 2015-05-30 19:09:36 +01:00
Stuart Boston e00d9357e2 Add check for rate limit
Delay and retry if code 429 encountered
2015-05-30 19:01:17 +01:00
Stuart Boston 212143b18d Update model with missing fields 2015-05-30 16:34:03 +01:00
Stuart Boston c9f85bab6d Remove gitter chat 2015-05-26 22:05:26 +01:00
Stuart Boston 4ec54425f3 Update badges and build status 2015-05-26 22:00:15 +01:00
Stuart Boston 00b538efb1 Updated People Test 2015-05-12 11:19:57 +01:00
Stuart Boston b16d452114 Correct return types for people methods 2015-04-27 14:24:52 +01:00
Stuart Boston a83c75070d Merge pull request #24 from gitter-badger/gitter-badge
Add a Gitter chat badge to README.md
2015-04-17 15:09:05 +01:00
The Gitter Badger 178b49c413 Added Gitter badge 2015-04-17 14:08:25 +00:00
Stuart Boston 55601a0698 Add commons-lang3 dependency 2015-04-16 15:02:56 +01:00
Stuart Boston a874297106 Use diamond interface 2015-04-09 21:42:43 +01:00
Stuart Boston eff654fd61 Update build procedure 2015-04-08 16:02:02 +01:00
Stuart Boston 63afef71a4 Update dependancy versions 2015-04-08 09:54:01 +01:00
Stuart Boston 1b180f9e28 Set source version to 1.7 2015-03-28 10:48:56 +00:00
Stuart Boston cfc215cd74 Fix AppendToResponseBuilder 2015-03-27 11:36:03 +00:00
Omertron 5fefa68352 [maven-release-plugin] prepare for next development iteration 2015-03-17 12:40:10 +00:00
104 changed files with 686 additions and 489 deletions
+5 -5
View File
@@ -10,13 +10,13 @@
*.dbproj merge=union
# Standard to msysgit
*.doc diff=astextplain
*.DOC diff=astextplain
*.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
*.PDF diff=astextplain
*.rtf diff=astextplain
*.RTF diff=astextplain
+2 -1
View File
@@ -8,5 +8,6 @@ import java.lang.annotation.Target;
@Target({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER})
@Retention(RetentionPolicy.RUNTIME)
public @interface JsonProperty {
String value() default "";
String value() default "";
}
+1 -1
View File
@@ -8,5 +8,5 @@ import java.lang.annotation.Target;
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
public @interface JsonRootName {
String value() default "";
String value() default "";
}
+51 -54
View File
@@ -11,59 +11,56 @@ 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);
}
}
/**
* 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);
}
}
@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);
}
}
}
}
+2 -5
View File
@@ -5,13 +5,10 @@ Author: Stuart Boston (Omertron AT Gmail DOT com)
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/)
Originally written for use by YetAnotherMovieJukebox ([YAMJv2](https://github.com/YAMJ/yamj-v2) & [YAMJv3](https://github.com/YAMJ/yamj-v3)), but anyone can feel free to use it for other projects as well.
But anyone can use it for other projects as well.
[![Build Status](http://jenkins.omertron.com/job/API-TheMovieDb/badge/icon)](http://jenkins.omertron.com/job/API-TheMovieDb)
[![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
+209 -205
View File
@@ -13,7 +13,7 @@
<groupId>com.omertron</groupId>
<artifactId>themoviedbapi</artifactId>
<version>4.0</version>
<version>4.1</version>
<packaging>jar</packaging>
<name>API-The MovieDB</name>
@@ -71,8 +71,12 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<distribution.format>zip</distribution.format>
<version.jackson>2.5.1</version.jackson>
<version.slf4j>1.7.10</version.slf4j>
<version.jackson>2.6.3</version.jackson>
<version.slf4j>1.7.12</version.slf4j>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
<timestamp>${maven.build.timestamp}</timestamp>
<maven.build.timestamp.format>yyyy-MM-dd-HHmm</maven.build.timestamp.format>
</properties>
<dependencies>
@@ -115,9 +119,14 @@
<dependency>
<groupId>org.yamj</groupId>
<artifactId>api-common</artifactId>
<version>1.4</version>
<version>2.0</version>
</dependency>
<!-- Apache Utils -->
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.4</version>
</dependency>
<dependency>
<groupId>commons-io</groupId>
<artifactId>commons-io</artifactId>
@@ -126,207 +135,6 @@
</dependency>
</dependencies>
<build>
<finalName>${project.artifactId}-${project.version}-${buildNumber}</finalName>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>buildnumber-maven-plugin</artifactId>
<version>1.3</version>
<configuration>
<shortRevisionLength>10</shortRevisionLength>
<doCheck>false</doCheck>
<doUpdate>false</doUpdate>
<timestampFormat>{0,date,yyyy-MM-dd HH:mm:ss}</timestampFormat>
</configuration>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>create</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.2</version>
<configuration>
<failOnError>true</failOnError>
<verbose>true</verbose>
<!-- excludes><exclude>**/*</exclude></excludes -->
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.5</version>
<configuration>
<archive>
<manifestEntries>
<Specification-Title>${project.name}</Specification-Title>
<Specification-Version>${project.version}</Specification-Version>
<Implementation-Version>${buildNumber}</Implementation-Version>
<Implementation-Title>${timestamp}</Implementation-Title>
</manifestEntries>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18</version>
<configuration>
<!-- To skip tests by default -->
<skipTests>${skipTests}</skipTests>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>create-version-txt</id>
<phase>generate-resources</phase>
<configuration>
<target>
<property name="version_file" value="${project.build.directory}/version.txt" />
<property name="header_line" value="The MovieDb API${line.separator}" />
<property name="build_date_line" value="Build Date: ${timestamp}${line.separator}" />
<property name="version_line" value="Version: ${project.version}${line.separator}" />
<property name="buildnumber_line" value="Git-SHA: ${buildNumber}${line.separator}" />
<echo>Writing version file: ${version_file}</echo>
<echo file="${version_file}" append="false">${header_line}</echo>
<echo file="${version_file}" append="true">${build_date_line}</echo>
<echo file="${version_file}" append="true">${version_line}</echo>
<echo file="${version_file}" append="true">${buildnumber_line}</echo>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.5.1</version>
<executions>
<execution>
<id>distro-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptors>
<descriptor>src/main/resources/bin.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
<version>2.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.4</version>
<configuration>
<reportPlugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>2.2</version>
<reports>
<report>index</report>
<report>scm</report>
<report>issue-tracking</report>
<report>help</report>
<report>dependency-convergence</report>
<report>summary</report>
<report>dependency-management</report>
<report>dependencies</report>
<report>license</report>
<report>modules</report>
</reports>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9</version>
</plugin>
</reportPlugins>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<version>2.6.1</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.5</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.7</version>
</plugin>
</plugins>
<extensions>
<extension>
<groupId>org.apache.maven.scm</groupId>
<artifactId>maven-scm-provider-gitexe</artifactId>
<version>1.8.1</version>
</extension>
<extension>
<groupId>org.apache.maven.scm</groupId>
<artifactId>maven-scm-manager-plexus</artifactId>
<version>1.8.1</version>
</extension>
<extension>
<groupId>org.kathrynhuxtable.maven.wagon</groupId>
<artifactId>wagon-gitsite</artifactId>
<version>0.3.1</version>
</extension>
</extensions>
</build>
<profiles>
<profile>
<id>release-sign-artifacts</id>
@@ -355,4 +163,200 @@
</profile>
</profiles>
<build>
<finalName>${project.artifactId}-${project.version}-${timestamp}-${git.commit.id.abbrev}</finalName>
<resources>
<resource>
<directory>src/main/resources/</directory>
<filtering>true</filtering>
<includes>
<include>version.txt</include>
</includes>
</resource>
</resources>
<pluginManagement>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.6</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<version>3.0.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.3</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.6</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.6</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.7</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.4</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.18.1</version>
</plugin>
<plugin>
<groupId>pl.project13.maven</groupId>
<artifactId>git-commit-id-plugin</artifactId>
<version>2.2.0</version>
</plugin>
</plugins>
</pluginManagement>
<plugins>
<plugin>
<groupId>pl.project13.maven</groupId>
<artifactId>git-commit-id-plugin</artifactId>
<executions>
<execution>
<phase>generate-resources</phase>
<goals>
<goal>revision</goal>
</goals>
</execution>
</executions>
<configuration>
<dotGitDirectory>${project.basedir}/.git</dotGitDirectory>
<dateFormat>yyyy-MM-dd HH:mm:ss z</dateFormat>
<abbrevLength>7</abbrevLength>
<injectAllReactorProjects>true</injectAllReactorProjects>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<configuration>
<archive>
<manifestEntries>
<Specification-Title>${project.name}</Specification-Title>
<Specification-Version>${project.version}</Specification-Version>
<Implementation-Version>${buildNumber}</Implementation-Version>
<Implementation-Title>${timestamp}</Implementation-Title>
</manifestEntries>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<!-- To skip tests by default -->
<skipTests>${skipTests}</skipTests>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<executions>
<execution>
<id>distro-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptors>
<descriptor>src/main/resources/bin.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<failOnError>true</failOnError>
<verbose>true</verbose>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<configuration>
<reportPlugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<reports>
<report>index</report>
<report>scm</report>
<report>issue-tracking</report>
<report>help</report>
<report>dependency-convergence</report>
<report>summary</report>
<report>dependency-management</report>
<report>dependencies</report>
<report>license</report>
<report>modules</report>
</reports>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
</plugin>
</reportPlugins>
</configuration>
</plugin>
</plugins>
<extensions>
<extension>
<groupId>org.apache.maven.scm</groupId>
<artifactId>maven-scm-provider-gitexe</artifactId>
<version>1.9.4</version>
</extension>
<extension>
<groupId>org.apache.maven.scm</groupId>
<artifactId>maven-scm-manager-plexus</artifactId>
<version>1.9.4</version>
</extension>
<extension>
<groupId>org.kathrynhuxtable.maven.wagon</groupId>
<artifactId>wagon-gitsite</artifactId>
<version>0.3.1</version>
</extension>
</extensions>
</build>
</project>
@@ -28,7 +28,7 @@ import com.omertron.themoviedbapi.interfaces.AppendToResponseMethod;
*/
public class AppendToResponseBuilder {
private StringBuilder response;
private final StringBuilder response;
/**
* Construct the builder with the first method
@@ -36,7 +36,7 @@ public class AppendToResponseBuilder {
* @param method
*/
public AppendToResponseBuilder(AppendToResponseMethod method) {
response.append(method.getPropertyString());
response = new StringBuilder(method.getPropertyString());
}
/**
@@ -60,6 +60,9 @@ import com.omertron.themoviedbapi.model.collection.CollectionInfo;
import com.omertron.themoviedbapi.model.company.Company;
import com.omertron.themoviedbapi.model.config.Configuration;
import com.omertron.themoviedbapi.model.config.JobDepartment;
import com.omertron.themoviedbapi.model.credits.CreditBasic;
import com.omertron.themoviedbapi.model.credits.CreditMovieBasic;
import com.omertron.themoviedbapi.model.credits.CreditTVBasic;
import com.omertron.themoviedbapi.model.discover.Discover;
import com.omertron.themoviedbapi.model.keyword.Keyword;
import com.omertron.themoviedbapi.model.list.ListItem;
@@ -1162,7 +1165,7 @@ public class TheMovieDbApi {
* @return
* @throws MovieDbException
*/
public PersonCreditList getPersonMovieCredits(int personId, String language) throws MovieDbException {
public PersonCreditList<CreditMovieBasic> getPersonMovieCredits(int personId, String language) throws MovieDbException {
return tmdbPeople.getPersonMovieCredits(personId, language);
}
@@ -1180,7 +1183,7 @@ public class TheMovieDbApi {
* @return
* @throws MovieDbException
*/
public PersonCreditList getPersonTVCredits(int personId, String language) throws MovieDbException {
public PersonCreditList<CreditTVBasic> getPersonTVCredits(int personId, String language) throws MovieDbException {
return tmdbPeople.getPersonTVCredits(personId, language);
}
@@ -1198,7 +1201,7 @@ public class TheMovieDbApi {
* @return
* @throws MovieDbException
*/
public PersonCreditList getPersonCombinedCredits(int personId, String language) throws MovieDbException {
public PersonCreditList<CreditBasic> getPersonCombinedCredits(int personId, String language) throws MovieDbException {
return tmdbPeople.getPersonCombinedCredits(personId, language);
}
@@ -1619,7 +1622,7 @@ public class TheMovieDbApi {
* @return
* @throws com.omertron.themoviedbapi.MovieDbException
*/
public ResultList<TVBasic> getTVOnTheAir(Integer page, String language) throws MovieDbException {
public ResultList<TVInfo> getTVOnTheAir(Integer page, String language) throws MovieDbException {
return tmdbTv.getTVOnTheAir(page, language);
}
@@ -1634,7 +1637,7 @@ public class TheMovieDbApi {
* @return
* @throws com.omertron.themoviedbapi.MovieDbException
*/
public ResultList<TVBasic> getTVAiringToday(Integer page, String language, String timezone) throws MovieDbException {
public ResultList<TVInfo> getTVAiringToday(Integer page, String language, String timezone) throws MovieDbException {
return tmdbTv.getTVAiringToday(page, language, timezone);
}
@@ -1651,7 +1654,7 @@ public class TheMovieDbApi {
* @return
* @throws com.omertron.themoviedbapi.MovieDbException
*/
public ResultList<TVBasic> getTVTopRated(Integer page, String language) throws MovieDbException {
public ResultList<TVInfo> getTVTopRated(Integer page, String language) throws MovieDbException {
return tmdbTv.getTVTopRated(page, language);
}
@@ -1663,7 +1666,7 @@ public class TheMovieDbApi {
* @return
* @throws com.omertron.themoviedbapi.MovieDbException
*/
public ResultList<TVBasic> getTVPopular(Integer page, String language) throws MovieDbException {
public ResultList<TVInfo> getTVPopular(Integer page, String language) throws MovieDbException {
return tmdbTv.getTVPopular(page, language);
}
//</editor-fold>
@@ -67,7 +67,7 @@ public class AbstractMethod {
protected final HttpTools httpTools;
// Jackson JSON configuration
protected static final ObjectMapper MAPPER = new ObjectMapper();
private static final Map<Class, TypeReference> TYPE_REFS = new HashMap<Class, TypeReference>();
private static final Map<Class, TypeReference> TYPE_REFS = new HashMap<>();
static {
TYPE_REFS.put(MovieBasic.class, new TypeReference<WrapperGenericList<MovieBasic>>() {
@@ -186,7 +186,7 @@ public class AbstractMethod {
try {
WrapperChanges wrapper = MAPPER.readValue(webpage, WrapperChanges.class);
ResultList<ChangeKeyItem> results = new ResultList<ChangeKeyItem>(wrapper.getChangedItems());
ResultList<ChangeKeyItem> results = new ResultList<>(wrapper.getChangedItems());
wrapper.setResultProperties(results);
return results;
} catch (IOException ex) {
@@ -65,7 +65,7 @@ public class TmdbCertifications extends AbstractMethod {
JsonNode node = MAPPER.readTree(webpage);
Map<String, List<Certification>> results = MAPPER.readValue(node.elements().next().traverse(), new TypeReference<Map<String, List<Certification>>>() {
});
return new ResultsMap<String, List<Certification>>(results);
return new ResultsMap<>(results);
} catch (IOException ex) {
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get movie certifications", url, ex);
}
@@ -85,7 +85,7 @@ public class TmdbCertifications extends AbstractMethod {
JsonNode node = MAPPER.readTree(webpage);
Map<String, List<Certification>> results = MAPPER.readValue(node.elements().next().traverse(), new TypeReference<Map<String, List<Certification>>>() {
});
return new ResultsMap<String, List<Certification>>(results);
return new ResultsMap<>(results);
} catch (IOException ex) {
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get TV certifications", url, ex);
}
@@ -97,7 +97,7 @@ public class TmdbCollections extends AbstractMethod {
try {
WrapperImages wrapper = MAPPER.readValue(webpage, WrapperImages.class);
ResultList<Artwork> results = new ResultList<Artwork>(wrapper.getAll(ArtworkType.POSTER, ArtworkType.BACKDROP));
ResultList<Artwork> results = new ResultList<>(wrapper.getAll(ArtworkType.POSTER, ArtworkType.BACKDROP));
wrapper.setResultProperties(results);
return results;
} catch (IOException ex) {
@@ -95,7 +95,7 @@ public class TmdbConfiguration extends AbstractMethod {
try {
WrapperJobList wrapper = MAPPER.readValue(webpage, WrapperJobList.class);
ResultList<JobDepartment> results = new ResultList<JobDepartment>(wrapper.getJobs());
ResultList<JobDepartment> results = new ResultList<>(wrapper.getJobs());
wrapper.setResultProperties(results);
return results;
} catch (IOException ex) {
@@ -121,7 +121,7 @@ public class TmdbConfiguration extends AbstractMethod {
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get timezone list", url, ex);
}
ResultsMap<String, List<String>> timezones = new ResultsMap<String, List<String>>();
ResultsMap<String, List<String>> timezones = new ResultsMap<>();
for (Map<String, List<String>> tzMap : tzList) {
for (Map.Entry<String, List<String>> x : tzMap.entrySet()) {
@@ -28,7 +28,6 @@ import com.omertron.themoviedbapi.tools.Param;
import com.omertron.themoviedbapi.tools.TmdbParameters;
import java.io.IOException;
import java.net.URL;
import org.slf4j.LoggerFactory;
import org.yamj.api.common.exception.ApiExceptionType;
/**
@@ -78,7 +77,6 @@ public class TmdbCredits extends AbstractMethod {
try {
return MAPPER.readValue(webpage, CreditInfo.class);
} catch (IOException ex) {
LoggerFactory.getLogger("test").info("{}",ex);
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get credit info", url, ex);
}
}
@@ -42,7 +42,6 @@ import com.omertron.themoviedbapi.results.WrapperImages;
import com.omertron.themoviedbapi.results.WrapperVideos;
import java.io.IOException;
import java.net.URL;
import org.slf4j.LoggerFactory;
import org.yamj.api.common.exception.ApiExceptionType;
/**
@@ -65,7 +64,8 @@ public class TmdbEpisodes extends AbstractMethod {
}
/**
* Get the primary information about a TV episode by combination of a season and episode number.
* Get the primary information about a TV episode by combination of a season
* and episode number.
*
* @param tvID
* @param seasonNumber
@@ -89,7 +89,6 @@ public class TmdbEpisodes extends AbstractMethod {
try {
return MAPPER.readValue(webpage, TVEpisodeInfo.class);
} catch (IOException ex) {
LoggerFactory.getLogger("test").warn("{}", ex);
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get TV Episode Info", url, ex);
}
}
@@ -108,7 +107,8 @@ public class TmdbEpisodes extends AbstractMethod {
}
/**
* This method lets users get the status of whether or not the TV episode has been rated.
* This method lets users get the status of whether or not the TV episode
* has been rated.
*
* A valid session id is required.
*
@@ -161,7 +161,8 @@ public class TmdbEpisodes extends AbstractMethod {
}
/**
* Get the external ids for a TV episode by comabination of a season and episode number.
* Get the external ids for a TV episode by comabination of a season and
* episode number.
*
* @param tvID
* @param seasonNumber
@@ -188,7 +189,8 @@ public class TmdbEpisodes extends AbstractMethod {
}
/**
* Get the images (episode stills) for a TV episode by combination of a season and episode number.
* Get the images (episode stills) for a TV episode by combination of a
* season and episode number.
*
* @param tvID
* @param seasonNumber
@@ -207,7 +209,7 @@ public class TmdbEpisodes extends AbstractMethod {
try {
WrapperImages wrapper = MAPPER.readValue(webpage, WrapperImages.class);
ResultList<Artwork> results = new ResultList<Artwork>(wrapper.getAll());
ResultList<Artwork> results = new ResultList<>(wrapper.getAll());
wrapper.setResultProperties(results);
return results;
} catch (IOException ex) {
@@ -216,7 +218,8 @@ public class TmdbEpisodes extends AbstractMethod {
}
/**
* This method lets users rate a TV episode. A valid session id or guest session id is required.
* This method lets users rate a TV episode. A valid session id or guest
* session id is required.
*
* @param tvID
* @param seasonNumber
@@ -253,7 +256,8 @@ public class TmdbEpisodes extends AbstractMethod {
}
/**
* Get the videos that have been added to a TV episode (teasers, clips, etc...)
* Get the videos that have been added to a TV episode (teasers, clips,
* etc...)
*
* @param tvID
* @param seasonNumber
@@ -274,7 +278,7 @@ public class TmdbEpisodes extends AbstractMethod {
try {
WrapperVideos wrapper = MAPPER.readValue(webpage, WrapperVideos.class);
ResultList<Video> results = new ResultList<Video>(wrapper.getVideos());
ResultList<Video> results = new ResultList<>(wrapper.getVideos());
wrapper.setResultProperties(results);
return results;
} catch (IOException ex) {
@@ -91,7 +91,7 @@ public class TmdbGenres extends AbstractMethod {
try {
WrapperGenres wrapper = MAPPER.readValue(webpage, WrapperGenres.class);
ResultList<Genre> results = new ResultList<Genre>(wrapper.getGenres());
ResultList<Genre> results = new ResultList<>(wrapper.getGenres());
wrapper.setResultProperties(results);
return results;
} catch (IOException ex) {
@@ -184,7 +184,7 @@ public class TmdbMovies extends AbstractMethod {
String webpage = httpTools.getRequest(url);
try {
WrapperAlternativeTitles wrapper = MAPPER.readValue(webpage, WrapperAlternativeTitles.class);
ResultList<AlternativeTitle> results = new ResultList<AlternativeTitle>(wrapper.getTitles());
ResultList<AlternativeTitle> results = new ResultList<>(wrapper.getTitles());
wrapper.setResultProperties(results);
return results;
} catch (IOException ex) {
@@ -231,7 +231,7 @@ public class TmdbMovies extends AbstractMethod {
try {
WrapperImages wrapper = MAPPER.readValue(webpage, WrapperImages.class);
ResultList<Artwork> results = new ResultList<Artwork>(wrapper.getAll());
ResultList<Artwork> results = new ResultList<>(wrapper.getAll());
wrapper.setResultProperties(results);
return results;
} catch (IOException ex) {
@@ -258,7 +258,7 @@ public class TmdbMovies extends AbstractMethod {
try {
WrapperMovieKeywords wrapper = MAPPER.readValue(webpage, WrapperMovieKeywords.class);
ResultList<Keyword> results = new ResultList<Keyword>(wrapper.getKeywords());
ResultList<Keyword> results = new ResultList<>(wrapper.getKeywords());
wrapper.setResultProperties(results);
return results;
} catch (IOException ex) {
@@ -285,7 +285,7 @@ public class TmdbMovies extends AbstractMethod {
try {
WrapperReleaseInfo wrapper = MAPPER.readValue(webpage, WrapperReleaseInfo.class);
ResultList<ReleaseInfo> results = new ResultList<ReleaseInfo>(wrapper.getCountries());
ResultList<ReleaseInfo> results = new ResultList<>(wrapper.getCountries());
wrapper.setResultProperties(results);
return results;
} catch (IOException ex) {
@@ -314,7 +314,7 @@ public class TmdbMovies extends AbstractMethod {
try {
WrapperVideos wrapper = MAPPER.readValue(webpage, WrapperVideos.class);
ResultList<Video> results = new ResultList<Video>(wrapper.getVideos());
ResultList<Video> results = new ResultList<>(wrapper.getVideos());
wrapper.setResultProperties(results);
return results;
} catch (IOException ex) {
@@ -339,7 +339,7 @@ public class TmdbMovies extends AbstractMethod {
try {
WrapperTranslations wrapper = MAPPER.readValue(webpage, WrapperTranslations.class);
ResultList<Translation> results = new ResultList<Translation>(wrapper.getTranslations());
ResultList<Translation> results = new ResultList<>(wrapper.getTranslations());
wrapper.setResultProperties(results);
return results;
} catch (IOException ex) {
@@ -46,7 +46,7 @@ import com.omertron.themoviedbapi.tools.Param;
import com.omertron.themoviedbapi.tools.TmdbParameters;
import java.io.IOException;
import java.net.URL;
import org.slf4j.LoggerFactory;
import org.apache.commons.lang3.StringUtils;
import org.yamj.api.common.exception.ApiExceptionType;
/**
@@ -79,13 +79,19 @@ public class TmdbPeople extends AbstractMethod {
parameters.add(Param.ID, personId);
parameters.add(Param.APPEND, appendToResponse);
// Switch combined credits for tv & movie.
String atr = (String) parameters.get(Param.APPEND);
if (StringUtils.isNotBlank(atr) && atr.contains("combined_credits")) {
atr = atr.replace("combined_credits", "tv_credits,movie_credits");
parameters.add(Param.APPEND, atr);
}
URL url = new ApiUrl(apiKey, MethodBase.PERSON).buildUrl(parameters);
String webpage = httpTools.getRequest(url);
try {
return MAPPER.readValue(webpage, PersonInfo.class);
} catch (IOException ex) {
LoggerFactory.getLogger("test").info("{}", ex);
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get person info", url, ex);
}
}
@@ -216,7 +222,7 @@ public class TmdbPeople extends AbstractMethod {
try {
WrapperImages wrapper = MAPPER.readValue(webpage, WrapperImages.class);
ResultList<Artwork> results = new ResultList<Artwork>(wrapper.getAll(ArtworkType.PROFILE));
ResultList<Artwork> results = new ResultList<>(wrapper.getAll(ArtworkType.PROFILE));
wrapper.setResultProperties(results);
return results;
} catch (IOException ex) {
@@ -203,13 +203,14 @@ public class TmdbSearch extends AbstractMethod {
try {
WrapperMultiSearch wrapper = MAPPER.readValue(webpage, WrapperMultiSearch.class);
ResultList<MediaBasic> results = new ResultList<MediaBasic>();
ResultList<MediaBasic> results = new ResultList<>();
results.getResults().addAll(wrapper.getResults());
wrapper.setResultProperties(results);
return results;
} catch (IOException ex) {
throw new MovieDbException(ApiExceptionType.MAPPING_FAILED, "Failed to get multi search", url, ex);
} }
}
}
/**
* This is a good starting point to start finding people on TMDb.
@@ -99,8 +99,7 @@ public class TmdbSeasons extends AbstractMethod {
}
/**
* This method lets users get the status of whether or not the TV episodes
* of a season have been rated.
* This method lets users get the status of whether or not the TV episodes of a season have been rated.
*
* A valid session id is required.
*
@@ -147,8 +146,7 @@ public class TmdbSeasons extends AbstractMethod {
}
/**
* Get the external ids that we have stored for a TV season by season
* number.
* Get the external ids that we have stored for a TV season by season number.
*
* @param tvID
* @param seasonNumber
@@ -194,7 +192,7 @@ public class TmdbSeasons extends AbstractMethod {
try {
WrapperImages wrapper = MAPPER.readValue(webpage, WrapperImages.class);
ResultList<Artwork> results = new ResultList<Artwork>(wrapper.getAll());
ResultList<Artwork> results = new ResultList<>(wrapper.getAll());
wrapper.setResultProperties(results);
return results;
} catch (IOException ex) {
@@ -203,8 +201,7 @@ public class TmdbSeasons extends AbstractMethod {
}
/**
* Get the videos that have been added to a TV season (trailers, teasers,
* etc...)
* Get the videos that have been added to a TV season (trailers, teasers, etc...)
*
* @param tvID
* @param seasonNumber
@@ -223,7 +220,7 @@ public class TmdbSeasons extends AbstractMethod {
try {
WrapperVideos wrapper = MAPPER.readValue(webpage, WrapperVideos.class);
ResultList<Video> results = new ResultList<Video>(wrapper.getVideos());
ResultList<Video> results = new ResultList<>(wrapper.getVideos());
wrapper.setResultProperties(results);
return results;
} catch (IOException ex) {
@@ -231,7 +231,7 @@ public class TmdbTV extends AbstractMethod {
try {
WrapperImages wrapper = MAPPER.readValue(webpage, WrapperImages.class);
ResultList<Artwork> results = new ResultList<Artwork>(wrapper.getAll());
ResultList<Artwork> results = new ResultList<>(wrapper.getAll());
wrapper.setResultProperties(results);
return results;
} catch (IOException ex) {
@@ -327,7 +327,7 @@ public class TmdbTV extends AbstractMethod {
try {
WrapperTranslations wrapper = MAPPER.readValue(webpage, WrapperTranslations.class);
ResultList<Translation> results = new ResultList<Translation>(wrapper.getTranslations());
ResultList<Translation> results = new ResultList<>(wrapper.getTranslations());
wrapper.setResultProperties(results);
return results;
} catch (IOException ex) {
@@ -354,7 +354,7 @@ public class TmdbTV extends AbstractMethod {
try {
WrapperVideos wrapper = MAPPER.readValue(webpage, WrapperVideos.class);
ResultList<Video> results = new ResultList<Video>(wrapper.getVideos());
ResultList<Video> results = new ResultList<>(wrapper.getVideos());
wrapper.setResultProperties(results);
return results;
} catch (IOException ex) {
@@ -390,13 +390,13 @@ public class TmdbTV extends AbstractMethod {
* @return
* @throws com.omertron.themoviedbapi.MovieDbException
*/
public ResultList<TVBasic> getTVOnTheAir(Integer page, String language) throws MovieDbException {
public ResultList<TVInfo> getTVOnTheAir(Integer page, String language) throws MovieDbException {
TmdbParameters parameters = new TmdbParameters();
parameters.add(Param.PAGE, page);
parameters.add(Param.LANGUAGE, language);
URL url = new ApiUrl(apiKey, MethodBase.TV).subMethod(MethodSub.ON_THE_AIR).buildUrl(parameters);
WrapperGenericList<TVBasic> wrapper = processWrapper(getTypeReference(TVBasic.class), url, "on the air");
WrapperGenericList<TVInfo> wrapper = processWrapper(getTypeReference(TVInfo.class), url, "on the air");
return wrapper.getResultsList();
}
@@ -411,14 +411,14 @@ public class TmdbTV extends AbstractMethod {
* @return
* @throws com.omertron.themoviedbapi.MovieDbException
*/
public ResultList<TVBasic> getTVAiringToday(Integer page, String language, String timezone) throws MovieDbException {
public ResultList<TVInfo> getTVAiringToday(Integer page, String language, String timezone) throws MovieDbException {
TmdbParameters parameters = new TmdbParameters();
parameters.add(Param.PAGE, page);
parameters.add(Param.LANGUAGE, language);
parameters.add(Param.TIMEZONE, timezone);
URL url = new ApiUrl(apiKey, MethodBase.TV).subMethod(MethodSub.AIRING_TODAY).buildUrl(parameters);
WrapperGenericList<TVBasic> wrapper = processWrapper(getTypeReference(TVBasic.class), url, "airing today");
WrapperGenericList<TVInfo> wrapper = processWrapper(getTypeReference(TVInfo.class), url, "airing today");
return wrapper.getResultsList();
}
@@ -435,13 +435,13 @@ public class TmdbTV extends AbstractMethod {
* @return
* @throws com.omertron.themoviedbapi.MovieDbException
*/
public ResultList<TVBasic> getTVTopRated(Integer page, String language) throws MovieDbException {
public ResultList<TVInfo> getTVTopRated(Integer page, String language) throws MovieDbException {
TmdbParameters parameters = new TmdbParameters();
parameters.add(Param.PAGE, page);
parameters.add(Param.LANGUAGE, language);
URL url = new ApiUrl(apiKey, MethodBase.TV).subMethod(MethodSub.TOP_RATED).buildUrl(parameters);
WrapperGenericList<TVBasic> wrapper = processWrapper(getTypeReference(TVBasic.class), url, "top rated TV shows");
WrapperGenericList<TVInfo> wrapper = processWrapper(getTypeReference(TVInfo.class), url, "top rated TV shows");
return wrapper.getResultsList();
}
@@ -453,13 +453,13 @@ public class TmdbTV extends AbstractMethod {
* @return
* @throws com.omertron.themoviedbapi.MovieDbException
*/
public ResultList<TVBasic> getTVPopular(Integer page, String language) throws MovieDbException {
public ResultList<TVInfo> getTVPopular(Integer page, String language) throws MovieDbException {
TmdbParameters parameters = new TmdbParameters();
parameters.add(Param.PAGE, page);
parameters.add(Param.LANGUAGE, language);
URL url = new ApiUrl(apiKey, MethodBase.TV).subMethod(MethodSub.POPULAR).buildUrl(parameters);
WrapperGenericList<TVBasic> wrapper = processWrapper(getTypeReference(TVBasic.class), url, "popular TV shows");
WrapperGenericList<TVInfo> wrapper = processWrapper(getTypeReference(TVInfo.class), url, "popular TV shows");
return wrapper.getResultsList();
}
}
@@ -31,7 +31,7 @@ import org.apache.commons.lang3.builder.HashCodeBuilder;
*/
public class AbstractIdName extends AbstractJsonMapping implements Serializable, Identification {
private static final long serialVersionUID = 4L;
private static final long serialVersionUID = 100L;
@JsonProperty("id")
private int id;
@@ -33,7 +33,7 @@ import org.slf4j.LoggerFactory;
*/
public abstract class AbstractJsonMapping implements Serializable {
private static final long serialVersionUID = 4L;
private static final long serialVersionUID = 100L;
private static final Logger LOG = LoggerFactory.getLogger(AbstractJsonMapping.class);
/**
@@ -26,7 +26,7 @@ import java.io.Serializable;
@JsonRootName("certification")
public class Certification extends AbstractJsonMapping implements Serializable {
private static final long serialVersionUID = 4L;
private static final long serialVersionUID = 100L;
// Properties
@JsonProperty("certification")
private String value;
@@ -33,7 +33,7 @@ import java.util.List;
*/
public class FindResults extends AbstractJsonMapping implements Serializable {
private static final long serialVersionUID = 4L;
private static final long serialVersionUID = 100L;
@JsonProperty("movie_results")
private List<MovieBasic> movieResults;
@@ -28,6 +28,6 @@ import java.io.Serializable;
@JsonRootName("genre")
public class Genre extends AbstractIdName implements Serializable {
private static final long serialVersionUID = 4L;
private static final long serialVersionUID = 100L;
// Nothing to override from the base class.
}
@@ -31,7 +31,7 @@ import org.apache.commons.lang3.builder.HashCodeBuilder;
@JsonRootName("spoken_language")
public class Language extends AbstractJsonMapping implements Serializable {
private static final long serialVersionUID = 4L;
private static final long serialVersionUID = 100L;
@JsonProperty("iso_639_1")
private String isoCode;
@@ -26,7 +26,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
*/
public class StatusCode extends AbstractJsonMapping {
private static final long serialVersionUID = 4L;
private static final long serialVersionUID = 100L;
@JsonProperty("status_code")
private int code;
@@ -22,11 +22,10 @@ package com.omertron.themoviedbapi.model.account;
import com.omertron.themoviedbapi.model.AbstractJsonMapping;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.omertron.themoviedbapi.interfaces.Identification;
import java.io.Serializable;
public class Account extends AbstractJsonMapping implements Serializable, Identification {
public class Account extends AbstractJsonMapping implements Identification {
private static final long serialVersionUID = 4L;
private static final long serialVersionUID = 100L;
@JsonProperty("id")
private int id;
@@ -40,6 +39,8 @@ public class Account extends AbstractJsonMapping implements Serializable, Identi
private String language;
@JsonProperty("iso_3166_1")
private String country;
@JsonProperty("avatar")
private Avatar avatar;
@Override
public int getId() {
@@ -90,4 +91,12 @@ public class Account extends AbstractJsonMapping implements Serializable, Identi
public void setCountry(String country) {
this.country = country;
}
public Avatar getAvatar() {
return avatar;
}
public void setAvatar(Avatar avatar) {
this.avatar = avatar;
}
}
@@ -0,0 +1,38 @@
/*
* Copyright (c) 2004-2015 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.account;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.omertron.themoviedbapi.model.AbstractJsonMapping;
public class Avatar extends AbstractJsonMapping {
@JsonProperty("gravatar")
private AvatarHash hash = null;
public String getHash() {
return hash == null ? "" : hash.getHash();
}
public void setHash(AvatarHash hash) {
this.hash = hash;
}
}
@@ -0,0 +1,38 @@
/*
* Copyright (c) 2004-2015 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.account;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.omertron.themoviedbapi.model.AbstractJsonMapping;
public class AvatarHash extends AbstractJsonMapping {
@JsonProperty("hash")
private String hash;
public String getHash() {
return hash;
}
public void setHash(String hash) {
this.hash = hash;
}
}
@@ -34,7 +34,7 @@ import org.apache.commons.lang3.builder.HashCodeBuilder;
*/
public class Artwork extends AbstractJsonMapping implements Serializable {
private static final long serialVersionUID = 4L;
private static final long serialVersionUID = 100L;
@JsonProperty("id")
private String id;
@@ -38,7 +38,7 @@ import org.apache.commons.lang3.builder.HashCodeBuilder;
*/
public class ArtworkMedia extends Artwork implements Serializable {
private static final long serialVersionUID = 4L;
private static final long serialVersionUID = 100L;
private MediaType mediaType;
@JsonTypeInfo(
@@ -25,7 +25,7 @@ import java.io.Serializable;
public class TokenAuthorisation extends AbstractJsonMapping implements Serializable {
private static final long serialVersionUID = 4L;
private static final long serialVersionUID = 100L;
@JsonProperty("expires_at")
private String expires;
@JsonProperty("request_token")
@@ -25,7 +25,7 @@ import java.io.Serializable;
public class TokenSession extends AbstractJsonMapping implements Serializable {
private static final long serialVersionUID = 4L;
private static final long serialVersionUID = 100L;
@JsonProperty("session_id")
private String sessionId;
@JsonProperty("success")
@@ -27,11 +27,11 @@ import java.util.List;
public class ChangeKeyItem extends AbstractJsonMapping implements Serializable {
private static final long serialVersionUID = 4L;
private static final long serialVersionUID = 100L;
@JsonProperty("key")
private String key;
@JsonProperty("items")
private List<ChangedItem> changedItems = new ArrayList<ChangedItem>();
private List<ChangedItem> changedItems = new ArrayList<>();
public String getKey() {
return key;
@@ -25,7 +25,7 @@ import java.io.Serializable;
public class ChangeListItem extends AbstractJsonMapping implements Serializable {
private static final long serialVersionUID = 4L;
private static final long serialVersionUID = 100L;
@JsonProperty("id")
private int id;
@@ -25,7 +25,7 @@ import java.io.Serializable;
public class ChangedItem extends AbstractJsonMapping implements Serializable {
private static final long serialVersionUID = 4L;
private static final long serialVersionUID = 100L;
@JsonProperty("id")
private String id;
@JsonProperty("action")
@@ -34,7 +34,7 @@ import org.apache.commons.lang3.builder.HashCodeBuilder;
@JsonRootName("collection")
public class Collection extends AbstractJsonMapping implements Serializable, Identification {
private static final long serialVersionUID = 4L;
private static final long serialVersionUID = 100L;
@JsonProperty("id")
private int id;
@@ -32,7 +32,7 @@ import java.util.List;
*/
public class CollectionInfo extends AbstractJsonMapping implements Serializable, Identification {
private static final long serialVersionUID = 4L;
private static final long serialVersionUID = 100L;
@JsonProperty("id")
private int id;
@@ -45,7 +45,7 @@ public class CollectionInfo extends AbstractJsonMapping implements Serializable,
@JsonProperty("backdrop_path")
private String backdropPath;
@JsonProperty("parts")
private List<Collection> parts = new ArrayList<Collection>();
private List<Collection> parts = new ArrayList<>();
public String getBackdropPath() {
return backdropPath;
@@ -32,7 +32,7 @@ import static org.apache.commons.lang3.StringUtils.EMPTY;
*/
public class Company extends AbstractJsonMapping implements Serializable, Identification {
private static final long serialVersionUID = 4L;
private static final long serialVersionUID = 100L;
// Properties
@JsonProperty("id")
private int id = 0;
@@ -34,7 +34,7 @@ import org.yamj.api.common.exception.ApiExceptionType;
*/
public class Configuration extends AbstractJsonMapping implements Serializable {
private static final long serialVersionUID = 4L;
private static final long serialVersionUID = 100L;
@JsonProperty("base_url")
private String baseUrl;
@@ -26,7 +26,7 @@ import java.util.List;
public class JobDepartment extends AbstractJsonMapping implements Serializable {
private static final long serialVersionUID = 4L;
private static final long serialVersionUID = 100L;
// Properties
@JsonProperty("department")
private String department;
@@ -33,7 +33,7 @@ import java.io.Serializable;
*/
public class CreditBasic extends AbstractJsonMapping implements Serializable, Identification {
private static final long serialVersionUID = 4L;
private static final long serialVersionUID = 100L;
private CreditType creditType;
private MediaType mediaType;
@@ -28,7 +28,7 @@ import java.io.Serializable;
*/
public class CreditMovieBasic extends CreditBasic implements Serializable {
private static final long serialVersionUID = 4L;
private static final long serialVersionUID = 100L;
@JsonProperty("adult")
private boolean adult;
@@ -28,7 +28,7 @@ import java.io.Serializable;
*/
public class CreditTVBasic extends CreditBasic implements Serializable {
private static final long serialVersionUID = 4L;
private static final long serialVersionUID = 100L;
@JsonProperty("episode_count")
private int episodeCount;
@@ -30,7 +30,7 @@ import java.io.Serializable;
*/
public class MediaCredit extends AbstractJsonMapping implements Serializable, Identification {
private static final long serialVersionUID = 4L;
private static final long serialVersionUID = 100L;
@JsonProperty("credit_id")
private String creditId;
@@ -28,7 +28,7 @@ import java.io.Serializable;
*/
public class MediaCreditCast extends MediaCredit implements Serializable {
private static final long serialVersionUID = 4L;
private static final long serialVersionUID = 100L;
@JsonProperty("cast_id")
private int castId = 0;
@@ -28,7 +28,7 @@ import java.io.Serializable;
*/
public class MediaCreditCrew extends MediaCredit implements Serializable {
private static final long serialVersionUID = 4L;
private static final long serialVersionUID = 100L;
@JsonProperty("department")
private String department;
@@ -29,6 +29,6 @@ import java.io.Serializable;
@JsonRootName("keyword")
public class Keyword extends AbstractIdName implements Serializable {
private static final long serialVersionUID = 4L;
private static final long serialVersionUID = 100L;
// Nothing to override from the base class.
}
@@ -33,7 +33,7 @@ import java.util.List;
*/
public class ListItem<T> extends AbstractJsonMapping implements Serializable {
private static final long serialVersionUID = 4L;
private static final long serialVersionUID = 100L;
@JsonProperty("id")
private String id;
@@ -21,20 +21,29 @@ package com.omertron.themoviedbapi.model.list;
import com.omertron.themoviedbapi.model.AbstractJsonMapping;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.io.Serializable;
/**
* @author Holger Brandl
*/
public class ListItemStatus extends AbstractJsonMapping implements Serializable {
public class ListItemStatus extends AbstractJsonMapping {
private static final long serialVersionUID = 4L;
private static final long serialVersionUID = 101L;
@JsonProperty("id")
private String id;
@JsonProperty("status_code")
private int statusCode;
@JsonProperty("item_present")
private boolean itemPresent;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public int getStatusCode() {
return statusCode;
}
@@ -30,7 +30,7 @@ import java.io.Serializable;
*/
public class UserList extends AbstractJsonMapping implements Serializable {
private static final long serialVersionUID = 4L;
private static final long serialVersionUID = 100L;
@JsonProperty("id")
private String id;
@@ -29,7 +29,7 @@ import org.apache.commons.lang3.builder.HashCodeBuilder;
*/
public class AlternativeTitle implements Serializable {
private static final long serialVersionUID = 4L;
private static final long serialVersionUID = 100L;
@JsonProperty("iso_3166_1")
private String country;
@@ -33,7 +33,7 @@ import java.io.Serializable;
*/
public class MediaBasic extends AbstractJsonMapping implements Serializable, Identification {
private static final long serialVersionUID = 4L;
private static final long serialVersionUID = 100L;
@JsonProperty("id")
private int id;
@@ -33,7 +33,7 @@ import java.util.List;
*/
public class MediaCreditList extends AbstractJsonMapping implements Serializable, Identification {
private static final long serialVersionUID = 4L;
private static final long serialVersionUID = 100L;
@JsonProperty("id")
private int id = 0;
@@ -31,7 +31,7 @@ import java.io.Serializable;
*/
public class MediaState extends AbstractJsonMapping implements Serializable, Identification {
private static final long serialVersionUID = 4L;
private static final long serialVersionUID = 100L;
@JsonProperty("id")
private int id;
@@ -29,7 +29,7 @@ import java.io.Serializable;
*/
public class RatedValue extends AbstractJsonMapping implements Serializable {
private static final long serialVersionUID = 4L;
private static final long serialVersionUID = 100L;
@JsonProperty("value")
private float value = -1f;
@@ -32,7 +32,7 @@ import org.apache.commons.lang3.builder.HashCodeBuilder;
*/
public class Trailer extends AbstractJsonMapping implements Serializable {
private static final long serialVersionUID = 4L;
private static final long serialVersionUID = 100L;
@JsonProperty("name")
private String name;
@@ -32,7 +32,7 @@ import org.apache.commons.lang3.builder.ToStringStyle;
*/
public class Translation extends AbstractJsonMapping implements Serializable {
private static final long serialVersionUID = 4L;
private static final long serialVersionUID = 100L;
@JsonProperty("english_name")
private String englishName;
@@ -32,7 +32,7 @@ import org.apache.commons.lang3.builder.HashCodeBuilder;
*/
public class Video extends AbstractJsonMapping implements Serializable {
private static final long serialVersionUID = 4L;
private static final long serialVersionUID = 100L;
@JsonProperty("id")
private String id;
@@ -23,6 +23,7 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import com.omertron.themoviedbapi.enumeration.MediaType;
import com.omertron.themoviedbapi.model.media.MediaBasic;
import java.io.Serializable;
import java.util.List;
/**
* Basic Movie information
@@ -31,8 +32,10 @@ import java.io.Serializable;
*/
public class MovieBasic extends MediaBasic implements Serializable {
private static final long serialVersionUID = 4L;
private static final long serialVersionUID = 100L;
@JsonProperty("_id")
private String mediaId;
@JsonProperty("adult")
private boolean adult;
@JsonProperty("original_title")
@@ -45,11 +48,27 @@ public class MovieBasic extends MediaBasic implements Serializable {
private Boolean video = null;
@JsonProperty("rating")
private float userRating = -1f;
@JsonProperty("genre_ids")
private List<Integer> genreIds;
@JsonProperty("original_language")
private String originalLanguage;
@JsonProperty("overview")
private String overview;
@JsonProperty("revenue")
private long revenue = 0L;
public MovieBasic() {
super.setMediaType(MediaType.MOVIE);
}
public String getMediaId() {
return mediaId;
}
public void setMediaId(String mediaId) {
this.mediaId = mediaId;
}
public boolean isAdult() {
return adult;
}
@@ -86,7 +105,7 @@ public class MovieBasic extends MediaBasic implements Serializable {
return video;
}
public void setVideo(boolean video) {
public void setVideo(Boolean video) {
this.video = video;
}
@@ -97,4 +116,36 @@ public class MovieBasic extends MediaBasic implements Serializable {
public void setUserRating(float userRating) {
this.userRating = userRating;
}
public List<Integer> getGenreIds() {
return genreIds;
}
public void setGenreIds(List<Integer> genreIds) {
this.genreIds = genreIds;
}
public String getOriginalLanguage() {
return originalLanguage;
}
public void setOriginalLanguage(String originalLanguage) {
this.originalLanguage = originalLanguage;
}
public String getOverview() {
return overview;
}
public void setOverview(String overview) {
this.overview = overview;
}
public long getRevenue() {
return revenue;
}
public void setRevenue(long revenue) {
this.revenue = revenue;
}
}
@@ -53,13 +53,13 @@ import java.util.List;
import java.util.Set;
/**
* Movie Bean
* Movie Info
*
* @author stuart.boston
*/
public class MovieInfo extends MovieBasic implements Serializable, Identification, AppendToResponse<MovieMethod> {
private static final long serialVersionUID = 4L;
private static final long serialVersionUID = 100L;
@JsonProperty("belongs_to_collection")
private Collection belongsToCollection;
@@ -71,18 +71,12 @@ public class MovieInfo extends MovieBasic implements Serializable, Identificatio
private String homepage;
@JsonProperty("imdb_id")
private String imdbID;
@JsonProperty("overview")
private String overview;
@JsonProperty("production_companies")
private List<ProductionCompany> productionCompanies = Collections.emptyList();
@JsonProperty("production_countries")
private List<ProductionCountry> productionCountries = Collections.emptyList();
@JsonProperty("revenue")
private long revenue;
@JsonProperty("runtime")
private int runtime;
@JsonProperty("original_language")
private String originalLanguage;
@JsonProperty("spoken_languages")
private List<Language> spokenLanguages = Collections.emptyList();
@JsonProperty("tagline")
@@ -125,10 +119,6 @@ public class MovieInfo extends MovieBasic implements Serializable, Identificatio
return imdbID;
}
public String getOverview() {
return overview;
}
public List<ProductionCompany> getProductionCompanies() {
return productionCompanies;
}
@@ -137,10 +127,6 @@ public class MovieInfo extends MovieBasic implements Serializable, Identificatio
return productionCountries;
}
public long getRevenue() {
return revenue;
}
public int getRuntime() {
return runtime;
}
@@ -156,10 +142,6 @@ public class MovieInfo extends MovieBasic implements Serializable, Identificatio
public String getStatus() {
return status;
}
public String getOriginalLanguage() {
return originalLanguage;
}
// </editor-fold>
// <editor-fold defaultstate="collapsed" desc="Setter methods">
@@ -183,10 +165,6 @@ public class MovieInfo extends MovieBasic implements Serializable, Identificatio
this.imdbID = imdbID;
}
public void setOverview(String overview) {
this.overview = overview;
}
public void setProductionCompanies(List<ProductionCompany> productionCompanies) {
this.productionCompanies = productionCompanies;
}
@@ -195,10 +173,6 @@ public class MovieInfo extends MovieBasic implements Serializable, Identificatio
this.productionCountries = productionCountries;
}
public void setRevenue(long revenue) {
this.revenue = revenue;
}
public void setRuntime(int runtime) {
this.runtime = runtime;
}
@@ -214,10 +188,6 @@ public class MovieInfo extends MovieBasic implements Serializable, Identificatio
public void setStatus(String status) {
this.status = status;
}
public void setOriginalLanguage(String originalLanguage) {
this.originalLanguage = originalLanguage;
}
// </editor-fold>
//<editor-fold defaultstate="collapsed" desc="AppendToResponse Getters">
@@ -29,6 +29,6 @@ import java.io.Serializable;
@JsonRootName("production_company")
public class ProductionCompany extends AbstractIdName implements Serializable {
private static final long serialVersionUID = 4L;
private static final long serialVersionUID = 100L;
// Nothing to override from the base class.
}
@@ -32,7 +32,7 @@ import org.apache.commons.lang3.builder.HashCodeBuilder;
@JsonRootName("production_country")
public class ProductionCountry extends AbstractJsonMapping implements Serializable {
private static final long serialVersionUID = 4L;
private static final long serialVersionUID = 100L;
@JsonProperty("iso_3166_1")
private String country;
@@ -30,7 +30,7 @@ import org.apache.commons.lang3.builder.HashCodeBuilder;
*/
public class ReleaseInfo extends AbstractJsonMapping implements Serializable {
private static final long serialVersionUID = 4L;
private static final long serialVersionUID = 100L;
@JsonProperty("iso_3166_1")
private String country;
@@ -28,7 +28,7 @@ import java.io.Serializable;
*/
public class Network extends AbstractIdName implements Serializable, Identification {
private static final long serialVersionUID = 4L;
private static final long serialVersionUID = 100L;
// Nothing to add to base class
}
@@ -28,7 +28,7 @@ import java.io.Serializable;
*/
public class ContentRating implements Serializable {
private static final long serialVersionUID = 4L;
private static final long serialVersionUID = 100L;
@JsonProperty("iso_3166_1")
private String country;
@@ -29,7 +29,7 @@ import java.io.Serializable;
*/
public class CreditInfo extends AbstractJsonMapping implements Serializable {
private static final long serialVersionUID = 4L;
private static final long serialVersionUID = 100L;
@JsonProperty("id")
private String id;
@@ -30,7 +30,7 @@ import java.io.Serializable;
*/
public class ExternalID extends AbstractJsonMapping implements Serializable, Identification {
private static final long serialVersionUID = 4L;
private static final long serialVersionUID = 100L;
@JsonProperty("id")
private int id;
@@ -28,7 +28,7 @@ import java.io.Serializable;
*/
public class PersonBasic extends AbstractIdName implements Serializable {
private static final long serialVersionUID = 4L;
private static final long serialVersionUID = 100L;
@JsonProperty("profile_path")
private String profilePath;
@@ -24,16 +24,15 @@ import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonSetter;
import com.omertron.themoviedbapi.interfaces.Identification;
import com.omertron.themoviedbapi.model.AbstractJsonMapping;
import java.io.Serializable;
import java.util.List;
/**
* @author stuart.boston
* @param <T>
*/
public class PersonCreditList<T extends CreditBasic> extends AbstractJsonMapping implements Serializable, Identification {
public class PersonCreditList<T extends CreditBasic> extends AbstractJsonMapping implements Identification {
private static final long serialVersionUID = 4L;
private static final long serialVersionUID = 101L;
@JsonProperty("id")
private int id;
@@ -35,7 +35,7 @@ import java.util.List;
*/
public class PersonFind extends PersonBasic implements Serializable {
private static final long serialVersionUID = 4L;
private static final long serialVersionUID = 100L;
@JsonProperty("adult")
private Boolean adult;
@@ -42,7 +42,7 @@ import java.util.Set;
*/
public class PersonInfo extends PersonBasic implements Serializable, AppendToResponse<PeopleMethod> {
private static final long serialVersionUID = 4L;
private static final long serialVersionUID = 100L;
@JsonProperty("adult")
private boolean adult;
@@ -66,12 +66,11 @@ public class PersonInfo extends PersonBasic implements Serializable, AppendToRes
private final Set<PeopleMethod> methods = EnumSet.noneOf(PeopleMethod.class);
// AppendToResponse Properties
private List<ChangeKeyItem> changes = Collections.emptyList();
// TODO: Add COMBINED_CREDITS
private ExternalID externalIDs = new ExternalID();
private List<Artwork> images = Collections.emptyList();
private PersonCreditList<CreditMovieBasic> movieCredits = new PersonCreditList<CreditMovieBasic>();
private List<ArtworkMedia> taggedImages = Collections.emptyList();
private PersonCreditList<CreditTVBasic> tvCredits = new PersonCreditList<CreditTVBasic>();
private PersonCreditList<CreditMovieBasic> movieCredits = new PersonCreditList<>();
private PersonCreditList<CreditTVBasic> tvCredits = new PersonCreditList<>();
//<editor-fold defaultstate="collapsed" desc="Getters and Setters">
public boolean isAdult() {
@@ -28,7 +28,7 @@ import java.io.Serializable;
*/
public class Review extends AbstractJsonMapping implements Serializable {
private static final long serialVersionUID = 4L;
private static final long serialVersionUID = 100L;
@JsonProperty("id")
private String id;
@@ -32,7 +32,7 @@ import java.util.List;
*/
public class TVBasic extends MediaBasic implements Serializable {
private static final long serialVersionUID = 4L;
private static final long serialVersionUID = 100L;
@JsonProperty("name")
private String name;
@@ -31,7 +31,7 @@ import java.util.List;
*/
public class TVCredit extends AbstractIdName implements Serializable {
private static final long serialVersionUID = 4L;
private static final long serialVersionUID = 100L;
@JsonProperty("original_name")
private String originalName;
@@ -31,7 +31,7 @@ import java.io.Serializable;
*/
public class TVEpisodeBasic extends MediaBasic implements Serializable {
private static final long serialVersionUID = 4L;
private static final long serialVersionUID = 100L;
@JsonProperty("air_date")
private String airDate;
@@ -44,7 +44,7 @@ import java.util.Set;
*/
public class TVEpisodeInfo extends TVEpisodeBasic implements Serializable, AppendToResponse<TVEpisodeMethod> {
private static final long serialVersionUID = 4L;
private static final long serialVersionUID = 100L;
@JsonProperty("crew")
private List<MediaCreditCrew> crew;
@@ -41,6 +41,7 @@ import com.omertron.themoviedbapi.results.WrapperGenericList;
import com.omertron.themoviedbapi.results.WrapperImages;
import com.omertron.themoviedbapi.results.WrapperTranslations;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collections;
import java.util.EnumSet;
import java.util.List;
@@ -52,7 +53,7 @@ import java.util.Set;
*/
public class TVInfo extends TVBasic implements Serializable, AppendToResponse<TVMethod> {
private static final long serialVersionUID = 4L;
private static final long serialVersionUID = 100L;
@JsonProperty("created_by")
private List<PersonBasic> createdBy;
@@ -230,6 +231,17 @@ public class TVInfo extends TVBasic implements Serializable, AppendToResponse<TV
}
//</editor-fold>
@JsonSetter("genre_ids")
public void setGenreIds(List<Integer> ids) {
this.genres = new ArrayList<>();
for (Integer id : ids) {
Genre g = new Genre();
g.setId(id);
genres.add(g);
}
}
private void addMethod(TVMethod method) {
methods.add(method);
}
@@ -31,7 +31,7 @@ import java.io.Serializable;
*/
public class TVSeasonBasic extends AbstractJsonMapping implements Serializable, Identification {
private static final long serialVersionUID = 4L;
private static final long serialVersionUID = 100L;
@JsonProperty("id")
private int id = -1;
@@ -42,7 +42,7 @@ import java.util.Set;
*/
public class TVSeasonInfo extends TVSeasonBasic implements Serializable, AppendToResponse<TVSeasonMethod> {
private static final long serialVersionUID = 4L;
private static final long serialVersionUID = 100L;
@JsonProperty("name")
private String name;
@@ -37,9 +37,9 @@ public abstract class AbstractWrapperBase extends AbstractJsonMapping {
*/
public <E extends Enum<E>> List<E> getTypeList(Class<E> clz, E[] typeList) {
if (typeList.length > 0) {
return new ArrayList<E>(Arrays.asList(typeList));
return new ArrayList<>(Arrays.asList(typeList));
} else {
return new ArrayList<E>(EnumSet.allOf(clz));
return new ArrayList<>(EnumSet.allOf(clz));
}
}
@@ -41,9 +41,9 @@ public final class ResultList<T> extends AbstractWrapperIdPages {
public ResultList(List<T> resultList) {
if (resultList == null) {
results = new ArrayList<T>();
results = new ArrayList<>();
} else {
results = new ArrayList<T>(resultList);
results = new ArrayList<>(resultList);
}
}
@@ -42,9 +42,9 @@ public final class ResultsMap<K, V> extends AbstractWrapperIdPages {
public ResultsMap(Map<K, V> resultsMap) {
if (resultsMap == null) {
results = new HashMap<K, V>();
results = new HashMap<>();
} else {
results = new HashMap<K, V>(resultsMap);
results = new HashMap<>(resultsMap);
}
}
@@ -27,7 +27,7 @@ import java.util.List;
public class WrapperChanges extends AbstractWrapperBase {
@JsonProperty("changes")
private List<ChangeKeyItem> changedItems = new ArrayList<ChangeKeyItem>();
private List<ChangeKeyItem> changedItems = new ArrayList<>();
public List<ChangeKeyItem> getChangedItems() {
return changedItems;
@@ -21,7 +21,6 @@ package com.omertron.themoviedbapi.results;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.omertron.themoviedbapi.results.ResultList;
import java.util.List;
/**
@@ -45,7 +44,7 @@ public class WrapperGenericList<T> extends AbstractWrapperAll {
}
public ResultList<T> getResultsList() {
ResultList<T> resultsList = new ResultList<T>(results);
ResultList<T> resultsList = new ResultList<>(results);
setResultProperties(resultsList);
return resultsList;
}
@@ -79,13 +79,13 @@ public class WrapperImages extends AbstractWrapperAll {
* @return
*/
public List<Artwork> getAll(ArtworkType... artworkList) {
List<Artwork> artwork = new ArrayList<Artwork>();
List<Artwork> artwork = new ArrayList<>();
List<ArtworkType> types;
if (artworkList.length > 0) {
types = new ArrayList<ArtworkType>(Arrays.asList(artworkList));
types = new ArrayList<>(Arrays.asList(artworkList));
} else {
types = new ArrayList<ArtworkType>(Arrays.asList(ArtworkType.values()));
types = new ArrayList<>(Arrays.asList(ArtworkType.values()));
}
// Add all the posters to the list
@@ -45,7 +45,7 @@ public class WrapperVideos extends AbstractWrapperId {
@JsonSetter("quicktime")
public void setQuickTime(List<Trailer> trailers) {
if (this.videos == null) {
this.videos = new ArrayList<Video>();
this.videos = new ArrayList<>();
}
for (Trailer t : trailers) {
@@ -56,7 +56,7 @@ public class WrapperVideos extends AbstractWrapperId {
@JsonSetter("youtube")
public void setYouTube(List<Trailer> trailers) {
if (this.videos == null) {
this.videos = new ArrayList<Video>();
this.videos = new ArrayList<>();
}
for (Trailer t : trailers) {
@@ -48,7 +48,7 @@ public class ApiUrl {
private final String apiKey;
private final MethodBase method;
private MethodSub submethod = MethodSub.NONE;
private static final List<Param> IGNORE_PARAMS = new ArrayList<Param>();
private static final List<Param> IGNORE_PARAMS = new ArrayList<>();
static {
IGNORE_PARAMS.add(Param.ID);
@@ -5,6 +5,7 @@ import java.io.IOException;
import java.net.URISyntaxException;
import java.net.URL;
import java.nio.charset.Charset;
import java.util.concurrent.TimeUnit;
import org.apache.http.HttpHeaders;
import org.apache.http.HttpStatus;
import org.apache.http.client.HttpClient;
@@ -28,6 +29,9 @@ public class HttpTools {
private final HttpClient httpClient;
private static final Charset CHARSET = Charset.forName("UTF-8");
private static final String APPLICATION_JSON = "application/json";
private static final long RETRY_DELAY = 1;
private static final int RETRY_MAX = 5;
private static final int STATUS_TOO_MANY_REQUESTS = 429;
public HttpTools(HttpClient httpClient) {
this.httpClient = httpClient;
@@ -44,16 +48,39 @@ public class HttpTools {
try {
HttpGet httpGet = new HttpGet(url.toURI());
httpGet.addHeader(HttpHeaders.ACCEPT, APPLICATION_JSON);
return validateResponse(DigestedResponseReader.requestContent(httpClient, httpGet, CHARSET), url);
} catch (URISyntaxException ex) {
throw new MovieDbException(ApiExceptionType.CONNECTION_ERROR, null, url, ex);
} catch (IOException ex) {
DigestedResponse response = DigestedResponseReader.requestContent(httpClient, httpGet, CHARSET);
long retryCount = 0L;
// If we have a 429 response, wait and try again
while (response.getStatusCode() == STATUS_TOO_MANY_REQUESTS && retryCount++ <= RETRY_MAX) {
delay(retryCount);
// Retry the request
response = DigestedResponseReader.requestContent(httpClient, httpGet, CHARSET);
}
return validateResponse(response, url);
} catch (URISyntaxException | IOException ex) {
throw new MovieDbException(ApiExceptionType.CONNECTION_ERROR, null, url, ex);
} catch (RuntimeException ex) {
throw new MovieDbException(ApiExceptionType.HTTP_503_ERROR, "Service Unavailable", url, ex);
}
}
/**
* Sleep for a period of time
*
* @param multiplier
*/
private void delay(long multiplier) {
try {
// Wait for the timeout to finish
Thread.sleep(TimeUnit.SECONDS.toMillis(RETRY_DELAY * multiplier));
} catch (InterruptedException ex) {
// Doesn't matter if we're interrupted
}
}
/**
* Execute a DELETE on the URL
*
@@ -65,9 +92,7 @@ public class HttpTools {
try {
HttpDelete httpDel = new HttpDelete(url.toURI());
return validateResponse(DigestedResponseReader.deleteContent(httpClient, httpDel, CHARSET), url);
} catch (URISyntaxException ex) {
throw new MovieDbException(ApiExceptionType.CONNECTION_ERROR, null, url, ex);
} catch (IOException ex) {
} catch (URISyntaxException | IOException ex) {
throw new MovieDbException(ApiExceptionType.CONNECTION_ERROR, null, url, ex);
}
}
@@ -89,9 +114,7 @@ public class HttpTools {
httpPost.setEntity(params);
return validateResponse(DigestedResponseReader.postContent(httpClient, httpPost, CHARSET), url);
} catch (URISyntaxException ex) {
throw new MovieDbException(ApiExceptionType.CONNECTION_ERROR, null, url, ex);
} catch (IOException ex) {
} catch (URISyntaxException | IOException ex) {
throw new MovieDbException(ApiExceptionType.CONNECTION_ERROR, null, url, ex);
}
}
@@ -105,7 +128,9 @@ public class HttpTools {
* @throws MovieDbException
*/
private String validateResponse(final DigestedResponse response, final URL url) throws MovieDbException {
if (response.getStatusCode() >= HttpStatus.SC_INTERNAL_SERVER_ERROR) {
if (response.getStatusCode() == 0) {
throw new MovieDbException(ApiExceptionType.CONNECTION_ERROR, response.getContent(), response.getStatusCode(), url, null);
} else if (response.getStatusCode() >= HttpStatus.SC_INTERNAL_SERVER_ERROR) {
throw new MovieDbException(ApiExceptionType.HTTP_503_ERROR, response.getContent(), response.getStatusCode(), url, null);
} else if (response.getStatusCode() >= HttpStatus.SC_MULTIPLE_CHOICES) {
throw new MovieDbException(ApiExceptionType.HTTP_404_ERROR, response.getContent(), response.getStatusCode(), url, null);
@@ -35,7 +35,7 @@ public class PostTools {
// Jackson JSON configuration
protected static final ObjectMapper MAPPER = new ObjectMapper();
private final Map<String, Object> values = new HashMap<String, Object>();
private final Map<String, Object> values = new HashMap<>();
public PostTools() {
}
@@ -33,7 +33,7 @@ import org.apache.commons.lang3.builder.ToStringStyle;
*/
public class TmdbParameters {
private final Map<Param, String> parameters = new EnumMap<Param, String>(Param.class);
private final Map<Param, String> parameters = new EnumMap<>(Param.class);
/**
* Construct an empty set of parameters
@@ -51,7 +51,7 @@ public class TmdbParameters {
}
/**
* Add a parameter to the collection
* Add an array parameter to the collection
*
* @param key Parameter to add
* @param value The array value to use (will be converted into a comma separated list)
@@ -165,17 +165,16 @@ public class TmdbParameters {
*/
public String toList(final String[] appendToResponse) {
StringBuilder sb = new StringBuilder();
if (appendToResponse.length > 0) {
boolean first = Boolean.TRUE;
for (String append : appendToResponse) {
if (first) {
first = Boolean.FALSE;
} else {
sb.append(",");
}
sb.append(append);
boolean first = Boolean.TRUE;
for (String append : appendToResponse) {
if (first) {
first = Boolean.FALSE;
} else {
sb.append(",");
}
sb.append(append);
}
return sb.toString();
}
+1 -1
View File
@@ -9,7 +9,7 @@
<fileSets>
<!-- add version.txt file -->
<fileSet>
<directory>${project.build.directory}</directory>
<directory>${project.build.directory}/classes</directory>
<outputDirectory></outputDirectory>
<includes>
<include>version.txt</include>
+9
View File
@@ -0,0 +1,9 @@
+-------------------------------------------------------------------------
| Project Name | ${project.name}
+-------------------------------------------------------------------------
| Version | ${project.version}
| Revision SHA | ${git.commit.id}
| Revision Date | ${git.commit.time}
| Build Date | ${git.build.time}
| Artifact Name | ${project.artifactId}-${project.version}-${timestamp}-${git.commit.id.abbrev}
-------------------------------------------------------------------------
@@ -33,7 +33,7 @@ public class ArtworkResults {
private final Map<ArtworkType, Boolean> results;
public ArtworkResults() {
results = new EnumMap<ArtworkType, Boolean>(ArtworkType.class);
results = new EnumMap<>(ArtworkType.class);
for (ArtworkType at : ArtworkType.values()) {
results.put(at, false);
}
@@ -58,8 +58,7 @@ public class TestLogger {
config.append("sun.net.www.protocol.http.HttpURLConnection.level = OFF").append(CRLF);
config.append("org.apache.http.level = SEVERE").append(CRLF);
InputStream ins = new ByteArrayInputStream(config.toString().getBytes());
try {
try (InputStream ins = new ByteArrayInputStream(config.toString().getBytes())) {
LogManager.getLogManager().readConfiguration(ins);
} catch (IOException e) {
LOG.warn("Failed to configure log manager due to an IO problem", e);
@@ -183,6 +183,14 @@ public class TestSuite {
assertTrue(message + " ID " + id + " not found in list", found);
}
/**
* Test the AppendToResponse method
*
* @param <T>
* @param test
* @param methodClass
* @param skip Any methods to skip
*/
public static <T extends AppendToResponseMethod> void testATR(AppendToResponse<T> test, Class<T> methodClass, T skip) {
for (T method : methodClass.getEnumConstants()) {
if (skip != null && method != skip) {
@@ -54,7 +54,7 @@ import org.junit.Test;
public class TmdbEpisodesTest extends AbstractTests {
private static TmdbEpisodes instance;
private static final List<TestID> TV_IDS = new ArrayList<TestID>();
private static final List<TestID> TV_IDS = new ArrayList<>();
public TmdbEpisodesTest() {
}
@@ -42,9 +42,9 @@ import org.junit.Test;
public class TmdbFindTest extends AbstractTests {
private static TmdbFind instance;
private static final List<TestID> PERSON_IDS = new ArrayList<TestID>();
private static final List<TestID> FILM_IDS = new ArrayList<TestID>();
private static final List<TestID> TV_IDS = new ArrayList<TestID>();
private static final List<TestID> PERSON_IDS = new ArrayList<>();
private static final List<TestID> FILM_IDS = new ArrayList<>();
private static final List<TestID> TV_IDS = new ArrayList<>();
public TmdbFindTest() {
}
@@ -63,7 +63,7 @@ import org.junit.Test;
public class TmdbMoviesTest extends AbstractTests {
private static TmdbMovies instance;
private static final List<TestID> FILM_IDS = new ArrayList<TestID>();
private static final List<TestID> FILM_IDS = new ArrayList<>();
public TmdbMoviesTest() {
}

Some files were not shown because too many files have changed in this diff Show More