use of com.ge.verdict.gsn.GSNInterface in project VERDICT by ge-high-assurance.
the class App method runGsn.
/**
* call the GSN creation interface from verdict-assurance-case Behavior: 1. If security cases
* have not been enabled - Creates normal GSN for every requirement specified 2. If security
* cases have been enabled - creates a security GSN for every cyber requirement that is
* specified - creates a normal GSN for all other requirements
*
* @param rootGoalId
* @param gsnOutputDir
* @param soteriaOutputDir
* @param caseAadlPath
*/
private static void runGsn(String inputLine, String gsnOutputDir, String soteriaOutputDir, String modelAadlPath, boolean generateXml, boolean securityCases, String modelName, String hostSTEMDir) throws VerdictRunException {
logHeader("GSN");
// The prefix for SOteria++ text outputs that are linked from solution nodes
String soteriaOutputLinkPathPrefix = hostSTEMDir + "/Output/Soteria_Output/" + modelName;
// Fetch the model first
File modelXml = new File(gsnOutputDir, "modelXML.xml");
// Fetch the DeliveryDrone model from the XML
Model model = VdmTranslator.unmarshalFromXml(modelXml);
// get all cyber Ids
List<String> cyberIds = new ArrayList<>();
for (verdict.vdm.vdm_model.CyberReq aCyberReq : model.getCyberReq()) {
cyberIds.add(aCyberReq.getId());
}
// splitting the input by ';'
String[] inputIds = inputLine.split(";");
List<String> allIds = new ArrayList<>();
for (String inputId : inputIds) {
allIds.add(inputId);
}
// remove duplicates
List<String> duplicateFreeIds = new ArrayList<>(new HashSet<>(allIds));
for (String id : duplicateFreeIds) {
// if cyberId
if (cyberIds.contains(id)) {
if (securityCases) {
// if security is enabled
// calling the function to create security GSN artefacts
SecurityGSNInterface createGsnObj = new SecurityGSNInterface();
try {
createGsnObj.runGsnArtifactsGenerator(id, gsnOutputDir, soteriaOutputDir, modelAadlPath, securityCases, generateXml, soteriaOutputLinkPathPrefix, hostSTEMDir);
} catch (IOException | ParserConfigurationException | SAXException e) {
// TODO Auto-generated catch block
throw new VerdictRunException("Failed to create GSN fragments", e);
}
} else {
// calling the function to create normal GSN artefacts
GSNInterface createGsnObj = new GSNInterface();
try {
createGsnObj.runGsnArtifactsGenerator(id, gsnOutputDir, soteriaOutputDir, modelAadlPath, generateXml, soteriaOutputLinkPathPrefix, hostSTEMDir);
} catch (IOException | ParserConfigurationException | SAXException e) {
// TODO Auto-generated catch block
throw new VerdictRunException("Failed to create GSN fragments", e);
}
}
} else {
// if not cyberId
// calling the function to create normal GSN artefacts
GSNInterface createGsnObj = new GSNInterface();
try {
createGsnObj.runGsnArtifactsGenerator(id, gsnOutputDir, soteriaOutputDir, modelAadlPath, generateXml, soteriaOutputLinkPathPrefix, hostSTEMDir);
} catch (IOException | ParserConfigurationException | SAXException e) {
// TODO Auto-generated catch block
throw new VerdictRunException("Failed to create GSN fragments", e);
}
}
}
// if running inside docker
if (isRunningInsideDocker()) {
// sleep for three seconds to allow docker to exit gracefully
try {
TimeUnit.SECONDS.sleep(3);
} catch (InterruptedException e) {
throw new VerdictRunException("Failed to create GSN fragments. Thread.sleep exception.", e);
}
}
logHeader("Finished");
}
Aggregations