Skip to content

Apache Lucene open-source search software

SOLR-2392: Add a dummy-compile task using jspc task (imported from jetty's jasper) to check that all webapps's JSP files at least compile

Uwe Schindler09b909171194
diff --git a/solr/build.xml b/solr/build.xml
index 78ecb8d6618..640363cd0f0 100644
--- a/solr/build.xml
+++ b/solr/build.xml
@@ -379,7 +379,7 @@
<!-- Run contrib unit tests. -->
<target name="test"
description="Runs the core unit tests."
- depends="test-core, test-contrib" />
+ depends="test-core, test-contrib, test-jsp" />
<target name="junit" depends="compileTests,junit-mkdir,junit-sequential,junit-parallel"/>
@@ -554,6 +554,37 @@
</clover-report>
</target>
+ <!-- ========================================================================= -->
+
+ <!-- Checks that all JSP files in the webapp compile successfully using Jetty's Jasper -->
+ <target name="test-jsp" depends="compile">
+ <property name="jsp.target" location="${dest}/jsp-temp" />
+ <taskdef classname="org.apache.jasper.JspC" name="jasper" >
+ <classpath>
+ <fileset dir="example/lib" includes="**/*.jar" />
+ </classpath>
+ </taskdef>
+ <delete dir="${jsp.target}" />
+ <mkdir dir="${jsp.target}" />
+ <jasper
+ uriroot="${src}/webapp/web"
+ outputDir="${jsp.target}"
+ compile="false"
+ verbose="1"
+ package="j"
+ />
+ <javac
+ srcdir="${jsp.target}"
+ destdir="${jsp.target}"
+ target="${java.compat.version}"
+ source="${java.compat.version}"
+ debug="off"
+ encoding="utf8"
+ includeAntRuntime="${javac.includeAntRuntime}"
+ classpathref="test.compile.classpath"
+ />
+ </target>
+
<!-- ========================================================================= -->
<!-- ===================== DISTRIBUTION-RELATED TASKS ======================== -->
@@ -568,7 +599,7 @@
<!-- Creates the Solr WAR file. -->
<target name="dist-war"
description="Creates the Solr WAR Distribution file."
- depends="compile, make-manifest, dist-jar, dist-solrj, lucene-jars-to-solr">
+ depends="compile, test-jsp, make-manifest, dist-jar, dist-solrj, lucene-jars-to-solr">
<mkdir dir="${dist}" />
<war destfile="${dist}/${fullnamever}.war"
webxml="${web.xml}"
diff --git a/solr/src/webapp/web/admin/get-file.jsp b/solr/src/webapp/web/admin/get-file.jsp
deleted file mode 100644
index 74ad4bc9ab6..00000000000
--- a/solr/src/webapp/web/admin/get-file.jsp
+++ /dev/null
@@ -1,72 +0,0 @@
-<%@ page contentType="text/plain; charset=utf-8" pageEncoding="UTF-8" %>
-<%--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
---%>
-<%@ page import="org.apache.solr.core.Config,
- org.apache.solr.core.SolrCore,
- org.apache.solr.core.SolrConfig,
- java.io.InputStream,
- java.io.InputStreamReader,
- java.io.Reader,
- java.util.StringTokenizer,
- java.util.logging.Logger"%>
-<%!
- static Logger log = Logger.getLogger(SolrCore.class.getName());
-%>
-<%
- // NOTE -- this file will be removed in a future release
- log.warning("Using deprecated JSP: " + request.getRequestURL().append("?").append(request.getQueryString()) + " -- check the ShowFileRequestHandler" );
-
- Object ocore = request.getAttribute("org.apache.solr.SolrCore");
- SolrCore core = ocore instanceof SolrCore? (SolrCore) ocore : SolrCore.getSolrCore();
- String fname = request.getParameter("file");
- String optional = request.getParameter("optional");
- String gettableFiles = core.getSolrConfig().get("admin/gettableFiles","");
- StringTokenizer st = new StringTokenizer(gettableFiles);
- InputStream is;
- boolean isValid = false;
- boolean isOptional = false;
- if (fname != null) {
- // Validate fname
- while(st.hasMoreTokens()) {
- if (st.nextToken().compareTo(fname) == 0) isValid = true;
- }
- }
- if (optional!=null && optional.equalsIgnoreCase("y")) {
- isOptional=true;
- }
- if (isValid) {
- try {
- is= core.getSolrConfig().openResource(fname);
- Reader input = new InputStreamReader(is);
- char[] buf = new char[4096];
- while (true) {
- int len = input.read(buf);
- if (len<=0) break;
- out.write(buf,0,len);
- }
- }
- catch (RuntimeException re) {
- if (!isOptional) {
- throw re;
- }
- }
- } else {
- out.println("<ERROR>");
- out.println("Permission denied for file "+ fname);
- out.println("</ERROR>");
- }
-%>
diff --git a/solr/src/webapp/web/admin/ping.jsp b/solr/src/webapp/web/admin/ping.jsp
deleted file mode 100644
index 3c3ddcbb868..00000000000
--- a/solr/src/webapp/web/admin/ping.jsp
+++ /dev/null
@@ -1,52 +0,0 @@
-<%@ page contentType="text/xml; charset=utf-8" pageEncoding="UTF-8" language="java" %>
-<%--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
---%>
-<%@ page import="org.apache.solr.core.SolrConfig,
- org.apache.solr.core.SolrCore,
- org.apache.solr.common.SolrException"%>
-<%@ page import="org.apache.solr.request.LocalSolrQueryRequest"%>
-<%@ page import="org.apache.solr.request.SolrQueryResponse"%>
-<%@ page import="org.apache.solr.request.ServletSolrParams"%>
-<%@ page import="org.apache.solr.request.SolrQueryRequest"%>
-
-<%@include file="_info.jsp" %>
-<?xml-stylesheet type="text/xsl" href="ping.xsl"?>
-
-<solr>
- <core><%=core.getName()%></core>
- <ping>
-<%
- SolrQueryRequest req = core.getPingQueryRequest();
- SolrQueryResponse resp = new SolrQueryResponse();
- try {
- core.execute(req,resp);
- if (resp.getException() == null) {
-// No need for explicit status in the body, when the standard HTTP
-// response codes already transmit success/failure message
- out.println("<status>200</status>");
- }
- else if (resp.getException() != null) {
- throw resp.getException();
- }
- } catch (Throwable t) {
- throw t;
- } finally {
- req.close();
- }
-%>
- </ping>
-</solr>
diff --git a/solr/src/webapp/web/admin/ping.xsl b/solr/src/webapp/web/admin/ping.xsl
deleted file mode 100644
index 1e497b8aba7..00000000000
--- a/solr/src/webapp/web/admin/ping.xsl
+++ /dev/null
@@ -1,71 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
--->
-<!-- $Id$ -->
-<!-- $URL$ -->
-
-<xsl:stylesheet
- xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
- version="1.0">
-
- <xsl:output
- method="html"
- indent="yes"
- encoding="utf-8"
- media-type="text/html; charset=UTF-8"
- doctype-public="-//W3C//DTD HTML 4.01//EN"
- doctype-system="http://www.w3.org/TR/html4/strict.dtd" />
-
- <xsl:template match="/">
- <html>
- <head>
- <link rel="stylesheet" type="text/css" href="solr-admin.css"></link>
- <link rel="icon" href="favicon.ico" type="image/ico"></link>
- <link rel="shortcut icon" href="favicon.ico" type="image/ico"></link>
- <title>Solr Admin: Ping</title>
- </head>
- <body>
- <a href=".">
- <img border="0" align="right" height="78" width="142" src="solr_small.png" alt="Apache Solr">
- </img>
- </a>
- <h1>Solr Admin (<xsl:value-of select="solr/meta/collection" />)</h1>
- <div style="margin-top: 1em;">
- <xsl:apply-templates/>
- <div>
- </div>
- <a href=".">Return to Admin Page</a>
- </div>
- </body>
- </html>
- </xsl:template>
-
- <xsl:include href="meta.xsl"/>
-
- <xsl:template match="solr/ping">
- <table>
- <tr>
- <td>
- <H3>Ping</H3>
- </td>
- <td>
- <xsl:value-of select="error" />
- </td>
- </tr>
- </table>
- </xsl:template>
-</xsl:stylesheet>
diff --git a/solr/src/webapp/web/admin/raw-schema.jsp b/solr/src/webapp/web/admin/raw-schema.jsp
deleted file mode 100644
index bf612a9816e..00000000000
--- a/solr/src/webapp/web/admin/raw-schema.jsp
+++ /dev/null
@@ -1,38 +0,0 @@
-<%--
- Licensed to the Apache Software Foundation (ASF) under one or more
- contributor license agreements. See the NOTICE file distributed with
- this work for additional information regarding copyright ownership.
- The ASF licenses this file to You under the Apache License, Version 2.0
- (the "License"); you may not use this file except in compliance with
- the License. You may obtain a copy of the License at
-
- http://www.apache.org/licenses/LICENSE-2.0
-
- Unless required by applicable law or agreed to in writing, software
- distributed under the License is distributed on an "AS IS" BASIS,
- WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- See the License for the specific language governing permissions and
- limitations under the License.
---%>
-<%@ page import="org.apache.solr.core.SolrCore,
- org.apache.solr.schema.IndexSchema"%>
-<%@ page import="java.io.InputStreamReader"%>
-<%@ page import="java.io.Reader"%>
-<%@ page import="java.util.logging.Logger"%>
-<%@ page contentType="text/plain;charset=UTF-8" language="java" %>
-<%@include file="_info.jsp" %>
-<%!
- static Logger log = Logger.getLogger(SolrCore.class.getName());
-%>
-<%
- // NOTE -- this file will be removed in a future release
- log.warning("Using deprecated JSP: " + request.getRequestURL().append("?").append(request.getQueryString()) + " -- check the ShowFileRequestHandler" );
-
- Reader input = new InputStreamReader(schema.getInputStream());
- char[] buf = new char[4096];
- while (true) {
- int len = input.read(buf);
- if (len<=0) break;
- out.write(buf,0,len);
- }
-%>