* ============LICENSE_START=======================================================
* ONAP-PDP-REST
* ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2017-2018 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
import java.util.Date;
import java.util.UUID;
-import org.glassfish.jersey.spi.Contract;
import org.onap.policy.api.PolicyException;
import org.onap.policy.api.PolicyParameters;
import org.onap.policy.common.logging.flexlogger.FlexLogger;
import org.onap.policy.rest.util.PolicyValidationRequestWrapper;
import org.onap.policy.xacml.api.XACMLErrorConstants;
import org.springframework.http.HttpStatus;
-import org.springframework.stereotype.Controller;
import com.google.common.base.Strings;
// Get Result.
response = microServicesPolicyService.getResult(updateFlag);
break;
+ case Optimization:
+ OptimizationPolicyService optimizationPolicyService = new OptimizationPolicyService(policyName, policyScope, policyParameters, date);
+
+ // Get Result
+ response = optimizationPolicyService.getResult(updateFlag);
+ break;
default:
- String message = XACMLErrorConstants.ERROR_DATA_ISSUE+ " Invalid Config Type Present";
+ message = XACMLErrorConstants.ERROR_DATA_ISSUE+ " Invalid Config Type Present";
LOGGER.error(message);
status = HttpStatus.BAD_REQUEST;
return message;
break;
}
}else {
- String message = XACMLErrorConstants.ERROR_DATA_ISSUE + "No Policy Class found.";
+ message = XACMLErrorConstants.ERROR_DATA_ISSUE + "No Policy Class found.";
LOGGER.error(message);
status = HttpStatus.BAD_REQUEST;
response = message;
try {
PolicyValidationRequestWrapper wrapper = new PolicyValidationRequestWrapper();
PolicyRestAdapter policyData = wrapper.populateRequestParameters(policyParameters);
- responseString = validation.validatePolicy(policyData);
+ if(policyData!=null) {
+ responseString = validation.validatePolicy(policyData);
+ } else {
+ message = XACMLErrorConstants.ERROR_DATA_ISSUE+ " improper JSON object : " + policyParameters.getConfigBody();
+ return false;
+ }
} catch (Exception e) {
LOGGER.error("Exception Occured during Policy Validation" +e);
if(e.getMessage()!=null){
}
if (responseString!=null){
- if("success".equals(responseString.toString())||"success@#".equals(responseString.toString())){
+ String response = responseString.toString().substring(0, 7);
+ if("success".equals(response)) {
return true;
} else {
message = XACMLErrorConstants.ERROR_DATA_ISSUE + PolicyApiUtils.formatResponse(responseString);