* 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.
import org.onap.policy.rest.dao.CommonClassDao;
import org.onap.policy.rest.jpa.ActionBodyEntity;
import org.onap.policy.rest.jpa.ConfigurationDataEntity;
-import org.onap.policy.rest.jpa.DCAEuuid;
+import org.onap.policy.rest.jpa.DcaeUuid;
import org.onap.policy.rest.jpa.GroupPolicyScopeList;
import org.onap.policy.rest.jpa.MicroServiceConfigName;
import org.onap.policy.rest.jpa.MicroServiceLocation;
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;
/**
* This is for downloading existing policy.
- *
+ *
* @param request HttpServletRequest
* @param response HttpServletResponse
* @throws IOException error out
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);
}
/**
* This is to upload a policy and save it to database.
- *
+ *
* @param file String
* @param request HttpServletRequest
* @return JSONObject
// Check if the Role and Scope Size are Null get the values from db.
List<Object> userRoles = controller.getRoles(userId);
Pair<Set<String>, List<String>> pair = org.onap.policy.utils.UserUtils.checkRoleAndScope(userRoles);
- List<String> roles = pair.u;
- Set<String> scopes = pair.t;
+ List<String> roles = pair.second;
+ Set<String> scopes = pair.first;
try (FileInputStream excelFile = new FileInputStream(new File(file));
HSSFWorkbook workbook = new HSSFWorkbook(excelFile)) {
/**
* This is to validate all matching required fields.
- *
+ *
* @param policyName String
* @param jsonString String
* @return String
private String validUuid(String uuid) {
String message = null;
if (uuid != null) {
- List<String> uuids = commonClassDao.getDataByColumn(DCAEuuid.class, "name");
+ List<String> uuids = commonClassDao.getDataByColumn(DcaeUuid.class, "name");
if (uuids != null && !(uuids.stream().filter(o -> o.equals(uuid)).findFirst().isPresent())) {
message = POLICY + policyName + " uuid: " + uuid + NOTVALID;
}
return false;
}
+ @SuppressWarnings("rawtypes")
private boolean isContinue(List<String> roles, String scope, UserInfo userInfo, Set scopes) {
if (roles.contains(admin) || roles.contains(editor)) {
if (scopes.isEmpty()) {
saveVersion(policyEntity, scope, userId); //
// Notify Other paps regarding Export Policy.
PolicyRestController restController = new PolicyRestController();
- restController.notifyOtherPAPSToUpdateConfigurations("exportPolicy", configName, null);
+ restController.notifyOtherPapsToUpdateConfigurations("exportPolicy", configName, null);
}
}
}