/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package service;

import be.luckycode.projetawebservice.Usergroup;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;

/**
 *
 * @author michael
 */
@Stateless
@Path("be.luckycode.projetawebservice.usergroup")
public class UsergroupFacadeREST extends AbstractFacade<Usergroup> {
    @PersistenceContext(unitName = "be.luckycode_projeta-webservice_war_1.0-SNAPSHOTPU")
    private EntityManager em;

    public UsergroupFacadeREST() {
        super(Usergroup.class);
    }

    @POST
    @Override
    @Consumes({"application/xml", "application/json"})
    public void create(Usergroup entity) {
        super.create(entity);
    }

    @PUT
    @Override
    @Consumes({"application/xml", "application/json"})
    public void edit(Usergroup entity) {
        super.edit(entity);
    }

    @DELETE
    @Path("{id}")
    public void remove(@PathParam("id") Integer id) {
        super.remove(super.find(id));
    }

    @GET
    @Path("{id}")
    @Produces({"application/xml", "application/json"})
    public Usergroup find(@PathParam("id") Integer id) {
        return super.find(id);
    }

    @GET
    @Override
    @Produces({"application/xml", "application/json"})
    public List<Usergroup> findAll() {
        return super.findAll();
    }

    @GET
    @Path("{from}/{to}")
    @Produces({"application/xml", "application/json"})
    public List<Usergroup> findRange(@PathParam("from") Integer from, @PathParam("to") Integer to) {
        return super.findRange(new int[]{from, to});
    }

    @GET
    @Path("count")
    @Produces("text/plain")
    public String countREST() {
        return String.valueOf(super.count());
    }

    @java.lang.Override
    protected EntityManager getEntityManager() {
        return em;
    }
    
}

@@ -183,16 +183,63 @@
 l.List;%0A
+import javax.annotation.security.RolesAllowed;%0A
 import j
@@ -258,16 +258,16 @@
 teless;%0A
-
 import j
@@ -944,37 +944,67 @@
    @
-Consumes(%7B%22application/xml%22, 
+RolesAllowed(%7B%22administrator%22, %22developer%22%7D)%0A    @Consumes(
 %22app
@@ -1009,33 +1009,32 @@
 pplication/json%22
-%7D
 )%0A    public voi
@@ -1131,37 +1131,67 @@
    @
-Consumes(%7B%22application/xml%22, 
+RolesAllowed(%7B%22administrator%22, %22developer%22%7D)%0A    @Consumes(
 %22app
@@ -1196,33 +1196,32 @@
 pplication/json%22
-%7D
 )%0A    public voi
@@ -1452,36 +1452,16 @@
 roduces(
-%7B%22application/xml%22, 
 %22applica
@@ -1462,33 +1462,32 @@
 pplication/json%22
-%7D
 )%0A    public Use
@@ -1604,36 +1604,16 @@
 roduces(
-%7B%22application/xml%22, 
 %22applica
@@ -1614,33 +1614,32 @@
 pplication/json%22
-%7D
 )%0A    public Lis
@@ -1754,28 +1754,8 @@
 ces(
-%7B%22application/xml%22, 
 %22app
@@ -1768,17 +1768,16 @@
 on/json%22
-%7D
 )%0A    pu

Return "application/json" in UsergroupFacadeREST.