ServerEnvironment env = null;
try {
env = serverEnvironment.getValue();
}
catch (IllegalStateException ise) {
throw new StartException(ServerEnvironment.class.getSimpleName() + " was not injected");
}
File deployDir = env.getServerDeployDir();
if (deployDir == null)
throw new IllegalArgumentException("deployDir is null");
if (deployDir.exists()) {
if (!deployDir.isDirectory()) {
throw new IllegalStateException("Deployment repository root " + deployDir.getAbsolutePath() + " is not a directory");
}
else if (!deployDir.canWrite()) {
throw new IllegalStateException("Deployment repository root " + deployDir.getAbsolutePath() + " is not a writable");
}
}
else if (!deployDir.mkdirs()) {
throw new IllegalStateException("Failed to create a directory at " + deployDir.getAbsolutePath());
}
this.repoRoot = deployDir;
try {
this.messageDigest = MessageDigest.getInstance("SHA-1");
} catch (NoSuchAlgorithmException e) {
throw new StartException("Cannot obtain SHA-1 " + MessageDigest.class.getSimpleName(), e);
}
log.debugf("%s started", ServerDeploymentRepository.class.getSimpleName());
}