| .. | .. |
|---|
| 46 | 46 | @Inject |
|---|
| 47 | 47 | Provider<EntityManager> emProvider; |
|---|
| 48 | 48 | |
|---|
| 49 | | - private static final Logger log = LogManager.getLogger(ApplicationResource.class); |
|---|
| 49 | + private static final Logger LOG = LogManager.getLogger(ApplicationResource.class); |
|---|
| 50 | 50 | |
|---|
| 51 | 51 | public ApplicationResource() { |
|---|
| 52 | 52 | } |
|---|
| .. | .. |
|---|
| 60 | 60 | @Produces( |
|---|
| 61 | 61 | { MediaType.APPLICATION_JSON }) |
|---|
| 62 | 62 | public Response index() { |
|---|
| 63 | | - log.info("Getting applications list "); |
|---|
| 63 | + LOG.info("Getting applications list "); |
|---|
| 64 | 64 | |
|---|
| 65 | 65 | EntityManager em = emProvider.get(); |
|---|
| 66 | 66 | TypedQuery<Application> q = em.createNamedQuery("list-applications", Application.class); |
|---|
| .. | .. |
|---|
| 78 | 78 | @Produces( |
|---|
| 79 | 79 | { MediaType.APPLICATION_JSON }) |
|---|
| 80 | 80 | public Response get(@PathParam("appid") String appid, @HeaderParam(TokenHelper.TOKEN_HEADER_PÀRAM) String token) { |
|---|
| 81 | | - log.info("Getting application data for id: {}: ", appid); |
|---|
| 81 | + LOG.info("Getting application data for id: {}: ", appid); |
|---|
| 82 | 82 | if (appid == null || appid.equals("")) { |
|---|
| 83 | | - log.error("Application ID is mandatory"); |
|---|
| 83 | + LOG.error("Application ID is mandatory"); |
|---|
| 84 | 84 | return Response.status(Status.NOT_FOUND).build(); |
|---|
| 85 | 85 | } |
|---|
| 86 | 86 | |
|---|
| 87 | 87 | EntityManager em = emProvider.get(); |
|---|
| 88 | 88 | Application app = em.find(Application.class, Integer.parseInt(appid)); |
|---|
| 89 | 89 | if (app == null) { |
|---|
| 90 | | - log.error("Application with id {} not found in DB", appid); |
|---|
| 90 | + LOG.error("Application with id {} not found in DB", appid); |
|---|
| 91 | 91 | |
|---|
| 92 | 92 | return Response.status(Status.NOT_FOUND).header(DefaultExceptionHandler.ERROR_MESSAGE_HEADER, "Application not found with ID: " + appid).build(); |
|---|
| 93 | 93 | } |
|---|
| .. | .. |
|---|
| 101 | 101 | { MediaType.APPLICATION_JSON }) |
|---|
| 102 | 102 | @Transactional |
|---|
| 103 | 103 | public Response create(Application app, @HeaderParam(TokenHelper.TOKEN_HEADER_PÀRAM) String token) { |
|---|
| 104 | | - log.info("Creating new application"); |
|---|
| 104 | + LOG.info("Creating new application"); |
|---|
| 105 | 105 | EntityManager em = emProvider.get(); |
|---|
| 106 | 106 | app.setCreationTimestamp(new Date()); |
|---|
| 107 | 107 | em.persist(app); |
|---|
| .. | .. |
|---|
| 117 | 117 | @Produces( |
|---|
| 118 | 118 | { MediaType.APPLICATION_JSON }) |
|---|
| 119 | 119 | public Response modify(Application app, @PathParam("appid") String appid, @HeaderParam(TokenHelper.TOKEN_HEADER_PÀRAM) String token) { |
|---|
| 120 | | - log.info("Modifying application with id: {}", appid); |
|---|
| 120 | + LOG.info("Modifying application with id: {}", appid); |
|---|
| 121 | 121 | EntityManager em = emProvider.get(); |
|---|
| 122 | 122 | Application currentapp = em.find(Application.class, Integer.parseInt(appid)); |
|---|
| 123 | 123 | if (currentapp == null) { |
|---|
| 124 | | - log.error("Application with id {} not found in DB", appid); |
|---|
| 124 | + LOG.error("Application with id {} not found in DB", appid); |
|---|
| 125 | 125 | return Response.status(Status.NOT_FOUND).header(DefaultExceptionHandler.ERROR_MESSAGE_HEADER, "Application not found with ID: " + appid).build(); |
|---|
| 126 | 126 | } |
|---|
| 127 | 127 | currentapp.setName(app.getName()); |
|---|
| .. | .. |
|---|
| 137 | 137 | @Produces( |
|---|
| 138 | 138 | { MediaType.APPLICATION_JSON }) |
|---|
| 139 | 139 | public Response delete(@PathParam("appid") String appid, @Context HttpServletRequest request) { |
|---|
| 140 | | - log.info("Deleting app with id: {}", appid); |
|---|
| 140 | + LOG.info("Deleting app with id: {}", appid); |
|---|
| 141 | 141 | EntityManager em = emProvider.get(); |
|---|
| 142 | 142 | Application app = em.find(Application.class, Integer.parseInt(appid)); |
|---|
| 143 | 143 | if (app == null) { |
|---|
| 144 | | - log.error("Application with id {} can not be deleted, It was not found in DB", appid); |
|---|
| 144 | + LOG.error("Application with id {} can not be deleted, It was not found in DB", appid); |
|---|
| 145 | 145 | return Response.status(Status.NOT_FOUND).header(DefaultExceptionHandler.ERROR_MESSAGE_HEADER, "Application not found with ID: " + appid).build(); |
|---|
| 146 | 146 | } |
|---|
| 147 | 147 | |
|---|