Advertisement
Guest User

Untitled

a guest
Jun 25th, 2017
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.64 KB | None | 0 0
  1. /*
  2.  * To change this license header, choose License Headers in Project Properties.
  3.  * To change this template file, choose Tools | Templates
  4.  * and open the template in the editor.
  5.  */
  6. package resources;
  7.  
  8. import java.util.ArrayList;
  9. import java.util.List;
  10. import javax.ejb.Singleton;
  11. import javax.ws.rs.core.Context;
  12. import javax.ws.rs.core.UriInfo;
  13. import javax.ws.rs.Consumes;
  14. import javax.ws.rs.Produces;
  15. import javax.ws.rs.GET;
  16. import javax.ws.rs.Path;
  17. import javax.ws.rs.PUT;
  18. import javax.ws.rs.core.MediaType;
  19.  
  20. /**
  21.  * REST Web Service
  22.  *
  23.  * @author tomas
  24.  */
  25. @Singleton
  26. @Path("zoznam")
  27. public class ZoznamResource {
  28.  
  29.     @Context
  30.     private UriInfo context;
  31.     private List<String> zoznam;
  32.  
  33.  
  34.  
  35.  
  36.     /**
  37.      * Creates a new instance of ZoznamResource
  38.      */
  39.     public ZoznamResource() {
  40.         zoznam = new ArrayList<>();
  41.         zoznam.add("test1");
  42.         zoznam.add("test2");
  43.     }
  44.  
  45.     /**
  46.      * Retrieves representation of an instance of resources.ZoznamResource
  47.      * @return an instance of java.lang.String
  48.      */
  49.     @GET
  50.     @Path("zoznam")
  51.     @Produces(MediaType.TEXT_PLAIN)
  52.     public String getText() {
  53.         //TODO return proper representation object
  54.         StringBuilder ret = new StringBuilder();
  55.         zoznam.forEach(val->{
  56.                 ret.append(val).append("\n");
  57.                         });
  58.         return ret.toString();
  59.     }
  60.  
  61.     /**
  62.      * PUT method for updating or creating an instance of ZoznamResource
  63.      * @param content representation for the resource
  64.      */
  65.     @PUT
  66.     @Consumes(MediaType.TEXT_PLAIN)
  67.     public void putText(String content) {
  68.     }
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement