69 lines
2.2 KiB
Java
69 lines
2.2 KiB
Java
package org.gcube.acme.rest;
|
|
|
|
import javax.ws.rs.Consumes;
|
|
import javax.ws.rs.DELETE;
|
|
import javax.ws.rs.DefaultValue;
|
|
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;
|
|
import javax.ws.rs.QueryParam;
|
|
import javax.ws.rs.core.Response;
|
|
|
|
import com.webcohesion.enunciate.metadata.rs.RequestHeader;
|
|
import com.webcohesion.enunciate.metadata.rs.RequestHeaders;
|
|
import com.webcohesion.enunciate.metadata.rs.ResourceGroup;
|
|
import com.webcohesion.enunciate.metadata.rs.ResourceLabel;
|
|
import com.webcohesion.enunciate.metadata.rs.ResponseCode;
|
|
import com.webcohesion.enunciate.metadata.rs.StatusCodes;
|
|
|
|
@Path("greetings")
|
|
@ResourceGroup("Greetings APIs")
|
|
@ResourceLabel("Greetings APIs")
|
|
@RequestHeaders ({
|
|
@RequestHeader( name = "Authorization", description = "Bearer token, see <a href=\"https://dev.d4science.org/how-to-access-resources\">https://dev.d4science.org/how-to-access-resources</a>")
|
|
})
|
|
public class HelloWorld {
|
|
|
|
@GET
|
|
@Produces({"application/json;charset=UTF-8", "application/vnd.api+json"})
|
|
public String list(@QueryParam("limit") @DefaultValue("10") int limit,
|
|
@QueryParam("offset") @DefaultValue("0") int offset) {
|
|
|
|
return "[\"saluti\",\"saluti_volgari\"]";
|
|
}
|
|
|
|
@POST
|
|
@Produces("application/json;charset=UTF-8")
|
|
@Consumes("application/json;charset=UTF-8")
|
|
public String create(String json) {
|
|
Greeting g = new Greeting();
|
|
return g.create(json);
|
|
}
|
|
|
|
@PUT
|
|
@Path("/{greeting_name}")
|
|
@Consumes("application/json;charset=UTF-8")
|
|
@Produces("application/json;charset=UTF-8")
|
|
@StatusCodes ({
|
|
@ResponseCode ( code = 200, condition = "The greeting has been updated successfully.")
|
|
})
|
|
// @AuthorizationControl(allowedRoles={"boss"}, exception=NotAuthorizedException.class)
|
|
public String update(@PathParam("greeting_name") String name, String json) {
|
|
return "{}";
|
|
}
|
|
|
|
|
|
@DELETE
|
|
@Path("/{greeting_name}")
|
|
@StatusCodes ({
|
|
@ResponseCode ( code = 204, condition = "The item has been deleted successfully."),
|
|
@ResponseCode ( code = 404, condition = "The item was not found.")
|
|
})
|
|
public String delete(@PathParam("greeting_name") String name) {
|
|
return "{}";
|
|
}
|
|
}
|