Skip to content

Commit

Permalink
moved simpledb code from aws to its own api module
Browse files Browse the repository at this point in the history
  • Loading branch information
Adrian Cole committed Jan 2, 2011
1 parent ae77435 commit 0eccc39
Show file tree
Hide file tree
Showing 32 changed files with 242 additions and 115 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
* ====================================================================
*/

package org.jclouds.aws.simpledb;
package org.jclouds.simpledb;

import static org.jclouds.aws.simpledb.reference.SimpleDBParameters.ACTION;
import static org.jclouds.aws.simpledb.reference.SimpleDBParameters.VERSION;
import static org.jclouds.simpledb.reference.SimpleDBParameters.ACTION;
import static org.jclouds.simpledb.reference.SimpleDBParameters.VERSION;

import java.util.Map;

Expand All @@ -30,20 +30,19 @@
import javax.ws.rs.Path;

import org.jclouds.aws.filters.FormSigner;
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.location.functions.RegionToEndpointOrProviderIfNull;
import org.jclouds.rest.annotations.BinderParam;
import org.jclouds.rest.annotations.EndpointParam;
import org.jclouds.rest.annotations.FormParams;
import org.jclouds.rest.annotations.RequestFilters;
import org.jclouds.rest.annotations.VirtualHost;
import org.jclouds.rest.annotations.XMLResponseParser;
import org.jclouds.simpledb.binders.BindAttributesToIndexedFormParams;
import org.jclouds.simpledb.domain.Item;
import org.jclouds.simpledb.domain.ListDomainsResponse;
import org.jclouds.simpledb.options.ListDomainsOptions;
import org.jclouds.simpledb.xml.ItemsHandler;
import org.jclouds.simpledb.xml.ListDomainsResponseHandler;

import com.google.common.util.concurrent.ListenableFuture;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,23 +17,17 @@
* ====================================================================
*/

package org.jclouds.aws.simpledb;
package org.jclouds.simpledb;

import java.util.Map;
import java.util.concurrent.TimeUnit;

import javax.annotation.Nullable;
import javax.ws.rs.FormParam;

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.location.functions.RegionToEndpointOrProviderIfNull;
import org.jclouds.rest.annotations.EndpointParam;

import com.google.common.util.concurrent.ListenableFuture;
import org.jclouds.simpledb.domain.Item;
import org.jclouds.simpledb.domain.ListDomainsResponse;
import org.jclouds.simpledb.options.ListDomainsOptions;

/**
* Provides access to SimpleDB via their REST API.
Expand Down Expand Up @@ -78,7 +72,7 @@ public interface SimpleDBClient {
* You can create up to 100 domains per account.
* <p/>
* If you require additional domains, go to
* http://aws.amazon.com/contact-us/simpledb-limit-request/.
* http://amazon.com/contact-us/simpledb-limit-request/.
*
* @param region
* Domains are Region-specific.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,15 +17,15 @@
* ====================================================================
*/

package org.jclouds.aws.simpledb;
package org.jclouds.simpledb;

import java.util.List;
import java.util.Properties;

import org.jclouds.aws.simpledb.config.SimpleDBRestClientModule;
import org.jclouds.http.config.JavaUrlHttpCommandExecutorServiceModule;
import org.jclouds.logging.jdk.config.JDKLoggingModule;
import org.jclouds.rest.RestContextBuilder;
import org.jclouds.simpledb.config.SimpleDBRestClientModule;

import com.google.inject.Injector;
import com.google.inject.Module;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,44 +17,46 @@
* ====================================================================
*/

package org.jclouds.aws.simpledb;
package org.jclouds.simpledb;

import static org.jclouds.Constants.PROPERTY_API_VERSION;
import static org.jclouds.Constants.PROPERTY_ENDPOINT;
import static org.jclouds.aws.domain.Region.AP_SOUTHEAST_1;
import static org.jclouds.aws.domain.Region.EU_WEST_1;
import static org.jclouds.aws.domain.Region.US_EAST_1;
import static org.jclouds.aws.domain.Region.US_WEST_1;
import static org.jclouds.aws.reference.AWSConstants.PROPERTY_AUTH_TAG;
import static org.jclouds.aws.reference.AWSConstants.PROPERTY_HEADER_TAG;
import static org.jclouds.aws.reference.AWSConstants.PROPERTY_REGIONS;

import java.util.Properties;
import java.util.Set;

