package org.onap.policy.controller;
+import java.io.BufferedWriter;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
+import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
import org.json.JSONObject;
import org.onap.policy.common.logging.flexlogger.FlexLogger;
import org.onap.policy.common.logging.flexlogger.Logger;
+import org.onap.policy.model.Roles;
import org.onap.policy.rest.adapter.PolicyExportAdapter;
import org.onap.policy.rest.dao.CommonClassDao;
import org.onap.policy.rest.jpa.ActionBodyEntity;
import org.onap.policy.rest.jpa.PolicyVersion;
import org.onap.policy.rest.jpa.UserInfo;
import org.onap.policy.xacml.api.XACMLErrorConstants;
-import org.openecomp.policy.model.Roles;
-import org.openecomp.portalsdk.core.controller.RestrictedBaseController;
-import org.openecomp.portalsdk.core.web.support.UserUtils;
+import org.onap.portalsdk.core.controller.RestrictedBaseController;
+import org.onap.portalsdk.core.web.support.UserUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
request.setCharacterEncoding("UTF-8");
PrintWriter out = response.getWriter();
- String successMap = file.toString().substring(file.toString().lastIndexOf("webapps")+8);
+ String successMap = file.substring(file.lastIndexOf("webapps")+8);
String responseString = mapper.writeValueAsString(successMap);
JSONObject j = new JSONObject("{data: " + responseString + "}");
out.write(j.toString());
Iterator<Row> rowIterator = datatypeSheet.iterator();
while (rowIterator.hasNext()) {
+ finalColumn = false;
policyEntity = new PolicyEntity();
configurationDataEntity = new ConfigurationDataEntity();
actionBodyEntity = new ActionBodyEntity();
}else{
//1. if Role contains admin, then check if parent scope has role admin, if not don't create a scope and add to list.
if(roles.contains(ADMIN)){
- String scopeCheck = scope.substring(0, scope.lastIndexOf("."));
+ String scopeCheck = scope.substring(0, scope.lastIndexOf('.'));
if(scopes.contains(scopeCheck)){
PolicyEditorScopes policyEditorScopeEntity = new PolicyEditorScopes();
policyEditorScopeEntity.setScopeName(scope);
configurationDataEntity.setCreatedBy(userId);
configurationDataEntity.setModifiedBy(userId);
commonClassDao.save(configurationDataEntity);
+ try(FileWriter fw = new FileWriter(PolicyController.getConfigHome() + File.separator + configName)){
+ BufferedWriter bw = new BufferedWriter(fw);
+ bw.write(configurationDataEntity.getConfigBody());
+ bw.close();
+ } catch (IOException e) {
+ logger.error("Exception Occured While cloning the configuration file",e);
+ }
}
if(actionExists){
actionBodyEntity.setDeleted(false);
actionBodyEntity.setCreatedBy(userId);
actionBodyEntity.setModifiedBy(userId);
commonClassDao.save(actionBodyEntity);
+ try(FileWriter fw = new FileWriter(PolicyController.getActionHome() + File.separator + actionBodyEntity.getActionBodyName())) {
+ BufferedWriter bw = new BufferedWriter(fw);
+ bw.write(actionBodyEntity.getActionBody());
+ bw.close();
+ } catch (IOException e) {
+ logger.error("Exception Occured While cloning the configuration file",e);
+ }
}
if(configName != null){
if(configName.contains("Config_")){
policyVersion = new PolicyVersion();
String policyName = policyEntity.getPolicyName().replace(".xml", "");
- int version = Integer.parseInt(policyName.substring(policyName.lastIndexOf(".")+1));
- policyName = policyName.substring(0, policyName.lastIndexOf("."));
+ int version = Integer.parseInt(policyName.substring(policyName.lastIndexOf('.')+1));
+ policyName = policyName.substring(0, policyName.lastIndexOf('.'));
policyVersion.setPolicyName(scope.replace(".", File.separator) + File.separator + policyName);
policyVersion.setActiveVersion(version);
//return the column header name value
private String getCellHeaderName(Cell cell){
- String cellHeaderName = cell.getSheet().getRow(0).getCell(cell.getColumnIndex()).getRichStringCellValue().toString();
- return cellHeaderName;
+ return cell.getSheet().getRow(0).getCell(cell.getColumnIndex()).getRichStringCellValue().toString();
}
}