diff options
| author | jesus m. rodriguez <jesusr@redhat.com> | 2009-11-16 16:30:00 -0500 |
|---|---|---|
| committer | jesus m. rodriguez <jesusr@redhat.com> | 2009-11-16 16:30:00 -0500 |
| commit | 4cfab46babfc3db27ec4afa0c62ffe821b2e5c07 (patch) | |
| tree | 5cd154d756359078ab9b532c7514c2adee4212fb /proxy/code/src | |
| parent | ff68ba177bee145a7496f5173bd55834336ba521 (diff) | |
| download | candlepin-4cfab46babfc3db27ec4afa0c62ffe821b2e5c07.tar.gz candlepin-4cfab46babfc3db27ec4afa0c62ffe821b2e5c07.tar.xz candlepin-4cfab46babfc3db27ec4afa0c62ffe821b2e5c07.zip | |
adding GET /products/ list
Diffstat (limited to 'proxy/code/src')
| -rw-r--r-- | proxy/code/src/org/fedoraproject/candlepin/resource/ProductResource.java | 58 |
1 files changed, 58 insertions, 0 deletions
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; + } +} |
