author | František Kučera <franta-hg@frantovo.cz> |
Mon Apr 05 22:21:01 2010 +0200 (2010-04-05) | |
changeset 89 | 59ba044de164 |
parent 88 | a5339bcce9a2 |
child 90 | 0967d5e3b470 |
permissions | -rw-r--r-- |
franta-hg@86 | 1 |
package cz.frantovo.nekurak.rest; |
franta-hg@86 | 2 |
|
franta-hg@87 | 3 |
import javax.ws.rs.Consumes; |
franta-hg@89 | 4 |
import javax.ws.rs.DELETE; |
franta-hg@86 | 5 |
import javax.ws.rs.GET; |
franta-hg@89 | 6 |
import javax.ws.rs.POST; |
franta-hg@87 | 7 |
import javax.ws.rs.PUT; |
franta-hg@86 | 8 |
import javax.ws.rs.Path; |
franta-hg@88 | 9 |
import javax.ws.rs.PathParam; |
franta-hg@86 | 10 |
import javax.ws.rs.Produces; |
franta-hg@86 | 11 |
|
franta-hg@86 | 12 |
@Path("clanek") |
franta-hg@86 | 13 |
public class ClankyREST { |
franta-hg@86 | 14 |
|
franta-hg@89 | 15 |
private static final String MIME_XML = "text/xml"; |
franta-hg@87 | 16 |
|
franta-hg@89 | 17 |
/** Vypíšeme seznam všech článků v systému */ |
franta-hg@89 | 18 |
@GET |
franta-hg@89 | 19 |
@Path("/") |
franta-hg@89 | 20 |
@Produces("text/plain") |
franta-hg@89 | 21 |
public String getClanky() { |
franta-hg@89 | 22 |
return "tady bude seznam"; |
franta-hg@89 | 23 |
} |
franta-hg@89 | 24 |
|
franta-hg@89 | 25 |
/** Získáme konkrétní článek */ |
franta-hg@86 | 26 |
@GET |
franta-hg@88 | 27 |
@Path("/{id}") |
franta-hg@86 | 28 |
@Produces("text/plain") |
franta-hg@89 | 29 |
//@Produces(MIME_XML) |
franta-hg@89 | 30 |
public String ziskej(@PathParam("id") int id) { |
franta-hg@89 | 31 |
return "jeden článek: " + id; |
franta-hg@87 | 32 |
} |
franta-hg@87 | 33 |
|
franta-hg@89 | 34 |
/** |
franta-hg@89 | 35 |
* Vložíme nový článek |
franta-hg@89 | 36 |
* @return ID založeného článku |
franta-hg@89 | 37 |
*/ |
franta-hg@89 | 38 |
@POST |
franta-hg@89 | 39 |
@Consumes(MIME_XML) |
franta-hg@89 | 40 |
@Produces("text/plain") |
franta-hg@89 | 41 |
public int zaloz() { |
franta-hg@89 | 42 |
return 0; |
franta-hg@89 | 43 |
} |
franta-hg@89 | 44 |
|
franta-hg@89 | 45 |
/** Aktualizujeme článek */ |
franta-hg@87 | 46 |
@PUT |
franta-hg@89 | 47 |
@Consumes(MIME_XML) |
franta-hg@89 | 48 |
@Path("/{id}") |
franta-hg@89 | 49 |
public void uloz(@PathParam("id") int id) { |
franta-hg@89 | 50 |
} |
franta-hg@89 | 51 |
|
franta-hg@89 | 52 |
/** Smažeme článek */ |
franta-hg@89 | 53 |
@DELETE |
franta-hg@89 | 54 |
@Path("/{id}") |
franta-hg@89 | 55 |
public void smaz(@PathParam("id") int id) { |
franta-hg@86 | 56 |
} |
franta-hg@86 | 57 |
} |