मुख्य सामग्री पर जाएँ

स्टैंडअलोन

सारांश - स्वतंत्र

स्टैंडअलोन फ़ाइल सारांश एक com.glasswall.analysissummary.FileSummary ऑब्जेक्ट बनाकर जनरेट किया जा सकता है।

API

कंस्ट्रक्टर्स

public FileSummary(
Path inputFilePath,
int sessionStatus,
String lastErrorMessage,
String processMessage,
InputStream analysisInputStream,
boolean skipUnsupportedFileTypes
) throws SAXException, ParserConfigurationException, IOException

पैरामीटर्स:

  • Path inputFilePath - उस फ़ाइल का file path जिसे process किया गया था।
  • int sessionStatus - GW2RunSession से return status।
  • String lastErrorMessage - GW2FileErrorMsg से त्रुटि संदेश। यदि यह null है या खाली है, तो इसे सारांश में शामिल नहीं किया जाएगा।
  • String processMessage - GW2FileSessionStatus से प्रोसेस संदेश। यदि यह null है या खाली है, तो इसे सारांश में शामिल नहीं किया जाएगा।
  • InputStream analysisInputStream - शामिल की जाने वाली analysis report वाला input stream।
  • boolean skipUnsupportedFileTypes - यह दर्शाने वाला boolean कि unsupported फ़ाइल प्रकारों को छोड़ा जाना चाहिए या नहीं।

इंस्टेंस मेथड्स

public String getFileName()

प्रोसेस की गई फ़ाइल का फ़ाइलनाम लौटाता है।

Returns: प्रोसेस की गई फ़ाइल का absolute फ़ाइल पथ।


public String getProcessMessage()

फ़ाइल सत्र का प्रोसेस संदेश लौटाता है। यदि प्रोसेस संदेश निर्दिष्ट नहीं किया गया था, तो यह null होगा।

Returns: फ़ाइल सत्र का प्रोसेस संदेश।


public EngineOutcome getEngineOutcome()

एक EngineOutcome enum लौटाता है, जो यह दर्शाता है कि प्रोसेस की गई फ़ाइल Managed, NonConforming, या Unsupported थी।

Returns: एक EngineOutcome enum।


public String getErrorMessage()

यदि फ़ाइल non-conforming है, तो त्रुटि संदेश लौटाता है। यदि फ़ाइल managed है, तो यह null होगा।

रिटर्न्स: त्रुटि संदेश।


public Map<String, Long> getSanitisedItems()

sanitised items का एक map उनके count के साथ लौटाता है।

रिटर्न्स: उनकी counts के साथ sanitised items का एक map।


public Map<String, Long> getAllowedItems()

allowed items का एक map उनके count के साथ लौटाता है।

रिटर्न्स: उनकी counts के साथ allowed items का एक map।


public Map<String, Long> getRemedyItems()

remedy items का एक map उनके count के साथ लौटाता है।

रिटर्न्स: उनकी counts के साथ remedy items का एक map।

API उदाहरण

File input_directory = new File("Input");
File output_directory = new File("Output");

output_directory.mkdirs();

for (File file : input_directory.listFiles())
{
if (file.isDirectory())
continue;

try (Core2JavaBridge gw = new Core2JavaBridge())
{
// Create the output path for file and analysis report
String file_output_path = Paths.get(output_directory.getAbsolutePath().toString(), file.getName()).toString();
String analysis_output_path = file_output_path + ".xml";

// Run the file through the Glasswall engine
int session = gw.GW2OpenSession();
gw.GW2RegisterInputFile(session, file.getAbsolutePath());
gw.GW2RegisterAnalysisFile(session, analysis_output_path, 0);
gw.GW2RegisterOutFile(session, file_output_path);
int run_status = gw.GW2RunSession(session);

// Retrieve the error message if the file is non-conforming
String error_message = null;

if (run_status < 0)
error_message = gw.GW2FileErrorMsgString(session);

// Retrieve the session status along with the session description
FileSessionStatus session_status = gw.GW2FileSessionStatusResult(session);

// Create a file summary
try (FileInputStream stream = new FileInputStream(analysis_output_path))
{
FileSummary file_summary = new FileSummary(
file.toPath(),
run_status,
error_message,
session_status.summaryDescription,
stream,
true // true to skip unsupported file types
);

// TODO - do something with the file summary
}
}
catch (Exception ex)
{
System.err.println("Exception occurred: " + ex.getMessage());
}
}