package br.edu.ifpb.nutrif.service;

import java.io.UnsupportedEncodingException;

import javax.annotation.security.PermitAll;
import javax.servlet.ServletContext;
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.HttpHeaders;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response.Status;

import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;

/**
 * Root of RESTful api. It provides login and logout. Also have method for
 * printing every method which is provides by RESTful api.
 * 
 * @author Rostislav Novak (Computing and Information Centre, CTU in Prague)
 * 
 */
@Path("/")
public class NutrIFRestIndex {
    
	private static Logger logger = LogManager.getLogger(NutrIFRestIndex.class);

    @javax.ws.rs.core.Context public static ServletContext servletContext;

    /**
     * Return html page with information about REST api. It contains methods all
     * methods provide by REST api.
     * 
     * @return HTML page which has information about all methods of REST api.
     */
    @PermitAll
    @GET
    @Produces(MediaType.TEXT_HTML)
    public String sayHtmlHello() { 
    	
    	logger.info("Acesso ao index do servio.");
    	
        return "<html>"
        		+ "<head>"
        		+ "	<meta http-equiv='content-type' content='text/html; charset=UTF-8'>"
        		+ "	<title>NutrIF Service - Home</title>"
        		+ "</head>" 
        		+ "<body>"
                	+ " <h1>NutrIF - Services </h1>"
                	+ " Server path: " + servletContext.getContextPath()
                	+ " <a href='servicos'>Servios</a>"
                + "</body></html> ";
    }

    /**
     * Method to check current status of the service and logged in user.
     * 
     * okay: true | false
     * authenticated: true | false
     * epersonEMAIL: user@example.com
     * epersonNAME: John Doe
     * @param headers
     * @return
     */
    @PermitAll
    @GET
    @Path("/status")
    @Consumes({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
    public Status status(@Context HttpHeaders headers) throws UnsupportedEncodingException {
    	return null;
    }
}

@@ -210,16 +210,41 @@
 rs.GET;%0A
+import javax.ws.rs.POST;%0A
 import j
@@ -394,16 +394,50 @@
 iaType;%0A
+import javax.ws.rs.core.Response;%0A
 import j
@@ -2114,18 +2114,17 @@
    @
-Consum
+Produc
 es(
-%7B
 Medi
@@ -2149,37 +2149,10 @@
 JSON
-, MediaType.APPLICATION_XML%7D
 )
+%09
 %0A   
@@ -2203,16 +2203,23 @@
 eaders) 
+%0A    %09%09
 throws U
@@ -2248,16 +2248,22 @@
 ption %7B%0A
+    %09%0A
     %09ret
@@ -2270,12 +2270,26 @@
 urn 
-null
+Response.Status.OK
 ;%0A  

Teste para o serviço