From ff81f007bd43f2f020c24f5fed341a62093de1ad Mon Sep 17 00:00:00 2001 From: Godin Date: Mon, 18 Oct 2010 10:58:41 +0000 Subject: [PATCH] SONAR-1705: When using the WAR packaging to deploy Sonar, if the "sonar.home" directory doesn't exist a clear message/exception must be displayed --- .../server/platform/DefaultServerFileSystem.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/sonar-server/src/main/java/org/sonar/server/platform/DefaultServerFileSystem.java b/sonar-server/src/main/java/org/sonar/server/platform/DefaultServerFileSystem.java index 9aaedb3870e..9822d909303 100644 --- a/sonar-server/src/main/java/org/sonar/server/platform/DefaultServerFileSystem.java +++ b/sonar-server/src/main/java/org/sonar/server/platform/DefaultServerFileSystem.java @@ -36,7 +36,7 @@ import java.util.List; /** * Introspect the filesystem and the classloader to get extension files at startup. - * + * * @since 2.2 */ public class DefaultServerFileSystem implements ServerFileSystem { @@ -65,13 +65,16 @@ public class DefaultServerFileSystem implements ServerFileSystem { } public void start() { - Logs.INFO.info("Sonar home:" + homeDir.getAbsolutePath()); + Logs.INFO.info("Sonar home: " + homeDir.getAbsolutePath()); + if ( !homeDir.isDirectory() || !homeDir.exists()) { + throw new ServerStartException("Sonar home directory does not exist"); + } if (deployDir == null) { throw new ServerStartException("The target directory to deploy libraries is not set"); } try { - Logs.INFO.info("Deploy dir:" + deployDir.getAbsolutePath()); + Logs.INFO.info("Deploy dir: " + deployDir.getAbsolutePath()); FileUtils.forceMkdir(deployDir); FileUtils.cleanDirectory(deployDir); @@ -180,7 +183,7 @@ public class DefaultServerFileSystem implements ServerFileSystem { private List getFiles(File dir, String... fileSuffixes) { List files = new ArrayList(); if (dir != null && dir.exists()) { - if (fileSuffixes != null && fileSuffixes.length>0) { + if (fileSuffixes != null && fileSuffixes.length > 0) { files.addAll(FileUtils.listFiles(dir, fileSuffixes, false)); } else { files.addAll(FileUtils.listFiles(dir, null, false)); -- 2.39.5