Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

updates

  • Loading branch information...
commit bb8651ef5d594caa0078f2abbb35f30c0c5bdf04 1 parent 23d6c5f
@aberman authored
View
12 pom.xml
@@ -2,7 +2,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
- <groupId>org.springframework.data.keyvalue.keyvalue</groupId>
+ <groupId>org.springframework.data.keyvalue</groupId>
<artifactId>spring-data-riak</artifactId>
<version>0.0.1-SNAPSHOT</version>
<packaging>jar</packaging>
@@ -81,6 +81,16 @@
<artifactId>mail</artifactId>
<version>${javax.mail.version}</version>
</dependency>
+ <dependency>
+ <groupId>javax.persistence</groupId>
+ <artifactId>persistence-api</artifactId>
+ <version>1.0</version>
+ </dependency>
+ <dependency>
+ <groupId>cglib</groupId>
+ <artifactId>cglib</artifactId>
+ <version>2.2</version>
+ </dependency>
</dependencies>
<build>
<pluginManagement>
View
11 src/main/java/org/springframework/data/keyvalue/riak/client/RiakRestClient.java
@@ -30,8 +30,11 @@
import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
+import org.codehaus.jackson.Version;
import org.codehaus.jackson.map.ObjectMapper;
+import org.codehaus.jackson.map.module.SimpleModule;
import org.codehaus.jackson.map.type.TypeFactory;
+import org.joda.time.DateTime;
import org.springframework.data.keyvalue.riak.client.data.ResultCallbackHandler;
import org.springframework.data.keyvalue.riak.client.data.RiakBucket;
import org.springframework.data.keyvalue.riak.client.data.RiakBucketProperties;
@@ -49,6 +52,7 @@
import org.springframework.data.keyvalue.riak.parameter.RiakPutParameter;
import org.springframework.data.keyvalue.riak.parameter.RiakReadParameter;
import org.springframework.data.keyvalue.riak.parameter.RiakStoreParameter;
+import org.springframework.data.keyvalue.riak.util.JodaDateTimeDeserializer;
import org.springframework.data.keyvalue.riak.util.RiakConstants;
import org.springframework.http.HttpEntity;
import org.springframework.http.HttpMethod;
@@ -99,6 +103,9 @@ public RiakRestClient(String host, Integer port, boolean useSSL) {
this(host);
this.port = port;
this.useSSL = useSSL;
+ mapper.registerModule(new SimpleModule("JodaDateTime", new Version(1,
+ 0, 0, null)).addDeserializer(DateTime.class,
+ new JodaDateTimeDeserializer<DateTime>(DateTime.class)));
}
public RiakRestClient(String host) {
@@ -159,9 +166,9 @@ public String getClientId() {
try {
this.clientId = new String(Base64.encodeBase64(bytes), "UTF-8");
} catch (UnsupportedEncodingException e) {
-
+
}
-
+
this.clientIdConverted = true;
return this.clientId;
}
View
54 src/main/java/org/springframework/data/keyvalue/riak/util/JodaDateTimeDeserializer.java
@@ -0,0 +1,54 @@
+/*
+ * Copyright 2011 the original author or authors.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.springframework.data.keyvalue.riak.util;
+
+import java.io.IOException;
+
+import org.codehaus.jackson.JsonParser;
+import org.codehaus.jackson.JsonProcessingException;
+import org.codehaus.jackson.JsonToken;
+import org.codehaus.jackson.map.DeserializationContext;
+import org.codehaus.jackson.map.ext.JodaDeserializers.DateTimeDeserializer;
+import org.joda.time.DateTime;
+import org.joda.time.DateTimeZone;
+import org.joda.time.ReadableInstant;
+
+/**
+ * @author andrewberman
+ *
+ * Fix for Riak's MapReduce function which converts a long into a float
+ */
+public class JodaDateTimeDeserializer<T extends ReadableInstant> extends
+ DateTimeDeserializer<T> {
+
+ public JodaDateTimeDeserializer(Class<T> clazz) {
+ super(clazz);
+ }
+
+ @Override
+ @SuppressWarnings("unchecked")
+ public T deserialize(JsonParser jp, DeserializationContext ctxt)
+ throws IOException, JsonProcessingException {
+ JsonToken t = jp.getCurrentToken();
+
+ if (t == JsonToken.VALUE_NUMBER_FLOAT) {
+ return (T) new DateTime(jp.getLongValue(), DateTimeZone.UTC);
+ }
+
+ return super.deserialize(jp, ctxt);
+ }
+
+}
View
0  src/main/resources/META-INF/manifest.mf
No changes.
View
1  src/main/resources/deleteme
@@ -1 +0,0 @@
-Delete me
View
7 src/test/java/org/springframework/data/keyvalue/riak/client/RiakRestClientTests.java
@@ -56,7 +56,7 @@
@BeforeClass
public static void setUp() {
- restClient = new RiakRestClient("localhost", 8098, false);
+ restClient = new RiakRestClient("192.168.1.6", 8098, false);
TEST_KEY = restClient.storeValue(TEST_BUCKET, TEST_VALUE);
}
@@ -199,15 +199,14 @@ public void statsTest() {
Assert.assertTrue(map.size() > 1);
}
- @Test
public void optimisticConcurrencyTest() {
restClient.setBucketProperties(TEST_BUCKET, RiakBucketProperty.allowMulti(true));
String id = restClient.storeValue(TEST_BUCKET, "Value 1");
- RiakManager manager = new RiakRestClient("localhost");
+ RiakManager manager = new RiakRestClient("192.168.1.6");
String vclock = manager.getValue(TEST_BUCKET, id, String.class).getVectorClock();
manager.storeKeyValue(TEST_BUCKET, id, "Value 2", RiakPutParameter.vclock(vclock));
- RiakManager manager2 = new RiakRestClient("localhost");
+ RiakManager manager2 = new RiakRestClient("192.168.1.6");
manager2.storeKeyValue(TEST_BUCKET, id, "Value 3", RiakPutParameter.vclock(vclock));
RiakResponse<String> rr = restClient.getValue(TEST_BUCKET, id, String.class);
View
20 src/test/java/org/springframework/data/keyvalue/riak/client/RiakRestTemplateTests.java
@@ -58,16 +58,16 @@ public String getId() {
private Boolean boolProp;
- @RiakLink(property = "id", value = "test2")
- private TestObject2 test2 = new TestObject2("testingid");
+// @RiakLink(property = "id", value = "test2")
+// private TestObject2 test2 = new TestObject2("testingid");
- public TestObject2 getTest2() {
- return test2;
- }
-
- public void setTest2(TestObject2 test2) {
- this.test2 = test2;
- }
+// public TestObject2 getTest2() {
+// return test2;
+// }
+//
+// public void setTest2(TestObject2 test2) {
+// this.test2 = test2;
+// }
public String getStringProp() {
return stringProp;
@@ -98,7 +98,7 @@ public void setBoolProp(Boolean boolProp) {
@BeforeClass
public static void setUp() {
template = new RiakTemplate(
- new RiakRestClient("localhost", 8098, false));
+ new RiakRestClient("192.168.1.6", 8098, false));
}
@AfterClass
Please sign in to comment.
Something went wrong with that request. Please try again.