aboutsummaryrefslogtreecommitdiffstats
path: root/ECOMP-REST/src/main/java/org/openecomp/policy/rest/util/Webapps.java
diff options
context:
space:
mode:
authorRavindra Bakkamanthala <rb7147@att.com>2017-05-31 15:54:24 -0400
committerRavindra Bakkamanthala <rb7147@att.com>2017-05-31 15:57:02 -0400
commitd9007d680d19734d5dc106479784c420236cca4b (patch)
treeb3356847c3d6e1543098b447c1df7d49e7118652 /ECOMP-REST/src/main/java/org/openecomp/policy/rest/util/Webapps.java
parent6a5e800771311208c66ad79ce1bdf76affd144b2 (diff)
[Policy-17] Removed the sql scripts from sdk app
Change-Id: I5b017aad569014c7f12eab35e1dbd1c215f90ebe Signed-off-by: Ravindra Bakkamanthala <rb7147@att.com>
Diffstat (limited to 'ECOMP-REST/src/main/java/org/openecomp/policy/rest/util/Webapps.java')
-rw-r--r--ECOMP-REST/src/main/java/org/openecomp/policy/rest/util/Webapps.java63
1 files changed, 34 insertions, 29 deletions
diff --git a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/util/Webapps.java b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/util/Webapps.java
index ef1eecf27..5cffb998a 100644
--- a/ECOMP-REST/src/main/java/org/openecomp/policy/rest/util/Webapps.java
+++ b/ECOMP-REST/src/main/java/org/openecomp/policy/rest/util/Webapps.java
@@ -38,7 +38,7 @@ import org.openecomp.policy.common.logging.eelf.PolicyLogger;
public class Webapps {
private static String actionHome = null;
private static String configHome = null;
- private static Log LOGGER = LogFactory.getLog(Webapps.class);
+ private static Log logger = LogFactory.getLog(Webapps.class);
private Webapps() {
}
@@ -47,6 +47,7 @@ public class Webapps {
try {
loadWebapps();
} catch (Exception e) {
+ logger.error("Exception Occured while loading webapps"+e);
return null;
}
return configHome;
@@ -56,55 +57,59 @@ public class Webapps {
try {
loadWebapps();
} catch (Exception e) {
+ logger.error("Exception Occured while loading webapps"+e);
return null;
}
return actionHome;
}
private static void loadWebapps() throws Exception{
+ String errorMessageName = "Invalid Webapps Path Location property :";
if(actionHome == null || configHome == null){
Path webappsPath = Paths.get(XACMLProperties.getProperty(XACMLRestProperties.PROP_PAP_WEBAPPS));
//Sanity Check
if (webappsPath == null) {
- LOGGER.error("Invalid Webapps Path Location property : " + XACMLRestProperties.PROP_PAP_WEBAPPS);
- PolicyLogger.error("Invalid Webapps Path Location property : " + XACMLRestProperties.PROP_PAP_WEBAPPS);
- throw new Exception("Invalid Webapps Path Location property : " + XACMLRestProperties.PROP_PAP_WEBAPPS);
+ logger.error(errorMessageName + XACMLRestProperties.PROP_PAP_WEBAPPS);
+ PolicyLogger.error(errorMessageName + XACMLRestProperties.PROP_PAP_WEBAPPS);
+ throw new Exception(errorMessageName + XACMLRestProperties.PROP_PAP_WEBAPPS);
}
Path webappsPathConfig;
Path webappsPathAction;
- if(webappsPath.toString().contains("\\"))
- {
+ if(webappsPath.toString().contains("\\")){
webappsPathConfig = Paths.get(webappsPath.toString()+"\\Config");
webappsPathAction = Paths.get(webappsPath.toString()+"\\Action");
- }
- else
- {
+ }else{
webappsPathConfig = Paths.get(webappsPath.toString()+"/Config");
webappsPathAction = Paths.get(webappsPath.toString()+"/Action");
}
- if (Files.notExists(webappsPathConfig))
- {
- try {
- Files.createDirectories(webappsPathConfig);
- } catch (IOException e) {
- LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Failed to create config directory: "
- + webappsPathConfig.toAbsolutePath().toString(), e);
- PolicyLogger.error(MessageCodes.ERROR_PROCESS_FLOW, e, "Webapps", "Failed to create config directory");
- }
- }
- if (Files.notExists(webappsPathAction))
- {
- try {
- Files.createDirectories(webappsPathAction);
- } catch (IOException e) {
- LOGGER.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Failed to create config directory: "
- + webappsPathAction.toAbsolutePath().toString(), e);
- PolicyLogger.error(MessageCodes.ERROR_PROCESS_FLOW, e, "Webapps", "Failed to create config directory");
- }
- }
+
+ checkConfigActionHomeExists(webappsPathConfig, webappsPathAction);
+
actionHome = webappsPathAction.toString();
configHome = webappsPathConfig.toString();
}
}
+
+ private static void checkConfigActionHomeExists(Path webappsPathConfig, Path webappsPathAction){
+ if (!webappsPathConfig.toFile().exists()){
+ try {
+ Files.createDirectories(webappsPathConfig);
+ } catch (IOException e) {
+ logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Failed to create config directory: "
+ + webappsPathConfig.toAbsolutePath().toString(), e);
+ PolicyLogger.error(MessageCodes.ERROR_PROCESS_FLOW, e, "Webapps", "Failed to create config directory");
+ }
+ }
+
+ if (!webappsPathAction.toFile().exists()){
+ try {
+ Files.createDirectories(webappsPathAction);
+ } catch (IOException e) {
+ logger.error(XACMLErrorConstants.ERROR_PROCESS_FLOW + "Failed to create config directory: "
+ + webappsPathAction.toAbsolutePath().toString(), e);
+ PolicyLogger.error(MessageCodes.ERROR_PROCESS_FLOW, e, "Webapps", "Failed to create config directory");
+ }
+ }
+ }
}