30d2f45dd260208f0fb882dde134a249318524b9Lubos KoscoCDDL HEADER START
30d2f45dd260208f0fb882dde134a249318524b9Lubos KoscoThe contents of this file are subject to the terms of the
59b6a8c0cc6ef741a7180504b3c371e67c2aa338Knut Anders HatlenCommon Development and Distribution License (the "License").
30d2f45dd260208f0fb882dde134a249318524b9Lubos KoscoYou may not use this file except in compliance with the License.
30d2f45dd260208f0fb882dde134a249318524b9Lubos KoscoSee LICENSE.txt included in this distribution for the specific
30d2f45dd260208f0fb882dde134a249318524b9Lubos Koscolanguage governing permissions and limitations under the License.
30d2f45dd260208f0fb882dde134a249318524b9Lubos KoscoWhen distributing Covered Code, include this CDDL HEADER in each
30d2f45dd260208f0fb882dde134a249318524b9Lubos Koscofile and include the License file at LICENSE.txt.
30d2f45dd260208f0fb882dde134a249318524b9Lubos KoscoIf applicable, add the following below this CDDL HEADER, with the
30d2f45dd260208f0fb882dde134a249318524b9Lubos Koscofields enclosed by brackets "[]" replaced with your own identifying
30d2f45dd260208f0fb882dde134a249318524b9Lubos Koscoinformation: Portions Copyright [yyyy] [name of copyright owner]
30d2f45dd260208f0fb882dde134a249318524b9Lubos KoscoCDDL HEADER END
a46f72a555abdeca43d8b4041026c003013d5d19Vladimir KotalCopyright (c) 2009, 2012, Oracle and/or its affiliates. All rights reserved.
14a41f02433890d19b2f871156271e3388cd0845Jens ElknerPortions Copyright 2011 Jens Elkner.
14a41f02433890d19b2f871156271e3388cd0845Jens Elkner--%><%@page session="false" errorPage="error.jsp" import="
59b6a8c0cc6ef741a7180504b3c371e67c2aa338Knut Anders Hatlen /* ---------------------- opensearch.jsp start --------------------- */
a46f72a555abdeca43d8b4041026c003013d5d19Vladimir Kotal // Optimize for URLs up to 128 characters.
59b6a8c0cc6ef741a7180504b3c371e67c2aa338Knut Anders Hatlen StringBuilder url = new StringBuilder(128);
a46f72a555abdeca43d8b4041026c003013d5d19Vladimir Kotal String ForwardedHost = request.getHeader("X-Forwarded-Host");
a46f72a555abdeca43d8b4041026c003013d5d19Vladimir Kotal String scheme = request.getScheme();
a46f72a555abdeca43d8b4041026c003013d5d19Vladimir Kotal url.append(scheme).append("://");
a46f72a555abdeca43d8b4041026c003013d5d19Vladimir Kotal // Play nice in proxy environment by using hostname from the original
a46f72a555abdeca43d8b4041026c003013d5d19Vladimir Kotal // request to construct the URLs.
a46f72a555abdeca43d8b4041026c003013d5d19Vladimir Kotal // Will not work well if the scheme or port is different for proxied server
a46f72a555abdeca43d8b4041026c003013d5d19Vladimir Kotal // and original server. Unfortunately the X-Forwarded-Host does not seem to
a46f72a555abdeca43d8b4041026c003013d5d19Vladimir Kotal // contain the port number so there is no way around it.
a46f72a555abdeca43d8b4041026c003013d5d19Vladimir Kotal if (ForwardedHost != null) {
a46f72a555abdeca43d8b4041026c003013d5d19Vladimir Kotal url.append(ForwardedHost);
a46f72a555abdeca43d8b4041026c003013d5d19Vladimir Kotal // Append port if needed.
a46f72a555abdeca43d8b4041026c003013d5d19Vladimir Kotal if ((port != 80 && scheme.equals("http")) ||
a46f72a555abdeca43d8b4041026c003013d5d19Vladimir Kotal (port != 443 && scheme.equals("https"))) {
a46f72a555abdeca43d8b4041026c003013d5d19Vladimir Kotal url.append(':').append(port);
a46f72a555abdeca43d8b4041026c003013d5d19Vladimir Kotal String imgurl = url + cfg.getCssDir() + "/img/icon.png";
59b6a8c0cc6ef741a7180504b3c371e67c2aa338Knut Anders Hatlen /* TODO Bug 11749 ??? */
59b6a8c0cc6ef741a7180504b3c371e67c2aa338Knut Anders Hatlen StringBuilder text = new StringBuilder();
59b6a8c0cc6ef741a7180504b3c371e67c2aa338Knut Anders Hatlen url.append(request.getContextPath()).append(Prefix.SEARCH_P).append('?');
59b6a8c0cc6ef741a7180504b3c371e67c2aa338Knut Anders Hatlen Set<String> projects = cfg.getRequestedProjects();
59b6a8c0cc6ef741a7180504b3c371e67c2aa338Knut Anders Hatlen for (String name : projects) {
59b6a8c0cc6ef741a7180504b3c371e67c2aa338Knut Anders Hatlen text.append(name).append(',');
59b6a8c0cc6ef741a7180504b3c371e67c2aa338Knut Anders Hatlen Util.appendQuery(url, "project", name);
30d2f45dd260208f0fb882dde134a249318524b9Lubos Kosco%><?xml version="1.0" encoding="UTF-8"?>
30d2f45dd260208f0fb882dde134a249318524b9Lubos Kosco<OpenSearchDescription xmlns="http://a9.com/-/spec/opensearch/1.1/">
59b6a8c0cc6ef741a7180504b3c371e67c2aa338Knut Anders Hatlen <ShortName>OpenGrok <%= text.toString() %></ShortName>
59b6a8c0cc6ef741a7180504b3c371e67c2aa338Knut Anders Hatlen <Description>Search in OpenGrok <%= text.toString() %></Description>
59b6a8c0cc6ef741a7180504b3c371e67c2aa338Knut Anders Hatlen <InputEncoding>UTF-8</InputEncoding>
a46f72a555abdeca43d8b4041026c003013d5d19Vladimir Kotal <Image height="16" width="16" type="image/png"><%= imgurl %></Image>
14a41f02433890d19b2f871156271e3388cd0845Jens Elkner<%-- <Url type="application/x-suggestions+json" template="suggestionURL"/>--%>
59b6a8c0cc6ef741a7180504b3c371e67c2aa338Knut Anders Hatlen <Url template="<%= url.toString() %>&q={searchTerms}" type="text/html"/>
30d2f45dd260208f0fb882dde134a249318524b9Lubos Kosco</OpenSearchDescription>
14a41f02433890d19b2f871156271e3388cd0845Jens Elkner/* ---------------------- opensearch.jsp end --------------------- */