import org.jclouds.PropertiesBuilder;
import org.jclouds.aws.domain.Region;

import com.google.common.base.Joiner;
import com.google.common.collect.ImmutableSet;

/**
* Builds properties used in SimpleDB Clients
*
* @author Adrian Cole
*/
public class SimpleDBPropertiesBuilder extends PropertiesBuilder {
public static Set<String> DEFAULT_REGIONS = ImmutableSet.of(EU_WEST_1, US_EAST_1, US_WEST_1, AP_SOUTHEAST_1);

@Override
protected Properties defaultProperties() {
Properties properties = super.defaultProperties();
properties.setProperty(PROPERTY_AUTH_TAG, "AWS");
properties.setProperty(PROPERTY_HEADER_TAG, "amz");
properties.setProperty(PROPERTY_API_VERSION, SimpleDBAsyncClient.VERSION);
properties.setProperty(PROPERTY_REGIONS, Joiner.on(',').join(Region.US_EAST_1,
Region.US_WEST_1, Region.EU_WEST_1, Region.AP_SOUTHEAST_1));
properties.setProperty(PROPERTY_REGIONS, Joiner.on(',').join(DEFAULT_REGIONS));
properties.setProperty(PROPERTY_ENDPOINT, "https://sdb.amazonaws.com");
properties.setProperty(PROPERTY_ENDPOINT + "." + Region.US_EAST_1,
"https://sdb.amazonaws.com");
properties.setProperty(PROPERTY_ENDPOINT + "." + Region.US_WEST_1,
"https://sdb.us-west-1.amazonaws.com");
properties.setProperty(PROPERTY_ENDPOINT + "." + Region.EU_WEST_1,
"https://sdb.eu-west-1.amazonaws.com");
properties.setProperty(PROPERTY_ENDPOINT + "." + Region.AP_SOUTHEAST_1,
"https://sdb.ap-southeast-1.amazonaws.com");
properties.setProperty(PROPERTY_ENDPOINT + "." + US_EAST_1, "https://sdb.amazonaws.com");
properties.setProperty(PROPERTY_ENDPOINT + "." + US_WEST_1, "https://sdb.us-west-1.amazonaws.com");
properties.setProperty(PROPERTY_ENDPOINT + "." + EU_WEST_1, "https://sdb.eu-west-1.amazonaws.com");
properties.setProperty(PROPERTY_ENDPOINT + "." + AP_SOUTHEAST_1, "https://sdb.ap-southeast-1.amazonaws.com");
return properties;
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.jclouds.aws.simpledb.binders;
package org.jclouds.simpledb.binders;

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
Expand All @@ -7,8 +7,8 @@
import java.util.Collection;
import java.util.Iterator;

import org.jclouds.aws.simpledb.domain.AttributePair;
import org.jclouds.aws.simpledb.domain.Item;
import org.jclouds.simpledb.domain.AttributePair;
import org.jclouds.simpledb.domain.Item;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.utils.ModifyRequest;
import org.jclouds.rest.Binder;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@
* ====================================================================
*/

package org.jclouds.aws.simpledb.config;
package org.jclouds.simpledb.config;

import org.jclouds.aws.config.AWSFormSigningRestClientModule;
import org.jclouds.aws.simpledb.SimpleDBAsyncClient;
import org.jclouds.aws.simpledb.SimpleDBClient;
import org.jclouds.http.RequiresHttp;
import org.jclouds.rest.ConfiguresRestClient;
import org.jclouds.simpledb.SimpleDBAsyncClient;
import org.jclouds.simpledb.SimpleDBClient;

/**
* Configures the SimpleDB connection.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package org.jclouds.aws.simpledb.domain;
package org.jclouds.simpledb.domain;

import java.util.ArrayList;
import java.util.List;


/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* ====================================================================
*/

package org.jclouds.aws.simpledb.domain;
package org.jclouds.simpledb.domain;

import java.util.Date;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package org.jclouds.aws.simpledb.domain;
package org.jclouds.simpledb.domain;

import javax.annotation.Nullable;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* ====================================================================
*/

package org.jclouds.aws.simpledb.domain;
package org.jclouds.simpledb.domain;

import java.util.Set;

Expand All @@ -35,4 +35,4 @@ public interface ListDomainsResponse extends Set<String> {
*/
String getNextToken();

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* ====================================================================
*/

package org.jclouds.aws.simpledb.options;
package org.jclouds.simpledb.options;

import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Preconditions.checkNotNull;
Expand All @@ -31,7 +31,7 @@
* (if needed):
* <p/>
* <code>
* import static org.jclouds.aws.simpledb.options.ListDomainsOptions.Builder.*
* import static org.jclouds.simpledb.options.ListDomainsOptions.Builder.*
* <p/>
* SimpleDBClient connection = // get connection
* Set<String> domains = connection.listDomainsInRegion(maxNumberOfDomains(1));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@
* @author Adrian Cole
* @author Luís A. Bastião Silva <bastiao@ua.pt>
*/
package org.jclouds.aws.simpledb;
package org.jclouds.simpledb;
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
* ====================================================================
*/

package org.jclouds.aws.simpledb.reference;
package org.jclouds.simpledb.reference;

/**
* Configuration properties and constants used in SimpleDB connections.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,4 @@
* This package contains properties and reference data used in SimpleDB.
* @author Adrian Cole
*/
package org.jclouds.aws.simpledb.reference;
package org.jclouds.simpledb.reference;
Original file line number Diff line number Diff line change
Expand Up @@ -17,22 +17,20 @@
* ====================================================================
*/

package org.jclouds.aws.simpledb.xml;
package org.jclouds.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 org.jclouds.simpledb.domain.AttributePair;
import org.jclouds.simpledb.domain.Item;
import org.xml.sax.Attributes;

import com.google.common.collect.LinkedHashMultimap;
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;

/**
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
* ====================================================================
*/

package org.jclouds.aws.simpledb.xml;
package org.jclouds.simpledb.xml;

import java.util.LinkedHashSet;
import java.util.Set;

import org.jclouds.aws.simpledb.domain.ListDomainsResponse;
import org.jclouds.simpledb.domain.ListDomainsResponse;
import org.jclouds.http.functions.ParseSax;

import com.google.common.collect.Iterables;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/**
*
* Copyright (C) 2010 Cloud Conscious, LLC. <info@cloudconscious.com>
*
* ====================================================================
* 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.simpledb;

import org.jclouds.rest.Providers;
import org.testng.annotations.Test;

import com.google.common.collect.Iterables;

/**
*
* @author Adrian Cole
*
*/
@Test(groups = "unit")
public class ProvidersInPropertiesTest {

@Test
public void testSupportedProviders() {
Iterable<String> providers = Providers.getSupportedProviders();
assert Iterables.contains(providers, "simpledb") : providers;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,17 @@
* ====================================================================
*/

package org.jclouds.aws.simpledb;
package org.jclouds.simpledb;

import static org.jclouds.simpledb.SimpleDBPropertiesBuilder.DEFAULT_REGIONS;
import static org.testng.Assert.assertEquals;

import java.io.IOException;
import java.lang.reflect.Method;
import java.util.Map;
import java.util.Properties;

import org.jclouds.aws.domain.Region;
import org.jclouds.aws.filters.FormSigner;
import org.jclouds.aws.simpledb.config.SimpleDBRestClientModule;
import org.jclouds.aws.simpledb.options.ListDomainsOptions;
import org.jclouds.aws.simpledb.xml.ListDomainsResponseHandler;
import org.jclouds.http.HttpRequest;
import org.jclouds.http.RequiresHttp;
import org.jclouds.http.functions.ParseSax;
Expand All @@ -40,6 +37,9 @@
import org.jclouds.rest.RestContextFactory;
import org.jclouds.rest.RestContextSpec;
import org.jclouds.rest.internal.RestAnnotationProcessor;
import org.jclouds.simpledb.config.SimpleDBRestClientModule;
import org.jclouds.simpledb.options.ListDomainsOptions;
import org.jclouds.simpledb.xml.ListDomainsResponseHandler;
import org.testng.annotations.Test;

import com.google.inject.Module;
Expand Down Expand Up @@ -100,7 +100,7 @@ public void testCreateDomainInRegion() throws SecurityException, NoSuchMethodExc
@Test(enabled = false)
public void testAllRegions() throws SecurityException, NoSuchMethodException, IOException {
Method method = SimpleDBAsyncClient.class.getMethod("putAttributes", String.class, String.class);
for (String region : Region.ALL_SIMPLEDB) {
for (String region : DEFAULT_REGIONS) {
processor.createRequest(method, region, "domainName");
}
}
Expand Down
Loading

0 comments on commit 0eccc39

Please sign in to comment.