import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
- import java.util.Iterator;
import java.util.List;
import java.util.Properties;
import java.util.Scanner;
import org.onap.policy.xacml.api.pap.OnapPDP;
import org.onap.policy.xacml.api.pap.OnapPDPGroup;
import org.onap.policy.xacml.api.pap.PAPPolicyEngine;
- import org.onap.policy.xacml.std.pap.StdPAPPolicy;
import org.onap.policy.xacml.std.pap.StdPDP;
import org.onap.policy.xacml.std.pap.StdPDPGroup;
import org.onap.policy.xacml.std.pap.StdPDPItemSetChangeNotifier.StdItemSetChangeListener;
//If the selected policy is in the group we must remove the old version of it
LOGGER.info("Removing old version of the policy");
for(PDPPolicy existingPolicy : currentPoliciesInGroup) {
- if (existingPolicy.getName().equals(policy.getName())){
- if (!existingPolicy.getId().equals(policy.getId())) {
- group.removePolicy(existingPolicy);
- LOGGER.info("Removing policy: " + existingPolicy);
- break;
- }
+ if (existingPolicy.getName().equals(policy.getName()) && !existingPolicy.getId().equals(policy.getId())){
+ group.removePolicy(existingPolicy);
+ LOGGER.info("Removing policy: " + existingPolicy);
+ break;
}
}
*/
if(apiflag != null){
- // get the request content into a String
- String json = null;
// read the inputStream into a buffer
java.util.Scanner scanner = new java.util.Scanner(request.getInputStream());
scanner.useDelimiter("\\A");
- json = scanner.hasNext() ? scanner.next() : "";
+ String json = scanner.hasNext() ? scanner.next() : "";
scanner.close();
LOGGER.info("PushPolicy API request: " + json);
}
//delete temporary policy file from the bin directory
- Files.deleteIfExists(Paths.get(policy.getId()));
+ if(policy != null) {
+ Files.deleteIfExists(Paths.get(policy.getId()));
+ }
}
} catch (Exception e) {
public UpdatePDPThread(OnapPDP pdp, ONAPLoggingContext loggingContext) {
this.pdp = pdp;
- if (!(loggingContext == null)) {
- if (!(loggingContext.getRequestID() == null) || (loggingContext.getRequestID() == "")) {
+ if ((loggingContext != null) && (loggingContext.getRequestID() != null || loggingContext.getRequestID() == "")) {
this.requestId = loggingContext.getRequestID();
- }
}
this.loggingContext = loggingContext;
}
HttpURLConnection connection = null;
// get a new logging context for the thread
try {
- if (this.loggingContext.equals(null)) {
+ if (this.loggingContext == null) {
loggingContext = new ONAPLoggingContext(baseLoggingContext);
}
} catch (Exception e) {
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;
return false;
}
- if(policyParameters.getPolicyClass() != null){
- if ("Config".equals(policyParameters.getPolicyClass().toString())){
- String policyConfigType = policyParameters.getPolicyConfigType().toString();
- if(!"BRMS_Param".equalsIgnoreCase(policyConfigType)){
- if(Strings.isNullOrEmpty(policyParameters.getConfigBody())){
- message = XACMLErrorConstants.ERROR_DATA_ISSUE + "ConfigBody: No Config Body given";
- LOGGER.error("Common validation did not return success: " + message);
- return false;
- }
- }
- }
+ if(policyParameters.getPolicyClass() != null && "Config".equals(policyParameters.getPolicyClass().toString())){
+ String policyConfigType = policyParameters.getPolicyConfigType().toString();
+ if(!"BRMS_Param".equalsIgnoreCase(policyConfigType) && Strings.isNullOrEmpty(policyParameters.getConfigBody())){
+ message = XACMLErrorConstants.ERROR_DATA_ISSUE + "ConfigBody: No Config Body given";
+ LOGGER.error("Common validation did not return success: " + message);
+ return false;
+ }
}
try {