aboutsummaryrefslogtreecommitdiffstats
path: root/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/MicroServiceConfigPolicy.java
diff options
context:
space:
mode:
authorrb7147 <rb7147@att.com>2017-06-09 15:11:06 -0400
committerrb7147 <rb7147@att.com>2017-06-12 16:59:35 -0400
commit685ed1545ed28b777a3ba6e7d315b78f355154cb (patch)
tree1e37d639242c5f1e9cbf5623821f8498542b81dc /ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/MicroServiceConfigPolicy.java
parentfc5c07705edc4dcb7083b39116a43844bb6a1490 (diff)
[Policy-20] getConfig & Policy resolved blockers
Change-Id: If08e4c90d419e8d6e1426d817a12dde5b7cafba3 Signed-off-by: rb7147 <rb7147@att.com>
Diffstat (limited to 'ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/MicroServiceConfigPolicy.java')
-rw-r--r--ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/MicroServiceConfigPolicy.java75
1 files changed, 10 insertions, 65 deletions
diff --git a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/MicroServiceConfigPolicy.java b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/MicroServiceConfigPolicy.java
index 5fc4370e1..5938faa66 100644
--- a/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/MicroServiceConfigPolicy.java
+++ b/ECOMP-PAP-REST/src/main/java/org/openecomp/policy/pap/xacml/rest/components/MicroServiceConfigPolicy.java
@@ -26,13 +26,9 @@ import java.net.URI;
import java.net.URISyntaxException;
import java.nio.file.Path;
import java.nio.file.Paths;
-import java.sql.Connection;
-import java.sql.DriverManager;
-import java.sql.ResultSet;
-import java.sql.SQLException;
-import java.sql.Statement;
import java.util.HashMap;
import java.util.Iterator;
+import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
@@ -42,11 +38,11 @@ import org.openecomp.policy.common.logging.eelf.MessageCodes;
import org.openecomp.policy.common.logging.eelf.PolicyLogger;
import org.openecomp.policy.common.logging.flexlogger.FlexLogger;
import org.openecomp.policy.common.logging.flexlogger.Logger;
-import org.openecomp.policy.rest.XACMLRestProperties;
+import org.openecomp.policy.pap.xacml.rest.daoimpl.CommonClassDaoImpl;
import org.openecomp.policy.rest.adapter.PolicyRestAdapter;
+import org.openecomp.policy.rest.jpa.MicroServiceModels;
import com.att.research.xacml.std.IdentifierImpl;
-import com.att.research.xacml.util.XACMLProperties;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.base.Splitter;
@@ -69,13 +65,6 @@ public class MicroServiceConfigPolicy extends Policy {
private static final Logger LOGGER = FlexLogger.getLogger(MicroServiceConfigPolicy.class);
- /*
- * These are the parameters needed for DB access from the PAP
- */
- private static String papDbDriver = null;
- private static String papDbUrl = null;
- private static String papDbUser = null;
- private static String papDbPassword = null;
private static Map<String, String> mapAttribute = new HashMap<>();
private static Map<String, String> matchMap = new HashMap<>();
@@ -188,7 +177,6 @@ public class MicroServiceConfigPolicy extends Policy {
matching = getValueFromDictionary(policyAdapter.getServiceType() + "-v" + jsonVersion);
}
- matchMap = new HashMap<>();
if (matching != null && !matching.isEmpty()){
matchMap = Splitter.on(",").withKeyValueSeparator("=").split(matching);
if(policyAdapter.getJsonBody() != null){
@@ -332,62 +320,19 @@ public class MicroServiceConfigPolicy extends Policy {
}
private String getValueFromDictionary(String service){
-
- Connection con = null;
- Statement st = null;
- ResultSet rs = null;
-
+ String ruleTemplate=null;
String modelName = service.split("-v")[0];
String modelVersion = service.split("-v")[1];
-
- /*
- * Retrieve the property values for db access from the xacml.pap.properties
- */
- 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 ruleTemplate=null;
-
- try {
- //Get DB Connection
- Class.forName(papDbDriver);
- con = DriverManager.getConnection(papDbUrl,papDbUser,papDbPassword);
- st = con.createStatement();
-
- String queryString = "Select * from MicroServiceModels where modelName=\"" + modelName
- + "\" AND version=\"" + modelVersion+"\"";
-
-
- rs = st.executeQuery(queryString);
- if(rs.next()){
- ruleTemplate=rs.getString("annotation");
- }
- rs.close();
- }catch (ClassNotFoundException e) {
- PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "MicroServiceModels", "Exception querying MicroServiceModels");
- } catch (SQLException e) {
- PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, "MicroServiceModels", "Exception querying MicroServiceModels");
- } finally {
- try{
- if (con!=null){
- con.close();
- }
- if (rs!=null){
- rs.close();
- }
- if (st!=null){
- st.close();
- }
- } catch (Exception ex){
- LOGGER.error("Exception Occured While Closing the Database Connection"+ex);
- }
+ CommonClassDaoImpl dbConnection = new CommonClassDaoImpl();
+ List<Object> result = dbConnection.getDataById(MicroServiceModels.class, "modelName:version", modelName+":"+modelVersion);
+ if(result != null && !result.isEmpty()){
+ MicroServiceModels model = (MicroServiceModels) result.get(0);
+ ruleTemplate = model.getAnnotation();
}
return ruleTemplate;
-
}
+
// Data required for Advice part is setting here.
private AdviceExpressionsType getAdviceExpressions(int version, String fileName) {
AdviceExpressionsType advices = new AdviceExpressionsType();