X-Git-Url: https://gerrit.onap.org/r/gitweb?a=blobdiff_plain;f=ECOMP-PAP-REST%2Fsrc%2Fmain%2Fjava%2Forg%2Fopenecomp%2Fpolicy%2Fpap%2Fxacml%2Frest%2Futil%2FJPAUtils.java;h=397c30594a8ede89c145f613cbd9d2674f874a37;hb=7e547eaa55920dfbc9691eab33bb728395b50cf2;hp=5326cb2c7262b44f9ed016b2c883ad798be04319;hpb=91d04c64771832a0b8815ffbe1f0f9920320d94d;p=policy%2Fengine.git diff --git a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/util/JPAUtils.java b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/util/JPAUtils.java index 5326cb2c7..397c30594 100644 --- a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/util/JPAUtils.java +++ b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/util/JPAUtils.java @@ -43,7 +43,7 @@ import org.openecomp.policy.common.logging.flexlogger.FlexLogger; import org.openecomp.policy.common.logging.flexlogger.Logger; public class JPAUtils { - private static Logger logger = FlexLogger.getLogger(JPAUtils.class); + private static Logger LOGGER = FlexLogger.getLogger(JPAUtils.class); private EntityManagerFactory emf; private static final Object mapAccess = new Object(); @@ -51,7 +51,6 @@ public class JPAUtils { private static Map mapID2Function = null; private static JPAUtils currentInstance = null; - //private static List lockdownListeners = new ArrayList(); /** * Get an instance of a JPAUtils. It creates one if it does not exist. @@ -61,7 +60,7 @@ public class JPAUtils { * @throws IllegalStateException if a JPAUtils has already been constructed. Call getJPAUtilsInstance() to get this. */ public static JPAUtils getJPAUtilsInstance(EntityManagerFactory emf) throws Exception{ - logger.debug("getJPAUtilsInstance(EntityManagerFactory emf) as getJPAUtilsInstance("+emf+") called"); + LOGGER.debug("getJPAUtilsInstance(EntityManagerFactory emf) as getJPAUtilsInstance("+emf+") called"); if(currentInstance == null){ if(emf != null){ currentInstance = new JPAUtils(emf); @@ -73,7 +72,7 @@ public class JPAUtils { } private JPAUtils(EntityManagerFactory emf){ - logger.debug("JPAUtils(EntityManagerFactory emf) as JPAUtils("+emf+") called"); + LOGGER.debug("JPAUtils(EntityManagerFactory emf) as JPAUtils("+emf+") called"); this.emf = emf; } @@ -83,7 +82,7 @@ public class JPAUtils { * @throws IllegalStateException if a JPAUtils instance is null. Call getJPAUtilsInstance(EntityManagerFactory emf) to get this. */ public static JPAUtils getJPAUtilsInstance() throws Exception{ - logger.debug("getJPAUtilsInstance() as getJPAUtilsInstance() called"); + LOGGER.debug("getJPAUtilsInstance() as getJPAUtilsInstance() called"); if(currentInstance != null){ return currentInstance; } @@ -96,12 +95,12 @@ public class JPAUtils { if (attribute.getCategoryBean() != null) { designator.setCategory(attribute.getCategoryBean().getXacmlId()); } else { - logger.warn("No category bean"); + LOGGER.warn("No category bean"); } if (attribute.getDatatypeBean() != null) { designator.setDataType(attribute.getDatatypeBean().getXacmlId()); } else { - logger.warn("No datatype bean"); + LOGGER.warn("No datatype bean"); } designator.setIssuer(attribute.getIssuer()); designator.setMustBePresent(attribute.isMustBePresent()); @@ -115,12 +114,12 @@ public class JPAUtils { if (attribute.getCategoryBean() != null) { selector.setCategory(attribute.getCategoryBean().getXacmlId()); } else { - logger.warn("No category bean"); + LOGGER.warn("No category bean"); } if (attribute.getDatatypeBean() != null) { selector.setDataType(attribute.getDatatypeBean().getXacmlId()); } else { - logger.warn("No datatype bean"); + LOGGER.warn("No datatype bean"); } selector.setMustBePresent(attribute.isMustBePresent()); return selector; @@ -139,8 +138,7 @@ public class JPAUtils { try { buildFunctionMaps(); } catch (ServletException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + LOGGER.error("Exception Occured"+e); } } } @@ -153,8 +151,7 @@ public class JPAUtils { try { buildFunctionMaps(); } catch (ServletException e) { - // TODO Auto-generated catch block - e.printStackTrace(); + LOGGER.error("Exception Occured"+e); } } } @@ -191,14 +188,14 @@ public class JPAUtils { * @throws ConversionException */ public boolean dbLockdownIgnoreErrors() { - if (logger.isTraceEnabled()) - logger.trace("ENTER"); + if (LOGGER.isTraceEnabled()) + LOGGER.trace("ENTER"); boolean lockdown = false; try { lockdown = dbLockdown(); } catch (Exception e) { - logger.warn("Cannot access DB lockdown value", e); + LOGGER.warn("Cannot access DB lockdown value", e); } return lockdown; } @@ -211,8 +208,8 @@ public class JPAUtils { */ public boolean dbLockdown() throws IllegalAccessException { - if (logger.isTraceEnabled()) - logger.trace("ENTER"); + if (LOGGER.isTraceEnabled()) + LOGGER.trace("ENTER"); EntityManager em = emf.createEntityManager(); Query globalRoleSettingsJPA = em.createNamedQuery("GlobalRoleSettings.findAll"); @@ -222,15 +219,15 @@ public class JPAUtils { if (globalRoleSettings == null) { // this should not happen String msg = "NO GlobalSetttings for " + XacmlAdminAuthorization.Role.ROLE_SUPERADMIN.toString(); - if (logger.isErrorEnabled()) - logger.error(msg); + if (LOGGER.isErrorEnabled()) + LOGGER.error(msg); throw new IllegalAccessException(msg); } if (!globalRoleSettings.getRole().equals(XacmlAdminAuthorization.Role.ROLE_SUPERADMIN.toString())) { String msg = "NOT FOUND db data for " + XacmlAdminAuthorization.Role.ROLE_SUPERADMIN.toString(); - if (logger.isErrorEnabled()) - logger.error(msg); + if (LOGGER.isErrorEnabled()) + LOGGER.error(msg); throw new IllegalAccessException(msg); }