| .. | .. |
|---|
| 7 | 7 | import java.util.List; |
|---|
| 8 | 8 | |
|---|
| 9 | 9 | import javax.inject.Inject; |
|---|
| 10 | | -import javax.inject.Provider; |
|---|
| 11 | 10 | import javax.persistence.EntityManager; |
|---|
| 12 | | -import javax.persistence.PersistenceContext; |
|---|
| 13 | | -import javax.persistence.SynchronizationType; |
|---|
| 14 | 11 | import javax.persistence.TypedQuery; |
|---|
| 12 | +import javax.transaction.Transactional; |
|---|
| 15 | 13 | import javax.ws.rs.Consumes; |
|---|
| 16 | 14 | import javax.ws.rs.DELETE; |
|---|
| 17 | 15 | import javax.ws.rs.DefaultValue; |
|---|
| .. | .. |
|---|
| 62 | 60 | import com.fasterxml.jackson.annotation.JsonAutoDetect; |
|---|
| 63 | 61 | import com.fasterxml.jackson.annotation.JsonIgnoreProperties; |
|---|
| 64 | 62 | import com.fasterxml.jackson.annotation.JsonProperty; |
|---|
| 65 | | -import com.google.inject.persist.Transactional; |
|---|
| 66 | 63 | |
|---|
| 67 | 64 | /** |
|---|
| 68 | 65 | * License resource, this service will provide methods to create, modify and |
|---|
| .. | .. |
|---|
| 85 | 82 | private LicenseHelper licenseHelper; |
|---|
| 86 | 83 | |
|---|
| 87 | 84 | @Inject |
|---|
| 88 | | - private Provider<EntityManager> emProvider; |
|---|
| 89 | | - |
|---|
| 90 | | - @PersistenceContext(unitName = "localdb", synchronization = SynchronizationType.SYNCHRONIZED) |
|---|
| 91 | | - private EntityManager entityManager; |
|---|
| 85 | + EntityManager em; |
|---|
| 92 | 86 | |
|---|
| 93 | 87 | @Inject |
|---|
| 94 | 88 | private LicenseGenerator licenseGenerator; |
|---|
| .. | .. |
|---|
| 106 | 100 | public Response index(@QueryParam("packId") Integer packId, @Context BasicSecurityContext bsc) { |
|---|
| 107 | 101 | LOG.info("Getting licenses list "); |
|---|
| 108 | 102 | |
|---|
| 109 | | - EntityManager em = emProvider.get(); |
|---|
| 103 | + // EntityManager em = emProvider.get(); |
|---|
| 110 | 104 | em.clear(); |
|---|
| 111 | 105 | |
|---|
| 112 | 106 | if (!bsc.isUserInRole(BasicSecurityContext.ROL_ADMIN)) { |
|---|
| .. | .. |
|---|
| 141 | 135 | public Response get(@PathParam("licId") Integer licId, @Context BasicSecurityContext bsc) throws SeCurisServiceException { |
|---|
| 142 | 136 | LOG.info("Getting organization data for id: {}: ", licId); |
|---|
| 143 | 137 | |
|---|
| 144 | | - EntityManager em = emProvider.get(); |
|---|
| 138 | + // EntityManager em = emProvider.get(); |
|---|
| 145 | 139 | em.clear(); |
|---|
| 146 | 140 | License lic = getCurrentLicense(licId, bsc, em); |
|---|
| 147 | 141 | return Response.ok(lic).build(); |
|---|
| .. | .. |
|---|
| 161 | 155 | @Transactional |
|---|
| 162 | 156 | public Response download(@PathParam("licId") Integer licId, @Context BasicSecurityContext bsc) throws SeCurisServiceException { |
|---|
| 163 | 157 | |
|---|
| 164 | | - EntityManager em = emProvider.get(); |
|---|
| 158 | + // EntityManager em = emProvider.get(); |
|---|
| 165 | 159 | License lic = getCurrentLicense(licId, bsc, em); |
|---|
| 166 | 160 | |
|---|
| 167 | 161 | if (lic.getLicenseData() == null) { |
|---|
| .. | .. |
|---|
| 198 | 192 | }) |
|---|
| 199 | 193 | public Response activate(@PathParam("licId") Integer licId, @Context BasicSecurityContext bsc) throws SeCurisServiceException { |
|---|
| 200 | 194 | |
|---|
| 201 | | - EntityManager em = emProvider.get(); |
|---|
| 195 | + // EntityManager em = emProvider.get(); |
|---|
| 202 | 196 | License lic = getCurrentLicense(licId, bsc, em); |
|---|
| 203 | 197 | |
|---|
| 204 | 198 | if (!License.Status.isActionValid(License.Action.ACTIVATION, lic.getStatus())) { |
|---|
| .. | .. |
|---|
| 247 | 241 | public Response send(@PathParam("licId") Integer licId, @DefaultValue("false") @FormParam("add_cc") Boolean addCC, |
|---|
| 248 | 242 | @Context BasicSecurityContext bsc) throws SeCurisServiceException, SeCurisException { |
|---|
| 249 | 243 | |
|---|
| 250 | | - EntityManager em = emProvider.get(); |
|---|
| 244 | + // EntityManager em = emProvider.get(); |
|---|
| 251 | 245 | License lic = getCurrentLicense(licId, bsc, em); |
|---|
| 252 | 246 | Application app = lic.getPack().getLicenseType().getApplication(); |
|---|
| 253 | 247 | File licFile = null; |
|---|
| .. | .. |
|---|
| 303 | 297 | public Response cancel(@PathParam("licId") Integer licId, CancellationLicenseActionBean actionData, @Context BasicSecurityContext bsc) |
|---|
| 304 | 298 | throws SeCurisServiceException { |
|---|
| 305 | 299 | |
|---|
| 306 | | - EntityManager em = emProvider.get(); |
|---|
| 300 | + // EntityManager em = emProvider.get(); |
|---|
| 307 | 301 | License lic = getCurrentLicense(licId, bsc, em); |
|---|
| 308 | 302 | |
|---|
| 309 | 303 | if (!License.Status.isActionValid(License.Action.CANCEL, lic.getStatus())) { |
|---|
| .. | .. |
|---|
| 348 | 342 | }) |
|---|
| 349 | 343 | @Transactional |
|---|
| 350 | 344 | public Response create(License lic, @Context BasicSecurityContext bsc) throws SeCurisServiceException { |
|---|
| 351 | | - EntityManager em = emProvider.get(); |
|---|
| 345 | + // EntityManager em = emProvider.get(); |
|---|
| 352 | 346 | |
|---|
| 353 | 347 | if (checkIfCodeExists(lic.getCode(), em)) { |
|---|
| 354 | 348 | throw new SeCurisServiceException(ErrorCodes.INVALID_DATA, "The license code is already used in an existing license"); |
|---|
| .. | .. |
|---|
| 476 | 470 | public Response modify(License lic, @PathParam("licId") Integer licId, @Context BasicSecurityContext bsc) throws SeCurisServiceException { |
|---|
| 477 | 471 | LOG.info("Modifying organization with id: {}", licId); |
|---|
| 478 | 472 | |
|---|
| 479 | | - EntityManager em = emProvider.get(); |
|---|
| 473 | + // EntityManager em = emProvider.get(); |
|---|
| 480 | 474 | |
|---|
| 481 | 475 | License currentLicense = getCurrentLicense(licId, bsc, em); |
|---|
| 482 | 476 | currentLicense.setComments(lic.getComments()); |
|---|
| .. | .. |
|---|
| 522 | 516 | }) |
|---|
| 523 | 517 | public Response delete(@PathParam("licId") Integer licId, @Context BasicSecurityContext bsc) throws SeCurisServiceException { |
|---|
| 524 | 518 | LOG.info("Deleting license with id: {}", licId); |
|---|
| 525 | | - EntityManager em = emProvider.get(); |
|---|
| 519 | + // EntityManager em = emProvider.get(); |
|---|
| 526 | 520 | License lic = getCurrentLicense(licId, bsc, em); |
|---|
| 527 | 521 | |
|---|
| 528 | 522 | if (!License.Status.isActionValid(License.Action.DELETE, lic.getStatus())) { |
|---|
| .. | .. |
|---|
| 554 | 548 | }) |
|---|
| 555 | 549 | public Response block(@PathParam("licId") Integer licId, @Context BasicSecurityContext bsc) throws SeCurisServiceException { |
|---|
| 556 | 550 | LOG.info("Blocking license with id: {}", licId); |
|---|
| 557 | | - EntityManager em = emProvider.get(); |
|---|
| 551 | + // EntityManager em = emProvider.get(); |
|---|
| 558 | 552 | License lic = getCurrentLicense(licId, bsc, em); |
|---|
| 559 | 553 | |
|---|
| 560 | 554 | if (!License.Status.isActionValid(License.Action.BLOCK, lic.getStatus())) { |
|---|
| .. | .. |
|---|
| 587 | 581 | }) |
|---|
| 588 | 582 | public Response unblock(@PathParam("licId") Integer licId, @Context BasicSecurityContext bsc) throws SeCurisServiceException { |
|---|
| 589 | 583 | LOG.info("Unblocking license with id: {}", licId); |
|---|
| 590 | | - EntityManager em = emProvider.get(); |
|---|
| 584 | + // EntityManager em = emProvider.get(); |
|---|
| 591 | 585 | License lic = getCurrentLicense(licId, bsc, em); |
|---|
| 592 | 586 | |
|---|
| 593 | 587 | if (BlockedRequest.isRequestBlocked(lic.getRequestData(), em)) { |
|---|