| .. | .. |
|---|
| 6 | 6 | |
|---|
| 7 | 7 | import javax.annotation.security.RolesAllowed; |
|---|
| 8 | 8 | import javax.inject.Inject; |
|---|
| 9 | | -import javax.inject.Provider; |
|---|
| 10 | 9 | import javax.persistence.EntityManager; |
|---|
| 11 | 10 | import javax.persistence.TypedQuery; |
|---|
| 12 | 11 | import javax.servlet.http.HttpServletRequest; |
|---|
| 12 | +import javax.transaction.Transactional; |
|---|
| 13 | 13 | import javax.ws.rs.Consumes; |
|---|
| 14 | 14 | import javax.ws.rs.DELETE; |
|---|
| 15 | 15 | import javax.ws.rs.GET; |
|---|
| .. | .. |
|---|
| 39 | 39 | import org.apache.logging.log4j.LogManager; |
|---|
| 40 | 40 | import org.apache.logging.log4j.Logger; |
|---|
| 41 | 41 | |
|---|
| 42 | | -import com.google.inject.persist.Transactional; |
|---|
| 43 | | - |
|---|
| 44 | 42 | /** |
|---|
| 45 | 43 | * LicenseType resource, this service will provide methods to create, modify and |
|---|
| 46 | 44 | * delete license types |
|---|
| .. | .. |
|---|
| 56 | 54 | TokenHelper tokenHelper; |
|---|
| 57 | 55 | |
|---|
| 58 | 56 | @Inject |
|---|
| 59 | | - Provider<EntityManager> emProvider; |
|---|
| 57 | + EntityManager em; |
|---|
| 60 | 58 | |
|---|
| 61 | 59 | public LicenseTypeResource() { |
|---|
| 62 | 60 | } |
|---|
| .. | .. |
|---|
| 74 | 72 | public Response index() { |
|---|
| 75 | 73 | LOG.info("Getting license types list "); |
|---|
| 76 | 74 | |
|---|
| 77 | | - EntityManager em = emProvider.get(); |
|---|
| 75 | + // EntityManager em = emProvider.get(); |
|---|
| 78 | 76 | em.clear(); |
|---|
| 79 | 77 | TypedQuery<LicenseType> q = em.createNamedQuery("list-license_types", LicenseType.class); |
|---|
| 80 | 78 | List<LicenseType> list = q.getResultList(); |
|---|
| .. | .. |
|---|
| 100 | 98 | return Response.status(Status.NOT_FOUND).build(); |
|---|
| 101 | 99 | } |
|---|
| 102 | 100 | |
|---|
| 103 | | - EntityManager em = emProvider.get(); |
|---|
| 101 | + // EntityManager em = emProvider.get(); |
|---|
| 104 | 102 | em.clear(); |
|---|
| 105 | 103 | LicenseType lt = em.find(LicenseType.class, Integer.parseInt(ltid)); |
|---|
| 106 | 104 | if (lt == null) { |
|---|
| .. | .. |
|---|
| 121 | 119 | @RolesAllowed(BasicSecurityContext.ROL_ADMIN) |
|---|
| 122 | 120 | public Response create(LicenseType lt, @HeaderParam(TokenHelper.TOKEN_HEADER_PÀRAM) String token) { |
|---|
| 123 | 121 | LOG.info("Creating new license type"); |
|---|
| 124 | | - EntityManager em = emProvider.get(); |
|---|
| 122 | + // EntityManager em = emProvider.get(); |
|---|
| 125 | 123 | |
|---|
| 126 | 124 | try { |
|---|
| 127 | 125 | setApplication(lt, lt.getApplicationId(), em); |
|---|
| .. | .. |
|---|
| 162 | 160 | @RolesAllowed(BasicSecurityContext.ROL_ADMIN) |
|---|
| 163 | 161 | public Response modify(LicenseType lt, @PathParam("ltid") String ltid, @HeaderParam(TokenHelper.TOKEN_HEADER_PÀRAM) String token) { |
|---|
| 164 | 162 | LOG.info("Modifying license type with id: {}", ltid); |
|---|
| 165 | | - EntityManager em = emProvider.get(); |
|---|
| 163 | + // EntityManager em = emProvider.get(); |
|---|
| 166 | 164 | LicenseType currentlt = em.find(LicenseType.class, Integer.parseInt(ltid)); |
|---|
| 167 | 165 | if (currentlt == null) { |
|---|
| 168 | 166 | LOG.error("LicenseType with id {} not found in DB", ltid); |
|---|
| .. | .. |
|---|
| 229 | 227 | @RolesAllowed(BasicSecurityContext.ROL_ADMIN) |
|---|
| 230 | 228 | public Response delete(@PathParam("ltid") String ltid, @Context HttpServletRequest request) { |
|---|
| 231 | 229 | LOG.info("Deleting app with id: {}", ltid); |
|---|
| 232 | | - EntityManager em = emProvider.get(); |
|---|
| 230 | + // EntityManager em = emProvider.get(); |
|---|
| 233 | 231 | LicenseType app = em.find(LicenseType.class, Integer.parseInt(ltid)); |
|---|
| 234 | 232 | if (app == null) { |
|---|
| 235 | 233 | LOG.error("LicenseType with id {} can not be deleted, It was not found in DB", ltid); |
|---|