114 Commits

Author SHA1 Message Date
Omertron 8068b9ac45 [maven-release-plugin] prepare release themoviedbapi-3.7 2013-08-23 10:21:30 +02:00
Omertron a25da9aa2f Reset version 2013-08-23 10:18:48 +02:00
Omertron 7a30ab831c Updated POM versions 2013-08-23 10:13:04 +02:00
Stuart Boston f64786e506 Update tests 2013-08-22 21:32:35 +01:00
Stuart Boston a57e7eeb37 Add toString methods 2013-08-22 21:32:26 +01:00
Stuart Boston 00bdfaf6a7 Add missing properties to MovieDbList
Tidy up other code
2013-08-22 13:13:25 +01:00
Stuart Boston 064117e66d Remove unused imports 2013-08-20 21:22:32 +01:00
Stuart Boston a520c75773 Remove duplicate literals 2013-08-20 21:12:26 +01:00
Stuart Boston 259eb81f32 Remove unused fields 2013-08-20 21:12:11 +01:00
Stuart Boston 8bfe7dcc1b WebBrowser: Throw MovieDbException 2013-08-20 21:11:34 +01:00
Stuart Boston ac57816b1d Merge pull request #6 from holgerbrandl/master
"List" and "Account" implemenation
2013-08-20 20:47:24 +01:00
Stuart Boston 073331cddb Close output stream 2013-08-20 13:18:06 +01:00
Stuart Boston 0ef278e19d Merge branch 'master' of https://github.com/Omertron/api-themoviedb 2013-08-20 09:01:28 +01:00
Stuart Boston d6e02bf1df Merge pull request #5 from holgerbrandl/master
implemented method to post movie ratings
2013-08-20 00:51:52 -07:00
holger fbdf744dc6 implemented method to post movie ratings 2013-08-19 14:28:28 +02:00
Stuart Boston 8478865141 Change ToString style to "short prefix" 2013-07-25 12:52:24 +01:00
Stuart Boston a98eac75dc Add dates to the wrapper where needed 2013-07-24 17:06:30 +01:00
Stuart Boston 9a237042f0 Change ToString style to "Simple" 2013-07-24 16:47:50 +01:00
Stuart Boston bb57c16fe8 Trim the string values for person to remove extra spaces 2013-07-22 13:43:54 +01:00
Stuart Boston 72186feaf9 Fixes issue #4 Company parent correctly de-serialised now 2013-07-15 09:16:16 +01:00
Stuart Boston 20349013cc Updated API-Common version 2013-06-26 16:31:47 +01:00
Stuart Boston c8e33abd59 Merge branch 'master' of https://github.com/Omertron/api-themoviedb 2013-06-26 16:30:42 +01:00
Stuart Boston 940b6a007f Revert "Updated API-Common version"
This reverts commit 822ac2a5d2.
2013-06-26 16:29:46 +01:00
Stuart Boston 822ac2a5d2 Updated API-Common version 2013-06-26 16:24:24 +01:00
Omertron f2593b2754 [maven-release-plugin] prepare for next development iteration 2013-06-26 14:31:33 +02:00
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
Omertron 98a1b5d1b9 [maven-release-plugin] prepare for next development iteration 2013-03-18 13:45:57 +01:00
Omertron 4c2463b14a [maven-release-plugin] prepare release themoviedbapi-3.4 2013-03-18 13:45:45 +01:00
Omertron 7de82cdba8 Updated POM versions 2013-03-18 13:42:56 +01:00
Stuart Boston bf8730c1ee Updated test case for getGenreMovies 2013-03-18 12:37:24 +00:00
Stuart Boston 3085018cf0 Added "Include All Movies" to getGenreMovies
Old method will be deprecated at some point
2013-03-18 12:36:26 +00:00
Stuart Boston d2972ac927 Added IMDB_ID and POPULARITY to Person 2013-03-07 15:32:10 +00:00
Stuart Boston bea972520b Removed unused imports 2013-02-27 08:54:52 +00:00
Stuart Boston e17db7a15b Tidied up test class 2013-02-25 12:56:09 +00:00
Stuart Boston 9e6a290f63 Added English literal to test cases 2013-02-25 09:32:03 +00:00
Stuart Boston 9e9f0b5c9e Optimised logging output 2013-02-25 08:57:26 +00:00
Stuart Boston 03c6e1917a Added Russian literal 2013-02-25 08:46:52 +00:00
Stuart Boston a0fca9e69a Fixed Russian test name 2013-02-25 08:45:54 +00:00
Stuart Boston 40567c3059 Added example Jackson Replacement code 2013-02-25 08:41:24 +00:00
Stuart Boston 160b478c11 Updated LOG messages 2013-02-25 08:30:14 +00:00
Stuart Boston de67805b0c Updated README with logging information 2013-02-24 19:52:57 +00:00
Omertron 1b62ae2ff8 Removed Log4J dependency and switched to SLF4J 2013-02-24 18:58:27 +00:00
Stuart Boston 618406b459 Removed unused imports 2013-02-04 16:15:10 +00:00
Stuart Boston a7498c5c69 Removed unnecessary locals 2013-02-04 16:04:47 +00:00
Omertron f177026261 Added keyword searches 2013-02-03 21:09:41 +00:00
Omertron 1e45b87508 Refactored to use a base class 2013-02-03 19:25:23 +00:00
Omertron 596cde7621 Removed Apiary URL 2013-02-03 19:24:46 +00:00
Omertron 857071676b Updated test cases 2013-02-03 10:51:22 +00:00
Omertron c275e71ab4 Added Keyword and List functions 2013-02-02 15:49:23 +00:00
Omertron f27f6f35fe Updated Javadoc 2013-01-29 21:05:12 +00:00
Omertron 47faecc207 Updated exception details 2013-01-29 20:48:50 +00:00
Omertron deb9eb6642 Renamed log4j properties file 2013-01-29 20:42:14 +00:00
Stuart Boston d3af326a77 removed blank @return's from javadoc 2013-01-28 21:05:10 +00:00
Stuart Boston 1d91a557eb Updated POM Versions 2013-01-28 14:48:55 +00:00
Stuart Boston e59f724466 Updated README 2013-01-28 13:47:05 +00:00
Stuart Boston ff93629ae8 Updated POM 2013-01-28 13:19:56 +00:00
Stuart Boston 50488f98b7 Added automatic site documentation to POM 2013-01-28 13:16:33 +00:00
Omertron 505b8c06dc Removed revision line from version.txt 2013-01-14 20:15:20 +00:00
Omertron 0f8731ffe5 Added accept for JSON to WebBrowser 2013-01-14 19:52:07 +00:00
Omertron 3029bf4086 Updated copyright date 2013-01-01 07:28:38 +00:00
Omertron 55b9760c34 Updated test cases 2012-12-27 21:50:48 +00:00
Omertron 7034be4681 Added keyword search 2012-12-27 21:50:28 +00:00
Omertron 44d63fbf76 Added new searches 2012-12-24 22:35:31 +00:00
Stuart Boston 1009e2598e Removed test for authentication as requires a HTTP session 2012-12-20 12:46:57 +00:00
Omertron 44a60ba786 Add get person latest method 2012-12-19 21:46:37 +00:00
Stuart Boston af0b657586 Remove deprecated functions 2012-12-19 16:00:57 +00:00
Stuart Boston 46cd35f908 Added getMovieChanges method 2012-12-19 15:56:45 +00:00
Stuart Boston 608c0a9b05 Added getMovieLists method 2012-12-18 16:07:10 +00:00
Stuart Boston 902db42094 Added Get Guest Session method 2012-12-18 15:29:05 +00:00
Omertron e7ec580ea2 Add Levenshtein Difference for movie compare 2012-12-17 22:03:12 +00:00
Omertron 1605a71528 [maven-release-plugin] prepare for next development iteration 2012-12-17 13:51:03 +01:00
87 changed files with 7308 additions and 4845 deletions
+2 -1
View File
@@ -5,4 +5,5 @@
*.war *.war
*.ear *.ear
/target/ /target/
/nbactions.xml
+12
View File
@@ -0,0 +1,12 @@
package com.darylbeattie.movies.util;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target(value=ElementType.METHOD)
@Retention(value=RetentionPolicy.RUNTIME)
public @interface JsonAnySetter {
}
+12
View File
@@ -0,0 +1,12 @@
package com.darylbeattie.movies.util;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target({ElementType.FIELD, ElementType.METHOD, ElementType.PARAMETER})
@Retention(RetentionPolicy.RUNTIME)
public @interface JsonProperty {
String value() default "";
}
+12
View File
@@ -0,0 +1,12 @@
package com.darylbeattie.movies.util;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
public @interface JsonRootName {
String value() default "";
}
+69
View File
@@ -0,0 +1,69 @@
package com.darylbeattie.movies.util;
import java.io.IOException;
import java.lang.annotation.Annotation;
import java.lang.reflect.Field;
import java.lang.reflect.ParameterizedType;
import java.util.List;
import org.json.JSONArray;
import org.json.JSONObject;
public class ObjectMapper {
/**
* This takes a JSON string and creates (and populates) an object of the given class
* with the data from that JSON string. It mimics the method signature of the jackson
* JSON API, so that we don't have to import the jackson library into this application.
*
* @param jsonString The JSON string to parse.
* @param objClass The class of object we want to create.
* @return The instantiation of that class, populated with data from the JSON object.
* @throws IOException If there was any kind of issue.
*/
public <T> T readValue(String jsonString, Class<T> objClass) throws IOException {
try {
return readValue(new JSONObject(jsonString), objClass);
}
catch (IOException ioe) {
throw ioe;
}
catch (Exception e) {
e.printStackTrace();
throw new IOException(e);
}
}
@SuppressWarnings("unchecked")
public <T, R> T readValue(JSONObject json, Class<T> objClass) throws IOException {
try {
//TODO Iterate through json object values and call the JsonAnySetter method on the unknown ones.
T obj = objClass.newInstance();
for (Field f : objClass.getFields()) {
Annotation a = f.getAnnotation(JsonProperty.class);
if (List.class.equals(f.getType()) && (json.optJSONArray(((JsonProperty) a).value()) != null)) { // It's a list.
JSONArray jsonArray = json.optJSONArray(((JsonProperty) a).value());
ParameterizedType listType = (ParameterizedType) f.getGenericType();
Class<?> subObj = (Class<?>) listType.getActualTypeArguments()[0];
List<R> subObjList = ((Class<List<R>>) f.getType()).newInstance();
for (int i = 0; i < jsonArray.length(); i++) {
subObjList.add((R) readValue(jsonArray.getJSONObject(i), subObj));
}
f.set(obj, subObjList);
}
else if (a != null) {
f.set(obj, json.opt(((JsonProperty) a).value()));
}
}
return obj;
}
catch (IOException ioe) {
throw ioe;
}
catch (Exception e) {
e.printStackTrace();
throw new IOException(e);
}
}
}
+6
View File
@@ -0,0 +1,6 @@
Jackson Library Replacement
===========================
These files are provided by Darren Beattie as an example of how to replace the Jackson libraries with native libraries inside Android.
They are provided without warrantee and if you modify them or find them useful, please let me know.
+27
View File
@@ -0,0 +1,27 @@
The Movie DB API
================
Author: Stuart Boston (Omertron AT Gmail DOT com)
This API uses the [TheMovieDB.org API](http://api.themoviedb.org/)
Originally written for use by Yet Another Movie Jukebox [(YAMJ)](http://code.google.com/p/moviejukebox/)
But anyone can use it for other projects as well.
***
### 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
---------------
This project uses [SLF4J](http://www.slf4j.org) to abstract the logging in the project.
To use the logging in your own project you should add one of the bindings listed [HERE](http://www.slf4j.org/manual.html#swapping)
Project Documentation
---------------------
The automatically generated documentation can be found [HERE](http://omertron.github.com/api-themoviedb/)
+272 -159
View File
@@ -13,10 +13,58 @@
<groupId>com.omertron</groupId> <groupId>com.omertron</groupId>
<artifactId>themoviedbapi</artifactId> <artifactId>themoviedbapi</artifactId>
<version>3.3</version> <version>3.7</version>
<name>API-The MovieDB</name>
<packaging>jar</packaging> <packaging>jar</packaging>
<name>API-The MovieDB</name>
<description>API for the TheMovieDb.org website</description> <description>API for the TheMovieDb.org website</description>
<url>https://github.com/Omertron/api-themoviedb</url>
<inceptionYear>2012</inceptionYear>
<developers>
<developer>
<name>Stuart Boston</name>
<email>omertron@gmail.com</email>
<id>omertron</id>
<url>http://omertron.com</url>
<timezone>0</timezone>
<roles>
<role>developer</role>
</roles>
</developer>
</developers>
<licenses>
<license>
<name>GNU General Public License v3+</name>
<url>http://www.gnu.org/licenses/gpl-3.0-standalone.html</url>
<distribution>repo</distribution>
</license>
</licenses>
<scm>
<url>scm:git:git@github.com:Omertron/api-themoviedb.git</url>
<connection>scm:git:git@github.com:Omertron/api-themoviedb.git</connection>
<developerConnection>scm:git:git@github.com:Omertron/api-themoviedb.git</developerConnection>
</scm>
<distributionManagement>
<site>
<id>github-project-site</id>
<name>GitHub Project Pages</name>
<url>gitsite:git@github.com/Omertron/api-themoviedb.git</url>
</site>
</distributionManagement>
<issueManagement>
<system>GitHub</system>
<url>https://github.com/Omertron/api-themoviedb/issues</url>
</issueManagement>
<ciManagement>
<system>Jenkins CI</system>
<url>http://jenkins.omertron.com/job/API-TheMovieDb/</url>
</ciManagement>
<properties> <properties>
<skipTests>false</skipTests> <skipTests>false</skipTests>
@@ -25,69 +73,253 @@
<distribution.format>zip</distribution.format> <distribution.format>zip</distribution.format>
</properties> </properties>
<issueManagement>
<system>GitHub</system>
<url>https://github.com/Omertron/api-themoviedb/issues</url>
</issueManagement>
<ciManagement>
<system>Hudson CI</system>
<url>http://jenkins.omertron.com/job/API-TheMovieDb/</url>
</ciManagement>
<scm>
<url>scm:git:git@github.com:Omertron/api-themoviedb.git</url>
<connection>scm:git:git@github.com:Omertron/api-themoviedb.git</connection>
<developerConnection>scm:git:git@github.com:Omertron/api-themoviedb.git</developerConnection>
</scm>
<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>
<groupId>log4j</groupId>
<artifactId>log4j</artifactId>
<version>1.2.17</version>
</dependency>
<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.2</version> <version>2.2.3</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.fasterxml.jackson.core</groupId> <groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId> <artifactId>jackson-annotations</artifactId>
<version>2.1.2</version> <version>2.2.3</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>com.fasterxml.jackson.core</groupId> <groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId> <artifactId>jackson-databind</artifactId>
<version>2.1.2</version> <version>2.2.3</version>
</dependency> </dependency>
<!--LOGGING-->
<dependency> <dependency>
<groupId>commons-codec</groupId> <groupId>org.slf4j</groupId>
<artifactId>commons-codec</artifactId> <artifactId>slf4j-api</artifactId>
<version>1.7</version> <version>1.7.5</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.apache.commons</groupId> <groupId>org.slf4j</groupId>
<artifactId>commons-lang3</artifactId> <artifactId>slf4j-jdk14</artifactId>
<version>3.1</version> <version>1.7.5</version>
<scope>test</scope>
</dependency>
<!--COMMON HTTP TOOLS-->
<dependency>
<groupId>org.yamj</groupId>
<artifactId>api-common</artifactId>
<version>1.0</version>
</dependency> </dependency>
</dependencies> </dependencies>
<build>
<finalName>${project.artifactId}-${project.version}-${buildNumber}</finalName>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>buildnumber-maven-plugin</artifactId>
<version>1.2</version>
<configuration>
<shortRevisionLength>10</shortRevisionLength>
<doCheck>false</doCheck>
<doUpdate>false</doUpdate>
<timestampFormat>{0,date,yyyy-MM-dd HH:mm:ss}</timestampFormat>
</configuration>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>create</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<failOnError>true</failOnError>
<verbose>true</verbose>
<!-- excludes><exclude>**/*</exclude></excludes -->
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<archive>
<manifestEntries>
<Specification-Title>${project.name}</Specification-Title>
<Specification-Version>${project.version}</Specification-Version>
<Implementation-Version>${buildNumber}</Implementation-Version>
<Implementation-Title>${timestamp}</Implementation-Title>
</manifestEntries>
</archive>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.14.1</version>
<configuration>
<!-- To skip tests by default -->
<skipTests>${skipTests}</skipTests>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>create-version-txt</id>
<phase>generate-resources</phase>
<configuration>
<target>
<property name="version_file" value="${project.build.directory}/version.txt" />
<property name="header_line" value="The MovieDb API${line.separator}" />
<property name="build_date_line" value="Build Date: ${timestamp}${line.separator}" />
<property name="version_line" value="Version: ${project.version}${line.separator}" />
<property name="buildnumber_line" value="Git-SHA: ${buildNumber}${line.separator}" />
<echo>Writing version file: ${version_file}</echo>
<echo file="${version_file}" append="false">${header_line}</echo>
<echo file="${version_file}" append="true">${build_date_line}</echo>
<echo file="${version_file}" append="true">${version_line}</echo>
<echo file="${version_file}" append="true">${buildnumber_line}</echo>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.4</version>
<executions>
<execution>
<id>distro-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptors>
<descriptor>src/main/resources/bin.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
<version>2.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-site-plugin</artifactId>
<version>3.3</version>
<configuration>
<reportPlugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-project-info-reports-plugin</artifactId>
<version>2.2</version>
<reports>
<report>index</report>
<report>scm</report>
<report>issue-tracking</report>
<report>help</report>
<report>dependency-convergence</report>
<report>summary</report>
<report>dependency-management</report>
<report>dependencies</report>
<report>license</report>
<report>modules</report>
</reports>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>2.9</version>
</plugin>
</reportPlugins>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-clean-plugin</artifactId>
<version>2.5</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.7</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.4</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-install-plugin</artifactId>
<version>2.4</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-resources-plugin</artifactId>
<version>2.6</version>
</plugin>
</plugins>
<extensions>
<extension>
<groupId>org.apache.maven.scm</groupId>
<artifactId>maven-scm-provider-gitexe</artifactId>
<version>1.8.1</version>
</extension>
<extension>
<groupId>org.apache.maven.scm</groupId>
<artifactId>maven-scm-manager-plexus</artifactId>
<version>1.8.1</version>
</extension>
<extension>
<groupId>org.kathrynhuxtable.maven.wagon</groupId>
<artifactId>wagon-gitsite</artifactId>
<version>0.3.1</version>
</extension>
</extensions>
</build>
<profiles> <profiles>
<profile> <profile>
<id>release-sign-artifacts</id> <id>release-sign-artifacts</id>
@@ -116,123 +348,4 @@
</profile> </profile>
</profiles> </profiles>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>buildnumber-maven-plugin</artifactId>
<version>1.1</version>
<configuration>
<getRevisionOnlyOnce>true</getRevisionOnlyOnce>
<revisionOnScmFailure>0000</revisionOnScmFailure>
<timestampFormat>{0,date,yyyy-MM-dd HH:mm:ss}</timestampFormat>
</configuration>
<executions>
<execution>
<phase>validate</phase>
<goals>
<goal>create</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.5.1</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
<failOnError>true</failOnError>
<verbose>true</verbose>
<!-- excludes><exclude>**/*</exclude></excludes -->
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<version>2.4</version>
<configuration>
<archive>
<manifestEntries>
<Specification-Title>${project.name}</Specification-Title>
<Specification-Version>${project.version}</Specification-Version>
<Implementation-Version>${buildNumber}</Implementation-Version>
<Implementation-Title>${timestamp}</Implementation-Title>
</manifestEntries>
</archive>
</configuration>
</plugin>
<!-- To skip tests by default -->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12.3</version>
<configuration>
<skipTests>${skipTests}</skipTests>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-antrun-plugin</artifactId>
<version>1.7</version>
<executions>
<execution>
<id>create-version-txt</id>
<phase>generate-resources</phase>
<configuration>
<target>
<property name="version_file" value="${project.build.directory}/version.txt" />
<property name="header_line" value="The MovieDb API${line.separator}" />
<property name="build_date_line" value="Build Date: ${timestamp}${line.separator}" />
<property name="version_line" value="Version: ${project.version}${line.separator}" />
<property name="revision_line" value="Revision: r${buildNumber}${line.separator}" />
<echo>Writing version file: ${version_file}</echo>
<echo file="${version_file}" append="false">${header_line}</echo>
<echo file="${version_file}" append="true">${build_date_line}</echo>
<echo file="${version_file}" append="true">${version_line}</echo>
<echo file="${version_file}" append="true">${revision_line}</echo>
</target>
</configuration>
<goals>
<goal>run</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.3</version>
<executions>
<execution>
<id>distro-assembly</id>
<phase>package</phase>
<goals>
<goal>single</goal>
</goals>
<configuration>
<descriptors>
<descriptor>src/main/resources/bin.xml</descriptor>
</descriptors>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>versions-maven-plugin</artifactId>
<version>1.3.1</version>
</plugin>
</plugins>
<finalName>${project.artifactId}-${project.version}-r${buildNumber}</finalName>
<resources>
</resources>
</build>
</project> </project>
-9
View File
@@ -1,9 +0,0 @@
Author: Stuart Boston (Omertron AT Gmail DOT com)
Originally written for use by YetAnotherMovieJukebox (YAMJ) http://code.google.com/p/moviejukebox/
But anyone can feel free to use it for other projects as well.
This uses TheMovieDB.org API as specified here http://api.themoviedb.org/
TheMovieDB.org is an excellent open database for movie and film content. I encourage you to check it
out and contribute to keep it growing.
http://www.themoviedb.org
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2004-2012 Stuart Boston * Copyright (c) 2004-2013 Stuart Boston
* *
* This file is part of TheMovieDB API. * This file is part of TheMovieDB API.
* *
@@ -21,10 +21,45 @@ package com.omertron.themoviedbapi;
public class MovieDbException extends Exception { public class MovieDbException extends Exception {
private static final long serialVersionUID = -8952129102483143278L; private static final long serialVersionUID = 1L;
public enum MovieDbExceptionType { public enum MovieDbExceptionType {
UNKNOWN_CAUSE, INVALID_URL, HTTP_404_ERROR, MOVIE_ID_NOT_FOUND, MAPPING_FAILED, CONNECTION_ERROR, INVALID_IMAGE, AUTHORISATION_FAILURE; /*
* Unknown error occured
*/
UNKNOWN_CAUSE,
/*
* URL is invalid
*/
INVALID_URL,
/*
* Page not found
*/
HTTP_404_ERROR,
/*
* The movie id was not found
*/
MOVIE_ID_NOT_FOUND,
/*
* Mapping failed from target to internal onbjects
*/
MAPPING_FAILED,
/*
* Error connecting to the service
*/
CONNECTION_ERROR,
/*
* Image was invalid
*/
INVALID_IMAGE,
/*
* Autorisation rejected
*/
AUTHORISATION_FAILURE,
/*
* 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,58 @@
/*
* Copyright (c) 2004-2013 Stuart Boston
*
* This file is part of TheMovieDB API.
*
* TheMovieDB API is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation;private either version 3 of the License;private or
* any later version.
*
* TheMovieDB API is distributed in the hope that it will be useful;private
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TheMovieDB API. If not;private see <http://www.gnu.org/licenses/>.
*
*/
package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.Serializable;
/**
* @author Holger Brandl
*/
public abstract class AbstractJsonMapping implements Serializable {
private static Logger getLogger(Class<?> aClass) {
return LoggerFactory.getLogger(aClass);
}
/**
* Handle unknown properties and print a message
*
* @param key
* @param value
*/
@JsonAnySetter
public void handleUnknown(String key, Object value) {
StringBuilder sb = new StringBuilder();
sb.append("Unknown property: '").append(key);
sb.append("' value: '").append(value).append("'");
getLogger(this.getClass()).warn(sb.toString());
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.SIMPLE_STYLE);
}
}
@@ -0,0 +1,66 @@
/*
* Copyright (c) 2004-2013 Stuart Boston
*
* This file is part of TheMovieDB API.
*
* TheMovieDB API is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation;private either version 3 of the License;private or
* any later version.
*
* TheMovieDB API is distributed in the hope that it will be useful;private
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TheMovieDB API. If not;private see <http://www.gnu.org/licenses/>.
*
*/
package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonProperty;
public class Account extends AbstractJsonMapping {
@JsonProperty("id")
private int id;
@JsonProperty("name")
private String name;
@JsonProperty("username")
private String userName;
@JsonProperty("include_adult")
private boolean includeAdult;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public boolean isIncludeAdult() {
return includeAdult;
}
public void setIncludeAdult(boolean includeAdult) {
this.includeAdult = includeAdult;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
}
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2004-2012 Stuart Boston * Copyright (c) 2004-2013 Stuart Boston
* *
* This file is part of TheMovieDB API. * This file is part of TheMovieDB API.
* *
@@ -19,23 +19,17 @@
*/ */
package com.omertron.themoviedbapi.model; package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import java.io.Serializable; import java.io.Serializable;
import org.apache.log4j.Logger;
/** /**
*
* @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 logger = Logger.getLogger(AlternativeTitle.class);
/* /*
* Properties * Properties
*/ */
@@ -64,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("'");
logger.trace(sb.toString());
}
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (obj == null) { if (obj == null) {
@@ -103,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();
}
} }
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2004-2012 Stuart Boston * Copyright (c) 2004-2013 Stuart Boston
* *
* This file is part of TheMovieDB API. * This file is part of TheMovieDB API.
* *
@@ -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.log4j.Logger;
/** /**
* 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 logger = Logger.getLogger(Artwork.class);
/* /*
* Properties * Properties
*/ */
@@ -54,6 +47,8 @@ public class Artwork implements Serializable {
private float voteAverage; private float voteAverage;
@JsonProperty("vote_count") @JsonProperty("vote_count")
private int voteCount; private int voteCount;
@JsonProperty("flag")
private String flag;
private ArtworkType artworkType = ArtworkType.POSTER; private ArtworkType artworkType = ArtworkType.POSTER;
// <editor-fold defaultstate="collapsed" desc="Getter methods"> // <editor-fold defaultstate="collapsed" desc="Getter methods">
@@ -88,6 +83,10 @@ public class Artwork implements Serializable {
public int getVoteCount() { public int getVoteCount() {
return voteCount; return voteCount;
} }
public String getFlag() {
return flag;
}
// </editor-fold> // </editor-fold>
// <editor-fold defaultstate="collapsed" desc="Setter methods"> // <editor-fold defaultstate="collapsed" desc="Setter methods">
@@ -122,21 +121,11 @@ public class Artwork implements Serializable {
public void setVoteCount(int voteCount) { public void setVoteCount(int voteCount) {
this.voteCount = voteCount; this.voteCount = voteCount;
} }
// </editor-fold>
/** public void setFlag(String flag) {
* Handle unknown properties and print a message this.flag = flag;
*
* @param key
* @param value
*/
@JsonAnySetter
public void handleUnknown(String key, Object value) {
StringBuilder sb = new StringBuilder();
sb.append("Unknown property: '").append(key);
sb.append("' value: '").append(value).append("'");
logger.trace(sb.toString());
} }
// </editor-fold>
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
@@ -179,17 +168,4 @@ public class Artwork implements Serializable {
hash = 71 * hash + (this.artworkType != null ? this.artworkType.hashCode() : 0); hash = 71 * hash + (this.artworkType != null ? this.artworkType.hashCode() : 0);
return hash; return hash;
} }
@Override
public String toString() {
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();
}
} }
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2004-2012 Stuart Boston * Copyright (c) 2004-2013 Stuart Boston
* *
* This file is part of TheMovieDB API. * This file is part of TheMovieDB API.
* *
@@ -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 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);
}
}
@@ -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 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);
}
}
@@ -1,177 +1,140 @@
/* /*
* Copyright (c) 2004-2012 Stuart Boston * Copyright (c) 2004-2013 Stuart Boston
* *
* This file is part of TheMovieDB API. * This file is part of TheMovieDB API.
* *
* TheMovieDB API is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* any later version. * any later version.
* *
* TheMovieDB API is distributed in the hope that it will be useful, * TheMovieDB API is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* 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.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 org.apache.commons.lang3.StringUtils;
import java.io.Serializable;
import org.apache.commons.lang3.StringUtils; /**
import org.apache.log4j.Logger; * @author stuart.boston
*/
/** @JsonRootName("collection")
* public class Collection extends AbstractJsonMapping {
* @author stuart.boston
*/ private static final long serialVersionUID = 1L;
@JsonRootName("collection")
public class Collection implements Serializable { /*
* Properties
private static final long serialVersionUID = 1L; */
/* @JsonProperty("id")
* Logger private int id;
*/ @JsonProperty("title")
private static final Logger logger = Logger.getLogger(Collection.class); private String title;
/* @JsonProperty("name")
* Properties private String name;
*/ @JsonProperty("poster_path")
@JsonProperty("id") private String posterPath;
private int id; @JsonProperty("backdrop_path")
@JsonProperty("title") private String backdropPath;
private String title; @JsonProperty("release_date")
@JsonProperty("name") private String releaseDate;
private String name;
@JsonProperty("poster_path") //<editor-fold defaultstate="collapsed" desc="Getter methods">
private String posterPath; public String getBackdropPath() {
@JsonProperty("backdrop_path") return backdropPath;
private String backdropPath; }
@JsonProperty("release_date")
private String releaseDate; public int getId() {
return id;
//<editor-fold defaultstate="collapsed" desc="Getter methods"> }
public String getBackdropPath() {
return backdropPath; public String getPosterPath() {
} return posterPath;
}
public int getId() {
return id; public String getReleaseDate() {
} return releaseDate;
}
public String getPosterPath() {
return posterPath; public String getTitle() {
} if (StringUtils.isBlank(title)) {
return name;
public String getReleaseDate() { }
return releaseDate; return title;
} }
public String getTitle() { public String getName() {
if (StringUtils.isBlank(title)) { if (StringUtils.isBlank(name)) {
return name; return title;
} }
return title; return name;
} }
public String getName() { public void setBackdropPath(String backdropPath) {
if (StringUtils.isBlank(name)) { this.backdropPath = backdropPath;
return title; }
}
return name; public void setId(int id) {
} this.id = id;
//</editor-fold> }
//<editor-fold defaultstate="collapsed" desc="Setter methods"> public void setPosterPath(String posterPath) {
public void setBackdropPath(String backdropPath) { this.posterPath = posterPath;
this.backdropPath = backdropPath; }
}
public void setReleaseDate(String releaseDate) {
public void setId(int id) { this.releaseDate = releaseDate;
this.id = id; }
}
public void setTitle(String title) {
public void setPosterPath(String posterPath) { this.title = title;
this.posterPath = posterPath; }
}
public void setName(String name) {
public void setReleaseDate(String releaseDate) { this.name = name;
this.releaseDate = releaseDate; }
}
@Override
public void setTitle(String title) { public boolean equals(Object obj) {
this.title = title; if (obj == null) {
} return false;
}
public void setName(String name) { if (getClass() != obj.getClass()) {
this.name = name; return false;
} }
//</editor-fold> final Collection other = (Collection) obj;
if ((this.backdropPath == null) ? (other.backdropPath != null) : !this.backdropPath.equals(other.backdropPath)) {
/** return false;
* Handle unknown properties and print a message }
* if (this.id != other.id) {
* @param key return false;
* @param value }
*/ if ((this.title == null) ? (other.title != null) : !this.title.equals(other.title)) {
@JsonAnySetter return false;
public void handleUnknown(String key, Object value) { }
StringBuilder sb = new StringBuilder(); if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) {
sb.append("Unknown property: '").append(key); return false;
sb.append("' value: '").append(value).append("'"); }
logger.trace(sb.toString()); return true;
} }
@Override @Override
public boolean equals(Object obj) { public int hashCode() {
if (obj == null) { int hash = 7;
return false; hash = 19 * hash + (this.backdropPath != null ? this.backdropPath.hashCode() : 0);
} hash = 19 * hash + this.id;
if (getClass() != obj.getClass()) { hash = 19 * hash + (this.title != null ? this.title.hashCode() : 0);
return false; hash = 19 * hash + (this.name != null ? this.name.hashCode() : 0);
} hash = 19 * hash + (this.posterPath != null ? this.posterPath.hashCode() : 0);
final Collection other = (Collection) obj; hash = 19 * hash + (this.releaseDate != null ? this.releaseDate.hashCode() : 0);
if ((this.backdropPath == null) ? (other.backdropPath != null) : !this.backdropPath.equals(other.backdropPath)) { return hash;
return false; }
} }
if (this.id != other.id) {
return false;
}
if ((this.title == null) ? (other.title != null) : !this.title.equals(other.title)) {
return false;
}
if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) {
return false;
}
return true;
}
@Override
public int hashCode() {
int hash = 7;
hash = 19 * hash + (this.backdropPath != null ? this.backdropPath.hashCode() : 0);
hash = 19 * hash + this.id;
hash = 19 * hash + (this.title != null ? this.title.hashCode() : 0);
hash = 19 * hash + (this.name != null ? this.name.hashCode() : 0);
hash = 19 * hash + (this.posterPath != null ? this.posterPath.hashCode() : 0);
hash = 19 * hash + (this.releaseDate != null ? this.releaseDate.hashCode() : 0);
return hash;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder("[Collection=");
sb.append("[id=").append(id);
sb.append("],[title=").append(title);
sb.append("],[name=").append(name);
sb.append("],[posterPath=").append(posterPath);
sb.append("],[backdropPath=").append(backdropPath);
sb.append("],[releaseDate=").append(releaseDate);
sb.append("]]");
return sb.toString();
}
}
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2004-2012 Stuart Boston * Copyright (c) 2004-2013 Stuart Boston
* *
* This file is part of TheMovieDB API. * This file is part of TheMovieDB API.
* *
@@ -19,24 +19,18 @@
*/ */
package com.omertron.themoviedbapi.model; package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.apache.log4j.Logger;
/** /**
*
* @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 logger = Logger.getLogger(CollectionInfo.class);
/* /*
* Properties * Properties
*/ */
@@ -44,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")
@@ -64,6 +60,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;
} }
@@ -71,9 +71,7 @@ public class CollectionInfo implements Serializable {
public String getPosterPath() { public String getPosterPath() {
return posterPath; return posterPath;
} }
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="Setter methods">
public void setBackdropPath(String backdropPath) { public void setBackdropPath(String backdropPath) {
this.backdropPath = backdropPath; this.backdropPath = backdropPath;
} }
@@ -86,6 +84,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;
} }
@@ -93,31 +95,4 @@ public class CollectionInfo implements Serializable {
public void setPosterPath(String posterPath) { public void setPosterPath(String posterPath) {
this.posterPath = posterPath; this.posterPath = posterPath;
} }
//</editor-fold>
/**
* Handle unknown properties and print a message
*
* @param key
* @param value
*/
@JsonAnySetter
public void handleUnknown(String key, Object value) {
StringBuilder sb = new StringBuilder();
sb.append("Unknown property: '").append(key);
sb.append("' value: '").append(value).append("'");
logger.trace(sb.toString());
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder("[CollectionInfo=");
sb.append("[id=").append(id);
sb.append("],[name=").append(name);
sb.append("],[posterPath=").append(posterPath);
sb.append("],[backdropPath=").append(backdropPath);
sb.append("],[# of parts=").append(parts.size());
sb.append("]]");
return sb.toString();
}
} }
@@ -1,132 +1,113 @@
/* /*
* Copyright (c) 2004-2012 Stuart Boston * Copyright (c) 2004-2013 Stuart Boston
* *
* This file is part of TheMovieDB API. * This file is part of TheMovieDB API.
* *
* TheMovieDB API is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* any later version. * any later version.
* *
* TheMovieDB API is distributed in the hope that it will be useful, * TheMovieDB API is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* 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.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.log4j.Logger; * Company information
*
/** * @author Stuart
* Company information */
* public class Company extends AbstractJsonMapping {
* @author Stuart
*/ private static final long serialVersionUID = 1L;
public class Company implements Serializable { private static final String DEFAULT_STRING = "";
// Properties
private static final long serialVersionUID = 1L; @JsonProperty("id")
// Logger private int companyId = 0;
private static final Logger logger = Logger.getLogger(Company.class); @JsonProperty("name")
private static final String DEFAULT_STRING = ""; private String name = DEFAULT_STRING;
// Properties @JsonProperty("description")
@JsonProperty("id") private String description = DEFAULT_STRING;
private int companyId = 0; @JsonProperty("headquarters")
@JsonProperty("name") private String headquarters = DEFAULT_STRING;
private String name = DEFAULT_STRING; @JsonProperty("homepage")
@JsonProperty("description") private String homepage = DEFAULT_STRING;
private String description = DEFAULT_STRING; @JsonProperty("logo_path")
@JsonProperty("headquarters") private String logoPath = DEFAULT_STRING;
private String headquarters = DEFAULT_STRING; @JsonProperty("parent_company")
@JsonProperty("homepage") private Company parentCompany = null;
private String homepage = DEFAULT_STRING;
@JsonProperty("logo_path") //<editor-fold defaultstate="collapsed" desc="Getter Methods">
private String logoPath = DEFAULT_STRING; public int getCompanyId() {
@JsonProperty("parent_company") return companyId;
private String parentCompany = DEFAULT_STRING; }
//<editor-fold defaultstate="collapsed" desc="Getter Methods"> public String getDescription() {
public int getCompanyId() { return description;
return companyId; }
}
public String getHeadquarters() {
public String getDescription() { return headquarters;
return description; }
}
public String getHomepage() {
public String getHeadquarters() { return homepage;
return headquarters; }
}
public String getLogoPath() {
public String getHomepage() { return logoPath;
return homepage; }
}
public String getName() {
public String getLogoPath() { return name;
return logoPath; }
}
public Company getParentCompany() {
public String getName() { return parentCompany;
return name; }
}
public void setCompanyId(int companyId) {
public String getParentCompany() { this.companyId = companyId;
return parentCompany; }
}
//</editor-fold> public void setDescription(String description) {
this.description = description;
//<editor-fold defaultstate="collapsed" desc="Setter Methods"> }
public void setCompanyId(int companyId) {
this.companyId = companyId; public void setHeadquarters(String headquarters) {
} this.headquarters = headquarters;
}
public void setDescription(String description) {
this.description = description; public void setHomepage(String homepage) {
} this.homepage = homepage;
}
public void setHeadquarters(String headquarters) {
this.headquarters = headquarters; public void setLogoPath(String logoPath) {
} this.logoPath = logoPath;
}
public void setHomepage(String homepage) {
this.homepage = homepage; public void setName(String name) {
} this.name = name;
}
public void setLogoPath(String logoPath) {
this.logoPath = logoPath; public void setParentCompany(Company parentCompany) {
} this.parentCompany = parentCompany;
}
public void setName(String name) {
this.name = name; public void setParentCompany(int id, String name, String logoPath) {
} Company parent = new Company();
parent.setCompanyId(companyId);
public void setParentCompany(String parentCompany) { parent.setName(name);
this.parentCompany = parentCompany; parent.setLogoPath(logoPath);
} this.parentCompany = parent;
//</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("'");
logger.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,264 @@
/*
* 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 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
*/
public Discover page(int page) {
if (page > 0) {
params.put(PARAM_PAGE, String.valueOf(page));
}
return this;
}
/**
* ISO 639-1 code
*
* @param language
*/
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
*/
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
*/
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
*/
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
*/
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
*/
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
*/
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
*/
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
*/
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
*/
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
*/
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
*/
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
*/
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);
}
}
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2004-2012 Stuart Boston * Copyright (c) 2004-2013 Stuart Boston
* *
* This file is part of TheMovieDB API. * This file is part of TheMovieDB API.
* *
@@ -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 com.fasterxml.jackson.annotation.JsonRootName; import com.fasterxml.jackson.annotation.JsonRootName;
import java.io.Serializable;
import org.apache.log4j.Logger;
/** /**
*
* @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 logger = Logger.getLogger(Genre.class);
/* /*
* Properties * Properties
*/ */
@@ -53,9 +45,7 @@ public class Genre implements Serializable {
public String getName() { public String getName() {
return name; return name;
} }
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="Setter methods">
public void setId(int id) { public void setId(int id) {
this.id = id; this.id = id;
} }
@@ -63,21 +53,6 @@ public class Genre implements Serializable {
public void setName(String name) { public void setName(String name) {
this.name = name; this.name = name;
} }
//</editor-fold>
/**
* Handle unknown properties and print a message
*
* @param key
* @param value
*/
@JsonAnySetter
public void handleUnknown(String key, Object value) {
StringBuilder sb = new StringBuilder();
sb.append("Unknown property: '").append(key);
sb.append("' value: '").append(value).append("'");
logger.trace(sb.toString());
}
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
@@ -104,13 +79,4 @@ public class Genre implements Serializable {
hash = 53 * hash + (this.name != null ? this.name.hashCode() : 0); hash = 53 * hash + (this.name != null ? this.name.hashCode() : 0);
return hash; return hash;
} }
@Override
public String toString() {
StringBuilder sb = new StringBuilder("[Genre=");
sb.append("[id=").append(id);
sb.append("],[name=").append(name);
sb.append("]]");
return sb.toString();
}
} }
@@ -0,0 +1,52 @@
/*
* 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 {
private static final long serialVersionUID = 1L;
// Properties
@JsonProperty("department")
private String department;
@JsonProperty("job_list")
private List<String> jobs;
//<editor-fold defaultstate="collapsed" desc="Getters">
public String getDepartment() {
return department;
}
public List<String> getJobs() {
return jobs;
}
//<editor-fold defaultstate="collapsed" desc="Setters">
public void setDepartment(String department) {
this.department = department;
}
public void setJobs(List<String> jobs) {
this.jobs = jobs;
}
}
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2004-2012 Stuart Boston * Copyright (c) 2004-2013 Stuart Boston
* *
* This file is part of TheMovieDB API. * This file is part of TheMovieDB API.
* *
@@ -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 com.fasterxml.jackson.annotation.JsonRootName; import com.fasterxml.jackson.annotation.JsonRootName;
import java.io.Serializable;
import org.apache.log4j.Logger;
/** /**
*
* @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 logger = Logger.getLogger(Keyword.class);
/* /*
* Properties * Properties
*/ */
@@ -54,9 +46,7 @@ public class Keyword implements Serializable {
public String getName() { public String getName() {
return name; return name;
} }
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="Setter methods">
public void setId(int id) { public void setId(int id) {
this.id = id; this.id = id;
} }
@@ -64,21 +54,6 @@ public class Keyword implements Serializable {
public void setName(String name) { public void setName(String name) {
this.name = name; this.name = name;
} }
//</editor-fold>
/**
* Handle unknown properties and print a message
*
* @param key
* @param value
*/
@JsonAnySetter
public void handleUnknown(String key, Object value) {
StringBuilder sb = new StringBuilder();
sb.append("Unknown property: '").append(key);
sb.append("' value: '").append(value).append("'");
logger.trace(sb.toString());
}
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
@@ -105,13 +80,4 @@ public class Keyword implements Serializable {
hash = 83 * hash + (this.name != null ? this.name.hashCode() : 0); hash = 83 * hash + (this.name != null ? this.name.hashCode() : 0);
return hash; return hash;
} }
@Override
public String toString() {
StringBuilder sb = new StringBuilder("[Keyword=");
sb.append("[id=").append(id);
sb.append("],[name=").append(name);
sb.append("]]");
return sb.toString();
}
} }
@@ -0,0 +1,142 @@
/*
* 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 KeywordMovie extends AbstractJsonMapping {
private static final long serialVersionUID = 1L;
/*
* Properties
*/
@JsonProperty("id")
private String id;
@JsonProperty("backdrop_path")
private String backdropPath;
@JsonProperty("original_title")
private String originalTitle;
@JsonProperty("release_date")
private String releaseDate;
@JsonProperty("poster_path")
private String posterPath;
@JsonProperty("title")
private String title;
@JsonProperty("vote_average")
private float voteAverage;
@JsonProperty("vote_count")
private double voteCount;
@JsonProperty("adult")
private boolean adult;
@JsonProperty("popularity")
private float popularity;
// <editor-fold defaultstate="collapsed" desc="Getter methods">
public static long getSerialVersionUID() {
return serialVersionUID;
}
public String getBackdropPath() {
return backdropPath;
}
public String getId() {
return id;
}
public String getOriginalTitle() {
return originalTitle;
}
public String getReleaseDate() {
return releaseDate;
}
public String getPosterPath() {
return posterPath;
}
public String getTitle() {
return title;
}
public float getVoteAverage() {
return voteAverage;
}
public double getVoteCount() {
return voteCount;
}
public boolean isAdult() {
return adult;
}
public float getPopularity() {
return popularity;
}
// </editor-fold>
// <editor-fold defaultstate="collapsed" desc="Setter methods">
public void setBackdropPath(String backdropPath) {
this.backdropPath = backdropPath;
}
public void setId(String id) {
this.id = id;
}
public void setOriginalTitle(String originalTitle) {
this.originalTitle = originalTitle;
}
public void setReleaseDate(String releaseDate) {
this.releaseDate = releaseDate;
}
public void setPosterPath(String posterPath) {
this.posterPath = posterPath;
}
public void setTitle(String title) {
this.title = title;
}
public void setVoteAverage(float voteAverage) {
this.voteAverage = voteAverage;
}
public void setVoteCount(double voteCount) {
this.voteCount = voteCount;
}
public void setAdult(boolean adult) {
this.adult = adult;
}
public void setPopularity(float popularity) {
this.popularity = popularity;
}
// </editor-fold>
}
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2004-2012 Stuart Boston * Copyright (c) 2004-2013 Stuart Boston
* *
* This file is part of TheMovieDB API. * This file is part of TheMovieDB API.
* *
@@ -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 com.fasterxml.jackson.annotation.JsonRootName; import com.fasterxml.jackson.annotation.JsonRootName;
import java.io.Serializable;
import org.apache.log4j.Logger;
/** /**
*
* @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 logger = Logger.getLogger(Language.class);
/* /*
* Properties * Properties
*/ */
@@ -53,9 +45,7 @@ public class Language implements Serializable {
public String getName() { public String getName() {
return name; return name;
} }
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="Setter methods">
public void setIsoCode(String isoCode) { public void setIsoCode(String isoCode) {
this.isoCode = isoCode; this.isoCode = isoCode;
} }
@@ -63,21 +53,6 @@ public class Language implements Serializable {
public void setName(String name) { public void setName(String name) {
this.name = name; this.name = name;
} }
//</editor-fold>
/**
* Handle unknown properties and print a message
*
* @param key
* @param value
*/
@JsonAnySetter
public void handleUnknown(String key, Object value) {
StringBuilder sb = new StringBuilder();
sb.append("Unknown property: '").append(key);
sb.append("' value: '").append(value).append("'");
logger.trace(sb.toString());
}
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
@@ -104,13 +79,4 @@ public class Language implements Serializable {
hash = 71 * hash + (this.name != null ? this.name.hashCode() : 0); hash = 71 * hash + (this.name != null ? this.name.hashCode() : 0);
return hash; return hash;
} }
@Override
public String toString() {
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;
}
}
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2004-2012 Stuart Boston * Copyright (c) 2004-2013 Stuart Boston
* *
* This file is part of TheMovieDB API. * This file is part of TheMovieDB API.
* *
@@ -19,40 +19,35 @@
*/ */
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.apache.log4j.Logger;
/** /**
* 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 logger = Logger.getLogger(MovieDb.class);
/* /*
* Properties * Properties
*/ */
@JsonProperty(("backdrop_path")) @JsonProperty("backdrop_path")
private String backdropPath; private String backdropPath;
@JsonProperty(("id")) @JsonProperty("id")
private int id; private int id;
@JsonProperty(("original_title")) @JsonProperty("original_title")
private String originalTitle; private String originalTitle;
@JsonProperty(("popularity")) @JsonProperty("popularity")
private float popularity; private float popularity;
@JsonProperty(("poster_path")) @JsonProperty("poster_path")
private String posterPath; private String posterPath;
@JsonProperty(("release_date")) @JsonProperty("release_date")
private String releaseDate; private String releaseDate;
@JsonProperty(("title")) @JsonProperty("title")
private String title; private String title;
@JsonProperty("adult") @JsonProperty("adult")
private boolean adult; private boolean adult;
@@ -80,12 +75,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() {
@@ -179,6 +197,10 @@ public class MovieDb implements Serializable {
public String getStatus() { public String getStatus() {
return status; return status;
} }
public float getUserRating() {
return userRating;
}
// </editor-fold> // </editor-fold>
// <editor-fold defaultstate="collapsed" desc="Setter methods"> // <editor-fold defaultstate="collapsed" desc="Setter methods">
@@ -274,22 +296,99 @@ public class MovieDb implements Serializable {
this.status = status; this.status = status;
} }
public void setUserRating(float userRating) {
this.userRating = userRating;
}
// </editor-fold> // </editor-fold>
/** //<editor-fold defaultstate="collapsed" desc="AppendToResponse Getters">
* Handle unknown properties and print a message public List<AlternativeTitle> getAlternativeTitles() {
* return alternativeTitles.getTitles();
* @param key
* @param value
*/
@JsonAnySetter
public void handleUnknown(String key, Object value) {
StringBuilder sb = new StringBuilder();
sb.append("Unknown property: '").append(key);
sb.append("' value: '").append(value).append("'");
logger.trace(sb.toString());
} }
public 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
public boolean equals(Object obj) { public boolean equals(Object obj) {
@@ -320,35 +419,5 @@ public class MovieDb implements Serializable {
hash = 89 * hash + this.runtime; hash = 89 * hash + this.runtime;
return hash; return hash;
} }
//</editor-fold> // </editor-fold>
@Override
public String toString() {
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();
}
} }
@@ -0,0 +1,151 @@
/*
* 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.Collections;
import java.util.List;
/**
* Wrapper for the MovieDbList function
*
* @author stuart.boston
*/
public class MovieDbList extends AbstractJsonMapping {
/*
* Properties
*/
@JsonProperty("id")
private String id;
@JsonProperty("created_by")
private String createdBy;
@JsonProperty("description")
private String description;
@JsonProperty("favorite_count")
private int favoriteCount;
@JsonProperty("items")
private List<MovieDb> items = Collections.EMPTY_LIST;
@JsonProperty("item_count")
private int itemCount;
@JsonProperty("iso_639_1")
private String language;
@JsonProperty("name")
private String name;
@JsonProperty("poster_path")
private String posterPath;
@JsonProperty("status_code")
private String statusCode;
@JsonProperty("status_message")
private String statusMessage;
//<editor-fold defaultstate="collapsed" desc="Getter Methods">
public String getId() {
return id;
}
public String getCreatedBy() {
return createdBy;
}
public String getDescription() {
return description;
}
public int getFavoriteCount() {
return favoriteCount;
}
public List<MovieDb> getItems() {
return items;
}
public int getItemCount() {
return itemCount;
}
public String getLanguage() {
return language;
}
public String getName() {
return name;
}
public String getPosterPath() {
return posterPath;
}
public String getStatusCode() {
return statusCode;
}
public String getStatusMessage() {
return statusMessage;
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="Setter Methods">
public void setId(String id) {
this.id = id;
}
public void setCreatedBy(String createdBy) {
this.createdBy = createdBy;
}
public void setDescription(String description) {
this.description = description;
}
public void setFavoriteCount(int favoriteCount) {
this.favoriteCount = favoriteCount;
}
public void setItems(List<MovieDb> items) {
this.items = items;
}
public void setItemCount(int itemCount) {
this.itemCount = itemCount;
}
public void setLanguage(String language) {
this.language = language;
}
public void setName(String name) {
this.name = name;
}
public void setPosterPath(String posterPath) {
this.posterPath = posterPath;
}
public void setStatusCode(String statusCode) {
this.statusCode = statusCode;
}
public void setStatusMessage(String statusMessage) {
this.statusMessage = statusMessage;
}
//</editor-fold>
}
@@ -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;
}
}
@@ -0,0 +1,118 @@
/*
* Copyright (c) 2004-2013 Stuart Boston
*
* This file is part of TheMovieDB API.
*
* TheMovieDB API is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* TheMovieDB API is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>.
*
*/
package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
* @author Stuart
*/
public class MovieList extends AbstractJsonMapping {
private static final long serialVersionUID = 1L;
/*
* Properties
*/
@JsonProperty("description")
private String description;
@JsonProperty("favorite_count")
private int favoriteCount;
@JsonProperty("id")
private String id;
@JsonProperty("item_count")
private int itemCount;
@JsonProperty("iso_639_1")
private String language;
@JsonProperty("name")
private String name;
@JsonProperty("poster_path")
private String posterPath;
@JsonProperty("list_type")
private String listType;
// <editor-fold defaultstate="collapsed" desc="Getter methods">
public String getDescription() {
return description;
}
public int getFavoriteCount() {
return favoriteCount;
}
public String getId() {
return id;
}
public int getItemCount() {
return itemCount;
}
public String getLanguage() {
return language;
}
public String getName() {
return name;
}
public String getPosterPath() {
return posterPath;
}
public String getListType() {
return listType;
}
// </editor-fold>
// <editor-fold defaultstate="collapsed" desc="Setter methods">
public void setDescription(String description) {
this.description = description;
}
public void setFavoriteCount(int favoriteCount) {
this.favoriteCount = favoriteCount;
}
public void setId(String id) {
this.id = id;
}
public void setItemCount(int itemCount) {
this.itemCount = itemCount;
}
public void setLanguage(String language) {
this.language = language;
}
public void setName(String name) {
this.name = name;
}
public void setPosterPath(String posterPath) {
this.posterPath = posterPath;
}
public void setListType(String listType) {
this.listType = listType;
}
// </editor-fold>
}
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2004-2012 Stuart Boston * Copyright (c) 2004-2013 Stuart Boston
* *
* This file is part of TheMovieDB API. * This file is part of TheMovieDB API.
* *
@@ -19,26 +19,19 @@
*/ */
package com.omertron.themoviedbapi.model; package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import java.io.Serializable; import org.apache.commons.lang3.StringUtils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.apache.log4j.Logger;
/** /**
*
* @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 logger = Logger.getLogger(Person.class);
/* /*
* Static fields for default cast information * Static fields for default cast information
*/ */
@@ -73,6 +66,10 @@ public class Person implements Serializable {
private String homepage = DEFAULT_STRING; private String homepage = DEFAULT_STRING;
@JsonProperty("place_of_birth") @JsonProperty("place_of_birth")
private String birthplace = DEFAULT_STRING; private String birthplace = DEFAULT_STRING;
@JsonProperty("imdb_id")
private String imdbId = DEFAULT_STRING;
@JsonProperty("popularity")
private float popularity = 0.0f;
/** /**
* Add a crew member * Add a crew member
@@ -84,14 +81,14 @@ public class Person implements Serializable {
* @param job * @param job
*/ */
public void addCrew(int id, String name, String profilePath, String department, String job) { public void addCrew(int id, String name, String profilePath, String department, String job) {
this.personType = PersonType.CREW; setPersonType(PersonType.CREW);
this.id = id; setId(id);
this.name = name; setName(name);
this.profilePath = profilePath; setProfilePath(profilePath);
this.department = department; setDepartment(department);
this.job = job; setJob(job);
this.character = ""; setCharacter("");
this.order = -1; setOrder(-1);
} }
/** /**
@@ -104,14 +101,14 @@ public class Person implements Serializable {
* @param order * @param order
*/ */
public void addCast(int id, String name, String profilePath, String character, int order) { public void addCast(int id, String name, String profilePath, String character, int order) {
this.personType = PersonType.CAST; setPersonType(PersonType.CAST);
this.id = id; setId(id);
this.name = name; setName(name);
this.profilePath = profilePath; setProfilePath(profilePath);
this.character = character; setCharacter(character);
this.order = order; setOrder(order);
this.department = CAST_DEPARTMENT; setDepartment(CAST_DEPARTMENT);
this.job = CAST_JOB; setJob(CAST_JOB);
} }
// <editor-fold defaultstate="collapsed" desc="Getter methods"> // <editor-fold defaultstate="collapsed" desc="Getter methods">
@@ -174,6 +171,14 @@ public class Person implements Serializable {
public String getHomepage() { public String getHomepage() {
return homepage; return homepage;
} }
public String getImdbId() {
return imdbId;
}
public float getPopularity() {
return popularity;
}
// </editor-fold> // </editor-fold>
// <editor-fold defaultstate="collapsed" desc="Setter methods"> // <editor-fold defaultstate="collapsed" desc="Setter methods">
@@ -190,11 +195,11 @@ public class Person implements Serializable {
} }
public void setJob(String job) { public void setJob(String job) {
this.job = job; this.job = StringUtils.trimToEmpty(job);
} }
public void setName(String name) { public void setName(String name) {
this.name = name; this.name = StringUtils.trimToEmpty(name);
} }
public void setOrder(int order) { public void setOrder(int order) {
@@ -206,7 +211,7 @@ public class Person implements Serializable {
} }
public void setProfilePath(String profilePath) { public void setProfilePath(String profilePath) {
this.profilePath = profilePath; this.profilePath = StringUtils.trimToEmpty(profilePath);
} }
public void setAdult(boolean adult) { public void setAdult(boolean adult) {
@@ -218,40 +223,34 @@ 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) {
this.imdbId = StringUtils.trimToEmpty(imdbId);
}
public void setPopularity(float popularity) {
this.popularity = popularity;
} }
// </editor-fold> // </editor-fold>
/**
* Handle unknown properties and print a message
*
* @param key
* @param value
*/
@JsonAnySetter
public void handleUnknown(String key, Object value) {
StringBuilder sb = new StringBuilder();
sb.append("Unknown property: '").append(key);
sb.append("' value: '").append(value).append("'");
logger.trace(sb.toString());
}
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (obj == null) { if (obj == null) {
@@ -297,26 +296,4 @@ public class Person implements Serializable {
hash = 37 * hash + (this.character != null ? this.character.hashCode() : 0); hash = 37 * hash + (this.character != null ? this.character.hashCode() : 0);
return hash; return hash;
} }
@Override
public String toString() {
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();
}
} }
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2004-2012 Stuart Boston * Copyright (c) 2004-2013 Stuart Boston
* *
* This file is part of TheMovieDB API. * This file is part of TheMovieDB API.
* *
@@ -19,23 +19,16 @@
*/ */
package com.omertron.themoviedbapi.model; package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import java.io.Serializable; import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
/** /**
*
* @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 logger = Logger.getLogger(PersonCast.class);
/* /*
* Properties * Properties
*/ */
@@ -77,11 +70,8 @@ public class PersonCast implements Serializable {
return castId; return castId;
} }
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="Setter methods">
public void setCharacter(String character) { public void setCharacter(String character) {
this.character = character; this.character = StringUtils.trimToEmpty(character);
} }
public void setId(int id) { public void setId(int id) {
@@ -89,7 +79,7 @@ public class PersonCast implements Serializable {
} }
public void setName(String name) { public void setName(String name) {
this.name = name; this.name = StringUtils.trimToEmpty(name);
} }
public void setOrder(int order) { public void setOrder(int order) {
@@ -97,29 +87,13 @@ public class PersonCast implements Serializable {
} }
public void setProfilePath(String profilePath) { public void setProfilePath(String profilePath) {
this.profilePath = profilePath; this.profilePath = StringUtils.trimToEmpty(profilePath);
} }
public void setCastId(int castId) { public void setCastId(int castId) {
this.castId = castId; this.castId = castId;
} }
//</editor-fold>
/**
* Handle unknown properties and print a message
*
* @param key
* @param value
*/
@JsonAnySetter
public void handleUnknown(String key, Object value) {
StringBuilder sb = new StringBuilder();
sb.append("Unknown property: '").append(key);
sb.append("' value: '").append(value).append("'");
logger.trace(sb.toString());
}
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
if (obj == null) { if (obj == null) {
@@ -157,16 +131,4 @@ public class PersonCast implements Serializable {
hash = 41 * hash + (this.profilePath != null ? this.profilePath.hashCode() : 0); hash = 41 * hash + (this.profilePath != null ? this.profilePath.hashCode() : 0);
return hash; return hash;
} }
@Override
public String toString() {
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();
}
} }
@@ -1,177 +1,135 @@
/* /*
* Copyright (c) 2004-2012 Stuart Boston * Copyright (c) 2004-2013 Stuart Boston
* *
* This file is part of TheMovieDB API. * This file is part of TheMovieDB API.
* *
* TheMovieDB API is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* any later version. * any later version.
* *
* TheMovieDB API is distributed in the hope that it will be useful, * TheMovieDB API is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* 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.model;
import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonProperty; import org.apache.commons.lang3.StringUtils;
import java.io.Serializable;
import org.apache.log4j.Logger; /**
* @author stuart.boston
/** */
* public class PersonCredit extends AbstractJsonMapping {
* @author stuart.boston
*/ private static final long serialVersionUID = 1L;
public class PersonCredit implements Serializable { private static final String DEFAULT_STRING = "";
/*
private static final long serialVersionUID = 1L; * Properties
*/
/* @JsonProperty("id")
* Logger private int movieId = 0;
*/ @JsonProperty("character")
private static final Logger logger = Logger.getLogger(PersonCredit.class); private String character = DEFAULT_STRING;
private static final String DEFAULT_STRING = ""; @JsonProperty("original_title")
/* private String movieOriginalTitle = DEFAULT_STRING;
* Properties @JsonProperty("poster_path")
*/ private String posterPath = DEFAULT_STRING;
@JsonProperty("id") @JsonProperty("release_date")
private int movieId = 0; private String releaseDate = DEFAULT_STRING;
@JsonProperty("character") @JsonProperty("title")
private String character = DEFAULT_STRING; private String movieTitle = DEFAULT_STRING;
@JsonProperty("original_title") @JsonProperty("department")
private String movieOriginalTitle = DEFAULT_STRING; private String department = DEFAULT_STRING;
@JsonProperty("poster_path") @JsonProperty("job")
private String posterPath = DEFAULT_STRING; private String job = DEFAULT_STRING;
@JsonProperty("release_date") @JsonProperty("adult")
private String releaseDate = DEFAULT_STRING; private String adult = DEFAULT_STRING;
@JsonProperty("title") private PersonType personType = PersonType.PERSON;
private String movieTitle = DEFAULT_STRING;
@JsonProperty("department") //<editor-fold defaultstate="collapsed" desc="Getter Methods">
private String department = DEFAULT_STRING; public String getCharacter() {
@JsonProperty("job") return character;
private String job = DEFAULT_STRING; }
@JsonProperty("adult")
private String adult = DEFAULT_STRING; public String getDepartment() {
private PersonType personType = PersonType.PERSON; return department;
}
//<editor-fold defaultstate="collapsed" desc="Getter Methods">
public String getCharacter() { public String getJob() {
return character; return job;
} }
public String getDepartment() { public int getMovieId() {
return department; return movieId;
} }
public String getJob() { public String getMovieOriginalTitle() {
return job; return movieOriginalTitle;
} }
public int getMovieId() { public String getMovieTitle() {
return movieId; return movieTitle;
} }
public String getMovieOriginalTitle() { public PersonType getPersonType() {
return movieOriginalTitle; return personType;
} }
public String getMovieTitle() { public String getPosterPath() {
return movieTitle; return posterPath;
} }
public PersonType getPersonType() { public String getReleaseDate() {
return personType; return releaseDate;
} }
public String getPosterPath() { public String getAdult() {
return posterPath; return adult;
} }
public String getReleaseDate() { public void setCharacter(String character) {
return releaseDate; this.character = StringUtils.trimToEmpty(character);
} }
public String getAdult() { public void setDepartment(String department) {
return adult; this.department = StringUtils.trimToEmpty(department);
} }
//</editor-fold>
public void setJob(String job) {
//<editor-fold defaultstate="collapsed" desc="Setter Methods"> this.job = StringUtils.trimToEmpty(job);
public void setCharacter(String character) { }
this.character = character;
} public void setMovieId(int movieId) {
this.movieId = movieId;
public void setDepartment(String department) { }
this.department = department;
} public void setMovieOriginalTitle(String movieOriginalTitle) {
this.movieOriginalTitle = StringUtils.trimToEmpty(movieOriginalTitle);
public void setJob(String job) { }
this.job = job;
} public void setMovieTitle(String movieTitle) {
this.movieTitle = StringUtils.trimToEmpty(movieTitle);
public void setMovieId(int movieId) { }
this.movieId = movieId;
} public void setPersonType(PersonType personType) {
this.personType = personType;
public void setMovieOriginalTitle(String movieOriginalTitle) { }
this.movieOriginalTitle = movieOriginalTitle;
} public void setPosterPath(String posterPath) {
this.posterPath = StringUtils.trimToEmpty(posterPath);
public void setMovieTitle(String movieTitle) { }
this.movieTitle = movieTitle;
} public void setReleaseDate(String releaseDate) {
this.releaseDate = StringUtils.trimToEmpty(releaseDate);
public void setPersonType(PersonType personType) { }
this.personType = personType;
} public void setAdult(String adult) {
this.adult = StringUtils.trimToEmpty(adult);
public void setPosterPath(String posterPath) { }
this.posterPath = posterPath; }
}
public void setReleaseDate(String releaseDate) {
this.releaseDate = releaseDate;
}
public void setAdult(String adult) {
this.adult = 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("'");
logger.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();
}
}
@@ -1,157 +1,121 @@
/* /*
* Copyright (c) 2004-2012 Stuart Boston * Copyright (c) 2004-2013 Stuart Boston
* *
* This file is part of TheMovieDB API. * This file is part of TheMovieDB API.
* *
* TheMovieDB API is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* any later version. * any later version.
* *
* TheMovieDB API is distributed in the hope that it will be useful, * TheMovieDB API is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* 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.model;
import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonProperty; import org.apache.commons.lang3.StringUtils;
import java.io.Serializable;
import org.apache.log4j.Logger; /**
* @author Stuart
/** */
* public class PersonCrew extends AbstractJsonMapping {
* @author Stuart
*/ private static final long serialVersionUID = 1L;
public class PersonCrew implements Serializable {
/*
private static final long serialVersionUID = 1L; * Properties
*/
/* @JsonProperty("id")
* Logger private int id;
*/ @JsonProperty("department")
private static final Logger logger = Logger.getLogger(PersonCrew.class); private String department;
/* @JsonProperty("job")
* Properties private String job;
*/ @JsonProperty("name")
@JsonProperty("id") private String name;
private int id; @JsonProperty("profile_path")
@JsonProperty("department") private String profilePath;
private String department;
@JsonProperty("job") //<editor-fold defaultstate="collapsed" desc="Getter methods">
private String job; public String getDepartment() {
@JsonProperty("name") return department;
private String name; }
@JsonProperty("profile_path")
private String profilePath; public int getId() {
return id;
//<editor-fold defaultstate="collapsed" desc="Getter methods"> }
public String getDepartment() {
return department; public String getJob() {
} return job;
}
public int getId() {
return id; public String getName() {
} return name;
}
public String getJob() {
return job; public String getProfilePath() {
} return profilePath;
}
public String getName() {
return name; public void setDepartment(String department) {
} this.department = StringUtils.trimToEmpty(department);
}
public String getProfilePath() {
return profilePath; public void setId(int id) {
} this.id = id;
//</editor-fold> }
//<editor-fold defaultstate="collapsed" desc="Setter methods"> public void setJob(String job) {
public void setDepartment(String department) { this.job = StringUtils.trimToEmpty(job);
this.department = department; }
}
public void setName(String name) {
public void setId(int id) { this.name = StringUtils.trimToEmpty(name);
this.id = id; }
}
public void setProfilePath(String profilePath) {
public void setJob(String job) { this.profilePath = StringUtils.trimToEmpty(profilePath);
this.job = job; }
}
@Override
public void setName(String name) { public boolean equals(Object obj) {
this.name = name; if (obj == null) {
} return false;
}
public void setProfilePath(String profilePath) { if (getClass() != obj.getClass()) {
this.profilePath = profilePath; return false;
} }
//</editor-fold> final PersonCrew other = (PersonCrew) obj;
if (this.id != other.id) {
/** return false;
* Handle unknown properties and print a message }
* if ((this.department == null) ? (other.department != null) : !this.department.equals(other.department)) {
* @param key return false;
* @param value }
*/ if ((this.job == null) ? (other.job != null) : !this.job.equals(other.job)) {
@JsonAnySetter return false;
public void handleUnknown(String key, Object value) { }
StringBuilder sb = new StringBuilder(); if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) {
sb.append("Unknown property: '").append(key); return false;
sb.append("' value: '").append(value).append("'"); }
logger.trace(sb.toString()); return true;
} }
@Override @Override
public boolean equals(Object obj) { public int hashCode() {
if (obj == null) { int hash = 7;
return false; hash = 59 * hash + this.id;
} hash = 59 * hash + (this.department != null ? this.department.hashCode() : 0);
if (getClass() != obj.getClass()) { hash = 59 * hash + (this.job != null ? this.job.hashCode() : 0);
return false; hash = 59 * hash + (this.name != null ? this.name.hashCode() : 0);
} hash = 59 * hash + (this.profilePath != null ? this.profilePath.hashCode() : 0);
final PersonCrew other = (PersonCrew) obj; return hash;
if (this.id != other.id) { }
return false; }
}
if ((this.department == null) ? (other.department != null) : !this.department.equals(other.department)) {
return false;
}
if ((this.job == null) ? (other.job != null) : !this.job.equals(other.job)) {
return false;
}
if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) {
return false;
}
return true;
}
@Override
public int hashCode() {
int hash = 7;
hash = 59 * hash + this.id;
hash = 59 * hash + (this.department != null ? this.department.hashCode() : 0);
hash = 59 * hash + (this.job != null ? this.job.hashCode() : 0);
hash = 59 * hash + (this.name != null ? this.name.hashCode() : 0);
hash = 59 * hash + (this.profilePath != null ? this.profilePath.hashCode() : 0);
return hash;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder("[PersonCrew=");
sb.append("id=").append(id);
sb.append("],[department=").append(department);
sb.append("],[job=").append(job);
sb.append("],[name=").append(name);
sb.append("],[profilePath=").append(profilePath);
sb.append("]]");
return sb.toString();
}
}
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2004-2012 Stuart Boston * Copyright (c) 2004-2013 Stuart Boston
* *
* This file is part of TheMovieDB API. * This file is part of TheMovieDB API.
* *
@@ -20,12 +20,11 @@
package com.omertron.themoviedbapi.model; package com.omertron.themoviedbapi.model;
/** /**
*
* @author stuart.boston * @author stuart.boston
*/ */
public enum PersonType { public enum PersonType {
CAST, // A member of the cast CAST, // A member of the cast
CREW, // A member of the crew CREW, // A member of the crew
PERSON // No specific type PERSON // No specific type
} }
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2004-2012 Stuart Boston * Copyright (c) 2004-2013 Stuart Boston
* *
* This file is part of TheMovieDB API. * This file is part of TheMovieDB API.
* *
@@ -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 com.fasterxml.jackson.annotation.JsonRootName; import com.fasterxml.jackson.annotation.JsonRootName;
import java.io.Serializable;
import org.apache.log4j.Logger;
/** /**
*
* @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 logger = Logger.getLogger(ProductionCompany.class);
/* /*
* Properties * Properties
*/ */
@@ -54,9 +46,7 @@ public class ProductionCompany implements Serializable {
public String getName() { public String getName() {
return name; return name;
} }
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="Setter methods">
public void setId(int id) { public void setId(int id) {
this.id = id; this.id = id;
} }
@@ -64,21 +54,6 @@ public class ProductionCompany implements Serializable {
public void setName(String name) { public void setName(String name) {
this.name = name; this.name = name;
} }
//</editor-fold>
/**
* Handle unknown properties and print a message
*
* @param key
* @param value
*/
@JsonAnySetter
public void handleUnknown(String key, Object value) {
StringBuilder sb = new StringBuilder();
sb.append("Unknown property: '").append(key);
sb.append("' value: '").append(value).append("'");
logger.trace(sb.toString());
}
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
@@ -105,13 +80,4 @@ public class ProductionCompany implements Serializable {
hash = 37 * hash + (this.name != null ? this.name.hashCode() : 0); hash = 37 * hash + (this.name != null ? this.name.hashCode() : 0);
return hash; return hash;
} }
@Override
public String toString() {
StringBuilder sb = new StringBuilder("[ProductionCompany=");
sb.append("[id=").append(id);
sb.append("],[name=").append(name);
sb.append("]]");
return sb.toString();
}
} }
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2004-2012 Stuart Boston * Copyright (c) 2004-2013 Stuart Boston
* *
* This file is part of TheMovieDB API. * This file is part of TheMovieDB API.
* *
@@ -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 com.fasterxml.jackson.annotation.JsonRootName; import com.fasterxml.jackson.annotation.JsonRootName;
import java.io.Serializable;
import org.apache.log4j.Logger;
/** /**
*
* @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 logger = Logger.getLogger(ProductionCountry.class);
/* /*
* Properties * Properties
*/ */
@@ -54,9 +46,7 @@ public class ProductionCountry implements Serializable {
public String getName() { public String getName() {
return name; return name;
} }
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="Setter methods">
public void setIsoCode(String isoCode) { public void setIsoCode(String isoCode) {
this.isoCode = isoCode; this.isoCode = isoCode;
} }
@@ -64,21 +54,6 @@ public class ProductionCountry implements Serializable {
public void setName(String name) { public void setName(String name) {
this.name = name; this.name = name;
} }
//</editor-fold>
/**
* Handle unknown properties and print a message
*
* @param key
* @param value
*/
@JsonAnySetter
public void handleUnknown(String key, Object value) {
StringBuilder sb = new StringBuilder();
sb.append("Unknown property: '").append(key);
sb.append("' value: '").append(value).append("'");
logger.trace(sb.toString());
}
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
@@ -105,13 +80,4 @@ public class ProductionCountry implements Serializable {
hash = 47 * hash + (this.name != null ? this.name.hashCode() : 0); hash = 47 * hash + (this.name != null ? this.name.hashCode() : 0);
return hash; return hash;
} }
@Override
public String toString() {
StringBuilder sb = new StringBuilder("[ProductionCountry=");
sb.append("[isoCode=").append(isoCode);
sb.append("],[name=").append(name);
sb.append("]]");
return sb.toString();
}
} }
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2004-2012 Stuart Boston * Copyright (c) 2004-2013 Stuart Boston
* *
* This file is part of TheMovieDB API. * This file is part of TheMovieDB API.
* *
@@ -19,23 +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.log4j.Logger;
/** /**
*
* @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 logger = Logger.getLogger(ReleaseInfo.class);
/* /*
* Properties * Properties
*/ */
@@ -58,9 +50,7 @@ public class ReleaseInfo implements Serializable {
public String getReleaseDate() { public String getReleaseDate() {
return releaseDate; return releaseDate;
} }
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="Setter methods">
public void setCertification(String certification) { public void setCertification(String certification) {
this.certification = certification; this.certification = certification;
} }
@@ -72,21 +62,6 @@ public class ReleaseInfo implements Serializable {
public void setReleaseDate(String releaseDate) { public void setReleaseDate(String releaseDate) {
this.releaseDate = releaseDate; this.releaseDate = releaseDate;
} }
//</editor-fold>
/**
* Handle unknown properties and print a message
*
* @param key
* @param value
*/
@JsonAnySetter
public void handleUnknown(String key, Object value) {
StringBuilder sb = new StringBuilder();
sb.append("Unknown property: '").append(key);
sb.append("' value: '").append(value).append("'");
logger.trace(sb.toString());
}
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
@@ -117,14 +92,4 @@ public class ReleaseInfo implements Serializable {
hash = 89 * hash + (this.releaseDate != null ? this.releaseDate.hashCode() : 0); hash = 89 * hash + (this.releaseDate != null ? this.releaseDate.hashCode() : 0);
return hash; return hash;
} }
@Override
public String toString() {
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,78 @@
/*
* 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;
// <editor-fold defaultstate="collapsed" desc="Getter methods">
public String getId() {
return id;
}
public String getAuthor() {
return author;
}
public String getContent() {
return content;
}
public String getUrl() {
return url;
}
// </editor-fold>
// <editor-fold defaultstate="collapsed" desc="Setter methods">
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;
}
// </editor-fold>
}
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2004-2012 Stuart Boston * Copyright (c) 2004-2013 Stuart Boston
* *
* This file is part of TheMovieDB API. * This file is part of TheMovieDB API.
* *
@@ -19,23 +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.log4j.Logger;
/** /**
*
* @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 logger = Logger.getLogger(StatusCode.class);
/* /*
* Properties * Properties
*/ */
@@ -52,9 +44,7 @@ public class StatusCode implements Serializable {
public void setStatusCode(int statusCode) { public void setStatusCode(int statusCode) {
this.statusCode = statusCode; this.statusCode = statusCode;
} }
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="Setter methods">
public String getStatusMessage() { public String getStatusMessage() {
return statusMessage; return statusMessage;
} }
@@ -62,27 +52,4 @@ public class StatusCode implements Serializable {
public void setStatusMessage(String statusMessage) { public void setStatusMessage(String statusMessage) {
this.statusMessage = statusMessage; this.statusMessage = statusMessage;
} }
//</editor-fold>
/**
* Handle unknown properties and print a message
*
* @param key
* @param value
*/
@JsonAnySetter
public void handleUnknown(String key, Object value) {
StringBuilder sb = new StringBuilder();
sb.append("Unknown property: '").append(key);
sb.append("' value: '").append(value).append("'");
logger.trace(sb.toString());
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder();
sb.append("Status Code: ").append(statusCode);
sb.append(", Message: ").append(statusMessage);
return sb.toString();
}
} }
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2004-2012 Stuart Boston * Copyright (c) 2004-2013 Stuart Boston
* *
* This file is part of TheMovieDB API. * This file is part of TheMovieDB API.
* *
@@ -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.util.List;
import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.StringUtils;
import org.apache.log4j.Logger;
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 logger = Logger.getLogger(TmdbConfiguration.class);
/* /*
* Properties * Properties
*/ */
@@ -122,7 +115,6 @@ 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,7 +127,6 @@ 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()) {
@@ -148,7 +139,6 @@ 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()) {
@@ -161,7 +151,6 @@ 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()) {
@@ -174,7 +163,6 @@ 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)
@@ -182,30 +170,4 @@ public class TmdbConfiguration implements Serializable {
|| isValidProfileSize(sizeToCheck) || isValidProfileSize(sizeToCheck)
|| isValidLogoSize(sizeToCheck)); || isValidLogoSize(sizeToCheck));
} }
/**
* Handle unknown properties and print a message
*
* @param key
* @param value
*/
@JsonAnySetter
public void handleUnknown(String key, Object value) {
StringBuilder sb = new StringBuilder();
sb.append("Unknown property: '").append(key);
sb.append("' value: '").append(value).append("'");
logger.trace(sb.toString());
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder("[ImageConfiguration=");
sb.append("[baseUrl=").append(baseUrl);
sb.append("],[posterSizes=").append(posterSizes.toString());
sb.append("],[backdropSizes=").append(backdropSizes.toString());
sb.append("],[profileSizes=").append(profileSizes.toString());
sb.append("],[logoSizes=").append(logoSizes.toString());
sb.append(("]]"));
return sb.toString();
}
} }
@@ -1,88 +1,70 @@
/* /*
* Copyright (c) 2004-2012 Stuart Boston * Copyright (c) 2004-2013 Stuart Boston
* *
* This file is part of TheMovieDB API. * This file is part of TheMovieDB API.
* *
* TheMovieDB API is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* any later version. * any later version.
* *
* TheMovieDB API is distributed in the hope that it will be useful, * TheMovieDB API is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* 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.model;
import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonProperty; import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.log4j.Logger; import org.apache.commons.lang3.builder.ToStringStyle;
public class TokenAuthorisation { public class TokenAuthorisation {
/*
* Logger /*
*/ * Properties
private static final Logger logger = Logger.getLogger(TokenAuthorisation.class); */
/* @JsonProperty("expires_at")
* Properties private String expires;
*/ @JsonProperty("request_token")
@JsonProperty("expires_at") private String requestToken;
private String expires; @JsonProperty("success")
@JsonProperty("request_token") private Boolean success;
private String requestToken;
@JsonProperty("success") // <editor-fold defaultstate="collapsed" desc="Getter methods">
private Boolean success; public String getExpires() {
return expires;
// <editor-fold defaultstate="collapsed" desc="Getter methods"> }
public String getExpires() {
return expires; public String getRequestToken() {
} return requestToken;
}
public String getRequestToken() {
return requestToken; public Boolean getSuccess() {
} return success;
}
public Boolean getSuccess() { // </editor-fold>
return success;
} // <editor-fold defaultstate="collapsed" desc="Setter methods">
// </editor-fold> public void setExpires(String expires) {
this.expires = expires;
// <editor-fold defaultstate="collapsed" desc="Setter methods"> }
public void setExpires(String expires) {
this.expires = expires; public void setRequestToken(String requestToken) {
} this.requestToken = requestToken;
}
public void setRequestToken(String requestToken) {
this.requestToken = requestToken; public void setSuccess(Boolean success) {
} this.success = success;
}
public void setSuccess(Boolean success) { // </editor-fold>
this.success = success;
} @Override
// </editor-fold> public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
/** }
* Handle unknown properties and print a message }
*
* @param key
* @param value
*/
@JsonAnySetter
public void handleUnknown(String key, Object value) {
StringBuilder sb = new StringBuilder();
sb.append("Unknown property: '").append(key);
sb.append("' value: '").append(value).append("'");
logger.trace(sb.toString());
}
@Override
public String toString() {
return "TokenAuthorisation{" + "expires=" + expires + ", requestToken=" + requestToken + ", success=" + success + '}';
}
}
@@ -1,98 +1,100 @@
/* /*
* Copyright (c) 2004-2012 Stuart Boston * Copyright (c) 2004-2013 Stuart Boston
* *
* This file is part of TheMovieDB API. * This file is part of TheMovieDB API.
* *
* TheMovieDB API is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* any later version. * any later version.
* *
* TheMovieDB API is distributed in the hope that it will be useful, * TheMovieDB API is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* 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.model;
import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonProperty; import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.log4j.Logger; import org.apache.commons.lang3.builder.ToStringStyle;
public class TokenSession { public class TokenSession {
/*
* Logger /*
*/ * Properties
private static final Logger logger = Logger.getLogger(TokenSession.class); */
/* @JsonProperty("session_id")
* Properties private String sessionId;
*/ @JsonProperty("success")
@JsonProperty("session_id") private Boolean success;
private String sessionId; @JsonProperty("status_code")
@JsonProperty("success") private String statusCode;
private Boolean success; @JsonProperty("status_message")
@JsonProperty("status_code") private String statusMessage;
private String statusCode; @JsonProperty("guest_session_id")
@JsonProperty("status_message") private String guestSessionId;
private String statusMessage; @JsonProperty("expires_at")
private String expiresAt;
// <editor-fold defaultstate="collapsed" desc="Getter methods">
public String getSessionId() { // <editor-fold defaultstate="collapsed" desc="Getter methods">
return sessionId; public String getSessionId() {
} return sessionId;
}
public Boolean getSuccess() {
return success; public Boolean getSuccess() {
} return success;
}
public String getStatusCode() {
return statusCode; public String getStatusCode() {
} return statusCode;
}
public String getStatusMessage() {
return statusMessage; public String getStatusMessage() {
} return statusMessage;
// </editor-fold> }
// <editor-fold defaultstate="collapsed" desc="Setter methods"> public String getGuestSessionId() {
public void setSessionId(String sessionId) { return guestSessionId;
this.sessionId = sessionId; }
}
public String getExpiresAt() {
public void setSuccess(Boolean success) { return expiresAt;
this.success = success; }
} // </editor-fold>
public void setStatusCode(String statusCode) { // <editor-fold defaultstate="collapsed" desc="Setter methods">
this.statusCode = statusCode; public void setSessionId(String sessionId) {
} this.sessionId = sessionId;
}
public void setStatusMessage(String statusMessage) {
this.statusMessage = statusMessage; public void setSuccess(Boolean success) {
} this.success = success;
// </editor-fold> }
/** public void setStatusCode(String statusCode) {
* Handle unknown properties and print a message this.statusCode = statusCode;
* }
* @param key
* @param value public void setStatusMessage(String statusMessage) {
*/ this.statusMessage = statusMessage;
@JsonAnySetter }
public void handleUnknown(String key, Object value) {
StringBuilder sb = new StringBuilder(); public void setGuestSessionId(String guestSessionId) {
sb.append("Unknown property: '").append(key); this.guestSessionId = guestSessionId;
sb.append("' value: '").append(value).append("'"); }
logger.trace(sb.toString());
} public void setExpiresAt(String expiresAt) {
this.expiresAt = expiresAt;
@Override }
public String toString() { // </editor-fold>
return "TokenSession{" + "sessionId=" + sessionId + ", success=" + success + ", statusCode=" + statusCode + ", statusMessage=" + statusMessage + '}';
} @Override
public String toString() {
} return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
}
}
@@ -1,142 +1,105 @@
/* /*
* Copyright (c) 2004-2012 Stuart Boston * Copyright (c) 2004-2013 Stuart Boston
* *
* This file is part of TheMovieDB API. * This file is part of TheMovieDB API.
* *
* TheMovieDB API is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* any later version. * any later version.
* *
* TheMovieDB API is distributed in the hope that it will be useful, * TheMovieDB API is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* 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.model;
import com.fasterxml.jackson.annotation.JsonAnySetter; /**
import java.io.Serializable; * @author Stuart
import org.apache.log4j.Logger; */
public class Trailer extends AbstractJsonMapping {
/**
* private static final long serialVersionUID = 1L;
* @author Stuart
*/ /*
public class Trailer implements Serializable { * Website sources
*/
private static final long serialVersionUID = 1L; public static final String WEBSITE_YOUTUBE = "youtube";
public static final String WEBSITE_QUICKTIME = "quicktime";
/* /*
* Logger * Properties
*/ */
private static final Logger logger = Logger.getLogger(Trailer.class); private String name;
/* private String size;
* Website sources private String source;
*/ private String website; // The website of the trailer
public static final String WEBSITE_YOUTUBE = "youtube";
public static final String WEBSITE_QUICKTIME = "quicktime"; //<editor-fold defaultstate="collapsed" desc="Getter methods">
/* public String getName() {
* Properties return name;
*/ }
private String name;
private String size; public String getSize() {
private String source; return size;
private String website; // The website of the trailer }
//<editor-fold defaultstate="collapsed" desc="Getter methods"> public String getSource() {
public String getName() { return source;
return name; }
}
public String getWebsite() {
public String getSize() { return website;
return size; }
}
public void setName(String name) {
public String getSource() { this.name = name;
return source; }
}
public void setSize(String size) {
public String getWebsite() { this.size = size;
return website; }
}
//</editor-fold> public void setSource(String source) {
this.source = source;
//<editor-fold defaultstate="collapsed" desc="Setter methods"> }
public void setName(String name) {
this.name = name; public void setWebsite(String website) {
} this.website = website;
}
public void setSize(String size) {
this.size = size; @Override
} public boolean equals(Object obj) {
if (obj == null) {
public void setSource(String source) { return false;
this.source = source; }
} if (getClass() != obj.getClass()) {
return false;
public void setWebsite(String website) { }
this.website = website; final Trailer other = (Trailer) obj;
} if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) {
//</editor-fold> return false;
}
/** if ((this.size == null) ? (other.size != null) : !this.size.equals(other.size)) {
* Handle unknown properties and print a message return false;
* }
* @param key if ((this.source == null) ? (other.source != null) : !this.source.equals(other.source)) {
* @param value return false;
*/ }
@JsonAnySetter return true;
public void handleUnknown(String key, Object value) { }
StringBuilder sb = new StringBuilder();
sb.append("Unknown property: '").append(key); @Override
sb.append("' value: '").append(value).append("'"); public int hashCode() {
logger.trace(sb.toString()); int hash = 7;
} hash = 61 * hash + (this.name != null ? this.name.hashCode() : 0);
hash = 61 * hash + (this.size != null ? this.size.hashCode() : 0);
@Override hash = 61 * hash + (this.source != null ? this.source.hashCode() : 0);
public boolean equals(Object obj) { hash = 61 * hash + (this.website != null ? this.website.hashCode() : 0);
if (obj == null) { return hash;
return false; }
} }
if (getClass() != obj.getClass()) {
return false;
}
final Trailer other = (Trailer) obj;
if ((this.name == null) ? (other.name != null) : !this.name.equals(other.name)) {
return false;
}
if ((this.size == null) ? (other.size != null) : !this.size.equals(other.size)) {
return false;
}
if ((this.source == null) ? (other.source != null) : !this.source.equals(other.source)) {
return false;
}
return true;
}
@Override
public int hashCode() {
int hash = 7;
hash = 61 * hash + (this.name != null ? this.name.hashCode() : 0);
hash = 61 * hash + (this.size != null ? this.size.hashCode() : 0);
hash = 61 * hash + (this.source != null ? this.source.hashCode() : 0);
hash = 61 * hash + (this.website != null ? this.website.hashCode() : 0);
return hash;
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder("[Trailer=");
sb.append("name=").append(name);
sb.append("],[size=").append(size);
sb.append("],[source=").append(source);
sb.append("],[website=").append(website);
sb.append("]]");
return sb.toString();
}
}
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2004-2012 Stuart Boston * Copyright (c) 2004-2013 Stuart Boston
* *
* This file is part of TheMovieDB API. * This file is part of TheMovieDB API.
* *
@@ -19,23 +19,17 @@
*/ */
package com.omertron.themoviedbapi.model; package com.omertron.themoviedbapi.model;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
import java.io.Serializable; import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.log4j.Logger; import org.apache.commons.lang3.builder.ToStringStyle;
/** /**
*
* @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 logger = Logger.getLogger(Translation.class);
/* /*
* Properties * Properties
*/ */
@@ -58,9 +52,7 @@ public class Translation implements Serializable {
public String getName() { public String getName() {
return name; return name;
} }
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="Setter methods">
public void setEnglishName(String englishName) { public void setEnglishName(String englishName) {
this.englishName = englishName; this.englishName = englishName;
} }
@@ -72,21 +64,6 @@ public class Translation implements Serializable {
public void setName(String name) { public void setName(String name) {
this.name = name; this.name = name;
} }
//</editor-fold>
/**
* Handle unknown properties and print a message
*
* @param key
* @param value
*/
@JsonAnySetter
public void handleUnknown(String key, Object value) {
StringBuilder sb = new StringBuilder();
sb.append("Unknown property: '").append(key);
sb.append("' value: '").append(value).append("'");
logger.trace(sb.toString());
}
@Override @Override
public boolean equals(Object obj) { public boolean equals(Object obj) {
@@ -120,11 +97,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,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 TmdbResults {
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.DEFAULT_STYLE);
}
}
@@ -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.results;
import java.util.ArrayList;
import java.util.List;
/**
* List of the results from TheMovieDb
*
* @author Stuart
* @param <T>
*/
public final class TmdbResultsList<T> extends TmdbResults {
private List<T> results;
public TmdbResultsList(List<T> resultList) {
if (resultList != null) {
results = new ArrayList<T>(resultList);
} else {
results = new ArrayList<T>(0);
}
}
public List<T> getResults() {
return results;
}
public void setResults(List<T> results) {
this.results = results;
}
}
@@ -0,0 +1,47 @@
/*
* 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 TmdbResults {
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;
}
}
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2004-2012 Stuart Boston * Copyright (c) 2004-2013 Stuart Boston
* *
* This file is part of TheMovieDB API. * This file is part of TheMovieDB API.
* *
@@ -19,14 +19,15 @@
*/ */
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.log4j.Logger; import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
* The API URL that is used to construct the API call * The API URL that is used to construct the API call
@@ -38,12 +39,11 @@ public class ApiUrl {
/* /*
* Logger * Logger
*/ */
private static final Logger logger = Logger.getLogger(ApiUrl.class); private static final Logger LOG = LoggerFactory.getLogger(ApiUrl.class);
/* /*
* TheMovieDbApi API Base URL * TheMovieDbApi API Base URL
*/ */
private static final String TMDB_API_BASE = "http://api.themoviedb.org/3/"; private static final String TMDB_API_BASE = "http://api.themoviedb.org/3/";
// private static final String TMDB_API_BASE = "http://private-3aa3-themoviedb.apiary.io/3/";
/* /*
* Parameter configuration * Parameter configuration
*/ */
@@ -53,7 +53,7 @@ public class ApiUrl {
/* /*
* Properties * Properties
*/ */
private TheMovieDbApi tmdb; private String apiKey;
private String method; private String method;
private String submethod; private String submethod;
private Map<String, String> arguments = new HashMap<String, String>(); private Map<String, String> arguments = new HashMap<String, String>();
@@ -66,7 +66,7 @@ public class ApiUrl {
public static final String PARAM_FAVORITE = "favorite="; public static final String PARAM_FAVORITE = "favorite=";
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_MOVIE_ID = "movie_id="; public static final String PARAM_INCLUDE_ALL_MOVIES = "include_all_movies=";
public static final String PARAM_MOVIE_WATCHLIST = "movie_watchlist="; public static final String PARAM_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=";
@@ -74,6 +74,9 @@ 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">
/** /**
@@ -81,8 +84,8 @@ public class ApiUrl {
* *
* @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;
} }
@@ -93,8 +96,8 @@ public class ApiUrl {
* @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;
} }
@@ -102,8 +105,6 @@ 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);
@@ -114,11 +115,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);
@@ -129,11 +133,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) {
logger.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
@@ -143,11 +148,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()) {
@@ -156,10 +164,10 @@ public class ApiUrl {
} }
try { try {
logger.trace("URL: " + urlString.toString()); LOG.trace("URL: {}", urlString.toString());
return new URL(urlString.toString()); return new URL(urlString.toString());
} catch (MalformedURLException ex) { } catch (MalformedURLException ex) {
logger.warn("Failed to create URL " + urlString.toString() + " - " + ex.toString()); LOG.warn("Failed to create URL {} - {}", urlString.toString(), ex.toString());
return null; return null;
} finally { } finally {
arguments.clear(); arguments.clear();
@@ -196,6 +204,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
*/ */
@@ -211,4 +229,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());
}
}
} }
@@ -1,75 +0,0 @@
/*
* Copyright (c) 2004-2012 Stuart Boston
*
* This file is part of TheMovieDB API.
*
* TheMovieDB API is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* TheMovieDB API is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>.
*
*/
package com.omertron.themoviedbapi.tools;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.apache.log4j.Logger;
import org.apache.log4j.PatternLayout;
import org.apache.log4j.spi.LoggingEvent;
/**
* Log4J Filtering routine to remove API keys from the output
*
* @author Stuart.Boston
*
*/
public class FilteringLayout extends PatternLayout {
private static final String REPLACEMENT = "[APIKEY]";
private static Pattern replacementPattern = Pattern.compile("DO_NOT_MATCH");
/**
* Add the string to replace in the log output
*
* @param replacementString
*/
public static void addReplacementString(String replacementString) {
replacementPattern = Pattern.compile(replacementString);
}
/**
* Extend the format to remove the API_KEYS from the output
*
* @param event
* @return
*/
@Override
public String format(LoggingEvent event) {
if (event.getMessage() instanceof String) {
String message = event.getRenderedMessage();
Matcher matcher = replacementPattern.matcher(message);
if (matcher.find()) {
String maskedMessage = matcher.replaceAll(REPLACEMENT);
Throwable throwable = event.getThrowableInformation() != null
? event.getThrowableInformation().getThrowable() : null;
LoggingEvent maskedEvent = new LoggingEvent(event.fqnOfCategoryClass,
Logger.getLogger(event.getLoggerName()), event.timeStamp,
event.getLevel(), maskedMessage, throwable);
return super.format(maskedEvent);
}
}
return super.format(event);
}
}
@@ -1,287 +1,335 @@
/* /*
* Copyright (c) 2004-2012 Stuart Boston * Copyright (c) 2004-2013 Stuart Boston
* *
* This file is part of TheMovieDB API. * This file is part of TheMovieDB API.
* *
* TheMovieDB API is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* any later version. * any later version.
* *
* TheMovieDB API is distributed in the hope that it will be useful, * TheMovieDB API is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* 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.tools; package com.omertron.themoviedbapi.tools;
import com.omertron.themoviedbapi.MovieDbException; import com.fasterxml.jackson.core.JsonProcessingException;
import java.io.BufferedReader; import com.fasterxml.jackson.databind.ObjectMapper;
import java.io.IOException; import com.omertron.themoviedbapi.MovieDbException;
import java.io.InputStreamReader; import org.apache.commons.codec.binary.Base64;
import java.io.StringWriter; import org.slf4j.Logger;
import java.net.HttpURLConnection; import org.slf4j.LoggerFactory;
import java.net.MalformedURLException;
import java.net.URL; import java.io.*;
import java.net.URLConnection; import java.net.HttpURLConnection;
import java.nio.charset.Charset; import java.net.MalformedURLException;
import java.nio.charset.UnsupportedCharsetException; import java.net.URL;
import java.util.HashMap; import java.net.URLConnection;
import java.util.List; import java.nio.charset.Charset;
import java.util.Map; import java.nio.charset.UnsupportedCharsetException;
import java.util.regex.Matcher; import java.util.HashMap;
import java.util.regex.Pattern; import java.util.List;
import org.apache.commons.codec.binary.Base64; import java.util.Map;
import org.apache.log4j.Logger; import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* Web browser with simple cookies support /**
*/ * Web browser with simple cookies support
public final class WebBrowser { */
public final class WebBrowser {
private static final Logger logger = Logger.getLogger(WebBrowser.class);
private static Map<String, String> browserProperties = new HashMap<String, String>(); private static final Logger LOG = LoggerFactory.getLogger(WebBrowser.class);
private static Map<String, Map<String, String>> cookies = new HashMap<String, Map<String, String>>(); private static Map<String, String> browserProperties = new HashMap<String, String>();
private static String proxyHost = null; private static Map<String, Map<String, String>> cookies = new HashMap<String, Map<String, String>>();
private static String proxyPort = null; private static String proxyHost = null;
private static String proxyUsername = null; private static String proxyPort = null;
private static String proxyPassword = null; private static String proxyUsername = null;
private static String proxyEncodedPassword = null; private static String proxyPassword = null;
private static int webTimeoutConnect = 25000; // 25 second timeout private static String proxyEncodedPassword = null;
private static int webTimeoutRead = 90000; // 90 second timeout private static int webTimeoutConnect = 25000; // 25 second timeout
private static int webTimeoutRead = 90000; // 90 second timeout
// Hide the constructor
protected WebBrowser() { // Hide the constructor
// prevents calls from subclass protected WebBrowser() {
throw new UnsupportedOperationException(); // prevents calls from subclass
} throw new UnsupportedOperationException();
}
/**
* Populate the browser properties /**
*/ * Populate the browser properties
private static void populateBrowserProperties() { */
if (browserProperties.isEmpty()) { private static void populateBrowserProperties() {
browserProperties.put("User-Agent", "Mozilla/5.25 Netscape/5.0 (Windows; I; Win95)"); if (browserProperties.isEmpty()) {
} browserProperties.put("User-Agent", "Mozilla/5.25 Netscape/5.0 (Windows; I; Win95)");
} browserProperties.put("Accept", "application/json");
browserProperties.put("Content-type", "application/json");
public static String request(String url) throws MovieDbException { }
try { }
return request(new URL(url));
} catch (MalformedURLException ex) { public static String request(String url) throws MovieDbException {
throw new MovieDbException(MovieDbException.MovieDbExceptionType.INVALID_URL, null, ex); try {
} return request(new URL(url));
} } catch (MalformedURLException ex) {
throw new MovieDbException(MovieDbException.MovieDbExceptionType.INVALID_URL, null, ex);
public static URLConnection openProxiedConnection(URL url) throws MovieDbException { }
try { }
if (proxyHost != null) {
System.getProperties().put("proxySet", "true"); public static URLConnection openProxiedConnection(URL url) throws MovieDbException {
System.getProperties().put("proxyHost", proxyHost); try {
System.getProperties().put("proxyPort", proxyPort); if (proxyHost != null) {
} System.getProperties().put("proxySet", "true");
System.getProperties().put("proxyHost", proxyHost);
URLConnection cnx = url.openConnection(); System.getProperties().put("proxyPort", proxyPort);
}
if (proxyUsername != null) {
cnx.setRequestProperty("Proxy-Authorization", proxyEncodedPassword); URLConnection cnx = url.openConnection();
}
if (proxyUsername != null) {
return cnx; cnx.setRequestProperty("Proxy-Authorization", proxyEncodedPassword);
} catch (IOException ex) { }
throw new MovieDbException(MovieDbException.MovieDbExceptionType.INVALID_URL, null, ex);
} return cnx;
} } catch (IOException ex) {
throw new MovieDbException(MovieDbException.MovieDbExceptionType.INVALID_URL, null, ex);
public static String request(URL url) throws MovieDbException { }
StringWriter content = null; }
try { public static String request(URL url) throws MovieDbException {
content = new StringWriter(); return request(url, null);
}
BufferedReader in = null;
URLConnection cnx = null; public static String request(URL url, String jsonBody) throws MovieDbException {
try { return request(url, jsonBody, false);
cnx = openProxiedConnection(url); }
sendHeader(cnx); public static String request(URL url, String jsonBody, boolean isDeleteRequest) throws MovieDbException {
readHeader(cnx);
StringWriter content = null;
in = new BufferedReader(new InputStreamReader(cnx.getInputStream(), getCharset(cnx)));
String line; try {
while ((line = in.readLine()) != null) { content = new StringWriter();
content.write(line);
} BufferedReader in = null;
} finally { HttpURLConnection cnx = null;
if (in != null) { OutputStreamWriter wr = null;
in.close(); try {
} cnx = (HttpURLConnection) openProxiedConnection(url);
if (cnx instanceof HttpURLConnection) { if (isDeleteRequest) {
((HttpURLConnection) cnx).disconnect(); cnx.setDoOutput(true);
} cnx.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
} cnx.setRequestMethod("DELETE");
return content.toString(); }
} catch (IOException ex) {
throw new MovieDbException(MovieDbException.MovieDbExceptionType.CONNECTION_ERROR, null, ex); sendHeader(cnx);
} finally {
if (content != null) { if (jsonBody != null) {
try { cnx.setDoOutput(true);
content.close(); wr = new OutputStreamWriter(cnx.getOutputStream());
} catch (IOException ex) { wr.write(jsonBody);
logger.debug("Failed to close connection: " + ex.getMessage()); }
}
} readHeader(cnx);
}
} // http://stackoverflow.com/questions/4633048/httpurlconnection-reading-response-content-on-403-error
if (cnx.getResponseCode() >= 400) {
private static void sendHeader(URLConnection cnx) { in = new BufferedReader(new InputStreamReader(cnx.getErrorStream(), getCharset(cnx)));
populateBrowserProperties(); } else {
in = new BufferedReader(new InputStreamReader(cnx.getInputStream(), getCharset(cnx)));
// send browser properties }
for (Map.Entry<String, String> browserProperty : browserProperties.entrySet()) {
cnx.setRequestProperty(browserProperty.getKey(), browserProperty.getValue()); String line;
} while ((line = in.readLine()) != null) {
// send cookies content.write(line);
String cookieHeader = createCookieHeader(cnx); }
if (!cookieHeader.isEmpty()) { } finally {
cnx.setRequestProperty("Cookie", cookieHeader); if (wr != null) {
} wr.flush();
} wr.close();
}
private static String createCookieHeader(URLConnection cnx) {
String host = cnx.getURL().getHost(); if (in != null) {
StringBuilder cookiesHeader = new StringBuilder(); in.close();
for (Map.Entry<String, Map<String, String>> domainCookies : cookies.entrySet()) { }
if (host.endsWith(domainCookies.getKey())) {
for (Map.Entry<String, String> cookie : domainCookies.getValue().entrySet()) { if (cnx instanceof HttpURLConnection) {
cookiesHeader.append(cookie.getKey()); ((HttpURLConnection) cnx).disconnect();
cookiesHeader.append("="); }
cookiesHeader.append(cookie.getValue()); }
cookiesHeader.append(";"); return content.toString();
} } catch (IOException ex) {
} throw new MovieDbException(MovieDbException.MovieDbExceptionType.CONNECTION_ERROR, null, ex);
} } finally {
if (cookiesHeader.length() > 0) { if (content != null) {
// remove last ; char try {
cookiesHeader.deleteCharAt(cookiesHeader.length() - 1); content.close();
} } catch (IOException ex) {
return cookiesHeader.toString(); LOG.debug("Failed to close connection: " + ex.getMessage());
} }
}
private static void readHeader(URLConnection cnx) { }
// read new cookies and update our cookies }
for (Map.Entry<String, List<String>> header : cnx.getHeaderFields().entrySet()) {
if ("Set-Cookie".equals(header.getKey())) { private static void sendHeader(URLConnection cnx) {
for (String cookieHeader : header.getValue()) { populateBrowserProperties();
String[] cookieElements = cookieHeader.split(" *; *");
if (cookieElements.length >= 1) { // send browser properties
String[] firstElem = cookieElements[0].split(" *= *"); for (Map.Entry<String, String> browserProperty : browserProperties.entrySet()) {
String cookieName = firstElem[0]; cnx.setRequestProperty(browserProperty.getKey(), browserProperty.getValue());
String cookieValue = firstElem.length > 1 ? firstElem[1] : null; }
String cookieDomain = null; // send cookies
// find cookie domain String cookieHeader = createCookieHeader(cnx);
for (int i = 1; i < cookieElements.length; i++) { if (!cookieHeader.isEmpty()) {
String[] cookieElement = cookieElements[i].split(" *= *"); cnx.setRequestProperty("Cookie", cookieHeader);
if ("domain".equals(cookieElement[0])) { }
cookieDomain = cookieElement.length > 1 ? cookieElement[1] : null; }
break;
} private static String createCookieHeader(URLConnection cnx) {
} String host = cnx.getURL().getHost();
if (cookieDomain == null) { StringBuilder cookiesHeader = new StringBuilder();
// if domain isn't set take current host for (Map.Entry<String, Map<String, String>> domainCookies : cookies.entrySet()) {
cookieDomain = cnx.getURL().getHost(); if (host.endsWith(domainCookies.getKey())) {
} for (Map.Entry<String, String> cookie : domainCookies.getValue().entrySet()) {
Map<String, String> domainCookies = cookies.get(cookieDomain); cookiesHeader.append(cookie.getKey());
if (domainCookies == null) { cookiesHeader.append("=");
domainCookies = new HashMap<String, String>(); cookiesHeader.append(cookie.getValue());
cookies.put(cookieDomain, domainCookies); cookiesHeader.append(";");
} }
// add or replace cookie }
domainCookies.put(cookieName, cookieValue); }
} if (cookiesHeader.length() > 0) {
} // remove last ; char
} cookiesHeader.deleteCharAt(cookiesHeader.length() - 1);
} }
} return cookiesHeader.toString();
}
private static Charset getCharset(URLConnection cnx) {
Charset charset = null; private static void readHeader(URLConnection cnx) {
// content type will be string like "text/html; charset=UTF-8" or "text/html" // read new cookies and update our cookies
String contentType = cnx.getContentType(); for (Map.Entry<String, List<String>> header : cnx.getHeaderFields().entrySet()) {
if (contentType != null) { if ("Set-Cookie".equals(header.getKey())) {
// changed 'charset' to 'harset' in regexp because some sites send 'Charset' for (String cookieHeader : header.getValue()) {
Matcher m = Pattern.compile("harset *=[ '\"]*([^ ;'\"]+)[ ;'\"]*").matcher(contentType); String[] cookieElements = cookieHeader.split(" *; *");
if (m.find()) { if (cookieElements.length >= 1) {
String encoding = m.group(1); String[] firstElem = cookieElements[0].split(" *= *");
try { String cookieName = firstElem[0];
charset = Charset.forName(encoding); String cookieValue = firstElem.length > 1 ? firstElem[1] : null;
} catch (UnsupportedCharsetException e) { String cookieDomain = null;
// there will be used default charset // find cookie domain
} for (int i = 1; i < cookieElements.length; i++) {
} String[] cookieElement = cookieElements[i].split(" *= *");
} if ("domain".equals(cookieElement[0])) {
if (charset == null) { cookieDomain = cookieElement.length > 1 ? cookieElement[1] : null;
charset = Charset.defaultCharset(); break;
} }
}
return charset; if (cookieDomain == null) {
} // if domain isn't set take current host
cookieDomain = cnx.getURL().getHost();
public static String getProxyHost() { }
return proxyHost; Map<String, String> domainCookies = cookies.get(cookieDomain);
} if (domainCookies == null) {
domainCookies = new HashMap<String, String>();
public static void setProxyHost(String myProxyHost) { cookies.put(cookieDomain, domainCookies);
WebBrowser.proxyHost = myProxyHost; }
} // add or replace cookie
domainCookies.put(cookieName, cookieValue);
public static String getProxyPort() { }
return proxyPort; }
} }
}
public static void setProxyPort(String myProxyPort) { }
WebBrowser.proxyPort = myProxyPort;
} private static Charset getCharset(URLConnection cnx) {
Charset charset = null;
public static String getProxyUsername() { // content type will be string like "text/html; charset=UTF-8" or "text/html"
return proxyUsername; String contentType = cnx.getContentType();
} if (contentType != null) {
// changed 'charset' to 'harset' in regexp because some sites send 'Charset'
public static void setProxyUsername(String myProxyUsername) { Matcher m = Pattern.compile("harset *=[ '\"]*([^ ;'\"]+)[ ;'\"]*").matcher(contentType);
WebBrowser.proxyUsername = myProxyUsername; if (m.find()) {
} String encoding = m.group(1);
try {
public static String getProxyPassword() { charset = Charset.forName(encoding);
return proxyPassword; } catch (UnsupportedCharsetException e) {
} // there will be used default charset
}
public static void setProxyPassword(String myProxyPassword) { }
WebBrowser.proxyPassword = myProxyPassword; }
if (charset == null) {
if (proxyUsername != null) { charset = Charset.defaultCharset();
proxyEncodedPassword = proxyUsername + ":" + proxyPassword; }
proxyEncodedPassword = "Basic " + new String(Base64.encodeBase64((proxyUsername + ":" + proxyPassword).getBytes()));
} return charset;
} }
public static int getWebTimeoutConnect() { public static String getProxyHost() {
return webTimeoutConnect; return proxyHost;
} }
public static int getWebTimeoutRead() { public static void setProxyHost(String myProxyHost) {
return webTimeoutRead; WebBrowser.proxyHost = myProxyHost;
} }
public static void setWebTimeoutConnect(int webTimeoutConnect) { public static String getProxyPort() {
WebBrowser.webTimeoutConnect = webTimeoutConnect; return proxyPort;
} }
public static void setWebTimeoutRead(int webTimeoutRead) { public static void setProxyPort(String myProxyPort) {
WebBrowser.webTimeoutRead = webTimeoutRead; WebBrowser.proxyPort = myProxyPort;
} }
}
public static String getProxyUsername() {
return proxyUsername;
}
public static void setProxyUsername(String myProxyUsername) {
WebBrowser.proxyUsername = myProxyUsername;
}
public static String getProxyPassword() {
return proxyPassword;
}
public static void setProxyPassword(String myProxyPassword) {
WebBrowser.proxyPassword = myProxyPassword;
if (proxyUsername != null) {
proxyEncodedPassword = proxyUsername + ":" + proxyPassword;
proxyEncodedPassword = "Basic " + new String(Base64.encodeBase64((proxyUsername + ":" + proxyPassword).getBytes()));
}
}
public static int getWebTimeoutConnect() {
return webTimeoutConnect;
}
public static int getWebTimeoutRead() {
return webTimeoutRead;
}
public static void setWebTimeoutConnect(int webTimeoutConnect) {
WebBrowser.webTimeoutConnect = webTimeoutConnect;
}
public static void setWebTimeoutRead(int webTimeoutRead) {
WebBrowser.webTimeoutRead = webTimeoutRead;
}
/**
* Use Jackson to convert Map to JSON string.
*/
public static String convertToJson(Map<String, ?> map) throws MovieDbException {
try {
return new ObjectMapper().writeValueAsString(map);
} catch (JsonProcessingException jpe) {
throw new MovieDbException(MovieDbException.MovieDbExceptionType.MAPPING_FAILED, "JSON conversion failed", jpe);
}
}
}
@@ -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.wrapper;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.EnumSet;
import java.util.List;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public abstract class AbstractWrapper {
private Logger log;
public AbstractWrapper(Class classToLog) {
this.log = LoggerFactory.getLogger(classToLog);
}
/**
* 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));
}
}
/**
* Handle unknown properties and print a message
*
* @param key
* @param value
*/
@JsonAnySetter
public void handleUnknown(String key, Object value) {
StringBuilder sb = new StringBuilder();
sb.append("Unknown property: '").append(key);
sb.append("' value: '").append(value).append("'");
log.trace(sb.toString());
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.DEFAULT_STYLE);
}
}
@@ -0,0 +1,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, 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 AbstractWrapperAll extends AbstractWrapperId implements IWrapperId, IWrapperPages, IWrapperDates {
/*
* Properties
*/
@JsonProperty("page")
private int page;
@JsonProperty("total_pages")
private int totalPages;
@JsonProperty("total_results")
private int totalResults;
@JsonProperty("dates")
private ResultDates dates = new ResultDates();
public AbstractWrapperAll(Class classToLog) {
super(classToLog);
}
@Override
public int getPage() {
return page;
}
@Override
public int getTotalPages() {
return totalPages;
}
@Override
public int getTotalResults() {
return totalResults;
}
@Override
public ResultDates getDates() {
return dates;
}
@Override
public void setPage(int page) {
this.page = page;
}
@Override
public void setTotalPages(int totalPages) {
this.totalPages = totalPages;
}
@Override
public void setTotalResults(int totalResults) {
this.totalResults = totalResults;
}
@Override
public void setDates(ResultDates dates) {
this.dates = dates;
}
}
@@ -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.wrapper;
import com.fasterxml.jackson.annotation.JsonProperty;
/**
* Base class for the wrappers
*
* @author Stuart
*/
public class AbstractWrapperId extends AbstractWrapper implements IWrapperId {
/*
* Properties
*/
@JsonProperty("id")
private int id;
public AbstractWrapperId(Class classToLog) {
super(classToLog);
}
@Override
public int getId() {
return id;
}
@Override
public void setId(int id) {
this.id = id;
}
}
@@ -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);
}
@@ -0,0 +1,89 @@
/*
* Copyright (c) 2004-2013 Stuart Boston
*
* This file is part of TheMovieDB API.
*
* TheMovieDB API is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* TheMovieDB API is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>.
*
*/
package com.omertron.themoviedbapi.wrapper;
import com.omertron.themoviedbapi.model.*;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonProperty;
import java.io.Serializable;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
*
* @author Stuart
*/
public class ResultDates implements Serializable {
private static final long serialVersionUID = 1L;
/*
* Logger
*/
private static final Logger LOG = LoggerFactory.getLogger(ResultDates.class);
/*
* Properties
*/
@JsonProperty("minimum")
private String minimum = "";
@JsonProperty("maximum")
private String maximum = "";
// <editor-fold defaultstate="collapsed" desc="Getter methods">
public String getMinimum() {
return minimum;
}
public String getMaximum() {
return maximum;
}
// </editor-fold>
// <editor-fold defaultstate="collapsed" desc="Setter methods">
public void setMinimum(String minimum) {
this.minimum = minimum;
}
public void setMaximum(String maximum) {
this.maximum = maximum;
}
// </editor-fold>
/**
* Handle unknown properties and print a message
*
* @param key
* @param value
*/
@JsonAnySetter
public void handleUnknown(String key, Object value) {
StringBuilder sb = new StringBuilder();
sb.append("Unknown property: '").append(key);
sb.append("' value: '").append(value).append("'");
LOG.trace(sb.toString());
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.SIMPLE_STYLE);
}
}
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2004-2012 Stuart Boston * Copyright (c) 2004-2013 Stuart Boston
* *
* This file is part of TheMovieDB API. * This file is part of TheMovieDB API.
* *
@@ -19,56 +19,28 @@
*/ */
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.util.List; import java.util.List;
import org.apache.log4j.Logger;
/** /**
* *
* @author Stuart * @author Stuart
*/ */
public class WrapperAlternativeTitles { public class WrapperAlternativeTitles extends AbstractWrapperId {
/*
* Logger
*/
private static final Logger logger = Logger.getLogger(WrapperAlternativeTitles.class);
/*
* Properties
*/
@JsonProperty("id")
private int id;
@JsonProperty("titles") @JsonProperty("titles")
private List<AlternativeTitle> titles; private List<AlternativeTitle> titles;
public int getId() { public WrapperAlternativeTitles() {
return id; super(WrapperAlternativeTitles.class);
} }
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("'");
logger.trace(sb.toString());
}
} }
@@ -0,0 +1,42 @@
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.JsonProperty;
import com.omertron.themoviedbapi.model.ChangeKeyItem;
import org.apache.commons.lang3.builder.ToStringBuilder;
import org.apache.commons.lang3.builder.ToStringStyle;
public class WrapperChanges {
@JsonProperty("changes")
private List<ChangeKeyItem> changedItems = new ArrayList<ChangeKeyItem>();
private Map<String, Object> newItems = new HashMap<String, Object>();
public List<ChangeKeyItem> getChangedItems() {
return changedItems;
}
public void setChangedItems(List<ChangeKeyItem> 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);
}
@Override
public String toString() {
return ToStringBuilder.reflectionToString(this, ToStringStyle.DEFAULT_STYLE);
}
}
@@ -0,0 +1,46 @@
/*
* 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.Collection;
import java.util.List;
/**
*
* @author stuart.boston
*/
public class WrapperCollection extends AbstractWrapperAll {
@JsonProperty("results")
private List<Collection> results;
public WrapperCollection() {
super(WrapperCollection.class);
}
public List<Collection> getResults() {
return results;
}
public void setResults(List<Collection> results) {
this.results = results;
}
}
@@ -1,98 +1,46 @@
/* /*
* Copyright (c) 2004-2012 Stuart Boston * Copyright (c) 2004-2013 Stuart Boston
* *
* This file is part of TheMovieDB API. * This file is part of TheMovieDB API.
* *
* TheMovieDB API is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* any later version. * any later version.
* *
* TheMovieDB API is distributed in the hope that it will be useful, * TheMovieDB API is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* 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.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.Company;
import com.omertron.themoviedbapi.model.Company; import java.util.List;
import java.util.List;
import org.apache.log4j.Logger; /**
*
/** * @author stuart.boston
* */
* @author stuart.boston public class WrapperCompany extends AbstractWrapperAll {
*/
public class WrapperCompany { @JsonProperty("results")
/* private List<Company> results;
* Logger
*/ public WrapperCompany() {
super(WrapperCompany.class);
private static final Logger logger = Logger.getLogger(WrapperCompany.class); }
/*
* Properties public List<Company> getResults() {
*/ return results;
@JsonProperty("page") }
private int page;
@JsonProperty("results") public void setResults(List<Company> results) {
private List<Company> results; this.results = results;
@JsonProperty("total_pages") }
private int totalPages; }
@JsonProperty("total_results")
private int totalResults;
//<editor-fold defaultstate="collapsed" desc="Getter methods">
public int getPage() {
return page;
}
public List<Company> getResults() {
return results;
}
public int getTotalPages() {
return totalPages;
}
public int getTotalResults() {
return totalResults;
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="Setter methods">
public void setPage(int page) {
this.page = page;
}
public void setResults(List<Company> results) {
this.results = results;
}
public void setTotalPages(int totalPages) {
this.totalPages = totalPages;
}
public void setTotalResults(int totalResults) {
this.totalResults = totalResults;
}
//</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("'");
logger.trace(sb.toString());
}
}
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2004-2012 Stuart Boston * Copyright (c) 2004-2013 Stuart Boston
* *
* This file is part of TheMovieDB API. * This file is part of TheMovieDB API.
* *
@@ -19,99 +19,28 @@
*/ */
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.MovieDb; import com.omertron.themoviedbapi.model.MovieDb;
import java.util.List; import java.util.List;
import org.apache.log4j.Logger;
/** /**
* *
* @author stuart.boston * @author stuart.boston
*/ */
public class WrapperCompanyMovies { public class WrapperCompanyMovies extends AbstractWrapperAll {
// Loggers
private static final Logger logger = Logger.getLogger(WrapperCompanyMovies.class);
/*
* Properties
*/
@JsonProperty("id")
private int companyId;
@JsonProperty("page")
private int page;
@JsonProperty("results") @JsonProperty("results")
private List<MovieDb> results; private List<MovieDb> results;
@JsonProperty("total_pages")
private int totalPages;
@JsonProperty("total_results")
private int totalResults;
//<editor-fold defaultstate="collapsed" desc="Getter methods"> public WrapperCompanyMovies() {
public int getCompanyId() { super(WrapperCompanyMovies.class);
return companyId;
}
public int getPage() {
return page;
} }
public List<MovieDb> getResults() { public List<MovieDb> getResults() {
return results; return results;
} }
public int getTotalPages() {
return totalPages;
}
public int getTotalResults() {
return totalResults;
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="Setter methods">
public void setCompanyId(int companyId) {
this.companyId = companyId;
}
public void setPage(int page) {
this.page = page;
}
public void setResults(List<MovieDb> results) { public void setResults(List<MovieDb> results) {
this.results = results; this.results = results;
} }
public void setTotalPages(int totalPages) {
this.totalPages = totalPages;
}
public void setTotalResults(int totalResults) {
this.totalResults = totalResults;
}
//</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("'");
logger.trace(sb.toString());
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder("[ResultList=[");
sb.append("[companyId=").append(companyId);
sb.append("],[page=").append(page);
sb.append("],[pageResults=").append(results.size());
sb.append("],[totalPages=").append(totalPages);
sb.append("],[totalResults=").append(totalResults);
sb.append("]]");
return sb.toString();
}
} }
@@ -1,76 +1,57 @@
/* /*
* Copyright (c) 2004-2012 Stuart Boston * Copyright (c) 2004-2013 Stuart Boston
* *
* This file is part of TheMovieDB API. * This file is part of TheMovieDB API.
* *
* TheMovieDB API is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* any later version. * any later version.
* *
* TheMovieDB API is distributed in the hope that it will be useful, * TheMovieDB API is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* 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.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.apache.log4j.Logger; /**
*
/** * @author Stuart
* */
* @author Stuart public class WrapperConfig extends AbstractWrapper {
*/
public class WrapperConfig { @JsonProperty("images")
/* private TmdbConfiguration tmdbConfiguration;
* Logger @JsonProperty("change_keys")
*/ private List<String> changeKeys = Collections.EMPTY_LIST;
private static final Logger logger = Logger.getLogger(WrapperConfig.class); public WrapperConfig() {
/* super(WrapperConfig.class);
* Properties }
*/
@JsonProperty("images") public TmdbConfiguration getTmdbConfiguration() {
private TmdbConfiguration tmdbConfiguration; return tmdbConfiguration;
@JsonProperty("change_keys") }
private List<String> changeKeys = Collections.EMPTY_LIST;
public void setTmdbConfiguration(TmdbConfiguration tmdbConfiguration) {
public TmdbConfiguration getTmdbConfiguration() { this.tmdbConfiguration = tmdbConfiguration;
return tmdbConfiguration; }
}
public List<String> getChangeKeys() {
public void setTmdbConfiguration(TmdbConfiguration tmdbConfiguration) { return changeKeys;
this.tmdbConfiguration = tmdbConfiguration; }
}
public void setChangeKeys(List<String> changeKeys) {
public List<String> getChangeKeys() { this.changeKeys = changeKeys;
return changeKeys; }
} }
public void setChangeKeys(List<String> 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("'");
logger.trace(sb.toString());
}
}
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2004-2012 Stuart Boston * Copyright (c) 2004-2013 Stuart Boston
* *
* This file is part of TheMovieDB API. * This file is part of TheMovieDB API.
* *
@@ -19,29 +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.Genre; import com.omertron.themoviedbapi.model.Genre;
import java.util.List; import java.util.List;
import org.apache.log4j.Logger;
/** /**
* 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 logger = Logger.getLogger(WrapperGenres.class);
/*
* Properties
*/
@JsonProperty("genres") @JsonProperty("genres")
private List<Genre> genres; private List<Genre> genres;
public WrapperGenres() {
super(WrapperGenres.class);
}
public List<Genre> getGenres() { public List<Genre> getGenres() {
return genres; return genres;
} }
@@ -49,18 +44,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("'");
logger.trace(sb.toString());
}
} }
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2004-2012 Stuart Boston * Copyright (c) 2004-2013 Stuart Boston
* *
* This file is part of TheMovieDB API. * This file is part of TheMovieDB API.
* *
@@ -19,37 +19,29 @@
*/ */
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.Artwork; import com.omertron.themoviedbapi.model.Artwork;
import com.omertron.themoviedbapi.model.ArtworkType;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List; import java.util.List;
import org.apache.log4j.Logger;
/** /**
* *
* @author Stuart * @author Stuart
*/ */
public class WrapperImages { public class WrapperImages extends AbstractWrapperAll {
/*
* Logger
*/
private static final Logger logger = Logger.getLogger(WrapperImages.class);
/*
* Properties
*/
@JsonProperty("id")
private int id;
@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;
//<editor-fold defaultstate="collapsed" desc="Getter methods"> public WrapperImages() {
public int getId() { super(WrapperImages.class);
return id;
} }
public List<Artwork> getBackdrops() { public List<Artwork> getBackdrops() {
@@ -63,12 +55,6 @@ public class WrapperImages {
public List<Artwork> getProfiles() { public List<Artwork> getProfiles() {
return profiles; return profiles;
} }
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="Setter methods">
public void setId(int id) {
this.id = id;
}
public void setBackdrops(List<Artwork> backdrops) { public void setBackdrops(List<Artwork> backdrops) {
this.backdrops = backdrops; this.backdrops = backdrops;
@@ -81,19 +67,54 @@ public class WrapperImages {
public void setProfiles(List<Artwork> profiles) { public void setProfiles(List<Artwork> profiles) {
this.profiles = profiles; this.profiles = profiles;
} }
//</editor-fold>
/** /**
* Handle unknown properties and print a message * Return a list of all the artwork with their types.
* *
* @param key * Leaving the parameters blank will return all types
* @param value *
* @return
*/ */
@JsonAnySetter public List<Artwork> getAll(ArtworkType... artworkList) {
public void handleUnknown(String key, Object value) { List<Artwork> artwork = new ArrayList<Artwork>();
StringBuilder sb = new StringBuilder(); List<ArtworkType> types;
sb.append("Unknown property: '").append(key);
sb.append("' value: '").append(value).append("'"); if (artworkList.length > 0) {
logger.trace(sb.toString()); 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,46 @@
/*
* 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 WrapperJobList() {
super(WrapperJobList.class);
}
public List<JobDepartment> getJobs() {
return jobs;
}
public void setJobs(List<JobDepartment> jobs) {
this.jobs = jobs;
}
}
@@ -0,0 +1,46 @@
/*
* 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.KeywordMovie;
import java.util.List;
/**
*
* @author stuart.boston
*/
public class WrapperKeywordMovies extends AbstractWrapperAll {
@JsonProperty("results")
private List<KeywordMovie> results;
public WrapperKeywordMovies() {
super(WrapperKeywordMovies.class);
}
public List<KeywordMovie> getResults() {
return results;
}
public void setResults(List<KeywordMovie> results) {
this.results = results;
}
}
@@ -0,0 +1,46 @@
/*
* 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.Keyword;
import java.util.List;
/**
*
* @author stuart.boston
*/
public class WrapperKeywords extends AbstractWrapperAll {
@JsonProperty("results")
private List<Keyword> results;
public WrapperKeywords() {
super(WrapperKeywords.class);
}
public List<Keyword> getResults() {
return results;
}
public void setResults(List<Keyword> results) {
this.results = results;
}
}
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2004-2012 Stuart Boston * Copyright (c) 2004-2013 Stuart Boston
* *
* This file is part of TheMovieDB API. * This file is part of TheMovieDB API.
* *
@@ -19,103 +19,28 @@
*/ */
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.MovieDb; import com.omertron.themoviedbapi.model.MovieDb;
import java.util.List; import java.util.List;
import org.apache.log4j.Logger;
/** /**
* *
* @author stuart.boston * @author stuart.boston
*/ */
public class WrapperMovie { public class WrapperMovie extends AbstractWrapperAll {
/*
* Logger
*/
private static final Logger logger = Logger.getLogger(WrapperMovie.class);
/*
* Properties
*/
@JsonProperty("page")
private int page;
@JsonProperty("results") @JsonProperty("results")
private List<MovieDb> movies; private List<MovieDb> movies;
@JsonProperty("total_pages")
private int totalPages;
@JsonProperty("total_results")
private int totalResults;
@JsonProperty("id")
private int id;
//<editor-fold defaultstate="collapsed" desc="Getter methods"> public WrapperMovie() {
public int getPage() { super(WrapperMovie.class);
return page;
} }
public List<MovieDb> getMovies() { public List<MovieDb> getMovies() {
return movies; return movies;
} }
public int getTotalPages() { public void setMovies(List<MovieDb> movies) {
return totalPages; this.movies = movies;
}
public int getTotalResults() {
return totalResults;
}
public int getId() {
return id;
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="Setter methods">
public void setPage(int page) {
this.page = page;
}
public void setMovies(List<MovieDb> results) {
this.movies = results;
}
public void setTotalPages(int totalPages) {
this.totalPages = totalPages;
}
public void setTotalResults(int totalResults) {
this.totalResults = totalResults;
}
public void setId(int id) {
this.id = id;
}
//</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("'");
logger.trace(sb.toString());
}
@Override
public String toString() {
StringBuilder sb = new StringBuilder("[ResultList=[");
sb.append("[page=").append(page);
sb.append("],[pageResults=").append(movies.size());
sb.append("],[totalPages=").append(totalPages);
sb.append("],[totalResults=").append(totalResults);
sb.append("],[id=").append(id);
sb.append("]]");
return sb.toString();
} }
} }
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2004-2012 Stuart Boston * Copyright (c) 2004-2013 Stuart Boston
* *
* This file is part of TheMovieDB API. * This file is part of TheMovieDB API.
* *
@@ -19,34 +19,28 @@
*/ */
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.util.ArrayList;
import java.util.List; import java.util.List;
import org.apache.log4j.Logger;
/** /**
* *
* @author Stuart * @author Stuart
*/ */
public class WrapperMovieCasts { public class WrapperMovieCasts extends AbstractWrapperId {
/*
* Logger
*/
private static final Logger logger = Logger.getLogger(WrapperMovieCasts.class);
/*
* 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 WrapperMovieCasts() {
super(WrapperMovieCasts.class);
}
public List<PersonCast> getCast() { public List<PersonCast> getCast() {
return cast; return cast;
} }
@@ -55,12 +49,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;
} }
@@ -69,21 +57,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) {
* @param key Person person = new Person();
* @param value person.addCast(member.getId(), member.getName(), member.getProfilePath(), member.getCharacter(), member.getOrder());
*/ people.add(person);
@JsonAnySetter }
public void handleUnknown(String key, Object value) {
StringBuilder sb = new StringBuilder(); // Add a crew member
sb.append("Unknown property: '").append(key); for (PersonCrew member : crew) {
sb.append("' value: '").append(value).append("'"); Person person = new Person();
logger.trace(sb.toString()); person.addCrew(member.getId(), member.getName(), member.getProfilePath(), member.getDepartment(), member.getJob());
people.add(person);
}
return people;
} }
} }
@@ -0,0 +1,25 @@
package com.omertron.themoviedbapi.wrapper;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.omertron.themoviedbapi.model.MovieDbList;
import java.util.List;
public class WrapperMovieDbList extends AbstractWrapperAll {
@JsonProperty("results")
private List<MovieDbList> lists;
public WrapperMovieDbList() {
super(WrapperMovieDbList.class);
}
public List<MovieDbList> getLists() {
return lists;
}
public void setLists(List<MovieDbList> lists) {
this.lists = lists;
}
}
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2004-2012 Stuart Boston * Copyright (c) 2004-2013 Stuart Boston
* *
* This file is part of TheMovieDB API. * This file is part of TheMovieDB API.
* *
@@ -19,60 +19,28 @@
*/ */
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.util.List; import java.util.List;
import org.apache.log4j.Logger;
/** /**
* *
* @author Stuart * @author Stuart
*/ */
public class WrapperMovieKeywords { public class WrapperMovieKeywords extends AbstractWrapperId {
/*
* Logger
*/
private static final Logger logger = Logger.getLogger(WrapperMovieKeywords.class);
/*
* 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 WrapperMovieKeywords() {
public int getId() { super(WrapperMovieKeywords.class);
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("'");
logger.trace(sb.toString());
}
} }
@@ -0,0 +1,46 @@
/*
* 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.MovieList;
import java.util.List;
/**
*
* @author Stuart
*/
public class WrapperMovieList extends AbstractWrapperAll {
@JsonProperty("results")
private List<MovieList> movieList;
public WrapperMovieList() {
super(WrapperMovieList.class);
}
public List<MovieList> getMovieList() {
return movieList;
}
public void setMovieList(List<MovieList> movieList) {
this.movieList = movieList;
}
}
@@ -1,98 +1,46 @@
/* /*
* Copyright (c) 2004-2012 Stuart Boston * Copyright (c) 2004-2013 Stuart Boston
* *
* This file is part of TheMovieDB API. * This file is part of TheMovieDB API.
* *
* TheMovieDB API is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* any later version. * any later version.
* *
* TheMovieDB API is distributed in the hope that it will be useful, * TheMovieDB API is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* 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.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.Person; import java.util.List;
import java.util.List;
import org.apache.log4j.Logger; /**
*
/** * @author stuart.boston
* */
* @author stuart.boston public class WrapperPerson extends AbstractWrapperAll {
*/
public class WrapperPerson { @JsonProperty("results")
/* private List<Person> results;
* Logger
*/ public WrapperPerson() {
super(WrapperPerson.class);
private static final Logger logger = Logger.getLogger(WrapperPerson.class); }
/*
* Properties public List<Person> getResults() {
*/ return results;
@JsonProperty("page") }
private int page;
@JsonProperty("results") public void setResults(List<Person> results) {
private List<Person> results; this.results = results;
@JsonProperty("total_pages") }
private int totalPages; }
@JsonProperty("total_results")
private int totalResults;
//<editor-fold defaultstate="collapsed" desc="Getter methods">
public int getPage() {
return page;
}
public List<Person> getResults() {
return results;
}
public int getTotalPages() {
return totalPages;
}
public int getTotalResults() {
return totalResults;
}
//</editor-fold>
//<editor-fold defaultstate="collapsed" desc="Setter methods">
public void setPage(int page) {
this.page = page;
}
public void setResults(List<Person> results) {
this.results = results;
}
public void setTotalPages(int totalPages) {
this.totalPages = totalPages;
}
public void setTotalResults(int totalResults) {
this.totalResults = totalResults;
}
//</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("'");
logger.trace(sb.toString());
}
}
@@ -1,88 +1,81 @@
/* /*
* Copyright (c) 2004-2012 Stuart Boston * Copyright (c) 2004-2013 Stuart Boston
* *
* This file is part of TheMovieDB API. * This file is part of TheMovieDB API.
* *
* TheMovieDB API is free software: you can redistribute it and/or modify * 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 * it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or * the Free Software Foundation, either version 3 of the License, or
* any later version. * any later version.
* *
* TheMovieDB API is distributed in the hope that it will be useful, * TheMovieDB API is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of * but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details. * GNU General Public License for more details.
* *
* You should have received a copy of the GNU General Public License * You should have received a copy of the GNU General Public License
* 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.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.PersonCredit;
import com.omertron.themoviedbapi.model.PersonCredit; import com.omertron.themoviedbapi.model.PersonType;
import java.util.List; import java.util.ArrayList;
import org.apache.log4j.Logger; import java.util.List;
/** /**
* *
* @author stuart.boston * @author stuart.boston
*/ */
public class WrapperPersonCredits { public class WrapperPersonCredits extends AbstractWrapperAll {
/*
* Logger @JsonProperty("cast")
*/ private List<PersonCredit> cast;
@JsonProperty("crew")
private static final Logger logger = Logger.getLogger(WrapperMovieCasts.class); private List<PersonCredit> crew;
/*
* Properties public WrapperPersonCredits() {
*/ super(WrapperMovieCasts.class);
@JsonProperty("id") }
private int id;
@JsonProperty("cast") public List<PersonCredit> getCast() {
private List<PersonCredit> cast; return cast;
@JsonProperty("crew") }
private List<PersonCredit> crew;
public void setCast(List<PersonCredit> cast) {
//<editor-fold defaultstate="collapsed" desc="Getter methods"> this.cast = cast;
public List<PersonCredit> getCast() { }
return cast;
} public List<PersonCredit> getCrew() {
return crew;
public List<PersonCredit> getCrew() { }
return crew;
} public void setCrew(List<PersonCredit> crew) {
this.crew = crew;
public int getId() { }
return id;
} public List<PersonCredit> getAll(PersonType... typeList) {
//</editor-fold> List<PersonCredit> personCredits = new ArrayList<PersonCredit>();
List<PersonType> types = getTypeList(PersonType.class, typeList);
//<editor-fold defaultstate="collapsed" desc="Setter methods">
public void setCast(List<PersonCredit> cast) { // Add a cast member
this.cast = cast; if (types.contains(PersonType.CAST)) {
} for (PersonCredit member : cast) {
member.setPersonType(PersonType.CAST);
public void setCrew(List<PersonCredit> crew) { personCredits.add(member);
this.crew = crew; }
} }
public void setId(int id) { // Add a crew member
this.id = id; if (types.contains(PersonType.CREW)) {
} for (PersonCredit member : crew) {
//</editor-fold> member.setPersonType(PersonType.CREW);
personCredits.add(member);
/** }
* Handle unknown properties and print a message }
* @param key
* @param value return personCredits;
*/ }
@JsonAnySetter }
public void handleUnknown(String key, Object value) {
StringBuilder sb = new StringBuilder();
sb.append("Unknown property: '").append(key);
sb.append("' value: '").append(value).append("'");
logger.trace(sb.toString());
}
}
@@ -0,0 +1,46 @@
/*
* 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 WrapperPersonList() {
super(WrapperPersonList.class);
}
public List<Person> getPersonList() {
return personList;
}
public void setPersonList(List<Person> personList) {
this.personList = personList;
}
}
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2004-2012 Stuart Boston * Copyright (c) 2004-2013 Stuart Boston
* *
* This file is part of TheMovieDB API. * This file is part of TheMovieDB API.
* *
@@ -19,60 +19,28 @@
*/ */
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.util.List; import java.util.List;
import org.apache.log4j.Logger;
/** /**
* *
* @author Stuart * @author Stuart
*/ */
public class WrapperReleaseInfo { public class WrapperReleaseInfo extends AbstractWrapperId {
/*
* Logger
*/
private static final Logger logger = Logger.getLogger(WrapperReleaseInfo.class);
/*
* 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 WrapperReleaseInfo() {
super(WrapperReleaseInfo.class);
}
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("'");
logger.trace(sb.toString());
}
} }
@@ -0,0 +1,46 @@
/*
* 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.util.List;
/**
*
* @author stuart.boston
*/
public class WrapperReviews extends AbstractWrapperAll {
@JsonProperty("results")
private List<Reviews> reviews;
public WrapperReviews() {
super(WrapperReviews.class);
}
public List<Reviews> getReviews() {
return reviews;
}
public void setReviews(List<Reviews> reviews) {
this.reviews = reviews;
}
}
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2004-2012 Stuart Boston * Copyright (c) 2004-2013 Stuart Boston
* *
* This file is part of TheMovieDB API. * This file is part of TheMovieDB API.
* *
@@ -19,35 +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.util.ArrayList;
import java.util.List; import java.util.List;
import org.apache.log4j.Logger;
/** /**
* *
* @author Stuart * @author Stuart
*/ */
public class WrapperTrailers { public class WrapperTrailers extends AbstractWrapperId {
/*
* Logger
*/
private static final Logger logger = Logger.getLogger(WrapperTrailers.class);
/*
* 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 WrapperTrailers() {
public int getId() { super(WrapperTrailers.class);
return id;
} }
public List<Trailer> getQuicktime() { public List<Trailer> getQuicktime() {
@@ -57,12 +46,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;
@@ -71,18 +54,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 *
* @param value * @return
*/ */
@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) {
logger.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;
} }
} }
@@ -1,5 +1,5 @@
/* /*
* Copyright (c) 2004-2012 Stuart Boston * Copyright (c) 2004-2013 Stuart Boston
* *
* This file is part of TheMovieDB API. * This file is part of TheMovieDB API.
* *
@@ -19,57 +19,28 @@
*/ */
package com.omertron.themoviedbapi.wrapper; package com.omertron.themoviedbapi.wrapper;
import com.fasterxml.jackson.annotation.JsonAnySetter; import com.fasterxml.jackson.annotation.JsonProperty;
import com.omertron.themoviedbapi.model.Translation; import com.omertron.themoviedbapi.model.Translation;
import java.util.List; import java.util.List;
import org.apache.log4j.Logger;
/** /**
* *
* @author Stuart * @author Stuart
*/ */
public class WrapperTranslations { public class WrapperTranslations extends AbstractWrapperId {
/*
* Logger
*/
private static final Logger logger = Logger.getLogger(WrapperTranslations.class); @JsonProperty("translations")
/*
* Properties
*/
private int id;
private List<Translation> translations; private List<Translation> translations;
//<editor-fold defaultstate="collapsed" desc="Setter methods"> public WrapperTranslations() {
public void setId(int id) { super(WrapperTranslations.class);
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("'");
logger.trace(sb.toString());
}
} }
+36 -36
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>
-7
View File
@@ -1,7 +0,0 @@
log4j.rootLogger=DEBUG, CONSOLE
log4j.appender.CONSOLE=org.apache.log4j.ConsoleAppender
log4j.appender.CONSOLE.layout=com.omertron.themoviedbapi.tools.FilteringLayout
#log4j.appender.CONSOLE.layout=org.apache.log4j.PatternLayout
log4j.appender.CONSOLE.layout.ConversionPattern=[TheMovieDB API-%C{1}] %m%n
#log4j.appender.CONSOLE.Threshold=DEBUG
log4j.appender.CONSOLE.Encoding=UTF-8
@@ -0,0 +1,72 @@
/*
* Copyright (c) 2004-2013 Stuart Boston
*
* This file is part of the FanartTV API.
*
* The FanartTV API is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* any later version.
*
* The FanartTV API is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with the FanartTV API. If not, see <http://www.gnu.org/licenses/>.
*
*/
package com.omertron.themoviedbapi;
import java.io.ByteArrayInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.logging.LogManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class TestLogger {
private static final Logger LOG = LoggerFactory.getLogger(TestLogger.class);
private static final String CRLF = "\n";
private TestLogger() {
throw new UnsupportedOperationException("Class can not be instantiated");
}
/**
* Configure the logger with a simple in-memory file for the required log level
*
* @param level The logging level required
* @return True if successful
*/
public static boolean Configure(String level) {
StringBuilder config = new StringBuilder("handlers = java.util.logging.ConsoleHandler\n");
config.append(".level = ").append(level).append(CRLF);
config.append("java.util.logging.ConsoleHandler.level = ").append(level).append(CRLF);
// Only works with Java 7 or later
config.append("java.util.logging.SimpleFormatter.format = [%1$tc %4$s] %2$s - %5$s %6$s%n").append(CRLF);
// Exclude http logging
config.append("sun.net.www.protocol.http.HttpURLConnection.level = OFF").append(CRLF);
InputStream ins = new ByteArrayInputStream(config.toString().getBytes());
try {
LogManager.getLogManager().readConfiguration(ins);
} catch (IOException e) {
LOG.warn("Failed to configure log manager due to an IO problem", e);
return Boolean.FALSE;
}
LOG.debug("Logger initialized to '{}' level", level);
return Boolean.TRUE;
}
/**
* Set the logging level to "ALL"
*
* @return True if successful
*/
public static boolean Configure() {
return Configure("ALL");
}
}
File diff suppressed because it is too large Load Diff