package uk.gov.register.resources;

import io.dropwizard.views.View;
import uk.gov.register.configuration.RegisterTrackingConfiguration;
import uk.gov.register.core.RegisterReadOnly;
import uk.gov.register.views.ViewFactory;
import uk.gov.register.views.representations.ExtraMediaType;

import javax.inject.Inject;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;
import java.security.NoSuchAlgorithmException;

@Path("/")
public class HomePageResource {
    private final RegisterReadOnly register;
    private final ViewFactory viewFactory;
    private final RegisterTrackingConfiguration config;

    @Inject
    public HomePageResource(RegisterReadOnly register, ViewFactory viewFactory, RegisterTrackingConfiguration config) {
        this.register = register;
        this.viewFactory = viewFactory;
        this.config = config;
    }

    @GET
    @Produces({ExtraMediaType.TEXT_HTML})
    public View home() throws NoSuchAlgorithmException {
        return viewFactory.homePageView(
                register.getTotalRecords(),
                register.getTotalEntries(),
                register.getLastUpdatedTime()
        );
    }

    @GET
    @Path("/robots.txt")
    @Produces(MediaType.TEXT_PLAIN)
    public String robots() {
        return "User-agent: *\n" +
                "Disallow: /\n";
    }
    @GET
    @Path("/analytics-code.js")
    @Produces(ExtraMediaType.APPLICATION_JAVASCRIPT)
    public String analyticsTrackingId() {
        return config.getRegisterTrackingId().map(
                trackingId -> "var gaTrackingId = \"" + trackingId + "\";\n"
        ).orElse("");
    }
}

@@ -297,21 +297,92 @@
 vax.
-inject.Inject
+annotation.security.PermitAll;%0Aimport javax.inject.Inject;%0Aimport javax.ws.rs.DELETE
 ;%0Aim
@@ -457,16 +457,16 @@
 oduces;%0A
-
 import j
@@ -492,16 +492,50 @@
 iaType;%0A
+import javax.ws.rs.core.Response;%0A
 import j
@@ -1479,16 +1479,17 @@
 ;%0A    %7D%0A
+%0A
     @GET
@@ -1771,11 +1771,206 @@
 );%0A    %7D
+%0A%0A    @DELETE%0A    @PermitAll%0A    @Path(%22/delete-register-data%22)%0A    public Response deleteRegisterData() %7B%0A        return Response.status(501).entity(%22Data has been deleted - not%22).build();%0A    %7D
 %0A%7D%0A

Add protected unimplemented enpoint /delete-register-data