public static final String URI_DATATYPE = "http://www.w3.org/2001/XMLSchema#anyURI";
public static final String RULE_VARIABLE = "var:";
public static final String EMPTY_STRING = "";
- private static final String String = null;
protected static String CONFIG_HOME = null;
protected static String ACTION_HOME = null;
String policyDir = EMPTY_STRING;
String absolutePath = parent.toString();
if (absolutePath != null && !absolutePath.equals(EMPTY_STRING)) {
- policyDir = absolutePath.substring(absolutePath.lastIndexOf("\\") + 1, absolutePath.length());
+ policyDir = absolutePath.substring(absolutePath.lastIndexOf('\\') + 1, absolutePath.length());
if (policyDir == null || policyDir.equals(EMPTY_STRING)) {
- policyDir = absolutePath.substring(absolutePath.lastIndexOf("/") + 1, absolutePath.length());
+ policyDir = absolutePath.substring(absolutePath.lastIndexOf('/') + 1, absolutePath.length());
}
}
if (policyDir != null && !policyDir.equals(EMPTY_STRING)) {
fileName = policyType + "_" + String.format(polcyFileName) + "." + version + ".xml";
}
- if (fileName != null) {
- newFile = Paths.get(parent.toString(), fileName);
- }
- if (Files.notExists(newFile)) {
+
+ newFile = Paths.get(parent.toString(), fileName);
+ if (newFile.toFile().exists()) {
return newFile;
}
return null;
String policyDir = EMPTY_STRING;
String absolutePath = parentPath.toString();
if (absolutePath != null && !absolutePath.equals(EMPTY_STRING)) {
- policyDir = absolutePath.substring(absolutePath.lastIndexOf("\\") + 1, absolutePath.length());
- if (policyDir == null || policyDir.equals(EMPTY_STRING)) {
- policyDir = absolutePath.substring(absolutePath.lastIndexOf("/") + 1, absolutePath.length());
+ policyDir = absolutePath.substring(absolutePath.lastIndexOf('\\') + 1, absolutePath.length());
+ if (policyDir.equals(EMPTY_STRING)) {
+ policyDir = absolutePath.substring(absolutePath.lastIndexOf('/') + 1, absolutePath.length());
}
}
String fileName = "default";
- if (policyDir != null && !policyDir.equals(EMPTY_STRING)) {
- if(policyConfigType.equals("ClosedLoop_PM")){
+ if (!policyDir.equals(EMPTY_STRING)) {
+ if("ClosedLoop_PM".equals(policyConfigType)){
fileName = policyType + "_" + "PM" + "_" +java.lang.String.format(policyFileName) + "." +version +".xml";
- }else if(policyConfigType.equals("ClosedLoop_Fault")){
+ }else if("ClosedLoop_Fault".equals(policyConfigType)){
fileName = policyType + "_" + "Fault" + "_" +java.lang.String.format(policyFileName) + "." + version + ".xml";
- }else if(policyConfigType.equals("Micro Service")){
+ }else if("Micro Service".equals(policyConfigType)){
fileName = policyType + "_" + "MS" + "_" + java.lang.String.format(policyFileName) + "." + version + ".xml";
+ }else if("Optimization".equals(policyConfigType)) {
+ fileName = policyType + "_" + "OOF" + "_" + java.lang.String.format(policyFileName) + "." + version + ".xml";
}
}
- if (fileName != null) {
- newFile = Paths.get(parentPath.toString(), fileName);
- }
- if (Files.notExists(newFile)) {
+
+ newFile = Paths.get(parentPath.toString(), fileName);
+
+ if (newFile.toFile().exists()) {
return newFile;
}
return null;
//
//Does not need to be XACMLPolicyWriterWithPapNotify since it is already in the PAP
//and this transaction is intercepted up stream.
- InputStream inputStream = null;
- try {
- inputStream = XACMLPolicyWriter.getXmlAsInputStream((PolicyType) policyData);
+
+ try(InputStream inputStream = XACMLPolicyWriter.getXmlAsInputStream((PolicyType) policyData)) {
PolicyDef policyDef = DOMPolicyDef.load(inputStream);
if (policyDef == null) {
success.put("validation", "PolicyDef Validation Failed");
} catch (Exception e) {
LOGGER.error("PolicyDef Validation failed"+e);
success.put("error", "Validation Failed");
- }finally{
- try {
- if(inputStream != null)
- inputStream.close();
- } catch (IOException e) {
- LOGGER.error("Exception Occured while closing the input stream"+e);
- }
}
} else {
PolicyLogger.error("Unknown data type sent back.");