diff --git a/BRMSGateway/src/main/java/org/onap/policy/brms/api/BrmsPush.java b/BRMSGateway/src/main/java/org/onap/policy/brms/api/BrmsPush.java
index 716b8ec..507e17f 100644
--- a/BRMSGateway/src/main/java/org/onap/policy/brms/api/BrmsPush.java
+++ b/BRMSGateway/src/main/java/org/onap/policy/brms/api/BrmsPush.java
@@ -3,6 +3,7 @@
  * ONAP Policy Engine
  * ================================================================================
  * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Modified Copyright (C) 2018 Samsung Electronics Co., Ltd.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -424,27 +425,9 @@
                 }
                 // Check User Specific values.
                 if ("$controller:".equals(key)) {
-                    try {
-                        final PEDependency dependency = PolicyUtils.jsonStringToObject(value, PEDependency.class);
-                        userControllerName = key.replaceFirst("$controller:", "");
-                        LOGGER.info("addRule: userControllerName - " + userControllerName + ", dependency: - "
-                                + dependency);
-                        addToGroup(userControllerName, dependency);
-                    } catch (final Exception e) {
-                        LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error while resolving Controller: " + e);
-                    }
-
+                    userControllerName = getUserControllerName(key, value);
                 } else if ("$dependency$".equals(key) && value.startsWith("[") && value.endsWith("]")) {
-                    value = value.substring(1, value.length() - 1).trim();
-                    final List<String> dependencyStrings = Arrays.asList(value.split(Pattern.quote("},{")));
-                    for (final String dependencyString : dependencyStrings) {
-                        try {
-                            userDependencies.add(PolicyUtils.jsonStringToObject(dependencyString, PEDependency.class));
-                        } catch (final Exception e) {
-                            LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error while resolving Dependencies: "
-                                    + e);
-                        }
-                    }
+                    updateUserDependencies(userDependencies, value);
                 }
             }
             if (userControllerName != null) {
@@ -479,6 +462,35 @@
         }
     }
 
+    private String getUserControllerName(String key, String value) {
+        String userControllerName = null;
+        // Check User Specific values.
+        try {
+            final PEDependency dependency = PolicyUtils.jsonStringToObject(value, PEDependency.class);
+            userControllerName = key.replaceFirst("$controller:", "");
+            LOGGER.info("addRule: userControllerName - " + userControllerName + ", dependency: - "
+                    + dependency);
+            addToGroup(userControllerName, dependency);
+        } catch (final Exception e) {
+            LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error while resolving Controller: " + e);
+        }
+        return userControllerName;
+    }
+
+    private void updateUserDependencies(ArrayList<PEDependency> userDependencies, String value) {
+        //update the user dependencies supplied as parameter to this method
+        value = value.substring(1, value.length() - 1).trim();
+        final List<String> dependencyStrings = Arrays.asList(value.split(Pattern.quote("},{")));
+        for (final String dependencyString : dependencyStrings) {
+            try {
+                userDependencies.add(PolicyUtils.jsonStringToObject(dependencyString, PEDependency.class));
+            } catch (final Exception e) {
+                LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Error while resolving Dependencies: "
+                        + e);
+            }
+        }
+    }
+
     private void syncGroupInfo() {
         // Sync DB to JMemory.
         final EntityTransaction et = em.getTransaction();
@@ -624,45 +636,49 @@
         try (JarFile jar = new JarFile(jarFileName)) {
             final Enumeration<?> enumEntries = jar.entries();
             while (enumEntries.hasMoreElements()) {
-                final JarEntry jarEntry = (JarEntry) enumEntries.nextElement();
-                File file = null;
-                final String fileName = jarEntry.getName().substring(jarEntry.getName().lastIndexOf("/") + 1);
-                if (jarEntry.getName().endsWith(".drl")) {
-                    final String path = PROJECTSLOCATION + File.separator + artifactId + File.separator + "src"
-                            + File.separator + "main" + File.separator + RESOURCES + File.separator + RULES;
-                    new File(path).mkdirs();
-                    if (syncFlag && policyMap.containsKey(fileName.replace(".drl", ""))) {
-                        file = new File(path + File.separator + fileName);
-                    } else {
-                        file = new File(path + File.separator + fileName);
-                    }
-                } else if (jarEntry.getName().endsWith(POM_XML_FILE)) {
-                    final String path = PROJECTSLOCATION + File.separator + artifactId;
-                    new File(path).mkdirs();
-                    file = new File(path + File.separator + fileName);
-                } else if (jarEntry.getName().endsWith(KMODULE_XML_FILE)) {
-                    final String path = PROJECTSLOCATION + File.separator + artifactId + File.separator + "src"
-                            + File.separator + "main" + File.separator + RESOURCES + File.separator + META_INF;
-                    new File(path).mkdirs();
-                    file = new File(path + File.separator + fileName);
-                }
-                if (file != null) {
-                    try (InputStream is = jar.getInputStream(jarEntry);
-                            FileOutputStream fos = new FileOutputStream(file)) {
-                        while (is.available() > 0) {
-                            fos.write(is.read());
-                        }
-                        LOGGER.info(fileName + " Created..");
-                    } catch (final IOException e) {
-                        LOGGER.info("exception Occured" + e);
-                    }
-                }
+                parseJarContents(artifactId, jar, enumEntries);
             }
         } catch (final IOException e) {
             LOGGER.info("exception Occured" + e);
         }
     }
 
+    private void parseJarContents(String artifactId, JarFile jar, Enumeration<?> enumEntries) {
+        final JarEntry jarEntry = (JarEntry) enumEntries.nextElement();
+        File file = null;
+        final String fileName = jarEntry.getName().substring(jarEntry.getName().lastIndexOf("/") + 1);
+        if (jarEntry.getName().endsWith(".drl")) {
+            final String path = PROJECTSLOCATION + File.separator + artifactId + File.separator + "src"
+                    + File.separator + "main" + File.separator + RESOURCES + File.separator + RULES;
+            new File(path).mkdirs();
+            if (syncFlag && policyMap.containsKey(fileName.replace(".drl", ""))) {
+                file = new File(path + File.separator + fileName);
+            } else {
+                file = new File(path + File.separator + fileName);
+            }
+        } else if (jarEntry.getName().endsWith(POM_XML_FILE)) {
+            final String path = PROJECTSLOCATION + File.separator + artifactId;
+            new File(path).mkdirs();
+            file = new File(path + File.separator + fileName);
+        } else if (jarEntry.getName().endsWith(KMODULE_XML_FILE)) {
+            final String path = PROJECTSLOCATION + File.separator + artifactId + File.separator + "src"
+                    + File.separator + "main" + File.separator + RESOURCES + File.separator + META_INF;
+            new File(path).mkdirs();
+            file = new File(path + File.separator + fileName);
+        }
+        if (file != null) {
+            try (InputStream is = jar.getInputStream(jarEntry);
+                 FileOutputStream fos = new FileOutputStream(file)) {
+                while (is.available() > 0) {
+                    fos.write(is.read());
+                }
+                LOGGER.info(fileName + " Created..");
+            } catch (final IOException e) {
+                LOGGER.info("exception Occured" + e);
+            }
+        }
+    }
+
     private NexusArtifact getLatestArtifactFromNexus(final String selectedName) {
         final List<NexusArtifact> artifacts = getArtifactFromNexus(selectedName, null);
         int bigNum = 0;
@@ -771,42 +787,7 @@
             LOGGER.error("Error while starting Transaction " + e);
         }
         if (!modifiedGroups.isEmpty()) {
-            Boolean flag = false;
-            for (final Map.Entry<String, String> entry : modifiedGroups.entrySet()) {
-                InvocationResult result = null;
-                final String group = entry.getKey();
-                try {
-                    LOGGER.info("PushRules: ModifiedGroups, Key: " + group + ", Value: " + entry.getValue());
-                    final InvocationRequest request = new DefaultInvocationRequest();
-                    setVersion(group);
-                    createPom(group);
-                    request.setPomFile(new File(
-                            PROJECTSLOCATION + File.separator + getArtifactId(group) + File.separator + POM_XML_FILE));
-                    request.setGoals(Arrays.asList(GOALS));
-                    final Invoker invoker = new DefaultInvoker();
-                    result = invoker.execute(request);
-                    if (result.getExecutionException() != null) {
-                        LOGGER.error(result.getExecutionException());
-                    } else if (result.getExitCode() != 0) {
-                        LOGGER.error("Maven Invocation failure..!");
-                    }
-                } catch (final Exception e) {
-                    LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Maven Invocation issue for "
-                            + getArtifactId(group) + e.getMessage(), e);
-                }
-                if (result != null && result.getExitCode() == 0) {
-                    LOGGER.info("Build Completed..!");
-                    if (createFlag) {
-                        addNotification(group, "create");
-                    } else {
-                        addNotification(group, entry.getValue());
-                    }
-                    flag = true;
-                } else {
-                    throw new PolicyException(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Maven Invocation failure!");
-                }
-            }
-            if (flag) {
+            if (buildAndGenerateJarFile()) {
                 sendNotification(controllers);
             }
         }
@@ -828,6 +809,45 @@
         getNameAndSetRemove(controllerName, name);
     }
 
+    private Boolean buildAndGenerateJarFile() throws PolicyException {
+        Boolean flag = false;
+        for (final Map.Entry<String, String> entry : modifiedGroups.entrySet()) {
+            InvocationResult result = null;
+            final String group = entry.getKey();
+            try {
+                LOGGER.info("PushRules: ModifiedGroups, Key: " + group + ", Value: " + entry.getValue());
+                final InvocationRequest request = new DefaultInvocationRequest();
+                setVersion(group);
+                createPom(group);
+                request.setPomFile(new File(
+                        PROJECTSLOCATION + File.separator + getArtifactId(group) + File.separator + POM_XML_FILE));
+                request.setGoals(Arrays.asList(GOALS));
+                final Invoker invoker = new DefaultInvoker();
+                result = invoker.execute(request);
+                if (result.getExecutionException() != null) {
+                    LOGGER.error(result.getExecutionException());
+                } else if (result.getExitCode() != 0) {
+                    LOGGER.error("Maven Invocation failure..!");
+                }
+            } catch (final Exception e) {
+                LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Maven Invocation issue for "
+                        + getArtifactId(group) + e.getMessage(), e);
+            }
+            if (result != null && result.getExitCode() == 0) {
+                LOGGER.info("Build Completed..!");
+                if (createFlag) {
+                    addNotification(group, "create");
+                } else {
+                    addNotification(group, entry.getValue());
+                }
+                flag = true;
+            } else {
+                throw new PolicyException(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Maven Invocation failure!");
+            }
+        }
+        return flag;
+    }
+
     private String getGroupName(final String name) {
         if (policyMap.containsKey(name)) {
             return policyMap.get(name);
diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/PAPRestConfig.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/PAPRestConfig.java
index 6c80f9c..614ba85 100644
--- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/PAPRestConfig.java
+++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/PAPRestConfig.java
@@ -3,6 +3,7 @@
  * ONAP-PAP-REST
  * ================================================================================
  * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Modified Copyright (C) 2018 Samsung Electronics Co., Ltd.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/ConfigPolicy.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/ConfigPolicy.java
index eed73f6..6c66898 100644
--- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/ConfigPolicy.java
+++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/ConfigPolicy.java
@@ -3,6 +3,7 @@
  * ONAP-PAP-REST
  * ================================================================================
  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Modified Copyright (C) 2018 Samsung Electronics Co., Ltd.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/CreateNewMicroServiceModel.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/CreateNewMicroServiceModel.java
index d6718ab..abb4251 100644
--- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/CreateNewMicroServiceModel.java
+++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/CreateNewMicroServiceModel.java
@@ -3,6 +3,7 @@
  * ONAP-PAP-REST
  * ================================================================================
  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Modified Copyright (C) 2018 Samsung Electronics Co., Ltd.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -57,7 +58,7 @@
     private HashMap<String,MSAttributeObject > classMap = new HashMap<>();
 
 
-    MSModelUtils utils = new MSModelUtils(XACMLPapServlet.getMsOnapName(), XACMLPapServlet.getMsPolicyName());
+    private MSModelUtils utils = new MSModelUtils(XACMLPapServlet.getMsOnapName(), XACMLPapServlet.getMsPolicyName());
 
     public CreateNewMicroServiceModel(String fileName, String serviceName, String string, String version) {
         super();
@@ -80,31 +81,8 @@
             File directory = new File("ExtractDir" + File.separator + randomID);
             List<File> fileList = listModelFiles(directory.toString());
             //get all the files from a director
-            for (File file : fileList){
-                if (file.isFile()){
-                    int i = file.getName().lastIndexOf('.');
-                    String type = file.getName().substring(i+1);
-
-                    if(type != null && "yml".equalsIgnoreCase(type)){
-
-                        processYmlModel(file.toString(), modelName);
-
-                    }else{
-
-                        tempMap = utils.processEpackage(file.getAbsolutePath(), MODEL_TYPE.XMI);
-                        classMap.putAll(tempMap);
-                    }
-                }
-            }
-            cleanUpFile = "ExtractDir" + File.separator + randomID + ".zip";
-            try {
-                FileUtils.deleteDirectory(new File("ExtractDir" + File.separator + randomID));
-                FileUtils.deleteDirectory(new File(randomID));
-                File deleteFile = new File(cleanUpFile);
-                FileUtils.forceDelete(deleteFile);
-            } catch (IOException e) {
-                logger.error("Failed to unzip model file " + randomID, e);
-            }
+            processFiles(modelName, fileList);
+            doCleanUpFiles(randomID);
         }else {
             if(importFile.contains(".yml")){
 
@@ -122,6 +100,39 @@
         }
     }
 
+    private void processFiles(String modelName, List<File> fileList) {
+        Map<String, MSAttributeObject> tempMap;
+        for (File file : fileList){
+            if (file.isFile()){
+                int i = file.getName().lastIndexOf('.');
+                String type = file.getName().substring(i+1);
+
+                if("yml".equalsIgnoreCase(type)){
+
+                    processYmlModel(file.toString(), modelName);
+
+                }else{
+
+                    tempMap = utils.processEpackage(file.getAbsolutePath(), MODEL_TYPE.XMI);
+                    classMap.putAll(tempMap);
+                }
+            }
+        }
+    }
+
+    private void doCleanUpFiles(String randomID) {
+        String cleanUpFile;
+        cleanUpFile = "ExtractDir" + File.separator + randomID + ".zip";
+        try {
+            FileUtils.deleteDirectory(new File("ExtractDir" + File.separator + randomID));
+            FileUtils.deleteDirectory(new File(randomID));
+            File deleteFile = new File(cleanUpFile);
+            FileUtils.forceDelete(deleteFile);
+        } catch (IOException e) {
+            logger.error("Failed to unzip model file " + randomID, e);
+        }
+    }
+
     private void processYmlModel(String fileName, String  modelName){
 
         try {
@@ -145,7 +156,7 @@
             returnReferenceList.put(modelName, utils.getReferenceAttributes());
             msAttributes.setRefAttribute(returnReferenceList);
 
-            if(utils.getListConstraints()!=""){
+            if(!PolicyDBDao.isNullOrEmpty(utils.getListConstraints())){
                 LinkedHashMap<String, String> enumList =new LinkedHashMap<>();
                 String[] listArray=utils.getListConstraints().split("#");
                 for(String str:listArray){
diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/DecisionPolicy.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/DecisionPolicy.java
index 56c23ac..c8c540c 100644
--- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/DecisionPolicy.java
+++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/DecisionPolicy.java
@@ -167,7 +167,9 @@
 		
 		if(policyAdapter.getRuleProvider().equals(GUARD_YAML) || policyAdapter.getRuleProvider().equals(GUARD_BL_YAML)){
 			Map<String, String> yamlParams = new HashMap<>();
-			yamlParams.put(DESCRIPTION, (policyAdapter.getPolicyDescription()!=null)? policyAdapter.getPolicyDescription(): "YAML Guard Policy");
+			String blackListEntryType = policyAdapter.getBlackListEntryType() !=null ? policyAdapter.getBlackListEntryType(): "Use Manual Entry";
+			String description = policyAdapter.getPolicyDescription() != null? policyAdapter.getPolicyDescription(): "YAML Guard Policy";
+			yamlParams.put(DESCRIPTION, description + "@blEntry@" + blackListEntryType + "@blEntry@");
 			String fileName = policyAdapter.getNewFileName();
 			String name = fileName.substring(fileName.lastIndexOf('\\') + 1, fileName.length());
 			if ((name == null) || ("".equals(name))) {
@@ -295,6 +297,16 @@
 					blackList.add(blackListString);
 				}	
 			}
+            if(yamlParams.containsKey("appendBlackList")){
+            	String appendBlackListString = yamlParams.get("appendBlackList");
+                List<String> appendBlackList = null;
+                if(appendBlackListString!=null && !appendBlackListString.trim().isEmpty()){
+                	appendBlackList = Arrays.asList(appendBlackListString.split(","));	
+                	for(int i=0; i<appendBlackList.size();i++){
+                		blackList.remove(appendBlackList.get(i));
+                	}
+                }
+            }
 			File templateFile;
 			Path xacmlTemplatePath;
 			ClassLoader classLoader = getClass().getClassLoader();
@@ -781,7 +793,7 @@
 	}
 	
 	public String getFunctionDefinitionId(String key){
-    	FunctionDefinition object = (FunctionDefinition) commonClassDao.getDataById(FunctionDefinition.class, "short_name", key);
+    	FunctionDefinition object = (FunctionDefinition) commonClassDao.getDataById(FunctionDefinition.class, "shortname", key);
     	if(object != null){
     		return object.getXacmlid();
     	}
diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/Policy.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/Policy.java
index 3b3e81e..1be27ae 100644
--- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/Policy.java
+++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/Policy.java
@@ -3,6 +3,7 @@
  * ONAP-PAP-REST
  * ================================================================================
  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Modified Copyright (C) 2018 Samsung Electronics Co., Ltd.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -51,334 +52,326 @@
 import oasis.names.tc.xacml._3_0.core.schema.wd_17.PolicyType;
 
 public abstract class Policy {
-	
-	private static final Logger LOGGER	= FlexLogger.getLogger(Policy.class);
-	
 
-	/**
-	 * Common Fields
-	 */
-	public static final String GET_INT_TYPE = "Integer";
-	public static final String GET_STRING_TYPE = "String";
-
-	public static final String ONAPID = "ONAPName";
-	public static final String CONFIGID = "ConfigName";
-	public static final String CLOSEDLOOPID = "ServiceType";
-
-	public static final String CONFIG_POLICY = "Config";
-	public static final String ACTION_POLICY = "Action";
-	public static final String DECISION_POLICY = "Decision";
-
-	protected String policyName = null;
-
-	protected boolean isValidForm = true;
-
-	private Path finalPolicyPath = null;
-
-	private boolean preparedToSave = false;
-
-	private boolean policyExists = false;
-
-	public Path getFinalPolicyPath() {
-		return finalPolicyPath;
-	}
-
-	public void setFinalPolicyPath(Path finalPolicyPath) {
-		this.finalPolicyPath = finalPolicyPath;
-	}
-
-	// Constants Used in XML Creation
-	public static final String CATEGORY_RECIPIENT_SUBJECT = "urn:oasis:names:tc:xacml:1.0:subject-category:recipient-subject";
-	public static final String CATEGORY_RESOURCE = "urn:oasis:names:tc:xacml:3.0:attribute-category:resource";
-	public static final String CATEGORY_ACTION = "urn:oasis:names:tc:xacml:3.0:attribute-category:action";
-	public static final String CATEGORY_ACCESS_SUBJECT = "urn:oasis:names:tc:xacml:1.0:subject-category:access-subject";
-	public static final String ACTION_ID = "urn:oasis:names:tc:xacml:1.0:action:action-id";
-	public static final String SUBJECT_ID = "urn:oasis:names:tc:xacml:1.0:subject:subject-id";
-	public static final String RESOURCE_ID = "urn:oasis:names:tc:xacml:1.0:resource:resource-id";
-	public static final String FUNTION_INTEGER_ONE_AND_ONLY = "urn:oasis:names:tc:xacml:1.0:function:integer-one-and-only";
-	public static final String FUNCTION_STRING_ONE_AND_ONLY = "urn:oasis:names:tc:xacml:1.0:function:string-one-and-only";
-	public static final String FUNCTION_BOOLEAN_ONE_AND_ONLY = "urn:oasis:names:tc:xacml:1.0:function:boolean-one-and-only";
-	public static final String FUNCTION_STRING_EQUAL = "urn:oasis:names:tc:xacml:1.0:function:string-equal";
-	public static final String FUNCTION_STRING_REGEX_MATCH = "org.onap.function.regex-match";
-	public static final String FUNCTION_STRING_REGEXP_MATCH = "urn:oasis:names:tc:xacml:1.0:function:string-regexp-match";
-	public static final String FUNCTION_STRING_EQUAL_IGNORE = "urn:oasis:names:tc:xacml:3.0:function:string-equal-ignore-case";
-	public static final String INTEGER_DATATYPE = "http://www.w3.org/2001/XMLSchema#integer";
-	public static final String BOOLEAN_DATATYPE = "http://www.w3.org/2001/XMLSchema#boolean";
-	public static final String STRING_DATATYPE = "http://www.w3.org/2001/XMLSchema#string";
-	public static final String URI_DATATYPE = "http://www.w3.org/2001/XMLSchema#anyURI";
-	public static final String RULE_VARIABLE = "var:";
-	public static final String EMPTY_STRING = "";
-
-	protected static String CONFIG_HOME = null;
-	protected static String ACTION_HOME = null;
-	protected static String CONFIG_URL = null;
-
-	protected Map<String, String> performer = new HashMap<>();
-
-	private static String actionHome = null;
-	private static String configHome = null;
-
-	public PolicyRestAdapter policyAdapter = null;
-	String ruleID = "";
-
-	public Policy() {
-		CONFIG_HOME = getConfigHome();
-		ACTION_HOME = getActionHome();
-		CONFIG_URL = "$URL";
-		performer.put("PDP", "PDPAction");
-		performer.put("PEP", "PEPAction");
-	}
-
-	//Each policy type seems to either use policyData or data field policy adapter when
-	//getting the xml to save the policy. Instead of keep this hardcoded in the save method,
-	//this method makes it usable outside.
-	/**
-	 * Return the data field of the PolicyAdapter that will be used when saving this policy
-	 * with the savePolicies method.
-	 * @return Either the PolicyAdapter.getData() or PolicyAdapter.getPolicyData()
-	 */
-	public abstract Object getCorrectPolicyDataObject();
-	public abstract Map<String, String>  savePolicies() throws PAPException;
-
-	//This is the method for preparing the policy for saving.  We have broken it out
-	//separately because the fully configured policy is used for multiple things
-	public abstract boolean prepareToSave() throws PAPException;
+    private static final Logger LOGGER	= FlexLogger.getLogger(Policy.class);
 
 
-	// create match for onap and config name
-	protected MatchType createMatch(String key, String value) {
-		MatchType match = new MatchType();
+    /**
+     * Common Fields
+     */
+    public static final String GET_INT_TYPE = "Integer";
+    public static final String GET_STRING_TYPE = "String";
 
-		AttributeValueType attributeValue = new AttributeValueType();
-		attributeValue.setDataType(STRING_DATATYPE);
-		attributeValue.getContent().add(value);
-		match.setAttributeValue(attributeValue);
-		AttributeDesignatorType attributeDesignator = new AttributeDesignatorType();
-		URI uri = null;
-		try {
-			uri = new URI(key);
-		} catch (URISyntaxException e) {
-			LOGGER.error("Exception Occured"+e);
-		}
-		attributeDesignator.setCategory(CATEGORY_ACCESS_SUBJECT);
-		attributeDesignator.setDataType(STRING_DATATYPE);
-		attributeDesignator.setAttributeId(new IdentifierImpl(uri).stringValue());
-		match.setAttributeDesignator(attributeDesignator);
-		match.setMatchId(FUNCTION_STRING_REGEX_MATCH);
-		return match;
-	}
+    public static final String ONAPID = "ONAPName";
+    public static final String CONFIGID = "ConfigName";
+    public static final String CLOSEDLOOPID = "ServiceType";
 
-	// Creating the match for dynamically added components.
-	protected MatchType createDynamicMatch(String key, String value) {
-		MatchType dynamicMatch = new MatchType();
-		AttributeValueType dynamicAttributeValue = new AttributeValueType();
-		String dataType = null;
-		dataType = STRING_DATATYPE;
-		dynamicAttributeValue.setDataType(dataType);
-		dynamicAttributeValue.getContent().add(value);
-		dynamicMatch.setAttributeValue(dynamicAttributeValue);
+    public static final String CONFIG_POLICY = "Config";
+    public static final String ACTION_POLICY = "Action";
+    public static final String DECISION_POLICY = "Decision";
 
-		AttributeDesignatorType dynamicAttributeDesignator = new AttributeDesignatorType();
+    protected String policyName = null;
 
-		URI dynamicURI = null;
-		try {
-			dynamicURI = new URI(key);
-		} catch (URISyntaxException e) {
-			LOGGER.error("Exception Occured"+e);// log msg
-		}
-		dynamicAttributeDesignator.setCategory(CATEGORY_RESOURCE);
-		dynamicAttributeDesignator.setDataType(dataType);
-		dynamicAttributeDesignator.setAttributeId(new IdentifierImpl(dynamicURI).stringValue());
-		dynamicMatch.setAttributeDesignator(dynamicAttributeDesignator);
-		dynamicMatch.setMatchId(FUNCTION_STRING_REGEX_MATCH);
+    protected boolean isValidForm = true;
 
-		return dynamicMatch;
-	}
+    private Path finalPolicyPath = null;
 
-	//  the Policy Name as Unique One throws error
-	@SuppressWarnings("static-access")
-	protected Path getNextFilename(Path parent, String policyType, String polcyFileName, Integer version) {
-		policyType = FilenameUtils.removeExtension(policyType);
-		polcyFileName = FilenameUtils.removeExtension(polcyFileName);
-		Path newFile = null;
-		String policyDir = EMPTY_STRING;
-		String absolutePath = parent.toString();
-		if (absolutePath != null && !absolutePath.equals(EMPTY_STRING)) {
-			policyDir = absolutePath.substring(absolutePath.lastIndexOf('\\') + 1, absolutePath.length());
-			if (policyDir == null || policyDir.equals(EMPTY_STRING)) {
-				policyDir = absolutePath.substring(absolutePath.lastIndexOf('/') + 1, absolutePath.length());
-			}
-		}
+    private boolean preparedToSave = false;
 
-		String fileName = "default";
-		if (policyDir != null && !policyDir.equals(EMPTY_STRING)) {
-			fileName = policyType + "_" + String.format(polcyFileName) + "." + version + ".xml";
-		} 
-			
-		newFile = Paths.get(parent.toString(), fileName);
-		if (newFile.toFile().exists()) {
-			return newFile;
-		}
-		return null;
-	}
+    private boolean policyExists = false;
 
-	protected Path getNextLoopFilename(Path parentPath, String policyType, String policyConfigType, String policyFileName, Integer version) {
-		policyType = FilenameUtils.removeExtension(policyType);
-		policyConfigType = FilenameUtils.removeExtension(policyConfigType);
-		policyFileName = FilenameUtils.removeExtension(policyFileName);
-		Path newFile = null;
-		String policyDir = EMPTY_STRING;
-		String absolutePath = parentPath.toString();
-		if (absolutePath != null && !absolutePath.equals(EMPTY_STRING)) {
-			policyDir = absolutePath.substring(absolutePath.lastIndexOf('\\') + 1, absolutePath.length());
-			if (policyDir == null || policyDir.equals(EMPTY_STRING)) {
-				policyDir = absolutePath.substring(absolutePath.lastIndexOf('/') + 1, absolutePath.length());
-			}
-		}
+    public Path getFinalPolicyPath() {
+        return finalPolicyPath;
+    }
 
-		String fileName = "default";
-		if (policyDir != null && !policyDir.equals(EMPTY_STRING)) {
-			if("ClosedLoop_PM".equals(policyConfigType)){
-				fileName = policyType + "_" + "PM" + "_" +java.lang.String.format(policyFileName) + "." +version +".xml";
-			}else if("ClosedLoop_Fault".equals(policyConfigType)){
-				fileName = policyType + "_" + "Fault" + "_" +java.lang.String.format(policyFileName) +  "." + version + ".xml";
-			}else if("Micro Service".equals(policyConfigType)){
-				fileName = policyType + "_" + "MS" + "_" + java.lang.String.format(policyFileName) + "." + version + ".xml";
-			}else if("Optimization".equals(policyConfigType)) {
-				fileName = policyType + "_" + "OOF" + "_" + java.lang.String.format(policyFileName) + "." + version + ".xml";
-			}
-		} 
+    public void setFinalPolicyPath(Path finalPolicyPath) {
+        this.finalPolicyPath = finalPolicyPath;
+    }
 
-		newFile = Paths.get(parentPath.toString(), fileName);
+    // Constants Used in XML Creation
+    public static final String CATEGORY_RECIPIENT_SUBJECT = "urn:oasis:names:tc:xacml:1.0:subject-category:recipient-subject";
+    public static final String CATEGORY_RESOURCE = "urn:oasis:names:tc:xacml:3.0:attribute-category:resource";
+    public static final String CATEGORY_ACTION = "urn:oasis:names:tc:xacml:3.0:attribute-category:action";
+    public static final String CATEGORY_ACCESS_SUBJECT = "urn:oasis:names:tc:xacml:1.0:subject-category:access-subject";
+    public static final String ACTION_ID = "urn:oasis:names:tc:xacml:1.0:action:action-id";
+    public static final String SUBJECT_ID = "urn:oasis:names:tc:xacml:1.0:subject:subject-id";
+    public static final String RESOURCE_ID = "urn:oasis:names:tc:xacml:1.0:resource:resource-id";
+    public static final String FUNTION_INTEGER_ONE_AND_ONLY = "urn:oasis:names:tc:xacml:1.0:function:integer-one-and-only";
+    public static final String FUNCTION_STRING_ONE_AND_ONLY = "urn:oasis:names:tc:xacml:1.0:function:string-one-and-only";
+    public static final String FUNCTION_BOOLEAN_ONE_AND_ONLY = "urn:oasis:names:tc:xacml:1.0:function:boolean-one-and-only";
+    public static final String FUNCTION_STRING_EQUAL = "urn:oasis:names:tc:xacml:1.0:function:string-equal";
+    public static final String FUNCTION_STRING_REGEX_MATCH = "org.onap.function.regex-match";
+    public static final String FUNCTION_STRING_REGEXP_MATCH = "urn:oasis:names:tc:xacml:1.0:function:string-regexp-match";
+    public static final String FUNCTION_STRING_EQUAL_IGNORE = "urn:oasis:names:tc:xacml:3.0:function:string-equal-ignore-case";
+    public static final String INTEGER_DATATYPE = "http://www.w3.org/2001/XMLSchema#integer";
+    public static final String BOOLEAN_DATATYPE = "http://www.w3.org/2001/XMLSchema#boolean";
+    public static final String STRING_DATATYPE = "http://www.w3.org/2001/XMLSchema#string";
+    public static final String URI_DATATYPE = "http://www.w3.org/2001/XMLSchema#anyURI";
+    public static final String RULE_VARIABLE = "var:";
+    public static final String EMPTY_STRING = "";
 
-		if (newFile.toFile().exists()) {
-			return newFile;
-		}
-		return null;
-	}
+    protected static String CONFIG_HOME = null;
+    protected static String ACTION_HOME = null;
+    protected static String CONFIG_URL = null;
+
+    protected Map<String, String> performer = new HashMap<>();
+
+    private static String actionHome = null;
+    private static String configHome = null;
+
+    public PolicyRestAdapter policyAdapter = null;
+    String ruleID = "";
+
+    public Policy() {
+        CONFIG_HOME = getConfigHome();
+        ACTION_HOME = getActionHome();
+        CONFIG_URL = "$URL";
+        performer.put("PDP", "PDPAction");
+        performer.put("PEP", "PEPAction");
+    }
+
+    //Each policy type seems to either use policyData or data field policy adapter when
+    //getting the xml to save the policy. Instead of keep this hardcoded in the save method,
+    //this method makes it usable outside.
+    /**
+     * Return the data field of the PolicyAdapter that will be used when saving this policy
+     * with the savePolicies method.
+     * @return Either the PolicyAdapter.getData() or PolicyAdapter.getPolicyData()
+     */
+    public abstract Object getCorrectPolicyDataObject();
+    public abstract Map<String, String>  savePolicies() throws PAPException;
+
+    //This is the method for preparing the policy for saving.  We have broken it out
+    //separately because the fully configured policy is used for multiple things
+    public abstract boolean prepareToSave() throws PAPException;
 
 
-	//create policy once all the validations are completed
-	protected Map<String, String> createPolicy(final Path policyPath, final Object policyData) {
-		Map<String, String> success = new HashMap<>(); 
-		//
-		// Is the root a PolicySet or Policy?
-		//
+    // create match for onap and config name
+    protected MatchType createMatch(String key, String value) {
+        MatchType match = new MatchType();
 
-		if (policyData instanceof PolicyType) {
-			//
-			// Write it out
-			//
-			//Does not need to be XACMLPolicyWriterWithPapNotify since it is already in the PAP
-			//and this transaction is intercepted up stream.
-			InputStream inputStream = null;
-			try {
-				inputStream = XACMLPolicyWriter.getXmlAsInputStream((PolicyType) policyData);
-				PolicyDef policyDef = DOMPolicyDef.load(inputStream);
-				if (policyDef == null) {
-					success.put("validation", "PolicyDef Validation Failed");
-				}else{
-					success.put("success", "success");
-				}
-			} catch (Exception e) {
-				LOGGER.error("PolicyDef Validation failed"+e);
-				success.put("error", "Validation Failed");
-			}finally{
-				try {
-					if(inputStream != null)
-						inputStream.close();
-				} catch (IOException e) {
-					LOGGER.error("Exception Occured while closing the input stream"+e);
-				}
-			}
-		} else {
-			PolicyLogger.error("Unknown data type sent back.");
-			return success;
-		}
-		return success;
-	}
+        AttributeValueType attributeValue = new AttributeValueType();
+        attributeValue.setDataType(STRING_DATATYPE);
+        attributeValue.getContent().add(value);
+        match.setAttributeValue(attributeValue);
+        AttributeDesignatorType attributeDesignator = new AttributeDesignatorType();
+        URI uri = null;
+        try {
+            uri = new URI(key);
+        } catch (URISyntaxException e) {
+            LOGGER.error("Exception Occured"+e);
+        }
+        attributeDesignator.setCategory(CATEGORY_ACCESS_SUBJECT);
+        attributeDesignator.setDataType(STRING_DATATYPE);
+        attributeDesignator.setAttributeId(new IdentifierImpl(uri).stringValue());
+        match.setAttributeDesignator(attributeDesignator);
+        match.setMatchId(FUNCTION_STRING_REGEX_MATCH);
+        return match;
+    }
 
-	public static String getConfigHome(){
-		try {
-			loadWebapps();
-		} catch (Exception e) {
-			LOGGER.debug(e);
-			return null;
-		}
-		return configHome;
-	}
+    // Creating the match for dynamically added components.
+    protected MatchType createDynamicMatch(String key, String value) {
+        MatchType dynamicMatch = new MatchType();
+        AttributeValueType dynamicAttributeValue = new AttributeValueType();
+        String dataType = null;
+        dataType = STRING_DATATYPE;
+        dynamicAttributeValue.setDataType(dataType);
+        dynamicAttributeValue.getContent().add(value);
+        dynamicMatch.setAttributeValue(dynamicAttributeValue);
 
-	public static String getActionHome(){
-		try {
-			loadWebapps();
-		} catch (Exception e) {
-			LOGGER.debug(e);
-			return null;
-		}
-		return actionHome;
-	}
+        AttributeDesignatorType dynamicAttributeDesignator = new AttributeDesignatorType();
 
-	private static void loadWebapps() throws PAPException{
-		if(actionHome == null || configHome == null){
-			Path webappsPath = Paths.get(XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_WEBAPPS));
-			//Sanity Check
-			if (webappsPath == null) {
-				PolicyLogger.error("Invalid Webapps Path Location property : " + XACMLRestProperties.PROP_PAP_WEBAPPS);
-				throw new PAPException("Invalid Webapps Path Location property : " + XACMLRestProperties.PROP_PAP_WEBAPPS);
-			}
-			Path webappsPathConfig;
-			Path webappsPathAction;
-			if(webappsPath.toString().contains("\\")){
-				webappsPathConfig = Paths.get(webappsPath.toString()+"\\Config");
-				webappsPathAction = Paths.get(webappsPath.toString()+"\\Action");
-			}else{
-				webappsPathConfig = Paths.get(webappsPath.toString()+"/Config");
-				webappsPathAction = Paths.get(webappsPath.toString()+"/Action");
-			}
-			if(!webappsPathConfig.toFile().exists()){
-				try {
-					Files.createDirectories(webappsPathConfig);
-				} catch (IOException e) {
-					PolicyLogger.error(MessageCodes.ERROR_PROCESS_FLOW, e, "Policy", "Failed to create config directory");
-				}
-			}
-			if(!webappsPathAction.toFile().exists()){
-				try {
-					Files.createDirectories(webappsPathAction);
-				} catch (IOException e) {
-					PolicyLogger.error(MessageCodes.ERROR_PROCESS_FLOW, e, "Policy", "Failed to create config directory");
-				}
-			}
-			actionHome = webappsPathAction.toString();
-			configHome = webappsPathConfig.toString();
-		}
-	}
-	
-	public boolean validateConfigForm() {
-		return true;
-	}
+        URI dynamicURI = null;
+        try {
+            dynamicURI = new URI(key);
+        } catch (URISyntaxException e) {
+            LOGGER.error("Exception Occured"+e);// log msg
+        }
+        dynamicAttributeDesignator.setCategory(CATEGORY_RESOURCE);
+        dynamicAttributeDesignator.setDataType(dataType);
+        dynamicAttributeDesignator.setAttributeId(new IdentifierImpl(dynamicURI).stringValue());
+        dynamicMatch.setAttributeDesignator(dynamicAttributeDesignator);
+        dynamicMatch.setMatchId(FUNCTION_STRING_REGEX_MATCH);
 
-	/**
-	 * @return the preparedToSave
-	 */
-	public boolean isPreparedToSave() {
-		return preparedToSave;
-	}
+        return dynamicMatch;
+    }
 
-	/**
-	 * @param preparedToSave the preparedToSave to set
-	 */
-	protected void setPreparedToSave(boolean preparedToSave) {
-		this.preparedToSave = preparedToSave;
-	}
+    //  the Policy Name as Unique One throws error
+    @SuppressWarnings("static-access")
+    protected Path getNextFilename(Path parent, String policyType, String polcyFileName, Integer version) {
+        policyType = FilenameUtils.removeExtension(policyType);
+        polcyFileName = FilenameUtils.removeExtension(polcyFileName);
+        Path newFile = null;
+        String policyDir = EMPTY_STRING;
+        String absolutePath = parent.toString();
+        if (absolutePath != null && !absolutePath.equals(EMPTY_STRING)) {
+            policyDir = absolutePath.substring(absolutePath.lastIndexOf('\\') + 1, absolutePath.length());
+            if (policyDir == null || policyDir.equals(EMPTY_STRING)) {
+                policyDir = absolutePath.substring(absolutePath.lastIndexOf('/') + 1, absolutePath.length());
+            }
+        }
 
-	public boolean isPolicyExists() {
-		return policyExists;
-	}
+        String fileName = "default";
+        if (policyDir != null && !policyDir.equals(EMPTY_STRING)) {
+            fileName = policyType + "_" + String.format(polcyFileName) + "." + version + ".xml";
+        }
 
-	public void setPolicyExists(boolean policyExists) {
-		this.policyExists = policyExists;
-	}
+        newFile = Paths.get(parent.toString(), fileName);
+        if (newFile.toFile().exists()) {
+            return newFile;
+        }
+        return null;
+    }
+
+    protected Path getNextLoopFilename(Path parentPath, String policyType, String policyConfigType, String policyFileName, Integer version) {
+        policyType = FilenameUtils.removeExtension(policyType);
+        policyConfigType = FilenameUtils.removeExtension(policyConfigType);
+        policyFileName = FilenameUtils.removeExtension(policyFileName);
+        Path newFile = null;
+        String policyDir = EMPTY_STRING;
+        String absolutePath = parentPath.toString();
+        if (absolutePath != null && !absolutePath.equals(EMPTY_STRING)) {
+            policyDir = absolutePath.substring(absolutePath.lastIndexOf('\\') + 1, absolutePath.length());
+            if (policyDir.equals(EMPTY_STRING)) {
+                policyDir = absolutePath.substring(absolutePath.lastIndexOf('/') + 1, absolutePath.length());
+            }
+        }
+
+        String fileName = "default";
+        if (!policyDir.equals(EMPTY_STRING)) {
+            if("ClosedLoop_PM".equals(policyConfigType)){
+                fileName = policyType + "_" + "PM" + "_" +java.lang.String.format(policyFileName) + "." +version +".xml";
+            }else if("ClosedLoop_Fault".equals(policyConfigType)){
+                fileName = policyType + "_" + "Fault" + "_" +java.lang.String.format(policyFileName) +  "." + version + ".xml";
+            }else if("Micro Service".equals(policyConfigType)){
+                fileName = policyType + "_" + "MS" + "_" + java.lang.String.format(policyFileName) + "." + version + ".xml";
+            }else if("Optimization".equals(policyConfigType)) {
+                fileName = policyType + "_" + "OOF" + "_" + java.lang.String.format(policyFileName) + "." + version + ".xml";
+            }
+        }
+
+        newFile = Paths.get(parentPath.toString(), fileName);
+
+        if (newFile.toFile().exists()) {
+            return newFile;
+        }
+        return null;
+    }
+
+
+    //create policy once all the validations are completed
+    protected Map<String, String> createPolicy(final Path policyPath, final Object policyData) {
+        Map<String, String> success = new HashMap<>();
+        //
+        // Is the root a PolicySet or Policy?
+        //
+
+        if (policyData instanceof PolicyType) {
+            //
+            // Write it out
+            //
+            //Does not need to be XACMLPolicyWriterWithPapNotify since it is already in the PAP
+            //and this transaction is intercepted up stream.
+
+            try(InputStream inputStream = XACMLPolicyWriter.getXmlAsInputStream((PolicyType) policyData)) {
+                PolicyDef policyDef = DOMPolicyDef.load(inputStream);
+                if (policyDef == null) {
+                    success.put("validation", "PolicyDef Validation Failed");
+                }else{
+                    success.put("success", "success");
+                }
+            } catch (Exception e) {
+                LOGGER.error("PolicyDef Validation failed"+e);
+                success.put("error", "Validation Failed");
+            }
+        } else {
+            PolicyLogger.error("Unknown data type sent back.");
+            return success;
+        }
+        return success;
+    }
+
+    public static String getConfigHome(){
+        try {
+            loadWebapps();
+        } catch (Exception e) {
+            LOGGER.debug(e);
+            return null;
+        }
+        return configHome;
+    }
+
+    public static String getActionHome(){
+        try {
+            loadWebapps();
+        } catch (Exception e) {
+            LOGGER.debug(e);
+            return null;
+        }
+        return actionHome;
+    }
+
+    private static void loadWebapps() throws PAPException{
+        if(actionHome == null || configHome == null){
+            Path webappsPath = Paths.get(XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_WEBAPPS));
+            //Sanity Check
+            if (webappsPath == null) {
+                PolicyLogger.error("Invalid Webapps Path Location property : " + XACMLRestProperties.PROP_PAP_WEBAPPS);
+                throw new PAPException("Invalid Webapps Path Location property : " + XACMLRestProperties.PROP_PAP_WEBAPPS);
+            }
+            Path webappsPathConfig;
+            Path webappsPathAction;
+            if(webappsPath.toString().contains("\\")){
+                webappsPathConfig = Paths.get(webappsPath.toString()+"\\Config");
+                webappsPathAction = Paths.get(webappsPath.toString()+"\\Action");
+            }else{
+                webappsPathConfig = Paths.get(webappsPath.toString()+"/Config");
+                webappsPathAction = Paths.get(webappsPath.toString()+"/Action");
+            }
+            if(!webappsPathConfig.toFile().exists()){
+                try {
+                    Files.createDirectories(webappsPathConfig);
+                } catch (IOException e) {
+                    PolicyLogger.error(MessageCodes.ERROR_PROCESS_FLOW, e, "Policy", "Failed to create config directory");
+                }
+            }
+            if(!webappsPathAction.toFile().exists()){
+                try {
+                    Files.createDirectories(webappsPathAction);
+                } catch (IOException e) {
+                    PolicyLogger.error(MessageCodes.ERROR_PROCESS_FLOW, e, "Policy", "Failed to create config directory");
+                }
+            }
+            actionHome = webappsPathAction.toString();
+            configHome = webappsPathConfig.toString();
+        }
+    }
+
+    public boolean validateConfigForm() {
+        return true;
+    }
+
+    /**
+     * @return the preparedToSave
+     */
+    public boolean isPreparedToSave() {
+        return preparedToSave;
+    }
+
+    /**
+     * @param preparedToSave the preparedToSave to set
+     */
+    protected void setPreparedToSave(boolean preparedToSave) {
+        this.preparedToSave = preparedToSave;
+    }
+
+    public boolean isPolicyExists() {
+        return policyExists;
+    }
+
+    public void setPolicyExists(boolean policyExists) {
+        this.policyExists = policyExists;
+    }
 
 
 }
diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/PolicyDBDao.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/PolicyDBDao.java
index 2374ac4..1b786ed 100644
--- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/PolicyDBDao.java
+++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/components/PolicyDBDao.java
@@ -3,13 +3,14 @@
  * ONAP-PAP-REST
  * ================================================================================
  * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Modified Copyright (C) 2018 Samsung Electronics Co., Ltd.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -86,14 +87,13 @@
 import org.onap.policy.xacml.util.XACMLPolicyWriter;
 import org.w3c.dom.Document;
 import org.xml.sax.InputSource;
+import oasis.names.tc.xacml._3_0.core.schema.wd_17.PolicyType;
 
 import com.att.research.xacml.api.pap.PAPException;
 import com.att.research.xacml.api.pap.PDP;
 import com.att.research.xacml.api.pap.PDPPolicy;
 import com.att.research.xacml.util.XACMLProperties;
 
-import oasis.names.tc.xacml._3_0.core.schema.wd_17.PolicyType;
-
 public class PolicyDBDao {
     private static final Logger logger	= FlexLogger.getLogger(PolicyDBDao.class);
     private List<?> otherServers;
@@ -101,31 +101,30 @@
     private static PolicyDBDao currentInstance = null;
     private PAPPolicyEngine papEngine;
 
-    public static final String JSON_CONFIG = "JSON";
-    public static final String XML_CONFIG = "XML";
-    public static final String PROPERTIES_CONFIG = "PROPERTIES";
-    public static final String OTHER_CONFIG = "OTHER";
-    public static final String AUDIT_USER = "audit";
+    private static final String JSON_CONFIG = "JSON";
+    private static final String XML_CONFIG = "XML";
+    private static final String PROPERTIES_CONFIG = "PROPERTIES";
+    private static final String OTHER_CONFIG = "OTHER";
 
     //Declared to static variables which were repeating multiple times across the PolicyDBDao
     public static final String config = "Config";
     public static final String action = "Action";
-    public static final String groupIdVar = "groupId";
-    public static final String deletedVar = "deleted";
-    public static final String groupEntitySelectQuery = "SELECT g FROM GroupEntity g WHERE g.groupId=:groupId AND g.deleted=:deleted";
-    public static final String pdpEntitySelectQuery = "SELECT p FROM PdpEntity p WHERE p.pdpId=:pdpId AND p.deleted=:deleted";
-    public static final String groupCannotBeFound = "The group could not be found with id ";
-    public static final String foundInDBNotDeleted = " were found in the database that are not deleted";
-    public static final String moreThanOnePDP = "Somehow, more than one pdp with the same id ";
-    public static final String deletedStatusFound = " and deleted status were found in the database";
-    public static final String duplicateGroupId = "Somehow, more than one group with the same id ";
-    public static final String pdpIdVariable = "pdpId";
-    public static final String queryFailedToCheckExisting = "Query failed trying to check for existing group";
-    public static final String queryFailedToGetGroup = "Query failed trying to get group ";
+    private static final String groupIdVar = "groupId";
+    private static final String deletedVar = "deleted";
+    private static final String groupEntitySelectQuery = "SELECT g FROM GroupEntity g WHERE g.groupId=:groupId AND g.deleted=:deleted";
+    private static final String pdpEntitySelectQuery = "SELECT p FROM PdpEntity p WHERE p.pdpId=:pdpId AND p.deleted=:deleted";
+    private static final String groupCannotBeFound = "The group could not be found with id ";
+    private static final String foundInDBNotDeleted = " were found in the database that are not deleted";
+    private static final String moreThanOnePDP = "Somehow, more than one pdp with the same id ";
+    private static final String deletedStatusFound = " and deleted status were found in the database";
+    private static final String duplicateGroupId = "Somehow, more than one group with the same id ";
+    private static final String pdpIdVariable = "pdpId";
+    private static final String queryFailedToCheckExisting = "Query failed trying to check for existing group";
+    private static final String queryFailedToGetGroup = "Query failed trying to get group ";
     public static final String scope = "scope";
-    public static final String policyDBDaoVar = "PolicyDBDao";
-    public static final String duplicatePolicyId = "Somehow, more than one policy with the id ";
-    public static final String foundInDB = " were found in the database";
+    private static final String policyDBDaoVar = "PolicyDBDao";
+    private static final String duplicatePolicyId = "Somehow, more than one policy with the id ";
+    private static final String foundInDB = " were found in the database";
 
     private static boolean isJunit = false;
 
@@ -425,30 +424,6 @@
         return true;
     }
 
-    public void notifyOthers(long entityId,String entityType){
-        notifyOthers(entityId,entityType,null);
-    }
-
-    public void notifyOthers(long entityId, String entityType, String newGroupId){
-        logger.debug("notifyOthers(long entityId, String entityType, long newGroupId) as notifyOthers("+entityId+","+entityType+","+newGroupId+") called");
-        LinkedList<Thread> notifyThreads = new LinkedList<>();
-
-        //we're going to run notifications in parallel threads to speed things up
-        for(Object obj : otherServers){
-            Thread newNotifyThread = new Thread(new NotifyOtherThread(obj, entityId, entityType, newGroupId));
-            newNotifyThread.start();
-            notifyThreads.add(newNotifyThread);
-        }
-        //we want to wait for all notifications to complete or timeout before we unlock the interface and allow more changes
-        for(Thread t : notifyThreads){
-            try {
-                t.join();
-            } catch (Exception e) {
-                logger.warn("Could not join a notifcation thread" + e);
-            }
-        }
-    }
-
     private class NotifyOtherThread implements Runnable {
         public NotifyOtherThread(Object obj, long entityId, String entityType, String newGroupId){
             this.obj = obj;
@@ -481,19 +456,18 @@
             URL url;
             String papUrl;
             try {
-                    String[] papUrlUserPass = getPapUrlUserPass();
-                    if(papUrlUserPass == null ){
-                        papUrl = "undefined";
-                    } else {
-                        papUrl = papUrlUserPass[0];
-                    }
+                String[] papUrlUserPass = getPapUrlUserPass();
+                if(papUrlUserPass == null ){
+                    papUrl = "undefined";
+                } else {
+                    papUrl = papUrlUserPass[0];
+                }
                 logger.debug("We are going to try to notify "+o);
                 //is this our own url?
                 String ourUrl = o;
                 try{
                     ourUrl = splitPapUrlUserPass((String)o)[0];
                 }catch(Exception e){
-                    ourUrl = o;
                     logger.debug(e);
                 }
                 if(o == null){
@@ -617,57 +591,57 @@
         int pauseBetweenRetries = 1000;
         switch(entityType){
 
-        case POLICY_NOTIFICATION:
-            for(int i=0; i<retries;i++){
-                try{
-                    handleIncomingPolicyChange(entityId);
-                    break;
-                } catch(Exception e){
-                    logger.debug(e);
-                    PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, policyDBDaoVar, "Caught exception on handleIncomingPolicyChange("+url+", "+entityId+", "+extraData+")");
+            case POLICY_NOTIFICATION:
+                for(int i=0; i<retries;i++){
+                    try{
+                        handleIncomingPolicyChange(entityId);
+                        break;
+                    } catch(Exception e){
+                        logger.debug(e);
+                        PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, policyDBDaoVar, "Caught exception on handleIncomingPolicyChange("+url+", "+entityId+", "+extraData+")");
+                    }
+                    try{
+                        Thread.sleep(pauseBetweenRetries);
+                    }catch(InterruptedException ie){
+                        Thread.currentThread().interrupt();
+                        break;
+                    }
                 }
-                try{
-                    Thread.sleep(pauseBetweenRetries);
-                }catch(InterruptedException ie){
-                    Thread.currentThread().interrupt();
-                    break;
+                break;
+            case PDP_NOTIFICATION:
+                for(int i=0; i<retries;i++){
+                    try{
+                        handleIncomingPdpChange(entityId, transaction);
+                        break;
+                    } catch(Exception e){
+                        logger.debug(e);
+                        PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, policyDBDaoVar, "Caught exception on handleIncomingPdpChange("+url+", "+entityId+", "+transaction+")");
+                    }
+                    try{
+                        Thread.sleep(pauseBetweenRetries);
+                    }catch(InterruptedException ie){
+                        Thread.currentThread().interrupt();
+                        break;
+                    }
                 }
-            }
-            break;
-        case PDP_NOTIFICATION:
-            for(int i=0; i<retries;i++){
-                try{
-                    handleIncomingPdpChange(entityId, transaction);
-                    break;
-                } catch(Exception e){
-                    logger.debug(e);
-                    PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, policyDBDaoVar, "Caught exception on handleIncomingPdpChange("+url+", "+entityId+", "+transaction+")");
+                break;
+            case GROUP_NOTIFICATION:
+                for(int i=0; i<retries;i++){
+                    try{
+                        handleIncomingGroupChange(entityId, extraData, transaction);
+                        break;
+                    }catch(Exception e){
+                        logger.debug(e);
+                        PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, policyDBDaoVar, "Caught exception on handleIncomingGroupChange("+url+", "+entityId+", "+extraData+", "+transaction+", "+xacmlPapServlet+")");
+                    }
+                    try{
+                        Thread.sleep(pauseBetweenRetries);
+                    }catch(InterruptedException ie){
+                        Thread.currentThread().interrupt();
+                        break;
+                    }
                 }
-                try{
-                    Thread.sleep(pauseBetweenRetries);
-                }catch(InterruptedException ie){
-                    Thread.currentThread().interrupt();
-                    break;
-                }
-            }
-            break;
-        case GROUP_NOTIFICATION:
-            for(int i=0; i<retries;i++){
-                try{
-                    handleIncomingGroupChange(entityId, extraData, transaction);
-                    break;
-                }catch(Exception e){
-                    logger.debug(e);
-                    PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, policyDBDaoVar, "Caught exception on handleIncomingGroupChange("+url+", "+entityId+", "+extraData+", "+transaction+", "+xacmlPapServlet+")");
-                }
-                try{
-                    Thread.sleep(pauseBetweenRetries);
-                }catch(InterruptedException ie){
-                    Thread.currentThread().interrupt();
-                    break;
-                }
-            }
-            break;
+                break;
         }
         //no changes should be being made in this function, we still need to close
         transaction.rollbackTransaction();
@@ -909,7 +883,7 @@
                 throw new PolicyDBException();
             }
         } catch(Exception e){
-            nameAndVersion[0] = originalPolicyName;         
+            nameAndVersion[0] = originalPolicyName;
             logger.debug(e);
         }
         try{
@@ -923,7 +897,7 @@
         }
         return nameAndVersion;
     }
-    
+
     private void handleIncomingPdpChange(String pdpId, PolicyDBDaoTransaction transaction) throws PAPException{
         //get pdp
         long pdpIdLong = -1;
@@ -1321,7 +1295,7 @@
     private String[] getNameScopeAndVersionFromPdpPolicy(String fileName){
         String[] splitByDots = fileName.split("\\.");
         if(splitByDots.length < 3){
-                return null;
+            return null;
         }
         String policyName = splitByDots[splitByDots.length-3];
         String version = splitByDots[splitByDots.length-2];
@@ -1367,7 +1341,7 @@
      * @param strings One or more Strings (or nulls) to check if they are null or empty
      * @return true if one or more of the given strings are empty or null
      */
-    private static boolean isNullOrEmpty(String... strings){
+    public static boolean isNullOrEmpty(String... strings){
         for(String s : strings){
             if(s == null || "".equals(s)){
                 return true;
@@ -1939,22 +1913,14 @@
 
         @Override
         public void createPolicy(Policy policy, String username){
-            InputStream policyXmlStream = null;
+
             try{
                 logger.debug("createPolicy(PolicyRestAdapter policy, String username) as createPolicy("+policy+","+username+") called");
                 String policyScope = policy.policyAdapter.getDomainDir().replace(File.separator, ".");
                 //Does not need to be XACMLPolicyWriterWithPapNotify since it is already in the PAP
                 //and this transaction is intercepted up stream.
-                String policyDataString;
-                try {
-                    policyXmlStream = XACMLPolicyWriter.getXmlAsInputStream((PolicyType)policy.getCorrectPolicyDataObject());
-                    policyDataString = IOUtils.toString(policyXmlStream);
-                } catch (IOException e) {
-                    policyDataString = "could not read";
-                    PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, policyDBDaoVar, "Caught IOException on IOUtils.toString("+policyXmlStream+")");
-                    throw new IllegalArgumentException("Cannot parse the policy xml from the PolicyRestAdapter.");
-                }
-                IOUtils.closeQuietly(policyXmlStream);
+
+                String policyDataString = getPolicyDataString((PolicyType)policy.getCorrectPolicyDataObject());
                 if(isJunit){
                     //Using parentPath object to set policy data.
                     policyDataString = policy.policyAdapter.getParentPath();
@@ -1971,19 +1937,7 @@
 
                     prefix = configPath.substring(configPath.indexOf(policyScope+".")+policyScope.concat(".").length(), configPath.lastIndexOf(policy.policyAdapter.getPolicyName()));
                     if(isNullOrEmpty(policy.policyAdapter.getConfigBodyData())){
-                        String configData = "";
-                        try{
-                            String newConfigPath = configPath;
-                            try{
-                                newConfigPath = processConfigPath(newConfigPath);
-                            }catch(Exception e2){
-                                logger.error("Could not process config path: "+newConfigPath,e2);
-                            }
-                            configData = readConfigFile(newConfigPath);
-                        }catch(Exception e){
-                            logger.error("Could not read config body data for "+configPath,e);
-                        }
-                        policy.policyAdapter.setConfigBodyData(configData);
+                        policy.policyAdapter.setConfigBodyData(getConfigData(configPath));
                     }
                 } else if (action.equalsIgnoreCase(policy.policyAdapter.getPolicyType())) {
                     prefix = "Action_";
@@ -2017,16 +1971,39 @@
                         }
                     }
                 }
-
                 createPolicy(policy.policyAdapter, username, policyScope,finalName,policyDataString);
-            }finally{
-                if(policyXmlStream != null){
-                    try {
-                        policyXmlStream.close();
-                    } catch (IOException e) {
-                        logger.error("Exception Occured while closing input stream"+e);
-                    }
-                }
+            } catch (Exception e) {
+                logger.error("Could not create policy for "+policy,e);
+                throw e;
+            }
+        }
+
+        private String getConfigData(String configPath) {
+            String configData = "";
+            try{
+                configData = getConfigPath(configPath);
+            }catch(Exception e){
+                logger.error("Could not read config body data for "+configPath,e);
+            }
+            return configData;
+        }
+
+        private String getConfigPath(String configPath) {
+            try{
+                String newConfigPath = processConfigPath(configPath);
+                return readConfigFile(newConfigPath);
+            } catch(IllegalArgumentException e2){
+                logger.error("Could not process config path: "+configPath,e2);
+            }
+            return "";
+        }
+
+        private String getPolicyDataString(PolicyType policyType) {
+            try (InputStream policyXmlStream = XACMLPolicyWriter.getXmlAsInputStream(policyType)) {
+                return IOUtils.toString(policyXmlStream, StandardCharsets.UTF_8);
+            } catch (IOException e) {
+                PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, policyDBDaoVar, "Caught IOException on IOUtils.toString(policyXmlStream)");
+                throw new IllegalArgumentException("Cannot parse the policy xml from the PolicyRestAdapter.", e);
             }
         }
 
@@ -2140,37 +2117,7 @@
                         //should be fast since getPolicies uses a HashSet in StdPDPGroup
                         if(!newPolicySet.contains(pol.getId())){
                             String[] scopeAndName = getNameScopeAndVersionFromPdpPolicy(pol.getId());
-                            PolicyEntity policyToDelete = null;
-                            try{
-                                if(scopeAndName!=null){
-                                    policyToDelete = getPolicy(scopeAndName[0],scopeAndName[1]);
-                                    if ("XACMLPapServlet.doDelete".equals(username)) {
-                                        Iterator<PolicyEntity> dbPolicyIt = groupToUpdateInDB.getPolicies().iterator();
-                                        String policyName = getPolicyNameAndVersionFromPolicyFileName(policyToDelete.getPolicyName())[0];
-
-                                        logger.info("PolicyDBDao: delete policy from GroupEntity");
-                                        try{
-                                            while(dbPolicyIt.hasNext()){
-                                                PolicyEntity dbpolicy = dbPolicyIt.next();
-                                                if(policyToDelete.getScope().equals(dbpolicy.getScope()) &&
-                                                        getPolicyNameAndVersionFromPolicyFileName(dbpolicy.getPolicyName())[0].equals(policyName)) {
-                                                    dbPolicyIt.remove();
-
-                                                    logger.info("PolicyDBDao: deleting policy from the existing group:\n "
-                                                            + "policyName is " + policyToDelete.getScope()+"."+policyToDelete.getPolicyName() + "\n"
-                                                            + "group is " + groupToUpdateInDB.getGroupId());
-                                                }
-                                            }
-                                        }catch(Exception e){
-                                            logger.debug(e);
-                                            PolicyLogger.error("Could not delete policy with name: "+ policyToDelete.getScope()+"."+policyToDelete.getPolicyName()+"\n ID: "+ policyToDelete.getPolicyId());
-                                        }
-                                    }
-                                }
-                            }catch(Exception e){
-                                PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, policyDBDaoVar, "Could not get policy to remove: "+pol.getId());
-                                throw new PersistenceException("Could not get policy to remove: "+pol.getId());
-                            }
+                            deletePolicyInScope(username, groupToUpdateInDB, pol, scopeAndName);
                         }
                     }
                 }
@@ -2201,6 +2148,45 @@
             }
         }
 
+        private void deletePolicyInScope(String username, GroupEntity groupToUpdateInDB, PDPPolicy pol, String[] scopeAndName) {
+            PolicyEntity policyToDelete;
+            if (scopeAndName == null) {
+                return;
+            }
+            try{
+                policyToDelete = getPolicy(scopeAndName[0],scopeAndName[1]);
+                if ("XACMLPapServlet.doDelete".equals(username)) {
+                    Iterator<PolicyEntity> dbPolicyIt = groupToUpdateInDB.getPolicies().iterator();
+                    String policyName = getPolicyNameAndVersionFromPolicyFileName(policyToDelete.getPolicyName())[0];
+
+                    logger.info("PolicyDBDao: delete policy from GroupEntity");
+                    deletePolicyFromGroupEntity(groupToUpdateInDB, policyToDelete, dbPolicyIt, policyName);
+                }
+            }catch(Exception e){
+                PolicyLogger.error(MessageCodes.EXCEPTION_ERROR, e, policyDBDaoVar, "Could not get policy to remove: "+pol.getId());
+                throw new PersistenceException("Could not get policy to remove: "+pol.getId());
+            }
+        }
+
+        private void deletePolicyFromGroupEntity(GroupEntity groupToUpdateInDB, PolicyEntity policyToDelete, Iterator<PolicyEntity> dbPolicyIt, String policyName) {
+            try{
+                while(dbPolicyIt.hasNext()){
+                    PolicyEntity dbpolicy = dbPolicyIt.next();
+                    if(policyToDelete.getScope().equals(dbpolicy.getScope()) &&
+                            getPolicyNameAndVersionFromPolicyFileName(dbpolicy.getPolicyName())[0].equals(policyName)) {
+                        dbPolicyIt.remove();
+
+                        logger.info("PolicyDBDao: deleting policy from the existing group:\n "
+                                + "policyName is " + policyToDelete.getScope()+"."+policyToDelete.getPolicyName() + "\n"
+                                + "group is " + groupToUpdateInDB.getGroupId());
+                    }
+                }
+            }catch(Exception e){
+                logger.debug(e);
+                PolicyLogger.error("Could not delete policy with name: "+ policyToDelete.getScope()+"."+policyToDelete.getPolicyName()+"\n ID: "+ policyToDelete.getPolicyId());
+            }
+        }
+
         @Override
         public void addPdpToGroup(String pdpID, String groupID, String pdpName, String pdpDescription, int pdpJmxPort, String username) {
             logger.debug("addPdpToGroup(String pdpID, String groupID, String pdpName, String pdpDescription, int pdpJmxPort, String username) as addPdpToGroup("+pdpID+", "+groupID+", "+pdpName+", "+pdpDescription+", "+pdpJmxPort+", "+username+") called");
@@ -2635,6 +2621,30 @@
                 this.pdpId = pdp.getPdpKey();
             }
         }
+
+        private void notifyOthers(long entityId,String entityType){
+            notifyOthers(entityId,entityType,null);
+        }
+
+        private void notifyOthers(long entityId, String entityType, String newGroupId){
+            logger.debug("notifyOthers(long entityId, String entityType, long newGroupId) as notifyOthers("+entityId+","+entityType+","+newGroupId+") called");
+            LinkedList<Thread> notifyThreads = new LinkedList<>();
+
+            //we're going to run notifications in parallel threads to speed things up
+            for(Object obj : otherServers){
+                Thread newNotifyThread = new Thread(new NotifyOtherThread(obj, entityId, entityType, newGroupId));
+                newNotifyThread.start();
+                notifyThreads.add(newNotifyThread);
+            }
+            //we want to wait for all notifications to complete or timeout before we unlock the interface and allow more changes
+            for(Thread t : notifyThreads){
+                try {
+                    t.join();
+                } catch (Exception e) {
+                    logger.warn("Could not join a notifcation thread" + e);
+                }
+            }
+        }
     }
 
     private PolicyDBDao(){
@@ -2654,4 +2664,4 @@
         }
     }
 
-}
+}
\ No newline at end of file
diff --git a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/policycontroller/PolicyCreation.java b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/policycontroller/PolicyCreation.java
index f7ef1a0..a6cda5e 100644
--- a/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/policycontroller/PolicyCreation.java
+++ b/ONAP-PAP-REST/src/main/java/org/onap/policy/pap/xacml/rest/policycontroller/PolicyCreation.java
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP-PAP-REST
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -416,6 +416,16 @@
 							String blackList = StringUtils.join(policyData.getYamlparams().getBlackList(), ",");
 							attributeMap.put("blackList", blackList);
 						}
+						if(DecisionPolicy.GUARD_BL_YAML.equals(policyData.getRuleProvider()) && "Use File Upload".equals(policyData.getBlackListEntryType())){
+							if(policyData.getBlackListEntries() != null && !policyData.getBlackListEntries().isEmpty()){
+								String blackList = StringUtils.join(policyData.getBlackListEntries(), ",");
+								attributeMap.put("blackList", blackList);
+							}
+							if(policyData.getAppendBlackListEntries() != null && !policyData.getAppendBlackListEntries().isEmpty()){
+								String blackList = StringUtils.join(policyData.getAppendBlackListEntries(), ",");
+								attributeMap.put("appendBlackList", blackList);
+							}
+						}
 						if(policyData.getYamlparams().getTargets()!=null){
 							String targets = StringUtils.join(policyData.getYamlparams().getTargets(),",");
 							attributeMap.put("targets", targets);
diff --git a/ONAP-PAP-REST/src/main/resources/Decision_GuardBLPolicyTemplate.xml b/ONAP-PAP-REST/src/main/resources/Decision_GuardBLPolicyTemplate.xml
index 1ac292c..43d7a23 100644
--- a/ONAP-PAP-REST/src/main/resources/Decision_GuardBLPolicyTemplate.xml
+++ b/ONAP-PAP-REST/src/main/resources/Decision_GuardBLPolicyTemplate.xml
@@ -122,7 +122,7 @@
         <AdviceExpressions>
             <AdviceExpression AdviceId="GUARD_BL_YAML" AppliesTo="Deny">
                 <AttributeAssignmentExpression AttributeId="guard.response" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource">
-                    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">Denied!</AttributeValue>
+                    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">Denied By Blacklist</AttributeValue>
                 </AttributeAssignmentExpression>
             </AdviceExpression>
         </AdviceExpressions>
diff --git a/ONAP-PAP-REST/src/main/resources/Decision_GuardPolicyTemplate.xml b/ONAP-PAP-REST/src/main/resources/Decision_GuardPolicyTemplate.xml
index 15465f3..809dc99 100644
--- a/ONAP-PAP-REST/src/main/resources/Decision_GuardPolicyTemplate.xml
+++ b/ONAP-PAP-REST/src/main/resources/Decision_GuardPolicyTemplate.xml
@@ -118,7 +118,7 @@
         <AdviceExpressions>
             <AdviceExpression AdviceId="GUARD_YAML" AppliesTo="Deny">
                 <AttributeAssignmentExpression AttributeId="guard.response" Category="urn:oasis:names:tc:xacml:3.0:attribute-category:resource">
-                    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">Denied!</AttributeValue>
+                    <AttributeValue DataType="http://www.w3.org/2001/XMLSchema#string">Denied By Guard</AttributeValue>
                 </AttributeAssignmentExpression>
             </AdviceExpression>
         </AdviceExpressions>
diff --git a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/XACMLPdpRegisterThread.java b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/XACMLPdpRegisterThread.java
index 49400d6..b33c4bd 100644
--- a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/XACMLPdpRegisterThread.java
+++ b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/XACMLPdpRegisterThread.java
@@ -3,6 +3,7 @@
  * ONAP-PDP-REST
  * ================================================================================
  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Modified Copyright (C) 2018 Samsung Electronics Co., Ltd.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -46,240 +47,240 @@
 import org.onap.policy.common.logging.flexlogger.*; 
 
 public class XACMLPdpRegisterThread implements Runnable {
-	private static final Logger LOGGER	= FlexLogger.getLogger(XACMLPdpRegisterThread.class);
-	private static final Logger auditLogger = FlexLogger.getLogger("auditLogger");
-	private ONAPLoggingContext baseLoggingContext = null;
-	
+    private static final Logger LOGGER	= FlexLogger.getLogger(XACMLPdpRegisterThread.class);
+    private static final Logger auditLogger = FlexLogger.getLogger("auditLogger");
+    private ONAPLoggingContext baseLoggingContext = null;
 
 
-	public volatile boolean isRunning = false;
-	
-	public XACMLPdpRegisterThread(ONAPLoggingContext baseLoggingContext) {
-		this.baseLoggingContext = baseLoggingContext;
-	}
 
-	public synchronized boolean isRunning() {
-		return this.isRunning;
-	}
-	
-	public synchronized void terminate() {
-		this.isRunning = false;
-	}
-	
-	/**
-	 * 
-	 * This is our thread that runs on startup to tell the PAP server we are up-and-running.
-	 * 
-	 */
-	@Override
-	public void run() {
-		synchronized(this) {
-			this.isRunning = true;
-		}
-		// get a new logging context for the thread
-		ONAPLoggingContext loggingContext = new ONAPLoggingContext(baseLoggingContext);
-		loggingContext.setServiceName("PDP:PAP.register");
-		//are we registered with at least one
-		boolean registered = false;
-		boolean interrupted = false;
-		/*
-		int seconds;
-		try {
-			seconds = Integer.parseInt(XACMLProperties.getProperty(XACMLRestProperties.PROP_PDP_REGISTER_SLEEP));
-		} catch (NumberFormatException e) {
-			LOGGER.error( XACMLErrorConstants.ERROR_SYSTEM_ERROR +"REGISTER_SLEEP: ", e);
-			seconds = 5;
-		}
-		if (seconds < 5) {
-			seconds = 5;
-		}
-		int retries;
-		try {
-			retries = Integer.parseInt(XACMLProperties.getProperty(XACMLRestProperties.PROP_PDP_REGISTER_RETRIES));
-		} catch (NumberFormatException e) {
-			LOGGER.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR +" REGISTER_SLEEP: ", e);
-			retries = -1;
-		}
-		*/
-		PapUrlResolver papUrls = PapUrlResolver.getInstance();
-		//while (! registered && ! interrupted && this.isRunning()) {
-		String tempRootPoliciesProperty = XACMLProperties.getProperty(XACMLProperties.PROP_ROOTPOLICIES);
-		String tempReferencedPoliciesProperty = XACMLProperties.getProperty(XACMLProperties.PROP_REFERENCEDPOLICIES);
-		Properties tempPipConfigProperties = new Properties();
-		try(InputStream pipFile = Files.newInputStream(XACMLPdpLoader.getPIPConfig())){
-			tempPipConfigProperties.load(pipFile);
-		} catch(Exception e){
-			LOGGER.error("Failed to open PIP property file", e);
-		}
-		while(papUrls.hasMoreUrls()){
-			String papID = papUrls.getUserId();
-			String papPass = papUrls.getPass();
-			Base64.Encoder encoder = Base64.getEncoder();
-			String encoding = encoder.encodeToString((papID+":"+papPass).getBytes(StandardCharsets.UTF_8));
-			HttpURLConnection connection = null;
-			try {
-				// get a new transaction (request) ID and update the logging context.
-				// each time through the outer loop is considered a new transaction.
-				// each time through the inner loop (which handles redirects) is a
-				// continuation of the same transaction.
-				UUID requestID = UUID.randomUUID();
-				loggingContext.setRequestID(requestID.toString());
-				//PolicyLogger.info("Request Id generated in XACMLPdpRegisterThread under XACML-PDP-REST");
-				loggingContext.transactionStarted();
-				//
-				// Get the list of PAP Servlet URLs from the property file
-				//
-				//String papUrlList = XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_URL);
-				//String[] papUrls = papUrlList.split(",");
-				//PapUrlResolver.setPapUrls(papUrls);
-				URL url = new URL(papUrls.getUrl());
-				LOGGER.info("Registering with " + url.toString());
-				//PolicyLogger.info("new transaction (request) ID and update to logging context in XACMLPdpRegisterThread");
-				boolean finished = false;
-				while (! finished) {
-					//
-					// Open up the connection
-					//
-					connection = (HttpURLConnection)url.openConnection();
-					//
-					// Setup our method and headers
-					//
-		            connection.setRequestMethod("POST");
-		            connection.setRequestProperty("Authorization", "Basic " + encoding);
-					connection.setRequestProperty("Accept", "text/x-java-properties");
-		            connection.setRequestProperty("Content-Type", "text/x-java-properties");
-		            connection.setRequestProperty(XACMLRestProperties.PROP_PDP_HTTP_HEADER_ID, XACMLProperties.getProperty(XACMLRestProperties.PROP_PDP_ID));
-		            connection.setRequestProperty(XACMLRestProperties.PROP_PDP_HTTP_HEADER_JMX_PORT, XACMLProperties.getProperty(XACMLRestProperties.PROP_PDP_JMX_PORT));
-		            connection.setRequestProperty("X-ECOMP-RequestID", requestID.toString());
-		            connection.setUseCaches(false);
-		            //
-		            // Adding this in. It seems the HttpUrlConnection class does NOT
-		            // properly forward our headers for POST re-direction. It does so
-		            // for a GET re-direction.
-		            //
-		            // So we need to handle this ourselves.
-		            //
-		            connection.setInstanceFollowRedirects(false);
-	    			connection.setDoOutput(true);
-	    			connection.setDoInput(true);
-		    		try {
-		    			//
-		    			// Send our current policy configuration
-		    			//
-		    			String lists = XACMLProperties.PROP_ROOTPOLICIES + "=" + tempRootPoliciesProperty;
-		    			lists = lists + "\n" + XACMLProperties.PROP_REFERENCEDPOLICIES + "=" + tempReferencedPoliciesProperty + "\n";
-		    			try (InputStream listsInputStream = new ByteArrayInputStream(lists.getBytes());		    					
-		    					OutputStream os = connection.getOutputStream()) {
-		    				IOUtils.copy(listsInputStream, os);
+    public volatile boolean isRunning = false;
 
-			    			//
-			    			// Send our current PIP configuration
-			    			//
-			    			//IOUtils.copy(pipInputStream, os);
-		    				tempPipConfigProperties.store(os, "");
-		    			}
-		    		} catch (Exception e) {
-		    			LOGGER.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR +"Failed to send property file", e);
-		    		}
-		            //
-		            // Do the connect
-		            //
-		            connection.connect();
-		            if (connection.getResponseCode() == 204) {
-		            	LOGGER.info("Success. We are configured correctly.");
-		            	loggingContext.transactionEnded();
-		            	PolicyLogger.audit("Success. We are configured correctly.");
-		            	papUrls.registered();
-		            	finished = true;
-		            	registered = true;		            	
-		            } else if (connection.getResponseCode() == 200) {
-		            	LOGGER.info("Success. We have a new configuration.");
-		            	loggingContext.transactionEnded();
-		            	PolicyLogger.audit("Success. We have a new configuration.");
-		            	papUrls.registered();
-		            	Properties properties = new Properties();
-		            	properties.load(connection.getInputStream());		            	
-		            	LOGGER.info("New properties: " + properties.toString());
-		            	//
-		            	// Queue it
-		            	//
-		            	// The incoming properties does NOT include urls		            
-		            	Properties returnedPolicyProperties = XACMLProperties.getPolicyProperties(properties, false);
-		            	tempRootPoliciesProperty = new String(returnedPolicyProperties.getProperty(XACMLProperties.PROP_ROOTPOLICIES));
-		            	tempReferencedPoliciesProperty = new String(returnedPolicyProperties.getProperty(XACMLProperties.PROP_REFERENCEDPOLICIES));		            	
-		            	Properties returnedPipProperties = XACMLProperties.getPipProperties(properties);
-		            	Properties threadSafeReturnedPipProperties = new Properties();
-		            	ByteArrayOutputStream threadSafeReturnedPipPropertiesOs = new ByteArrayOutputStream();
-		            	returnedPipProperties.store(threadSafeReturnedPipPropertiesOs, "");		            	
-		            	InputStream threadSafeReturnedPipPropertiesIs = new ByteArrayInputStream(threadSafeReturnedPipPropertiesOs.toByteArray());
-		            	threadSafeReturnedPipProperties.load(threadSafeReturnedPipPropertiesIs);
-		            	tempPipConfigProperties = threadSafeReturnedPipProperties;
+    public XACMLPdpRegisterThread(ONAPLoggingContext baseLoggingContext) {
+        this.baseLoggingContext = baseLoggingContext;
+    }
 
-		            	PutRequest req = new PutRequest(returnedPolicyProperties,returnedPipProperties);
-		            	XACMLPdpServlet.queue.offer(req);
-		            	//
-		            	// We are now registered
-		            	//
-		            	finished = true;
-		            	registered=true;
-		            } else if (connection.getResponseCode() >= 300 && connection.getResponseCode()  <= 399) {
-		            	//
-		            	// Re-direction
-		            	//
-		            	String newLocation = connection.getHeaderField("Location");
-		            	if (newLocation == null || newLocation.isEmpty()) {
-		            		LOGGER.warn(XACMLErrorConstants.ERROR_SYSTEM_ERROR +"Did not receive a valid re-direction location");
-			            	loggingContext.transactionEnded();
-			            	auditLogger.warn(XACMLErrorConstants.ERROR_SYSTEM_ERROR +"Did not receive a valid re-direction location");
-			            	PolicyLogger.audit("Transaction Failed - See Error.log");
-		            		finished = true;
-		            	} else {
-		            		LOGGER.info("New Location: " + newLocation);
-		            		url = new URL(newLocation);
-		            	}
-		            } else {
-		            	LOGGER.warn(XACMLErrorConstants.ERROR_SYSTEM_ERROR + "Failed: " + connection.getResponseCode() + "  message: " + connection.getResponseMessage());
-		            	loggingContext.transactionEnded();
-		            	auditLogger.warn(XACMLErrorConstants.ERROR_SYSTEM_ERROR + "Failed: " + connection.getResponseCode() + "  message: " + connection.getResponseMessage());
-		            	PolicyLogger.audit("Transaction Failed - See Error.log");
-		            	finished = true;
-		            	papUrls.failed();
-		            }
-				}
-			} catch (Exception e) {
-				LOGGER.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + e);
-				loggingContext.transactionEnded();
-				PolicyLogger.audit("Transaction Failed - See Error.log");
-				papUrls.failed();
-			} finally {
-				// cleanup the connection
- 				if (connection != null) {
-					try {
-						// For some reason trying to get the inputStream from the connection
-						// throws an exception rather than returning null when the InputStream does not exist.
-						InputStream is = null;
-						try {
-							is = connection.getInputStream();
-						} catch (Exception e1) {
-							LOGGER.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + "Failed to get Input Stream: " + e1);
-						}
-						if (is != null) {
-							is.close();
-						}
+    public synchronized boolean isRunning() {
+        return this.isRunning;
+    }
 
-					} catch (IOException ex) {
-						LOGGER.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + "Failed to close connection: " + ex, ex);
-					}
-					connection.disconnect();
-				}
-			}
+    public synchronized void terminate() {
+        this.isRunning = false;
+    }
 
-			papUrls.getNext();
-		}
-		synchronized(this) {
-			this.isRunning = false;
-		}
-		LOGGER.info("Thread exiting...(registered=" + registered + ", interrupted=" + interrupted + ", isRunning=" + this.isRunning() + ", retries=" + "0" + ")");
-	}
+    /**
+     *
+     * This is our thread that runs on startup to tell the PAP server we are up-and-running.
+     *
+     */
+    @Override
+    public void run() {
+        synchronized(this) {
+            this.isRunning = true;
+        }
+        // get a new logging context for the thread
+        ONAPLoggingContext loggingContext = new ONAPLoggingContext(baseLoggingContext);
+        loggingContext.setServiceName("PDP:PAP.register");
+        //are we registered with at least one
+        boolean registered = false;
+        boolean interrupted = false;
+        /*
+        int seconds;
+        try {
+            seconds = Integer.parseInt(XACMLProperties.getProperty(XACMLRestProperties.PROP_PDP_REGISTER_SLEEP));
+        } catch (NumberFormatException e) {
+            LOGGER.error( XACMLErrorConstants.ERROR_SYSTEM_ERROR +"REGISTER_SLEEP: ", e);
+            seconds = 5;
+        }
+        if (seconds < 5) {
+            seconds = 5;
+        }
+        int retries;
+        try {
+            retries = Integer.parseInt(XACMLProperties.getProperty(XACMLRestProperties.PROP_PDP_REGISTER_RETRIES));
+        } catch (NumberFormatException e) {
+            LOGGER.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR +" REGISTER_SLEEP: ", e);
+            retries = -1;
+        }
+        */
+        PapUrlResolver papUrls = PapUrlResolver.getInstance();
+        //while (! registered && ! interrupted && this.isRunning()) {
+        String tempRootPoliciesProperty = XACMLProperties.getProperty(XACMLProperties.PROP_ROOTPOLICIES);
+        String tempReferencedPoliciesProperty = XACMLProperties.getProperty(XACMLProperties.PROP_REFERENCEDPOLICIES);
+        Properties tempPipConfigProperties = new Properties();
+        try(InputStream pipFile = Files.newInputStream(XACMLPdpLoader.getPIPConfig())){
+            tempPipConfigProperties.load(pipFile);
+        } catch(Exception e){
+            LOGGER.error("Failed to open PIP property file", e);
+        }
+        while(papUrls.hasMoreUrls()){
+            String papID = papUrls.getUserId();
+            String papPass = papUrls.getPass();
+            Base64.Encoder encoder = Base64.getEncoder();
+            String encoding = encoder.encodeToString((papID+":"+papPass).getBytes(StandardCharsets.UTF_8));
+            HttpURLConnection connection = null;
+            try {
+                // get a new transaction (request) ID and update the logging context.
+                // each time through the outer loop is considered a new transaction.
+                // each time through the inner loop (which handles redirects) is a
+                // continuation of the same transaction.
+                UUID requestID = UUID.randomUUID();
+                loggingContext.setRequestID(requestID.toString());
+                //PolicyLogger.info("Request Id generated in XACMLPdpRegisterThread under XACML-PDP-REST");
+                loggingContext.transactionStarted();
+                //
+                // Get the list of PAP Servlet URLs from the property file
+                //
+                //String papUrlList = XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_URL);
+                //String[] papUrls = papUrlList.split(",");
+                //PapUrlResolver.setPapUrls(papUrls);
+                URL url = new URL(papUrls.getUrl());
+                LOGGER.info("Registering with " + url.toString());
+                //PolicyLogger.info("new transaction (request) ID and update to logging context in XACMLPdpRegisterThread");
+                boolean finished = false;
+                while (! finished) {
+                    //
+                    // Open up the connection
+                    //
+                    connection = (HttpURLConnection)url.openConnection();
+                    //
+                    // Setup our method and headers
+                    //
+                    connection.setRequestMethod("POST");
+                    connection.setRequestProperty("Authorization", "Basic " + encoding);
+                    connection.setRequestProperty("Accept", "text/x-java-properties");
+                    connection.setRequestProperty("Content-Type", "text/x-java-properties");
+                    connection.setRequestProperty(XACMLRestProperties.PROP_PDP_HTTP_HEADER_ID, XACMLProperties.getProperty(XACMLRestProperties.PROP_PDP_ID));
+                    connection.setRequestProperty(XACMLRestProperties.PROP_PDP_HTTP_HEADER_JMX_PORT, XACMLProperties.getProperty(XACMLRestProperties.PROP_PDP_JMX_PORT));
+                    connection.setRequestProperty("X-ECOMP-RequestID", requestID.toString());
+                    connection.setUseCaches(false);
+                    //
+                    // Adding this in. It seems the HttpUrlConnection class does NOT
+                    // properly forward our headers for POST re-direction. It does so
+                    // for a GET re-direction.
+                    //
+                    // So we need to handle this ourselves.
+                    //
+                    connection.setInstanceFollowRedirects(false);
+                    connection.setDoOutput(true);
+                    connection.setDoInput(true);
+                    try {
+                        //
+                        // Send our current policy configuration
+                        //
+                        String lists = XACMLProperties.PROP_ROOTPOLICIES + "=" + tempRootPoliciesProperty;
+                        lists = lists + "\n" + XACMLProperties.PROP_REFERENCEDPOLICIES + "=" + tempReferencedPoliciesProperty + "\n";
+                        try (InputStream listsInputStream = new ByteArrayInputStream(lists.getBytes());
+                                OutputStream os = connection.getOutputStream()) {
+                            IOUtils.copy(listsInputStream, os);
+
+                            //
+                            // Send our current PIP configuration
+                            //
+                            //IOUtils.copy(pipInputStream, os);
+                            tempPipConfigProperties.store(os, "");
+                        }
+                    } catch (Exception e) {
+                        LOGGER.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR +"Failed to send property file", e);
+                    }
+                    //
+                    // Do the connect
+                    //
+                    connection.connect();
+                    if (connection.getResponseCode() == 204) {
+                        LOGGER.info("Success. We are configured correctly.");
+                        loggingContext.transactionEnded();
+                        PolicyLogger.audit("Success. We are configured correctly.");
+                        papUrls.registered();
+                        finished = true;
+                        registered = true;
+                    } else if (connection.getResponseCode() == 200) {
+                        LOGGER.info("Success. We have a new configuration.");
+                        loggingContext.transactionEnded();
+                        PolicyLogger.audit("Success. We have a new configuration.");
+                        papUrls.registered();
+                        Properties properties = new Properties();
+                        properties.load(connection.getInputStream());
+                        LOGGER.info("New properties: " + properties.toString());
+                        //
+                        // Queue it
+                        //
+                        // The incoming properties does NOT include urls
+                        Properties returnedPolicyProperties = XACMLProperties.getPolicyProperties(properties, false);
+                        tempRootPoliciesProperty = returnedPolicyProperties.getProperty(XACMLProperties.PROP_ROOTPOLICIES);
+                        tempReferencedPoliciesProperty = returnedPolicyProperties.getProperty(XACMLProperties.PROP_REFERENCEDPOLICIES);
+                        Properties returnedPipProperties = XACMLProperties.getPipProperties(properties);
+                        Properties threadSafeReturnedPipProperties = new Properties();
+                        ByteArrayOutputStream threadSafeReturnedPipPropertiesOs = new ByteArrayOutputStream();
+                        returnedPipProperties.store(threadSafeReturnedPipPropertiesOs, "");
+                        InputStream threadSafeReturnedPipPropertiesIs = new ByteArrayInputStream(threadSafeReturnedPipPropertiesOs.toByteArray());
+                        threadSafeReturnedPipProperties.load(threadSafeReturnedPipPropertiesIs);
+                        tempPipConfigProperties = threadSafeReturnedPipProperties;
+
+                        PutRequest req = new PutRequest(returnedPolicyProperties,returnedPipProperties);
+                        XACMLPdpServlet.queue.offer(req);
+                        //
+                        // We are now registered
+                        //
+                        finished = true;
+                        registered=true;
+                    } else if (connection.getResponseCode() >= 300 && connection.getResponseCode()  <= 399) {
+                        //
+                        // Re-direction
+                        //
+                        String newLocation = connection.getHeaderField("Location");
+                        if (newLocation == null || newLocation.isEmpty()) {
+                            LOGGER.warn(XACMLErrorConstants.ERROR_SYSTEM_ERROR +"Did not receive a valid re-direction location");
+                            loggingContext.transactionEnded();
+                            auditLogger.warn(XACMLErrorConstants.ERROR_SYSTEM_ERROR +"Did not receive a valid re-direction location");
+                            PolicyLogger.audit("Transaction Failed - See Error.log");
+                            finished = true;
+                        } else {
+                            LOGGER.info("New Location: " + newLocation);
+                            url = new URL(newLocation);
+                        }
+                    } else {
+                        LOGGER.warn(XACMLErrorConstants.ERROR_SYSTEM_ERROR + "Failed: " + connection.getResponseCode() + "  message: " + connection.getResponseMessage());
+                        loggingContext.transactionEnded();
+                        auditLogger.warn(XACMLErrorConstants.ERROR_SYSTEM_ERROR + "Failed: " + connection.getResponseCode() + "  message: " + connection.getResponseMessage());
+                        PolicyLogger.audit("Transaction Failed - See Error.log");
+                        finished = true;
+                        papUrls.failed();
+                    }
+                }
+            } catch (Exception e) {
+                LOGGER.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + e);
+                loggingContext.transactionEnded();
+                PolicyLogger.audit("Transaction Failed - See Error.log");
+                papUrls.failed();
+            } finally {
+                // cleanup the connection
+                if (connection != null) {
+                    try {
+                        // For some reason trying to get the inputStream from the connection
+                        // throws an exception rather than returning null when the InputStream does not exist.
+                        InputStream is = null;
+                        try {
+                            is = connection.getInputStream();
+                        } catch (Exception e1) {
+                            LOGGER.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + "Failed to get Input Stream: " + e1);
+                        }
+                        if (is != null) {
+                            is.close();
+                        }
+
+                    } catch (IOException ex) {
+                        LOGGER.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + "Failed to close connection: " + ex, ex);
+                    }
+                    connection.disconnect();
+                }
+            }
+
+            papUrls.getNext();
+        }
+        synchronized(this) {
+            this.isRunning = false;
+        }
+        LOGGER.info("Thread exiting...(registered=" + registered + ", interrupted=" + interrupted + ", isRunning=" + this.isRunning() + ", retries=" + "0" + ")");
+    }
 
 }
diff --git a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/PDPServices.java b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/PDPServices.java
index 5d831f6..6dae064 100644
--- a/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/PDPServices.java
+++ b/ONAP-PDP-REST/src/main/java/org/onap/policy/pdp/rest/api/services/PDPServices.java
@@ -3,6 +3,7 @@
  * ONAP-PDP-REST
  * ================================================================================
  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Modified Copyright (C) 2018 Samsung Electronics Co., Ltd.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -340,83 +341,66 @@
         if(pdpConfigLocation.contains("/")){
             pdpConfigLocation = pdpConfigLocation.replace("/", File.separator);
         }
-        InputStream inputStream = null;
-        JsonReader jsonReader = null;
-        try {
-            inputStream = new FileInputStream(new File(pdpConfigLocation));
-            try {
-                if (pdpConfigLocation.endsWith("json")) {
-                    pdpResponse.setType(PolicyType.JSON);
-                    jsonReader = Json.createReader(inputStream);
+
+        try(InputStream inputStream = new FileInputStream(new File(pdpConfigLocation))) {
+            if (pdpConfigLocation.endsWith("json")) {
+                pdpResponse.setType(PolicyType.JSON);
+                try(JsonReader jsonReader = Json.createReader(inputStream);) {
                     pdpResponse.setConfig(jsonReader.readObject().toString());
-                    jsonReader.close();
-                } else if (pdpConfigLocation.endsWith("xml")) {
-                    pdpResponse.setType(PolicyType.XML);
-                    DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
-                    dbf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
-                    dbf.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
-                    DocumentBuilder db = null;
-                    try {
-                        db = dbf.newDocumentBuilder();
-                        Document document = db.parse(inputStream);
-                        DOMSource domSource = new DOMSource(document);
-                        StringWriter writer = new StringWriter();
-                        StreamResult result = new StreamResult(writer);
-                        TransformerFactory tf = TransformerFactory.newInstance();
-                        Transformer transformer;
-                        transformer = tf.newTransformer();
-                        transformer.transform(domSource, result);
-                        pdpResponse.setConfig(writer.toString());
-                    } catch (Exception e) {
-                        LOGGER.error(XACMLErrorConstants.ERROR_SCHEMA_INVALID+ e);
-                        throw new PDPException(XACMLErrorConstants.ERROR_SCHEMA_INVALID+ "Unable to parse the XML config", e);
-                    }
-                } else if (pdpConfigLocation.endsWith("properties")) {
-                    pdpResponse.setType(PolicyType.PROPERTIES);
-                    Properties configProp = new Properties();
-                    configProp.load(inputStream);
-                    Map<String, String> propVal = new HashMap<>();
-                    for(String name: configProp.stringPropertyNames()) {
-                        propVal.put(name, configProp.getProperty(name));
-                    }
-                    pdpResponse.setProperty(propVal);
-                } else if (pdpConfigLocation.endsWith("txt")) {
-                    pdpResponse.setType(PolicyType.OTHER);
-                    String other = IOUtils.toString(inputStream);
-                    IOUtils.closeQuietly(inputStream);
-                    pdpResponse.setConfig(other);
-                } else {
-                    LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "Config Not Found");
-                    pdpResponse.setPolicyConfigStatus(PolicyConfigStatus.CONFIG_NOT_FOUND);
-                    pdpResponse.setPolicyConfigMessage("Illegal form of Configuration Type Found.");
-                    inputStream.close();
-                    return pdpResponse;
                 }
-                LOGGER.info("config Retrieved " + pdpConfigLocation);
-                pdpResponse.setStatus("Config Retrieved! ",
-                        PolicyResponseStatus.NO_ACTION_REQUIRED,
-                        PolicyConfigStatus.CONFIG_RETRIEVED);
+            } else if (pdpConfigLocation.endsWith("xml")) {
+                pdpResponse.setType(PolicyType.XML);
+                DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
+                dbf.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
+                dbf.setFeature("http://apache.org/xml/features/disallow-doctype-decl", true);
+                DocumentBuilder db = null;
+                try {
+                    db = dbf.newDocumentBuilder();
+                    Document document = db.parse(inputStream);
+                    DOMSource domSource = new DOMSource(document);
+                    StringWriter writer = new StringWriter();
+                    StreamResult result = new StreamResult(writer);
+                    TransformerFactory tf = TransformerFactory.newInstance();
+                    Transformer transformer;
+                    transformer = tf.newTransformer();
+                    transformer.transform(domSource, result);
+                    pdpResponse.setConfig(writer.toString());
+                } catch (Exception e) {
+                    LOGGER.error(XACMLErrorConstants.ERROR_SCHEMA_INVALID+ e);
+                    throw new PDPException(XACMLErrorConstants.ERROR_SCHEMA_INVALID+ "Unable to parse the XML config", e);
+                }
+            } else if (pdpConfigLocation.endsWith("properties")) {
+                pdpResponse.setType(PolicyType.PROPERTIES);
+                Properties configProp = new Properties();
+                configProp.load(inputStream);
+                Map<String, String> propVal = new HashMap<>();
+                for(String name: configProp.stringPropertyNames()) {
+                    propVal.put(name, configProp.getProperty(name));
+                }
+                pdpResponse.setProperty(propVal);
+            } else if (pdpConfigLocation.endsWith("txt")) {
+                pdpResponse.setType(PolicyType.OTHER);
+                String other = IOUtils.toString(inputStream);
+                IOUtils.closeQuietly(inputStream);
+                pdpResponse.setConfig(other);
+            } else {
+                LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "Config Not Found");
+                pdpResponse.setPolicyConfigStatus(PolicyConfigStatus.CONFIG_NOT_FOUND);
+                pdpResponse.setPolicyConfigMessage("Illegal form of Configuration Type Found.");
                 return pdpResponse;
-            } catch (IOException | ParserConfigurationException e) {
-                LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
-                throw new PDPException(XACMLErrorConstants.ERROR_PROCESS_FLOW +
-                        "Cannot open a connection to the configURL", e);
-            } finally {
-                if(jsonReader != null) {
-                    try {
-                        jsonReader.close();
-                    } catch (Exception e) {
-                        LOGGER.error("Exception Occured while closing the JsonReader"+e);
-                    }
-                }
             }
+            LOGGER.info("config Retrieved " + pdpConfigLocation);
+            pdpResponse.setStatus("Config Retrieved! ",
+                    PolicyResponseStatus.NO_ACTION_REQUIRED,
+                    PolicyConfigStatus.CONFIG_RETRIEVED);
+            return pdpResponse;
         } catch (FileNotFoundException e) {
             LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE + e);
             throw new PDPException(XACMLErrorConstants.ERROR_DATA_ISSUE + "Error in ConfigURL", e);
-        }finally{
-            if(inputStream != null){
-                inputStream.close();
-            }
+        } catch (IOException | ParserConfigurationException e) {
+            LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + e);
+            throw new PDPException(XACMLErrorConstants.ERROR_PROCESS_FLOW +
+                    "Cannot open a connection to the configURL", e);
         }
     }
 
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/XACMLRest.java b/ONAP-REST/src/main/java/org/onap/policy/rest/XACMLRest.java
index 0912515..7cced56 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/XACMLRest.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/XACMLRest.java
@@ -3,6 +3,7 @@
  * ONAP-REST
  * ================================================================================
  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Modified Copyright (C) 2018 Samsung Electronics Co., Ltd.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -44,174 +45,176 @@
  *
  */
 public class XACMLRest {
-	private static final Log logger	= LogFactory.getLog(XACMLRest.class);
-	private static Properties restProperties = new Properties();
+    private static final Log logger	= LogFactory.getLog(XACMLRest.class);
+    private static Properties restProperties = new Properties();
 
-	private XACMLRest(){
-	    // Empty constructor
+    private XACMLRest(){
+        // Empty constructor
     }
-	/**
-	 * This must be called during servlet initialization. It sets up the xacml.?.properties
-	 * file as a system property. If the System property is already set, then it does not
-	 * do anything. This allows the developer to specify their own xacml.properties file to be
-	 * used. They can 1) modify the default properties that comes with the project, or 2) change
-	 * the WebInitParam annotation, or 3) specify an alternative path in the web.xml, or 4) set
-	 * the Java System property to point to their xacml.properties file.
-	 * 
-	 * The recommended way of overriding the default xacml.properties file is using a Java System
-	 * property:
-	 * 
-	 * -Dxacml.properties=/opt/app/xacml/etc/xacml.admin.properties
-	 * 
-	 * This way one does not change any actual code or files in the project and can leave the 
-	 * defaults alone.
-	 * 
-	 * @param config - The servlet config file passed from the javax servlet init() function
-	 */
-	public static void xacmlInit(ServletConfig config) {
-		//
-		// Get the XACML Properties File parameter first
-		//
-		String propFile = config.getInitParameter("XACML_PROPERTIES_NAME");
-		if (propFile != null) {
-			//
-			// Look for system override
-			//
-			String xacmlPropertiesName = System.getProperty(XACMLProperties.XACML_PROPERTIES_NAME);
-			logger.info("\n\n" + xacmlPropertiesName + "\n" + XACMLProperties.XACML_PROPERTIES_NAME);
-			if (xacmlPropertiesName == null) {
-				//
-				// Set it to our servlet default
-				//
-				if (logger.isDebugEnabled()) {
-					logger.debug("Using Servlet Config Property for XACML_PROPERTIES_NAME:" + propFile);
-				}
-				System.setProperty(XACMLProperties.XACML_PROPERTIES_NAME, propFile);
-			} else {
-				if (logger.isDebugEnabled()) {
-					logger.debug("Using System Property for XACML_PROPERTIES_NAME:" + xacmlPropertiesName);
-				}
-			}
-		}
-		//
-		// Setup the remaining properties
-		//
-		Enumeration<String> params = config.getInitParameterNames();
-		while (params.hasMoreElements()) {
-			String param = params.nextElement();
-			if (! "XACML_PROPERTIES_NAME".equals(param)) {
-				String value = config.getInitParameter(param);
-				PolicyLogger.info(param + "=" + config.getInitParameter(param));
-				restProperties.setProperty(param, value);
-			}
-		}
-	}
-	
-	/**
-	 * Reset's the XACMLProperties internal properties object so we start
-	 * in a fresh environment. Then adds back in our Servlet init properties that were
-	 * passed in the javax Servlet init() call.
-	 * 
-	 * This function is primarily used when a new configuration is passed in and the
-	 * PDP servlet needs to load a new PDP engine instance.
-	 * 
-	 * @param pipProperties - PIP configuration properties
-	 * @param policyProperties  - Policy configuration properties
-	 */
-	public static void loadXacmlProperties(Properties policyProperties, Properties pipProperties) {
-		try {
-			//
-			// Start fresh
-			//
-			XACMLProperties.reloadProperties();
-			//
-			// Now load our init properties
-			//
-			XACMLProperties.getProperties().putAll(XACMLRest.restProperties);
-			//
-			// Load our policy properties
-			//
-			if (policyProperties != null) {
-				XACMLProperties.getProperties().putAll(policyProperties);
-			}
-			//
-			// Load our pip config properties
-			//
-			if (pipProperties != null) {
-				XACMLProperties.getProperties().putAll(pipProperties);
-			}
-		} catch (IOException e) {
-			PolicyLogger.error(MessageCodes.ERROR_PROCESS_FLOW, e, "Failed to put init properties into Xacml properties");
-		}
-		//
-		// Dump them
-		//
-		if (logger.isDebugEnabled()) {
-			try {
-				logger.debug(XACMLProperties.getProperties().toString());				
-			} catch (IOException e) {
-				PolicyLogger.error(MessageCodes.ERROR_PROCESS_FLOW, e, "Cannot dump properties");
-			}
-		}
-	}
-	
-	/**
-	 * Helper routine to dump the HTTP servlet request being serviced. Primarily for debugging.
-	 * 
-	 * @param request - Servlet request (from a POST/GET/PUT/etc.)
-	 */
-	public static void dumpRequest(HttpServletRequest request) {
-		if (logger.isDebugEnabled()) {
-			// special-case for receiving heartbeat - don't need to repeatedly output all of the information in multiple lines
-			if ("GET".equals(request.getMethod()) && "hb".equals(request.getParameter("type"))  ) {
-				PolicyLogger.debug("GET type=hb : heartbeat received");
-				return;				
-			}
-			logger.debug(request.getMethod() + ":" + request.getRemoteAddr() + " " + request.getRemoteHost() + " " + request.getRemotePort());
-			logger.debug(request.getLocalAddr() + " " + request.getLocalName() + " " + request.getLocalPort());
-			Enumeration<String> en = request.getHeaderNames();
-			logger.debug("Headers:");
-			while (en.hasMoreElements()) {
-				String element = en.nextElement();
-				Enumeration<String> values = request.getHeaders(element);
-				while (values.hasMoreElements()) {
-					String value = values.nextElement();
-					logger.debug(element + ":" + value);
-				}
-			}
-			logger.debug("Attributes:");
-			en = request.getAttributeNames();
-			while (en.hasMoreElements()) {
-				String element = en.nextElement();
-				logger.debug(element + ":" + request.getAttribute(element));
-			}
-			logger.debug("ContextPath: " + request.getContextPath());
-			if ("PUT".equals(request.getMethod()) || "POST".equals(request.getMethod())) {
-				// POST and PUT are allowed to have parameters in the content, but in our usage the parameters are always in the Query string.
-				// More importantly, there are cases where the POST and PUT content is NOT parameters (e.g. it might contain a Policy file).
-				// Unfortunately the request.getParameterMap method reads the content to see if there are any parameters,
-				// and once the content is read it cannot be read again.
-				// Thus for PUT and POST we must avoid reading the content here so that the main code can read it.
-				logger.debug("Query String:" + request.getQueryString());
-				try {
-					if (request.getInputStream() == null) {
-						logger.debug("Content: No content inputStream");
-					} else {
-						logger.debug("Content available: " + request.getInputStream().available());
-					}
-				} catch (Exception e) {
-					logger.debug("Content: inputStream exception: " + e.getMessage() + ";  (May not be relevant)" +e);
-				}
-			} else {
-				logger.debug("Parameters:");
-				Map<String, String[]> params = request.getParameterMap();
-				Set<String> keys = params.keySet();
-				for (String key : keys) {
-					String[] values = params.get(key);
-					logger.debug(key + "(" + values.length + "): " + (values.length > 0 ? values[0] : ""));
-				}
-			}
-			logger.debug("Request URL:" + request.getRequestURL());
-		}
-	}
+    /**
+     * This must be called during servlet initialization. It sets up the xacml.?.properties
+     * file as a system property. If the System property is already set, then it does not
+     * do anything. This allows the developer to specify their own xacml.properties file to be
+     * used. They can 1) modify the default properties that comes with the project, or 2) change
+     * the WebInitParam annotation, or 3) specify an alternative path in the web.xml, or 4) set
+     * the Java System property to point to their xacml.properties file.
+     *
+     * The recommended way of overriding the default xacml.properties file is using a Java System
+     * property:
+     *
+     * -Dxacml.properties=/opt/app/xacml/etc/xacml.admin.properties
+     *
+     * This way one does not change any actual code or files in the project and can leave the
+     * defaults alone.
+     *
+     * @param config - The servlet config file passed from the javax servlet init() function
+     */
+    public static void xacmlInit(ServletConfig config) {
+        //
+        // Get the XACML Properties File parameter first
+        //
+        String propFile = config.getInitParameter("XACML_PROPERTIES_NAME");
+        if (propFile != null) {
+            //
+            // Look for system override
+            //
+            String xacmlPropertiesName = System.getProperty(XACMLProperties.XACML_PROPERTIES_NAME);
+            logger.info("\n\n" + xacmlPropertiesName + "\n" + XACMLProperties.XACML_PROPERTIES_NAME);
+            if (xacmlPropertiesName == null) {
+                //
+                // Set it to our servlet default
+                //
+                if (logger.isDebugEnabled()) {
+                    logger.debug("Using Servlet Config Property for XACML_PROPERTIES_NAME:" + propFile);
+                }
+                System.setProperty(XACMLProperties.XACML_PROPERTIES_NAME, propFile);
+            } else {
+                if (logger.isDebugEnabled()) {
+                    logger.debug("Using System Property for XACML_PROPERTIES_NAME:" + xacmlPropertiesName);
+                }
+            }
+        }
+        //
+        // Setup the remaining properties
+        //
+        Enumeration<String> params = config.getInitParameterNames();
+        while (params.hasMoreElements()) {
+            String param = params.nextElement();
+            if (! "XACML_PROPERTIES_NAME".equals(param)) {
+                String value = config.getInitParameter(param);
+                PolicyLogger.info(param + "=" + config.getInitParameter(param));
+                restProperties.setProperty(param, value);
+            }
+        }
+    }
+
+    /**
+     * Reset's the XACMLProperties internal properties object so we start
+     * in a fresh environment. Then adds back in our Servlet init properties that were
+     * passed in the javax Servlet init() call.
+     *
+     * This function is primarily used when a new configuration is passed in and the
+     * PDP servlet needs to load a new PDP engine instance.
+     *
+     * @param pipProperties - PIP configuration properties
+     * @param policyProperties  - Policy configuration properties
+     */
+    public static void loadXacmlProperties(Properties policyProperties, Properties pipProperties) {
+        try {
+            //
+            // Start fresh
+            //
+            XACMLProperties.reloadProperties();
+            //
+            // Now load our init properties
+            //
+            XACMLProperties.getProperties().putAll(XACMLRest.restProperties);
+            //
+            // Load our policy properties
+            //
+            if (policyProperties != null) {
+                XACMLProperties.getProperties().putAll(policyProperties);
+            }
+            //
+            // Load our pip config properties
+            //
+            if (pipProperties != null) {
+                XACMLProperties.getProperties().putAll(pipProperties);
+            }
+        } catch (IOException e) {
+            PolicyLogger.error(MessageCodes.ERROR_PROCESS_FLOW, e, "Failed to put init properties into Xacml properties");
+        }
+        //
+        // Dump them
+        //
+        if (logger.isDebugEnabled()) {
+            try {
+                logger.debug(XACMLProperties.getProperties().toString());
+            } catch (IOException e) {
+                PolicyLogger.error(MessageCodes.ERROR_PROCESS_FLOW, e, "Cannot dump properties");
+            }
+        }
+    }
+
+    /**
+     * Helper routine to dump the HTTP servlet request being serviced. Primarily for debugging.
+     *
+     * @param request - Servlet request (from a POST/GET/PUT/etc.)
+     */
+    public static void dumpRequest(HttpServletRequest request) {
+        if (!logger.isDebugEnabled()) {
+            return;
+        }
+
+        // special-case for receiving heartbeat - don't need to repeatedly output all of the information in multiple lines
+        if ("GET".equals(request.getMethod()) && "hb".equals(request.getParameter("type"))  ) {
+            PolicyLogger.debug("GET type=hb : heartbeat received");
+            return;
+        }
+        logger.debug(request.getMethod() + ":" + request.getRemoteAddr() + " " + request.getRemoteHost() + " " + request.getRemotePort());
+        logger.debug(request.getLocalAddr() + " " + request.getLocalName() + " " + request.getLocalPort());
+        Enumeration<String> en = request.getHeaderNames();
+        logger.debug("Headers:");
+        while (en.hasMoreElements()) {
+            String element = en.nextElement();
+            Enumeration<String> values = request.getHeaders(element);
+            while (values.hasMoreElements()) {
+                String value = values.nextElement();
+                logger.debug(element + ":" + value);
+            }
+        }
+        logger.debug("Attributes:");
+        en = request.getAttributeNames();
+        while (en.hasMoreElements()) {
+            String element = en.nextElement();
+            logger.debug(element + ":" + request.getAttribute(element));
+        }
+        logger.debug("ContextPath: " + request.getContextPath());
+        if ("PUT".equals(request.getMethod()) || "POST".equals(request.getMethod())) {
+            // POST and PUT are allowed to have parameters in the content, but in our usage the parameters are always in the Query string.
+            // More importantly, there are cases where the POST and PUT content is NOT parameters (e.g. it might contain a Policy file).
+            // Unfortunately the request.getParameterMap method reads the content to see if there are any parameters,
+            // and once the content is read it cannot be read again.
+            // Thus for PUT and POST we must avoid reading the content here so that the main code can read it.
+            logger.debug("Query String:" + request.getQueryString());
+            try {
+                if (request.getInputStream() == null) {
+                    logger.debug("Content: No content inputStream");
+                } else {
+                    logger.debug("Content available: " + request.getInputStream().available());
+                }
+            } catch (Exception e) {
+                logger.debug("Content: inputStream exception: " + e.getMessage() + ";  (May not be relevant)" +e);
+            }
+        } else {
+            logger.debug("Parameters:");
+            Map<String, String[]> params = request.getParameterMap();
+            Set<String> keys = params.keySet();
+            for (String key : keys) {
+                String[] values = params.get(key);
+                logger.debug(key + "(" + values.length + "): " + (values.length > 0 ? values[0] : ""));
+            }
+        }
+        logger.debug("Request URL:" + request.getRequestURL());
+    }
 }
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/PolicyRestAdapter.java b/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/PolicyRestAdapter.java
index a9daf17..e815fe2 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/PolicyRestAdapter.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/PolicyRestAdapter.java
@@ -127,6 +127,9 @@
 	private String actionDictUrl = null;
 	private String actionDictMethod = null;
 	private YAMLParams yamlparams; 
+	private List<String> blackListEntries;
+	private List<String> appendBlackListEntries;
+	private String blackListEntryType;
 	
 	//Rainy Day Decision
 	private RainyDayParams rainyday;
@@ -907,4 +910,22 @@
 	public void setFaultDatas(ClosedLoopFaultTrapDatas faultDatas) {
 		this.faultDatas = faultDatas;
 	}
+	public List<String> getAppendBlackListEntries() {
+		return appendBlackListEntries;
+	}
+	public void setAppendBlackListEntries(List<String> appendBlackListEntries) {
+		this.appendBlackListEntries = appendBlackListEntries;
+	}
+	public List<String> getBlackListEntries() {
+		return blackListEntries;
+	}
+	public void setBlackListEntries(List<String> blackListEntries) {
+		this.blackListEntries = blackListEntries;
+	}
+	public String getBlackListEntryType() {
+		return blackListEntryType;
+	}
+	public void setBlackListEntryType(String blackListEntryType) {
+		this.blackListEntryType = blackListEntryType;
+	}
 }
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/ReturnBlackList.java b/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/ReturnBlackList.java
new file mode 100644
index 0000000..6ecf1b5
--- /dev/null
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/adapter/ReturnBlackList.java
@@ -0,0 +1,51 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP Policy Engine
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.rest.adapter;
+
+public class ReturnBlackList {
+    private boolean entryCheck;
+    private int actionValue;
+    private String entryValue;
+
+    public boolean isEntryCheck() {
+        return entryCheck;
+    }
+
+    public void setEntryCheck(boolean entryCheck) {
+        this.entryCheck = entryCheck;
+    }
+
+    public int getActionValue() {
+        return actionValue;
+    }
+
+    public void setActionValue(int actionValue) {
+        this.actionValue = actionValue;
+    }
+
+    public String getEntryValue() {
+        return entryValue;
+    }
+
+    public void setEntryValue(String entryValue) {
+        this.entryValue = entryValue;
+    }
+}
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/Category.java b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/Category.java
index 275b03e..f3874a4 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/Category.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/jpa/Category.java
@@ -3,6 +3,7 @@
  * ONAP-REST
  * ================================================================================
  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Modified Copyright (C) 2018 Samsung Electronics Co., Ltd.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -48,171 +49,171 @@
 @Table(name="Category")
 @NamedQuery(name="Category.findAll", query="SELECT c FROM Category c")
 public class Category implements Serializable {
-	private static final long serialVersionUID = 1L;
-	
-	public static final char STANDARD = 'S';
-	public static final char CUSTOM = 'C';
+    private static final long serialVersionUID = 1L;
 
-	@Id
-	@GeneratedValue(strategy = GenerationType.AUTO)
-	@Column(name="id")
-	private int id;
+    public static final char STANDARD = 'S';
+    public static final char CUSTOM = 'C';
 
-	@Column(name="grouping", nullable=false, length=64)
-	private String grouping;
+    @Id
+    @GeneratedValue(strategy = GenerationType.AUTO)
+    @Column(name="id")
+    private int id;
 
-	@Column(name="is_standard", nullable=false)
-	private char isStandard;
+    @Column(name="grouping", nullable=false, length=64)
+    private String grouping;
 
-	@Column(name="xacml_id", nullable=false, unique=true, length=255)
-	private String xacmlId;
-	
-	@Column(name="short_name", nullable=false, length=64)
-	private String shortName;
-	
-	//bi-directional many-to-one association to Attribute
-	@OneToMany(mappedBy="categoryBean")
-	@JsonBackReference
-	private Set<Attribute> attributes = new HashSet<>();
+    @Column(name="is_standard", nullable=false)
+    private char isStandard;
 
-	public Category() {
-		this.xacmlId = XACML3.ID_SUBJECT_CATEGORY_ACCESS_SUBJECT.stringValue();
-		this.grouping = "subject";
-		this.isStandard = Category.STANDARD;
-		this.shortName = "subject";
-	}
+    @Column(name="xacml_id", nullable=false, unique=true, length=255)
+    private String xacmlId;
 
-	public Category(Identifier cat, String grouping, char isStandard) {
-		if (cat != null) {
-			this.xacmlId = cat.stringValue();
-		}
-		this.isStandard = isStandard;
-		if (grouping != null) {
-			this.grouping = grouping;
-		} else {
-			this.grouping = Category.extractGrouping(this.xacmlId);
-		}
-	}
+    @Column(name="short_name", nullable=false, length=64)
+    private String shortName;
 
-	public Category(Identifier cat, String grouping) {
-		this(cat, grouping, Category.STANDARD);
-	}
+    //bi-directional many-to-one association to Attribute
+    @OneToMany(mappedBy="categoryBean")
+    @JsonBackReference
+    private Set<Attribute> attributes = new HashSet<>();
 
-	public Category(Identifier cat, char standard) {
-		this(cat, null, standard);
-	}
+    public Category() {
+        this.xacmlId = XACML3.ID_SUBJECT_CATEGORY_ACCESS_SUBJECT.stringValue();
+        this.grouping = "subject";
+        this.isStandard = Category.STANDARD;
+        this.shortName = "subject";
+    }
 
-	public Category(Identifier cat) {
-		this(cat, Category.STANDARD);
-	}
+    public Category(Identifier cat, String grouping, char isStandard) {
+        if (cat != null) {
+            this.xacmlId = cat.stringValue();
+        }
+        this.isStandard = isStandard;
+        if (grouping != null) {
+            this.grouping = grouping;
+        } else {
+            this.grouping = Category.extractGrouping(this.xacmlId);
+        }
+    }
 
-	public int getId() {
-		return this.id;
-	}
+    public Category(Identifier cat, String grouping) {
+        this(cat, grouping, Category.STANDARD);
+    }
 
-	public void setId(int id) {
-		this.id = id;
-	}
+    public Category(Identifier cat, char standard) {
+        this(cat, null, standard);
+    }
 
-	public String getGrouping() {
-		return this.grouping;
-	}
+    public Category(Identifier cat) {
+        this(cat, Category.STANDARD);
+    }
 
-	public void setGrouping(String grouping) {
-		this.grouping = grouping;
-	}
+    public int getId() {
+        return this.id;
+    }
 
-	public char getIsStandard() {
-		return this.isStandard;
-	}
+    public void setId(int id) {
+        this.id = id;
+    }
 
-	public void setIsStandard(char isStandard) {
-		this.isStandard = isStandard;
-	}
+    public String getGrouping() {
+        return this.grouping;
+    }
 
-	public String getXacmlId() {
-		return this.xacmlId;
-	}
+    public void setGrouping(String grouping) {
+        this.grouping = grouping;
+    }
 
-	public void setXacmlId(String xacmlId) {
-		this.xacmlId = xacmlId;
-	}
+    public char getIsStandard() {
+        return this.isStandard;
+    }
 
-	public String getShortName() {
-		return this.shortName;
-	}
+    public void setIsStandard(char isStandard) {
+        this.isStandard = isStandard;
+    }
 
-	public void setShortName(String shortName) {
-		this.shortName = shortName;
-	}
+    public String getXacmlId() {
+        return this.xacmlId;
+    }
 
-	public Set<Attribute> getAttributes() {
-		return this.attributes;
-	}
+    public void setXacmlId(String xacmlId) {
+        this.xacmlId = xacmlId;
+    }
 
-	public void setAttributes(Set<Attribute> attributes) {
-		this.attributes = attributes;
-	}
+    public String getShortName() {
+        return this.shortName;
+    }
 
-	public Attribute addAttribute(Attribute attribute) {
-		getAttributes().add(attribute);
-		attribute.setCategoryBean(this);
+    public void setShortName(String shortName) {
+        this.shortName = shortName;
+    }
 
-		return attribute;
-	}
+    public Set<Attribute> getAttributes() {
+        return this.attributes;
+    }
 
-	public Attribute removeAttribute(Attribute attribute) {
-		getAttributes().remove(attribute);
-		attribute.setCategoryBean(null);
+    public void setAttributes(Set<Attribute> attributes) {
+        this.attributes = attributes;
+    }
 
-		return attribute;
-	}
+    public Attribute addAttribute(Attribute attribute) {
+        getAttributes().add(attribute);
+        attribute.setCategoryBean(this);
 
-	@Transient
-	public boolean isStandard() {
-		return this.isStandard == Category.STANDARD;
-	}
-	
-	@Transient
-	public boolean isCustom() {
-		return this.isStandard == Category.CUSTOM;
-	}
-	
-	@Transient
-	public static String	extractGrouping(String xacmlId) {
-		if (xacmlId == null) {
-			return null;
-		}
-		if (xacmlId.matches(".*:attribute\\-category:.*")) {
-			String[] parts = xacmlId.split("[:]");
-			if (parts != null && parts.length > 0) {
-				return parts[parts.length - 1];
-			}
-		} else if (xacmlId.matches(".*:[a-zA-Z]+[\\-]category:.*")) {
-			String[] parts = xacmlId.split("[:]");
-			if (parts != null && parts.length > 0) {
-				for (String part : parts) {
-					int index = part.indexOf("-category");
-					if (index > 0) {
-						return part.substring(0, index);
-					}
-				}
-			}
-		}
-		return null;
-	}
-	
-	@Transient
-	public Identifier getIdentifer() {
-		return new IdentifierImpl(this.xacmlId);
-	}
+        return attribute;
+    }
 
-	@Transient
-	@Override
-	public String toString() {
-		return "Category [id=" + id + ", grouping=" + grouping
-				+ ", isStandard=" + isStandard + ", xacmlId=" + xacmlId
-				+ ", attributes=" + attributes + "]";
-	}
+    public Attribute removeAttribute(Attribute attribute) {
+        getAttributes().remove(attribute);
+        attribute.setCategoryBean(null);
+
+        return attribute;
+    }
+
+    @Transient
+    public boolean isStandard() {
+        return this.isStandard == Category.STANDARD;
+    }
+
+    @Transient
+    public boolean isCustom() {
+        return this.isStandard == Category.CUSTOM;
+    }
+
+    @Transient
+    public static String	extractGrouping(String xacmlId) {
+        if (xacmlId == null) {
+            return null;
+        }
+        String[] parts = xacmlId.split("[:]");
+        if (xacmlId.matches(".*:attribute\\-category:.*")) {            
+            if (parts.length > 0) {
+                return parts[parts.length - 1];
+            }
+        } else if (xacmlId.matches(".*:[a-zA-Z]+[\\-]category:.*")) {            
+            if (parts.length <= 0) {
+                return null;
+            }
+            for (String part : parts) {
+                int index = part.indexOf("-category");
+                if (index > 0) {
+                    return part.substring(0, index);
+                }
+            }
+        }
+        return null;
+    }
+
+    @Transient
+    public Identifier getIdentifer() {
+        return new IdentifierImpl(this.xacmlId);
+    }
+
+    @Transient
+    @Override
+    public String toString() {
+        return "Category [id=" + id + ", grouping=" + grouping
+                + ", isStandard=" + isStandard + ", xacmlId=" + xacmlId
+                + ", attributes=" + attributes + "]";
+    }
 
 }
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/util/MSModelUtils.java b/ONAP-REST/src/main/java/org/onap/policy/rest/util/MSModelUtils.java
index 1f40be6..50628d7 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/util/MSModelUtils.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/util/MSModelUtils.java
@@ -3,6 +3,7 @@
  * ONAP-REST
  * ================================================================================
  * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Modified Copyright (C) 2018 Samsung Electronics Co., Ltd.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -20,41 +21,13 @@
 
 package org.onap.policy.rest.util;
 
-import java.io.File;
-import java.io.FileInputStream;
-import java.io.FileNotFoundException;
-import java.io.IOException;
-import java.io.InputStream;
-import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.Collections;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Iterator;
-import java.util.LinkedHashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import java.util.Map.Entry;
-
+import com.att.research.xacml.util.XACMLProperties;
+import com.google.gson.Gson;
 import org.apache.commons.lang.StringUtils;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
-import org.eclipse.emf.common.util.EList;
-import org.eclipse.emf.common.util.EMap;
-import org.eclipse.emf.common.util.Enumerator;
-import org.eclipse.emf.common.util.TreeIterator;
-import org.eclipse.emf.common.util.URI;
-import org.eclipse.emf.ecore.EAnnotation;
-import org.eclipse.emf.ecore.EClass;
-import org.eclipse.emf.ecore.EClassifier;
-import org.eclipse.emf.ecore.EEnum;
-import org.eclipse.emf.ecore.EEnumLiteral;
-import org.eclipse.emf.ecore.EObject;
-import org.eclipse.emf.ecore.EPackage;
-import org.eclipse.emf.ecore.EReference;
-import org.eclipse.emf.ecore.EStructuralFeature;
+import org.eclipse.emf.common.util.*;
+import org.eclipse.emf.ecore.*;
 import org.eclipse.emf.ecore.impl.EAttributeImpl;
 import org.eclipse.emf.ecore.impl.EEnumImpl;
 import org.eclipse.emf.ecore.resource.Resource;
@@ -65,1320 +38,1349 @@
 import org.onap.policy.rest.XACMLRestProperties;
 import org.yaml.snakeyaml.Yaml;
 
-import com.att.research.xacml.util.XACMLProperties;
-import com.google.gson.Gson;
+import java.io.*;
+import java.util.*;
+import java.util.Map.Entry;
 
 
 public class MSModelUtils {
 
-	private static final Log logger	= LogFactory.getLog(MSModelUtils.class);
+    private static final Log logger	= LogFactory.getLog(MSModelUtils.class);
 
-	private HashMap<String,MSAttributeObject > classMap = new HashMap<>();
-	private HashMap<String, String> enumMap = new HashMap<>();
-	private HashMap<String, String> matchingClass = new HashMap<>();
-	private String configuration = "configuration";
-	private String dictionary = "dictionary";
-	private String onap = "";
-	private String policy = "";
-	private String eProxyURI = "eProxyURI:";
-	private List<String> orderedElements = new ArrayList<>();
-	private String dataOrderInfo = null;
-	private Set<String> uniqueDataKeys= new HashSet<>();
-	private Set<String> uniqueKeys= new HashSet<>();
-	private String listConstraints = null;
-	private String referenceAttributes;
-	private LinkedHashMap<String, Object> retmap = new LinkedHashMap<>();
-	private Map<String, String>  matchableValues;
-	public static final String PROPERTIES=".properties.";
-	public static final String DATATYPE  = "data_types.policy.data.";
-	public static final String TYPE=".type";
-	public static final String REQUIRED=".required";
-	public static final String MATCHABLE=".matchable";
-	public static final String STRING="string";
-	public static final String INTEGER="integer";
-	public static final String LIST="list";
-	public static final String MAP="map";
-	public static final String DEFAULT=".default";
-	public static final String MANYFALSE=":MANY-false";
-	public static final String MANYTRUE=":MANY-true";
-	public static final String DEFAULTVALUE=":defaultValue-";
-	public static final String REQUIREDVALUE=":required-";
-	public static final String MATCHABLEKEY="matchable";
-	public static final String REQUIREDFALSE=":required-false";
-	public static final String REQUIREDTRUE=":required-true";
-	public static final String MATCHINGTRUE="matching-true";
+    private HashMap<String,MSAttributeObject > classMap = new HashMap<>();
+    private HashMap<String, String> enumMap = new HashMap<>();
+    private HashMap<String, String> matchingClass = new HashMap<>();
+    private String configuration = "configuration";
+    private String dictionary = "dictionary";
+    private String onap = "";
+    private String policy = "";
+    private String eProxyURI = "eProxyURI:";
+    private List<String> orderedElements = new ArrayList<>();
+    private String dataOrderInfo = null;
+    private Set<String> uniqueDataKeys= new HashSet<>();
+    private Set<String> uniqueKeys= new HashSet<>();
+    private String listConstraints = null;
+    private String referenceAttributes;
+    private LinkedHashMap<String, Object> retmap = new LinkedHashMap<>();
+    private Map<String, String>  matchableValues;
+    private static final String PROPERTIES=".properties.";
+    public static final String DATATYPE  = "data_types.policy.data.";
+    public static final String TYPE=".type";
+    public static final String REQUIRED=".required";
+    private static final String MATCHABLE=".matchable";
+    private static final String STRING="string";
+    private static final String INTEGER="integer";
+    private static final String LIST="list";
+    public static final String MAP="map";
+    private static final String DEFAULT=".default";
+    private static final String MANYFALSE=":MANY-false";
+    private static final String MANYTRUE=":MANY-true";
+    private static final String DEFAULTVALUE=":defaultValue-";
+    private static final String REQUIREDVALUE=":required-";
+    private static final String MATCHABLEKEY="matchable";
+    private static final String REQUIREDFALSE=":required-false";
+    private static final String REQUIREDTRUE=":required-true";
+    private static final String MATCHINGTRUE="matching-true";
 
-	private StringBuilder dataListBuffer=new StringBuilder();
-	private List<String> dataConstraints= new ArrayList <>();
-	private String attributeString = null;
-	
-	public MSModelUtils(){
-	}
-	
-	public MSModelUtils(String onap, String policy){
-		this.onap = onap;
-		this.policy = policy;
-	}
+    private StringBuilder dataListBuffer=new StringBuilder();
+    private List<String> dataConstraints= new ArrayList <>();
+    private String attributeString = null;
 
-	private enum ANNOTATION_TYPE{
-		MATCHING, VALIDATION, DICTIONARY
-	};
+    public MSModelUtils(){
+    }
 
-	public enum MODEL_TYPE {
-		XMI
-	};
+    public MSModelUtils(String onap, String policy){
+        this.onap = onap;
+        this.policy = policy;
+    }
 
+    private enum ANNOTATION_TYPE{
+        MATCHING, VALIDATION, DICTIONARY
+    };
 
-	public Map<String, MSAttributeObject> processEpackage(String file, MODEL_TYPE model){
-		if (model == MODEL_TYPE.XMI ){
-			processXMIEpackage(file);
-		}
-		return classMap;
+    public enum MODEL_TYPE {
+        XMI
+    };
 
-	} 
 
-	private void processXMIEpackage(String xmiFile){
-		EPackage root = getEpackage(xmiFile);
-		TreeIterator<EObject> treeItr = root.eAllContents();
-		String className;
-		String returnValue;
+    public Map<String, MSAttributeObject> processEpackage(String file, MODEL_TYPE model){
+        if (model == MODEL_TYPE.XMI ){
+            processXMIEpackage(file);
+        }
+        return classMap;
 
-		//    Pulling out dependency from file
-		while (treeItr.hasNext()) {	    
-			EObject obj = treeItr.next();
-			if (obj instanceof EClassifier) {
-				EClassifier eClassifier = (EClassifier) obj;
-				className = eClassifier.getName();
+    }
 
-				if (obj instanceof EEnum) {
-					enumMap.putAll(getEEnum(obj));
-				}else if (obj instanceof EClass) {
-					String temp = getDependencyList(eClassifier).toString();
-					returnValue = StringUtils.replaceEach(temp, new String[]{"[", "]"}, new String[]{"", ""});
-					getAttributes(className, returnValue, root);
-				}        		   		
-			}
-		}
+    private void processXMIEpackage(String xmiFile){
+        EPackage root = getEpackage(xmiFile);
+        TreeIterator<EObject> treeItr = root.eAllContents();
+        String className;
+        String returnValue;
 
-		if (!enumMap.isEmpty()){
-			addEnumClassMap();
-		}
-		if (!matchingClass.isEmpty()){
-			CheckForMatchingClass();
-		}
-	}
+        //    Pulling out dependency from file
+        while (treeItr.hasNext()) {
+            EObject obj = treeItr.next();
+            if (obj instanceof EClassifier) {
+                EClassifier eClassifier = (EClassifier) obj;
+                className = eClassifier.getName();
 
-	private void CheckForMatchingClass() {
-		HashMap<String, String> tempAttribute = new HashMap<>();
+                if (obj instanceof EEnum) {
+                    enumMap.putAll(getEEnum(obj));
+                }else if (obj instanceof EClass) {
+                    String temp = getDependencyList(eClassifier).toString();
+                    returnValue = StringUtils.replaceEach(temp, new String[]{"[", "]"}, new String[]{"", ""});
+                    getAttributes(className, returnValue, root);
+                }
+            }
+        }
 
-		for (Entry<String, String> set : matchingClass.entrySet()){
-			String key = set.getKey();
-			if (classMap.containsKey(key)){
-				Map<String, String> listAttributes = classMap.get(key).getAttribute();
-				Map<String, String> listRef = classMap.get(key).getRefAttribute();
-				for (  Entry<String, String> eSet : listAttributes.entrySet()){
-					String key2 = eSet.getKey();
-					tempAttribute.put(key2, MATCHINGTRUE);
-				}
-				for (  Entry<String, String> eSet : listRef.entrySet()){
-					String key3 = eSet.getKey();
-					tempAttribute.put(key3, MATCHINGTRUE);
-				}
+        if (!enumMap.isEmpty()){
+            addEnumClassMap();
+        }
+        if (!matchingClass.isEmpty()){
+            CheckForMatchingClass();
+        }
+    }
 
-			}
-			UpdateMatching(tempAttribute, key);
-		}
+    private void CheckForMatchingClass() {
+        HashMap<String, String> tempAttribute = new HashMap<>();
 
-	}
+        for (Entry<String, String> set : matchingClass.entrySet()){
+            String key = set.getKey();
+            if (classMap.containsKey(key)){
+                Map<String, String> listAttributes = classMap.get(key).getAttribute();
+                Map<String, String> listRef = classMap.get(key).getRefAttribute();
+                for (  Entry<String, String> eSet : listAttributes.entrySet()){
+                    String key2 = eSet.getKey();
+                    tempAttribute.put(key2, MATCHINGTRUE);
+                }
+                for (  Entry<String, String> eSet : listRef.entrySet()){
+                    String key3 = eSet.getKey();
+                    tempAttribute.put(key3, MATCHINGTRUE);
+                }
 
+            }
+            UpdateMatching(tempAttribute, key);
+        }
 
+    }
 
-	private void UpdateMatching(HashMap<String, String> tempAttribute, String key) {
-		Map<String, MSAttributeObject> newClass = classMap;
 
-		for (Entry<String, MSAttributeObject> updateClass :  newClass.entrySet()){
-			Map<String, String> valueMap = updateClass.getValue().getMatchingSet();
-			String keymap = updateClass.getKey();
-			if (valueMap.containsKey(key)){
-				Map<String, String> modifyMap = classMap.get(keymap).getMatchingSet();
-				modifyMap.remove(key);
-				modifyMap.putAll(tempAttribute);
-				classMap.get(keymap).setMatchingSet(modifyMap);
-			}
 
-		}
-	}
+    private void UpdateMatching(HashMap<String, String> tempAttribute, String key) {
+        Map<String, MSAttributeObject> newClass = classMap;
 
-	private void addEnumClassMap() {
-		for (Entry<String, MSAttributeObject> value :classMap.entrySet()){
-			value.getValue().setEnumType(enumMap);
-		}
-	}
+        for (Entry<String, MSAttributeObject> updateClass :  newClass.entrySet()){
+            Map<String, String> valueMap = updateClass.getValue().getMatchingSet();
+            String keymap = updateClass.getKey();
+            if (valueMap.containsKey(key)){
+                Map<String, String> modifyMap = classMap.get(keymap).getMatchingSet();
+                modifyMap.remove(key);
+                modifyMap.putAll(tempAttribute);
+                classMap.get(keymap).setMatchingSet(modifyMap);
+            }
 
-	private EPackage getEpackage(String xmiFile) {
-		ResourceSet resSet = new ResourceSetImpl();
-		Resource.Factory.Registry reg = Resource.Factory.Registry.INSTANCE;
-		Map<String, Object> m = reg.getExtensionToFactoryMap();
-		m.put("xmi", new XMIResourceFactoryImpl());
-		Resource resource = resSet.getResource(URI.createFileURI(xmiFile), true);
-		try {
-			resource.load(Collections.emptyMap());
-		} catch (IOException e) {
-			logger.error("Error loading Encore Resource for new Model" + e);
-		}
+        }
+    }
 
-		return (EPackage) resource.getContents().get(0);
-	}
+    private void addEnumClassMap() {
+        for (Entry<String, MSAttributeObject> value :classMap.entrySet()){
+            value.getValue().setEnumType(enumMap);
+        }
+    }
 
-	private HashMap<String, String> getEEnum(EObject obj) {
-		List<String> valueList = new ArrayList<>();
-		HashMap<String, String> returnMap = new HashMap<>();
-		EEnum eenum = (EEnum)obj;
+    private EPackage getEpackage(String xmiFile) {
+        ResourceSet resSet = new ResourceSetImpl();
+        Resource.Factory.Registry reg = Resource.Factory.Registry.INSTANCE;
+        Map<String, Object> m = reg.getExtensionToFactoryMap();
+        m.put("xmi", new XMIResourceFactoryImpl());
+        Resource resource = resSet.getResource(URI.createFileURI(xmiFile), true);
+        try {
+            resource.load(Collections.emptyMap());
+        } catch (IOException e) {
+            logger.error("Error loading Encore Resource for new Model" + e);
+        }
 
-		String name = eenum.getName();
-		for (EEnumLiteral eEnumLiteral : eenum.getELiterals())
-		{
-			Enumerator instance = eEnumLiteral.getInstance();
-			String value = instance.getLiteral();
-			valueList.add(value);
-		}
-		returnMap.put(name, valueList.toString());
-		return returnMap;
-	}
+        return (EPackage) resource.getContents().get(0);
+    }
 
-	public void getAttributes(String className, String dependency, EPackage root) {
-		List<String> dpendList = new ArrayList<>();
-		if (dependency!=null){
-			dpendList = new ArrayList<>(Arrays.asList(dependency.split(",")));
-		}
-		MSAttributeObject msAttributeObject = new MSAttributeObject();
-		msAttributeObject.setClassName(className);
-		String extendClass = getSubTypes(root, className);
-		Map<String, String> returnRefList = getRefAttributeList(root, className, extendClass);
-		Map<String, String> returnAttributeList = getAttributeList(root, className, extendClass);
-		Map<String, Object> returnSubList = getSubAttributeList(root, className, extendClass);
-		HashMap<String, String> returnAnnotation = getAnnotation(root, className, extendClass);
-		msAttributeObject.setAttribute(returnAttributeList);
-		msAttributeObject.setRefAttribute(returnRefList);
-		msAttributeObject.setSubClass(returnSubList);
-		msAttributeObject.setDependency(dpendList.toString());
-		msAttributeObject.addMatchingSet(returnAnnotation);
-		msAttributeObject.setPolicyTempalate(isPolicyTemplate(root, className));
+    private HashMap<String, String> getEEnum(EObject obj) {
+        List<String> valueList = new ArrayList<>();
+        HashMap<String, String> returnMap = new HashMap<>();
+        EEnum eenum = (EEnum)obj;
 
-		this.classMap.put(className, msAttributeObject);	
-	}
+        String name = eenum.getName();
+        for (EEnumLiteral eEnumLiteral : eenum.getELiterals())
+        {
+            Enumerator instance = eEnumLiteral.getInstance();
+            String value = instance.getLiteral();
+            valueList.add(value);
+        }
+        returnMap.put(name, valueList.toString());
+        return returnMap;
+    }
 
-	private HashMap<String, String> getAnnotation(EPackage root, String className, String extendClass) {
-		TreeIterator<EObject> treeItr = root.eAllContents();
-		boolean requiredAttribute = false; 
-		boolean requiredMatchAttribute = false;
-		HashMap<String, String> annotationSet = new HashMap<>();
-		String  matching;
-		String range;
-		String annotationDict;
+    public void getAttributes(String className, String dependency, EPackage root) {
+        List<String> dpendList = new ArrayList<>();
+        if (dependency!=null){
+            dpendList = new ArrayList<>(Arrays.asList(dependency.split(",")));
+        }
+        MSAttributeObject msAttributeObject = new MSAttributeObject();
+        msAttributeObject.setClassName(className);
+        String extendClass = getSubTypes(root, className);
+        Map<String, String> returnRefList = getRefAttributeList(root, className, extendClass);
+        Map<String, String> returnAttributeList = getAttributeList(root, className, extendClass);
+        Map<String, Object> returnSubList = getSubAttributeList(root, className, extendClass);
+        HashMap<String, String> returnAnnotation = getAnnotation(root, className, extendClass);
+        msAttributeObject.setAttribute(returnAttributeList);
+        msAttributeObject.setRefAttribute(returnRefList);
+        msAttributeObject.setSubClass(returnSubList);
+        msAttributeObject.setDependency(dpendList.toString());
+        msAttributeObject.addMatchingSet(returnAnnotation);
+        msAttributeObject.setPolicyTempalate(isPolicyTemplate(root, className));
 
-		//    Pulling out dependency from file
-		while (treeItr.hasNext()) {	    
-			EObject obj = treeItr.next();
-			if (obj instanceof EClassifier) {
-				requiredAttribute = isRequiredAttribute(obj,  className );
-				requiredMatchAttribute = isRequiredAttribute(obj,  extendClass );
-			}
+        this.classMap.put(className, msAttributeObject);
+    }
 
-			if (requiredAttribute){
-				if (obj instanceof EStructuralFeature) {
-					EStructuralFeature eStrucClassifier = (EStructuralFeature) obj;
-					if (!eStrucClassifier.getEAnnotations().isEmpty()) {
-						matching  = annotationValue(eStrucClassifier, ANNOTATION_TYPE.MATCHING, policy);
-						if (matching!=null){
-							annotationSet.put(eStrucClassifier.getName(), matching);
-						}
-						range  = annotationValue(eStrucClassifier, ANNOTATION_TYPE.VALIDATION, policy);
-						if (range!=null){
-							annotationSet.put(eStrucClassifier.getName(), range);
-						}
-						annotationDict = annotationValue(eStrucClassifier, ANNOTATION_TYPE.DICTIONARY, policy);
-						if (annotationDict!=null){
-							annotationSet.put(eStrucClassifier.getName(), annotationDict);
-						}
-					}
-				}
-			} else if (requiredMatchAttribute && (obj instanceof EStructuralFeature)) {
-					EStructuralFeature eStrucClassifier = (EStructuralFeature) obj;
-					if (!eStrucClassifier.getEAnnotations().isEmpty()) {
-						matching  = annotationValue(eStrucClassifier, ANNOTATION_TYPE.MATCHING, policy);
-						if (matching!=null){
-							if (obj instanceof EReference){
-								EClass refType = ((EReference) obj).getEReferenceType();
-								annotationSet.put(refType.getName(), matching);
-								matchingClass.put(refType.getName(), matching);
-							}else{
-								annotationSet.put(eStrucClassifier.getName(), matching);
-							}
-						}
-					}
-			}
-		}
-		return annotationSet;
-	}
+    private HashMap<String, String> getAnnotation(EPackage root, String className, String extendClass) {
+        TreeIterator<EObject> treeItr = root.eAllContents();
+        boolean requiredAttribute = false;
+        boolean requiredMatchAttribute = false;
+        HashMap<String, String> annotationSet = new HashMap<>();
 
-	private Map<String, Object> getSubAttributeList(EPackage root, String className , String superClass) {
-		TreeIterator<EObject> treeItr = root.eAllContents();
-		boolean requiredAttribute = false; 
-		Map<String, Object> subAttribute = new HashMap<>();
-		int rollingCount = 0;
-		int processClass = 0;
-		boolean annotation;
+        //    Pulling out dependency from file
+        while (treeItr.hasNext()) {
+            EObject obj = treeItr.next();
+            if (obj instanceof EClassifier) {
+                requiredAttribute = isRequiredAttribute(obj,  className );
+                requiredMatchAttribute = isRequiredAttribute(obj,  extendClass );
+            }
 
-		//    Pulling out dependency from file
-		while (treeItr.hasNext() && rollingCount < 2) {	 
+            if (requiredAttribute){
+                if (obj instanceof EStructuralFeature) {
+                    checkAnnotation(annotationSet, (EStructuralFeature) obj);
+                }
+            } else if (requiredMatchAttribute && (obj instanceof EStructuralFeature)) {
+                findMatchingAnnotation(annotationSet, obj);
+            }
+        }
+        return annotationSet;
+    }
 
-			EObject obj = treeItr.next();
-			if (obj instanceof EClassifier) {
-				if (isRequiredAttribute(obj,  className ) || isRequiredAttribute(obj,  superClass )){
-					requiredAttribute = true;
-				}else {
-					requiredAttribute = false;
-				}
-				if (requiredAttribute){
-					processClass++;
-				}
-				rollingCount = rollingCount+processClass;
-			}
+    private void findMatchingAnnotation(HashMap<String, String> annotationSet, EObject obj) {
+        EStructuralFeature eStrucClassifier = (EStructuralFeature) obj;
+        if (eStrucClassifier.getEAnnotations().isEmpty()) {
+            return;
+        }
+        String matching  = annotationValue(eStrucClassifier, ANNOTATION_TYPE.MATCHING, policy);
+        if (matching!=null){
+            if (obj instanceof EReference){
+                EClass refType = ((EReference) obj).getEReferenceType();
+                annotationSet.put(refType.getName(), matching);
+                matchingClass.put(refType.getName(), matching);
+            }else{
+                annotationSet.put(eStrucClassifier.getName(), matching);
+            }
+        }
 
-			if (requiredAttribute && (obj instanceof EStructuralFeature)) {
-				EStructuralFeature eStrucClassifier = (EStructuralFeature) obj;
-				if (!eStrucClassifier.getEAnnotations().isEmpty()) {
-					annotation = annotationTest(eStrucClassifier, configuration, onap);
-					if (annotation &&  obj instanceof EReference) {
-						EClass refType = ((EReference) obj).getEReferenceType();
-						if(!refType.toString().contains(eProxyURI)){
-							String required = REQUIREDFALSE;
-							if(eStrucClassifier.getLowerBound() == 1){
-								required = REQUIREDTRUE;
-							}
-							subAttribute.put(eStrucClassifier.getName(), refType.getName() + required);						
-						}
-					}	
-				}
-			}
-		}
-		return subAttribute;
-	}
+    }
 
-	public String checkDefultValue(String defultValue) {
-		if (defultValue!=null){
-			return DEFAULTVALUE+ defultValue;
-		}
-		return ":defaultValue-NA";
+    private void checkAnnotation(HashMap<String, String> annotationSet, EStructuralFeature obj) {
+        EStructuralFeature eStrucClassifier = obj;
+        if (eStrucClassifier.getEAnnotations().isEmpty()) {
+            return;
+        }
+        String matching  = annotationValue(eStrucClassifier, ANNOTATION_TYPE.MATCHING, policy);
+        if (matching!=null){
+            annotationSet.put(eStrucClassifier.getName(), matching);
+        }
+        String range  = annotationValue(eStrucClassifier, ANNOTATION_TYPE.VALIDATION, policy);
+        if (range!=null){
+            annotationSet.put(eStrucClassifier.getName(), range);
+        }
+        String annotationDict = annotationValue(eStrucClassifier, ANNOTATION_TYPE.DICTIONARY, policy);
+        if (annotationDict!=null){
+            annotationSet.put(eStrucClassifier.getName(), annotationDict);
+        }
+    }
+
+    private Map<String, Object> getSubAttributeList(EPackage root, String className , String superClass) {
+        TreeIterator<EObject> treeItr = root.eAllContents();
+        boolean requiredAttribute = false;
+        Map<String, Object> subAttribute = new HashMap<>();
+        int rollingCount = 0;
+        int processClass = 0;
+
+        //    Pulling out dependency from file
+        while (treeItr.hasNext() && rollingCount < 2) {
+
+            EObject obj = treeItr.next();
+            if (obj instanceof EClassifier) {
+                requiredAttribute = isRequiredAttribute(obj,  className ) || isRequiredAttribute(obj,  superClass );
+                if (requiredAttribute){
+                    processClass++;
+                }
+                rollingCount = rollingCount+processClass;
+            }
+
+            if (requiredAttribute && (obj instanceof EStructuralFeature)) {
+                EStructuralFeature eStrucClassifier = (EStructuralFeature) obj;
+                if (!eStrucClassifier.getEAnnotations().isEmpty()) {
+                    updateSubAttributes(subAttribute, obj, eStrucClassifier);
+                }
+            }
+        }
+        return subAttribute;
+    }
+
+    private void updateSubAttributes(Map<String, Object> subAttribute, EObject obj, EStructuralFeature eStrucClassifier) {
+        if (!(obj instanceof EReference)) {
+            return;
+        }
+        if (annotationTest(eStrucClassifier, configuration, onap)) {
+            EClass refType = ((EReference) obj).getEReferenceType();
+            if(!refType.toString().contains(eProxyURI)){
+                String required = REQUIREDFALSE;
+                if(eStrucClassifier.getLowerBound() == 1){
+                    required = REQUIREDTRUE;
+                }
+                subAttribute.put(eStrucClassifier.getName(), refType.getName() + required);
+            }
+        }
+    }
+
+    public String checkDefultValue(String defultValue) {
+        if (defultValue!=null){
+            return DEFAULTVALUE+ defultValue;
+        }
+        return ":defaultValue-NA";
+
+    }
+
+    public String checkRequiredPattern(int upper, int lower) {
+
+        String pattern = XACMLProperties.getProperty(XACMLRestProperties.PROP_XCORE_REQUIRED_PATTERN);
+
+        if (pattern!=null){
+            if (upper == Integer.parseInt(pattern.split(",")[1]) && lower==Integer.parseInt(pattern.split(",")[0])){
+                return REQUIREDTRUE;
+            }
+        }
+
+        return REQUIREDFALSE;
+    }
+
+    public JSONObject buildJavaObject(Map<String, String> map){
+
+        return  new JSONObject(map);
+    }
+
+    public Map<String, String> getRefAttributeList(EPackage root, String className, String superClass){
+
+        TreeIterator<EObject> treeItr = root.eAllContents();
+        boolean requiredAttribute = false;
+        HashMap<String, String> refAttribute = new HashMap<>();
+        int rollingCount = 0;
+        int processClass = 0;
+        boolean annotation;
+        //    Pulling out dependency from file
+        while (treeItr.hasNext()) {
+            EObject obj = treeItr.next();
+            if (obj instanceof EClassifier) {
+                requiredAttribute = isRequiredAttribute(obj,  className ) || isRequiredAttribute(obj,  superClass );
+                if (requiredAttribute){
+                    processClass++;
+                }
+                rollingCount = rollingCount+processClass;
+            }
+
+            if (requiredAttribute && (obj instanceof EStructuralFeature)) {
+                    EStructuralFeature eStrucClassifier = (EStructuralFeature) obj;
+                    if (!eStrucClassifier.getEAnnotations().isEmpty()) {
+                        annotation = annotationTest(eStrucClassifier, configuration, onap);
+                        if ( annotation &&  obj instanceof EReference) {
+                            updRefAttributes(refAttribute, (EStructuralFeature) obj, eStrucClassifier);
+                        } else if (annotation &&  obj instanceof EAttributeImpl) {
+                            updEnumTypeRefAttrib(refAttribute, (EStructuralFeature) obj, eStrucClassifier);
+                        }
+                    }
+            }
+        }
 
-	}
+        return refAttribute;
+    }
 
-	public String checkRequiredPattern(int upper, int lower) {	
+    private void updEnumTypeRefAttrib(HashMap<String, String> refAttribute, EStructuralFeature obj, EStructuralFeature eStrucClassifier) {
+        EClassifier refType = ((EAttributeImpl) obj).getEType();
+        if (!(refType instanceof EEnumImpl)){
+            return;
+        }
 
-		String pattern = XACMLProperties.getProperty(XACMLRestProperties.PROP_XCORE_REQUIRED_PATTERN);
+        String array = arrayCheck(obj.getUpperBound());
+        String required = REQUIREDFALSE;
+        if(obj.getLowerBound() == 1){
+            required = REQUIREDTRUE;
+        }
+        refAttribute.put(eStrucClassifier.getName(), refType.getName() + array + required);
+    }
 
-		if (pattern!=null){
-			if (upper == Integer.parseInt(pattern.split(",")[1]) && lower==Integer.parseInt(pattern.split(",")[0])){
-				return REQUIREDTRUE;
-			}
-		}
+    private void updRefAttributes(HashMap<String, String> refAttribute, EStructuralFeature obj, EStructuralFeature eStrucClassifier) {
+        EClass refType = ((EReference) obj).getEReferenceType();
+        if(refType.toString().contains(eProxyURI)){
+            String one = refType.toString().split(eProxyURI)[1];
+            String refValue = StringUtils.replaceEach(one.split("#")[1], new String[]{"//", ")"}, new String[]{"", ""});
+            refAttribute.put(eStrucClassifier.getName(), refValue);
+        } else {
+            String required = REQUIREDFALSE;
+            if(obj.getLowerBound() == 1){
+                required = REQUIREDTRUE;
+            }
+            refAttribute.put(eStrucClassifier.getName(), refType.getName() + arrayCheck(obj.getUpperBound()) + required);
+        }
+    }
 
-		return REQUIREDFALSE;
-	}
+    private boolean annotationTest(EStructuralFeature eStrucClassifier, String annotation, String type) {
+        String annotationType;
+        EAnnotation eAnnotation;
+        String onapType;
+        String onapValue;
 
-	public JSONObject buildJavaObject(Map<String, String> map){
+        EList<EAnnotation> value = eStrucClassifier.getEAnnotations();
 
-		return  new JSONObject(map);
-	}
+        for (int i = 0; i < value.size(); i++){
+            annotationType = value.get(i).getSource();
+            eAnnotation = eStrucClassifier.getEAnnotations().get(i);
+            onapType = eAnnotation.getDetails().get(0).getValue();
+            onapValue = eAnnotation.getDetails().get(0).getKey();
 
-	public Map<String, String> getRefAttributeList(EPackage root, String className, String superClass){
+            if (annotationType.contains(type) && onapType.contains(annotation)){
+                return true;
+            }
 
-		TreeIterator<EObject> treeItr = root.eAllContents();
-		boolean requiredAttribute = false; 
-		HashMap<String, String> refAttribute = new HashMap<>();
-		int rollingCount = 0;
-		int processClass = 0;
-		boolean annotation;
-		//    Pulling out dependency from file
-		while (treeItr.hasNext()) {	    
-			EObject obj = treeItr.next();
-			if (obj instanceof EClassifier) {
-				if (isRequiredAttribute(obj,  className ) || isRequiredAttribute(obj,  superClass )){
-					requiredAttribute = true;
-				}else {
-					requiredAttribute = false;
-				}	
-				if (requiredAttribute){
-					processClass++;
-				}
-				rollingCount = rollingCount+processClass;
-			}
+            if (annotationType.contains(type) && onapValue.contains(annotation)){
+                return true;
+            }
+        }
 
-			if (requiredAttribute && (obj instanceof EStructuralFeature)) {
-					EStructuralFeature eStrucClassifier = (EStructuralFeature) obj;
-					if (!eStrucClassifier.getEAnnotations().isEmpty()) {
-						annotation = annotationTest(eStrucClassifier, configuration, onap);
-						if ( annotation &&  obj instanceof EReference) {
-							EClass refType = ((EReference) obj).getEReferenceType();
-							if(refType.toString().contains(eProxyURI)){
-								String one = refType.toString().split(eProxyURI)[1];
-								String refValue = StringUtils.replaceEach(one.split("#")[1], new String[]{"//", ")"}, new String[]{"", ""});							
-								refAttribute.put(eStrucClassifier.getName(), refValue);							
-							} else {
-								String array = arrayCheck(((EStructuralFeature) obj).getUpperBound());
-								String required = REQUIREDFALSE;
-								if(((EStructuralFeature) obj).getLowerBound() == 1){
-									required = REQUIREDTRUE;
-								}
-								refAttribute.put(eStrucClassifier.getName(), refType.getName() + array + required);
-							}
-						} else if (annotation &&  obj instanceof EAttributeImpl){
-							EClassifier refType = ((EAttributeImpl) obj).getEType();
-							if (refType instanceof EEnumImpl){
-								String array = arrayCheck(((EStructuralFeature) obj).getUpperBound());
-								String required = REQUIREDFALSE;
-								if(((EStructuralFeature) obj).getLowerBound() == 1){
-									required = REQUIREDTRUE;
-								}
-								refAttribute.put(eStrucClassifier.getName(), refType.getName() + array + required);							
-							}
-						}	
-					}
-			}
-		}
-		
-		return refAttribute;
-	}
+        return false;
+    }
 
-	private boolean annotationTest(EStructuralFeature eStrucClassifier, String annotation, String type) {
-		String annotationType;
-		EAnnotation eAnnotation;
-		String onapType;
-		String onapValue;
 
-		EList<EAnnotation> value = eStrucClassifier.getEAnnotations();
+    private String annotationValue(EStructuralFeature eStrucClassifier, ANNOTATION_TYPE annotation, String type) {
+        String annotationType;
+        EAnnotation eAnnotation;
+        String onapType;
+        String onapValue = null;
 
-		for (int i = 0; i < value.size(); i++){
-			annotationType = value.get(i).getSource();
-			eAnnotation = eStrucClassifier.getEAnnotations().get(i);
-			onapType = eAnnotation.getDetails().get(0).getValue();
-			onapValue = eAnnotation.getDetails().get(0).getKey();
-			
-			if (annotationType.contains(type) && onapType.contains(annotation)){
-				return true;
-			}
-			
-			if (annotationType.contains(type) && onapValue.contains(annotation)){
-				return true;
-			}
-		}
+        EList<EAnnotation> value = eStrucClassifier.getEAnnotations();
 
-		return false;
-	}
+        for (int i = 0; i < value.size(); i++){
+            annotationType = value.get(i).getSource();
+            eAnnotation = eStrucClassifier.getEAnnotations().get(i);
+            onapType = eAnnotation.getDetails().get(0).getKey();
+            if (annotationType.contains(type) && onapType.compareToIgnoreCase(annotation.toString())==0){
+                onapValue = eAnnotation.getDetails().get(0).getValue();
+                if (annotation == ANNOTATION_TYPE.VALIDATION){
+                    return onapValue;
+                } else {
+                    return onapType + "-" + onapValue;
+                }
+            }
+        }
 
+        return onapValue;
+    }
+    public boolean isRequiredAttribute(EObject obj, String className){
+        EClassifier eClassifier = (EClassifier) obj;
+        String workingClass = eClassifier.getName().trim();
+        if (workingClass.equalsIgnoreCase(className)){
+            return  true;
+        }
 
-	private String annotationValue(EStructuralFeature eStrucClassifier, ANNOTATION_TYPE annotation, String type) {
-		String annotationType;
-		EAnnotation eAnnotation;
-		String onapType;
-		String onapValue = null;
+        return false;
+    }
 
-		EList<EAnnotation> value = eStrucClassifier.getEAnnotations();
+    private boolean isPolicyTemplate(EPackage root, String className){
+        boolean result = false;
+        for (EClassifier classifier : root.getEClassifiers()){
+            if (classifier instanceof EClass) {
+                EClass eClass = (EClass)classifier;
+                if (eClass.getName().contentEquals(className)) {
+                    result = checkPolicyTemplate(eClass);
+                    break;
+                }
+            }
+        }
+        return result;
+    }
 
-		for (int i = 0; i < value.size(); i++){
-			annotationType = value.get(i).getSource();
-			eAnnotation = eStrucClassifier.getEAnnotations().get(i);
-			onapType = eAnnotation.getDetails().get(0).getKey();
-			if (annotationType.contains(type) && onapType.compareToIgnoreCase(annotation.toString())==0){
-				onapValue = eAnnotation.getDetails().get(0).getValue();
-				if (annotation == ANNOTATION_TYPE.VALIDATION){
-					return onapValue;
-				} else {
-					return onapType + "-" + onapValue;
-				}
-			}
-		}
+    private boolean checkPolicyTemplate(EClass eClass) {
+        EList<EAnnotation> value = eClass.getEAnnotations();
+        for (EAnnotation workingValue : value){
+            EMap<String, String> keyMap = workingValue.getDetails();
+            if (keyMap.containsKey("policyTemplate")){
+                return true;
+            }
+        }
+        return false;
+    }
 
-		return onapValue;
-	}
-	public boolean isRequiredAttribute(EObject obj, String className){
-		EClassifier eClassifier = (EClassifier) obj;
-		String workingClass = eClassifier.getName().trim();
-		if (workingClass.equalsIgnoreCase(className)){
-			return  true;
-		}
+    private String getSubTypes(EPackage root, String className) {
+        String returnSubTypes = null;
+        for (EClassifier classifier : root.getEClassifiers()){
+            if (classifier instanceof EClass) {
+                returnSubTypes = findSubTypes(className, returnSubTypes, (EClass) classifier);
+            }
+        }
+        return returnSubTypes;
+    }
 
-		return false;
-	} 
+    private String findSubTypes(String className, String returnSubTypes, EClass classifier) {
+        EClass eClass = classifier;
 
-	private boolean isPolicyTemplate(EPackage root, String className){
+        for (EClass eSuperType : eClass.getEAllSuperTypes())
+        {
+            if (eClass.getName().contentEquals(className)){
+                returnSubTypes = eSuperType.getName();
+            }
+        }
+        return returnSubTypes;
+    }
 
-		for (EClassifier classifier : root.getEClassifiers()){ 
-			if (classifier instanceof EClass) { 
-				EClass eClass = (EClass)classifier; 
-				if (eClass.getName().contentEquals(className)){
-					EList<EAnnotation> value = eClass.getEAnnotations();
-					for (EAnnotation workingValue : value){
-						EMap<String, String> keyMap = workingValue.getDetails();	
-						if (keyMap.containsKey("policyTemplate")){
-							return true;
-						}
-					}	
-				}
-			}
-		}
-		return false;
-	}
-	private String getSubTypes(EPackage root, String className) {
-		String returnSubTypes = null;
-		for (EClassifier classifier : root.getEClassifiers()){ 
-			if (classifier instanceof EClass) { 
-				EClass eClass = (EClass)classifier; 
+    public Map<String, String> getAttributeList(EPackage root, String className, String superClass){
 
-				for (EClass eSuperType : eClass.getEAllSuperTypes()) 
-				{ 
-					if (eClass.getName().contentEquals(className)){
-						returnSubTypes = eSuperType.getName();
-					}
-				} 
-			} 
-		} 
-		return returnSubTypes;
-	} 
+        TreeIterator<EObject> treeItr = root.eAllContents();
+        boolean requiredAttribute = false;
+        HashMap<String, String> refAttribute = new HashMap<>();
 
-	public Map<String, String> getAttributeList(EPackage root, String className, String superClass){
+        //    Pulling out dependency from file
+        while (treeItr.hasNext()) {
+            EObject obj = treeItr.next();
+            if (obj instanceof EClassifier) {
+                requiredAttribute = isRequiredAttribute(obj,  className ) || isRequiredAttribute(obj,  superClass );
+            }
 
-		TreeIterator<EObject> treeItr = root.eAllContents();
-		boolean requiredAttribute = false; 
-		HashMap<String, String> refAttribute = new HashMap<>();
-		boolean annotation;
-		boolean dictionaryTest;
-		String defaultValue;
-		String eType;
+            if (requiredAttribute && (obj instanceof EStructuralFeature)) {
+                EStructuralFeature eStrucClassifier = (EStructuralFeature) obj;
+                if (!eStrucClassifier.getEAnnotations().isEmpty()) {
+                    checkStrucClassifier(refAttribute, obj, eStrucClassifier);
+                }
+            }
+        }
+        return refAttribute;
 
-		//    Pulling out dependency from file
-		while (treeItr.hasNext()) {	    
-			EObject obj = treeItr.next();
-			if (obj instanceof EClassifier) {
-				if (isRequiredAttribute(obj,  className ) || isRequiredAttribute(obj,  superClass )){
-					requiredAttribute = true;
-				}else {
-					requiredAttribute = false;
-				}
+    }
 
-			}
+    private void checkStrucClassifier(HashMap<String, String> refAttribute, EObject obj, EStructuralFeature eStrucClassifier) {
+        EClassifier refType = ((EStructuralFeature) obj).getEType();
+        boolean annotation = annotationTest(eStrucClassifier, configuration, onap);
+        boolean dictionaryTest = annotationTest(eStrucClassifier, dictionary, policy);
+        if (annotation && !(obj instanceof EReference) && !(refType instanceof EEnumImpl)) {
+            updEReferenceAttrib(refAttribute, dictionaryTest, (EStructuralFeature) obj, eStrucClassifier);
+        }
+    }
 
-			if (requiredAttribute && (obj instanceof EStructuralFeature)) {
-					EStructuralFeature eStrucClassifier = (EStructuralFeature) obj;
-					if (!eStrucClassifier.getEAnnotations().isEmpty()) {
-						annotation = annotationTest(eStrucClassifier, configuration, onap);
-						dictionaryTest = annotationTest(eStrucClassifier, dictionary, policy);
-						EClassifier refType = ((EStructuralFeature) obj).getEType();
-						if (annotation && !(obj instanceof EReference) && !(refType instanceof EEnumImpl)) {
-							String name = eStrucClassifier.getName();
-							if (dictionaryTest){
-								eType = annotationValue(eStrucClassifier, ANNOTATION_TYPE.DICTIONARY, policy);
-							}else {
-								eType = eStrucClassifier.getEType().getInstanceClassName();
-							}
-							defaultValue = checkDefultValue(((EStructuralFeature) obj).getDefaultValueLiteral());
+    private void updEReferenceAttrib(HashMap<String, String> refAttribute, boolean dictionaryTest, EStructuralFeature obj, EStructuralFeature eStrucClassifier) {
+        String eType;
+        String name = eStrucClassifier.getName();
+        if (dictionaryTest){
+            eType = annotationValue(eStrucClassifier, ANNOTATION_TYPE.DICTIONARY, policy);
+        }else {
+            eType = eStrucClassifier.getEType().getInstanceClassName();
+        }
+        String defaultValue = checkDefultValue(obj.getDefaultValueLiteral());
+        String array = arrayCheck(obj.getUpperBound());
+        String required = checkRequiredPattern(obj.getUpperBound(), obj.getLowerBound());
+        refAttribute.put(name, eType + defaultValue + required + array);
+    }
 
-							String array = arrayCheck(((EStructuralFeature) obj).getUpperBound());
-							String required = checkRequiredPattern(((EStructuralFeature) obj).getUpperBound(), ((EStructuralFeature) obj).getLowerBound());
-							String attributeValue =  eType + defaultValue + required + array;
-							refAttribute.put(name, attributeValue);	
-						}
-					}
-			}
-		}
-		return refAttribute;
+    public String arrayCheck(int upperBound) {
 
-	}
+        if (upperBound == -1){
+            return MANYTRUE;
+        }
 
-	public String arrayCheck(int upperBound) {
+        return MANYFALSE;
+    }
 
-		if (upperBound == -1){
-			return MANYTRUE;
-		}
+    public List<String> getDependencyList(EClassifier eClassifier){
+        List<String> returnValue = new ArrayList<>();;
+        EList<EClass> somelist = ((EClass) eClassifier).getEAllSuperTypes();
+        if (somelist.isEmpty()){
+            return returnValue;
+        }
+        for(EClass depend: somelist){
+            if (depend.toString().contains(eProxyURI)){
+                String one = depend.toString().split(eProxyURI)[1];
+                String value = StringUtils.replaceEach(one.split("#")[1], new String[]{"//", ")"}, new String[]{"", ""});
+                returnValue.add(value);
+            }
+        }
 
-		return MANYFALSE;
-	}
+        return returnValue;
+    }
 
-	public List<String> getDependencyList(EClassifier eClassifier){
-		List<String> returnValue = new ArrayList<>();;
-		EList<EClass> somelist = ((EClass) eClassifier).getEAllSuperTypes();
-		if (somelist.isEmpty()){
-			return returnValue;
-		}
-		for(EClass depend: somelist){
-			if (depend.toString().contains(eProxyURI)){
-				String one = depend.toString().split(eProxyURI)[1];
-				String value = StringUtils.replaceEach(one.split("#")[1], new String[]{"//", ")"}, new String[]{"", ""});
-				returnValue.add(value);
-			}
-		}
+    public Map<String, String> buildSubList(Map<String, String> subClassAttributes, Map<String, MSAttributeObject> classMap, String className){
+        Map<String, String> missingValues = new HashMap<>();
+        Map<String, String> workingMap;
+        boolean enumType;
 
-		return returnValue;
-	}
+        for ( Entry<String, String> map : classMap.get(className).getRefAttribute().entrySet()){
+            String value = map.getValue().split(":")[0];
+            if (value!=null){
+                classMap.get(className).getEnumType();
+                enumType = classMap.get(className).getEnumType().containsKey(value);
+                if (!enumType){
+                    workingMap =  classMap.get(value).getRefAttribute();
+                    for ( Entry<String, String> subMab : workingMap.entrySet()){
+                        String value2 = subMab.getValue().split(":")[0];
+                        if (!subClassAttributes.containsValue(value2)){
+                            missingValues.put(subMab.getKey(), subMab.getValue());
+                        }
+                    }
 
-	public Map<String, String> buildSubList(Map<String, String> subClassAttributes, Map<String, MSAttributeObject> classMap, String className){
-		Map<String, String> missingValues = new HashMap<>();
-		Map<String, String> workingMap;
-		boolean enumType;
+                }
+            }
+        }
 
-		for ( Entry<String, String> map : classMap.get(className).getRefAttribute().entrySet()){
-			String value = map.getValue().split(":")[0];
-			if (value!=null){
-				classMap.get(className).getEnumType();
-				enumType = classMap.get(className).getEnumType().containsKey(value);
-				if (!enumType){
-					workingMap =  classMap.get(value).getRefAttribute();
-					for ( Entry<String, String> subMab : workingMap.entrySet()){
-						String value2 = subMab.getValue().split(":")[0];
-						if (!subClassAttributes.containsValue(value2)){
-							missingValues.put(subMab.getKey(), subMab.getValue());
-						}
-					}
+        return missingValues;
+    }
 
-				}
-			}
-		}
+    public Map<String, Map<String, String>> recursiveReference(Map<String, MSAttributeObject> classMap, String className){
 
-		return missingValues;
-	}
+        Map<String, Map<String, String>> returnObject = new HashMap<>();
+        Map<String, String> returnClass = getRefclass(classMap, className);
+        returnObject.put(className, returnClass);
+        for (Entry<String, String> reAttribute :returnClass.entrySet()){
+            if (reAttribute.getValue().split(":")[1].contains("MANY") &&
+                    classMap.get(reAttribute.getValue().split(":")[0]) != null){
+                    returnObject.putAll(recursiveReference(classMap, reAttribute.getValue().split(":")[0]));
+            }
 
-	public Map<String, Map<String, String>> recursiveReference(Map<String, MSAttributeObject> classMap, String className){
+        }
 
-		Map<String, Map<String, String>> returnObject = new HashMap<>();
-		Map<String, String> returnClass = getRefclass(classMap, className);
-		returnObject.put(className, returnClass);
-		for (Entry<String, String> reAttribute :returnClass.entrySet()){
-			if (reAttribute.getValue().split(":")[1].contains("MANY") && 
-					classMap.get(reAttribute.getValue().split(":")[0]) != null){
-					returnObject.putAll(recursiveReference(classMap, reAttribute.getValue().split(":")[0]));
-			}
+        return returnObject;
 
-		}
+    }
 
-		return returnObject;
+    public String createJson(Map<String, MSAttributeObject> classMap, String className) {
+        boolean enumType;
+        Map<String, Map<String, String>> myObject = new HashMap<>();
+        for ( Entry<String, String> map : classMap.get(className).getRefAttribute().entrySet()){
+            String value = map.getValue().split(":")[0];
+            if (value!=null){
+                enumType = classMap.get(className).getEnumType().containsKey(value);
+                if (!enumType && map.getValue().split(":")[1].contains("MANY")){
+                        Map<String, Map<String, String>> testRecursive = recursiveReference(classMap, map.getValue().split(":")[0] );
+                        myObject.putAll(testRecursive);
+                }
+            }
+        }
 
-	}
+        Gson gson = new Gson();
+        return gson.toJson(myObject);
+    }
 
-	public String createJson(Map<String, MSAttributeObject> classMap, String className) {
-		boolean enumType;
-		Map<String, Map<String, String>> myObject = new HashMap<>();
-		for ( Entry<String, String> map : classMap.get(className).getRefAttribute().entrySet()){
-			String value = map.getValue().split(":")[0];
-			if (value!=null){
-				enumType = classMap.get(className).getEnumType().containsKey(value);
-				if (!enumType && map.getValue().split(":")[1].contains("MANY")){
-						Map<String, Map<String, String>> testRecursive = recursiveReference(classMap, map.getValue().split(":")[0] );
-						myObject.putAll(testRecursive);
-				}
-			}
-		}
+    public Map<String, String> getRefclass(Map<String, MSAttributeObject> classMap, String className){
+        HashMap<String, String> missingValues = new HashMap<>();
 
-		Gson gson = new Gson(); 
-		return gson.toJson(myObject);
-	}
+        if (classMap.get(className).getAttribute()!=null || !classMap.get(className).getAttribute().isEmpty()){
+            missingValues.putAll(classMap.get(className).getAttribute());
+        }
 
-	public Map<String, String> getRefclass(Map<String, MSAttributeObject> classMap, String className){
-		HashMap<String, String> missingValues = new HashMap<>();
+        if (classMap.get(className).getRefAttribute()!=null || !classMap.get(className).getRefAttribute().isEmpty()){
+            missingValues.putAll(classMap.get(className).getRefAttribute());
+        }
 
-		if (classMap.get(className).getAttribute()!=null || !classMap.get(className).getAttribute().isEmpty()){
-			missingValues.putAll(classMap.get(className).getAttribute());
-		}
+        return missingValues;
+    }
 
-		if (classMap.get(className).getRefAttribute()!=null || !classMap.get(className).getRefAttribute().isEmpty()){
-			missingValues.putAll(classMap.get(className).getRefAttribute());
-		}
+    public String createSubAttributes(List<String> dependency, Map<String, MSAttributeObject> classMap, String modelName) {
 
-		return missingValues;	
-	}
+        HashMap <String,  Object>  workingMap = new HashMap<>();
+        MSAttributeObject tempObject;
+        if (dependency!=null){
+            if (dependency.isEmpty()){
+                return "{}";
+            }
+            dependency.add(modelName);
+            for (String element: dependency){
+                tempObject = classMap.get(element);
+                if (tempObject!=null){
+                    workingMap.putAll(classMap.get(element).getSubClass());
+                }
+            }
+        }
 
-	public String createSubAttributes(List<String> dependency, Map<String, MSAttributeObject> classMap, String modelName) {
+        return createJson(classMap, modelName);
+    }
 
-		HashMap <String,  Object>  workingMap = new HashMap<>();
-		MSAttributeObject tempObject;
-		if (dependency!=null){
-			if (dependency.isEmpty()){
-				return "{}";
-			}	
-			dependency.add(modelName);
-			for (String element: dependency){
-				tempObject = classMap.get(element);
-				if (tempObject!=null){
-					workingMap.putAll(classMap.get(element).getSubClass());
-				}
-			}
-		}
+    public List<String> getFullDependencyList(List<String> dependency, Map<String,MSAttributeObject > classMap) {
+        ArrayList<String> returnList = new ArrayList<>();
+        ArrayList<String> workingList;
+        returnList.addAll(dependency);
+        for (String element : dependency ){
+            if (classMap.containsKey(element)){
+                MSAttributeObject value = classMap.get(element);
+                String rawValue = StringUtils.replaceEach(value.getDependency(), new String[]{"[", "]"}, new String[]{"", ""});
+                workingList = new ArrayList<>(Arrays.asList(rawValue.split(",")));
+                for(String depend : workingList) {
+                    updDependencyList(returnList, depend);
+                }
+            }
+        }
 
-		return createJson(classMap, modelName);
-	}
+        return returnList;
+    }
 
-	public List<String> getFullDependencyList(List<String> dependency, Map<String,MSAttributeObject > classMap) {
-		ArrayList<String> returnList = new ArrayList<>();
-		ArrayList<String> workingList;
-		returnList.addAll(dependency);
-		for (String element : dependency ){
-			if (classMap.containsKey(element)){
-				MSAttributeObject value = classMap.get(element);
-				String rawValue = StringUtils.replaceEach(value.getDependency(), new String[]{"[", "]"}, new String[]{"", ""});
-				workingList = new ArrayList<>(Arrays.asList(rawValue.split(",")));
-				for(String depend : workingList){
-					if (!returnList.contains(depend) && !depend.isEmpty()){
-						returnList.add(depend.trim());
-					}
-				}
-			}
-		}
+    private void updDependencyList(ArrayList<String> returnList, String depend) {
+        if (!returnList.contains(depend) && !depend.isEmpty()){
+            returnList.add(depend.trim());
+        }
+    }
 
-		return returnList;
-	}
-	
     /*
      * For TOSCA Model
      */
-	public String parseTosca (String fileName){
-		LinkedHashMap<String,String> map= new LinkedHashMap<>();
+    public String parseTosca (String fileName){
+        LinkedHashMap<String,String> map= new LinkedHashMap<>();
     
-    	try {
-			map=load(fileName);
-			
-			if(map != null){
-				if(map.get("error") != null){
-					return map.get("error");
-				}
-			}
-			
-			parseDataAndPolicyNodes(map);
-			
-			LinkedHashMap<String,String> dataMapForJson=parseDataNodes(map);
-			
-			constructJsonForDataFields(dataMapForJson);	
-			
-			LinkedHashMap<String,LinkedHashMap<String,String>> mapKey= parsePolicyNodes(map);
-			
-			createAttributes(mapKey);
-		
-    	} catch (IOException e) {
-    		logger.error(e);
-    	}catch(ParserException e){
-    		logger.error(e);
-    		return e.getMessage();
-    	}
-	   
-    	return null;
-	} 
-	
-	@SuppressWarnings("unchecked")
-	public LinkedHashMap<String, String> load(String fileName) throws IOException,ParserException { 
-		File newConfiguration = new File(fileName);
-		StringBuilder orderInfo = new StringBuilder("[");
-		Yaml yaml = new Yaml();
-		LinkedHashMap<Object, Object> yamlMap = null;
-		try(InputStream is = new FileInputStream(newConfiguration)){
-			yamlMap = (LinkedHashMap<Object, Object>) yaml.load(is); 
-		} catch (FileNotFoundException e) {
-			logger.error(e);
-		}catch(Exception e){
-			throw new ParserException("Invalid TOSCA Model format. Please make sure it is a valid YAML file");
-		}
+        try {
+            map=load(fileName);
 
-		StringBuilder sb = new StringBuilder(); 
-		LinkedHashMap<String, String> settings = new LinkedHashMap<>(); 
-		if (yamlMap == null) { 
-			return settings; 
-		} 
-				
-		String message = validations(yamlMap);	
-		
-		if(message != null){
-			settings.put("error", message);
-			return settings;					
-		}
-		
-		findNode(yamlMap);
-		
-		orderedElements.stream().forEach((string) -> {
-			orderInfo.append(string);
-			orderInfo.append(",");
-			logger.info("Content: " + string);
-		});
-		
-		orderInfo.append("]");
-		
-		dataOrderInfo = orderInfo.toString();
-		dataOrderInfo = dataOrderInfo.replace(",]", "]");
-		
-		logger.info("dataOrderInfo :" + dataOrderInfo);
-		
-		List<String> path = new ArrayList <>(); 
-		serializeMap(settings, sb, path, yamlMap); 
-		return settings; 
-	}
-	
-	@SuppressWarnings("unchecked")
-	private String validations(@SuppressWarnings("rawtypes") LinkedHashMap yamlMap){
-		
-		boolean isNoteTypeFound = false;
-		boolean isDataTypeFound = false;
-		boolean isToscaVersionKeyFound = false;
-		boolean isToscaVersionValueFound = false;
-		@SuppressWarnings("rawtypes")
-		Map m1 = new HashMap();
-		short order =0;
-		if(yamlMap != null){
-			// Get a set of the entries
-		     @SuppressWarnings("rawtypes")
-			Set set = yamlMap.entrySet();		      
-		     // Get an iterator
-		     @SuppressWarnings("rawtypes")
-			Iterator i = set.iterator();		      
-		      // Display elements
-		     while(i.hasNext()) {
-		         @SuppressWarnings("rawtypes")		         
-				 Map.Entry me = (Map.Entry)i.next();
-		         
-		         if("tosca_definitions_version".equals(me.getKey())){
-		        	 isToscaVersionKeyFound = true;
-		        	 order++;
-		        	 m1.put("tosca_definitions_version", order);
-		         }
-		         
-		         if("tosca_simple_yaml_1_0_0".equals(me.getValue())){
-		        	 isToscaVersionValueFound = true;
-		         }
-
-		         if("node_types".equals(me.getKey())){
-		        	 isNoteTypeFound = true;
-		        	 order++;
-		        	 m1.put("node_types", order);
-		         }
-		         
-		         if("data_types".equals(me.getKey())){
-		        	 isDataTypeFound = true;
-		        	 order++;
-		        	 m1.put("data_types", order);
-		         }
-
-		     }
-		     
-	         
-	         if(!isDataTypeFound){
-	        	 return "data_types are missing or invalid.";
-	         }  
-	         
-	         if(!isToscaVersionKeyFound || !isToscaVersionValueFound){
-	        	 return "tosca_definitions_version is missing or invalid.";
-	         }  
-	         
-	         if(!isNoteTypeFound){
-	        	 return "node_types are missing or invalid.";
-	         }  
-	         
-	         short version = (short) m1.get("tosca_definitions_version");
-	         
-	         if(version > 1 ){
-	        	return "tosca_definitions_version should be defined first.";
-	         }
-	         
-	         short data = (short) m1.get("data_types");
-	         short node = (short) m1.get("node_types");
-	         if(node > data){
-	        	return "node_types should be defined before data_types.";	        	 
-	         }	         
-	         
-		}
-		
-		return null;
-	}
-	
-	@SuppressWarnings({ "unchecked", "rawtypes" })
-	private void serializeMap(LinkedHashMap<String, String> settings, StringBuilder sb, List<String> path, Map<Object, Object> yamlMap) { 
-		for (Map.Entry<Object, Object> entry : yamlMap.entrySet()) { 
-				        
-			if (entry.getValue() instanceof Map) { 
-				path.add((String) entry.getKey()); 
-				serializeMap(settings, sb, path, (Map<Object, Object>) entry.getValue()); 
-				path.remove(path.size() - 1); 
-			} else if (entry.getValue() instanceof List) { 
-				path.add((String) entry.getKey()); 
-				serializeList(settings, sb, path, (List) entry.getValue()); 
-				path.remove(path.size() - 1); 
-			} else { 
-				serializeValue(settings, sb, path, (String) entry.getKey(), entry.getValue()); 
-			} 
-		} 
-	}
-	
-	@SuppressWarnings("unchecked")
-	private void serializeList(LinkedHashMap<String, String> settings, StringBuilder sb, List<String> path, List<String> yamlList) { 
-		int counter = 0; 
-		for (Object listEle : yamlList) { 
-			if (listEle instanceof Map) { 
-				path.add(Integer.toString(counter)); 
-				serializeMap(settings, sb, path, (Map<Object, Object>) listEle); 
-				path.remove(path.size() - 1); 
-			} else if (listEle instanceof List) { 
-				path.add(Integer.toString(counter)); 
-				serializeList(settings, sb, path, (List<String>) listEle); 
-				path.remove(path.size() - 1); 
-			} else { 
-				serializeValue(settings, sb, path, Integer.toString(counter), listEle); 
-			} 
-			counter++; 
-		} 
-	} 
-
-	private void serializeValue(LinkedHashMap<String, String> settings, StringBuilder sb, List<String> path, String name, Object value) { 		
-	    if (value == null) { 
-			return; 
-		} 
-		sb.setLength(0); 
-		for (String pathEle : path) { 
-			sb.append(pathEle).append('.'); 
-		} 
-		sb.append(name); 
-		settings.put(sb.toString(), value.toString()); 
-	} 
-	
-	
-	void parseDataAndPolicyNodes(LinkedHashMap<String,String> map){
-		for(String key:map.keySet()){
-			if(key.contains("policy.nodes.Root"))
-			{
-				continue;
-			}
-			else if(key.contains("policy.nodes")){
-				String wordToFind = "policy.nodes.";
-				int indexForPolicyNode=key.indexOf(wordToFind);
-				String subNodeString= key.substring(indexForPolicyNode+13, key.length());
-
-				stringBetweenDots(subNodeString);
-			}
-			else if(key.contains("policy.data")){
-				String wordToFind="policy.data.";
-				int indexForPolicyNode=key.indexOf(wordToFind);
-				String subNodeString= key.substring(indexForPolicyNode+12, key.length());
-
-				stringBetweenDotsForDataFields(subNodeString);
-			}
-		}
-	}
-	
-	// Second index of dot should be returned. 
-	public int stringBetweenDots(String str){
-		String stringToSearch=str;
-		String[]ss=stringToSearch.split("\\.");
-		if(ss!=null){
-			int len= ss.length;
-			if(len>2){
-				uniqueKeys.add(ss[2]);
-			}
-		}
-		
-		return uniqueKeys.size();
-	}
-	
-	
-	public void stringBetweenDotsForDataFields(String str){
-		String stringToSearch=str;
-		String[]ss=stringToSearch.split("\\.");
-		if(ss!=null){
-			int len= ss.length;
-
-			if(len>2){
-				uniqueDataKeys.add(ss[0]+"%"+ss[2]);
-			}
-		}
-	}
-	
-	void constructJsonForDataFields(LinkedHashMap<String,String> dataMapForJson){
-		LinkedHashMap<String,LinkedHashMap<String,String>> dataMapKey= new LinkedHashMap <>();
-		LinkedHashMap<String, String> hmSub;
-		for(Map.Entry<String, String> entry: dataMapForJson.entrySet()){
-			String uniqueDataKey= entry.getKey();
-			String[] uniqueDataKeySplit=uniqueDataKey.split("%");
-			String value= dataMapForJson.get(uniqueDataKey);
-			if(dataMapKey.containsKey(uniqueDataKeySplit[0])){
-				hmSub = dataMapKey.get(uniqueDataKeySplit[0]);
-				hmSub.put(uniqueDataKeySplit[1], value);
-			}
-			else{
-				hmSub=new LinkedHashMap <>();
-				hmSub.put(uniqueDataKeySplit[1], value);
-			}
-				
-			dataMapKey.put(uniqueDataKeySplit[0], hmSub);
-		}
-				
-		JSONObject mainObject= new JSONObject();
-		JSONObject json;
-		for(Map.Entry<String,LinkedHashMap<String,String>> entry: dataMapKey.entrySet()){
-			String s=entry.getKey();
-			json= new JSONObject();
-			HashMap<String,String> jsonHm=dataMapKey.get(s);
-			for(Map.Entry<String,String> entryMap:jsonHm.entrySet()){
-				String key=entryMap.getKey();
-				json.put(key, jsonHm.get(key));
-			}
-			mainObject.put(s,json);
-		}	
-		Iterator<String> keysItr = mainObject.keys();
-		while(keysItr.hasNext()) {
-			String key = keysItr.next();
-			String value = mainObject.get(key).toString();
-			retmap.put(key, value);
-		}
-		
-		logger.info("#############################################################################");
-		logger.info(mainObject);
-		logger.info("###############################################################################");	
-	}
-	LinkedHashMap<String,String> parseDataNodes(LinkedHashMap<String,String> map){
-		LinkedHashMap<String,String> dataMapForJson=new LinkedHashMap <>(); 
-		matchableValues = new HashMap <>(); 
-		for(String uniqueDataKey: uniqueDataKeys){
-			if(uniqueDataKey.contains("%")){
-				String[] uniqueDataKeySplit= uniqueDataKey.split("%");
-				String findType=DATATYPE+uniqueDataKeySplit[0]+PROPERTIES+uniqueDataKeySplit[1]+TYPE;
-				String typeValue=map.get(findType);
-				logger.info(typeValue);
-				
-				String findRequired=DATATYPE+uniqueDataKeySplit[0]+PROPERTIES+uniqueDataKeySplit[1]+REQUIRED;
-				String requiredValue= map.get(findRequired);
-				
-				String matchable =DATATYPE+uniqueDataKeySplit[0]+PROPERTIES+uniqueDataKeySplit[1]+MATCHABLE;
-
-				String matchableValue= map.get(matchable);
-
-				if(matchableValue != null && matchableValue.equalsIgnoreCase("true")){
-					if(uniqueDataKey.contains("%")){
-						String[] keys= uniqueDataKey.split("%");
-						String key=keys[keys.length -1];
-						matchableValues.put(key, MATCHINGTRUE);
-					}else{
-						matchableValues.put(uniqueDataKey, MATCHINGTRUE);
-					}
-				}
-					
-				if(requiredValue == null || requiredValue.isEmpty()){
-					requiredValue = "false";
-				}
-				if(typeValue != null && (typeValue.equalsIgnoreCase(STRING)||
-						typeValue.equalsIgnoreCase(INTEGER))){
-					
-					String findDefault=DATATYPE+uniqueDataKeySplit[0]+PROPERTIES+uniqueDataKeySplit[1]+DEFAULT;
-					String defaultValue= map.get(findDefault);
-					logger.info("defaultValue is:"+ defaultValue);
-					logger.info("requiredValue is:"+ requiredValue);
-					
-					StringBuilder attributeIndividualStringBuilder= new StringBuilder();
-					attributeIndividualStringBuilder.append(typeValue+DEFAULTVALUE);
-					attributeIndividualStringBuilder.append(defaultValue+REQUIREDVALUE);
-					attributeIndividualStringBuilder.append(requiredValue+MANYFALSE);
-					dataMapForJson.put(uniqueDataKey, attributeIndividualStringBuilder.toString());		
-				}
-				else if(LIST.equalsIgnoreCase(typeValue) || MAP.equalsIgnoreCase(typeValue)){
-					logger.info("requiredValue is:"+ requiredValue);
-					String findList= DATATYPE+uniqueDataKeySplit[0]+PROPERTIES+uniqueDataKeySplit[1]+".entry_schema.type";
-					String listValue=map.get(findList);
-					if(listValue!=null){
-						logger.info("Type of list is:"+ listValue);
-						//Its userdefined
-						if(listValue.contains(".")){
-							String trimValue=listValue.substring(listValue.lastIndexOf('.')+1);
-							StringBuilder referenceIndividualStringBuilder= new StringBuilder();
-							referenceIndividualStringBuilder.append(trimValue+REQUIREDVALUE);
-							referenceIndividualStringBuilder.append(requiredValue+MANYTRUE);
-							dataMapForJson.put(uniqueDataKey, referenceIndividualStringBuilder.toString());
-						}//Its string
-						else{
-							StringBuilder stringListItems= new StringBuilder();
-							if(LIST.equalsIgnoreCase(typeValue)){
-							    stringListItems.append(uniqueDataKeySplit[1].toUpperCase()+REQUIREDVALUE+requiredValue +MANYFALSE);
-							}else if( MAP.equalsIgnoreCase(typeValue)){
-								stringListItems.append(uniqueDataKeySplit[1].toUpperCase()+REQUIREDVALUE+requiredValue +MANYTRUE);
-							}
-							dataMapForJson.put(uniqueDataKey, stringListItems.toString());
-							boolean isConstraintsFound = false;
-							for(int i=0;i<10;i++){
-								String findConstraints= DATATYPE+uniqueDataKeySplit[0]+PROPERTIES+uniqueDataKeySplit[1]+".entry_schema.constraints.0.valid_values."+i;
-								logger.info("findConstraints => " + findConstraints);
-								String constraintsValue=map.get(findConstraints);
-								logger.info("constraintsValue => " + constraintsValue);
-
-								if((constraintsValue==null || constraintsValue.isEmpty()) && i==0){ //if no constraints at all ( index i as 0 can tell this )									
-									isConstraintsFound = false;
-									//if type is list but no constraints
-									String newValue = dataMapForJson.get(uniqueDataKey).replace("MANY-false", "MANY-true");	
-									newValue = newValue.replace(uniqueDataKeySplit[1].toUpperCase()+":", "");	
-									dataMapForJson.put(uniqueDataKey, newValue);
-									break;
-								} else{
-									isConstraintsFound = true;
-									if(i == 0){ // only need to add one time for the same attribute
-									   dataListBuffer.append(uniqueDataKeySplit[1].toUpperCase()+"=[");
-									}
-									
-									if(constraintsValue==null){
-										constraintsValue = "";
-									}else if (constraintsValue.contains("=")) {
-										constraintsValue = constraintsValue.replace("=", "equal-sign");
-									}
-
-									dataConstraints.add(constraintsValue);									
-									dataListBuffer.append(constraintsValue+",");
-								}
-							}
-							if(isConstraintsFound){							
-							    dataListBuffer.append("]#");
-							}
-						}
-					}else{
-						logger.info("entry_schema.type is not defined correctly");
-					}
-				}
-				else{
-					String findUserDefined=DATATYPE+uniqueDataKeySplit[0]+"."+"properties"+"."+uniqueDataKeySplit[1]+TYPE;
-					String userDefinedValue=map.get(findUserDefined);
-					String trimValue=userDefinedValue.substring(userDefinedValue.lastIndexOf('.')+1);
-					StringBuilder referenceIndividualStringBuilder= new StringBuilder();
-					referenceIndividualStringBuilder.append(trimValue+REQUIREDVALUE);
-					referenceIndividualStringBuilder.append(requiredValue+MANYFALSE);
-					dataMapForJson.put(uniqueDataKey, referenceIndividualStringBuilder.toString());
-					
-				}
-			}
-		}
-		
-		return dataMapForJson;
-	}
-	
-	
-	LinkedHashMap<String, LinkedHashMap<String, String>> parsePolicyNodes(Map<String,String> map) throws ParserException{
-		LinkedHashMap<String,LinkedHashMap<String,String>> mapKey= new LinkedHashMap <>();
-		for(String uniqueKey: uniqueKeys){
-			LinkedHashMap<String,String> hm;
-
-			for(Map.Entry<String,String> entry:map.entrySet()){
-				String key=entry.getKey();
-				if(key.contains(uniqueKey) && key.contains("policy.nodes")){
-					if(mapKey.containsKey(uniqueKey)){
-						hm = mapKey.get(uniqueKey);
-						String keyStr= key.substring(key.lastIndexOf('.')+1);
-						String valueStr= map.get(key);
-						if("type".equalsIgnoreCase(keyStr) && ((key.contains("entry_schema.0.type") || key.contains("entry_schema.type") && valueStr.contains("policy.data.")))){
-						   throw new ParserException("For using user defined object type, Please make sure no space between 'type:' and object " + valueStr );
-							
-						}	
-						if("type".equals(keyStr)){
-							if(!key.contains("entry_schema"))
-							{
-								hm.put(keyStr,valueStr);
-							}
-						}else{
-							hm.put(keyStr,valueStr);
-						}
-
-					} else {
-						hm = new LinkedHashMap <>();
-						String keyStr= key.substring(key.lastIndexOf('.')+1);
-						String valueStr= map.get(key);
-						if(key.contains(".objective.")){							
-							throw new ParserException("Attribute objective is a key word. Please use a different name");
-						}
-						if(("type").equals(keyStr)){
-							if(!key.contains("entry_schema"))
-							{
-								hm.put(keyStr,valueStr);
-							}
-						}else{
-							hm.put(keyStr,valueStr);
-						}
-						mapKey.put(uniqueKey, hm);
-					}
-				}
-			}
-		}
-		return mapKey;
-	}
-
-	void createAttributes(LinkedHashMap<String,LinkedHashMap<String,String>> mapKey){
-		StringBuilder attributeStringBuilder= new StringBuilder();
-		StringBuilder referenceStringBuilder= new StringBuilder();
-		StringBuilder listBuffer= new StringBuilder();
-		List<String> constraints= new ArrayList<>();
-		for(Map.Entry<String,LinkedHashMap<String,String>> entry: mapKey.entrySet()){
-			String keySetString= entry.getKey();
-			LinkedHashMap<String,String> keyValues=mapKey.get(keySetString);
-			if(STRING.equalsIgnoreCase(keyValues.get("type"))|| 
-					INTEGER.equalsIgnoreCase(keyValues.get("type"))){
-				StringBuilder attributeIndividualStringBuilder= new StringBuilder();
-				attributeIndividualStringBuilder.append(keySetString+"=");
-				attributeIndividualStringBuilder.append(keyValues.get("type")+DEFAULTVALUE);
-				attributeIndividualStringBuilder.append(keyValues.get("default")+REQUIREDVALUE);
-				attributeIndividualStringBuilder.append(keyValues.get("required")+MANYFALSE);
-				attributeStringBuilder.append(attributeIndividualStringBuilder+",");	
-                if("true".equalsIgnoreCase(keyValues.get(MATCHABLEKEY))){
-				    matchableValues.put(keySetString, MATCHINGTRUE);
+            if(map != null){
+                if(map.get("error") != null){
+                    return map.get("error");
                 }
-			}
-			else if(LIST.equalsIgnoreCase(keyValues.get("type"))){
-				
+            }
+
+            parseDataAndPolicyNodes(map);
+
+            LinkedHashMap<String,String> dataMapForJson=parseDataNodes(map);
+
+            constructJsonForDataFields(dataMapForJson);
+
+            LinkedHashMap<String,LinkedHashMap<String,String>> mapKey= parsePolicyNodes(map);
+
+            createAttributes(mapKey);
+
+        } catch (IOException e) {
+            logger.error(e);
+        }catch(ParserException e){
+            logger.error(e);
+            return e.getMessage();
+        }
+
+        return null;
+    }
+
+    @SuppressWarnings("unchecked")
+    public LinkedHashMap<String, String> load(String fileName) throws IOException,ParserException {
+        File newConfiguration = new File(fileName);
+        StringBuilder orderInfo = new StringBuilder("[");
+        Yaml yaml = new Yaml();
+        LinkedHashMap<Object, Object> yamlMap = null;
+        try(InputStream is = new FileInputStream(newConfiguration)){
+            yamlMap = (LinkedHashMap<Object, Object>) yaml.load(is);
+        } catch (FileNotFoundException e) {
+            logger.error(e);
+        }catch(Exception e){
+            throw new ParserException("Invalid TOSCA Model format. Please make sure it is a valid YAML file");
+        }
+
+        StringBuilder sb = new StringBuilder();
+        LinkedHashMap<String, String> settings = new LinkedHashMap<>();
+        if (yamlMap == null) {
+            return settings;
+        }
+
+        String message = validations(yamlMap);
+
+        if(message != null){
+            settings.put("error", message);
+            return settings;
+        }
+
+        findNode(yamlMap);
+
+        orderedElements.stream().forEach((string) -> {
+            orderInfo.append(string);
+            orderInfo.append(",");
+            logger.info("Content: " + string);
+        });
+
+        orderInfo.append("]");
+
+        dataOrderInfo = orderInfo.toString();
+        dataOrderInfo = dataOrderInfo.replace(",]", "]");
+
+        logger.info("dataOrderInfo :" + dataOrderInfo);
+
+        List<String> path = new ArrayList <>();
+        serializeMap(settings, sb, path, yamlMap);
+        return settings;
+    }
+
+    @SuppressWarnings("unchecked")
+    private String validations(@SuppressWarnings("rawtypes") LinkedHashMap yamlMap){
+
+        boolean isNoteTypeFound = false;
+        boolean isDataTypeFound = false;
+        boolean isToscaVersionKeyFound = false;
+        boolean isToscaVersionValueFound = false;
+        @SuppressWarnings("rawtypes")
+        Map m1 = new HashMap();
+        short order =0;
+        if(yamlMap != null){
+            // Get a set of the entries
+             @SuppressWarnings("rawtypes")
+            Set set = yamlMap.entrySet();
+             // Get an iterator
+             @SuppressWarnings("rawtypes")
+            Iterator i = set.iterator();
+              // Display elements
+             while(i.hasNext()) {
+                 @SuppressWarnings("rawtypes")
+                 Entry me = (Entry)i.next();
+
+                 if("tosca_definitions_version".equals(me.getKey())){
+                     isToscaVersionKeyFound = true;
+                     order++;
+                     m1.put("tosca_definitions_version", order);
+                 }
+
+                 if("tosca_simple_yaml_1_0_0".equals(me.getValue())){
+                     isToscaVersionValueFound = true;
+                 }
+
+                 if("node_types".equals(me.getKey())){
+                     isNoteTypeFound = true;
+                     order++;
+                     m1.put("node_types", order);
+                 }
+
+                 if("data_types".equals(me.getKey())){
+                     isDataTypeFound = true;
+                     order++;
+                     m1.put("data_types", order);
+                 }
+
+             }
+
+
+             if(!isDataTypeFound){
+                 return "data_types are missing or invalid.";
+             }
+
+             if(!isToscaVersionKeyFound || !isToscaVersionValueFound){
+                 return "tosca_definitions_version is missing or invalid.";
+             }
+
+             if(!isNoteTypeFound){
+                 return "node_types are missing or invalid.";
+             }
+
+             short version = (short) m1.get("tosca_definitions_version");
+
+             if(version > 1 ){
+                return "tosca_definitions_version should be defined first.";
+             }
+
+             short data = (short) m1.get("data_types");
+             short node = (short) m1.get("node_types");
+             if(node > data){
+                return "node_types should be defined before data_types.";
+             }
+
+        }
+
+        return null;
+    }
+
+    @SuppressWarnings({ "unchecked", "rawtypes" })
+    private void serializeMap(LinkedHashMap<String, String> settings, StringBuilder sb, List<String> path, Map<Object, Object> yamlMap) {
+        for (Entry<Object, Object> entry : yamlMap.entrySet()) {
+
+            if (entry.getValue() instanceof Map) {
+                path.add((String) entry.getKey());
+                serializeMap(settings, sb, path, (Map<Object, Object>) entry.getValue());
+                path.remove(path.size() - 1);
+            } else if (entry.getValue() instanceof List) {
+                path.add((String) entry.getKey());
+                serializeList(settings, sb, path, (List) entry.getValue());
+                path.remove(path.size() - 1);
+            } else {
+                serializeValue(settings, sb, path, (String) entry.getKey(), entry.getValue());
+            }
+        }
+    }
+
+    @SuppressWarnings("unchecked")
+    private void serializeList(LinkedHashMap<String, String> settings, StringBuilder sb, List<String> path, List<String> yamlList) {
+        int counter = 0;
+        for (Object listEle : yamlList) {
+            if (listEle instanceof Map) {
+                path.add(Integer.toString(counter));
+                serializeMap(settings, sb, path, (Map<Object, Object>) listEle);
+                path.remove(path.size() - 1);
+            } else if (listEle instanceof List) {
+                path.add(Integer.toString(counter));
+                serializeList(settings, sb, path, (List<String>) listEle);
+                path.remove(path.size() - 1);
+            } else {
+                serializeValue(settings, sb, path, Integer.toString(counter), listEle);
+            }
+            counter++;
+        }
+    }
+
+    private void serializeValue(LinkedHashMap<String, String> settings, StringBuilder sb, List<String> path, String name, Object value) {
+        if (value == null) {
+            return;
+        }
+        sb.setLength(0);
+        for (String pathEle : path) {
+            sb.append(pathEle).append('.');
+        }
+        sb.append(name);
+        settings.put(sb.toString(), value.toString());
+    }
+
+
+    void parseDataAndPolicyNodes(LinkedHashMap<String,String> map){
+        for(String key:map.keySet()){
+            if(key.contains("policy.nodes.Root"))
+            {
+                continue;
+            }
+            else if(key.contains("policy.nodes")){
+                String wordToFind = "policy.nodes.";
+                int indexForPolicyNode=key.indexOf(wordToFind);
+                String subNodeString= key.substring(indexForPolicyNode+13, key.length());
+
+                stringBetweenDots(subNodeString);
+            }
+            else if(key.contains("policy.data")){
+                String wordToFind="policy.data.";
+                int indexForPolicyNode=key.indexOf(wordToFind);
+                String subNodeString= key.substring(indexForPolicyNode+12, key.length());
+
+                stringBetweenDotsForDataFields(subNodeString);
+            }
+        }
+    }
+
+    // Second index of dot should be returned.
+    public int stringBetweenDots(String str){
+        String stringToSearch=str;
+        String[]ss=stringToSearch.split("\\.");
+        if(ss!=null){
+            int len= ss.length;
+            if(len>2){
+                uniqueKeys.add(ss[2]);
+            }
+        }
+
+        return uniqueKeys.size();
+    }
+
+
+    public void stringBetweenDotsForDataFields(String str){
+        String stringToSearch=str;
+        String[]ss=stringToSearch.split("\\.");
+        if(ss!=null){
+            int len= ss.length;
+
+            if(len>2){
+                uniqueDataKeys.add(ss[0]+"%"+ss[2]);
+            }
+        }
+    }
+
+    void constructJsonForDataFields(LinkedHashMap<String,String> dataMapForJson){
+        LinkedHashMap<String,LinkedHashMap<String,String>> dataMapKey= new LinkedHashMap <>();
+        LinkedHashMap<String, String> hmSub;
+        for(Entry<String, String> entry: dataMapForJson.entrySet()){
+            String uniqueDataKey= entry.getKey();
+            String[] uniqueDataKeySplit=uniqueDataKey.split("%");
+            String value= dataMapForJson.get(uniqueDataKey);
+            if(dataMapKey.containsKey(uniqueDataKeySplit[0])){
+                hmSub = dataMapKey.get(uniqueDataKeySplit[0]);
+                hmSub.put(uniqueDataKeySplit[1], value);
+            }
+            else{
+                hmSub=new LinkedHashMap <>();
+                hmSub.put(uniqueDataKeySplit[1], value);
+            }
+
+            dataMapKey.put(uniqueDataKeySplit[0], hmSub);
+        }
+
+        JSONObject mainObject= new JSONObject();
+        JSONObject json;
+        for(Entry<String,LinkedHashMap<String,String>> entry: dataMapKey.entrySet()){
+            String s=entry.getKey();
+            json= new JSONObject();
+            HashMap<String,String> jsonHm=dataMapKey.get(s);
+            for(Entry<String,String> entryMap:jsonHm.entrySet()){
+                String key=entryMap.getKey();
+                json.put(key, jsonHm.get(key));
+            }
+            mainObject.put(s,json);
+        }
+        Iterator<String> keysItr = mainObject.keys();
+        while(keysItr.hasNext()) {
+            String key = keysItr.next();
+            String value = mainObject.get(key).toString();
+            retmap.put(key, value);
+        }
+
+        logger.info("#############################################################################");
+        logger.info(mainObject);
+        logger.info("###############################################################################");
+    }
+    LinkedHashMap<String,String> parseDataNodes(LinkedHashMap<String,String> map){
+        LinkedHashMap<String,String> dataMapForJson=new LinkedHashMap <>();
+        matchableValues = new HashMap <>();
+        for(String uniqueDataKey: uniqueDataKeys){
+            if(uniqueDataKey.contains("%")){
+                String[] uniqueDataKeySplit= uniqueDataKey.split("%");
+                String findType=DATATYPE+uniqueDataKeySplit[0]+PROPERTIES+uniqueDataKeySplit[1]+TYPE;
+                String typeValue=map.get(findType);
+                logger.info(typeValue);
+
+                String findRequired=DATATYPE+uniqueDataKeySplit[0]+PROPERTIES+uniqueDataKeySplit[1]+REQUIRED;
+                String requiredValue= map.get(findRequired);
+
+                String matchable =DATATYPE+uniqueDataKeySplit[0]+PROPERTIES+uniqueDataKeySplit[1]+MATCHABLE;
+
+                String matchableValue= map.get(matchable);
+
+                if(matchableValue != null && matchableValue.equalsIgnoreCase("true")){
+                    if(uniqueDataKey.contains("%")){
+                        String[] keys= uniqueDataKey.split("%");
+                        String key=keys[keys.length -1];
+                        matchableValues.put(key, MATCHINGTRUE);
+                    }else{
+                        matchableValues.put(uniqueDataKey, MATCHINGTRUE);
+                    }
+                }
+
+                if(requiredValue == null || requiredValue.isEmpty()){
+                    requiredValue = "false";
+                }
+                if(typeValue != null && (typeValue.equalsIgnoreCase(STRING)||
+                        typeValue.equalsIgnoreCase(INTEGER))){
+
+                    String findDefault=DATATYPE+uniqueDataKeySplit[0]+PROPERTIES+uniqueDataKeySplit[1]+DEFAULT;
+                    String defaultValue= map.get(findDefault);
+                    logger.info("defaultValue is:"+ defaultValue);
+                    logger.info("requiredValue is:"+ requiredValue);
+
+                    StringBuilder attributeIndividualStringBuilder= new StringBuilder();
+                    attributeIndividualStringBuilder.append(typeValue+DEFAULTVALUE);
+                    attributeIndividualStringBuilder.append(defaultValue+REQUIREDVALUE);
+                    attributeIndividualStringBuilder.append(requiredValue+MANYFALSE);
+                    dataMapForJson.put(uniqueDataKey, attributeIndividualStringBuilder.toString());
+                }
+                else if(LIST.equalsIgnoreCase(typeValue) || MAP.equalsIgnoreCase(typeValue)){
+                    logger.info("requiredValue is:"+ requiredValue);
+                    String findList= DATATYPE+uniqueDataKeySplit[0]+PROPERTIES+uniqueDataKeySplit[1]+".entry_schema.type";
+                    String listValue=map.get(findList);
+                    if(listValue!=null){
+                        logger.info("Type of list is:"+ listValue);
+                        //Its userdefined
+                        if(listValue.contains(".")){
+                            String trimValue=listValue.substring(listValue.lastIndexOf('.')+1);
+                            StringBuilder referenceIndividualStringBuilder= new StringBuilder();
+                            referenceIndividualStringBuilder.append(trimValue+REQUIREDVALUE);
+                            referenceIndividualStringBuilder.append(requiredValue+MANYTRUE);
+                            dataMapForJson.put(uniqueDataKey, referenceIndividualStringBuilder.toString());
+                        }//Its string
+                        else{
+                            StringBuilder stringListItems= new StringBuilder();
+                            if(LIST.equalsIgnoreCase(typeValue)){
+                                stringListItems.append(uniqueDataKeySplit[1].toUpperCase()+REQUIREDVALUE+requiredValue +MANYFALSE);
+                            }else if( MAP.equalsIgnoreCase(typeValue)){
+                                stringListItems.append(uniqueDataKeySplit[1].toUpperCase()+REQUIREDVALUE+requiredValue +MANYTRUE);
+                            }
+                            dataMapForJson.put(uniqueDataKey, stringListItems.toString());
+                            boolean isConstraintsFound = false;
+                            for(int i=0;i<10;i++){
+                                String findConstraints= DATATYPE+uniqueDataKeySplit[0]+PROPERTIES+uniqueDataKeySplit[1]+".entry_schema.constraints.0.valid_values."+i;
+                                logger.info("findConstraints => " + findConstraints);
+                                String constraintsValue=map.get(findConstraints);
+                                logger.info("constraintsValue => " + constraintsValue);
+
+                                if((constraintsValue==null || constraintsValue.isEmpty()) && i==0){ //if no constraints at all ( index i as 0 can tell this )
+                                    isConstraintsFound = false;
+                                    //if type is list but no constraints
+                                    String newValue = dataMapForJson.get(uniqueDataKey).replace("MANY-false", "MANY-true");
+                                    newValue = newValue.replace(uniqueDataKeySplit[1].toUpperCase()+":", "");
+                                    dataMapForJson.put(uniqueDataKey, newValue);
+                                    break;
+                                } else{
+                                    isConstraintsFound = true;
+                                    if(i == 0){ // only need to add one time for the same attribute
+                                       dataListBuffer.append(uniqueDataKeySplit[1].toUpperCase()+"=[");
+                                    }
+
+                                    if(constraintsValue==null){
+                                        constraintsValue = "";
+                                    }else if (constraintsValue.contains("=")) {
+                                        constraintsValue = constraintsValue.replace("=", "equal-sign");
+                                    }
+
+                                    dataConstraints.add(constraintsValue);
+                                    dataListBuffer.append(constraintsValue+",");
+                                }
+                            }
+                            if(isConstraintsFound){
+                                dataListBuffer.append("]#");
+                            }
+                        }
+                    }else{
+                        logger.info("entry_schema.type is not defined correctly");
+                    }
+                }
+                else{
+                    String findUserDefined=DATATYPE+uniqueDataKeySplit[0]+"."+"properties"+"."+uniqueDataKeySplit[1]+TYPE;
+                    String userDefinedValue=map.get(findUserDefined);
+                    String trimValue=userDefinedValue.substring(userDefinedValue.lastIndexOf('.')+1);
+                    StringBuilder referenceIndividualStringBuilder= new StringBuilder();
+                    referenceIndividualStringBuilder.append(trimValue+REQUIREDVALUE);
+                    referenceIndividualStringBuilder.append(requiredValue+MANYFALSE);
+                    dataMapForJson.put(uniqueDataKey, referenceIndividualStringBuilder.toString());
+
+                }
+            }
+        }
+
+        return dataMapForJson;
+    }
+
+
+    LinkedHashMap<String, LinkedHashMap<String, String>> parsePolicyNodes(Map<String,String> map) throws ParserException{
+        LinkedHashMap<String,LinkedHashMap<String,String>> mapKey= new LinkedHashMap <>();
+        for(String uniqueKey: uniqueKeys){
+            LinkedHashMap<String,String> hm;
+
+            for(Entry<String,String> entry:map.entrySet()){
+                String key=entry.getKey();
+                if(key.contains(uniqueKey) && key.contains("policy.nodes")){
+                    if(mapKey.containsKey(uniqueKey)){
+                        hm = mapKey.get(uniqueKey);
+                        String keyStr= key.substring(key.lastIndexOf('.')+1);
+                        String valueStr= map.get(key);
+                        if("type".equalsIgnoreCase(keyStr) && ((key.contains("entry_schema.0.type") || key.contains("entry_schema.type") && valueStr.contains("policy.data.")))){
+                           throw new ParserException("For using user defined object type, Please make sure no space between 'type:' and object " + valueStr );
+
+                        }
+                        if("type".equals(keyStr)){
+                            if(!key.contains("entry_schema"))
+                            {
+                                hm.put(keyStr,valueStr);
+                            }
+                        }else{
+                            hm.put(keyStr,valueStr);
+                        }
+
+                    } else {
+                        hm = new LinkedHashMap <>();
+                        String keyStr= key.substring(key.lastIndexOf('.')+1);
+                        String valueStr= map.get(key);
+                        if(key.contains(".objective.")){
+                            throw new ParserException("Attribute objective is a key word. Please use a different name");
+                        }
+                        if(("type").equals(keyStr)){
+                            if(!key.contains("entry_schema"))
+                            {
+                                hm.put(keyStr,valueStr);
+                            }
+                        }else{
+                            hm.put(keyStr,valueStr);
+                        }
+                        mapKey.put(uniqueKey, hm);
+                    }
+                }
+            }
+        }
+        return mapKey;
+    }
+
+    void createAttributes(LinkedHashMap<String,LinkedHashMap<String,String>> mapKey){
+        StringBuilder attributeStringBuilder= new StringBuilder();
+        StringBuilder referenceStringBuilder= new StringBuilder();
+        StringBuilder listBuffer= new StringBuilder();
+        List<String> constraints= new ArrayList<>();
+        for(Entry<String,LinkedHashMap<String,String>> entry: mapKey.entrySet()){
+            String keySetString= entry.getKey();
+            LinkedHashMap<String,String> keyValues=mapKey.get(keySetString);
+            if(STRING.equalsIgnoreCase(keyValues.get("type"))||
+                    INTEGER.equalsIgnoreCase(keyValues.get("type"))){
+                StringBuilder attributeIndividualStringBuilder= new StringBuilder();
+                attributeIndividualStringBuilder.append(keySetString+"=");
+                attributeIndividualStringBuilder.append(keyValues.get("type")+DEFAULTVALUE);
+                attributeIndividualStringBuilder.append(keyValues.get("default")+REQUIREDVALUE);
+                attributeIndividualStringBuilder.append(keyValues.get("required")+MANYFALSE);
+                attributeStringBuilder.append(attributeIndividualStringBuilder+",");
+                if("true".equalsIgnoreCase(keyValues.get(MATCHABLEKEY))){
+                    matchableValues.put(keySetString, MATCHINGTRUE);
+                }
+            }
+            else if(LIST.equalsIgnoreCase(keyValues.get("type"))){
+
                 if(("true").equalsIgnoreCase(keyValues.get(MATCHABLEKEY))){
-				    matchableValues.put(keySetString, MATCHINGTRUE);
+                    matchableValues.put(keySetString, MATCHINGTRUE);
                 }
-				//List Datatype
-				Set<String> keys= keyValues.keySet();
-				Iterator<String> itr=keys.iterator();
-				boolean isDefinedType = false;
-				while(itr.hasNext()){
-					String key= itr.next();
-					if((!("type").equals(key) ||("required").equals(key)))
-					{
-						String value= keyValues.get(key);
-						//The "." in the value determines if its a string or a user defined type.  
-						if (!value.contains(".")){
-							//This is string
-							if(StringUtils.isNumeric(key) ){  //only integer key for the value of Constrains 
-							    constraints.add(keyValues.get(key));
-							}
-						}else{
-							//This is user defined type
-							String trimValue=value.substring(value.lastIndexOf('.')+1);
-							StringBuilder referenceIndividualStringBuilder= new StringBuilder();
-							referenceIndividualStringBuilder.append(keySetString+"="+trimValue+MANYTRUE);
-							referenceStringBuilder.append(referenceIndividualStringBuilder+",");
-							isDefinedType = true;
-						}
-					}				
+                //List Datatype
+                Set<String> keys= keyValues.keySet();
+                Iterator<String> itr=keys.iterator();
+                boolean isDefinedType = false;
+                while(itr.hasNext()){
+                    String key= itr.next();
+                    if((!("type").equals(key) ||("required").equals(key)))
+                    {
+                        String value= keyValues.get(key);
+                        //The "." in the value determines if its a string or a user defined type.
+                        if (!value.contains(".")){
+                            //This is string
+                            if(StringUtils.isNumeric(key) ){  //only integer key for the value of Constrains
+                                constraints.add(keyValues.get(key));
+                            }
+                        }else{
+                            //This is user defined type
+                            String trimValue=value.substring(value.lastIndexOf('.')+1);
+                            StringBuilder referenceIndividualStringBuilder= new StringBuilder();
+                            referenceIndividualStringBuilder.append(keySetString+"="+trimValue+MANYTRUE);
+                            referenceStringBuilder.append(referenceIndividualStringBuilder+",");
+                            isDefinedType = true;
+                        }
+                    }
 
-				}
+                }
 
-				if(!isDefinedType && LIST.equalsIgnoreCase(keyValues.get("type"))){ //type is not user defined and is a list but no constraints defined.
-					if(constraints == null || constraints.isEmpty()){
-						referenceStringBuilder.append(keySetString+"=MANY-true"+",");
-					}
-				}
-			}else{
-				//User defined Datatype.
+                if(!isDefinedType && LIST.equalsIgnoreCase(keyValues.get("type"))){ //type is not user defined and is a list but no constraints defined.
+                    if(constraints == null || constraints.isEmpty()){
+                        referenceStringBuilder.append(keySetString+"=MANY-true"+",");
+                    }
+                }
+            }else{
+                //User defined Datatype.
                 if("true".equalsIgnoreCase(keyValues.get(MATCHABLEKEY))){
-				    matchableValues.put(keySetString, MATCHINGTRUE);
+                    matchableValues.put(keySetString, MATCHINGTRUE);
                 }
-				String value=keyValues.get("type");
-				if(value != null && !value.isEmpty()){
-					String trimValue=value.substring(value.lastIndexOf('.')+1);
-					StringBuilder referenceIndividualStringBuilder= new StringBuilder();
-					referenceIndividualStringBuilder.append(keySetString+"="+trimValue+MANYFALSE);
-					referenceStringBuilder.append(referenceIndividualStringBuilder+",");
-				}else{
-					logger.info("keyValues.get(type) is null/empty");
-				}
+                String value=keyValues.get("type");
+                if(value != null && !value.isEmpty()){
+                    String trimValue=value.substring(value.lastIndexOf('.')+1);
+                    StringBuilder referenceIndividualStringBuilder= new StringBuilder();
+                    referenceIndividualStringBuilder.append(keySetString+"="+trimValue+MANYFALSE);
+                    referenceStringBuilder.append(referenceIndividualStringBuilder+",");
+                }else{
+                    logger.info("keyValues.get(type) is null/empty");
+                }
 
-			}
-			if(constraints!=null && !constraints.isEmpty()){
-				//List handling. 
-				listBuffer.append(keySetString.toUpperCase()+"=[");
-				for(String str:constraints){
-					listBuffer.append(str+",");
-				}
-				listBuffer.append("]#");
-				logger.info(listBuffer);
+            }
+            if(constraints!=null && !constraints.isEmpty()){
+                //List handling.
+                listBuffer.append(keySetString.toUpperCase()+"=[");
+                for(String str:constraints){
+                    listBuffer.append(str+",");
+                }
+                listBuffer.append("]#");
+                logger.info(listBuffer);
 
 
-				StringBuilder referenceIndividualStringBuilder= new StringBuilder();
-				referenceIndividualStringBuilder.append(keySetString+"="+keySetString.toUpperCase()+MANYFALSE);
-				referenceStringBuilder.append(referenceIndividualStringBuilder+",");
-				constraints.clear();
-			}
-		}
-		
-		dataListBuffer.append(listBuffer);
-		
+                StringBuilder referenceIndividualStringBuilder= new StringBuilder();
+                referenceIndividualStringBuilder.append(keySetString+"="+keySetString.toUpperCase()+MANYFALSE);
+                referenceStringBuilder.append(referenceIndividualStringBuilder+",");
+                constraints.clear();
+            }
+        }
 
-		logger.info("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$");
-		logger.info("Whole attribute String is:"+attributeStringBuilder);	
-		logger.info("Whole reference String is:"+referenceStringBuilder);
-		logger.info("List String is:"+listBuffer);
-		logger.info("Data list buffer is:"+dataListBuffer);
-		logger.info("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$");
-		
-		this.listConstraints=dataListBuffer.toString();
-		this.referenceAttributes=referenceStringBuilder.toString();
-		this.attributeString=attributeStringBuilder.toString();
-	}
-	
-	@SuppressWarnings("unchecked")
-	public void findNode(LinkedHashMap<Object, Object> map) {
-		
-		map.forEach((key,value) -> {
-			// if the value is properties and its type is map object, then save all the keys
-			if(key.equals("properties") && value instanceof Map){
-				saveNodes((LinkedHashMap<?, ?>)value);
-			}
-			
-			if(!key.equals("policy.nodes.Root") && value instanceof Map){
-				//value is a Map object, then make a recursive call
-			    findNode((LinkedHashMap<Object, Object>) value);   
-			}
-		});
+        dataListBuffer.append(listBuffer);
 
-	}
-	
-	public void saveNodes(LinkedHashMap<?, ?> map) {
-		
-		map.forEach((key,value) -> {
-			
-		    orderedElements.add((String)key);
-	    
-		});
 
-	}
-	
-	public String getAttributeString() {
-		return attributeString;
-	}
-	public void setAttributeString(String attributeString) {
-		this.attributeString = attributeString;
-	}
-	
-	public LinkedHashMap<String, Object> getRetmap() {
-		return retmap;
-	}
+        logger.info("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$");
+        logger.info("Whole attribute String is:"+attributeStringBuilder);
+        logger.info("Whole reference String is:"+referenceStringBuilder);
+        logger.info("List String is:"+listBuffer);
+        logger.info("Data list buffer is:"+dataListBuffer);
+        logger.info("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$");
 
-	public void setRetmap(LinkedHashMap<String, Object> retmap) {
-		this.retmap = retmap;
-	}
-	public Map<String, String> getMatchableValues() {
-		return matchableValues;
-	}
+        this.listConstraints=dataListBuffer.toString();
+        this.referenceAttributes=referenceStringBuilder.toString();
+        this.attributeString=attributeStringBuilder.toString();
+    }
 
-	public void setMatchableValues(Map<String, String> matchableValues) {
-		this.matchableValues = matchableValues;
-	}
-	public String getReferenceAttributes() {
-		return referenceAttributes;
-	}
+    @SuppressWarnings("unchecked")
+    public void findNode(LinkedHashMap<Object, Object> map) {
 
-	public void setReferenceAttributes(String referenceAttributes) {
-		this.referenceAttributes = referenceAttributes;
-	}
-	public String getListConstraints() {
-		return listConstraints;
-	}
+        map.forEach((key,value) -> {
+            // if the value is properties and its type is map object, then save all the keys
+            if(key.equals("properties") && value instanceof Map){
+                saveNodes((LinkedHashMap<?, ?>)value);
+            }
 
-	public void setListConstraints(String listConstraints) {
-		this.listConstraints = listConstraints;
-	}
-	public String getDataOrderInfo() {
-		return dataOrderInfo;
-	}
+            if(!key.equals("policy.nodes.Root") && value instanceof Map){
+                //value is a Map object, then make a recursive call
+                findNode((LinkedHashMap<Object, Object>) value);
+            }
+        });
 
-	public void setDataOrderInfo(String dataOrderInfo) {
-		this.dataOrderInfo = dataOrderInfo;
-	}
+    }
+
+    public void saveNodes(LinkedHashMap<?, ?> map) {
+
+        map.forEach((key,value) -> {
+
+            orderedElements.add((String)key);
+
+        });
+
+    }
+
+    public String getAttributeString() {
+        return attributeString;
+    }
+    public void setAttributeString(String attributeString) {
+        this.attributeString = attributeString;
+    }
+
+    public LinkedHashMap<String, Object> getRetmap() {
+        return retmap;
+    }
+
+    public void setRetmap(LinkedHashMap<String, Object> retmap) {
+        this.retmap = retmap;
+    }
+    public Map<String, String> getMatchableValues() {
+        return matchableValues;
+    }
+
+    public void setMatchableValues(Map<String, String> matchableValues) {
+        this.matchableValues = matchableValues;
+    }
+    public String getReferenceAttributes() {
+        return referenceAttributes;
+    }
+
+    public void setReferenceAttributes(String referenceAttributes) {
+        this.referenceAttributes = referenceAttributes;
+    }
+    public String getListConstraints() {
+        return listConstraints;
+    }
+
+    public void setListConstraints(String listConstraints) {
+        this.listConstraints = listConstraints;
+    }
+    public String getDataOrderInfo() {
+        return dataOrderInfo;
+    }
+
+    public void setDataOrderInfo(String dataOrderInfo) {
+        this.dataOrderInfo = dataOrderInfo;
+    }
 
 }
\ No newline at end of file
diff --git a/ONAP-REST/src/main/java/org/onap/policy/rest/util/PolicyValidation.java b/ONAP-REST/src/main/java/org/onap/policy/rest/util/PolicyValidation.java
index 50985b1..0478f5f 100644
--- a/ONAP-REST/src/main/java/org/onap/policy/rest/util/PolicyValidation.java
+++ b/ONAP-REST/src/main/java/org/onap/policy/rest/util/PolicyValidation.java
@@ -940,20 +940,25 @@
 								responseString.append("Guard Params <b>Time Units</b> is Required" + HTML_ITALICS_LNBREAK);
 								valid = false;
 							}
-						}else if("GUARD_BL_YAML".equals(policyData.getRuleProvider())){
-							if(policyData.getYamlparams().getBlackList()==null || policyData.getYamlparams().getBlackList().isEmpty()){
-								responseString.append(" Guard Params <b>BlackList</b> is Required " + HTML_ITALICS_LNBREAK);
-								valid = false;
-							}else{
-								for(String blackList: policyData.getYamlparams().getBlackList()){
-									if(blackList==null || !(SUCCESS.equals(PolicyUtils.policySpecialCharValidator(blackList)))){
-										responseString.append(" Guard Params <b>BlackList</b> Should be valid String" + HTML_ITALICS_LNBREAK);
-										valid = false;
-										break;
-									}
-								}
-							}
-						}
+						} else if ("GUARD_BL_YAML".equals(policyData.getRuleProvider())
+                                && "Use Manual Entry".equals(policyData.getBlackListEntryType())) {
+                            if (policyData.getYamlparams().getBlackList() == null
+                                    || policyData.getYamlparams().getBlackList().isEmpty()) {
+                                responseString
+                                        .append(" Guard Params <b>BlackList</b> is Required " + HTML_ITALICS_LNBREAK);
+                                valid = false;
+                            } else {
+                                for (String blackList : policyData.getYamlparams().getBlackList()) {
+                                    if (blackList == null
+                                            || !(SUCCESS.equals(PolicyUtils.policySpecialCharValidator(blackList)))) {
+                                        responseString.append(" Guard Params <b>BlackList</b> Should be valid String"
+                                                + HTML_ITALICS_LNBREAK);
+                                        valid = false;
+                                        break;
+                                    }
+                                }
+                            }
+                        }
 					}
 				}
 			}
diff --git a/ONAP-REST/src/test/java/org/onap/policy/rest/adapter/ReturnBlackListTest.java b/ONAP-REST/src/test/java/org/onap/policy/rest/adapter/ReturnBlackListTest.java
new file mode 100644
index 0000000..e8f6684
--- /dev/null
+++ b/ONAP-REST/src/test/java/org/onap/policy/rest/adapter/ReturnBlackListTest.java
@@ -0,0 +1,41 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP Policy Engine
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.rest.adapter;
+
+import static org.junit.Assert.assertTrue;
+
+import org.junit.Test;
+
+public class ReturnBlackListTest {
+
+    @Test
+    public void testReturnBlackList() {
+        ReturnBlackList list = new ReturnBlackList();
+        list.setActionValue(1);
+        list.setEntryCheck(true);
+        list.setEntryValue("Test");
+
+        assertTrue(1 == list.getActionValue());
+        assertTrue(list.isEntryCheck());
+        assertTrue("Test".equals(list.getEntryValue()));
+    }
+
+}
diff --git a/ONAP-XACML/src/main/java/org/onap/policy/xacml/util/XACMLPolicyWriter.java b/ONAP-XACML/src/main/java/org/onap/policy/xacml/util/XACMLPolicyWriter.java
index 168bc54..9281659 100644
--- a/ONAP-XACML/src/main/java/org/onap/policy/xacml/util/XACMLPolicyWriter.java
+++ b/ONAP-XACML/src/main/java/org/onap/policy/xacml/util/XACMLPolicyWriter.java
@@ -3,6 +3,7 @@
  * ONAP-XACML
  * ================================================================================
  * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Modified Copyright (C) 2018 Samsung Electronics Co., Ltd.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -61,266 +62,266 @@
  */
 public class XACMLPolicyWriter {
 
-	/**
-	 * Helper static class that does the work to write a policy set to a file on disk.
-	 * 
-	 *
-	 */
-	public static Path writePolicyFile(Path filename, PolicySetType policySet) {
-		JAXBElement<PolicySetType> policySetElement = new ObjectFactory().createPolicySet(policySet);		
-		try {
-			JAXBContext context = JAXBContext.newInstance(PolicySetType.class);
-			Marshaller m = context.createMarshaller();
-			m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
-			m.marshal(policySetElement, filename.toFile());
+    /**
+     * Helper static class that does the work to write a policy set to a file on disk.
+     *
+     *
+     */
+    public static Path writePolicyFile(Path filename, PolicySetType policySet) {
+        JAXBElement<PolicySetType> policySetElement = new ObjectFactory().createPolicySet(policySet);
+        try {
+            JAXBContext context = JAXBContext.newInstance(PolicySetType.class);
+            Marshaller m = context.createMarshaller();
+            m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
+            m.marshal(policySetElement, filename.toFile());
 
-			if (Files.exists(filename)) {
-				return filename;
-			} else {
-				PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE + "File does not exist after marshalling.");
-				return null;
-			}
+            if (Files.exists(filename)) {
+                return filename;
+            } else {
+                PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE + "File does not exist after marshalling.");
+                return null;
+            }
 
-		} catch (JAXBException e) {
-			PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, e, "XACMLPolicyWriter", "writePolicyFile failed");
-			return null;
-		}
-	}
+        } catch (JAXBException e) {
+            PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, e, "XACMLPolicyWriter", "writePolicyFile failed");
+            return null;
+        }
+    }
 
-	/**
-	 * Helper static class that does the work to write a policy set to an output stream.
-	 * 
-	 *
-	 */
-	public static void writePolicyFile(OutputStream os, PolicySetType policySet) {
-		JAXBElement<PolicySetType> policySetElement = new ObjectFactory().createPolicySet(policySet);
-		try {
-			JAXBContext context = JAXBContext.newInstance(PolicySetType.class);
-			Marshaller m = context.createMarshaller();
-			m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
-			m.marshal(policySetElement, os);
-		} catch (JAXBException e) {
-			PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, e, "XACMLPolicyWriter", "writePolicyFile failed");
-		}
-	}
+    /**
+     * Helper static class that does the work to write a policy set to an output stream.
+     *
+     *
+     */
+    public static void writePolicyFile(OutputStream os, PolicySetType policySet) {
+        JAXBElement<PolicySetType> policySetElement = new ObjectFactory().createPolicySet(policySet);
+        try {
+            JAXBContext context = JAXBContext.newInstance(PolicySetType.class);
+            Marshaller m = context.createMarshaller();
+            m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
+            m.marshal(policySetElement, os);
+        } catch (JAXBException e) {
+            PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, e, "XACMLPolicyWriter", "writePolicyFile failed");
+        }
+    }
 
-	/**
-	 * Helper static class that does the work to write a policy to a file on disk.
-	 * 
-	 *
-	 */
-	public static Path writePolicyFile(Path filename, PolicyType policy) {
-		JAXBElement<PolicyType> policyElement = new ObjectFactory().createPolicy(policy);		
-		try {
-			JAXBContext context = JAXBContext.newInstance(PolicyType.class);
-			Marshaller m = context.createMarshaller();
-			m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
-			m.marshal(policyElement, filename.toFile());
+    /**
+     * Helper static class that does the work to write a policy to a file on disk.
+     *
+     *
+     */
+    public static Path writePolicyFile(Path filename, PolicyType policy) {
+        JAXBElement<PolicyType> policyElement = new ObjectFactory().createPolicy(policy);
+        try {
+            JAXBContext context = JAXBContext.newInstance(PolicyType.class);
+            Marshaller m = context.createMarshaller();
+            m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
+            m.marshal(policyElement, filename.toFile());
 
-			if (Files.exists(filename)) {
-				return filename;
-			} else {
-				PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE + "File does not exist after marshalling.");
-				return null;
-			}
+            if (Files.exists(filename)) {
+                return filename;
+            } else {
+                PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE + "File does not exist after marshalling.");
+                return null;
+            }
 
-		} catch (JAXBException e) {
-			PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, e, "XACMLPolicyWriter", "writePolicyFile failed");
-			return null;
-		}		
-	}
+        } catch (JAXBException e) {
+            PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, e, "XACMLPolicyWriter", "writePolicyFile failed");
+            return null;
+        }
+    }
 
 
-	/**
-	 * Helper static class that does the work to write a policy to a file on disk.
-	 * 
-	 *
-	 */
-	public static InputStream getXmlAsInputStream(PolicyType policy) {
-		JAXBElement<PolicyType> policyElement = new ObjectFactory().createPolicy(policy);		
-		try {
-			ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();			
-			JAXBContext context = JAXBContext.newInstance(PolicyType.class);
-			Marshaller m = context.createMarshaller();
-			m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
-			m.marshal(policyElement, byteArrayOutputStream);
-			return new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
-		} catch (JAXBException e) {
-			PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, e, "XACMLPolicyWriter", "writePolicyFile failed");
-			return null;
-		}		
-	}
-	/**
-	 * Helper static class that does the work to write a policy set to an output stream.
-	 * 
-	 *
-	 */
-	public static void writePolicyFile(OutputStream os, PolicyType policy) {
-		JAXBElement<PolicyType> policySetElement = new ObjectFactory().createPolicy(policy);		
-		try {
-			JAXBContext context = JAXBContext.newInstance(PolicyType.class);
-			Marshaller m = context.createMarshaller();
-			m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
-			m.marshal(policySetElement, os);
-		} catch (JAXBException e) {
-			PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, e, "XACMLPolicyWriter", "writePolicyFile failed");
-		}
-	}
-	
-	@SuppressWarnings({ "unchecked", "rawtypes" })
-	public static String changeFileNameInXmlWhenRenamePolicy(Path filename) {
+    /**
+     * Helper static class that does the work to write a policy to a file on disk.
+     *
+     *
+     */
+    public static InputStream getXmlAsInputStream(PolicyType policy) {
+        JAXBElement<PolicyType> policyElement = new ObjectFactory().createPolicy(policy);
+        try {
+            ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
+            JAXBContext context = JAXBContext.newInstance(PolicyType.class);
+            Marshaller m = context.createMarshaller();
+            m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
+            m.marshal(policyElement, byteArrayOutputStream);
+            return new ByteArrayInputStream(byteArrayOutputStream.toByteArray());
+        } catch (JAXBException e) {
+            PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, e, "XACMLPolicyWriter", "writePolicyFile failed");
+            throw new IllegalArgumentException("XACMLPolicyWriter writePolicyFile failed", e);
+        }
+    }
+    /**
+     * Helper static class that does the work to write a policy set to an output stream.
+     *
+     *
+     */
+    public static void writePolicyFile(OutputStream os, PolicyType policy) {
+        JAXBElement<PolicyType> policySetElement = new ObjectFactory().createPolicy(policy);
+        try {
+            JAXBContext context = JAXBContext.newInstance(PolicyType.class);
+            Marshaller m = context.createMarshaller();
+            m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE);
+            m.marshal(policySetElement, os);
+        } catch (JAXBException e) {
+            PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, e, "XACMLPolicyWriter", "writePolicyFile failed");
+        }
+    }
 
-		String extension = "";
-		String domain = null;
-		String repository = "repository";
-		if(filename.toString().contains("Config_")){
-			domain = filename.toString().substring(filename.toString().indexOf(repository) + (repository.length()+1), filename.toString().indexOf("Config_"));		
-		}else if(filename.toString().contains("Action_")){
-			domain = filename.toString().substring(filename.toString().indexOf(repository) + (repository.length()+1), filename.toString().indexOf("Action_"));
-		}else if(filename.toString().contains("Decision_")){
-			domain = filename.toString().substring(filename.toString().indexOf(repository) + (repository.length()+1), filename.toString().indexOf("Decision_"));
-		}
-		if(domain.contains(File.separator)){
-			domain =	domain.replace(File.separator, ".");
-		}
-		try {
-			JAXBContext context = JAXBContext.newInstance(PolicyType.class);
-			Unmarshaller m = context.createUnmarshaller();
-			JAXBElement<PolicyType> policyElement = (JAXBElement<PolicyType>) m.unmarshal(filename.toFile());
-			PolicyType policyType = policyElement.getValue();
-			if (policyType != null) {
-				TargetType targetType = policyType.getTarget();
-				List<AnyOfType> anyOfTypes = targetType.getAnyOf();
-				for( Iterator anyOfIte = anyOfTypes.iterator(); anyOfIte.hasNext(); ){
-					AnyOfType anyOfType = (AnyOfType) anyOfIte.next();
-					List<AllOfType> allOf = anyOfType.getAllOf();
-					for( Iterator allOfIte = allOf.iterator(); allOfIte.hasNext(); ){
-						AllOfType allOfType = (AllOfType) allOfIte.next();
-						List<MatchType> match = allOfType.getMatch();						
-						for( Iterator matchIte = match.iterator(); matchIte.hasNext();) {							
-							MatchType  matchType = (MatchType) matchIte.next();
-							if("PolicyName".equals(matchType.getAttributeDesignator().getAttributeId())){
-								AttributeValueType attributeValueType = matchType.getAttributeValue();
-								List<Object> contents = attributeValueType.getContent();
-								if (contents != null && !contents.isEmpty()) {
-									String tmp = filename.getFileName()+"";
-									String newName = tmp.substring(0, tmp.lastIndexOf("."));
-									attributeValueType.getContent().clear();
-									attributeValueType.getContent().add(domain + newName  + "." + "xml");
-								}	
-							}
-						}
-					}
-				}
-				if(filename.toString().contains("Config_") || filename.toString().contains("Action_")){	
-					List<Object> objects = policyType.getCombinerParametersOrRuleCombinerParametersOrVariableDefinition();
-					if (objects != null && !objects.isEmpty()) {
-						for (Iterator ite = objects.iterator(); ite.hasNext();) {
+    @SuppressWarnings({ "unchecked", "rawtypes" })
+    public static String changeFileNameInXmlWhenRenamePolicy(Path filename) {
 
-							RuleType  ruleType = (RuleType ) ite.next();
-							AdviceExpressionsType adviceExpressionsType = ruleType.getAdviceExpressions();
-							if (adviceExpressionsType != null) {
-								List<AdviceExpressionType> adviceExpressionTypes = adviceExpressionsType.getAdviceExpression();
-								if (adviceExpressionTypes != null && !adviceExpressionTypes.isEmpty()) {
-									for (Iterator iterator = adviceExpressionTypes
-											.iterator(); iterator.hasNext();) {
-										AdviceExpressionType adviceExpressionType = (AdviceExpressionType) iterator
-												.next();
-										if (adviceExpressionType.getAdviceId() != null && !"".equals(adviceExpressionType.getAdviceId()) && ("configID".equals(adviceExpressionType.getAdviceId())
-												|| "faultID".equals(adviceExpressionType.getAdviceId()) || "PMID".equals(adviceExpressionType.getAdviceId())||"firewallConfigID".equals(adviceExpressionType.getAdviceId()) || "OptimizationID".equals(adviceExpressionType.getAdviceId())
-												|| "MSID".equals(adviceExpressionType.getAdviceId())) || "GocID".equals(adviceExpressionType.getAdviceId())||"GocHPID".equals(adviceExpressionType.getAdviceId())||"BRMSRAWID".equals(adviceExpressionType.getAdviceId())
-												|| "BRMSPARAMID".equals(adviceExpressionType.getAdviceId())|| "HPSuppID".equals(adviceExpressionType.getAdviceId()) || "HPFlapID".equals(adviceExpressionType.getAdviceId()) || "HPOverID".equals(adviceExpressionType.getAdviceId()))
-										{
-											List<AttributeAssignmentExpressionType> attributeAssignmentExpressionTypes = adviceExpressionType.getAttributeAssignmentExpression();
-											if (attributeAssignmentExpressionTypes != null && !attributeAssignmentExpressionTypes.isEmpty()) {
-												for (Iterator iterator2 = attributeAssignmentExpressionTypes
-														.iterator(); iterator2.hasNext();) {
-													AttributeAssignmentExpressionType attributeAssignmentExpressionType = (AttributeAssignmentExpressionType) iterator2
-															.next();
-													if ("URLID".equals(attributeAssignmentExpressionType.getAttributeId())) {
-														JAXBElement<AttributeValueType> attributeValueType = (JAXBElement<AttributeValueType>) attributeAssignmentExpressionType.getExpression();
-														AttributeValueType attributeValueType1 = attributeValueType.getValue();
-														String configUrl = "$URL";
-														String urlVal = (String) attributeValueType1.getContent().get(0);   
-														String origExtension = urlVal.substring(urlVal.lastIndexOf('.')+1).trim();
-														extension = origExtension;
-														attributeValueType1.getContent().clear();
-														String txtFileName = filename.getFileName().toString();
-														txtFileName = txtFileName.substring(0, txtFileName.lastIndexOf(".")+1) + origExtension;
-														txtFileName = configUrl+ File.separator + "Config" + File.separator + domain + txtFileName;
-														attributeValueType1.getContent().add(txtFileName);	
-													} else if ("PolicyName".equals(attributeAssignmentExpressionType.getAttributeId())) {
-														JAXBElement<AttributeValueType> attributeValueType = (JAXBElement<AttributeValueType>) attributeAssignmentExpressionType.getExpression();
-														AttributeValueType attributeValueType1 = attributeValueType.getValue();
-														List<Object> contents = attributeValueType1.getContent();
-														if (contents != null && !contents.isEmpty()) {
-															String tmp = filename.getFileName()+"";
-															String newName = tmp.substring(0, tmp.lastIndexOf("."));
-															attributeValueType1.getContent().clear();
-															attributeValueType1.getContent().add(domain + newName + "." + "xml");
-														}										
+        String extension = "";
+        String domain = null;
+        String repository = "repository";
+        if(filename.toString().contains("Config_")){
+            domain = filename.toString().substring(filename.toString().indexOf(repository) + (repository.length()+1), filename.toString().indexOf("Config_"));
+        }else if(filename.toString().contains("Action_")){
+            domain = filename.toString().substring(filename.toString().indexOf(repository) + (repository.length()+1), filename.toString().indexOf("Action_"));
+        }else if(filename.toString().contains("Decision_")){
+            domain = filename.toString().substring(filename.toString().indexOf(repository) + (repository.length()+1), filename.toString().indexOf("Decision_"));
+        }
+        if(domain.contains(File.separator)){
+            domain =	domain.replace(File.separator, ".");
+        }
+        try {
+            JAXBContext context = JAXBContext.newInstance(PolicyType.class);
+            Unmarshaller m = context.createUnmarshaller();
+            JAXBElement<PolicyType> policyElement = (JAXBElement<PolicyType>) m.unmarshal(filename.toFile());
+            PolicyType policyType = policyElement.getValue();
+            if (policyType != null) {
+                TargetType targetType = policyType.getTarget();
+                List<AnyOfType> anyOfTypes = targetType.getAnyOf();
+                for( Iterator anyOfIte = anyOfTypes.iterator(); anyOfIte.hasNext(); ){
+                    AnyOfType anyOfType = (AnyOfType) anyOfIte.next();
+                    List<AllOfType> allOf = anyOfType.getAllOf();
+                    for( Iterator allOfIte = allOf.iterator(); allOfIte.hasNext(); ){
+                        AllOfType allOfType = (AllOfType) allOfIte.next();
+                        List<MatchType> match = allOfType.getMatch();
+                        for( Iterator matchIte = match.iterator(); matchIte.hasNext();) {
+                            MatchType  matchType = (MatchType) matchIte.next();
+                            if("PolicyName".equals(matchType.getAttributeDesignator().getAttributeId())){
+                                AttributeValueType attributeValueType = matchType.getAttributeValue();
+                                List<Object> contents = attributeValueType.getContent();
+                                if (contents != null && !contents.isEmpty()) {
+                                    String tmp = filename.getFileName()+"";
+                                    String newName = tmp.substring(0, tmp.lastIndexOf("."));
+                                    attributeValueType.getContent().clear();
+                                    attributeValueType.getContent().add(domain + newName  + "." + "xml");
+                                }
+                            }
+                        }
+                    }
+                }
+                if(filename.toString().contains("Config_") || filename.toString().contains("Action_")){
+                    List<Object> objects = policyType.getCombinerParametersOrRuleCombinerParametersOrVariableDefinition();
+                    if (objects != null && !objects.isEmpty()) {
+                        for (Iterator ite = objects.iterator(); ite.hasNext();) {
 
-													}
+                            RuleType  ruleType = (RuleType ) ite.next();
+                            AdviceExpressionsType adviceExpressionsType = ruleType.getAdviceExpressions();
+                            if (adviceExpressionsType != null) {
+                                List<AdviceExpressionType> adviceExpressionTypes = adviceExpressionsType.getAdviceExpression();
+                                if (adviceExpressionTypes != null && !adviceExpressionTypes.isEmpty()) {
+                                    for (Iterator iterator = adviceExpressionTypes
+                                            .iterator(); iterator.hasNext();) {
+                                        AdviceExpressionType adviceExpressionType = (AdviceExpressionType) iterator
+                                                .next();
+                                        if (adviceExpressionType.getAdviceId() != null && !"".equals(adviceExpressionType.getAdviceId()) && ("configID".equals(adviceExpressionType.getAdviceId())
+                                                || "faultID".equals(adviceExpressionType.getAdviceId()) || "PMID".equals(adviceExpressionType.getAdviceId())||"firewallConfigID".equals(adviceExpressionType.getAdviceId()) || "OptimizationID".equals(adviceExpressionType.getAdviceId())
+                                                || "MSID".equals(adviceExpressionType.getAdviceId())) || "GocID".equals(adviceExpressionType.getAdviceId())||"GocHPID".equals(adviceExpressionType.getAdviceId())||"BRMSRAWID".equals(adviceExpressionType.getAdviceId())
+                                                || "BRMSPARAMID".equals(adviceExpressionType.getAdviceId())|| "HPSuppID".equals(adviceExpressionType.getAdviceId()) || "HPFlapID".equals(adviceExpressionType.getAdviceId()) || "HPOverID".equals(adviceExpressionType.getAdviceId()))
+                                        {
+                                            List<AttributeAssignmentExpressionType> attributeAssignmentExpressionTypes = adviceExpressionType.getAttributeAssignmentExpression();
+                                            if (attributeAssignmentExpressionTypes != null && !attributeAssignmentExpressionTypes.isEmpty()) {
+                                                for (Iterator iterator2 = attributeAssignmentExpressionTypes
+                                                        .iterator(); iterator2.hasNext();) {
+                                                    AttributeAssignmentExpressionType attributeAssignmentExpressionType = (AttributeAssignmentExpressionType) iterator2
+                                                            .next();
+                                                    if ("URLID".equals(attributeAssignmentExpressionType.getAttributeId())) {
+                                                        JAXBElement<AttributeValueType> attributeValueType = (JAXBElement<AttributeValueType>) attributeAssignmentExpressionType.getExpression();
+                                                        AttributeValueType attributeValueType1 = attributeValueType.getValue();
+                                                        String configUrl = "$URL";
+                                                        String urlVal = (String) attributeValueType1.getContent().get(0);
+                                                        String origExtension = urlVal.substring(urlVal.lastIndexOf('.')+1).trim();
+                                                        extension = origExtension;
+                                                        attributeValueType1.getContent().clear();
+                                                        String txtFileName = filename.getFileName().toString();
+                                                        txtFileName = txtFileName.substring(0, txtFileName.lastIndexOf(".")+1) + origExtension;
+                                                        txtFileName = configUrl+ File.separator + "Config" + File.separator + domain + txtFileName;
+                                                        attributeValueType1.getContent().add(txtFileName);
+                                                    } else if ("PolicyName".equals(attributeAssignmentExpressionType.getAttributeId())) {
+                                                        JAXBElement<AttributeValueType> attributeValueType = (JAXBElement<AttributeValueType>) attributeAssignmentExpressionType.getExpression();
+                                                        AttributeValueType attributeValueType1 = attributeValueType.getValue();
+                                                        List<Object> contents = attributeValueType1.getContent();
+                                                        if (contents != null && !contents.isEmpty()) {
+                                                            String tmp = filename.getFileName()+"";
+                                                            String newName = tmp.substring(0, tmp.lastIndexOf("."));
+                                                            attributeValueType1.getContent().clear();
+                                                            attributeValueType1.getContent().add(domain + newName + "." + "xml");
+                                                        }
 
-												}
-											}
-										}
-									}
-								}
-							}
-						}
-						if (objects != null && !objects.isEmpty()) {
-							for (Iterator ite1 = objects.iterator(); ite1.hasNext();) {
+                                                    }
 
-								RuleType  ruleType1 = (RuleType ) ite1.next();
-								ObligationExpressionsType obligationExpressionsType = ruleType1.getObligationExpressions();
-								if (obligationExpressionsType != null) {
-									List<ObligationExpressionType> obligationExpressionType = obligationExpressionsType.getObligationExpression();
-									if (obligationExpressionType != null && !obligationExpressionType.isEmpty()) {
-										for (Iterator iterator = obligationExpressionType
-												.iterator(); iterator.hasNext();) {
-											ObligationExpressionType obligationExpressionTypes = (ObligationExpressionType) iterator
-													.next();
-											if (obligationExpressionTypes.getObligationId() != null && !"".equals(obligationExpressionTypes.getObligationId())) {
-												List<AttributeAssignmentExpressionType> attributeAssignmentExpressionTypes = obligationExpressionTypes.getAttributeAssignmentExpression();
-												if (attributeAssignmentExpressionTypes != null && !attributeAssignmentExpressionTypes.isEmpty()) {
-													for (Iterator iterator2 = attributeAssignmentExpressionTypes
-															.iterator(); iterator2.hasNext();) {
-														AttributeAssignmentExpressionType attributeAssignmentExpressionType = (AttributeAssignmentExpressionType) iterator2
-																.next();
-														if ("body".equals(attributeAssignmentExpressionType.getAttributeId())) {
-															JAXBElement<AttributeValueType> attributeValueType = (JAXBElement<AttributeValueType>) attributeAssignmentExpressionType.getExpression();
-															AttributeValueType attributeValueType1 = attributeValueType.getValue();
-															String configUrl = "$URL";
-															String urlVal = (String) attributeValueType1.getContent().get(0);    	
-															String origExtension = urlVal.substring(urlVal.lastIndexOf('.')+1).trim();
-															extension = "json";
-															attributeValueType1.getContent().clear();
-															String txtFileName = filename.getFileName().toString();
-															txtFileName = txtFileName.substring(0, txtFileName.lastIndexOf(".")+1) + origExtension;
-															txtFileName = configUrl+ File.separator + "Action" + File.separator + domain + txtFileName;
-															attributeValueType1.getContent().add(txtFileName);	
-														} 
+                                                }
+                                            }
+                                        }
+                                    }
+                                }
+                            }
+                        }
+                        if (objects != null && !objects.isEmpty()) {
+                            for (Iterator ite1 = objects.iterator(); ite1.hasNext();) {
 
-													}
-												}
+                                RuleType  ruleType1 = (RuleType ) ite1.next();
+                                ObligationExpressionsType obligationExpressionsType = ruleType1.getObligationExpressions();
+                                if (obligationExpressionsType != null) {
+                                    List<ObligationExpressionType> obligationExpressionType = obligationExpressionsType.getObligationExpression();
+                                    if (obligationExpressionType != null && !obligationExpressionType.isEmpty()) {
+                                        for (Iterator iterator = obligationExpressionType
+                                                .iterator(); iterator.hasNext();) {
+                                            ObligationExpressionType obligationExpressionTypes = (ObligationExpressionType) iterator
+                                                    .next();
+                                            if (obligationExpressionTypes.getObligationId() != null && !"".equals(obligationExpressionTypes.getObligationId())) {
+                                                List<AttributeAssignmentExpressionType> attributeAssignmentExpressionTypes = obligationExpressionTypes.getAttributeAssignmentExpression();
+                                                if (attributeAssignmentExpressionTypes != null && !attributeAssignmentExpressionTypes.isEmpty()) {
+                                                    for (Iterator iterator2 = attributeAssignmentExpressionTypes
+                                                            .iterator(); iterator2.hasNext();) {
+                                                        AttributeAssignmentExpressionType attributeAssignmentExpressionType = (AttributeAssignmentExpressionType) iterator2
+                                                                .next();
+                                                        if ("body".equals(attributeAssignmentExpressionType.getAttributeId())) {
+                                                            JAXBElement<AttributeValueType> attributeValueType = (JAXBElement<AttributeValueType>) attributeAssignmentExpressionType.getExpression();
+                                                            AttributeValueType attributeValueType1 = attributeValueType.getValue();
+                                                            String configUrl = "$URL";
+                                                            String urlVal = (String) attributeValueType1.getContent().get(0);
+                                                            String origExtension = urlVal.substring(urlVal.lastIndexOf('.')+1).trim();
+                                                            extension = "json";
+                                                            attributeValueType1.getContent().clear();
+                                                            String txtFileName = filename.getFileName().toString();
+                                                            txtFileName = txtFileName.substring(0, txtFileName.lastIndexOf(".")+1) + origExtension;
+                                                            txtFileName = configUrl+ File.separator + "Action" + File.separator + domain + txtFileName;
+                                                            attributeValueType1.getContent().add(txtFileName);
+                                                        }
 
-											}
+                                                    }
+                                                }
 
-										}
-									}
-								}
-							}
-						}
-					}
-				}
-				writePolicyFile(filename, policyType);
-			}
-		}catch (JAXBException e) {
-			PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, e, "XACMLPolicyWriter", "writePolicyFile failed");
-		}	
+                                            }
 
-		return extension;
-	}
+                                        }
+                                    }
+                                }
+                            }
+                        }
+                    }
+                }
+                writePolicyFile(filename, policyType);
+            }
+        }catch (JAXBException e) {
+            PolicyLogger.error(MessageCodes.ERROR_DATA_ISSUE, e, "XACMLPolicyWriter", "writePolicyFile failed");
+        }
+
+        return extension;
+    }
 
 }
diff --git a/POLICY-SDK-APP/pom.xml b/POLICY-SDK-APP/pom.xml
index 7017017..1160a8f 100644
--- a/POLICY-SDK-APP/pom.xml
+++ b/POLICY-SDK-APP/pom.xml
@@ -182,6 +182,11 @@
 			<artifactId>jackson-dataformat-xml</artifactId>
 			<version>${jackson.version}</version>
 		</dependency>
+		<dependency>
+			<groupId>com.google.code.gson</groupId>
+			<artifactId>gson</artifactId>
+			<version>2.8.0</version>
+		</dependency>
 		<!-- Elastic Search -->
 		<dependency>
 			<groupId>org.elasticsearch</groupId>
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/CheckPDP.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/CheckPDP.java
index 6433204..8349fab 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/CheckPDP.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/CheckPDP.java
@@ -3,6 +3,7 @@
  * ONAP Policy Engine
  * ================================================================================
  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Modified Copyright (C) 2018 Samsung Electronics Co., Ltd.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -57,149 +58,147 @@
  *
  */
 public class CheckPDP {
-	private static Path pdpPath = null;
-	private static Long oldModified = null;
-	private static HashMap<String, String> pdpMap = null;
-	private static final Logger LOGGER = FlexLogger.getLogger(CheckPDP.class);
-	
-	private CheckPDP(){
-		//default constructor
-	}
-	
-	public static Map<String, String> getPdpMap() {
-		return pdpMap;
-	}
-	
-	private static void reset() {
-		pdpPath = null;
-		oldModified = null;
-		pdpMap = null;
-	}
+    private static Path pdpPath = null;
+    private static Long oldModified = null;
+    private static HashMap<String, String> pdpMap = null;
+    private static final Logger LOGGER = FlexLogger.getLogger(CheckPDP.class);
 
-	public static boolean validateID(String id) {
-		// ReadFile
-		try {
-			readFile();
-		} catch (Exception e) {
-			LOGGER.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + e);
-			return false;
-		}
-		if (pdpMap == null) {
-			return false;
-		}
-		// Check ID
-		return pdpMap.containsKey(id);
-	}
+    private CheckPDP(){
+        //default constructor
+    }
 
-	private static void readFile(){
-		String pdpFile = null;
-		try{
-			pdpFile = XACMLProperties.getProperty(XACMLRestProperties.PROP_PDP_IDFILE);	
-		}catch (Exception e){
-			LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "Cannot read the PDP ID File" + e);
-			return;
-		}
-		if (pdpFile == null) {
-			LOGGER.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + "PDP File name not Valid : " + pdpFile);
-		}
-		if (pdpPath == null) {
-			pdpPath = Paths.get(pdpFile);
-			if (!pdpPath.toString().endsWith(".properties") || !pdpPath.toFile().exists()) {
-				LOGGER.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + "File doesn't exist in the specified Path : "	+ pdpPath.toString());
-				CheckPDP.reset();
-				return;
-			}
-			readProps();
-		}
-		// Check if File is updated recently
-		else {
-			Long newModified = pdpPath.toFile().lastModified();
-			if (!newModified.equals(oldModified)) {
-				// File has been updated.
-				readProps();
-			}
-		}
-	}
+    public static Map<String, String> getPdpMap() {
+        return pdpMap;
+    }
 
-	@SuppressWarnings({ "unchecked", "rawtypes" })
-	private static void readProps() {
-		Properties pdpProp;
-		pdpProp = new Properties();
-		try {
-			InputStream in = new FileInputStream(pdpPath.toFile());
-			oldModified = pdpPath.toFile().lastModified();
-			pdpProp.load(in);
-			// Read the Properties and Load the PDPs and encoding.
-			pdpMap = new HashMap<>();
-			// Check the Keys for PDP_URLs
-			Collection<Object> unsorted = pdpProp.keySet();
-			List<String> sorted = new ArrayList(unsorted);
-			Collections.sort(sorted);
-			for (String propKey : sorted) {
-				loadPDPProperties(propKey, pdpProp);
-			}
-			in.close();
-		} catch (IOException e) {
-			LOGGER.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + e);
-		}
-		if (pdpMap == null || pdpMap.isEmpty()) {
-			LOGGER.debug(XACMLErrorConstants.ERROR_SYSTEM_ERROR + "Cannot Proceed without PDP_URLs");
-			CheckPDP.reset();
-		}
-	}
-	
-	private static void loadPDPProperties(String propKey, Properties pdpProp){
-		if (propKey.startsWith("PDP_URL")) {
-			String checkVal = pdpProp.getProperty(propKey);
-			if (checkVal == null) {
-				LOGGER.error("Properties file doesn't have the PDP_URL parameter");
-			}
-			if (checkVal != null && checkVal.contains(";")) {
-				List<String> pdpDefault = new ArrayList<>(Arrays.asList(checkVal.split("\\s*;\\s*")));
-				int pdpCount = 0;
-				while (pdpCount < pdpDefault.size()) {
-					String pdpVal = pdpDefault.get(pdpCount);
-					readPDPParam(pdpVal);
-					pdpCount++;
-				}
-			}
-		}
-	}
+    private static void reset() {
+        pdpPath = null;
+        oldModified = null;
+        pdpMap = null;
+    }
 
-	private static void readPDPParam(String pdpVal){
-		if(pdpVal.contains(",")){
-			List<String> pdpValues = new ArrayList<>(Arrays.asList(pdpVal.split("\\s*,\\s*")));
-			if(pdpValues.size()==3){
-				// 1:2 will be UserID:Password
-				String userID = pdpValues.get(1);
-				String pass = pdpValues.get(2);
-				Base64.Encoder encoder = Base64.getEncoder();
-				// 0 - PDPURL
-				pdpMap.put(pdpValues.get(0), encoder.encodeToString((userID+":"+pass).getBytes(StandardCharsets.UTF_8)));
-			}else{
-				LOGGER.error(XACMLErrorConstants.ERROR_PERMISSIONS + "No Credentials to send Request: " + pdpValues);
-			}
-		}else{
-			LOGGER.error(XACMLErrorConstants.ERROR_PERMISSIONS + "No Credentials to send Request: " + pdpVal);
-		}
-	}
-	
-	public static String getEncoding(String pdpID){
-		try {
-			readFile();
-		} catch (Exception e) {
-			LOGGER.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + e);
-		}
-		String encoding = null;
-		if(pdpMap!=null && (!pdpMap.isEmpty())){
-			try{
-				encoding = pdpMap.get(pdpID);
-			} catch(Exception e){
-				LOGGER.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + e);
-			}
-			return encoding;
-		}else{
-			return null;
-		}
-	}
+    public static boolean validateID(String id) {
+        // ReadFile
+        try {
+            readFile();
+        } catch (Exception e) {
+            LOGGER.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + e);
+            return false;
+        }
+        if (pdpMap == null) {
+            return false;
+        }
+        // Check ID
+        return pdpMap.containsKey(id);
+    }
+
+    private static void readFile(){
+        String pdpFile = null;
+        try{
+            pdpFile = XACMLProperties.getProperty(XACMLRestProperties.PROP_PDP_IDFILE);
+        }catch (Exception e){
+            LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "Cannot read the PDP ID File" + e);
+            return;
+        }
+        if (pdpFile == null) {
+            LOGGER.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + "PDP File name not Valid : " + pdpFile);
+        }
+        if (pdpPath == null) {
+            pdpPath = Paths.get(pdpFile);
+            if (!pdpPath.toString().endsWith(".properties") || !pdpPath.toFile().exists()) {
+                LOGGER.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + "File doesn't exist in the specified Path : "	+ pdpPath.toString());
+                CheckPDP.reset();
+                return;
+            }
+            readProps();
+        }
+        // Check if File is updated recently
+        else {
+            Long newModified = pdpPath.toFile().lastModified();
+            if (!newModified.equals(oldModified)) {
+                // File has been updated.
+                readProps();
+            }
+        }
+    }
+
+    @SuppressWarnings({ "unchecked", "rawtypes" })
+    private static void readProps() {
+        Properties pdpProp;
+        pdpProp = new Properties();
+        try(InputStream in = new FileInputStream(pdpPath.toFile())) {
+            oldModified = pdpPath.toFile().lastModified();
+            pdpProp.load(in);
+            // Read the Properties and Load the PDPs and encoding.
+            pdpMap = new HashMap<>();
+            // Check the Keys for PDP_URLs
+            Collection<Object> unsorted = pdpProp.keySet();
+            List<String> sorted = new ArrayList(unsorted);
+            Collections.sort(sorted);
+            for (String propKey : sorted) {
+                loadPDPProperties(propKey, pdpProp);
+            }
+        } catch (IOException e) {
+            LOGGER.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + e);
+        }
+        if (pdpMap == null || pdpMap.isEmpty()) {
+            LOGGER.debug(XACMLErrorConstants.ERROR_SYSTEM_ERROR + "Cannot Proceed without PDP_URLs");
+            CheckPDP.reset();
+        }
+    }
+
+    private static void loadPDPProperties(String propKey, Properties pdpProp){
+        if (propKey.startsWith("PDP_URL")) {
+            String checkVal = pdpProp.getProperty(propKey);
+            if (checkVal == null) {
+                LOGGER.error("Properties file doesn't have the PDP_URL parameter");
+            }
+            if (checkVal != null && checkVal.contains(";")) {
+                List<String> pdpDefault = new ArrayList<>(Arrays.asList(checkVal.split("\\s*;\\s*")));
+                int pdpCount = 0;
+                while (pdpCount < pdpDefault.size()) {
+                    String pdpVal = pdpDefault.get(pdpCount);
+                    readPDPParam(pdpVal);
+                    pdpCount++;
+                }
+            }
+        }
+    }
+
+    private static void readPDPParam(String pdpVal){
+        if(pdpVal.contains(",")){
+            List<String> pdpValues = new ArrayList<>(Arrays.asList(pdpVal.split("\\s*,\\s*")));
+            if(pdpValues.size()==3){
+                // 1:2 will be UserID:Password
+                String userID = pdpValues.get(1);
+                String pass = pdpValues.get(2);
+                Base64.Encoder encoder = Base64.getEncoder();
+                // 0 - PDPURL
+                pdpMap.put(pdpValues.get(0), encoder.encodeToString((userID+":"+pass).getBytes(StandardCharsets.UTF_8)));
+            }else{
+                LOGGER.error(XACMLErrorConstants.ERROR_PERMISSIONS + "No Credentials to send Request: " + pdpValues);
+            }
+        }else{
+            LOGGER.error(XACMLErrorConstants.ERROR_PERMISSIONS + "No Credentials to send Request: " + pdpVal);
+        }
+    }
+
+    public static String getEncoding(String pdpID){
+        try {
+            readFile();
+        } catch (Exception e) {
+            LOGGER.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + e);
+        }
+        String encoding = null;
+        if(pdpMap!=null && (!pdpMap.isEmpty())){
+            try{
+                encoding = pdpMap.get(pdpID);
+            } catch(Exception e){
+                LOGGER.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + e);
+            }
+            return encoding;
+        }else{
+            return null;
+        }
+    }
 }
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyAdapter.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyAdapter.java
index c1d1e9c..be660c8 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyAdapter.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyAdapter.java
@@ -3,13 +3,14 @@
  * ONAP Policy Engine
  * ================================================================================
  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Modified Copyright (C) 2018 Samsung Electronics Co., Ltd.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
- * 
+ *
  *      http://www.apache.org/licenses/LICENSE-2.0
- * 
+ *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
@@ -39,86 +40,87 @@
 
 public class PolicyAdapter {
 
-	private static final Logger LOGGER	= FlexLogger.getLogger(PolicyAdapter.class);
-	
-	public void configure(PolicyRestAdapter policyAdapter, PolicyEntity entity) {
-		if(extendedOptions(policyAdapter, entity)){
-			return;
-		}
-		String policyNameValue = policyAdapter.getPolicyName().substring(0, policyAdapter.getPolicyName().indexOf('_'));
-		String	configPolicyName = null ;
-		if(policyAdapter.getPolicyName().startsWith("Config_PM")){
-			configPolicyName = "ClosedLoop_PM";
-		}else if(policyAdapter.getPolicyName().startsWith("Config_Fault")){
-			configPolicyName = "ClosedLoop_Fault";
-		}else if(policyAdapter.getPolicyName().startsWith("Config_FW")){
-			configPolicyName = "Firewall Config";
-		}else if(policyAdapter.getPolicyName().startsWith("Config_BRMS_Raw")){
-			configPolicyName = "BRMS_Raw";
-		}else if(policyAdapter.getPolicyName().startsWith("Config_BRMS_Param")){
-			configPolicyName = "BRMS_Param";
-		}else if(policyAdapter.getPolicyName().startsWith("Config_MS")){
-			configPolicyName = "Micro Service";
-		}else if(policyAdapter.getPolicyName().startsWith("Config_OOF")){
-			configPolicyName = "Optimization";
-		}else if(policyAdapter.getPolicyName().startsWith("Action") || policyAdapter.getPolicyName().startsWith("Decision") ){
-			// No configPolicyName is applicable
-		}else{
-			configPolicyName = "Base";
-		}
-		if (policyNameValue != null) {
-			policyAdapter.setPolicyType(policyNameValue);
-		}
-		if (configPolicyName != null) {
-			policyAdapter.setConfigPolicyType(configPolicyName);
-		}
+    private static final Logger LOGGER	= FlexLogger.getLogger(PolicyAdapter.class);
 
-		if("Action".equalsIgnoreCase(policyAdapter.getPolicyType())){
-			new ActionPolicyController().prePopulateActionPolicyData(policyAdapter, entity);
-		}
-		if("Decision".equalsIgnoreCase(policyAdapter.getPolicyType())){
-			new DecisionPolicyController().prePopulateDecisionPolicyData(policyAdapter, entity);
-		}
-		if("Config".equalsIgnoreCase(policyAdapter.getPolicyType())){
-			if("Base".equalsIgnoreCase(policyAdapter.getConfigPolicyType())){
-				new CreatePolicyController().prePopulateBaseConfigPolicyData(policyAdapter, entity);
-			}
-			else if("BRMS_Raw".equalsIgnoreCase(policyAdapter.getConfigPolicyType())){
-				new CreateBRMSRawController().prePopulateBRMSRawPolicyData(policyAdapter, entity);
-			}
-			else if("BRMS_Param".equalsIgnoreCase(policyAdapter.getConfigPolicyType())){
-				new CreateBRMSParamController().prePopulateBRMSParamPolicyData(policyAdapter, entity);
-			}
-			else if("ClosedLoop_Fault".equalsIgnoreCase(policyAdapter.getConfigPolicyType())){
-				new CreateClosedLoopFaultController().prePopulateClosedLoopFaultPolicyData(policyAdapter, entity);
-			}
-			else if("ClosedLoop_PM".equalsIgnoreCase(policyAdapter.getConfigPolicyType())){
-				new CreateClosedLoopPMController().prePopulateClosedLoopPMPolicyData(policyAdapter, entity);
-			}
-			else if("Micro Service".equalsIgnoreCase(policyAdapter.getConfigPolicyType())){
-				new CreateDcaeMicroServiceController().prePopulateDCAEMSPolicyData(policyAdapter, entity);
-			}
-			else if("Optimization".equalsIgnoreCase(policyAdapter.getConfigPolicyType())){
-				new CreateOptimizationController().prePopulatePolicyData(policyAdapter, entity);
-			}
-			else if("Firewall Config".equalsIgnoreCase(policyAdapter.getConfigPolicyType())){
-				new CreateFirewallController().prePopulateFWPolicyData(policyAdapter, entity);
-			}
-		}
-	}
-	
-	public boolean extendedOptions(PolicyRestAdapter policyAdapter, PolicyEntity entity) {
-		return false;
-	}
+    public void configure(PolicyRestAdapter policyAdapter, PolicyEntity entity) {
+        String policyNameValue = policyAdapter.getPolicyName().substring(0, policyAdapter.getPolicyName().indexOf('_'));
+        String configPolicyName = getConfigPolicyName(policyAdapter);
+        policyAdapter.setPolicyType(policyNameValue);
 
-	public static PolicyAdapter getInstance() {
-		try {
-			Class<?> policyAdapter = Class.forName(XACMLProperties.getProperty("policyAdapter.impl.className", PolicyAdapter.class.getName()));
-			return (PolicyAdapter) policyAdapter.newInstance();
-		} catch (ClassNotFoundException | InstantiationException | IllegalAccessException | IllegalArgumentException e) {
-			LOGGER.error("Exception Occured"+e);
-		}
-		return null;
-	}
+        if (configPolicyName != null) {
+            policyAdapter.setConfigPolicyType(configPolicyName);
+        }
 
-}
+        if("Action".equalsIgnoreCase(policyAdapter.getPolicyType())){
+            new ActionPolicyController().prePopulateActionPolicyData(policyAdapter, entity);
+        }
+        if("Decision".equalsIgnoreCase(policyAdapter.getPolicyType())){
+            new DecisionPolicyController().prePopulateDecisionPolicyData(policyAdapter, entity);
+        }
+        if("Config".equalsIgnoreCase(policyAdapter.getPolicyType())){
+            prePopulatePolicyData(policyAdapter, entity);
+        }
+    }
+
+    private String getConfigPolicyName(PolicyRestAdapter policyAdapter) {
+        String	configPolicyName = null ;
+        if(policyAdapter.getPolicyName().startsWith("Config_PM")){
+            configPolicyName = "ClosedLoop_PM";
+        }else if(policyAdapter.getPolicyName().startsWith("Config_Fault")){
+            configPolicyName = "ClosedLoop_Fault";
+        }else if(policyAdapter.getPolicyName().startsWith("Config_FW")){
+            configPolicyName = "Firewall Config";
+        }else if(policyAdapter.getPolicyName().startsWith("Config_BRMS_Raw")){
+            configPolicyName = "BRMS_Raw";
+        }else if(policyAdapter.getPolicyName().startsWith("Config_BRMS_Param")){
+            configPolicyName = "BRMS_Param";
+        }else if(policyAdapter.getPolicyName().startsWith("Config_MS")){
+            configPolicyName = "Micro Service";
+        }else if(policyAdapter.getPolicyName().startsWith("Config_OOF")){
+            configPolicyName = "Optimization";
+        }else if(policyAdapter.getPolicyName().startsWith("Action") || policyAdapter.getPolicyName().startsWith("Decision") ){
+            // No configPolicyName is applicable
+        }else{
+            configPolicyName = "Base";
+        }
+        return configPolicyName;
+    }
+
+    private void prePopulatePolicyData(PolicyRestAdapter policyAdapter, PolicyEntity entity) {
+        if("Base".equalsIgnoreCase(policyAdapter.getConfigPolicyType())){
+            new CreatePolicyController().prePopulateBaseConfigPolicyData(policyAdapter, entity);
+        }
+        else if("BRMS_Raw".equalsIgnoreCase(policyAdapter.getConfigPolicyType())){
+            new CreateBRMSRawController().prePopulateBRMSRawPolicyData(policyAdapter, entity);
+        }
+        else if("BRMS_Param".equalsIgnoreCase(policyAdapter.getConfigPolicyType())){
+            new CreateBRMSParamController().prePopulateBRMSParamPolicyData(policyAdapter, entity);
+        }
+        else if("ClosedLoop_Fault".equalsIgnoreCase(policyAdapter.getConfigPolicyType())){
+            new CreateClosedLoopFaultController().prePopulateClosedLoopFaultPolicyData(policyAdapter, entity);
+        }
+        else if("ClosedLoop_PM".equalsIgnoreCase(policyAdapter.getConfigPolicyType())){
+            new CreateClosedLoopPMController().prePopulateClosedLoopPMPolicyData(policyAdapter, entity);
+        }
+        else if("Micro Service".equalsIgnoreCase(policyAdapter.getConfigPolicyType())){
+            new CreateDcaeMicroServiceController().prePopulateDCAEMSPolicyData(policyAdapter, entity);
+        }
+        else if("Optimization".equalsIgnoreCase(policyAdapter.getConfigPolicyType())){
+            new CreateOptimizationController().prePopulatePolicyData(policyAdapter, entity);
+        }
+        else if("Firewall Config".equalsIgnoreCase(policyAdapter.getConfigPolicyType())){
+            new CreateFirewallController().prePopulateFWPolicyData(policyAdapter, entity);
+        }
+    }
+
+    public static PolicyAdapter getInstance() {
+        try {
+            Class<?> policyAdapter = Class.forName(XACMLProperties.getProperty("policyAdapter.impl.className", PolicyAdapter.class.getName()));
+            return (PolicyAdapter) policyAdapter.newInstance();
+        } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | IllegalArgumentException e) {
+            LOGGER.error("Exception Occured"+e);
+        }
+        return null;
+    }
+
+}
\ No newline at end of file
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyManagerServlet.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyManagerServlet.java
index b28850d..de83b04 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyManagerServlet.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyManagerServlet.java
@@ -3,6 +3,7 @@
  * ONAP Policy Engine
  * ================================================================================
  * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Modified Copyright (C) 2018 Samsung Electronics Co., Ltd.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -90,686 +91,709 @@
 
 @WebServlet(value ="/fm/*",  loadOnStartup = 1, initParams = { @WebInitParam(name = "XACML_PROPERTIES_NAME", value = "xacml.admin.properties", description = "The location of the properties file holding configuration information.") })
 public class PolicyManagerServlet extends HttpServlet {
-	private static final Logger LOGGER	= FlexLogger.getLogger(PolicyManagerServlet.class);
-	private static final long serialVersionUID = -8453502699403909016L;
+    private static final Logger LOGGER	= FlexLogger.getLogger(PolicyManagerServlet.class);
+    private static final long serialVersionUID = -8453502699403909016L;
+    private static final String VERSION = "version";;
+    private static final String NAME = "name";
+    private static final String DATE = "date";
+    private static final String SIZE = "size";
+    private static final String TYPE = "type";
+    private static final String CREATED_BY = "createdBy";
+    private static final String MODIFIED_BY = "modifiedBy";
 
-	private enum Mode {
-		LIST, RENAME, COPY, DELETE, EDITFILE, ADDFOLDER, DESCRIBEPOLICYFILE, VIEWPOLICY, ADDSUBSCOPE, SWITCHVERSION, EXPORT, SEARCHLIST
-	}
+    private enum Mode {
+        LIST, RENAME, COPY, DELETE, EDITFILE, ADDFOLDER, DESCRIBEPOLICYFILE, VIEWPOLICY, ADDSUBSCOPE, SWITCHVERSION, EXPORT, SEARCHLIST
+    }
 
-	private static PolicyController policyController;
-	public synchronized PolicyController getPolicyController() {
-		return policyController;
-	}
+    private static PolicyController policyController;
+    public synchronized PolicyController getPolicyController() {
+        return policyController;
+    }
 
-	public static synchronized void setPolicyController(PolicyController policyController) {
-		PolicyManagerServlet.policyController = policyController;
-	}
+    public static synchronized void setPolicyController(PolicyController policyController) {
+        PolicyManagerServlet.policyController = policyController;
+    }
 
-	private static String CONTENTTYPE = "application/json";
-	private static String SUPERADMIN = "super-admin";
-	private static String SUPEREDITOR = "super-editor";
-	private static String SUPERGUEST = "super-guest";
-	private static String ADMIN = "admin";
-	private static String EDITOR = "editor";
-	private static String GUEST = "guest";
-	private static String RESULT = "result";
+    private static String CONTENTTYPE = "application/json";
+    private static String SUPERADMIN = "super-admin";
+    private static String SUPEREDITOR = "super-editor";
+    private static String SUPERGUEST = "super-guest";
+    private static String ADMIN = "admin";
+    private static String EDITOR = "editor";
+    private static String GUEST = "guest";
+    private static String RESULT = "result";
 
-	private static Path closedLoopJsonLocation;
-	private static JsonArray policyNames;
-	private static String testUserId = null;
+    private static Path closedLoopJsonLocation;
+    private static JsonArray policyNames;
+    private static String testUserId = null;
 
-	public static JsonArray getPolicyNames() {
-		return policyNames;
-	}
+    public static JsonArray getPolicyNames() {
+        return policyNames;
+    }
 
-	public static void setPolicyNames(JsonArray policyNames) {
-		PolicyManagerServlet.policyNames = policyNames;
-	}
+    public static void setPolicyNames(JsonArray policyNames) {
+        PolicyManagerServlet.policyNames = policyNames;
+    }
 
-	private static List<String> serviceTypeNamesList = new ArrayList<>();
+    private static List<String> serviceTypeNamesList = new ArrayList<>();
 
-	public static List<String> getServiceTypeNamesList() {
-		return serviceTypeNamesList;
-	}
+    public static List<String> getServiceTypeNamesList() {
+        return serviceTypeNamesList;
+    }
 
-	@Override
-	public void init(ServletConfig servletConfig) throws ServletException {
-		super.init(servletConfig);
-		//
-		// Common initialization
-		//
-		XACMLRest.xacmlInit(servletConfig);
-		//
-		//Initialize ClosedLoop JSON
-		//
-		PolicyManagerServlet.initializeJSONLoad();
-	}
+    @Override
+    public void init(ServletConfig servletConfig) throws ServletException {
+        super.init(servletConfig);
+        //
+        // Common initialization
+        //
+        XACMLRest.xacmlInit(servletConfig);
+        //
+        //Initialize ClosedLoop JSON
+        //
+        PolicyManagerServlet.initializeJSONLoad();
+    }
 
-	protected static void initializeJSONLoad() {
-		closedLoopJsonLocation = Paths.get(XACMLProperties
-				.getProperty(XACMLRestProperties.PROP_ADMIN_CLOSEDLOOP));
-		String location = closedLoopJsonLocation.toString();
-		if (! location.endsWith("json")) {
-			LOGGER.warn("JSONConfig file does not end with extension .json");
-			return;
-		}
-		try (FileInputStream inputStream = new FileInputStream(location);
-			JsonReader jsonReader = Json.createReader(inputStream)) {
-			policyNames = jsonReader.readArray();
-			serviceTypeNamesList = new ArrayList<>();
-			for (int i = 0; i < policyNames.size(); i++) {
-				javax.json.JsonObject policyName = policyNames.getJsonObject(i);
-				String name = policyName.getJsonString("serviceTypePolicyName").getString();
-				serviceTypeNamesList.add(name);
-			}
-		} catch (IOException e) {
-			LOGGER.error("Exception Occured while initializing the JSONConfig file"+e);
-		}
-	}
+    protected static void initializeJSONLoad() {
+        closedLoopJsonLocation = Paths.get(XACMLProperties
+                .getProperty(XACMLRestProperties.PROP_ADMIN_CLOSEDLOOP));
+        String location = closedLoopJsonLocation.toString();
+        if (! location.endsWith("json")) {
+            LOGGER.warn("JSONConfig file does not end with extension .json");
+            return;
+        }
+        try (FileInputStream inputStream = new FileInputStream(location);
+             JsonReader jsonReader = Json.createReader(inputStream)) {
+            policyNames = jsonReader.readArray();
+            serviceTypeNamesList = new ArrayList<>();
+            for (int i = 0; i < policyNames.size(); i++) {
+                javax.json.JsonObject policyName = policyNames.getJsonObject(i);
+                String name = policyName.getJsonString("serviceTypePolicyName").getString();
+                serviceTypeNamesList.add(name);
+            }
+        } catch (IOException e) {
+            LOGGER.error("Exception Occured while initializing the JSONConfig file"+e);
+        }
+    }
 
-	@Override
-	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
-		LOGGER.debug("doPost");
-		try {
-			// if request contains multipart-form-data
-			if (ServletFileUpload.isMultipartContent(request)) {
-				uploadFile(request, response);
-			}
-			// all other post request has json params in body
-			else {
-				fileOperation(request, response);
-			}
-		} catch (Exception e) {
-			try {
-				setError(e, response);
-			}catch(Exception e1){
-				LOGGER.error("Exception Occured"+e1);
-			}
-		}
-	}
+    @Override
+    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+        LOGGER.debug("doPost");
+        try {
+            // if request contains multipart-form-data
+            if (ServletFileUpload.isMultipartContent(request)) {
+                uploadFile(request, response);
+            }
+            // all other post request has json params in body
+            else {
+                fileOperation(request, response);
+            }
+        } catch (Exception e) {
+            try {
+                setError(e, response);
+            }catch(Exception e1){
+                LOGGER.error("Exception Occured"+e1);
+            }
+        }
+    }
 
-	//Set Error Message for Exception
-	private void setError(Exception t, HttpServletResponse response) throws IOException {
-		try {
-			JSONObject responseJsonObject = error(t.getMessage());
-			response.setContentType(CONTENTTYPE);
-			PrintWriter out = response.getWriter();
-			out.print(responseJsonObject);
-			out.flush();
-		} catch (Exception x) {
-			LOGGER.error("Exception Occured"+x);
-			response.sendError(HttpStatus.SC_INTERNAL_SERVER_ERROR, x.getMessage());
-		}
-	}
+    //Set Error Message for Exception
+    private void setError(Exception t, HttpServletResponse response) throws IOException {
+        try {
+            JSONObject responseJsonObject = error(t.getMessage());
+            response.setContentType(CONTENTTYPE);
+            PrintWriter out = response.getWriter();
+            out.print(responseJsonObject);
+            out.flush();
+        } catch (Exception x) {
+            LOGGER.error("Exception Occured"+x);
+            response.sendError(HttpStatus.SC_INTERNAL_SERVER_ERROR, x.getMessage());
+        }
+    }
 
-	//Policy Import Functionality
-	private void uploadFile(HttpServletRequest request, HttpServletResponse response) throws ServletException {
-		try {
-			String newFile;
-			Map<String, InputStream> files = new HashMap<>();
+    //Policy Import Functionality
+    private void uploadFile(HttpServletRequest request, HttpServletResponse response) throws ServletException {
+        try {
+            Map<String, InputStream> files = new HashMap<>();
 
-			List<FileItem> items = new ServletFileUpload(new DiskFileItemFactory()).parseRequest(request);
-			for (FileItem item : items) {
-				if (!item.isFormField()) {
-					// Process form file field (input type="file").
-					files.put(item.getName(), item.getInputStream());
-					if(item.getName().endsWith(".xls") && item.getSize() <= PolicyController.getFileSizeLimit()){
-						File file = new File(item.getName());
-						try (OutputStream outputStream = new FileOutputStream(file);)
-						{
-							IOUtils.copy(item.getInputStream(), outputStream);
-							newFile = file.toString();
-							PolicyExportAndImportController importController = new PolicyExportAndImportController();
-							importController.importRepositoryFile(newFile, request);
-						}catch(Exception e){
-							LOGGER.error("Upload error : " + e);
-						}
-					}
-					else if (!item.getName().endsWith(".xls")) {
-						LOGGER.error("Non .xls filetype uploaded: " + item.getName());
-					} 
-					else { //uploaded file size is greater than allowed 
-						LOGGER.error("Upload file size limit exceeded! File size (Bytes) is: " + item.getSize());
-					}
-				}
-			}
+            List<FileItem> items = new ServletFileUpload(new DiskFileItemFactory()).parseRequest(request);
+            for (FileItem item : items) {
+                if (!item.isFormField()) {
+                    // Process form file field (input type="file").
+                    files.put(item.getName(), item.getInputStream());
+                    processFormFile(request, item);
+                }
+            }
 
-			JSONObject responseJsonObject;
-			responseJsonObject = this.success();
-			response.setContentType(CONTENTTYPE);
-			PrintWriter out = response.getWriter();
-			out.print(responseJsonObject);
-			out.flush();
-		} catch (Exception e) {
-			LOGGER.debug("Cannot write file");
-			throw new ServletException("Cannot write file", e);
-		}
-	}
+            JSONObject responseJsonObject;
+            responseJsonObject = this.success();
+            response.setContentType(CONTENTTYPE);
+            PrintWriter out = response.getWriter();
+            out.print(responseJsonObject);
+            out.flush();
+        } catch (Exception e) {
+            LOGGER.debug("Cannot write file");
+            throw new ServletException("Cannot write file", e);
+        }
+    }
 
-	//File Operation Functionality
-	private void fileOperation(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
-		JSONObject responseJsonObject = null;
-		try {
-			StringBuilder sb = new StringBuilder();
-			BufferedReader br = request.getReader();
-			String str;
-			while ((str = br.readLine()) != null) {
-				sb.append(str);
-			}
-			br.close();
-			JSONObject jObj = new JSONObject(sb.toString());
-			JSONObject params = jObj.getJSONObject("params");
-			Mode mode = Mode.valueOf(params.getString("mode"));
-			
-			String userId = UserUtils.getUserSession(request).getOrgUserId();
-			LOGGER.info("****************************************Logging UserID while doing actions on Editor tab*******************************************");
-			LOGGER.info("UserId:  " + userId + "Action Mode:  "+ mode.toString() + "Action Params: "+params.toString());
-			LOGGER.info("***********************************************************************************************************************************");
-			
-			switch (mode) {
-			case ADDFOLDER:
-			case ADDSUBSCOPE:
-				responseJsonObject = addFolder(params, request);
-				break;
-			case COPY:
-				responseJsonObject = copy(params, request);
-				break;
-			case DELETE:
-				responseJsonObject = delete(params, request);
-				break;
-			case EDITFILE:
-			case VIEWPOLICY:
-				responseJsonObject = editFile(params);
-				break;
-			case LIST:
-				responseJsonObject = list(params, request);
-				break;
-			case RENAME:
-				responseJsonObject = rename(params, request);
-				break;
-			case DESCRIBEPOLICYFILE:
-				responseJsonObject = describePolicy(params);
-				break;
-			case SWITCHVERSION:
-				responseJsonObject = switchVersion(params, request);
-				break;
-			case SEARCHLIST:
-				responseJsonObject = searchPolicyList(params, request);
-				break;
-			default:
-				throw new ServletException("not implemented");
-			}
-			if (responseJsonObject == null) {
-				responseJsonObject = error("generic error : responseJsonObject is null");
-			}
-		} catch (Exception e) {
-			LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "Exception Occured While doing File Operation" + e);
-			responseJsonObject = error(e.getMessage());
-		}
-		response.setContentType(CONTENTTYPE);
-		PrintWriter out = response.getWriter();
-		out.print(responseJsonObject);
-		out.flush();
-	}
+    private void processFormFile(HttpServletRequest request, FileItem item) {
+        String newFile;
+        if(item.getName().endsWith(".xls") && item.getSize() <= PolicyController.getFileSizeLimit()){
+            File file = new File(item.getName());
+            try (OutputStream outputStream = new FileOutputStream(file);)
+            {
+                IOUtils.copy(item.getInputStream(), outputStream);
+                newFile = file.toString();
+                PolicyExportAndImportController importController = new PolicyExportAndImportController();
+                importController.importRepositoryFile(newFile, request);
+            }catch(Exception e){
+                LOGGER.error("Upload error : " + e);
+            }
+        }
+        else if (!item.getName().endsWith(".xls")) {
+            LOGGER.error("Non .xls filetype uploaded: " + item.getName());
+        }
+        else { //uploaded file size is greater than allowed
+            LOGGER.error("Upload file size limit exceeded! File size (Bytes) is: " + item.getSize());
+        }
+    }
 
-	private JSONObject searchPolicyList(JSONObject params, HttpServletRequest request) {
-		Set<String> scopes;
-		List<String> roles;
-		List<Object> policyData = new ArrayList<>();
-		JSONArray policyList = null;
-		if(params.has("policyList")){
-			policyList = (JSONArray) params.get("policyList");
-		}
-		PolicyController controller = getPolicyControllerInstance();
-		List<JSONObject> resultList = new ArrayList<>();
-		try {
-			//Get the Login Id of the User from Request
-			String userId =  UserUtils.getUserSession(request).getOrgUserId();
-			List<Object> userRoles = controller.getRoles(userId);
-			Pair<Set<String>, List<String>> pair = org.onap.policy.utils.UserUtils.checkRoleAndScope(userRoles);
-			roles = pair.u;
-			scopes = pair.t;
-			if (roles.contains(ADMIN) || roles.contains(EDITOR) || roles.contains(GUEST) ) {
-				if(scopes.isEmpty()){
-					return error("No Scopes has been Assigned to the User. Please, Contact Super-Admin");
-				}
-				Set<String> tempScopes = scopes;
-				for(String scope : tempScopes){
-					List<Object> scopesList = queryPolicyEditorScopes(scope);
-					if(!scopesList.isEmpty()){
-						for(int i = 0; i < scopesList.size(); i++){
-							PolicyEditorScopes tempScope = (PolicyEditorScopes) scopesList.get(i);
-							scopes.add(tempScope.getScopeName());
-						}
-					}
-				}
-			}
-			if(policyList!= null){
-				for(int i = 0; i < policyList.length(); i++){
-					String policyName = policyList.get(i).toString().replace(".xml", "");
-					String version = policyName.substring(policyName.lastIndexOf('.')+1);
-					policyName = policyName.substring(0, policyName.lastIndexOf('.')).replace(".", File.separator);
-					if(policyName.contains("\\")){
-						policyName = policyName.replace("\\", "\\\\");
-					}
-					String policyVersionQuery = "From PolicyVersion where policy_name = :policyName  and active_version = :version and id >0";
-					SimpleBindings pvParams = new SimpleBindings();
-					pvParams.put("policyName", policyName);
-					pvParams.put("version", version);
-					List<Object> activeData = controller.getDataByQuery(policyVersionQuery, pvParams);
-					if(!activeData.isEmpty()){
-						PolicyVersion policy = (PolicyVersion) activeData.get(0);
-						JSONObject el = new JSONObject();
-						el.put("name", policy.getPolicyName().replace(File.separator, "/"));
-						el.put("date", policy.getModifiedDate());
-						el.put("version", policy.getActiveVersion());
-						el.put("size", "");
-						el.put("type", "file");
-						el.put("createdBy", getUserName(policy.getCreatedBy()));
-						el.put("modifiedBy", getUserName(policy.getModifiedBy()));
-						resultList.add(el);
-					}
-				}
-			}else{
-				if (roles.contains(SUPERADMIN) || roles.contains(SUPEREDITOR)   || roles.contains(SUPERGUEST) ){
-					policyData = controller.getData(PolicyVersion.class);
-				}else{
-					List<Object> filterdatas = controller.getData(PolicyVersion.class);
-					for(Object filter : filterdatas){
-						PolicyVersion filterdata = (PolicyVersion) filter;
-						try{
-							String scopeName = filterdata.getPolicyName().substring(0, filterdata.getPolicyName().lastIndexOf(File.separator));
-							if(scopes.contains(scopeName)){
-								policyData.add(filterdata);
-							}
-						}catch(Exception e){
-							LOGGER.error("Exception occured while filtering policyversion data"+e);
-						}
-					}
-				}
+    //File Operation Functionality
+    private void fileOperation(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
+        JSONObject responseJsonObject = null;
+        try {
+            StringBuilder sb = new StringBuilder();
+            BufferedReader br = request.getReader();
+            String str;
+            while ((str = br.readLine()) != null) {
+                sb.append(str);
+            }
+            br.close();
+            JSONObject jObj = new JSONObject(sb.toString());
+            JSONObject params = jObj.getJSONObject("params");
+            Mode mode = Mode.valueOf(params.getString("mode"));
 
-				if(!policyData.isEmpty()){
-					for(int i =0; i < policyData.size(); i++){
-						PolicyVersion policy = (PolicyVersion) policyData.get(i);
-						JSONObject el = new JSONObject();
-						el.put("name", policy.getPolicyName().replace(File.separator, "/"));
-						el.put("date", policy.getModifiedDate());
-						el.put("version", policy.getActiveVersion());
-						el.put("size", "");
-						el.put("type", "file");
-						el.put("createdBy", getUserName(policy.getCreatedBy()));
-						el.put("modifiedBy", getUserName(policy.getModifiedBy()));
-						resultList.add(el);
-					}
-				}
-			}
-		}catch(Exception e){
-			LOGGER.error("Exception occured while reading policy Data from Policy Version table for Policy Search Data"+e);
-		}
+            String userId = UserUtils.getUserSession(request).getOrgUserId();
+            LOGGER.info("****************************************Logging UserID while doing actions on Editor tab*******************************************");
+            LOGGER.info("UserId:  " + userId + "Action Mode:  "+ mode.toString() + "Action Params: "+params.toString());
+            LOGGER.info("***********************************************************************************************************************************");
 
-		return new JSONObject().put(RESULT, resultList);
-	}
+            switch (mode) {
+                case ADDFOLDER:
+                case ADDSUBSCOPE:
+                    responseJsonObject = addFolder(params, request);
+                    break;
+                case COPY:
+                    responseJsonObject = copy(params, request);
+                    break;
+                case DELETE:
+                    responseJsonObject = delete(params, request);
+                    break;
+                case EDITFILE:
+                case VIEWPOLICY:
+                    responseJsonObject = editFile(params);
+                    break;
+                case LIST:
+                    responseJsonObject = list(params, request);
+                    break;
+                case RENAME:
+                    responseJsonObject = rename(params, request);
+                    break;
+                case DESCRIBEPOLICYFILE:
+                    responseJsonObject = describePolicy(params);
+                    break;
+                case SWITCHVERSION:
+                    responseJsonObject = switchVersion(params, request);
+                    break;
+                case SEARCHLIST:
+                    responseJsonObject = searchPolicyList(params, request);
+                    break;
+                default:
+                    throw new ServletException("not implemented");
+            }
+            if (responseJsonObject == null) {
+                responseJsonObject = error("generic error : responseJsonObject is null");
+            }
+        } catch (Exception e) {
+            LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "Exception Occured While doing File Operation" + e);
+            responseJsonObject = error(e.getMessage());
+        }
+        response.setContentType(CONTENTTYPE);
+        PrintWriter out = response.getWriter();
+        out.print(responseJsonObject);
+        out.flush();
+    }
 
-	//Switch Version Functionality
-	private JSONObject switchVersion(JSONObject params, HttpServletRequest request) throws ServletException{
-		String path = params.getString("path");
-		String userId = null;
-		try {
-			userId = UserUtils.getUserSession(request).getOrgUserId();
-		} catch (Exception e) {
-			LOGGER.error("Exception Occured while reading userid from cookie" +e);
-		}
-		String policyName;
-		String removeExtension = path.replace(".xml", "");
-		if(path.startsWith("/")){
-			policyName = removeExtension.substring(1, removeExtension.lastIndexOf('.'));
-		}else{
-			policyName = removeExtension.substring(0, removeExtension.lastIndexOf('.'));
-		}
+    private JSONObject searchPolicyList(JSONObject params, HttpServletRequest request) {
+        Set<String> scopes;
+        List<String> roles;
+        List<Object> policyData = new ArrayList<>();
+        JSONArray policyList = null;
+        if(params.has("policyList")){
+            policyList = (JSONArray) params.get("policyList");
+        }
+        PolicyController controller = getPolicyControllerInstance();
+        List<JSONObject> resultList = new ArrayList<>();
+        try {
+            //Get the Login Id of the User from Request
+            String userId =  UserUtils.getUserSession(request).getOrgUserId();
+            List<Object> userRoles = controller.getRoles(userId);
+            Pair<Set<String>, List<String>> pair = org.onap.policy.utils.UserUtils.checkRoleAndScope(userRoles);
+            roles = pair.u;
+            scopes = pair.t;
+            if (roles.contains(ADMIN) || roles.contains(EDITOR) || roles.contains(GUEST) ) {
+                if(scopes.isEmpty()){
+                    return error("No Scopes has been Assigned to the User. Please, Contact Super-Admin");
+                }
+                Set<String> tempScopes = scopes;
+                for(String scope : tempScopes){
+                    addScope(scopes, scope);
+                }
+            }
+            if(policyList!= null){
+                for(int i = 0; i < policyList.length(); i++){
+                    String policyName = policyList.get(i).toString().replace(".xml", "");
+                    String version = policyName.substring(policyName.lastIndexOf('.')+1);
+                    policyName = policyName.substring(0, policyName.lastIndexOf('.')).replace(".", File.separator);
+                    parsePolicyList(resultList, controller, policyName, version);
+                }
+            }else{
+                if (roles.contains(SUPERADMIN) || roles.contains(SUPEREDITOR)   || roles.contains(SUPERGUEST) ){
+                    policyData = controller.getData(PolicyVersion.class);
+                }else{
+                    List<Object> filterdatas = controller.getData(PolicyVersion.class);
+                    for(Object filter : filterdatas){
+                        PolicyVersion filterdata = (PolicyVersion) filter;
+                        try{
+                            String scopeName = filterdata.getPolicyName().substring(0, filterdata.getPolicyName().lastIndexOf(File.separator));
+                            if(scopes.contains(scopeName)){
+                                policyData.add(filterdata);
+                            }
+                        }catch(Exception e){
+                            LOGGER.error("Exception occured while filtering policyversion data"+e);
+                        }
+                    }
+                }
 
-		String activePolicy;
-		PolicyController controller = getPolicyControllerInstance();
-		if(! params.toString().contains("activeVersion")){
-			return controller.switchVersionPolicyContent(policyName);
-		}
-		String activeVersion = params.getString("activeVersion");
-		String highestVersion = params.get("highestVersion").toString();
-		if(Integer.parseInt(activeVersion) > Integer.parseInt(highestVersion)){
-			return error("The Version shouldn't be greater than Highest Value");
-		}
-		activePolicy = policyName + "." + activeVersion + ".xml";
-		String dbCheckName = activePolicy.replace("/", ".");
-		if(dbCheckName.contains("Config_")){
-			dbCheckName = dbCheckName.replace(".Config_", ":Config_");
-		}else if(dbCheckName.contains("Action_")){
-			dbCheckName = dbCheckName.replace(".Action_", ":Action_");
-		}else if(dbCheckName.contains("Decision_")){
-			dbCheckName = dbCheckName.replace(".Decision_", ":Decision_");
-		}
-		String[] splitDBCheckName = dbCheckName.split(":");
-		String peQuery =   "FROM PolicyEntity where policyName = :splitDBCheckName_1 and scope = :splitDBCheckName_0";
-		SimpleBindings policyParams = new SimpleBindings();
-		policyParams.put("splitDBCheckName_1", splitDBCheckName[1]);
-		policyParams.put("splitDBCheckName_0", splitDBCheckName[0]);
-		List<Object> policyEntity = controller.getDataByQuery(peQuery, policyParams);
-		PolicyEntity pentity = (PolicyEntity) policyEntity.get(0);
-		if(pentity.isDeleted()){
-			return error("The Policy is Not Existing in Workspace");
-		}
-		if(policyName.contains("/")){
-			policyName = policyName.replace("/", File.separator);
-		}
-		policyName = policyName.substring(policyName.indexOf(File.separator)+1);
-		if(policyName.contains("\\")){
-			policyName = policyName.replace(File.separator, "\\");
-		}
-		policyName = splitDBCheckName[0].replace(".", File.separator)+File.separator+policyName;
-		String watchPolicyName = policyName;
-		if(policyName.contains("/")){
-			policyName = policyName.replace("/", File.separator);
-		}
-		if(policyName.contains("\\")){
-			policyName = policyName.replace("\\", "\\\\");
-		}
-		String query = "update PolicyVersion set active_version='"+activeVersion+"' where policy_name ='"+policyName+"'  and id >0";
-		//query the database
-		controller.executeQuery(query);
-		//Policy Notification
-		PolicyVersion entity = new PolicyVersion();
-		entity.setPolicyName(watchPolicyName);
-		entity.setActiveVersion(Integer.parseInt(activeVersion));
-		entity.setModifiedBy(userId);
-		controller.watchPolicyFunction(entity, activePolicy, "SwitchVersion");
-		return success();
-	}
+                if(!policyData.isEmpty()){
+                    updateResultList(policyData, resultList);
+                }
+            }
+        }catch(Exception e){
+            LOGGER.error("Exception occured while reading policy Data from Policy Version table for Policy Search Data"+e);
+        }
 
-	//Describe Policy
-	private JSONObject describePolicy(JSONObject params) throws ServletException{
-		JSONObject object = null;
-		String path = params.getString("path");
-		String policyName = null;
-		if(path.startsWith("/")){
-			path = path.substring(1);
-			policyName = path.substring(path.lastIndexOf('/') +1);
-			path = path.replace("/", ".");
-		}else{
-			path = path.replace("/", ".");
-			policyName = path;
-		}
-		if(path.contains("Config_")){
-			path = path.replace(".Config_", ":Config_");
-		}else if(path.contains("Action_")){
-			path = path.replace(".Action_", ":Action_");
-		}else if(path.contains("Decision_")){
-			path = path.replace(".Decision_", ":Decision_");
-		}
-		PolicyController controller = getPolicyControllerInstance();
-		String[] split = path.split(":");
-		String query = "FROM PolicyEntity where policyName = :split_1 and scope = :split_0";
-		SimpleBindings peParams = new SimpleBindings();
-		peParams.put("split_1", split[1]);
-		peParams.put("split_0", split[0]);
-		List<Object> queryData = null;
-		if(PolicyController.isjUnit()){
-			queryData = controller.getDataByQuery(query, null);
-		}else{
-			queryData = controller.getDataByQuery(query, peParams);
-		}
-		if(queryData.isEmpty()){
-			return error("Error Occured while Describing the Policy - query is empty");
-		}
-		PolicyEntity entity = (PolicyEntity) queryData.get(0);
-		File temp = null;
-		try {
-			temp = File.createTempFile(policyName, ".tmp");
-		} catch (IOException e) {
-			String message = "Failed to create temp file " + policyName + ".tmp";
-			LOGGER.error(message + e);
-			return error(message);
-		}
-		try (BufferedWriter bw = new BufferedWriter(new FileWriter(temp))) {
-			bw.write(entity.getPolicyData());
-		} catch (IOException e) {
-			LOGGER.error("Exception Occured while Describing the Policy"+e);
-		}
-		object = HumanPolicyComponent.DescribePolicy(temp);
-		if(temp != null){
-			try {
-				Files.delete(temp.toPath());
-			} catch (IOException e) {
-				LOGGER.warn("Failed to delete " + temp.getName() + e);
-			}
-		}
-		return object;
-	}
+        return new JSONObject().put(RESULT, resultList);
+    }
 
-	//Get the List of Policies and Scopes for Showing in Editor tab
-	private JSONObject list(JSONObject params, HttpServletRequest request) throws ServletException {
-		Set<String> scopes = null;
-		List<String> roles = null;
-		try {
-			PolicyController controller = getPolicyControllerInstance();
-			//Get the Login Id of the User from Request
-			String testUserID = getTestUserId();
-			String userId =  testUserID != null ? testUserID : UserUtils.getUserSession(request).getOrgUserId();
-			List<Object> userRoles = controller.getRoles(userId);
-			Pair<Set<String>, List<String>> pair = org.onap.policy.utils.UserUtils.checkRoleAndScope(userRoles);
-			roles = pair.u;
-			scopes = pair.t;
+    private void updateResultList(List<Object> policyData, List<JSONObject> resultList) {
+        for(int i =0; i < policyData.size(); i++){
+            PolicyVersion policy = (PolicyVersion) policyData.get(i);
+            JSONObject el = new JSONObject();
+            el.put(NAME, policy.getPolicyName().replace(File.separator, "/"));
+            el.put(DATE, policy.getModifiedDate());
+            el.put(VERSION, policy.getActiveVersion());
+            el.put(SIZE, "");
+            el.put(TYPE, "file");
+            el.put(CREATED_BY, getUserName(policy.getCreatedBy()));
+            el.put(MODIFIED_BY, getUserName(policy.getModifiedBy()));
+            resultList.add(el);
+        }
+    }
 
-			List<JSONObject> resultList = new ArrayList<>();
-			boolean onlyFolders = params.getBoolean("onlyFolders");
-			String path = params.getString("path");
-			if(path.contains("..xml")){
-				path = path.replaceAll("..xml", "").trim();
-			}
+    private void parsePolicyList(List<JSONObject> resultList, PolicyController controller, String policyName, String version) {
+        if(policyName.contains("\\")){
+            policyName = policyName.replace("\\", "\\\\");
+        }
+        String policyVersionQuery = "From PolicyVersion where policy_name = :policyName  and active_version = :version and id >0";
+        SimpleBindings pvParams = new SimpleBindings();
+        pvParams.put("policyName", policyName);
+        pvParams.put(VERSION, version);
+        List<Object> activeData = controller.getDataByQuery(policyVersionQuery, pvParams);
+        if(!activeData.isEmpty()){
+            PolicyVersion policy = (PolicyVersion) activeData.get(0);
+            JSONObject el = new JSONObject();
+            el.put(NAME, policy.getPolicyName().replace(File.separator, "/"));
+            el.put(DATE, policy.getModifiedDate());
+            el.put(VERSION, policy.getActiveVersion());
+            el.put(SIZE, "");
+            el.put(TYPE, "file");
+            el.put(CREATED_BY, getUserName(policy.getCreatedBy()));
+            el.put(MODIFIED_BY, getUserName(policy.getModifiedBy()));
+            resultList.add(el);
+        }
+    }
 
-			if (roles.contains(ADMIN) || roles.contains(EDITOR) || roles.contains(GUEST) ) {
-				if(scopes.isEmpty()){
-					return error("No Scopes has been Assigned to the User. Please, Contact Super-Admin");
-				}else{
-					if(!"/".equals(path)){
-						String tempScope = path.substring(1, path.length());
-						tempScope = tempScope.replace("/", File.separator);
-						scopes.add(tempScope);
-					}
-				}
-			}
+    private void addScope(Set<String> scopes, String scope) {
+        List<Object> scopesList = queryPolicyEditorScopes(scope);
+        if(!scopesList.isEmpty()){
+            for(int i = 0; i < scopesList.size(); i++){
+                PolicyEditorScopes tempScope = (PolicyEditorScopes) scopesList.get(i);
+                scopes.add(tempScope.getScopeName());
+            }
+        }
+    }
 
-			if("/".equals(path)){
-				if(roles.contains(SUPERADMIN) || roles.contains(SUPEREDITOR) || roles.contains(SUPERGUEST)){
-					List<Object> scopesList = queryPolicyEditorScopes(null);
-					for(Object list : scopesList){
-						PolicyEditorScopes scope = (PolicyEditorScopes) list;
-						if(!(scope.getScopeName().contains(File.separator))){
-							JSONObject el = new JSONObject();
-							el.put("name", scope.getScopeName());
-							el.put("date", scope.getModifiedDate());
-							el.put("size", "");
-							el.put("type", "dir");
-							el.put("createdBy", scope.getUserCreatedBy().getUserName());
-							el.put("modifiedBy", scope.getUserModifiedBy().getUserName());
-							resultList.add(el);
-						}
-					}
-				}else if(roles.contains(ADMIN) || roles.contains(EDITOR) || roles.contains(GUEST)){
-					for(Object scope : scopes){
-						JSONObject el = new JSONObject();
-						List<Object> scopesList = queryPolicyEditorScopes(scope.toString());
-						if(!scopesList.isEmpty()){
-							PolicyEditorScopes scopeById = (PolicyEditorScopes) scopesList.get(0);
-							el.put("name", scopeById.getScopeName());
-							el.put("date", scopeById.getModifiedDate());
-							el.put("size", "");
-							el.put("type", "dir");
-							el.put("createdBy", scopeById.getUserCreatedBy().getUserName());
-							el.put("modifiedBy", scopeById.getUserModifiedBy().getUserName());
-							resultList.add(el);
-						}
-					}
-				}
-			}else{
-				try{
-					String scopeName = path.substring(path.indexOf('/') +1);
-					activePolicyList(scopeName, resultList, roles, scopes, onlyFolders);
-				} catch (Exception ex) {
-					LOGGER.error("Error Occured While reading Policy Files List"+ex );
-				}
-			}
+    //Switch Version Functionality
+    private JSONObject switchVersion(JSONObject params, HttpServletRequest request) throws ServletException{
+        String path = params.getString("path");
+        String userId = null;
+        try {
+            userId = UserUtils.getUserSession(request).getOrgUserId();
+        } catch (Exception e) {
+            LOGGER.error("Exception Occured while reading userid from cookie" +e);
+        }
+        String policyName;
+        String removeExtension = path.replace(".xml", "");
+        if(path.startsWith("/")){
+            policyName = removeExtension.substring(1, removeExtension.lastIndexOf('.'));
+        }else{
+            policyName = removeExtension.substring(0, removeExtension.lastIndexOf('.'));
+        }
 
-			return new JSONObject().put(RESULT, resultList);
-		} catch (Exception e) {
-			LOGGER.error("list", e);
-			return error(e.getMessage());
-		}
-	}
+        String activePolicy;
+        PolicyController controller = getPolicyControllerInstance();
+        if(! params.toString().contains("activeVersion")){
+            return controller.switchVersionPolicyContent(policyName);
+        }
+        String activeVersion = params.getString("activeVersion");
+        String highestVersion = params.get("highestVersion").toString();
+        if(Integer.parseInt(activeVersion) > Integer.parseInt(highestVersion)){
+            return error("The Version shouldn't be greater than Highest Value");
+        }
+        activePolicy = policyName + "." + activeVersion + ".xml";
+        String dbCheckName = activePolicy.replace("/", ".");
+        if(dbCheckName.contains("Config_")){
+            dbCheckName = dbCheckName.replace(".Config_", ":Config_");
+        }else if(dbCheckName.contains("Action_")){
+            dbCheckName = dbCheckName.replace(".Action_", ":Action_");
+        }else if(dbCheckName.contains("Decision_")){
+            dbCheckName = dbCheckName.replace(".Decision_", ":Decision_");
+        }
+        String[] splitDBCheckName = dbCheckName.split(":");
+        String peQuery =   "FROM PolicyEntity where policyName = :splitDBCheckName_1 and scope = :splitDBCheckName_0";
+        SimpleBindings policyParams = new SimpleBindings();
+        policyParams.put("splitDBCheckName_1", splitDBCheckName[1]);
+        policyParams.put("splitDBCheckName_0", splitDBCheckName[0]);
+        List<Object> policyEntity = controller.getDataByQuery(peQuery, policyParams);
+        PolicyEntity pentity = (PolicyEntity) policyEntity.get(0);
+        if(pentity.isDeleted()){
+            return error("The Policy is Not Existing in Workspace");
+        }
+        if(policyName.contains("/")){
+            policyName = policyName.replace("/", File.separator);
+        }
+        policyName = policyName.substring(policyName.indexOf(File.separator)+1);
+        if(policyName.contains("\\")){
+            policyName = policyName.replace(File.separator, "\\");
+        }
+        policyName = splitDBCheckName[0].replace(".", File.separator)+File.separator+policyName;
+        String watchPolicyName = policyName;
+        if(policyName.contains("/")){
+            policyName = policyName.replace("/", File.separator);
+        }
+        if(policyName.contains("\\")){
+            policyName = policyName.replace("\\", "\\\\");
+        }
+        String query = "update PolicyVersion set active_version='"+activeVersion+"' where policy_name ='"+policyName+"'  and id >0";
+        //query the database
+        controller.executeQuery(query);
+        //Policy Notification
+        PolicyVersion entity = new PolicyVersion();
+        entity.setPolicyName(watchPolicyName);
+        entity.setActiveVersion(Integer.parseInt(activeVersion));
+        entity.setModifiedBy(userId);
+        controller.watchPolicyFunction(entity, activePolicy, "SwitchVersion");
+        return success();
+    }
 
-	private List<Object> queryPolicyEditorScopes(String scopeName){
-		String scopeNamequery;
-		SimpleBindings params = new SimpleBindings();
-		if(scopeName == null){
-			scopeNamequery = "from PolicyEditorScopes";
-		}else{
-			scopeNamequery = "from PolicyEditorScopes where SCOPENAME like :scopeName";
-			params.put("scopeName", scopeName + "%");
-		}
-		PolicyController controller = getPolicyControllerInstance();
-		List<Object> scopesList;
-		if(PolicyController.isjUnit()){
-			scopesList = controller.getDataByQuery(scopeNamequery, null);
-		}else{
-			scopesList = controller.getDataByQuery(scopeNamequery, params);
-		}
-		return  scopesList;
-	}
+    //Describe Policy
+    private JSONObject describePolicy(JSONObject params) throws ServletException{
+        JSONObject object = null;
+        String path = params.getString("path");
+        String policyName = null;
+        if(path.startsWith("/")){
+            path = path.substring(1);
+            policyName = path.substring(path.lastIndexOf('/') +1);
+            path = path.replace("/", ".");
+        }else{
+            path = path.replace("/", ".");
+            policyName = path;
+        }
+        if(path.contains("Config_")){
+            path = path.replace(".Config_", ":Config_");
+        }else if(path.contains("Action_")){
+            path = path.replace(".Action_", ":Action_");
+        }else if(path.contains("Decision_")){
+            path = path.replace(".Decision_", ":Decision_");
+        }
+        PolicyController controller = getPolicyControllerInstance();
+        String[] split = path.split(":");
+        String query = "FROM PolicyEntity where policyName = :split_1 and scope = :split_0";
+        SimpleBindings peParams = new SimpleBindings();
+        peParams.put("split_1", split[1]);
+        peParams.put("split_0", split[0]);
+        List<Object> queryData = null;
+        if(PolicyController.isjUnit()){
+            queryData = controller.getDataByQuery(query, null);
+        }else{
+            queryData = controller.getDataByQuery(query, peParams);
+        }
+        if(queryData.isEmpty()){
+            return error("Error Occured while Describing the Policy - query is empty");
+        }
+        PolicyEntity entity = (PolicyEntity) queryData.get(0);
+        File temp = null;
+        try {
+            temp = File.createTempFile(policyName, ".tmp");
+        } catch (IOException e) {
+            String message = "Failed to create temp file " + policyName + ".tmp";
+            LOGGER.error(message + e);
+            return error(message);
+        }
+        try (BufferedWriter bw = new BufferedWriter(new FileWriter(temp))) {
+            bw.write(entity.getPolicyData());
+        } catch (IOException e) {
+            LOGGER.error("Exception Occured while Describing the Policy"+e);
+        }
+        object = HumanPolicyComponent.DescribePolicy(temp);
+        if(temp != null){
+            try {
+                Files.delete(temp.toPath());
+            } catch (IOException e) {
+                LOGGER.warn("Failed to delete " + temp.getName() + e);
+            }
+        }
+        return object;
+    }
 
-	//Get Active Policy List based on Scope Selection form Policy Version table
-	private void activePolicyList(String inScopeName, List<JSONObject> resultList, List<String> roles, Set<String> scopes, boolean onlyFolders){
-		PolicyController controller = getPolicyControllerInstance();
-		String scopeName = inScopeName;
-		if(scopeName.contains("/")){
-			scopeName = scopeName.replace("/", File.separator);
-		}
-		if(scopeName.contains("\\")){
-			scopeName = scopeName.replace("\\", "\\\\");
-		}
-		String query = "from PolicyVersion where POLICY_NAME like :scopeName";
-		String scopeNamequery = "from PolicyEditorScopes where SCOPENAME like :scopeName";
+    //Get the List of Policies and Scopes for Showing in Editor tab
+    private JSONObject list(JSONObject params, HttpServletRequest request) throws ServletException {
+        Set<String> scopes = null;
+        List<String> roles = null;
+        try {
+            PolicyController controller = getPolicyControllerInstance();
+            //Get the Login Id of the User from Request
+            String testUserID = getTestUserId();
+            String userId =  testUserID != null ? testUserID : UserUtils.getUserSession(request).getOrgUserId();
+            List<Object> userRoles = controller.getRoles(userId);
+            Pair<Set<String>, List<String>> pair = org.onap.policy.utils.UserUtils.checkRoleAndScope(userRoles);
+            roles = pair.u;
+            scopes = pair.t;
 
-		SimpleBindings params = new SimpleBindings();
-		params.put("scopeName", scopeName + "%");
+            List<JSONObject> resultList = new ArrayList<>();
+            boolean onlyFolders = params.getBoolean("onlyFolders");
+            String path = params.getString("path");
+            if(path.contains("..xml")){
+                path = path.replaceAll("..xml", "").trim();
+            }
 
-		List<Object> activePolicies;
-		List<Object> scopesList;
-		if(PolicyController.isjUnit()){
-			activePolicies = controller.getDataByQuery(query, null);
-			scopesList = controller.getDataByQuery(scopeNamequery, null);
-		}else{
-			activePolicies = controller.getDataByQuery(query, params);
-			scopesList = controller.getDataByQuery(scopeNamequery, params);
-		}
-		for(Object list : scopesList){
-			PolicyEditorScopes scopeById = (PolicyEditorScopes) list;
-			String scope = scopeById.getScopeName();
-			if(scope.contains(File.separator)){
-				String checkScope = scope.substring(0, scope.lastIndexOf(File.separator));
-				if(scopeName.contains("\\\\")){
-					scopeName = scopeName.replace("\\\\", File.separator);
-				}
-				if(scope.contains(File.separator)){
-					scope = scope.substring(checkScope.length()+1);
-					if(scope.contains(File.separator)){
-						scope = scope.substring(0, scope.indexOf(File.separator));
-					}
-				}
-				if(scopeName.equalsIgnoreCase(checkScope)){
-					JSONObject el = new JSONObject();
-					el.put("name", scope);
-					el.put("date", scopeById.getModifiedDate());
-					el.put("size", "");
-					el.put("type", "dir");
-					el.put("createdBy", scopeById.getUserCreatedBy().getUserName());
-					el.put("modifiedBy", scopeById.getUserModifiedBy().getUserName());
-					resultList.add(el);
-				}
-			}
-		}
-		String scopeNameCheck;
-		for (Object list : activePolicies) {
-			PolicyVersion policy = (PolicyVersion) list;
-			String scopeNameValue = policy.getPolicyName().substring(0, policy.getPolicyName().lastIndexOf(File.separator));
-			if(roles.contains(SUPERADMIN) || roles.contains(SUPEREDITOR) || roles.contains(SUPERGUEST)){
-				if(scopeName.contains("\\\\")){
-					scopeNameCheck = scopeName.replace("\\\\", File.separator);
-				}else{
-					scopeNameCheck = scopeName;
-				}
-				if(scopeNameValue.equals(scopeNameCheck)){
-					JSONObject el = new JSONObject();
-					el.put("name", policy.getPolicyName().substring(policy.getPolicyName().lastIndexOf(File.separator)+1));
-					el.put("date", policy.getModifiedDate());
-					el.put("version", policy.getActiveVersion());
-					el.put("size", "");
-					el.put("type", "file");
-					el.put("createdBy", getUserName(policy.getCreatedBy()));
-					el.put("modifiedBy", getUserName(policy.getModifiedBy()));
-					resultList.add(el);
-				}
-			}else if(!scopes.isEmpty() && scopes.contains(scopeNameValue)){
-					JSONObject el = new JSONObject();
-					el.put("name", policy.getPolicyName().substring(policy.getPolicyName().lastIndexOf(File.separator)+1));
-					el.put("date", policy.getModifiedDate());
-					el.put("version", policy.getActiveVersion());
-					el.put("size", "");
-					el.put("type", "file");
-					el.put("createdBy", getUserName(policy.getCreatedBy()));
-					el.put("modifiedBy", getUserName(policy.getModifiedBy()));
-					resultList.add(el);
-			}
-		}
-	}
+            if (roles.contains(ADMIN) || roles.contains(EDITOR) || roles.contains(GUEST) ) {
+                if(scopes.isEmpty()){
+                    return error("No Scopes has been Assigned to the User. Please, Contact Super-Admin");
+                }else{
+                    if(!"/".equals(path)){
+                        String tempScope = path.substring(1, path.length());
+                        tempScope = tempScope.replace("/", File.separator);
+                        scopes.add(tempScope);
+                    }
+                }
+            }
 
-	private String getUserName(String loginId){
-		PolicyController controller = getPolicyControllerInstance();
-		UserInfo userInfo = (UserInfo) controller.getEntityItem(UserInfo.class, "userLoginId", loginId);
-		if(userInfo == null){
-			return SUPERADMIN;
-		}
-		return userInfo.getUserName();
-	}
+            if("/".equals(path)){
+                if(roles.contains(SUPERADMIN) || roles.contains(SUPEREDITOR) || roles.contains(SUPERGUEST)){
+                    List<Object> scopesList = queryPolicyEditorScopes(null);
+                    for(Object list : scopesList){
+                        PolicyEditorScopes scope = (PolicyEditorScopes) list;
+                        if(!(scope.getScopeName().contains(File.separator))){
+                            JSONObject el = new JSONObject();
+                            el.put(NAME, scope.getScopeName());
+                            el.put(DATE, scope.getModifiedDate());
+                            el.put(SIZE, "");
+                            el.put(TYPE, "dir");
+                            el.put(CREATED_BY, scope.getUserCreatedBy().getUserName());
+                            el.put(MODIFIED_BY, scope.getUserModifiedBy().getUserName());
+                            resultList.add(el);
+                        }
+                    }
+                }else if(roles.contains(ADMIN) || roles.contains(EDITOR) || roles.contains(GUEST)){
+                    for(Object scope : scopes){
+                        JSONObject el = new JSONObject();
+                        List<Object> scopesList = queryPolicyEditorScopes(scope.toString());
+                        if(!scopesList.isEmpty()){
+                            PolicyEditorScopes scopeById = (PolicyEditorScopes) scopesList.get(0);
+                            el.put(NAME, scopeById.getScopeName());
+                            el.put(DATE, scopeById.getModifiedDate());
+                            el.put(SIZE, "");
+                            el.put(TYPE, "dir");
+                            el.put(CREATED_BY, scopeById.getUserCreatedBy().getUserName());
+                            el.put(MODIFIED_BY, scopeById.getUserModifiedBy().getUserName());
+                            resultList.add(el);
+                        }
+                    }
+                }
+            }else{
+                try{
+                    String scopeName = path.substring(path.indexOf('/') +1);
+                    activePolicyList(scopeName, resultList, roles, scopes, onlyFolders);
+                } catch (Exception ex) {
+                    LOGGER.error("Error Occured While reading Policy Files List"+ex );
+                }
+            }
 
-	//Rename Policy
-	private JSONObject rename(JSONObject params, HttpServletRequest request) throws ServletException {
-		try {
-			boolean isActive = false;
-			List<String> policyActiveInPDP = new ArrayList<>();
-			Set<String>  scopeOfPolicyActiveInPDP = new HashSet<>();
-			String userId = UserUtils.getUserSession(request).getOrgUserId();
-			String oldPath = params.getString("path");
-			String newPath = params.getString("newPath");
-			oldPath = oldPath.substring(oldPath.indexOf('/')+1);
-			newPath = newPath.substring(newPath.indexOf('/')+1);
-			String checkValidation = null;
-			if(oldPath.endsWith(".xml")){
-				checkValidation = newPath.replace(".xml", "");
-				checkValidation = checkValidation.substring(checkValidation.indexOf('_') + 1, checkValidation.lastIndexOf("."));
-				checkValidation = checkValidation.substring(checkValidation.lastIndexOf("/")+1);
-				if(!PolicyUtils.policySpecialCharValidator(checkValidation).contains("success")){
-					return error("Policy Rename Failed. The Name contains special characters.");
-				}
-				JSONObject result = policyRename(oldPath, newPath, userId);
-				if(!(Boolean)(result.getJSONObject("result").get("success"))){
-					return result;
-				}
-			}else{
-				String scopeName = oldPath;
-				String newScopeName = newPath;
-				if(scopeName.contains("/")){
-					scopeName = scopeName.replace("/", File.separator);
-					newScopeName = newScopeName.replace("/", File.separator);
-				}
-				checkValidation = newScopeName.substring(newScopeName.lastIndexOf(File.separator)+1);
+            return new JSONObject().put(RESULT, resultList);
+        } catch (Exception e) {
+            LOGGER.error("list", e);
+            return error(e.getMessage());
+        }
+    }
+
+    private List<Object> queryPolicyEditorScopes(String scopeName){
+        String scopeNamequery;
+        SimpleBindings params = new SimpleBindings();
+        if(scopeName == null){
+            scopeNamequery = "from PolicyEditorScopes";
+        }else{
+            scopeNamequery = "from PolicyEditorScopes where SCOPENAME like :scopeName";
+            params.put("scopeName", scopeName + "%");
+        }
+        PolicyController controller = getPolicyControllerInstance();
+        List<Object> scopesList;
+        if(PolicyController.isjUnit()){
+            scopesList = controller.getDataByQuery(scopeNamequery, null);
+        }else{
+            scopesList = controller.getDataByQuery(scopeNamequery, params);
+        }
+        return  scopesList;
+    }
+
+    //Get Active Policy List based on Scope Selection form Policy Version table
+    private void activePolicyList(String inScopeName, List<JSONObject> resultList, List<String> roles, Set<String> scopes, boolean onlyFolders){
+        PolicyController controller = getPolicyControllerInstance();
+        String scopeName = inScopeName;
+        if(scopeName.contains("/")){
+            scopeName = scopeName.replace("/", File.separator);
+        }
+        if(scopeName.contains("\\")){
+            scopeName = scopeName.replace("\\", "\\\\");
+        }
+        String query = "from PolicyVersion where POLICY_NAME like :scopeName";
+        String scopeNamequery = "from PolicyEditorScopes where SCOPENAME like :scopeName";
+
+        SimpleBindings params = new SimpleBindings();
+        params.put("scopeName", scopeName + "%");
+
+        List<Object> activePolicies;
+        List<Object> scopesList;
+        if(PolicyController.isjUnit()){
+            activePolicies = controller.getDataByQuery(query, null);
+            scopesList = controller.getDataByQuery(scopeNamequery, null);
+        }else{
+            activePolicies = controller.getDataByQuery(query, params);
+            scopesList = controller.getDataByQuery(scopeNamequery, params);
+        }
+        for(Object list : scopesList){
+            PolicyEditorScopes scopeById = (PolicyEditorScopes) list;
+            String scope = scopeById.getScopeName();
+            if(scope.contains(File.separator)){
+                String checkScope = scope.substring(0, scope.lastIndexOf(File.separator));
+                if(scopeName.contains("\\\\")){
+                    scopeName = scopeName.replace("\\\\", File.separator);
+                }
+                if(scope.contains(File.separator)){
+                    scope = scope.substring(checkScope.length()+1);
+                    if(scope.contains(File.separator)){
+                        scope = scope.substring(0, scope.indexOf(File.separator));
+                    }
+                }
+                if(scopeName.equalsIgnoreCase(checkScope)){
+                    JSONObject el = new JSONObject();
+                    el.put(NAME, scope);
+                    el.put(DATE, scopeById.getModifiedDate());
+                    el.put(SIZE, "");
+                    el.put(TYPE, "dir");
+                    el.put(CREATED_BY, scopeById.getUserCreatedBy().getUserName());
+                    el.put(MODIFIED_BY, scopeById.getUserModifiedBy().getUserName());
+                    resultList.add(el);
+                }
+            }
+        }
+        String scopeNameCheck;
+        for (Object list : activePolicies) {
+            PolicyVersion policy = (PolicyVersion) list;
+            String scopeNameValue = policy.getPolicyName().substring(0, policy.getPolicyName().lastIndexOf(File.separator));
+            if(roles.contains(SUPERADMIN) || roles.contains(SUPEREDITOR) || roles.contains(SUPERGUEST)){
+                if(scopeName.contains("\\\\")){
+                    scopeNameCheck = scopeName.replace("\\\\", File.separator);
+                }else{
+                    scopeNameCheck = scopeName;
+                }
+                if(scopeNameValue.equals(scopeNameCheck)){
+                    JSONObject el = new JSONObject();
+                    el.put(NAME, policy.getPolicyName().substring(policy.getPolicyName().lastIndexOf(File.separator)+1));
+                    el.put(DATE, policy.getModifiedDate());
+                    el.put(VERSION, policy.getActiveVersion());
+                    el.put(SIZE, "");
+                    el.put(TYPE, "file");
+                    el.put(CREATED_BY, getUserName(policy.getCreatedBy()));
+                    el.put(MODIFIED_BY, getUserName(policy.getModifiedBy()));
+                    resultList.add(el);
+                }
+            }else if(!scopes.isEmpty() && scopes.contains(scopeNameValue)){
+                JSONObject el = new JSONObject();
+                el.put(NAME, policy.getPolicyName().substring(policy.getPolicyName().lastIndexOf(File.separator)+1));
+                el.put(DATE, policy.getModifiedDate());
+                el.put(VERSION, policy.getActiveVersion());
+                el.put(SIZE, "");
+                el.put(TYPE, "file");
+                el.put(CREATED_BY, getUserName(policy.getCreatedBy()));
+                el.put(MODIFIED_BY, getUserName(policy.getModifiedBy()));
+                resultList.add(el);
+            }
+        }
+    }
+
+    private String getUserName(String loginId){
+        PolicyController controller = getPolicyControllerInstance();
+        UserInfo userInfo = (UserInfo) controller.getEntityItem(UserInfo.class, "userLoginId", loginId);
+        if(userInfo == null){
+            return SUPERADMIN;
+        }
+        return userInfo.getUserName();
+    }
+
+    //Rename Policy
+    private JSONObject rename(JSONObject params, HttpServletRequest request) throws ServletException {
+        try {
+            boolean isActive = false;
+            List<String> policyActiveInPDP = new ArrayList<>();
+            Set<String>  scopeOfPolicyActiveInPDP = new HashSet<>();
+            String userId = UserUtils.getUserSession(request).getOrgUserId();
+            String oldPath = params.getString("path");
+            String newPath = params.getString("newPath");
+            oldPath = oldPath.substring(oldPath.indexOf('/')+1);
+            newPath = newPath.substring(newPath.indexOf('/')+1);
+            String checkValidation = null;
+            if(oldPath.endsWith(".xml")){
+                checkValidation = newPath.replace(".xml", "");
+                checkValidation = checkValidation.substring(checkValidation.indexOf('_') + 1, checkValidation.lastIndexOf("."));
+                checkValidation = checkValidation.substring(checkValidation.lastIndexOf("/")+1);
+                if(!PolicyUtils.policySpecialCharValidator(checkValidation).contains("success")){
+                    return error("Policy Rename Failed. The Name contains special characters.");
+                }
+                JSONObject result = policyRename(oldPath, newPath, userId);
+                if(!(Boolean)(result.getJSONObject("result").get("success"))){
+                    return result;
+                }
+            }else{
+                String scopeName = oldPath;
+                String newScopeName = newPath;
+                if(scopeName.contains("/")){
+                    scopeName = scopeName.replace("/", File.separator);
+                    newScopeName = newScopeName.replace("/", File.separator);
+                }
+                checkValidation = newScopeName.substring(newScopeName.lastIndexOf(File.separator)+1);
                 if(scopeName.contains("\\")){
                     scopeName = scopeName.replace("\\", "\\\\\\\\");
                     newScopeName = newScopeName.replace("\\", "\\\\\\\\");
@@ -777,783 +801,783 @@
                 if(!PolicyUtils.policySpecialCharValidator(checkValidation).contains("success")){
                     return error("Scope Rename Failed. The Name contains special characters.");
                 }
-				PolicyController controller = getPolicyControllerInstance();
-				String query = "from PolicyVersion where POLICY_NAME like :scopeName";
-				String scopeNamequery = "from PolicyEditorScopes where SCOPENAME like :scopeName";
-				SimpleBindings pvParams = new SimpleBindings();
-				pvParams.put("scopeName", scopeName + "%");
-				List<Object> activePolicies = controller.getDataByQuery(query, pvParams);
-				List<Object> scopesList = controller.getDataByQuery(scopeNamequery, pvParams);
-				for(Object object : activePolicies){
-					PolicyVersion activeVersion = (PolicyVersion) object;
-					String policyOldPath = activeVersion.getPolicyName().replace(File.separator, "/") + "." + activeVersion.getActiveVersion() + ".xml";
-					String policyNewPath = policyOldPath.replace(oldPath, newPath);
-					JSONObject result = policyRename(policyOldPath, policyNewPath, userId);
-					if(!(Boolean)(result.getJSONObject("result").get("success"))){
-						isActive = true;
-						policyActiveInPDP.add(policyOldPath);
-						String scope = policyOldPath.substring(0, policyOldPath.lastIndexOf('/'));
-						scopeOfPolicyActiveInPDP.add(scope.replace("/", File.separator));
-					}
-				}
-				boolean rename = false;
-				if(activePolicies.size() != policyActiveInPDP.size()){
-					rename = true;
-				}
+                PolicyController controller = getPolicyControllerInstance();
+                String query = "from PolicyVersion where POLICY_NAME like :scopeName";
+                String scopeNamequery = "from PolicyEditorScopes where SCOPENAME like :scopeName";
+                SimpleBindings pvParams = new SimpleBindings();
+                pvParams.put("scopeName", scopeName + "%");
+                List<Object> activePolicies = controller.getDataByQuery(query, pvParams);
+                List<Object> scopesList = controller.getDataByQuery(scopeNamequery, pvParams);
+                for(Object object : activePolicies){
+                    PolicyVersion activeVersion = (PolicyVersion) object;
+                    String policyOldPath = activeVersion.getPolicyName().replace(File.separator, "/") + "." + activeVersion.getActiveVersion() + ".xml";
+                    String policyNewPath = policyOldPath.replace(oldPath, newPath);
+                    JSONObject result = policyRename(policyOldPath, policyNewPath, userId);
+                    if(!(Boolean)(result.getJSONObject("result").get("success"))){
+                        isActive = true;
+                        policyActiveInPDP.add(policyOldPath);
+                        String scope = policyOldPath.substring(0, policyOldPath.lastIndexOf('/'));
+                        scopeOfPolicyActiveInPDP.add(scope.replace("/", File.separator));
+                    }
+                }
+                boolean rename = false;
+                if(activePolicies.size() != policyActiveInPDP.size()){
+                    rename = true;
+                }
 
-				UserInfo userInfo = new UserInfo();
-				userInfo.setUserLoginId(userId);
-				if(policyActiveInPDP.isEmpty()){
-					renameScope(scopesList, scopeName, newScopeName, controller);
-				}else if(rename){
-					renameScope(scopesList, scopeName, newScopeName, controller);
-					for(String scope : scopeOfPolicyActiveInPDP){
-						PolicyEditorScopes editorScopeEntity = new PolicyEditorScopes();
-						editorScopeEntity.setScopeName(scope.replace("\\", "\\\\\\\\"));
-						editorScopeEntity.setUserCreatedBy(userInfo);
-						editorScopeEntity.setUserModifiedBy(userInfo);
-						controller.saveData(editorScopeEntity);
-					}
-				}
-				if(isActive){
-					return error("The Following policies rename failed. Since they are active in PDP Groups" +policyActiveInPDP);
-				}
-			}
-			return success();
-		} catch (Exception e) {
-			LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE+"Exception Occured While Renaming Policy"+e);
-			return error(e.getMessage());
-		}
-	}
+                UserInfo userInfo = new UserInfo();
+                userInfo.setUserLoginId(userId);
+                if(policyActiveInPDP.isEmpty()){
+                    renameScope(scopesList, scopeName, newScopeName, controller);
+                }else if(rename){
+                    renameScope(scopesList, scopeName, newScopeName, controller);
+                    for(String scope : scopeOfPolicyActiveInPDP){
+                        PolicyEditorScopes editorScopeEntity = new PolicyEditorScopes();
+                        editorScopeEntity.setScopeName(scope.replace("\\", "\\\\\\\\"));
+                        editorScopeEntity.setUserCreatedBy(userInfo);
+                        editorScopeEntity.setUserModifiedBy(userInfo);
+                        controller.saveData(editorScopeEntity);
+                    }
+                }
+                if(isActive){
+                    return error("The Following policies rename failed. Since they are active in PDP Groups" +policyActiveInPDP);
+                }
+            }
+            return success();
+        } catch (Exception e) {
+            LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE+"Exception Occured While Renaming Policy"+e);
+            return error(e.getMessage());
+        }
+    }
 
-	private void renameScope(List<Object> scopesList, String inScopeName, String newScopeName, PolicyController controller){
-		for(Object object : scopesList){
-			PolicyEditorScopes editorScopeEntity = (PolicyEditorScopes) object;
-			String scopeName = inScopeName;
-			if(scopeName.contains("\\\\\\\\")){
-				scopeName = scopeName.replace("\\\\\\\\", File.separator);
-				newScopeName = newScopeName.replace("\\\\\\\\", File.separator);
-			}
-			String scope = editorScopeEntity.getScopeName().replace(scopeName, newScopeName);
-			editorScopeEntity.setScopeName(scope);
-			controller.updateData(editorScopeEntity);
-		}
-	}
+    private void renameScope(List<Object> scopesList, String inScopeName, String newScopeName, PolicyController controller){
+        for(Object object : scopesList){
+            PolicyEditorScopes editorScopeEntity = (PolicyEditorScopes) object;
+            String scopeName = inScopeName;
+            if(scopeName.contains("\\\\\\\\")){
+                scopeName = scopeName.replace("\\\\\\\\", File.separator);
+                newScopeName = newScopeName.replace("\\\\\\\\", File.separator);
+            }
+            String scope = editorScopeEntity.getScopeName().replace(scopeName, newScopeName);
+            editorScopeEntity.setScopeName(scope);
+            controller.updateData(editorScopeEntity);
+        }
+    }
 
-	private JSONObject policyRename(String oldPath, String newPath, String userId) throws ServletException {
-		try {
-			PolicyEntity entity;
-			PolicyController controller = getPolicyControllerInstance();
+    private JSONObject policyRename(String oldPath, String newPath, String userId) throws ServletException {
+        try {
+            PolicyEntity entity;
+            PolicyController controller = getPolicyControllerInstance();
 
-			String policyVersionName = newPath.replace(".xml", "");
-			String policyName = policyVersionName.substring(0, policyVersionName.lastIndexOf('.')).replace("/", File.separator);
+            String policyVersionName = newPath.replace(".xml", "");
+            String policyName = policyVersionName.substring(0, policyVersionName.lastIndexOf('.')).replace("/", File.separator);
 
-			String oldpolicyVersionName = oldPath.replace(".xml", "");
-			String oldpolicyName = oldpolicyVersionName.substring(0, oldpolicyVersionName.lastIndexOf('.')).replace("/", File.separator);
+            String oldpolicyVersionName = oldPath.replace(".xml", "");
+            String oldpolicyName = oldpolicyVersionName.substring(0, oldpolicyVersionName.lastIndexOf('.')).replace("/", File.separator);
 
-			String newpolicyName = newPath.replace("/", ".");
-			String newPolicyCheck = newpolicyName;
-			if(newPolicyCheck.contains("Config_")){
-				newPolicyCheck = newPolicyCheck.replace(".Config_", ":Config_");
-			}else if(newPolicyCheck.contains("Action_")){
-				newPolicyCheck = newPolicyCheck.replace(".Action_", ":Action_");
-			}else if(newPolicyCheck.contains("Decision_")){
-				newPolicyCheck = newPolicyCheck.replace(".Decision_", ":Decision_");
-			}
-			String[] newPolicySplit = newPolicyCheck.split(":");
+            String newpolicyName = newPath.replace("/", ".");
+            String newPolicyCheck = newpolicyName;
+            if(newPolicyCheck.contains("Config_")){
+                newPolicyCheck = newPolicyCheck.replace(".Config_", ":Config_");
+            }else if(newPolicyCheck.contains("Action_")){
+                newPolicyCheck = newPolicyCheck.replace(".Action_", ":Action_");
+            }else if(newPolicyCheck.contains("Decision_")){
+                newPolicyCheck = newPolicyCheck.replace(".Decision_", ":Decision_");
+            }
+            String[] newPolicySplit = newPolicyCheck.split(":");
 
-			String orignalPolicyName = oldPath.replace("/", ".");
-			String oldPolicyCheck = orignalPolicyName;
-			if(oldPolicyCheck.contains("Config_")){
-				oldPolicyCheck = oldPolicyCheck.replace(".Config_", ":Config_");
-			}else if(oldPolicyCheck.contains("Action_")){
-				oldPolicyCheck = oldPolicyCheck.replace(".Action_", ":Action_");
-			}else if(oldPolicyCheck.contains("Decision_")){
-				oldPolicyCheck = oldPolicyCheck.replace(".Decision_", ":Decision_");
-			}
-			String[] oldPolicySplit = oldPolicyCheck.split(":");
+            String orignalPolicyName = oldPath.replace("/", ".");
+            String oldPolicyCheck = orignalPolicyName;
+            if(oldPolicyCheck.contains("Config_")){
+                oldPolicyCheck = oldPolicyCheck.replace(".Config_", ":Config_");
+            }else if(oldPolicyCheck.contains("Action_")){
+                oldPolicyCheck = oldPolicyCheck.replace(".Action_", ":Action_");
+            }else if(oldPolicyCheck.contains("Decision_")){
+                oldPolicyCheck = oldPolicyCheck.replace(".Decision_", ":Decision_");
+            }
+            String[] oldPolicySplit = oldPolicyCheck.split(":");
 
-			//Check PolicyEntity table with newPolicy Name
-			String policyEntityquery = "FROM PolicyEntity where policyName = :newPolicySplit_1 and scope = :newPolicySplit_0";
-			SimpleBindings policyParams = new SimpleBindings();
-			policyParams.put("newPolicySplit_1", newPolicySplit[1]);
-			policyParams.put("newPolicySplit_0", newPolicySplit[0]);
-			List<Object> queryData = controller.getDataByQuery(policyEntityquery, policyParams);
-			if(!queryData.isEmpty()){
-				return error("Policy rename failed. Since, the policy with same name already exists.");
-			}
+            //Check PolicyEntity table with newPolicy Name
+            String policyEntityquery = "FROM PolicyEntity where policyName = :newPolicySplit_1 and scope = :newPolicySplit_0";
+            SimpleBindings policyParams = new SimpleBindings();
+            policyParams.put("newPolicySplit_1", newPolicySplit[1]);
+            policyParams.put("newPolicySplit_0", newPolicySplit[0]);
+            List<Object> queryData = controller.getDataByQuery(policyEntityquery, policyParams);
+            if(!queryData.isEmpty()){
+                return error("Policy rename failed. Since, the policy with same name already exists.");
+            }
 
-			//Query the Policy Entity with oldPolicy Name
-			String policyEntityCheck = oldPolicySplit[1].substring(0, oldPolicySplit[1].indexOf('.'));
-			String oldpolicyEntityquery = "FROM PolicyEntity where policyName like :policyEntityCheck and scope = :oldPolicySplit_0";
-			SimpleBindings params = new SimpleBindings();
-			params.put("policyEntityCheck", policyEntityCheck + "%");
-			params.put("oldPolicySplit_0", oldPolicySplit[0]);
-			List<Object> oldEntityData = controller.getDataByQuery(oldpolicyEntityquery, params);
-			if(!oldEntityData.isEmpty()){
-				StringBuilder groupQuery = new StringBuilder();
-				groupQuery.append("FROM PolicyGroupEntity where (");
-				SimpleBindings geParams = new SimpleBindings();
-				for(int i=0; i<oldEntityData.size(); i++){
-					entity = (PolicyEntity) oldEntityData.get(i);
-					if(i == 0){
-						groupQuery.append("policyid = :policyId");
-						geParams.put("policyId", entity.getPolicyId());
-					}else{
-						groupQuery.append(" or policyid = :policyId" + i);
-						geParams.put("policyId" + i, entity.getPolicyId());
-					}
-				}
-				groupQuery.append(")");
-				List<Object> groupEntityData = controller.getDataByQuery(groupQuery.toString(), geParams);
-				if(! groupEntityData.isEmpty()){
-					return error("Policy rename failed. Since the policy or its version is active in PDP Groups.");
-				}
-				for(int i=0; i<oldEntityData.size(); i++){
-					entity = (PolicyEntity) oldEntityData.get(i);
-					String checkEntityName = entity.getPolicyName().replace(".xml", "");
+            //Query the Policy Entity with oldPolicy Name
+            String policyEntityCheck = oldPolicySplit[1].substring(0, oldPolicySplit[1].indexOf('.'));
+            String oldpolicyEntityquery = "FROM PolicyEntity where policyName like :policyEntityCheck and scope = :oldPolicySplit_0";
+            SimpleBindings params = new SimpleBindings();
+            params.put("policyEntityCheck", policyEntityCheck + "%");
+            params.put("oldPolicySplit_0", oldPolicySplit[0]);
+            List<Object> oldEntityData = controller.getDataByQuery(oldpolicyEntityquery, params);
+            if(!oldEntityData.isEmpty()){
+                StringBuilder groupQuery = new StringBuilder();
+                groupQuery.append("FROM PolicyGroupEntity where (");
+                SimpleBindings geParams = new SimpleBindings();
+                for(int i=0; i<oldEntityData.size(); i++){
+                    entity = (PolicyEntity) oldEntityData.get(i);
+                    if(i == 0){
+                        groupQuery.append("policyid = :policyId");
+                        geParams.put("policyId", entity.getPolicyId());
+                    }else{
+                        groupQuery.append(" or policyid = :policyId" + i);
+                        geParams.put("policyId" + i, entity.getPolicyId());
+                    }
+                }
+                groupQuery.append(")");
+                List<Object> groupEntityData = controller.getDataByQuery(groupQuery.toString(), geParams);
+                if(! groupEntityData.isEmpty()){
+                    return error("Policy rename failed. Since the policy or its version is active in PDP Groups.");
+                }
+                for(int i=0; i<oldEntityData.size(); i++){
+                    entity = (PolicyEntity) oldEntityData.get(i);
+                    String checkEntityName = entity.getPolicyName().replace(".xml", "");
                     checkEntityName = checkEntityName.substring(0, checkEntityName.lastIndexOf('.'));
                     String originalPolicyName = oldpolicyName.substring(oldpolicyName.lastIndexOf(File.separator)+1);
                     if(checkEntityName.equals(originalPolicyName)){
                         checkOldPolicyEntryAndUpdate(entity, newPolicySplit[0] , newPolicySplit[1], oldPolicySplit[0], oldPolicySplit[1], policyName, newpolicyName, oldpolicyName, userId);
                     }
-				}
-			}else{
-				return error("Policy rename failed due to policy not able to retrieve from database. Please, contact super-admin.");
-			}
+                }
+            }else{
+                return error("Policy rename failed due to policy not able to retrieve from database. Please, contact super-admin.");
+            }
 
-			return success();
-		} catch (Exception e) {
-			LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE+"Exception Occured While Renaming Policy"+e);
-			return error(e.getMessage());
-		}
-	}
+            return success();
+        } catch (Exception e) {
+            LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE+"Exception Occured While Renaming Policy"+e);
+            return error(e.getMessage());
+        }
+    }
 
-	private JSONObject checkOldPolicyEntryAndUpdate(PolicyEntity entity, String newScope, String removenewPolicyExtension, String oldScope, String removeoldPolicyExtension,
-			String policyName, String  newpolicyName, String oldpolicyName, String userId) throws ServletException{
-		try {
-			ConfigurationDataEntity configEntity = entity.getConfigurationData();
-			ActionBodyEntity actionEntity = entity.getActionBodyEntity();
-			PolicyController controller = getPolicyControllerInstance();
+    private JSONObject checkOldPolicyEntryAndUpdate(PolicyEntity entity, String newScope, String removenewPolicyExtension, String oldScope, String removeoldPolicyExtension,
+                                                    String policyName, String  newpolicyName, String oldpolicyName, String userId) throws ServletException{
+        try {
+            ConfigurationDataEntity configEntity = entity.getConfigurationData();
+            ActionBodyEntity actionEntity = entity.getActionBodyEntity();
+            PolicyController controller = getPolicyControllerInstance();
 
-			String oldPolicyNameWithoutExtension = removeoldPolicyExtension;
-			String newPolicyNameWithoutExtension = removenewPolicyExtension;
-			if(removeoldPolicyExtension.endsWith(".xml")){
-				oldPolicyNameWithoutExtension = oldPolicyNameWithoutExtension.substring(0, oldPolicyNameWithoutExtension.indexOf('.'));
-				newPolicyNameWithoutExtension = newPolicyNameWithoutExtension.substring(0, newPolicyNameWithoutExtension.indexOf('.'));
-			}
-			entity.setPolicyName(entity.getPolicyName().replace(oldPolicyNameWithoutExtension, newPolicyNameWithoutExtension));
-			entity.setPolicyData(entity.getPolicyData().replace(oldScope +"."+oldPolicyNameWithoutExtension, newScope+"."+newPolicyNameWithoutExtension));
-			entity.setScope(newScope);
-			entity.setModifiedBy(userId);
-			
-			String oldConfigurationName = null;
-			String newConfigurationName = null;
-			if(newpolicyName.contains("Config_")){
-				oldConfigurationName = configEntity.getConfigurationName();
-				configEntity.setConfigurationName(configEntity.getConfigurationName().replace(oldScope +"."+oldPolicyNameWithoutExtension, newScope+"."+newPolicyNameWithoutExtension));
-				controller.updateData(configEntity);
-				newConfigurationName = configEntity.getConfigurationName();
-				File file = new File(PolicyController.getConfigHome() + File.separator + oldConfigurationName);
-				if(file.exists()){
-					File renamefile = new File(PolicyController.getConfigHome() + File.separator + newConfigurationName);
-					file.renameTo(renamefile);
-				}
-			}else if(newpolicyName.contains("Action_")){
-				oldConfigurationName = actionEntity.getActionBodyName();
-				actionEntity.setActionBody(actionEntity.getActionBody().replace(oldScope +"."+oldPolicyNameWithoutExtension, newScope+"."+newPolicyNameWithoutExtension));
-				controller.updateData(actionEntity);
-				newConfigurationName = actionEntity.getActionBodyName();
-				File file = new File(PolicyController.getActionHome() + File.separator + oldConfigurationName);
-				if(file.exists()){
-					File renamefile = new File(PolicyController.getActionHome() + File.separator + newConfigurationName);
-					file.renameTo(renamefile);
-				}
-			}
-			controller.updateData(entity);
+            String oldPolicyNameWithoutExtension = removeoldPolicyExtension;
+            String newPolicyNameWithoutExtension = removenewPolicyExtension;
+            if(removeoldPolicyExtension.endsWith(".xml")){
+                oldPolicyNameWithoutExtension = oldPolicyNameWithoutExtension.substring(0, oldPolicyNameWithoutExtension.indexOf('.'));
+                newPolicyNameWithoutExtension = newPolicyNameWithoutExtension.substring(0, newPolicyNameWithoutExtension.indexOf('.'));
+            }
+            entity.setPolicyName(entity.getPolicyName().replace(oldPolicyNameWithoutExtension, newPolicyNameWithoutExtension));
+            entity.setPolicyData(entity.getPolicyData().replace(oldScope +"."+oldPolicyNameWithoutExtension, newScope+"."+newPolicyNameWithoutExtension));
+            entity.setScope(newScope);
+            entity.setModifiedBy(userId);
 
-			PolicyRestController restController = new PolicyRestController();
-			restController.notifyOtherPAPSToUpdateConfigurations("rename", newConfigurationName, oldConfigurationName);
-			PolicyVersion versionEntity = (PolicyVersion) controller.getEntityItem(PolicyVersion.class, "policyName", oldpolicyName);
-			versionEntity.setPolicyName(policyName);
-			versionEntity.setModifiedBy(userId);
-			controller.updateData(versionEntity);
-			String movePolicyCheck = policyName.substring(policyName.lastIndexOf(File.separator)+1);
-			String moveOldPolicyCheck = oldpolicyName.substring(oldpolicyName.lastIndexOf(File.separator)+1);
-			if(movePolicyCheck.equals(moveOldPolicyCheck)){
-				controller.watchPolicyFunction(versionEntity, oldpolicyName, "Move");
-			}else{
-				controller.watchPolicyFunction(versionEntity, oldpolicyName, "Rename");
-			}
-			return success();
-		} catch (Exception e) {
-			LOGGER.error("Exception Occured"+e);
-			return error(e.getMessage());
-		}
-	}
+            String oldConfigurationName = null;
+            String newConfigurationName = null;
+            if(newpolicyName.contains("Config_")){
+                oldConfigurationName = configEntity.getConfigurationName();
+                configEntity.setConfigurationName(configEntity.getConfigurationName().replace(oldScope +"."+oldPolicyNameWithoutExtension, newScope+"."+newPolicyNameWithoutExtension));
+                controller.updateData(configEntity);
+                newConfigurationName = configEntity.getConfigurationName();
+                File file = new File(PolicyController.getConfigHome() + File.separator + oldConfigurationName);
+                if(file.exists()){
+                    File renamefile = new File(PolicyController.getConfigHome() + File.separator + newConfigurationName);
+                    file.renameTo(renamefile);
+                }
+            }else if(newpolicyName.contains("Action_")){
+                oldConfigurationName = actionEntity.getActionBodyName();
+                actionEntity.setActionBody(actionEntity.getActionBody().replace(oldScope +"."+oldPolicyNameWithoutExtension, newScope+"."+newPolicyNameWithoutExtension));
+                controller.updateData(actionEntity);
+                newConfigurationName = actionEntity.getActionBodyName();
+                File file = new File(PolicyController.getActionHome() + File.separator + oldConfigurationName);
+                if(file.exists()){
+                    File renamefile = new File(PolicyController.getActionHome() + File.separator + newConfigurationName);
+                    file.renameTo(renamefile);
+                }
+            }
+            controller.updateData(entity);
 
-	private JSONObject cloneRecord(String newpolicyName, String oldScope, String inRemoveoldPolicyExtension, String newScope, String inRemovenewPolicyExtension, PolicyEntity entity, String userId) throws ServletException{
-		String queryEntityName;
-		PolicyController controller = getPolicyControllerInstance();
-		PolicyEntity cloneEntity = new PolicyEntity();
-		cloneEntity.setPolicyName(newpolicyName);
-		String removeoldPolicyExtension = inRemoveoldPolicyExtension;
-		String removenewPolicyExtension = inRemovenewPolicyExtension;
-		removeoldPolicyExtension = removeoldPolicyExtension.replace(".xml", "");
-		removenewPolicyExtension = removenewPolicyExtension.replace(".xml", "");
-		cloneEntity.setPolicyData(entity.getPolicyData().replace(oldScope+"."+removeoldPolicyExtension, newScope+"."+removenewPolicyExtension));
-		cloneEntity.setScope(entity.getScope());
-		String oldConfigRemoveExtension = removeoldPolicyExtension.replace(".xml", "");
-		String newConfigRemoveExtension = removenewPolicyExtension.replace(".xml", "");
-		String newConfigurationName = null;
-		if(newpolicyName.contains("Config_")){
-			ConfigurationDataEntity configurationDataEntity = new ConfigurationDataEntity();
-			configurationDataEntity.setConfigurationName(entity.getConfigurationData().getConfigurationName().replace(oldScope+"."+oldConfigRemoveExtension, newScope+"."+newConfigRemoveExtension));
-			queryEntityName = configurationDataEntity.getConfigurationName();
-			configurationDataEntity.setConfigBody(entity.getConfigurationData().getConfigBody());
-			configurationDataEntity.setConfigType(entity.getConfigurationData().getConfigType());
-			configurationDataEntity.setDeleted(false);
-			configurationDataEntity.setCreatedBy(userId);
-			configurationDataEntity.setModifiedBy(userId);
-			controller.saveData(configurationDataEntity);
-			ConfigurationDataEntity configEntiy = (ConfigurationDataEntity) controller.getEntityItem(ConfigurationDataEntity.class, "configurationName", queryEntityName);
-			cloneEntity.setConfigurationData(configEntiy);
-			newConfigurationName = configEntiy.getConfigurationName();
-			try (FileWriter fw = new FileWriter(PolicyController.getConfigHome() + File.separator + newConfigurationName);
-					BufferedWriter bw = new BufferedWriter(fw)){
-				bw.write(configEntiy.getConfigBody());
-			} catch (IOException e) {
-				LOGGER.error("Exception Occured While cloning the configuration file"+e);
-			}
-		}else if(newpolicyName.contains("Action_")){
-			ActionBodyEntity actionBodyEntity = new ActionBodyEntity();
-			actionBodyEntity.setActionBodyName(entity.getActionBodyEntity().getActionBodyName().replace(oldScope+"."+oldConfigRemoveExtension, newScope+"."+newConfigRemoveExtension));
-			queryEntityName = actionBodyEntity.getActionBodyName();
-			actionBodyEntity.setActionBody(entity.getActionBodyEntity().getActionBody());
-			actionBodyEntity.setDeleted(false);
-			actionBodyEntity.setCreatedBy(userId);
-			actionBodyEntity.setModifiedBy(userId);
-			controller.saveData(actionBodyEntity);
-			ActionBodyEntity actionEntiy = (ActionBodyEntity) controller.getEntityItem(ActionBodyEntity.class, "actionBodyName", queryEntityName);
-			cloneEntity.setActionBodyEntity(actionEntiy);
-			newConfigurationName = actionEntiy.getActionBodyName();
-			 try (FileWriter fw = new FileWriter(PolicyController.getActionHome() + File.separator + newConfigurationName);
-					 BufferedWriter bw = new BufferedWriter(fw)){
-				 bw.write(actionEntiy.getActionBody());
-			 } catch (IOException e) {
-				LOGGER.error("Exception Occured While cloning the configuration file"+e);
-			}
-		}
-		
-		cloneEntity.setDeleted(entity.isDeleted());
-		cloneEntity.setCreatedBy(userId);
-		cloneEntity.setModifiedBy(userId);
-		controller.saveData(cloneEntity);
+            PolicyRestController restController = new PolicyRestController();
+            restController.notifyOtherPAPSToUpdateConfigurations("rename", newConfigurationName, oldConfigurationName);
+            PolicyVersion versionEntity = (PolicyVersion) controller.getEntityItem(PolicyVersion.class, "policyName", oldpolicyName);
+            versionEntity.setPolicyName(policyName);
+            versionEntity.setModifiedBy(userId);
+            controller.updateData(versionEntity);
+            String movePolicyCheck = policyName.substring(policyName.lastIndexOf(File.separator)+1);
+            String moveOldPolicyCheck = oldpolicyName.substring(oldpolicyName.lastIndexOf(File.separator)+1);
+            if(movePolicyCheck.equals(moveOldPolicyCheck)){
+                controller.watchPolicyFunction(versionEntity, oldpolicyName, "Move");
+            }else{
+                controller.watchPolicyFunction(versionEntity, oldpolicyName, "Rename");
+            }
+            return success();
+        } catch (Exception e) {
+            LOGGER.error("Exception Occured"+e);
+            return error(e.getMessage());
+        }
+    }
 
-		//Notify others paps regarding clone policy.
-		PolicyRestController restController = new PolicyRestController();
-		restController.notifyOtherPAPSToUpdateConfigurations("clonePolicy", newConfigurationName, null);
-		return success();
-	}
+    private JSONObject cloneRecord(String newpolicyName, String oldScope, String inRemoveoldPolicyExtension, String newScope, String inRemovenewPolicyExtension, PolicyEntity entity, String userId) throws ServletException{
+        String queryEntityName;
+        PolicyController controller = getPolicyControllerInstance();
+        PolicyEntity cloneEntity = new PolicyEntity();
+        cloneEntity.setPolicyName(newpolicyName);
+        String removeoldPolicyExtension = inRemoveoldPolicyExtension;
+        String removenewPolicyExtension = inRemovenewPolicyExtension;
+        removeoldPolicyExtension = removeoldPolicyExtension.replace(".xml", "");
+        removenewPolicyExtension = removenewPolicyExtension.replace(".xml", "");
+        cloneEntity.setPolicyData(entity.getPolicyData().replace(oldScope+"."+removeoldPolicyExtension, newScope+"."+removenewPolicyExtension));
+        cloneEntity.setScope(entity.getScope());
+        String oldConfigRemoveExtension = removeoldPolicyExtension.replace(".xml", "");
+        String newConfigRemoveExtension = removenewPolicyExtension.replace(".xml", "");
+        String newConfigurationName = null;
+        if(newpolicyName.contains("Config_")){
+            ConfigurationDataEntity configurationDataEntity = new ConfigurationDataEntity();
+            configurationDataEntity.setConfigurationName(entity.getConfigurationData().getConfigurationName().replace(oldScope+"."+oldConfigRemoveExtension, newScope+"."+newConfigRemoveExtension));
+            queryEntityName = configurationDataEntity.getConfigurationName();
+            configurationDataEntity.setConfigBody(entity.getConfigurationData().getConfigBody());
+            configurationDataEntity.setConfigType(entity.getConfigurationData().getConfigType());
+            configurationDataEntity.setDeleted(false);
+            configurationDataEntity.setCreatedBy(userId);
+            configurationDataEntity.setModifiedBy(userId);
+            controller.saveData(configurationDataEntity);
+            ConfigurationDataEntity configEntiy = (ConfigurationDataEntity) controller.getEntityItem(ConfigurationDataEntity.class, "configurationName", queryEntityName);
+            cloneEntity.setConfigurationData(configEntiy);
+            newConfigurationName = configEntiy.getConfigurationName();
+            try (FileWriter fw = new FileWriter(PolicyController.getConfigHome() + File.separator + newConfigurationName);
+                 BufferedWriter bw = new BufferedWriter(fw)){
+                bw.write(configEntiy.getConfigBody());
+            } catch (IOException e) {
+                LOGGER.error("Exception Occured While cloning the configuration file"+e);
+            }
+        }else if(newpolicyName.contains("Action_")){
+            ActionBodyEntity actionBodyEntity = new ActionBodyEntity();
+            actionBodyEntity.setActionBodyName(entity.getActionBodyEntity().getActionBodyName().replace(oldScope+"."+oldConfigRemoveExtension, newScope+"."+newConfigRemoveExtension));
+            queryEntityName = actionBodyEntity.getActionBodyName();
+            actionBodyEntity.setActionBody(entity.getActionBodyEntity().getActionBody());
+            actionBodyEntity.setDeleted(false);
+            actionBodyEntity.setCreatedBy(userId);
+            actionBodyEntity.setModifiedBy(userId);
+            controller.saveData(actionBodyEntity);
+            ActionBodyEntity actionEntiy = (ActionBodyEntity) controller.getEntityItem(ActionBodyEntity.class, "actionBodyName", queryEntityName);
+            cloneEntity.setActionBodyEntity(actionEntiy);
+            newConfigurationName = actionEntiy.getActionBodyName();
+            try (FileWriter fw = new FileWriter(PolicyController.getActionHome() + File.separator + newConfigurationName);
+                 BufferedWriter bw = new BufferedWriter(fw)){
+                bw.write(actionEntiy.getActionBody());
+            } catch (IOException e) {
+                LOGGER.error("Exception Occured While cloning the configuration file"+e);
+            }
+        }
 
-	//Clone the Policy
-	private JSONObject copy(JSONObject params, HttpServletRequest request) throws ServletException {
-		try {
-			String userId = UserUtils.getUserSession(request).getOrgUserId();
-			String oldPath = params.getString("path");
-			String newPath = params.getString("newPath");
-			oldPath = oldPath.substring(oldPath.indexOf('/')+1);
-			newPath = newPath.substring(newPath.indexOf('/')+1);
+        cloneEntity.setDeleted(entity.isDeleted());
+        cloneEntity.setCreatedBy(userId);
+        cloneEntity.setModifiedBy(userId);
+        controller.saveData(cloneEntity);
 
-			String policyVersionName = newPath.replace(".xml", "");
-			String version = policyVersionName.substring(policyVersionName.indexOf('.')+1);
-			String policyName = policyVersionName.substring(0, policyVersionName.lastIndexOf('.')).replace("/", File.separator);
+        //Notify others paps regarding clone policy.
+        PolicyRestController restController = new PolicyRestController();
+        restController.notifyOtherPAPSToUpdateConfigurations("clonePolicy", newConfigurationName, null);
+        return success();
+    }
 
-			String newpolicyName = newPath.replace("/", ".");
+    //Clone the Policy
+    private JSONObject copy(JSONObject params, HttpServletRequest request) throws ServletException {
+        try {
+            String userId = UserUtils.getUserSession(request).getOrgUserId();
+            String oldPath = params.getString("path");
+            String newPath = params.getString("newPath");
+            oldPath = oldPath.substring(oldPath.indexOf('/')+1);
+            newPath = newPath.substring(newPath.indexOf('/')+1);
 
-			String orignalPolicyName = oldPath.replace("/", ".");
+            String policyVersionName = newPath.replace(".xml", "");
+            String version = policyVersionName.substring(policyVersionName.indexOf('.')+1);
+            String policyName = policyVersionName.substring(0, policyVersionName.lastIndexOf('.')).replace("/", File.separator);
 
-			String newPolicyCheck = newpolicyName;
-			if(newPolicyCheck.contains("Config_")){
-				newPolicyCheck = newPolicyCheck.replace(".Config_", ":Config_");
-			}else if(newPolicyCheck.contains("Action_")){
-				newPolicyCheck = newPolicyCheck.replace(".Action_", ":Action_");
-			}else if(newPolicyCheck.contains("Decision_")){
-				newPolicyCheck = newPolicyCheck.replace(".Decision_", ":Decision_");
-			}
-			if(!newPolicyCheck.contains(":")){
-				 return error("Policy Clone Failed. The Name contains special characters.");
-			}
-			String[] newPolicySplit = newPolicyCheck.split(":");
+            String newpolicyName = newPath.replace("/", ".");
 
-			String checkValidation = newPolicySplit[1].replace(".xml", "");
+            String orignalPolicyName = oldPath.replace("/", ".");
+
+            String newPolicyCheck = newpolicyName;
+            if(newPolicyCheck.contains("Config_")){
+                newPolicyCheck = newPolicyCheck.replace(".Config_", ":Config_");
+            }else if(newPolicyCheck.contains("Action_")){
+                newPolicyCheck = newPolicyCheck.replace(".Action_", ":Action_");
+            }else if(newPolicyCheck.contains("Decision_")){
+                newPolicyCheck = newPolicyCheck.replace(".Decision_", ":Decision_");
+            }
+            if(!newPolicyCheck.contains(":")){
+                return error("Policy Clone Failed. The Name contains special characters.");
+            }
+            String[] newPolicySplit = newPolicyCheck.split(":");
+
+            String checkValidation = newPolicySplit[1].replace(".xml", "");
             checkValidation = checkValidation.substring(checkValidation.indexOf('_') + 1, checkValidation.lastIndexOf("."));
             if(!PolicyUtils.policySpecialCharValidator(checkValidation).contains("success")){
                 return error("Policy Clone Failed. The Name contains special characters.");
             }
-            
-			String oldPolicyCheck = orignalPolicyName;
-			if(oldPolicyCheck.contains("Config_")){
-				oldPolicyCheck = oldPolicyCheck.replace(".Config_", ":Config_");
-			}else if(oldPolicyCheck.contains("Action_")){
-				oldPolicyCheck = oldPolicyCheck.replace(".Action_", ":Action_");
-			}else if(oldPolicyCheck.contains("Decision_")){
-				oldPolicyCheck = oldPolicyCheck.replace(".Decision_", ":Decision_");
-			}
-			String[] oldPolicySplit = oldPolicyCheck.split(":");
 
-			PolicyController controller = getPolicyControllerInstance();
+            String oldPolicyCheck = orignalPolicyName;
+            if(oldPolicyCheck.contains("Config_")){
+                oldPolicyCheck = oldPolicyCheck.replace(".Config_", ":Config_");
+            }else if(oldPolicyCheck.contains("Action_")){
+                oldPolicyCheck = oldPolicyCheck.replace(".Action_", ":Action_");
+            }else if(oldPolicyCheck.contains("Decision_")){
+                oldPolicyCheck = oldPolicyCheck.replace(".Decision_", ":Decision_");
+            }
+            String[] oldPolicySplit = oldPolicyCheck.split(":");
 
-			PolicyEntity entity = null;
-			boolean success = false;
+            PolicyController controller = getPolicyControllerInstance();
 
-			//Check PolicyEntity table with newPolicy Name
-			String policyEntityquery = "FROM PolicyEntity where policyName = :newPolicySplit_1 and scope = :newPolicySplit_0";
-			SimpleBindings policyParams = new SimpleBindings();
-			policyParams.put("newPolicySplit_1", newPolicySplit[1]);
-			policyParams.put("newPolicySplit_0", newPolicySplit[0]);
-			List<Object> queryData = controller.getDataByQuery(policyEntityquery, policyParams);
-			if(!queryData.isEmpty()){
-				return error("Policy already exists with same name");
-			}
+            PolicyEntity entity = null;
+            boolean success = false;
 
-			//Query the Policy Entity with oldPolicy Name
-			policyEntityquery = "FROM PolicyEntity where policyName = :oldPolicySplit_1 and scope = :oldPolicySplit_0";
-			SimpleBindings peParams = new SimpleBindings();
-			peParams.put("oldPolicySplit_1", oldPolicySplit[1]);
-			peParams.put("oldPolicySplit_0", oldPolicySplit[0]);
-			if(PolicyController.isjUnit()){
-				queryData = controller.getDataByQuery(policyEntityquery, null);
-			}else{
-				queryData = controller.getDataByQuery(policyEntityquery, peParams);
-			}
-			if(!queryData.isEmpty()){
-				entity = (PolicyEntity) queryData.get(0);
-			}
-			if(entity != null){
-				cloneRecord(newPolicySplit[1], oldPolicySplit[0], oldPolicySplit[1],  newPolicySplit[0], newPolicySplit[1], entity, userId);
-				success = true;
-			}
+            //Check PolicyEntity table with newPolicy Name
+            String policyEntityquery = "FROM PolicyEntity where policyName = :newPolicySplit_1 and scope = :newPolicySplit_0";
+            SimpleBindings policyParams = new SimpleBindings();
+            policyParams.put("newPolicySplit_1", newPolicySplit[1]);
+            policyParams.put("newPolicySplit_0", newPolicySplit[0]);
+            List<Object> queryData = controller.getDataByQuery(policyEntityquery, policyParams);
+            if(!queryData.isEmpty()){
+                return error("Policy already exists with same name");
+            }
 
-			if(success){
-				PolicyVersion entityItem = new PolicyVersion();
-				entityItem.setActiveVersion(Integer.parseInt(version));
-				entityItem.setHigherVersion(Integer.parseInt(version));
-				entityItem.setPolicyName(policyName);
-				entityItem.setCreatedBy(userId);
-				entityItem.setModifiedBy(userId);
-				entityItem.setModifiedDate(new Date());
-				controller.saveData(entityItem);
-			}
+            //Query the Policy Entity with oldPolicy Name
+            policyEntityquery = "FROM PolicyEntity where policyName = :oldPolicySplit_1 and scope = :oldPolicySplit_0";
+            SimpleBindings peParams = new SimpleBindings();
+            peParams.put("oldPolicySplit_1", oldPolicySplit[1]);
+            peParams.put("oldPolicySplit_0", oldPolicySplit[0]);
+            if(PolicyController.isjUnit()){
+                queryData = controller.getDataByQuery(policyEntityquery, null);
+            }else{
+                queryData = controller.getDataByQuery(policyEntityquery, peParams);
+            }
+            if(!queryData.isEmpty()){
+                entity = (PolicyEntity) queryData.get(0);
+            }
+            if(entity != null){
+                cloneRecord(newPolicySplit[1], oldPolicySplit[0], oldPolicySplit[1],  newPolicySplit[0], newPolicySplit[1], entity, userId);
+                success = true;
+            }
 
-			LOGGER.debug("copy from: {} to: {}" + oldPath +newPath);
+            if(success){
+                PolicyVersion entityItem = new PolicyVersion();
+                entityItem.setActiveVersion(Integer.parseInt(version));
+                entityItem.setHigherVersion(Integer.parseInt(version));
+                entityItem.setPolicyName(policyName);
+                entityItem.setCreatedBy(userId);
+                entityItem.setModifiedBy(userId);
+                entityItem.setModifiedDate(new Date());
+                controller.saveData(entityItem);
+            }
 
-			return success();
-		} catch (Exception e) {
-			LOGGER.error("copy", e);
-			return error(e.getMessage());
-		}
-	}
+            LOGGER.debug("copy from: {} to: {}" + oldPath +newPath);
 
-	//Delete Policy or Scope Functionality
-	private JSONObject delete(JSONObject params, HttpServletRequest request) throws ServletException {
-		PolicyController controller = getPolicyControllerInstance();
-		PolicyRestController restController = new PolicyRestController();
-		PolicyEntity policyEntity = null;
-		String policyNamewithoutExtension;
-		try {
-			String userId = UserUtils.getUserSession(request).getOrgUserId();
-			String deleteVersion = "";
-			String path = params.getString("path");
-			LOGGER.debug("delete {}" +path);
-			if(params.has("deleteVersion")){
-				deleteVersion  = params.getString("deleteVersion");
-			}
-			path = path.substring(path.indexOf('/')+1);
-			String policyNamewithExtension = path.replace("/", File.separator);
-			String policyVersionName = policyNamewithExtension.replace(".xml", "");
-			String query;
-			SimpleBindings policyParams = new SimpleBindings();
-			if(path.endsWith(".xml")){
-				policyNamewithoutExtension = policyVersionName.substring(0, policyVersionName.lastIndexOf('.'));
-				policyNamewithoutExtension = policyNamewithoutExtension.replace(File.separator, ".");
-				String splitPolicyName = null;
-				if(policyNamewithoutExtension.contains("Config_")){
-					splitPolicyName = policyNamewithoutExtension.replace(".Config_", ":Config_");
-				}else if(policyNamewithoutExtension.contains("Action_")){
-					splitPolicyName = policyNamewithoutExtension.replace(".Action_", ":Action_");
-				}else if(policyNamewithoutExtension.contains("Decision_")){
-					splitPolicyName = policyNamewithoutExtension.replace(".Decision_", ":Decision_");
-				}
-				String[] split = splitPolicyName.split(":");
+            return success();
+        } catch (Exception e) {
+            LOGGER.error("copy", e);
+            return error(e.getMessage());
+        }
+    }
 
-				query = "FROM PolicyEntity where policyName like :split_1 and scope = :split_0";
-				policyParams.put("split_1", split[1] + "%");
-				policyParams.put("split_0", split[0]);
-			}else{
-				policyNamewithoutExtension = path.replace(File.separator, ".");
-				query = "FROM PolicyEntity where scope like :policyNamewithoutExtension";
-				policyParams.put("policyNamewithoutExtension", policyNamewithoutExtension + "%");
-			}
+    //Delete Policy or Scope Functionality
+    private JSONObject delete(JSONObject params, HttpServletRequest request) throws ServletException {
+        PolicyController controller = getPolicyControllerInstance();
+        PolicyRestController restController = new PolicyRestController();
+        PolicyEntity policyEntity = null;
+        String policyNamewithoutExtension;
+        try {
+            String userId = UserUtils.getUserSession(request).getOrgUserId();
+            String deleteVersion = "";
+            String path = params.getString("path");
+            LOGGER.debug("delete {}" +path);
+            if(params.has("deleteVersion")){
+                deleteVersion  = params.getString("deleteVersion");
+            }
+            path = path.substring(path.indexOf('/')+1);
+            String policyNamewithExtension = path.replace("/", File.separator);
+            String policyVersionName = policyNamewithExtension.replace(".xml", "");
+            String query;
+            SimpleBindings policyParams = new SimpleBindings();
+            if(path.endsWith(".xml")){
+                policyNamewithoutExtension = policyVersionName.substring(0, policyVersionName.lastIndexOf('.'));
+                policyNamewithoutExtension = policyNamewithoutExtension.replace(File.separator, ".");
+                String splitPolicyName = null;
+                if(policyNamewithoutExtension.contains("Config_")){
+                    splitPolicyName = policyNamewithoutExtension.replace(".Config_", ":Config_");
+                }else if(policyNamewithoutExtension.contains("Action_")){
+                    splitPolicyName = policyNamewithoutExtension.replace(".Action_", ":Action_");
+                }else if(policyNamewithoutExtension.contains("Decision_")){
+                    splitPolicyName = policyNamewithoutExtension.replace(".Decision_", ":Decision_");
+                }
+                String[] split = splitPolicyName.split(":");
 
-			List<Object> policyEntityobjects = controller.getDataByQuery(query, policyParams);
-			String activePolicyName = null;
-			boolean pdpCheck = false;
-			if(path.endsWith(".xml")){
-				policyNamewithoutExtension = policyNamewithoutExtension.replace(".", File.separator);
-				int version = Integer.parseInt(policyVersionName.substring(policyVersionName.indexOf('.')+1));
-				if("ALL".equals(deleteVersion)){
-					if(!policyEntityobjects.isEmpty()){
-						for(Object object : policyEntityobjects){
-							policyEntity = (PolicyEntity) object;
-							String groupEntityquery = "from PolicyGroupEntity where policyid ='"+policyEntity.getPolicyId()+"'";
-							SimpleBindings pgeParams = new SimpleBindings();
-							List<Object> groupobject = controller.getDataByQuery(groupEntityquery, pgeParams);
-							if(!groupobject.isEmpty()){
-								pdpCheck = true;
-								activePolicyName = policyEntity.getScope() +"."+ policyEntity.getPolicyName();
-							}else{
-								//Delete the entity from Elastic Search Database
-								String searchFileName = policyEntity.getScope() + "." + policyEntity.getPolicyName();
-								restController.deleteElasticData(searchFileName);
-								//Delete the entity from Policy Entity table
-								controller.deleteData(policyEntity);
-								if(policyNamewithoutExtension.contains("Config_")){
-									Files.deleteIfExists(Paths.get(PolicyController.getConfigHome() + File.separator + policyEntity.getConfigurationData().getConfigurationName()));
-									controller.deleteData(policyEntity.getConfigurationData());
-									restController.notifyOtherPAPSToUpdateConfigurations("delete", null, policyEntity.getConfigurationData().getConfigurationName());
-								}else if(policyNamewithoutExtension.contains("Action_")){
-									Files.deleteIfExists(Paths.get(PolicyController.getActionHome() + File.separator + policyEntity.getActionBodyEntity().getActionBodyName()));
-									controller.deleteData(policyEntity.getActionBodyEntity());
-									restController.notifyOtherPAPSToUpdateConfigurations("delete", null, policyEntity.getActionBodyEntity().getActionBodyName());
-								}
-							}
-						}
-					}
-					//Policy Notification
-					PolicyVersion versionEntity = new PolicyVersion();
-					versionEntity.setPolicyName(policyNamewithoutExtension);
-					versionEntity.setModifiedBy(userId);
-					controller.watchPolicyFunction(versionEntity, policyNamewithExtension, "DeleteAll");
-					if(pdpCheck){
-						//Delete from policyVersion table
-						String getActivePDPPolicyVersion = activePolicyName.replace(".xml", "");
-						getActivePDPPolicyVersion = getActivePDPPolicyVersion.substring(getActivePDPPolicyVersion.lastIndexOf('.')+1);
-						String policyVersionQuery = "update PolicyVersion set active_version='"+getActivePDPPolicyVersion+"' , highest_version='"+getActivePDPPolicyVersion+"'  where policy_name ='" +policyNamewithoutExtension.replace("\\", "\\\\")+"' and id >0";
-						if(policyVersionQuery != null){
-							controller.executeQuery(policyVersionQuery);
-						}
-						return error("Policies with Same name has been deleted. Except the Active Policy in PDP.     PolicyName: "+activePolicyName);
-					}else{
-						//No Active Policy in PDP. So, deleting all entries from policyVersion table
-						String policyVersionQuery = "delete from PolicyVersion  where policy_name ='" +policyNamewithoutExtension.replace("\\", "\\\\")+"' and id >0";
-						if(policyVersionQuery != null){
-							controller.executeQuery(policyVersionQuery);
-						}
-					}
-				}else if("CURRENT".equals(deleteVersion)){
-					String currentVersionPolicyName = policyNamewithExtension.substring(policyNamewithExtension.lastIndexOf(File.separator)+1);
-					String currentVersionScope = policyNamewithExtension.substring(0, policyNamewithExtension.lastIndexOf(File.separator)).replace(File.separator, ".");
-					query = "FROM PolicyEntity where policyName = :currentVersionPolicyName and scope = :currentVersionScope";
+                query = "FROM PolicyEntity where policyName like :split_1 and scope = :split_0";
+                policyParams.put("split_1", split[1] + "%");
+                policyParams.put("split_0", split[0]);
+            }else{
+                policyNamewithoutExtension = path.replace(File.separator, ".");
+                query = "FROM PolicyEntity where scope like :policyNamewithoutExtension";
+                policyParams.put("policyNamewithoutExtension", policyNamewithoutExtension + "%");
+            }
 
-					SimpleBindings peParams = new SimpleBindings();
-					peParams.put("currentVersionPolicyName", currentVersionPolicyName);
-					peParams.put("currentVersionScope", currentVersionScope);
+            List<Object> policyEntityobjects = controller.getDataByQuery(query, policyParams);
+            String activePolicyName = null;
+            boolean pdpCheck = false;
+            if(path.endsWith(".xml")){
+                policyNamewithoutExtension = policyNamewithoutExtension.replace(".", File.separator);
+                int version = Integer.parseInt(policyVersionName.substring(policyVersionName.indexOf('.')+1));
+                if("ALL".equals(deleteVersion)){
+                    if(!policyEntityobjects.isEmpty()){
+                        for(Object object : policyEntityobjects){
+                            policyEntity = (PolicyEntity) object;
+                            String groupEntityquery = "from PolicyGroupEntity where policyid ='"+policyEntity.getPolicyId()+"'";
+                            SimpleBindings pgeParams = new SimpleBindings();
+                            List<Object> groupobject = controller.getDataByQuery(groupEntityquery, pgeParams);
+                            if(!groupobject.isEmpty()){
+                                pdpCheck = true;
+                                activePolicyName = policyEntity.getScope() +"."+ policyEntity.getPolicyName();
+                            }else{
+                                //Delete the entity from Elastic Search Database
+                                String searchFileName = policyEntity.getScope() + "." + policyEntity.getPolicyName();
+                                restController.deleteElasticData(searchFileName);
+                                //Delete the entity from Policy Entity table
+                                controller.deleteData(policyEntity);
+                                if(policyNamewithoutExtension.contains("Config_")){
+                                    Files.deleteIfExists(Paths.get(PolicyController.getConfigHome() + File.separator + policyEntity.getConfigurationData().getConfigurationName()));
+                                    controller.deleteData(policyEntity.getConfigurationData());
+                                    restController.notifyOtherPAPSToUpdateConfigurations("delete", null, policyEntity.getConfigurationData().getConfigurationName());
+                                }else if(policyNamewithoutExtension.contains("Action_")){
+                                    Files.deleteIfExists(Paths.get(PolicyController.getActionHome() + File.separator + policyEntity.getActionBodyEntity().getActionBodyName()));
+                                    controller.deleteData(policyEntity.getActionBodyEntity());
+                                    restController.notifyOtherPAPSToUpdateConfigurations("delete", null, policyEntity.getActionBodyEntity().getActionBodyName());
+                                }
+                            }
+                        }
+                    }
+                    //Policy Notification
+                    PolicyVersion versionEntity = new PolicyVersion();
+                    versionEntity.setPolicyName(policyNamewithoutExtension);
+                    versionEntity.setModifiedBy(userId);
+                    controller.watchPolicyFunction(versionEntity, policyNamewithExtension, "DeleteAll");
+                    if(pdpCheck){
+                        //Delete from policyVersion table
+                        String getActivePDPPolicyVersion = activePolicyName.replace(".xml", "");
+                        getActivePDPPolicyVersion = getActivePDPPolicyVersion.substring(getActivePDPPolicyVersion.lastIndexOf('.')+1);
+                        String policyVersionQuery = "update PolicyVersion set active_version='"+getActivePDPPolicyVersion+"' , highest_version='"+getActivePDPPolicyVersion+"'  where policy_name ='" +policyNamewithoutExtension.replace("\\", "\\\\")+"' and id >0";
+                        if(policyVersionQuery != null){
+                            controller.executeQuery(policyVersionQuery);
+                        }
+                        return error("Policies with Same name has been deleted. Except the Active Policy in PDP.     PolicyName: "+activePolicyName);
+                    }else{
+                        //No Active Policy in PDP. So, deleting all entries from policyVersion table
+                        String policyVersionQuery = "delete from PolicyVersion  where policy_name ='" +policyNamewithoutExtension.replace("\\", "\\\\")+"' and id >0";
+                        if(policyVersionQuery != null){
+                            controller.executeQuery(policyVersionQuery);
+                        }
+                    }
+                }else if("CURRENT".equals(deleteVersion)){
+                    String currentVersionPolicyName = policyNamewithExtension.substring(policyNamewithExtension.lastIndexOf(File.separator)+1);
+                    String currentVersionScope = policyNamewithExtension.substring(0, policyNamewithExtension.lastIndexOf(File.separator)).replace(File.separator, ".");
+                    query = "FROM PolicyEntity where policyName = :currentVersionPolicyName and scope = :currentVersionScope";
 
-					List<Object> policyEntitys = controller.getDataByQuery(query, peParams);
-					if(!policyEntitys.isEmpty()){
-						policyEntity = (PolicyEntity) policyEntitys.get(0);
-					}
-					if(policyEntity != null){
-						String groupEntityquery = "from PolicyGroupEntity where policyid = :policyEntityId and policyid > 0";
-						SimpleBindings geParams = new SimpleBindings();
-						geParams.put("policyEntityId", policyEntity.getPolicyId());
-						List<Object> groupobject = controller.getDataByQuery(groupEntityquery, geParams);
-						if(groupobject.isEmpty()){
-							//Delete the entity from Elastic Search Database
-							String searchFileName = policyEntity.getScope() + "." + policyEntity.getPolicyName();
-							restController.deleteElasticData(searchFileName);
-							//Delete the entity from Policy Entity table
-							controller.deleteData(policyEntity);
-							if(policyNamewithoutExtension.contains("Config_")){
-								Files.deleteIfExists(Paths.get(PolicyController.getConfigHome() + File.separator + policyEntity.getConfigurationData().getConfigurationName()));
-								controller.deleteData(policyEntity.getConfigurationData());
-								restController.notifyOtherPAPSToUpdateConfigurations("delete", null, policyEntity.getConfigurationData().getConfigurationName());
-							}else if(policyNamewithoutExtension.contains("Action_")){
-								Files.deleteIfExists(Paths.get(PolicyController.getActionHome() + File.separator + policyEntity.getActionBodyEntity().getActionBodyName()));
-								controller.deleteData(policyEntity.getActionBodyEntity());
-								restController.notifyOtherPAPSToUpdateConfigurations("delete", null, policyEntity.getActionBodyEntity().getActionBodyName());
-							}
+                    SimpleBindings peParams = new SimpleBindings();
+                    peParams.put("currentVersionPolicyName", currentVersionPolicyName);
+                    peParams.put("currentVersionScope", currentVersionScope);
 
-							if(version > 1){
-								int highestVersion = 0;
-								if(!policyEntityobjects.isEmpty()){
-									for(Object object : policyEntityobjects){
-										policyEntity = (PolicyEntity) object;
-										String policyEntityName = policyEntity.getPolicyName().replace(".xml", "");
-										int policyEntityVersion = Integer.parseInt(policyEntityName.substring(policyEntityName.lastIndexOf('.')+1));
-										if(policyEntityVersion > highestVersion && policyEntityVersion != version){
-											highestVersion = policyEntityVersion;
-										}
-									}
-								}
+                    List<Object> policyEntitys = controller.getDataByQuery(query, peParams);
+                    if(!policyEntitys.isEmpty()){
+                        policyEntity = (PolicyEntity) policyEntitys.get(0);
+                    }
+                    if(policyEntity != null){
+                        String groupEntityquery = "from PolicyGroupEntity where policyid = :policyEntityId and policyid > 0";
+                        SimpleBindings geParams = new SimpleBindings();
+                        geParams.put("policyEntityId", policyEntity.getPolicyId());
+                        List<Object> groupobject = controller.getDataByQuery(groupEntityquery, geParams);
+                        if(groupobject.isEmpty()){
+                            //Delete the entity from Elastic Search Database
+                            String searchFileName = policyEntity.getScope() + "." + policyEntity.getPolicyName();
+                            restController.deleteElasticData(searchFileName);
+                            //Delete the entity from Policy Entity table
+                            controller.deleteData(policyEntity);
+                            if(policyNamewithoutExtension.contains("Config_")){
+                                Files.deleteIfExists(Paths.get(PolicyController.getConfigHome() + File.separator + policyEntity.getConfigurationData().getConfigurationName()));
+                                controller.deleteData(policyEntity.getConfigurationData());
+                                restController.notifyOtherPAPSToUpdateConfigurations("delete", null, policyEntity.getConfigurationData().getConfigurationName());
+                            }else if(policyNamewithoutExtension.contains("Action_")){
+                                Files.deleteIfExists(Paths.get(PolicyController.getActionHome() + File.separator + policyEntity.getActionBodyEntity().getActionBodyName()));
+                                controller.deleteData(policyEntity.getActionBodyEntity());
+                                restController.notifyOtherPAPSToUpdateConfigurations("delete", null, policyEntity.getActionBodyEntity().getActionBodyName());
+                            }
 
-								//Policy Notification
-								PolicyVersion entity = new PolicyVersion();
-								entity.setPolicyName(policyNamewithoutExtension);
-								entity.setActiveVersion(highestVersion);
-								entity.setModifiedBy(userId);
-								controller.watchPolicyFunction(entity, policyNamewithExtension, "DeleteOne");
+                            if(version > 1){
+                                int highestVersion = 0;
+                                if(!policyEntityobjects.isEmpty()){
+                                    for(Object object : policyEntityobjects){
+                                        policyEntity = (PolicyEntity) object;
+                                        String policyEntityName = policyEntity.getPolicyName().replace(".xml", "");
+                                        int policyEntityVersion = Integer.parseInt(policyEntityName.substring(policyEntityName.lastIndexOf('.')+1));
+                                        if(policyEntityVersion > highestVersion && policyEntityVersion != version){
+                                            highestVersion = policyEntityVersion;
+                                        }
+                                    }
+                                }
 
-								String updatequery = "";
-								if(highestVersion != 0){
-									updatequery = "update PolicyVersion set active_version='"+highestVersion+"' , highest_version='"+highestVersion+"' where policy_name ='" +policyNamewithoutExtension.replace("\\", "\\\\")+"'";	
-								}else{
-									updatequery = "delete from PolicyVersion  where policy_name ='" +policyNamewithoutExtension.replace("\\", "\\\\")+"' and id >0";
-								}
-								controller.executeQuery(updatequery);
-							}else{
-								String policyVersionQuery = "delete from PolicyVersion  where policy_name ='" +policyNamewithoutExtension.replace("\\", "\\\\")+"' and id >0";
-								if(policyVersionQuery != null){
-									controller.executeQuery(policyVersionQuery);
-								}
-							}
-						}else{
-							return error("Policy can't be deleted, it is active in PDP Groups.     PolicyName: '"+policyEntity.getScope() + "." +policyEntity.getPolicyName()+"'");
-						}
-					}
-				}
-			}else{
-				List<String> activePoliciesInPDP = new ArrayList<>();
-				if(!policyEntityobjects.isEmpty()){
-					for(Object object : policyEntityobjects){
-						policyEntity = (PolicyEntity) object;
-						String groupEntityquery = "from PolicyGroupEntity where policyid = :policyEntityId";
-						SimpleBindings geParams = new SimpleBindings();
-						geParams.put("policyEntityId", policyEntity.getPolicyId());
-						List<Object> groupobject = controller.getDataByQuery(groupEntityquery, geParams);
-						if(!groupobject.isEmpty()){
-							pdpCheck = true;
-							activePoliciesInPDP.add(policyEntity.getScope()+"."+policyEntity.getPolicyName());
-						}else{
-							//Delete the entity from Elastic Search Database
-							String searchFileName = policyEntity.getScope() + "." + policyEntity.getPolicyName();
-							restController.deleteElasticData(searchFileName);
-							//Delete the entity from Policy Entity table
-							controller.deleteData(policyEntity);
-							policyNamewithoutExtension = policyEntity.getPolicyName();
-							if(policyNamewithoutExtension.contains("Config_")){
-								Files.deleteIfExists(Paths.get(PolicyController.getConfigHome() + File.separator + policyEntity.getConfigurationData().getConfigurationName()));
-								controller.deleteData(policyEntity.getConfigurationData());
-								restController.notifyOtherPAPSToUpdateConfigurations("delete", null, policyEntity.getConfigurationData().getConfigurationName());
-							}else if(policyNamewithoutExtension.contains("Action_")){
-								Files.deleteIfExists(Paths.get(PolicyController.getActionHome() + File.separator + policyEntity.getActionBodyEntity().getActionBodyName()));
-								controller.deleteData(policyEntity.getActionBodyEntity());
-								restController.notifyOtherPAPSToUpdateConfigurations("delete", null, policyEntity.getActionBodyEntity().getActionBodyName());
-							}
-						}
-					}
-					//Delete from policyVersion and policyEditor Scope table
-					String policyVersionQuery = "delete PolicyVersion where POLICY_NAME like '"+path.replace("\\", "\\\\")+"%' and id >0";
-					controller.executeQuery(policyVersionQuery);
+                                //Policy Notification
+                                PolicyVersion entity = new PolicyVersion();
+                                entity.setPolicyName(policyNamewithoutExtension);
+                                entity.setActiveVersion(highestVersion);
+                                entity.setModifiedBy(userId);
+                                controller.watchPolicyFunction(entity, policyNamewithExtension, "DeleteOne");
 
-					//Policy Notification
-					PolicyVersion entity = new PolicyVersion();
-					entity.setPolicyName(path);
-					entity.setModifiedBy(userId);
-					controller.watchPolicyFunction(entity, path, "DeleteScope");
-					if(pdpCheck){
-						//Add Active Policies List to PolicyVersionTable
-						for(int i =0; i < activePoliciesInPDP.size(); i++){
-							String activePDPPolicyName = activePoliciesInPDP.get(i).replace(".xml", "");
-							int activePDPPolicyVersion = Integer.parseInt(activePDPPolicyName.substring(activePDPPolicyName.lastIndexOf('.')+1));
-							activePDPPolicyName = activePDPPolicyName.substring(0, activePDPPolicyName.lastIndexOf('.')).replace(".", File.separator);
-							PolicyVersion insertactivePDPVersion = new PolicyVersion();
-							insertactivePDPVersion.setPolicyName(activePDPPolicyName);
-							insertactivePDPVersion.setHigherVersion(activePDPPolicyVersion);
-							insertactivePDPVersion.setActiveVersion(activePDPPolicyVersion);
-							insertactivePDPVersion.setCreatedBy(userId);
-							insertactivePDPVersion.setModifiedBy(userId);
-							controller.saveData(insertactivePDPVersion);
-						}
+                                String updatequery = "";
+                                if(highestVersion != 0){
+                                    updatequery = "update PolicyVersion set active_version='"+highestVersion+"' , highest_version='"+highestVersion+"' where policy_name ='" +policyNamewithoutExtension.replace("\\", "\\\\")+"'";
+                                }else{
+                                    updatequery = "delete from PolicyVersion  where policy_name ='" +policyNamewithoutExtension.replace("\\", "\\\\")+"' and id >0";
+                                }
+                                controller.executeQuery(updatequery);
+                            }else{
+                                String policyVersionQuery = "delete from PolicyVersion  where policy_name ='" +policyNamewithoutExtension.replace("\\", "\\\\")+"' and id >0";
+                                if(policyVersionQuery != null){
+                                    controller.executeQuery(policyVersionQuery);
+                                }
+                            }
+                        }else{
+                            return error("Policy can't be deleted, it is active in PDP Groups.     PolicyName: '"+policyEntity.getScope() + "." +policyEntity.getPolicyName()+"'");
+                        }
+                    }
+                }
+            }else{
+                List<String> activePoliciesInPDP = new ArrayList<>();
+                if(!policyEntityobjects.isEmpty()){
+                    for(Object object : policyEntityobjects){
+                        policyEntity = (PolicyEntity) object;
+                        String groupEntityquery = "from PolicyGroupEntity where policyid = :policyEntityId";
+                        SimpleBindings geParams = new SimpleBindings();
+                        geParams.put("policyEntityId", policyEntity.getPolicyId());
+                        List<Object> groupobject = controller.getDataByQuery(groupEntityquery, geParams);
+                        if(!groupobject.isEmpty()){
+                            pdpCheck = true;
+                            activePoliciesInPDP.add(policyEntity.getScope()+"."+policyEntity.getPolicyName());
+                        }else{
+                            //Delete the entity from Elastic Search Database
+                            String searchFileName = policyEntity.getScope() + "." + policyEntity.getPolicyName();
+                            restController.deleteElasticData(searchFileName);
+                            //Delete the entity from Policy Entity table
+                            controller.deleteData(policyEntity);
+                            policyNamewithoutExtension = policyEntity.getPolicyName();
+                            if(policyNamewithoutExtension.contains("Config_")){
+                                Files.deleteIfExists(Paths.get(PolicyController.getConfigHome() + File.separator + policyEntity.getConfigurationData().getConfigurationName()));
+                                controller.deleteData(policyEntity.getConfigurationData());
+                                restController.notifyOtherPAPSToUpdateConfigurations("delete", null, policyEntity.getConfigurationData().getConfigurationName());
+                            }else if(policyNamewithoutExtension.contains("Action_")){
+                                Files.deleteIfExists(Paths.get(PolicyController.getActionHome() + File.separator + policyEntity.getActionBodyEntity().getActionBodyName()));
+                                controller.deleteData(policyEntity.getActionBodyEntity());
+                                restController.notifyOtherPAPSToUpdateConfigurations("delete", null, policyEntity.getActionBodyEntity().getActionBodyName());
+                            }
+                        }
+                    }
+                    //Delete from policyVersion and policyEditor Scope table
+                    String policyVersionQuery = "delete PolicyVersion where POLICY_NAME like '"+path.replace("\\", "\\\\")+"%' and id >0";
+                    controller.executeQuery(policyVersionQuery);
 
-						return error("All the Policies has been deleted in Scope. Except the following list of Policies:"+activePoliciesInPDP);
-					}else{
-						String policyScopeQuery = "delete PolicyEditorScopes where SCOPENAME like '"+path.replace("\\", "\\\\")+"%' and id >0";
-					    controller.executeQuery(policyScopeQuery);
-					}
-				}else{
-					String policyScopeQuery = "delete PolicyEditorScopes where SCOPENAME like '"+path.replace("\\", "\\\\")+"%' and id >0";
-					controller.executeQuery(policyScopeQuery);
-				}
-			}
-			return success();
-		} catch (Exception e) {
-			LOGGER.error("delete", e);
-			return error(e.getMessage());
-		}
-	}
+                    //Policy Notification
+                    PolicyVersion entity = new PolicyVersion();
+                    entity.setPolicyName(path);
+                    entity.setModifiedBy(userId);
+                    controller.watchPolicyFunction(entity, path, "DeleteScope");
+                    if(pdpCheck){
+                        //Add Active Policies List to PolicyVersionTable
+                        for(int i =0; i < activePoliciesInPDP.size(); i++){
+                            String activePDPPolicyName = activePoliciesInPDP.get(i).replace(".xml", "");
+                            int activePDPPolicyVersion = Integer.parseInt(activePDPPolicyName.substring(activePDPPolicyName.lastIndexOf('.')+1));
+                            activePDPPolicyName = activePDPPolicyName.substring(0, activePDPPolicyName.lastIndexOf('.')).replace(".", File.separator);
+                            PolicyVersion insertactivePDPVersion = new PolicyVersion();
+                            insertactivePDPVersion.setPolicyName(activePDPPolicyName);
+                            insertactivePDPVersion.setHigherVersion(activePDPPolicyVersion);
+                            insertactivePDPVersion.setActiveVersion(activePDPPolicyVersion);
+                            insertactivePDPVersion.setCreatedBy(userId);
+                            insertactivePDPVersion.setModifiedBy(userId);
+                            controller.saveData(insertactivePDPVersion);
+                        }
 
-	//Edit the Policy
-	private JSONObject editFile(JSONObject params) throws ServletException {
-		// get content
-		try {
-			PolicyController controller = getPolicyControllerInstance();
-			String mode = params.getString("mode");
-			String path = params.getString("path");
-			LOGGER.debug("editFile path: {}"+ path);
+                        return error("All the Policies has been deleted in Scope. Except the following list of Policies:"+activePoliciesInPDP);
+                    }else{
+                        String policyScopeQuery = "delete PolicyEditorScopes where SCOPENAME like '"+path.replace("\\", "\\\\")+"%' and id >0";
+                        controller.executeQuery(policyScopeQuery);
+                    }
+                }else{
+                    String policyScopeQuery = "delete PolicyEditorScopes where SCOPENAME like '"+path.replace("\\", "\\\\")+"%' and id >0";
+                    controller.executeQuery(policyScopeQuery);
+                }
+            }
+            return success();
+        } catch (Exception e) {
+            LOGGER.error("delete", e);
+            return error(e.getMessage());
+        }
+    }
 
-			String domain = path.substring(1, path.lastIndexOf('/'));
-			domain = domain.replace("/", ".");
+    //Edit the Policy
+    private JSONObject editFile(JSONObject params) throws ServletException {
+        // get content
+        try {
+            PolicyController controller = getPolicyControllerInstance();
+            String mode = params.getString("mode");
+            String path = params.getString("path");
+            LOGGER.debug("editFile path: {}"+ path);
 
-			path = path.substring(1);
-			path = path.replace("/", ".");
-			String dbCheckName = path;
-			if(dbCheckName.contains("Config_")){
-				dbCheckName = dbCheckName.replace(".Config_", ":Config_");
-			}else if(dbCheckName.contains("Action_")){
-				dbCheckName = dbCheckName.replace(".Action_", ":Action_");
-			}else if(dbCheckName.contains("Decision_")){
-				dbCheckName = dbCheckName.replace(".Decision_", ":Decision_");
-			}
+            String domain = path.substring(1, path.lastIndexOf('/'));
+            domain = domain.replace("/", ".");
 
-			String[] split = dbCheckName.split(":");
-			String query = "FROM PolicyEntity where policyName = :split_1 and scope = :split_0";
-			SimpleBindings peParams = new SimpleBindings();
-			peParams.put("split_1", split[1]);
-			peParams.put("split_0", split[0]);
-			List<Object> queryData;
-			if(PolicyController.isjUnit()){
-				queryData = controller.getDataByQuery(query, null);
-			}else{
-				queryData = controller.getDataByQuery(query, peParams);
-			}
-			PolicyEntity entity = (PolicyEntity) queryData.get(0);
-			InputStream stream = new ByteArrayInputStream(entity.getPolicyData().getBytes(StandardCharsets.UTF_8));
+            path = path.substring(1);
+            path = path.replace("/", ".");
+            String dbCheckName = path;
+            if(dbCheckName.contains("Config_")){
+                dbCheckName = dbCheckName.replace(".Config_", ":Config_");
+            }else if(dbCheckName.contains("Action_")){
+                dbCheckName = dbCheckName.replace(".Action_", ":Action_");
+            }else if(dbCheckName.contains("Decision_")){
+                dbCheckName = dbCheckName.replace(".Decision_", ":Decision_");
+            }
+
+            String[] split = dbCheckName.split(":");
+            String query = "FROM PolicyEntity where policyName = :split_1 and scope = :split_0";
+            SimpleBindings peParams = new SimpleBindings();
+            peParams.put("split_1", split[1]);
+            peParams.put("split_0", split[0]);
+            List<Object> queryData;
+            if(PolicyController.isjUnit()){
+                queryData = controller.getDataByQuery(query, null);
+            }else{
+                queryData = controller.getDataByQuery(query, peParams);
+            }
+            PolicyEntity entity = (PolicyEntity) queryData.get(0);
+            InputStream stream = new ByteArrayInputStream(entity.getPolicyData().getBytes(StandardCharsets.UTF_8));
 
 
-			Object policy = XACMLPolicyScanner.readPolicy(stream);
-			PolicyRestAdapter policyAdapter  = new PolicyRestAdapter();
-			policyAdapter.setData(policy);
+            Object policy = XACMLPolicyScanner.readPolicy(stream);
+            PolicyRestAdapter policyAdapter  = new PolicyRestAdapter();
+            policyAdapter.setData(policy);
 
-			if("viewPolicy".equalsIgnoreCase(mode)){
-				policyAdapter.setReadOnly(true);
-				policyAdapter.setEditPolicy(false);
-			}else{
-				policyAdapter.setReadOnly(false);
-				policyAdapter.setEditPolicy(true);
-			}
-			
-			policyAdapter.setDomainDir(domain);
-			policyAdapter.setPolicyData(policy);
-			String policyName = path.replace(".xml", "");
-			policyName = policyName.substring(0, policyName.lastIndexOf('.'));
-			policyAdapter.setPolicyName(policyName.substring(policyName.lastIndexOf('.')+1));
+            if("viewPolicy".equalsIgnoreCase(mode)){
+                policyAdapter.setReadOnly(true);
+                policyAdapter.setEditPolicy(false);
+            }else{
+                policyAdapter.setReadOnly(false);
+                policyAdapter.setEditPolicy(true);
+            }
 
-			PolicyAdapter setpolicyAdapter = PolicyAdapter.getInstance();
-			setpolicyAdapter.configure(policyAdapter,entity);
+            policyAdapter.setDomainDir(domain);
+            policyAdapter.setPolicyData(policy);
+            String policyName = path.replace(".xml", "");
+            policyName = policyName.substring(0, policyName.lastIndexOf('.'));
+            policyAdapter.setPolicyName(policyName.substring(policyName.lastIndexOf('.')+1));
 
-			policyAdapter.setParentPath(null);
-			ObjectMapper mapper = new ObjectMapper();
-			String json = mapper.writeValueAsString(policyAdapter);
-			JsonNode jsonNode = mapper.readTree(json);
+            PolicyAdapter setpolicyAdapter = PolicyAdapter.getInstance();
+            setpolicyAdapter.configure(policyAdapter,entity);
 
-			return new JSONObject().put(RESULT, jsonNode);
-		} catch (Exception e) {
-			LOGGER.error("editFile", e);
-			return error(e.getMessage());
-		}
-	}
+            policyAdapter.setParentPath(null);
+            ObjectMapper mapper = new ObjectMapper();
+            String json = mapper.writeValueAsString(policyAdapter);
+            JsonNode jsonNode = mapper.readTree(json);
 
-	//Add Scopes
-	private JSONObject addFolder(JSONObject params, HttpServletRequest request) throws ServletException {
-		PolicyController controller = getPolicyControllerInstance();
-		String name = "";
-		try {
-			String userId = UserUtils.getUserSession(request).getOrgUserId();
-			String path = params.getString("path");
-			try{
-				if(params.has("subScopename")){
-					if(! "".equals(params.getString("subScopename"))) {
-						name = params.getString("path").replace("/", File.separator) + File.separator +params.getString("subScopename");
-					}
-				}else{
-					name = params.getString("name");
-				}
-			}catch(Exception e){
-				name = params.getString("name");
-				LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "Exception Occured While Adding Scope"+e);
-			}
-			String validateName;
-			if(name.contains(File.separator)){
-				validateName = name.substring(name.lastIndexOf(File.separator)+1);
-			}else{
-				validateName = name;
-			}
-			if(!name.isEmpty()){
-				String validate = PolicyUtils.policySpecialCharValidator(validateName);
-				if(!validate.contains("success")){
-					return error(validate);
-				}
-			}
-			LOGGER.debug("addFolder path: {} name: {}" + path +name);
-			if(! "".equals(name)){
-				if(name.startsWith(File.separator)){
-					name = name.substring(1);
-				}
-				PolicyEditorScopes entity = (PolicyEditorScopes) controller.getEntityItem(PolicyEditorScopes.class, "scopeName", name);
-				if(entity == null){
-					UserInfo userInfo = new UserInfo();
-					userInfo.setUserLoginId(userId);
-					PolicyEditorScopes newScope = new PolicyEditorScopes();
-					newScope.setScopeName(name);
-					newScope.setUserCreatedBy(userInfo);
-					newScope.setUserModifiedBy(userInfo);
-					controller.saveData(newScope);
-				}else{
-					return error("Scope Already Exists");
-				}
-			}
-			return success();
-		} catch (Exception e) {
-			LOGGER.error("addFolder", e);
-			return error(e.getMessage());
-		}
-	}
+            return new JSONObject().put(RESULT, jsonNode);
+        } catch (Exception e) {
+            LOGGER.error("editFile", e);
+            return error(e.getMessage());
+        }
+    }
 
-	//Return Error Object
-	private JSONObject error(String msg) throws ServletException {
-		try {
-			JSONObject result = new JSONObject();
-			result.put("success", false);
-			result.put("error", msg);
-			return new JSONObject().put(RESULT, result);
-		} catch (JSONException e) {
-			throw new ServletException(e);
-		}
-	}
+    //Add Scopes
+    private JSONObject addFolder(JSONObject params, HttpServletRequest request) throws ServletException {
+        PolicyController controller = getPolicyControllerInstance();
+        String name = "";
+        try {
+            String userId = UserUtils.getUserSession(request).getOrgUserId();
+            String path = params.getString("path");
+            try{
+                if(params.has("subScopename")){
+                    if(! "".equals(params.getString("subScopename"))) {
+                        name = params.getString("path").replace("/", File.separator) + File.separator +params.getString("subScopename");
+                    }
+                }else{
+                    name = params.getString(NAME);
+                }
+            }catch(Exception e){
+                name = params.getString(NAME);
+                LOGGER.error(XACMLErrorConstants.ERROR_DATA_ISSUE + "Exception Occured While Adding Scope"+e);
+            }
+            String validateName;
+            if(name.contains(File.separator)){
+                validateName = name.substring(name.lastIndexOf(File.separator)+1);
+            }else{
+                validateName = name;
+            }
+            if(!name.isEmpty()){
+                String validate = PolicyUtils.policySpecialCharValidator(validateName);
+                if(!validate.contains("success")){
+                    return error(validate);
+                }
+            }
+            LOGGER.debug("addFolder path: {} name: {}" + path +name);
+            if(! "".equals(name)){
+                if(name.startsWith(File.separator)){
+                    name = name.substring(1);
+                }
+                PolicyEditorScopes entity = (PolicyEditorScopes) controller.getEntityItem(PolicyEditorScopes.class, "scopeName", name);
+                if(entity == null){
+                    UserInfo userInfo = new UserInfo();
+                    userInfo.setUserLoginId(userId);
+                    PolicyEditorScopes newScope = new PolicyEditorScopes();
+                    newScope.setScopeName(name);
+                    newScope.setUserCreatedBy(userInfo);
+                    newScope.setUserModifiedBy(userInfo);
+                    controller.saveData(newScope);
+                }else{
+                    return error("Scope Already Exists");
+                }
+            }
+            return success();
+        } catch (Exception e) {
+            LOGGER.error("addFolder", e);
+            return error(e.getMessage());
+        }
+    }
 
-	//Return Success Object
-	private JSONObject success() throws ServletException {
-		try {
-			JSONObject result = new JSONObject();
-			result.put("success", true);
-			result.put("error", (Object) null);
-			return new JSONObject().put(RESULT, result);
-		} catch (JSONException e) {
-			throw new ServletException(e);
-		}
-	}
+    //Return Error Object
+    private JSONObject error(String msg) throws ServletException {
+        try {
+            JSONObject result = new JSONObject();
+            result.put("success", false);
+            result.put("error", msg);
+            return new JSONObject().put(RESULT, result);
+        } catch (JSONException e) {
+            throw new ServletException(e);
+        }
+    }
 
-	private PolicyController getPolicyControllerInstance(){
-		return policyController != null ? getPolicyController() : new PolicyController();
-	}
+    //Return Success Object
+    private JSONObject success() throws ServletException {
+        try {
+            JSONObject result = new JSONObject();
+            result.put("success", true);
+            result.put("error", (Object) null);
+            return new JSONObject().put(RESULT, result);
+        } catch (JSONException e) {
+            throw new ServletException(e);
+        }
+    }
 
-	public String getTestUserId() {
-		return testUserId;
-	}
+    private PolicyController getPolicyControllerInstance(){
+        return policyController != null ? getPolicyController() : new PolicyController();
+    }
 
-	public static void setTestUserId(String testUserId) {
-		PolicyManagerServlet.testUserId = testUserId;
-	}
-}
+    public String getTestUserId() {
+        return testUserId;
+    }
+
+    public static void setTestUserId(String testUserId) {
+        PolicyManagerServlet.testUserId = testUserId;
+    }
+}
\ No newline at end of file
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyNotificationMail.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyNotificationMail.java
index 6424465..c791910 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyNotificationMail.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyNotificationMail.java
@@ -3,6 +3,7 @@
  * ONAP Policy Engine
  * ================================================================================
  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Modified Copyright (C) 2018 Samsung Electronics Co., Ltd.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -45,125 +46,159 @@
 import org.springframework.mail.javamail.JavaMailSenderImpl;
 import org.springframework.mail.javamail.MimeMessageHelper;
 
+/**
+ * Send policy notification mail depending on the mode for every policy being watched
+ */
 @Configurable
 public class PolicyNotificationMail{
-	private static Logger policyLogger	= FlexLogger.getLogger(PolicyNotificationMail.class);
-	
-	@Bean
-	public JavaMailSenderImpl javaMailSenderImpl(){
-		JavaMailSenderImpl mailSender = new JavaMailSenderImpl();
-		mailSender.setHost(PolicyController.getSmtpHost());
-		mailSender.setPort(Integer.parseInt(PolicyController.getSmtpPort()));
-		mailSender.setUsername(PolicyController.getSmtpUsername());
-		mailSender.setPassword(PolicyController.getSmtpPassword());
-		Properties prop = mailSender.getJavaMailProperties();
-		prop.put("mail.transport.protocol", "smtp");
-		prop.put("mail.smtp.auth", "true");
-		prop.put("mail.smtp.starttls.enable", "true");
-		prop.put("mail.debug", "true");
-		return mailSender;
-	}
+    private static final String POLICY_WATCHING_MESSAGE = "The Policy Which you are watching in  ";
+    private static final String EMAIL_MESSAGE_POSTSCRIPT = "Policy Notification System  (please don't respond to this email)";
+    private static final String ACTIVE_VERSION = "Active Version  : ";
+    private static Logger policyLogger	= FlexLogger.getLogger(PolicyNotificationMail.class);
 
-	public void sendMail(PolicyVersion entityItem, String policyName, String mode, CommonClassDao policyNotificationDao) throws MessagingException {  
-		String from = PolicyController.getSmtpUsername();
-		String to;
-		String subject = "";
-		String message = "";
-		DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
-		Date date = new Date();
-		if("EditPolicy".equalsIgnoreCase(mode)){
-			subject = "Policy has been Updated : "+entityItem.getPolicyName();
-			message = "The Policy Which you are watching in  " + PolicyController.getSmtpApplicationName() + " has been Updated" + '\n'  + '\n'  + '\n'+ "Scope + Policy Name  : "  + policyName + '\n' + "Active Version  : " +entityItem.getActiveVersion() 
-					 + '\n'  + '\n' + "Modified By : " +entityItem.getModifiedBy() + '\n' + "Modified Time  : " +dateFormat.format(date) + '\n' + '\n' + '\n' + '\n' + "Policy Notification System  (please don't respond to this email)";
-		}
-		if("Rename".equalsIgnoreCase(mode)){
-			subject = "Policy has been Renamed : "+entityItem.getPolicyName();
-			message = "The Policy Which you are watching in  " + PolicyController.getSmtpApplicationName() + " has been Renamed" + '\n'  + '\n'  + '\n'+ "Scope + Policy Name  : "  + policyName + '\n' + "Active Version  : " +entityItem.getActiveVersion() 
-					 + '\n'  + '\n' + "Renamed By : " +entityItem.getModifiedBy() + '\n' + "Renamed Time  : " +dateFormat.format(date) + '\n' + '\n' + '\n' + '\n' + "Policy Notification System  (please don't respond to this email)";
-		}
-		if("DeleteAll".equalsIgnoreCase(mode)){
-			subject = "Policy has been Deleted : "+entityItem.getPolicyName();
-			message = "The Policy Which you are watching in  " + PolicyController.getSmtpApplicationName() + " has been Deleted with All Versions" + '\n'  + '\n'  + '\n'+ "Scope + Policy Name  : "  + policyName + '\n'  
-					 + '\n'  + '\n' + "Deleted By : " +entityItem.getModifiedBy() + '\n' + "Deleted Time  : " +dateFormat.format(date) + '\n' + '\n' + '\n' + '\n' + "Policy Notification System  (please don't respond to this email)";
-		}
-		if("DeleteOne".equalsIgnoreCase(mode)){
-			subject = "Policy has been Deleted : "+entityItem.getPolicyName();
-			message = "The Policy Which you are watching in  " + PolicyController.getSmtpApplicationName() + " has been Deleted" + '\n'  + '\n'  + '\n'+ "Scope + Policy Name  : "  + policyName + '\n'  +"Policy Version : " +entityItem.getActiveVersion()
-					 + '\n'  + '\n' + "Deleted By : " +entityItem.getModifiedBy() + '\n' + "Deleted Time  : " +dateFormat.format(date) + '\n' + '\n' + '\n' + '\n' + "Policy Notification System  (please don't respond to this email)";
-		}
-		if("DeleteScope".equalsIgnoreCase(mode)){
-			subject = "Scope has been Deleted : "+entityItem.getPolicyName();
-			message = "The Scope Which you are watching in  " + PolicyController.getSmtpApplicationName() + " has been Deleted" + '\n'  + '\n'  + '\n'+ "Scope + Scope Name  : "  + policyName + '\n'  
-					 + '\n'  + '\n' + "Deleted By : " +entityItem.getModifiedBy() + '\n' + "Deleted Time  : " +dateFormat.format(date) + '\n' + '\n' + '\n' + '\n' + "Policy Notification System  (please don't respond to this email)";
-		}
-		if("SwitchVersion".equalsIgnoreCase(mode)){
-			subject = "Policy has been SwitchedVersion : "+entityItem.getPolicyName();
-			message = "The Policy Which you are watching in  " + PolicyController.getSmtpApplicationName() + " has been SwitchedVersion" + '\n'  + '\n'  + '\n'+ "Scope + Policy Name  : "  + policyName + '\n' + "Active Version  : " +entityItem.getActiveVersion() 
-					 + '\n'  + '\n' + "Switched By : " +entityItem.getModifiedBy() + '\n' + "Switched Time  : " +dateFormat.format(date) + '\n' + '\n' + '\n' + '\n' + "Policy Notification System  (please don't respond to this email)";
-		}
-		if("Move".equalsIgnoreCase(mode)){
-			subject = "Policy has been Moved to Other Scope : "+entityItem.getPolicyName();
-			message = "The Policy Which you are watching in  " + PolicyController.getSmtpApplicationName() + " has been Moved to Other Scope" + '\n'  + '\n'  + '\n'+ "Scope + Policy Name  : "  + policyName + '\n' + "Active Version  : " +entityItem.getActiveVersion() 
-					 + '\n'  + '\n' + "Moved By : " +entityItem.getModifiedBy() + '\n' + "Moved Time  : " +dateFormat.format(date) + '\n' + '\n' + '\n' + '\n' + "Policy Notification System  (please don't respond to this email)";
-		}
-		String policyFileName = entityItem.getPolicyName();
-		String checkPolicyName = policyName;
-		if(checkPolicyName.endsWith(".xml") || checkPolicyName.contains(".")){
-			checkPolicyName = checkPolicyName.substring(0, checkPolicyName.indexOf('.'));
-		}
-		if(policyFileName.contains("/")){
-			policyFileName = policyFileName.substring(0, policyFileName.indexOf('/'));
-			policyFileName = policyFileName.replace("/", File.separator);
-		}
-		if(policyFileName.contains("\\")){
-			policyFileName = policyFileName.substring(0, policyFileName.indexOf('\\'));
-			policyFileName = policyFileName.replace("\\", "\\\\");
-		}
-		
-		policyFileName += "%";
-		String query = "from WatchPolicyNotificationTable where policyName like:policyFileName";
-		boolean sendFlag = false;
-		SimpleBindings params = new SimpleBindings();
-		params.put("policyFileName", policyFileName);
-		List<Object> watchList;
-		if(PolicyController.isjUnit()){
-			watchList = policyNotificationDao.getDataByQuery(query, null);
-		}else{
-			watchList = policyNotificationDao.getDataByQuery(query, params);
-		}
-		if(watchList != null && !watchList.isEmpty()){
-			for(Object watch : watchList){
-				WatchPolicyNotificationTable list = (WatchPolicyNotificationTable) watch;
-				String watchPolicyName = list.getPolicyName();
-				if(watchPolicyName.contains("Config_") || watchPolicyName.contains("Action_") || watchPolicyName.contains("Decision_")){
-					if(watchPolicyName.equals(checkPolicyName)){
-						sendFlag = true;
-					}else{
-						sendFlag = false;
-					}
-				}
-				if(sendFlag){
-					try (AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext()) {
-						to = list.getLoginIds()+"@"+PolicyController.getSmtpEmailExtension();
-						to = to.trim();
-						ctx.register(PolicyNotificationMail.class);
-						ctx.refresh();
-						JavaMailSenderImpl mailSender = ctx.getBean(JavaMailSenderImpl.class);
-						MimeMessage mimeMessage = mailSender.createMimeMessage();
-						MimeMessageHelper mailMsg = new MimeMessageHelper(mimeMessage);
-						mailMsg.setFrom(new InternetAddress(from, "Policy Notification System"));
-						mailMsg.setTo(to);
-						mailMsg.setSubject(subject);
-						mailMsg.setText(message);
-						mailSender.send(mimeMessage);
-						if("Rename".equalsIgnoreCase(mode) || mode.contains("Delete") || mode.contains("Move")){
-							policyNotificationDao.delete(watch);
-						}
-					} catch (Exception e) {
-						policyLogger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW+"Exception Occured in Policy Notification" +e);
-					}
-				}
-			}
-		}
-	}
+    @Bean
+    public JavaMailSenderImpl javaMailSenderImpl(){
+        JavaMailSenderImpl mailSender = new JavaMailSenderImpl();
+        mailSender.setHost(PolicyController.getSmtpHost());
+        mailSender.setPort(Integer.parseInt(PolicyController.getSmtpPort()));
+        mailSender.setUsername(PolicyController.getSmtpUsername());
+        mailSender.setPassword(PolicyController.getSmtpPassword());
+        Properties prop = mailSender.getJavaMailProperties();
+        prop.put("mail.transport.protocol", "smtp");
+        prop.put("mail.smtp.auth", "true");
+        prop.put("mail.smtp.starttls.enable", "true");
+        prop.put("mail.debug", "true");
+        return mailSender;
+    }
+
+    /**
+     * Depending on the mode of operation on the policy, compose the subject and message.
+     * Invoke another internal method to actual send the mail. If the watch list is empty , then
+     * this method returns without sending notification mail
+     * @param entityItem Database item from which policy name could be extracted
+     * @param policyName Name of the policy for which notification is to be sent
+     * @param mode kind of operation done on the policy
+     * @param policyNotificationDao database access object for policy
+     * @throws MessagingException
+     */
+    public void sendMail(PolicyVersion entityItem, String policyName, String mode, CommonClassDao policyNotificationDao) throws MessagingException {
+
+        String subject = "";
+        String message = "";
+        DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
+        Date date = new Date();
+        if("EditPolicy".equalsIgnoreCase(mode)){
+            subject = "Policy has been Updated : "+entityItem.getPolicyName();
+            message = POLICY_WATCHING_MESSAGE + PolicyController.getSmtpApplicationName() + " has been Updated" + '\n'  + '\n'  + '\n'+ "Scope + Policy Name  : "  + policyName + '\n' + ACTIVE_VERSION +entityItem.getActiveVersion()
+                     + '\n'  + '\n' + "Modified By : " +entityItem.getModifiedBy() + '\n' + "Modified Time  : " +dateFormat.format(date) + '\n' + '\n' + '\n' + '\n' + EMAIL_MESSAGE_POSTSCRIPT;
+        }
+        if("Rename".equalsIgnoreCase(mode)){
+            subject = "Policy has been Renamed : "+entityItem.getPolicyName();
+            message = POLICY_WATCHING_MESSAGE + PolicyController.getSmtpApplicationName() + " has been Renamed" + '\n'  + '\n'  + '\n'+ "Scope + Policy Name  : "  + policyName + '\n' + ACTIVE_VERSION +entityItem.getActiveVersion()
+                     + '\n'  + '\n' + "Renamed By : " +entityItem.getModifiedBy() + '\n' + "Renamed Time  : " +dateFormat.format(date) + '\n' + '\n' + '\n' + '\n' + EMAIL_MESSAGE_POSTSCRIPT;
+        }
+        if("DeleteAll".equalsIgnoreCase(mode)){
+            subject = "Policy has been Deleted : "+entityItem.getPolicyName();
+            message = POLICY_WATCHING_MESSAGE + PolicyController.getSmtpApplicationName() + " has been Deleted with All Versions" + '\n'  + '\n'  + '\n'+ "Scope + Policy Name  : "  + policyName + '\n'
+                     + '\n'  + '\n' + "Deleted By : " +entityItem.getModifiedBy() + '\n' + "Deleted Time  : " +dateFormat.format(date) + '\n' + '\n' + '\n' + '\n' + EMAIL_MESSAGE_POSTSCRIPT;
+        }
+        if("DeleteOne".equalsIgnoreCase(mode)){
+            subject = "Policy has been Deleted : "+entityItem.getPolicyName();
+            message = POLICY_WATCHING_MESSAGE + PolicyController.getSmtpApplicationName() + " has been Deleted" + '\n'  + '\n'  + '\n'+ "Scope + Policy Name  : "  + policyName + '\n'  +"Policy Version : " +entityItem.getActiveVersion()
+                     + '\n'  + '\n' + "Deleted By : " +entityItem.getModifiedBy() + '\n' + "Deleted Time  : " +dateFormat.format(date) + '\n' + '\n' + '\n' + '\n' + EMAIL_MESSAGE_POSTSCRIPT;
+        }
+        if("DeleteScope".equalsIgnoreCase(mode)){
+            subject = "Scope has been Deleted : "+entityItem.getPolicyName();
+            message = "The Scope Which you are watching in  " + PolicyController.getSmtpApplicationName() + " has been Deleted" + '\n'  + '\n'  + '\n'+ "Scope + Scope Name  : "  + policyName + '\n'
+                     + '\n'  + '\n' + "Deleted By : " +entityItem.getModifiedBy() + '\n' + "Deleted Time  : " +dateFormat.format(date) + '\n' + '\n' + '\n' + '\n' + EMAIL_MESSAGE_POSTSCRIPT;
+        }
+        if("SwitchVersion".equalsIgnoreCase(mode)){
+            subject = "Policy has been SwitchedVersion : "+entityItem.getPolicyName();
+            message = POLICY_WATCHING_MESSAGE + PolicyController.getSmtpApplicationName() + " has been SwitchedVersion" + '\n'  + '\n'  + '\n'+ "Scope + Policy Name  : "  + policyName + '\n' + ACTIVE_VERSION +entityItem.getActiveVersion()
+                     + '\n'  + '\n' + "Switched By : " +entityItem.getModifiedBy() + '\n' + "Switched Time  : " +dateFormat.format(date) + '\n' + '\n' + '\n' + '\n' + EMAIL_MESSAGE_POSTSCRIPT;
+        }
+        if("Move".equalsIgnoreCase(mode)){
+            subject = "Policy has been Moved to Other Scope : "+entityItem.getPolicyName();
+            message = POLICY_WATCHING_MESSAGE + PolicyController.getSmtpApplicationName() + " has been Moved to Other Scope" + '\n'  + '\n'  + '\n'+ "Scope + Policy Name  : "  + policyName + '\n' + ACTIVE_VERSION +entityItem.getActiveVersion()
+                     + '\n'  + '\n' + "Moved By : " +entityItem.getModifiedBy() + '\n' + "Moved Time  : " +dateFormat.format(date) + '\n' + '\n' + '\n' + '\n' + EMAIL_MESSAGE_POSTSCRIPT;
+        }
+        String policyFileName = entityItem.getPolicyName();
+        String checkPolicyName = policyName;
+        if(checkPolicyName.endsWith(".xml") || checkPolicyName.contains(".")){
+            checkPolicyName = checkPolicyName.substring(0, checkPolicyName.indexOf('.'));
+        }
+        if(policyFileName.contains("/")){
+            policyFileName = policyFileName.substring(0, policyFileName.indexOf('/'));
+            policyFileName = policyFileName.replace("/", File.separator);
+        }
+        if(policyFileName.contains("\\")){
+            policyFileName = policyFileName.substring(0, policyFileName.indexOf('\\'));
+            policyFileName = policyFileName.replace("\\", "\\\\");
+        }
+
+        policyFileName += "%";
+        String query = "from WatchPolicyNotificationTable where policyName like:policyFileName";
+
+        SimpleBindings params = new SimpleBindings();
+        params.put("policyFileName", policyFileName);
+        List<Object> watchList;
+        if(PolicyController.isjUnit()){
+            watchList = policyNotificationDao.getDataByQuery(query, null);
+        }else{
+            watchList = policyNotificationDao.getDataByQuery(query, params);
+        }
+
+        if(watchList == null || watchList.isEmpty()) {
+            policyLogger.debug("List of policy being watched is either null or empty, hence return without sending mail");
+            return;
+        }
+
+        composeAndSendMail(mode, policyNotificationDao, subject, message, checkPolicyName, watchList);
+    }
+
+    /**
+     * For every policy being watched and when the policy name is one of the Config_, Action_ or Decision_,
+     * send the notification
+     * @param mode
+     * @param policyNotificationDao
+     * @param subject
+     * @param message
+     * @param checkPolicyName
+     * @param watchList
+     */
+    private void composeAndSendMail(String mode, CommonClassDao policyNotificationDao, String subject, String message, String checkPolicyName, List<Object> watchList) {
+        String from = PolicyController.getSmtpUsername();
+        String to;
+        for(Object watch : watchList){
+            WatchPolicyNotificationTable list = (WatchPolicyNotificationTable) watch;
+            String watchPolicyName = list.getPolicyName();
+            //this conditino check for specific stringin policy name being watched and
+            //also if the policy being checked is different from the watched ones,
+            //then there is no need to send mail, hence continue with next policy in the loop
+            if((watchPolicyName.contains("Config_") || watchPolicyName.contains("Action_") || watchPolicyName.contains("Decision_"))
+                    && !watchPolicyName.equals(checkPolicyName)){
+                continue;
+            }
+            try (AnnotationConfigApplicationContext ctx = new AnnotationConfigApplicationContext()) {
+                to = list.getLoginIds()+"@"+PolicyController.getSmtpEmailExtension();
+                to = to.trim();
+                ctx.register(PolicyNotificationMail.class);
+                ctx.refresh();
+                JavaMailSenderImpl mailSender = ctx.getBean(JavaMailSenderImpl.class);
+                MimeMessage mimeMessage = mailSender.createMimeMessage();
+                MimeMessageHelper mailMsg = new MimeMessageHelper(mimeMessage);
+                mailMsg.setFrom(new InternetAddress(from, "Policy Notification System"));
+                mailMsg.setTo(to);
+                mailMsg.setSubject(subject);
+                mailMsg.setText(message);
+                mailSender.send(mimeMessage);
+                if("Rename".equalsIgnoreCase(mode) || mode.contains("Delete") || mode.contains("Move")){
+                    policyNotificationDao.delete(watch);
+                }
+            } catch (Exception e) {
+                policyLogger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW+"Exception Occured in Policy Notification" +e);
+            }
+
+        }
+    }
 }
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyRestController.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyRestController.java
index 2eba697..2a52335 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyRestController.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyRestController.java
@@ -3,6 +3,7 @@
  * ONAP Policy Engine
  * ================================================================================
  * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Modified Copyright (C) 2018 Samsung Electronics Co., Ltd.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -289,12 +290,7 @@
                     connection.setRequestProperty("Content-Type",PolicyController.getContenttype());
                     ObjectMapper mapper = new ObjectMapper();
                     mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
-                    JsonNode root = null;
-                    try {
-                        root = mapper.readTree(request.getReader());
-                    }catch (Exception e1) {
-                        policyLogger.error("Exception Occured while calling PAP"+e1);
-                    }
+                    JsonNode root = getJsonNode(request, mapper);
 
                     ObjectMapper mapper1 = new ObjectMapper();
                     mapper1.configure(SerializationFeature.ORDER_MAP_ENTRIES_BY_KEYS, true);
@@ -302,15 +298,12 @@
                     Object obj = mapper1.treeToValue(root, Object.class);
                     String json = mapper1.writeValueAsString(obj);
 
-                    Object content =  new ByteArrayInputStream(json.getBytes());
-
-                    if (content instanceof InputStream) {
-                        // send current configuration
-                        try (OutputStream os = connection.getOutputStream()) {
-                            int count = IOUtils.copy((InputStream) content, os);
-                            if (policyLogger.isDebugEnabled()) {
-                                policyLogger.debug("copied to output, bytes=" + count);
-                            }
+                    // send current configuration
+                    try(InputStream content =  new ByteArrayInputStream(json.getBytes());
+                        OutputStream os = connection.getOutputStream()) {
+                        int count = IOUtils.copy(content, os);
+                        if (policyLogger.isDebugEnabled()) {
+                            policyLogger.debug("copied to output, bytes=" + count);
                         }
                     }
                 }else{
@@ -330,30 +323,7 @@
                     }
                 }
             }
-
-            connection.connect();
-
-            int responseCode = connection.getResponseCode();
-            if(responseCode == 200){
-                // get the response content into a String
-                String responseJson = null;
-                // read the inputStream into a buffer (trick found online scans entire input looking for end-of-file)
-                try(java.util.Scanner scanner = new java.util.Scanner(connection.getInputStream())) {
-                    scanner.useDelimiter("\\A");
-                    responseJson = scanner.hasNext() ? scanner.next() : "";
-                } catch (Exception e){
-                    //Reason for rethrowing the exception is if any exception occurs during reading of inputsteam
-                    //then the exception handling is done by the outer block without returning the response immediately
-                    //Also finally block is existing only in outer block and not here so all exception handling is
-                    //done in only one place
-                    policyLogger.error("Exception Occured"+e);
-                    throw e;
-                }
-
-                policyLogger.info("JSON response from PAP: " + responseJson);
-                return responseJson;
-            }
-
+            return doConnect(connection);
         } catch (Exception e) {
             policyLogger.error("Exception Occured"+e);
         }finally{
@@ -377,6 +347,41 @@
         return null;
     }
 
+    private JsonNode getJsonNode(HttpServletRequest request, ObjectMapper mapper) {
+        JsonNode root = null;
+        try {
+            root = mapper.readTree(request.getReader());
+        }catch (Exception e1) {
+            policyLogger.error("Exception Occured while calling PAP"+e1);
+        }
+        return root;
+    }
+
+    private String doConnect(final HttpURLConnection connection) throws IOException{
+        connection.connect();
+        int responseCode = connection.getResponseCode();
+        if(responseCode == 200){
+            // get the response content into a String
+            String responseJson = null;
+            // read the inputStream into a buffer (trick found online scans entire input looking for end-of-file)
+            try(java.util.Scanner scanner = new java.util.Scanner(connection.getInputStream())) {
+                scanner.useDelimiter("\\A");
+                responseJson = scanner.hasNext() ? scanner.next() : "";
+            } catch (Exception e){
+                //Reason for rethrowing the exception is if any exception occurs during reading of inputsteam
+                //then the exception handling is done by the outer block without returning the response immediately
+                //Also finally block is existing only in outer block and not here so all exception handling is
+                //done in only one place
+                policyLogger.error("Exception Occured"+e);
+                throw e;
+            }
+
+            policyLogger.info("JSON response from PAP: " + responseJson);
+            return responseJson;
+        }
+        return null;
+    }
+
     @RequestMapping(value={"/getDictionary/*"}, method={RequestMethod.GET})
     public void getDictionaryController(HttpServletRequest request, HttpServletResponse response){
         String uri = request.getRequestURI().replace("/getDictionary", "");
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/RESTfulPAPEngine.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/RESTfulPAPEngine.java
index 53be099..c09944c 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/RESTfulPAPEngine.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/RESTfulPAPEngine.java
@@ -3,6 +3,7 @@
  * ONAP Policy Engine
  * ================================================================================
  * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Modified Copyright (C) 2018 Samsung Electronics Co., Ltd.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -405,19 +406,7 @@
 
             if (contentObj != null) {
                 if (contentObj instanceof InputStream) {
-                    try {
-                        //
-                        // Send our current policy configuration
-                        //
-                        try (OutputStream os = connection.getOutputStream()) {
-                        int count = IOUtils.copy((InputStream)contentObj, os);
-                            if (LOGGER.isDebugEnabled()) {
-                                LOGGER.debug("copied to output, bytes="+count);
-                            }
-                        }
-                    } catch (Exception e) {
-                        LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Failed to write content in '" + method + "'", e);
-                    }
+                    sendCurrPolicyConfig(method, connection, (InputStream) contentObj);
                 } else {
                     // The contentObj is an object to be encoded in JSON
                     ObjectMapper mapper = new ObjectMapper();
@@ -453,16 +442,7 @@
                     return successMap;
                 } else {
                     // get the response content into a String
-                    String json = null;
-                    // read the inputStream into a buffer (trick found online scans entire input looking for end-of-file)
-                    try(java.util.Scanner scanner = new java.util.Scanner(connection.getInputStream())) {
-                        scanner.useDelimiter("\\A");
-                        json = scanner.hasNext() ? scanner.next() : "";
-                    } catch (Exception e){
-                        LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Failed to read inputStream from connection: " + e, e);
-                        throw e;
-                    }
-                    LOGGER.info("JSON response from PAP: " + json);
+                    String json = getJsonString(connection);
 
                     // convert Object sent as JSON into local object
                     ObjectMapper mapper = new ObjectMapper();
@@ -517,4 +497,34 @@
             }
         }
     }
+
+    private void sendCurrPolicyConfig(String method, final HttpURLConnection connection, InputStream contentObj) {
+        try {
+            //
+            // Send our current policy configuration
+            //
+            try (OutputStream os = connection.getOutputStream()) {
+            int count = IOUtils.copy(contentObj, os);
+                if (LOGGER.isDebugEnabled()) {
+                    LOGGER.debug("copied to output, bytes="+count);
+                }
+            }
+        } catch (Exception e) {
+            LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Failed to write content in '" + method + "'", e);
+        }
+    }
+
+    private String getJsonString(final HttpURLConnection connection) throws IOException {
+        String json = null;
+        // read the inputStream into a buffer (trick found online scans entire input looking for end-of-file)
+        try(java.util.Scanner scanner = new java.util.Scanner(connection.getInputStream())) {
+            scanner.useDelimiter("\\A");
+            json = scanner.hasNext() ? scanner.next() : "";
+        } catch (Exception e){
+            LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Failed to read inputStream from connection: " + e, e);
+            throw e;
+        }
+        LOGGER.info("JSON response from PAP: " + json);
+        return json;
+    }
 }
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/ExportAndImportDecisionBlackListEntries.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/ExportAndImportDecisionBlackListEntries.java
new file mode 100644
index 0000000..8a37e9d
--- /dev/null
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/ExportAndImportDecisionBlackListEntries.java
@@ -0,0 +1,380 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP Policy Engine
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.policy.controller;
+
+import com.google.gson.Gson;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.PrintWriter;
+import java.nio.file.Files;
+import java.text.SimpleDateFormat;
+import java.util.ArrayList;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Set;
+import java.util.stream.Collectors;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import org.apache.commons.compress.utils.IOUtils;
+import org.apache.commons.fileupload.FileItem;
+import org.apache.commons.fileupload.FileUploadException;
+import org.apache.commons.fileupload.disk.DiskFileItemFactory;
+import org.apache.commons.fileupload.servlet.ServletFileUpload;
+import org.apache.poi.hssf.usermodel.HSSFRow;
+import org.apache.poi.hssf.usermodel.HSSFSheet;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.Row;
+import org.apache.poi.ss.usermodel.Sheet;
+import org.apache.poi.ss.usermodel.Workbook;
+import org.apache.poi.ss.usermodel.WorkbookFactory;
+import org.json.JSONObject;
+import org.onap.policy.common.logging.flexlogger.FlexLogger;
+import org.onap.policy.common.logging.flexlogger.Logger;
+import org.onap.policy.rest.adapter.PolicyRestAdapter;
+import org.onap.policy.rest.adapter.ReturnBlackList;
+import org.onap.policy.xacml.api.XACMLErrorConstants;
+import org.onap.portalsdk.core.controller.RestrictedBaseController;
+import org.onap.portalsdk.core.web.support.JsonMessage;
+import org.springframework.stereotype.Controller;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestMethod;
+
+
+
+/**
+ * This class is used to import and export the black list entries which were used in the Decision Blacklist Guard YAML
+ * Policy.
+ *
+ */
+@Controller
+@RequestMapping("/")
+public class ExportAndImportDecisionBlackListEntries extends RestrictedBaseController {
+
+    private static final Logger policyLogger = FlexLogger.getLogger(ExportAndImportDecisionBlackListEntries.class);
+    private static final String BLACKLISTENTRIESDATA = "blackListEntries";
+    private static final String ACTION = "Action";
+    private static final String BLACKLISTENTRY = "BlackListEntry";
+
+    /**
+     * This method is used to Export the Black List entries data from Decision BlackList Guard YAML Policy. So, user can
+     * update the file on adding or removing the entries, for updating the policies or using in other Environments.
+     * 
+     * @param request the request contains the policy data. So, based on that we can populate and read and write the
+     *        entries.
+     * @param response after reading and writing the blacklist list entries to file, the file is copied to tmp directory
+     *        and making available to user to download from GUI.
+     * @throws IOException exception throws if anything goes wrong in the process.
+     */
+    @RequestMapping(value = {"/policycreation/exportDecisionBlackListEntries"}, method = {RequestMethod.POST})
+    public void exportBlackList(HttpServletRequest request, HttpServletResponse response) throws IOException {
+        try (HSSFWorkbook workBook = new HSSFWorkbook()) {
+            String requestData = request.getReader().lines().collect(Collectors.joining());
+            JSONObject root = new JSONObject(requestData);
+            PolicyRestAdapter adapter = new Gson().fromJson(root.get("policyData").toString(), PolicyRestAdapter.class);
+            DecisionPolicyController controller = new DecisionPolicyController();
+            controller.prePopulateDecisionPolicyData(adapter, null);
+            List<String> blackLists = adapter.getYamlparams().getBlackList();
+            HSSFSheet sheet = workBook.createSheet("BlackList");
+            HSSFRow headingRow = sheet.createRow(0);
+            headingRow.createCell(0).setCellValue("Action");
+            headingRow.createCell(1).setCellValue("BlackListEntry");
+
+            short rowNo = 1;
+            for (Object object : blackLists) {
+                HSSFRow row = sheet.createRow(rowNo);
+                row.createCell(0).setCellValue(1);
+                row.createCell(1).setCellValue(object.toString());
+                rowNo++;
+            }
+
+            String tmpFile = System.getProperty("catalina.base") + File.separator + "webapps" + File.separator + "temp";
+
+            /*
+             * Export FileName is the combination of BlacList+Scope+PolicyName+Version+PolicyCreatedDate.
+             * 
+             */
+
+            SimpleDateFormat parseFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+            Date date = parseFormat.parse(root.get("date").toString().replaceAll("\"", ""));
+            SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd_HHmmss");
+            String formatedDate = dateFormat.format(date);
+
+            String fileName = "BlackList_Scope_" + adapter.getDomainDir() + "_Name_" + adapter.getPolicyName()
+                    + "_Version_" + root.get("version").toString() + "_Date_" + formatedDate + ".xls";
+
+            String deleteCheckPath = tmpFile + File.separator + fileName;
+            File deleteCheck = new File(deleteCheckPath);
+            if (deleteCheck.exists() && deleteCheck.delete()) {
+                policyLogger.info("Deleted the file from system before exporting a new file.");
+            }
+
+            File temPath = new File(tmpFile);
+            if (!temPath.exists()) {
+                temPath.mkdir();
+            }
+
+            String file = temPath + File.separator + fileName;
+            File filepath = new File(file);
+            FileOutputStream fos = new FileOutputStream(filepath);
+            workBook.write(fos);
+            fos.flush();
+
+            response.setCharacterEncoding("UTF-8");
+            response.setContentType("application / json");
+            request.setCharacterEncoding("UTF-8");
+
+            PrintWriter out = response.getWriter();
+            String successMap = file.substring(file.lastIndexOf("webapps") + 8);
+            String responseString = new Gson().toJson(successMap);
+            JSONObject jsonResposne = new JSONObject("{data: " + responseString + "}");
+            out.write(jsonResposne.toString());
+        } catch (Exception e) {
+            policyLogger.error(
+                    XACMLErrorConstants.ERROR_SYSTEM_ERROR + "Exception Occured while Exporting BlackList Entries" , e);
+        }
+    }
+
+    /**
+     * This method is used to import the BlackList excel file into the system. Which is used to create Decision
+     * Blacklist Guard YAML Policy.
+     * 
+     * @param request the HTTP request contains file upload stream form GUI.
+     * @param response the response is send to the GUI after reading the file input stream.
+     * @throws FileUploadException throws fileUpload Exception.
+     * @throws IOException throws IO Exceptions.
+     */
+    @RequestMapping(value = {"/policycreation/importBlackListForDecisionPolicy"}, method = {RequestMethod.POST})
+    public void importBlackListFile(HttpServletRequest request, HttpServletResponse response) throws Exception {
+        List<FileItem> items = new ServletFileUpload(new DiskFileItemFactory()).parseRequest(request);
+        List<String> errorLogs = new ArrayList<>();
+        Gson mapper = new Gson();
+        errorLogs.add("error");
+        Map<String, Object> model = new HashMap<>();
+        if (items.isEmpty()) {
+            errorLogs.add("The File doesn't have any content and it is invalid.");
+            model.put(BLACKLISTENTRIESDATA, errorLogs);
+        } else {
+            readItems(items, errorLogs, model);
+        }
+        JsonMessage msg = new JsonMessage(mapper.toJson(model));
+        JSONObject jsonResposne = new JSONObject(msg);
+        response.getWriter().write(jsonResposne.toString());
+    }
+
+    /**
+     * This method is used to read the first item, as we expect only one entry in the file upload.
+     * 
+     * @param items The file entries which were uploaded from GUI.
+     * @param errorLogs on adding all incorrect entries, we can let user know what need to fixed.
+     * @param model Map which stores key value (blacklist and append list data)
+     * @throws Exception throws exception if it is not .xls format
+     */
+    private void readItems(List<FileItem> items, List<String> errorLogs, Map<String, Object> model) throws Exception {
+        Map<String, InputStream> files = new HashMap<>();
+
+        FileItem item = items.get(0);
+        files.put(item.getName(), item.getInputStream());
+        File file = new File(item.getName());
+        String fileName = file.getName();
+        try (OutputStream outputStream = new FileOutputStream(file);) {
+            IOUtils.copy(item.getInputStream(), outputStream);
+            if (fileName.startsWith("BlackList") && fileName.endsWith(".xls")) {
+                readWorkBook(fileName, errorLogs, model);
+            } else {
+                errorLogs.add("The File Name should start with BlackList and must be .xls format.");
+                model.put(BLACKLISTENTRIESDATA, errorLogs);
+            }
+        }
+        Files.delete(file.toPath());
+    }
+
+    /**
+     * This method is used to read the workbook in xls file item.
+     * 
+     * @param fileName fileName as input parameter
+     * @param errorLogs on adding all incorrect entries, we can let user know what need to fixed.
+     * @param model Map which stores key value (blacklist and append list data)
+     */
+    private void readWorkBook(String fileName, List<String> errorLogs, Map<String, Object> model) {
+        Set<String> blackListEntries = new HashSet<>();
+        Set<String> appendBlackListEntries = new HashSet<>();
+        try (Workbook workbook = WorkbookFactory.create(new File(fileName))) {
+            Sheet datatypeSheet = workbook.getSheetAt(0);
+            Iterator<Row> rowIterator = datatypeSheet.iterator();
+            readExcelRows(rowIterator, blackListEntries, appendBlackListEntries, errorLogs);
+            if (errorLogs.size() == 1) {
+                model.put(BLACKLISTENTRIESDATA, blackListEntries);
+                model.put("appendBlackListEntries", appendBlackListEntries);
+            } else {
+                model.put(BLACKLISTENTRIESDATA, errorLogs);
+            }
+        } catch (Exception e) {
+            String error = "Error Occured While Reading File. Please check the format of the file.";
+            errorLogs.add(error);
+            model.put(BLACKLISTENTRIESDATA, errorLogs);
+            policyLogger.error(error , e);
+        }
+    }
+
+    /**
+     * This method is used to read all the rows from imported Excel sheet and set to respective objects.
+     * 
+     * @param rowIterator Excel Sheet rows are passed as input parameters.
+     * @param blackListEntries the data is set to this object, which is going to be added.
+     * @param appendBlackListEntries the data is set to this object which is going to be removed.
+     * @param errorLogs on adding all incorrect entries, we can let user know what need to fixed.
+     */
+    private void readExcelRows(Iterator<Row> rowIterator, Set<String> blackListEntries,
+            Set<String> appendBlackListEntries, List<String> errorLogs) {
+        while (rowIterator.hasNext()) {
+            Row currentRow = rowIterator.next();
+            if (currentRow.getRowNum() == 0) {
+                continue;
+            }
+            Iterator<Cell> cellIterator = currentRow.cellIterator();
+            readExcelCells(cellIterator, blackListEntries, appendBlackListEntries, errorLogs);
+        }
+    }
+
+    /**
+     * This method is used to read all the cells in the row.
+     * 
+     * @param cellIterator iterating the cells and will parse based on the cell type.
+     * @param blackListEntries the data is set to this object, which is going to be added.
+     * @param appendBlackListEntries the data is set to this object which is going to be removed.
+     * @param errorLogs on adding all incorrect entries, we can let user know what need to fixed.
+     */
+    private void readExcelCells(Iterator<Cell> cellIterator, Set<String> blackListEntries,
+            Set<String> appendBlackListEntries, List<String> errorLogs) {
+        boolean actionCheck = false;
+        boolean blackListCheck = false;
+        String blEntry = "";
+        int actionEntry = 0;
+        int lineNo = 1;
+        while (cellIterator.hasNext()) {
+            Cell cell = cellIterator.next();
+            if (ACTION.equalsIgnoreCase(getCellHeaderName(cell))) {
+                ReturnBlackList returnList = readActionCell(cell, lineNo, errorLogs);
+                actionEntry = returnList.getActionValue();
+                actionCheck = returnList.isEntryCheck();
+            }
+            if (BLACKLISTENTRY.equalsIgnoreCase(getCellHeaderName(cell))) {
+                ReturnBlackList returnList = readBlackListCell(cell, lineNo, errorLogs);
+                blEntry = returnList.getEntryValue();
+                blackListCheck = returnList.isEntryCheck();
+                actionEntry = returnList.getActionValue();
+            }
+            lineNo++;
+        }
+        if (actionCheck && blackListCheck) {
+            addBlackListEntries(actionEntry, blackListEntries, appendBlackListEntries, blEntry);
+        }
+    }
+
+    /**
+     * This method is used to read the Action cell entry.
+     * 
+     * @param cell reading the action entry cell.
+     * @param lineNo counts the number of the cell.
+     * @param errorLogs on adding all incorrect entries, we can let user know what need to fixed.
+     * @return returns the response on setting to ReturnBlackList class.
+     */
+    private ReturnBlackList readActionCell(Cell cell, int lineNo, List<String> errorLogs) {
+        ReturnBlackList returnValues = new ReturnBlackList();
+        String error = "Entry at row " + lineNo + " not added, the value in the " + ACTION
+                + "column is neither \"0\" nor \"1\"";
+        int actionEntry = 0;
+        try {
+            actionEntry = (int) cell.getNumericCellValue();
+            returnValues.setEntryCheck(true);
+            if (actionEntry != 1 && actionEntry != 0) {
+                errorLogs.add(error);
+            }
+        } catch (Exception e) {
+            errorLogs.add(error);
+            policyLogger.error(error, e);
+            actionEntry = 0;
+        }
+        returnValues.setActionValue(actionEntry);
+        return returnValues;
+    }
+
+    /**
+     * 
+     * This method is used to read the BlackList cell entry.
+     * 
+     * @param cell reading the blacklist entry cell.
+     * @param lineNo counts the number of the cell.
+     * @param errorLogs on adding all incorrect entries, we can let user know what need to fixed.
+     * @return returns the response on setting to ReturnBlackList class.
+     */
+    private ReturnBlackList readBlackListCell(Cell cell, int lineNo, List<String> errorLogs) {
+        ReturnBlackList returnValues = new ReturnBlackList();
+        String blEntry = "";
+        try {
+            blEntry = cell.getStringCellValue();
+            returnValues.setEntryCheck(true);
+        } catch (Exception e) {
+            String error = "Entry at row " + lineNo + " not added, the value in the " + BLACKLISTENTRY
+                    + " column is not a valid string";
+            errorLogs.add(error);
+            policyLogger.error(error, e);
+            returnValues.setActionValue(0);
+        }
+        returnValues.setEntryValue(blEntry);
+        return returnValues;
+    }
+
+    /**
+     * This method is used to add the data to blacklist and append list after parsing each and every row.
+     * 
+     * @param actionEntry it has the input to add or not and holds either 0 or 1.
+     * @param blackListEntries list to add blacklist entries based on action entry = 1.
+     * @param appendBlackListEntries list to add append list entries based on action entry = 0.
+     * @param blEntry the value added to both entries based on action entry.
+     */
+    private void addBlackListEntries(int actionEntry, Set<String> blackListEntries, Set<String> appendBlackListEntries,
+            String blEntry) {
+        if (actionEntry == 1) {
+            blackListEntries.add(blEntry);
+        } else {
+            appendBlackListEntries.add(blEntry);
+        }
+    }
+
+    /**
+     * This method is used to identify the header of the cell.
+     * 
+     * @param cell Excel sheet cell is passed as input parameter.
+     * @return the column header name value
+     */
+    private String getCellHeaderName(Cell cell) {
+        return cell.getSheet().getRow(0).getCell(cell.getColumnIndex()).getRichStringCellValue().toString();
+    }
+}
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PolicyController.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PolicyController.java
index ae473f3..2200eae 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PolicyController.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PolicyController.java
@@ -3,6 +3,7 @@
  * ONAP Policy Engine
  * ================================================================================
  * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Modified Copyright (C) 2018 Samsung Electronics Co., Ltd.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -71,663 +72,659 @@
 @Controller
 @RequestMapping("/")
 public class PolicyController extends RestrictedBaseController {
-	private static final Logger	policyLogger	= FlexLogger.getLogger(PolicyController.class);
+    private static final Logger	policyLogger	= FlexLogger.getLogger(PolicyController.class);
 
-	private static CommonClassDao commonClassDao;
-	//
-	// The PAP Engine
-	//
-	private static PAPPolicyEngine papEngine;
+    private static CommonClassDao commonClassDao;
+    //
+    // The PAP Engine
+    //
+    private static PAPPolicyEngine papEngine;
 
-	private static String logTableLimit;
-	private static String systemAlertTableLimit;
-	protected static Map<String, String> dropDownMap = new HashMap<>();
-	public static Map<String, String> getDropDownMap() {
-		return dropDownMap;
-	}
+    private static String logTableLimit;
+    private static String systemAlertTableLimit;
+    protected static Map<String, String> dropDownMap = new HashMap<>();
+    public static Map<String, String> getDropDownMap() {
+        return dropDownMap;
+    }
 
-	public static void setDropDownMap(Map<String, String> dropDownMap) {
-		PolicyController.dropDownMap = dropDownMap;
-	}
+    public static void setDropDownMap(Map<String, String> dropDownMap) {
+        PolicyController.dropDownMap = dropDownMap;
+    }
 
-	public static String getDomain() {
-		return XACMLProperties.getProperty(XACMLRestProperties.PROP_ADMIN_DOMAIN, "urn");
-	}
+    public static String getDomain() {
+        return XACMLProperties.getProperty(XACMLRestProperties.PROP_ADMIN_DOMAIN, "urn");
+    }
 
-	private static final Object mapAccess = new Object();
-	private static Map<Datatype, List<FunctionDefinition>> mapDatatype2Function = null;
-	private static Map<String, FunctionDefinition> mapID2Function = null;
+    private static final Object mapAccess = new Object();
+    private static Map<Datatype, List<FunctionDefinition>> mapDatatype2Function = null;
+    private static Map<String, FunctionDefinition> mapID2Function = null;
 
-	//Constant variables used across Policy-sdk
-	private static final String policyData = "policyData";
-	private static final String characterEncoding = "UTF-8";
-	private static final String contentType = "application/json";
-	private static final String file = "file";
+    //Constant variables used across Policy-sdk
+    private static final String policyData = "policyData";
+    private static final String characterEncoding = "UTF-8";
+    private static final String contentType = "application/json";
+    private static final String file = "file";
 
-	//Smtp Java Mail Properties
-	private static String smtpHost = null;
-	private static String smtpPort = null;
-	private static String smtpUsername = null;
-	private static String smtpPassword = null;
-	private static String smtpApplicationName = null;
-	private static String smtpEmailExtension = null;
-	//log db Properties
-	private static String logdbDriver = null;
-	private static String logdbUrl = null;
-	private static String logdbUserName = null;
-	private static String logdbPassword = null;
-	private static String logdbDialect = null;
-	//Xacml db properties
-	private static String xacmldbUrl = null;
-	private static String xacmldbUserName = null;
-	private static String xacmldbPassword = null;
+    //Smtp Java Mail Properties
+    private static String smtpHost = null;
+    private static String smtpPort = null;
+    private static String smtpUsername = null;
+    private static String smtpPassword = null;
+    private static String smtpApplicationName = null;
+    private static String smtpEmailExtension = null;
+    //log db Properties
+    private static String logdbDriver = null;
+    private static String logdbUrl = null;
+    private static String logdbUserName = null;
+    private static String logdbPassword = null;
+    private static String logdbDialect = null;
+    //Xacml db properties
+    private static String xacmldbUrl = null;
+    private static String xacmldbUserName = null;
+    private static String xacmldbPassword = null;
 
-	//AutoPush feature.
-	private static String autoPushAvailable;
-	private static String autoPushDSClosedLoop;
-	private static String autoPushDSFirewall;
-	private static String autoPushDSMicroservice;
-	private static String autoPushPDPGroup;
+    //AutoPush feature.
+    private static String autoPushAvailable;
+    private static String autoPushDSClosedLoop;
+    private static String autoPushDSFirewall;
+    private static String autoPushDSMicroservice;
+    private static String autoPushPDPGroup;
 
-	//papURL
-	private static String papUrl;
+    //papURL
+    private static String papUrl;
 
-	//MicroService Model Properties
-	private static String msOnapName;
-	private static String msPolicyName;
+    //MicroService Model Properties
+    private static String msOnapName;
+    private static String msPolicyName;
 
-	//WebApp directories
-	private static String configHome;
-	private static String actionHome;
-	
-	//File upload size
-	private static long fileSizeLimit;
-	
-	private static boolean jUnit = false;
-	
+    //WebApp directories
+    private static String configHome;
+    private static String actionHome;
 
-	public static boolean isjUnit() {
-		return jUnit;
-	}
+    //File upload size
+    private static long fileSizeLimit;
 
-	public static void setjUnit(boolean jUnit) {
-		PolicyController.jUnit = jUnit;
-	}
+    private static boolean jUnit = false;
 
-	@Autowired
-	private PolicyController(CommonClassDao commonClassDao){
-		PolicyController.commonClassDao = commonClassDao;
-	}
 
-	public PolicyController() {
-		// Empty constructor
-	}
+    public static boolean isjUnit() {
+        return jUnit;
+    }
 
-	@PostConstruct
-	public void init(){
-		Properties prop = new Properties();
-		InputStream input = null;
-		try {
-			if(jUnit){
-				File file = new File(new File(".").getCanonicalPath() + File.separator + "src"+ File.separator + "test" + File.separator + "resources" + File.separator + "JSONConfig.json");
-				input = new FileInputStream(file);
-			}else{
-				input = new FileInputStream("xacml.admin.properties");
-			}
-			// load a properties file
-			prop.load(input);
-			//file upload size limit property
-			setFileSizeLimit(prop.getProperty("file.size.limit"));
-			//pap url
-			setPapUrl(prop.getProperty("xacml.rest.pap.url"));
-			// get the property values
-			setSmtpHost(prop.getProperty("onap.smtp.host"));
-			setSmtpPort(prop.getProperty("onap.smtp.port"));
-			setSmtpUsername(prop.getProperty("onap.smtp.userName"));
-			setSmtpPassword(prop.getProperty("onap.smtp.password"));
-			setSmtpApplicationName(prop.getProperty("onap.application.name"));
-			setSmtpEmailExtension(prop.getProperty("onap.smtp.emailExtension"));
-			//Log Database Properties
-			setLogdbDriver(prop.getProperty("xacml.log.db.driver"));
-			setLogdbUrl(prop.getProperty("xacml.log.db.url"));
-			setLogdbUserName(prop.getProperty("xacml.log.db.user"));
-			setLogdbPassword(prop.getProperty("xacml.log.db.password"));
-			setLogdbDialect(prop.getProperty("onap.dialect"));
-			//Xacml Database Properties
-			setXacmldbUrl(prop.getProperty("javax.persistence.jdbc.url"));
-			setXacmldbUserName(prop.getProperty("javax.persistence.jdbc.user"));
-			setXacmldbPassword(prop.getProperty("javax.persistence.jdbc.password"));
-			//AutoPuh
-			setAutoPushAvailable(prop.getProperty("xacml.automatic.push"));
-			setAutoPushDSClosedLoop(prop.getProperty("xacml.autopush.closedloop"));
-			setAutoPushDSFirewall(prop.getProperty("xacml.autopush.firewall"));
-			setAutoPushDSMicroservice(prop.getProperty("xacml.autopush.microservice"));
-			setAutoPushPDPGroup(prop.getProperty("xacml.autopush.pdpGroup"));
-			//Micro Service Properties
-			setMsOnapName(prop.getProperty("xacml.policy.msOnapName"));
-			if(getMsOnapName() == null){
-				setMsOnapName(prop.getProperty("xacml.policy.msEcompName"));
-			}
-			policyLogger.info("getMsOnapName => " + getMsOnapName());
-			setMsPolicyName(prop.getProperty("xacml.policy.msPolicyName"));
-			policyLogger.info("setMsPolicyName => " + getMsPolicyName());
-			//WebApp directories
-			setConfigHome(prop.getProperty("xacml.rest.config.webapps") + "Config");
-			setActionHome(prop.getProperty("xacml.rest.config.webapps") + "Action");
-			//Get the Property Values for Dashboard tab Limit
-			try{
-				setLogTableLimit(prop.getProperty("xacml.onap.dashboard.logTableLimit"));
-				setSystemAlertTableLimit(prop.getProperty("xacml.onap.dashboard.systemAlertTableLimit"));
-			}catch(Exception e){
-				policyLogger.error(XACMLErrorConstants.ERROR_DATA_ISSUE+"Dashboard tab Property fields are missing" +e);
-				setLogTableLimit("5000");
-				setSystemAlertTableLimit("2000");
-			}
-			System.setProperty(XACMLProperties.XACML_PROPERTIES_NAME, "xacml.admin.properties");
-		} catch (IOException ex) {
-			policyLogger.error(XACMLErrorConstants.ERROR_DATA_ISSUE+"Exception Occured while reading the Smtp properties from xacml.admin.properties file" +ex);
-		} finally {
-			if (input != null) {
-				try {
-					input.close();
-				} catch (IOException e) {
-					policyLogger.error(XACMLErrorConstants.ERROR_DATA_ISSUE+"Exception Occured while Closing the xacml.admin.properties file" +e);
-				}
-			}
-		}
+    public static void setjUnit(boolean jUnit) {
+        PolicyController.jUnit = jUnit;
+    }
 
-		//Initialize the FunctionDefinition table at Server Start up
-		Map<Datatype, List<FunctionDefinition>> functionMap = getFunctionDatatypeMap();
-		for ( Entry<Datatype, List<FunctionDefinition>> entry : functionMap.entrySet()) {
-			List<FunctionDefinition> functionDefinations = entry.getValue();
-			for (FunctionDefinition functionDef : functionDefinations) {
-				dropDownMap.put(functionDef.getShortname(),functionDef.getXacmlid());
-			}
-		}
+    @Autowired
+    private PolicyController(CommonClassDao commonClassDao){
+        PolicyController.commonClassDao = commonClassDao;
+    }
 
-	}
+    public PolicyController() {
+        // Empty constructor
+    }
 
-	public static  Map<Datatype, List<FunctionDefinition>>	getFunctionDatatypeMap() {
-		synchronized(mapAccess) {
-			if (mapDatatype2Function == null) {
-				buildFunctionMaps();
-			}
-		}
-		return mapDatatype2Function;
-	}
+    @PostConstruct
+    public void init(){
+        Properties prop = new Properties();
 
-	public static Map<String, FunctionDefinition> getFunctionIDMap() {
-		synchronized(mapAccess) {
-			if (mapID2Function == null) {
-				buildFunctionMaps();
-			}
-		}
-		return mapID2Function;
-	}
+        try {
+            String fileName;
+            if(jUnit){
+                fileName = new File(".").getCanonicalPath() + File.separator + "src"+ File.separator + "test" + File.separator + "resources" + File.separator + "JSONConfig.json";
+            } else {
+                fileName = "xacml.admin.properties";
+            }
 
-	private static  void buildFunctionMaps() {
-		mapDatatype2Function = new HashMap<>();
-		mapID2Function = new  HashMap<>();
-		List<Object> functiondefinitions = commonClassDao.getData(FunctionDefinition.class);
-		for (int i = 0; i < functiondefinitions.size(); i ++) {
-			FunctionDefinition value = (FunctionDefinition) functiondefinitions.get(i);
-			mapID2Function.put(value.getXacmlid(), value);
-			if (!mapDatatype2Function.containsKey(value.getDatatypeBean())) {
-				mapDatatype2Function.put(value.getDatatypeBean(), new ArrayList<FunctionDefinition>());
-			}
-			mapDatatype2Function.get(value.getDatatypeBean()).add(value);
-		}
-	}
+            try(InputStream input = new FileInputStream(fileName)) {
+                // load a properties file
+                prop.load(input);
+            }
 
-	@RequestMapping(value={"/get_FunctionDefinitionDataByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
-	public void getFunctionDefinitionData(HttpServletRequest request, HttpServletResponse response){
-		try{
-			Map<String, Object> model = new HashMap<>();
-			ObjectMapper mapper = new ObjectMapper();
-			model.put("functionDefinitionDatas", mapper.writeValueAsString(commonClassDao.getDataByColumn(FunctionDefinition.class, "shortname")));
-			JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
-			JSONObject j = new JSONObject(msg);
-			response.getWriter().write(j.toString());
-		}
-		catch (Exception e){
-			policyLogger.error(XACMLErrorConstants.ERROR_DATA_ISSUE +"Error while retriving the Function Definition data"+e);
-		}
-	}
+            //file upload size limit property
+            setFileSizeLimit(prop.getProperty("file.size.limit"));
+            //pap url
+            setPapUrl(prop.getProperty("xacml.rest.pap.url"));
+            // get the property values
+            setSmtpHost(prop.getProperty("onap.smtp.host"));
+            setSmtpPort(prop.getProperty("onap.smtp.port"));
+            setSmtpUsername(prop.getProperty("onap.smtp.userName"));
+            setSmtpPassword(prop.getProperty("onap.smtp.password"));
+            setSmtpApplicationName(prop.getProperty("onap.application.name"));
+            setSmtpEmailExtension(prop.getProperty("onap.smtp.emailExtension"));
+            //Log Database Properties
+            setLogdbDriver(prop.getProperty("xacml.log.db.driver"));
+            setLogdbUrl(prop.getProperty("xacml.log.db.url"));
+            setLogdbUserName(prop.getProperty("xacml.log.db.user"));
+            setLogdbPassword(prop.getProperty("xacml.log.db.password"));
+            setLogdbDialect(prop.getProperty("onap.dialect"));
+            //Xacml Database Properties
+            setXacmldbUrl(prop.getProperty("javax.persistence.jdbc.url"));
+            setXacmldbUserName(prop.getProperty("javax.persistence.jdbc.user"));
+            setXacmldbPassword(prop.getProperty("javax.persistence.jdbc.password"));
+            //AutoPuh
+            setAutoPushAvailable(prop.getProperty("xacml.automatic.push"));
+            setAutoPushDSClosedLoop(prop.getProperty("xacml.autopush.closedloop"));
+            setAutoPushDSFirewall(prop.getProperty("xacml.autopush.firewall"));
+            setAutoPushDSMicroservice(prop.getProperty("xacml.autopush.microservice"));
+            setAutoPushPDPGroup(prop.getProperty("xacml.autopush.pdpGroup"));
+            //Micro Service Properties
+            setMsOnapName(prop.getProperty("xacml.policy.msOnapName"));
+            if(getMsOnapName() == null){
+                setMsOnapName(prop.getProperty("xacml.policy.msEcompName"));
+            }
+            policyLogger.info("getMsOnapName => " + getMsOnapName());
+            setMsPolicyName(prop.getProperty("xacml.policy.msPolicyName"));
+            policyLogger.info("setMsPolicyName => " + getMsPolicyName());
+            //WebApp directories
+            setConfigHome(prop.getProperty("xacml.rest.config.webapps") + "Config");
+            setActionHome(prop.getProperty("xacml.rest.config.webapps") + "Action");
+            //Get the Property Values for Dashboard tab Limit
+            try{
+                setLogTableLimit(prop.getProperty("xacml.onap.dashboard.logTableLimit"));
+                setSystemAlertTableLimit(prop.getProperty("xacml.onap.dashboard.systemAlertTableLimit"));
+            }catch(Exception e){
+                policyLogger.error(XACMLErrorConstants.ERROR_DATA_ISSUE+"Dashboard tab Property fields are missing" +e);
+                setLogTableLimit("5000");
+                setSystemAlertTableLimit("2000");
+            }
+            System.setProperty(XACMLProperties.XACML_PROPERTIES_NAME, "xacml.admin.properties");
+        } catch (IOException ex) {
+            policyLogger.error(XACMLErrorConstants.ERROR_DATA_ISSUE+"Exception Occured while reading the Smtp properties from xacml.admin.properties file" +ex);
+        }
 
-	public PolicyEntity getPolicyEntityData(String scope, String policyName){
-		String key = scope + ":" + policyName;
-		List<Object> data = commonClassDao.getDataById(PolicyEntity.class, "scope:policyName", key);
-		return (PolicyEntity) data.get(0);
-	}
+        //Initialize the FunctionDefinition table at Server Start up
+        Map<Datatype, List<FunctionDefinition>> functionMap = getFunctionDatatypeMap();
+        for ( Entry<Datatype, List<FunctionDefinition>> entry : functionMap.entrySet()) {
+            List<FunctionDefinition> functionDefinations = entry.getValue();
+            for (FunctionDefinition functionDef : functionDefinations) {
+                dropDownMap.put(functionDef.getShortname(),functionDef.getXacmlid());
+            }
+        }
 
-	public static Map<String, Roles> getUserRoles(String userId) {
-		Map<String, Roles> scopes = new HashMap<>();
-		List<Object> roles = commonClassDao.getDataById(Roles.class, "loginId", userId);
-		if (roles != null && !roles.isEmpty()) {
-			for (Object role : roles) {
-				scopes.put(((Roles) role).getScope(), (Roles) role);
-			}
-		}
-		return scopes;
-	}
+    }
 
-	public List<String> getRolesOfUser(String userId) {
-		List<String> rolesList = new ArrayList<>();
-		List<Object> roles = commonClassDao.getDataById(Roles.class, "loginId", userId);
-		for (Object role: roles) {
-			rolesList.add(((Roles) role).getRole());
-		}
-		return rolesList;
-	}
+    public static  Map<Datatype, List<FunctionDefinition>>	getFunctionDatatypeMap() {
+        synchronized(mapAccess) {
+            if (mapDatatype2Function == null) {
+                buildFunctionMaps();
+            }
+        }
+        return mapDatatype2Function;
+    }
 
-	public List<Object> getRoles(String userId) {
-		return commonClassDao.getDataById(Roles.class, "loginId", userId);
-	}
+    public static Map<String, FunctionDefinition> getFunctionIDMap() {
+        synchronized(mapAccess) {
+            if (mapID2Function == null) {
+                buildFunctionMaps();
+            }
+        }
+        return mapID2Function;
+    }
 
-	//Get List of User Roles
-	@RequestMapping(value={"/get_UserRolesData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
-	public void getUserRolesEntityData(HttpServletRequest request, HttpServletResponse response){
-		try{
-			String userId = UserUtils.getUserSession(request).getOrgUserId();
-			Map<String, Object> model = new HashMap<>();
-			ObjectMapper mapper = new ObjectMapper();
-			model.put("userRolesDatas", mapper.writeValueAsString(getRolesOfUser(userId)));
-			JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
-			JSONObject j = new JSONObject(msg);
-			response.getWriter().write(j.toString());
-		}
-		catch (Exception e){
-			policyLogger.error("Exception Occured"+e);
-		}
-	}
+    private static  void buildFunctionMaps() {
+        mapDatatype2Function = new HashMap<>();
+        mapID2Function = new  HashMap<>();
+        List<Object> functiondefinitions = commonClassDao.getData(FunctionDefinition.class);
+        for (int i = 0; i < functiondefinitions.size(); i ++) {
+            FunctionDefinition value = (FunctionDefinition) functiondefinitions.get(i);
+            mapID2Function.put(value.getXacmlid(), value);
+            if (!mapDatatype2Function.containsKey(value.getDatatypeBean())) {
+                mapDatatype2Function.put(value.getDatatypeBean(), new ArrayList<FunctionDefinition>());
+            }
+            mapDatatype2Function.get(value.getDatatypeBean()).add(value);
+        }
+    }
 
-	//Policy tabs Model and View
+    @RequestMapping(value={"/get_FunctionDefinitionDataByName"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
+    public void getFunctionDefinitionData(HttpServletRequest request, HttpServletResponse response){
+        try{
+            Map<String, Object> model = new HashMap<>();
+            ObjectMapper mapper = new ObjectMapper();
+            model.put("functionDefinitionDatas", mapper.writeValueAsString(commonClassDao.getDataByColumn(FunctionDefinition.class, "shortname")));
+            JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
+            JSONObject j = new JSONObject(msg);
+            response.getWriter().write(j.toString());
+        }
+        catch (Exception e){
+            policyLogger.error(XACMLErrorConstants.ERROR_DATA_ISSUE +"Error while retriving the Function Definition data"+e);
+        }
+    }
+
+    public PolicyEntity getPolicyEntityData(String scope, String policyName){
+        String key = scope + ":" + policyName;
+        List<Object> data = commonClassDao.getDataById(PolicyEntity.class, "scope:policyName", key);
+        return (PolicyEntity) data.get(0);
+    }
+
+    public static Map<String, Roles> getUserRoles(String userId) {
+        Map<String, Roles> scopes = new HashMap<>();
+        List<Object> roles = commonClassDao.getDataById(Roles.class, "loginId", userId);
+        if (roles != null && !roles.isEmpty()) {
+            for (Object role : roles) {
+                scopes.put(((Roles) role).getScope(), (Roles) role);
+            }
+        }
+        return scopes;
+    }
+
+    public List<String> getRolesOfUser(String userId) {
+        List<String> rolesList = new ArrayList<>();
+        List<Object> roles = commonClassDao.getDataById(Roles.class, "loginId", userId);
+        for (Object role: roles) {
+            rolesList.add(((Roles) role).getRole());
+        }
+        return rolesList;
+    }
+
+    public List<Object> getRoles(String userId) {
+        return commonClassDao.getDataById(Roles.class, "loginId", userId);
+    }
+
+    //Get List of User Roles
+    @RequestMapping(value={"/get_UserRolesData"}, method={org.springframework.web.bind.annotation.RequestMethod.GET} , produces=MediaType.APPLICATION_JSON_VALUE)
+    public void getUserRolesEntityData(HttpServletRequest request, HttpServletResponse response){
+        try{
+            String userId = UserUtils.getUserSession(request).getOrgUserId();
+            Map<String, Object> model = new HashMap<>();
+            ObjectMapper mapper = new ObjectMapper();
+            model.put("userRolesDatas", mapper.writeValueAsString(getRolesOfUser(userId)));
+            JsonMessage msg = new JsonMessage(mapper.writeValueAsString(model));
+            JSONObject j = new JSONObject(msg);
+            response.getWriter().write(j.toString());
+        }
+        catch (Exception e){
+            policyLogger.error("Exception Occured"+e);
+        }
+    }
+
+    //Policy tabs Model and View
     @RequestMapping(value= {"/policy", "/policy/Editor" } , method = RequestMethod.GET)
-	public ModelAndView view(HttpServletRequest request){
-		String myRequestURL = request.getRequestURL().toString();
-		try {
-			//
-			// Set the URL for the RESTful PAP Engine
-			//
-			setPapEngine((PAPPolicyEngine) new RESTfulPAPEngine(myRequestURL));
-			new PDPGroupContainer((PAPPolicyEngine) new RESTfulPAPEngine(myRequestURL));
-		} catch (Exception e) {
-			policyLogger.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR+"Exception Occured while loading PAP"+e);
-		}
-		Map<String, Object> model = new HashMap<>();
-		return new ModelAndView("policy_Editor","model", model);
-	}
+    public ModelAndView view(HttpServletRequest request){
+        String myRequestURL = request.getRequestURL().toString();
+        try {
+            //
+            // Set the URL for the RESTful PAP Engine
+            //
+            setPapEngine((PAPPolicyEngine) new RESTfulPAPEngine(myRequestURL));
+            new PDPGroupContainer((PAPPolicyEngine) new RESTfulPAPEngine(myRequestURL));
+        } catch (Exception e) {
+            policyLogger.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR+"Exception Occured while loading PAP"+e);
+        }
+        Map<String, Object> model = new HashMap<>();
+        return new ModelAndView("policy_Editor","model", model);
+    }
 
-	public PAPPolicyEngine getPapEngine() {
-		return papEngine;
-	}
+    public PAPPolicyEngine getPapEngine() {
+        return papEngine;
+    }
 
-	public static void setPapEngine(PAPPolicyEngine papEngine) {
-		PolicyController.papEngine = papEngine;
-	}
+    public static void setPapEngine(PAPPolicyEngine papEngine) {
+        PolicyController.papEngine = papEngine;
+    }
 
-	public String getUserName(String createdBy) {
-		String loginId = createdBy;
-		List<Object> data = commonClassDao.getDataById(UserInfo.class, "loginId", loginId);
-		return data.get(0).toString();
-	}
+    public String getUserName(String createdBy) {
+        String loginId = createdBy;
+        List<Object> data = commonClassDao.getDataById(UserInfo.class, "loginId", loginId);
+        return data.get(0).toString();
+    }
 
-	public static boolean getActivePolicy(String query) {
-		if(!commonClassDao.getDataByQuery(query, new SimpleBindings()).isEmpty()){
-			return true;
-		}else{
-			return false;
-		}
-	}
+    public static boolean getActivePolicy(String query) {
+        if(!commonClassDao.getDataByQuery(query, new SimpleBindings()).isEmpty()){
+            return true;
+        }else{
+            return false;
+        }
+    }
 
-	public void executeQuery(String query) {
-		commonClassDao.updateQuery(query);
-	}
+    public void executeQuery(String query) {
+        commonClassDao.updateQuery(query);
+    }
 
-	public void saveData(Object cloneEntity) {
-		commonClassDao.save(cloneEntity);
-	}
+    public void saveData(Object cloneEntity) {
+        commonClassDao.save(cloneEntity);
+    }
 
-	public void updateData(Object entity) {
-		commonClassDao.update(entity);
-	}
+    public void updateData(Object entity) {
+        commonClassDao.update(entity);
+    }
 
-	public void deleteData(Object entity) {
-		commonClassDao.delete(entity);
-	}
+    public void deleteData(Object entity) {
+        commonClassDao.delete(entity);
+    }
 
-	public List<Object> getData(@SuppressWarnings("rawtypes") Class className){
-		return commonClassDao.getData(className);
-	}
+    public List<Object> getData(@SuppressWarnings("rawtypes") Class className){
+        return commonClassDao.getData(className);
+    }
 
-	public PolicyVersion getPolicyEntityFromPolicyVersion(String query){
-		return (PolicyVersion) commonClassDao.getEntityItem(PolicyVersion.class, "policyName", query);
-	}
+    public PolicyVersion getPolicyEntityFromPolicyVersion(String query){
+        return (PolicyVersion) commonClassDao.getEntityItem(PolicyVersion.class, "policyName", query);
+    }
 
-	public List<Object> getDataByQuery(String query, SimpleBindings params){
-		return commonClassDao.getDataByQuery(query, params);
-	}
+    public List<Object> getDataByQuery(String query, SimpleBindings params){
+        return commonClassDao.getDataByQuery(query, params);
+    }
 
 
-	@SuppressWarnings("rawtypes")
-	public Object getEntityItem(Class className, String columname, String key){
-		return commonClassDao.getEntityItem(className, columname, key);
-	}
+    @SuppressWarnings("rawtypes")
+    public Object getEntityItem(Class className, String columname, String key){
+        return commonClassDao.getEntityItem(className, columname, key);
+    }
 
 
-	public void watchPolicyFunction(PolicyVersion entity, String policyName, String mode){
-		PolicyNotificationMail email = new PolicyNotificationMail();
-		try {
-			email.sendMail(entity, policyName, mode, commonClassDao);
-		} catch (MessagingException e) {
-			policyLogger.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + "Excepton Occured while Renaming/Deleting a Policy or Scope" + e);
-		}
-	}
+    public void watchPolicyFunction(PolicyVersion entity, String policyName, String mode){
+        PolicyNotificationMail email = new PolicyNotificationMail();
+        try {
+            email.sendMail(entity, policyName, mode, commonClassDao);
+        } catch (MessagingException e) {
+            policyLogger.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + "Excepton Occured while Renaming/Deleting a Policy or Scope" + e);
+        }
+    }
 
-	//Switch Version
-	public JSONObject switchVersionPolicyContent(String policyName) {
-		String dbCheckName = policyName.replace("/", ".");
-		if(dbCheckName.contains("Config_")){
-			dbCheckName = dbCheckName.replace(".Config_", ":Config_");
-		}else if(dbCheckName.contains("Action_")){
-			dbCheckName = dbCheckName.replace(".Action_", ":Action_");
-		}else if(dbCheckName.contains("Decision_")){
-			dbCheckName = dbCheckName.replace(".Decision_", ":Decision_");
-		}
-		String[] splitDBCheckName = dbCheckName.split(":");
-		String query =   "FROM PolicyEntity where policyName like :splitDBCheckName1 and scope = :splitDBCheckName0";
-		SimpleBindings params = new SimpleBindings();
-		params.put("splitDBCheckName1", splitDBCheckName[1] + "%");
-		params.put("splitDBCheckName0", splitDBCheckName[0]);
-		List<Object> policyEntity = commonClassDao.getDataByQuery(query, params);
-		List<String> av = new ArrayList<>();
-		for(Object entity : policyEntity){
-			PolicyEntity pEntity = (PolicyEntity) entity;
-			String removeExtension = pEntity.getPolicyName().replace(".xml", "");
-			String version = removeExtension.substring(removeExtension.lastIndexOf('.')+1);
-			av.add(version);
-		}
-		if(policyName.contains("/")){
-			policyName = policyName.replace("/", File.separator);
-		}
-		PolicyVersion entity = (PolicyVersion) commonClassDao.getEntityItem(PolicyVersion.class, "policyName", policyName);
-		JSONObject el = new JSONObject();
-		el.put("activeVersion", entity.getActiveVersion());
-		el.put("availableVersions", av);
-		el.put("highestVersion", entity.getHigherVersion());
-		return el;
-	}
+    //Switch Version
+    public JSONObject switchVersionPolicyContent(String policyName) {
+        String dbCheckName = policyName.replace("/", ".");
+        if(dbCheckName.contains("Config_")){
+            dbCheckName = dbCheckName.replace(".Config_", ":Config_");
+        }else if(dbCheckName.contains("Action_")){
+            dbCheckName = dbCheckName.replace(".Action_", ":Action_");
+        }else if(dbCheckName.contains("Decision_")){
+            dbCheckName = dbCheckName.replace(".Decision_", ":Decision_");
+        }
+        String[] splitDBCheckName = dbCheckName.split(":");
+        String query =   "FROM PolicyEntity where policyName like :splitDBCheckName1 and scope = :splitDBCheckName0";
+        SimpleBindings params = new SimpleBindings();
+        params.put("splitDBCheckName1", splitDBCheckName[1] + "%");
+        params.put("splitDBCheckName0", splitDBCheckName[0]);
+        List<Object> policyEntity = commonClassDao.getDataByQuery(query, params);
+        List<String> av = new ArrayList<>();
+        for(Object entity : policyEntity){
+            PolicyEntity pEntity = (PolicyEntity) entity;
+            String removeExtension = pEntity.getPolicyName().replace(".xml", "");
+            String version = removeExtension.substring(removeExtension.lastIndexOf('.')+1);
+            av.add(version);
+        }
+        if(policyName.contains("/")){
+            policyName = policyName.replace("/", File.separator);
+        }
+        PolicyVersion entity = (PolicyVersion) commonClassDao.getEntityItem(PolicyVersion.class, "policyName", policyName);
+        JSONObject el = new JSONObject();
+        el.put("activeVersion", entity.getActiveVersion());
+        el.put("availableVersions", av);
+        el.put("highestVersion", entity.getHigherVersion());
+        return el;
+    }
 
-	public static String getLogTableLimit() {
-		return logTableLimit;
-	}
+    public static String getLogTableLimit() {
+        return logTableLimit;
+    }
 
-	public static void setLogTableLimit(String logTableLimit) {
-		PolicyController.logTableLimit = logTableLimit;
-	}
+    public static void setLogTableLimit(String logTableLimit) {
+        PolicyController.logTableLimit = logTableLimit;
+    }
 
-	public static String getSystemAlertTableLimit() {
-		return systemAlertTableLimit;
-	}
+    public static String getSystemAlertTableLimit() {
+        return systemAlertTableLimit;
+    }
 
-	public static void setSystemAlertTableLimit(String systemAlertTableLimit) {
-		PolicyController.systemAlertTableLimit = systemAlertTableLimit;
-	}
+    public static void setSystemAlertTableLimit(String systemAlertTableLimit) {
+        PolicyController.systemAlertTableLimit = systemAlertTableLimit;
+    }
 
-	public static CommonClassDao getCommonClassDao() {
-		return commonClassDao;
-	}
+    public static CommonClassDao getCommonClassDao() {
+        return commonClassDao;
+    }
 
-	public static void setCommonClassDao(CommonClassDao commonClassDao) {
-		PolicyController.commonClassDao = commonClassDao;
-	}
+    public static void setCommonClassDao(CommonClassDao commonClassDao) {
+        PolicyController.commonClassDao = commonClassDao;
+    }
 
-	public static Map<Datatype, List<FunctionDefinition>> getMapDatatype2Function() {
-		return mapDatatype2Function;
-	}
+    public static Map<Datatype, List<FunctionDefinition>> getMapDatatype2Function() {
+        return mapDatatype2Function;
+    }
 
-	public static void setMapDatatype2Function(Map<Datatype, List<FunctionDefinition>> mapDatatype2Function) {
-		PolicyController.mapDatatype2Function = mapDatatype2Function;
-	}
+    public static void setMapDatatype2Function(Map<Datatype, List<FunctionDefinition>> mapDatatype2Function) {
+        PolicyController.mapDatatype2Function = mapDatatype2Function;
+    }
 
-	public static Map<String, FunctionDefinition> getMapID2Function() {
-		return mapID2Function;
-	}
+    public static Map<String, FunctionDefinition> getMapID2Function() {
+        return mapID2Function;
+    }
 
-	public static void setMapID2Function(Map<String, FunctionDefinition> mapID2Function) {
-		PolicyController.mapID2Function = mapID2Function;
-	}
+    public static void setMapID2Function(Map<String, FunctionDefinition> mapID2Function) {
+        PolicyController.mapID2Function = mapID2Function;
+    }
 
-	public static String getSmtpHost() {
-		return smtpHost;
-	}
+    public static String getSmtpHost() {
+        return smtpHost;
+    }
 
-	public static void setSmtpHost(String smtpHost) {
-		PolicyController.smtpHost = smtpHost;
-	}
+    public static void setSmtpHost(String smtpHost) {
+        PolicyController.smtpHost = smtpHost;
+    }
 
-	public static String getSmtpPort() {
-		return smtpPort;
-	}
+    public static String getSmtpPort() {
+        return smtpPort;
+    }
 
-	public static void setSmtpPort(String smtpPort) {
-		PolicyController.smtpPort = smtpPort;
-	}
+    public static void setSmtpPort(String smtpPort) {
+        PolicyController.smtpPort = smtpPort;
+    }
 
-	public static String getSmtpUsername() {
-		return smtpUsername;
-	}
+    public static String getSmtpUsername() {
+        return smtpUsername;
+    }
 
-	public static void setSmtpUsername(String smtpUsername) {
-		PolicyController.smtpUsername = smtpUsername;
-	}
+    public static void setSmtpUsername(String smtpUsername) {
+        PolicyController.smtpUsername = smtpUsername;
+    }
 
-	public static String getSmtpPassword() {
-		return smtpPassword;
-	}
+    public static String getSmtpPassword() {
+        return smtpPassword;
+    }
 
-	public static void setSmtpPassword(String smtpPassword) {
-		PolicyController.smtpPassword = smtpPassword;
-	}
+    public static void setSmtpPassword(String smtpPassword) {
+        PolicyController.smtpPassword = smtpPassword;
+    }
+
+    public static String getSmtpApplicationName() {
+        return smtpApplicationName;
+    }
+
+    public static void setSmtpApplicationName(String smtpApplicationName) {
+        PolicyController.smtpApplicationName = smtpApplicationName;
+    }
 
-	public static String getSmtpApplicationName() {
-		return smtpApplicationName;
-	}
+    public static String getSmtpEmailExtension() {
+        return smtpEmailExtension;
+    }
 
-	public static void setSmtpApplicationName(String smtpApplicationName) {
-		PolicyController.smtpApplicationName = smtpApplicationName;
-	}
+    public static void setSmtpEmailExtension(String smtpEmailExtension) {
+        PolicyController.smtpEmailExtension = smtpEmailExtension;
+    }
 
-	public static String getSmtpEmailExtension() {
-		return smtpEmailExtension;
-	}
+    public static String getLogdbDriver() {
+        return logdbDriver;
+    }
 
-	public static void setSmtpEmailExtension(String smtpEmailExtension) {
-		PolicyController.smtpEmailExtension = smtpEmailExtension;
-	}
+    public static void setLogdbDriver(String logdbDriver) {
+        PolicyController.logdbDriver = logdbDriver;
+    }
 
-	public static String getLogdbDriver() {
-		return logdbDriver;
-	}
+    public static String getLogdbUrl() {
+        return logdbUrl;
+    }
 
-	public static void setLogdbDriver(String logdbDriver) {
-		PolicyController.logdbDriver = logdbDriver;
-	}
+    public static void setLogdbUrl(String logdbUrl) {
+        PolicyController.logdbUrl = logdbUrl;
+    }
 
-	public static String getLogdbUrl() {
-		return logdbUrl;
-	}
+    public static String getLogdbUserName() {
+        return logdbUserName;
+    }
 
-	public static void setLogdbUrl(String logdbUrl) {
-		PolicyController.logdbUrl = logdbUrl;
-	}
+    public static void setLogdbUserName(String logdbUserName) {
+        PolicyController.logdbUserName = logdbUserName;
+    }
 
-	public static String getLogdbUserName() {
-		return logdbUserName;
-	}
+    public static String getLogdbPassword() {
+        return logdbPassword;
+    }
 
-	public static void setLogdbUserName(String logdbUserName) {
-		PolicyController.logdbUserName = logdbUserName;
-	}
+    public static void setLogdbPassword(String logdbPassword) {
+        PolicyController.logdbPassword = logdbPassword;
+    }
 
-	public static String getLogdbPassword() {
-		return logdbPassword;
-	}
+    public static String getLogdbDialect() {
+        return logdbDialect;
+    }
 
-	public static void setLogdbPassword(String logdbPassword) {
-		PolicyController.logdbPassword = logdbPassword;
-	}
+    public static void setLogdbDialect(String logdbDialect) {
+        PolicyController.logdbDialect = logdbDialect;
+    }
 
-	public static String getLogdbDialect() {
-		return logdbDialect;
-	}
+    public static String getXacmldbUrl() {
+        return xacmldbUrl;
+    }
 
-	public static void setLogdbDialect(String logdbDialect) {
-		PolicyController.logdbDialect = logdbDialect;
-	}
+    public static void setXacmldbUrl(String xacmldbUrl) {
+        PolicyController.xacmldbUrl = xacmldbUrl;
+    }
 
-	public static String getXacmldbUrl() {
-		return xacmldbUrl;
-	}
+    public static String getXacmldbUserName() {
+        return xacmldbUserName;
+    }
 
-	public static void setXacmldbUrl(String xacmldbUrl) {
-		PolicyController.xacmldbUrl = xacmldbUrl;
-	}
+    public static void setXacmldbUserName(String xacmldbUserName) {
+        PolicyController.xacmldbUserName = xacmldbUserName;
+    }
 
-	public static String getXacmldbUserName() {
-		return xacmldbUserName;
-	}
+    public static String getXacmldbPassword() {
+        return xacmldbPassword;
+    }
 
-	public static void setXacmldbUserName(String xacmldbUserName) {
-		PolicyController.xacmldbUserName = xacmldbUserName;
-	}
+    public static void setXacmldbPassword(String xacmldbPassword) {
+        PolicyController.xacmldbPassword = xacmldbPassword;
+    }
 
-	public static String getXacmldbPassword() {
-		return xacmldbPassword;
-	}
+    public static String getAutoPushAvailable() {
+        return autoPushAvailable;
+    }
 
-	public static void setXacmldbPassword(String xacmldbPassword) {
-		PolicyController.xacmldbPassword = xacmldbPassword;
-	}
+    public static void setAutoPushAvailable(String autoPushAvailable) {
+        PolicyController.autoPushAvailable = autoPushAvailable;
+    }
 
-	public static String getAutoPushAvailable() {
-		return autoPushAvailable;
-	}
+    public static String getAutoPushDSClosedLoop() {
+        return autoPushDSClosedLoop;
+    }
 
-	public static void setAutoPushAvailable(String autoPushAvailable) {
-		PolicyController.autoPushAvailable = autoPushAvailable;
-	}
+    public static void setAutoPushDSClosedLoop(String autoPushDSClosedLoop) {
+        PolicyController.autoPushDSClosedLoop = autoPushDSClosedLoop;
+    }
 
-	public static String getAutoPushDSClosedLoop() {
-		return autoPushDSClosedLoop;
-	}
+    public static String getAutoPushDSFirewall() {
+        return autoPushDSFirewall;
+    }
 
-	public static void setAutoPushDSClosedLoop(String autoPushDSClosedLoop) {
-		PolicyController.autoPushDSClosedLoop = autoPushDSClosedLoop;
-	}
+    public static void setAutoPushDSFirewall(String autoPushDSFirewall) {
+        PolicyController.autoPushDSFirewall = autoPushDSFirewall;
+    }
 
-	public static String getAutoPushDSFirewall() {
-		return autoPushDSFirewall;
-	}
+    public static String getAutoPushDSMicroservice() {
+        return autoPushDSMicroservice;
+    }
 
-	public static void setAutoPushDSFirewall(String autoPushDSFirewall) {
-		PolicyController.autoPushDSFirewall = autoPushDSFirewall;
-	}
+    public static void setAutoPushDSMicroservice(String autoPushDSMicroservice) {
+        PolicyController.autoPushDSMicroservice = autoPushDSMicroservice;
+    }
 
-	public static String getAutoPushDSMicroservice() {
-		return autoPushDSMicroservice;
-	}
+    public static String getAutoPushPDPGroup() {
+        return autoPushPDPGroup;
+    }
 
-	public static void setAutoPushDSMicroservice(String autoPushDSMicroservice) {
-		PolicyController.autoPushDSMicroservice = autoPushDSMicroservice;
-	}
+    public static void setAutoPushPDPGroup(String autoPushPDPGroup) {
+        PolicyController.autoPushPDPGroup = autoPushPDPGroup;
+    }
 
-	public static String getAutoPushPDPGroup() {
-		return autoPushPDPGroup;
-	}
+    public static String getPapUrl() {
+        return papUrl;
+    }
 
-	public static void setAutoPushPDPGroup(String autoPushPDPGroup) {
-		PolicyController.autoPushPDPGroup = autoPushPDPGroup;
-	}
+    public static void setPapUrl(String papUrl) {
+        PolicyController.papUrl = papUrl;
+    }
 
-	public static String getPapUrl() {
-		return papUrl;
-	}
+    public static String getMsOnapName() {
+        return msOnapName;
+    }
 
-	public static void setPapUrl(String papUrl) {
-		PolicyController.papUrl = papUrl;
-	}
+    public static void setMsOnapName(String msOnapName) {
+        PolicyController.msOnapName = msOnapName;
+    }
 
-	public static String getMsOnapName() {
-		return msOnapName;
-	}
+    public static String getMsPolicyName() {
+        return msPolicyName;
+    }
 
-	public static void setMsOnapName(String msOnapName) {
-		PolicyController.msOnapName = msOnapName;
-	}
+    public static void setMsPolicyName(String msPolicyName) {
+        PolicyController.msPolicyName = msPolicyName;
+    }
 
-	public static String getMsPolicyName() {
-		return msPolicyName;
-	}
+    public static String getConfigHome() {
+        return configHome;
+    }
 
-	public static void setMsPolicyName(String msPolicyName) {
-		PolicyController.msPolicyName = msPolicyName;
-	}
+    public static void setConfigHome(String configHome) {
+        PolicyController.configHome = configHome;
+    }
 
-	public static String getConfigHome() {
-		return configHome;
-	}
+    public static String getActionHome() {
+        return actionHome;
+    }
 
-	public static void setConfigHome(String configHome) {
-		PolicyController.configHome = configHome;
-	}
+    public static void setActionHome(String actionHome) {
+        PolicyController.actionHome = actionHome;
+    }
 
-	public static String getActionHome() {
-		return actionHome;
-	}
+    public static Object getMapaccess() {
+        return mapAccess;
+    }
 
-	public static void setActionHome(String actionHome) {
-		PolicyController.actionHome = actionHome;
-	}
+    public static String getPolicydata() {
+        return policyData;
+    }
 
-	public static Object getMapaccess() {
-		return mapAccess;
-	}
+    public static String getCharacterencoding() {
+        return characterEncoding;
+    }
 
-	public static String getPolicydata() {
-		return policyData;
-	}
+    public static String getContenttype() {
+        return contentType;
+    }
 
-	public static String getCharacterencoding() {
-		return characterEncoding;
-	}
+    public static String getFile() {
+        return file;
+    }
 
-	public static String getContenttype() {
-		return contentType;
-	}
+    public static void setFileSizeLimit(String uploadSize) {
+        //Default size limit is 30MB
+        if (uploadSize == null || uploadSize.isEmpty()) {
+            fileSizeLimit = 30000000;
+        }
+        else {
+            fileSizeLimit = Long.parseLong(uploadSize);
+        }
+    }
 
-	public static String getFile() {
-		return file;
-	}
-	
-	public static void setFileSizeLimit(String uploadSize) {
-		//Default size limit is 30MB
-		if (uploadSize == null || uploadSize.isEmpty()) {
-			fileSizeLimit = 30000000;
-		}
-		else {
-			fileSizeLimit = Long.parseLong(uploadSize);
-		}
-	}
-	
-	public static long getFileSizeLimit() {
-		return fileSizeLimit;
-	}
-	public String convertDate(String dateTTL) {
-		String formateDate = null;
-		if(dateTTL.contains("-")){
-			formateDate = dateTTL.replace("-", "/");
-		}
-		return formateDate;
-	}
+    public static long getFileSizeLimit() {
+        return fileSizeLimit;
+    }
+    public String convertDate(String dateTTL) {
+        String formateDate = null;
+        if(dateTTL.contains("-")){
+            formateDate = dateTTL.replace("-", "/");
+        }
+        return formateDate;
+    }
 }
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/DecisionPolicyController.js b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/DecisionPolicyController.js
index 5b2bdb2..f560f4d 100644
--- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/DecisionPolicyController.js
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplateController/DecisionPolicyController.js
@@ -2,7 +2,7 @@
  * ============LICENSE_START=======================================================
  * ONAP Policy Engine
  * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -17,14 +17,16 @@
  * limitations under the License.
  * ============LICENSE_END=========================================================
  */
-angular.module('abs').controller('decisionPolicyController', ['$scope', 'PolicyAppService', 'policyNavigator', 'modalService', '$modal', 'Notification', function ($scope, PolicyAppService, PolicyNavigator, modalService, $modal, Notification) {
+angular.module('abs').controller('decisionPolicyController', ['$scope', 'PolicyAppService', 'policyNavigator', 'modalService', '$modal', 'Notification', '$http', function ($scope, PolicyAppService, PolicyNavigator, modalService, $modal, Notification, $http) {
     $("#dialog").hide();
     
     $scope.policyNavigator;
     $scope.savebutton = true;
     $scope.refreshCheck = false;
+    $scope.disableOnCreate = false;
     
     if(!$scope.temp.policy.editPolicy  && !$scope.temp.policy.readOnly){
+    	$scope.disableOnCreate = true;
     	$scope.temp.policy = {
     			policyType : "Decision"
     	}
@@ -45,7 +47,11 @@
 	if($scope.temp.policy.ruleProvider==undefined){
 		$scope.temp.policy.ruleProvider="Custom";
 	}
-		
+	
+	if($scope.temp.policy.blackListEntryType==undefined){
+		$scope.temp.policy.blackListEntryType="Use Manual Entry";
+	}
+	
 	PolicyAppService.getData('getDictionary/get_OnapNameDataByName').then(function (data) {
 		var j = data;
 		$scope.data = JSON.parse(j.data);
@@ -216,9 +222,15 @@
 		   $scope.temp.policy.ruleAlgorithmschoices = [];
 	   }
     }else if($scope.temp.policy.ruleProvider=="GUARD_BL_YAML"){
-	   if($scope.temp.policy.yamlparams.blackList.length==0){
-		   $scope.temp.policy.yamlparams.blackList = [];
-	   }
+    	if($scope.temp.policy.yamlparams.blackList == null || $scope.temp.policy.yamlparams.blackList.length==0){
+    		$scope.temp.policy.yamlparams.blackList = [];
+    	}
+    	if($scope.temp.policy.blackListEntries == null || $scope.temp.policy.blackListEntries.length==0){
+    		$scope.temp.policy.blackListEntries = [];
+    	}
+    	$scope.blackListEntries = [];
+    	$scope.temp.policy.appendBlackListEntries = [];
+    	$scope.blackListEntries = arrayUnique($scope.temp.policy.blackListEntries.concat($scope.temp.policy.yamlparams.blackList));
     }else if($scope.temp.policy.ruleProvider=="GUARD_YAML"){
     	if($scope.temp.policy.yamlparams.targets.length==0){
  		   $scope.temp.policy.yamlparams.targets = [];
@@ -259,9 +271,11 @@
     $scope.addNewBL = function() {
     	$scope.temp.policy.yamlparams.blackList.push('');
     };
-    $scope.removeBL = function() {
-    	var lastItem = $scope.temp.policy.yamlparams.blackList.length-1;
-    	$scope.temp.policy.yamlparams.blackList.splice(lastItem);
+    
+    $scope.removeBL = function(id) {
+    	$scope.temp.policy.yamlparams.blackList = $scope.temp.policy.yamlparams.blackList.filter(function (obj){
+			return obj !== id;
+		});
     };
     
     $scope.treatmentDatas = [{"treatmentValues" : $scope.temp.policy.rainyday.treatmentTableChoices}];
@@ -324,4 +338,93 @@
     		$scope.temp.policy.attributes = [];
     	}
     };
+    
+    $scope.importButton = true;
+    var fd;
+	$scope.uploadBLFile = function(files) {
+		fd = new FormData();
+		fd.append("file", files[0]);
+		var fileExtension = files[0].name.split(".")[1];
+		if(fileExtension == "xls"){
+			$scope.importButton = false;
+			$scope.$apply();
+		}else{
+			Notification.error("Upload the BlackList file which extends with .xls format.");
+		}
+	};
+	
+	function arrayUnique(array) {
+	    var a = array.concat();
+	    for(var i=0; i<a.length; ++i) {
+	        for(var j=i+1; j<a.length; ++j) {
+	            if(a[i] === a[j])
+	                a.splice(j--, 1);
+	        }
+	    }
+	    return a;
+	}
+	
+	$scope.submitUpload = function(){
+		$http.post("policycreation/importBlackListForDecisionPolicy", fd,  {
+			withCredentials: false,
+			headers: {'Content-Type': undefined},
+			transformRequest: angular.identity
+		}).success(function(data){
+			$scope.data = JSON.parse(data.data);
+			$scope.temp.policy.blackListEntries = $scope.data.blackListEntries;
+			if($scope.temp.policy.blackListEntries[0] !== "error"){
+				$scope.blackListEntries = arrayUnique($scope.temp.policy.blackListEntries.concat($scope.temp.policy.yamlparams.blackList));
+				$scope.temp.policy.appendBlackListEntries = $scope.data.appendBlackListEntries;
+				$scope.blackListEntries = $scope.blackListEntries.filter(function (obj){
+					return !$scope.temp.policy.appendBlackListEntries.includes(obj);
+				});
+				if($scope.blackListEntries.length == 0){
+					$scope.validateButton = true;
+					Notification.error("Black Lists are empty. Minimum one entry required.");
+				}else{
+					$scope.temp.policy.blackListEntries = $scope.blackListEntries;
+					Notification.success("Blacklist File Uploaded Successfully.");
+					$scope.validateButton = false;
+					$scope.importButton = true;
+				}
+			}else{
+				 Notification.error("Blacklist File Upload Failed." + $scope.temp.policy.blackListEntries[1]);
+			}
+		}).error(function(data){
+			 Notification.error("Blacklist File Upload Failed.");
+		});
+	};
+	
+	$scope.initializeBlackList = function(){
+		if($scope.temp.policy.blackListEntryType === "Use File Upload"){
+			 $scope.validateButton = true;	
+		} else {
+			 $scope.validateButton = false;	
+		}
+		$("#importFile").val('');
+	};
+	
+	$scope.exportBlackListEntries = function(){
+		var uuu = "policycreation/exportDecisionBlackListEntries";
+		var postData={policyData: $scope.temp.policy, date : $scope.temp.model.modifiedDate, version : $scope.temp.model.version};
+		$.ajax({
+			type : 'POST',
+			url : uuu,
+			dataType: 'json',
+			contentType: 'application/json',
+			data: JSON.stringify(postData),
+			success : function(data){
+				$scope.$apply(function(){
+					$scope.data=data.data;
+					var url = '../' + $scope.data;
+					window.location = url;
+					Notification.success("BlackList Entries Exported Successfully.");
+				});
+				console.log($scope.data);
+			},
+			error : function(data){      	
+				Notification.error("Error Occured while Exporting BlackList Entries.");
+			}
+		});
+	};	
 }]);
\ No newline at end of file
diff --git a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplates/DecisionPolicyTemplate.html b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplates/DecisionPolicyTemplate.html
index 27b6287..151af15 100644
--- a/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplates/DecisionPolicyTemplate.html
+++ b/POLICY-SDK-APP/src/main/webapp/app/policyApp/policy-models/Editor/PolicyTemplates/DecisionPolicyTemplate.html
@@ -31,8 +31,8 @@
 				<div class="form-group col-sm-6">
 					<label>Description:</label> <input type="text" class="form-control"
 						ng-disabled="temp.policy.readOnly"
-						ng-model="temp.policy.policyDescription" 
-						title="Description field will accept any type of data."/>
+						ng-model="temp.policy.policyDescription"
+						title="Description field will accept any type of data." />
 				</div>
 			</div>
 			<div class="form-group row">
@@ -41,7 +41,8 @@
 						class="form-control" ng-disabled="temp.policy.readOnly"
 						ng-model="temp.policy.onapName"
 						ng-options="option for option in onapNameDictionaryDatas track by option"
-						required pattern="\S+" title="Select the dropdown value driven from OnapName (common)Dictionary."></select>
+						required pattern="\S+"
+						title="Select the dropdown value driven from OnapName (common)Dictionary."></select>
 				</div>
 				<div class="form-group col-sm-6">
 					<label>Rule Provider:<sup><b>*</b></sup></label><select
@@ -53,7 +54,7 @@
 						<option>AAF</option>
 						<option>Rainy_Day</option>
 						<option>GUARD_YAML</option>
-						<option>GUARD_BL_YAML<option>
+						<option>GUARD_BL_YAML</option>
 					</select>
 				</div>
 			</div>
@@ -67,39 +68,40 @@
 						</div>
 						<div class="form-group col-sm-2">
 							<input type="text" class="form-control"
-								ng-disabled="temp.policy.readOnly" ng-model="temp.policy.rainyday.serviceType"
-								placeholder="Service Type" title="Enter Service Type value."/>
+								ng-disabled="temp.policy.readOnly"
+								ng-model="temp.policy.rainyday.serviceType"
+								placeholder="Service Type" title="Enter Service Type value." />
 						</div>
 						<div class="form-group col-sm-1">
 							<label>VNF Type:<sup><b>*</b></sup></label>
 						</div>
 						<div class="form-group col-sm-2">
 							<input type="text" class="form-control"
-								ng-disabled="temp.policy.readOnly" ng-model="temp.policy.rainyday.vnfType"
-								placeholder="VNF Type" title="Enter VNF Type value."/>
+								ng-disabled="temp.policy.readOnly"
+								ng-model="temp.policy.rainyday.vnfType" placeholder="VNF Type"
+								title="Enter VNF Type value." />
 						</div>
 						<div class="form-group col-sm-1">
 							<label>Building Block ID:<sup><b>*</b></sup></label>
 						</div>
 						<div class="form-group col-sm-2">
-								<select
-									class="form-control" ng-disabled="temp.policy.readOnly"
-									ng-model="temp.policy.rainyday.bbid"
-									ng-options="option for option in rainyDayDictionaryDatas track by option"
-									ng-change="getWorkstepValues(temp.policy.rainyday.bbid)" title="Select the dropdown value driven from Rainday Allowed Treatments (Decision)Dictionary.">
-									<option value="">{{temp.policy.rainyday.bbid}}</option>
-								</select>
+							<select class="form-control" ng-disabled="temp.policy.readOnly"
+								ng-model="temp.policy.rainyday.bbid"
+								ng-options="option for option in rainyDayDictionaryDatas track by option"
+								ng-change="getWorkstepValues(temp.policy.rainyday.bbid)"
+								title="Select the dropdown value driven from Rainday Allowed Treatments (Decision)Dictionary.">
+								<option value="">{{temp.policy.rainyday.bbid}}</option>
+							</select>
 						</div>
 						<div class="form-group col-sm-1">
 							<label>Work Step:<sup><b>*</b></sup></label>
 						</div>
 						<div class="form-group col-sm-2">
-							<select
-									class="form-control" ng-disabled="temp.policy.readOnly"
-									ng-model="temp.policy.rainyday.workstep"
-									ng-options="option for option in workstepDictionaryDatas track by option"
-									ng-change="getTreatmentValues(temp.policy.rainyday.bbid, temp.policy.rainyday.workstep)">
-									<option value="">{{temp.policy.rainyday.workstep}}</option>
+							<select class="form-control" ng-disabled="temp.policy.readOnly"
+								ng-model="temp.policy.rainyday.workstep"
+								ng-options="option for option in workstepDictionaryDatas track by option"
+								ng-change="getTreatmentValues(temp.policy.rainyday.bbid, temp.policy.rainyday.workstep)">
+								<option value="">{{temp.policy.rainyday.workstep}}</option>
 							</select>
 						</div>
 					</div>
@@ -107,46 +109,44 @@
 						<div class="form-group col-sm-3">
 							<label>Desired Automated Treatments:</label>
 							<button type="button" class="btn btn-default"
-								ng-disabled="temp.policy.readOnly"
-								ng-click="addNewTreatment()">
+								ng-disabled="temp.policy.readOnly" ng-click="addNewTreatment()">
 								<i class="fa fa-plus"></i>
 							</button>
 						</div>
 					</div>
 					<div class="form-group row">
-					<div data-ng-repeat="treatmentTableChoice in temp.policy.rainyday.treatmentTableChoices">
-						<div class="form-group row" style="margin-left: 2%">
-							<div class="form-group col-sm-1">
-								<label>Error Code:<sup><b>*</b></sup></label>
-							</div>
-							<div class="form-group col-sm-3">
-								<input type="text" class="form-control"
-									ng-disabled="temp.policy.readOnly"
-									ng-model="treatmentTableChoice.errorcode"
-									placeholder="Error Code" />
-							</div>
-							<div class="form-group col-sm-1">
-								<label>Desired Treatment:<sup><b>*</b></sup></label>
-							</div>		
-							<div class="form-group col-sm-3">
-								<select
-									class="form-control" 
-									ng-disabled="temp.policy.readOnly"
-									ng-model="treatmentTableChoice.treatment"
-									ng-options="option for option in allowedTreatmentsDatas track by option">
-									<option value="">{{treatmentTableChoice.treatment}}</option>
-								</select>						
-							</div>
-							<div class="form-group col-sm-1">
-								<button type="button" class="btn btn-default"
-									ng-disabled="temp.policy.readOnly"
-									ng-click="removeTreatment()">
-									<i class="fa fa-minus"></i>
-								</button>
+						<div
+							data-ng-repeat="treatmentTableChoice in temp.policy.rainyday.treatmentTableChoices">
+							<div class="form-group row" style="margin-left: 2%">
+								<div class="form-group col-sm-1">
+									<label>Error Code:<sup><b>*</b></sup></label>
+								</div>
+								<div class="form-group col-sm-3">
+									<input type="text" class="form-control"
+										ng-disabled="temp.policy.readOnly"
+										ng-model="treatmentTableChoice.errorcode"
+										placeholder="Error Code" />
+								</div>
+								<div class="form-group col-sm-1">
+									<label>Desired Treatment:<sup><b>*</b></sup></label>
+								</div>
+								<div class="form-group col-sm-3">
+									<select class="form-control" ng-disabled="temp.policy.readOnly"
+										ng-model="treatmentTableChoice.treatment"
+										ng-options="option for option in allowedTreatmentsDatas track by option">
+										<option value="">{{treatmentTableChoice.treatment}}</option>
+									</select>
+								</div>
+								<div class="form-group col-sm-1">
+									<button type="button" class="btn btn-default"
+										ng-disabled="temp.policy.readOnly"
+										ng-click="removeTreatment()">
+										<i class="fa fa-minus"></i>
+									</button>
+								</div>
 							</div>
 						</div>
 					</div>
-					</div>
 				</div>
 			</div>
 		</div>
@@ -158,86 +158,145 @@
 					</div>
 				</div>
 				<div class="form-group row">
-						<div class="form-group row" style="margin-left: 2%">
-							<div class="form-group col-sm-3">
-								<label> actor: </label>
-							</div>
-							<div class="form-group col-sm-3">
-								<input type="text" class="form-control"
-									ng-disabled="temp.policy.readOnly" ng-model="temp.policy.yamlparams.actor"
-									placeholder="Actor" />
-							</div>
+					<div class="form-group row" style="margin-left: 2%">
+						<div class="form-group col-sm-3">
+							<label> actor: </label>
 						</div>
-						<div class="form-group row" style="margin-left: 2%">
-							<div class="form-group col-sm-3">
-								<label> recipe: </label>
-							</div>
-							<div class="form-group col-sm-3">
-								<input type="text" class="form-control"
-									ng-disabled="temp.policy.readOnly" ng-model="temp.policy.yamlparams.recipe"
-									placeholder="Recipe" />
-							</div>
+						<div class="form-group col-sm-3">
+							<input type="text" class="form-control"
+								ng-disabled="temp.policy.readOnly"
+								ng-model="temp.policy.yamlparams.actor" placeholder="Actor" />
 						</div>
-						<div class="form-group row" style="margin-left: 2%">
-							<div class="form-group col-sm-3">
-								<label> CLName: </label>
-							</div>
-							<div class="form-group col-sm-3">
-								<input type="text" class="form-control"
-									ng-disabled="temp.policy.readOnly" ng-model="temp.policy.yamlparams.clname"
-									placeholder="CLName" />
-							</div>
+					</div>
+					<div class="form-group row" style="margin-left: 2%">
+						<div class="form-group col-sm-3">
+							<label> recipe: </label>
 						</div>
-						<div class="form-group row" style="margin-left: 2%">
-							<div class="form-group col-sm-3">
-								<label> guardActiveStart: </label>
-							</div>
-							<div class="form-group col-sm-3">
-								<input type="text" class="form-control"
-									ng-disabled="temp.policy.readOnly" ng-model="temp.policy.yamlparams.guardActiveStart"
-									placeholder="00:00:00-05:00" />
-							</div>
+						<div class="form-group col-sm-3">
+							<input type="text" class="form-control"
+								ng-disabled="temp.policy.readOnly"
+								ng-model="temp.policy.yamlparams.recipe" placeholder="Recipe" />
 						</div>
-						<div class="form-group row" style="margin-left: 2%">
-							<div class="form-group col-sm-3">
-								<label> guardActiveEnd: </label>
-							</div>
-							<div class="form-group col-sm-3">
-								<input type="text" class="form-control"
-									ng-disabled="temp.policy.readOnly" ng-model="temp.policy.yamlparams.guardActiveEnd"
-									placeholder="00:00:00-05:00" />
-							</div>
+					</div>
+					<div class="form-group row" style="margin-left: 2%">
+						<div class="form-group col-sm-3">
+							<label> CLName: </label>
 						</div>
-						<div class="form-group row" style="margin-left: 2%">
-							<div class="form-group col-sm-3">
-								<label> BlackList: </label>
-								<button type="button" class="btn btn-default"
-									ng-disabled="temp.policy.readOnly" ng-click="addNewBL()">
-									<i class="fa fa-plus"></i>
-								</button>
-							</div>
-							<div class="form-group col-sm-4">
-								<div data-ng-repeat="choice in temp.policy.yamlparams.blackList track by $index">
-									<div class="form-group row">
+						<div class="form-group col-sm-3">
+							<input type="text" class="form-control"
+								ng-disabled="temp.policy.readOnly"
+								ng-model="temp.policy.yamlparams.clname" placeholder="CLName" />
+						</div>
+					</div>
+					<div class="form-group row" style="margin-left: 2%">
+						<div class="form-group col-sm-3">
+							<label> guardActiveStart: </label>
+						</div>
+						<div class="form-group col-sm-3">
+							<input type="text" class="form-control"
+								ng-disabled="temp.policy.readOnly"
+								ng-model="temp.policy.yamlparams.guardActiveStart"
+								placeholder="00:00:00-05:00" />
+						</div>
+					</div>
+					<div class="form-group row" style="margin-left: 2%">
+						<div class="form-group col-sm-3">
+							<label> guardActiveEnd: </label>
+						</div>
+						<div class="form-group col-sm-3">
+							<input type="text" class="form-control"
+								ng-disabled="temp.policy.readOnly"
+								ng-model="temp.policy.yamlparams.guardActiveEnd"
+								placeholder="00:00:00-05:00" />
+						</div>
+					</div>
+					<div class="form-group row" style="margin-left: 2%">
+						<div class="form-group col-sm-3">
+							<label> BlackList Entry Type: </label>
+						</div>
+						<div class="form-group col-sm-3">
+							<select class="form-control"
+								ng-model="temp.policy.blackListEntryType"
+								ng-disabled="temp.policy.readOnly"
+								ng-change="initializeBlackList(temp.policy.blackListEntryType)">
+								<option>Use Manual Entry</option>
+								<option>Use File Upload</option>
+							</select>
+						</div>
+					</div>
+					<div class="form-group row" style="margin-left: 2%">
+						<div class="form-group col-sm-3">
+							<label>Export BlackList Entries:</label>
+						</div>
+						<div class="form-group col-sm-3">
+							<button type="button" class="btn btn-default"
+								ng-disabled="disableOnCreate"
+								ng-click="exportBlackListEntries()">Export BlackList</button>
+						</div>
+					</div>
+					<div ng-if="temp.policy.blackListEntryType == 'Use File Upload'"
+						class="form-group row" style="margin-left: 2%">
+						<div class="form-group col-sm-3">
+							<label>Upload BlackList: </label>
+						</div>
+						<div class="form-group col-sm-4">
+							<input type="file" name="file" class="form-control"
+								id="importFile"
+								onchange="angular.element(this).scope().uploadBLFile(this.files)" />
+						</div>
+						<div class="form-group col-sm-2">
+							<button class="btn btn-primary" ng-disabled="importButton"
+								ng-click="submitUpload()">Upload</button>
+						</div>
+					</div>
+					<div ng-if="temp.policy.blackListEntryType == 'Use File Upload'"
+						class="form-group row" style="margin-left: 2%">
+						<div class="form-group col-sm-3">
+							<label>Search BlackList: </label>
+						</div>
+						<div class="form-group col-sm-4">
+							<input type="text" class="form-control" class="search"
+								placeholder="{{'search'}}..." ng-model="search"> <select
+								class="form-control" multiple ng-disabled="true"
+								style="height: 400px;"
+								ng-model="temp.policy.blackListSearchEntry"
+								ng-options="option for option in blackListEntries | filter:search"></select>
+						</div>
+					</div>
+					<div ng-if="temp.policy.blackListEntryType == 'Use Manual Entry'"
+						class="form-group row" style="margin-left: 2%">
+						<div class="form-group col-sm-3">
+							<label> BlackList: </label>
+							<button type="button" class="btn btn-default"
+								ng-disabled="temp.policy.readOnly" ng-click="addNewBL()">
+								<i class="fa fa-plus"></i>
+							</button>
+						</div>
+						<div class="form-group col-sm-4">
+							<div
+								data-ng-repeat="choice in temp.policy.yamlparams.blackList track by $index">
+								<div class="form-group row">
 									<div class="form-group col-sm-9">
 										<input type="text" class="form-control"
-										ng-disabled="temp.policy.readOnly"
-										ng-model="temp.policy.yamlparams.blackList[$index]" placeholder="BlackList" />
+											ng-disabled="temp.policy.readOnly"
+											ng-model="temp.policy.yamlparams.blackList[$index]"
+											placeholder="BlackList" />
 									</div>
 									<div class="form-group col-sm-1">
-										<button type="button" class="btn btn-default" ng-show="$last"
-										ng-disabled="temp.policy.readOnly" ng-click="removeBL()">
-										<i class="fa fa-minus"></i>
+										<button type="button" class="btn btn-default"
+											ng-disabled="temp.policy.readOnly"
+											ng-click="removeBL(temp.policy.yamlparams.blackList[$index])">
+											<i class="fa fa-minus"></i>
 										</button>
 									</div>
-									</div>
 								</div>
 							</div>
 						</div>
+					</div>
 				</div>
 			</div>
 		</div>
-		
+
 		<div ng-if="temp.policy.ruleProvider == 'GUARD_YAML'">
 			<div class="well">
 				<div class="form-group row">
@@ -246,113 +305,122 @@
 					</div>
 				</div>
 				<div class="form-group row">
-						<div class="form-group row" style="margin-left: 2%">
-							<div class="form-group col-sm-3">
-								<label> actor: </label>
-							</div>
-							<div class="form-group col-sm-3">
-								<input type="text" class="form-control"
-									ng-disabled="temp.policy.readOnly" ng-model="temp.policy.yamlparams.actor"
-									placeholder="Actor" />
-							</div>
+					<div class="form-group row" style="margin-left: 2%">
+						<div class="form-group col-sm-3">
+							<label> actor: </label>
 						</div>
-						<div class="form-group row" style="margin-left: 2%">
-							<div class="form-group col-sm-3">
-								<label> recipe: </label>
-							</div>
-							<div class="form-group col-sm-3">
-								<input type="text" class="form-control"
-									ng-disabled="temp.policy.readOnly" ng-model="temp.policy.yamlparams.recipe"
-									placeholder="Recipe" />
-							</div>
+						<div class="form-group col-sm-3">
+							<input type="text" class="form-control"
+								ng-disabled="temp.policy.readOnly"
+								ng-model="temp.policy.yamlparams.actor" placeholder="Actor" />
 						</div>
-						<div class="form-group row" style="margin-left: 2%">
-							<div class="form-group col-sm-3">
-								<label> CLName: </label>
-							</div>
-							<div class="form-group col-sm-3">
-								<input type="text" class="form-control"
-									ng-disabled="temp.policy.readOnly" ng-model="temp.policy.yamlparams.clname"
-									placeholder="CLName" />
-							</div>
+					</div>
+					<div class="form-group row" style="margin-left: 2%">
+						<div class="form-group col-sm-3">
+							<label> recipe: </label>
 						</div>
-						<div class="form-group row" style="margin-left: 2%">
-							<div class="form-group col-sm-3">
-								<label> Targets: </label>
-								<button type="button" class="btn btn-default"
-									ng-disabled="temp.policy.readOnly" ng-click="addNewTarget()">
-									<i class="fa fa-plus"></i>
-								</button>
-							</div>
-							<div class="form-group col-sm-4">
-								<div data-ng-repeat="choice in temp.policy.yamlparams.targets track by $index">
-									<div class="form-group row">
+						<div class="form-group col-sm-3">
+							<input type="text" class="form-control"
+								ng-disabled="temp.policy.readOnly"
+								ng-model="temp.policy.yamlparams.recipe" placeholder="Recipe" />
+						</div>
+					</div>
+					<div class="form-group row" style="margin-left: 2%">
+						<div class="form-group col-sm-3">
+							<label> CLName: </label>
+						</div>
+						<div class="form-group col-sm-3">
+							<input type="text" class="form-control"
+								ng-disabled="temp.policy.readOnly"
+								ng-model="temp.policy.yamlparams.clname" placeholder="CLName" />
+						</div>
+					</div>
+					<div class="form-group row" style="margin-left: 2%">
+						<div class="form-group col-sm-3">
+							<label> Targets: </label>
+							<button type="button" class="btn btn-default"
+								ng-disabled="temp.policy.readOnly" ng-click="addNewTarget()">
+								<i class="fa fa-plus"></i>
+							</button>
+						</div>
+						<div class="form-group col-sm-4">
+							<div
+								data-ng-repeat="choice in temp.policy.yamlparams.targets track by $index">
+								<div class="form-group row">
 									<div class="form-group col-sm-9">
 										<input type="text" class="form-control"
-										ng-disabled="temp.policy.readOnly"
-										ng-model="temp.policy.yamlparams.targets[$index]" placeholder="Target" />
+											ng-disabled="temp.policy.readOnly"
+											ng-model="temp.policy.yamlparams.targets[$index]"
+											placeholder="Target" />
 									</div>
 									<div class="form-group col-sm-1">
 										<button type="button" class="btn btn-default" ng-show="$last"
-										ng-disabled="temp.policy.readOnly" ng-click="removeTarget()">
-										<i class="fa fa-minus"></i>
+											ng-disabled="temp.policy.readOnly" ng-click="removeTarget()">
+											<i class="fa fa-minus"></i>
 										</button>
 									</div>
-									</div>
 								</div>
 							</div>
 						</div>
-						<div class="form-group row" style="margin-left: 2%">
-							<div class="form-group col-sm-3">
-								<label> limit: </label>
-							</div>
-							<div class="form-group col-sm-3">
-								<input type="text" class="form-control"
-									ng-disabled="temp.policy.readOnly" ng-model="temp.policy.yamlparams.limit"
-									placeholder="Limit" title="Enter time limit value."/>
-							</div>
+					</div>
+					<div class="form-group row" style="margin-left: 2%">
+						<div class="form-group col-sm-3">
+							<label> limit: </label>
 						</div>
-						<div class="form-group row" style="margin-left: 2%">
-							<div class="form-group col-sm-3">
-								<label> timeWindow: </label>
-							</div>
-							<div class="form-group col-sm-2">
-								<input type="text" class="form-control"
-									ng-disabled="temp.policy.readOnly" ng-model="temp.policy.yamlparams.timeWindow"
-									placeholder="Time Window" title="Enter time window value."/>
-							</div>
-							<div class="form-group col-sm-1">
-								<select class="form-control" ng-disabled="temp.policy.readOnly" 
-								ng-model="temp.policy.yamlparams.timeUnits" title="Select the Time Units value from dropdown options.">
+						<div class="form-group col-sm-3">
+							<input type="text" class="form-control"
+								ng-disabled="temp.policy.readOnly"
+								ng-model="temp.policy.yamlparams.limit" placeholder="Limit"
+								title="Enter time limit value." />
+						</div>
+					</div>
+					<div class="form-group row" style="margin-left: 2%">
+						<div class="form-group col-sm-3">
+							<label> timeWindow: </label>
+						</div>
+						<div class="form-group col-sm-2">
+							<input type="text" class="form-control"
+								ng-disabled="temp.policy.readOnly"
+								ng-model="temp.policy.yamlparams.timeWindow"
+								placeholder="Time Window" title="Enter time window value." />
+						</div>
+						<div class="form-group col-sm-1">
+							<select class="form-control" ng-disabled="temp.policy.readOnly"
+								ng-model="temp.policy.yamlparams.timeUnits"
+								title="Select the Time Units value from dropdown options.">
 								<option>minute</option>
 								<option>hour</option>
 								<option>day</option>
 								<option>week</option>
 								<option>month</option>
 								<option>year</option>
-								</select>
-							</div>
+							</select>
 						</div>
-						<div class="form-group row" style="margin-left: 2%">
-							<div class="form-group col-sm-3">
-								<label> guardActiveStart: </label>
-							</div>
-							<div class="form-group col-sm-3">
-								<input type="text" class="form-control"
-									ng-disabled="temp.policy.readOnly" ng-model="temp.policy.yamlparams.guardActiveStart" title="Enter Guard Active Start value in following patren '00:00:00-05:00'."
-									placeholder="00:00:00-05:00" />
-							</div>
+					</div>
+					<div class="form-group row" style="margin-left: 2%">
+						<div class="form-group col-sm-3">
+							<label> guardActiveStart: </label>
 						</div>
-						<div class="form-group row" style="margin-left: 2%">
-							<div class="form-group col-sm-3">
-								<label> guardActiveEnd: </label>
-							</div>
-							<div class="form-group col-sm-3">
-								<input type="text" class="form-control"
-									ng-disabled="temp.policy.readOnly" ng-model="temp.policy.yamlparams.guardActiveEnd" title="Enter Guard Active End value in following patren '00:00:00-05:00'."
-									placeholder="00:00:00-05:00" />
-							</div>
+						<div class="form-group col-sm-3">
+							<input type="text" class="form-control"
+								ng-disabled="temp.policy.readOnly"
+								ng-model="temp.policy.yamlparams.guardActiveStart"
+								title="Enter Guard Active Start value in following patren '00:00:00-05:00'."
+								placeholder="00:00:00-05:00" />
 						</div>
+					</div>
+					<div class="form-group row" style="margin-left: 2%">
+						<div class="form-group col-sm-3">
+							<label> guardActiveEnd: </label>
+						</div>
+						<div class="form-group col-sm-3">
+							<input type="text" class="form-control"
+								ng-disabled="temp.policy.readOnly"
+								ng-model="temp.policy.yamlparams.guardActiveEnd"
+								title="Enter Guard Active End value in following patren '00:00:00-05:00'."
+								placeholder="00:00:00-05:00" />
+						</div>
+					</div>
 				</div>
 			</div>
 		</div>
@@ -364,7 +432,8 @@
 					<div class="form-group col-sm-1">
 						<label>Component Attributes:</label><br>
 						<button type="button" class="btn btn-default"
-							ng-disabled="temp.policy.readOnly" ng-click="addNewChoice()" title="onClick Component Attribute row is added.">
+							ng-disabled="temp.policy.readOnly" ng-click="addNewChoice()"
+							title="onClick Component Attribute row is added.">
 							<i class="fa fa-plus"></i>
 						</button>
 					</div>
@@ -375,18 +444,21 @@
 							<div class="form-group col-sm-3">
 								<select class="form-control" ng-disabled="temp.policy.readOnly"
 									ng-model="choice.key"
-									ng-options="option for option in attributeDictionaryDatas track by option" title="Select the dropdown value driven from Attribute (common)Dictionary.">
+									ng-options="option for option in attributeDictionaryDatas track by option"
+									title="Select the dropdown value driven from Attribute (common)Dictionary.">
 									<option value="">{{choice.key}}</option>
 								</select>
 							</div>
 							<div class="form-group col-sm-3">
 								<input type="text" class="form-control"
 									ng-disabled="temp.policy.readOnly" ng-model="choice.value"
-									placeholder="Attribute Value" title="Enter the Attribute Value without any spaces and special characters"/>
+									placeholder="Attribute Value"
+									title="Enter the Attribute Value without any spaces and special characters" />
 							</div>
 							<div class="form-group col-sm-1">
 								<button type="button" class="btn btn-default" ng-show="$last"
-									ng-disabled="temp.policy.readOnly" ng-click="removeChoice()" title="onClick will remove the last row">
+									ng-disabled="temp.policy.readOnly" ng-click="removeChoice()"
+									title="onClick will remove the last row">
 									<i class="fa fa-minus"></i>
 								</button>
 							</div>
@@ -403,7 +475,8 @@
 						<label>Settings Attributes:</label><br>
 						<button type="button" class="btn btn-default"
 							ng-disabled="temp.policy.readOnly"
-							ng-click="addNewSettingsChoice()" title="onClick Settings Attribute row is added.">
+							ng-click="addNewSettingsChoice()"
+							title="onClick Settings Attribute row is added.">
 							<i class="fa fa-plus"></i>
 						</button>
 					</div>
@@ -414,19 +487,22 @@
 							<div class="form-group col-sm-3">
 								<select class="form-control" ng-disabled="temp.policy.readOnly"
 									ng-model="settingschoice.key"
-									ng-options="option for option in settingsDictionaryDatas track by option" title="Select the dropdown value driven from Settings (Decision)Dictionary.">
+									ng-options="option for option in settingsDictionaryDatas track by option"
+									title="Select the dropdown value driven from Settings (Decision)Dictionary.">
 									<option value="">{{settingschoice.key}}</option>
 								</select>
 							</div>
 							<div class="form-group col-sm-3">
 								<input type="text" class="form-control"
 									ng-disabled="temp.policy.readOnly"
-									ng-model="settingschoice.value" placeholder="Settings Value" title="Enter the Settings Attribute Value without any spaces and special characters"/>
+									ng-model="settingschoice.value" placeholder="Settings Value"
+									title="Enter the Settings Attribute Value without any spaces and special characters" />
 							</div>
 							<div class="form-group col-sm-1">
 								<button type="button" class="btn btn-default" ng-show="$last"
 									ng-disabled="temp.policy.readOnly"
-									ng-click="removeSettingsChoice()" title="onClick will remove the last row">
+									ng-click="removeSettingsChoice()"
+									title="onClick will remove the last row">
 									<i class="fa fa-minus"></i>
 								</button>
 							</div>
@@ -443,7 +519,8 @@
 					<div class="form-group col-sm-1">
 						<button type="button" class="btn btn-default"
 							ng-disabled="temp.policy.readOnly"
-							ng-click="addNewRuleAlgorithm()" title="onClick Rule Algorithms row is added.">
+							ng-click="addNewRuleAlgorithm()"
+							title="onClick Rule Algorithms row is added.">
 							<i class="fa fa-plus"></i>
 						</button>
 					</div>
@@ -462,7 +539,8 @@
 									ng-disabled="temp.policy.readOnly"
 									ng-model="ruleAlgorithmschoice.dynamicRuleAlgorithmField1"
 									ng-options="option for option in attributeDictionaryDatas track by option"
-									name="dynamicRuleAlgorithmField1" title="Select the dropdown value driven from Attribute (common)Dictionary or Settings (Decision)Dictionary.">
+									name="dynamicRuleAlgorithmField1"
+									title="Select the dropdown value driven from Attribute (common)Dictionary or Settings (Decision)Dictionary.">
 									<option value="">{{ruleAlgorithmschoice.dynamicRuleAlgorithmField1}}</option>
 								</select>
 							</div>
@@ -471,18 +549,21 @@
 									ng-disabled="temp.policy.readOnly"
 									ng-model="ruleAlgorithmschoice.dynamicRuleAlgorithmCombo"
 									ng-options="option for option in functionDefinitionDatas track by option"
-									name="dynamicRuleAlgorithmCombo" title="Select the dropdown value driven from FunctionDataType."></select>
+									name="dynamicRuleAlgorithmCombo"
+									title="Select the dropdown value driven from FunctionDataType."></select>
 							</div>
 							<div class="form-group col-sm-3">
 								<input type="text" class="form-control"
 									ng-disabled="temp.policy.readOnly"
 									ng-model="ruleAlgorithmschoice.dynamicRuleAlgorithmField2"
-									name="dynamicRuleAlgorithmField2" title="Enter the Value without any spaces and special characters and for rule formation use A1, A2,..etc., based on above Rules."/>
+									name="dynamicRuleAlgorithmField2"
+									title="Enter the Value without any spaces and special characters and for rule formation use A1, A2,..etc., based on above Rules." />
 							</div>
 							<div class="form-group col-sm-1">
 								<button type="button" class="btn btn-default"
 									ng-disabled="temp.policy.readOnly"
-									ng-click="removeRuleAlgorithm()" title="onClick will remove the last row">
+									ng-click="removeRuleAlgorithm()"
+									title="onClick will remove the last row">
 									<i class="fa fa-minus"></i>
 								</button>
 							</div>
@@ -497,11 +578,14 @@
 		<div class="modal-footer">
 			<button class="btn btn-primary" herf="javascript:void(0)"
 				ng-disabled="temp.policy.readOnly"
-				ng-click="validatePolicy(temp.policy);" title="Validate the data entered in the Policy fields.">Validate</button>
+				ng-click="validatePolicy(temp.policy);"
+				title="Validate the data entered in the Policy fields.">Validate</button>
 			<button class="btn btn-success" herf="javascript:void(0)"
 				ng-disabled="savebutton" ng-disabled="temp.policy.readOnly"
-				ng-click="saveDecisionPolicy(temp);" title="Save the Policy with validated data.">Save</button>
-			<button type="button" class="btn btn-default" ng-click="refresh();" title="Close the template.">Close</button>
+				ng-click="saveDecisionPolicy(temp);"
+				title="Save the Policy with validated data.">Save</button>
+			<button type="button" class="btn btn-default" ng-click="refresh();"
+				title="Close the template.">Close</button>
 		</div>
 	</form>
 </div>
\ No newline at end of file
diff --git a/POLICY-SDK-APP/src/test/java/org/onap/policy/controller/ExportAndImportDecisionBlackListEntriesTest.java b/POLICY-SDK-APP/src/test/java/org/onap/policy/controller/ExportAndImportDecisionBlackListEntriesTest.java
new file mode 100644
index 0000000..bf01ac1
--- /dev/null
+++ b/POLICY-SDK-APP/src/test/java/org/onap/policy/controller/ExportAndImportDecisionBlackListEntriesTest.java
@@ -0,0 +1,126 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP Policy Engine
+ * ================================================================================
+ * Copyright (C) 2018 AT&T Intellectual Property. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+package org.onap.policy.controller;
+
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
+import static org.mockito.Mockito.mock;
+
+import java.io.BufferedReader;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.StringReader;
+
+import javax.servlet.ReadListener;
+import javax.servlet.ServletInputStream;
+import javax.servlet.http.HttpServletRequest;
+
+import org.apache.commons.io.IOUtils;
+import org.junit.Before;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.springframework.mock.web.MockHttpServletRequest;
+import org.springframework.mock.web.MockHttpServletResponse;
+
+public class ExportAndImportDecisionBlackListEntriesTest {
+
+	private HttpServletRequest request;
+	private MockHttpServletResponse response;
+	String jsonString;
+	
+	@Before
+	public void setUp() throws Exception {
+		request = mock(HttpServletRequest.class);       
+		response =  new MockHttpServletResponse();
+	}
+	
+	@Test
+	public void testExportBlackList() throws IOException{
+		ClassLoader classLoader = getClass().getClassLoader();
+		jsonString = IOUtils.toString(classLoader.getResourceAsStream("DecisionPolicyData.txt"));
+		try(BufferedReader reader = new BufferedReader(new StringReader(jsonString))){
+			Mockito.when(request.getReader()).thenReturn(reader);
+			ExportAndImportDecisionBlackListEntries controller = new ExportAndImportDecisionBlackListEntries();
+			controller.exportBlackList(request, response);
+			assertTrue("".equals(response.getContentAsString()));
+		}catch(Exception e){
+			fail("Not expecting Exception while Exporting BlackListEntries.");
+		}
+	}
+	
+	@Test
+	public void testImportBlackList() throws Exception{
+		MockHttpServletRequest request =  new MockHttpServletRequest();
+		ExportAndImportDecisionBlackListEntries controller = new ExportAndImportDecisionBlackListEntries();
+		File file = new File("src/test/resources/BlackList.xls");
+		try(FileInputStream targetStream = new FileInputStream(file)){
+			ExportAndImportDecisionBlackListEntriesTest testController = Mockito.mock(ExportAndImportDecisionBlackListEntriesTest.class);
+			ServletInputStream inputStream = testController.getInputStream(getBytes(targetStream));
+			Mockito.when(request.getInputStream()).thenReturn(inputStream);
+			String boundary = "===" + System.currentTimeMillis() + "===";
+			request.addHeader("Content-Type", "multipart/form-data; boundary=" + boundary);
+			request.addHeader("name", "BlackList.xls");
+			controller.importBlackListFile(request, response);
+			assertTrue(response.getContentAsString().contains("data"));
+		}catch(Exception e){
+			fail("Not expecting Exception while importing BlackListEntries.");
+		}
+	}
+	
+	public static byte[] getBytes(InputStream is) throws IOException {
+		int len;
+		int size = 1024;
+		byte[] buf;
+		ByteArrayOutputStream bos = new ByteArrayOutputStream();
+		buf = new byte[size];
+		while ((len = is.read(buf, 0, size)) != -1)
+			bos.write(buf, 0, len);
+		buf = bos.toByteArray();
+		return buf;
+	}
+	
+	public ServletInputStream getInputStream(byte[] body) throws IOException { 
+        final ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(body); 
+        ServletInputStream servletInputStream = new ServletInputStream() { 
+            public int read() throws IOException { 
+                return byteArrayInputStream.read(); 
+            }
+
+			@Override
+			public boolean isFinished() {
+				return false;
+			}
+
+			@Override
+			public boolean isReady() {
+				return false;
+			}
+
+			@Override
+			public void setReadListener(ReadListener readListener) {
+			} 
+        }; 
+        return servletInputStream; 
+    } 
+}
diff --git a/POLICY-SDK-APP/src/test/resources/BlackList.xls b/POLICY-SDK-APP/src/test/resources/BlackList.xls
new file mode 100644
index 0000000..228d724
--- /dev/null
+++ b/POLICY-SDK-APP/src/test/resources/BlackList.xls
Binary files differ
diff --git a/POLICY-SDK-APP/src/test/resources/DecisionPolicyData.txt b/POLICY-SDK-APP/src/test/resources/DecisionPolicyData.txt
new file mode 100644
index 0000000..26b07cf
--- /dev/null
+++ b/POLICY-SDK-APP/src/test/resources/DecisionPolicyData.txt
@@ -0,0 +1 @@
+{"policyData":{"data":{"description":"SampelGuardBLOne@CreatedBy:demo@CreatedBy:@ModifiedBy:demo@ModifiedBy:","policyIssuer":null,"policyDefaults":null,"target":{"anyOf":[{"allOf":[{"match":[{"attributeValue":{"content":["com.Decision_SampelGuardBLOne.4.xml"],"dataType":"http://www.w3.org/2001/XMLSchema#string","otherAttributes":{}},"attributeDesignator":{"category":"urn:oasis:names:tc:xacml:1.0:subject-category:access-subject","attributeId":"PolicyName","dataType":"http://www.w3.org/2001/XMLSchema#string","issuer":null,"mustBePresent":false},"attributeSelector":null,"matchId":"org.onap.function.regex-match"}]},{"match":[{"attributeValue":{"content":["Test"],"dataType":"http://www.w3.org/2001/XMLSchema#string","otherAttributes":{}},"attributeDesignator":{"category":"urn:oasis:names:tc:xacml:1.0:subject-category:access-subject","attributeId":"ONAPName","dataType":"http://www.w3.org/2001/XMLSchema#string","issuer":null,"mustBePresent":false},"attributeSelector":null,"matchId":"org.onap.function.regex-match"},{"attributeValue":{"content":["(?i)testActor"],"dataType":"http://www.w3.org/2001/XMLSchema#string","otherAttributes":{}},"attributeDesignator":{"category":"urn:oasis:names:tc:xacml:3.0:attribute-category:resource","attributeId":"actor","dataType":"http://www.w3.org/2001/XMLSchema#string","issuer":null,"mustBePresent":false},"attributeSelector":null,"matchId":"urn:oasis:names:tc:xacml:1.0:function:string-regexp-match"},{"attributeValue":{"content":["(?i)testRecipe"],"dataType":"http://www.w3.org/2001/XMLSchema#string","otherAttributes":{}},"attributeDesignator":{"category":"urn:oasis:names:tc:xacml:3.0:attribute-category:resource","attributeId":"recipe","dataType":"http://www.w3.org/2001/XMLSchema#string","issuer":null,"mustBePresent":false},"attributeSelector":null,"matchId":"urn:oasis:names:tc:xacml:1.0:function:string-regexp-match"},{"attributeValue":{"content":["testCLName"],"dataType":"http://www.w3.org/2001/XMLSchema#string","otherAttributes":{}},"attributeDesignator":{"category":"urn:oasis:names:tc:xacml:3.0:attribute-category:resource","attributeId":"clname","dataType":"http://www.w3.org/2001/XMLSchema#string","issuer":null,"mustBePresent":false},"attributeSelector":null,"matchId":"urn:oasis:names:tc:xacml:1.0:function:string-regexp-match"},{"attributeValue":{"content":["Use Manual Entry"],"dataType":"http://www.w3.org/2001/XMLSchema#string","otherAttributes":{}},"attributeDesignator":{"category":"urn:oasis:names:tc:xacml:3.0:attribute-category:resource","attributeId":"blackListEntryType","dataType":"http://www.w3.org/2001/XMLSchema#string","issuer":null,"mustBePresent":false},"attributeSelector":null,"matchId":"urn:oasis:names:tc:xacml:1.0:function:string-regexp-match"}]}]}]},"combinerParametersOrRuleCombinerParametersOrVariableDefinition":[{"description":null,"target":{"anyOf":[{"allOf":[{"match":[{"attributeValue":{"content":["DECIDE"],"dataType":"http://www.w3.org/2001/XMLSchema#string","otherAttributes":{}},"attributeDesignator":{"category":"urn:oasis:names:tc:xacml:3.0:attribute-category:action","attributeId":"urn:oasis:names:tc:xacml:1.0:action:action-id","dataType":"http://www.w3.org/2001/XMLSchema#string","issuer":null,"mustBePresent":false},"attributeSelector":null,"matchId":"urn:oasis:names:tc:xacml:3.0:function:string-equal-ignore-case"}]}]}]},"condition":{"expression":{"name":"{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Apply","declaredType":"oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType","scope":"javax.xml.bind.JAXBElement$GlobalScope","value":{"description":null,"expression":[{"name":"{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Apply","declaredType":"oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType","scope":"javax.xml.bind.JAXBElement$GlobalScope","value":{"description":null,"expression":[{"name":"{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Apply","declaredType":"oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType","scope":"javax.xml.bind.JAXBElement$GlobalScope","value":{"description":null,"expression":[{"name":"{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Apply","declaredType":"oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType","scope":"javax.xml.bind.JAXBElement$GlobalScope","value":{"description":null,"expression":[{"name":"{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}AttributeDesignator","declaredType":"oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeDesignatorType","scope":"javax.xml.bind.JAXBElement$GlobalScope","value":{"category":"urn:oasis:names:tc:xacml:3.0:attribute-category:environment","attributeId":"urn:oasis:names:tc:xacml:1.0:environment:current-time","dataType":"http://www.w3.org/2001/XMLSchema#time","issuer":null,"mustBePresent":false},"nil":false,"globalScope":true,"typeSubstituted":false}],"functionId":"urn:oasis:names:tc:xacml:1.0:function:time-one-and-only"},"nil":false,"globalScope":true,"typeSubstituted":false},{"name":"{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}AttributeValue","declaredType":"oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeValueType","scope":"javax.xml.bind.JAXBElement$GlobalScope","value":{"content":["5:00"],"dataType":"http://www.w3.org/2001/XMLSchema#time","otherAttributes":{}},"nil":false,"globalScope":true,"typeSubstituted":false},{"name":"{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}AttributeValue","declaredType":"oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeValueType","scope":"javax.xml.bind.JAXBElement$GlobalScope","value":{"content":["10:00"],"dataType":"http://www.w3.org/2001/XMLSchema#time","otherAttributes":{}},"nil":false,"globalScope":true,"typeSubstituted":false}],"functionId":"urn:oasis:names:tc:xacml:2.0:function:time-in-range"},"nil":false,"globalScope":true,"typeSubstituted":false},{"name":"{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Apply","declaredType":"oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType","scope":"javax.xml.bind.JAXBElement$GlobalScope","value":{"description":null,"expression":[{"name":"{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Function","declaredType":"oasis.names.tc.xacml._3_0.core.schema.wd_17.FunctionType","scope":"javax.xml.bind.JAXBElement$GlobalScope","value":{"functionId":"urn:oasis:names:tc:xacml:1.0:function:string-equal"},"nil":false,"globalScope":true,"typeSubstituted":false},{"name":"{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Apply","declaredType":"oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType","scope":"javax.xml.bind.JAXBElement$GlobalScope","value":{"description":null,"expression":[{"name":"{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}AttributeDesignator","declaredType":"oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeDesignatorType","scope":"javax.xml.bind.JAXBElement$GlobalScope","value":{"category":"urn:oasis:names:tc:xacml:3.0:attribute-category:resource","attributeId":"target","dataType":"http://www.w3.org/2001/XMLSchema#string","issuer":null,"mustBePresent":false},"nil":false,"globalScope":true,"typeSubstituted":false}],"functionId":"urn:oasis:names:tc:xacml:1.0:function:string-one-and-only"},"nil":false,"globalScope":true,"typeSubstituted":false},{"name":"{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Apply","declaredType":"oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType","scope":"javax.xml.bind.JAXBElement$GlobalScope","value":{"description":null,"expression":[{"name":"{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}AttributeValue","declaredType":"oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeValueType","scope":"javax.xml.bind.JAXBElement$GlobalScope","value":{"content":["testBL2"],"dataType":"http://www.w3.org/2001/XMLSchema#string","otherAttributes":{}},"nil":false,"globalScope":true,"typeSubstituted":false},{"name":"{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}AttributeValue","declaredType":"oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeValueType","scope":"javax.xml.bind.JAXBElement$GlobalScope","value":{"content":["testBL3"],"dataType":"http://www.w3.org/2001/XMLSchema#string","otherAttributes":{}},"nil":false,"globalScope":true,"typeSubstituted":false},{"name":"{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}AttributeValue","declaredType":"oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeValueType","scope":"javax.xml.bind.JAXBElement$GlobalScope","value":{"content":["testBL4"],"dataType":"http://www.w3.org/2001/XMLSchema#string","otherAttributes":{}},"nil":false,"globalScope":true,"typeSubstituted":false}],"functionId":"urn:oasis:names:tc:xacml:1.0:function:string-bag"},"nil":false,"globalScope":true,"typeSubstituted":false}],"functionId":"urn:oasis:names:tc:xacml:3.0:function:any-of"},"nil":false,"globalScope":true,"typeSubstituted":false}],"functionId":"urn:oasis:names:tc:xacml:1.0:function:and"},"nil":false,"globalScope":true,"typeSubstituted":false}],"functionId":"urn:oasis:names:tc:xacml:1.0:function:not"},"nil":false,"globalScope":true,"typeSubstituted":false}},"obligationExpressions":null,"adviceExpressions":null,"ruleId":"urn:com:xacml:rule:id:284d9393-f861-4250-b62d-fc36640a363a","effect":"PERMIT"},{"description":null,"target":{"anyOf":[{"allOf":[{"match":[{"attributeValue":{"content":["DECIDE"],"dataType":"http://www.w3.org/2001/XMLSchema#string","otherAttributes":{}},"attributeDesignator":{"category":"urn:oasis:names:tc:xacml:3.0:attribute-category:action","attributeId":"urn:oasis:names:tc:xacml:1.0:action:action-id","dataType":"http://www.w3.org/2001/XMLSchema#string","issuer":null,"mustBePresent":false},"attributeSelector":null,"matchId":"urn:oasis:names:tc:xacml:3.0:function:string-equal-ignore-case"}]}]}]},"condition":{"expression":{"name":"{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Apply","declaredType":"oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType","scope":"javax.xml.bind.JAXBElement$GlobalScope","value":{"description":null,"expression":[{"name":"{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Apply","declaredType":"oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType","scope":"javax.xml.bind.JAXBElement$GlobalScope","value":{"description":null,"expression":[{"name":"{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Apply","declaredType":"oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType","scope":"javax.xml.bind.JAXBElement$GlobalScope","value":{"description":null,"expression":[{"name":"{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Apply","declaredType":"oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType","scope":"javax.xml.bind.JAXBElement$GlobalScope","value":{"description":null,"expression":[{"name":"{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Apply","declaredType":"oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType","scope":"javax.xml.bind.JAXBElement$GlobalScope","value":{"description":null,"expression":[{"name":"{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}AttributeDesignator","declaredType":"oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeDesignatorType","scope":"javax.xml.bind.JAXBElement$GlobalScope","value":{"category":"urn:oasis:names:tc:xacml:3.0:attribute-category:environment","attributeId":"urn:oasis:names:tc:xacml:1.0:environment:current-time","dataType":"http://www.w3.org/2001/XMLSchema#time","issuer":null,"mustBePresent":false},"nil":false,"globalScope":true,"typeSubstituted":false}],"functionId":"urn:oasis:names:tc:xacml:1.0:function:time-one-and-only"},"nil":false,"globalScope":true,"typeSubstituted":false},{"name":"{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}AttributeValue","declaredType":"oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeValueType","scope":"javax.xml.bind.JAXBElement$GlobalScope","value":{"content":["5:00"],"dataType":"http://www.w3.org/2001/XMLSchema#time","otherAttributes":{}},"nil":false,"globalScope":true,"typeSubstituted":false},{"name":"{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}AttributeValue","declaredType":"oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeValueType","scope":"javax.xml.bind.JAXBElement$GlobalScope","value":{"content":["10:00"],"dataType":"http://www.w3.org/2001/XMLSchema#time","otherAttributes":{}},"nil":false,"globalScope":true,"typeSubstituted":false}],"functionId":"urn:oasis:names:tc:xacml:2.0:function:time-in-range"},"nil":false,"globalScope":true,"typeSubstituted":false},{"name":"{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Apply","declaredType":"oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType","scope":"javax.xml.bind.JAXBElement$GlobalScope","value":{"description":null,"expression":[{"name":"{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Function","declaredType":"oasis.names.tc.xacml._3_0.core.schema.wd_17.FunctionType","scope":"javax.xml.bind.JAXBElement$GlobalScope","value":{"functionId":"urn:oasis:names:tc:xacml:1.0:function:string-equal"},"nil":false,"globalScope":true,"typeSubstituted":false},{"name":"{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Apply","declaredType":"oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType","scope":"javax.xml.bind.JAXBElement$GlobalScope","value":{"description":null,"expression":[{"name":"{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}AttributeDesignator","declaredType":"oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeDesignatorType","scope":"javax.xml.bind.JAXBElement$GlobalScope","value":{"category":"urn:oasis:names:tc:xacml:3.0:attribute-category:resource","attributeId":"target","dataType":"http://www.w3.org/2001/XMLSchema#string","issuer":null,"mustBePresent":false},"nil":false,"globalScope":true,"typeSubstituted":false}],"functionId":"urn:oasis:names:tc:xacml:1.0:function:string-one-and-only"},"nil":false,"globalScope":true,"typeSubstituted":false},{"name":"{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Apply","declaredType":"oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType","scope":"javax.xml.bind.JAXBElement$GlobalScope","value":{"description":null,"expression":[{"name":"{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}AttributeValue","declaredType":"oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeValueType","scope":"javax.xml.bind.JAXBElement$GlobalScope","value":{"content":["testBL2"],"dataType":"http://www.w3.org/2001/XMLSchema#string","otherAttributes":{}},"nil":false,"globalScope":true,"typeSubstituted":false},{"name":"{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}AttributeValue","declaredType":"oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeValueType","scope":"javax.xml.bind.JAXBElement$GlobalScope","value":{"content":["testBL3"],"dataType":"http://www.w3.org/2001/XMLSchema#string","otherAttributes":{}},"nil":false,"globalScope":true,"typeSubstituted":false},{"name":"{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}AttributeValue","declaredType":"oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeValueType","scope":"javax.xml.bind.JAXBElement$GlobalScope","value":{"content":["testBL4"],"dataType":"http://www.w3.org/2001/XMLSchema#string","otherAttributes":{}},"nil":false,"globalScope":true,"typeSubstituted":false}],"functionId":"urn:oasis:names:tc:xacml:1.0:function:string-bag"},"nil":false,"globalScope":true,"typeSubstituted":false}],"functionId":"urn:oasis:names:tc:xacml:3.0:function:any-of"},"nil":false,"globalScope":true,"typeSubstituted":false}],"functionId":"urn:oasis:names:tc:xacml:1.0:function:and"},"nil":false,"globalScope":true,"typeSubstituted":false}],"functionId":"urn:oasis:names:tc:xacml:1.0:function:not"},"nil":false,"globalScope":true,"typeSubstituted":false}],"functionId":"urn:oasis:names:tc:xacml:1.0:function:not"},"nil":false,"globalScope":true,"typeSubstituted":false}},"obligationExpressions":null,"adviceExpressions":{"adviceExpression":[{"attributeAssignmentExpression":[{"expression":{"name":"{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}AttributeValue","declaredType":"oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeValueType","scope":"javax.xml.bind.JAXBElement$GlobalScope","value":{"content":["Denied!"],"dataType":"http://www.w3.org/2001/XMLSchema#string","otherAttributes":{}},"nil":false,"globalScope":true,"typeSubstituted":false},"attributeId":"guard.response","category":"urn:oasis:names:tc:xacml:3.0:attribute-category:resource","issuer":null}],"adviceId":"GUARD_BL_YAML","appliesTo":"DENY"}]},"ruleId":"urn:com:xacml:rule:id:284d9393-f861-4250-b62d-fc36640a363a","effect":"DENY"}],"obligationExpressions":null,"adviceExpressions":null,"policyId":"urn:com:xacml:policy:id:d56af069-6cf1-430c-ba07-e26602e06a52","version":"4","ruleCombiningAlgId":"urn:oasis:names:tc:xacml:3.0:rule-combining-algorithm:permit-overrides","maxDelegationDepth":null},"policyName":"SampelGuardBLOne","configBodyData":null,"configType":null,"policyID":null,"policyType":"Decision","comboPolicyType":null,"configPolicyType":null,"policyDescription":"SampelGuardBLOne","onapName":"Test","configName":null,"ruleID":null,"parentPath":null,"adminNotification":null,"policyData":{"description":"SampelGuardBLOne@CreatedBy:demo@CreatedBy:@ModifiedBy:demo@ModifiedBy:","policyIssuer":null,"policyDefaults":null,"target":{"anyOf":[{"allOf":[{"match":[{"attributeValue":{"content":["com.Decision_SampelGuardBLOne.4.xml"],"dataType":"http://www.w3.org/2001/XMLSchema#string","otherAttributes":{}},"attributeDesignator":{"category":"urn:oasis:names:tc:xacml:1.0:subject-category:access-subject","attributeId":"PolicyName","dataType":"http://www.w3.org/2001/XMLSchema#string","issuer":null,"mustBePresent":false},"attributeSelector":null,"matchId":"org.onap.function.regex-match"}]},{"match":[{"attributeValue":{"content":["Test"],"dataType":"http://www.w3.org/2001/XMLSchema#string","otherAttributes":{}},"attributeDesignator":{"category":"urn:oasis:names:tc:xacml:1.0:subject-category:access-subject","attributeId":"ONAPName","dataType":"http://www.w3.org/2001/XMLSchema#string","issuer":null,"mustBePresent":false},"attributeSelector":null,"matchId":"org.onap.function.regex-match"},{"attributeValue":{"content":["(?i)testActor"],"dataType":"http://www.w3.org/2001/XMLSchema#string","otherAttributes":{}},"attributeDesignator":{"category":"urn:oasis:names:tc:xacml:3.0:attribute-category:resource","attributeId":"actor","dataType":"http://www.w3.org/2001/XMLSchema#string","issuer":null,"mustBePresent":false},"attributeSelector":null,"matchId":"urn:oasis:names:tc:xacml:1.0:function:string-regexp-match"},{"attributeValue":{"content":["(?i)testRecipe"],"dataType":"http://www.w3.org/2001/XMLSchema#string","otherAttributes":{}},"attributeDesignator":{"category":"urn:oasis:names:tc:xacml:3.0:attribute-category:resource","attributeId":"recipe","dataType":"http://www.w3.org/2001/XMLSchema#string","issuer":null,"mustBePresent":false},"attributeSelector":null,"matchId":"urn:oasis:names:tc:xacml:1.0:function:string-regexp-match"},{"attributeValue":{"content":["testCLName"],"dataType":"http://www.w3.org/2001/XMLSchema#string","otherAttributes":{}},"attributeDesignator":{"category":"urn:oasis:names:tc:xacml:3.0:attribute-category:resource","attributeId":"clname","dataType":"http://www.w3.org/2001/XMLSchema#string","issuer":null,"mustBePresent":false},"attributeSelector":null,"matchId":"urn:oasis:names:tc:xacml:1.0:function:string-regexp-match"},{"attributeValue":{"content":["Use Manual Entry"],"dataType":"http://www.w3.org/2001/XMLSchema#string","otherAttributes":{}},"attributeDesignator":{"category":"urn:oasis:names:tc:xacml:3.0:attribute-category:resource","attributeId":"blackListEntryType","dataType":"http://www.w3.org/2001/XMLSchema#string","issuer":null,"mustBePresent":false},"attributeSelector":null,"matchId":"urn:oasis:names:tc:xacml:1.0:function:string-regexp-match"}]}]}]},"combinerParametersOrRuleCombinerParametersOrVariableDefinition":[{"description":null,"target":{"anyOf":[{"allOf":[{"match":[{"attributeValue":{"content":["DECIDE"],"dataType":"http://www.w3.org/2001/XMLSchema#string","otherAttributes":{}},"attributeDesignator":{"category":"urn:oasis:names:tc:xacml:3.0:attribute-category:action","attributeId":"urn:oasis:names:tc:xacml:1.0:action:action-id","dataType":"http://www.w3.org/2001/XMLSchema#string","issuer":null,"mustBePresent":false},"attributeSelector":null,"matchId":"urn:oasis:names:tc:xacml:3.0:function:string-equal-ignore-case"}]}]}]},"condition":{"expression":{"name":"{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Apply","declaredType":"oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType","scope":"javax.xml.bind.JAXBElement$GlobalScope","value":{"description":null,"expression":[{"name":"{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Apply","declaredType":"oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType","scope":"javax.xml.bind.JAXBElement$GlobalScope","value":{"description":null,"expression":[{"name":"{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Apply","declaredType":"oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType","scope":"javax.xml.bind.JAXBElement$GlobalScope","value":{"description":null,"expression":[{"name":"{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Apply","declaredType":"oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType","scope":"javax.xml.bind.JAXBElement$GlobalScope","value":{"description":null,"expression":[{"name":"{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}AttributeDesignator","declaredType":"oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeDesignatorType","scope":"javax.xml.bind.JAXBElement$GlobalScope","value":{"category":"urn:oasis:names:tc:xacml:3.0:attribute-category:environment","attributeId":"urn:oasis:names:tc:xacml:1.0:environment:current-time","dataType":"http://www.w3.org/2001/XMLSchema#time","issuer":null,"mustBePresent":false},"nil":false,"globalScope":true,"typeSubstituted":false}],"functionId":"urn:oasis:names:tc:xacml:1.0:function:time-one-and-only"},"nil":false,"globalScope":true,"typeSubstituted":false},{"name":"{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}AttributeValue","declaredType":"oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeValueType","scope":"javax.xml.bind.JAXBElement$GlobalScope","value":{"content":["5:00"],"dataType":"http://www.w3.org/2001/XMLSchema#time","otherAttributes":{}},"nil":false,"globalScope":true,"typeSubstituted":false},{"name":"{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}AttributeValue","declaredType":"oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeValueType","scope":"javax.xml.bind.JAXBElement$GlobalScope","value":{"content":["10:00"],"dataType":"http://www.w3.org/2001/XMLSchema#time","otherAttributes":{}},"nil":false,"globalScope":true,"typeSubstituted":false}],"functionId":"urn:oasis:names:tc:xacml:2.0:function:time-in-range"},"nil":false,"globalScope":true,"typeSubstituted":false},{"name":"{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Apply","declaredType":"oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType","scope":"javax.xml.bind.JAXBElement$GlobalScope","value":{"description":null,"expression":[{"name":"{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Function","declaredType":"oasis.names.tc.xacml._3_0.core.schema.wd_17.FunctionType","scope":"javax.xml.bind.JAXBElement$GlobalScope","value":{"functionId":"urn:oasis:names:tc:xacml:1.0:function:string-equal"},"nil":false,"globalScope":true,"typeSubstituted":false},{"name":"{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Apply","declaredType":"oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType","scope":"javax.xml.bind.JAXBElement$GlobalScope","value":{"description":null,"expression":[{"name":"{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}AttributeDesignator","declaredType":"oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeDesignatorType","scope":"javax.xml.bind.JAXBElement$GlobalScope","value":{"category":"urn:oasis:names:tc:xacml:3.0:attribute-category:resource","attributeId":"target","dataType":"http://www.w3.org/2001/XMLSchema#string","issuer":null,"mustBePresent":false},"nil":false,"globalScope":true,"typeSubstituted":false}],"functionId":"urn:oasis:names:tc:xacml:1.0:function:string-one-and-only"},"nil":false,"globalScope":true,"typeSubstituted":false},{"name":"{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Apply","declaredType":"oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType","scope":"javax.xml.bind.JAXBElement$GlobalScope","value":{"description":null,"expression":[{"name":"{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}AttributeValue","declaredType":"oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeValueType","scope":"javax.xml.bind.JAXBElement$GlobalScope","value":{"content":["testBL2"],"dataType":"http://www.w3.org/2001/XMLSchema#string","otherAttributes":{}},"nil":false,"globalScope":true,"typeSubstituted":false},{"name":"{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}AttributeValue","declaredType":"oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeValueType","scope":"javax.xml.bind.JAXBElement$GlobalScope","value":{"content":["testBL3"],"dataType":"http://www.w3.org/2001/XMLSchema#string","otherAttributes":{}},"nil":false,"globalScope":true,"typeSubstituted":false},{"name":"{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}AttributeValue","declaredType":"oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeValueType","scope":"javax.xml.bind.JAXBElement$GlobalScope","value":{"content":["testBL4"],"dataType":"http://www.w3.org/2001/XMLSchema#string","otherAttributes":{}},"nil":false,"globalScope":true,"typeSubstituted":false}],"functionId":"urn:oasis:names:tc:xacml:1.0:function:string-bag"},"nil":false,"globalScope":true,"typeSubstituted":false}],"functionId":"urn:oasis:names:tc:xacml:3.0:function:any-of"},"nil":false,"globalScope":true,"typeSubstituted":false}],"functionId":"urn:oasis:names:tc:xacml:1.0:function:and"},"nil":false,"globalScope":true,"typeSubstituted":false}],"functionId":"urn:oasis:names:tc:xacml:1.0:function:not"},"nil":false,"globalScope":true,"typeSubstituted":false}},"obligationExpressions":null,"adviceExpressions":null,"ruleId":"urn:com:xacml:rule:id:284d9393-f861-4250-b62d-fc36640a363a","effect":"PERMIT"},{"description":null,"target":{"anyOf":[{"allOf":[{"match":[{"attributeValue":{"content":["DECIDE"],"dataType":"http://www.w3.org/2001/XMLSchema#string","otherAttributes":{}},"attributeDesignator":{"category":"urn:oasis:names:tc:xacml:3.0:attribute-category:action","attributeId":"urn:oasis:names:tc:xacml:1.0:action:action-id","dataType":"http://www.w3.org/2001/XMLSchema#string","issuer":null,"mustBePresent":false},"attributeSelector":null,"matchId":"urn:oasis:names:tc:xacml:3.0:function:string-equal-ignore-case"}]}]}]},"condition":{"expression":{"name":"{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Apply","declaredType":"oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType","scope":"javax.xml.bind.JAXBElement$GlobalScope","value":{"description":null,"expression":[{"name":"{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Apply","declaredType":"oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType","scope":"javax.xml.bind.JAXBElement$GlobalScope","value":{"description":null,"expression":[{"name":"{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Apply","declaredType":"oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType","scope":"javax.xml.bind.JAXBElement$GlobalScope","value":{"description":null,"expression":[{"name":"{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Apply","declaredType":"oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType","scope":"javax.xml.bind.JAXBElement$GlobalScope","value":{"description":null,"expression":[{"name":"{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Apply","declaredType":"oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType","scope":"javax.xml.bind.JAXBElement$GlobalScope","value":{"description":null,"expression":[{"name":"{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}AttributeDesignator","declaredType":"oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeDesignatorType","scope":"javax.xml.bind.JAXBElement$GlobalScope","value":{"category":"urn:oasis:names:tc:xacml:3.0:attribute-category:environment","attributeId":"urn:oasis:names:tc:xacml:1.0:environment:current-time","dataType":"http://www.w3.org/2001/XMLSchema#time","issuer":null,"mustBePresent":false},"nil":false,"globalScope":true,"typeSubstituted":false}],"functionId":"urn:oasis:names:tc:xacml:1.0:function:time-one-and-only"},"nil":false,"globalScope":true,"typeSubstituted":false},{"name":"{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}AttributeValue","declaredType":"oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeValueType","scope":"javax.xml.bind.JAXBElement$GlobalScope","value":{"content":["5:00"],"dataType":"http://www.w3.org/2001/XMLSchema#time","otherAttributes":{}},"nil":false,"globalScope":true,"typeSubstituted":false},{"name":"{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}AttributeValue","declaredType":"oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeValueType","scope":"javax.xml.bind.JAXBElement$GlobalScope","value":{"content":["10:00"],"dataType":"http://www.w3.org/2001/XMLSchema#time","otherAttributes":{}},"nil":false,"globalScope":true,"typeSubstituted":false}],"functionId":"urn:oasis:names:tc:xacml:2.0:function:time-in-range"},"nil":false,"globalScope":true,"typeSubstituted":false},{"name":"{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Apply","declaredType":"oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType","scope":"javax.xml.bind.JAXBElement$GlobalScope","value":{"description":null,"expression":[{"name":"{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Function","declaredType":"oasis.names.tc.xacml._3_0.core.schema.wd_17.FunctionType","scope":"javax.xml.bind.JAXBElement$GlobalScope","value":{"functionId":"urn:oasis:names:tc:xacml:1.0:function:string-equal"},"nil":false,"globalScope":true,"typeSubstituted":false},{"name":"{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Apply","declaredType":"oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType","scope":"javax.xml.bind.JAXBElement$GlobalScope","value":{"description":null,"expression":[{"name":"{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}AttributeDesignator","declaredType":"oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeDesignatorType","scope":"javax.xml.bind.JAXBElement$GlobalScope","value":{"category":"urn:oasis:names:tc:xacml:3.0:attribute-category:resource","attributeId":"target","dataType":"http://www.w3.org/2001/XMLSchema#string","issuer":null,"mustBePresent":false},"nil":false,"globalScope":true,"typeSubstituted":false}],"functionId":"urn:oasis:names:tc:xacml:1.0:function:string-one-and-only"},"nil":false,"globalScope":true,"typeSubstituted":false},{"name":"{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}Apply","declaredType":"oasis.names.tc.xacml._3_0.core.schema.wd_17.ApplyType","scope":"javax.xml.bind.JAXBElement$GlobalScope","value":{"description":null,"expression":[{"name":"{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}AttributeValue","declaredType":"oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeValueType","scope":"javax.xml.bind.JAXBElement$GlobalScope","value":{"content":["testBL2"],"dataType":"http://www.w3.org/2001/XMLSchema#string","otherAttributes":{}},"nil":false,"globalScope":true,"typeSubstituted":false},{"name":"{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}AttributeValue","declaredType":"oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeValueType","scope":"javax.xml.bind.JAXBElement$GlobalScope","value":{"content":["testBL3"],"dataType":"http://www.w3.org/2001/XMLSchema#string","otherAttributes":{}},"nil":false,"globalScope":true,"typeSubstituted":false},{"name":"{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}AttributeValue","declaredType":"oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeValueType","scope":"javax.xml.bind.JAXBElement$GlobalScope","value":{"content":["testBL4"],"dataType":"http://www.w3.org/2001/XMLSchema#string","otherAttributes":{}},"nil":false,"globalScope":true,"typeSubstituted":false}],"functionId":"urn:oasis:names:tc:xacml:1.0:function:string-bag"},"nil":false,"globalScope":true,"typeSubstituted":false}],"functionId":"urn:oasis:names:tc:xacml:3.0:function:any-of"},"nil":false,"globalScope":true,"typeSubstituted":false}],"functionId":"urn:oasis:names:tc:xacml:1.0:function:and"},"nil":false,"globalScope":true,"typeSubstituted":false}],"functionId":"urn:oasis:names:tc:xacml:1.0:function:not"},"nil":false,"globalScope":true,"typeSubstituted":false}],"functionId":"urn:oasis:names:tc:xacml:1.0:function:not"},"nil":false,"globalScope":true,"typeSubstituted":false}},"obligationExpressions":null,"adviceExpressions":{"adviceExpression":[{"attributeAssignmentExpression":[{"expression":{"name":"{urn:oasis:names:tc:xacml:3.0:core:schema:wd-17}AttributeValue","declaredType":"oasis.names.tc.xacml._3_0.core.schema.wd_17.AttributeValueType","scope":"javax.xml.bind.JAXBElement$GlobalScope","value":{"content":["Denied!"],"dataType":"http://www.w3.org/2001/XMLSchema#string","otherAttributes":{}},"nil":false,"globalScope":true,"typeSubstituted":false},"attributeId":"guard.response","category":"urn:oasis:names:tc:xacml:3.0:attribute-category:resource","issuer":null}],"adviceId":"GUARD_BL_YAML","appliesTo":"DENY"}]},"ruleId":"urn:com:xacml:rule:id:284d9393-f861-4250-b62d-fc36640a363a","effect":"DENY"}],"obligationExpressions":null,"adviceExpressions":null,"policyId":"urn:com:xacml:policy:id:d56af069-6cf1-430c-ba07-e26602e06a52","version":"4","ruleCombiningAlgId":"urn:oasis:names:tc:xacml:3.0:rule-combining-algorithm:permit-overrides","maxDelegationDepth":null},"gitPath":null,"readOnly":false,"configHome":null,"configUrl":null,"finalPolicyPath":null,"version":null,"jsonBody":null,"apiflag":null,"prevJsonBody":null,"highestVersion":null,"entityManagerFactory":null,"policyExists":false,"oldPolicyFileName":"Decision_SampelGuardBLOne","userId":null,"newFileName":null,"clWarning":null,"newCLName":null,"existingCLName":null,"onapNameField":null,"jsonBodyData":null,"dirPath":null,"configBodyPath":null,"attributes":[],"settings":[],"ruleAlgorithmschoices":[],"serviceTypePolicyName":null,"verticaMetrics":null,"description":null,"attributeFields":null,"clearTimeOut":null,"trapMaxAge":null,"verificationclearTimeOut":null,"dynamicLayoutMap":null,"trapDatas":null,"faultDatas":null,"fwPolicyType":null,"fwattributes":null,"parentForChild":null,"securityZone":null,"ruleCombiningAlgId":null,"dynamicFieldConfigAttributes":null,"dynamicSettingsMap":null,"dropDownMap":null,"actionPerformer":null,"actionAttribute":null,"dynamicRuleAlgorithmLabels":null,"dynamicRuleAlgorithmCombo":null,"dynamicRuleAlgorithmField1":null,"dynamicRuleAlgorithmField2":null,"dynamicVariableList":null,"dataTypeList":null,"actionAttributeValue":null,"ruleProvider":"GUARD_BL_YAML","actionBody":null,"actionDictHeader":null,"actionDictType":null,"actionDictUrl":null,"actionDictMethod":null,"yamlparams":{"actor":"testActor","recipe":"testRecipe","clname":"testCLName","limit":null,"timeWindow":null,"timeUnits":null,"guardActiveStart":"5:00","guardActiveEnd":"10:00","blackList":["testBL2","testBL3","testBL4"],"targets":null,"blackListEntryType":"Use Manual Entry"},"blackListEntries":[],"appendBlackListEntries":[],"rainyday":{"serviceType":null,"vnfType":null,"bbid":null,"workstep":null,"treatmentTableChoices":[],"errorcode":null,"treatment":null},"rainydayMap":null,"errorCodeList":null,"treatmentList":null,"serviceType":null,"uuid":null,"location":null,"priority":null,"msLocation":null,"policyJSON":null,"ruleName":null,"brmsParamBody":null,"brmsController":null,"brmsDependency":null,"ruleData":null,"ruleListData":null,"drlRuleAndUIParams":null,"policyScope":null,"providerComboBox":null,"riskType":null,"riskLevel":null,"guard":null,"ttlDate":null,"matching":null,"triggerSignatures":null,"symptomSignatures":null,"logicalConnector":null,"policyStatus":null,"gocServerScope":null,"supressionType":null,"editPolicy":true,"domainDir":"com","validData":false,"draft":false,"viewPolicy":false,"blackListEntryType":"Use Manual Entry"},"date":"2018-03-27 13:36:12.0","version":4}
\ No newline at end of file
diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/std/ManualClientEndDMAAP.java b/PolicyEngineAPI/src/main/java/org/onap/policy/std/ManualClientEndDMAAP.java
index 0281f60..065f084 100644
--- a/PolicyEngineAPI/src/main/java/org/onap/policy/std/ManualClientEndDMAAP.java
+++ b/PolicyEngineAPI/src/main/java/org/onap/policy/std/ManualClientEndDMAAP.java
@@ -3,6 +3,7 @@
  * PolicyEngineAPI
  * ================================================================================
  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Modified Copyright (C) 2018 Samsung Electronics Co., Ltd.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -33,98 +34,103 @@
 import org.onap.policy.xacml.api.XACMLErrorConstants;
 
 public class ManualClientEndDMAAP {
-	private static StdPDPNotification notification = null;
-	private static String resultJson = null;
-	private static Logger logger = FlexLogger.getLogger(ManualClientEndDMAAP.class.getName());
-	private static BusConsumer dmaapConsumer = null;
-	private static String uniquID = null;
-	private static String topic = null;
-	
-	private ManualClientEndDMAAP() {
-		// Empty constructor
-	}
-	
+    private static StdPDPNotification notification = null;
+    private static String resultJson = null;
+    private static Logger logger = FlexLogger.getLogger(ManualClientEndDMAAP.class.getName());
+    private static BusConsumer dmaapConsumer = null;
+    private static String uniquID = null;
+    private static String topic = null;
+    private static int RETRY_LIMIT = 4;
+    private ManualClientEndDMAAP() {
+        // Empty constructor
+    }
 
-	public static PDPNotification result(NotificationScheme scheme) {
-		if (resultJson == null || notification == null) {
-			logger.debug("No Result" );
-			return null;
-		}
-		if(scheme.equals(NotificationScheme.MANUAL_ALL_NOTIFICATIONS)) {
-			boolean removed = false;
-			boolean updated = false; 
-			if(notification.getRemovedPolicies()!=null && !notification.getRemovedPolicies().isEmpty()){
-				removed = true;
-			}
-			if(notification.getLoadedPolicies()!=null && !notification.getLoadedPolicies().isEmpty()){
-				updated = true;
-			}
-			if(removed && updated) {
-				notification.setNotificationType(NotificationType.BOTH);
-			}else if(removed){
-				notification.setNotificationType(NotificationType.REMOVE);
-			}else if(updated){
-				notification.setNotificationType(NotificationType.UPDATE);
-			}
-			return notification;
-		}else if(scheme.equals(NotificationScheme.MANUAL_NOTIFICATIONS)) {
-			return MatchStore.checkMatch(notification);
-		}
-		return null;
-	}
 
-	private static void publishMessage(String pubTopic, String uniqueID, List<String> dmaapList, String aafLogin, String aafPassword) {
+    public static PDPNotification result(NotificationScheme scheme) {
+        if (resultJson == null || notification == null) {
+            logger.debug("No Result" );
+            return null;
+        }
+        if(scheme.equals(NotificationScheme.MANUAL_ALL_NOTIFICATIONS)) {
+            boolean removed = false;
+            boolean updated = false;
+            if(notification.getRemovedPolicies()!=null && !notification.getRemovedPolicies().isEmpty()){
+                removed = true;
+            }
+            if(notification.getLoadedPolicies()!=null && !notification.getLoadedPolicies().isEmpty()){
+                updated = true;
+            }
+            if(removed && updated) {
+                notification.setNotificationType(NotificationType.BOTH);
+            }else if(removed){
+                notification.setNotificationType(NotificationType.REMOVE);
+            }else if(updated){
+                notification.setNotificationType(NotificationType.UPDATE);
+            }
+            return notification;
+        }else if(scheme.equals(NotificationScheme.MANUAL_NOTIFICATIONS)) {
+            return MatchStore.checkMatch(notification);
+        }
+        return null;
+    }
+
+    private static void publishMessage(String pubTopic, String uniqueID, List<String> dmaapList, String aafLogin, String aafPassword) {
         BusPublisher pub = null;
-		try {
-			pub = new BusPublisher.DmaapPublisherWrapper(dmaapList, topic, aafLogin, aafPassword);
-			final JSONObject msg1 = new JSONObject (); 
-	        msg1.put ( "JSON", "DMaaP Update Request UID=" + uniqueID);  
-	        pub.send ( "MyPartitionKey", msg1.toString () );
-		} catch (Exception e) {
-			logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Unable to create DMaaP Publisher: ", e);
-		}
-		if(pub != null){
-	        pub.close (); 
-		}
-	}
+        try {
+            pub = new BusPublisher.DmaapPublisherWrapper(dmaapList, topic, aafLogin, aafPassword);
+            final JSONObject msg1 = new JSONObject ();
+            msg1.put ( "JSON", "DMaaP Update Request UID=" + uniqueID);
+            pub.send ( "MyPartitionKey", msg1.toString () );
+        } catch (Exception e) {
+            logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Unable to create DMaaP Publisher: ", e);
+        }
+        if(pub != null){
+            pub.close ();
+        }
+    }
 
-	//NOTE:  should be able to remove this for DMAAP since we will not be creating topics dynamically
-	public static void createTopic (String topic, String uniquID, List<String> dmaapList, String aafLogin, String aafPassword){
-		ManualClientEndDMAAP.topic = topic;
-		publishMessage(topic, uniquID, dmaapList, aafLogin, aafPassword);
-	}
-	
-	
-	public static void start(List<String> dmaapList, String topic, String aafLogin, String aafPassword, String uniqueID) {
-		
-		ManualClientEndDMAAP.uniquID = uniqueID;
-		ManualClientEndDMAAP.topic = topic;
-		
-		String id = "0";
-		
-		try {
-			dmaapConsumer = new BusConsumer.DmaapConsumerWrapper(dmaapList, topic, aafLogin, aafPassword, "clientGroup", id, 15*1000, 1000);
-		} catch (Exception e) {
-			logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Unable to create DMaaP Consumer: ", e);
-		}
-		
-		int count = 1;
-		while (count < 4) {
-				publishMessage(topic, uniquID, dmaapList, aafLogin, aafPassword);
-				try {
-					for ( String msg : dmaapConsumer.fetch () )
-					{	
-						logger.debug("Manual Notification Recieved Message " + msg + " from DMaaP server : " + dmaapList.toString());
-						resultJson = msg;
-						if (!msg.contains("DMaaP Update")){
-							notification = NotificationUnMarshal.notificationJSON(msg);
-							count = 4;
-						}
-					}
-				}catch (Exception e) {
-					logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Unable to fetch messages from DMaaP servers: ", e);
-				} 
-				count++;
-			}		
-	}
+    //NOTE:  should be able to remove this for DMAAP since we will not be creating topics dynamically
+    public static void createTopic (String topic, String uniquID, List<String> dmaapList, String aafLogin, String aafPassword){
+        ManualClientEndDMAAP.topic = topic;
+        publishMessage(topic, uniquID, dmaapList, aafLogin, aafPassword);
+    }
+
+
+    public static void start(List<String> dmaapList, String topic, String aafLogin, String aafPassword, String uniqueID) {
+
+        ManualClientEndDMAAP.uniquID = uniqueID;
+        ManualClientEndDMAAP.topic = topic;
+
+        String id = "0";
+
+        try {
+            dmaapConsumer = new BusConsumer.DmaapConsumerWrapper(dmaapList, topic, aafLogin, aafPassword, "clientGroup", id, 15*1000, 1000);
+        } catch (Exception e) {
+            logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Unable to create DMaaP Consumer: ", e);
+        }
+
+        int retries = 1;
+        boolean isSuccess = false;
+        while (retries < RETRY_LIMIT && !isSuccess) {
+            isSuccess = publishMessageAndSetNotification(dmaapList, topic, aafLogin, aafPassword);
+            retries++;
+        }
+    }
+
+    private static boolean publishMessageAndSetNotification(List<String> dmaapList, String topic, String aafLogin, String aafPassword) {
+        publishMessage(topic, uniquID, dmaapList, aafLogin, aafPassword);
+        try {
+            for ( String msg : dmaapConsumer.fetch () ) {
+                logger.debug("Manual Notification Recieved Message " + msg + " from DMaaP server : " + dmaapList.toString());
+                resultJson = msg;
+                if (!msg.contains("DMaaP Update")){
+                    notification = NotificationUnMarshal.notificationJSON(msg);
+                    return true;
+                }
+            }
+        }catch (Exception e) {
+            logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Unable to fetch messages from DMaaP servers: ", e);
+        }
+        return false;
+    }
 }
diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/std/ManualClientEndUEB.java b/PolicyEngineAPI/src/main/java/org/onap/policy/std/ManualClientEndUEB.java
index c04736e..d67e136 100644
--- a/PolicyEngineAPI/src/main/java/org/onap/policy/std/ManualClientEndUEB.java
+++ b/PolicyEngineAPI/src/main/java/org/onap/policy/std/ManualClientEndUEB.java
@@ -3,6 +3,7 @@
  * PolicyEngineAPI
  * ================================================================================
  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Modified Copyright (C) 2018 Samsung Electronics Co., Ltd.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -39,123 +40,127 @@
 
 @SuppressWarnings("deprecation")
 public class ManualClientEndUEB {
-	private static StdPDPNotification notification = null;
-	private static String resultJson = null;
-	private static Logger logger = FlexLogger.getLogger(ManualClientEndUEB.class.getName());
-	private static CambriaConsumer CConsumer = null;
-	@SuppressWarnings("unused")
-	private static List<String> uebURLList = null; 
-	@SuppressWarnings("unused")
-	private static boolean messageNotReceived = false;
-	@SuppressWarnings("unused")
-	private static String url = null;
-	private static String uniquID = null;
-	private static String topic = null;
+    private static StdPDPNotification notification = null;
+    private static String resultJson = null;
+    private static Logger logger = FlexLogger.getLogger(ManualClientEndUEB.class.getName());
+    private static CambriaConsumer CConsumer = null;
+    @SuppressWarnings("unused")
+    private static List<String> uebURLList = null;
+    @SuppressWarnings("unused")
+    private static boolean messageNotReceived = false;
+    @SuppressWarnings("unused")
+    private static String url = null;
+    private static String uniquID = null;
+    private static String topic = null;
+    private static int RETRY_LIMIT = 4;
 
-	private ManualClientEndUEB() {
-		// Empty constructor
-	}
+    private ManualClientEndUEB() {
+        // Empty constructor
+    }
 
-	public static PDPNotification result(NotificationScheme scheme) {
-		if (resultJson == null || notification == null) {
-			logger.debug("No Result" );
-			return null;
-		}
-		if(scheme.equals(NotificationScheme.MANUAL_ALL_NOTIFICATIONS)) {
-			boolean removed = false;
-			boolean updated = false; 
-			if(notification.getRemovedPolicies()!=null && !notification.getRemovedPolicies().isEmpty()){
-				removed = true;
-			}
-			if(notification.getLoadedPolicies()!=null && !notification.getLoadedPolicies().isEmpty()){
-				updated = true;
-			}
-			if(removed && updated) {
-				notification.setNotificationType(NotificationType.BOTH);
-			}else if(removed){
-				notification.setNotificationType(NotificationType.REMOVE);
-			}else if(updated){
-				notification.setNotificationType(NotificationType.UPDATE);
-			}
-			return notification;
-		}else if(scheme.equals(NotificationScheme.MANUAL_NOTIFICATIONS)) {
-			return MatchStore.checkMatch(notification);
-		}
-		return null;
-	}
+    public static PDPNotification result(NotificationScheme scheme) {
+        if (resultJson == null || notification == null) {
+            logger.debug("No Result" );
+            return null;
+        }
+        if(scheme.equals(NotificationScheme.MANUAL_ALL_NOTIFICATIONS)) {
+            boolean removed = false;
+            boolean updated = false;
+            if(notification.getRemovedPolicies()!=null && !notification.getRemovedPolicies().isEmpty()){
+                removed = true;
+            }
+            if(notification.getLoadedPolicies()!=null && !notification.getLoadedPolicies().isEmpty()){
+                updated = true;
+            }
+            if(removed && updated) {
+                notification.setNotificationType(NotificationType.BOTH);
+            }else if(removed){
+                notification.setNotificationType(NotificationType.REMOVE);
+            }else if(updated){
+                notification.setNotificationType(NotificationType.UPDATE);
+            }
+            return notification;
+        }else if(scheme.equals(NotificationScheme.MANUAL_NOTIFICATIONS)) {
+            return MatchStore.checkMatch(notification);
+        }
+        return null;
+    }
 
-	private static void publishMessage(String pubTopic, String uniqueID , List<String> uebURLList) {
-		
-		String UEBlist = uebURLList.toString();
-		UEBlist = UEBlist.substring(1,UEBlist.length()-1);
+    private static void publishMessage(String pubTopic, String uniqueID , List<String> uebURLList) {
+
+        String UEBlist = uebURLList.toString();
+        UEBlist = UEBlist.substring(1,UEBlist.length()-1);
         CambriaPublisher pub = null;
-		try {
-			pub = CambriaClientFactory.createSimplePublisher(null, UEBlist, pubTopic);
-		} catch (Exception e1) {
-			logger.error("Exception Occured"+e1);
-		}
+        try {
+            pub = CambriaClientFactory.createSimplePublisher(null, UEBlist, pubTopic);
+        } catch (Exception e1) {
+            logger.error("Exception Occured"+e1);
+        }
         final JSONObject msg1 = new JSONObject (); 
 
         msg1.put ( "JSON", "UEB Update Ruest UID=" + uniqueID);  
         if(pub != null){
-        	 try {
-     			pub.send ( "MyPartitionKey", msg1.toString () );
-     			pub.close (); 	
-     		} catch (IOException e) {
-     			logger.error("Exception Occured"+e);
-     		}
+             try {
+                pub.send ( "MyPartitionKey", msg1.toString () );
+                pub.close ();
+            } catch (IOException e) {
+                logger.error("Exception Occured"+e);
+            }
         }	
-	}
+    }
 
-	public static void createTopic (String url, String uniquID, List<String> uebURLList){
-		URL aURL;
-		try {
-			aURL = new URL(url);
-			topic = aURL.getHost() + aURL.getPort();
-		} catch (MalformedURLException e) {
-			topic = url.replace("[:/]", "");
-		}
+    public static void createTopic (String url, String uniquID, List<String> uebURLList){
+        URL aURL;
+        try {
+            aURL = new URL(url);
+            topic = aURL.getHost() + aURL.getPort();
+        } catch (MalformedURLException e) {
+            topic = url.replace("[:/]", "");
+        }
 
-		publishMessage(topic+ uniquID , uniquID, uebURLList);
-		
-	}
-	public static void start(String url, List<String> uebURLList,
-			String uniqueID) {
-		ManualClientEndUEB.uebURLList  = uebURLList;
-		ManualClientEndUEB.url = url;
-		ManualClientEndUEB.uniquID = uniqueID;
-		URL aURL;
-		try {
-			aURL = new URL(url);
-			ManualClientEndUEB.topic = aURL.getHost() + aURL.getPort();
-		} catch (MalformedURLException e) {
-			ManualClientEndUEB.topic = url.replace("[:/]", "");
-		}
-		String id = "0";
-		try {
-			CConsumer = CambriaClientFactory.createConsumer ( null, uebURLList, topic + uniquID, "clientGroup", id, 15*1000, 1000 );
-		} catch (Exception e1) {
-			logger.error("Exception Occured"+e1);
-		} 		
-		int count = 1;
-		while (count < 4) {
-				publishMessage(topic + "UpdateRequest", uniquID, uebURLList);
-				try {
-					for ( String msg : CConsumer.fetch () )
-					{	
-						
-						logger.debug("Manual Notification Recieved Message " + msg + " from UEB cluster : " + uebURLList.toString());
-						resultJson = msg;
-						if (!msg.contains("UEB Update")){
-							notification = NotificationUnMarshal.notificationJSON(msg);
-							count = 4;
-						}
-					}
-				}catch (Exception e) {
-					logger.error("Error in Manual CLient UEB notification ", e);
-				} 
-				count++;
-			}		
-	}
-	
+        publishMessage(topic+ uniquID , uniquID, uebURLList);
+
+    }
+    public static void start(String url, List<String> uebURLList,
+            String uniqueID) {
+        ManualClientEndUEB.uebURLList  = uebURLList;
+        ManualClientEndUEB.url = url;
+        ManualClientEndUEB.uniquID = uniqueID;
+        URL aURL;
+        try {
+            aURL = new URL(url);
+            ManualClientEndUEB.topic = aURL.getHost() + aURL.getPort();
+        } catch (MalformedURLException e) {
+            ManualClientEndUEB.topic = url.replace("[:/]", "");
+        }
+        String id = "0";
+        try {
+            CConsumer = CambriaClientFactory.createConsumer ( null, uebURLList, topic + uniquID, "clientGroup", id, 15*1000, 1000 );
+        } catch (Exception e1) {
+            logger.error("Exception Occured"+e1);
+        }
+        int retries = 1;
+        boolean isSuccess = false;
+        while (retries < RETRY_LIMIT && !isSuccess) {
+            isSuccess = publishMessageAndSetNotification(uebURLList);
+            retries++;
+        }
+    }
+
+    private static boolean publishMessageAndSetNotification(List<String> uebURLList) {
+        publishMessage(topic + "UpdateRequest", uniquID, uebURLList);
+        try {
+            for ( String msg : CConsumer.fetch () ) {
+                logger.debug("Manual Notification Recieved Message " + msg + " from UEB cluster : " + uebURLList.toString());
+                resultJson = msg;
+                if (!msg.contains("UEB Update")){
+                    notification = NotificationUnMarshal.notificationJSON(msg);
+                    return true;
+                }
+            }
+        }catch (Exception e) {
+            logger.error("Error in Manual CLient UEB notification ", e);
+        }
+        return false;
+    }
 }
diff --git a/PolicyEngineAPI/src/main/java/org/onap/policy/std/StdPolicyEngine.java b/PolicyEngineAPI/src/main/java/org/onap/policy/std/StdPolicyEngine.java
index f09b577..8f3cf04 100644
--- a/PolicyEngineAPI/src/main/java/org/onap/policy/std/StdPolicyEngine.java
+++ b/PolicyEngineAPI/src/main/java/org/onap/policy/std/StdPolicyEngine.java
@@ -3,6 +3,7 @@
  * PolicyEngineAPI
  * ================================================================================
  * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Modified Copyright (C) 2018 Samsung Electronics Co., Ltd.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -348,7 +349,7 @@
         return deletePolicyImpl(parameters);
     }
 
-    public PolicyChangeResponse deletePolicyImpl(final DeletePolicyParameters parameters) throws PolicyException {
+    private PolicyChangeResponse deletePolicyImpl(final DeletePolicyParameters parameters) throws PolicyException {
         final StdPolicyChangeResponse response = new StdPolicyChangeResponse();
         String body = null;
         // Create Request.
@@ -379,7 +380,7 @@
         return getDictionaryItemImpl(parameters);
     }
 
-    public DictionaryResponse getDictionaryItemImpl(final DictionaryParameters parameters) throws PolicyException {
+    private DictionaryResponse getDictionaryItemImpl(final DictionaryParameters parameters) throws PolicyException {
         final StdDictionaryResponse response = new StdDictionaryResponse();
         String body = "{}";
         // Create Request.
@@ -450,7 +451,7 @@
         return createUpdateDictionaryItemImpl(parameters, true);
     }
 
-    public PolicyChangeResponse createUpdateDictionaryItemImpl(final DictionaryParameters parameters,
+    private PolicyChangeResponse createUpdateDictionaryItemImpl(final DictionaryParameters parameters,
             final boolean updateFlag) throws PolicyException {
 
         final String resource = getDictionaryResouceName(updateFlag);
@@ -487,7 +488,7 @@
         return policyEngineImportImpl(importParameters);
     }
 
-    public PolicyChangeResponse policyEngineImportImpl(final ImportParameters importParameters) throws PolicyException {
+    private PolicyChangeResponse policyEngineImportImpl(final ImportParameters importParameters) throws PolicyException {
         final LinkedMultiValueMap<String, Object> parameters = new LinkedMultiValueMap<>();
         // Create Request.
         try {
@@ -530,7 +531,7 @@
         return createUpdatePolicyImpl(policyParameters, true);
     }
 
-    public PolicyChangeResponse createUpdatePolicyImpl(final PolicyParameters policyParameters,
+    private PolicyChangeResponse createUpdatePolicyImpl(final PolicyParameters policyParameters,
             final boolean updateFlag) throws PolicyException {
         final String resource = getPolicyResourceName(updateFlag);
         String body = null;
@@ -575,7 +576,7 @@
         }
     }
 
-    public DecisionResponse getDecisionImpl(final String onapName, final Map<String, String> decisionAttributes,
+    private DecisionResponse getDecisionImpl(final String onapName, final Map<String, String> decisionAttributes,
             final UUID requestID) throws PolicyDecisionException {
         String body = null;
         // Create Request.
@@ -604,7 +605,7 @@
         }
     }
 
-    public Collection<PolicyConfig> getConfigImpl(final ConfigRequestParameters configRequestParameters)
+    private Collection<PolicyConfig> getConfigImpl(final ConfigRequestParameters configRequestParameters)
             throws PolicyConfigException {
         String body = null;
         // Create Request.
@@ -632,51 +633,53 @@
     private ArrayList<PolicyConfig> configResult(final APIPolicyConfigResponse[] response)
             throws PolicyConfigException {
         final ArrayList<PolicyConfig> result = new ArrayList<>();
-        if (response != null) {
-            for (final APIPolicyConfigResponse policyConfigResponse : response) {
-                final StdPolicyConfig policyConfig = new StdPolicyConfig();
-                policyConfig.setConfigStatus(policyConfigResponse.getPolicyConfigMessage());
-                policyConfig.setMatchingConditions(policyConfigResponse.getMatchingConditions());
-                policyConfig.setPolicyConfigStatus(policyConfigResponse.getPolicyConfigStatus());
-                policyConfig.setPolicyName(policyConfigResponse.getPolicyName());
-                policyConfig.setPolicyType(policyConfigResponse.getType());
-                policyConfig.setPolicyVersion(policyConfigResponse.getPolicyVersion());
-                policyConfig.setPolicyType(policyConfigResponse.getPolicyType());
-                policyConfig.setResponseAttributes(policyConfigResponse.getResponseAttributes());
-                setMatches(policyConfig.getMatchingConditions());
-                if (policyConfigResponse.getType() != null) {
-                    try {
-                        switch (policyConfigResponse.getType()) {
-                            case JSON:
-                                final StringReader reader = new StringReader(policyConfigResponse.getConfig());
-                                try (final JsonReader jsonReader = Json.createReader(reader)) {
-                                    final JsonObject object = jsonReader.readObject();
-                                    policyConfig.setJsonObject(object);
-                                }
-                                break;
-                            case OTHER:
-                                policyConfig.setOther(policyConfigResponse.getConfig());
-                                break;
-                            case PROPERTIES:
-                                final Properties props = new Properties();
-                                props.putAll(policyConfigResponse.getProperty());
-                                policyConfig.setProperties(props);
-                                break;
-                            case XML:
-                                final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
-                                final DocumentBuilder builder = factory.newDocumentBuilder();
-                                final StringReader stringReader = new StringReader(policyConfigResponse.getConfig());
-                                policyConfig.setDocument(builder.parse(new InputSource(stringReader)));
-                                break;
-                        }
-                    } catch (final Exception exception) {
-                        LOGGER.error(XACMLErrorConstants.ERROR_SCHEMA_INVALID + exception);
-                        throw new PolicyConfigException(
-                                XACMLErrorConstants.ERROR_SCHEMA_INVALID + "Unable to parse the config", exception);
+        if (response == null) {
+            return result;
+        }
+
+        for (final APIPolicyConfigResponse policyConfigResponse : response) {
+            final StdPolicyConfig policyConfig = new StdPolicyConfig();
+            policyConfig.setConfigStatus(policyConfigResponse.getPolicyConfigMessage());
+            policyConfig.setMatchingConditions(policyConfigResponse.getMatchingConditions());
+            policyConfig.setPolicyConfigStatus(policyConfigResponse.getPolicyConfigStatus());
+            policyConfig.setPolicyName(policyConfigResponse.getPolicyName());
+            policyConfig.setPolicyType(policyConfigResponse.getType());
+            policyConfig.setPolicyVersion(policyConfigResponse.getPolicyVersion());
+            policyConfig.setPolicyType(policyConfigResponse.getPolicyType());
+            policyConfig.setResponseAttributes(policyConfigResponse.getResponseAttributes());
+            setMatches(policyConfig.getMatchingConditions());
+            if (policyConfigResponse.getType() != null) {
+                try {
+                    switch (policyConfigResponse.getType()) {
+                        case JSON:
+                            final StringReader reader = new StringReader(policyConfigResponse.getConfig());
+                            try (final JsonReader jsonReader = Json.createReader(reader)) {
+                                final JsonObject object = jsonReader.readObject();
+                                policyConfig.setJsonObject(object);
+                            }
+                            break;
+                        case OTHER:
+                            policyConfig.setOther(policyConfigResponse.getConfig());
+                            break;
+                        case PROPERTIES:
+                            final Properties props = new Properties();
+                            props.putAll(policyConfigResponse.getProperty());
+                            policyConfig.setProperties(props);
+                            break;
+                        case XML:
+                            final DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
+                            final DocumentBuilder builder = factory.newDocumentBuilder();
+                            final StringReader stringReader = new StringReader(policyConfigResponse.getConfig());
+                            policyConfig.setDocument(builder.parse(new InputSource(stringReader)));
+                            break;
                     }
+                } catch (final Exception exception) {
+                    LOGGER.error(XACMLErrorConstants.ERROR_SCHEMA_INVALID + exception);
+                    throw new PolicyConfigException(
+                            XACMLErrorConstants.ERROR_SCHEMA_INVALID + "Unable to parse the config", exception);
                 }
-                result.add(policyConfig);
             }
+            result.add(policyConfig);
         }
         return result;
     }
@@ -774,7 +777,7 @@
         clientEncoding = encoder.encodeToString((userName + ":" + pass).getBytes(StandardCharsets.UTF_8));
     }
 
-    public Collection<String> listConfigImpl(final ConfigRequestParameters listRequestParameters)
+    private Collection<String> listConfigImpl(final ConfigRequestParameters listRequestParameters)
             throws PolicyConfigException {
         final Collection<String> policyList = new ArrayList<>();
         if (junit) {
@@ -792,7 +795,7 @@
         return policyList;
     }
 
-    public Collection<PolicyResponse> sendEventImpl(final Map<String, String> eventAttributes, final UUID requestID)
+    private Collection<PolicyResponse> sendEventImpl(final Map<String, String> eventAttributes, final UUID requestID)
             throws PolicyEventException {
         String body = null;
         // Create Request.
@@ -864,7 +867,7 @@
         apiKey = properties.getProperty(UEB_API_KEY_PROP_NAME);
         apiSecret = properties.getProperty(UEB_API_SECRET_PROP_NAME);
 
-        setNotificationType(notificationTypeValue, DEFAULT_NOTIFICATION);
+        setNotificationType(notificationTypeValue);
 
         if (serverList == null) {
             notificationType.clear();
@@ -872,7 +875,7 @@
             LOGGER.info(
                     "Properties file doesn't have the NOTIFICATION_SERVERS parameter system will use defualt websockets");
         } else {
-            notificationURLList = getPropertyValueAsList(serverList.trim(), COMMA);
+            notificationURLList = getPropertyValueAsList(serverList.trim());
         }
 
         if (topic != null) {
@@ -907,19 +910,7 @@
         // Check the Keys for PDP_URLs
         for (final String propertyKey : prop.stringPropertyNames()) {
             if (propertyKey.startsWith(PDP_URL_PROP_NAME)) {
-                final String propertyValue = prop.getProperty(propertyKey);
-                if (propertyValue == null) {
-                    throw new PolicyEngineException(XACMLErrorConstants.ERROR_DATA_ISSUE
-                            + "Properties file doesn't have the PDP_URL parameter");
-                }
-                if (propertyValue.contains(SEMICOLLON)) {
-                    final List<String> pdpDefault = Arrays.asList(propertyValue.split(REGEX));
-                    for (final String pdpVal : pdpDefault) {
-                        readPDPParam(pdpVal);
-                    }
-                } else {
-                    readPDPParam(propertyValue);
-                }
+                readPDPPropertyURL(prop, propertyKey);
             }
         }
         if (pdps == null || pdps.isEmpty()) {
@@ -928,13 +919,29 @@
         }
     }
 
-    private void setNotificationType(final String propertyValue, final String defaultValue) {
+    private void readPDPPropertyURL(Properties prop, String propertyKey) throws PolicyEngineException {
+        final String propertyValue = prop.getProperty(propertyKey);
         if (propertyValue == null) {
-            notificationType.add(defaultValue);
+            throw new PolicyEngineException(XACMLErrorConstants.ERROR_DATA_ISSUE
+                    + "Properties file doesn't have the PDP_URL parameter");
+        }
+        if (propertyValue.contains(SEMICOLLON)) {
+            final List<String> pdpDefault = Arrays.asList(propertyValue.split(REGEX));
+            for (final String pdpVal : pdpDefault) {
+                readPDPParam(pdpVal);
+            }
+        } else {
+            readPDPParam(propertyValue);
+        }
+    }
+
+    private void setNotificationType(final String propertyValue) {
+        if (propertyValue == null) {
+            notificationType.add(DEFAULT_NOTIFICATION);
             LOGGER.info(
                     "Properties file doesn't have the NOTIFICATION_TYPE parameter system will use defualt websockets");
         } else {
-            notificationType = getPropertyValueAsList(propertyValue.trim(), COMMA);
+            notificationType = getPropertyValueAsList(propertyValue.trim());
         }
     }
 
@@ -992,9 +999,9 @@
         }
     }
 
-    private List<String> getPropertyValueAsList(final String propertyValue, final String split) {
-        if (propertyValue.contains(split)) {
-            return Arrays.asList(propertyValue.split(split));
+    private List<String> getPropertyValueAsList(final String propertyValue) {
+        if (propertyValue.contains(COMMA)) {
+            return Arrays.asList(propertyValue.split(COMMA));
         }
         final List<String> valuesList = new ArrayList<>();
         valuesList.add(propertyValue);
@@ -1087,28 +1094,29 @@
         if (junit) {
             return;
         }
+        if (pdps == null) {
+            return;
+        }
 
-        if (pdps != null) {
-            if (UEB.equals(notificationType.get(0)) && !this.uebThread) {
-                this.uebClientThread = new AutoClientUEB(pdps.get(0), notificationURLList, apiKey, apiSecret);
-                AutoClientUEB.setAuto(scheme, handler);
-                this.registerUEBThread = new Thread(this.uebClientThread);
-                this.registerUEBThread.start();
-                this.uebThread = true;
-            } else if (notificationType.get(0).equals(DMAAP) && !this.dmaapThread) {
-                this.dmaapClientThread = new AutoClientDMAAP(notificationURLList, topic, userName, pass);
-                AutoClientDMAAP.setAuto(scheme, handler);
-                this.registerDMAAPThread = new Thread(this.dmaapClientThread);
-                this.registerDMAAPThread.start();
-                this.dmaapThread = true;
-            } else {
-                if (pdps.get(0) != null) {
-                    if (AutoClientEnd.getUrl() == null) {
-                        AutoClientEnd.start(pdps.get(0));
-                    } else {
-                        AutoClientEnd.stop();
-                        AutoClientEnd.start(pdps.get(0));
-                    }
+        if (UEB.equals(notificationType.get(0)) && !this.uebThread) {
+            this.uebClientThread = new AutoClientUEB(pdps.get(0), notificationURLList, apiKey, apiSecret);
+            AutoClientUEB.setAuto(scheme, handler);
+            this.registerUEBThread = new Thread(this.uebClientThread);
+            this.registerUEBThread.start();
+            this.uebThread = true;
+        } else if (notificationType.get(0).equals(DMAAP) && !this.dmaapThread) {
+            this.dmaapClientThread = new AutoClientDMAAP(notificationURLList, topic, userName, pass);
+            AutoClientDMAAP.setAuto(scheme, handler);
+            this.registerDMAAPThread = new Thread(this.dmaapClientThread);
+            this.registerDMAAPThread.start();
+            this.dmaapThread = true;
+        } else {
+            if (pdps.get(0) != null) {
+                if (AutoClientEnd.getUrl() == null) {
+                    AutoClientEnd.start(pdps.get(0));
+                } else {
+                    AutoClientEnd.stop();
+                    AutoClientEnd.start(pdps.get(0));
                 }
             }
         }
@@ -1227,7 +1235,7 @@
     /*
      * Create Config Policy API Implementation
      */
-    public String createUpdateConfigPolicyImpl(final String policyName, final String policyDescription,
+    private String createUpdateConfigPolicyImpl(final String policyName, final String policyDescription,
             final String onapName, final String configName, final Map<String, String> configAttributes,
             final String configType, final String body, final String policyScope, final UUID requestID,
             final String riskLevel, final String riskType, final String guard, final String ttlDate,
@@ -1276,7 +1284,7 @@
     /*
      * Create Update Config Firewall Policy API implementation
      */
-    public String createUpdateConfigFirewallPolicyImpl(final String policyName, final JsonObject firewallJson,
+    private String createUpdateConfigFirewallPolicyImpl(final String policyName, final JsonObject firewallJson,
             final String policyScope, final UUID requestID, final String riskLevel, final String riskType,
             final String guard, final String ttlDate, final boolean updateFlag) throws PolicyException {
         validateParameters(policyName, policyScope);
diff --git a/PolicyEngineUtils/src/main/java/org/onap/policy/std/NotificationStore.java b/PolicyEngineUtils/src/main/java/org/onap/policy/std/NotificationStore.java
index 24e1263..6164418 100644
--- a/PolicyEngineUtils/src/main/java/org/onap/policy/std/NotificationStore.java
+++ b/PolicyEngineUtils/src/main/java/org/onap/policy/std/NotificationStore.java
@@ -3,6 +3,7 @@
  * PolicyEngineUtils
  * ================================================================================
  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Modified Copyright (C) 2018 Samsung Electronics Co., Ltd.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -41,8 +42,8 @@
     private static StdPDPNotification notificationRecord = new StdPDPNotification();
 
     private NotificationStore () {
-    	// Sonar prefers that we have an empty public constructor
-    	// as opposed to an implicit public constructor.
+        // Sonar prefers that we have an empty public constructor
+        // as opposed to an implicit public constructor.
     }
     
     public static StdPDPNotification getDeltaNotification(StdPDPNotification newNotification) {
@@ -63,195 +64,218 @@
             }
             return notificationDelta;
         }
+
+        if (newNotification == null) {
+            return notificationDelta;
+        }
         // do the Delta operation.
-        if (newNotification != null) {
-            // check for old removed policies.
-            if (!newNotification.getRemovedPolicies().isEmpty()) {
-                for (RemovedPolicy newRemovedPolicy : newNotification.getRemovedPolicies()) {
-                    //Look for policy Not in Remove
-                    Boolean removed = true;
-                    String policyName = newRemovedPolicy.getPolicyName();
-                    String ver = newRemovedPolicy.getVersionNo();
-                    for (RemovedPolicy oldRemovedPolicy : notificationRecord.getRemovedPolicies()) {
-                        if (policyName.equals(oldRemovedPolicy.getPolicyName())
-                            && ver.equals(oldRemovedPolicy.getVersionNo())) {
-                            removed = false;
-                            // Don't want a duplicate.
-                            oldRemovedPolicies.remove(oldRemovedPolicy);
-                        }
-                    }
-                    //We need to change our record we have an Update record of this remove.
-                    for (LoadedPolicy oldUpdatedPolicy : notificationRecord.getLoadedPolicies()) {
-                        if (policyName.equals(oldUpdatedPolicy.getPolicyName())
-                            && ver.equals(oldUpdatedPolicy.getVersionNo())) {
-                            oldUpdatedPolicies.remove(oldUpdatedPolicy);
-                            oldUpdatedLostPolicies.remove(oldUpdatedPolicy);
-                        }
-                    }
-                    if (removed) {
-                        remove = true;
-                        notificationRecord.getRemovedPolicies().add(newRemovedPolicy);
-                        removedDelta.add((StdRemovedPolicy) newRemovedPolicy);
-                    }
-                    // This will be converted to New Later.
-                    oldRemovedPolicies.add(newRemovedPolicy);
-                }
-            }
-            // Check for old Updated Policies.
-            if (!newNotification.getLoadedPolicies().isEmpty()) {
-                for (LoadedPolicy newUpdatedPolicy : newNotification.getLoadedPolicies()) {
-                    // Look for policies which are not in Update
-                    Boolean updated = true;
-                    String policyName = newUpdatedPolicy.getPolicyName();
-                    String ver = newUpdatedPolicy.getVersionNo();
-                    for (LoadedPolicy oldUpdatedPolicy : notificationRecord.getLoadedPolicies()) {
-                        if (policyName.equals(oldUpdatedPolicy.getPolicyName())
-                            && ver.equals(oldUpdatedPolicy.getVersionNo())) {
-                            updated = false;
-                            // Remove the policy from copy.
-                            oldUpdatedLostPolicies.remove(oldUpdatedPolicy);
-                            // Eliminating Duplicate.
-                            oldUpdatedPolicies.remove(oldUpdatedPolicy);
-                        }
-                    }
-                    // Change the record if the policy has been Removed earlier.
-                    for (RemovedPolicy oldRemovedPolicy : notificationRecord.getRemovedPolicies()) {
-                        if (oldRemovedPolicy.getPolicyName().equals(policyName)
-                            && oldRemovedPolicy.getVersionNo().equals(ver)) {
-                            oldRemovedPolicies.remove(oldRemovedPolicy);
-                        }
-                    }
-                    if (updated) {
-                        update = true;
-                        updatedDelta.add((StdLoadedPolicy) newUpdatedPolicy);
-                    }
-                    // This will be converted to new Later
-                    oldUpdatedPolicies.add(newUpdatedPolicy);
-                }
-                // Conversion of Update to Remove if that occurred.
-                if (!oldUpdatedLostPolicies.isEmpty()) {
-                    for (LoadedPolicy updatedPolicy : oldUpdatedLostPolicies) {
-                        StdRemovedPolicy removedPolicy = new StdRemovedPolicy();
-                        removedPolicy.setPolicyName(updatedPolicy.getPolicyName());
-                        removedPolicy.setVersionNo(updatedPolicy.getVersionNo());
-                        removedDelta.add(removedPolicy);
-                        remove = true;
-                    }
-                }
-            }
-            // Update our Record.
-            if (!oldUpdatedPolicies.isEmpty()) {
-                for (LoadedPolicy updatedPolicy : oldUpdatedPolicies) {
-                    newUpdatedPolicies.add((StdLoadedPolicy) updatedPolicy);
-                }
-            }
-            if (!oldRemovedPolicies.isEmpty()) {
-                for (RemovedPolicy removedPolicy : oldRemovedPolicies) {
-                    newRemovedPolicies.add((StdRemovedPolicy) removedPolicy);
-                }
-            }
-            notificationRecord.setRemovedPolicies(newRemovedPolicies);
-            notificationRecord.setLoadedPolicies(newUpdatedPolicies);
-            // Update the notification Result.
-            notificationDelta.setRemovedPolicies(removedDelta);
-            notificationDelta.setLoadedPolicies(updatedDelta);
-            if (remove && update) {
-                notificationDelta.setNotificationType(NotificationType.BOTH);
-            } else if (remove) {
-                notificationDelta.setNotificationType(NotificationType.REMOVE);
-            } else if (update) {
-                notificationDelta.setNotificationType(NotificationType.UPDATE);
+        // check for old removed policies.
+        if (!newNotification.getRemovedPolicies().isEmpty()) {
+            for (RemovedPolicy newRemovedPolicy : newNotification.getRemovedPolicies()) {
+                remove = updateRemovedPolicies(removedDelta, oldUpdatedLostPolicies, oldRemovedPolicies, oldUpdatedPolicies, remove, newRemovedPolicy);
             }
         }
+        // Check for old Updated Policies.
+        if (!newNotification.getLoadedPolicies().isEmpty()) {
+            for (LoadedPolicy newUpdatedPolicy : newNotification.getLoadedPolicies()) {
+                update = modifyUpdatedPolicies(updatedDelta, oldUpdatedLostPolicies, oldRemovedPolicies, oldUpdatedPolicies, update, newUpdatedPolicy);
+            }
+            // Conversion of Update to Remove if that occurred.
+            if (!oldUpdatedLostPolicies.isEmpty()) {
+                for (LoadedPolicy updatedPolicy : oldUpdatedLostPolicies) {
+                    StdRemovedPolicy removedPolicy = new StdRemovedPolicy();
+                    removedPolicy.setPolicyName(updatedPolicy.getPolicyName());
+                    removedPolicy.setVersionNo(updatedPolicy.getVersionNo());
+                    removedDelta.add(removedPolicy);
+                    remove = true;
+                }
+            }
+        }
+        // Update our Record.
+        if (!oldUpdatedPolicies.isEmpty()) {
+            for (LoadedPolicy updatedPolicy : oldUpdatedPolicies) {
+                newUpdatedPolicies.add((StdLoadedPolicy) updatedPolicy);
+            }
+        }
+        if (!oldRemovedPolicies.isEmpty()) {
+            for (RemovedPolicy removedPolicy : oldRemovedPolicies) {
+                newRemovedPolicies.add((StdRemovedPolicy) removedPolicy);
+            }
+        }
+        notificationRecord.setRemovedPolicies(newRemovedPolicies);
+        notificationRecord.setLoadedPolicies(newUpdatedPolicies);
+        // Update the notification Result.
+        notificationDelta.setRemovedPolicies(removedDelta);
+        notificationDelta.setLoadedPolicies(updatedDelta);
+        if (remove && update) {
+            notificationDelta.setNotificationType(NotificationType.BOTH);
+        } else if (remove) {
+            notificationDelta.setNotificationType(NotificationType.REMOVE);
+        } else if (update) {
+            notificationDelta.setNotificationType(NotificationType.UPDATE);
+        }
+
         return notificationDelta;
     }
 
+    private static Boolean modifyUpdatedPolicies(ArrayList<StdLoadedPolicy> updatedDelta, Collection<LoadedPolicy> oldUpdatedLostPolicies, Collection<RemovedPolicy> oldRemovedPolicies, Collection<LoadedPolicy> oldUpdatedPolicies, Boolean update, LoadedPolicy newUpdatedPolicy) {
+        // Look for policies which are not in Update
+        Boolean updated = true;
+        String policyName = newUpdatedPolicy.getPolicyName();
+        String ver = newUpdatedPolicy.getVersionNo();
+        for (LoadedPolicy oldUpdatedPolicy : notificationRecord.getLoadedPolicies()) {
+            if (policyName.equals(oldUpdatedPolicy.getPolicyName())
+                && ver.equals(oldUpdatedPolicy.getVersionNo())) {
+                updated = false;
+                // Remove the policy from copy.
+                oldUpdatedLostPolicies.remove(oldUpdatedPolicy);
+                // Eliminating Duplicate.
+                oldUpdatedPolicies.remove(oldUpdatedPolicy);
+            }
+        }
+        // Change the record if the policy has been Removed earlier.
+        for (RemovedPolicy oldRemovedPolicy : notificationRecord.getRemovedPolicies()) {
+            if (oldRemovedPolicy.getPolicyName().equals(policyName)
+                && oldRemovedPolicy.getVersionNo().equals(ver)) {
+                oldRemovedPolicies.remove(oldRemovedPolicy);
+            }
+        }
+        if (updated) {
+            update = true;
+            updatedDelta.add((StdLoadedPolicy) newUpdatedPolicy);
+        }
+        // This will be converted to new Later
+        oldUpdatedPolicies.add(newUpdatedPolicy);
+        return update;
+    }
+
+    private static Boolean updateRemovedPolicies(ArrayList<StdRemovedPolicy> removedDelta, Collection<LoadedPolicy> oldUpdatedLostPolicies, Collection<RemovedPolicy> oldRemovedPolicies, Collection<LoadedPolicy> oldUpdatedPolicies, Boolean remove, RemovedPolicy newRemovedPolicy) {
+        //Look for policy Not in Remove
+        Boolean removed = true;
+        String policyName = newRemovedPolicy.getPolicyName();
+        String ver = newRemovedPolicy.getVersionNo();
+        for (RemovedPolicy oldRemovedPolicy : notificationRecord.getRemovedPolicies()) {
+            if (policyName.equals(oldRemovedPolicy.getPolicyName())
+                && ver.equals(oldRemovedPolicy.getVersionNo())) {
+                removed = false;
+                // Don't want a duplicate.
+                oldRemovedPolicies.remove(oldRemovedPolicy);
+            }
+        }
+        //We need to change our record we have an Update record of this remove.
+        for (LoadedPolicy oldUpdatedPolicy : notificationRecord.getLoadedPolicies()) {
+            if (policyName.equals(oldUpdatedPolicy.getPolicyName())
+                && ver.equals(oldUpdatedPolicy.getVersionNo())) {
+                oldUpdatedPolicies.remove(oldUpdatedPolicy);
+                oldUpdatedLostPolicies.remove(oldUpdatedPolicy);
+            }
+        }
+        if (removed) {
+            remove = true;
+            notificationRecord.getRemovedPolicies().add(newRemovedPolicy);
+            removedDelta.add((StdRemovedPolicy) newRemovedPolicy);
+        }
+        // This will be converted to New Later.
+        oldRemovedPolicies.add(newRemovedPolicy);
+        return remove;
+    }
+
     public static void recordNotification(StdPDPNotification notification) {
-        if (notification != null) {
-            if (notificationRecord.getRemovedPolicies() == null || notificationRecord.getLoadedPolicies() == null) {
-                notificationRecord = notification;
-            } else {
-                // Check if there is anything new and update the record.
-                if (notificationRecord.getLoadedPolicies() != null || notificationRecord.getRemovedPolicies() != null) {
-                    HashSet<StdRemovedPolicy> removedPolicies = new HashSet<>();
-                    for (RemovedPolicy rPolicy : notificationRecord.getRemovedPolicies()) {
-                        StdRemovedPolicy sRPolicy = new StdRemovedPolicy();
-                        sRPolicy.setPolicyName(rPolicy.getPolicyName());
-                        sRPolicy.setVersionNo(rPolicy.getVersionNo());
-                        removedPolicies.add(sRPolicy);
-                    }
-                    HashSet<StdLoadedPolicy> updatedPolicies = new HashSet<>();
-                    for (LoadedPolicy uPolicy : notificationRecord.getLoadedPolicies()) {
-                        StdLoadedPolicy sUPolicy = new StdLoadedPolicy();
-                        sUPolicy.setMatches(uPolicy.getMatches());
-                        sUPolicy.setPolicyName(uPolicy.getPolicyName());
-                        sUPolicy.setVersionNo(uPolicy.getVersionNo());
-                        sUPolicy.setUpdateType(uPolicy.getUpdateType());
-                        updatedPolicies.add(sUPolicy);
-                    }
+        if (notification == null) {
+            return;
+        }
 
-                    // Checking with the new updated policies.
-                    if (notification.getLoadedPolicies() != null && !notification.getLoadedPolicies().isEmpty()) {
-                        for (LoadedPolicy newUpdatedPolicy : notification.getLoadedPolicies()) {
-                            // If it was removed earlier then we need to remove from our record
-                            Iterator<StdRemovedPolicy> oldRemovedPolicy = removedPolicies.iterator();
-                            String policyName = newUpdatedPolicy.getPolicyName();
-                            String ver = newUpdatedPolicy.getVersionNo();
-                            while (oldRemovedPolicy.hasNext()) {
-                                RemovedPolicy policy = oldRemovedPolicy.next();
-                                if (policyName.equals(policy.getPolicyName())
-                                    && ver.equals(policy.getVersionNo())) {
-                                    oldRemovedPolicy.remove();
-                                }
-                            }
-                            // If it was previously updated need to Overwrite it to the record.
-                            updatedPolicies.removeIf(policy -> policyName.equals(policy.getPolicyName())
-                                && ver.equals(policy.getVersionNo()));
-
-                            StdLoadedPolicy sUPolicy = new StdLoadedPolicy();
-                            sUPolicy.setMatches(newUpdatedPolicy.getMatches());
-                            sUPolicy.setPolicyName(newUpdatedPolicy.getPolicyName());
-                            sUPolicy.setVersionNo(newUpdatedPolicy.getVersionNo());
-                            sUPolicy.setUpdateType(newUpdatedPolicy.getUpdateType());
-                            updatedPolicies.add(sUPolicy);
-                        }
-                    }
-                    // Checking with New Removed Policies.
-                    if (notification.getRemovedPolicies() != null && !notification.getRemovedPolicies().isEmpty()) {
-                        for (RemovedPolicy newRemovedPolicy : notification.getRemovedPolicies()) {
-                            // If it was previously removed Overwrite it to the record.
-                            Iterator<StdRemovedPolicy> oldRemovedPolicy = removedPolicies.iterator();
-                            String policyName = newRemovedPolicy.getPolicyName();
-                            String ver = newRemovedPolicy.getVersionNo();
-                            while (oldRemovedPolicy.hasNext()) {
-                                RemovedPolicy policy = oldRemovedPolicy.next();
-                                if (policyName.equals(policy.getPolicyName())
-                                    && ver.equals(policy.getVersionNo())) {
-                                    oldRemovedPolicy.remove();
-                                }
-                            }
-                            // If it was added earlier then we need to remove from our record.
-                            updatedPolicies.removeIf(policy -> policyName.equals(policy.getPolicyName())
-                                && ver.equals(policy.getVersionNo()));
-
-                            StdRemovedPolicy sRPolicy = new StdRemovedPolicy();
-                            sRPolicy.setPolicyName(policyName);
-                            sRPolicy.setVersionNo(ver);
-                            removedPolicies.add(sRPolicy);
-                        }
-                    }
-                    notificationRecord.setRemovedPolicies(removedPolicies);
-                    notificationRecord.setLoadedPolicies(updatedPolicies);
+        if (notificationRecord.getRemovedPolicies() == null || notificationRecord.getLoadedPolicies() == null) {
+            notificationRecord = notification;
+        } else {
+            // Check if there is anything new and update the record.
+            if (notificationRecord.getLoadedPolicies() != null || notificationRecord.getRemovedPolicies() != null) {
+                HashSet<StdRemovedPolicy> removedPolicies = new HashSet<>();
+                for (RemovedPolicy rPolicy : notificationRecord.getRemovedPolicies()) {
+                    StdRemovedPolicy sRPolicy = new StdRemovedPolicy();
+                    sRPolicy.setPolicyName(rPolicy.getPolicyName());
+                    sRPolicy.setVersionNo(rPolicy.getVersionNo());
+                    removedPolicies.add(sRPolicy);
                 }
-                if (!notificationRecord.getLoadedPolicies().isEmpty() && !notificationRecord.getRemovedPolicies()
-                    .isEmpty()) {
-                    notificationRecord.setNotificationType(NotificationType.BOTH);
-                } else if (!notificationRecord.getLoadedPolicies().isEmpty()) {
-                    notificationRecord.setNotificationType(NotificationType.UPDATE);
-                } else if (!notificationRecord.getRemovedPolicies().isEmpty()) {
-                    notificationRecord.setNotificationType(NotificationType.REMOVE);
+                HashSet<StdLoadedPolicy> updatedPolicies = new HashSet<>();
+                for (LoadedPolicy uPolicy : notificationRecord.getLoadedPolicies()) {
+                    StdLoadedPolicy sUPolicy = new StdLoadedPolicy();
+                    sUPolicy.setMatches(uPolicy.getMatches());
+                    sUPolicy.setPolicyName(uPolicy.getPolicyName());
+                    sUPolicy.setVersionNo(uPolicy.getVersionNo());
+                    sUPolicy.setUpdateType(uPolicy.getUpdateType());
+                    updatedPolicies.add(sUPolicy);
+                }
+
+                // Checking with the new updated policies.
+                if (notification.getLoadedPolicies() != null && !notification.getLoadedPolicies().isEmpty()) {
+                    checkNewUpdatedPolicies(notification, removedPolicies, updatedPolicies);
+                }
+                // Checking with New Removed Policies.
+                if (notification.getRemovedPolicies() != null && !notification.getRemovedPolicies().isEmpty()) {
+                    checkNewRemovedPolicies(notification, removedPolicies, updatedPolicies);
+                }
+                notificationRecord.setRemovedPolicies(removedPolicies);
+                notificationRecord.setLoadedPolicies(updatedPolicies);
+            }
+            if (!notificationRecord.getLoadedPolicies().isEmpty() && !notificationRecord.getRemovedPolicies()
+                .isEmpty()) {
+                notificationRecord.setNotificationType(NotificationType.BOTH);
+            } else if (!notificationRecord.getLoadedPolicies().isEmpty()) {
+                notificationRecord.setNotificationType(NotificationType.UPDATE);
+            } else if (!notificationRecord.getRemovedPolicies().isEmpty()) {
+                notificationRecord.setNotificationType(NotificationType.REMOVE);
+            }
+        }
+    }
+
+    private static void checkNewUpdatedPolicies(StdPDPNotification notification, HashSet<StdRemovedPolicy> removedPolicies, HashSet<StdLoadedPolicy> updatedPolicies) {
+        for (LoadedPolicy newUpdatedPolicy : notification.getLoadedPolicies()) {
+            // If it was removed earlier then we need to remove from our record
+            Iterator<StdRemovedPolicy> oldRemovedPolicy = removedPolicies.iterator();
+            String policyName = newUpdatedPolicy.getPolicyName();
+            String ver = newUpdatedPolicy.getVersionNo();
+            while (oldRemovedPolicy.hasNext()) {
+                RemovedPolicy policy = oldRemovedPolicy.next();
+                if (policyName.equals(policy.getPolicyName())
+                    && ver.equals(policy.getVersionNo())) {
+                    oldRemovedPolicy.remove();
                 }
             }
+            // If it was previously updated need to Overwrite it to the record.
+            updatedPolicies.removeIf(policy -> policyName.equals(policy.getPolicyName())
+                && ver.equals(policy.getVersionNo()));
+
+            StdLoadedPolicy sUPolicy = new StdLoadedPolicy();
+            sUPolicy.setMatches(newUpdatedPolicy.getMatches());
+            sUPolicy.setPolicyName(newUpdatedPolicy.getPolicyName());
+            sUPolicy.setVersionNo(newUpdatedPolicy.getVersionNo());
+            sUPolicy.setUpdateType(newUpdatedPolicy.getUpdateType());
+            updatedPolicies.add(sUPolicy);
+        }
+    }
+
+    private static void checkNewRemovedPolicies(StdPDPNotification notification, HashSet<StdRemovedPolicy> removedPolicies, HashSet<StdLoadedPolicy> updatedPolicies) {
+        for (RemovedPolicy newRemovedPolicy : notification.getRemovedPolicies()) {
+            // If it was previously removed Overwrite it to the record.
+            Iterator<StdRemovedPolicy> oldRemovedPolicy = removedPolicies.iterator();
+            String policyName = newRemovedPolicy.getPolicyName();
+            String ver = newRemovedPolicy.getVersionNo();
+            while (oldRemovedPolicy.hasNext()) {
+                RemovedPolicy policy = oldRemovedPolicy.next();
+                if (policyName.equals(policy.getPolicyName())
+                    && ver.equals(policy.getVersionNo())) {
+                    oldRemovedPolicy.remove();
+                }
+            }
+            // If it was added earlier then we need to remove from our record.
+            updatedPolicies.removeIf(policy -> policyName.equals(policy.getPolicyName())
+                && ver.equals(policy.getVersionNo()));
+
+            StdRemovedPolicy sRPolicy = new StdRemovedPolicy();
+            sRPolicy.setPolicyName(policyName);
+            sRPolicy.setVersionNo(ver);
+            removedPolicies.add(sRPolicy);
         }
     }
 
diff --git a/PolicyEngineUtils/src/main/java/org/onap/policy/utils/AAFPolicyClientImpl.java b/PolicyEngineUtils/src/main/java/org/onap/policy/utils/AAFPolicyClientImpl.java
index 732183d..5c46c76 100644
--- a/PolicyEngineUtils/src/main/java/org/onap/policy/utils/AAFPolicyClientImpl.java
+++ b/PolicyEngineUtils/src/main/java/org/onap/policy/utils/AAFPolicyClientImpl.java
@@ -3,6 +3,7 @@
  * PolicyEngineUtils
  * ================================================================================
  * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
+ * Modified Copyright (C) 2018 Samsung Electronics Co., Ltd.
  * ================================================================================
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -42,173 +43,175 @@
  * 
  */
 public class AAFPolicyClientImpl implements AAFPolicyClient{
-	private static Logger logger = Logger.getLogger(AAFPolicyClientImpl.class.getName());
+    private static Logger logger = Logger.getLogger(AAFPolicyClientImpl.class.getName());
 
-	private static final String ENVIRONMENT = "ENVIRONMENT";
-	
-	// Warning Please don't Change these Values. Confirm with AAF team.  
-	private static final String DEVL_AAF_URL = "";
-	private static final String TEST_AAF_URL = "";
-	private static final String PROD_AAF_URL = "";
-	private static final String DEFAULT_AFT_LATITUDE = "32.780140";
-	private static final String DEFAULT_AFT_LONGITUDE = "-96.800451";
-	private static final String TEST_AFT_ENVIRONMENT = "AFTUAT";
-	private static final String PROD_AFT_ENVIRONMENT = "AFTPRD";
-	private static final String DEFAULT_AAF_USER_EXPIRES = Integer.toString(5*60000); 	// 5 minutes for found items to live in cache
-	private static final String DEFAULT_AAF_HIGH_COUNT = Integer.toString(400); 		// Maximum number of items in Cache
+    private static final String ENVIRONMENT = "ENVIRONMENT";
 
-	private static AAFPolicyClientImpl instance = null;
+    // Warning Please don't Change these Values. Confirm with AAF team.
+    private static final String DEVL_AAF_URL = "";
+    private static final String TEST_AAF_URL = "";
+    private static final String PROD_AAF_URL = "";
+    private static final String DEFAULT_AFT_LATITUDE = "32.780140";
+    private static final String DEFAULT_AFT_LONGITUDE = "-96.800451";
+    private static final String TEST_AFT_ENVIRONMENT = "AFTUAT";
+    private static final String PROD_AFT_ENVIRONMENT = "AFTPRD";
+    private static final String DEFAULT_AAF_USER_EXPIRES = Integer.toString(5*60000); 	// 5 minutes for found items to live in cache
+    private static final String DEFAULT_AAF_HIGH_COUNT = Integer.toString(400); 		// Maximum number of items in Cache
 
-	private static Properties props = new Properties();
-	private static AAFCon<?> aafCon = null;
-	private static AAFLurPerm aafLurPerm = null;
-	private static AAFAuthn<?> aafAuthn = null;
-	private static PropAccess access = null;
+    private static AAFPolicyClientImpl instance = null;
 
-	private AAFPolicyClientImpl(Properties properties) throws AAFPolicyException{
-		setup(properties);
-	}
+    private static Properties props = new Properties();
+    private static AAFCon<?> aafCon = null;
+    private static AAFLurPerm aafLurPerm = null;
+    private static AAFAuthn<?> aafAuthn = null;
+    private static PropAccess access = null;
 
-	/**
-	 * Gets the instance of the AAFClient instance. Needs Proper properties with CLIENT_ID, CLIENT_KEY and ENVIRONMENT
-	 * 
-	 * @param properties Properties with CLIENT_ID, CLIENT_KEY and ENVIRONMENT
-	 * @return AAFClient instance. 
-	 * @throws AAFPolicyException Exceptions. 
-	 */
-	public static synchronized AAFPolicyClientImpl getInstance(Properties properties) throws AAFPolicyException{
-		if(instance == null) {
-			logger.info("Creating AAFClient Instance ");
-			instance = new AAFPolicyClientImpl(properties);
-		}
-		return instance;
-	}
+    private AAFPolicyClientImpl(Properties properties) throws AAFPolicyException{
+        setup(properties);
+    }
 
-	// To set Property values && Connections. 
-	private static void setup(Properties properties) throws AAFPolicyException {
-		if(properties!=null && !properties.isEmpty()){
-			props = System.getProperties();
-			props.setProperty("AFT_LATITUDE", properties.getProperty("AFT_LATITUDE", DEFAULT_AFT_LATITUDE));
-			props.setProperty("AFT_LONGITUDE", properties.getProperty("AFT_LONGITUDE", DEFAULT_AFT_LONGITUDE));
-			String aftEnv = TEST_AFT_ENVIRONMENT;
-			props.setProperty("aaf_id",properties.getProperty("aaf_id", "aafID"));
-			props.setProperty("aaf_password", properties.getProperty("aaf_password", "aafPass"));
-			if(properties.containsKey(Config.AAF_URL)){
-				// if given a value in properties file. 
-				props.setProperty(Config.AAF_URL, properties.getProperty(Config.AAF_URL));
-			}else{
-				// Set Default values. 
-				if(properties.getProperty(ENVIRONMENT, "DEVL").equalsIgnoreCase(AAFEnvironment.TEST.toString())){
-					props.setProperty(Config.AAF_URL, TEST_AAF_URL);
-				}else if(properties.getProperty(ENVIRONMENT, "DEVL").equalsIgnoreCase(AAFEnvironment.PROD.toString())){
-					props.setProperty(Config.AAF_URL, PROD_AAF_URL);
-					aftEnv = PROD_AFT_ENVIRONMENT;
-				}else{
-					props.setProperty(Config.AAF_URL, DEVL_AAF_URL);
-				}
-			}
-			props.setProperty("AFT_ENVIRONMENT", properties.getProperty("AFT_ENVIRONMENT", aftEnv));
-			props.setProperty(Config.AAF_USER_EXPIRES, properties.getProperty(Config.AAF_USER_EXPIRES, DEFAULT_AAF_USER_EXPIRES));	
-			props.setProperty(Config.AAF_HIGH_COUNT, properties.getProperty(Config.AAF_HIGH_COUNT, DEFAULT_AAF_HIGH_COUNT));
-		}else{
-			logger.error("Required Property value is missing : " + ENVIRONMENT);
-			throw new AAFPolicyException("Required Property value is missing : " + ENVIRONMENT);
-		}
-		access = new PolicyAccess(props, Level.valueOf(properties.getProperty("AAF_LOG_LEVEL", Level.ERROR.toString())));
-		setUpAAF();
-	}
+    /**
+     * Gets the instance of the AAFClient instance. Needs Proper properties with CLIENT_ID, CLIENT_KEY and ENVIRONMENT
+     *
+     * @param properties Properties with CLIENT_ID, CLIENT_KEY and ENVIRONMENT
+     * @return AAFClient instance.
+     * @throws AAFPolicyException Exceptions.
+     */
+    public static synchronized AAFPolicyClientImpl getInstance(Properties properties) throws AAFPolicyException{
+        if(instance == null) {
+            logger.info("Creating AAFClient Instance ");
+            instance = new AAFPolicyClientImpl(properties);
+        }
+        return instance;
+    }
 
-	/**
-	 * Updates the Properties file in case if required. 
-	 * 
-	 * @param properties  Properties with CLIENT_ID, CLIENT_KEY and ENVIRONMENT
-	 * @throws AAFPolicyException exceptions if any.
-	 */
-	@Override
-	public void updateProperties(Properties properties) throws AAFPolicyException{
-		setup(properties);
-	}
+    // To set Property values && Connections.
+    private static void setup(Properties properties) throws AAFPolicyException {
+        if(properties!=null && !properties.isEmpty()){
+            props = System.getProperties();
+            props.setProperty("AFT_LATITUDE", properties.getProperty("AFT_LATITUDE", DEFAULT_AFT_LATITUDE));
+            props.setProperty("AFT_LONGITUDE", properties.getProperty("AFT_LONGITUDE", DEFAULT_AFT_LONGITUDE));
+            String aftEnv = TEST_AFT_ENVIRONMENT;
+            props.setProperty("aaf_id",properties.getProperty("aaf_id", "aafID"));
+            props.setProperty("aaf_password", properties.getProperty("aaf_password", "aafPass"));
+            if(properties.containsKey(Config.AAF_URL)){
+                // if given a value in properties file.
+                props.setProperty(Config.AAF_URL, properties.getProperty(Config.AAF_URL));
+            }else{
+                // Set Default values.
+                if(properties.getProperty(ENVIRONMENT, "DEVL").equalsIgnoreCase(AAFEnvironment.TEST.toString())){
+                    props.setProperty(Config.AAF_URL, TEST_AAF_URL);
+                }else if(properties.getProperty(ENVIRONMENT, "DEVL").equalsIgnoreCase(AAFEnvironment.PROD.toString())){
+                    props.setProperty(Config.AAF_URL, PROD_AAF_URL);
+                    aftEnv = PROD_AFT_ENVIRONMENT;
+                }else{
+                    props.setProperty(Config.AAF_URL, DEVL_AAF_URL);
+                }
+            }
+            props.setProperty("AFT_ENVIRONMENT", properties.getProperty("AFT_ENVIRONMENT", aftEnv));
+            props.setProperty(Config.AAF_USER_EXPIRES, properties.getProperty(Config.AAF_USER_EXPIRES, DEFAULT_AAF_USER_EXPIRES));
+            props.setProperty(Config.AAF_HIGH_COUNT, properties.getProperty(Config.AAF_HIGH_COUNT, DEFAULT_AAF_HIGH_COUNT));
+        }else{
+            logger.error("Required Property value is missing : " + ENVIRONMENT);
+            throw new AAFPolicyException("Required Property value is missing : " + ENVIRONMENT);
+        }
+        access = new PolicyAccess(props, Level.valueOf(properties.getProperty("AAF_LOG_LEVEL", Level.ERROR.toString())));
+        setUpAAF();
+    }
 
-	/**
-	 * Checks the Authentication and Permissions for the given values. 
-	 * 
-	 * @param mechID MechID or ATT ID must be registered under the Name space. 
-	 * @param pass Password pertaining to the MechID or ATTID. 
-	 * @param type Permissions Type.
-	 * @param instance Permissions Instance. 
-	 * @param action Permissions Action. 
-	 * @return
-	 */
-	@Override
-	public boolean checkAuthPerm(String mechID, String pass, String type, String instance, String action){
-		return checkAuth(mechID, pass) && checkPerm(mechID, pass, type, instance, action);
-	}
+    /**
+     * Updates the Properties file in case if required.
+     *
+     * @param properties  Properties with CLIENT_ID, CLIENT_KEY and ENVIRONMENT
+     * @throws AAFPolicyException exceptions if any.
+     */
+    @Override
+    public void updateProperties(Properties properties) throws AAFPolicyException{
+        setup(properties);
+    }
 
-	/**
-	 * Checks the Authentication of the UserName and Password Given. 
-	 * 
-	 * @param userName UserName or MechID
-	 * @param pass Password.
-	 * @return True or False. 
-	 */
-	@Override
-	public boolean checkAuth(String userName, String pass){
-		if(aafAuthn!=null){
-			try {
-				int i=0;
-				do{
-					if(aafAuthn.validate(userName, pass)==null){ 
-						return true; 
-					}
-					i++;
-				}while(i<2);
-			} catch (Exception e) {
-				logger.error(e.getMessage() + e);
-			}
-		}
-		return false;
-	}
+    /**
+     * Checks the Authentication and Permissions for the given values.
+     *
+     * @param mechID MechID or ATT ID must be registered under the Name space.
+     * @param pass Password pertaining to the MechID or ATTID.
+     * @param type Permissions Type.
+     * @param instance Permissions Instance.
+     * @param action Permissions Action.
+     * @return
+     */
+    @Override
+    public boolean checkAuthPerm(String mechID, String pass, String type, String instance, String action){
+        return checkAuth(mechID, pass) && checkPerm(mechID, pass, type, instance, action);
+    }
 
-	/**
-	 * Checks Permissions for the given UserName, Password and Type, Instance Action. 
-	 * 
-	 * @param userName UserName or MechID
-	 * @param pass Password.
-	 * @param type Permissions Type. 
-	 * @param instance Permissions Instance. 
-	 * @param action Permissions Action. 
-	 * @return True or False. 
-	 */
-	@Override
-	public boolean checkPerm(String userName, String pass, String type, String instance, String action){
-		int i =0;
-		Boolean result= false;
-		do{
-			if(aafCon!=null && aafLurPerm !=null){
-				try {
-					aafCon.basicAuth(userName, pass);
-					AAFPermission perm = new AAFPermission(type, instance, action);
-					final Principal p = new UnAuthPrincipal(userName); 
-					result = aafLurPerm.fish(p, perm);
-				} catch (CadiException e) {
-					logger.error(e.getMessage() + e);
-					aafLurPerm.destroy();
-				}
-			}
-			i++;
-		}while(i<2 && !result); // Try once more to check if this can be passed. AAF has some issues. 
-		return result;
-	}
+    /**
+     * Checks the Authentication of the UserName and Password Given.
+     *
+     * @param userName UserName or MechID
+     * @param pass Password.
+     * @return True or False.
+     */
+    @Override
+    public boolean checkAuth(String userName, String pass){
+        if (aafAuthn == null) {
+            return false;
+        }
+        try {
+            int i=0;
+            do{
+                if(aafAuthn.validate(userName, pass)==null){
+                    return true;
+                }
+                i++;
+            }while(i<2);
+        } catch (Exception e) {
+            logger.error(e.getMessage() + e);
+        }
 
-	private static boolean setUpAAF(){
-		try {
-			aafCon = new AAFConHttp(access,new PropertyLocator("https://aaf-onap-beijing-test.osaaf.org:8100"));
-			aafLurPerm = aafCon.newLur();
-			aafAuthn = aafCon.newAuthn(aafLurPerm);
-			return true;
-		} catch (Exception e) {
-			logger.error("Error while setting up AAF Connection " + e.getMessage() + e);
-			return false;
-		}
-	}
+        return false;
+    }
+
+    /**
+     * Checks Permissions for the given UserName, Password and Type, Instance Action.
+     *
+     * @param userName UserName or MechID
+     * @param pass Password.
+     * @param type Permissions Type.
+     * @param instance Permissions Instance.
+     * @param action Permissions Action.
+     * @return True or False.
+     */
+    @Override
+    public boolean checkPerm(String userName, String pass, String type, String instance, String action){
+        int i =0;
+        Boolean result= false;
+        do{
+            if(aafCon!=null && aafLurPerm !=null){
+                try {
+                    aafCon.basicAuth(userName, pass);
+                    AAFPermission perm = new AAFPermission(type, instance, action);
+                    final Principal p = new UnAuthPrincipal(userName);
+                    result = aafLurPerm.fish(p, perm);
+                } catch (CadiException e) {
+                    logger.error(e.getMessage() + e);
+                    aafLurPerm.destroy();
+                }
+            }
+            i++;
+        }while(i<2 && !result); // Try once more to check if this can be passed. AAF has some issues.
+        return result;
+    }
+
+    private static boolean setUpAAF(){
+        try {
+            aafCon = new AAFConHttp(access,new PropertyLocator("https://aaf-onap-beijing-test.osaaf.org:8100"));
+            aafLurPerm = aafCon.newLur();
+            aafAuthn = aafCon.newAuthn(aafLurPerm);
+            return true;
+        } catch (Exception e) {
+            logger.error("Error while setting up AAF Connection " + e.getMessage() + e);
+            return false;
+        }
+    }
 }
