// Path: linkshortener-api/src/main/java/be/drissamri/rest/LinkController.java
// @Component
// @Path(LinkController.LINKS)
// public class LinkController {
//   private static final Logger LOGGER = LoggerFactory.getLogger(LinkController.class);
//   public static final String LINKS = "/links";
//   private final LinkService service;
// 
//   @Autowired
//   public LinkController(LinkService srvc) {
//     this.service = srvc;
//   }
// 
//   @GET
//   @Produces(MediaType.APPLICATION_JSON)
//   public final Response find(
//     @Context UriInfo context,
//     @QueryParam("expand") @DefaultValue("false") final boolean expand,
//     @QueryParam("offset") @DefaultValue("1") final int offset,
//     @QueryParam("limit") @DefaultValue("10") final int limit) throws Exception {
//     LOGGER.debug("Find links request. expand: {} - offset: {}, limit: {}", expand, offset, limit);
// 
//     final List<LinkEntity> foundLinks = service.find(offset, limit);
// 
//     final List<Resource> resources = foundLinks
//       .stream()
//       .map(link -> expand ? new LinkResource(context, link) : new Resource(context, link.getHash()))
//       .collect(Collectors.toList());
// 
//     final CollectionResource collection = new CollectionResource(context, resources, offset, limit);
//     LOGGER.debug("Returning collection of {} links", collection.get("size"));
//     return Response.ok().entity(collection).build();
//   }
// 
//   @POST
//   @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
//   @Produces(MediaType.APPLICATION_JSON)
//   public final Response createShortLink(@Context UriInfo context, @FormParam("url") String url) {
//     LOGGER.debug("Shorten request for: {}", url);
//     final LinkResource link = new LinkResource(context, this.service.create(url));
//     LOGGER.debug("Returning link: {}", link);
//     return created(link);
//   }
// 
//   @DELETE
//   @Path("/{hash}")
//   @Produces(MediaType.APPLICATION_JSON)
//   public final Response deleteLinkByHash(@PathParam(value = "hash") String hash) {
//     LOGGER.info("Request link delete for hash: {}", hash);
//     this.service.deleteByHash(hash);
//     return Response.noContent().build();
//   }
// 
//   private Response created(Resource createdResource) {
//     final String href = (String) createdResource.get("href");
//     return Response
//       .created(URI.create(href))
//       .entity(createdResource)
//       .build();
//   }
// }
// 
// Path: linkshortener-api/src/main/java/be/drissamri/rest/RedirectController.java
// @Component
// @Path("/")
// public class RedirectController {
//   private LinkService service;
// 
//   @Autowired
//   public RedirectController(LinkService srvc) {
//     this.service = srvc;
//   }
// 
//   @GET
//   @Path("/{hash}")
//   public Response redirect(@PathParam("hash") String hash) {
//     Response response;
// 
//     final String url = service.findUrlByHash(hash);
//     if (!StringUtils.isEmpty(url)) {
//       URI uri = URI.create(url);
//       response = Response
//         .status(Response.Status.MOVED_PERMANENTLY)
//         .location(uri)
//         .build();
//     } else {
//       response = Response
//         .status(Response.Status.BAD_REQUEST)
//         .build();
//     }
// 
//     return response;
//   }
// }


import be.drissamri.rest.LinkController;
import be.drissamri.rest.RedirectController;
import javax.ws.rs.ApplicationPath;
import org.glassfish.jersey.server.ResourceConfig;
import org.springframework.stereotype.Component;
/*
 * The MIT License (MIT)
 *
 * Copyright (c) 2014 Driss Amri
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */
package be.drissamri.config;


@Component
@ApplicationPath("/api/v1")
public class JerseyConfig extends ResourceConfig {

