- public String getResult(boolean updateFlag) throws PolicyException {
- String response = null;
- String operation = null;
- if (updateFlag){
- operation = "update";
- } else {
- operation = "create";
- }
- Map<String,String> ruleAttributes = null;
- if(policyParameters.getAttributes()!=null){
- ruleAttributes = policyParameters.getAttributes().get(AttributeType.RULE);
- }
- // Create Policy
- StdPAPPolicy newPAPPolicy = new StdPAPPolicy("BRMS_Raw",policyName,policyParameters.getPolicyDescription(),
- "BRMS_RAW_RULE",updateFlag,policyScope, ruleAttributes, 0, "DROOLS",
- brmsRawBody, policyParameters.getRiskLevel(),
- policyParameters.getRiskType(), String.valueOf(policyParameters.getGuard()), date, policyParameters.getControllerName(), policyParameters.getDependencyNames());
- // Send JSON to PAP
- response = (String) papServices.callPAP(newPAPPolicy, new String[] {"operation="+operation, "apiflag=api", "policyType=Config"}, policyParameters.getRequestID(), "ConfigBrmsRaw");
- LOGGER.info(response);
- return response;
- }
+ public Boolean getValidation() {
+ brmsRawBody = policyParameters.getConfigBody();
+ if (brmsRawBody == null || brmsRawBody.trim().isEmpty()) {
+ message = XACMLErrorConstants.ERROR_DATA_ISSUE + " No Rule Body given";
+ return false;
+ }
+ message = PolicyUtils.brmsRawValidate(brmsRawBody);
+ if (message.contains("[ERR")) {
+ message = XACMLErrorConstants.ERROR_DATA_ISSUE + "Raw rule given is invalid" + message;
+ return false;
+ }
+ levelCheck = PolicyApiUtils.isNumeric(policyParameters.getRiskLevel());
+ if (!levelCheck) {
+ message = XACMLErrorConstants.ERROR_DATA_ISSUE + "Incorrect Risk Level given.";
+ return false;
+ }
+ return true;
+ }
+
+ public String getMessage() {
+ return message;
+ }
+
+ public String getResult(boolean updateFlag) throws PolicyException {
+ String response = null;
+ String operation = null;
+ if (updateFlag) {
+ operation = "update";
+ } else {
+ operation = "create";
+ }
+ Map<String, String> ruleAttributes = null;
+ if (policyParameters.getAttributes() != null) {
+ ruleAttributes = policyParameters.getAttributes().get(AttributeType.RULE);
+ }
+ // Create Policy
+ StdPAPPolicy newPAPPolicy = new StdPAPPolicy("BRMS_Raw", policyName, policyParameters.getPolicyDescription(),
+ "BRMS_RAW_RULE", updateFlag, policyScope, ruleAttributes, 0, "DROOLS",
+ brmsRawBody, policyParameters.getRiskLevel(),
+ policyParameters.getRiskType(), String.valueOf(policyParameters.getGuard()), date,
+ policyParameters.getControllerName(), policyParameters.getDependencyNames());
+ // Send JSON to PAP
+ response = (String) papServices.callPAP(newPAPPolicy, new String[]{"operation=" + operation, "apiflag=api",
+ "policyType=Config"}, policyParameters.getRequestID(), "ConfigBrmsRaw");
+ LOGGER.info(response);
+ return response;
+ }