package com.sangdol.experiment.portableDb;

import com.codahale.metrics.annotation.Timed;

import javax.ws.rs.*;
import javax.ws.rs.core.MediaType;
import java.util.List;

/**
 * @author hugh
 */
@Path("/user")
@Produces(MediaType.APPLICATION_JSON)
public class ViewResource {
    private ViewService viewService;

    public ViewResource(ViewService viewService) {
        this.viewService = viewService;
    }

    @GET
    @Path("{id}")
    @Timed
    public List<View> viewList(@PathParam("id") int hostId) {
        checkValidity(hostId);

        return viewService.getLatest10Visitors(hostId);
    }

    @POST
    @Path("{id}")
    @Timed
    public int createView(@PathParam("id") int hostId, @QueryParam("visitor_id") int visitorId) {
        checkValidity(visitorId);

        return viewService.createView(hostId, visitorId);
    }

    private void checkValidity(int userId) {
        if (userId < 1)
            throw new WebApplicationException(404);
    }

    @POST
    @Path("clear")
    @Timed
    public String clear() {
        viewService.clear();
        return "Success";
    }

    @GET
    @Path("view-counts")
    @Timed
    public List<Integer> viewCount() {
        return viewService.getAllViewCounts();
    }
}

@@ -429,35 +429,24 @@
 ath(%22%7Bid%7D%22)%0A
-    @Timed%0A
     public L
@@ -618,27 +618,16 @@
 %22%7Bid%7D%22)%0A
-    @Timed%0A
     publ
@@ -973,27 +973,16 @@
 clear%22)%0A
-    @Timed%0A
     publ
@@ -1101,19 +1101,8 @@
 s%22)%0A
-    @Timed%0A
     

Remove unused annotations