X-Git-Url: https://gerrit.onap.org/r/gitweb?p=policy%2Fengine.git;a=blobdiff_plain;f=POLICY-SDK-APP%2Fsrc%2Fmain%2Fjava%2Forg%2Fonap%2Fpolicy%2Fcontroller%2FPolicyExportAndImportController.java;h=8f508ca3133a6f9cfb4bc36166ae9cc762839445;hp=fb566f37d6b85de30ef2730f56d8e4e584a04fdc;hb=1e61676b77dd09659027b8984f050df7e8538526;hpb=dfd9c0a09c35e4b5b4b61be08b8424e4a3d0d500 diff --git a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PolicyExportAndImportController.java b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PolicyExportAndImportController.java index fb566f37d..8f508ca31 100644 --- a/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PolicyExportAndImportController.java +++ b/POLICY-SDK-APP/src/main/java/org/onap/policy/controller/PolicyExportAndImportController.java @@ -7,9 +7,9 @@ * 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. @@ -64,6 +64,7 @@ import org.onap.policy.rest.jpa.PolicyEditorScopes; import org.onap.policy.rest.jpa.PolicyEntity; import org.onap.policy.rest.jpa.PolicyVersion; import org.onap.policy.rest.jpa.UserInfo; +import org.onap.policy.utils.PolicyUtils; import org.onap.policy.utils.UserUtils.Pair; import org.onap.policy.xacml.api.XACMLErrorConstants; import org.onap.portalsdk.core.controller.RestrictedBaseController; @@ -117,7 +118,7 @@ public class PolicyExportAndImportController extends RestrictedBaseController { /** * This is for downloading existing policy. - * + * * @param request HttpServletRequest * @param response HttpServletResponse * @throws IOException error out @@ -174,14 +175,14 @@ public class PolicyExportAndImportController extends RestrictedBaseController { workBook2.write(fos); fos.flush(); - response.setContentType("application / json"); - request.setCharacterEncoding("UTF-8"); + response.setContentType(PolicyUtils.APPLICATION_JSON); + request.setCharacterEncoding(PolicyUtils.CHARACTER_ENCODING); PrintWriter out = response.getWriter(); String successMap = file.substring(file.lastIndexOf("webapps") + 8); String responseString = mapper.writeValueAsString(successMap); - JSONObject j = new JSONObject("{data: " + responseString + "}"); - out.write(j.toString()); + JSONObject json = new JSONObject("{data: " + responseString + "}"); + out.write(json.toString()); } catch (Exception e) { logger.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + "Exception Occured while Exporting Policies" + e); } @@ -250,7 +251,7 @@ public class PolicyExportAndImportController extends RestrictedBaseController { /** * This is to upload a policy and save it to database. - * + * * @param file String * @param request HttpServletRequest * @return JSONObject @@ -268,8 +269,8 @@ public class PolicyExportAndImportController extends RestrictedBaseController { // Check if the Role and Scope Size are Null get the values from db. List userRoles = controller.getRoles(userId); Pair, List> pair = org.onap.policy.utils.UserUtils.checkRoleAndScope(userRoles); - List roles = pair.u; - Set scopes = pair.t; + List roles = pair.second; + Set scopes = pair.first; try (FileInputStream excelFile = new FileInputStream(new File(file)); HSSFWorkbook workbook = new HSSFWorkbook(excelFile)) { @@ -358,7 +359,7 @@ public class PolicyExportAndImportController extends RestrictedBaseController { /** * This is to validate all matching required fields. - * + * * @param policyName String * @param jsonString String * @return String @@ -563,6 +564,7 @@ public class PolicyExportAndImportController extends RestrictedBaseController { return false; } + @SuppressWarnings("rawtypes") private boolean isContinue(List roles, String scope, UserInfo userInfo, Set scopes) { if (roles.contains(admin) || roles.contains(editor)) { if (scopes.isEmpty()) { @@ -769,7 +771,7 @@ public class PolicyExportAndImportController extends RestrictedBaseController { saveVersion(policyEntity, scope, userId); // // Notify Other paps regarding Export Policy. PolicyRestController restController = new PolicyRestController(); - restController.notifyOtherPAPSToUpdateConfigurations("exportPolicy", configName, null); + restController.notifyOtherPapsToUpdateConfigurations("exportPolicy", configName, null); } } }