REST: mazání
authorFrantišek Kučera <franta-hg@frantovo.cz>
Tue Apr 06 00:50:30 2010 +0200 (2010-04-06)
changeset 94ac4a5fc868eb
parent 93 ac53dcce11a9
child 95 ec671fc8fb9c
REST: mazání
java/nekurak.net-ejb/src/java/cz/frantovo/nekurak/dao/ClanekDAO.java
java/nekurak.net-ejb/src/java/cz/frantovo/nekurak/ejb/ClanekEJB.java
java/nekurak.net-lib/src/cz/frantovo/nekurak/ejb/ClanekRemote.java
java/nekurak.net-rest/src/java/cz/frantovo/nekurak/rest/ClankyREST.java
     1.1 --- a/java/nekurak.net-ejb/src/java/cz/frantovo/nekurak/dao/ClanekDAO.java	Tue Apr 06 00:32:12 2010 +0200
     1.2 +++ b/java/nekurak.net-ejb/src/java/cz/frantovo/nekurak/dao/ClanekDAO.java	Tue Apr 06 00:50:30 2010 +0200
     1.3 @@ -4,6 +4,7 @@
     1.4  import java.util.Collection;
     1.5  import javax.ejb.LocalBean;
     1.6  import javax.ejb.Stateless;
     1.7 +import javax.jms.Session;
     1.8  import javax.persistence.EntityManager;
     1.9  import javax.persistence.PersistenceContext;
    1.10  import javax.persistence.Query;
    1.11 @@ -35,4 +36,9 @@
    1.12      public void upravClanek(Clanek clanek) {
    1.13  	em.merge(clanek);
    1.14      }
    1.15 +
    1.16 +    public void smazClanek(Clanek clanek) {
    1.17 +	clanek = em.merge(clanek);
    1.18 +	em.remove(clanek);
    1.19 +    }
    1.20  }
     2.1 --- a/java/nekurak.net-ejb/src/java/cz/frantovo/nekurak/ejb/ClanekEJB.java	Tue Apr 06 00:32:12 2010 +0200
     2.2 +++ b/java/nekurak.net-ejb/src/java/cz/frantovo/nekurak/ejb/ClanekEJB.java	Tue Apr 06 00:50:30 2010 +0200
     2.3 @@ -34,4 +34,9 @@
     2.4      public void upravClanek(Clanek clanek) {
     2.5  	clanekDAO.upravClanek(clanek);
     2.6      }
     2.7 +
     2.8 +    //@RolesAllowed("redaktor")
     2.9 +    public void smazClanek(Clanek clanek) {
    2.10 +	clanekDAO.smazClanek(clanek);
    2.11 +    }
    2.12  }
     3.1 --- a/java/nekurak.net-lib/src/cz/frantovo/nekurak/ejb/ClanekRemote.java	Tue Apr 06 00:32:12 2010 +0200
     3.2 +++ b/java/nekurak.net-lib/src/cz/frantovo/nekurak/ejb/ClanekRemote.java	Tue Apr 06 00:50:30 2010 +0200
     3.3 @@ -18,4 +18,6 @@
     3.4      public void upravClanek(Clanek clanek);
     3.5  
     3.6      public Collection<Clanek> getClanky();
     3.7 +
     3.8 +    public void smazClanek(Clanek clanek);
     3.9  }
     4.1 --- a/java/nekurak.net-rest/src/java/cz/frantovo/nekurak/rest/ClankyREST.java	Tue Apr 06 00:32:12 2010 +0200
     4.2 +++ b/java/nekurak.net-rest/src/java/cz/frantovo/nekurak/rest/ClankyREST.java	Tue Apr 06 00:50:30 2010 +0200
     4.3 @@ -67,5 +67,8 @@
     4.4      @DELETE
     4.5      @Path("/{id}")
     4.6      public void smaz(@PathParam("id") int id) {
     4.7 +	Clanek c = new Clanek();
     4.8 +	c.setId(id);
     4.9 +	hledac.getClanekEJB().smazClanek(c);
    4.10      }
    4.11  }