104 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
Omertron 8068b9ac45 [maven-release-plugin] prepare release themoviedbapi-3.7 2013-08-23 10:21:30 +02:00
Omertron a25da9aa2f Reset version 2013-08-23 10:18:48 +02:00
Omertron 7a30ab831c Updated POM versions 2013-08-23 10:13:04 +02:00
Stuart Boston f64786e506 Update tests 2013-08-22 21:32:35 +01:00
Stuart Boston a57e7eeb37 Add toString methods 2013-08-22 21:32:26 +01:00
Stuart Boston 00bdfaf6a7 Add missing properties to MovieDbList
Tidy up other code
2013-08-22 13:13:25 +01:00
Stuart Boston 064117e66d Remove unused imports 2013-08-20 21:22:32 +01:00
Stuart Boston a520c75773 Remove duplicate literals 2013-08-20 21:12:26 +01:00
Stuart Boston 259eb81f32 Remove unused fields 2013-08-20 21:12:11 +01:00
Stuart Boston 8bfe7dcc1b WebBrowser: Throw MovieDbException 2013-08-20 21:11:34 +01:00
Stuart Boston ac57816b1d Merge pull request #6 from holgerbrandl/master
"List" and "Account" implemenation
2013-08-20 20:47:24 +01:00
Stuart Boston 073331cddb Close output stream 2013-08-20 13:18:06 +01:00
Stuart Boston 0ef278e19d Merge branch 'master' of https://github.com/Omertron/api-themoviedb 2013-08-20 09:01:28 +01:00
Stuart Boston d6e02bf1df Merge pull request #5 from holgerbrandl/master
implemented method to post movie ratings
2013-08-20 00:51:52 -07:00
holger fbdf744dc6 implemented method to post movie ratings 2013-08-19 14:28:28 +02:00
Stuart Boston 8478865141 Change ToString style to "short prefix" 2013-07-25 12:52:24 +01:00
Stuart Boston a98eac75dc Add dates to the wrapper where needed 2013-07-24 17:06:30 +01:00
Stuart Boston 9a237042f0 Change ToString style to "Simple" 2013-07-24 16:47:50 +01:00
Stuart Boston bb57c16fe8 Trim the string values for person to remove extra spaces 2013-07-22 13:43:54 +01:00
Stuart Boston 72186feaf9 Fixes issue #4 Company parent correctly de-serialised now 2013-07-15 09:16:16 +01:00
Stuart Boston 20349013cc Updated API-Common version 2013-06-26 16:31:47 +01:00
Stuart Boston c8e33abd59 Merge branch 'master' of https://github.com/Omertron/api-themoviedb 2013-06-26 16:30:42 +01:00
Stuart Boston 940b6a007f Revert "Updated API-Common version"
This reverts commit 822ac2a5d2.
2013-06-26 16:29:46 +01:00
Stuart Boston 822ac2a5d2 Updated API-Common version 2013-06-26 16:24:24 +01:00
Omertron f2593b2754 [maven-release-plugin] prepare for next development iteration 2013-06-26 14:31:33 +02:00
Omertron 24f7b507b9 [maven-release-plugin] prepare release themoviedbapi-3.6 2013-06-26 14:31:25 +02:00
Stuart Boston d298faec9a Removed getMovieChanges test 2013-06-26 13:29:24 +01:00
Stuart Boston 486486b753 Removed unused imports 2013-06-26 13:02:23 +01:00
Stuart Boston 159fe23efb Updated POM versions 2013-06-13 21:48:34 +01:00
Stuart Boston fc1e05d0b4 Added HTTP 503 error and message 2013-06-13 07:30:18 +01:00
Stuart Boston dc6f5f07b1 Standardised toString methods 2013-06-09 22:26:16 +01:00
Stuart Boston 4243b5aa81 Catch RuntimeException when 503 error 2013-06-09 18:23:41 +01:00
Stuart Boston 1070abcabc Update README.md 2013-06-04 10:38:46 +02:00
Stuart Boston 9cca4660bc Add adult and popularity to KeywordMovie 2013-06-03 12:13:46 +01:00
Stuart Boston 5f27260f57 Updated api-common dependency 2013-05-31 09:59:05 +01:00
Stuart Boston bec9b24129 Reverted to "com.moviejukebox" for groupId 2013-05-28 20:18:39 +01:00
Stuart Boston 8679b03930 Updated to use API-Common component for HTTPClient functionality 2013-05-28 14:27:00 +01:00
Stuart Boston 845aedf871 Added MovieChange method 2013-05-20 13:05:19 +01:00
Stuart Boston d6adc40215 Fix correct logging class for JobDepartment 2013-05-20 13:03:55 +01:00
Stuart Boston 17815b9ffc Fixed some issues 2013-05-20 10:36:01 +01:00
Stuart Boston 60cb490eca Add appendToResponse to person methods 2013-05-19 18:42:26 +01:00
Stuart Boston f08c78c921 Corrected resultsMap
Removed unused imports
2013-05-19 08:24:24 +01:00
Stuart Boston 0414369327 Removed unused imports and dead variables 2013-05-18 22:22:51 +01:00
Stuart Boston 44ba85aaa8 Changed return values to include page values 2013-05-18 22:08:40 +01:00
Stuart Boston 009e725cb6 Added new classes to return the results 2013-05-18 11:23:44 +01:00
Stuart Boston edf4518f35 Refactored Wrapper classes 2013-05-17 22:15:52 +01:00
Omertron c6248b621e [maven-release-plugin] prepare for next development iteration 2013-05-15 20:34:38 +02:00
Omertron 7900b6d25b [maven-release-plugin] prepare release themoviedbapi-3.5 2013-05-15 20:34:15 +02:00
Omertron 4747c42fc6 Updated POM versions 2013-05-15 20:31:44 +02:00
Stuart Boston 1a96343924 Updated Test class 2013-05-15 18:15:12 +01:00
Stuart Boston 76191c13c0 Add overview to CollectionInfo 2013-05-15 18:14:54 +01:00
Stuart Boston ce533c2b41 removed unused log messages in test class 2013-05-15 18:06:54 +01:00
Stuart Boston de623ff0db Add discover method 2013-05-15 16:24:57 +01:00
Stuart Boston 6745f5f3d5 Fix issue with WrapperImages not having initialised collections 2013-05-15 14:16:15 +01:00
Stuart Boston 955ef0369e Add Job List 2013-05-15 14:09:57 +01:00
Stuart Boston 4c682731b6 Add PopularPerson method 2013-05-15 13:46:59 +01:00
Stuart Boston c99f60f636 Un"ignored" the tests 2013-05-15 13:22:06 +01:00
Stuart Boston 265878d016 Added AppendToResponse for MovieDb (MovieInfo methods) 2013-05-15 13:19:02 +01:00
Stuart Boston 9bf7175ee8 Add "getAll" method to Images and Trailers 2013-05-15 13:18:14 +01:00
Stuart Boston 00063cc85d Add reviews 2013-05-15 13:16:44 +01:00
Stuart Boston 2f7468914c Allow AppendToReponse to contain multiple elements 2013-05-15 11:51:20 +01:00
Stuart Boston 4d9d53421f Add placeholder "append_to_response" parameters 2013-05-14 16:20:27 +01:00
Stuart Boston 9f135c3ca7 Removed reliance on MovieDb object from ApiBuilder 2013-05-14 16:01:25 +01:00
Stuart Boston 7d9552a08c Updated bin.xml to add correct README 2013-04-19 10:03:42 +01:00
Stuart Boston 3acf07b36a Non-functional changes to POM and bin.xml 2013-04-19 09:35:09 +01:00
Stuart Boston f501126b76 Reverted build version to 1.6 2013-04-03 15:05:45 +01:00
Stuart Boston 8ab8699dd5 updated version.txt 2013-03-25 22:08:40 +00:00
Stuart Boston 6c4ba2a492 Updated version.txt 2013-03-25 21:49:50 +00:00
Stuart Boston 44df73f2d1 Updated POM versions and build number 2013-03-25 20:57:44 +00:00
91 changed files with 10801 additions and 9352 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
+1
View File
@@ -6,3 +6,4 @@
*.ear *.ear
/target/ /target/
/nbactions.xml
+29 -6
View File
@@ -3,17 +3,40 @@ The Movie DB API
Author: Stuart Boston (Omertron AT Gmail DOT com) Author: Stuart Boston (Omertron AT Gmail DOT com)
This API uses the TheMovieDB.org API as specified here http://api.themoviedb.org/ This API uses the [TheMovieDB.org API](http://api.themoviedb.org/)
Originally written for use by YetAnotherMovieJukebox (YAMJ) http://code.google.com/p/moviejukebox/ Originally written for use by Yet Another Movie Jukebox [(YAMJ)](http://code.google.com/p/moviejukebox/)
But anyone can feel free to use it for other projects as well.
TheMovieDB.org is an excellent open database for movie and film content. I encourage you to check it out and contribute to keep it growing. But anyone can use it for other projects as well.
http://www.themoviedb.org
[![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.
I *strongly* encourage you to check it out and contribute to keep it growing.
### http://www.themoviedb.org
***
Project Logging Project Logging
--------------- ---------------
This project uses SLF4J (http://www.slf4j.org) to abstract the logging in the project. This project uses [SLF4J](http://www.slf4j.org) to abstract the logging in the project.
To use the logging in your own project you should add one of the bindings listed [HERE](http://www.slf4j.org/manual.html#swapping) To use the logging in your own project you should add one of the bindings listed [HERE](http://www.slf4j.org/manual.html#swapping)
Project Documentation Project Documentation
+46 -30
View File
@@ -13,7 +13,7 @@
<groupId>com.omertron</groupId> <groupId>com.omertron</groupId>
<artifactId>themoviedbapi</artifactId> <artifactId>themoviedbapi</artifactId>
<version>3.5-SNAPSHOT</version> <version>3.9</version>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>API-The MovieDB</name> <name>API-The MovieDB</name>
@@ -62,7 +62,7 @@
</issueManagement> </issueManagement>
<ciManagement> <ciManagement>
<system>Hudson CI</system> <system>Jenkins CI</system>
<url>http://jenkins.omertron.com/job/API-TheMovieDb/</url> <url>http://jenkins.omertron.com/job/API-TheMovieDb/</url>
</ciManagement> </ciManagement>
@@ -71,64 +71,67 @@
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding> <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<distribution.format>zip</distribution.format> <distribution.format>zip</distribution.format>
<version.jackson>2.3.0</version.jackson>
<version.slf4j>1.7.5</version.slf4j>
</properties> </properties>
<dependencies> <dependencies>
<!--TESTING-->
<dependency> <dependency>
<groupId>junit</groupId> <groupId>junit</groupId>
<artifactId>junit</artifactId> <artifactId>junit</artifactId>
<version>4.11</version> <version>4.11</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<!--JSON-->
<dependency> <dependency>
<groupId>com.fasterxml.jackson.core</groupId> <groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId> <artifactId>jackson-core</artifactId>
<version>2.1.4</version> <version>${version.jackson}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.fasterxml.jackson.core</groupId> <groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId> <artifactId>jackson-annotations</artifactId>
<version>2.1.4</version> <version>${version.jackson}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.fasterxml.jackson.core</groupId> <groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId> <artifactId>jackson-databind</artifactId>
<version>2.1.4</version> <version>${version.jackson}</version>
</dependency>
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.7</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId>
<version>3.1</version>
</dependency> </dependency>
<!--LOGGING-->
<dependency> <dependency>
<groupId>org.slf4j</groupId> <groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId> <artifactId>slf4j-api</artifactId>
<version>1.7.3</version> <version>${version.slf4j}</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.slf4j</groupId> <groupId>org.slf4j</groupId>
<artifactId>slf4j-jdk14</artifactId> <artifactId>slf4j-jdk14</artifactId>
<version>1.7.3</version> <version>${version.slf4j}</version>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<!--COMMON HTTP TOOLS-->
<dependency>
<groupId>org.yamj</groupId>
<artifactId>api-common</artifactId>
<version>1.1</version>
</dependency>
</dependencies> </dependencies>
<build> <build>
<finalName>${project.artifactId}-${project.version}-r${buildNumber}</finalName> <finalName>${project.artifactId}-${project.version}-${buildNumber}</finalName>
<plugins> <plugins>
<plugin> <plugin>
<groupId>org.codehaus.mojo</groupId> <groupId>org.codehaus.mojo</groupId>
<artifactId>buildnumber-maven-plugin</artifactId> <artifactId>buildnumber-maven-plugin</artifactId>
<version>1.2</version> <version>1.2</version>
<configuration> <configuration>
<getRevisionOnlyOnce>true</getRevisionOnlyOnce> <shortRevisionLength>10</shortRevisionLength>
<revisionOnScmFailure>0000</revisionOnScmFailure> <doCheck>false</doCheck>
<doUpdate>false</doUpdate>
<timestampFormat>{0,date,yyyy-MM-dd HH:mm:ss}</timestampFormat> <timestampFormat>{0,date,yyyy-MM-dd HH:mm:ss}</timestampFormat>
</configuration> </configuration>
<executions> <executions>
@@ -140,10 +143,11 @@
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId> <artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version> <version>3.1</version>
<configuration> <configuration>
<source>1.6</source> <source>1.6</source>
<target>1.6</target> <target>1.6</target>
@@ -152,6 +156,7 @@
<!-- excludes><exclude>**/*</exclude></excludes --> <!-- excludes><exclude>**/*</exclude></excludes -->
</configuration> </configuration>
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId> <artifactId>maven-jar-plugin</artifactId>
@@ -167,15 +172,17 @@
</archive> </archive>
</configuration> </configuration>
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId> <artifactId>maven-surefire-plugin</artifactId>
<version>2.13</version> <version>2.16</version>
<configuration> <configuration>
<!-- To skip tests by default --> <!-- To skip tests by default -->
<skipTests>${skipTests}</skipTests> <skipTests>${skipTests}</skipTests>
</configuration> </configuration>
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId> <artifactId>maven-antrun-plugin</artifactId>
@@ -190,12 +197,12 @@
<property name="header_line" value="The MovieDb API${line.separator}" /> <property name="header_line" value="The MovieDb API${line.separator}" />
<property name="build_date_line" value="Build Date: ${timestamp}${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="version_line" value="Version: ${project.version}${line.separator}" />
<!--<property name="revision_line" value="Revision: r${buildNumber}${line.separator}" />--> <property name="buildnumber_line" value="Git-SHA: ${buildNumber}${line.separator}" />
<echo>Writing version file: ${version_file}</echo> <echo>Writing version file: ${version_file}</echo>
<echo file="${version_file}" append="false">${header_line}</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">${build_date_line}</echo>
<echo file="${version_file}" append="true">${version_line}</echo> <echo file="${version_file}" append="true">${version_line}</echo>
<!--<echo file="${version_file}" append="true">${revision_line}</echo>--> <echo file="${version_file}" append="true">${buildnumber_line}</echo>
</target> </target>
</configuration> </configuration>
<goals> <goals>
@@ -204,6 +211,7 @@
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId> <artifactId>maven-assembly-plugin</artifactId>
@@ -223,15 +231,17 @@
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.codehaus.mojo</groupId> <groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId> <artifactId>versions-maven-plugin</artifactId>
<version>2.0</version> <version>2.1</version>
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId> <artifactId>maven-site-plugin</artifactId>
<version>3.2</version> <version>3.3</version>
<configuration> <configuration>
<reportPlugins> <reportPlugins>
<plugin> <plugin>
@@ -259,43 +269,49 @@
</reportPlugins> </reportPlugins>
</configuration> </configuration>
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId> <artifactId>maven-clean-plugin</artifactId>
<version>2.5</version> <version>2.5</version>
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId> <artifactId>maven-deploy-plugin</artifactId>
<version>2.7</version> <version>2.8.1</version>
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId> <artifactId>maven-gpg-plugin</artifactId>
<version>1.4</version> <version>1.4</version>
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId> <artifactId>maven-install-plugin</artifactId>
<version>2.4</version> <version>2.5.1</version>
</plugin> </plugin>
<plugin> <plugin>
<groupId>org.apache.maven.plugins</groupId> <groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId> <artifactId>maven-resources-plugin</artifactId>
<version>2.6</version> <version>2.6</version>
</plugin> </plugin>
</plugins> </plugins>
<extensions> <extensions>
<extension> <extension>
<groupId>org.apache.maven.scm</groupId> <groupId>org.apache.maven.scm</groupId>
<artifactId>maven-scm-provider-gitexe</artifactId> <artifactId>maven-scm-provider-gitexe</artifactId>
<version>1.4</version> <version>1.8.1</version>
</extension> </extension>
<extension> <extension>
<groupId>org.apache.maven.scm</groupId> <groupId>org.apache.maven.scm</groupId>
<artifactId>maven-scm-manager-plexus</artifactId> <artifactId>maven-scm-manager-plexus</artifactId>
<version>1.4</version> <version>1.8.1</version>
</extension> </extension>
<extension> <extension>
<groupId>org.kathrynhuxtable.maven.wagon</groupId> <groupId>org.kathrynhuxtable.maven.wagon</groupId>
@@ -55,7 +55,11 @@ public class MovieDbException extends Exception {
/* /*
* Autorisation rejected * Autorisation rejected
*/ */
AUTHORISATION_FAILURE; AUTHORISATION_FAILURE,
/*
* Service Unavailable, usually temporary
*/
HTTP_503_ERROR;
} }
private final MovieDbExceptionType exceptionType; private final MovieDbExceptionType exceptionType;
File diff suppressed because it is too large Load Diff
@@ -0,0 +1,70 @@
/*
* Copyright (c) 2004-2013 Stuart Boston
*
* This file is part of TheMovieDB API.
*
* TheMovieDB API is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation;private either version 3 of the License;private or
* any later version.
*
* TheMovieDB API is distributed in the hope that it will be useful;private
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TheMovieDB API. If not;private see <http://www.gnu.org/licenses/>.
*
*/
package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.Serializable;
/**
* Abstract class to handle any unknown properties by outputting a log message
*
* @author stuart.boston
*/
public abstract class AbstractJsonMapping implements Serializable {
private Logger log = null;
/**
* Return the current logger.
*
* @return
*/
private Logger getLogger() {
if (log == null) {
log = LoggerFactory.getLogger(this.getClass());
}
return log;
}
/**
* Handle unknown properties and print a message
*
* @param key
* @param value
*/
@JsonAnySetter
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().trace(unknown.toString());
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
}
}
@@ -0,0 +1,86 @@
/*
* Copyright (c) 2004-2013 Stuart Boston
*
* This file is part of TheMovieDB API.
*
* TheMovieDB API is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation;private either version 3 of the License;private or
* any later version.
*
* TheMovieDB API is distributed in the hope that it will be useful;private
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TheMovieDB API. If not;private see <http://www.gnu.org/licenses/>.
*
*/
package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonProperty;
public class Account extends AbstractJsonMapping {
@JsonProperty("id")
private int id;
@JsonProperty("name")
private String name;
@JsonProperty("username")
private String userName;
@JsonProperty("include_adult")
private boolean includeAdult;
@JsonProperty("iso_639_1")
private String language;
@JsonProperty("iso_3166_1")
private String country;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public boolean isIncludeAdult() {
return includeAdult;
}
public void setIncludeAdult(boolean includeAdult) {
this.includeAdult = includeAdult;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
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;
}
}
@@ -19,24 +19,17 @@
*/ */
package com.omertron.themoviedbapi.model; package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import java.io.Serializable; import java.io.Serializable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
*
* @author Stuart * @author Stuart
*/ */
public class AlternativeTitle implements Serializable { public class AlternativeTitle implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/*
* Logger
*/
private static final Logger LOG = LoggerFactory.getLogger(AlternativeTitle.class);
/* /*
* Properties * Properties
*/ */
@@ -65,20 +58,6 @@ public class AlternativeTitle implements Serializable {
} }
// </editor-fold> // </editor-fold>
/**
* Handle unknown properties and print a message
*
* @param key
* @param value
*/
@JsonAnySetter
public void handleUnknown(String key, Object value) {
StringBuilder sb = new StringBuilder();
sb.append("Unknown property: '").append(key);
sb.append("' value: '").append(value).append("'");
LOG.trace(sb.toString());
}
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (obj == null) { if (obj == null) {
@@ -104,13 +83,4 @@ public class AlternativeTitle implements Serializable {
hash = 89 * hash + (this.title != null ? this.title.hashCode() : 0); hash = 89 * hash + (this.title != null ? this.title.hashCode() : 0);
return hash; return hash;
} }
@Override
public String toString() {
StringBuilder sb = new StringBuilder("[AlternativeTitle=");
sb.append("[country=").append(country);
sb.append("],[title=").append(title);
sb.append("]]");
return sb.toString();
}
} }
@@ -19,28 +19,17 @@
*/ */
package com.omertron.themoviedbapi.model; package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import java.io.Serializable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* The artwork type information * The artwork type information
* *
* @author Stuart * @author Stuart
*/ */
public class Artwork implements Serializable { public class Artwork extends AbstractJsonMapping {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/*
* Logger
*/
private static final Logger LOG = LoggerFactory.getLogger(Artwork.class);
/*
* Properties
*/
@JsonProperty("aspect_ratio") @JsonProperty("aspect_ratio")
private float aspectRatio; private float aspectRatio;
@JsonProperty("file_path") @JsonProperty("file_path")
@@ -59,7 +48,6 @@ public class Artwork implements Serializable {
private String flag; private String flag;
private ArtworkType artworkType = ArtworkType.POSTER; private ArtworkType artworkType = ArtworkType.POSTER;
// <editor-fold defaultstate="collapsed" desc="Getter methods">
public ArtworkType getArtworkType() { public ArtworkType getArtworkType() {
return artworkType; return artworkType;
} }
@@ -96,9 +84,6 @@ public class Artwork implements Serializable {
return flag; return flag;
} }
// </editor-fold>
// <editor-fold defaultstate="collapsed" desc="Setter methods">
public void setArtworkType(ArtworkType artworkType) { public void setArtworkType(ArtworkType artworkType) {
this.artworkType = artworkType; this.artworkType = artworkType;
} }
@@ -131,26 +116,10 @@ public class Artwork implements Serializable {
this.voteCount = voteCount; this.voteCount = voteCount;
} }
public void setFlag(String flag) { public void setFlag(String flag) {
this.flag = flag; this.flag = flag;
} }
// </editor-fold>
/**
* Handle unknown properties and print a message
*
* @param key
* @param value
*/
@JsonAnySetter
public void handleUnknown(String key, Object value) {
StringBuilder sb = new StringBuilder();
sb.append("Unknown property: '").append(key);
sb.append("' value: '").append(value).append("'");
LOG.trace(sb.toString());
}
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (obj == null) { if (obj == null) {
@@ -192,17 +161,4 @@ public class Artwork implements Serializable {
hash = 71 * hash + (this.artworkType != null ? this.artworkType.hashCode() : 0); hash = 71 * hash + (this.artworkType != null ? this.artworkType.hashCode() : 0);
return hash; return hash;
} }
@Override
public String toString() {
StringBuilder sb = new StringBuilder("[Artwork=");
sb.append("[aspectRatio=").append(aspectRatio);
sb.append("],[filePath=").append(filePath);
sb.append("],[height=").append(height);
sb.append("],[language=").append(language);
sb.append("],[width=").append(width);
sb.append("],[artworkType=").append(artworkType);
sb.append("]]");
return sb.toString();
}
} }
@@ -24,7 +24,10 @@ package com.omertron.themoviedbapi.model;
*/ */
public enum ArtworkType { public enum ArtworkType {
POSTER, // Poster artwork // Poster artwork
BACKDROP, // Fanart/backdrop POSTER,
PROFILE // Person image // Fanart/backdrop
BACKDROP,
// Person image
PROFILE
} }
@@ -1,122 +0,0 @@
/*
* Copyright (c) 2004-2013 Stuart Boston
*
* This file is part of TheMovieDB API.
*
* TheMovieDB API is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* TheMovieDB API is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>.
*
*/
package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class ChangeItem {
private static final long serialVersionUID = 1L;
/*
* Logger
*/
private static final Logger LOG = LoggerFactory.getLogger(MovieChanges.class);
/*
* Properties
*/
@JsonProperty("id")
private String id;
@JsonProperty("action")
private String action;
@JsonProperty("time")
private String time;
@JsonProperty("value")
private ChangeValue value;
@JsonProperty("original_value")
private ChangeValue originalValue;
@JsonProperty("iso_639_1")
private String language;
//<editor-fold defaultstate="collapsed" desc="Getter Methods">
public String getId() {
return id;
}
public String getAction() {
return action;
}
public String getTime() {
return time;
}
public ChangeValue getValue() {
return value;
}
public ChangeValue getOriginalValue() {
return originalValue;
}
public String getLanguage() {
return language;
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="Setter Methods">
public void setId(String id) {
this.id = id;
}
public void setAction(String action) {
this.action = action;
}
public void setTime(String time) {
this.time = time;
}
public void setValue(ChangeValue value) {
this.value = value;
}
public void setOriginalValue(ChangeValue originalValue) {
this.originalValue = originalValue;
}
public void setLanguage(String language) {
this.language = language;
}
//</editor-fold>
@Override
public String toString() {
return "ChangeItem{" + "id=" + id + ", action=" + action + ", time=" + time + ", value=" + value + '}';
}
/**
* Handle unknown properties and print a message
*
* @param key
* @param value
*/
@JsonAnySetter
public void handleUnknown(String key, Object value) {
StringBuilder sb = new StringBuilder();
sb.append("Unknown property: '").append(key);
sb.append("' value: '").append(value).append("'");
LOG.trace(sb.toString());
}
}
@@ -0,0 +1,46 @@
package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
public class ChangeKeyItem {
private static final long serialVersionUID = 1L;
@JsonProperty("key")
private String key;
@JsonProperty("items")
private List<ChangedItem> changedItems = new ArrayList<ChangedItem>();
private final Map<String, Object> newItems = new HashMap<String, Object>();
public String getKey() {
return key;
}
public void setKey(String key) {
this.key = key;
}
public List<ChangedItem> getChangedItems() {
return changedItems;
}
public void setChangedItems(List<ChangedItem> changes) {
this.changedItems = changes;
}
@JsonAnyGetter
public Map<String, Object> getNewItems() {
return this.newItems;
}
@JsonAnySetter
public void setNewItems(String name, Object value) {
this.newItems.put(name, value);
}
}
@@ -1,128 +0,0 @@
/*
* Copyright (c) 2004-2013 Stuart Boston
*
* This file is part of TheMovieDB API.
*
* TheMovieDB API is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* TheMovieDB API is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>.
*
*/
package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class ChangeValue {
private static final long serialVersionUID = 1L;
/*
* Logger
*/
private static final Logger LOG = LoggerFactory.getLogger(MovieChanges.class);
/*
* Properties
*/
@JsonProperty("poster")
private Artwork poster;
@JsonProperty("backdrop")
private Artwork backdrop;
@JsonProperty("title")
private String title;
@JsonProperty("iso_3166_1")
private String language;
@JsonProperty("site")
private String site;
@JsonProperty("name")
private String name;
@JsonProperty("id")
private int id;
//<editor-fold defaultstate="collapsed" desc="Getter Methods">
public Artwork getPoster() {
return poster;
}
public Artwork getBackdrop() {
return backdrop;
}
public String getTitle() {
return title;
}
public String getLanguage() {
return language;
}
public String getSite() {
return site;
}
public String getName() {
return name;
}
public int getId() {
return id;
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="Setter Methods">
public void setPoster(Artwork poster) {
this.poster = poster;
}
public void setBackdrop(Artwork backdrop) {
this.backdrop = backdrop;
backdrop.setArtworkType(ArtworkType.BACKDROP);
}
public void setTitle(String title) {
this.title = title;
}
public void setLanguage(String language) {
this.language = language;
}
public void setSite(String site) {
this.site = site;
}
public void setName(String name) {
this.name = name;
}
public void setId(int id) {
this.id = id;
}
//</editor-fold>
/**
* Handle unknown properties and print a message
*
* @param key
* @param value
*/
@JsonAnySetter
public void handleUnknown(String key, Object value) {
StringBuilder sb = new StringBuilder();
sb.append("Unknown property: '").append(key);
sb.append("' value: '").append(value).append("'");
LOG.trace(sb.toString());
}
}
@@ -0,0 +1,74 @@
package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.HashMap;
import java.util.Map;
public class ChangedItem extends AbstractJsonMapping {
private static final long serialVersionUID = 1L;
@JsonProperty("id")
private String id;
@JsonProperty("action")
private String action;
@JsonProperty("time")
private String time;
@JsonProperty("iso_639_1")
private String language;
@JsonProperty("value")
private Object value;
private final Map<String, Object> newItems = new HashMap<String, Object>();
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getAction() {
return action;
}
public void setAction(String action) {
this.action = action;
}
public String getTime() {
return time;
}
public void setTime(String time) {
this.time = time;
}
public String getLanguage() {
return language;
}
public void setLanguage(String language) {
this.language = language;
}
public Object getValue() {
return value;
}
public void setValue(Object value) {
this.value = value;
}
@JsonAnyGetter
public Map<String, Object> getNewItems() {
return this.newItems;
}
@JsonAnySetter
public void setNewItems(String name, Object value) {
this.newItems.put(name, value);
}
}
@@ -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;
}
}
@@ -19,26 +19,18 @@
*/ */
package com.omertron.themoviedbapi.model; package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonRootName; import com.fasterxml.jackson.annotation.JsonRootName;
import java.io.Serializable;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
*
* @author stuart.boston * @author stuart.boston
*/ */
@JsonRootName("collection") @JsonRootName("collection")
public class Collection implements Serializable { public class Collection extends AbstractJsonMapping {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/*
* Logger
*/
private static final Logger LOG = LoggerFactory.getLogger(Collection.class);
/* /*
* Properties * Properties
*/ */
@@ -55,7 +47,6 @@ public class Collection implements Serializable {
@JsonProperty("release_date") @JsonProperty("release_date")
private String releaseDate; private String releaseDate;
//<editor-fold defaultstate="collapsed" desc="Getter methods">
public String getBackdropPath() { public String getBackdropPath() {
return backdropPath; return backdropPath;
} }
@@ -85,9 +76,7 @@ public class Collection implements Serializable {
} }
return name; return name;
} }
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="Setter methods">
public void setBackdropPath(String backdropPath) { public void setBackdropPath(String backdropPath) {
this.backdropPath = backdropPath; this.backdropPath = backdropPath;
} }
@@ -111,21 +100,6 @@ public class Collection implements Serializable {
public void setName(String name) { public void setName(String name) {
this.name = name; this.name = name;
} }
//</editor-fold>
/**
* Handle unknown properties and print a message
*
* @param key
* @param value
*/
@JsonAnySetter
public void handleUnknown(String key, Object value) {
StringBuilder sb = new StringBuilder();
sb.append("Unknown property: '").append(key);
sb.append("' value: '").append(value).append("'");
LOG.trace(sb.toString());
}
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
@@ -162,17 +136,4 @@ public class Collection implements Serializable {
hash = 19 * hash + (this.releaseDate != null ? this.releaseDate.hashCode() : 0); hash = 19 * hash + (this.releaseDate != null ? this.releaseDate.hashCode() : 0);
return hash; return hash;
} }
@Override
public String toString() {
StringBuilder sb = new StringBuilder("[Collection=");
sb.append("[id=").append(id);
sb.append("],[title=").append(title);
sb.append("],[name=").append(name);
sb.append("],[posterPath=").append(posterPath);
sb.append("],[backdropPath=").append(backdropPath);
sb.append("],[releaseDate=").append(releaseDate);
sb.append("]]");
return sb.toString();
}
} }
@@ -19,25 +19,18 @@
*/ */
package com.omertron.themoviedbapi.model; package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
*
* @author Stuart * @author Stuart
*/ */
public class CollectionInfo implements Serializable { public class CollectionInfo extends AbstractJsonMapping {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/*
* Logger
*/
private static final Logger LOG = LoggerFactory.getLogger(CollectionInfo.class);
/* /*
* Properties * Properties
*/ */
@@ -45,6 +38,8 @@ public class CollectionInfo implements Serializable {
private int id; private int id;
@JsonProperty("name") @JsonProperty("name")
private String name; private String name;
@JsonProperty("overview")
private String overview;
@JsonProperty("poster_path") @JsonProperty("poster_path")
private String posterPath; private String posterPath;
@JsonProperty("backdrop_path") @JsonProperty("backdrop_path")
@@ -52,7 +47,6 @@ public class CollectionInfo implements Serializable {
@JsonProperty("parts") @JsonProperty("parts")
private List<Collection> parts = new ArrayList<Collection>(); private List<Collection> parts = new ArrayList<Collection>();
//<editor-fold defaultstate="collapsed" desc="Getter methods">
public String getBackdropPath() { public String getBackdropPath() {
return backdropPath; return backdropPath;
} }
@@ -65,6 +59,10 @@ public class CollectionInfo implements Serializable {
return name; return name;
} }
public String getOverview() {
return overview;
}
public List<Collection> getParts() { public List<Collection> getParts() {
return parts; return parts;
} }
@@ -72,9 +70,7 @@ public class CollectionInfo implements Serializable {
public String getPosterPath() { public String getPosterPath() {
return posterPath; return posterPath;
} }
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="Setter methods">
public void setBackdropPath(String backdropPath) { public void setBackdropPath(String backdropPath) {
this.backdropPath = backdropPath; this.backdropPath = backdropPath;
} }
@@ -87,6 +83,10 @@ public class CollectionInfo implements Serializable {
this.name = name; this.name = name;
} }
public void setOverview(String overview) {
this.overview = overview;
}
public void setParts(List<Collection> parts) { public void setParts(List<Collection> parts) {
this.parts = parts; this.parts = parts;
} }
@@ -94,31 +94,4 @@ public class CollectionInfo implements Serializable {
public void setPosterPath(String posterPath) { public void setPosterPath(String posterPath) {
this.posterPath = posterPath; this.posterPath = posterPath;
} }
//</editor-fold>
/**
* Handle unknown properties and print a message
*
* @param key
* @param value
*/
@JsonAnySetter
public void handleUnknown(String key, Object value) {
StringBuilder sb = new StringBuilder();
sb.append("Unknown property: '").append(key);
sb.append("' value: '").append(value).append("'");
LOG.trace(sb.toString());
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder("[CollectionInfo=");
sb.append("[id=").append(id);
sb.append("],[name=").append(name);
sb.append("],[posterPath=").append(posterPath);
sb.append("],[backdropPath=").append(backdropPath);
sb.append("],[# of parts=").append(parts.size());
sb.append("]]");
return sb.toString();
}
} }
@@ -19,22 +19,16 @@
*/ */
package com.omertron.themoviedbapi.model; package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import java.io.Serializable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* Company information * Company information
* *
* @author Stuart * @author Stuart
*/ */
public class Company implements Serializable { public class Company extends AbstractJsonMapping {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
// Logger
private static final Logger LOG = LoggerFactory.getLogger(Company.class);
private static final String DEFAULT_STRING = ""; private static final String DEFAULT_STRING = "";
// Properties // Properties
@JsonProperty("id") @JsonProperty("id")
@@ -50,9 +44,8 @@ public class Company implements Serializable {
@JsonProperty("logo_path") @JsonProperty("logo_path")
private String logoPath = DEFAULT_STRING; private String logoPath = DEFAULT_STRING;
@JsonProperty("parent_company") @JsonProperty("parent_company")
private String parentCompany = DEFAULT_STRING; private Company parentCompany = null;
//<editor-fold defaultstate="collapsed" desc="Getter Methods">
public int getCompanyId() { public int getCompanyId() {
return companyId; return companyId;
} }
@@ -77,12 +70,10 @@ public class Company implements Serializable {
return name; return name;
} }
public String getParentCompany() { public Company getParentCompany() {
return parentCompany; return parentCompany;
} }
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="Setter Methods">
public void setCompanyId(int companyId) { public void setCompanyId(int companyId) {
this.companyId = companyId; this.companyId = companyId;
} }
@@ -107,27 +98,15 @@ public class Company implements Serializable {
this.name = name; this.name = name;
} }
public void setParentCompany(String parentCompany) { public void setParentCompany(Company parentCompany) {
this.parentCompany = parentCompany; this.parentCompany = parentCompany;
} }
//</editor-fold>
/** public void setParentCompany(int id, String name, String logoPath) {
* Handle unknown properties and print a message Company parent = new Company();
* parent.setCompanyId(companyId);
* @param key parent.setName(name);
* @param value parent.setLogoPath(logoPath);
*/ this.parentCompany = parent;
@JsonAnySetter
public void handleUnknown(String key, Object value) {
StringBuilder sb = new StringBuilder();
sb.append("Unknown property: '").append(key);
sb.append("' value: '").append(value).append("'");
LOG.trace(sb.toString());
}
@Override
public String toString() {
return "Company{" + "companyId=" + companyId + ", name=" + name + ", description=" + description + ", headquarters=" + headquarters + ", homepage=" + homepage + ", logoPath=" + logoPath + ", parentCompany=" + parentCompany + '}';
} }
} }
@@ -0,0 +1,278 @@
/*
* Copyright (c) 2004-2013 Stuart Boston
*
* This file is part of TheMovieDB API.
*
* TheMovieDB API is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation;private either version 3 of the License;private or
* any later version.
*
* TheMovieDB API is distributed in the hope that it will be useful;private
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TheMovieDB API. If not;private see <http://www.gnu.org/licenses/>.
*
*/
package com.omertron.themoviedbapi.model;
import org.apache.commons.lang3.StringUtils;
import java.util.HashMap;
import java.util.Map;
import static com.omertron.themoviedbapi.tools.ApiUrl.*;
/**
* Generate a discover object for use in the MovieDbApi
* <p/>
* This allows you to just add the search components you are concerned with
*
* @author stuart.boston
*/
public class Discover {
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=";
private static final String PARAM_WITH_GENRES = "with_genres=";
private static final String PARAM_RELEASE_DATE_GTE = "release_date.gte=";
private static final String PARAM_RELEASE_DATE_LTE = "release_date.lte=";
private static final String PARAM_CERTIFICATION_COUNTRY = "certification_country=";
private static final String PARAM_CERTIFICATION_LTE = "certification.lte=";
private static final String PARAM_WITH_COMPANIES = "with_companies=";
private static final String PARAM_SORT_BY = "sort_by=";
private static final int YEAR_MIN = 1900;
private static final int YEAR_MAX = 2100;
/**
* Get the parameters
* <p/>
* This will be used to construct the URL in the API
*
* @return
*/
public Map<String, String> getParams() {
return params;
}
/**
* Minimum value is 1 if included.
*
* @param page
* @return
*/
public Discover page(int page) {
if (page > 0) {
params.put(PARAM_PAGE, String.valueOf(page));
}
return this;
}
/**
* ISO 639-1 code
*
* @param language
* @return
*/
public Discover language(String language) {
if (StringUtils.isNotBlank(language)) {
params.put(PARAM_LANGUAGE, language);
}
return this;
}
/**
* Available options are <br>
* vote_average.desc<br>
* vote_average.asc<br>
* release_date.desc<br>
* release_date.asc<br>
* popularity.desc<br>
* popularity.asc
*
* @param sortBy
* @return
*/
public Discover sortBy(String sortBy) {
if (StringUtils.isNotBlank(sortBy)) {
params.put(PARAM_SORT_BY, sortBy);
}
return this;
}
/**
* Toggle the inclusion of adult titles
*
* @param includeAdult
* @return
*/
public Discover includeAdult(boolean includeAdult) {
params.put(PARAM_ADULT, String.valueOf(includeAdult));
return this;
}
/**
* Filter the results release dates to matches that include this value.
*
* @param year
* @return
*/
public Discover year(int year) {
if (checkYear(year)) {
params.put(PARAM_YEAR, String.valueOf(year));
}
return this;
}
/**
* 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)) {
params.put(PARAM_PRIMARY_RELEASE_YEAR, String.valueOf(primaryReleaseYear));
}
return this;
}
/**
* 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) {
params.put(PARAM_VOTE_COUNT_GTE, String.valueOf(voteCountGte));
}
return this;
}
/**
* 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) {
params.put(PARAM_VOTE_AVERAGE_GTE, String.valueOf(voteAverageGte));
}
return this;
}
/**
* Only include movies with the specified genres.
* <p/>
* Expected value is an integer (the id of a genre).
* <p/>
* Multiple values can be specified.
* <p/>
* 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)) {
params.put(PARAM_WITH_GENRES, withGenres);
}
return this;
}
/**
* The minimum release to include.
* <p/>
* Expected format is YYYY-MM-DD.
*
* @param releaseDateGte
* @return
*/
public Discover releaseDateGte(String releaseDateGte) {
if (StringUtils.isNotBlank(releaseDateGte)) {
params.put(PARAM_RELEASE_DATE_GTE, releaseDateGte);
}
return this;
}
/**
* The maximum release to include.
* <p/>
* Expected format is YYYY-MM-DD.
*
* @param releaseDateLte
* @return
*/
public Discover releaseDateLte(String releaseDateLte) {
if (StringUtils.isNotBlank(releaseDateLte)) {
params.put(PARAM_RELEASE_DATE_LTE, releaseDateLte);
}
return this;
}
/**
* Only include movies with certifications for a specific country.
* <p/>
* When this value is specified, 'certificationLte' is required.
* <p/>
* A ISO 3166-1 is expected
*
* @param certificationCountry
* @return
*/
public Discover certificationCountry(String certificationCountry) {
if (StringUtils.isNotBlank(certificationCountry)) {
params.put(PARAM_CERTIFICATION_COUNTRY, certificationCountry);
}
return this;
}
/**
* Only include movies with this certification and lower.
* <p/>
* Expected value is a valid certification for the specified 'certificationCountry'.
*
* @param certificationLte
* @return
*/
public Discover certificationLte(String certificationLte) {
if (StringUtils.isNotBlank(certificationLte)) {
params.put(PARAM_CERTIFICATION_LTE, certificationLte);
}
return this;
}
/**
* Filter movies to include a specific company.
* <p/>
* Expected value is an integer (the id of a company).
* <p/>
* They can be comma separated to indicate an 'AND' query
*
* @param withCompanies
* @return
*/
public Discover withCompanies(String withCompanies) {
if (StringUtils.isNotBlank(withCompanies)) {
params.put(PARAM_WITH_COMPANIES, withCompanies);
}
return this;
}
/**
* check the year is between the min and max
*
* @param year
* @return
*/
private boolean checkYear(int year) {
return (year >= YEAR_MIN && year <= YEAR_MAX);
}
}
@@ -19,25 +19,16 @@
*/ */
package com.omertron.themoviedbapi.model; package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonRootName; import com.fasterxml.jackson.annotation.JsonRootName;
import java.io.Serializable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
*
* @author stuart.boston * @author stuart.boston
*/ */
@JsonRootName("genre") @JsonRootName("genre")
public class Genre implements Serializable { public class Genre extends AbstractJsonMapping {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/*
* Logger
*/
private static final Logger LOG = LoggerFactory.getLogger(Genre.class);
/* /*
* Properties * Properties
*/ */
@@ -46,7 +37,6 @@ public class Genre implements Serializable {
@JsonProperty("name") @JsonProperty("name")
private String name; private String name;
//<editor-fold defaultstate="collapsed" desc="Getter methods">
public int getId() { public int getId() {
return id; return id;
} }
@@ -54,9 +44,7 @@ public class Genre implements Serializable {
public String getName() { public String getName() {
return name; return name;
} }
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="Setter methods">
public void setId(int id) { public void setId(int id) {
this.id = id; this.id = id;
} }
@@ -64,21 +52,6 @@ public class Genre implements Serializable {
public void setName(String name) { public void setName(String name) {
this.name = name; this.name = name;
} }
//</editor-fold>
/**
* Handle unknown properties and print a message
*
* @param key
* @param value
*/
@JsonAnySetter
public void handleUnknown(String key, Object value) {
StringBuilder sb = new StringBuilder();
sb.append("Unknown property: '").append(key);
sb.append("' value: '").append(value).append("'");
LOG.trace(sb.toString());
}
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
@@ -105,13 +78,4 @@ public class Genre implements Serializable {
hash = 53 * hash + (this.name != null ? this.name.hashCode() : 0); hash = 53 * hash + (this.name != null ? this.name.hashCode() : 0);
return hash; return hash;
} }
@Override
public String toString() {
StringBuilder sb = new StringBuilder("[Genre=");
sb.append("[id=").append(id);
sb.append("],[name=").append(name);
sb.append("]]");
return sb.toString();
}
} }
@@ -0,0 +1,50 @@
/*
* Copyright (c) 2004-2013 Stuart Boston
*
* This file is part of TheMovieDB API.
*
* TheMovieDB API is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* TheMovieDB API is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>.
*
*/
package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.List;
public class JobDepartment extends AbstractJsonMapping {
private static final long serialVersionUID = 1L;
// Properties
@JsonProperty("department")
private String department;
@JsonProperty("job_list")
private List<String> jobs;
public String getDepartment() {
return department;
}
public List<String> getJobs() {
return jobs;
}
public void setDepartment(String department) {
this.department = department;
}
public void setJobs(List<String> jobs) {
this.jobs = jobs;
}
}
@@ -19,26 +19,17 @@
*/ */
package com.omertron.themoviedbapi.model; package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonRootName; import com.fasterxml.jackson.annotation.JsonRootName;
import java.io.Serializable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
*
* @author stuart.boston * @author stuart.boston
*/ */
@JsonRootName("keyword") @JsonRootName("keyword")
public class Keyword implements Serializable { public class Keyword extends AbstractJsonMapping {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/*
* Logger
*/
private static final Logger LOG = LoggerFactory.getLogger(Keyword.class);
/* /*
* Properties * Properties
*/ */
@@ -47,7 +38,6 @@ public class Keyword implements Serializable {
@JsonProperty("name") @JsonProperty("name")
private String name; private String name;
//<editor-fold defaultstate="collapsed" desc="Getter methods">
public int getId() { public int getId() {
return id; return id;
} }
@@ -55,9 +45,7 @@ public class Keyword implements Serializable {
public String getName() { public String getName() {
return name; return name;
} }
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="Setter methods">
public void setId(int id) { public void setId(int id) {
this.id = id; this.id = id;
} }
@@ -65,21 +53,6 @@ public class Keyword implements Serializable {
public void setName(String name) { public void setName(String name) {
this.name = name; this.name = name;
} }
//</editor-fold>
/**
* Handle unknown properties and print a message
*
* @param key
* @param value
*/
@JsonAnySetter
public void handleUnknown(String key, Object value) {
StringBuilder sb = new StringBuilder();
sb.append("Unknown property: '").append(key);
sb.append("' value: '").append(value).append("'");
LOG.trace(sb.toString());
}
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
@@ -106,13 +79,4 @@ public class Keyword implements Serializable {
hash = 83 * hash + (this.name != null ? this.name.hashCode() : 0); hash = 83 * hash + (this.name != null ? this.name.hashCode() : 0);
return hash; return hash;
} }
@Override
public String toString() {
StringBuilder sb = new StringBuilder("[Keyword=");
sb.append("[id=").append(id);
sb.append("],[name=").append(name);
sb.append("]]");
return sb.toString();
}
} }
@@ -19,24 +19,15 @@
*/ */
package com.omertron.themoviedbapi.model; package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import java.io.Serializable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
*
* @author Stuart * @author Stuart
*/ */
public class KeywordMovie implements Serializable { public class KeywordMovie extends AbstractJsonMapping {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/*
* Logger
*/
private static final Logger LOG = LoggerFactory.getLogger(KeywordMovie.class);
/* /*
* Properties * Properties
*/ */
@@ -56,8 +47,11 @@ public class KeywordMovie implements Serializable {
private float voteAverage; private float voteAverage;
@JsonProperty("vote_count") @JsonProperty("vote_count")
private double voteCount; private double voteCount;
@JsonProperty("adult")
private boolean adult;
@JsonProperty("popularity")
private float popularity;
// <editor-fold defaultstate="collapsed" desc="Getter methods">
public static long getSerialVersionUID() { public static long getSerialVersionUID() {
return serialVersionUID; return serialVersionUID;
} }
@@ -93,9 +87,15 @@ public class KeywordMovie implements Serializable {
public double getVoteCount() { public double getVoteCount() {
return voteCount; return voteCount;
} }
// </editor-fold>
// <editor-fold defaultstate="collapsed" desc="Setter methods"> public boolean isAdult() {
return adult;
}
public float getPopularity() {
return popularity;
}
public void setBackdropPath(String backdropPath) { public void setBackdropPath(String backdropPath) {
this.backdropPath = backdropPath; this.backdropPath = backdropPath;
} }
@@ -127,20 +127,12 @@ public class KeywordMovie implements Serializable {
public void setVoteCount(double voteCount) { public void setVoteCount(double voteCount) {
this.voteCount = voteCount; this.voteCount = voteCount;
} }
// </editor-fold>
/** public void setAdult(boolean adult) {
* Handle unknown properties and print a message this.adult = adult;
*
* @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());
} }
public void setPopularity(float popularity) {
this.popularity = popularity;
}
} }
@@ -19,25 +19,16 @@
*/ */
package com.omertron.themoviedbapi.model; package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonRootName; import com.fasterxml.jackson.annotation.JsonRootName;
import java.io.Serializable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
*
* @author stuart.boston * @author stuart.boston
*/ */
@JsonRootName("spoken_language") @JsonRootName("spoken_language")
public class Language implements Serializable { public class Language extends AbstractJsonMapping {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/*
* Logger
*/
private static final Logger LOG = LoggerFactory.getLogger(Language.class);
/* /*
* Properties * Properties
*/ */
@@ -46,7 +37,6 @@ public class Language implements Serializable {
@JsonProperty("name") @JsonProperty("name")
private String name; private String name;
//<editor-fold defaultstate="collapsed" desc="Getter methods">
public String getIsoCode() { public String getIsoCode() {
return isoCode; return isoCode;
} }
@@ -54,9 +44,7 @@ public class Language implements Serializable {
public String getName() { public String getName() {
return name; return name;
} }
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="Setter methods">
public void setIsoCode(String isoCode) { public void setIsoCode(String isoCode) {
this.isoCode = isoCode; this.isoCode = isoCode;
} }
@@ -64,21 +52,6 @@ public class Language implements Serializable {
public void setName(String name) { public void setName(String name) {
this.name = name; this.name = name;
} }
//</editor-fold>
/**
* Handle unknown properties and print a message
*
* @param key
* @param value
*/
@JsonAnySetter
public void handleUnknown(String key, Object value) {
StringBuilder sb = new StringBuilder();
sb.append("Unknown property: '").append(key);
sb.append("' value: '").append(value).append("'");
LOG.trace(sb.toString());
}
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
@@ -105,13 +78,4 @@ public class Language implements Serializable {
hash = 71 * hash + (this.name != null ? this.name.hashCode() : 0); hash = 71 * hash + (this.name != null ? this.name.hashCode() : 0);
return hash; return hash;
} }
@Override
public String toString() {
StringBuilder sb = new StringBuilder("[Language=");
sb.append("isoCode=").append(isoCode);
sb.append(", name=").append(name);
sb.append("]]");
return sb.toString();
}
} }
@@ -0,0 +1,51 @@
/*
* Copyright (c) 2004-2013 Stuart Boston
*
* This file is part of TheMovieDB API.
*
* TheMovieDB API is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* TheMovieDB API is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>.
*
*/
package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
* @author Holger Brandl
*/
public class ListItemStatus extends AbstractJsonMapping {
private static final long serialVersionUID = 1L;
@JsonProperty("status_code")
private int statusCode;
@JsonProperty("item_present")
private boolean itemPresent;
public int getStatusCode() {
return statusCode;
}
public void setStatusCode(int statusCode) {
this.statusCode = statusCode;
}
public boolean isItemPresent() {
return itemPresent;
}
public void setItemPresent(boolean itemPresent) {
this.itemPresent = itemPresent;
}
}
@@ -19,28 +19,19 @@
*/ */
package com.omertron.themoviedbapi.model; package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import java.io.Serializable; import com.omertron.themoviedbapi.wrapper.*;
import java.util.List; import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* Movie Bean * Movie Bean
* *
* @author stuart.boston * @author stuart.boston
*/ */
public class MovieDb implements Serializable { public class MovieDb extends AbstractJsonMapping {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/*
* Logger
*/
private static final Logger LOG = LoggerFactory.getLogger(MovieDb.class);
/*
* Properties
*/
@JsonProperty("backdrop_path") @JsonProperty("backdrop_path")
private String backdropPath; private String backdropPath;
@JsonProperty("id") @JsonProperty("id")
@@ -81,12 +72,35 @@ public class MovieDb implements Serializable {
private List<Language> spokenLanguages; private List<Language> spokenLanguages;
@JsonProperty("tagline") @JsonProperty("tagline")
private String tagline; private String tagline;
@JsonProperty("rating")
private float userRating;
@JsonProperty("vote_average") @JsonProperty("vote_average")
private float voteAverage; private float voteAverage;
@JsonProperty("vote_count") @JsonProperty("vote_count")
private int voteCount; private int voteCount;
@JsonProperty("status") @JsonProperty("status")
private String status; private String status;
// AppendToResponse Properties
@JsonProperty("alternative_titles")
private WrapperAlternativeTitles alternativeTitles;
@JsonProperty("casts")
private WrapperMovieCasts casts;
@JsonProperty("images")
private WrapperImages images;
@JsonProperty("keywords")
private WrapperMovieKeywords keywords;
@JsonProperty("releases")
private WrapperReleaseInfo releases;
@JsonProperty("trailers")
private WrapperTrailers trailers;
@JsonProperty("translations")
private WrapperTranslations translations;
@JsonProperty("similar_movies")
private WrapperMovie similarMovies;
@JsonProperty("reviews")
private WrapperReviews reviews;
@JsonProperty("lists")
private WrapperMovieList lists;
// <editor-fold defaultstate="collapsed" desc="Getter methods"> // <editor-fold defaultstate="collapsed" desc="Getter methods">
public String getBackdropPath() { public String getBackdropPath() {
@@ -180,6 +194,10 @@ public class MovieDb implements Serializable {
public String getStatus() { public String getStatus() {
return status; return status;
} }
public float getUserRating() {
return userRating;
}
// </editor-fold> // </editor-fold>
// <editor-fold defaultstate="collapsed" desc="Setter methods"> // <editor-fold defaultstate="collapsed" desc="Setter methods">
@@ -275,20 +293,98 @@ public class MovieDb implements Serializable {
this.status = status; this.status = status;
} }
// </editor-fold> public void setUserRating(float userRating) {
/** this.userRating = userRating;
* Handle unknown properties and print a message
*
* @param key
* @param value
*/
@JsonAnySetter
public void handleUnknown(String key, Object value) {
StringBuilder sb = new StringBuilder();
sb.append("Unknown property: '").append(key);
sb.append("' value: '").append(value).append("'");
LOG.trace(sb.toString());
} }
// </editor-fold>
//<editor-fold defaultstate="collapsed" desc="AppendToResponse Getters">
public List<AlternativeTitle> getAlternativeTitles() {
return alternativeTitles.getTitles();
}
public List<PersonCast> getCast() {
return casts.getCast();
}
public List<PersonCrew> getCrew() {
return casts.getCrew();
}
public List<Artwork> getImages() {
return images.getAll();
}
public List<Keyword> getKeywords() {
return keywords.getKeywords();
}
public List<ReleaseInfo> getReleases() {
return releases.getCountries();
}
public List<Trailer> getTrailers() {
return trailers.getAll();
}
public List<Translation> getTranslations() {
return translations.getTranslations();
}
public List<MovieDb> getSimilarMovies() {
return similarMovies.getMovies();
}
public List<MovieList> getLists() {
return lists.getMovieList();
}
public List<Reviews> getReviews() {
return reviews.getReviews();
}
// </editor-fold>
//<editor-fold defaultstate="collapsed" desc="AppendToResponse Setters">
public void setAlternativeTitles(WrapperAlternativeTitles alternativeTitles) {
this.alternativeTitles = alternativeTitles;
}
public void setCasts(WrapperMovieCasts casts) {
this.casts = casts;
}
public void setImages(WrapperImages images) {
this.images = images;
}
public void setKeywords(WrapperMovieKeywords keywords) {
this.keywords = keywords;
}
public void setReleases(WrapperReleaseInfo releases) {
this.releases = releases;
}
public void setTrailers(WrapperTrailers trailers) {
this.trailers = trailers;
}
public void setTranslations(WrapperTranslations translations) {
this.translations = translations;
}
public void setSimilarMovies(WrapperMovie similarMovies) {
this.similarMovies = similarMovies;
}
public void setLists(WrapperMovieList lists) {
this.lists = lists;
}
public void setReviews(WrapperReviews reviews) {
this.reviews = reviews;
}
// </editor-fold>
//<editor-fold defaultstate="collapsed" desc="Equals and HashCode"> //<editor-fold defaultstate="collapsed" desc="Equals and HashCode">
@Override @Override
@@ -320,35 +416,5 @@ public class MovieDb implements Serializable {
hash = 89 * hash + this.runtime; hash = 89 * hash + this.runtime;
return hash; return hash;
} }
//</editor-fold> // </editor-fold>
@Override
public String toString() {
StringBuilder sb = new StringBuilder("[MovieDB=");
sb.append("[backdropPath=").append(backdropPath);
sb.append("],[id=").append(id);
sb.append("],[originalTitle=").append(originalTitle);
sb.append("],[popularity=").append(popularity);
sb.append("],[posterPath=").append(posterPath);
sb.append("],[releaseDate=").append(releaseDate);
sb.append("],[title=").append(title);
sb.append("],[adult=").append(adult);
sb.append("],[belongsToCollection=").append(belongsToCollection);
sb.append("],[budget=").append(budget);
sb.append("],[genres=").append(genres);
sb.append("],[homepage=").append(homepage);
sb.append("],[imdbID=").append(imdbID);
sb.append("],[overview=").append(overview);
sb.append("],[productionCompanies=").append(productionCompanies);
sb.append("],[productionCountries=").append(productionCountries);
sb.append("],[revenue=").append(revenue);
sb.append("],[runtime=").append(runtime);
sb.append("],[spokenLanguages=").append(spokenLanguages);
sb.append("],[tagline=").append(tagline);
sb.append("],[voteAverage=").append(voteAverage);
sb.append("],[voteCount=").append(voteCount);
sb.append("],[status=").append(status);
sb.append("]]");
return sb.toString();
}
} }
@@ -19,26 +19,18 @@
*/ */
package com.omertron.themoviedbapi.model; package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* Wrapper for the MovieDbList function * Wrapper for the MovieDbList function
*
* @author stuart.boston * @author stuart.boston
*/ */
public class MovieDbList { public class MovieDbList extends AbstractJsonMapping {
/*
* Logger
*/
private static final Logger LOG = LoggerFactory.getLogger(MovieDbList.class);
/*
* Properties
*/
@JsonProperty("id") @JsonProperty("id")
private String id; private String id;
@JsonProperty("created_by") @JsonProperty("created_by")
@@ -57,8 +49,11 @@ public class MovieDbList {
private String name; private String name;
@JsonProperty("poster_path") @JsonProperty("poster_path")
private String posterPath; private String posterPath;
@JsonProperty("status_code")
private String statusCode;
@JsonProperty("status_message")
private String statusMessage;
//<editor-fold defaultstate="collapsed" desc="Getter Methods">
public String getId() { public String getId() {
return id; return id;
} }
@@ -94,9 +89,15 @@ public class MovieDbList {
public String getPosterPath() { public String getPosterPath() {
return posterPath; return posterPath;
} }
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="Setter Methods"> public String getStatusCode() {
return statusCode;
}
public String getStatusMessage() {
return statusMessage;
}
public void setId(String id) { public void setId(String id) {
this.id = id; this.id = id;
} }
@@ -132,20 +133,12 @@ public class MovieDbList {
public void setPosterPath(String posterPath) { public void setPosterPath(String posterPath) {
this.posterPath = posterPath; this.posterPath = posterPath;
} }
//</editor-fold>
/** public void setStatusCode(String statusCode) {
* Handle unknown properties and print a message this.statusCode = statusCode;
*
* @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());
} }
public void setStatusMessage(String statusMessage) {
this.statusMessage = statusMessage;
}
} }
@@ -0,0 +1,36 @@
/*
* Copyright (c) 2004-2013 Stuart Boston
*
* This file is part of TheMovieDB API.
*
* TheMovieDB API is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation;private either version 3 of the License;private or
* any later version.
*
* TheMovieDB API is distributed in the hope that it will be useful;private
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TheMovieDB API. If not;private see <http://www.gnu.org/licenses/>.
*
*/
package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonProperty;
public class MovieDbListStatus extends StatusCode {
@JsonProperty("list_id")
private String listId;
public String getListId() {
return listId;
}
public void setListId(String listId) {
this.listId = listId;
}
}
@@ -19,27 +19,15 @@
*/ */
package com.omertron.themoviedbapi.model; package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import java.io.Serializable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
*
* @author Stuart * @author Stuart
*/ */
public class MovieList implements Serializable { public class MovieList extends AbstractJsonMapping {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/*
* Logger
*/
private static final Logger LOG = LoggerFactory.getLogger(MovieList.class);
/*
* Properties
*/
@JsonProperty("description") @JsonProperty("description")
private String description; private String description;
@JsonProperty("favorite_count") @JsonProperty("favorite_count")
@@ -57,7 +45,6 @@ public class MovieList implements Serializable {
@JsonProperty("list_type") @JsonProperty("list_type")
private String listType; private String listType;
// <editor-fold defaultstate="collapsed" desc="Getter methods">
public String getDescription() { public String getDescription() {
return description; return description;
} }
@@ -89,9 +76,7 @@ public class MovieList implements Serializable {
public String getListType() { public String getListType() {
return listType; return listType;
} }
// </editor-fold>
// <editor-fold defaultstate="collapsed" desc="Setter methods">
public void setDescription(String description) { public void setDescription(String description) {
this.description = description; this.description = description;
} }
@@ -123,24 +108,4 @@ public class MovieList implements Serializable {
public void setListType(String listType) { public void setListType(String listType) {
this.listType = listType; this.listType = listType;
} }
// </editor-fold>
/**
* Handle unknown properties and print a message
*
* @param key
* @param value
*/
@JsonAnySetter
public void handleUnknown(String key, Object value) {
StringBuilder sb = new StringBuilder();
sb.append("Unknown property: '").append(key);
sb.append("' value: '").append(value).append("'");
LOG.trace(sb.toString());
}
@Override
public String toString() {
return "MovieList{" + "description=" + description + ", favoriteCount=" + favoriteCount + ", id=" + id + ", itemCount=" + itemCount + ", language=" + language + ", name=" + name + ", posterPath=" + posterPath + '}';
}
} }
@@ -19,27 +19,19 @@
*/ */
package com.omertron.themoviedbapi.model; package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import java.io.Serializable; import org.apache.commons.lang3.StringUtils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
*
* @author stuart.boston * @author stuart.boston
*/ */
public class Person implements Serializable { public class Person extends AbstractJsonMapping {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/*
* Logger
*/
private static final Logger LOG = LoggerFactory.getLogger(Person.class);
/* /*
* Static fields for default cast information * Static fields for default cast information
*/ */
@@ -56,12 +48,17 @@ public class Person implements Serializable {
@JsonProperty("profile_path") @JsonProperty("profile_path")
private String profilePath = DEFAULT_STRING; private String profilePath = DEFAULT_STRING;
private PersonType personType = PersonType.PERSON; private PersonType personType = PersonType.PERSON;
private String department = DEFAULT_STRING; // Crew // Crew
private String job = DEFAULT_STRING; // Crew private String department = DEFAULT_STRING;
private String character = DEFAULT_STRING; // Cast // Crew
private int order = -1; // Cast private String job = DEFAULT_STRING;
// Cast
private String character = DEFAULT_STRING;
// Cast
private int order = -1;
@JsonProperty("adult") @JsonProperty("adult")
private boolean adult = false; // Person info // Person info
private boolean adult = false;
@JsonProperty("also_known_as") @JsonProperty("also_known_as")
private List<String> aka = new ArrayList<String>(); private List<String> aka = new ArrayList<String>();
@JsonProperty("biography") @JsonProperty("biography")
@@ -89,14 +86,14 @@ public class Person implements Serializable {
* @param job * @param job
*/ */
public void addCrew(int id, String name, String profilePath, String department, String job) { public void addCrew(int id, String name, String profilePath, String department, String job) {
this.personType = PersonType.CREW; setPersonType(PersonType.CREW);
this.id = id; setId(id);
this.name = name; setName(name);
this.profilePath = profilePath; setProfilePath(profilePath);
this.department = department; setDepartment(department);
this.job = job; setJob(job);
this.character = ""; setCharacter("");
this.order = -1; setOrder(-1);
} }
/** /**
@@ -109,17 +106,16 @@ public class Person implements Serializable {
* @param order * @param order
*/ */
public void addCast(int id, String name, String profilePath, String character, int order) { public void addCast(int id, String name, String profilePath, String character, int order) {
this.personType = PersonType.CAST; setPersonType(PersonType.CAST);
this.id = id; setId(id);
this.name = name; setName(name);
this.profilePath = profilePath; setProfilePath(profilePath);
this.character = character; setCharacter(character);
this.order = order; setOrder(order);
this.department = CAST_DEPARTMENT; setDepartment(CAST_DEPARTMENT);
this.job = CAST_JOB; setJob(CAST_JOB);
} }
// <editor-fold defaultstate="collapsed" desc="Getter methods">
public String getCharacter() { public String getCharacter() {
return character; return character;
} }
@@ -187,9 +183,7 @@ public class Person implements Serializable {
public float getPopularity() { public float getPopularity() {
return popularity; return popularity;
} }
// </editor-fold>
// <editor-fold defaultstate="collapsed" desc="Setter methods">
public void setCharacter(String character) { public void setCharacter(String character) {
this.character = character; this.character = character;
} }
@@ -203,11 +197,11 @@ public class Person implements Serializable {
} }
public void setJob(String job) { public void setJob(String job) {
this.job = job; this.job = StringUtils.trimToEmpty(job);
} }
public void setName(String name) { public void setName(String name) {
this.name = name; this.name = StringUtils.trimToEmpty(name);
} }
public void setOrder(int order) { public void setOrder(int order) {
@@ -219,7 +213,7 @@ public class Person implements Serializable {
} }
public void setProfilePath(String profilePath) { public void setProfilePath(String profilePath) {
this.profilePath = profilePath; this.profilePath = StringUtils.trimToEmpty(profilePath);
} }
public void setAdult(boolean adult) { public void setAdult(boolean adult) {
@@ -231,47 +225,32 @@ public class Person implements Serializable {
} }
public void setBiography(String biography) { public void setBiography(String biography) {
this.biography = biography; this.biography = StringUtils.trimToEmpty(biography);
} }
public void setBirthday(String birthday) { public void setBirthday(String birthday) {
this.birthday = birthday; this.birthday = StringUtils.trimToEmpty(birthday);
} }
public void setBirthplace(String birthplace) { public void setBirthplace(String birthplace) {
this.birthplace = birthplace; this.birthplace = StringUtils.trimToEmpty(birthplace);
} }
public void setDeathday(String deathday) { public void setDeathday(String deathday) {
this.deathday = deathday; this.deathday = StringUtils.trimToEmpty(deathday);
} }
public void setHomepage(String homepage) { public void setHomepage(String homepage) {
this.homepage = homepage; this.homepage = StringUtils.trimToEmpty(homepage);
} }
public void setImdbId(String imdbId) { public void setImdbId(String imdbId) {
this.imdbId = imdbId; this.imdbId = StringUtils.trimToEmpty(imdbId);
} }
public void setPopularity(float popularity) { public void setPopularity(float popularity) {
this.popularity = popularity; this.popularity = popularity;
} }
// </editor-fold>
/**
* Handle unknown properties and print a message
*
* @param key
* @param value
*/
@JsonAnySetter
public void handleUnknown(String key, Object value) {
StringBuilder sb = new StringBuilder();
sb.append("Unknown property: '").append(key);
sb.append("' value: '").append(value).append("'");
LOG.trace(sb.toString());
}
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
@@ -318,26 +297,4 @@ public class Person implements Serializable {
hash = 37 * hash + (this.character != null ? this.character.hashCode() : 0); hash = 37 * hash + (this.character != null ? this.character.hashCode() : 0);
return hash; return hash;
} }
@Override
public String toString() {
StringBuilder sb = new StringBuilder("[Person=");
sb.append("[id=").append(id);
sb.append("],[name=").append(name);
sb.append("],[profilePath=").append(profilePath);
sb.append("],[personType=").append(personType);
sb.append("],[department=").append(department);
sb.append("],[job=").append(job);
sb.append("],[character=").append(character);
sb.append("],[order=").append(order);
sb.append("],[adult=").append(adult);
sb.append("],[=aka").append(aka.toString());
sb.append("],[biography=").append(biography);
sb.append("],[birthday=").append(birthday);
sb.append("],[deathday=").append(deathday);
sb.append("],[homepage=").append(homepage);
sb.append("],[birthplace=").append(birthplace);
sb.append("]]");
return sb.toString();
}
} }
@@ -19,24 +19,16 @@
*/ */
package com.omertron.themoviedbapi.model; package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import java.io.Serializable; import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
*
* @author Stuart * @author Stuart
*/ */
public class PersonCast implements Serializable { public class PersonCast extends AbstractJsonMapping {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/*
* Logger
*/
private static final Logger LOG = LoggerFactory.getLogger(PersonCast.class);
/* /*
* Properties * Properties
*/ */
@@ -53,7 +45,6 @@ public class PersonCast implements Serializable {
@JsonProperty("cast_id") @JsonProperty("cast_id")
private int castId; private int castId;
//<editor-fold defaultstate="collapsed" desc="Getter methods">
public String getCharacter() { public String getCharacter() {
return character; return character;
} }
@@ -78,11 +69,8 @@ public class PersonCast implements Serializable {
return castId; return castId;
} }
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="Setter methods">
public void setCharacter(String character) { public void setCharacter(String character) {
this.character = character; this.character = StringUtils.trimToEmpty(character);
} }
public void setId(int id) { public void setId(int id) {
@@ -90,7 +78,7 @@ public class PersonCast implements Serializable {
} }
public void setName(String name) { public void setName(String name) {
this.name = name; this.name = StringUtils.trimToEmpty(name);
} }
public void setOrder(int order) { public void setOrder(int order) {
@@ -98,29 +86,13 @@ public class PersonCast implements Serializable {
} }
public void setProfilePath(String profilePath) { public void setProfilePath(String profilePath) {
this.profilePath = profilePath; this.profilePath = StringUtils.trimToEmpty(profilePath);
} }
public void setCastId(int castId) { public void setCastId(int castId) {
this.castId = castId; this.castId = castId;
} }
//</editor-fold>
/**
* Handle unknown properties and print a message
*
* @param key
* @param value
*/
@JsonAnySetter
public void handleUnknown(String key, Object value) {
StringBuilder sb = new StringBuilder();
sb.append("Unknown property: '").append(key);
sb.append("' value: '").append(value).append("'");
LOG.trace(sb.toString());
}
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (obj == null) { if (obj == null) {
@@ -158,16 +130,4 @@ public class PersonCast implements Serializable {
hash = 41 * hash + (this.profilePath != null ? this.profilePath.hashCode() : 0); hash = 41 * hash + (this.profilePath != null ? this.profilePath.hashCode() : 0);
return hash; return hash;
} }
@Override
public String toString() {
StringBuilder sb = new StringBuilder("[PersonCast=");
sb.append("id=").append(id);
sb.append("],[character=").append(character);
sb.append("],[name=").append(name);
sb.append("],[order=").append(order);
sb.append("],[profilePath=").append(profilePath);
sb.append("]]");
return sb.toString();
}
} }
@@ -19,24 +19,15 @@
*/ */
package com.omertron.themoviedbapi.model; package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import java.io.Serializable; import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
*
* @author stuart.boston * @author stuart.boston
*/ */
public class PersonCredit implements Serializable { public class PersonCredit extends AbstractJsonMapping {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/*
* Logger
*/
private static final Logger LOG = LoggerFactory.getLogger(PersonCredit.class);
private static final String DEFAULT_STRING = ""; private static final String DEFAULT_STRING = "";
/* /*
* Properties * Properties
@@ -61,7 +52,6 @@ public class PersonCredit implements Serializable {
private String adult = DEFAULT_STRING; private String adult = DEFAULT_STRING;
private PersonType personType = PersonType.PERSON; private PersonType personType = PersonType.PERSON;
//<editor-fold defaultstate="collapsed" desc="Getter Methods">
public String getCharacter() { public String getCharacter() {
return character; return character;
} }
@@ -101,19 +91,17 @@ public class PersonCredit implements Serializable {
public String getAdult() { public String getAdult() {
return adult; return adult;
} }
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="Setter Methods">
public void setCharacter(String character) { public void setCharacter(String character) {
this.character = character; this.character = StringUtils.trimToEmpty(character);
} }
public void setDepartment(String department) { public void setDepartment(String department) {
this.department = department; this.department = StringUtils.trimToEmpty(department);
} }
public void setJob(String job) { public void setJob(String job) {
this.job = job; this.job = StringUtils.trimToEmpty(job);
} }
public void setMovieId(int movieId) { public void setMovieId(int movieId) {
@@ -121,11 +109,11 @@ public class PersonCredit implements Serializable {
} }
public void setMovieOriginalTitle(String movieOriginalTitle) { public void setMovieOriginalTitle(String movieOriginalTitle) {
this.movieOriginalTitle = movieOriginalTitle; this.movieOriginalTitle = StringUtils.trimToEmpty(movieOriginalTitle);
} }
public void setMovieTitle(String movieTitle) { public void setMovieTitle(String movieTitle) {
this.movieTitle = movieTitle; this.movieTitle = StringUtils.trimToEmpty(movieTitle);
} }
public void setPersonType(PersonType personType) { public void setPersonType(PersonType personType) {
@@ -133,46 +121,14 @@ public class PersonCredit implements Serializable {
} }
public void setPosterPath(String posterPath) { public void setPosterPath(String posterPath) {
this.posterPath = posterPath; this.posterPath = StringUtils.trimToEmpty(posterPath);
} }
public void setReleaseDate(String releaseDate) { public void setReleaseDate(String releaseDate) {
this.releaseDate = releaseDate; this.releaseDate = StringUtils.trimToEmpty(releaseDate);
} }
public void setAdult(String adult) { public void setAdult(String adult) {
this.adult = adult; this.adult = StringUtils.trimToEmpty(adult);
}
//</editor-fold>
/**
* Handle unknown properties and print a message
*
* @param key
* @param value
*/
@JsonAnySetter
public void handleUnknown(String key, Object value) {
StringBuilder sb = new StringBuilder();
sb.append("Unknown property: '").append(key);
sb.append("' value: '").append(value).append("'");
LOG.trace(sb.toString());
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder("[PersonCredit=");
sb.append("[movieId=").append(movieId);
sb.append("],[personType=").append(personType);
sb.append("],[originalTitle=").append(movieOriginalTitle);
sb.append("],[movieTitle=").append(movieTitle);
sb.append("],[posterPath=").append(posterPath);
sb.append("],[releaseDate=").append(releaseDate);
sb.append("],[character=").append(character);
sb.append("],[department=").append(department);
sb.append("],[job=").append(job);
sb.append("],[adult=").append(adult);
sb.append("]]");
return sb.toString();
} }
} }
@@ -19,24 +19,16 @@
*/ */
package com.omertron.themoviedbapi.model; package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import java.io.Serializable; import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
*
* @author Stuart * @author Stuart
*/ */
public class PersonCrew implements Serializable { public class PersonCrew extends AbstractJsonMapping {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/*
* Logger
*/
private static final Logger LOG = LoggerFactory.getLogger(PersonCrew.class);
/* /*
* Properties * Properties
*/ */
@@ -51,7 +43,6 @@ public class PersonCrew implements Serializable {
@JsonProperty("profile_path") @JsonProperty("profile_path")
private String profilePath; private String profilePath;
//<editor-fold defaultstate="collapsed" desc="Getter methods">
public String getDepartment() { public String getDepartment() {
return department; return department;
} }
@@ -71,11 +62,9 @@ public class PersonCrew implements Serializable {
public String getProfilePath() { public String getProfilePath() {
return profilePath; return profilePath;
} }
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="Setter methods">
public void setDepartment(String department) { public void setDepartment(String department) {
this.department = department; this.department = StringUtils.trimToEmpty(department);
} }
public void setId(int id) { public void setId(int id) {
@@ -83,30 +72,15 @@ public class PersonCrew implements Serializable {
} }
public void setJob(String job) { public void setJob(String job) {
this.job = job; this.job = StringUtils.trimToEmpty(job);
} }
public void setName(String name) { public void setName(String name) {
this.name = name; this.name = StringUtils.trimToEmpty(name);
} }
public void setProfilePath(String profilePath) { public void setProfilePath(String profilePath) {
this.profilePath = profilePath; this.profilePath = StringUtils.trimToEmpty(profilePath);
}
//</editor-fold>
/**
* Handle unknown properties and print a message
*
* @param key
* @param value
*/
@JsonAnySetter
public void handleUnknown(String key, Object value) {
StringBuilder sb = new StringBuilder();
sb.append("Unknown property: '").append(key);
sb.append("' value: '").append(value).append("'");
LOG.trace(sb.toString());
} }
@Override @Override
@@ -143,16 +117,4 @@ public class PersonCrew implements Serializable {
hash = 59 * hash + (this.profilePath != null ? this.profilePath.hashCode() : 0); hash = 59 * hash + (this.profilePath != null ? this.profilePath.hashCode() : 0);
return hash; return hash;
} }
@Override
public String toString() {
StringBuilder sb = new StringBuilder("[PersonCrew=");
sb.append("id=").append(id);
sb.append("],[department=").append(department);
sb.append("],[job=").append(job);
sb.append("],[name=").append(name);
sb.append("],[profilePath=").append(profilePath);
sb.append("]]");
return sb.toString();
}
} }
@@ -20,12 +20,14 @@
package com.omertron.themoviedbapi.model; package com.omertron.themoviedbapi.model;
/** /**
*
* @author stuart.boston * @author stuart.boston
*/ */
public enum PersonType { public enum PersonType {
CAST, // A member of the cast // A member of the cast
CREW, // A member of the crew CAST,
PERSON // No specific type // A member of the crew
CREW,
// No specific type
PERSON
} }
@@ -19,26 +19,17 @@
*/ */
package com.omertron.themoviedbapi.model; package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonRootName; import com.fasterxml.jackson.annotation.JsonRootName;
import java.io.Serializable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
*
* @author stuart.boston * @author stuart.boston
*/ */
@JsonRootName("production_company") @JsonRootName("production_company")
public class ProductionCompany implements Serializable { public class ProductionCompany extends AbstractJsonMapping {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/*
* Logger
*/
private static final Logger LOG = LoggerFactory.getLogger(ProductionCompany.class);
/* /*
* Properties * Properties
*/ */
@@ -47,7 +38,6 @@ public class ProductionCompany implements Serializable {
@JsonProperty("name") @JsonProperty("name")
private String name; private String name;
//<editor-fold defaultstate="collapsed" desc="Getter methods">
public int getId() { public int getId() {
return id; return id;
} }
@@ -55,9 +45,7 @@ public class ProductionCompany implements Serializable {
public String getName() { public String getName() {
return name; return name;
} }
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="Setter methods">
public void setId(int id) { public void setId(int id) {
this.id = id; this.id = id;
} }
@@ -65,21 +53,6 @@ public class ProductionCompany implements Serializable {
public void setName(String name) { public void setName(String name) {
this.name = name; this.name = name;
} }
//</editor-fold>
/**
* Handle unknown properties and print a message
*
* @param key
* @param value
*/
@JsonAnySetter
public void handleUnknown(String key, Object value) {
StringBuilder sb = new StringBuilder();
sb.append("Unknown property: '").append(key);
sb.append("' value: '").append(value).append("'");
LOG.trace(sb.toString());
}
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
@@ -106,13 +79,4 @@ public class ProductionCompany implements Serializable {
hash = 37 * hash + (this.name != null ? this.name.hashCode() : 0); hash = 37 * hash + (this.name != null ? this.name.hashCode() : 0);
return hash; return hash;
} }
@Override
public String toString() {
StringBuilder sb = new StringBuilder("[ProductionCompany=");
sb.append("[id=").append(id);
sb.append("],[name=").append(name);
sb.append("]]");
return sb.toString();
}
} }
@@ -19,26 +19,17 @@
*/ */
package com.omertron.themoviedbapi.model; package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonRootName; import com.fasterxml.jackson.annotation.JsonRootName;
import java.io.Serializable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
*
* @author stuart.boston * @author stuart.boston
*/ */
@JsonRootName("production_country") @JsonRootName("production_country")
public class ProductionCountry implements Serializable { public class ProductionCountry extends AbstractJsonMapping {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/*
* Logger
*/
private static final Logger LOG = LoggerFactory.getLogger(ProductionCountry.class);
/* /*
* Properties * Properties
*/ */
@@ -47,7 +38,6 @@ public class ProductionCountry implements Serializable {
@JsonProperty("name") @JsonProperty("name")
private String name; private String name;
//<editor-fold defaultstate="collapsed" desc="Getter methods">
public String getIsoCode() { public String getIsoCode() {
return isoCode; return isoCode;
} }
@@ -55,9 +45,7 @@ public class ProductionCountry implements Serializable {
public String getName() { public String getName() {
return name; return name;
} }
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="Setter methods">
public void setIsoCode(String isoCode) { public void setIsoCode(String isoCode) {
this.isoCode = isoCode; this.isoCode = isoCode;
} }
@@ -65,21 +53,6 @@ public class ProductionCountry implements Serializable {
public void setName(String name) { public void setName(String name) {
this.name = name; this.name = name;
} }
//</editor-fold>
/**
* Handle unknown properties and print a message
*
* @param key
* @param value
*/
@JsonAnySetter
public void handleUnknown(String key, Object value) {
StringBuilder sb = new StringBuilder();
sb.append("Unknown property: '").append(key);
sb.append("' value: '").append(value).append("'");
LOG.trace(sb.toString());
}
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
@@ -106,13 +79,4 @@ public class ProductionCountry implements Serializable {
hash = 47 * hash + (this.name != null ? this.name.hashCode() : 0); hash = 47 * hash + (this.name != null ? this.name.hashCode() : 0);
return hash; return hash;
} }
@Override
public String toString() {
StringBuilder sb = new StringBuilder("[ProductionCountry=");
sb.append("[isoCode=").append(isoCode);
sb.append("],[name=").append(name);
sb.append("]]");
return sb.toString();
}
} }
@@ -19,24 +19,15 @@
*/ */
package com.omertron.themoviedbapi.model; package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import java.io.Serializable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
*
* @author Stuart * @author Stuart
*/ */
public class ReleaseInfo implements Serializable { public class ReleaseInfo extends AbstractJsonMapping {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/*
* Logger
*/
private static final Logger LOG = LoggerFactory.getLogger(ReleaseInfo.class);
/* /*
* Properties * Properties
*/ */
@@ -47,7 +38,6 @@ public class ReleaseInfo implements Serializable {
@JsonProperty("release_date") @JsonProperty("release_date")
private String releaseDate; private String releaseDate;
//<editor-fold defaultstate="collapsed" desc="Getter methods">
public String getCertification() { public String getCertification() {
return certification; return certification;
} }
@@ -59,9 +49,7 @@ public class ReleaseInfo implements Serializable {
public String getReleaseDate() { public String getReleaseDate() {
return releaseDate; return releaseDate;
} }
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="Setter methods">
public void setCertification(String certification) { public void setCertification(String certification) {
this.certification = certification; this.certification = certification;
} }
@@ -73,21 +61,6 @@ public class ReleaseInfo implements Serializable {
public void setReleaseDate(String releaseDate) { public void setReleaseDate(String releaseDate) {
this.releaseDate = releaseDate; this.releaseDate = releaseDate;
} }
//</editor-fold>
/**
* Handle unknown properties and print a message
*
* @param key
* @param value
*/
@JsonAnySetter
public void handleUnknown(String key, Object value) {
StringBuilder sb = new StringBuilder();
sb.append("Unknown property: '").append(key);
sb.append("' value: '").append(value).append("'");
LOG.trace(sb.toString());
}
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
@@ -118,14 +91,4 @@ public class ReleaseInfo implements Serializable {
hash = 89 * hash + (this.releaseDate != null ? this.releaseDate.hashCode() : 0); hash = 89 * hash + (this.releaseDate != null ? this.releaseDate.hashCode() : 0);
return hash; return hash;
} }
@Override
public String toString() {
StringBuilder sb = new StringBuilder("[ReleaseInfo=");
sb.append("[country=").append(country);
sb.append("],[certification=").append(certification);
sb.append("],[releaseDate=").append(releaseDate);
sb.append("]]");
return sb.toString();
}
} }
@@ -0,0 +1,74 @@
/*
* Copyright (c) 2004-2013 Stuart Boston
*
* This file is part of TheMovieDB API.
*
* TheMovieDB API is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* TheMovieDB API is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>.
*
*/
package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
* @author Stuart
*/
public class Reviews extends AbstractJsonMapping {
private static final long serialVersionUID = 1L;
/*
* Properties
*/
@JsonProperty("id")
private String id;
@JsonProperty("author")
private String author;
@JsonProperty("content")
private String content;
@JsonProperty("url")
private String url;
public String getId() {
return id;
}
public String getAuthor() {
return author;
}
public String getContent() {
return content;
}
public String getUrl() {
return url;
}
public void setId(String id) {
this.id = id;
}
public void setAuthor(String author) {
this.author = author;
}
public void setContent(String content) {
this.content = content;
}
public void setUrl(String url) {
this.url = url;
}
}
@@ -19,24 +19,15 @@
*/ */
package com.omertron.themoviedbapi.model; package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import java.io.Serializable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
*
* @author Stuart * @author Stuart
*/ */
public class StatusCode implements Serializable { public class StatusCode extends AbstractJsonMapping {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/*
* Logger
*/
private static final Logger LOG = LoggerFactory.getLogger(StatusCode.class);
/* /*
* Properties * Properties
*/ */
@@ -45,7 +36,6 @@ public class StatusCode implements Serializable {
@JsonProperty("status_message") @JsonProperty("status_message")
private String statusMessage; private String statusMessage;
//<editor-fold defaultstate="collapsed" desc="Getter methods">
public int getStatusCode() { public int getStatusCode() {
return statusCode; return statusCode;
} }
@@ -53,9 +43,7 @@ public class StatusCode implements Serializable {
public void setStatusCode(int statusCode) { public void setStatusCode(int statusCode) {
this.statusCode = statusCode; this.statusCode = statusCode;
} }
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="Setter methods">
public String getStatusMessage() { public String getStatusMessage() {
return statusMessage; return statusMessage;
} }
@@ -63,27 +51,4 @@ public class StatusCode implements Serializable {
public void setStatusMessage(String statusMessage) { public void setStatusMessage(String statusMessage) {
this.statusMessage = statusMessage; this.statusMessage = statusMessage;
} }
//</editor-fold>
/**
* Handle unknown properties and print a message
*
* @param key
* @param value
*/
@JsonAnySetter
public void handleUnknown(String key, Object value) {
StringBuilder sb = new StringBuilder();
sb.append("Unknown property: '").append(key);
sb.append("' value: '").append(value).append("'");
LOG.trace(sb.toString());
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("Status Code: ").append(statusCode);
sb.append(", Message: ").append(statusMessage);
return sb.toString();
}
} }
@@ -19,25 +19,17 @@
*/ */
package com.omertron.themoviedbapi.model; package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import java.io.Serializable;
import java.util.List;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import java.util.List;
/** /**
*
* @author stuart.boston * @author stuart.boston
*/ */
public class TmdbConfiguration implements Serializable { public class TmdbConfiguration extends AbstractJsonMapping {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/*
* Logger
*/
private static final Logger LOG = LoggerFactory.getLogger(TmdbConfiguration.class);
/* /*
* Properties * Properties
*/ */
@@ -54,7 +46,6 @@ public class TmdbConfiguration implements Serializable {
@JsonProperty("logo_sizes") @JsonProperty("logo_sizes")
private List<String> logoSizes; private List<String> logoSizes;
// <editor-fold defaultstate="collapsed" desc="Getter methods">//GEN-BEGIN:getterMethods
public List<String> getBackdropSizes() { public List<String> getBackdropSizes() {
return backdropSizes; return backdropSizes;
} }
@@ -79,8 +70,6 @@ public class TmdbConfiguration implements Serializable {
return secureBaseUrl; return secureBaseUrl;
} }
// </editor-fold>
// <editor-fold defaultstate="collapsed" desc="Setter methods">//GEN-BEGIN:setterMethods
public void setBackdropSizes(List<String> backdropSizes) { public void setBackdropSizes(List<String> backdropSizes) {
this.backdropSizes = backdropSizes; this.backdropSizes = backdropSizes;
} }
@@ -104,7 +93,6 @@ public class TmdbConfiguration implements Serializable {
public void setSecureBaseUrl(String secureBaseUrl) { public void setSecureBaseUrl(String secureBaseUrl) {
this.secureBaseUrl = secureBaseUrl; this.secureBaseUrl = secureBaseUrl;
} }
// </editor-fold>
/** /**
* Copy the data from the passed object to this one * Copy the data from the passed object to this one
@@ -123,6 +111,7 @@ public class TmdbConfiguration implements Serializable {
* Check that the poster size is valid * Check that the poster size is valid
* *
* @param posterSize * @param posterSize
* @return
*/ */
public boolean isValidPosterSize(String posterSize) { public boolean isValidPosterSize(String posterSize) {
if (StringUtils.isBlank(posterSize) || posterSizes.isEmpty()) { if (StringUtils.isBlank(posterSize) || posterSizes.isEmpty()) {
@@ -135,6 +124,7 @@ public class TmdbConfiguration implements Serializable {
* Check that the backdrop size is valid * Check that the backdrop size is valid
* *
* @param backdropSize * @param backdropSize
* @return
*/ */
public boolean isValidBackdropSize(String backdropSize) { public boolean isValidBackdropSize(String backdropSize) {
if (StringUtils.isBlank(backdropSize) || backdropSizes.isEmpty()) { if (StringUtils.isBlank(backdropSize) || backdropSizes.isEmpty()) {
@@ -147,6 +137,7 @@ public class TmdbConfiguration implements Serializable {
* Check that the profile size is valid * Check that the profile size is valid
* *
* @param profileSize * @param profileSize
* @return
*/ */
public boolean isValidProfileSize(String profileSize) { public boolean isValidProfileSize(String profileSize) {
if (StringUtils.isBlank(profileSize) || profileSizes.isEmpty()) { if (StringUtils.isBlank(profileSize) || profileSizes.isEmpty()) {
@@ -159,6 +150,7 @@ public class TmdbConfiguration implements Serializable {
* Check that the logo size is valid * Check that the logo size is valid
* *
* @param logoSize * @param logoSize
* @return
*/ */
public boolean isValidLogoSize(String logoSize) { public boolean isValidLogoSize(String logoSize) {
if (StringUtils.isBlank(logoSize) || logoSizes.isEmpty()) { if (StringUtils.isBlank(logoSize) || logoSizes.isEmpty()) {
@@ -171,6 +163,7 @@ public class TmdbConfiguration implements Serializable {
* Check to see if the size is valid for any of the images types * Check to see if the size is valid for any of the images types
* *
* @param sizeToCheck * @param sizeToCheck
* @return
*/ */
public boolean isValidSize(String sizeToCheck) { public boolean isValidSize(String sizeToCheck) {
return (isValidPosterSize(sizeToCheck) return (isValidPosterSize(sizeToCheck)
@@ -178,30 +171,4 @@ public class TmdbConfiguration implements Serializable {
|| isValidProfileSize(sizeToCheck) || isValidProfileSize(sizeToCheck)
|| isValidLogoSize(sizeToCheck)); || isValidLogoSize(sizeToCheck));
} }
/**
* Handle unknown properties and print a message
*
* @param key
* @param value
*/
@JsonAnySetter
public void handleUnknown(String key, Object value) {
StringBuilder sb = new StringBuilder();
sb.append("Unknown property: '").append(key);
sb.append("' value: '").append(value).append("'");
LOG.trace(sb.toString());
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder("[ImageConfiguration=");
sb.append("[baseUrl=").append(baseUrl);
sb.append("],[posterSizes=").append(posterSizes.toString());
sb.append("],[backdropSizes=").append(backdropSizes.toString());
sb.append("],[profileSizes=").append(profileSizes.toString());
sb.append("],[logoSizes=").append(logoSizes.toString());
sb.append(("]]"));
return sb.toString();
}
} }
@@ -19,16 +19,10 @@
*/ */
package com.omertron.themoviedbapi.model; package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class TokenAuthorisation { public class TokenAuthorisation extends AbstractJsonMapping {
/*
* Logger
*/
private static final Logger LOG = LoggerFactory.getLogger(TokenAuthorisation.class);
/* /*
* Properties * Properties
*/ */
@@ -39,7 +33,6 @@ public class TokenAuthorisation {
@JsonProperty("success") @JsonProperty("success")
private Boolean success; private Boolean success;
// <editor-fold defaultstate="collapsed" desc="Getter methods">
public String getExpires() { public String getExpires() {
return expires; return expires;
} }
@@ -51,9 +44,7 @@ public class TokenAuthorisation {
public Boolean getSuccess() { public Boolean getSuccess() {
return success; return success;
} }
// </editor-fold>
// <editor-fold defaultstate="collapsed" desc="Setter methods">
public void setExpires(String expires) { public void setExpires(String expires) {
this.expires = expires; this.expires = expires;
} }
@@ -65,25 +56,4 @@ public class TokenAuthorisation {
public void setSuccess(Boolean success) { public void setSuccess(Boolean success) {
this.success = success; this.success = success;
} }
// </editor-fold>
/**
* Handle unknown properties and print a message
*
* @param key
* @param value
*/
@JsonAnySetter
public void handleUnknown(String key, Object value) {
StringBuilder sb = new StringBuilder();
sb.append("Unknown property: '").append(key);
sb.append("' value: '").append(value).append("'");
LOG.trace(sb.toString());
}
@Override
public String toString() {
return "TokenAuthorisation{" + "expires=" + expires + ", requestToken=" + requestToken + ", success=" + success + '}';
}
} }
@@ -19,17 +19,10 @@
*/ */
package com.omertron.themoviedbapi.model; package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class TokenSession { public class TokenSession extends AbstractJsonMapping {
/*
* Logger
*/
private static final Logger LOG = LoggerFactory.getLogger(TokenSession.class);
/* /*
* Properties * Properties
*/ */
@@ -46,7 +39,6 @@ public class TokenSession {
@JsonProperty("expires_at") @JsonProperty("expires_at")
private String expiresAt; private String expiresAt;
// <editor-fold defaultstate="collapsed" desc="Getter methods">
public String getSessionId() { public String getSessionId() {
return sessionId; return sessionId;
} }
@@ -70,9 +62,7 @@ public class TokenSession {
public String getExpiresAt() { public String getExpiresAt() {
return expiresAt; return expiresAt;
} }
// </editor-fold>
// <editor-fold defaultstate="collapsed" desc="Setter methods">
public void setSessionId(String sessionId) { public void setSessionId(String sessionId) {
this.sessionId = sessionId; this.sessionId = sessionId;
} }
@@ -96,25 +86,4 @@ public class TokenSession {
public void setExpiresAt(String expiresAt) { public void setExpiresAt(String expiresAt) {
this.expiresAt = expiresAt; this.expiresAt = expiresAt;
} }
// </editor-fold>
/**
* Handle unknown properties and print a message
*
* @param key
* @param value
*/
@JsonAnySetter
public void handleUnknown(String key, Object value) {
StringBuilder sb = new StringBuilder();
sb.append("Unknown property: '").append(key);
sb.append("' value: '").append(value).append("'");
LOG.trace(sb.toString());
}
@Override
public String toString() {
return "TokenSession{" + "sessionId=" + sessionId + ", success=" + success + ", statusCode=" + statusCode + ", statusMessage=" + statusMessage + ", guestSessionId=" + guestSessionId + ", expiresAt=" + expiresAt + '}';
}
} }
@@ -19,23 +19,13 @@
*/ */
package com.omertron.themoviedbapi.model; package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import java.io.Serializable;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
*
* @author Stuart * @author Stuart
*/ */
public class Trailer implements Serializable { public class Trailer extends AbstractJsonMapping {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/*
* Logger
*/
private static final Logger LOG = LoggerFactory.getLogger(Trailer.class);
/* /*
* Website sources * Website sources
*/ */
@@ -47,9 +37,10 @@ public class Trailer implements Serializable {
private String name; private String name;
private String size; private String size;
private String source; 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() { public String getName() {
return name; return name;
} }
@@ -65,9 +56,11 @@ public class Trailer implements Serializable {
public String getWebsite() { public String getWebsite() {
return website; return website;
} }
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="Setter methods"> public String getType() {
return type;
}
public void setName(String name) { public void setName(String name) {
this.name = name; this.name = name;
} }
@@ -83,20 +76,9 @@ public class Trailer implements Serializable {
public void setWebsite(String website) { public void setWebsite(String website) {
this.website = website; this.website = website;
} }
//</editor-fold>
/** public void setType(String type) {
* Handle unknown properties and print a message this.type = type;
*
* @param key
* @param value
*/
@JsonAnySetter
public void handleUnknown(String key, Object value) {
StringBuilder sb = new StringBuilder();
sb.append("Unknown property: '").append(key);
sb.append("' value: '").append(value).append("'");
LOG.trace(sb.toString());
} }
@Override @Override
@@ -129,15 +111,4 @@ public class Trailer implements Serializable {
hash = 61 * hash + (this.website != null ? this.website.hashCode() : 0); hash = 61 * hash + (this.website != null ? this.website.hashCode() : 0);
return hash; return hash;
} }
@Override
public String toString() {
StringBuilder sb = new StringBuilder("[Trailer=");
sb.append("name=").append(name);
sb.append("],[size=").append(size);
sb.append("],[source=").append(source);
sb.append("],[website=").append(website);
sb.append("]]");
return sb.toString();
}
} }
@@ -19,24 +19,17 @@
*/ */
package com.omertron.themoviedbapi.model; package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import java.io.Serializable; import org.apache.commons.lang3.builder.ToStringBuilder;
import org.slf4j.Logger; import org.apache.commons.lang3.builder.ToStringStyle;
import org.slf4j.LoggerFactory;
/** /**
*
* @author Stuart * @author Stuart
*/ */
public class Translation implements Serializable { public class Translation extends AbstractJsonMapping {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/*
* Logger
*/
private static final Logger LOG = LoggerFactory.getLogger(Translation.class);
/* /*
* Properties * Properties
*/ */
@@ -47,7 +40,6 @@ public class Translation implements Serializable {
@JsonProperty("name") @JsonProperty("name")
private String name; private String name;
//<editor-fold defaultstate="collapsed" desc="Getter methods">
public String getEnglishName() { public String getEnglishName() {
return englishName; return englishName;
} }
@@ -59,9 +51,7 @@ public class Translation implements Serializable {
public String getName() { public String getName() {
return name; return name;
} }
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="Setter methods">
public void setEnglishName(String englishName) { public void setEnglishName(String englishName) {
this.englishName = englishName; this.englishName = englishName;
} }
@@ -73,21 +63,6 @@ public class Translation implements Serializable {
public void setName(String name) { public void setName(String name) {
this.name = name; this.name = name;
} }
//</editor-fold>
/**
* Handle unknown properties and print a message
*
* @param key
* @param value
*/
@JsonAnySetter
public void handleUnknown(String key, Object value) {
StringBuilder sb = new StringBuilder();
sb.append("Unknown property: '").append(key);
sb.append("' value: '").append(value).append("'");
LOG.trace(sb.toString());
}
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
@@ -121,11 +96,6 @@ public class Translation implements Serializable {
@Override @Override
public String toString() { public String toString() {
StringBuilder sb = new StringBuilder("[Translation="); return ToStringBuilder.reflectionToString(this, ToStringStyle.SIMPLE_STYLE);
sb.append("[englishName=").append(englishName);
sb.append("],[isoCode=").append(isoCode);
sb.append("],[name=").append(name);
sb.append("]]");
return sb.toString();
} }
} }
@@ -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;
}
}
@@ -0,0 +1,105 @@
/*
* Copyright (c) 2004-2013 Stuart Boston
*
* This file is part of TheMovieDB API.
*
* TheMovieDB API is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* TheMovieDB API is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>.
*
*/
package com.omertron.themoviedbapi.results;
import com.omertron.themoviedbapi.wrapper.AbstractWrapper;
import com.omertron.themoviedbapi.wrapper.AbstractWrapperAll;
import com.omertron.themoviedbapi.wrapper.AbstractWrapperId;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
/**
* Abstract class to return the results and the id/page info
*
* @author Stuart
*/
public abstract class AbstractResults {
private int id = 0;
private int page = 0;
private int totalPages = 0;
private int totalResults = 0;
//<editor-fold defaultstate="collapsed" desc="Getters">
public int getId() {
return id;
}
public int getPage() {
return page;
}
public int getTotalPages() {
return totalPages;
}
public int getTotalResults() {
return totalResults;
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="Setters">
public void setId(int id) {
this.id = id;
}
public void setPage(int page) {
this.page = page;
}
public void setTotalPages(int totalPages) {
this.totalPages = totalPages;
}
public void setTotalResults(int totalResults) {
this.totalResults = totalResults;
}
//</editor-fold>
public void copyWrapper(AbstractWrapper wrapper) {
// These results have nothing to copy, so this is just a placeholder
}
/**
* Copy the Id from the wrapper
*
* @param wrapper
*/
public void copyWrapper(AbstractWrapperId wrapper) {
this.id = wrapper.getId();
}
/**
* Copy the Id and pages from the wrapper
*
* @param wrapper
*/
public void copyWrapper(AbstractWrapperAll wrapper) {
this.id = wrapper.getId();
this.page = wrapper.getPage();
this.totalPages = wrapper.getTotalPages();
this.totalResults = wrapper.getTotalResults();
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
}
}
@@ -0,0 +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 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();
}
}
}
@@ -0,0 +1,56 @@
/*
* 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.HashMap;
import java.util.Map;
/**
* Map of the results from TheMovieDb
*
* @author Stuart
* @param <K>
* @param <V>
*/
public final class TmdbResultsMap<K, V> extends AbstractResults {
private Map<K, V> results;
public TmdbResultsMap(Map<K, V> resultsMap) {
results = new HashMap<K, V>(resultsMap);
}
public Map<K, V> getResults() {
return results;
}
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();
}
}
}
@@ -19,13 +19,13 @@
*/ */
package com.omertron.themoviedbapi.tools; package com.omertron.themoviedbapi.tools;
import com.omertron.themoviedbapi.TheMovieDbApi;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.net.URL; import java.net.URL;
import java.net.URLEncoder; import java.net.URLEncoder;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@@ -53,10 +53,10 @@ public class ApiUrl {
/* /*
* Properties * Properties
*/ */
private TheMovieDbApi tmdb; private final String apiKey;
private String method; private final String method;
private String submethod; private final String submethod;
private Map<String, String> arguments = new HashMap<String, String>(); private final Map<String, String> arguments = new HashMap<String, String>();
/* /*
* API Parameters * API Parameters
*/ */
@@ -67,7 +67,6 @@ public class ApiUrl {
public static final String PARAM_ID = "id="; public static final String PARAM_ID = "id=";
public static final String PARAM_LANGUAGE = "language="; public static final String PARAM_LANGUAGE = "language=";
public static final String PARAM_INCLUDE_ALL_MOVIES = "include_all_movies="; public static final String PARAM_INCLUDE_ALL_MOVIES = "include_all_movies=";
// public static final String PARAM_MOVIE_ID = "movie_id=";
public static final String PARAM_MOVIE_WATCHLIST = "movie_watchlist="; public static final String PARAM_MOVIE_WATCHLIST = "movie_watchlist=";
public static final String PARAM_PAGE = "page="; public static final String PARAM_PAGE = "page=";
public static final String PARAM_QUERY = "query="; public static final String PARAM_QUERY = "query=";
@@ -75,15 +74,19 @@ public class ApiUrl {
public static final String PARAM_TOKEN = "request_token="; public static final String PARAM_TOKEN = "request_token=";
public static final String PARAM_VALUE = "value="; public static final String PARAM_VALUE = "value=";
public static final String PARAM_YEAR = "year="; 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"> //<editor-fold defaultstate="collapsed" desc="Constructor Methods">
/** /**
* Constructor for the simple API URL method without a sub-method * Constructor for the simple API URL method without a sub-method
* *
* @param apiKey
* @param method * @param method
*/ */
public ApiUrl(TheMovieDbApi tmdb, String method) { public ApiUrl(String apiKey, String method) {
this.tmdb = tmdb; this.apiKey = apiKey;
this.method = method; this.method = method;
this.submethod = DEFAULT_STRING; this.submethod = DEFAULT_STRING;
} }
@@ -91,11 +94,12 @@ public class ApiUrl {
/** /**
* Constructor for the API URL with a sub-method * Constructor for the API URL with a sub-method
* *
* @param apiKey
* @param method * @param method
* @param submethod * @param submethod
*/ */
public ApiUrl(TheMovieDbApi tmdb, String method, String submethod) { public ApiUrl(String apiKey, String method, String submethod) {
this.tmdb = tmdb; this.apiKey = apiKey;
this.method = method; this.method = method;
this.submethod = submethod; this.submethod = submethod;
} }
@@ -103,6 +107,8 @@ public class ApiUrl {
/** /**
* Build the URL from the pre-created arguments. * Build the URL from the pre-created arguments.
*
* @return
*/ */
public URL buildUrl() { public URL buildUrl() {
StringBuilder urlString = new StringBuilder(TMDB_API_BASE); StringBuilder urlString = new StringBuilder(TMDB_API_BASE);
@@ -113,11 +119,14 @@ public class ApiUrl {
// We have either a queury, or a direct request // We have either a queury, or a direct request
if (arguments.containsKey(PARAM_QUERY)) { if (arguments.containsKey(PARAM_QUERY)) {
// Append the suffix of the API URL // Append the suffix of the API URL
if (StringUtils.endsWith(urlString, "/") && submethod.startsWith("/")) {
urlString.deleteCharAt(urlString.length() - 1);
}
urlString.append(submethod); urlString.append(submethod);
// Append the key information // Append the key information
urlString.append(DELIMITER_FIRST).append(PARAM_API_KEY); urlString.append(DELIMITER_FIRST).append(PARAM_API_KEY);
urlString.append(tmdb.getApiKey()); urlString.append(apiKey);
// Append the search term // Append the search term
urlString.append(DELIMITER_SUBSEQUENT); urlString.append(DELIMITER_SUBSEQUENT);
@@ -128,11 +137,12 @@ public class ApiUrl {
try { try {
urlString.append(URLEncoder.encode(query, "UTF-8")); urlString.append(URLEncoder.encode(query, "UTF-8"));
} catch (UnsupportedEncodingException ex) { } catch (UnsupportedEncodingException ex) {
LOG.trace("Unable to encode query: '" + query + "' trying raw."); LOG.trace("Unable to encode query: '{}' trying raw.", query);
// If we can't encode it, try it raw // If we can't encode it, try it raw
urlString.append(query); urlString.append(query);
} }
// Remove the query from the arguments so it is not added later
arguments.remove(PARAM_QUERY); arguments.remove(PARAM_QUERY);
} else { } else {
// Append the ID if provided // Append the ID if provided
@@ -142,11 +152,14 @@ public class ApiUrl {
} }
// Append the suffix of the API URL // Append the suffix of the API URL
if (StringUtils.endsWith(urlString, "/") && submethod.startsWith("/")) {
urlString.deleteCharAt(urlString.length() - 1);
}
urlString.append(submethod); urlString.append(submethod);
// Append the key information // Append the key information
urlString.append(DELIMITER_FIRST).append(PARAM_API_KEY); urlString.append(DELIMITER_FIRST).append(PARAM_API_KEY);
urlString.append(tmdb.getApiKey()); urlString.append(apiKey);
} }
for (Map.Entry<String, String> argEntry : arguments.entrySet()) { for (Map.Entry<String, String> argEntry : arguments.entrySet()) {
@@ -195,6 +208,16 @@ public class ApiUrl {
arguments.put(key, Boolean.toString(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 * Clear the arguments
*/ */
@@ -210,4 +233,25 @@ public class ApiUrl {
public void setArguments(Map<String, String> args) { public void setArguments(Map<String, String> args) {
arguments.putAll(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());
}
}
} }
@@ -20,10 +20,11 @@
package com.omertron.themoviedbapi.tools; package com.omertron.themoviedbapi.tools;
import com.omertron.themoviedbapi.MovieDbException; import com.omertron.themoviedbapi.MovieDbException;
import java.io.BufferedReader; import org.apache.commons.codec.binary.Base64;
import java.io.IOException; import org.slf4j.Logger;
import java.io.InputStreamReader; import org.slf4j.LoggerFactory;
import java.io.StringWriter;
import java.io.*;
import java.net.HttpURLConnection; import java.net.HttpURLConnection;
import java.net.MalformedURLException; import java.net.MalformedURLException;
import java.net.URL; import java.net.URL;
@@ -35,9 +36,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.regex.Matcher; import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import org.apache.commons.codec.binary.Base64; import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* Web browser with simple cookies support * Web browser with simple cookies support
@@ -45,15 +44,17 @@ import org.slf4j.LoggerFactory;
public final class WebBrowser { public final class WebBrowser {
private static final Logger LOG = LoggerFactory.getLogger(WebBrowser.class); private static final Logger LOG = LoggerFactory.getLogger(WebBrowser.class);
private static Map<String, String> browserProperties = new HashMap<String, String>(); private static final Map<String, String> BROWSER_PROPERTIES = new HashMap<String, String>();
private static Map<String, Map<String, String>> cookies = new HashMap<String, Map<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 proxyHost = null;
private static String proxyPort = null; private static int proxyPort = 0;
private static String proxyUsername = null; private static String proxyUsername = null;
private static String proxyPassword = null; private static String proxyPassword = null;
private static String proxyEncodedPassword = null; private static String proxyEncodedPassword = null;
private static int webTimeoutConnect = 25000; // 25 second timeout // 25 second timeout
private static int webTimeoutRead = 90000; // 90 second timeout private static int webTimeoutConnect = 25000;
// 90 second timeout
private static int webTimeoutRead = 90000;
// Hide the constructor // Hide the constructor
protected WebBrowser() { protected WebBrowser() {
@@ -65,9 +66,10 @@ public final class WebBrowser {
* Populate the browser properties * Populate the browser properties
*/ */
private static void populateBrowserProperties() { private static void populateBrowserProperties() {
if (browserProperties.isEmpty()) { if (BROWSER_PROPERTIES.isEmpty()) {
browserProperties.put("User-Agent", "Mozilla/5.25 Netscape/5.0 (Windows; I; Win95)"); BROWSER_PROPERTIES.put("User-Agent", "Mozilla/5.25 Netscape/5.0 (Windows; I; Win95)");
browserProperties.put("Accept", "application/json"); BROWSER_PROPERTIES.put("Accept", "application/json");
BROWSER_PROPERTIES.put("Content-type", "application/json");
} }
} }
@@ -100,25 +102,59 @@ public final class WebBrowser {
} }
public static String request(URL url) throws MovieDbException { public static String request(URL url) throws MovieDbException {
return request(url, null, Boolean.FALSE);
}
public static String request(URL url, String jsonBody) throws MovieDbException {
return request(url, jsonBody, Boolean.FALSE);
}
public static String request(URL url, String jsonBody, boolean isDeleteRequest) throws MovieDbException {
StringWriter content = null; StringWriter content = null;
try { try {
content = new StringWriter(); content = new StringWriter();
BufferedReader in = null; BufferedReader in = null;
URLConnection cnx = null; HttpURLConnection cnx = null;
OutputStreamWriter wr = null;
try { try {
cnx = openProxiedConnection(url); cnx = (HttpURLConnection) openProxiedConnection(url);
if (isDeleteRequest) {
cnx.setDoOutput(true);
cnx.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
cnx.setRequestMethod("DELETE");
}
sendHeader(cnx); sendHeader(cnx);
if (StringUtils.isNotBlank(jsonBody)) {
cnx.setDoOutput(true);
wr = new OutputStreamWriter(cnx.getOutputStream());
wr.write(jsonBody);
}
readHeader(cnx); readHeader(cnx);
in = new BufferedReader(new InputStreamReader(cnx.getInputStream(), getCharset(cnx))); // http://stackoverflow.com/questions/4633048/httpurlconnection-reading-response-content-on-403-error
if (cnx.getResponseCode() >= 400) {
in = new BufferedReader(new InputStreamReader(cnx.getErrorStream(), getCharset(cnx)));
} else {
in = new BufferedReader(new InputStreamReader(cnx.getInputStream(), getCharset(cnx)));
}
String line; String line;
while ((line = in.readLine()) != null) { while ((line = in.readLine()) != null) {
content.write(line); content.write(line);
} }
} finally { } finally {
if (wr != null) {
wr.flush();
wr.close();
}
if (in != null) { if (in != null) {
in.close(); in.close();
} }
@@ -145,7 +181,7 @@ public final class WebBrowser {
populateBrowserProperties(); populateBrowserProperties();
// send browser properties // 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()); cnx.setRequestProperty(browserProperty.getKey(), browserProperty.getValue());
} }
// send cookies // send cookies
@@ -158,7 +194,7 @@ public final class WebBrowser {
private static String createCookieHeader(URLConnection cnx) { private static String createCookieHeader(URLConnection cnx) {
String host = cnx.getURL().getHost(); String host = cnx.getURL().getHost();
StringBuilder cookiesHeader = new StringBuilder(); 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())) { if (host.endsWith(domainCookies.getKey())) {
for (Map.Entry<String, String> cookie : domainCookies.getValue().entrySet()) { for (Map.Entry<String, String> cookie : domainCookies.getValue().entrySet()) {
cookiesHeader.append(cookie.getKey()); cookiesHeader.append(cookie.getKey());
@@ -198,10 +234,10 @@ public final class WebBrowser {
// if domain isn't set take current host // if domain isn't set take current host
cookieDomain = cnx.getURL().getHost(); cookieDomain = cnx.getURL().getHost();
} }
Map<String, String> domainCookies = cookies.get(cookieDomain); Map<String, String> domainCookies = COOKIES.get(cookieDomain);
if (domainCookies == null) { if (domainCookies == null) {
domainCookies = new HashMap<String, String>(); domainCookies = new HashMap<String, String>();
cookies.put(cookieDomain, domainCookies); COOKIES.put(cookieDomain, domainCookies);
} }
// add or replace cookie // add or replace cookie
domainCookies.put(cookieName, cookieValue); domainCookies.put(cookieName, cookieValue);
@@ -242,11 +278,11 @@ public final class WebBrowser {
WebBrowser.proxyHost = myProxyHost; WebBrowser.proxyHost = myProxyHost;
} }
public static String getProxyPort() { public static int getProxyPort() {
return proxyPort; return proxyPort;
} }
public static void setProxyPort(String myProxyPort) { public static void setProxyPort(int myProxyPort) {
WebBrowser.proxyPort = myProxyPort; WebBrowser.proxyPort = myProxyPort;
} }
@@ -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.wrapper;
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;
public abstract class AbstractWrapper extends AbstractJsonMapping implements Serializable {
private static final long serialVersionUID = 1L;
/**
* Get a list of the enums passed
*
* @param <E>
* @param clz Class of the enum
* @param typeList Array of the enums
* @return
*/
public <E extends Enum<E>> List<E> getTypeList(Class<E> clz, E[] typeList) {
if (typeList.length > 0) {
return new ArrayList<E>(Arrays.asList(typeList));
} else {
return new ArrayList<E>(EnumSet.allOf(clz));
}
}
}
@@ -19,84 +19,61 @@
*/ */
package com.omertron.themoviedbapi.wrapper; package com.omertron.themoviedbapi.wrapper;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import org.slf4j.Logger;
/** /**
* Base class for the wrappers * Base class for the wrappers
* *
* @author Stuart * @author Stuart
*/ */
public class WrapperBase { public class AbstractWrapperAll extends AbstractWrapperId implements IWrapperId, IWrapperPages, IWrapperDates {
/*
* Logger - set by the sub-classes
*/
private Logger log;
/*
* Properties
*/
@JsonProperty("id")
private int id;
@JsonProperty("page") @JsonProperty("page")
private int page; private int page;
@JsonProperty("total_pages") @JsonProperty("total_pages")
private int totalPages; private int totalPages;
@JsonProperty("total_results") @JsonProperty("total_results")
private int totalResults; private int totalResults;
@JsonProperty("dates")
private ResultDates dates = new ResultDates();
public WrapperBase(Logger logger) { @Override
this.log = logger;
}
//<editor-fold defaultstate="collapsed" desc="Getter Methods">
public int getId() {
return id;
}
public int getPage() { public int getPage() {
return page; return page;
} }
@Override
public int getTotalPages() { public int getTotalPages() {
return totalPages; return totalPages;
} }
@Override
public int getTotalResults() { public int getTotalResults() {
return totalResults; return totalResults;
} }
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="Setter Methods"> @Override
public void setId(int id) { public ResultDates getDates() {
this.id = id; return dates;
} }
@Override
public void setPage(int page) { public void setPage(int page) {
this.page = page; this.page = page;
} }
@Override
public void setTotalPages(int totalPages) { public void setTotalPages(int totalPages) {
this.totalPages = totalPages; this.totalPages = totalPages;
} }
@Override
public void setTotalResults(int totalResults) { public void setTotalResults(int totalResults) {
this.totalResults = totalResults; this.totalResults = totalResults;
} }
//</editor-fold>
/** @Override
* Handle unknown properties and print a message public void setDates(ResultDates dates) {
* this.dates = dates;
* @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());
} }
} }
@@ -0,0 +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 {
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;
}
}
@@ -0,0 +1,27 @@
/*
* Copyright (c) 2004-2013 Stuart Boston
*
* This file is part of TheMovieDB API.
*
* TheMovieDB API is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* TheMovieDB API is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>.
*
*/
package com.omertron.themoviedbapi.wrapper;
public interface IWrapperDates {
ResultDates getDates();
void setDates(ResultDates dates);
}
@@ -0,0 +1,27 @@
/*
* Copyright (c) 2004-2013 Stuart Boston
*
* This file is part of TheMovieDB API.
*
* TheMovieDB API is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* TheMovieDB API is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>.
*
*/
package com.omertron.themoviedbapi.wrapper;
public interface IWrapperId {
int getId();
void setId(int id);
}
@@ -0,0 +1,35 @@
/*
* Copyright (c) 2004-2013 Stuart Boston
*
* This file is part of TheMovieDB API.
*
* TheMovieDB API is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* TheMovieDB API is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>.
*
*/
package com.omertron.themoviedbapi.wrapper;
public interface IWrapperPages {
int getPage();
void setPage(int page);
int getTotalPages();
void setTotalPages(int totalPages);
int getTotalResults();
void setTotalResults(int totalResults);
}
@@ -17,12 +17,13 @@
* along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>. * along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>.
* *
*/ */
package com.omertron.themoviedbapi.model; package com.omertron.themoviedbapi.wrapper;
import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import java.io.Serializable; import java.io.Serializable;
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.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@@ -30,41 +31,41 @@ import org.slf4j.LoggerFactory;
* *
* @author Stuart * @author Stuart
*/ */
public class MovieChanges implements Serializable { public class ResultDates implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/* /*
* Logger * Logger
*/ */
private static final Logger LOG = LoggerFactory.getLogger(MovieChanges.class); private static final Logger LOG = LoggerFactory.getLogger(ResultDates.class);
/* /*
* Properties * Properties
*/ */
@JsonProperty("key") @JsonProperty("minimum")
private String key; private String minimum = "";
@JsonProperty("items") @JsonProperty("maximum")
private List<ChangeItem> items; private String maximum = "";
//<editor-fold defaultstate="collapsed" desc="Getter Methods"> // <editor-fold defaultstate="collapsed" desc="Getter methods">
public String getKey() { public String getMinimum() {
return key; return minimum;
} }
public List<ChangeItem> getItems() { public String getMaximum() {
return items; return maximum;
} }
//</editor-fold> // </editor-fold>
//<editor-fold defaultstate="collapsed" desc="Setter Methods"> // <editor-fold defaultstate="collapsed" desc="Setter methods">
public void setKey(String key) { public void setMinimum(String minimum) {
this.key = key; this.minimum = minimum;
} }
public void setItems(List<ChangeItem> items) { public void setMaximum(String maximum) {
this.items = items; this.maximum = maximum;
} }
//</editor-fold> // </editor-fold>
/** /**
* Handle unknown properties and print a message * Handle unknown properties and print a message
@@ -79,4 +80,9 @@ public class MovieChanges implements Serializable {
sb.append("' value: '").append(value).append("'"); sb.append("' value: '").append(value).append("'");
LOG.trace(sb.toString()); LOG.trace(sb.toString());
} }
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.SIMPLE_STYLE);
}
} }
@@ -19,58 +19,26 @@
*/ */
package com.omertron.themoviedbapi.wrapper; package com.omertron.themoviedbapi.wrapper;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.omertron.themoviedbapi.model.AlternativeTitle; import com.omertron.themoviedbapi.model.AlternativeTitle;
import java.io.Serializable;
import java.util.List; import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* *
* @author Stuart * @author Stuart
*/ */
public class WrapperAlternativeTitles { public class WrapperAlternativeTitles extends AbstractWrapperId implements Serializable {
/*
* Logger
*/
private static final Logger LOG = LoggerFactory.getLogger(WrapperAlternativeTitles.class); private static final long serialVersionUID = 1L;
/*
* Properties
*/
@JsonProperty("id")
private int id;
@JsonProperty("titles") @JsonProperty("titles")
private List<AlternativeTitle> titles; private List<AlternativeTitle> titles;
public int getId() {
return id;
}
public List<AlternativeTitle> getTitles() { public List<AlternativeTitle> getTitles() {
return titles; return titles;
} }
public void setId(int id) {
this.id = id;
}
public void setTitles(List<AlternativeTitle> titles) { public void setTitles(List<AlternativeTitle> titles) {
this.titles = titles; this.titles = titles;
} }
/**
* Handle unknown properties and print a message
*
* @param key
* @param value
*/
@JsonAnySetter
public void handleUnknown(String key, Object value) {
StringBuilder sb = new StringBuilder();
sb.append("Unknown property: '").append(key);
sb.append("' value: '").append(value).append("'");
LOG.trace(sb.toString());
}
} }
@@ -1,70 +1,42 @@
/*
* 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; package com.omertron.themoviedbapi.wrapper;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.omertron.themoviedbapi.model.MovieChanges; import com.omertron.themoviedbapi.model.ChangeKeyItem;
import java.util.List; import org.apache.commons.lang3.builder.ToStringBuilder;
import org.slf4j.Logger; import org.apache.commons.lang3.builder.ToStringStyle;
import org.slf4j.LoggerFactory;
/**
*
* @author stuart.boston
*/
public class WrapperChanges { public class WrapperChanges {
/*
* Logger
*/
private static final Logger LOG = LoggerFactory.getLogger(WrapperChanges.class);
/*
* Properties
*/
@JsonProperty("changes") @JsonProperty("changes")
private List<MovieChanges> changes; private List<ChangeKeyItem> changedItems = new ArrayList<ChangeKeyItem>();
private final Map<String, Object> newItems = new HashMap<String, Object>();
//<editor-fold defaultstate="collapsed" desc="Getter methods"> public List<ChangeKeyItem> getChangedItems() {
public List<MovieChanges> getChanges() { return changedItems;
return changes;
} }
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="Setter methods"> public void setChangedItems(List<ChangeKeyItem> changes) {
public void setChanges(List<MovieChanges> changes) { this.changedItems = changes;
this.changes = changes; }
@JsonAnyGetter
public Map<String, Object> getNewItems() {
return this.newItems;
} }
//</editor-fold>
/**
* Handle unknown properties and print a message
*
* @param key
* @param value
*/
@JsonAnySetter @JsonAnySetter
public void handleUnknown(String key, Object value) { public void setNewItems(String name, Object value) {
StringBuilder sb = new StringBuilder(); this.newItems.put(name, value);
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);
} }
} }
@@ -22,24 +22,16 @@ package com.omertron.themoviedbapi.wrapper;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.omertron.themoviedbapi.model.Collection; import com.omertron.themoviedbapi.model.Collection;
import java.util.List; import java.util.List;
import org.slf4j.LoggerFactory;
/** /**
* *
* @author stuart.boston * @author stuart.boston
*/ */
public class WrapperCollection extends WrapperBase { public class WrapperCollection extends AbstractWrapperAll {
/*
* Properties
*/
@JsonProperty("results") @JsonProperty("results")
private List<Collection> results; private List<Collection> results;
public WrapperCollection() {
super(LoggerFactory.getLogger(WrapperCollection.class));
}
public List<Collection> getResults() { public List<Collection> getResults() {
return results; return results;
} }
@@ -22,24 +22,16 @@ package com.omertron.themoviedbapi.wrapper;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.omertron.themoviedbapi.model.Company; import com.omertron.themoviedbapi.model.Company;
import java.util.List; import java.util.List;
import org.slf4j.LoggerFactory;
/** /**
* *
* @author stuart.boston * @author stuart.boston
*/ */
public class WrapperCompany extends WrapperBase { public class WrapperCompany extends AbstractWrapperAll {
/*
* Properties
*/
@JsonProperty("results") @JsonProperty("results")
private List<Company> results; private List<Company> results;
public WrapperCompany() {
super(LoggerFactory.getLogger(WrapperCompany.class));
}
public List<Company> getResults() { public List<Company> getResults() {
return results; return results;
} }
@@ -22,24 +22,16 @@ package com.omertron.themoviedbapi.wrapper;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.omertron.themoviedbapi.model.MovieDb; import com.omertron.themoviedbapi.model.MovieDb;
import java.util.List; import java.util.List;
import org.slf4j.LoggerFactory;
/** /**
* *
* @author stuart.boston * @author stuart.boston
*/ */
public class WrapperCompanyMovies extends WrapperBase { public class WrapperCompanyMovies extends AbstractWrapperAll {
/*
* Properties
*/
@JsonProperty("results") @JsonProperty("results")
private List<MovieDb> results; private List<MovieDb> results;
public WrapperCompanyMovies() {
super(LoggerFactory.getLogger(WrapperCompanyMovies.class));
}
public List<MovieDb> getResults() { public List<MovieDb> getResults() {
return results; return results;
} }
@@ -47,16 +39,4 @@ public class WrapperCompanyMovies extends WrapperBase {
public void setResults(List<MovieDb> results) { public void setResults(List<MovieDb> results) {
this.results = results; this.results = results;
} }
@Override
public String toString() {
StringBuilder sb = new StringBuilder("[ResultList=[");
sb.append("[companyId=").append(getId());
sb.append("],[page=").append(getPage());
sb.append("],[pageResults=").append(getResults().size());
sb.append("],[totalPages=").append(getTotalPages());
sb.append("],[totalResults=").append(getTotalResults());
sb.append("]]");
return sb.toString();
}
} }
@@ -19,27 +19,17 @@
*/ */
package com.omertron.themoviedbapi.wrapper; package com.omertron.themoviedbapi.wrapper;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.omertron.themoviedbapi.model.TmdbConfiguration; import com.omertron.themoviedbapi.model.TmdbConfiguration;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* *
* @author Stuart * @author Stuart
*/ */
public class WrapperConfig { public class WrapperConfig extends AbstractWrapper {
/*
* Logger
*/
private static final Logger LOG = LoggerFactory.getLogger(WrapperConfig.class);
/*
* Properties
*/
@JsonProperty("images") @JsonProperty("images")
private TmdbConfiguration tmdbConfiguration; private TmdbConfiguration tmdbConfiguration;
@JsonProperty("change_keys") @JsonProperty("change_keys")
@@ -60,18 +50,4 @@ public class WrapperConfig {
public void setChangeKeys(List<String> changeKeys) { public void setChangeKeys(List<String> changeKeys) {
this.changeKeys = changeKeys; this.changeKeys = changeKeys;
} }
/**
* 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());
}
} }
@@ -19,27 +19,17 @@
*/ */
package com.omertron.themoviedbapi.wrapper; package com.omertron.themoviedbapi.wrapper;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.omertron.themoviedbapi.model.Genre; import com.omertron.themoviedbapi.model.Genre;
import java.util.List; import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* Wrapper class for the Genres searches * Wrapper class for the Genres searches
* *
* @author Stuart * @author Stuart
*/ */
public class WrapperGenres { public class WrapperGenres extends AbstractWrapper {
/*
* Logger
*/
private static final Logger LOG = LoggerFactory.getLogger(WrapperGenres.class);
/*
* Properties
*/
@JsonProperty("genres") @JsonProperty("genres")
private List<Genre> genres; private List<Genre> genres;
@@ -50,18 +40,4 @@ public class WrapperGenres {
public void setGenres(List<Genre> genres) { public void setGenres(List<Genre> genres) {
this.genres = genres; this.genres = genres;
} }
/**
* Handle unknown properties and print a message
*
* @param key
* @param value
*/
@JsonAnySetter
public void handleUnknown(String key, Object value) {
StringBuilder sb = new StringBuilder();
sb.append("Unknown property: '").append(key);
sb.append("' value: '").append(value).append("'");
LOG.trace(sb.toString());
}
} }
@@ -21,30 +21,27 @@ package com.omertron.themoviedbapi.wrapper;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.omertron.themoviedbapi.model.Artwork; 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;
import java.util.List; import java.util.List;
import org.slf4j.LoggerFactory;
/** /**
* *
* @author Stuart * @author Stuart
*/ */
public class WrapperImages extends WrapperBase { public class WrapperImages extends AbstractWrapperAll implements Serializable {
/*
* Properties
*/
private static final long serialVersionUID = 1L;
@JsonProperty("backdrops") @JsonProperty("backdrops")
private List<Artwork> backdrops; private List<Artwork> backdrops = Collections.EMPTY_LIST;
@JsonProperty("posters") @JsonProperty("posters")
private List<Artwork> posters; private List<Artwork> posters = Collections.EMPTY_LIST;
@JsonProperty("profiles") @JsonProperty("profiles")
private List<Artwork> profiles; private List<Artwork> profiles = Collections.EMPTY_LIST;
public WrapperImages() {
super(LoggerFactory.getLogger(WrapperImages.class));
}
//<editor-fold defaultstate="collapsed" desc="Getter methods">
public List<Artwork> getBackdrops() { public List<Artwork> getBackdrops() {
return backdrops; return backdrops;
} }
@@ -56,9 +53,7 @@ public class WrapperImages extends WrapperBase {
public List<Artwork> getProfiles() { public List<Artwork> getProfiles() {
return profiles; return profiles;
} }
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="Setter methods">
public void setBackdrops(List<Artwork> backdrops) { public void setBackdrops(List<Artwork> backdrops) {
this.backdrops = backdrops; this.backdrops = backdrops;
} }
@@ -70,5 +65,55 @@ public class WrapperImages extends WrapperBase {
public void setProfiles(List<Artwork> profiles) { public void setProfiles(List<Artwork> profiles) {
this.profiles = profiles; this.profiles = profiles;
} }
//</editor-fold>
/**
* Return a list of all the artwork with their types.
*
* Leaving the parameters blank will return all types
*
* @param artworkList
* @return
*/
public List<Artwork> getAll(ArtworkType... artworkList) {
List<Artwork> artwork = new ArrayList<Artwork>();
List<ArtworkType> types;
if (artworkList.length > 0) {
types = new ArrayList<ArtworkType>(Arrays.asList(artworkList));
} else {
types = new ArrayList<ArtworkType>(Arrays.asList(ArtworkType.values()));
}
// Add all the posters to the list
if (types.contains(ArtworkType.POSTER)) {
updateArtworkType(posters, ArtworkType.POSTER);
artwork.addAll(posters);
}
// Add all the backdrops to the list
if (types.contains(ArtworkType.BACKDROP)) {
updateArtworkType(backdrops, ArtworkType.BACKDROP);
artwork.addAll(backdrops);
}
// Add all the backdrops to the list
if (types.contains(ArtworkType.PROFILE)) {
updateArtworkType(profiles, ArtworkType.PROFILE);
artwork.addAll(profiles);
}
return artwork;
}
/**
* Update the artwork type for the artwork list
*
* @param artworkList
* @param type
*/
private void updateArtworkType(List<Artwork> artworkList, ArtworkType type) {
for (Artwork artwork : artworkList) {
artwork.setArtworkType(type);
}
}
} }
@@ -0,0 +1,42 @@
/*
* 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;
import com.omertron.themoviedbapi.model.JobDepartment;
import java.util.List;
/**
*
* @author Stuart
*/
public class WrapperJobList extends AbstractWrapper {
@JsonProperty("jobs")
private List<JobDepartment> jobs;
public List<JobDepartment> getJobs() {
return jobs;
}
public void setJobs(List<JobDepartment> jobs) {
this.jobs = jobs;
}
}
@@ -22,24 +22,16 @@ package com.omertron.themoviedbapi.wrapper;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.omertron.themoviedbapi.model.KeywordMovie; import com.omertron.themoviedbapi.model.KeywordMovie;
import java.util.List; import java.util.List;
import org.slf4j.LoggerFactory;
/** /**
* *
* @author stuart.boston * @author stuart.boston
*/ */
public class WrapperKeywordMovies extends WrapperBase { public class WrapperKeywordMovies extends AbstractWrapperAll {
/*
* Properties
*/
@JsonProperty("results") @JsonProperty("results")
private List<KeywordMovie> results; private List<KeywordMovie> results;
public WrapperKeywordMovies() {
super(LoggerFactory.getLogger(WrapperKeywordMovies.class));
}
public List<KeywordMovie> getResults() { public List<KeywordMovie> getResults() {
return results; return results;
} }
@@ -22,24 +22,16 @@ package com.omertron.themoviedbapi.wrapper;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.omertron.themoviedbapi.model.Keyword; import com.omertron.themoviedbapi.model.Keyword;
import java.util.List; import java.util.List;
import org.slf4j.LoggerFactory;
/** /**
* *
* @author stuart.boston * @author stuart.boston
*/ */
public class WrapperKeywords extends WrapperBase { public class WrapperKeywords extends AbstractWrapperAll {
/*
* Properties
*/
@JsonProperty("results") @JsonProperty("results")
private List<Keyword> results; private List<Keyword> results;
public WrapperKeywords() {
super(LoggerFactory.getLogger(WrapperKeywords.class));
}
public List<Keyword> getResults() { public List<Keyword> getResults() {
return results; return results;
} }
@@ -21,25 +21,19 @@ package com.omertron.themoviedbapi.wrapper;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.omertron.themoviedbapi.model.MovieDb; import com.omertron.themoviedbapi.model.MovieDb;
import java.io.Serializable;
import java.util.List; import java.util.List;
import org.slf4j.LoggerFactory;
/** /**
* *
* @author stuart.boston * @author stuart.boston
*/ */
public class WrapperMovie extends WrapperBase { public class WrapperMovie extends AbstractWrapperAll implements Serializable {
/*
* Properties
*/
private static final long serialVersionUID = 1L;
@JsonProperty("results") @JsonProperty("results")
private List<MovieDb> movies; private List<MovieDb> movies;
public WrapperMovie() {
super(LoggerFactory.getLogger(WrapperMovie.class));
}
public List<MovieDb> getMovies() { public List<MovieDb> getMovies() {
return movies; return movies;
} }
@@ -47,16 +41,4 @@ public class WrapperMovie extends WrapperBase {
public void setMovies(List<MovieDb> movies) { public void setMovies(List<MovieDb> movies) {
this.movies = movies; this.movies = movies;
} }
@Override
public String toString() {
StringBuilder sb = new StringBuilder("[ResultList=[");
sb.append("[page=").append(getPage());
sb.append("],[pageResults=").append(getMovies().size());
sb.append("],[totalPages=").append(getTotalPages());
sb.append("],[totalResults=").append(getTotalResults());
sb.append("],[id=").append(getId());
sb.append("]]");
return sb.toString();
}
} }
@@ -19,35 +19,26 @@
*/ */
package com.omertron.themoviedbapi.wrapper; package com.omertron.themoviedbapi.wrapper;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.omertron.themoviedbapi.model.Person;
import com.omertron.themoviedbapi.model.PersonCast; import com.omertron.themoviedbapi.model.PersonCast;
import com.omertron.themoviedbapi.model.PersonCrew; import com.omertron.themoviedbapi.model.PersonCrew;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* *
* @author Stuart * @author Stuart
*/ */
public class WrapperMovieCasts { public class WrapperMovieCasts extends AbstractWrapperId implements Serializable {
/*
* Logger
*/
private static final Logger LOG = LoggerFactory.getLogger(WrapperMovieCasts.class); private static final long serialVersionUID = 1L;
/*
* Properties
*/
@JsonProperty("id")
private int id;
@JsonProperty("cast") @JsonProperty("cast")
private List<PersonCast> cast; private List<PersonCast> cast;
@JsonProperty("crew") @JsonProperty("crew")
private List<PersonCrew> crew; private List<PersonCrew> crew;
//<editor-fold defaultstate="collapsed" desc="Getter methods">
public List<PersonCast> getCast() { public List<PersonCast> getCast() {
return cast; return cast;
} }
@@ -56,12 +47,6 @@ public class WrapperMovieCasts {
return crew; return crew;
} }
public int getId() {
return id;
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="Setter methods">
public void setCast(List<PersonCast> cast) { public void setCast(List<PersonCast> cast) {
this.cast = cast; this.cast = cast;
} }
@@ -70,22 +55,23 @@ public class WrapperMovieCasts {
this.crew = crew; this.crew = crew;
} }
public void setId(int id) { public List<Person> getAll() {
this.id = id; List<Person> people = new ArrayList<Person>();
}
//</editor-fold>
/** // Add a cast member
* Handle unknown properties and print a message for (PersonCast member : cast) {
* Person person = new Person();
* @param key person.addCast(member.getId(), member.getName(), member.getProfilePath(), member.getCharacter(), member.getOrder());
* @param value people.add(person);
*/ }
@JsonAnySetter
public void handleUnknown(String key, Object value) { // Add a crew member
StringBuilder sb = new StringBuilder(); for (PersonCrew member : crew) {
sb.append("Unknown property: '").append(key); Person person = new Person();
sb.append("' value: '").append(value).append("'"); person.addCrew(member.getId(), member.getName(), member.getProfilePath(), member.getDepartment(), member.getJob());
LOG.trace(sb.toString()); people.add(person);
}
return people;
} }
} }
@@ -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;
}
}
@@ -0,0 +1,21 @@
package com.omertron.themoviedbapi.wrapper;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.omertron.themoviedbapi.model.MovieDbList;
import java.util.List;
public class WrapperMovieDbList extends AbstractWrapperAll {
@JsonProperty("results")
private List<MovieDbList> lists;
public List<MovieDbList> getLists() {
return lists;
}
public void setLists(List<MovieDbList> lists) {
this.lists = lists;
}
}
@@ -19,62 +19,26 @@
*/ */
package com.omertron.themoviedbapi.wrapper; package com.omertron.themoviedbapi.wrapper;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.omertron.themoviedbapi.model.Keyword; import com.omertron.themoviedbapi.model.Keyword;
import java.io.Serializable;
import java.util.List; import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* *
* @author Stuart * @author Stuart
*/ */
public class WrapperMovieKeywords { public class WrapperMovieKeywords extends AbstractWrapperId implements Serializable {
/*
* Logger
*/
private static final Logger LOG = LoggerFactory.getLogger(WrapperMovieKeywords.class); private static final long serialVersionUID = 1L;
/*
* Properties
*/
@JsonProperty("id")
private int id;
@JsonProperty("keywords") @JsonProperty("keywords")
private List<Keyword> keywords; private List<Keyword> keywords;
//<editor-fold defaultstate="collapsed" desc="Getter methods">
public int getId() {
return id;
}
public List<Keyword> getKeywords() { public List<Keyword> getKeywords() {
return keywords; return keywords;
} }
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="Setter methods">
public void setId(int id) {
this.id = id;
}
public void setKeywords(List<Keyword> keywords) { public void setKeywords(List<Keyword> keywords) {
this.keywords = keywords; this.keywords = keywords;
} }
//</editor-fold>
/**
* Handle unknown properties and print a message
*
* @param key
* @param value
*/
@JsonAnySetter
public void handleUnknown(String key, Object value) {
StringBuilder sb = new StringBuilder();
sb.append("Unknown property: '").append(key);
sb.append("' value: '").append(value).append("'");
LOG.trace(sb.toString());
}
} }
@@ -21,25 +21,19 @@ package com.omertron.themoviedbapi.wrapper;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.omertron.themoviedbapi.model.MovieList; import com.omertron.themoviedbapi.model.MovieList;
import java.io.Serializable;
import java.util.List; import java.util.List;
import org.slf4j.LoggerFactory;
/** /**
* *
* @author Stuart * @author Stuart
*/ */
public class WrapperMovieList extends WrapperBase { public class WrapperMovieList extends AbstractWrapperAll implements Serializable {
/*
* Properties
*/
private static final long serialVersionUID = 1L;
@JsonProperty("results") @JsonProperty("results")
private List<MovieList> movieList; private List<MovieList> movieList;
public WrapperMovieList() {
super(LoggerFactory.getLogger(WrapperMovieList.class));
}
public List<MovieList> getMovieList() { public List<MovieList> getMovieList() {
return movieList; return movieList;
} }
@@ -22,24 +22,16 @@ package com.omertron.themoviedbapi.wrapper;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.omertron.themoviedbapi.model.Person; import com.omertron.themoviedbapi.model.Person;
import java.util.List; import java.util.List;
import org.slf4j.LoggerFactory;
/** /**
* *
* @author stuart.boston * @author stuart.boston
*/ */
public class WrapperPerson extends WrapperBase { public class WrapperPerson extends AbstractWrapperAll {
/*
* Properties
*/
@JsonProperty("results") @JsonProperty("results")
private List<Person> results; private List<Person> results;
public WrapperPerson() {
super(LoggerFactory.getLogger(WrapperPerson.class));
}
public List<Person> getResults() { public List<Person> getResults() {
return results; return results;
} }
@@ -21,27 +21,21 @@ package com.omertron.themoviedbapi.wrapper;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.omertron.themoviedbapi.model.PersonCredit; import com.omertron.themoviedbapi.model.PersonCredit;
import com.omertron.themoviedbapi.model.PersonType;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.slf4j.LoggerFactory;
/** /**
* *
* @author stuart.boston * @author stuart.boston
*/ */
public class WrapperPersonCredits extends WrapperBase { public class WrapperPersonCredits extends AbstractWrapperAll {
/*
* Properties
*/
@JsonProperty("cast") @JsonProperty("cast")
private List<PersonCredit> cast; private List<PersonCredit> cast;
@JsonProperty("crew") @JsonProperty("crew")
private List<PersonCredit> crew; private List<PersonCredit> crew;
public WrapperPersonCredits() {
super(LoggerFactory.getLogger(WrapperMovieCasts.class));
}
public List<PersonCredit> getCast() { public List<PersonCredit> getCast() {
return cast; return cast;
} }
@@ -57,4 +51,27 @@ public class WrapperPersonCredits extends WrapperBase {
public void setCrew(List<PersonCredit> crew) { public void setCrew(List<PersonCredit> crew) {
this.crew = crew; this.crew = crew;
} }
public List<PersonCredit> getAll(PersonType... typeList) {
List<PersonCredit> personCredits = new ArrayList<PersonCredit>();
List<PersonType> types = getTypeList(PersonType.class, typeList);
// Add a cast member
if (types.contains(PersonType.CAST)) {
for (PersonCredit member : cast) {
member.setPersonType(PersonType.CAST);
personCredits.add(member);
}
}
// Add a crew member
if (types.contains(PersonType.CREW)) {
for (PersonCredit member : crew) {
member.setPersonType(PersonType.CREW);
personCredits.add(member);
}
}
return personCredits;
}
} }
@@ -0,0 +1,42 @@
/*
* 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;
import com.omertron.themoviedbapi.model.Person;
import java.util.List;
/**
*
* @author Stuart
*/
public class WrapperPersonList extends AbstractWrapperAll {
@JsonProperty("results")
private List<Person> personList;
public List<Person> getPersonList() {
return personList;
}
public void setPersonList(List<Person> personList) {
this.personList = personList;
}
}
@@ -19,62 +19,26 @@
*/ */
package com.omertron.themoviedbapi.wrapper; package com.omertron.themoviedbapi.wrapper;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.omertron.themoviedbapi.model.ReleaseInfo; import com.omertron.themoviedbapi.model.ReleaseInfo;
import java.io.Serializable;
import java.util.List; import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* *
* @author Stuart * @author Stuart
*/ */
public class WrapperReleaseInfo { public class WrapperReleaseInfo extends AbstractWrapperId implements Serializable {
/*
* Logger
*/
private static final Logger LOG = LoggerFactory.getLogger(WrapperReleaseInfo.class); private static final long serialVersionUID = 1L;
/*
* Properties
*/
@JsonProperty("id")
private int id;
@JsonProperty("countries") @JsonProperty("countries")
private List<ReleaseInfo> countries; private List<ReleaseInfo> countries;
//<editor-fold defaultstate="collapsed" desc="Getter methods">
public List<ReleaseInfo> getCountries() { public List<ReleaseInfo> getCountries() {
return countries; return countries;
} }
public int getId() {
return id;
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="Setter methods">
public void setCountries(List<ReleaseInfo> countries) { public void setCountries(List<ReleaseInfo> countries) {
this.countries = countries; this.countries = countries;
} }
public void setId(int id) {
this.id = id;
}
//</editor-fold>
/**
* Handle unknown properties and print a message
*
* @param key
* @param value
*/
@JsonAnySetter
public void handleUnknown(String key, Object value) {
StringBuilder sb = new StringBuilder();
sb.append("Unknown property: '").append(key);
sb.append("' value: '").append(value).append("'");
LOG.trace(sb.toString());
}
} }
@@ -0,0 +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;
import com.omertron.themoviedbapi.model.Reviews;
import java.io.Serializable;
import java.util.List;
/**
*
* @author stuart.boston
*/
public class WrapperReviews extends AbstractWrapperAll implements Serializable {
private static final long serialVersionUID = 1L;
@JsonProperty("results")
private List<Reviews> reviews;
public List<Reviews> getReviews() {
return reviews;
}
public void setReviews(List<Reviews> reviews) {
this.reviews = reviews;
}
}
@@ -19,38 +19,24 @@
*/ */
package com.omertron.themoviedbapi.wrapper; package com.omertron.themoviedbapi.wrapper;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.omertron.themoviedbapi.model.Trailer; import com.omertron.themoviedbapi.model.Trailer;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* *
* @author Stuart * @author Stuart
*/ */
public class WrapperTrailers { public class WrapperTrailers extends AbstractWrapperId implements Serializable {
/*
* Logger
*/
private static final Logger LOG = LoggerFactory.getLogger(WrapperTrailers.class); private static final long serialVersionUID = 1L;
/*
* Properties
*/
@JsonProperty("id")
private int id;
@JsonProperty("quicktime") @JsonProperty("quicktime")
private List<Trailer> quicktime; private List<Trailer> quicktime;
@JsonProperty("youtube") @JsonProperty("youtube")
private List<Trailer> youtube; private List<Trailer> youtube;
//<editor-fold defaultstate="collapsed" desc="Getter methods">
public int getId() {
return id;
}
public List<Trailer> getQuicktime() { public List<Trailer> getQuicktime() {
return quicktime; return quicktime;
} }
@@ -58,12 +44,6 @@ public class WrapperTrailers {
public List<Trailer> getYoutube() { public List<Trailer> getYoutube() {
return youtube; return youtube;
} }
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="Setter methods">
public void setId(int id) {
this.id = id;
}
public void setQuicktime(List<Trailer> quicktime) { public void setQuicktime(List<Trailer> quicktime) {
this.quicktime = quicktime; this.quicktime = quicktime;
@@ -72,19 +52,26 @@ public class WrapperTrailers {
public void setYoutube(List<Trailer> youtube) { public void setYoutube(List<Trailer> youtube) {
this.youtube = youtube; this.youtube = youtube;
} }
//</editor-fold>
/** /**
* Handle unknown properties and print a message * Get a combined list of the trailers with their source website
* *
* @param key * @return
* @param value
*/ */
@JsonAnySetter public List<Trailer> getAll() {
public void handleUnknown(String key, Object value) { List<Trailer> trailers = new ArrayList<Trailer>();
StringBuilder sb = new StringBuilder();
sb.append("Unknown property: '").append(key); // Add the trailer to the return list along with it's source
sb.append("' value: '").append(value).append("'"); for (Trailer trailer : quicktime) {
LOG.trace(sb.toString()); trailer.setWebsite(Trailer.WEBSITE_QUICKTIME);
trailers.add(trailer);
}
// Add the trailer to the return list along with it's source
for (Trailer trailer : youtube) {
trailer.setWebsite(Trailer.WEBSITE_YOUTUBE);
trailers.add(trailer);
}
return trailers;
} }
} }
@@ -19,62 +19,26 @@
*/ */
package com.omertron.themoviedbapi.wrapper; package com.omertron.themoviedbapi.wrapper;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import com.omertron.themoviedbapi.model.Translation; import com.omertron.themoviedbapi.model.Translation;
import java.io.Serializable;
import java.util.List; import java.util.List;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* *
* @author Stuart * @author Stuart
*/ */
public class WrapperTranslations { public class WrapperTranslations extends AbstractWrapperId implements Serializable {
/*
* Logger
*/
private static final Logger LOG = LoggerFactory.getLogger(WrapperTranslations.class); private static final long serialVersionUID = 1L;
/*
* Properties
*/
@JsonProperty("id")
private int id;
@JsonProperty("translations") @JsonProperty("translations")
private List<Translation> translations; private List<Translation> translations;
//<editor-fold defaultstate="collapsed" desc="Setter methods">
public void setId(int id) {
this.id = id;
}
public void setTranslations(List<Translation> translations) { public void setTranslations(List<Translation> translations) {
this.translations = translations; this.translations = translations;
} }
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="Getter methods">
public int getId() {
return id;
}
public List<Translation> getTranslations() { public List<Translation> getTranslations() {
return translations; return translations;
} }
//</editor-fold>
/**
* Handle unknown properties and print a message
*
* @param key
* @param value
*/
@JsonAnySetter
public void handleUnknown(String key, Object value) {
StringBuilder sb = new StringBuilder();
sb.append("Unknown property: '").append(key);
sb.append("' value: '").append(value).append("'");
LOG.trace(sb.toString());
}
} }
+33 -33
View File
@@ -1,39 +1,39 @@
<assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2" <assembly xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd"> xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.2 http://maven.apache.org/xsd/assembly-1.1.2.xsd">
<id>bin</id> <id>bin</id>
<formats> <formats>
<format>${distribution.format}</format> <format>${distribution.format}</format>
</formats> </formats>
<includeBaseDirectory>false</includeBaseDirectory> <includeBaseDirectory>false</includeBaseDirectory>
<fileSets> <fileSets>
<!-- add version.txt file --> <!-- add version.txt file -->
<fileSet> <fileSet>
<directory>${project.build.directory}</directory> <directory>${project.build.directory}</directory>
<outputDirectory></outputDirectory> <outputDirectory></outputDirectory>
<includes> <includes>
<include>version.txt</include> <include>version.txt</include>
</includes> </includes>
</fileSet> </fileSet>
<!-- add readme.txt file --> <!-- add readme.txt file -->
<fileSet> <fileSet>
<directory>${basedir}</directory> <directory>${basedir}</directory>
<outputDirectory></outputDirectory> <outputDirectory></outputDirectory>
<includes> <includes>
<include>readme.txt</include> <include>README.md</include>
</includes> </includes>
</fileSet> </fileSet>
<!-- add jar files --> <!-- add jar files -->
<fileSet> <fileSet>
<directory>${project.build.directory}</directory> <directory>${project.build.directory}</directory>
<outputDirectory></outputDirectory> <outputDirectory></outputDirectory>
<includes> <includes>
<include>**/*.jar</include> <include>**/*.jar</include>
</includes> </includes>
</fileSet> </fileSet>
</fileSets> </fileSets>
</assembly> </assembly>
@@ -46,7 +46,7 @@ public class TestLogger {
config.append(".level = ").append(level).append(CRLF); config.append(".level = ").append(level).append(CRLF);
config.append("java.util.logging.ConsoleHandler.level = ").append(level).append(CRLF); config.append("java.util.logging.ConsoleHandler.level = ").append(level).append(CRLF);
// Only works with Java 7 or later // 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); 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 // Exclude http logging
config.append("sun.net.www.protocol.http.HttpURLConnection.level = OFF").append(CRLF); config.append("sun.net.www.protocol.http.HttpURLConnection.level = OFF").append(CRLF);
@@ -19,34 +19,54 @@
*/ */
package com.omertron.themoviedbapi; package com.omertron.themoviedbapi;
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.util.List;
import java.util.Random;
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.AlternativeTitle;
import com.omertron.themoviedbapi.model.Artwork; 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.Collection;
import com.omertron.themoviedbapi.model.CollectionInfo; import com.omertron.themoviedbapi.model.CollectionInfo;
import com.omertron.themoviedbapi.model.Company; import com.omertron.themoviedbapi.model.Company;
import com.omertron.themoviedbapi.model.Discover;
import com.omertron.themoviedbapi.model.Genre; import com.omertron.themoviedbapi.model.Genre;
import com.omertron.themoviedbapi.model.JobDepartment;
import com.omertron.themoviedbapi.model.Keyword; import com.omertron.themoviedbapi.model.Keyword;
import com.omertron.themoviedbapi.model.KeywordMovie; import com.omertron.themoviedbapi.model.KeywordMovie;
import com.omertron.themoviedbapi.model.MovieChanges;
import com.omertron.themoviedbapi.model.MovieDb; import com.omertron.themoviedbapi.model.MovieDb;
import com.omertron.themoviedbapi.model.MovieDbList; import com.omertron.themoviedbapi.model.MovieDbList;
import com.omertron.themoviedbapi.model.MovieList; import com.omertron.themoviedbapi.model.MovieList;
import com.omertron.themoviedbapi.model.Person; import com.omertron.themoviedbapi.model.Person;
import com.omertron.themoviedbapi.model.PersonCredit; import com.omertron.themoviedbapi.model.PersonCredit;
import com.omertron.themoviedbapi.model.ReleaseInfo; 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.TmdbConfiguration;
import com.omertron.themoviedbapi.model.TokenAuthorisation; import com.omertron.themoviedbapi.model.TokenAuthorisation;
import com.omertron.themoviedbapi.model.TokenSession; import com.omertron.themoviedbapi.model.TokenSession;
import com.omertron.themoviedbapi.model.Trailer; import com.omertron.themoviedbapi.model.Trailer;
import com.omertron.themoviedbapi.model.Translation; import com.omertron.themoviedbapi.model.Translation;
import java.io.IOException; import com.omertron.themoviedbapi.results.TmdbResultsList;
import java.util.Collections; import com.omertron.themoviedbapi.results.TmdbResultsMap;
import java.util.List;
import org.apache.commons.lang3.StringUtils;
import org.junit.*;
import static org.junit.Assert.*;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* Test cases for TheMovieDbApi API * Test cases for TheMovieDbApi API
@@ -62,9 +82,10 @@ public class TheMovieDbApiTest {
private static TheMovieDbApi tmdb; private static TheMovieDbApi tmdb;
// Test data // Test data
private static final int ID_MOVIE_BLADE_RUNNER = 78; private static final int ID_MOVIE_BLADE_RUNNER = 78;
private static final int ID_MOVIE_STAR_WARS_COLLECTION = 10; private static final int ID_MOVIE_THE_AVENGERS = 24428;
private static final int ID_COLLECTION_STAR_WARS = 10;
private static final int ID_PERSON_BRUCE_WILLIS = 62; private static final int ID_PERSON_BRUCE_WILLIS = 62;
private static final int ID_COMPANY_LUCASFILM = 1; private static final int ID_COMPANY = 2;
private static final String COMPANY_NAME = "Marvel Studios"; private static final String COMPANY_NAME = "Marvel Studios";
private static final int ID_GENRE_ACTION = 28; private static final int ID_GENRE_ACTION = 28;
private static final String ID_KEYWORD = "1721"; private static final String ID_KEYWORD = "1721";
@@ -72,6 +93,9 @@ public class TheMovieDbApiTest {
private static final String LANGUAGE_DEFAULT = ""; private static final String LANGUAGE_DEFAULT = "";
private static final String LANGUAGE_ENGLISH = "en"; private static final String LANGUAGE_ENGLISH = "en";
private static final String LANGUAGE_RUSSIAN = "ru"; private static final String LANGUAGE_RUSSIAN = "ru";
// session and account id of test users named 'apitests'
private static final String SESSION_ID_APITESTS = "63c85deb39337e29b69d78265eb28d639cbd6f72";
private static final int ACCOUNT_ID_APITESTS = 6065849;
public TheMovieDbApiTest() throws MovieDbException { public TheMovieDbApiTest() throws MovieDbException {
} }
@@ -98,7 +122,7 @@ public class TheMovieDbApiTest {
* Test of getConfiguration method, of class TheMovieDbApi. * Test of getConfiguration method, of class TheMovieDbApi.
*/ */
@Test @Test
public void testConfiguration() throws IOException { public void testConfiguration() {
LOG.info("Test Configuration"); LOG.info("Test Configuration");
TmdbConfiguration tmdbConfig = tmdb.getConfiguration(); TmdbConfiguration tmdbConfig = tmdb.getConfiguration();
@@ -110,68 +134,121 @@ public class TheMovieDbApiTest {
LOG.info(tmdbConfig.toString()); LOG.info(tmdbConfig.toString());
} }
@Test
public void testAccount() throws MovieDbException {
Account account = tmdb.getAccount(SESSION_ID_APITESTS);
// Make sure properties are extracted correctly
assertEquals(account.getUserName(), "apitests");
assertEquals(account.getId(), ACCOUNT_ID_APITESTS);
}
@Ignore("Session required")
public void testWatchList() throws MovieDbException {
// make sure it's empty (because it's just a test account
Assert.assertTrue(tmdb.getWatchList(SESSION_ID_APITESTS, ACCOUNT_ID_APITESTS).isEmpty());
// add a movie
tmdb.addToWatchList(SESSION_ID_APITESTS, ACCOUNT_ID_APITESTS, 550);
List<MovieDb> watchList = tmdb.getWatchList(SESSION_ID_APITESTS, ACCOUNT_ID_APITESTS);
assertNotNull("Empty watch list returned", watchList);
assertEquals("Watchlist wrong size", 1, watchList.size());
// clean up again
tmdb.removeFromWatchList(SESSION_ID_APITESTS, ACCOUNT_ID_APITESTS, 550);
Assert.assertTrue(tmdb.getWatchList(SESSION_ID_APITESTS, ACCOUNT_ID_APITESTS).isEmpty());
}
@Ignore("Session required")
public void testFavorites() throws MovieDbException {
// make sure it's empty (because it's just a test account
Assert.assertTrue(tmdb.getFavoriteMovies(SESSION_ID_APITESTS, ACCOUNT_ID_APITESTS).isEmpty());
// add a movie
tmdb.changeFavoriteStatus(SESSION_ID_APITESTS, ACCOUNT_ID_APITESTS, 550, true);
List<MovieDb> watchList = tmdb.getFavoriteMovies(SESSION_ID_APITESTS, ACCOUNT_ID_APITESTS);
assertNotNull("Empty watch list returned", watchList);
assertEquals("Watchlist wrong size", 1, watchList.size());
// clean up again
tmdb.changeFavoriteStatus(SESSION_ID_APITESTS, ACCOUNT_ID_APITESTS, 550, false);
Assert.assertTrue(tmdb.getFavoriteMovies(SESSION_ID_APITESTS, ACCOUNT_ID_APITESTS).isEmpty());
}
/** /**
* Test of searchMovie method, of class TheMovieDbApi. * Test of searchMovie method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/ */
@Test @Test
public void testSearchMovie() throws MovieDbException { public void testSearchMovie() throws MovieDbException {
LOG.info("searchMovie"); LOG.info("searchMovie");
// Try a movie with less than 1 page of results // Try a movie with less than 1 page of results
List<MovieDb> movieList = tmdb.searchMovie("Blade Runner", 0, "", true, 0); TmdbResultsList<MovieDb> movieList = tmdb.searchMovie("Blade Runner", 0, "", true, 0);
// List<MovieDb> movieList = tmdb.searchMovie("Blade Runner", "", true); // List<MovieDb> movieList = tmdb.searchMovie("Blade Runner", "", true);
assertTrue("No movies found, should be at least 1", movieList.size() > 0); assertTrue("No movies found, should be at least 1", movieList.getResults().size() > 0);
// Try a russian langugage movie // Try a russian langugage movie
movieList = tmdb.searchMovie("О чём говорят мужчины", 0, LANGUAGE_RUSSIAN, true, 0); movieList = tmdb.searchMovie("О чём говорят мужчины", 0, LANGUAGE_RUSSIAN, true, 0);
assertTrue("No 'RU' movies found, should be at least 1", movieList.size() > 0); assertTrue("No 'RU' movies found, should be at least 1", movieList.getResults().size() > 0);
// Try a movie with more than 20 results // Try a movie with more than 20 results
movieList = tmdb.searchMovie("Star Wars", 0, LANGUAGE_ENGLISH, false, 0); movieList = tmdb.searchMovie("Star Wars", 0, LANGUAGE_ENGLISH, false, 0);
assertTrue("Not enough movies found, should be over 15, found " + movieList.size(), movieList.size() >= 15); assertTrue("Not enough movies found, should be over 15, found " + movieList.getResults().size(), movieList.getResults().size() >= 15);
} }
/** /**
* Test of getMovieInfo method, of class TheMovieDbApi. * Test of getMovieInfo method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/ */
@Test @Test
public void testGetMovieInfo() throws MovieDbException { public void testGetMovieInfo() throws MovieDbException {
LOG.info("getMovieInfo"); LOG.info("getMovieInfo");
MovieDb result = tmdb.getMovieInfo(ID_MOVIE_BLADE_RUNNER, LANGUAGE_ENGLISH); MovieDb result = tmdb.getMovieInfo(ID_MOVIE_BLADE_RUNNER, LANGUAGE_ENGLISH, "alternative_titles,casts,images,keywords,releases,trailers,translations,similar_movies,reviews,lists");
assertEquals("Incorrect movie information", "Blade Runner", result.getOriginalTitle()); assertEquals("Incorrect movie information", "Blade Runner", result.getOriginalTitle());
} }
/** /**
* Test of getMovieAlternativeTitles method, of class TheMovieDbApi. * Test of getMovieAlternativeTitles method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/ */
@Test @Test
public void testGetMovieAlternativeTitles() throws MovieDbException { public void testGetMovieAlternativeTitles() throws MovieDbException {
LOG.info("getMovieAlternativeTitles"); LOG.info("getMovieAlternativeTitles");
String country = ""; String country = "";
List<AlternativeTitle> results = tmdb.getMovieAlternativeTitles(ID_MOVIE_BLADE_RUNNER, country); TmdbResultsList<AlternativeTitle> result = tmdb.getMovieAlternativeTitles(ID_MOVIE_BLADE_RUNNER, country, "casts,images,keywords,releases,trailers,translations,similar_movies,reviews,lists");
assertTrue("No alternative titles found", results.size() > 0); assertTrue("No alternative titles found", result.getResults().size() > 0);
country = "US"; country = "US";
results = tmdb.getMovieAlternativeTitles(ID_MOVIE_BLADE_RUNNER, country); result = tmdb.getMovieAlternativeTitles(ID_MOVIE_BLADE_RUNNER, country);
assertTrue("No alternative titles found", results.size() > 0); assertTrue("No alternative titles found", result.getResults().size() > 0);
} }
/** /**
* Test of getMovieCasts method, of class TheMovieDbApi. * Test of getMovieCasts method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/ */
@Test @Test
public void testGetMovieCasts() throws MovieDbException { public void testGetMovieCasts() throws MovieDbException {
LOG.info("getMovieCasts"); LOG.info("getMovieCasts");
List<Person> people = tmdb.getMovieCasts(ID_MOVIE_BLADE_RUNNER); TmdbResultsList<Person> people = tmdb.getMovieCasts(ID_MOVIE_BLADE_RUNNER, "alternative_titles,casts,images,keywords,releases,trailers,translations,similar_movies,reviews,lists");
assertTrue("No cast information", people.size() > 0); assertTrue("No cast information", people.getResults().size() > 0);
String name1 = "Harrison Ford"; String name1 = "Harrison Ford";
String name2 = "Charles Knode"; String name2 = "Charles Knode";
boolean foundName1 = Boolean.FALSE; boolean foundName1 = Boolean.FALSE;
boolean foundName2 = Boolean.FALSE; boolean foundName2 = Boolean.FALSE;
for (Person person : people) { for (Person person : people.getResults()) {
if (!foundName1 && person.getName().equalsIgnoreCase(name1)) { if (!foundName1 && person.getName().equalsIgnoreCase(name1)) {
foundName1 = Boolean.TRUE; foundName1 = Boolean.TRUE;
} }
@@ -186,63 +263,75 @@ public class TheMovieDbApiTest {
/** /**
* Test of getMovieImages method, of class TheMovieDbApi. * Test of getMovieImages method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/ */
@Test @Test
public void testGetMovieImages() throws MovieDbException { public void testGetMovieImages() throws MovieDbException {
LOG.info("getMovieImages"); LOG.info("getMovieImages");
String language = ""; String language = "";
List<Artwork> result = tmdb.getMovieImages(ID_MOVIE_BLADE_RUNNER, language); TmdbResultsList<Artwork> result = tmdb.getMovieImages(ID_MOVIE_BLADE_RUNNER, language);
assertFalse("No artwork found", result.isEmpty()); assertFalse("No artwork found", result.getResults().isEmpty());
} }
/** /**
* Test of getMovieKeywords method, of class TheMovieDbApi. * Test of getMovieKeywords method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/ */
@Test @Test
public void testGetMovieKeywords() throws MovieDbException { public void testGetMovieKeywords() throws MovieDbException {
LOG.info("getMovieKeywords"); LOG.info("getMovieKeywords");
List<Keyword> result = tmdb.getMovieKeywords(ID_MOVIE_BLADE_RUNNER); TmdbResultsList<Keyword> result = tmdb.getMovieKeywords(ID_MOVIE_BLADE_RUNNER);
assertFalse("No keywords found", result.isEmpty()); assertFalse("No keywords found", result.getResults().isEmpty());
} }
/** /**
* Test of getMovieReleaseInfo method, of class TheMovieDbApi. * Test of getMovieReleaseInfo method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/ */
@Test @Test
public void testGetMovieReleaseInfo() throws MovieDbException { public void testGetMovieReleaseInfo() throws MovieDbException {
LOG.info("getMovieReleaseInfo"); LOG.info("getMovieReleaseInfo");
List<ReleaseInfo> result = tmdb.getMovieReleaseInfo(ID_MOVIE_BLADE_RUNNER, ""); TmdbResultsList<ReleaseInfo> result = tmdb.getMovieReleaseInfo(ID_MOVIE_BLADE_RUNNER, "");
assertFalse("Release information missing", result.isEmpty()); assertFalse("Release information missing", result.getResults().isEmpty());
} }
/** /**
* Test of getMovieTrailers method, of class TheMovieDbApi. * Test of getMovieTrailers method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/ */
@Test @Test
public void testGetMovieTrailers() throws MovieDbException { public void testGetMovieTrailers() throws MovieDbException {
LOG.info("getMovieTrailers"); LOG.info("getMovieTrailers");
List<Trailer> result = tmdb.getMovieTrailers(ID_MOVIE_BLADE_RUNNER, ""); TmdbResultsList<Trailer> result = tmdb.getMovieTrailers(ID_MOVIE_BLADE_RUNNER, "");
assertFalse("Movie trailers missing", result.isEmpty()); assertFalse("Movie trailers missing", result.getResults().isEmpty());
} }
/** /**
* Test of getMovieTranslations method, of class TheMovieDbApi. * Test of getMovieTranslations method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/ */
@Test @Test
public void testGetMovieTranslations() throws MovieDbException { public void testGetMovieTranslations() throws MovieDbException {
LOG.info("getMovieTranslations"); LOG.info("getMovieTranslations");
List<Translation> result = tmdb.getMovieTranslations(ID_MOVIE_BLADE_RUNNER); TmdbResultsList<Translation> result = tmdb.getMovieTranslations(ID_MOVIE_BLADE_RUNNER);
assertFalse("No translations found", result.isEmpty()); assertFalse("No translations found", result.getResults().isEmpty());
} }
/** /**
* Test of getCollectionInfo method, of class TheMovieDbApi. * Test of getCollectionInfo method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/ */
@Test @Test
public void testGetCollectionInfo() throws MovieDbException { public void testGetCollectionInfo() throws MovieDbException {
LOG.info("getCollectionInfo"); LOG.info("getCollectionInfo");
String language = ""; String language = "";
CollectionInfo result = tmdb.getCollectionInfo(ID_MOVIE_STAR_WARS_COLLECTION, language); CollectionInfo result = tmdb.getCollectionInfo(ID_COLLECTION_STAR_WARS, language);
assertFalse("No collection information", result.getParts().isEmpty()); assertFalse("No collection information", result.getParts().isEmpty());
} }
@@ -261,6 +350,8 @@ public class TheMovieDbApiTest {
/** /**
* Test of getMovieInfoImdb method, of class TheMovieDbApi. * Test of getMovieInfoImdb method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/ */
@Test @Test
public void testGetMovieInfoImdb() throws MovieDbException { public void testGetMovieInfoImdb() throws MovieDbException {
@@ -271,6 +362,7 @@ public class TheMovieDbApiTest {
/** /**
* Test of getApiKey method, of class TheMovieDbApi. * Test of getApiKey method, of class TheMovieDbApi.
*
*/ */
@Test @Test
public void testGetApiKey() { public void testGetApiKey() {
@@ -279,6 +371,7 @@ public class TheMovieDbApiTest {
/** /**
* Test of getApiBase method, of class TheMovieDbApi. * Test of getApiBase method, of class TheMovieDbApi.
*
*/ */
@Test @Test
public void testGetApiBase() { public void testGetApiBase() {
@@ -287,6 +380,7 @@ public class TheMovieDbApiTest {
/** /**
* Test of getConfiguration method, of class TheMovieDbApi. * Test of getConfiguration method, of class TheMovieDbApi.
*
*/ */
@Test @Test
public void testGetConfiguration() { public void testGetConfiguration() {
@@ -295,18 +389,22 @@ public class TheMovieDbApiTest {
/** /**
* Test of searchPeople method, of class TheMovieDbApi. * Test of searchPeople method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/ */
@Test @Test
public void testSearchPeople() throws MovieDbException { public void testSearchPeople() throws MovieDbException {
LOG.info("searchPeople"); LOG.info("searchPeople");
String personName = "Bruce Willis"; String personName = "Bruce Willis";
boolean includeAdult = false; boolean includeAdult = false;
List<Person> result = tmdb.searchPeople(personName, includeAdult, 0); TmdbResultsList<Person> result = tmdb.searchPeople(personName, includeAdult, 0);
assertTrue("Couldn't find the person", result.size() > 0); assertTrue("Couldn't find the person", result.getResults().size() > 0);
} }
/** /**
* Test of getPersonInfo method, of class TheMovieDbApi. * Test of getPersonInfo method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/ */
@Test @Test
public void testGetPersonInfo() throws MovieDbException { public void testGetPersonInfo() throws MovieDbException {
@@ -317,28 +415,34 @@ public class TheMovieDbApiTest {
/** /**
* Test of getPersonCredits method, of class TheMovieDbApi. * Test of getPersonCredits method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/ */
@Test @Test
public void testGetPersonCredits() throws MovieDbException { public void testGetPersonCredits() throws MovieDbException {
LOG.info("getPersonCredits"); LOG.info("getPersonCredits");
List<PersonCredit> people = tmdb.getPersonCredits(ID_PERSON_BRUCE_WILLIS); TmdbResultsList<PersonCredit> result = tmdb.getPersonCredits(ID_PERSON_BRUCE_WILLIS);
assertTrue("No cast information", people.size() > 0); assertTrue("No cast information", result.getResults().size() > 0);
} }
/** /**
* Test of getPersonImages method, of class TheMovieDbApi. * Test of getPersonImages method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/ */
@Test @Test
public void testGetPersonImages() throws MovieDbException { public void testGetPersonImages() throws MovieDbException {
LOG.info("getPersonImages"); LOG.info("getPersonImages");
List<Artwork> artwork = tmdb.getPersonImages(ID_PERSON_BRUCE_WILLIS); TmdbResultsList<Artwork> result = tmdb.getPersonImages(ID_PERSON_BRUCE_WILLIS);
assertTrue("No cast information", artwork.size() > 0); assertTrue("No cast information", result.getResults().size() > 0);
} }
/** /**
* Test of getLatestMovie method, of class TheMovieDbApi. * Test of getLatestMovie method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/ */
@Test @Test
public void testGetLatestMovie() throws MovieDbException { public void testGetLatestMovie() throws MovieDbException {
@@ -350,6 +454,7 @@ public class TheMovieDbApiTest {
/** /**
* Test of compareMovies method, of class TheMovieDbApi. * Test of compareMovies method, of class TheMovieDbApi.
*
*/ */
@Test @Test
public void testCompareMovies() { public void testCompareMovies() {
@@ -358,6 +463,7 @@ public class TheMovieDbApiTest {
/** /**
* Test of setProxy method, of class TheMovieDbApi. * Test of setProxy method, of class TheMovieDbApi.
*
*/ */
@Test @Test
public void testSetProxy() { public void testSetProxy() {
@@ -366,6 +472,7 @@ public class TheMovieDbApiTest {
/** /**
* Test of setTimeout method, of class TheMovieDbApi. * Test of setTimeout method, of class TheMovieDbApi.
*
*/ */
@Test @Test
public void testSetTimeout() { public void testSetTimeout() {
@@ -374,116 +481,141 @@ public class TheMovieDbApiTest {
/** /**
* Test of getNowPlayingMovies method, of class TheMovieDbApi. * Test of getNowPlayingMovies method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/ */
@Test @Test
public void testGetNowPlayingMovies() throws MovieDbException { public void testGetNowPlayingMovies() throws MovieDbException {
LOG.info("getNowPlayingMovies"); LOG.info("getNowPlayingMovies");
List<MovieDb> results = tmdb.getNowPlayingMovies(LANGUAGE_DEFAULT, 0); TmdbResultsList<MovieDb> result = tmdb.getNowPlayingMovies(LANGUAGE_DEFAULT, 0);
assertTrue("No now playing movies found", !results.isEmpty()); assertTrue("No now playing movies found", !result.getResults().isEmpty());
} }
/** /**
* Test of getPopularMovieList method, of class TheMovieDbApi. * Test of getPopularMovieList method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/ */
@Test @Test
public void testGetPopularMovieList() throws MovieDbException { public void testGetPopularMovieList() throws MovieDbException {
LOG.info("getPopularMovieList"); LOG.info("getPopularMovieList");
List<MovieDb> results = tmdb.getPopularMovieList(LANGUAGE_DEFAULT, 0); TmdbResultsList<MovieDb> result = tmdb.getPopularMovieList(LANGUAGE_DEFAULT, 0);
assertTrue("No popular movies found", !results.isEmpty()); assertTrue("No popular movies found", !result.getResults().isEmpty());
} }
/** /**
* Test of getTopRatedMovies method, of class TheMovieDbApi. * Test of getTopRatedMovies method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/ */
@Test @Test
public void testGetTopRatedMovies() throws MovieDbException { public void testGetTopRatedMovies() throws MovieDbException {
LOG.info("getTopRatedMovies"); LOG.info("getTopRatedMovies");
List<MovieDb> results = tmdb.getTopRatedMovies(LANGUAGE_DEFAULT, 0); TmdbResultsList<MovieDb> result = tmdb.getTopRatedMovies(LANGUAGE_DEFAULT, 0);
assertTrue("No top rated movies found", !results.isEmpty()); assertTrue("No top rated movies found", !result.getResults().isEmpty());
} }
/** /**
* Test of getCompanyInfo method, of class TheMovieDbApi. * Test of getCompanyInfo method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/ */
@Test @Test
public void testGetCompanyInfo() throws MovieDbException { public void testGetCompanyInfo() throws MovieDbException {
LOG.info("getCompanyInfo"); LOG.info("getCompanyInfo");
Company company = tmdb.getCompanyInfo(ID_COMPANY_LUCASFILM); Company company = tmdb.getCompanyInfo(ID_COMPANY);
assertTrue("No company information found", company.getCompanyId() > 0); assertTrue("No company information found", company.getCompanyId() > 0);
assertNotNull("No parent company found", company.getParentCompany());
} }
/** /**
* Test of getCompanyMovies method, of class TheMovieDbApi. * Test of getCompanyMovies method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/ */
@Test @Test
public void testGetCompanyMovies() throws MovieDbException { public void testGetCompanyMovies() throws MovieDbException {
LOG.info("getCompanyMovies"); LOG.info("getCompanyMovies");
List<MovieDb> results = tmdb.getCompanyMovies(ID_COMPANY_LUCASFILM, LANGUAGE_DEFAULT, 0); TmdbResultsList<MovieDb> result = tmdb.getCompanyMovies(ID_COMPANY, LANGUAGE_DEFAULT, 0);
assertTrue("No company movies found", !results.isEmpty()); assertTrue("No company movies found", !result.getResults().isEmpty());
} }
/** /**
* Test of searchCompanies method, of class TheMovieDbApi. * Test of searchCompanies method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/ */
@Test @Test
public void testSearchCompanies() throws MovieDbException { public void testSearchCompanies() throws MovieDbException {
LOG.info("searchCompanies"); LOG.info("searchCompanies");
List<Company> results = tmdb.searchCompanies(COMPANY_NAME, 0); TmdbResultsList<Company> result = tmdb.searchCompanies(COMPANY_NAME, 0);
assertTrue("No company information found", !results.isEmpty()); assertTrue("No company information found", !result.getResults().isEmpty());
} }
/** /**
* Test of getSimilarMovies method, of class TheMovieDbApi. * Test of getSimilarMovies method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/ */
@Test @Test
public void testGetSimilarMovies() throws MovieDbException { public void testGetSimilarMovies() throws MovieDbException {
LOG.info("getSimilarMovies"); LOG.info("getSimilarMovies");
List<MovieDb> results = tmdb.getSimilarMovies(ID_MOVIE_BLADE_RUNNER, LANGUAGE_DEFAULT, 0); TmdbResultsList<MovieDb> result = tmdb.getSimilarMovies(ID_MOVIE_BLADE_RUNNER, LANGUAGE_DEFAULT, 0);
assertTrue("No similar movies found", !results.isEmpty()); assertTrue("No similar movies found", !result.getResults().isEmpty());
} }
/** /**
* Test of getGenreList method, of class TheMovieDbApi. * Test of getGenreList method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/ */
@Test @Test
public void testGetGenreList() throws MovieDbException { public void testGetGenreList() throws MovieDbException {
LOG.info("getGenreList"); LOG.info("getGenreList");
List<Genre> results = tmdb.getGenreList(LANGUAGE_DEFAULT); TmdbResultsList<Genre> result = tmdb.getGenreList(LANGUAGE_DEFAULT);
assertTrue("No genres found", !results.isEmpty()); assertTrue("No genres found", !result.getResults().isEmpty());
} }
/** /**
* Test of getGenreMovies method, of class TheMovieDbApi. * Test of getGenreMovies method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/ */
@Test @Test
public void testGetGenreMovies() throws MovieDbException { public void testGetGenreMovies() throws MovieDbException {
LOG.info("getGenreMovies"); LOG.info("getGenreMovies");
List<MovieDb> results = tmdb.getGenreMovies(ID_GENRE_ACTION, LANGUAGE_DEFAULT, 0, Boolean.TRUE); TmdbResultsList<MovieDb> result = tmdb.getGenreMovies(ID_GENRE_ACTION, LANGUAGE_DEFAULT, 0, Boolean.TRUE);
assertTrue("No genre movies found", !results.isEmpty()); assertTrue("No genre movies found", !result.getResults().isEmpty());
} }
/** /**
* Test of getUpcoming method, of class TheMovieDbApi. * Test of getUpcoming method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/ */
@Test @Test
public void testGetUpcoming() throws Exception { public void testGetUpcoming() throws Exception {
LOG.info("getUpcoming"); LOG.info("getUpcoming");
List<MovieDb> results = tmdb.getUpcoming(LANGUAGE_DEFAULT, 0); TmdbResultsList<MovieDb> result = tmdb.getUpcoming(LANGUAGE_DEFAULT, 0);
assertTrue("No upcoming movies found", !results.isEmpty()); assertTrue("No upcoming movies found", !result.getResults().isEmpty());
} }
/** /**
* Test of getCollectionImages method, of class TheMovieDbApi. * Test of getCollectionImages method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/ */
@Test @Test
public void testGetCollectionImages() throws Exception { public void testGetCollectionImages() throws Exception {
LOG.info("getCollectionImages"); LOG.info("getCollectionImages");
List<Artwork> result = tmdb.getCollectionImages(ID_MOVIE_STAR_WARS_COLLECTION, LANGUAGE_DEFAULT); TmdbResultsList<Artwork> result = tmdb.getCollectionImages(ID_COLLECTION_STAR_WARS, LANGUAGE_DEFAULT);
assertFalse("No artwork found", result.isEmpty()); assertFalse("No artwork found", result.getResults().isEmpty());
} }
/** /**
* Test of getAuthorisationToken method, of class TheMovieDbApi. * Test of getAuthorisationToken method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/ */
@Test @Test
public void testGetAuthorisationToken() throws Exception { public void testGetAuthorisationToken() throws Exception {
@@ -498,13 +630,16 @@ public class TheMovieDbApiTest {
* Test of getSessionToken method, of class TheMovieDbApi. * Test of getSessionToken method, of class TheMovieDbApi.
* *
* TODO: Cannot be tested without a HTTP authorisation: http://help.themoviedb.org/kb/api/user-authentication * TODO: Cannot be tested without a HTTP authorisation: http://help.themoviedb.org/kb/api/user-authentication
*
* @throws MovieDbException
*/ */
@Ignore("Session required")
public void testGetSessionToken() throws Exception { public void testGetSessionToken() throws Exception {
LOG.info("getSessionToken"); LOG.info("getSessionToken");
TokenAuthorisation token = tmdb.getAuthorisationToken(); TokenAuthorisation token = tmdb.getAuthorisationToken();
assertFalse("Token is null", token == null); assertFalse("Token is null", token == null);
assertTrue("Token is not valid", token.getSuccess()); assertTrue("Token is not valid", token.getSuccess());
LOG.info(token.toString()); LOG.info("Token: {}", token.toString());
TokenSession result = tmdb.getSessionToken(token); TokenSession result = tmdb.getSessionToken(token);
assertFalse("Session token is null", result == null); assertFalse("Session token is null", result == null);
@@ -514,8 +649,10 @@ public class TheMovieDbApiTest {
/** /**
* Test of getGuestSessionToken method, of class TheMovieDbApi. * Test of getGuestSessionToken method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/ */
@Test @Ignore("Not ready yet")
public void testGetGuestSessionToken() throws Exception { public void testGetGuestSessionToken() throws Exception {
LOG.info("getGuestSessionToken"); LOG.info("getGuestSessionToken");
TokenSession result = tmdb.getGuestSessionToken(); TokenSession result = tmdb.getGuestSessionToken();
@@ -526,32 +663,33 @@ public class TheMovieDbApiTest {
@Test @Test
public void testGetMovieLists() throws Exception { public void testGetMovieLists() throws Exception {
LOG.info("getMovieLists"); LOG.info("getMovieLists");
List<MovieList> results = tmdb.getMovieLists(ID_MOVIE_BLADE_RUNNER, LANGUAGE_ENGLISH, 0); TmdbResultsList<MovieList> result = tmdb.getMovieLists(ID_MOVIE_BLADE_RUNNER, LANGUAGE_ENGLISH, 0);
assertNotNull("No results found", results); assertNotNull("No results found", result);
assertTrue("No results found", results.size() > 0); assertTrue("No results found", result.getResults().size() > 0);
} }
/** /**
* Test of getMovieChanges method,of class TheMovieDbApi * Test of getMovieChanges method,of class TheMovieDbApi
* *
* TODO: Do not test this until it is fixed * 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 { public void testGetMovieChanges() throws Exception {
LOG.info("getMovieChanges"); LOG.info("getMovieChanges");
String startDate = ""; String startDate = "";
String endDate = null; String endDate = null;
List<MovieChanges> results = Collections.EMPTY_LIST;
// Get some popular movies // Get some popular movies
List<MovieDb> movieList = tmdb.getPopularMovieList(LANGUAGE_DEFAULT, 0); TmdbResultsList<MovieDb> movieList = tmdb.getPopularMovieList(LANGUAGE_DEFAULT, 0);
for (MovieDb movie : movieList) { for (MovieDb movie : movieList.getResults()) {
results = tmdb.getMovieChanges(movie.getId(), startDate, endDate); TmdbResultsMap<String, List<ChangedItem>> result = tmdb.getMovieChanges(movie.getId(), startDate, endDate);
LOG.info("{} has {} changes.", new Object[]{movie.getTitle(), results.size()}); LOG.info("{} has {} changes.", movie.getTitle(), result.getResults().size());
assertTrue("No changes found", result.getResults().size() > 0);
break;
} }
assertNotNull("No results found", results);
assertTrue("No results found", results.size() > 0);
} }
@Test @Test
@@ -566,64 +704,114 @@ public class TheMovieDbApiTest {
/** /**
* Test of searchCollection method, of class TheMovieDbApi. * Test of searchCollection method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/ */
@Test @Test
public void testSearchCollection() throws Exception { public void testSearchCollection() throws Exception {
LOG.info("searchCollection"); LOG.info("searchCollection");
String query = "batman"; String query = "batman";
int page = 0; int page = 0;
List<Collection> result = tmdb.searchCollection(query, LANGUAGE_DEFAULT, page); TmdbResultsList<Collection> result = tmdb.searchCollection(query, LANGUAGE_DEFAULT, page);
assertFalse("No collections found", result == null); assertFalse("No collections found", result == null);
assertTrue("No collections found", result.size() > 0); assertTrue("No collections found", result.getResults().size() > 0);
} }
/** /**
* Test of searchList method, of class TheMovieDbApi. * Test of searchList method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/ */
@Test @Test
public void testSearchList() throws Exception { public void testSearchList() throws Exception {
LOG.info("searchList"); LOG.info("searchList");
String query = "watch"; String query = "watch";
int page = 0; int page = 0;
List result = tmdb.searchList(query, LANGUAGE_DEFAULT, page); TmdbResultsList<MovieList> result = tmdb.searchList(query, LANGUAGE_DEFAULT, page);
assertFalse("No lists found", result == null); assertFalse("No lists found", result.getResults() == null);
assertTrue("No lists found", result.size() > 0); assertTrue("No lists found", result.getResults().size() > 0);
} }
/** /**
* Test of searchKeyword method, of class TheMovieDbApi. * Test of searchKeyword method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/ */
@Test @Test
public void testSearchKeyword() throws Exception { public void testSearchKeyword() throws Exception {
LOG.info("searchKeyword"); LOG.info("searchKeyword");
String query = "action"; String query = "action";
int page = 0; int page = 0;
List<Keyword> result = tmdb.searchKeyword(query, page); TmdbResultsList<Keyword> result = tmdb.searchKeyword(query, page);
assertFalse("No keywords found", result == null); assertFalse("No keywords found", result.getResults() == null);
assertTrue("No keywords found", result.size() > 0); assertTrue("No keywords found", result.getResults().size() > 0);
} }
/** /**
* Test of postMovieRating method, of class TheMovieDbApi. * Test of postMovieRating method, of class TheMovieDbApi.
* *
* TODO: Cannot be tested without a HTTP authorisation: http://help.themoviedb.org/kb/api/user-authentication * TODO: Cannot be tested without a HTTP authorisation: http://help.themoviedb.org/kb/api/user-authentication
*
* @throws MovieDbException
*/ */
public void testPostMovieRating() throws Exception { @Ignore("Session required")
public void testMovieRating() throws Exception {
LOG.info("postMovieRating"); LOG.info("postMovieRating");
String sessionId = ""; Integer movieID = 68724;
String rating = ""; Integer rating = new Random().nextInt(10) + 1;
boolean expResult = false;
boolean result = tmdb.postMovieRating(sessionId, rating); boolean wasPosted = tmdb.postMovieRating(SESSION_ID_APITESTS, movieID, rating);
assertEquals(expResult, result);
// TODO review the generated test code and remove the default call to fail. assertNotNull(wasPosted);
fail("The test case is a prototype."); assertTrue(wasPosted);
// get all rated movies
List<MovieDb> ratedMovies = tmdb.getRatedMovies(SESSION_ID_APITESTS, ACCOUNT_ID_APITESTS);
assertTrue(ratedMovies.size() > 0);
// make sure that we find the movie and it is rated correctly
boolean foundMovie = false;
for (MovieDb movie : ratedMovies) {
if (movie.getId() == movieID) {
assertEquals(movie.getUserRating(), (float) rating, 0);
foundMovie = true;
}
}
assertTrue(foundMovie);
}
@Ignore("Session required")
public void testMovieLists() throws Exception {
Integer movieID = 68724;
// use a random name to avoid that we clash we leftovers of incomplete test runs
String name = "test list " + new Random().nextInt(100);
// create the list
String listId = tmdb.createList(SESSION_ID_APITESTS, name, "api testing only");
// add a movie, and test that it is on the list now
tmdb.addMovieToList(SESSION_ID_APITESTS, listId, movieID);
MovieDbList list = tmdb.getList(listId);
assertNotNull("Movie list returned was null", list);
assertEquals("Unexpected number of items returned", 1, list.getItemCount());
assertEquals((int) movieID, list.getItems().get(0).getId());
// now remove the movie
tmdb.removeMovieFromList(SESSION_ID_APITESTS, listId, movieID);
assertEquals(tmdb.getList(listId).getItemCount(), 0);
// delete the test list
StatusCode statusCode = tmdb.deleteMovieList(SESSION_ID_APITESTS, listId);
assertEquals(statusCode.getStatusCode(), 13);
} }
/** /**
* Test of getPersonChanges method, of class TheMovieDbApi. * Test of getPersonChanges method, of class TheMovieDbApi.
* *
* TODO: Fix the method before testing * @throws MovieDbException
*/ */
@Ignore("Not ready yet")
public void testGetPersonChanges() throws Exception { public void testGetPersonChanges() throws Exception {
LOG.info("getPersonChanges"); LOG.info("getPersonChanges");
String startDate = ""; String startDate = "";
@@ -633,6 +821,8 @@ public class TheMovieDbApiTest {
/** /**
* Test of getList method, of class TheMovieDbApi. * Test of getList method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/ */
@Test @Test
public void testGetList() throws Exception { public void testGetList() throws Exception {
@@ -644,6 +834,8 @@ public class TheMovieDbApiTest {
/** /**
* Test of getKeyword method, of class TheMovieDbApi. * Test of getKeyword method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/ */
@Test @Test
public void testGetKeyword() throws Exception { public void testGetKeyword() throws Exception {
@@ -654,12 +846,150 @@ public class TheMovieDbApiTest {
/** /**
* Test of getKeywordMovies method, of class TheMovieDbApi. * Test of getKeywordMovies method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/ */
@Test @Test
public void testGetKeywordMovies() throws Exception { public void testGetKeywordMovies() throws Exception {
LOG.info("getKeywordMovies"); LOG.info("getKeywordMovies");
int page = 0; int page = 0;
List<KeywordMovie> result = tmdb.getKeywordMovies(ID_KEYWORD, LANGUAGE_DEFAULT, page); TmdbResultsList<KeywordMovie> result = tmdb.getKeywordMovies(ID_KEYWORD, LANGUAGE_DEFAULT, page);
assertFalse("No keyword movies found", result.isEmpty()); assertFalse("No keyword movies found", result.getResults().isEmpty());
}
/**
* Test of getReviews method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/
@Test
public void testGetReviews() throws Exception {
LOG.info("getReviews");
int page = 0;
TmdbResultsList<Reviews> result = tmdb.getReviews(ID_MOVIE_THE_AVENGERS, LANGUAGE_DEFAULT, page);
assertFalse("No reviews found", result.getResults().isEmpty());
}
/**
* Test of compareMovies method, of class TheMovieDbApi.
*
*/
@Ignore("Not required")
public void testCompareMovies_3args() {
}
/**
* Test of compareMovies method, of class TheMovieDbApi.
*
*/
@Ignore("Not required")
public void testCompareMovies_4args() {
}
/**
* Test of getPersonPopular method, of class TheMovieDbApi.
*
*/
@Ignore("Not required")
public void testGetPersonPopular_0args() {
}
/**
* Test of getPersonPopular method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/
@Test
public void testGetPersonPopular_int() throws Exception {
LOG.info("getPersonPopular");
int page = 0;
TmdbResultsList<Person> result = tmdb.getPersonPopular(page);
assertFalse("No popular people", result.getResults().isEmpty());
}
/**
* Test of getGenreMovies method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/
@Ignore("Not required")
public void testGetGenreMovies_3args() throws Exception {
}
/**
* Test of getGenreMovies method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/
@Ignore("Not required")
public void testGetGenreMovies_4args() throws Exception {
}
/**
* Test of getMovieChangesList method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/
@Test
public void testGetMovieChangesList() throws Exception {
LOG.info("getMovieChangesList");
int page = 0;
String startDate = "";
String endDate = "";
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 {
LOG.info("getPersonChangesList");
int page = 0;
String startDate = "";
String endDate = "";
tmdb.getPersonChangesList(page, startDate, endDate);
// TODO review the generated test code and remove the default call to fail.
fail("The test case is a prototype.");
}
/**
* Test of getJobs method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/
@Test
public void testGetJobs() throws Exception {
LOG.info("getJobs");
TmdbResultsList<JobDepartment> result = tmdb.getJobs();
assertFalse("No jobs found", result.getResults().isEmpty());
}
/**
* Test of getDiscover method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/
@Ignore("Not required")
public void testGetDiscover_14args() throws Exception {
}
/**
* Test of getDiscover method, of class TheMovieDbApi.
*
* @throws MovieDbException
*/
@Test
public void testGetDiscover_Discover() throws Exception {
LOG.info("getDiscover");
Discover discover = new Discover();
discover.year(2013).language(LANGUAGE_ENGLISH);
TmdbResultsList<MovieDb> result = tmdb.getDiscover(discover);
assertFalse("No movies discovered", result.getResults().isEmpty());
} }
} }