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

रिपोर्ट

सारांश रिपोर्ट

सारांश रिपोर्ट उदाहरण

<?xml version="1.0" encoding="UTF-8"?>
<ContentGroups>
<!-- Example of a conforming file -->
<ContentGroup>
<AdditionalInformation>
<AllowedItems>
<AllowedItem InstanceCount="3">External Hyperlinks</AllowedItem>
<AllowedItem InstanceCount="2">Metadata</AllowedItem>
</AllowedItems>
<SanitisationItems>
<SanitisationItem InstanceCount="25">Embedded File</SanitisationItem>
</SanitisationItems>
</AdditionalInformation>
<FileName>/home/glasswall/Documents/Example.doc</FileName>
<ProcessMessage>Remedies Applied</ProcessMessage>
<EngineOutcome>Managed</EngineOutcome>
<LastErrorMessage/>
</ContentGroup>
<!-- Example of a non-conforming file -->
<ContentGroup>
<AdditionalInformation>
<AllowedItems>
<AllowedItem InstanceCount="22">Metadata</AllowedItem>
</AllowedItems>
</AdditionalInformation>
<FileName>/home/glasswall/Documents/Example2.docx</FileName>
<ProcessMessage>Issues Found</ProcessMessage>
<EngineOutcome>Non-conforming</EngineOutcome>
<LastErrorMessage>End of stream 'xl/workbook.xml' not reached</LastErrorMessage>
</ContentGroup>
<!-- Example of an unsupported file type when the skip unsupported file types flag is set to true -->
<ContentGroup>
<AdditionalInformation/>
<FileName>/home/glasswall/Documents/UnsupportedFileType.cat</FileName>
<ProcessMessage/>
<EngineOutcome>Unsupported</EngineOutcome>
<LastErrorMessage>Skipping unsupported filetype</LastErrorMessage>
</ContentGroup>
<!-- Example of an unsupported file type when the skip unsupported file types flag is set to false -->
<ContentGroup>
<AdditionalInformation/>
<FileName>/home/glasswall/Documents/UnsupportedFileType.cat</FileName>
<ProcessMessage>Issues Found</ProcessMessage>
<EngineOutcome>Non-conforming</EngineOutcome>
<LastErrorMessage>Unable to determine file type</LastErrorMessage>
</ContentGroup>
</ContentGroups>

API

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

SummaryReport() throws ParserConfigurationException, DOMException
SummaryReport(boolean skipUnsupportedFileTypes) throws ParserConfigurationException, DOMException

पैरामीटर्स:

  • boolean skipUnsupportedFileTypes - यह skipUnsupportedFileTypes flag सेट करता है। यदि यह flag निर्दिष्ट नहीं किया गया है, तो skip unsupported file types को false पर सेट किया जाएगा।

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

void setSkipUnsupportedFileTypes(boolean skipUnsupportedFileTypes)

skip unsupported file types फ़्लैग के लिए Setter.

पैरामीटर्स:

  • boolean skipUnsupportedFileTypes - यह skip unsupported file types फ़्लैग सेट करता है।

boolean getSkipUnsupportedFileTypes()

skip unsupported file types फ़्लैग के लिए Getter.

Returns: यदि unsupported file types को skip किया जाना चाहिए तो true, अन्यथा false


void addAnalysisReport(
Path inputFilePath,
int sessionStatus,
String lastErrorMessage,
String processMessage,
InputStream analysisInputStream
) throws SAXException, ParserConfigurationException, IOException

summary report में एक नई Glasswall analysis report जोड़ें।

पैरामीटर्स:

  • Path inputFilePath - उस फ़ाइल का file path जिसे process किया गया था।
  • int sessionStatus - GW2RunSession से return status।
  • String lastErrorMessage - [GW2FileErrorMsg]/embedded-engine/embedded-engine-gw2fileerrormsg) से error message। यदि यह null या empty है, तो इसे summary report में शामिल नहीं किया जाएगा।
  • String processMessage - GW2FileSessionStatus से process message। यदि यह null या empty है, तो इसे summary report में शामिल नहीं किया जाएगा।
  • InputStream analysisInputStream - शामिल की जाने वाली analysis report वाला input stream।

void addAnalysisReport(FileSummary summary) throws SAXException, ParserConfigurationException, IOException

summary report में एक नया Glasswall file summary जोड़ें।

पैरामीटर्स:

  • FileSummary summary - summary report में जोड़ी जाने वाली summary information।

public void generateSummaryReport(Writer writer) throws TransformerConfigurationException, TransformerException

प्रदान की गई analysis reports से एक XML summary report जनरेट करें।

पैरामीटर्स:

  • Writer writer - एक writer जिसमें summary report लिखी जाएगी।

public void generateSummaryReport(Writer writer, Transformer transformer) throws TransformerException

निर्दिष्ट transformer का उपयोग करके प्रदान की गई analysis reports से एक XML summary report जनरेट करें।

पैरामीटर्स:

  • Writer writer - एक writer जिसमें summary report लिखी जाएगी।
  • Transformer transformer - XML report जनरेट करने के लिए उपयोग किया जाने वाला transformer।

API उदाहरण

Summary report की functionality com.glasswall.analysissummary.SummaryReport class में implement की गई है। पहले class का एक instance बनाया जाता है, फिर summary report में शामिल की जाने वाली प्रत्येक analysis report के लिए addAnalysisReport को call किया जाता है, और अंत में summary report जनरेट करने के लिए generateSummaryReport को call किया जाता है। एक उदाहरण नीचे देखा जा सकता है:

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

output_directory.mkdirs();

SummaryReport summary_report = new SummaryReport();
summary_report.setSkipUnsupportedFileTypes(true); // Optionally set the skip unsupported file types flag

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);

// Add the analysis report to the summary report
try (FileInputStream stream = new FileInputStream(analysis_output_path))
{
summary_report.addAnalysisReport(file.toPath(), run_status, error_message, session_status.summaryDescription, stream);
}
}
catch (Exception ex)
{
System.err.println("Exception occurred: " + ex.getMessage());
}
}

// Write the summary report to `SummaryReport.xml` file
try (BufferedWriter writer = Files.newBufferedWriter(
Paths.get(output_directory.getAbsolutePath().toString(), "SummaryReport.xml"),
StandardCharsets.UTF_8,
StandardOpenOption.TRUNCATE_EXISTING,
StandardOpenOption.CREATE,
StandardOpenOption.WRITE))
{
summary_report.generateSummaryReport(writer);
}