if(serverGroups != null || allServerGroups) {
throw new OperationFormatException(this.serverGroups.getFullName() + " and " + this.allServerGroups.getFullName() +
" can't be used in combination with a CLI archive.");
}
MountHandle root;
try {
root = extractArchive(f);
} catch (IOException e) {
throw new OperationFormatException("Unable to extract archive '" + f.getAbsolutePath() + "' to temporary location");
}
final File currentDir = ctx.getCurrentDir();
ctx.setCurrentDir(root.getMountSource());
String holdbackBatch = activateNewBatch(ctx);
try {
String script = this.script.getValue(args);
if (script == null) {
script = "deploy.scr";
}
File scriptFile = new File(ctx.getCurrentDir(),script);
if (!scriptFile.exists()) {
throw new CommandFormatException("ERROR: script '" + script + "' not found.");
}
try {
BufferedReader reader = new BufferedReader(new FileReader(scriptFile));
String line = reader.readLine();
while (!ctx.isTerminated() && line != null) {
ctx.handle(line);
line = reader.readLine();
}
} catch (FileNotFoundException e) {
throw new CommandFormatException("ERROR: script '" + script + "' not found.");
} catch (IOException e) {
throw new CommandFormatException("Failed to read the next command from " + scriptFile.getName() + ": " + e.getMessage(), e);
} catch (CommandLineException e) {
throw new CommandFormatException(e.getMessage(), e);
}
return ctx.getBatchManager().getActiveBatch().toRequest();
} finally {
// reset current dir in context
ctx.setCurrentDir(currentDir);
discardBatch(ctx, holdbackBatch);
try {
root.close();
} catch (IOException ignore) {}
}
}
// actually, the deployment is added before it is deployed