result.addAll(collectExtraDocumentsFromZip(pluginID, directory, url));
private static List<String> collectExtraDocumentsFromZip(String pluginID, String directory, URL url) { List<String> result = new ArrayList<>(); URL realZipURL; try { realZipURL = FileLocator.toFileURL(FileLocator.resolve(url)); if (realZipURL.toExternalForm().startsWith("jar:")) { //$NON-NLS-1$ // doc.zip not allowed in jarred plug-ins. return result; } } catch (IOException ioe) { HelpPlugin.logError("IOException occurred, when resolving URL " //$NON-NLS-1$ + url.toString() + ".", ioe); //$NON-NLS-1$ return result; } try (ZipFile zipFile = new ZipFile(realZipURL.getFile())) { result = createExtraTopicsFromZipFile(pluginID, zipFile, directory); } catch (IOException ioe) { HelpPlugin.logError( "IOException occurred, when accessing Zip file " //$NON-NLS-1$ + realZipURL.getFile() + ". File might not be locally available.", ioe); //$NON-NLS-1$ return new ArrayList<>(); } return result; }
public TocContribution parse(TocFile tocFile) throws IOException, SAXException, ParserConfigurationException { if (reader == null) { reader = new DocumentReader(); } try (InputStream in = tocFile.getInputStream()) { if (in != null) { Toc toc = (Toc) reader.read(in); TocContribution contribution = new TocContribution(); contribution.setCategoryId(tocFile.getCategory()); contribution.setContributorId(tocFile.getPluginId()); contribution.setExtraDocuments(DocumentFinder.collectExtraDocuments(tocFile)); contribution.setId(HrefUtil.normalizeHref(tocFile.getPluginId(), tocFile.getFile())); contribution.setLocale(tocFile.getLocale()); contribution.setToc(toc); contribution.setPrimary(tocFile.isPrimary()); return contribution; } else { throw new FileNotFoundException(); } } } }