| .. | .. |
|---|
| 7 | 7 | |
|---|
| 8 | 8 | import javax.annotation.security.RolesAllowed; |
|---|
| 9 | 9 | import javax.inject.Inject; |
|---|
| 10 | | -import javax.inject.Provider; |
|---|
| 11 | 10 | import javax.persistence.EntityManager; |
|---|
| 12 | 11 | import javax.persistence.TypedQuery; |
|---|
| 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.FormParam; |
|---|
| .. | .. |
|---|
| 46 | 46 | import org.apache.logging.log4j.LogManager; |
|---|
| 47 | 47 | import org.apache.logging.log4j.Logger; |
|---|
| 48 | 48 | |
|---|
| 49 | | -import com.google.inject.persist.Transactional; |
|---|
| 50 | | - |
|---|
| 51 | 49 | /** |
|---|
| 52 | 50 | * Pack resource, this service will provide methods to create, modify and delete |
|---|
| 53 | 51 | * packs |
|---|
| .. | .. |
|---|
| 63 | 61 | TokenHelper tokenHelper; |
|---|
| 64 | 62 | |
|---|
| 65 | 63 | @Inject |
|---|
| 66 | | - Provider<EntityManager> emProvider; |
|---|
| 64 | + EntityManager em; |
|---|
| 67 | 65 | |
|---|
| 68 | 66 | @Inject |
|---|
| 69 | 67 | private LicenseHelper licenseHelper; |
|---|
| .. | .. |
|---|
| 81 | 79 | public Response index(@Context BasicSecurityContext bsc) { |
|---|
| 82 | 80 | LOG.info("Getting packs list "); |
|---|
| 83 | 81 | |
|---|
| 84 | | - EntityManager em = emProvider.get(); |
|---|
| 82 | + // EntityManager em = emProvider.get(); |
|---|
| 85 | 83 | em.clear(); |
|---|
| 86 | 84 | |
|---|
| 87 | 85 | TypedQuery<Pack> q; |
|---|
| .. | .. |
|---|
| 123 | 121 | return Response.status(Status.NOT_FOUND).build(); |
|---|
| 124 | 122 | } |
|---|
| 125 | 123 | |
|---|
| 126 | | - EntityManager em = emProvider.get(); |
|---|
| 124 | + // EntityManager em = emProvider.get(); |
|---|
| 127 | 125 | em.clear(); |
|---|
| 128 | 126 | Pack pack = em.find(Pack.class, packId); |
|---|
| 129 | 127 | if (pack == null) { |
|---|
| .. | .. |
|---|
| 148 | 146 | @Transactional |
|---|
| 149 | 147 | public Response create(Pack pack, @Context BasicSecurityContext bsc) throws SeCurisServiceException { |
|---|
| 150 | 148 | LOG.info("Creating new pack"); |
|---|
| 151 | | - EntityManager em = emProvider.get(); |
|---|
| 149 | + // EntityManager em = emProvider.get(); |
|---|
| 152 | 150 | |
|---|
| 153 | 151 | if (checkIfCodeExists(pack.getCode(), em)) { |
|---|
| 154 | 152 | throw new SeCurisServiceException(ErrorCodes.INVALID_DATA, "The pack code is already used in an existing pack"); |
|---|
| .. | .. |
|---|
| 213 | 211 | MediaType.TEXT_PLAIN |
|---|
| 214 | 212 | }) |
|---|
| 215 | 213 | public Response getCodeSuffix(@PathParam("packId") Integer packId, @Context BasicSecurityContext bsc) throws SeCurisServiceException { |
|---|
| 216 | | - EntityManager em = emProvider.get(); |
|---|
| 214 | + // EntityManager em = emProvider.get(); |
|---|
| 217 | 215 | |
|---|
| 218 | 216 | if (packId == null) { |
|---|
| 219 | 217 | throw new SeCurisServiceException(ErrorCodes.INVALID_DATA, "The pack code is mandatory"); |
|---|
| .. | .. |
|---|
| 250 | 248 | }) |
|---|
| 251 | 249 | public Response modify(Pack pack, @PathParam("packId") Integer packId) { |
|---|
| 252 | 250 | LOG.info("Modifying pack with id: {}", packId); |
|---|
| 253 | | - EntityManager em = emProvider.get(); |
|---|
| 251 | + // EntityManager em = emProvider.get(); |
|---|
| 254 | 252 | Pack currentPack = em.find(Pack.class, packId); |
|---|
| 255 | 253 | |
|---|
| 256 | 254 | try { |
|---|
| .. | .. |
|---|
| 305 | 303 | }) |
|---|
| 306 | 304 | public Response activate(@PathParam("packId") Integer packId) throws SeCurisServiceException { |
|---|
| 307 | 305 | LOG.info("Activating pack with id: {}", packId); |
|---|
| 308 | | - EntityManager em = emProvider.get(); |
|---|
| 306 | + // EntityManager em = emProvider.get(); |
|---|
| 309 | 307 | |
|---|
| 310 | 308 | Pack currentPack = em.find(Pack.class, packId); |
|---|
| 311 | 309 | |
|---|
| .. | .. |
|---|
| 331 | 329 | }) |
|---|
| 332 | 330 | public Response onhold(@PathParam("packId") Integer packId) throws SeCurisServiceException { |
|---|
| 333 | 331 | LOG.info("Putting On hold pack with id: {}", packId); |
|---|
| 334 | | - EntityManager em = emProvider.get(); |
|---|
| 332 | + // EntityManager em = emProvider.get(); |
|---|
| 335 | 333 | |
|---|
| 336 | 334 | Pack currentPack = em.find(Pack.class, packId); |
|---|
| 337 | 335 | |
|---|
| .. | .. |
|---|
| 358 | 356 | public Response cancel(@PathParam("packId") Integer packId, @FormParam("reason") String reason, @Context BasicSecurityContext bsc) |
|---|
| 359 | 357 | throws SeCurisServiceException { |
|---|
| 360 | 358 | LOG.info("Cancelling pack with id: {}", packId); |
|---|
| 361 | | - EntityManager em = emProvider.get(); |
|---|
| 359 | + // EntityManager em = emProvider.get(); |
|---|
| 362 | 360 | |
|---|
| 363 | 361 | Pack currentPack = em.find(Pack.class, packId); |
|---|
| 364 | 362 | |
|---|
| .. | .. |
|---|
| 401 | 399 | }) |
|---|
| 402 | 400 | public Response delete(@PathParam("packId") String packId) throws SeCurisServiceException { |
|---|
| 403 | 401 | LOG.info("Deleting pack with id: {}", packId); |
|---|
| 404 | | - EntityManager em = emProvider.get(); |
|---|
| 402 | + // EntityManager em = emProvider.get(); |
|---|
| 405 | 403 | Pack pack = em.find(Pack.class, Integer.parseInt(packId)); |
|---|
| 406 | 404 | if (pack == null) { |
|---|
| 407 | 405 | LOG.error("Pack with id {} can not be deleted, It was not found in DB", packId); |
|---|