* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
- *
+ *
* http://www.apache.org/licenses/LICENSE-2.0
- *
+ *
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
import org.apache.commons.io.IOUtils;
import org.onap.policy.pdp.rest.notifications.NotificationController;
-import org.onap.policy.rest.XACMLRest;
-import org.onap.policy.rest.XACMLRestProperties;
+import org.onap.policy.rest.XacmlRest;
+import org.onap.policy.rest.XacmlRestProperties;
import org.onap.policy.common.logging.flexlogger.FlexLogger;
import org.onap.policy.common.logging.flexlogger.Logger;
/**
* Does the work for loading policy and PIP configurations sent from the PAP
* servlet.
- *
- *
+ *
+ *
*
*/
public class XACMLPdpLoader {
// Reset our official properties the PDP factory
// uses to configure the PDP engine.
//
- XACMLRest.loadXacmlProperties(policyProperties, pipProperties);
+ XacmlRest.loadXacmlProperties(policyProperties, pipProperties);
//
// Dump ALL our properties that we are trying to load
//
}
private static HashMap<String, PolicyDef> policyContainer = null;
-
+
public static synchronized void sendNotification(){
Thread notify = new Thread(){
- public void run(){
+ @Override
+ public void run(){
try{
Thread.sleep(notifyDelay);
NotificationController.sendNotification();
};
notify.start();
}
-
+
public static synchronized void validatePolicies(Properties properties,
StdPDPStatus status) throws PAPException {
Set<String> rootPolicies = XACMLProperties.getRootPolicyIDs(properties);
policyContainer.clear();
}
-
+
public static synchronized void loadPolicy(Properties properties,
StdPDPStatus status, String id, boolean isRoot) throws PAPException {
PolicyDef policy = null;
String location = null;
URI locationURI = null;
- boolean isFile = false;
+ boolean isFile = false;
boolean rougeFile = false;
try {
location = properties.getProperty(id + ".file");
try (InputStream is = Files.newInputStream(Paths.get(location))) {
policy = DOMPolicyDef.load(is);
} catch (Exception e){
- // This Happens if a any issue with the error policyFile. Lets remove it.
+ // This Happens if a any issue with the error policyFile. Lets remove it.
try {
LOGGER.error("Corrupted policy file, deleting: " + location + e);
Files.delete(Paths.get(location));
papUrls.getNext();
break;
}
- urlConnection.setRequestProperty(XACMLRestProperties.PROP_PDP_HTTP_HEADER_ID,
- XACMLProperties.getProperty(XACMLRestProperties.PROP_PDP_ID));
+ urlConnection.setRequestProperty(XacmlRestProperties.PROP_PDP_HTTP_HEADER_ID,
+ XACMLProperties.getProperty(XacmlRestProperties.PROP_PDP_ID));
urlConnection.setRequestProperty("Authorization", "Basic " + encoding);
//
// Now construct the output file name
}
}while(error && errorCount>2);
}
- }
+ }
if (policy != null) {
status.addLoadedPolicy(new StdPDPPolicy(id, isRoot,
locationURI, properties));
try {
LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Corrupted policy file, deleting: " + location);
Files.delete(Paths.get(location));
-
+
} catch (IOException e1) {
LOGGER.error(XACMLErrorConstants.ERROR_SYSTEM_ERROR + e1);
}
* the local directory; if so create a ".file" property for it. - if not,
* get the "<PolicyID>.url" property and try to GET the policy from
* that location (and set the ".file" property)
- *
+ *
* If the ".file" property is created, then true is returned to tell the
* caller that the props object changed.
- *
+ *
* @param props
* @return true/false if anything was changed in the props object
* @throws PAPException
// Open the connection
//
URLConnection urlConnection = url.openConnection();
- urlConnection.setRequestProperty(XACMLRestProperties.PROP_PDP_HTTP_HEADER_ID,
- XACMLProperties.getProperty(XACMLRestProperties.PROP_PDP_ID));
+ urlConnection.setRequestProperty(XacmlRestProperties.PROP_PDP_HTTP_HEADER_ID,
+ XACMLProperties.getProperty(XacmlRestProperties.PROP_PDP_ID));
urlConnection.setRequestProperty("Authorization", "Basic " + encoding);
//
// Copy it to disk
public static synchronized Path getPDPConfig() throws PAPException {
Path config = Paths.get(XACMLProperties
- .getProperty(XACMLRestProperties.PROP_PDP_CONFIG));
+ .getProperty(XacmlRestProperties.PROP_PDP_CONFIG));
if (Files.notExists(config)) {
LOGGER.warn(XACMLErrorConstants.ERROR_PROCESS_FLOW + config.toAbsolutePath().toString() + " does NOT exist.");
//