Java tutorial
/* ======================================================================== * Copyright 2014 miso4204 * * Licensed under the MIT, The MIT License (MIT) * Copyright (c) 2014 miso4204 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. * ======================================================================== Source generated by CrudMaker version 1.0.0.qualifier */ package co.edu.uniandes.csw.miso4204.wishlistitem.service; import co.edu.uniandes.csw.miso4204.security.jwt.api.JsonWebToken; import co.edu.uniandes.csw.miso4204.security.jwt.api.JwtHashAlgorithm; import java.util.List; import javax.ws.rs.DELETE; import javax.ws.rs.GET; import javax.ws.rs.POST; import javax.ws.rs.PUT; import javax.ws.rs.Path; import javax.ws.rs.PathParam; import javax.ws.rs.QueryParam; import javax.ws.rs.QueryParam; import org.springframework.beans.factory.annotation.Autowired; import co.edu.uniandes.csw.miso4204.wishlistitem.logic.ejb.WishListItemLogicService; import co.edu.uniandes.csw.miso4204.wishlistitem.logic.dto.WishListItemDTO; import co.edu.uniandes.csw.miso4204.wishlistitem.logic.dto.WishListItemPageDTO; import com.google.gson.Gson; import com.google.gson.JsonElement; import com.google.gson.JsonObject; import java.util.Map; public abstract class _WishListItemService { @Autowired protected WishListItemLogicService wishListItemLogicService; @POST public WishListItemDTO createWishListItem(WishListItemDTO wishListItem) { return wishListItemLogicService.createWishListItem(wishListItem); } @DELETE @Path("{id}") public void deleteWishListItem(@PathParam("id") Long id) { wishListItemLogicService.deleteWishListItem(id); } @GET public WishListItemPageDTO getWishListItems(@QueryParam("page") Integer page, @QueryParam("maxRecords") Integer maxRecords) { return wishListItemLogicService.getWishListItems(page, maxRecords); } @GET @Path("{id}") public WishListItemDTO getWishListItem(@PathParam("id") Long id) { return wishListItemLogicService.getWishListItem(id); } @GET @Path("get_top_5") public List<WishListItemDTO> getTop5() { return wishListItemLogicService.getTop5(); } @PUT public void updateWishListItem(@PathParam("id") Long id, WishListItemDTO wishListItem) { wishListItemLogicService.updateWishListItem(wishListItem); } @GET @Path("validate/{token}") public Long validateUser(@PathParam("token") String token) { String respuesta; String id = "-1"; try { Gson gsonUtil = new Gson(); respuesta = JsonWebToken.decode(token.replace("\"", ""), "Un14nd3s2014@", true); JsonElement jsonPayload = gsonUtil.fromJson(respuesta, JsonElement.class); JsonObject jobjPayload = jsonPayload.getAsJsonObject(); id = (String) jobjPayload.get("id").getAsString(); } catch (Exception ex) { return Long.parseLong("-1"); } return Long.parseLong(id); } }