rsanchez
2015-01-28 da889d489da5d7fa8c71d9f21f24b1dc2e29d8e1
securis/src/main/java/net/curisit/securis/services/ApplicationResource.java
....@@ -6,10 +6,10 @@
66
77 import javax.annotation.security.RolesAllowed;
88 import javax.inject.Inject;
9
-import javax.inject.Provider;
109 import javax.persistence.EntityManager;
1110 import javax.persistence.TypedQuery;
1211 import javax.servlet.http.HttpServletRequest;
12
+import javax.transaction.Transactional;
1313 import javax.ws.rs.Consumes;
1414 import javax.ws.rs.DELETE;
1515 import javax.ws.rs.GET;
....@@ -39,8 +39,6 @@
3939 import org.apache.logging.log4j.LogManager;
4040 import org.apache.logging.log4j.Logger;
4141
42
-import com.google.inject.persist.Transactional;
43
-
4442 /**
4543 * Application resource, this service will provide methods to create, modify and
4644 * delete applications
....@@ -54,7 +52,7 @@
5452 TokenHelper tokenHelper;
5553
5654 @Inject
57
- Provider<EntityManager> emProvider;
55
+ EntityManager em;
5856
5957 private static final Logger LOG = LogManager.getLogger(ApplicationResource.class);
6058
....@@ -74,7 +72,7 @@
7472 public Response index() {
7573 LOG.info("Getting applications list ");
7674
77
- EntityManager em = emProvider.get();
75
+ // EntityManager em = emProvider.get();
7876 em.clear();
7977 TypedQuery<Application> q = em.createNamedQuery("list-applications", Application.class);
8078 List<Application> list = q.getResultList();
....@@ -100,7 +98,7 @@
10098 return Response.status(Status.NOT_FOUND).build();
10199 }
102100
103
- EntityManager em = emProvider.get();
101
+ // EntityManager em = emProvider.get();
104102 em.clear();
105103
106104 Application app = null;
....@@ -138,7 +136,7 @@
138136 @RolesAllowed(BasicSecurityContext.ROL_ADMIN)
139137 public Response create(Application app, @HeaderParam(TokenHelper.TOKEN_HEADER_PÀRAM) String token) {
140138 LOG.info("Creating new application");
141
- EntityManager em = emProvider.get();
139
+ // EntityManager em = emProvider.get();
142140 app.setCreationTimestamp(new Date());
143141 em.persist(app);
144142 LOG.info("App ID: {}", app.getId());
....@@ -167,7 +165,7 @@
167165 @RolesAllowed(BasicSecurityContext.ROL_ADMIN)
168166 public Response modify(Application app, @PathParam("appid") String appid, @HeaderParam(TokenHelper.TOKEN_HEADER_PÀRAM) String token) {
169167 LOG.info("Modifying application with id: {}", appid);
170
- EntityManager em = emProvider.get();
168
+ // EntityManager em = emProvider.get();
171169 Application currentapp = em.find(Application.class, Integer.parseInt(appid));
172170 if (currentapp == null) {
173171 LOG.error("Application with id {} not found in DB", appid);
....@@ -214,7 +212,7 @@
214212 @RolesAllowed(BasicSecurityContext.ROL_ADMIN)
215213 public Response delete(@PathParam("appid") String appid, @Context HttpServletRequest request) {
216214 LOG.info("Deleting app with id: {}", appid);
217
- EntityManager em = emProvider.get();
215
+ // EntityManager em = emProvider.get();
218216 Application app = em.find(Application.class, Integer.parseInt(appid));
219217 if (app == null) {
220218 LOG.error("Application with id {} can not be deleted, It was not found in DB", appid);