diff --git a/aws/core/src/main/java/org/jclouds/aws/simpledb/SimpleDBAsyncClient.java b/aws/core/src/main/java/org/jclouds/aws/simpledb/SimpleDBAsyncClient.java
index f797191579..855bf45568 100644
--- a/aws/core/src/main/java/org/jclouds/aws/simpledb/SimpleDBAsyncClient.java
+++ b/aws/core/src/main/java/org/jclouds/aws/simpledb/SimpleDBAsyncClient.java
@@ -22,6 +22,8 @@ package org.jclouds.aws.simpledb;
import static org.jclouds.aws.simpledb.reference.SimpleDBParameters.ACTION;
import static org.jclouds.aws.simpledb.reference.SimpleDBParameters.VERSION;
+import java.util.Map;
+
import javax.annotation.Nullable;
import javax.ws.rs.FormParam;
import javax.ws.rs.POST;
@@ -29,9 +31,14 @@ import javax.ws.rs.Path;
import org.jclouds.aws.filters.FormSigner;
import org.jclouds.aws.functions.RegionToEndpoint;
+import org.jclouds.aws.simpledb.binders.BindAttributesToIndexedFormParams;
+import org.jclouds.aws.simpledb.domain.Item;
+import org.jclouds.aws.simpledb.domain.AttributePair;
import org.jclouds.aws.simpledb.domain.ListDomainsResponse;
import org.jclouds.aws.simpledb.options.ListDomainsOptions;
+import org.jclouds.aws.simpledb.xml.ItemsHandler;
import org.jclouds.aws.simpledb.xml.ListDomainsResponseHandler;
+import org.jclouds.rest.annotations.BinderParam;
import org.jclouds.rest.annotations.EndpointParam;
import org.jclouds.rest.annotations.FormParams;
import org.jclouds.rest.annotations.RequestFilters;
@@ -45,6 +52,7 @@ import com.google.common.util.concurrent.ListenableFuture;
*
*
* @author Adrian Cole
+ * @author Luís A. Bastião Silva
*/
@RequestFilters(FormSigner.class)
@FormParams(keys = VERSION, values = SimpleDBAsyncClient.VERSION)
@@ -80,4 +88,28 @@ public interface SimpleDBAsyncClient {
ListenableFuture deleteDomainInRegion(@EndpointParam(parser = RegionToEndpoint.class) @Nullable String region,
@FormParam("DomainName") String domainName);
+
+ /**
+ * @see SimpleDBClient#putAttributes
+ */
+ @POST
+ @Path("/")
+ @FormParams(keys = ACTION, values = "PutAttributes")
+ ListenableFuture putAttributes(@EndpointParam(parser = RegionToEndpoint.class) @Nullable String region,
+ @FormParam("DomainName") String domainName,
+ @FormParam("ItemName") String itemName,
+ @BinderParam(BindAttributesToIndexedFormParams.class) Item attributes);
+
+ /**
+ * @see SimpleDBClient#putAttributes
+ */
+ @POST
+ @Path("/")
+ @FormParams(keys = ACTION, values = "Select")
+ @XMLResponseParser(ItemsHandler.class)
+ ListenableFuture extends Map> select(@EndpointParam(parser = RegionToEndpoint.class) @Nullable String region,
+ @FormParam("SelectExpression") String selectExpression);
+
+
+
}
diff --git a/aws/core/src/main/java/org/jclouds/aws/simpledb/SimpleDBClient.java b/aws/core/src/main/java/org/jclouds/aws/simpledb/SimpleDBClient.java
index e3d63cc080..25aa7db973 100644
--- a/aws/core/src/main/java/org/jclouds/aws/simpledb/SimpleDBClient.java
+++ b/aws/core/src/main/java/org/jclouds/aws/simpledb/SimpleDBClient.java
@@ -19,19 +19,28 @@
package org.jclouds.aws.simpledb;
+import java.util.Map;
import java.util.concurrent.TimeUnit;
import javax.annotation.Nullable;
+import javax.ws.rs.FormParam;
+import org.jclouds.aws.functions.RegionToEndpoint;
+import org.jclouds.aws.simpledb.domain.Item;
+import org.jclouds.aws.simpledb.domain.AttributePair;
import org.jclouds.aws.simpledb.domain.ListDomainsResponse;
import org.jclouds.aws.simpledb.options.ListDomainsOptions;
import org.jclouds.concurrent.Timeout;
+import org.jclouds.rest.annotations.EndpointParam;
+
+import com.google.common.util.concurrent.ListenableFuture;
/**
* Provides access to SimpleDB via their REST API.
*
*
* @author Adrian Cole
+ * @author Luís A. Bastião Silva
*/
@Timeout(duration = 30, timeUnit = TimeUnit.SECONDS)
public interface SimpleDBClient {
@@ -103,5 +112,6 @@ public interface SimpleDBClient {
* />
*/
void deleteDomainInRegion(String region, String domainName);
-
+ void putAttributes(String region, String domain, String itemName, Item attributes);
+ Map select(String region, String selectionExpression);
}
diff --git a/aws/core/src/main/java/org/jclouds/aws/simpledb/SimpleDBContextBuilder.java b/aws/core/src/main/java/org/jclouds/aws/simpledb/SimpleDBContextBuilder.java
index 4b210cd866..ecb61057ca 100644
--- a/aws/core/src/main/java/org/jclouds/aws/simpledb/SimpleDBContextBuilder.java
+++ b/aws/core/src/main/java/org/jclouds/aws/simpledb/SimpleDBContextBuilder.java
@@ -41,6 +41,7 @@ import com.google.inject.Module;
* {@link JavaUrlHttpCommandExecutorServiceModule http transports} will be installed.
*
* @author Adrian Cole
+ * @author Luís A. Bastião Silva
* @see SimpleDBContext
*/
public class SimpleDBContextBuilder extends RestContextBuilder {
diff --git a/aws/core/src/main/java/org/jclouds/aws/simpledb/binders/BindAttributesToIndexedFormParams.java b/aws/core/src/main/java/org/jclouds/aws/simpledb/binders/BindAttributesToIndexedFormParams.java
new file mode 100644
index 0000000000..44d1d67158
--- /dev/null
+++ b/aws/core/src/main/java/org/jclouds/aws/simpledb/binders/BindAttributesToIndexedFormParams.java
@@ -0,0 +1,63 @@
+package org.jclouds.aws.simpledb.binders;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import static com.google.common.base.Preconditions.checkNotNull;
+import static java.lang.String.format;
+import static org.jclouds.http.HttpUtils.addFormParamTo;
+
+import java.util.Collection;
+import java.util.Iterator;
+
+import java.util.List;
+import org.jclouds.aws.simpledb.domain.Item;
+import org.jclouds.aws.simpledb.domain.AttributePair;
+import org.jclouds.http.HttpRequest;
+import org.jclouds.rest.Binder;
+
+/**
+ *
+ * @author Luís A. Bastião Silva
+ */
+public class BindAttributesToIndexedFormParams implements Binder
+{
+
+ private final String attributeName = "Attribute.%d.Name";
+ private final String attributeValue = "Attribute.%d.Value";
+ private final String attributeReplace = "Attribute.%d.Replace";
+
+ public void bindToRequest(HttpRequest request, Object input) {
+ checkArgument(checkNotNull(input, "input") instanceof Item,
+ "this binder is only valid for AttributeMap");
+ Item attributeMap = (Item) input;
+
+ int amazonOneBasedIndex = 1; // according to docs, counters must start with 1
+ for (String itemName : attributeMap.getAttributes().keySet())
+ {
+
+ Collection c = attributeMap.getAttributes().get(itemName);
+ Iterator it = c.iterator();
+ while(it.hasNext())
+ {
+ AttributePair attr = it.next();
+ // not null by contract
+
+ String value = attr.getValue();
+
+ if (value != null) {
+ addFormParamTo(request, format(attributeName, amazonOneBasedIndex), attr.getKey() );
+ addFormParamTo(request, format(attributeValue, amazonOneBasedIndex),
+ value);
+ addFormParamTo(request, format(attributeReplace, amazonOneBasedIndex), String
+ .valueOf(attr.isReplace()));
+
+
+ }
+ amazonOneBasedIndex++;
+ }
+
+
+ }
+
+ }
+
+}
diff --git a/aws/core/src/main/java/org/jclouds/aws/simpledb/config/SimpleDBRestClientModule.java b/aws/core/src/main/java/org/jclouds/aws/simpledb/config/SimpleDBRestClientModule.java
index 4870bfcded..4aca4586a9 100644
--- a/aws/core/src/main/java/org/jclouds/aws/simpledb/config/SimpleDBRestClientModule.java
+++ b/aws/core/src/main/java/org/jclouds/aws/simpledb/config/SimpleDBRestClientModule.java
@@ -29,6 +29,7 @@ import org.jclouds.rest.ConfiguresRestClient;
* Configures the SimpleDB connection.
*
* @author Adrian Cole
+ * @author Luís A. Bastião Silva
*/
@RequiresHttp
@ConfiguresRestClient
diff --git a/aws/core/src/main/java/org/jclouds/aws/simpledb/domain/AttributePair.java b/aws/core/src/main/java/org/jclouds/aws/simpledb/domain/AttributePair.java
new file mode 100644
index 0000000000..03c68816b0
--- /dev/null
+++ b/aws/core/src/main/java/org/jclouds/aws/simpledb/domain/AttributePair.java
@@ -0,0 +1,62 @@
+package org.jclouds.aws.simpledb.domain;
+
+import java.util.ArrayList;
+import java.util.List;
+
+
+/**
+ * AttributePair is a class to support the attributes to put in the SimpleDB
+ *
+ *
+ * @author Luís A. Bastião Silva
+ */
+public class AttributePair
+{
+
+ private String key;
+ private String value;
+ private boolean replace;
+
+
+ /**
+ *
+ * Default constructor to represent an attribute in a domain in SimpleDB
+ *
+ *
+ *
+ * @param key Name of Attribute
+ * @param value Value of Attribute
+ * @param replace Replace value if it already exists in domain
+ */
+ public AttributePair(String key, String value, boolean replace)
+ {
+ this.key = key;
+
+ this.value = value ;
+ this.replace = replace;
+ }
+
+
+ public String getKey() {
+ return key;
+ }
+
+
+ public String getValue() {
+ return value;
+ }
+
+ public void setValue(String value)
+ {
+ this.value = value;
+ }
+
+
+ public boolean isReplace() {
+ return replace;
+ }
+
+
+
+
+}
diff --git a/aws/core/src/main/java/org/jclouds/aws/simpledb/domain/DomainMetadata.java b/aws/core/src/main/java/org/jclouds/aws/simpledb/domain/DomainMetadata.java
index 90d5a9c3f2..aff4dffdec 100644
--- a/aws/core/src/main/java/org/jclouds/aws/simpledb/domain/DomainMetadata.java
+++ b/aws/core/src/main/java/org/jclouds/aws/simpledb/domain/DomainMetadata.java
@@ -27,6 +27,7 @@ import java.util.Date;
* "http://docs.amazonwebservices.com/AmazonSimpleDB/2009-04-15/DeveloperGuide/index.html?SDB_API_CreateDomain.html"
* />
* @author Adrian Cole
+ * @author Luís A. Bastião Silva
*/
public class DomainMetadata {
private final String region;
diff --git a/aws/core/src/main/java/org/jclouds/aws/simpledb/domain/Item.java b/aws/core/src/main/java/org/jclouds/aws/simpledb/domain/Item.java
new file mode 100644
index 0000000000..aa6c9b590f
--- /dev/null
+++ b/aws/core/src/main/java/org/jclouds/aws/simpledb/domain/Item.java
@@ -0,0 +1,45 @@
+package org.jclouds.aws.simpledb.domain;
+
+import javax.annotation.Nullable;
+
+import com.google.common.collect.ImmutableMultimap;
+import com.google.common.collect.LinkedHashMultimap;
+import com.google.common.collect.Multimap;
+
+/**
+ * Defines the mapping of Items
+ *
+ * @author Luís A. Bastião Silva
+ */
+public class Item {
+
+ private final Multimap attributes = LinkedHashMultimap
+ .create();
+
+ public Item() {
+ }
+
+ /**
+ * Creates a map of Attribute Pair
+ *
+ */
+ public Item(Multimap attributes)
+ {
+
+ this.attributes.putAll(attributes);
+
+ }
+
+ public Item addAttributePair(@Nullable String itemName,
+ AttributePair attrPair)
+ {
+ this.attributes.put(itemName, attrPair);
+ return this;
+ }
+
+ public Multimap getAttributes()
+ {
+ return ImmutableMultimap. builder().putAll(
+ attributes).build();
+ }
+}
diff --git a/aws/core/src/main/java/org/jclouds/aws/simpledb/domain/ListDomainsResponse.java b/aws/core/src/main/java/org/jclouds/aws/simpledb/domain/ListDomainsResponse.java
index 4fa1ba9339..c15bc02dcd 100644
--- a/aws/core/src/main/java/org/jclouds/aws/simpledb/domain/ListDomainsResponse.java
+++ b/aws/core/src/main/java/org/jclouds/aws/simpledb/domain/ListDomainsResponse.java
@@ -24,6 +24,7 @@ import java.util.Set;
/**
*
* @author Adrian Cole
+ * @author Luís A. Bastião Silva
* @see
*/
public interface ListDomainsResponse extends Set {
diff --git a/aws/core/src/main/java/org/jclouds/aws/simpledb/options/ListDomainsOptions.java b/aws/core/src/main/java/org/jclouds/aws/simpledb/options/ListDomainsOptions.java
index 4db2c3453f..6fbef10003 100644
--- a/aws/core/src/main/java/org/jclouds/aws/simpledb/options/ListDomainsOptions.java
+++ b/aws/core/src/main/java/org/jclouds/aws/simpledb/options/ListDomainsOptions.java
@@ -38,6 +38,7 @@ import org.jclouds.http.options.BaseHttpRequestOptions;
*
*
* @author Adrian Cole
+ * @author Luís A. Bastião Silva
* @see
diff --git a/aws/core/src/main/java/org/jclouds/aws/simpledb/package-info.java b/aws/core/src/main/java/org/jclouds/aws/simpledb/package-info.java
index 12a98f4bdd..bcd961915c 100644
--- a/aws/core/src/main/java/org/jclouds/aws/simpledb/package-info.java
+++ b/aws/core/src/main/java/org/jclouds/aws/simpledb/package-info.java
@@ -21,5 +21,6 @@
*
* @see
* @author Adrian Cole
+ * @author Luís A. Bastião Silva
*/
package org.jclouds.aws.simpledb;
diff --git a/aws/core/src/main/java/org/jclouds/aws/simpledb/reference/SimpleDBParameters.java b/aws/core/src/main/java/org/jclouds/aws/simpledb/reference/SimpleDBParameters.java
index afd6e8e638..d325be7f22 100644
--- a/aws/core/src/main/java/org/jclouds/aws/simpledb/reference/SimpleDBParameters.java
+++ b/aws/core/src/main/java/org/jclouds/aws/simpledb/reference/SimpleDBParameters.java
@@ -25,6 +25,7 @@ package org.jclouds.aws.simpledb.reference;
* @see
* @author Adrian Cole
+ * @author Luís A. Bastião Silva
*/
public interface SimpleDBParameters {
diff --git a/aws/core/src/main/java/org/jclouds/aws/simpledb/xml/ItemsHandler.java b/aws/core/src/main/java/org/jclouds/aws/simpledb/xml/ItemsHandler.java
new file mode 100644
index 0000000000..c23043520f
--- /dev/null
+++ b/aws/core/src/main/java/org/jclouds/aws/simpledb/xml/ItemsHandler.java
@@ -0,0 +1,112 @@
+/**
+ *
+ * Copyright (C) 2010 Cloud Conscious, LLC.
+ *
+ * ====================================================================
+ * 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.jclouds.aws.simpledb.xml;
+
+import com.google.common.collect.LinkedHashMultimap;
+import java.util.Map;
+
+import org.jclouds.aws.simpledb.domain.AttributePair;
+import org.jclouds.date.DateService;
+import org.jclouds.http.functions.ParseSax;
+
+import com.google.common.collect.Maps;
+import com.google.common.collect.Multimap;
+import com.google.inject.Inject;
+import java.util.ArrayList;
+import java.util.List;
+import org.jclouds.aws.simpledb.domain.Item;
+import org.xml.sax.Attributes;
+
+/**
+ *
+ * @author Luís A. Bastião Silva
+ */
+public class ItemsHandler extends
+ ParseSax.HandlerWithResult