import java.util.Collections;
import java.util.HashMap;
import java.util.List;
+import java.util.Map;
import java.util.Properties;
import org.onap.policy.common.logging.flexlogger.FlexLogger;
private static HashMap<String, String> pdpMap = null;
private static final Logger LOGGER = FlexLogger.getLogger(CheckPDP.class);
- private CheckPDP(){
+ public static Map<String, String> getPdpMap() {
+ return pdpMap;
+ }
+
+ public CheckPDP(){
//default constructor
}
+
public static boolean validateID(String id) {
// ReadFile
try {
private static void readFile(){
String pdpFile = null;
- Long newModified = null;
try{
pdpFile = XACMLProperties.getProperty(XACMLRestProperties.PROP_PDP_IDFILE);
}catch (Exception e){
}
// Check if File is updated recently
else {
- newModified = pdpPath.toFile().lastModified();
+ Long newModified = pdpPath.toFile().lastModified();
if (!newModified.equals(oldModified)) {
// File has been updated.
readProps();
@SuppressWarnings({ "unchecked", "rawtypes" })
private static void readProps() {
- Properties pdpProp = null;
+ Properties pdpProp;
pdpProp = new Properties();
try {
InputStream in = new FileInputStream(pdpPath.toFile());
private static void loadPDPProperties(String propKey, Properties pdpProp){
if (propKey.startsWith("PDP_URL")) {
- String check_val = pdpProp.getProperty(propKey);
- if (check_val == null) {
+ String checkVal = pdpProp.getProperty(propKey);
+ if (checkVal == null) {
LOGGER.error("Properties file doesn't have the PDP_URL parameter");
}
- if (check_val != null && check_val.contains(";")) {
- List<String> pdp_default = new ArrayList<>(Arrays.asList(check_val.split("\\s*;\\s*")));
+ if (checkVal != null && checkVal.contains(";")) {
+ List<String> pdpDefault = new ArrayList<>(Arrays.asList(checkVal.split("\\s*;\\s*")));
int pdpCount = 0;
- while (pdpCount < pdp_default.size()) {
- String pdpVal = pdp_default.get(pdpCount);
+ while (pdpCount < pdpDefault.size()) {
+ String pdpVal = pdpDefault.get(pdpCount);
readPDPParam(pdpVal);
pdpCount++;
}