aboutsummaryrefslogtreecommitdiffstats
path: root/POLICY-SDK-APP/src/main/java/org/onap/policy/admin
diff options
context:
space:
mode:
Diffstat (limited to 'POLICY-SDK-APP/src/main/java/org/onap/policy/admin')
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/admin/CheckPDP.java12
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyAdapter.java17
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyManagerServlet.java193
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyNotificationMail.java120
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyRestController.java7
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyUserInfoController.java7
-rw-r--r--POLICY-SDK-APP/src/main/java/org/onap/policy/admin/RESTfulPAPEngine.java18
7 files changed, 205 insertions, 169 deletions
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 26b9798ac..0965ee63b 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
@@ -22,8 +22,8 @@
package org.onap.policy.admin;
-
import com.att.research.xacml.util.XACMLProperties;
+
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;
@@ -39,6 +39,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;
+
import org.onap.policy.common.logging.flexlogger.FlexLogger;
import org.onap.policy.common.logging.flexlogger.Logger;
import org.onap.policy.rest.XACMLRestProperties;
@@ -63,7 +64,7 @@ public class CheckPDP {
private static final Logger LOGGER = FlexLogger.getLogger(CheckPDP.class);
private CheckPDP() {
- //default constructor
+ // default constructor
}
public static Map<String, String> getPdpMap() {
@@ -104,9 +105,8 @@ public class CheckPDP {
} else 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());
+ LOGGER.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + "File doesn't exist in the specified Path : "
+ + pdpPath.toString());
CheckPDP.reset();
return;
}
@@ -173,7 +173,7 @@ public class CheckPDP {
Base64.Encoder encoder = Base64.getEncoder();
// 0 - PDPURL
pdpMap.put(pdpValues.get(0),
- encoder.encodeToString((userID + ":" + pass).getBytes(StandardCharsets.UTF_8)));
+ encoder.encodeToString((userID + ":" + pass).getBytes(StandardCharsets.UTF_8)));
} else {
LOGGER.error(XACMLErrorConstants.ERROR_PERMISSIONS + "No Credentials to send Request: " + pdpValues);
}
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 6aa40dacf..339702297 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
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP Policy Engine
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017, 2019 AT&T Intellectual Property. All rights reserved.
* Modified Copyright (C) 2018 Samsung Electronics Co., Ltd.
* Modifications Copyright (C) 2019 Bell Canada
* ================================================================================
@@ -22,6 +22,8 @@
package org.onap.policy.admin;
+import com.att.research.xacml.util.XACMLProperties;
+
import org.onap.policy.common.logging.flexlogger.FlexLogger;
import org.onap.policy.common.logging.flexlogger.Logger;
import org.onap.policy.controller.ActionPolicyController;
@@ -37,8 +39,6 @@ import org.onap.policy.controller.DecisionPolicyController;
import org.onap.policy.rest.adapter.PolicyRestAdapter;
import org.onap.policy.rest.jpa.PolicyEntity;
-import com.att.research.xacml.util.XACMLProperties;
-
public class PolicyAdapter {
private static final Logger LOGGER = FlexLogger.getLogger(PolicyAdapter.class);
@@ -78,8 +78,8 @@ public class PolicyAdapter {
configPolicyName = "Micro Service";
} else if (policyAdapter.getPolicyName().startsWith("Config_OOF")) {
configPolicyName = "Optimization";
- } else if (policyAdapter.getPolicyName().startsWith("Action") || policyAdapter.getPolicyName()
- .startsWith("Decision")) {
+ } else if (policyAdapter.getPolicyName().startsWith("Action")
+ || policyAdapter.getPolicyName().startsWith("Decision")) {
// No configPolicyName is applicable
} else {
configPolicyName = "Base";
@@ -109,10 +109,11 @@ public class PolicyAdapter {
public static PolicyAdapter getInstance() {
try {
- Class<?> policyAdapter = Class
- .forName(XACMLProperties.getProperty("policyAdapter.impl.className", PolicyAdapter.class.getName()));
+ Class<?> policyAdapter = Class.forName(
+ XACMLProperties.getProperty("policyAdapter.impl.className", PolicyAdapter.class.getName()));
return (PolicyAdapter) policyAdapter.newInstance();
- } catch (ClassNotFoundException | InstantiationException | IllegalAccessException | IllegalArgumentException e) {
+ } catch (ClassNotFoundException | InstantiationException | IllegalAccessException
+ | IllegalArgumentException e) {
LOGGER.error("Exception Occurred" + e);
}
return null;
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 513fc5795..78d7e5a19 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
@@ -25,6 +25,7 @@ package org.onap.policy.admin;
import com.att.research.xacml.util.XACMLProperties;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
+
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.ByteArrayInputStream;
@@ -48,6 +49,7 @@ import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Set;
+
import javax.json.Json;
import javax.json.JsonArray;
import javax.json.JsonReader;
@@ -59,6 +61,7 @@ import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
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.disk.DiskFileItemFactory;
@@ -89,9 +92,13 @@ import org.onap.policy.xacml.api.XACMLErrorConstants;
import org.onap.policy.xacml.util.XACMLPolicyScanner;
import org.onap.portalsdk.core.web.support.UserUtils;
-
-@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.") })
+@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;
@@ -126,11 +133,13 @@ public class PolicyManagerServlet extends HttpServlet {
private static final String BACKSLASH = "\\";
private static final String ESCAPE_BACKSLASH = "\\\\";
private static final String BACKSLASH_8TIMES = "\\\\\\\\";
- private static final String DELETE_POLICY_VERSION_WHERE_POLICY_NAME = "delete from PolicyVersion where policy_name ='";
+ private static final String DELETE_POLICY_VERSION_WHERE_POLICY_NAME =
+ "delete from PolicyVersion where policy_name ='";
private static final String UPDATE_POLICY_VERSION_SET_ACTIVE_VERSION = "update PolicyVersion set active_version='";
private static final String SPLIT_1 = "split_1";
private static final String SPLIT_0 = "split_0";
- private static final String FROM_POLICY_EDITOR_SCOPES_WHERE_SCOPENAME_LIKE_SCOPE_NAME = "from PolicyEditorScopes where SCOPENAME like :scopeName";
+ private static final String FROM_POLICY_EDITOR_SCOPES_WHERE_SCOPENAME_LIKE_SCOPE_NAME =
+ "from PolicyEditorScopes where SCOPENAME like :scopeName";
private static final String SCOPE_NAME = "scopeName";
private static final String SUCCESS = "success";
private static final String SUB_SCOPENAME = "subScopename";
@@ -141,8 +150,7 @@ public class PolicyManagerServlet extends HttpServlet {
private static String testUserId = null;
private enum Mode {
- LIST, RENAME, COPY, DELETE, EDITFILE, ADDFOLDER, DESCRIBEPOLICYFILE, VIEWPOLICY, ADDSUBSCOPE, SWITCHVERSION,
- EXPORT, SEARCHLIST
+ LIST, RENAME, COPY, DELETE, EDITFILE, ADDFOLDER, DESCRIBEPOLICYFILE, VIEWPOLICY, ADDSUBSCOPE, SWITCHVERSION, EXPORT, SEARCHLIST
}
private static PolicyController policyController;
@@ -467,7 +475,8 @@ public class PolicyManagerServlet extends HttpServlet {
if (policyName.contains(BACKSLASH)) {
policyName = policyName.replace(BACKSLASH, ESCAPE_BACKSLASH);
}
- String policyVersionQuery = "From PolicyVersion where policy_name = :policyName and active_version = :version and id >0";
+ 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);
@@ -672,39 +681,37 @@ public class PolicyManagerServlet extends HttpServlet {
Map<String, String> roleByScope) {
if (roles.contains(SUPERADMIN) || roles.contains(SUPEREDITOR) || roles.contains(SUPERGUEST)) {
List<Object> scopesList = queryPolicyEditorScopes(null);
- scopesList.stream()
- .map(list -> (PolicyEditorScopes) list)
- .filter(scope -> !(scope.getScopeName().contains(File.separator))
- && !scopes.contains(scope.getScopeName()))
- .forEach(scope -> {
- 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());
- el.put(ROLETYPE, roleByScope.get(ALLSCOPES));
- resultList.add(el);
- });
+ scopesList.stream().map(list -> (PolicyEditorScopes) list).filter(
+ scope -> !(scope.getScopeName().contains(File.separator)) && !scopes.contains(scope.getScopeName()))
+ .forEach(scope -> {
+ 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());
+ el.put(ROLETYPE, roleByScope.get(ALLSCOPES));
+ resultList.add(el);
+ });
}
if (roles.contains(ADMIN) || roles.contains(EDITOR) || roles.contains(GUEST)) {
- scopes.stream().map(this::queryPolicyEditorScopes)
- .filter(scopesList -> !scopesList.isEmpty())
- .forEach(scopesList -> {
- JSONObject el = new JSONObject();
- 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());
- if ((resultList).stream().noneMatch(item -> item.get("name").equals(scopeById.getScopeName()))) {
- el.put(ROLETYPE, roleByScope.get(scopeById.getScopeName()));
- resultList.add(el);
- }
- });
+ scopes.stream().map(this::queryPolicyEditorScopes).filter(scopesList -> !scopesList.isEmpty())
+ .forEach(scopesList -> {
+ JSONObject el = new JSONObject();
+ 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());
+ if ((resultList).stream()
+ .noneMatch(item -> item.get("name").equals(scopeById.getScopeName()))) {
+ el.put(ROLETYPE, roleByScope.get(scopeById.getScopeName()));
+ resultList.add(el);
+ }
+ });
}
}
@@ -739,18 +746,18 @@ public class PolicyManagerServlet extends HttpServlet {
List<Object> activePolicies = getDataByQueryFromController(controller, query, params);
List<Object> scopesList = getDataByQueryFromController(controller,
- FROM_POLICY_EDITOR_SCOPES_WHERE_SCOPENAME_LIKE_SCOPE_NAME, params);
+ FROM_POLICY_EDITOR_SCOPES_WHERE_SCOPENAME_LIKE_SCOPE_NAME, params);
for (Object list : scopesList) {
scopeName = checkScope(resultList, scopeName, (PolicyEditorScopes) list, roleByScope);
}
for (Object list : activePolicies) {
PolicyVersion policy = (PolicyVersion) list;
- String scopeNameValue = policy.getPolicyName().substring(0,
- policy.getPolicyName().lastIndexOf(File.separator));
+ String scopeNameValue =
+ policy.getPolicyName().substring(0, policy.getPolicyName().lastIndexOf(File.separator));
if (roles.contains(SUPERADMIN) || roles.contains(SUPEREDITOR) || roles.contains(SUPERGUEST)) {
String scopeNameCheck =
- scopeName.contains(ESCAPE_BACKSLASH) ? scopeName.replace(ESCAPE_BACKSLASH, File.separator) :
- scopeName;
+ scopeName.contains(ESCAPE_BACKSLASH) ? scopeName.replace(ESCAPE_BACKSLASH, File.separator)
+ : scopeName;
if (!scopeNameValue.equals(scopeNameCheck)) {
continue;
}
@@ -762,8 +769,8 @@ public class PolicyManagerServlet extends HttpServlet {
el.put(TYPE, "file");
el.put(CREATED_BY, getUserName(policy.getCreatedBy()));
el.put(MODIFIED_BY, getUserName(policy.getModifiedBy()));
- String roleType = Strings.isNullOrEmpty(roleByScope.get(scopeNameValue)) ?
- roleByScope.get(ALLSCOPES) : roleByScope.get(scopeNameValue);
+ String roleType = Strings.isNullOrEmpty(roleByScope.get(scopeNameValue)) ? roleByScope.get(ALLSCOPES)
+ : roleByScope.get(scopeNameValue);
el.put(ROLETYPE, roleType);
resultList.add(el);
} else if (!scopes.isEmpty() && scopes.contains(scopeNameValue)) {
@@ -781,7 +788,7 @@ public class PolicyManagerServlet extends HttpServlet {
}
private List<Object> getDataByQueryFromController(final PolicyController controller, final String query,
- final SimpleBindings params) {
+ final SimpleBindings params) {
final List<Object> activePolicies;
if (PolicyController.isjUnit()) {
activePolicies = controller.getDataByQuery(query, null);
@@ -858,8 +865,8 @@ public class PolicyManagerServlet extends HttpServlet {
String checkValidation;
if (oldPath.endsWith(".xml")) {
checkValidation = newPath.replace(".xml", "");
- checkValidation = checkValidation.substring(checkValidation.indexOf('_') + 1,
- checkValidation.lastIndexOf('.'));
+ checkValidation =
+ checkValidation.substring(checkValidation.indexOf('_') + 1, checkValidation.lastIndexOf('.'));
checkValidation = checkValidation.substring(checkValidation.lastIndexOf(FORWARD_SLASH) + 1);
if (!PolicyUtils.policySpecialCharValidator(checkValidation).contains(SUCCESS)) {
return error("Policy Rename Failed. The Name contains special characters.");
@@ -888,7 +895,8 @@ public class PolicyManagerServlet extends HttpServlet {
SimpleBindings pvParams = new SimpleBindings();
pvParams.put(SCOPE_NAME, scopeName + "%");
List<Object> activePolicies = controller.getDataByQuery(query, pvParams);
- List<Object> scopesList = controller.getDataByQuery(FROM_POLICY_EDITOR_SCOPES_WHERE_SCOPENAME_LIKE_SCOPE_NAME, pvParams);
+ List<Object> scopesList =
+ controller.getDataByQuery(FROM_POLICY_EDITOR_SCOPES_WHERE_SCOPENAME_LIKE_SCOPE_NAME, pvParams);
for (Object object : activePolicies) {
PolicyVersion activeVersion = (PolicyVersion) object;
String policyOldPath = activeVersion.getPolicyName().replace(File.separator, FORWARD_SLASH) + "."
@@ -958,7 +966,8 @@ public class PolicyManagerServlet extends HttpServlet {
String[] oldPolicySplit = modifyPolicyName(oldPath);
// Check PolicyEntity table with newPolicy Name
- String policyEntityquery = "FROM PolicyEntity where policyName = :newPolicySplit_1 and scope = :newPolicySplit_0";
+ 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]);
@@ -969,8 +978,8 @@ public class PolicyManagerServlet extends HttpServlet {
// 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";
+ 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]);
@@ -1042,10 +1051,10 @@ public class PolicyManagerServlet extends HttpServlet {
String oldPolicyNameWithoutExtension = removeOldPolicyExtension;
String newPolicyNameWithoutExtension = removeNewPolicyExtension;
if (removeOldPolicyExtension.endsWith(".xml")) {
- oldPolicyNameWithoutExtension = oldPolicyNameWithoutExtension.substring(0,
- oldPolicyNameWithoutExtension.indexOf('.'));
- newPolicyNameWithoutExtension = newPolicyNameWithoutExtension.substring(0,
- newPolicyNameWithoutExtension.indexOf('.'));
+ oldPolicyNameWithoutExtension =
+ oldPolicyNameWithoutExtension.substring(0, oldPolicyNameWithoutExtension.indexOf('.'));
+ newPolicyNameWithoutExtension =
+ newPolicyNameWithoutExtension.substring(0, newPolicyNameWithoutExtension.indexOf('.'));
}
entity.setPolicyName(
entity.getPolicyName().replace(oldPolicyNameWithoutExtension, newPolicyNameWithoutExtension));
@@ -1065,8 +1074,8 @@ public class PolicyManagerServlet extends HttpServlet {
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 renameFile =
+ new File(PolicyController.getConfigHome() + File.separator + newConfigurationName);
file.renameTo(renameFile);
}
} else if (newPolicyName.contains(ACTION2)) {
@@ -1078,8 +1087,8 @@ public class PolicyManagerServlet extends HttpServlet {
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 renameFile =
+ new File(PolicyController.getActionHome() + File.separator + newConfigurationName);
file.renameTo(renameFile);
}
}
@@ -1087,8 +1096,8 @@ public class PolicyManagerServlet extends HttpServlet {
PolicyRestController restController = new PolicyRestController();
restController.notifyOtherPAPSToUpdateConfigurations("rename", newConfigurationName, oldConfigurationName);
- PolicyVersion versionEntity = (PolicyVersion) controller.getEntityItem(PolicyVersion.class, "policyName",
- oldPolicyName);
+ PolicyVersion versionEntity =
+ (PolicyVersion) controller.getEntityItem(PolicyVersion.class, "policyName", oldPolicyName);
versionEntity.setPolicyName(policyName);
versionEntity.setModifiedBy(userId);
controller.updateData(versionEntity);
@@ -1136,8 +1145,8 @@ public class PolicyManagerServlet extends HttpServlet {
.getEntityItem(ConfigurationDataEntity.class, "configurationName", queryEntityName);
cloneEntity.setConfigurationData(configEntiy);
newConfigurationName = configEntiy.getConfigurationName();
- try (FileWriter fw = new FileWriter(
- PolicyController.getConfigHome() + File.separator + newConfigurationName);
+ try (FileWriter fw =
+ new FileWriter(PolicyController.getConfigHome() + File.separator + newConfigurationName);
BufferedWriter bw = new BufferedWriter(fw)) {
bw.write(configEntiy.getConfigBody());
} catch (IOException e) {
@@ -1158,8 +1167,8 @@ public class PolicyManagerServlet extends HttpServlet {
"actionBodyName", queryEntityName);
cloneEntity.setActionBodyEntity(actionEntiy);
newConfigurationName = actionEntiy.getActionBodyName();
- try (FileWriter fw = new FileWriter(
- PolicyController.getActionHome() + File.separator + newConfigurationName);
+ try (FileWriter fw =
+ new FileWriter(PolicyController.getActionHome() + File.separator + newConfigurationName);
BufferedWriter bw = new BufferedWriter(fw)) {
bw.write(actionEntiy.getActionBody());
} catch (IOException e) {
@@ -1210,8 +1219,8 @@ public class PolicyManagerServlet extends HttpServlet {
String[] newPolicySplit = newPolicyCheck.split(":");
String checkValidation = newPolicySplit[1].replace(".xml", "");
- checkValidation = checkValidation.substring(checkValidation.indexOf('_') + 1,
- checkValidation.lastIndexOf('.'));
+ checkValidation =
+ checkValidation.substring(checkValidation.indexOf('_') + 1, checkValidation.lastIndexOf('.'));
if (!PolicyUtils.policySpecialCharValidator(checkValidation).contains(SUCCESS)) {
return error("Policy Clone Failed. The Name contains special characters.");
}
@@ -1224,7 +1233,8 @@ public class PolicyManagerServlet extends HttpServlet {
boolean success = false;
// Check PolicyEntity table with newPolicy Name
- String policyEntityquery = "FROM PolicyEntity where policyName = :newPolicySplit_1 and scope = :newPolicySplit_0";
+ 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]);
@@ -1307,8 +1317,8 @@ public class PolicyManagerServlet extends HttpServlet {
if (!policyEntityObjects.isEmpty()) {
for (Object object : policyEntityObjects) {
policyEntity = (PolicyEntity) object;
- String groupEntityquery = "from PolicyGroupEntity where policyid ='"
- + policyEntity.getPolicyId() + "'";
+ String groupEntityquery =
+ "from PolicyGroupEntity where policyid ='" + policyEntity.getPolicyId() + "'";
SimpleBindings pgeParams = new SimpleBindings();
List<Object> groupobject = controller.getDataByQuery(groupEntityquery, pgeParams);
if (!groupobject.isEmpty()) {
@@ -1316,7 +1326,7 @@ public class PolicyManagerServlet extends HttpServlet {
activePolicyName = policyEntity.getScope() + "." + policyEntity.getPolicyName();
} else {
deleteEntityFromEsAndPolicyEntityTable(controller, restController, policyEntity,
- policyNamewithoutExtension);
+ policyNamewithoutExtension);
}
}
}
@@ -1328,8 +1338,8 @@ public class PolicyManagerServlet extends HttpServlet {
if (pdpCheck) {
// Delete from policyVersion table
String getActivePDPPolicyVersion = activePolicyName.replace(".xml", "");
- getActivePDPPolicyVersion = getActivePDPPolicyVersion
- .substring(getActivePDPPolicyVersion.lastIndexOf('.') + 1);
+ getActivePDPPolicyVersion =
+ getActivePDPPolicyVersion.substring(getActivePDPPolicyVersion.lastIndexOf('.') + 1);
String policyVersionQuery = UPDATE_POLICY_VERSION_SET_ACTIVE_VERSION + getActivePDPPolicyVersion
+ "' , highest_version='" + getActivePDPPolicyVersion + "' where policy_name ='"
+ policyNamewithoutExtension.replace(BACKSLASH, ESCAPE_BACKSLASH) + "' and id >0";
@@ -1344,11 +1354,11 @@ public class PolicyManagerServlet extends HttpServlet {
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, ".");
+ 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";
SimpleBindings peParams = new SimpleBindings();
@@ -1363,7 +1373,8 @@ public class PolicyManagerServlet extends HttpServlet {
return success();
}
- String groupEntityquery = "from PolicyGroupEntity where policyid = :policyEntityId and policyid > 0";
+ 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);
@@ -1374,7 +1385,7 @@ public class PolicyManagerServlet extends HttpServlet {
// Delete the entity from Elastic Search Database
deleteEntityFromEsAndPolicyEntityTable(controller, restController, policyEntity,
- policyNamewithoutExtension);
+ policyNamewithoutExtension);
if (version > 1) {
int highestVersion = 0;
@@ -1495,8 +1506,8 @@ public class PolicyManagerServlet extends HttpServlet {
}
private void deleteEntityFromEsAndPolicyEntityTable(final PolicyController controller,
- final PolicyRestController restController, final PolicyEntity policyEntity,
- final String policyNamewithoutExtension) throws IOException {
+ final PolicyRestController restController, final PolicyEntity policyEntity,
+ final String policyNamewithoutExtension) throws IOException {
// Delete the entity from Elastic Search Database
String searchFileName = policyEntity.getScope() + "." + policyEntity.getPolicyName();
restController.deleteElasticData(searchFileName);
@@ -1504,16 +1515,16 @@ public class PolicyManagerServlet extends HttpServlet {
controller.deleteData(policyEntity);
if (policyNamewithoutExtension.contains(CONFIG2)) {
Files.deleteIfExists(Paths.get(PolicyController.getConfigHome() + File.separator
- + policyEntity.getConfigurationData().getConfigurationName()));
+ + policyEntity.getConfigurationData().getConfigurationName()));
controller.deleteData(policyEntity.getConfigurationData());
restController.notifyOtherPAPSToUpdateConfigurations(DELETE, null,
- policyEntity.getConfigurationData().getConfigurationName());
+ policyEntity.getConfigurationData().getConfigurationName());
} else if (policyNamewithoutExtension.contains(ACTION2)) {
Files.deleteIfExists(Paths.get(PolicyController.getActionHome() + File.separator
- + policyEntity.getActionBodyEntity().getActionBodyName()));
+ + policyEntity.getActionBodyEntity().getActionBodyName()));
controller.deleteData(policyEntity.getActionBodyEntity());
restController.notifyOtherPAPSToUpdateConfigurations(DELETE, null,
- policyEntity.getActionBodyEntity().getActionBodyName());
+ policyEntity.getActionBodyEntity().getActionBodyName());
}
}
@@ -1581,7 +1592,7 @@ public class PolicyManagerServlet extends HttpServlet {
try {
String name = getNameFromParams(params);
String validateName =
- name.contains(File.separator) ? name.substring(name.lastIndexOf(File.separator) + 1) : name;
+ name.contains(File.separator) ? name.substring(name.lastIndexOf(File.separator) + 1) : name;
if (!name.isEmpty()) {
String validate = PolicyUtils.policySpecialCharValidator(validateName);
if (!validate.contains(SUCCESS)) {
@@ -1591,8 +1602,8 @@ public class PolicyManagerServlet extends HttpServlet {
if (name.startsWith(File.separator)) {
name = name.substring(1);
}
- PolicyEditorScopes entity = (PolicyEditorScopes) controller.getEntityItem(PolicyEditorScopes.class,
- SCOPE_NAME, name);
+ PolicyEditorScopes entity =
+ (PolicyEditorScopes) controller.getEntityItem(PolicyEditorScopes.class, SCOPE_NAME, name);
if (entity != null) {
return error("Scope Already Exists");
}
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 1fccfda78..a135397af 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
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP Policy Engine
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017, 2019 AT&T Intellectual Property. All rights reserved.
* Modified Copyright (C) 2018 Samsung Electronics Co., Ltd.
* Modifications Copyright (C) 2019 Bell Canada
* ================================================================================
@@ -51,17 +51,18 @@ import org.springframework.mail.javamail.MimeMessageHelper;
* Send policy notification mail depending on the mode for every policy being watched
*/
@Configurable
-public class PolicyNotificationMail{
+public class PolicyNotificationMail {
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 EMAIL_MESSAGE_POSTSCRIPT =
+ "Policy Notification System (please don't respond to this email)";
private static final String ACTIVE_VERSION = "Active Version : ";
private static final String SCOPE_POLICY_NAME = "Scope + Policy Name : ";
private static final String DELETED_TIME = "Deleted Time : ";
private static final String DELETED_BY = "Deleted By : ";
- private static Logger policyLogger = FlexLogger.getLogger(PolicyNotificationMail.class);
+ private static Logger policyLogger = FlexLogger.getLogger(PolicyNotificationMail.class);
@Bean
- public JavaMailSenderImpl javaMailSenderImpl(){
+ public JavaMailSenderImpl javaMailSenderImpl() {
JavaMailSenderImpl mailSender = new JavaMailSenderImpl();
mailSender.setHost(PolicyController.getSmtpHost());
mailSender.setPort(Integer.parseInt(PolicyController.getSmtpPort()));
@@ -79,51 +80,71 @@ public class PolicyNotificationMail{
* 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
*/
- public void sendMail(PolicyVersion entityItem, String policyName, String mode, CommonClassDao policyNotificationDao) {
+ public void sendMail(PolicyVersion entityItem, String policyName, String mode,
+ CommonClassDao policyNotificationDao) {
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 ("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 ("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 ("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 ("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 ("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 ("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;
+ 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 checkPolicyName = findCheckPolicyName(policyName);
@@ -147,7 +168,7 @@ public class PolicyNotificationMail{
if (watchList == null || watchList.isEmpty()) {
policyLogger
- .debug("List of policy being watched is either null or empty, hence return without sending mail");
+ .debug("List of policy being watched is either null or empty, hence return without sending mail");
watchList = new ArrayList<>();
}
return watchList;
@@ -155,11 +176,11 @@ public class PolicyNotificationMail{
private String findPolicyFileName(PolicyVersion entityItem) {
String policyFileName = entityItem.getPolicyName();
- if(policyFileName.contains("/")){
+ if (policyFileName.contains("/")) {
policyFileName = policyFileName.substring(0, policyFileName.indexOf('/'));
policyFileName = policyFileName.replace("/", File.separator);
}
- if(policyFileName.contains("\\")){
+ if (policyFileName.contains("\\")) {
policyFileName = policyFileName.substring(0, policyFileName.indexOf('\\'));
policyFileName = policyFileName.replace("\\", "\\\\");
}
@@ -170,7 +191,7 @@ public class PolicyNotificationMail{
private String findCheckPolicyName(String policyName) {
String checkPolicyName = policyName;
- if(checkPolicyName.endsWith(".xml") || checkPolicyName.contains(".")){
+ if (checkPolicyName.endsWith(".xml") || checkPolicyName.contains(".")) {
checkPolicyName = checkPolicyName.substring(0, checkPolicyName.indexOf('.'));
}
return checkPolicyName;
@@ -179,6 +200,7 @@ public class PolicyNotificationMail{
/**
* 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
@@ -186,21 +208,22 @@ public class PolicyNotificationMail{
* @param checkPolicyName
* @param watchList
*/
- private void composeAndSendMail(String mode, CommonClassDao policyNotificationDao, String subject, String message, String checkPolicyName, List<Object> 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){
+ 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)){
+ // 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 = list.getLoginIds() + "@" + PolicyController.getSmtpEmailExtension();
to = to.trim();
ctx.register(PolicyNotificationMail.class);
ctx.refresh();
@@ -212,11 +235,12 @@ public class PolicyNotificationMail{
mailMsg.setSubject(subject);
mailMsg.setText(message);
mailSender.send(mimeMessage);
- if("Rename".equalsIgnoreCase(mode) || mode.contains("Delete") || mode.contains("Move")){
+ 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);
+ 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 03dbccfd9..9d078a983 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
@@ -27,6 +27,7 @@ import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
+
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.IOException;
@@ -39,8 +40,10 @@ import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Base64;
import java.util.List;
+
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
+
import org.apache.commons.fileupload.FileItem;
import org.apache.commons.fileupload.disk.DiskFileItemFactory;
import org.apache.commons.fileupload.servlet.ServletFileUpload;
@@ -121,8 +124,6 @@ public class PolicyRestController extends RestrictedBaseController {
PolicyRestController.commonClassDao = commonClassDao;
}
-
-
@RequestMapping(value = {"/policycreation/save_policy"}, method = {RequestMethod.POST})
public void policyCreationController(HttpServletRequest request, HttpServletResponse response) {
String userId = UserUtils.getUserSession(request).getOrgUserId();
@@ -227,7 +228,6 @@ public class PolicyRestController extends RestrictedBaseController {
}
}
-
private ResponseEntity<?> sendToPAP(String body, String requestURI, HttpMethod method) {
String papUrl = PolicyController.getPapUrl();
String papID = XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_USERID);
@@ -292,7 +292,6 @@ public class PolicyRestController extends RestrictedBaseController {
headers.set(AUTHORIZATION, BASIC + encoding);
headers.set(CONTENT_TYPE, PolicyController.getContenttype());
-
HttpURLConnection connection = null;
List<FileItem> items;
FileItem item = null;
diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyUserInfoController.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyUserInfoController.java
index 7e0aef2e9..ac11776a1 100644
--- a/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyUserInfoController.java
+++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/admin/PolicyUserInfoController.java
@@ -2,7 +2,7 @@
* ============LICENSE_START=======================================================
* ONAP Policy Engine
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017, 2019 AT&T Intellectual Property. All rights reserved.
* Modifications Copyright (C) 2019 Bell Canada
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
@@ -18,8 +18,11 @@
* limitations under the License.
* ============LICENSE_END=========================================================
*/
+
package org.onap.policy.admin;
+import com.fasterxml.jackson.databind.ObjectMapper;
+
import java.util.HashMap;
import java.util.Map;
@@ -36,8 +39,6 @@ import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
-import com.fasterxml.jackson.databind.ObjectMapper;
-
@Controller
@RequestMapping("/")
public class PolicyUserInfoController extends RestrictedBaseController {
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 c0987c38c..fc1a70466 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
@@ -22,6 +22,14 @@
package org.onap.policy.admin;
+import com.att.research.xacml.api.pap.PAPException;
+import com.att.research.xacml.api.pap.PDPPolicy;
+import com.att.research.xacml.api.pap.PDPStatus;
+import com.att.research.xacml.util.XACMLProperties;
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.type.CollectionType;
+
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
@@ -39,6 +47,7 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
+
import org.apache.commons.io.IOUtils;
import org.onap.policy.common.logging.flexlogger.FlexLogger;
import org.onap.policy.common.logging.flexlogger.Logger;
@@ -55,13 +64,6 @@ import org.onap.policy.xacml.std.pap.StdPDPGroup;
import org.onap.policy.xacml.std.pap.StdPDPItemSetChangeNotifier;
import org.onap.policy.xacml.std.pap.StdPDPPolicy;
import org.onap.policy.xacml.std.pap.StdPDPStatus;
-import com.att.research.xacml.api.pap.PAPException;
-import com.att.research.xacml.api.pap.PDPPolicy;
-import com.att.research.xacml.api.pap.PDPStatus;
-import com.att.research.xacml.util.XACMLProperties;
-import com.fasterxml.jackson.databind.DeserializationFeature;
-import com.fasterxml.jackson.databind.ObjectMapper;
-import com.fasterxml.jackson.databind.type.CollectionType;
/**
* Implementation of the PAPEngine interface that communicates with a PAP engine in a remote servlet through a RESTful
@@ -259,8 +261,6 @@ public class RESTfulPAPEngine extends StdPDPItemSetChangeNotifier implements PAP
"policyType=" + policyType);
}
-
-
@Override
public void publishPolicy(String id, String name, boolean isRoot, InputStream policy, OnapPDPGroup group)
throws PAPException {