From 9a4cd45fb80d8a6b57663fa20e1aa27d5bf45d0e Mon Sep 17 00:00:00 2001 From: Tanjong Agbor Smith Date: Wed, 1 Jul 2020 12:30:51 +0100 Subject: [PATCH] Undo change: Add back print statement --- .../LicenseRDFAGenerator.java | 61 ++++++++++--------- 1 file changed, 31 insertions(+), 30 deletions(-) diff --git a/src/org/spdx/licenselistpublisher/LicenseRDFAGenerator.java b/src/org/spdx/licenselistpublisher/LicenseRDFAGenerator.java index a4503bb..93b4955 100644 --- a/src/org/spdx/licenselistpublisher/LicenseRDFAGenerator.java +++ b/src/org/spdx/licenselistpublisher/LicenseRDFAGenerator.java @@ -67,11 +67,11 @@ /** * Converts input license text and metadata into various output formats. - * + * * Supported input formats: * - License XML file - File following the SPDX legal team license format * - Directory of XML files - Directory of files following the SPDX legal team license format - * + * * Supported output formats: * - Text - license text * - Templates - license templates as defined by the SPDX legal team matching guidelines @@ -81,20 +81,20 @@ * - RDF XML - RDF XML format defined by the SPDX Spec * - RDF Turtle - RDF Turtle format defined by the SPDX Spec * - Website - the content for the website available at https://spdx.org/licenses - * - * Output generated by this tool can be found at https://github.com/spdx/license-list-data and on the + * + * Output generated by this tool can be found at https://github.com/spdx/license-list-data and on the * spdx.org licenses website - * + * * To add a new output format, create a class supporting the ILicenseFormatWriter interface and add it * to the writers list. - * + * * @author Gary O'Neall * */ public class LicenseRDFAGenerator { - + static final Set INVALID_TEXT_CHARS = Sets.newHashSet(); - + static { INVALID_TEXT_CHARS.add('\uFFFD'); } @@ -118,7 +118,7 @@ public class LicenseRDFAGenerator { private static final String RDFNT_FOLDER_NAME = "rdfnt"; private static final String TABLE_OF_CONTENTS_FILE_NAME = "licenses.md"; private static final String RDF_JSON_LD_FOLDER_NAME = "jsonld"; - + /** * @param args Arg 0 is either a license XML file or a directory of licenses in XML format, arg 1 is the directory for the output html files */ @@ -226,7 +226,7 @@ public static void main(String[] args) { * @param releaseDate Release data string for the license * @param testFileDir Directory of license text to test the generated licenses against * @return warnings - * @throws LicenseGeneratorException + * @throws LicenseGeneratorException */ public static List generateLicenseData(File licenseXml, File dir, String version, String releaseDate, File testFileDir) throws LicenseGeneratorException { @@ -335,7 +335,7 @@ public static List generateLicenseData(File licenseXml, File dir, throw new LicenseGeneratorException("\nUnhandled exception generating html: "+e.getMessage(),e); } } - + /** * @param version License list version * @param releaseDate release date for the license list @@ -343,11 +343,11 @@ public static List generateLicenseData(File licenseXml, File dir, * @param warnings Populated with any warnings if they occur * @param writers License Format Writers to handle the writing for the different formats * @param tester License tester used to test the results of licenses - * @throws IOException - * @throws SpreadsheetException - * @throws LicenseRestrictionException - * @throws LicenseGeneratorException - * @throws InvalidLicenseTemplateException + * @throws IOException + * @throws SpreadsheetException + * @throws LicenseRestrictionException + * @throws LicenseGeneratorException + * @throws InvalidLicenseTemplateException */ private static void writeExceptionList(String version, String releaseDate, ISpdxListedLicenseProvider licenseProvider, List warnings, List writers, @@ -358,11 +358,11 @@ private static void writeExceptionList(String version, String releaseDate, Iterator licIter = licenseProvider.getLicenseIterator(); while (licIter.hasNext()) { licenseIds.add(licIter.next().getLicenseId()); - } + } } catch (SpdxListedLicenseException e) { System.out.println("Warning - Not able to check for duplicate license and exception ID's"); } - + Iterator exceptionIter = licenseProvider.getExceptionIterator(); Map addedExceptionsMap = Maps.newHashMap(); while (exceptionIter.hasNext()) { @@ -380,13 +380,13 @@ private static void writeExceptionList(String version, String releaseDate, } } // check for a license ID with the same ID as the exception - + addedExceptionsMap.put(nextException.getLicenseExceptionId(), nextException.getLicenseExceptionText()); } if (licenseIds.contains(nextException.getLicenseExceptionId())) { warnings.add("A license ID exists with the same ID as an exception ID: "+nextException.getLicenseExceptionId()); } - checkText(nextException.getLicenseExceptionText(), + checkText(nextException.getLicenseExceptionText(), "License Exception Text for "+nextException.getLicenseExceptionId(), warnings); for (ILicenseFormatWriter writer:writers) { writer.writeException(nextException); @@ -399,11 +399,11 @@ private static void writeExceptionList(String version, String releaseDate, } } } - + } } } - + /** * Add any additional data to a license exception from external sources * @param exception Exception with fields updated from external sources @@ -411,7 +411,7 @@ private static void writeExceptionList(String version, String releaseDate, private static void addExternalMetaData(LicenseException exception) { // Currently, there is no data to add } - + /** * Check text for invalid characters * @param text Text to check @@ -428,7 +428,7 @@ private static void checkText(String text, String textDescription, for (int i = 0; i < line.length(); i++) { if (INVALID_TEXT_CHARS.contains(line.charAt(i))) { warnings.add("Invalid character in " + textDescription + - " at line number " + String.valueOf(lineNumber) + + " at line number " + String.valueOf(lineNumber) + " \"" +line + "\" at character location "+String.valueOf(i)); } } @@ -445,7 +445,7 @@ private static void checkText(String text, String textDescription, } } } - + /** * Formats and writes the license list data * @param version License list version @@ -466,6 +466,7 @@ private static void writeLicenseList(String version, String releaseDate, Iterator licenseIter = licenseProvider.getLicenseIterator(); Map addedLicIdTextMap = Maps.newHashMap(); // keep track for duplicate checking while (licenseIter.hasNext()) { + System.out.print("."); SpdxListedLicense license = licenseIter.next(); addExternalMetaData(license); if (license.getLicenseId() != null && !license.getLicenseId().isEmpty()) { @@ -499,17 +500,17 @@ private static void writeLicenseList(String version, String releaseDate, /** * Update license fields based on information from external metadata * @param license - * @throws LicenseGeneratorException + * @throws LicenseGeneratorException */ private static void addExternalMetaData(SpdxListedLicense license) throws LicenseGeneratorException { license.setFsfLibre(FsfLicenseDataParser.getFsfLicenseDataParser().isSpdxLicenseFsfLibre(license.getLicenseId())); } - + /** * Copy a file from the resources directory to a destination file * @param resourceFileName filename of the file in the resources directory * @param destination target file - warning, this will be overwritten - * @throws IOException + * @throws IOException */ private static void copyResourceFile(String resourceFileName, File destination) throws IOException { File resourceFile = new File(resourceFileName); @@ -544,7 +545,7 @@ private static void writeCssFile(File dir) throws IOException { } copyResourceFile(CSS_TEMPLATE_FILE, cssFile); } - + private static void writeSortTableFile(File dir) throws IOException { File sortTableFile = new File(dir.getPath()+ File.separator + SORTTABLE_FILE_NAME); if (sortTableFile.exists()) { @@ -552,7 +553,7 @@ private static void writeSortTableFile(File dir) throws IOException { } copyResourceFile(SORTTABLE_JS_FILE, sortTableFile); } - + private static void usage() { System.out.println("Usage:"); System.out.println("LicenseRDFAGenerator licencenseXmlFileOrDir outputDirectory [version] [releasedate] [testfiles] [ignoredwarnings]");