Merge pull request #6 from holgerbrandl/master
"List" and "Account" implemenation
This commit is contained in:
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;
|
||||
}
|
||||
}
|
||||
@@ -19,16 +19,13 @@
|
||||
*/
|
||||
package 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;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Stuart
|
||||
*/
|
||||
public class AlternativeTitle implements Serializable {
|
||||
@@ -67,20 +64,6 @@ public class AlternativeTitle implements Serializable {
|
||||
}
|
||||
// </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 boolean equals(Object obj) {
|
||||
if (obj == null) {
|
||||
@@ -106,9 +89,4 @@ public class AlternativeTitle implements Serializable {
|
||||
hash = 89 * hash + (this.title != null ? this.title.hashCode() : 0);
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,11 +19,7 @@
|
||||
*/
|
||||
package 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;
|
||||
|
||||
@@ -32,7 +28,7 @@ import org.slf4j.LoggerFactory;
|
||||
*
|
||||
* @author Stuart
|
||||
*/
|
||||
public class Artwork implements Serializable {
|
||||
public class Artwork extends AbstractJsonMapping {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@@ -97,7 +93,6 @@ public class Artwork implements Serializable {
|
||||
public String getFlag() {
|
||||
return flag;
|
||||
}
|
||||
|
||||
// </editor-fold>
|
||||
|
||||
// <editor-fold defaultstate="collapsed" desc="Setter methods">
|
||||
@@ -133,26 +128,11 @@ public class Artwork implements Serializable {
|
||||
this.voteCount = voteCount;
|
||||
}
|
||||
|
||||
public void setFlag(String flag) {
|
||||
public void setFlag(String flag) {
|
||||
this.flag = flag;
|
||||
}
|
||||
|
||||
// </editor-fold>
|
||||
|
||||
/**
|
||||
* Handle unknown properties and print a message
|
||||
*
|
||||
* @param key
|
||||
* @param value
|
||||
*/
|
||||
@JsonAnySetter
|
||||
public void handleUnknown(String key, Object value) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("Unknown property: '").append(key);
|
||||
sb.append("' value: '").append(value).append("'");
|
||||
LOG.trace(sb.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null) {
|
||||
@@ -194,9 +174,4 @@ public class Artwork implements Serializable {
|
||||
hash = 71 * hash + (this.artworkType != null ? this.artworkType.hashCode() : 0);
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
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;
|
||||
import com.fasterxml.jackson.annotation.JsonAnyGetter;
|
||||
import com.fasterxml.jackson.annotation.JsonAnySetter;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
public class ChangeKeyItem {
|
||||
|
||||
@@ -44,9 +43,4 @@ public class ChangeKeyItem {
|
||||
public void setNewItems(String name, Object value) {
|
||||
this.newItems.put(name, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,14 +1,13 @@
|
||||
package com.omertron.themoviedbapi.model;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import com.fasterxml.jackson.annotation.JsonAnyGetter;
|
||||
import com.fasterxml.jackson.annotation.JsonAnySetter;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
|
||||
public class ChangedItem {
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class ChangedItem extends AbstractJsonMapping {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
@JsonProperty("id")
|
||||
@@ -72,9 +71,4 @@ public class ChangedItem {
|
||||
public void setNewItems(String name, Object value) {
|
||||
this.newItems.put(name, value);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,28 +19,18 @@
|
||||
*/
|
||||
package com.omertron.themoviedbapi.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAnySetter;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonRootName;
|
||||
import java.io.Serializable;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author stuart.boston
|
||||
*/
|
||||
@JsonRootName("collection")
|
||||
public class Collection implements Serializable {
|
||||
public class Collection extends AbstractJsonMapping {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
/*
|
||||
* Logger
|
||||
*/
|
||||
private static final Logger LOG = LoggerFactory.getLogger(Collection.class);
|
||||
|
||||
/*
|
||||
* Properties
|
||||
*/
|
||||
@@ -87,9 +77,7 @@ public class Collection implements Serializable {
|
||||
}
|
||||
return name;
|
||||
}
|
||||
//</editor-fold>
|
||||
|
||||
//<editor-fold defaultstate="collapsed" desc="Setter methods">
|
||||
public void setBackdropPath(String backdropPath) {
|
||||
this.backdropPath = backdropPath;
|
||||
}
|
||||
@@ -113,21 +101,6 @@ public class Collection implements Serializable {
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
//</editor-fold>
|
||||
|
||||
/**
|
||||
* Handle unknown properties and print a message
|
||||
*
|
||||
* @param key
|
||||
* @param value
|
||||
*/
|
||||
@JsonAnySetter
|
||||
public void handleUnknown(String key, Object value) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("Unknown property: '").append(key);
|
||||
sb.append("' value: '").append(value).append("'");
|
||||
LOG.trace(sb.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
@@ -164,9 +137,4 @@ public class Collection implements Serializable {
|
||||
hash = 19 * hash + (this.releaseDate != null ? this.releaseDate.hashCode() : 0);
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,27 +19,18 @@
|
||||
*/
|
||||
package com.omertron.themoviedbapi.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAnySetter;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import java.io.Serializable;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Stuart
|
||||
*/
|
||||
public class CollectionInfo implements Serializable {
|
||||
public class CollectionInfo extends AbstractJsonMapping {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
/*
|
||||
* Logger
|
||||
*/
|
||||
private static final Logger LOG = LoggerFactory.getLogger(CollectionInfo.class);
|
||||
|
||||
/*
|
||||
* Properties
|
||||
*/
|
||||
@@ -80,9 +71,7 @@ public class CollectionInfo implements Serializable {
|
||||
public String getPosterPath() {
|
||||
return posterPath;
|
||||
}
|
||||
//</editor-fold>
|
||||
|
||||
//<editor-fold defaultstate="collapsed" desc="Setter methods">
|
||||
public void setBackdropPath(String backdropPath) {
|
||||
this.backdropPath = backdropPath;
|
||||
}
|
||||
@@ -106,24 +95,4 @@ public class CollectionInfo implements Serializable {
|
||||
public void setPosterPath(String posterPath) {
|
||||
this.posterPath = posterPath;
|
||||
}
|
||||
//</editor-fold>
|
||||
|
||||
/**
|
||||
* Handle unknown properties and print a message
|
||||
*
|
||||
* @param key
|
||||
* @param value
|
||||
*/
|
||||
@JsonAnySetter
|
||||
public void handleUnknown(String key, Object value) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("Unknown property: '").append(key);
|
||||
sb.append("' value: '").append(value).append("'");
|
||||
LOG.trace(sb.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,24 +19,16 @@
|
||||
*/
|
||||
package 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;
|
||||
|
||||
/**
|
||||
* Company information
|
||||
*
|
||||
* @author Stuart
|
||||
*/
|
||||
public class Company implements Serializable {
|
||||
public class Company extends AbstractJsonMapping {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
// Logger
|
||||
private static final Logger LOG = LoggerFactory.getLogger(Company.class);
|
||||
private static final String DEFAULT_STRING = "";
|
||||
// Properties
|
||||
@JsonProperty("id")
|
||||
@@ -82,9 +74,7 @@ public class Company implements Serializable {
|
||||
public Company getParentCompany() {
|
||||
return parentCompany;
|
||||
}
|
||||
//</editor-fold>
|
||||
|
||||
//<editor-fold defaultstate="collapsed" desc="Setter Methods">
|
||||
public void setCompanyId(int companyId) {
|
||||
this.companyId = companyId;
|
||||
}
|
||||
@@ -120,24 +110,4 @@ public class Company implements Serializable {
|
||||
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("'");
|
||||
LOG.trace(sb.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,14 +19,16 @@
|
||||
*/
|
||||
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.*;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
/**
|
||||
* 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
|
||||
@@ -49,7 +51,7 @@ public class Discover {
|
||||
|
||||
/**
|
||||
* Get the parameters
|
||||
*
|
||||
* <p/>
|
||||
* This will be used to construct the URL in the API
|
||||
*
|
||||
* @return
|
||||
@@ -160,11 +162,11 @@ public class Discover {
|
||||
|
||||
/**
|
||||
* 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
|
||||
@@ -178,7 +180,7 @@ public class Discover {
|
||||
|
||||
/**
|
||||
* The minimum release to include.
|
||||
*
|
||||
* <p/>
|
||||
* Expected format is YYYY-MM-DD.
|
||||
*
|
||||
* @param releaseDateGte
|
||||
@@ -192,7 +194,7 @@ public class Discover {
|
||||
|
||||
/**
|
||||
* The maximum release to include.
|
||||
*
|
||||
* <p/>
|
||||
* Expected format is YYYY-MM-DD.
|
||||
*
|
||||
* @param releaseDateLte
|
||||
@@ -206,9 +208,9 @@ public class Discover {
|
||||
|
||||
/**
|
||||
* 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
|
||||
@@ -222,7 +224,7 @@ public class Discover {
|
||||
|
||||
/**
|
||||
* Only include movies with this certification and lower.
|
||||
*
|
||||
* <p/>
|
||||
* Expected value is a valid certification for the specified 'certificationCountry'.
|
||||
*
|
||||
* @param certificationLte
|
||||
@@ -236,9 +238,9 @@ public class Discover {
|
||||
|
||||
/**
|
||||
* 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
|
||||
|
||||
@@ -19,27 +19,16 @@
|
||||
*/
|
||||
package com.omertron.themoviedbapi.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAnySetter;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonRootName;
|
||||
import java.io.Serializable;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author stuart.boston
|
||||
*/
|
||||
@JsonRootName("genre")
|
||||
public class Genre implements Serializable {
|
||||
public class Genre extends AbstractJsonMapping {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
/*
|
||||
* Logger
|
||||
*/
|
||||
private static final Logger LOG = LoggerFactory.getLogger(Genre.class);
|
||||
/*
|
||||
* Properties
|
||||
*/
|
||||
@@ -56,9 +45,7 @@ public class Genre implements Serializable {
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
//</editor-fold>
|
||||
|
||||
//<editor-fold defaultstate="collapsed" desc="Setter methods">
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
@@ -66,21 +53,6 @@ public class Genre implements Serializable {
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
//</editor-fold>
|
||||
|
||||
/**
|
||||
* Handle unknown properties and print a message
|
||||
*
|
||||
* @param key
|
||||
* @param value
|
||||
*/
|
||||
@JsonAnySetter
|
||||
public void handleUnknown(String key, Object value) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("Unknown property: '").append(key);
|
||||
sb.append("' value: '").append(value).append("'");
|
||||
LOG.trace(sb.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
@@ -107,9 +79,4 @@ public class Genre implements Serializable {
|
||||
hash = 53 * hash + (this.name != null ? this.name.hashCode() : 0);
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,19 +19,13 @@
|
||||
*/
|
||||
package com.omertron.themoviedbapi.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAnySetter;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import java.util.List;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class JobDepartment {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
// Logger
|
||||
private static final Logger LOG = LoggerFactory.getLogger(JobDepartment.class);
|
||||
// Properties
|
||||
@JsonProperty("department")
|
||||
private String department;
|
||||
@@ -46,7 +40,6 @@ public class JobDepartment {
|
||||
public List<String> getJobs() {
|
||||
return jobs;
|
||||
}
|
||||
//</editor-fold>
|
||||
|
||||
//<editor-fold defaultstate="collapsed" desc="Setters">
|
||||
public void setDepartment(String department) {
|
||||
@@ -56,24 +49,4 @@ public class JobDepartment {
|
||||
public void setJobs(List<String> jobs) {
|
||||
this.jobs = jobs;
|
||||
}
|
||||
//</editor-fold>
|
||||
|
||||
/**
|
||||
* Handle unknown properties and print a message
|
||||
*
|
||||
* @param key
|
||||
* @param value
|
||||
*/
|
||||
@JsonAnySetter
|
||||
public void handleUnknown(String key, Object value) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("Unknown property: '").append(key);
|
||||
sb.append("' value: '").append(value).append("'");
|
||||
LOG.trace(sb.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,28 +19,17 @@
|
||||
*/
|
||||
package com.omertron.themoviedbapi.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAnySetter;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonRootName;
|
||||
import java.io.Serializable;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author stuart.boston
|
||||
*/
|
||||
@JsonRootName("keyword")
|
||||
public class Keyword implements Serializable {
|
||||
public class Keyword extends AbstractJsonMapping {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/*
|
||||
* Logger
|
||||
*/
|
||||
private static final Logger LOG = LoggerFactory.getLogger(Keyword.class);
|
||||
/*
|
||||
* Properties
|
||||
*/
|
||||
@@ -57,9 +46,7 @@ public class Keyword implements Serializable {
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
//</editor-fold>
|
||||
|
||||
//<editor-fold defaultstate="collapsed" desc="Setter methods">
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
@@ -67,21 +54,6 @@ public class Keyword implements Serializable {
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
//</editor-fold>
|
||||
|
||||
/**
|
||||
* Handle unknown properties and print a message
|
||||
*
|
||||
* @param key
|
||||
* @param value
|
||||
*/
|
||||
@JsonAnySetter
|
||||
public void handleUnknown(String key, Object value) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("Unknown property: '").append(key);
|
||||
sb.append("' value: '").append(value).append("'");
|
||||
LOG.trace(sb.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
@@ -108,9 +80,4 @@ public class Keyword implements Serializable {
|
||||
hash = 83 * hash + (this.name != null ? this.name.hashCode() : 0);
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,26 +19,15 @@
|
||||
*/
|
||||
package 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 KeywordMovie implements Serializable {
|
||||
public class KeywordMovie extends AbstractJsonMapping {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/*
|
||||
* Logger
|
||||
*/
|
||||
private static final Logger LOG = LoggerFactory.getLogger(KeywordMovie.class);
|
||||
/*
|
||||
* Properties
|
||||
*/
|
||||
@@ -150,23 +139,4 @@ public class KeywordMovie implements Serializable {
|
||||
this.popularity = popularity;
|
||||
}
|
||||
// </editor-fold>
|
||||
|
||||
/**
|
||||
* Handle unknown properties and print a message
|
||||
*
|
||||
* @param key
|
||||
* @param value
|
||||
*/
|
||||
@JsonAnySetter
|
||||
public void handleUnknown(String key, Object value) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("Unknown property: '").append(key);
|
||||
sb.append("' value: '").append(value).append("'");
|
||||
LOG.trace(sb.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,27 +19,16 @@
|
||||
*/
|
||||
package com.omertron.themoviedbapi.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAnySetter;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonRootName;
|
||||
import java.io.Serializable;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author stuart.boston
|
||||
*/
|
||||
@JsonRootName("spoken_language")
|
||||
public class Language implements Serializable {
|
||||
public class Language extends AbstractJsonMapping {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
/*
|
||||
* Logger
|
||||
*/
|
||||
private static final Logger LOG = LoggerFactory.getLogger(Language.class);
|
||||
/*
|
||||
* Properties
|
||||
*/
|
||||
@@ -56,9 +45,7 @@ public class Language implements Serializable {
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
//</editor-fold>
|
||||
|
||||
//<editor-fold defaultstate="collapsed" desc="Setter methods">
|
||||
public void setIsoCode(String isoCode) {
|
||||
this.isoCode = isoCode;
|
||||
}
|
||||
@@ -66,21 +53,6 @@ public class Language implements Serializable {
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
//</editor-fold>
|
||||
|
||||
/**
|
||||
* Handle unknown properties and print a message
|
||||
*
|
||||
* @param key
|
||||
* @param value
|
||||
*/
|
||||
@JsonAnySetter
|
||||
public void handleUnknown(String key, Object value) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("Unknown property: '").append(key);
|
||||
sb.append("' value: '").append(value).append("'");
|
||||
LOG.trace(sb.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
@@ -107,9 +79,4 @@ public class Language implements Serializable {
|
||||
hash = 71 * hash + (this.name != null ? this.name.hashCode() : 0);
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
/*
|
||||
* Copyright (c) 2004-2013 Stuart Boston
|
||||
*
|
||||
* This file is part of TheMovieDB API.
|
||||
*
|
||||
* TheMovieDB API is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* TheMovieDB API is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
package com.omertron.themoviedbapi.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
/**
|
||||
* @author Holger Brandl
|
||||
*/
|
||||
public class ListItemStatus extends AbstractJsonMapping {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@JsonProperty("status_code")
|
||||
private int statusCode;
|
||||
@JsonProperty("item_present")
|
||||
private boolean itemPresent;
|
||||
|
||||
public int getStatusCode() {
|
||||
return statusCode;
|
||||
}
|
||||
|
||||
public void setStatusCode(int statusCode) {
|
||||
this.statusCode = statusCode;
|
||||
}
|
||||
|
||||
public boolean isItemPresent() {
|
||||
return itemPresent;
|
||||
}
|
||||
|
||||
public void setItemPresent(boolean itemPresent) {
|
||||
this.itemPresent = itemPresent;
|
||||
}
|
||||
}
|
||||
@@ -19,37 +19,19 @@
|
||||
*/
|
||||
package com.omertron.themoviedbapi.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAnySetter;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.omertron.themoviedbapi.wrapper.WrapperAlternativeTitles;
|
||||
import com.omertron.themoviedbapi.wrapper.WrapperImages;
|
||||
import com.omertron.themoviedbapi.wrapper.WrapperMovie;
|
||||
import com.omertron.themoviedbapi.wrapper.WrapperMovieCasts;
|
||||
import com.omertron.themoviedbapi.wrapper.WrapperMovieKeywords;
|
||||
import com.omertron.themoviedbapi.wrapper.WrapperMovieList;
|
||||
import com.omertron.themoviedbapi.wrapper.WrapperReleaseInfo;
|
||||
import com.omertron.themoviedbapi.wrapper.WrapperReviews;
|
||||
import com.omertron.themoviedbapi.wrapper.WrapperTrailers;
|
||||
import com.omertron.themoviedbapi.wrapper.WrapperTranslations;
|
||||
import java.io.Serializable;
|
||||
import com.omertron.themoviedbapi.wrapper.*;
|
||||
|
||||
import java.util.List;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Movie Bean
|
||||
*
|
||||
* @author stuart.boston
|
||||
*/
|
||||
public class MovieDb implements Serializable {
|
||||
public class MovieDb extends AbstractJsonMapping {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
/*
|
||||
* Logger
|
||||
*/
|
||||
private static final Logger LOG = LoggerFactory.getLogger(MovieDb.class);
|
||||
/*
|
||||
* Properties
|
||||
*/
|
||||
@@ -93,6 +75,8 @@ public class MovieDb implements Serializable {
|
||||
private List<Language> spokenLanguages;
|
||||
@JsonProperty("tagline")
|
||||
private String tagline;
|
||||
@JsonProperty("rating")
|
||||
private float userRating;
|
||||
@JsonProperty("vote_average")
|
||||
private float voteAverage;
|
||||
@JsonProperty("vote_count")
|
||||
@@ -309,7 +293,6 @@ public class MovieDb implements Serializable {
|
||||
}
|
||||
|
||||
// </editor-fold>
|
||||
|
||||
//<editor-fold defaultstate="collapsed" desc="AppendToResponse Getters">
|
||||
public List<AlternativeTitle> getAlternativeTitles() {
|
||||
return alternativeTitles.getTitles();
|
||||
@@ -354,7 +337,6 @@ public class MovieDb implements Serializable {
|
||||
public List<Reviews> getReviews() {
|
||||
return reviews.getReviews();
|
||||
}
|
||||
//</editor-fold>
|
||||
|
||||
//<editor-fold defaultstate="collapsed" desc="AppendToResponse Setters">
|
||||
public void setAlternativeTitles(WrapperAlternativeTitles alternativeTitles) {
|
||||
@@ -397,22 +379,6 @@ public class MovieDb implements Serializable {
|
||||
this.reviews = reviews;
|
||||
}
|
||||
|
||||
//</editor-fold>
|
||||
|
||||
/**
|
||||
* Handle unknown properties and print a message
|
||||
*
|
||||
* @param key
|
||||
* @param value
|
||||
*/
|
||||
@JsonAnySetter
|
||||
public void handleUnknown(String key, Object value) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("Unknown property: '").append(key);
|
||||
sb.append("' value: '").append(value).append("'");
|
||||
LOG.trace(sb.toString());
|
||||
}
|
||||
|
||||
//<editor-fold defaultstate="collapsed" desc="Equals and HashCode">
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
@@ -443,10 +409,12 @@ public class MovieDb implements Serializable {
|
||||
hash = 89 * hash + this.runtime;
|
||||
return hash;
|
||||
}
|
||||
//</editor-fold>
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
|
||||
public float getUserRating() {
|
||||
return userRating;
|
||||
}
|
||||
|
||||
public void setUserRating(float userRating) {
|
||||
this.userRating = userRating;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,14 +19,10 @@
|
||||
*/
|
||||
package com.omertron.themoviedbapi.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAnySetter;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Wrapper for the MovieDbList function
|
||||
@@ -34,11 +30,7 @@ import org.slf4j.LoggerFactory;
|
||||
* @author stuart.boston
|
||||
*/
|
||||
public class MovieDbList {
|
||||
/*
|
||||
* Logger
|
||||
*/
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(MovieDbList.class);
|
||||
/*
|
||||
* Properties
|
||||
*/
|
||||
@@ -97,9 +89,7 @@ public class MovieDbList {
|
||||
public String getPosterPath() {
|
||||
return posterPath;
|
||||
}
|
||||
//</editor-fold>
|
||||
|
||||
//<editor-fold defaultstate="collapsed" desc="Setter Methods">
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
@@ -135,24 +125,4 @@ public class MovieDbList {
|
||||
public void setPosterPath(String posterPath) {
|
||||
this.posterPath = posterPath;
|
||||
}
|
||||
//</editor-fold>
|
||||
|
||||
/**
|
||||
* Handle unknown properties and print a message
|
||||
*
|
||||
* @param key
|
||||
* @param value
|
||||
*/
|
||||
@JsonAnySetter
|
||||
public void handleUnknown(String key, Object value) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("Unknown property: '").append(key);
|
||||
sb.append("' value: '").append(value).append("'");
|
||||
LOG.trace(sb.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,36 @@
|
||||
/*
|
||||
* Copyright (c) 2004-2013 Stuart Boston
|
||||
*
|
||||
* This file is part of TheMovieDB API.
|
||||
*
|
||||
* TheMovieDB API is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation;private either version 3 of the License;private or
|
||||
* any later version.
|
||||
*
|
||||
* TheMovieDB API is distributed in the hope that it will be useful;private
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with TheMovieDB API. If not;private see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
package com.omertron.themoviedbapi.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
|
||||
public class MovieDbListStatus extends StatusCode {
|
||||
|
||||
@JsonProperty("list_id")
|
||||
private String listId;
|
||||
|
||||
public String getListId() {
|
||||
return listId;
|
||||
}
|
||||
|
||||
public void setListId(String listId) {
|
||||
this.listId = listId;
|
||||
}
|
||||
}
|
||||
@@ -19,26 +19,15 @@
|
||||
*/
|
||||
package com.omertron.themoviedbapi.model;
|
||||
|
||||
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 MovieList implements Serializable {
|
||||
public class MovieList extends AbstractJsonMapping {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/*
|
||||
* Logger
|
||||
*/
|
||||
private static final Logger LOG = LoggerFactory.getLogger(MovieList.class);
|
||||
/*
|
||||
* Properties
|
||||
*/
|
||||
@@ -126,23 +115,4 @@ public class MovieList implements Serializable {
|
||||
this.listType = listType;
|
||||
}
|
||||
// </editor-fold>
|
||||
|
||||
/**
|
||||
* Handle unknown properties and print a message
|
||||
*
|
||||
* @param key
|
||||
* @param value
|
||||
*/
|
||||
@JsonAnySetter
|
||||
public void handleUnknown(String key, Object value) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("Unknown property: '").append(key);
|
||||
sb.append("' value: '").append(value).append("'");
|
||||
LOG.trace(sb.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,30 +19,19 @@
|
||||
*/
|
||||
package 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.StringUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author stuart.boston
|
||||
*/
|
||||
public class Person implements Serializable {
|
||||
public class Person extends AbstractJsonMapping {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/*
|
||||
* Logger
|
||||
*/
|
||||
private static final Logger LOG = LoggerFactory.getLogger(Person.class);
|
||||
|
||||
/*
|
||||
* Static fields for default cast information
|
||||
*/
|
||||
@@ -262,20 +251,6 @@ public class Person implements Serializable {
|
||||
}
|
||||
// </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 boolean equals(Object obj) {
|
||||
if (obj == null) {
|
||||
@@ -321,9 +296,4 @@ public class Person implements Serializable {
|
||||
hash = 37 * hash + (this.character != null ? this.character.hashCode() : 0);
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,27 +19,16 @@
|
||||
*/
|
||||
package 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.StringUtils;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Stuart
|
||||
*/
|
||||
public class PersonCast implements Serializable {
|
||||
public class PersonCast extends AbstractJsonMapping {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/*
|
||||
* Logger
|
||||
*/
|
||||
private static final Logger LOG = LoggerFactory.getLogger(PersonCast.class);
|
||||
/*
|
||||
* Properties
|
||||
*/
|
||||
@@ -81,9 +70,6 @@ public class PersonCast implements Serializable {
|
||||
return castId;
|
||||
}
|
||||
|
||||
//</editor-fold>
|
||||
|
||||
//<editor-fold defaultstate="collapsed" desc="Setter methods">
|
||||
public void setCharacter(String character) {
|
||||
this.character = StringUtils.trimToEmpty(character);
|
||||
}
|
||||
@@ -108,22 +94,6 @@ public class PersonCast implements Serializable {
|
||||
this.castId = castId;
|
||||
}
|
||||
|
||||
//</editor-fold>
|
||||
|
||||
/**
|
||||
* Handle unknown properties and print a message
|
||||
*
|
||||
* @param key
|
||||
* @param value
|
||||
*/
|
||||
@JsonAnySetter
|
||||
public void handleUnknown(String key, Object value) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("Unknown property: '").append(key);
|
||||
sb.append("' value: '").append(value).append("'");
|
||||
LOG.trace(sb.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
if (obj == null) {
|
||||
@@ -161,9 +131,4 @@ public class PersonCast implements Serializable {
|
||||
hash = 41 * hash + (this.profilePath != null ? this.profilePath.hashCode() : 0);
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,27 +19,15 @@
|
||||
*/
|
||||
package 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.StringUtils;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author stuart.boston
|
||||
*/
|
||||
public class PersonCredit implements Serializable {
|
||||
public class PersonCredit extends AbstractJsonMapping {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/*
|
||||
* Logger
|
||||
*/
|
||||
private static final Logger LOG = LoggerFactory.getLogger(PersonCredit.class);
|
||||
private static final String DEFAULT_STRING = "";
|
||||
/*
|
||||
* Properties
|
||||
@@ -104,9 +92,7 @@ public class PersonCredit implements Serializable {
|
||||
public String getAdult() {
|
||||
return adult;
|
||||
}
|
||||
//</editor-fold>
|
||||
|
||||
//<editor-fold defaultstate="collapsed" desc="Setter Methods">
|
||||
public void setCharacter(String character) {
|
||||
this.character = StringUtils.trimToEmpty(character);
|
||||
}
|
||||
@@ -146,24 +132,4 @@ public class PersonCredit implements Serializable {
|
||||
public void setAdult(String adult) {
|
||||
this.adult = StringUtils.trimToEmpty(adult);
|
||||
}
|
||||
//</editor-fold>
|
||||
|
||||
/**
|
||||
* Handle unknown properties and print a message
|
||||
*
|
||||
* @param key
|
||||
* @param value
|
||||
*/
|
||||
@JsonAnySetter
|
||||
public void handleUnknown(String key, Object value) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("Unknown property: '").append(key);
|
||||
sb.append("' value: '").append(value).append("'");
|
||||
LOG.trace(sb.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,27 +19,16 @@
|
||||
*/
|
||||
package 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.StringUtils;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Stuart
|
||||
*/
|
||||
public class PersonCrew implements Serializable {
|
||||
public class PersonCrew extends AbstractJsonMapping {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/*
|
||||
* Logger
|
||||
*/
|
||||
private static final Logger LOG = LoggerFactory.getLogger(PersonCrew.class);
|
||||
/*
|
||||
* Properties
|
||||
*/
|
||||
@@ -74,9 +63,7 @@ public class PersonCrew implements Serializable {
|
||||
public String getProfilePath() {
|
||||
return profilePath;
|
||||
}
|
||||
//</editor-fold>
|
||||
|
||||
//<editor-fold defaultstate="collapsed" desc="Setter methods">
|
||||
public void setDepartment(String department) {
|
||||
this.department = StringUtils.trimToEmpty(department);
|
||||
}
|
||||
@@ -96,21 +83,6 @@ public class PersonCrew implements Serializable {
|
||||
public void setProfilePath(String profilePath) {
|
||||
this.profilePath = StringUtils.trimToEmpty(profilePath);
|
||||
}
|
||||
//</editor-fold>
|
||||
|
||||
/**
|
||||
* Handle unknown properties and print a message
|
||||
*
|
||||
* @param key
|
||||
* @param value
|
||||
*/
|
||||
@JsonAnySetter
|
||||
public void handleUnknown(String key, Object value) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("Unknown property: '").append(key);
|
||||
sb.append("' value: '").append(value).append("'");
|
||||
LOG.trace(sb.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
@@ -146,9 +118,4 @@ public class PersonCrew implements Serializable {
|
||||
hash = 59 * hash + (this.profilePath != null ? this.profilePath.hashCode() : 0);
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,12 +20,11 @@
|
||||
package com.omertron.themoviedbapi.model;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author stuart.boston
|
||||
*/
|
||||
public enum PersonType {
|
||||
|
||||
CAST, // A member of the cast
|
||||
CREW, // A member of the crew
|
||||
CAST, // A member of the cast
|
||||
CREW, // A member of the crew
|
||||
PERSON // No specific type
|
||||
}
|
||||
|
||||
@@ -19,28 +19,17 @@
|
||||
*/
|
||||
package com.omertron.themoviedbapi.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAnySetter;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonRootName;
|
||||
import java.io.Serializable;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author stuart.boston
|
||||
*/
|
||||
@JsonRootName("production_company")
|
||||
public class ProductionCompany implements Serializable {
|
||||
public class ProductionCompany extends AbstractJsonMapping {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/*
|
||||
* Logger
|
||||
*/
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ProductionCompany.class);
|
||||
/*
|
||||
* Properties
|
||||
*/
|
||||
@@ -57,9 +46,7 @@ public class ProductionCompany implements Serializable {
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
//</editor-fold>
|
||||
|
||||
//<editor-fold defaultstate="collapsed" desc="Setter methods">
|
||||
public void setId(int id) {
|
||||
this.id = id;
|
||||
}
|
||||
@@ -67,21 +54,6 @@ public class ProductionCompany implements Serializable {
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
//</editor-fold>
|
||||
|
||||
/**
|
||||
* Handle unknown properties and print a message
|
||||
*
|
||||
* @param key
|
||||
* @param value
|
||||
*/
|
||||
@JsonAnySetter
|
||||
public void handleUnknown(String key, Object value) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("Unknown property: '").append(key);
|
||||
sb.append("' value: '").append(value).append("'");
|
||||
LOG.trace(sb.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
@@ -108,9 +80,4 @@ public class ProductionCompany implements Serializable {
|
||||
hash = 37 * hash + (this.name != null ? this.name.hashCode() : 0);
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,28 +19,17 @@
|
||||
*/
|
||||
package com.omertron.themoviedbapi.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAnySetter;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.annotation.JsonRootName;
|
||||
import java.io.Serializable;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author stuart.boston
|
||||
*/
|
||||
@JsonRootName("production_country")
|
||||
public class ProductionCountry implements Serializable {
|
||||
public class ProductionCountry extends AbstractJsonMapping {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/*
|
||||
* Logger
|
||||
*/
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ProductionCountry.class);
|
||||
/*
|
||||
* Properties
|
||||
*/
|
||||
@@ -57,9 +46,7 @@ public class ProductionCountry implements Serializable {
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
//</editor-fold>
|
||||
|
||||
//<editor-fold defaultstate="collapsed" desc="Setter methods">
|
||||
public void setIsoCode(String isoCode) {
|
||||
this.isoCode = isoCode;
|
||||
}
|
||||
@@ -67,21 +54,6 @@ public class ProductionCountry implements Serializable {
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
//</editor-fold>
|
||||
|
||||
/**
|
||||
* Handle unknown properties and print a message
|
||||
*
|
||||
* @param key
|
||||
* @param value
|
||||
*/
|
||||
@JsonAnySetter
|
||||
public void handleUnknown(String key, Object value) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("Unknown property: '").append(key);
|
||||
sb.append("' value: '").append(value).append("'");
|
||||
LOG.trace(sb.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
@@ -108,9 +80,4 @@ public class ProductionCountry implements Serializable {
|
||||
hash = 47 * hash + (this.name != null ? this.name.hashCode() : 0);
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,26 +19,15 @@
|
||||
*/
|
||||
package 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 ReleaseInfo implements Serializable {
|
||||
public class ReleaseInfo extends AbstractJsonMapping {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/*
|
||||
* Logger
|
||||
*/
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ReleaseInfo.class);
|
||||
/*
|
||||
* Properties
|
||||
*/
|
||||
@@ -61,9 +50,7 @@ public class ReleaseInfo implements Serializable {
|
||||
public String getReleaseDate() {
|
||||
return releaseDate;
|
||||
}
|
||||
//</editor-fold>
|
||||
|
||||
//<editor-fold defaultstate="collapsed" desc="Setter methods">
|
||||
public void setCertification(String certification) {
|
||||
this.certification = certification;
|
||||
}
|
||||
@@ -75,21 +62,6 @@ public class ReleaseInfo implements Serializable {
|
||||
public void setReleaseDate(String releaseDate) {
|
||||
this.releaseDate = releaseDate;
|
||||
}
|
||||
//</editor-fold>
|
||||
|
||||
/**
|
||||
* Handle unknown properties and print a message
|
||||
*
|
||||
* @param key
|
||||
* @param value
|
||||
*/
|
||||
@JsonAnySetter
|
||||
public void handleUnknown(String key, Object value) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("Unknown property: '").append(key);
|
||||
sb.append("' value: '").append(value).append("'");
|
||||
LOG.trace(sb.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
@@ -120,9 +92,4 @@ public class ReleaseInfo implements Serializable {
|
||||
hash = 89 * hash + (this.releaseDate != null ? this.releaseDate.hashCode() : 0);
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,26 +19,15 @@
|
||||
*/
|
||||
package 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 Reviews implements Serializable {
|
||||
public class Reviews extends AbstractJsonMapping {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/*
|
||||
* Logger
|
||||
*/
|
||||
private static final Logger LOG = LoggerFactory.getLogger(Reviews.class);
|
||||
/*
|
||||
* Properties
|
||||
*/
|
||||
@@ -86,23 +75,4 @@ public class Reviews implements Serializable {
|
||||
this.url = url;
|
||||
}
|
||||
// </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.SHORT_PREFIX_STYLE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,26 +19,15 @@
|
||||
*/
|
||||
package 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 StatusCode implements Serializable {
|
||||
public class StatusCode extends AbstractJsonMapping {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/*
|
||||
* Logger
|
||||
*/
|
||||
private static final Logger LOG = LoggerFactory.getLogger(StatusCode.class);
|
||||
/*
|
||||
* Properties
|
||||
*/
|
||||
@@ -55,9 +44,7 @@ public class StatusCode implements Serializable {
|
||||
public void setStatusCode(int statusCode) {
|
||||
this.statusCode = statusCode;
|
||||
}
|
||||
//</editor-fold>
|
||||
|
||||
//<editor-fold defaultstate="collapsed" desc="Setter methods">
|
||||
public String getStatusMessage() {
|
||||
return statusMessage;
|
||||
}
|
||||
@@ -65,24 +52,4 @@ public class StatusCode implements Serializable {
|
||||
public void setStatusMessage(String statusMessage) {
|
||||
this.statusMessage = statusMessage;
|
||||
}
|
||||
//</editor-fold>
|
||||
|
||||
/**
|
||||
* Handle unknown properties and print a message
|
||||
*
|
||||
* @param key
|
||||
* @param value
|
||||
*/
|
||||
@JsonAnySetter
|
||||
public void handleUnknown(String key, Object value) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("Unknown property: '").append(key);
|
||||
sb.append("' value: '").append(value).append("'");
|
||||
LOG.trace(sb.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,27 +19,17 @@
|
||||
*/
|
||||
package com.omertron.themoviedbapi.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAnySetter;
|
||||
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.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author stuart.boston
|
||||
*/
|
||||
public class TmdbConfiguration implements Serializable {
|
||||
public class TmdbConfiguration extends AbstractJsonMapping {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
/*
|
||||
* Logger
|
||||
*/
|
||||
private static final Logger LOG = LoggerFactory.getLogger(TmdbConfiguration.class);
|
||||
/*
|
||||
* Properties
|
||||
*/
|
||||
@@ -180,23 +170,4 @@ public class TmdbConfiguration implements Serializable {
|
||||
|| isValidProfileSize(sizeToCheck)
|
||||
|| isValidLogoSize(sizeToCheck));
|
||||
}
|
||||
|
||||
/**
|
||||
* Handle unknown properties and print a message
|
||||
*
|
||||
* @param key
|
||||
* @param value
|
||||
*/
|
||||
@JsonAnySetter
|
||||
public void handleUnknown(String key, Object value) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("Unknown property: '").append(key);
|
||||
sb.append("' value: '").append(value).append("'");
|
||||
LOG.trace(sb.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,18 +19,10 @@
|
||||
*/
|
||||
package com.omertron.themoviedbapi.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAnySetter;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class TokenAuthorisation {
|
||||
/*
|
||||
* Logger
|
||||
*/
|
||||
private static final Logger LOG = LoggerFactory.getLogger(TokenAuthorisation.class);
|
||||
|
||||
/*
|
||||
* Properties
|
||||
*/
|
||||
@@ -68,24 +60,4 @@ public class TokenAuthorisation {
|
||||
this.success = success;
|
||||
}
|
||||
// </editor-fold>
|
||||
|
||||
/**
|
||||
* Handle unknown properties and print a message
|
||||
*
|
||||
* @param key
|
||||
* @param value
|
||||
*/
|
||||
@JsonAnySetter
|
||||
public void handleUnknown(String key, Object value) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("Unknown property: '").append(key);
|
||||
sb.append("' value: '").append(value).append("'");
|
||||
LOG.trace(sb.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -19,19 +19,10 @@
|
||||
*/
|
||||
package com.omertron.themoviedbapi.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAnySetter;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
public class TokenSession {
|
||||
/*
|
||||
* Logger
|
||||
*/
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(TokenSession.class);
|
||||
/*
|
||||
* Properties
|
||||
*/
|
||||
@@ -98,25 +89,5 @@ public class TokenSession {
|
||||
public void setExpiresAt(String expiresAt) {
|
||||
this.expiresAt = expiresAt;
|
||||
}
|
||||
|
||||
// </editor-fold>
|
||||
|
||||
/**
|
||||
* Handle unknown properties and print a message
|
||||
*
|
||||
* @param key
|
||||
* @param value
|
||||
*/
|
||||
@JsonAnySetter
|
||||
public void handleUnknown(String key, Object value) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("Unknown property: '").append(key);
|
||||
sb.append("' value: '").append(value).append("'");
|
||||
LOG.trace(sb.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,25 +19,13 @@
|
||||
*/
|
||||
package com.omertron.themoviedbapi.model;
|
||||
|
||||
import com.fasterxml.jackson.annotation.JsonAnySetter;
|
||||
import java.io.Serializable;
|
||||
import org.apache.commons.lang3.builder.ToStringBuilder;
|
||||
import org.apache.commons.lang3.builder.ToStringStyle;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Stuart
|
||||
*/
|
||||
public class Trailer implements Serializable {
|
||||
public class Trailer extends AbstractJsonMapping {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/*
|
||||
* Logger
|
||||
*/
|
||||
private static final Logger LOG = LoggerFactory.getLogger(Trailer.class);
|
||||
/*
|
||||
* Website sources
|
||||
*/
|
||||
@@ -67,9 +55,7 @@ public class Trailer implements Serializable {
|
||||
public String getWebsite() {
|
||||
return website;
|
||||
}
|
||||
//</editor-fold>
|
||||
|
||||
//<editor-fold defaultstate="collapsed" desc="Setter methods">
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
@@ -85,21 +71,6 @@ public class Trailer implements Serializable {
|
||||
public void setWebsite(String website) {
|
||||
this.website = website;
|
||||
}
|
||||
//</editor-fold>
|
||||
|
||||
/**
|
||||
* Handle unknown properties and print a message
|
||||
*
|
||||
* @param key
|
||||
* @param value
|
||||
*/
|
||||
@JsonAnySetter
|
||||
public void handleUnknown(String key, Object value) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("Unknown property: '").append(key);
|
||||
sb.append("' value: '").append(value).append("'");
|
||||
LOG.trace(sb.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
@@ -131,9 +102,4 @@ public class Trailer implements Serializable {
|
||||
hash = 61 * hash + (this.website != null ? this.website.hashCode() : 0);
|
||||
return hash;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,26 +19,17 @@
|
||||
*/
|
||||
package 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 Translation implements Serializable {
|
||||
public class Translation extends AbstractJsonMapping {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/*
|
||||
* Logger
|
||||
*/
|
||||
private static final Logger LOG = LoggerFactory.getLogger(Translation.class);
|
||||
/*
|
||||
* Properties
|
||||
*/
|
||||
@@ -61,9 +52,7 @@ public class Translation implements Serializable {
|
||||
public String getName() {
|
||||
return name;
|
||||
}
|
||||
//</editor-fold>
|
||||
|
||||
//<editor-fold defaultstate="collapsed" desc="Setter methods">
|
||||
public void setEnglishName(String englishName) {
|
||||
this.englishName = englishName;
|
||||
}
|
||||
@@ -75,21 +64,6 @@ public class Translation implements Serializable {
|
||||
public void setName(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
//</editor-fold>
|
||||
|
||||
/**
|
||||
* Handle unknown properties and print a message
|
||||
*
|
||||
* @param key
|
||||
* @param value
|
||||
*/
|
||||
@JsonAnySetter
|
||||
public void handleUnknown(String key, Object value) {
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("Unknown property: '").append(key);
|
||||
sb.append("' value: '").append(value).append("'");
|
||||
LOG.trace(sb.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object obj) {
|
||||
@@ -123,6 +97,6 @@ public class Translation implements Serializable {
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return ToStringBuilder.reflectionToString(this, ToStringStyle.SHORT_PREFIX_STYLE);
|
||||
}
|
||||
return ToStringBuilder.reflectionToString(this, ToStringStyle.SIMPLE_STYLE);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,305 +1,336 @@
|
||||
/*
|
||||
* Copyright (c) 2004-2013 Stuart Boston
|
||||
*
|
||||
* This file is part of TheMovieDB API.
|
||||
*
|
||||
* TheMovieDB API is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* TheMovieDB API is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
package com.omertron.themoviedbapi.tools;
|
||||
|
||||
import com.omertron.themoviedbapi.MovieDbException;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.UnsupportedCharsetException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* Web browser with simple cookies support
|
||||
*/
|
||||
public final class WebBrowser {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(WebBrowser.class);
|
||||
private static Map<String, String> browserProperties = new HashMap<String, String>();
|
||||
private static Map<String, Map<String, String>> cookies = new HashMap<String, Map<String, String>>();
|
||||
private static String proxyHost = null;
|
||||
private static String proxyPort = null;
|
||||
private static String proxyUsername = null;
|
||||
private static String proxyPassword = null;
|
||||
private static String proxyEncodedPassword = null;
|
||||
private static int webTimeoutConnect = 25000; // 25 second timeout
|
||||
private static int webTimeoutRead = 90000; // 90 second timeout
|
||||
|
||||
// Hide the constructor
|
||||
protected WebBrowser() {
|
||||
// prevents calls from subclass
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/**
|
||||
* Populate the browser properties
|
||||
*/
|
||||
private static void populateBrowserProperties() {
|
||||
if (browserProperties.isEmpty()) {
|
||||
browserProperties.put("User-Agent", "Mozilla/5.25 Netscape/5.0 (Windows; I; Win95)");
|
||||
browserProperties.put("Accept", "application/json");
|
||||
browserProperties.put("Content-type", "application/json");
|
||||
}
|
||||
}
|
||||
|
||||
public static String request(String url) throws MovieDbException {
|
||||
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");
|
||||
System.getProperties().put("proxyHost", proxyHost);
|
||||
System.getProperties().put("proxyPort", proxyPort);
|
||||
}
|
||||
|
||||
URLConnection cnx = url.openConnection();
|
||||
|
||||
if (proxyUsername != null) {
|
||||
cnx.setRequestProperty("Proxy-Authorization", proxyEncodedPassword);
|
||||
}
|
||||
|
||||
return cnx;
|
||||
} catch (IOException ex) {
|
||||
throw new MovieDbException(MovieDbException.MovieDbExceptionType.INVALID_URL, null, ex);
|
||||
}
|
||||
}
|
||||
|
||||
public static String request(URL url) throws MovieDbException {
|
||||
return request(url, null);
|
||||
}
|
||||
|
||||
public static String request(URL url, String jsonBody) throws MovieDbException {
|
||||
StringWriter content = null;
|
||||
|
||||
try {
|
||||
content = new StringWriter();
|
||||
|
||||
BufferedReader in = null;
|
||||
URLConnection cnx = null;
|
||||
OutputStreamWriter wr = null;
|
||||
try {
|
||||
cnx = openProxiedConnection(url);
|
||||
|
||||
sendHeader(cnx);
|
||||
|
||||
if (jsonBody != null) {
|
||||
cnx.setDoOutput(true);
|
||||
wr = new OutputStreamWriter(cnx.getOutputStream());
|
||||
wr.write(jsonBody);
|
||||
}
|
||||
|
||||
readHeader(cnx);
|
||||
|
||||
in = new BufferedReader(new InputStreamReader(cnx.getInputStream(), getCharset(cnx)));
|
||||
String line;
|
||||
while ((line = in.readLine()) != null) {
|
||||
content.write(line);
|
||||
}
|
||||
} finally {
|
||||
if (wr != null) {
|
||||
wr.flush();
|
||||
wr.close();
|
||||
}
|
||||
|
||||
if (in != null) {
|
||||
in.close();
|
||||
}
|
||||
|
||||
if (cnx instanceof HttpURLConnection) {
|
||||
((HttpURLConnection) cnx).disconnect();
|
||||
}
|
||||
}
|
||||
return content.toString();
|
||||
} catch (IOException ex) {
|
||||
throw new MovieDbException(MovieDbException.MovieDbExceptionType.CONNECTION_ERROR, null, ex);
|
||||
} finally {
|
||||
if (content != null) {
|
||||
try {
|
||||
content.close();
|
||||
} catch (IOException ex) {
|
||||
LOG.debug("Failed to close connection: " + ex.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void sendHeader(URLConnection cnx) {
|
||||
populateBrowserProperties();
|
||||
|
||||
// send browser properties
|
||||
for (Map.Entry<String, String> browserProperty : browserProperties.entrySet()) {
|
||||
cnx.setRequestProperty(browserProperty.getKey(), browserProperty.getValue());
|
||||
}
|
||||
// send cookies
|
||||
String cookieHeader = createCookieHeader(cnx);
|
||||
if (!cookieHeader.isEmpty()) {
|
||||
cnx.setRequestProperty("Cookie", cookieHeader);
|
||||
}
|
||||
}
|
||||
|
||||
private static String createCookieHeader(URLConnection cnx) {
|
||||
String host = cnx.getURL().getHost();
|
||||
StringBuilder cookiesHeader = new StringBuilder();
|
||||
for (Map.Entry<String, Map<String, String>> domainCookies : cookies.entrySet()) {
|
||||
if (host.endsWith(domainCookies.getKey())) {
|
||||
for (Map.Entry<String, String> cookie : domainCookies.getValue().entrySet()) {
|
||||
cookiesHeader.append(cookie.getKey());
|
||||
cookiesHeader.append("=");
|
||||
cookiesHeader.append(cookie.getValue());
|
||||
cookiesHeader.append(";");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (cookiesHeader.length() > 0) {
|
||||
// remove last ; char
|
||||
cookiesHeader.deleteCharAt(cookiesHeader.length() - 1);
|
||||
}
|
||||
return cookiesHeader.toString();
|
||||
}
|
||||
|
||||
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())) {
|
||||
for (String cookieHeader : header.getValue()) {
|
||||
String[] cookieElements = cookieHeader.split(" *; *");
|
||||
if (cookieElements.length >= 1) {
|
||||
String[] firstElem = cookieElements[0].split(" *= *");
|
||||
String cookieName = firstElem[0];
|
||||
String cookieValue = firstElem.length > 1 ? firstElem[1] : null;
|
||||
String cookieDomain = null;
|
||||
// find cookie domain
|
||||
for (int i = 1; i < cookieElements.length; i++) {
|
||||
String[] cookieElement = cookieElements[i].split(" *= *");
|
||||
if ("domain".equals(cookieElement[0])) {
|
||||
cookieDomain = cookieElement.length > 1 ? cookieElement[1] : null;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (cookieDomain == null) {
|
||||
// if domain isn't set take current host
|
||||
cookieDomain = cnx.getURL().getHost();
|
||||
}
|
||||
Map<String, String> domainCookies = cookies.get(cookieDomain);
|
||||
if (domainCookies == null) {
|
||||
domainCookies = new HashMap<String, String>();
|
||||
cookies.put(cookieDomain, domainCookies);
|
||||
}
|
||||
// add or replace cookie
|
||||
domainCookies.put(cookieName, cookieValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static Charset getCharset(URLConnection cnx) {
|
||||
Charset charset = null;
|
||||
// content type will be string like "text/html; charset=UTF-8" or "text/html"
|
||||
String contentType = cnx.getContentType();
|
||||
if (contentType != null) {
|
||||
// changed 'charset' to 'harset' in regexp because some sites send 'Charset'
|
||||
Matcher m = Pattern.compile("harset *=[ '\"]*([^ ;'\"]+)[ ;'\"]*").matcher(contentType);
|
||||
if (m.find()) {
|
||||
String encoding = m.group(1);
|
||||
try {
|
||||
charset = Charset.forName(encoding);
|
||||
} catch (UnsupportedCharsetException e) {
|
||||
// there will be used default charset
|
||||
}
|
||||
}
|
||||
}
|
||||
if (charset == null) {
|
||||
charset = Charset.defaultCharset();
|
||||
}
|
||||
|
||||
return charset;
|
||||
}
|
||||
|
||||
public static String getProxyHost() {
|
||||
return proxyHost;
|
||||
}
|
||||
|
||||
public static void setProxyHost(String myProxyHost) {
|
||||
WebBrowser.proxyHost = myProxyHost;
|
||||
}
|
||||
|
||||
public static String getProxyPort() {
|
||||
return proxyPort;
|
||||
}
|
||||
|
||||
public static void setProxyPort(String myProxyPort) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
/*
|
||||
* Copyright (c) 2004-2013 Stuart Boston
|
||||
*
|
||||
* This file is part of TheMovieDB API.
|
||||
*
|
||||
* TheMovieDB API is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* any later version.
|
||||
*
|
||||
* TheMovieDB API is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with TheMovieDB API. If not, see <http://www.gnu.org/licenses/>.
|
||||
*
|
||||
*/
|
||||
package com.omertron.themoviedbapi.tools;
|
||||
|
||||
import com.fasterxml.jackson.core.JsonProcessingException;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.omertron.themoviedbapi.MovieDbException;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.*;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.UnsupportedCharsetException;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* Web browser with simple cookies support
|
||||
*/
|
||||
public final class WebBrowser {
|
||||
|
||||
private static final Logger LOG = LoggerFactory.getLogger(WebBrowser.class);
|
||||
private static Map<String, String> browserProperties = new HashMap<String, String>();
|
||||
private static Map<String, Map<String, String>> cookies = new HashMap<String, Map<String, String>>();
|
||||
private static String proxyHost = null;
|
||||
private static String proxyPort = null;
|
||||
private static String proxyUsername = null;
|
||||
private static String proxyPassword = null;
|
||||
private static String proxyEncodedPassword = null;
|
||||
private static int webTimeoutConnect = 25000; // 25 second timeout
|
||||
private static int webTimeoutRead = 90000; // 90 second timeout
|
||||
|
||||
// Hide the constructor
|
||||
protected WebBrowser() {
|
||||
// prevents calls from subclass
|
||||
throw new UnsupportedOperationException();
|
||||
}
|
||||
|
||||
/**
|
||||
* Populate the browser properties
|
||||
*/
|
||||
private static void populateBrowserProperties() {
|
||||
if (browserProperties.isEmpty()) {
|
||||
browserProperties.put("User-Agent", "Mozilla/5.25 Netscape/5.0 (Windows; I; Win95)");
|
||||
browserProperties.put("Accept", "application/json");
|
||||
browserProperties.put("Content-type", "application/json");
|
||||
}
|
||||
}
|
||||
|
||||
public static String request(String url) throws MovieDbException {
|
||||
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");
|
||||
System.getProperties().put("proxyHost", proxyHost);
|
||||
System.getProperties().put("proxyPort", proxyPort);
|
||||
}
|
||||
|
||||
URLConnection cnx = url.openConnection();
|
||||
|
||||
if (proxyUsername != null) {
|
||||
cnx.setRequestProperty("Proxy-Authorization", proxyEncodedPassword);
|
||||
}
|
||||
|
||||
return cnx;
|
||||
} catch (IOException ex) {
|
||||
throw new MovieDbException(MovieDbException.MovieDbExceptionType.INVALID_URL, null, ex);
|
||||
}
|
||||
}
|
||||
|
||||
public static String request(URL url) throws MovieDbException {
|
||||
return request(url, null);
|
||||
}
|
||||
|
||||
public static String request(URL url, String jsonBody) throws MovieDbException {
|
||||
return request(url, jsonBody, false);
|
||||
}
|
||||
|
||||
public static String request(URL url, String jsonBody, boolean isDeleteRequest) throws MovieDbException {
|
||||
|
||||
StringWriter content = null;
|
||||
|
||||
try {
|
||||
content = new StringWriter();
|
||||
|
||||
BufferedReader in = null;
|
||||
HttpURLConnection cnx = null;
|
||||
OutputStreamWriter wr = null;
|
||||
try {
|
||||
cnx = (HttpURLConnection) openProxiedConnection(url);
|
||||
|
||||
if (isDeleteRequest) {
|
||||
cnx.setDoOutput(true);
|
||||
cnx.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
|
||||
cnx.setRequestMethod("DELETE");
|
||||
}
|
||||
|
||||
sendHeader(cnx);
|
||||
|
||||
if (jsonBody != null) {
|
||||
cnx.setDoOutput(true);
|
||||
wr = new OutputStreamWriter(cnx.getOutputStream());
|
||||
wr.write(jsonBody);
|
||||
}
|
||||
|
||||
readHeader(cnx);
|
||||
|
||||
// http://stackoverflow.com/questions/4633048/httpurlconnection-reading-response-content-on-403-error
|
||||
if (cnx.getResponseCode() >= 400) {
|
||||
in = new BufferedReader(new InputStreamReader(cnx.getErrorStream(), getCharset(cnx)));
|
||||
} else {
|
||||
in = new BufferedReader(new InputStreamReader(cnx.getInputStream(), getCharset(cnx)));
|
||||
}
|
||||
|
||||
String line;
|
||||
while ((line = in.readLine()) != null) {
|
||||
content.write(line);
|
||||
}
|
||||
} finally {
|
||||
if (wr != null) {
|
||||
wr.flush();
|
||||
wr.close();
|
||||
}
|
||||
|
||||
if (in != null) {
|
||||
in.close();
|
||||
}
|
||||
|
||||
if (cnx instanceof HttpURLConnection) {
|
||||
((HttpURLConnection) cnx).disconnect();
|
||||
}
|
||||
}
|
||||
return content.toString();
|
||||
} catch (IOException ex) {
|
||||
throw new MovieDbException(MovieDbException.MovieDbExceptionType.CONNECTION_ERROR, null, ex);
|
||||
} finally {
|
||||
if (content != null) {
|
||||
try {
|
||||
content.close();
|
||||
} catch (IOException ex) {
|
||||
LOG.debug("Failed to close connection: " + ex.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static void sendHeader(URLConnection cnx) {
|
||||
populateBrowserProperties();
|
||||
|
||||
// send browser properties
|
||||
for (Map.Entry<String, String> browserProperty : browserProperties.entrySet()) {
|
||||
cnx.setRequestProperty(browserProperty.getKey(), browserProperty.getValue());
|
||||
}
|
||||
// send cookies
|
||||
String cookieHeader = createCookieHeader(cnx);
|
||||
if (!cookieHeader.isEmpty()) {
|
||||
cnx.setRequestProperty("Cookie", cookieHeader);
|
||||
}
|
||||
}
|
||||
|
||||
private static String createCookieHeader(URLConnection cnx) {
|
||||
String host = cnx.getURL().getHost();
|
||||
StringBuilder cookiesHeader = new StringBuilder();
|
||||
for (Map.Entry<String, Map<String, String>> domainCookies : cookies.entrySet()) {
|
||||
if (host.endsWith(domainCookies.getKey())) {
|
||||
for (Map.Entry<String, String> cookie : domainCookies.getValue().entrySet()) {
|
||||
cookiesHeader.append(cookie.getKey());
|
||||
cookiesHeader.append("=");
|
||||
cookiesHeader.append(cookie.getValue());
|
||||
cookiesHeader.append(";");
|
||||
}
|
||||
}
|
||||
}
|
||||
if (cookiesHeader.length() > 0) {
|
||||
// remove last ; char
|
||||
cookiesHeader.deleteCharAt(cookiesHeader.length() - 1);
|
||||
}
|
||||
return cookiesHeader.toString();
|
||||
}
|
||||
|
||||
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())) {
|
||||
for (String cookieHeader : header.getValue()) {
|
||||
String[] cookieElements = cookieHeader.split(" *; *");
|
||||
if (cookieElements.length >= 1) {
|
||||
String[] firstElem = cookieElements[0].split(" *= *");
|
||||
String cookieName = firstElem[0];
|
||||
String cookieValue = firstElem.length > 1 ? firstElem[1] : null;
|
||||
String cookieDomain = null;
|
||||
// find cookie domain
|
||||
for (int i = 1; i < cookieElements.length; i++) {
|
||||
String[] cookieElement = cookieElements[i].split(" *= *");
|
||||
if ("domain".equals(cookieElement[0])) {
|
||||
cookieDomain = cookieElement.length > 1 ? cookieElement[1] : null;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (cookieDomain == null) {
|
||||
// if domain isn't set take current host
|
||||
cookieDomain = cnx.getURL().getHost();
|
||||
}
|
||||
Map<String, String> domainCookies = cookies.get(cookieDomain);
|
||||
if (domainCookies == null) {
|
||||
domainCookies = new HashMap<String, String>();
|
||||
cookies.put(cookieDomain, domainCookies);
|
||||
}
|
||||
// add or replace cookie
|
||||
domainCookies.put(cookieName, cookieValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static Charset getCharset(URLConnection cnx) {
|
||||
Charset charset = null;
|
||||
// content type will be string like "text/html; charset=UTF-8" or "text/html"
|
||||
String contentType = cnx.getContentType();
|
||||
if (contentType != null) {
|
||||
// changed 'charset' to 'harset' in regexp because some sites send 'Charset'
|
||||
Matcher m = Pattern.compile("harset *=[ '\"]*([^ ;'\"]+)[ ;'\"]*").matcher(contentType);
|
||||
if (m.find()) {
|
||||
String encoding = m.group(1);
|
||||
try {
|
||||
charset = Charset.forName(encoding);
|
||||
} catch (UnsupportedCharsetException e) {
|
||||
// there will be used default charset
|
||||
}
|
||||
}
|
||||
}
|
||||
if (charset == null) {
|
||||
charset = Charset.defaultCharset();
|
||||
}
|
||||
|
||||
return charset;
|
||||
}
|
||||
|
||||
public static String getProxyHost() {
|
||||
return proxyHost;
|
||||
}
|
||||
|
||||
public static void setProxyHost(String myProxyHost) {
|
||||
WebBrowser.proxyHost = myProxyHost;
|
||||
}
|
||||
|
||||
public static String getProxyPort() {
|
||||
return proxyPort;
|
||||
}
|
||||
|
||||
public static void setProxyPort(String myProxyPort) {
|
||||
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) {
|
||||
try {
|
||||
return new ObjectMapper().writeValueAsString(map);
|
||||
} catch (JsonProcessingException jpe) {
|
||||
throw new RuntimeException("json conversion failed", jpe);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -29,6 +29,7 @@ import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
@@ -58,8 +59,9 @@ public class TheMovieDbApiTest {
|
||||
private static final String LANGUAGE_ENGLISH = "en";
|
||||
private static final String LANGUAGE_RUSSIAN = "ru";
|
||||
|
||||
// session id of test users named 'apitests'
|
||||
// session and account id of test users named 'apitests'
|
||||
private static final String SESSION_ID_APITESTS = "63c85deb39337e29b69d78265eb28d639cbd6f72";
|
||||
private static final int ACCOUNT_ID_APITESTS = 6065849;
|
||||
|
||||
public TheMovieDbApiTest() throws MovieDbException {
|
||||
}
|
||||
@@ -98,6 +100,50 @@ public class TheMovieDbApiTest {
|
||||
LOG.info(tmdbConfig.toString());
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testAccount() throws MovieDbException {
|
||||
Account account = tmdb.getAccount(SESSION_ID_APITESTS);
|
||||
|
||||
// Make sure properties are extracted correctly
|
||||
assertEquals(account.getUserName(), "apitests");
|
||||
assertEquals(account.getId(), ACCOUNT_ID_APITESTS);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testWatchList() throws MovieDbException {
|
||||
// make sure it's empty (because it's just a test account
|
||||
Assert.assertTrue(tmdb.getWatchList(SESSION_ID_APITESTS, ACCOUNT_ID_APITESTS).isEmpty());
|
||||
|
||||
// add a movie
|
||||
tmdb.addToWatchList(SESSION_ID_APITESTS, ACCOUNT_ID_APITESTS, 550);
|
||||
|
||||
List<MovieDb> watchList = tmdb.getWatchList(SESSION_ID_APITESTS, ACCOUNT_ID_APITESTS);
|
||||
assertTrue(watchList.size()==1);
|
||||
|
||||
// clean up again
|
||||
tmdb.removeFromWatchList(SESSION_ID_APITESTS, ACCOUNT_ID_APITESTS, 550);
|
||||
|
||||
Assert.assertTrue(tmdb.getWatchList(SESSION_ID_APITESTS, ACCOUNT_ID_APITESTS).isEmpty());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testFavorites() throws MovieDbException {
|
||||
// make sure it's empty (because it's just a test account
|
||||
Assert.assertTrue(tmdb.getFavoriteMovies(SESSION_ID_APITESTS, ACCOUNT_ID_APITESTS).isEmpty());
|
||||
|
||||
// add a movie
|
||||
tmdb.changeFavoriteStatus(SESSION_ID_APITESTS, ACCOUNT_ID_APITESTS, 550, true);
|
||||
|
||||
List<MovieDb> watchList = tmdb.getFavoriteMovies(SESSION_ID_APITESTS, ACCOUNT_ID_APITESTS);
|
||||
assertTrue(watchList.size()==1);
|
||||
|
||||
// clean up again
|
||||
tmdb.changeFavoriteStatus(SESSION_ID_APITESTS, ACCOUNT_ID_APITESTS, 550, false);
|
||||
|
||||
Assert.assertTrue(tmdb.getFavoriteMovies(SESSION_ID_APITESTS, ACCOUNT_ID_APITESTS).isEmpty());
|
||||
}
|
||||
|
||||
/**
|
||||
* Test of searchMovie method, of class TheMovieDbApi.
|
||||
*/
|
||||
@@ -597,20 +643,60 @@ public class TheMovieDbApiTest {
|
||||
* TODO: Cannot be tested without a HTTP authorisation: http://help.themoviedb.org/kb/api/user-authentication
|
||||
*/
|
||||
@Test
|
||||
public void testPostMovieRating() throws Exception {
|
||||
public void testMovieRating() throws Exception {
|
||||
LOG.info("postMovieRating");
|
||||
Integer movieID = 68724;
|
||||
Integer rating = 3;
|
||||
Integer rating = new Random().nextInt(10)+1;
|
||||
|
||||
boolean wasPosted = tmdb.postMovieRating(SESSION_ID_APITESTS, movieID, rating);
|
||||
|
||||
assertTrue(wasPosted);
|
||||
|
||||
// get all rated movies
|
||||
|
||||
List<MovieDb> ratedMovies = tmdb.getRatedMovies(SESSION_ID_APITESTS, ACCOUNT_ID_APITESTS);
|
||||
assertTrue(ratedMovies.size()>0);
|
||||
|
||||
// make sure that we find the movie and it is rated correctly
|
||||
boolean foundMovie = false;
|
||||
for (MovieDb movie : ratedMovies) {
|
||||
if(movie.getId()==movieID){
|
||||
assertEquals(movie.getUserRating(), (float) rating, 0);
|
||||
foundMovie = true;
|
||||
}
|
||||
}
|
||||
assertTrue(foundMovie);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test of getPersonChanges method, of class TheMovieDbApi.
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
public void testMovieLists() throws Exception {
|
||||
Integer movieID = 68724;
|
||||
|
||||
// use a random name to avoid that we clash we leftovers of incomplete test runs
|
||||
String name = "test list " + new Random().nextInt(100);
|
||||
|
||||
// create the list
|
||||
String listId = tmdb.createList(SESSION_ID_APITESTS, name, "api testing only");
|
||||
|
||||
// add a movie, and test that it is on the list now
|
||||
tmdb.addMovieToList(SESSION_ID_APITESTS, listId, movieID);
|
||||
MovieDbList list = tmdb.getList(listId);
|
||||
Assert.assertEquals(list.getItemCount(), 1);
|
||||
Assert.assertEquals(list.getItems().get(0).getId(), (int) movieID);
|
||||
|
||||
// now remove the movie
|
||||
tmdb.removeMovieFromList(SESSION_ID_APITESTS, listId, movieID);
|
||||
Assert.assertEquals(tmdb.getList(listId).getItemCount(), 0);
|
||||
|
||||
// delete the test list
|
||||
StatusCode statusCode = tmdb.deleteMovieList(SESSION_ID_APITESTS, listId);
|
||||
assertEquals(statusCode.getStatusCode(), 13);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test of getPersonChanges method, of class TheMovieDbApi.
|
||||
*
|
||||
*/
|
||||
@Ignore("Not ready yet")
|
||||
public void testGetPersonChanges() throws Exception {
|
||||
LOG.info("getPersonChanges");
|
||||
|
||||
Reference in New Issue
Block a user