// Path: modules/exemplary/src/main/java/com/intuit/autumn/exemplary/data/Ping.java
// public class Ping {
// 
//     private String id;
//     private String message;
// 
//     /**
//      * Empty constructor.
//      *
//      * note: necessary default constructor used by jackson for serialization/deserialization
//      */
// 
//     public Ping() {
//     }
// 
//     /**
//      * Constructor with configurable state.
//      *
//      * @param id instance id
//      * @param message instance payload
//      */
// 
//     public Ping(String id, String message) {
//         this.id = id;
//         this.message = message;
//     }
// 
//     /**
//      * Get instance id.
//      *
//      * @return instance id
//      */
// 
//     public String getId() {
//         return id;
//     }
// 
//     /**
//      * Set instance id.
//      *
//      * @param id instance id
//      */
// 
//     public void setId(String id) {
//         this.id = id;
//     }
// 
//     /**
//      * Get instance payload.
//      *
//      * @return instance payload
//      */
// 
//     public String getMessage() {
//         return message;
//     }
// 
//     /**
//      * Set instance payload.
//      *
//      * @param message instance payload
//      */
// 
//     public void setMessage(String message) {
//         this.message = message;
//     }
// 
//     /**
//      * Instance JSON representation.
//      *
//      * @return json representation
//      */
// 
//     @Override
//     public String toString() {
//         return format("Ping{id='%s',message='%s'}", id, message);
//     }
// }
// 
// Path: modules/web/src/main/java/com/intuit/autumn/web/HttpHeader.java
// public class HttpHeader {
// 
//     private final CacheControl cacheControl;
// 
//     @Inject
//     public HttpHeader() {
//         cacheControl = new CacheControl();
// 
//         cacheControl.setPrivate(TRUE);
//         cacheControl.setNoCache(TRUE);
//     }
// 
//     public Response.ResponseBuilder headers() {
//         return headers(OK);
//     }
// 
//     public Response.ResponseBuilder headers(Response.Status status) {
//         return headers(status.getStatusCode());
//     }
// 
//     public Response.ResponseBuilder headers(int status) {
//         return status(status)
//                 .cacheControl(cacheControl)
//                 .header(ACCESS_CONTROL_ALLOW_ORIGIN, "*")
//                 .header(ACCESS_CONTROL_ALLOW_HEADERS, "Authorization,X-Forwarded-For,Accept-Language,Content-Type")
//                 .header(ACCESS_CONTROL_ALLOW_METHODS, "GET,POST,OPTIONS")
//                 .header(ACCESS_CONTROL_REQUEST_METHOD, "GET,POST,OPTIONS");
// //                .header("X-Application-Id", applicationName);
//     }
// }


import com.codahale.metrics.Counter;
import com.codahale.metrics.MetricRegistry;
import com.codahale.metrics.Timer;
import com.google.common.base.Joiner;
import com.google.inject.Inject;
import com.intuit.autumn.exemplary.data.Ping;
import com.intuit.autumn.web.HttpHeader;
import org.slf4j.Logger;
import javax.ws.rs.*;
import javax.ws.rs.core.Response;
import javax.ws.rs.ext.Provider;
import java.util.List;
import java.util.UUID;
import static com.google.common.base.Joiner.on;
import static java.util.Arrays.asList;
import static java.util.UUID.fromString;
import static java.util.UUID.randomUUID;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
import static org.slf4j.LoggerFactory.getLogger;
/*
 * Copyright 2016 Intuit
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.intuit.autumn.exemplary.server;




/**
 * Prototypical application endpoint implementation.
 */

@Provider
@Path("/proto")
public class PingService {

    private static final Joiner JOINER = on(",");
    private static final Logger LOGGER = getLogger(PingService.class);
    private final HttpHeader httpHeader;
    private final Counter getPingCounter;
    private final Timer getPingTimer;
    private final Counter postPingCounter;
    private final Counter getPingsCounter;
    private final Timer getPingsTimer;

    /**
     * Instantiation method.
     *
     * @param metricRegistry operational metrics registry
     */

    @Inject
    public PingService(final HttpHeader httpHeader, final MetricRegistry metricRegistry) {
        this.httpHeader = httpHeader;
        getPingCounter = metricRegistry.counter("get-ping-counter");
        getPingTimer = metricRegistry.timer("get-ping-timer");
        postPingCounter = metricRegistry.counter("post-ping-counter");
        getPingsCounter = metricRegistry.counter("get-pings-counter");
        getPingsTimer = metricRegistry.timer("get-pings-timer");
    }

    /**
     * Object reader, retrieving the object associated with the provided ID.
     *
     * @param id object ID
     * @return representative object
     * @throws Exception
     */

