Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Goldthorpe2011-03-18 17:44:02 +0000
committerChris Goldthorpe2011-03-18 17:44:02 +0000
commit747f75096f203ed36279a49b6e52211999e41527 (patch)
tree3b8505cb4d104081fd1e4904ad58a66853226ac2
parent9b1f0d643df70f76a92c7860c028a1df7c2bda44 (diff)
downloadeclipse.platform.ua-747f75096f203ed36279a49b6e52211999e41527.tar.gz
eclipse.platform.ua-747f75096f203ed36279a49b6e52211999e41527.tar.xz
eclipse.platform.ua-747f75096f203ed36279a49b6e52211999e41527.zip
Bug 338922 - [Webapp] Eclipse infocenter not using or saving a search scope
-rw-r--r--org.eclipse.help.base/src/org/eclipse/help/internal/server/JettyHelpServer.java8
-rw-r--r--org.eclipse.help.webapp/advanced/view.js2
-rw-r--r--org.eclipse.help.webapp/advanced/views.jsp4
-rw-r--r--org.eclipse.help.webapp/advanced/workingSet.jsp6
-rw-r--r--org.eclipse.help.webapp/advanced/workingSetManager.jsp8
-rw-r--r--org.eclipse.help.webapp/advancedstate/scopeState.jsp37
-rw-r--r--org.eclipse.help.webapp/advancedstate/workingSetState.jsp37
-rw-r--r--org.eclipse.help.webapp/index.jsp6
-rw-r--r--org.eclipse.help.webapp/plugin.xml15
-rw-r--r--org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/RequestScope.java2
-rw-r--r--org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/ScopeSavingSearchData.java29
-rw-r--r--org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/SearchData.java20
-rw-r--r--org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/CookieUtil.java48
13 files changed, 183 insertions, 39 deletions
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;
+ }
+%>
+
+<html lang="<%=ServletResources.getString("locale", request)%>">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<title><%=ServletResources.getString("Loading", request)%></title>
+
+<script language="JavaScript">
+ function onloadHandler() {
+ location.href="advanced/searchScoped.jsp<%=UrlUtil.JavaScriptEncode(args)%>";
+ }
+</script>
+
+</head>
+
+<body onload="onloadHandler()">
+</body>
+</html> \ 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;
+ }
+%>
+
+<html lang="<%=ServletResources.getString("locale", request)%>">
+<head>
+<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
+<title><%=ServletResources.getString("Loading", request)%></title>
+
+<script language="JavaScript">
+ function onloadHandler() {
+ location.href="advanced/workingSetManager.jsp<%=UrlUtil.JavaScriptEncode(args)%>";
+ }
+</script>
+
+</head>
+
+<body onload="onloadHandler()">
+</body>
+</html> \ 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
@@ -129,6 +129,21 @@
httpcontextId="help">
</servlet>
<servlet
+ alias="/index.jsp"
+ class="org.eclipse.equinox.jsp.jasper.registry.JSPFactory:/index.jsp"
+ httpcontextId="help">
+ </servlet>
+ <servlet
+ alias="/scopeState.jsp"
+ class="org.eclipse.equinox.jsp.jasper.registry.JSPFactory:/advancedstate/scopeState.jsp"
+ httpcontextId="help">
+ </servlet>
+ <servlet
+ alias="/workingSetState.jsp"
+ class="org.eclipse.equinox.jsp.jasper.registry.JSPFactory:/advancedstate/workingSetState.jsp"
+ httpcontextId="help">
+ </servlet>
+ <servlet
alias="/advanced/*.jsp"
class="org.eclipse.equinox.jsp.jasper.registry.JSPFactory:/advanced/"
httpcontextId="help">
diff --git a/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/RequestScope.java b/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/RequestScope.java
index 8a2754605..ea60b12a8 100644
--- a/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/RequestScope.java
+++ b/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/RequestScope.java
@@ -197,7 +197,7 @@ public class RequestScope {
boolean value)
{
if (HelpSystem.isShared()) {
- CookieUtil.setCookieValue(flagName, Boolean.toString(value), request, response);
+ CookieUtil.setCookieValueWithoutPath(flagName, Boolean.toString(value), request, response);
} else {
IEclipsePreferences pref = InstanceScope.INSTANCE.getNode(HelpBasePlugin.PLUGIN_ID);
pref.putBoolean(flagName + "Webapp", value ); //$NON-NLS-1$
diff --git a/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/ScopeSavingSearchData.java b/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/ScopeSavingSearchData.java
new file mode 100644
index 000000000..f7081059c
--- /dev/null
+++ b/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/ScopeSavingSearchData.java
@@ -0,0 +1,29 @@
+/*******************************************************************************
+ * 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
+ *******************************************************************************/
+
+package org.eclipse.help.internal.webapp.data;
+
+import javax.servlet.ServletContext;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+public class ScopeSavingSearchData extends SearchData {
+
+ public ScopeSavingSearchData(ServletContext context,
+ HttpServletRequest request, HttpServletResponse response) {
+ super(context, request, response);
+ }
+
+ protected boolean canSaveScope() {
+ return true;
+ }
+
+}
diff --git a/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/SearchData.java b/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/SearchData.java
index fe4413c6f..37534a731 100644
--- a/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/SearchData.java
+++ b/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/data/SearchData.java
@@ -103,13 +103,21 @@ public class SearchData extends ActivitiesData {
if (isScopeRequest()) {
workingSetName = request.getParameter("workingSet"); //$NON-NLS-1$
- saveWorkingSet(workingSetName);
+ if ( canSaveScope() ) {
+ saveWorkingSet(workingSetName);
+ }
}
// try loading search results or get the indexing progress info.
readSearchResults();
}
+ protected boolean canSaveScope() {
+ // Scope is only saved from scopeState.jsp
+ // This prevents cookies from being saved with a /advanced path
+ return false;
+ }
+
private void readDisplayFlags(HttpServletRequest request, HttpServletResponse response) {
String showCategoriesParam = request.getParameter(SHOW_CATEGORIES);
if (showCategoriesParam != null) {
@@ -399,16 +407,6 @@ public class SearchData extends ActivitiesData {
return workingSetName;
}
- /**
- * This method is used to persist the working set name and is called from
- * the search view, after each search
- */
- public void saveScope() {
- // if a working set is defined, set it in the preferences
- String workingSet = request.getParameter("scope"); //$NON-NLS-1$
- saveWorkingSet(workingSet);
- }
-
private void saveWorkingSet(String workingSet) {
String lastWS = wsmgr.getCurrentWorkingSet();
if (workingSet != null && !workingSet.equals(lastWS)) {
diff --git a/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/CookieUtil.java b/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/CookieUtil.java
index 45134be86..af6bbe400 100644
--- a/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/CookieUtil.java
+++ b/org.eclipse.help.webapp/src/org/eclipse/help/internal/webapp/servlet/CookieUtil.java
@@ -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
@@ -51,30 +51,58 @@ public class CookieUtil {
}
return ret;
}
+
public static void setCookieValue(String name, String value,
HttpServletRequest request, HttpServletResponse response) {
Cookie cookie = new Cookie(name, value);
cookie.setMaxAge(COOKIE_LIFE);
- cookie.setPath(getCookiePath(request));
+
+ if ( needsCookiePath(request)) {
+ cookie.setPath(getCookiePath(request)); // Only set path if necessary
+ }
response.addCookie(cookie);
if (HelpWebappPlugin.DEBUG_WORKINGSETS) {
System.out
.println("CookieUtil.setCookieValue(" + name + ", " + value + ",...)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
}
}
- protected static String getCookiePath(HttpServletRequest request) {
- String path = request.getContextPath() + '/';
- return path;
+
+ public static void setCookieValueWithoutPath(String name, String value,
+ HttpServletRequest request, HttpServletResponse response ) {
+ Cookie cookie = new Cookie(name, value);
+ cookie.setMaxAge(COOKIE_LIFE);
+
+ response.addCookie(cookie);
+ if (HelpWebappPlugin.DEBUG_WORKINGSETS) {
+ System.out
+ .println("CookieUtil.setCookieValueWithoutPath(" + name + ", " + value + ",...)"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
+ }
+ }
+
+ private static boolean needsCookiePath(HttpServletRequest request) {
+ // All cookies should be at the same path level as the context ( /help )
+ // The cookie path needs to be set if there are more path segments
+ // between the context path and file name
+ String requestURI = request.getRequestURI();
+ String contextPath = request.getContextPath();
+ return requestURI.indexOf('/', contextPath.length() + 1) > 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$
}
}
}

Back to the top