+ public MicroServicesPolicyService(String policyName, String policyScope, PolicyParameters policyParameters,
+ String date) {
+ this.policyParameters = policyParameters;
+ this.policyName = policyName;
+ this.policyScope = policyScope;
+ this.date = date;
+ papServices = new PAPServices();
+ }
+
+ public Boolean getValidation() {
+ if (policyParameters.getConfigBody() == null) {
+ message = XACMLErrorConstants.ERROR_DATA_ISSUE + " No Micro Service or Attributes Config Body Present";
+ return false;
+ }
+ try {
+ microServiceAttributes = PolicyApiUtils.stringToJsonObject(policyParameters.getConfigBody());
+ } catch (JsonException | IllegalStateException e) {
+ message =
+ XACMLErrorConstants.ERROR_DATA_ISSUE + " improper JSON object : " +
+ policyParameters.getConfigBody();
+ LOGGER.error("Error while parsing JSON body for MicroService Policy creation. ", e);
+ return false;
+ }
+ onapName = policyParameters.getOnapName();
+ if (onapName == null || onapName.trim().isEmpty()) {
+ message = XACMLErrorConstants.ERROR_DATA_ISSUE + "No Onap Name given.";
+ return false;
+ }
+ boolean levelCheck = 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;