    @GET
    @Path("/ping/{id}")
    @Produces(APPLICATION_JSON)
    public Response ping(@PathParam("id") String id) throws Exception {
        getPingCounter.inc();
        LOGGER.debug("getting ping id: {}, count: {}", id, getPingCounter.getCount());

// Path: modules/exemplary/src/main/java/com/intuit/autumn/exemplary/data/Ping.java
// public class Ping {
// 
//     private String id;
//     private String message;
// 
//     /**
//      * Empty constructor.
//      *
//      * note: necessary default constructor used by jackson for serialization/deserialization
//      */
// 
//     public Ping() {
//     }
// 
//     /**
//      * Constructor with configurable state.
//      *
//      * @param id instance id
//      * @param message instance payload
//      */
// 
//     public Ping(String id, String message) {
//         this.id = id;
//         this.message = message;
//     }
// 
//     /**
//      * Get instance id.
//      *
//      * @return instance id
//      */
// 
//     public String getId() {
//         return id;
//     }
// 
//     /**
//      * Set instance id.
//      *
//      * @param id instance id
//      */
// 
//     public void setId(String id) {
//         this.id = id;
//     }
// 
//     /**
//      * Get instance payload.
//      *
//      * @return instance payload
//      */
// 
//     public String getMessage() {
//         return message;
//     }
// 
//     /**
//      * Set instance payload.
//      *
//      * @param message instance payload
//      */
// 
//     public void setMessage(String message) {
//         this.message = message;
//     }
// 
//     /**
//      * Instance JSON representation.
//      *
//      * @return json representation
//      */
// 
//     @Override
//     public String toString() {
//         return format("Ping{id='%s',message='%s'}", id, message);
//     }
// }
// 
// Path: modules/web/src/main/java/com/intuit/autumn/web/HttpHeader.java
// public class HttpHeader {
// 
//     private final CacheControl cacheControl;
// 
//     @Inject
//     public HttpHeader() {
//         cacheControl = new CacheControl();
// 
//         cacheControl.setPrivate(TRUE);
//         cacheControl.setNoCache(TRUE);
//     }
// 
//     public Response.ResponseBuilder headers() {
//         return headers(OK);
//     }
// 
//     public Response.ResponseBuilder headers(Response.Status status) {
//         return headers(status.getStatusCode());
//     }
// 
//     public Response.ResponseBuilder headers(int status) {
//         return status(status)
//                 .cacheControl(cacheControl)
//                 .header(ACCESS_CONTROL_ALLOW_ORIGIN, "*")
//                 .header(ACCESS_CONTROL_ALLOW_HEADERS, "Authorization,X-Forwarded-For,Accept-Language,Content-Type")
//                 .header(ACCESS_CONTROL_ALLOW_METHODS, "GET,POST,OPTIONS")
//                 .header(ACCESS_CONTROL_REQUEST_METHOD, "GET,POST,OPTIONS");
// //                .header("X-Application-Id", applicationName);
//     }
// }


// Path: modules/exemplary/src/main/java/com/intuit/autumn/exemplary/server/PingService.java
import com.codahale.metrics.Counter;
import com.codahale.metrics.MetricRegistry;
import com.codahale.metrics.Timer;
import com.google.common.base.Joiner;
import com.google.inject.Inject;
import com.intuit.autumn.exemplary.data.Ping;
import com.intuit.autumn.web.HttpHeader;
import org.slf4j.Logger;
import javax.ws.rs.*;
import javax.ws.rs.core.Response;
import javax.ws.rs.ext.Provider;
import java.util.List;
import java.util.UUID;
import static com.google.common.base.Joiner.on;
import static java.util.Arrays.asList;
import static java.util.UUID.fromString;
import static java.util.UUID.randomUUID;
import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
import static org.slf4j.LoggerFactory.getLogger;

/*
 * Copyright 2016 Intuit
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.intuit.autumn.exemplary.server;




/**
 * Prototypical application endpoint implementation.
 */

@Provider
@Path("/proto")
public class PingService {

    private static final Joiner JOINER = on(",");
    private static final Logger LOGGER = getLogger(PingService.class);
    private final HttpHeader httpHeader;
    private final Counter getPingCounter;
    private final Timer getPingTimer;
    private final Counter postPingCounter;
    private final Counter getPingsCounter;
    private final Timer getPingsTimer;

    /**
     * Instantiation method.
     *
     * @param metricRegistry operational metrics registry
     */

    @Inject
    public PingService(final HttpHeader httpHeader, final MetricRegistry metricRegistry) {
        this.httpHeader = httpHeader;
        getPingCounter = metricRegistry.counter("get-ping-counter");
        getPingTimer = metricRegistry.timer("get-ping-timer");
        postPingCounter = metricRegistry.counter("post-ping-counter");
        getPingsCounter = metricRegistry.counter("get-pings-counter");
        getPingsTimer = metricRegistry.timer("get-pings-timer");
    }

    /**
     * Object reader, retrieving the object associated with the provided ID.
     *
     * @param id object ID
     * @return representative object
     * @throws Exception
     */

    @GET
    @Path("/ping/{id}")
    @Produces(APPLICATION_JSON)
    public Response ping(@PathParam("id") String id) throws Exception {
        getPingCounter.inc();
        LOGGER.debug("getting ping id: {}, count: {}", id, getPingCounter.getCount());

        Ping ping;