import org.onap.policy.rest.adapter.PolicyRestAdapter;
import org.onap.policy.rest.util.PolicyValidation;
import org.onap.policy.rest.util.PolicyValidationRequestWrapper;
-import org.openecomp.portalsdk.core.controller.RestrictedBaseController;
-import org.openecomp.portalsdk.core.web.support.JsonMessage;
+import org.onap.policy.utils.PolicyUtils;
+import org.onap.portalsdk.core.controller.RestrictedBaseController;
+import org.onap.portalsdk.core.web.support.JsonMessage;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
public class PolicyValidationController extends RestrictedBaseController {
private static final Logger LOGGER = FlexLogger.getLogger(PolicyValidationController.class);
-
- public static final String CONFIG_POLICY = "Config";
- public static final String ACTION_POLICY = "Action";
- public static final String DECISION_POLICY = "Decision";
- public static final String CLOSEDLOOP_POLICY = "ClosedLoop_Fault";
- public static final String CLOSEDLOOP_PM = "ClosedLoop_PM";
- public static final String ENFORCER_CONFIG_POLICY= "Enforcer Config";
- public static final String MICROSERVICES="Micro Service";
@RequestMapping(value={"/policyController/validate_policy.htm"}, method={org.springframework.web.bind.annotation.RequestMethod.POST})
public ModelAndView validatePolicy(HttpServletRequest request, HttpServletResponse response) throws IOException{
PolicyValidationRequestWrapper wrapper = new PolicyValidationRequestWrapper();
StringBuilder responseString;
ObjectMapper mapper = new ObjectMapper();
-
+
PolicyRestAdapter policyData = wrapper.populateRequestParameters(request);
responseString = validation.validatePolicy(policyData);
response.setCharacterEncoding("UTF-8");
request.setCharacterEncoding("UTF-8");
PrintWriter out = response.getWriter();
- out.write(e.getMessage());
+ out.write(PolicyUtils.CATCH_EXCEPTION);
}
return null;
}