import org.onap.policy.common.logging.flexlogger.Logger;
import org.onap.policy.rest.adapter.PolicyRestAdapter;
+import com.att.research.xacml.api.pap.PAPException;
import com.att.research.xacml.std.IdentifierImpl;
import oasis.names.tc.xacml._3_0.core.schema.wd_17.AdviceExpressionType;
//save configuration of the policy based on the policyname
private void saveConfigurations(String policyName, String jsonBody) {
- try {
+
+ if(policyName.endsWith(".xml")){
+ policyName = policyName.replace(".xml", "");
+ }
+ try (PrintWriter out = new PrintWriter(CONFIG_HOME + File.separator+ policyName +".json")){
String body = jsonBody;
- try {
- try{
- //Remove the trapMaxAge in Verification Signature
- body = body.replace(",\"trapMaxAge\":null", "");
- }catch(Exception e){
- LOGGER.debug("No Trap Max Age in JSON body");
- }
- this.policyAdapter.setJsonBody(body);
- } catch (Exception e) {
- LOGGER.error("Exception Occured"+e);
- }
-
- if(policyName.endsWith(".xml")){
- policyName = policyName.replace(".xml", "");
- }
- PrintWriter out = new PrintWriter(CONFIG_HOME + File.separator+ policyName +".json");
+ //Remove the trapMaxAge in Verification Signature
+ body = body.replace(",\"trapMaxAge\":null", "");
+ this.policyAdapter.setJsonBody(body);
out.println(body);
- out.close();
-
} catch (Exception e) {
LOGGER.error("Exception Occured while writing Configuration Data"+e);
}
}
@Override
- public Map<String, String> savePolicies() throws Exception {
+ public Map<String, String> savePolicies() throws PAPException {
Map<String, String> successMap = new HashMap<>();
if(isPolicyExists()){
//This is the method for preparing the policy for saving. We have broken it out
//separately because the fully configured policy is used for multiple things
@Override
- public boolean prepareToSave() throws Exception{
+ public boolean prepareToSave() throws PAPException{
if(isPreparedToSave()){
//we have already done this