Permalink
Browse files

Merge pull request #3 from garakelian/master

Upgrade to Spring Social 1.1.0 and Jackson 2
  • Loading branch information...
2 parents dd2b03a + f189c40 commit 2b79176875c78e9648b658f054929610b0617537 @vbfischer committed Jun 10, 2015
View
42 pom.xml
@@ -4,20 +4,21 @@
<groupId>org.springframework.social</groupId>
<artifactId>spring-social-dropbox</artifactId>
- <version>1.0.0.M1</version>
+ <version>1.1.0.RELEASE</version>
<packaging>jar</packaging>
<name>spring-social-dropbox</name>
<url>http://maven.apache.org</url>
<properties>
<java-version>1.6</java-version>
- <org.springframework.social-version>1.0.2.BUILD-SNAPSHOT</org.springframework.social-version>
- <org.springframework-version>3.1.0.RELEASE</org.springframework-version>
- <org.springframework.security-version>3.1.0.RELEASE</org.springframework.security-version>
+ <org.springframework.social-version>1.1.0.RELEASE</org.springframework.social-version>
+ <org.springframework.social-test-version>1.0.3.RELEASE</org.springframework.social-test-version>
+ <org.springframework-version>3.2.0.RELEASE</org.springframework-version>
+ <org.springframework.security-version>3.2.0.RELEASE</org.springframework.security-version>
<org.slf4j-version>1.6.1</org.slf4j-version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
- <jacksonVersion>1.9.3</jacksonVersion>
+ <jacksonVersion>2.4.1</jacksonVersion>
<jspApiVersion>2.1</jspApiVersion>
<junitVersion>4.10</junitVersion>
<mockitoVersion>1.9.0</mockitoVersion>
@@ -37,16 +38,31 @@
<version>${org.springframework-version}</version>
</dependency>
<dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-core</artifactId>
+ <version>${org.springframework-version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.springframework</groupId>
+ <artifactId>spring-web</artifactId>
+ <version>${org.springframework-version}</version>
+ </dependency>
+ <dependency>
<groupId>org.springframework.social</groupId>
<artifactId>spring-social-core</artifactId>
<version>${org.springframework.social-version}</version>
</dependency>
<dependency>
<groupId>org.springframework.social</groupId>
- <artifactId>spring-social-test</artifactId>
+ <artifactId>spring-social-web</artifactId>
<version>${org.springframework.social-version}</version>
</dependency>
<dependency>
+ <groupId>org.springframework.social</groupId>
+ <artifactId>spring-social-test</artifactId>
+ <version>${org.springframework.social-test-version}</version>
+ </dependency>
+ <dependency>
<groupId>org.springframework.security</groupId>
<artifactId>spring-security-core</artifactId>
<version>${org.springframework.security-version}</version>
@@ -71,8 +87,18 @@
<dependency>
- <groupId>org.codehaus.jackson</groupId>
- <artifactId>jackson-mapper-asl</artifactId>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-core</artifactId>
+ <version>${jacksonVersion}</version>
+ </dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-annotations</artifactId>
+ <version>${jacksonVersion}</version>
+ </dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-databind</artifactId>
<version>${jacksonVersion}</version>
</dependency>
<dependency>
@@ -1,18 +1,19 @@
package org.springframework.social.dropbox.api.impl;
-import org.codehaus.jackson.Version;
-import org.codehaus.jackson.map.module.SimpleModule;
import org.springframework.social.dropbox.api.DropboxUserProfile;
import org.springframework.social.dropbox.api.FileUrl;
import org.springframework.social.dropbox.api.Metadata;
+import com.fasterxml.jackson.databind.module.SimpleModule;
+
/**
* @author Bryce Fischer
* @author Robert Drysdale
*/
+@SuppressWarnings("serial")
public class DropboxModule extends SimpleModule {
public DropboxModule() {
- super("DropboxModule", new Version(1, 0, 0, null));
+ super("DropboxModule");
}
@Override
@@ -1,15 +1,20 @@
package org.springframework.social.dropbox.api.impl;
-import org.codehaus.jackson.JsonNode;
-import org.codehaus.jackson.map.ObjectMapper;
-import org.codehaus.jackson.type.TypeReference;
+import java.io.InputStream;
+import java.net.URI;
+import java.util.List;
+
import org.springframework.http.HttpHeaders;
import org.springframework.http.HttpMethod;
import org.springframework.http.client.ClientHttpRequest;
import org.springframework.http.client.ClientHttpResponse;
import org.springframework.http.converter.HttpMessageConverter;
-import org.springframework.http.converter.json.MappingJacksonHttpMessageConverter;
-import org.springframework.social.dropbox.api.*;
+import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
+import org.springframework.social.dropbox.api.Dropbox;
+import org.springframework.social.dropbox.api.DropboxFile;
+import org.springframework.social.dropbox.api.DropboxUserProfile;
+import org.springframework.social.dropbox.api.FileUrl;
+import org.springframework.social.dropbox.api.Metadata;
import org.springframework.social.oauth1.AbstractOAuth1ApiBinding;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
@@ -18,9 +23,9 @@
import org.springframework.web.client.RestTemplate;
import org.springframework.web.util.UriTemplate;
-import java.io.InputStream;
-import java.net.URI;
-import java.util.List;
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.ObjectMapper;
/**
* @author Bryce Fischer
@@ -86,7 +91,7 @@ public Metadata move(String fromPath, String toPath) {
JsonNode node = getRestTemplate().getForObject(REVISIONS_URL, JsonNode.class, appFolderUrl, path);
try {
- return objectMapper.readValue(node, new TypeReference<List<Metadata>>() {});
+ return objectMapper.readValue(node.traverse(), new TypeReference<List<Metadata>>() {});
}
catch (Exception e) {
throw new RuntimeException(e);
@@ -97,7 +102,7 @@ public Metadata move(String fromPath, String toPath) {
JsonNode node = getRestTemplate().getForObject(SEARCH_URL + "?query=" + query, JsonNode.class, appFolderUrl, path);
try {
- return objectMapper.readValue(node, new TypeReference<List<Metadata>>() {});
+ return objectMapper.readValue(node.traverse(), new TypeReference<List<Metadata>>() {});
}
catch (Exception e) {
throw new RuntimeException(e);
@@ -174,8 +179,8 @@ private void registerDropboxJsonModule(RestTemplate restTemplate) {
List<HttpMessageConverter<?>> converters = restTemplate.getMessageConverters();
for (HttpMessageConverter<?> converter : converters) {
- if (converter instanceof MappingJacksonHttpMessageConverter) {
- MappingJacksonHttpMessageConverter jsonConverter = (MappingJacksonHttpMessageConverter) converter;
+ if (converter instanceof MappingJackson2HttpMessageConverter) {
+ MappingJackson2HttpMessageConverter jsonConverter = (MappingJackson2HttpMessageConverter) converter;
objectMapper = new ObjectMapper();
objectMapper.registerModule(new DropboxModule());
@@ -1,16 +1,17 @@
package org.springframework.social.dropbox.api.impl;
-import org.codehaus.jackson.JsonNode;
-import org.codehaus.jackson.JsonParser;
-import org.codehaus.jackson.annotate.JsonIgnoreProperties;
-import org.codehaus.jackson.map.DeserializationContext;
-import org.codehaus.jackson.map.JsonDeserializer;
-import org.codehaus.jackson.map.annotate.JsonDeserialize;
-import org.springframework.social.dropbox.api.DropboxUserProfile;
-
import java.io.IOException;
import java.math.BigInteger;
+import org.springframework.social.dropbox.api.DropboxUserProfile;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.databind.DeserializationContext;
+import com.fasterxml.jackson.databind.JsonDeserializer;
+import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
+
/**
* @author Bryce Fischer
*/
@@ -22,16 +23,16 @@
public DropboxUserProfile deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
JsonNode tree = jp.readValueAsTree();
- String referralLink = tree.get("referral_link").getValueAsText();
- String country = tree.get("country").getValueAsText();
- String displayName = tree.get("display_name").getValueAsText();
- String email = tree.get("email").getValueAsText();
- BigInteger uid = tree.get("uid").getBigIntegerValue();
+ String referralLink = tree.get("referral_link").asText();
+ String country = tree.get("country").asText();
+ String displayName = tree.get("display_name").asText();
+ String email = tree.get("email").asText();
+ BigInteger uid = tree.get("uid").bigIntegerValue();
JsonNode quotaNode = tree.get("quota_info");
- BigInteger sharedQuota = quotaNode.get("shared").getBigIntegerValue();
- BigInteger quota = quotaNode.get("quota").getBigIntegerValue();
- BigInteger normalQuota = quotaNode.get("normal").getBigIntegerValue();
+ BigInteger sharedQuota = quotaNode.get("shared").bigIntegerValue();
+ BigInteger quota = quotaNode.get("quota").bigIntegerValue();
+ BigInteger normalQuota = quotaNode.get("normal").bigIntegerValue();
return new DropboxUserProfile(uid, displayName, email, country, referralLink, sharedQuota, quota, normalQuota);
}
@@ -1,19 +1,19 @@
package org.springframework.social.dropbox.api.impl;
-import org.codehaus.jackson.annotate.JsonCreator;
-import org.codehaus.jackson.annotate.JsonIgnoreProperties;
-import org.codehaus.jackson.annotate.JsonProperty;
-
import java.util.Date;
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
/**
* @author Robert Drysdale
- *
+ *
*/
@JsonIgnoreProperties(ignoreUnknown = true)
public class FileUrlMixin {
@JsonCreator
- public FileUrlMixin(
- @JsonProperty("url") String url,
- @JsonProperty("expires") Date expires) {}
+ public FileUrlMixin(@JsonProperty("url") String url,
+ @JsonProperty("expires") Date expires) {
+ }
}
@@ -1,13 +1,14 @@
package org.springframework.social.dropbox.api.impl;
-import org.codehaus.jackson.annotate.JsonCreator;
-import org.codehaus.jackson.annotate.JsonIgnoreProperties;
-import org.codehaus.jackson.annotate.JsonProperty;
-import org.springframework.social.dropbox.api.Metadata;
-
import java.util.Date;
import java.util.List;
+import org.springframework.social.dropbox.api.Metadata;
+
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+import com.fasterxml.jackson.annotation.JsonProperty;
+
/**
* @author Robert Drysdale
*/

0 comments on commit 2b79176

Please sign in to comment.