Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
package com.basho.riak.client.mapreduce.filter;

import org.json.JSONException;
import org.json.JSONObject;
import org.json.JSONArray;

public class BetweenFilter implements MapReduceFilter {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
*/
package com.basho.riak.client.mapreduce.filter;

import org.json.JSONException;
import org.json.JSONObject;
import org.json.JSONArray;

public class EndsWithFilter implements MapReduceFilter {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
package com.basho.riak.client.mapreduce.filter;

import org.json.JSONException;
import org.json.JSONObject;
import org.json.JSONArray;

public class EqualToFilter implements MapReduceFilter {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
*/
package com.basho.riak.client.mapreduce.filter;

import org.json.JSONException;
import org.json.JSONObject;
import org.json.JSONArray;

public class FloatToStringFilter implements MapReduceFilter {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
package com.basho.riak.client.mapreduce.filter;

import org.json.JSONException;
import org.json.JSONObject;
import org.json.JSONArray;

public class GreaterThanFilter implements MapReduceFilter {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
package com.basho.riak.client.mapreduce.filter;

import org.json.JSONException;
import org.json.JSONObject;
import org.json.JSONArray;

public class GreaterThanOrEqualFilter implements MapReduceFilter {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
*/
package com.basho.riak.client.mapreduce.filter;

import org.json.JSONException;
import org.json.JSONObject;
import org.json.JSONArray;

public class IntToStringFilter implements MapReduceFilter {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
package com.basho.riak.client.mapreduce.filter;

import org.json.JSONException;
import org.json.JSONObject;
import org.json.JSONArray;

public class LessThanFilter implements MapReduceFilter {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
package com.basho.riak.client.mapreduce.filter;

import org.json.JSONException;
import org.json.JSONObject;
import org.json.JSONArray;

public class LessThanOrEqualFilter implements MapReduceFilter {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
*/
package com.basho.riak.client.mapreduce.filter;

import org.json.JSONException;
import org.json.JSONObject;
import org.json.JSONArray;

public class LogicalAndFilter implements MapReduceFilter {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,6 @@
*/
package com.basho.riak.client.mapreduce.filter;

import java.util.List;

import org.json.JSONException;
import org.json.JSONObject;
import org.json.JSONArray;

public class LogicalFilterGroup implements MapReduceFilter {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
*/
package com.basho.riak.client.mapreduce.filter;

import org.json.JSONException;
import org.json.JSONObject;
import org.json.JSONArray;

public class LogicalNotFilter implements MapReduceFilter {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
*/
package com.basho.riak.client.mapreduce.filter;

import org.json.JSONException;
import org.json.JSONObject;
import org.json.JSONArray;

public class LogicalOrFilter implements MapReduceFilter {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
*/
package com.basho.riak.client.mapreduce.filter;

import java.util.List;
import org.json.JSONArray;

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
*/
package com.basho.riak.client.mapreduce.filter;

import org.json.JSONException;
import org.json.JSONObject;
import org.json.JSONArray;

public class MatchFilter implements MapReduceFilter {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
package com.basho.riak.client.mapreduce.filter;

import org.json.JSONException;
import org.json.JSONObject;
import org.json.JSONArray;

public class NotEqualToFilter implements MapReduceFilter {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@
import java.util.List;

import org.json.JSONException;
import org.json.JSONObject;
import org.json.JSONArray;

public class SetMemberFilter implements MapReduceFilter {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
*/
package com.basho.riak.client.mapreduce.filter;

import org.json.JSONException;
import org.json.JSONObject;
import org.json.JSONArray;

public class SimilarToFilter implements MapReduceFilter {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
*/
package com.basho.riak.client.mapreduce.filter;

import org.json.JSONException;
import org.json.JSONObject;
import org.json.JSONArray;

public class StartsWithFilter implements MapReduceFilter {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
*/
package com.basho.riak.client.mapreduce.filter;

import org.json.JSONException;
import org.json.JSONObject;
import org.json.JSONArray;

public class StringToFloatFilter implements MapReduceFilter {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
*/
package com.basho.riak.client.mapreduce.filter;

import org.json.JSONException;
import org.json.JSONObject;
import org.json.JSONArray;

public class StringToIntFilter implements MapReduceFilter {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
*/
package com.basho.riak.client.mapreduce.filter;

import org.json.JSONException;
import org.json.JSONObject;
import org.json.JSONArray;

public class ToLowerFilter implements MapReduceFilter {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
*/
package com.basho.riak.client.mapreduce.filter;

import org.json.JSONException;
import org.json.JSONObject;
import org.json.JSONArray;

public class ToUpperFilter implements MapReduceFilter {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
*/
package com.basho.riak.client.mapreduce.filter;

import org.json.JSONException;
import org.json.JSONObject;
import org.json.JSONArray;

public class TokenizeFilter implements MapReduceFilter {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
*/
package com.basho.riak.client.mapreduce.filter;

import org.json.JSONException;
import org.json.JSONObject;
import org.json.JSONArray;

public class UrlDecodeFilter implements MapReduceFilter {
Expand Down
39 changes: 21 additions & 18 deletions src/main/java/com/basho/riak/client/util/ClientUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.util.List;
import java.util.Map;
import java.util.Random;
import java.util.Map.Entry;

import org.apache.commons.codec.binary.Base64;
import org.apache.commons.httpclient.Header;
Expand All @@ -50,7 +51,7 @@ public class ClientUtils {

// Matches the scheme, host and port of a URL
private static String URL_PATH_MASK = "^(?:[A-Za-z0-9+-\\.]+://)?[^/]*";

private static Random rng = new Random();
/**
* Construct a new {@link HttpClient} instance given a {@link RiakConfig}.
*
Expand Down Expand Up @@ -201,7 +202,7 @@ public static String encodeClientId(String clientId) {
*/
public static String randomClientId() {
byte[] rnd = new byte[4];
new Random().nextBytes(rnd);
rng.nextBytes(rnd);
return encodeClientId(rnd);
}

Expand Down Expand Up @@ -284,16 +285,16 @@ public static List<String> jsonArrayAsList(JSONArray json) {
* Join the elements in arr in to a single string separated by delimiter.
*/
public static String join(String[] arr, String delimiter) {
String res = null;
StringBuffer buf = new StringBuffer();
if (arr == null || arr.length == 0)
return res;
return null;

res = arr[0];
buf.append(arr[0]);
for (int i = 1; i < arr.length; i++) {
res += delimiter + arr[i];
buf.append(delimiter);
buf.append(arr[i]);
}

return res;
return buf.toString();
}

/**
Expand Down Expand Up @@ -328,11 +329,12 @@ public static void copyStream(InputStream in, OutputStream out) throws IOExcepti
public static List<RiakLink> parseLinkHeader(String header) {
List<RiakLink> links = new ArrayList<RiakLink>();
Map<String, Map<String, String>> parsedLinks = LinkHeader.parse(header);
for (String url : parsedLinks.keySet()) {
RiakLink link = parseOneLink(url, parsedLinks.get(url));
if (link != null) {
links.add(link);
}
for (Entry<String, Map<String, String>> e: parsedLinks.entrySet()) {
String url = e.getKey();
RiakLink link = parseOneLink(url, e.getValue());
if (link != null) {
links.add(link);
}
}
return links;
}
Expand Down Expand Up @@ -370,11 +372,12 @@ private static RiakLink parseOneLink(String url, Map<String, String> params) {
public static Map<String, String> parseUsermeta(Map<String, String> headers) {
Map<String, String> usermeta = new HashMap<String, String>();
if (headers != null) {
for (String header : headers.keySet()) {
if (header != null && header.toLowerCase().startsWith(Constants.HDR_USERMETA_PREFIX)) {
usermeta.put(header.substring(Constants.HDR_USERMETA_PREFIX.length()), headers.get(header));
}
}
for (Entry<String, String> e : headers.entrySet()) {
String header = e.getKey();
if (header != null && header.toLowerCase().startsWith(Constants.HDR_USERMETA_PREFIX)) {
usermeta.put(header.substring(Constants.HDR_USERMETA_PREFIX.length()), e.getValue());
}
}
}
return usermeta;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.trifork.riak;
package com.basho.riak.pbc;

//Copyright 2003-2010 Christian d'Heureuse, Inventec Informatik AG, Zurich, Switzerland
//www.source-code.biz, www.inventec.ch/chdh
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package com.trifork.riak;
package com.basho.riak.pbc;

import com.trifork.riak.RPB.RpbBucketProps;
import com.trifork.riak.RPB.RpbGetBucketResp;
import com.trifork.riak.RPB.RpbBucketProps.Builder;
import com.basho.riak.pbc.RPB.RpbBucketProps;
import com.basho.riak.pbc.RPB.RpbGetBucketResp;
import com.basho.riak.pbc.RPB.RpbBucketProps.Builder;

public class BucketProperties {

Expand Down
19 changes: 19 additions & 0 deletions src/main/java/com/basho/riak/pbc/IRequestMeta.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package com.basho.riak.pbc;

import com.google.protobuf.ByteString;

public interface IRequestMeta {

public abstract void preparePut(RPB.RpbPutReq.Builder builder);

public abstract IRequestMeta returnBody(boolean ret);

public abstract IRequestMeta w(int w);

public abstract IRequestMeta dw(int dw);

public abstract IRequestMeta contentType(String contentType);

public abstract ByteString getContentType();

}
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
* limitations under the License.
**/

package com.trifork.riak;
package com.basho.riak.pbc;

import java.io.IOException;
import java.util.NoSuchElementException;

import com.basho.riak.pbc.RPB.RpbListKeysResp;
import com.google.protobuf.ByteString;
import com.trifork.riak.RPB.RpbListKeysResp;

public class KeySource extends RiakStreamClient<ByteString> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
* limitations under the License.
**/

package com.trifork.riak;
package com.basho.riak.pbc;

import java.io.IOException;
import java.util.NoSuchElementException;

import com.basho.riak.pbc.RPB.RpbMapRedResp;
import com.basho.riak.pbc.mapreduce.MapReduceResponse;
import com.google.protobuf.ByteString;
import com.trifork.riak.RPB.RpbMapRedResp;
import com.trifork.riak.mapreduce.MapReduceResponse;

public class MapReduceResponseSource extends
RiakStreamClient<MapReduceResponse> {
Expand Down
Loading