import org.onap.policy.common.logging.ONAPLoggingContext;
import org.onap.policy.common.logging.eelf.MessageCodes;
import org.onap.policy.common.logging.eelf.PolicyLogger;
+import org.onap.policy.common.logging.flexlogger.FlexLogger;
+import org.onap.policy.common.logging.flexlogger.Logger;
import org.onap.policy.pap.xacml.rest.XACMLPapServlet;
import org.onap.policy.pap.xacml.rest.components.PolicyDBDaoTransaction;
import org.onap.policy.pap.xacml.rest.elk.client.PolicyElasticSearchController;
public class DeleteHandler {
private OnapPDPGroup newgroup;
-
- private static String papDbDriver = null;
- private static String papDbUrl = null;
- private static String papDbUser = null;
- private static String papDbPassword = null;
+ private static Logger logger = FlexLogger.getLogger(DeleteHandler.class);
- public void doAPIDeleteFromPAP(HttpServletRequest request, HttpServletResponse response, ONAPLoggingContext loggingContext) throws Exception {
+ public void doAPIDeleteFromPAP(HttpServletRequest request, HttpServletResponse response, ONAPLoggingContext loggingContext) throws IOException, SQLException {
// get the request content into a String
String json = null;
java.util.Scanner scanner = new java.util.Scanner(request.getInputStream());
PolicyEntity policyEntity = null;
JPAUtils jpaUtils = null;
- papDbDriver = XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_DB_DRIVER);
- papDbUrl = XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_DB_URL);
- papDbUser = XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_DB_USER);
- papDbPassword = XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_DB_PASSWORD);
+ String papDbDriver = XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_DB_DRIVER);
+ String papDbUrl = XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_DB_URL);
+ String papDbUser = XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_DB_USER);
+ String papDbPassword = XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_DB_PASSWORD);
Connection con = null;
try {
response.setStatus(HttpServletResponse.SC_ACCEPTED);
return;
}
- EntityManager em = (EntityManager) XACMLPapServlet.getEmf().createEntityManager();
+ EntityManager em = XACMLPapServlet.getEmf().createEntityManager();
Query policyEntityQuery = null;
try{
if(policyName.endsWith(".xml")){
policyVersionDeleted = true;
em.remove(pVersion);
}catch(Exception e){
+ logger.error(e.getMessage(),e);
policyVersionDeleted = false;
}
}
policyVersionDeleted = true;
em.persist(pVersion);
}catch(Exception e){
+ logger.error(e.getMessage(),e);
policyVersionDeleted = false;
}
}else{
policyVersionDeleted = true;
em.remove(pVersion);
}catch(Exception e){
+ logger.error(e.getMessage(),e);
policyVersionDeleted = false;
}
}
}
}
- public String deletePolicyEntityData(EntityManager em, PolicyEntity policyEntity) throws SQLException{
+ public static String deletePolicyEntityData(EntityManager em, PolicyEntity policyEntity){
PolicyElasticSearchController controller = new PolicyElasticSearchController();
PolicyRestAdapter policyData = new PolicyRestAdapter();
String policyName = policyEntity.getPolicyName();
controller.deleteElk(policyData);
em.remove(policyEntity);
}catch(Exception e){
+ logger.error(e.getMessage(),e);
return "error";
}
return "success";
}
- public boolean checkPolicyGroupEntity(EntityManager em, Connection con, List<?> peResult) throws SQLException{
+ public static boolean checkPolicyGroupEntity(EntityManager em, Connection con, List<?> peResult) throws SQLException{
for(Object peData : peResult){
PolicyEntity policyEntity = (PolicyEntity) peData;
Statement st = null;
public static DeleteHandler getInstance() {
try {
Class<?> deleteHandler = Class.forName(XACMLProperties.getProperty("deletePolicy.impl.className", DeleteHandler.class.getName()));
- DeleteHandler instance = (DeleteHandler) deleteHandler.newInstance();
- return instance;
+ return (DeleteHandler) deleteHandler.newInstance();
} catch (Exception e) {
- PolicyLogger.error(e.getMessage());
+ logger.error(e.getMessage(),e);
}
return null;
}