diff --git a/aws/demos/simpledb/README.txt b/aws/demos/simpledb/README.txt new file mode 100644 index 0000000000..f072b3aec6 --- /dev/null +++ b/aws/demos/simpledb/README.txt @@ -0,0 +1,29 @@ +==== + + 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. + ==================================================================== +==== + +# +# this is a simple example command line client to test usage of simpledb +# functions like putAttribute is tested and then it select and retrieve results. +# 1. execute 'mvn install' to build the sample +# 2. invoke the jar, passing your aws credentials and the bucket you wish to create +# ex. +# java -jar target/jclouds-aws-demo-simpledb-jar-with-dependencies.jar $AWS_USER $AWS_PWD simpledbtest + + +# Further information: Luís A. astião Silva bastiao@ua.pt> diff --git a/aws/demos/simpledb/pom.xml b/aws/demos/simpledb/pom.xml new file mode 100644 index 0000000000..7f1f67771f --- /dev/null +++ b/aws/demos/simpledb/pom.xml @@ -0,0 +1,75 @@ + + + + + 4.0.0 + + org.jclouds + jclouds-aws-demos-project + 1.0-SNAPSHOT + + jclouds-aws-demo-simpledb + jclouds simpledb sample that putAttributes and select it + jclouds simpledb sample that putAttributes and select it + + ${project.artifactId} + + + + org.apache.maven.plugins + maven-jar-plugin + + + + org.jclouds.aws.s3.samples.MainApp + + + + + + + maven-assembly-plugin + + + jar-with-dependencies + + + + org.jclouds.aws.simpledb.samples.MainApp + + + + + + make-assembly + package + + single + + + + + + + + + diff --git a/aws/demos/simpledb/src/main/java/org/jclouds/aws/simpledb/samples/MainApp.java b/aws/demos/simpledb/src/main/java/org/jclouds/aws/simpledb/samples/MainApp.java new file mode 100644 index 0000000000..1323f836da --- /dev/null +++ b/aws/demos/simpledb/src/main/java/org/jclouds/aws/simpledb/samples/MainApp.java @@ -0,0 +1,80 @@ +/** + * + * 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.samples; + +import java.io.IOException; +import java.util.Map; +import java.util.Properties; + +import org.jclouds.aws.domain.Region; +import org.jclouds.aws.simpledb.SimpleDBAsyncClient; +import org.jclouds.aws.simpledb.SimpleDBClient; +import org.jclouds.aws.simpledb.domain.AttributePair; +import org.jclouds.aws.simpledb.domain.Item; +import org.jclouds.aws.simpledb.options.ListDomainsOptions; +import org.jclouds.rest.RestContext; +import org.jclouds.rest.RestContextFactory; + +import com.google.common.collect.LinkedHashMultimap; +import com.google.common.collect.Multimap; + + +/** + * This the Main class of an Application that demonstrates the use of the simpledb. + * + * Usage is: java MainApp \"accesskeyid\" \"secretkey\" + * + * @author Luís A. Bastião Silva + * + */ +public class MainApp +{ + + public static int PARAMETERS = 3; + public static String INVALID_SYNTAX = "Invalid number of parameters. Syntax is: \"accesskeyid\" \"secretkey\" \"bucketName\" "; + + public static void main(String[] args) throws IOException { + + + // Args + String accesskeyid = args[0]; + String secretkey = args[1]; + Properties properties = new Properties(); + properties.setProperty("simpledb.identity", accesskeyid); + properties.setProperty("simpledb.credential", secretkey); + + + RestContext context = new RestContextFactory().createContext("simpledb", "AKIAJODKICBEKG7MM4XA", "FfqiNSiC88B6tJPDIOKUWUJGY68BQaQpkNz6Fsgq", new Properties()); + AttributePair p = new AttributePair("AccessNumber", "1213123", true); + Multimap m =LinkedHashMultimap.create(); + m.put("AccessNumber", p); + Item attributes = new Item(m); + + // Use Provider API + context.getApi().putAttributes(Region.EU_WEST_1, "tse", "AccessNumber", attributes ); + //context.getApi().createDomainInRegion(Region.EU_WEST_1, "tse"); + Map results = context.getApi().select(Region.EU_WEST_1, "select * from tse"); + System.out.println(results); + ListDomainsOptions [] list = new ListDomainsOptions[100]; + //context.getApi().listDomainsInRegion(Region.EU_WEST_1, list); + System.out.println(list[0]); + context.close(); + } +}