diff options
author | jesus m. rodriguez <jesusr@redhat.com> | 2009-11-16 16:31:01 -0500 |
---|---|---|
committer | jesus m. rodriguez <jesusr@redhat.com> | 2009-11-16 16:31:01 -0500 |
commit | 3bbe389257a650428646258ae2473c3278981f26 (patch) | |
tree | a587c8d982fd32ed02ef1b6ca893f071e4116bd5 | |
parent | 496668a823f8538bad82fd93defc24ab0da8c04b (diff) | |
parent | 6a5cf056d3493d40716c2ec1c487862301c7d427 (diff) | |
download | candlepin-3bbe389257a650428646258ae2473c3278981f26.tar.gz candlepin-3bbe389257a650428646258ae2473c3278981f26.tar.xz candlepin-3bbe389257a650428646258ae2473c3278981f26.zip |
Merge branch 'master' into buildr
-rw-r--r-- | proxy/README | 3 | ||||
-rw-r--r-- | proxy/build.xml | 2 | ||||
-rwxr-xr-x | proxy/code/scripts/test-entitlementapi.py | 2 | ||||
-rwxr-xr-x | proxy/code/scripts/test-poolapi.py | 4 | ||||
-rwxr-xr-x | proxy/code/scripts/test-productapi.py | 11 | ||||
-rw-r--r-- | proxy/code/src/org/fedoraproject/candlepin/resource/ProductResource.java | 58 |
6 files changed, 76 insertions, 4 deletions
diff --git a/proxy/README b/proxy/README index 649465d..c082dc7 100644 --- a/proxy/README +++ b/proxy/README @@ -1,2 +1 @@ -the proxy is an entitlement server used to manage -entitlements. +the proxy is an entitlement server used to manage entitlements. diff --git a/proxy/build.xml b/proxy/build.xml index 87a8fd3..c0a48eb 100644 --- a/proxy/build.xml +++ b/proxy/build.xml @@ -587,7 +587,7 @@ <property name="dir.genhbm" value="build/schemagen/" /> - <target name="gen-schema"> + <target name="gen-schema" depends="init-taskdefs"> <delete dir="${dir.genhbm}" /> <mkdir dir="${dir.genhbm}" /> diff --git a/proxy/code/scripts/test-entitlementapi.py b/proxy/code/scripts/test-entitlementapi.py index 8930316..78551d4 100755 --- a/proxy/code/scripts/test-entitlementapi.py +++ b/proxy/code/scripts/test-entitlementapi.py @@ -25,4 +25,4 @@ print("get: %s" % rsp) response = urllib.urlopen('http://localhost:8080/candlepin/entitlement/list') rsp = response.read() -print("list: %s" % rsp)
\ No newline at end of file +print("list: %s" % rsp) diff --git a/proxy/code/scripts/test-poolapi.py b/proxy/code/scripts/test-poolapi.py index f297ef2..bfb09c6 100755 --- a/proxy/code/scripts/test-poolapi.py +++ b/proxy/code/scripts/test-poolapi.py @@ -7,3 +7,7 @@ import simplejson response = urllib.urlopen('http://localhost:8080/candlepin/entitlementpool') rsp = response.read() print("list: %s" % rsp) +pool = simplejson.loads(rsp) +print(type(pool)) +for (k, v) in pool.iteritems(): + print("pool[%s] = '%s'" % (k, v)) diff --git a/proxy/code/scripts/test-productapi.py b/proxy/code/scripts/test-productapi.py new file mode 100755 index 0000000..ee95906 --- /dev/null +++ b/proxy/code/scripts/test-productapi.py @@ -0,0 +1,11 @@ +#!/usr/bin/python + +import httplib, urllib +import sys +import simplejson + +response = urllib.urlopen('http://localhost:8080/candlepin/product') +rsp = response.read() +print("list: %s" % rsp) +prod = simplejson.loads(rsp) +print(type(prod)) diff --git a/proxy/code/src/org/fedoraproject/candlepin/resource/ProductResource.java b/proxy/code/src/org/fedoraproject/candlepin/resource/ProductResource.java new file mode 100644 index 0000000..1316230 --- /dev/null +++ b/proxy/code/src/org/fedoraproject/candlepin/resource/ProductResource.java @@ -0,0 +1,58 @@ +/** + * Copyright (c) 2008 Red Hat, Inc. + * + * This software is licensed to you under the GNU General Public License, + * version 2 (GPLv2). There is NO WARRANTY for this software, express or + * implied, including the implied warranties of MERCHANTABILITY or FITNESS + * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 + * along with this software; if not, see + * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. + * + * Red Hat trademarks are not licensed under GPLv2. No permission is + * granted to use or replicate Red Hat trademarks that are incorporated + * in this software or its documentation. + */ +package org.fedoraproject.candlepin.resource; + +import org.fedoraproject.candlepin.model.ObjectFactory; +import org.fedoraproject.candlepin.model.Product; + +import java.util.ArrayList; +import java.util.List; + +import javax.ws.rs.GET; +import javax.ws.rs.Path; +import javax.ws.rs.Produces; +import javax.ws.rs.core.MediaType; + + +/** + * API Gateway into /product + * @version $Rev$ + */ +@Path("/product") +public class ProductResource extends BaseResource { + + /** + * default ctor + */ + public ProductResource() { + super(Product.class); + } + + + /** + * returns the list of Products available. + * @return the list of available products. + */ + @GET + @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) + public List<Product> list() { + List<Object> u = ObjectFactory.get().listObjectsByClass(getApiClass()); + List<Product> products = new ArrayList<Product>(); + for (Object o : u) { + products.add((Product) o); + } + return products; + } +} |