From 747f75096f203ed36279a49b6e52211999e41527 Mon Sep 17 00:00:00 2001 From: Chris Goldthorpe Date: Fri, 18 Mar 2011 17:44:02 +0000 Subject: Bug 338922 - [Webapp] Eclipse infocenter not using or saving a search scope --- .../help/internal/server/JettyHelpServer.java | 8 +++- org.eclipse.help.webapp/advanced/view.js | 2 +- org.eclipse.help.webapp/advanced/views.jsp | 4 +- org.eclipse.help.webapp/advanced/workingSet.jsp | 6 +-- .../advanced/workingSetManager.jsp | 8 +--- .../advancedstate/scopeState.jsp | 37 +++++++++++++++++ .../advancedstate/workingSetState.jsp | 37 +++++++++++++++++ org.eclipse.help.webapp/index.jsp | 6 ++- org.eclipse.help.webapp/plugin.xml | 15 +++++++ .../help/internal/webapp/data/RequestScope.java | 2 +- .../webapp/data/ScopeSavingSearchData.java | 29 +++++++++++++ .../help/internal/webapp/data/SearchData.java | 20 ++++----- .../help/internal/webapp/servlet/CookieUtil.java | 48 +++++++++++++++++----- 13 files changed, 183 insertions(+), 39 deletions(-) create mode 100644 org.eclipse.help.webapp/advancedstate/scopeState.jsp create mode 100644 org.eclipse.help.webapp/advancedstate/workingSetState.jsp create mode 100644 org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/ScopeSavingSearchData.java diff --git a/org.eclipse.help.base/src/org/eclipse/help/internal/server/JettyHelpServer.java b/org.eclipse.help.base/src/org/eclipse/help/internal/server/JettyHelpServer.java index d04219df7..8178edb7d 100644 --- a/org.eclipse.help.base/src/org/eclipse/help/internal/server/JettyHelpServer.java +++ b/org.eclipse.help.base/src/org/eclipse/help/internal/server/JettyHelpServer.java @@ -1,5 +1,5 @@ /******************************************************************************* - * Copyright (c) 2008, 2010 IBM Corporation and others. + * Copyright (c) 2008, 2011 IBM Corporation and others. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at @@ -62,7 +62,7 @@ public class JettyHelpServer extends HelpServer { d.put("http.port", new Integer(getPortParameter())); //$NON-NLS-1$ // set the base URL - d.put("context.path", "/help"); //$NON-NLS-1$ //$NON-NLS-2$ + d.put("context.path", getContextPath()); //$NON-NLS-1$ d.put("other.info", getOtherInfo()); //$NON-NLS-1$ // suppress Jetty INFO/DEBUG messages to stderr @@ -208,6 +208,10 @@ public class JettyHelpServer extends HelpServer { return "org.eclipse.help"; //$NON-NLS-1$ } + protected String getContextPath() { + return "/help"; //$NON-NLS-1$ + } + public boolean bindServerToHostname() { if (BaseHelpSystem.getMode() == BaseHelpSystem.MODE_WORKBENCH) { return true; diff --git a/org.eclipse.help.webapp/advanced/view.js b/org.eclipse.help.webapp/advanced/view.js index 4b84e3249..e8fea9ccf 100644 --- a/org.eclipse.help.webapp/advanced/view.js +++ b/org.eclipse.help.webapp/advanced/view.js @@ -14,7 +14,7 @@ function showAll() { var searchFrame = parent.parent.parent.parent.parent.HelpToolbarFrame.SearchFrame; if (searchFrame.getSearchWord) { - searchFrame.location.replace("searchScoped.jsp?searchWord=" + searchFrame.getSearchWord() + "&workingSet="); + searchFrame.location.replace("../scopeState.jsp?searchWord=" + searchFrame.getSearchWord() + "&workingSet="); } } diff --git a/org.eclipse.help.webapp/advanced/views.jsp b/org.eclipse.help.webapp/advanced/views.jsp index bcc91cf7d..8abe0efe1 100644 --- a/org.eclipse.help.webapp/advanced/views.jsp +++ b/org.eclipse.help.webapp/advanced/views.jsp @@ -1,5 +1,5 @@ <%-- - Copyright (c) 2000, 2010 IBM Corporation and others. + Copyright (c) 2000, 2011 IBM Corporation and others. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at @@ -14,8 +14,6 @@ LayoutData data = new LayoutData(application,request, response); WebappPreferences prefs = data.getPrefs(); AbstractView[] views = data.getViews(); - // Read the scope parameter - RequestScope.setScopeFromRequest(request, response); %> diff --git a/org.eclipse.help.webapp/advanced/workingSet.jsp b/org.eclipse.help.webapp/advanced/workingSet.jsp index 5a7db74eb..1def12faa 100644 --- a/org.eclipse.help.webapp/advanced/workingSet.jsp +++ b/org.eclipse.help.webapp/advanced/workingSet.jsp @@ -1,5 +1,5 @@ <%-- - Copyright (c) 2000, 2010 IBM Corporation and others. + Copyright (c) 2000, 2011 IBM Corporation and others. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at @@ -237,8 +237,8 @@ function doSubmit() var criteria = getSelectedCriteriaResources(); var query = "operation="+'<%=UrlUtil.JavaScriptEncode(data.getOperation())%>'+"&workingSet="+encodeURIComponent(workingSet)+ hrefs+criteria+"&oldName="+encodeURIComponent(oldName); - window.opener.location.replace("workingSetManager.jsp?"+query); - window.opener.focus(); + window.opener.location.replace("../workingSetState.jsp?"+query); + window.opener.focus(); window.close(); } catch(ex) {alert("Error..." + ex.message)} } diff --git a/org.eclipse.help.webapp/advanced/workingSetManager.jsp b/org.eclipse.help.webapp/advanced/workingSetManager.jsp index 6aa0ae7ae..4800a89ea 100644 --- a/org.eclipse.help.webapp/advanced/workingSetManager.jsp +++ b/org.eclipse.help.webapp/advanced/workingSetManager.jsp @@ -186,11 +186,7 @@ function selectWorkingSet() { if (searchWord) search += "&searchWord="+encodeURIComponent(searchWord); - window.opener.location.replace( - window.opener.location.protocol + - "//" + - window.opener.location.host + - window.opener.location.pathname + + window.opener.location.replace("../scopeState.jsp" + search); window.close(); @@ -198,7 +194,7 @@ function selectWorkingSet() { } function removeWorkingSet() { - window.location.replace("workingSetManager.jsp?operation=remove&workingSet="+encodeURIComponent(getWorkingSet())); + window.location.replace("../workingSetState.jsp?operation=remove&workingSet="+encodeURIComponent(getWorkingSet())); if (getWorkingSet()==window.opener.document.getElementById("scope").firstChild.nodeValue){ window.opener.document.getElementById("scope").firstChild.nodeValue= "<%=UrlUtil.JavaScriptEncode(ServletResources.getString("All", request))%>"; diff --git a/org.eclipse.help.webapp/advancedstate/scopeState.jsp b/org.eclipse.help.webapp/advancedstate/scopeState.jsp new file mode 100644 index 000000000..c9b5b90ec --- /dev/null +++ b/org.eclipse.help.webapp/advancedstate/scopeState.jsp @@ -0,0 +1,37 @@ +<%-- + Copyright (c) 2011 IBM Corporation and others. + All rights reserved. This program and the accompanying materials + are made available under the terms of the Eclipse Public License v1.0 + which accompanies this distribution, and is available at + http://www.eclipse.org/legal/epl-v10.html + + Contributors: + IBM Corporation - initial API and implementation +--%> +<%@ page import="org.eclipse.help.internal.webapp.data.*" errorPage="/advanced/err.jsp" contentType="text/html; charset=UTF-8"%> + +<% + SearchData data = new ScopeSavingSearchData(application, request, response); + String workingSet = request.getParameter("workingSet"); + String args = "?searchWord=" + data.getSearchWord(); + if (workingSet != null) { + args += "&workingSet=" + workingSet; + } +%> + +"> + + +<%=ServletResources.getString("Loading", request)%> + + + + + + + + \ No newline at end of file diff --git a/org.eclipse.help.webapp/advancedstate/workingSetState.jsp b/org.eclipse.help.webapp/advancedstate/workingSetState.jsp new file mode 100644 index 000000000..9abc5bbef --- /dev/null +++ b/org.eclipse.help.webapp/advancedstate/workingSetState.jsp @@ -0,0 +1,37 @@ +<%-- + Copyright (c) 2011 IBM Corporation and others. + All rights reserved. This program and the accompanying materials + are made available under the terms of the Eclipse Public License v1.0 + which accompanies this distribution, and is available at + http://www.eclipse.org/legal/epl-v10.html + + Contributors: + IBM Corporation - initial API and implementation +--%> +<%@ page import="org.eclipse.help.internal.webapp.data.*" errorPage="/advanced/err.jsp" contentType="text/html; charset=UTF-8"%> + +<% + new WorkingSetManagerData(application, request, response); + String workingSet = request.getParameter("workingSet"); + String args = ""; + if (workingSet != null && workingSet.length() > 0) { + args = "?workingSet=" + workingSet; + } +%> + +"> + + +<%=ServletResources.getString("Loading", request)%> + + + + + + + + \ No newline at end of file diff --git a/org.eclipse.help.webapp/index.jsp b/org.eclipse.help.webapp/index.jsp index d006e9b44..c8fa90197 100644 --- a/org.eclipse.help.webapp/index.jsp +++ b/org.eclipse.help.webapp/index.jsp @@ -1,5 +1,5 @@ <%-- - Copyright (c) 2000, 2010 IBM Corporation and others. + Copyright (c) 2000, 2011 IBM Corporation and others. All rights reserved. This program and the accompanying materials are made available under the terms of the Eclipse Public License v1.0 which accompanies this distribution, and is available at @@ -11,7 +11,9 @@ <%@ page import="org.eclipse.help.internal.webapp.data.*" errorPage="/advanced/err.jsp" contentType="text/html; charset=UTF-8"%> <% request.setCharacterEncoding("UTF-8"); - ServerState.webappStarted(application,request, response); + ServerState.webappStarted(application,request, response); + // Read the scope parameter + RequestScope.setScopeFromRequest(request, response); LayoutData data = new LayoutData(application,request, response); if (request.getParameter("noscript") != null) { diff --git a/org.eclipse.help.webapp/plugin.xml b/org.eclipse.help.webapp/plugin.xml index b9be17994..85d3684a7 100644 --- a/org.eclipse.help.webapp/plugin.xml +++ b/org.eclipse.help.webapp/plugin.xml @@ -128,6 +128,21 @@ class="org.eclipse.equinox.jsp.jasper.registry.JSPFactory:/" httpcontextId="help"> + + + + + + 0; + } + + private static String getCookiePath(HttpServletRequest request) { + return request.getContextPath() + '/'; } public static void deleteCookie(String name, HttpServletRequest request, HttpServletResponse response) { - deleteCookieUsingPath(name, response, getCookiePath(request)); + deleteCookieUsingPath(name, request, response, getCookiePath(request)); } - protected static void deleteCookieUsingPath(String name, + protected static void deleteCookieUsingPath(String name, HttpServletRequest request, HttpServletResponse response, String cookiePath) { Cookie cookie = new Cookie(name, ""); //$NON-NLS-1$ - cookie.setPath(cookiePath); + String requestURI = request.getRequestURI(); + if (!(requestURI.startsWith(cookiePath) && requestURI.indexOf('/', cookiePath.length() + 1) == -1)) { + cookie.setPath(cookiePath); + } cookie.setMaxAge(0); response.addCookie(cookie); } @@ -95,8 +123,8 @@ public class CookieUtil { for (Iterator iter = cookiesToDelete.iterator(); iter.hasNext();) { String name = (String) iter.next(); - deleteCookieUsingPath(name, response, request.getContextPath() + "/advanced/"); //$NON-NLS-1$ - deleteCookieUsingPath(name, response, "/"); //$NON-NLS-1$ + deleteCookieUsingPath(name, request, response, request.getContextPath() + "/advanced/"); //$NON-NLS-1$ + deleteCookieUsingPath(name, request, response, "/"); //$NON-NLS-1$ } } } -- cgit v1.2.3