10d40e9d0SAdam Hornáček<%-- 20d40e9d0SAdam HornáčekCDDL HEADER START 30d40e9d0SAdam Hornáček 40d40e9d0SAdam HornáčekThe contents of this file are subject to the terms of the 50d40e9d0SAdam HornáčekCommon Development and Distribution License (the "License"). 60d40e9d0SAdam HornáčekYou may not use this file except in compliance with the License. 70d40e9d0SAdam Hornáček 80d40e9d0SAdam HornáčekSee LICENSE.txt included in this distribution for the specific 90d40e9d0SAdam Hornáčeklanguage governing permissions and limitations under the License. 100d40e9d0SAdam Hornáček 110d40e9d0SAdam HornáčekWhen distributing Covered Code, include this CDDL HEADER in each 120d40e9d0SAdam Hornáčekfile and include the License file at LICENSE.txt. 130d40e9d0SAdam HornáčekIf applicable, add the following below this CDDL HEADER, with the 140d40e9d0SAdam Hornáčekfields enclosed by brackets "[]" replaced with your own identifying 150d40e9d0SAdam Hornáčekinformation: Portions Copyright [yyyy] [name of copyright owner] 160d40e9d0SAdam Hornáček 170d40e9d0SAdam HornáčekCDDL HEADER END 180d40e9d0SAdam Hornáček 19*b13c5a0eSAdam HornacekCopyright (c) 2005, 2021, Oracle and/or its affiliates. All rights reserved. 200d40e9d0SAdam HornáčekPortions Copyright 2011 Jens Elkner. 215c931ce8SChris FrairePortions Copyright (c) 2017-2020, Chris Fraire <cfraire@me.com>. 220d40e9d0SAdam Hornáček 230d40e9d0SAdam Hornáček--%> 240d40e9d0SAdam Hornáček<%@page errorPage="error.jsp" import=" 250d40e9d0SAdam Hornáčekjava.io.BufferedInputStream, 261c830032SChris Frairejava.io.File, 270d40e9d0SAdam Hornáčekjava.io.FileInputStream, 280d40e9d0SAdam Hornáčekjava.io.InputStream, 290d40e9d0SAdam Hornáčekjava.io.InputStreamReader, 301c830032SChris Frairejava.io.IOException, 310d40e9d0SAdam Hornáčekjava.io.Reader, 320d40e9d0SAdam Hornáčekjava.net.URLEncoder, 330d40e9d0SAdam Hornáčekjava.nio.charset.StandardCharsets, 340d40e9d0SAdam Hornáčekjava.util.List, 3552dccac1SChris Frairejava.util.Locale, 36e829566cSChris Frairejava.util.logging.Level, 37e829566cSChris Frairejava.util.logging.Logger, 385c931ce8SChris Frairejava.util.Set, 395c931ce8SChris Frairejava.util.TreeSet, 40686556f2SAdam Hornáčekorg.opengrok.indexer.analysis.AnalyzerGuru, 41e829566cSChris Fraireorg.opengrok.indexer.analysis.Ctags, 42686556f2SAdam Hornáčekorg.opengrok.indexer.analysis.Definitions, 43e829566cSChris Fraireorg.opengrok.indexer.analysis.AbstractAnalyzer, 44e829566cSChris Fraireorg.opengrok.indexer.analysis.AbstractAnalyzer.Genre, 45e829566cSChris Fraireorg.opengrok.indexer.analysis.AnalyzerFactory, 4641351de3SChris Fraireorg.opengrok.indexer.analysis.NullableNumLinesLOC, 47686556f2SAdam Hornáčekorg.opengrok.indexer.history.Annotation, 481c830032SChris Fraireorg.opengrok.indexer.history.HistoryGuru, 49686556f2SAdam Hornáčekorg.opengrok.indexer.index.IndexDatabase, 50e829566cSChris Fraireorg.opengrok.indexer.logger.LoggerFactory, 51686556f2SAdam Hornáčekorg.opengrok.indexer.search.DirectoryEntry, 52686556f2SAdam Hornáčekorg.opengrok.indexer.search.DirectoryExtraReader, 53686556f2SAdam Hornáčekorg.opengrok.indexer.util.FileExtraZipper, 547d004396SChris Fraireorg.opengrok.indexer.util.ForbiddenSymlinkException, 55e829566cSChris Fraireorg.opengrok.indexer.util.ObjectPool, 56686556f2SAdam Hornáčekorg.opengrok.indexer.util.IOUtils, 571c830032SChris Fraireorg.opengrok.indexer.web.QueryParameters, 5856f072caSAdam Hornáčekorg.opengrok.web.DirectoryListing, 59686556f2SAdam Hornáčekorg.opengrok.indexer.web.SearchHelper" 6057eefa47SKryštof Tulinger%> 6157eefa47SKryštof Tulinger<% 6255774b8bSChris Frairefinal String DUMMY_REVISION = "unknown"; 6355774b8bSChris Fraire 640d40e9d0SAdam Hornáček{ 650d40e9d0SAdam Hornáček // need to set it here since requesting parameters 660d40e9d0SAdam Hornáček if (request.getCharacterEncoding() == null) { 670d40e9d0SAdam Hornáček request.setCharacterEncoding("UTF-8"); 680d40e9d0SAdam Hornáček } 690d40e9d0SAdam Hornáček 700d40e9d0SAdam Hornáček PageConfig cfg = PageConfig.get(request); 710d40e9d0SAdam Hornáček cfg.checkSourceRootExistence(); 720d40e9d0SAdam Hornáček 7355774b8bSChris Fraire String rev = cfg.getRequestedRevision(); 7455774b8bSChris Fraire if (!cfg.isDir() && rev.length() == 0) { 7555774b8bSChris Fraire /* 7655774b8bSChris Fraire * Get the latest revision and redirect so that the revision number 7755774b8bSChris Fraire * appears in the URL. 7855774b8bSChris Fraire */ 7996b0c142SChris Fraire String latestRevision = cfg.getLatestRevision(); 8096b0c142SChris Fraire if (latestRevision != null) { 81eeb95924SChris Fraire cfg.evaluateMatchOffset(); 8296b0c142SChris Fraire String location = cfg.getRevisionLocation(latestRevision); 8355774b8bSChris Fraire response.sendRedirect(location); 8455774b8bSChris Fraire return; 8555774b8bSChris Fraire } 8655774b8bSChris Fraire if (!cfg.getEnv().isGenerateHtml()) { 87eeb95924SChris Fraire cfg.evaluateMatchOffset(); 8855774b8bSChris Fraire /* 8955774b8bSChris Fraire * Economy mode is on and failed to get the last revision 9055774b8bSChris Fraire * (presumably running with history turned off). Use dummy 9155774b8bSChris Fraire * revision string so that xref can be generated from the resource 9255774b8bSChris Fraire * file directly. 9355774b8bSChris Fraire */ 9496b0c142SChris Fraire String location = cfg.getRevisionLocation(DUMMY_REVISION); 9555774b8bSChris Fraire response.sendRedirect(location); 9655774b8bSChris Fraire return; 9755774b8bSChris Fraire } 98eeb95924SChris Fraire 99eeb95924SChris Fraire if (cfg.evaluateMatchOffset()) { 100eeb95924SChris Fraire /* 101eeb95924SChris Fraire * If after calling, a match offset has been translated to a 102eeb95924SChris Fraire * fragment identifier (specifying a line#), then redirect to self. 103eeb95924SChris Fraire * This block will not be activated again the second time. 104eeb95924SChris Fraire */ 105eeb95924SChris Fraire String location = cfg.getRevisionLocation(""); // empty 10655774b8bSChris Fraire response.sendRedirect(location); 10755774b8bSChris Fraire return; 10855774b8bSChris Fraire } 10955774b8bSChris Fraire } 11055774b8bSChris Fraire 1110d40e9d0SAdam Hornáček Annotation annotation = cfg.getAnnotation(); 1120d40e9d0SAdam Hornáček if (annotation != null) { 1130d40e9d0SAdam Hornáček int r = annotation.getWidestRevision(); 1140d40e9d0SAdam Hornáček int a = annotation.getWidestAuthor(); 1150d40e9d0SAdam Hornáček cfg.addHeaderData("<style type=\"text/css\">" 1160d40e9d0SAdam Hornáček + ".blame .r { width: " + (r == 0 ? 6 : Math.ceil(r * 0.7)) + "em; } " 1170d40e9d0SAdam Hornáček + ".blame .a { width: " + (a == 0 ? 6 : Math.ceil(a * 0.7)) + "em; } " 1180d40e9d0SAdam Hornáček + "</style>"); 1190d40e9d0SAdam Hornáček } 1200d40e9d0SAdam Hornáček} 1210d40e9d0SAdam Hornáček%><%@include 1220d40e9d0SAdam Hornáček 1230d40e9d0SAdam Hornáčekfile="mast.jsp" 1240d40e9d0SAdam Hornáček 1250d40e9d0SAdam Hornáček%><script type="text/javascript">/* <![CDATA[ */ 1260d40e9d0SAdam Hornáčekdocument.pageReady.push(function() { pageReadyList();}); 1270d40e9d0SAdam Hornáček/* ]]> */</script> 1280d40e9d0SAdam Hornáček<% 1290d40e9d0SAdam Hornáček/* ---------------------- list.jsp start --------------------- */ 1300d40e9d0SAdam Hornáček{ 131e829566cSChris Fraire final Logger LOGGER = LoggerFactory.getLogger(getClass()); 132e829566cSChris Fraire 1330d40e9d0SAdam Hornáček PageConfig cfg = PageConfig.get(request); 1340d40e9d0SAdam Hornáček String rev = cfg.getRequestedRevision(); 135e393cb49SAdam Hornáček Project project = cfg.getProject(); 1360d40e9d0SAdam Hornáček 137e393cb49SAdam Hornáček String navigateWindowEnabled = project != null ? Boolean.toString( 138e393cb49SAdam Hornáček project.isNavigateWindowEnabled()) : "false"; 1390d40e9d0SAdam Hornáček File resourceFile = cfg.getResourceFile(); 1400d40e9d0SAdam Hornáček String path = cfg.getPath(); 1410d40e9d0SAdam Hornáček String basename = resourceFile.getName(); 1420d40e9d0SAdam Hornáček String rawPath = request.getContextPath() + Prefix.DOWNLOAD_P + path; 1430d40e9d0SAdam Hornáček Reader r = null; 1440d40e9d0SAdam Hornáček if (cfg.isDir()) { 1450d40e9d0SAdam Hornáček // valid resource is requested 1460d40e9d0SAdam Hornáček // mast.jsp assures, that resourceFile is valid and not / 1470d40e9d0SAdam Hornáček // see cfg.resourceNotAvailable() 1480d40e9d0SAdam Hornáček String cookieValue = cfg.getRequestedProjectsAsString(); 1495c931ce8SChris Fraire String projectName = null; 150e393cb49SAdam Hornáček if (project != null) { 1515c931ce8SChris Fraire projectName = project.getName(); 1520d40e9d0SAdam Hornáček Set<String> projects = cfg.getRequestedProjects(); 1535c931ce8SChris Fraire if (!projects.contains(projectName)) { 1545c931ce8SChris Fraire projects.add(projectName); 1550d40e9d0SAdam Hornáček // update cookie 1565c931ce8SChris Fraire cookieValue = cookieValue.length() == 0 ? projectName : 1575c931ce8SChris Fraire projectName + ',' + cookieValue; 158*b13c5a0eSAdam Hornacek Cookie cookie = new Cookie(PageConfig.OPEN_GROK_PROJECT, URLEncoder.encode(cookieValue, StandardCharsets.UTF_8)); 1590d40e9d0SAdam Hornáček // TODO hmmm, projects.jspf doesn't set a path 1600d40e9d0SAdam Hornáček cookie.setPath(request.getContextPath() + '/'); 1610d40e9d0SAdam Hornáček response.addCookie(cookie); 1620d40e9d0SAdam Hornáček } 1630d40e9d0SAdam Hornáček } 1640d40e9d0SAdam Hornáček // requesting a directory listing 1650d40e9d0SAdam Hornáček DirectoryListing dl = new DirectoryListing(cfg.getEftarReader()); 1660d40e9d0SAdam Hornáček List<String> files = cfg.getResourceFileList(); 1670d40e9d0SAdam Hornáček if (!files.isEmpty()) { 16841351de3SChris Fraire List<NullableNumLinesLOC> extras = null; 1690d40e9d0SAdam Hornáček SearchHelper searchHelper = cfg.prepareInternalSearch(); 1705c931ce8SChris Fraire /* 1715c931ce8SChris Fraire * N.b. searchHelper.destroy() is called via 1725c931ce8SChris Fraire * WebappListener.requestDestroyed() on presence of the following 1735c931ce8SChris Fraire * REQUEST_ATTR. 1745c931ce8SChris Fraire */ 1750d40e9d0SAdam Hornáček request.setAttribute(SearchHelper.REQUEST_ATTR, searchHelper); 1765c931ce8SChris Fraire if (project != null) { 177e393cb49SAdam Hornáček searchHelper.prepareExec(project); 1785c931ce8SChris Fraire } else { 1795c931ce8SChris Fraire //noinspection Convert2Diamond 1805c931ce8SChris Fraire searchHelper.prepareExec(new TreeSet<String>()); 1815c931ce8SChris Fraire } 1820d40e9d0SAdam Hornáček 1830d40e9d0SAdam Hornáček if (searchHelper.searcher != null) { 1845c931ce8SChris Fraire DirectoryExtraReader extraReader = new DirectoryExtraReader(); 1857d004396SChris Fraire String primePath = path; 1867d004396SChris Fraire try { 1875c931ce8SChris Fraire primePath = searchHelper.getPrimeRelativePath(projectName, path); 1887d004396SChris Fraire } catch (IOException | ForbiddenSymlinkException ex) { 1897d004396SChris Fraire LOGGER.log(Level.WARNING, String.format( 1907d004396SChris Fraire "Error getting prime relative for %s", path), ex); 1917d004396SChris Fraire } 1927d004396SChris Fraire extras = extraReader.search(searchHelper.searcher, primePath); 1930d40e9d0SAdam Hornáček } 1940d40e9d0SAdam Hornáček 1950d40e9d0SAdam Hornáček FileExtraZipper zipper = new FileExtraZipper(); 1960d40e9d0SAdam Hornáček List<DirectoryEntry> entries = zipper.zip(resourceFile, files, 1970d40e9d0SAdam Hornáček extras); 1980d40e9d0SAdam Hornáček 1990d40e9d0SAdam Hornáček List<String> readMes = dl.extraListTo( 2000d40e9d0SAdam Hornáček Util.URIEncodePath(request.getContextPath()), 2010d40e9d0SAdam Hornáček resourceFile, out, path, entries); 2020d40e9d0SAdam Hornáček File[] catfiles = cfg.findDataFiles(readMes); 2030d40e9d0SAdam Hornáček for (int i=0; i < catfiles.length; i++) { 2040d40e9d0SAdam Hornáček if (catfiles[i] == null) { 2050d40e9d0SAdam Hornáček continue; 2060d40e9d0SAdam Hornáček } 2070d40e9d0SAdam Hornáček%> 2080d40e9d0SAdam Hornáček<% 20952dccac1SChris Fraire String lcName = readMes.get(i).toLowerCase(Locale.ROOT); 2100d40e9d0SAdam Hornáček if (lcName.endsWith(".md") || lcName.endsWith(".markdown")) { 2110d40e9d0SAdam Hornáček %><div id="src<%=i%>" data-markdown> 2120d40e9d0SAdam Hornáček <div class="markdown-heading"> 2130d40e9d0SAdam Hornáček <h3><%= readMes.get(i) %></h3> 2140d40e9d0SAdam Hornáček </div> 2150d40e9d0SAdam Hornáček <div class="markdown-content" 2160d40e9d0SAdam Hornáček data-markdown-download="<%= request.getContextPath() + Prefix.DOWNLOAD_P + Util.URIEncodePath(cfg.getPath() + readMes.get(i)) %>"> 2170d40e9d0SAdam Hornáček </div> 2180d40e9d0SAdam Hornáček <pre data-markdown-original><% 2190d40e9d0SAdam Hornáček Util.dump(out, catfiles[i], catfiles[i].getName().endsWith(".gz")); 2200d40e9d0SAdam Hornáček %></pre> 2210d40e9d0SAdam Hornáček </div> 2220d40e9d0SAdam Hornáček<% } else { %> 2230d40e9d0SAdam Hornáček <h3><%= readMes.get(i) %></h3> 2240d40e9d0SAdam Hornáček <div id="src<%=i%>"> 2250d40e9d0SAdam Hornáček <pre><% 2260d40e9d0SAdam Hornáček Util.dump(out, catfiles[i], catfiles[i].getName().endsWith(".gz")); 2270d40e9d0SAdam Hornáček %></pre> 2280d40e9d0SAdam Hornáček </div> 2290d40e9d0SAdam Hornáček<% 2300d40e9d0SAdam Hornáček } 2310d40e9d0SAdam Hornáček 2320d40e9d0SAdam Hornáček } 2330d40e9d0SAdam Hornáček } 234a03922c4SAdam Hornáček } else if (rev.length() != 0) { 235a03922c4SAdam Hornáček // requesting a revision 23655774b8bSChris Fraire File xrefFile; 237ee13dbaeSChris Fraire if (cfg.isLatestRevision(rev) && 238ee13dbaeSChris Fraire (xrefFile = cfg.findDataFile()) != null) { 239a03922c4SAdam Hornáček if (cfg.annotate()) { 2400d40e9d0SAdam Hornáček // annotate 2410d40e9d0SAdam Hornáček BufferedInputStream bin = 2420d40e9d0SAdam Hornáček new BufferedInputStream(new FileInputStream(resourceFile)); 2430d40e9d0SAdam Hornáček try { 24457eefa47SKryštof Tulinger AnalyzerFactory a = AnalyzerGuru.find(basename); 24557eefa47SKryštof Tulinger AbstractAnalyzer.Genre g = AnalyzerGuru.getGenre(a); 2460d40e9d0SAdam Hornáček if (g == null) { 2470d40e9d0SAdam Hornáček a = AnalyzerGuru.find(bin); 2480d40e9d0SAdam Hornáček g = AnalyzerGuru.getGenre(a); 2490d40e9d0SAdam Hornáček } 25057eefa47SKryštof Tulinger if (g == AbstractAnalyzer.Genre.IMAGE) { 2510d40e9d0SAdam Hornáček%> 2520d40e9d0SAdam Hornáček<div id="src"> 2531c830032SChris Fraire <img src="<%= rawPath %>" alt="Image from Source Repository"/> 2540d40e9d0SAdam Hornáček</div><% 25557eefa47SKryštof Tulinger } else if ( g == AbstractAnalyzer.Genre.HTML) { 2560d40e9d0SAdam Hornáček /** 2570d40e9d0SAdam Hornáček * For backward compatibility, read the OpenGrok-produced 2580d40e9d0SAdam Hornáček * document using the system default charset. 2590d40e9d0SAdam Hornáček */ 2600d40e9d0SAdam Hornáček r = new InputStreamReader(bin); 261e393cb49SAdam Hornáček // dumpXref() is also useful here for translating links. 262e393cb49SAdam Hornáček Util.dumpXref(out, r, request.getContextPath()); 26357eefa47SKryštof Tulinger } else if (g == AbstractAnalyzer.Genre.PLAIN) { 2640d40e9d0SAdam Hornáček%> 2650d40e9d0SAdam Hornáček<div id="src" data-navigate-window-enabled="<%= navigateWindowEnabled %>"> 2660d40e9d0SAdam Hornáček <pre><% 2670d40e9d0SAdam Hornáček // We're generating xref for the latest revision, so we can 2680d40e9d0SAdam Hornáček // find the definitions in the index. 2690d40e9d0SAdam Hornáček Definitions defs = IndexDatabase.getDefinitions(resourceFile); 2700d40e9d0SAdam Hornáček Annotation annotation = cfg.getAnnotation(); 2710d40e9d0SAdam Hornáček // SRCROOT is read with UTF-8 as a default. 2720d40e9d0SAdam Hornáček r = IOUtils.createBOMStrippedReader(bin, 2730d40e9d0SAdam Hornáček StandardCharsets.UTF_8.name()); 274e393cb49SAdam Hornáček AnalyzerGuru.writeDumpedXref(request.getContextPath(), a, 275e393cb49SAdam Hornáček r, out, defs, annotation, project); 2760d40e9d0SAdam Hornáček %></pre> 2770d40e9d0SAdam Hornáček</div><% 2780d40e9d0SAdam Hornáček } else { 2790d40e9d0SAdam Hornáček%> 2800d40e9d0SAdam HornáčekClick <a href="<%= rawPath %>">download <%= basename %></a><% 2810d40e9d0SAdam Hornáček } 2820d40e9d0SAdam Hornáček } finally { 2830d40e9d0SAdam Hornáček if (r != null) { 284963a3f81SChris Fraire IOUtils.close(r); 285963a3f81SChris Fraire bin = null; 2860d40e9d0SAdam Hornáček } 2870d40e9d0SAdam Hornáček if (bin != null) { 288963a3f81SChris Fraire IOUtils.close(bin); 289963a3f81SChris Fraire bin = null; 2900d40e9d0SAdam Hornáček } 2910d40e9d0SAdam Hornáček } 292a03922c4SAdam Hornáček 293a03922c4SAdam Hornáček } else { 2940d40e9d0SAdam Hornáček%> 2950d40e9d0SAdam Hornáček<div id="src" data-navigate-window-enabled="<%= navigateWindowEnabled %>"> 2960d40e9d0SAdam Hornáček <pre><% 297e393cb49SAdam Hornáček boolean compressed = xrefFile.getName().endsWith(".gz"); 298e393cb49SAdam Hornáček Util.dumpXref(out, xrefFile, compressed, 299e393cb49SAdam Hornáček request.getContextPath()); 3000d40e9d0SAdam Hornáček %></pre> 3010d40e9d0SAdam Hornáček</div><% 3020d40e9d0SAdam Hornáček } 3030d40e9d0SAdam Hornáček } else { 304f3e7c6e8SVladimir Kotal // requesting a previous revision or needed to generate xref on the fly (economy mode). 30557eefa47SKryštof Tulinger AnalyzerFactory a = AnalyzerGuru.find(basename); 306e829566cSChris Fraire Genre g = AnalyzerGuru.getGenre(a); 3070d40e9d0SAdam Hornáček String error = null; 308e829566cSChris Fraire if (g == Genre.PLAIN || g == Genre.HTML || g == null) { 3090d40e9d0SAdam Hornáček InputStream in = null; 310e829566cSChris Fraire File tempf = null; 3110d40e9d0SAdam Hornáček try { 31217c862aeSVladimir Kotal if (rev.equals(DUMMY_REVISION)) { 3134f99ffafSChris Fraire in = new BufferedInputStream(new FileInputStream(resourceFile)); 31417c862aeSVladimir Kotal } else { 315e829566cSChris Fraire tempf = File.createTempFile("ogtags", basename); 316e829566cSChris Fraire if (HistoryGuru.getInstance().getRevision(tempf, 317e829566cSChris Fraire resourceFile.getParent(), basename, rev)) { 3184f99ffafSChris Fraire in = new BufferedInputStream(new FileInputStream(tempf)); 319e829566cSChris Fraire } else { 320e829566cSChris Fraire tempf.delete(); 321e829566cSChris Fraire tempf = null; 322e829566cSChris Fraire } 32317c862aeSVladimir Kotal } 3240d40e9d0SAdam Hornáček } catch (Exception e) { 3250d40e9d0SAdam Hornáček // fall through to error message 3260d40e9d0SAdam Hornáček error = e.getMessage(); 327e829566cSChris Fraire if (tempf != null) { 328e829566cSChris Fraire tempf.delete(); 329e829566cSChris Fraire tempf = null; 330e829566cSChris Fraire } 3310d40e9d0SAdam Hornáček } 3320d40e9d0SAdam Hornáček if (in != null) { 3330d40e9d0SAdam Hornáček try { 3340d40e9d0SAdam Hornáček if (g == null) { 335e829566cSChris Fraire a = AnalyzerGuru.find(in, basename); 3360d40e9d0SAdam Hornáček g = AnalyzerGuru.getGenre(a); 3370d40e9d0SAdam Hornáček } 33857eefa47SKryštof Tulinger if (g == AbstractAnalyzer.Genre.DATA || g == AbstractAnalyzer.Genre.XREFABLE || g == null) { 3390d40e9d0SAdam Hornáček %> 3400d40e9d0SAdam Hornáček <div id="src"> 3411c830032SChris Fraire Download binary file, <a href="<%= rawPath %>?<%= QueryParameters.REVISION_PARAM_EQ %> 3421c830032SChris Fraire<%= Util.URIEncode(rev) %>"><%= basename %></a> 3430d40e9d0SAdam Hornáček </div><% 3440d40e9d0SAdam Hornáček } else { 3450d40e9d0SAdam Hornáček %> 3460d40e9d0SAdam Hornáček <div id="src"> 3470d40e9d0SAdam Hornáček <pre><% 34857eefa47SKryštof Tulinger if (g == AbstractAnalyzer.Genre.PLAIN) { 3490d40e9d0SAdam Hornáček Definitions defs = null; 350e829566cSChris Fraire ObjectPool<Ctags> ctagsPool = cfg.getEnv(). 351e829566cSChris Fraire getIndexerParallelizer().getCtagsPool(); 352e829566cSChris Fraire int tries = 2; 353e829566cSChris Fraire while (cfg.getEnv().isWebappCtags()) { 354e829566cSChris Fraire Ctags ctags = ctagsPool.get(); 355e829566cSChris Fraire try { 356e829566cSChris Fraire ctags.setTabSize(project != null ? 357e829566cSChris Fraire project.getTabSize() : 0); 358e829566cSChris Fraire defs = ctags.doCtags(tempf.getPath()); 359e829566cSChris Fraire break; 360e829566cSChris Fraire } catch (InterruptedException ex) { 361e829566cSChris Fraire if (--tries > 0) { 362e829566cSChris Fraire LOGGER.log(Level.WARNING, 363e829566cSChris Fraire "doCtags() interrupted--{0}", 364e829566cSChris Fraire ex.getMessage()); 365e829566cSChris Fraire continue; 366e829566cSChris Fraire } 367e829566cSChris Fraire LOGGER.log(Level.WARNING, "doCtags()", ex); 368e829566cSChris Fraire break; 369e829566cSChris Fraire } catch (Exception ex) { 370e829566cSChris Fraire LOGGER.log(Level.WARNING, "doCtags()", ex); 371e829566cSChris Fraire break; 372e829566cSChris Fraire } finally { 373e829566cSChris Fraire ctags.reset(); 374e829566cSChris Fraire ctagsPool.release(ctags); 375e829566cSChris Fraire } 376e829566cSChris Fraire } 3770d40e9d0SAdam Hornáček Annotation annotation = cfg.getAnnotation(); 3780d40e9d0SAdam Hornáček //not needed yet 3790d40e9d0SAdam Hornáček //annotation.writeTooltipMap(out); 3800d40e9d0SAdam Hornáček // SRCROOT is read with UTF-8 as a default. 3810d40e9d0SAdam Hornáček r = IOUtils.createBOMStrippedReader(in, 3820d40e9d0SAdam Hornáček StandardCharsets.UTF_8.name()); 383e393cb49SAdam Hornáček AnalyzerGuru.writeDumpedXref( 384a03922c4SAdam Hornáček request.getContextPath(), 385a03922c4SAdam Hornáček a, r, out, 386e393cb49SAdam Hornáček defs, annotation, project); 38757eefa47SKryštof Tulinger } else if (g == AbstractAnalyzer.Genre.IMAGE) { 3880d40e9d0SAdam Hornáček %></pre> 3891c830032SChris Fraire <img src="<%= rawPath %>?<%= QueryParameters.REVISION_PARAM_EQ %><%= Util.URIEncode(rev) %>"/> 3900d40e9d0SAdam Hornáček <pre><% 39157eefa47SKryštof Tulinger } else if (g == AbstractAnalyzer.Genre.HTML) { 3920d40e9d0SAdam Hornáček /** 3930d40e9d0SAdam Hornáček * For backward compatibility, read the 3940d40e9d0SAdam Hornáček * OpenGrok-produced document using the system 3950d40e9d0SAdam Hornáček * default charset. 3960d40e9d0SAdam Hornáček */ 3970d40e9d0SAdam Hornáček r = new InputStreamReader(in); 398e393cb49SAdam Hornáček /** 399e393cb49SAdam Hornáček * dumpXref() is also useful here for 400e393cb49SAdam Hornáček * translating links. 401e393cb49SAdam Hornáček */ 402e393cb49SAdam Hornáček Util.dumpXref(out, r, request.getContextPath()); 4030d40e9d0SAdam Hornáček } else { 4041c830032SChris Fraire %>Download binary file, <a href="<%= rawPath %>?<%= QueryParameters.REVISION_PARAM_EQ %> 4051c830032SChris Fraire<%= Util.URIEncode(rev) %>"><%= basename %></a><% 4060d40e9d0SAdam Hornáček } 4070d40e9d0SAdam Hornáček } 4080d40e9d0SAdam Hornáček } catch (IOException e) { 409b5cf4968SChris Fraire LOGGER.log(Level.SEVERE, "Failed xref on-the-fly", e); 4100d40e9d0SAdam Hornáček } finally { 4110d40e9d0SAdam Hornáček if (r != null) { 412963a3f81SChris Fraire IOUtils.close(r); 413963a3f81SChris Fraire in = null; 4140d40e9d0SAdam Hornáček } 4150d40e9d0SAdam Hornáček if (in != null) { 416963a3f81SChris Fraire IOUtils.close(in); 417963a3f81SChris Fraire in = null; 4180d40e9d0SAdam Hornáček } 419e829566cSChris Fraire if (tempf != null) { 420e829566cSChris Fraire tempf.delete(); 421e829566cSChris Fraire } 4220d40e9d0SAdam Hornáček } 4230d40e9d0SAdam Hornáček %></pre> 4240d40e9d0SAdam Hornáček </div><% 4250d40e9d0SAdam Hornáček } else { 4260d40e9d0SAdam Hornáček %> 4270d40e9d0SAdam Hornáček <h3 class="error">Error reading file</h3><% 4280d40e9d0SAdam Hornáček if (error != null) { 4290d40e9d0SAdam Hornáček %> 4300d40e9d0SAdam Hornáček <p class="error"><%= error %></p><% 4310d40e9d0SAdam Hornáček } 4320d40e9d0SAdam Hornáček } 43357eefa47SKryštof Tulinger } else if (g == AbstractAnalyzer.Genre.IMAGE) { 4340d40e9d0SAdam Hornáček %> 4350d40e9d0SAdam Hornáček <div id="src"> 4361c830032SChris Fraire <img src="<%= rawPath %>?<%= QueryParameters.REVISION_PARAM_EQ %><%= Util.URIEncode(rev) %>" 4371c830032SChris Fraire alt="Image from Source Repository"/> 4380d40e9d0SAdam Hornáček </div><% 4390d40e9d0SAdam Hornáček } else { 4400d40e9d0SAdam Hornáček %> 4410d40e9d0SAdam Hornáček <div id="src"> 4421c830032SChris Fraire Download binary file, <a href="<%= rawPath %>?<%= QueryParameters.REVISION_PARAM_EQ %> 4431c830032SChris Fraire<%= Util.URIEncode(rev) %>"><%= basename %></a> 4440d40e9d0SAdam Hornáček </div><% 4450d40e9d0SAdam Hornáček } 4460d40e9d0SAdam Hornáček } 4470d40e9d0SAdam Hornáček } else { 4480d40e9d0SAdam Hornáček // requesting cross referenced file 4490d40e9d0SAdam Hornáček 45055774b8bSChris Fraire File xrefFile = cfg.findDataFile(); 4510d40e9d0SAdam Hornáček if (xrefFile != null) { 4520d40e9d0SAdam Hornáček%> 4530d40e9d0SAdam Hornáček<div id="src" data-navigate-window-enabled="<%= navigateWindowEnabled %>"> 4540d40e9d0SAdam Hornáček <pre><% 455e393cb49SAdam Hornáček boolean compressed = xrefFile.getName().endsWith(".gz"); 456e393cb49SAdam Hornáček Util.dumpXref(out, xrefFile, compressed, request.getContextPath()); 4570d40e9d0SAdam Hornáček %></pre> 4580d40e9d0SAdam Hornáček</div><% 45917c862aeSVladimir Kotal } else { 46017c862aeSVladimir Kotal%> 4615c4b57feSVladimir Kotal<p class="error">Failed to get xref file</p><% 4620d40e9d0SAdam Hornáček } 4630d40e9d0SAdam Hornáček } 4640d40e9d0SAdam Hornáček} 4650d40e9d0SAdam Hornáček/* ---------------------- list.jsp end --------------------- */ 4660d40e9d0SAdam Hornáček%><%@ 4670d40e9d0SAdam Hornáček 4680d40e9d0SAdam Hornáčekinclude file="foot.jspf" 4690d40e9d0SAdam Hornáček 4700d40e9d0SAdam Hornáček%> 471