/** * Looping through installed scripts and checking if scriptName * is there. If so returns it otherwise returns null. */ private ScriptText findInstalledScript(String scriptName) { for(ScriptText installedScript: installedScripts) { if(installedScript.getFileName().equals(scriptName)) return installedScript; } return null; } }
/** * Deletes rules from Byteman. * * @param scripts * rule scripts to be deleted from Byteman * * @return the results of the deletion * * @throws Exception * if the request failed */ public String deleteScripts(List<ScriptText> scripts) throws Exception { if (scripts == null || scripts.size() == 0) { return ""; } StringBuilder str = new StringBuilder("DELETE\n"); for (ScriptText scriptText : scripts) { str.append("SCRIPT " + scriptText.getFileName() + '\n'); str.append(scriptText.getText()).append('\n'); str.append("ENDSCRIPT\n"); } str.append("ENDDELETE\n"); return submitRequest(str.toString()); }
/** * Deploys rule scripts into Byteman * * @param scripts * scripts to be deployed to Byteman * * @return the results of the deployment * * @throws Exception * if the request failed */ public String addScripts(List<ScriptText> scripts) throws Exception { if (scripts == null || scripts.size() == 0) { return ""; } StringBuilder str = new StringBuilder("LOAD\n"); for (ScriptText scriptText : scripts) { str.append("SCRIPT " + scriptText.getFileName() + '\n'); str.append(scriptText.getText()).append('\n'); str.append("ENDSCRIPT\n"); } str.append("ENDLOAD\n"); return submitRequest(str.toString()); }
ScriptText updatedScriptText = null; for(ScriptText scriptText : installedScripts) { if(scriptText.getFileName().equals(redirectedSubmissionsFile.getCanonicalPath())) { installedScriptText = scriptText; updatedScriptText = new ScriptText(installedScriptText.getFileName(), installedScriptText.getText()+scriptString); } else { updatedScriptText = new ScriptText(redirectedSubmissionsFile.getCanonicalPath(), scriptString);