  public JerseyConfig() {
    packages("be.drissamri.rest");
// Path: linkshortener-api/src/main/java/be/drissamri/rest/LinkController.java
// @Component
// @Path(LinkController.LINKS)
// public class LinkController {
//   private static final Logger LOGGER = LoggerFactory.getLogger(LinkController.class);
//   public static final String LINKS = "/links";
//   private final LinkService service;
// 
//   @Autowired
//   public LinkController(LinkService srvc) {
//     this.service = srvc;
//   }
// 
//   @GET
//   @Produces(MediaType.APPLICATION_JSON)
//   public final Response find(
//     @Context UriInfo context,
//     @QueryParam("expand") @DefaultValue("false") final boolean expand,
//     @QueryParam("offset") @DefaultValue("1") final int offset,
//     @QueryParam("limit") @DefaultValue("10") final int limit) throws Exception {
//     LOGGER.debug("Find links request. expand: {} - offset: {}, limit: {}", expand, offset, limit);
// 
//     final List<LinkEntity> foundLinks = service.find(offset, limit);
// 
//     final List<Resource> resources = foundLinks
//       .stream()
//       .map(link -> expand ? new LinkResource(context, link) : new Resource(context, link.getHash()))
//       .collect(Collectors.toList());
// 
//     final CollectionResource collection = new CollectionResource(context, resources, offset, limit);
//     LOGGER.debug("Returning collection of {} links", collection.get("size"));
//     return Response.ok().entity(collection).build();
//   }
// 
//   @POST
//   @Consumes(MediaType.APPLICATION_FORM_URLENCODED)
//   @Produces(MediaType.APPLICATION_JSON)
//   public final Response createShortLink(@Context UriInfo context, @FormParam("url") String url) {
//     LOGGER.debug("Shorten request for: {}", url);
//     final LinkResource link = new LinkResource(context, this.service.create(url));
//     LOGGER.debug("Returning link: {}", link);
//     return created(link);
//   }
// 
//   @DELETE
//   @Path("/{hash}")
//   @Produces(MediaType.APPLICATION_JSON)
//   public final Response deleteLinkByHash(@PathParam(value = "hash") String hash) {
//     LOGGER.info("Request link delete for hash: {}", hash);
//     this.service.deleteByHash(hash);
//     return Response.noContent().build();
//   }
// 
//   private Response created(Resource createdResource) {
//     final String href = (String) createdResource.get("href");
//     return Response
//       .created(URI.create(href))
//       .entity(createdResource)
//       .build();
//   }
// }
// 
// Path: linkshortener-api/src/main/java/be/drissamri/rest/RedirectController.java
// @Component
// @Path("/")
// public class RedirectController {
//   private LinkService service;
// 
//   @Autowired
//   public RedirectController(LinkService srvc) {
//     this.service = srvc;
//   }
// 
//   @GET
//   @Path("/{hash}")
//   public Response redirect(@PathParam("hash") String hash) {
//     Response response;
// 
//     final String url = service.findUrlByHash(hash);
//     if (!StringUtils.isEmpty(url)) {
//       URI uri = URI.create(url);
//       response = Response
//         .status(Response.Status.MOVED_PERMANENTLY)
//         .location(uri)
//         .build();
//     } else {
//       response = Response
//         .status(Response.Status.BAD_REQUEST)
//         .build();
//     }
// 
//     return response;
//   }
// }


// Path: linkshortener-api/src/main/java/be/drissamri/config/JerseyConfig.java
import be.drissamri.rest.LinkController;
import be.drissamri.rest.RedirectController;
import javax.ws.rs.ApplicationPath;
import org.glassfish.jersey.server.ResourceConfig;
import org.springframework.stereotype.Component;

/*
 * The MIT License (MIT)
 *
 * Copyright (c) 2014 Driss Amri
 *
 * Permission is hereby granted, free of charge, to any person obtaining a copy
 * of this software and associated documentation files (the "Software"), to deal
 * in the Software without restriction, including without limitation the rights
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
 * copies of the Software, and to permit persons to whom the Software is
 * furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in all
 * copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
 * SOFTWARE.
 */
package be.drissamri.config;


@Component
@ApplicationPath("/api/v1")
public class JerseyConfig extends ResourceConfig {

  public JerseyConfig() {
    packages("be.drissamri.rest");
    register(LinkController.class);