import org.onap.policy.common.logging.flexlogger.Logger;
import org.onap.policy.rest.adapter.PolicyRestAdapter;
import org.onap.policy.rest.jpa.PolicyEntity;
-import org.openecomp.portalsdk.core.controller.RestrictedBaseController;
+import org.onap.portalsdk.core.controller.RestrictedBaseController;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
private ArrayList<Object> attributeList;
boolean isValidForm = false;
- private String convertDate(String dateTTL, boolean portalType) {
- String formateDate = null;
- String[] date;
- String[] parts;
-
- if (portalType){
- parts = dateTTL.split("-");
- formateDate = parts[2] + "-" + parts[1] + "-" + parts[0] + "T05:00:00.000Z";
- } else {
- date = dateTTL.split("T");
- parts = date[0].split("-");
- formateDate = parts[2] + "-" + parts[1] + "-" + parts[0];
- }
- return formateDate;
- }
-
public void prePopulateBaseConfigPolicyData(PolicyRestAdapter policyAdapter, PolicyEntity entity) {
attributeList = new ArrayList<>();
if (policyAdapter.getPolicyData() instanceof PolicyType) {
policyAdapter.setOldPolicyFileName(policyAdapter.getPolicyName());
policyAdapter.setConfigType(entity.getConfigurationData().getConfigType());
policyAdapter.setConfigBodyData(entity.getConfigurationData().getConfigBody());
- String policyNameValue = policyAdapter.getPolicyName().substring(policyAdapter.getPolicyName().indexOf(' ') + 1);
+ String policyNameValue = policyAdapter.getPolicyName().substring(policyAdapter.getPolicyName().indexOf('_') + 1);
policyAdapter.setPolicyName(policyNameValue);
String description = "";
try{
AttributeDesignatorType designator = match.getAttributeDesignator();
String attributeId = designator.getAttributeId();
// First match in the target is OnapName, so set that value.
- if (attributeId.equals("ONAPName")) {
+ if ("ONAPName".equals(attributeId)) {
policyAdapter.setOnapName(value);
}
- if (attributeId.equals("RiskType")){
+ if ("RiskType".equals(attributeId)){
policyAdapter.setRiskType(value);
}
- if (attributeId.equals("RiskLevel")){
+ if ("RiskLevel".equals(attributeId)){
policyAdapter.setRiskLevel(value);
}
- if (attributeId.equals("guard")){
+ if ("guard".equals(attributeId)){
policyAdapter.setGuard(value);
}
- if (attributeId.equals("TTLDate") && !value.contains("NA")){
- String newDate = convertDate(value, true);
+ if ("TTLDate".equals(attributeId) && !value.contains("NA")){
+ PolicyController controller = new PolicyController();
+ String newDate = controller.convertDate(value);
policyAdapter.setTtlDate(newDate);
}
- if (attributeId.equals("ConfigName")){
+ if ("ConfigName".equals(attributeId)){
policyAdapter.setConfigName(value);
}
// After Onap and Config it is optional to have attributes, so