Skip to main content
summaryrefslogtreecommitdiffstats
blob: db5aebe45fe386e64dfcc337043f9276a6a2573a (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
/*******************************************************************************
 * Copyright (c) 2007, 2010 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.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.eclipse.core.runtime.Platform;
import org.eclipse.help.internal.base.HelpBasePlugin;
import org.eclipse.help.internal.webapp.servlet.CookieUtil;

/**
 * Helper class for reading cookie values
 */
public class CookiesData extends RequestData {

	public CookiesData(ServletContext context, HttpServletRequest request,
			HttpServletResponse response) {
		super(context, request, response);

	}

	public boolean isSynchToc() {
		Cookie[] cookies = request.getCookies();
		if (cookies != null) {
        		for (Cookie cookie : cookies) {
        			if ("synchToc".equals(cookie.getName())) { //$NON-NLS-1$
        				return String.valueOf(true).equals(cookie.getValue());
        			}
        		}
		}
		boolean isSynchToc = Platform.getPreferencesService().getBoolean
		    (HelpBasePlugin.PLUGIN_ID, "advanced.syncDefault", false, null); //$NON-NLS-1$
		CookieUtil.setCookieValue("synchToc", Boolean.toString(isSynchToc), request, response); //$NON-NLS-1$
		return isSynchToc;
    }

}

Back to the top