From da889d489da5d7fa8c71d9f21f24b1dc2e29d8e1 Mon Sep 17 00:00:00 2001
From: rsanchez <rsanchez@curisit.net>
Date: Wed, 28 Jan 2015 08:53:21 +0000
Subject: [PATCH] #0 refactoring - Removing Google Guice by CDI standard
---
securis/src/main/java/net/curisit/securis/services/PackResource.java | 24 +++++++++++-------------
1 files changed, 11 insertions(+), 13 deletions(-)
diff --git a/securis/src/main/java/net/curisit/securis/services/PackResource.java b/securis/src/main/java/net/curisit/securis/services/PackResource.java
index 31840e5..9a5e7a5 100644
--- a/securis/src/main/java/net/curisit/securis/services/PackResource.java
+++ b/securis/src/main/java/net/curisit/securis/services/PackResource.java
@@ -7,9 +7,9 @@
import javax.annotation.security.RolesAllowed;
import javax.inject.Inject;
-import javax.inject.Provider;
import javax.persistence.EntityManager;
import javax.persistence.TypedQuery;
+import javax.transaction.Transactional;
import javax.ws.rs.Consumes;
import javax.ws.rs.DELETE;
import javax.ws.rs.FormParam;
@@ -46,8 +46,6 @@
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
-import com.google.inject.persist.Transactional;
-
/**
* Pack resource, this service will provide methods to create, modify and delete
* packs
@@ -63,7 +61,7 @@
TokenHelper tokenHelper;
@Inject
- Provider<EntityManager> emProvider;
+ EntityManager em;
@Inject
private LicenseHelper licenseHelper;
@@ -81,7 +79,7 @@
public Response index(@Context BasicSecurityContext bsc) {
LOG.info("Getting packs list ");
- EntityManager em = emProvider.get();
+ // EntityManager em = emProvider.get();
em.clear();
TypedQuery<Pack> q;
@@ -123,7 +121,7 @@
return Response.status(Status.NOT_FOUND).build();
}
- EntityManager em = emProvider.get();
+ // EntityManager em = emProvider.get();
em.clear();
Pack pack = em.find(Pack.class, packId);
if (pack == null) {
@@ -148,7 +146,7 @@
@Transactional
public Response create(Pack pack, @Context BasicSecurityContext bsc) throws SeCurisServiceException {
LOG.info("Creating new pack");
- EntityManager em = emProvider.get();
+ // EntityManager em = emProvider.get();
if (checkIfCodeExists(pack.getCode(), em)) {
throw new SeCurisServiceException(ErrorCodes.INVALID_DATA, "The pack code is already used in an existing pack");
@@ -213,7 +211,7 @@
MediaType.TEXT_PLAIN
})
public Response getCodeSuffix(@PathParam("packId") Integer packId, @Context BasicSecurityContext bsc) throws SeCurisServiceException {
- EntityManager em = emProvider.get();
+ // EntityManager em = emProvider.get();
if (packId == null) {
throw new SeCurisServiceException(ErrorCodes.INVALID_DATA, "The pack code is mandatory");
@@ -250,7 +248,7 @@
})
public Response modify(Pack pack, @PathParam("packId") Integer packId) {
LOG.info("Modifying pack with id: {}", packId);
- EntityManager em = emProvider.get();
+ // EntityManager em = emProvider.get();
Pack currentPack = em.find(Pack.class, packId);
try {
@@ -305,7 +303,7 @@
})
public Response activate(@PathParam("packId") Integer packId) throws SeCurisServiceException {
LOG.info("Activating pack with id: {}", packId);
- EntityManager em = emProvider.get();
+ // EntityManager em = emProvider.get();
Pack currentPack = em.find(Pack.class, packId);
@@ -331,7 +329,7 @@
})
public Response onhold(@PathParam("packId") Integer packId) throws SeCurisServiceException {
LOG.info("Putting On hold pack with id: {}", packId);
- EntityManager em = emProvider.get();
+ // EntityManager em = emProvider.get();
Pack currentPack = em.find(Pack.class, packId);
@@ -358,7 +356,7 @@
public Response cancel(@PathParam("packId") Integer packId, @FormParam("reason") String reason, @Context BasicSecurityContext bsc)
throws SeCurisServiceException {
LOG.info("Cancelling pack with id: {}", packId);
- EntityManager em = emProvider.get();
+ // EntityManager em = emProvider.get();
Pack currentPack = em.find(Pack.class, packId);
@@ -401,7 +399,7 @@
})
public Response delete(@PathParam("packId") String packId) throws SeCurisServiceException {
LOG.info("Deleting pack with id: {}", packId);
- EntityManager em = emProvider.get();
+ // EntityManager em = emProvider.get();
Pack pack = em.find(Pack.class, Integer.parseInt(packId));
if (pack == null) {
LOG.error("Pack with id {} can not be deleted, It was not found in DB", packId);
--
Gitblit v1.3.2