<commit_before>/*
 * eXist Open Source Native XML Database
 * Copyright (C) 2001-2006 The eXist team
 *  http://exist-db.org
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *  
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program; if not, write to the Free Software Foundation
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 *  
 *  $Id$
 */

package org.exist.cocoon;

import java.io.IOException;
import java.io.OutputStream;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;

import org.apache.cocoon.environment.Cookie;
import org.apache.cocoon.environment.Response;
import org.apache.cocoon.environment.http.HttpCookie;
import org.apache.cocoon.environment.http.HttpResponse;
import org.exist.http.servlets.ResponseWrapper;

/**
 * @author <NAME> (<EMAIL>)
 */
public class CocoonResponseWrapper implements ResponseWrapper {

	private Response response;
	
	/**
	 * 
	 */
	public CocoonResponseWrapper(Response response) {
		this.response = response;
	}

	/**
	 * @param name Name of the Cookie
	 * @param value Value of the Cookie
	 */
	public void addCookie(String name, String value)
	{
		response.addCookie(new HttpCookie(name, value));
	}

	/**
	 * @param name Name of the Cookie
	 * @param value Value of the Cookie
	 * @param maxAge MaxAge of the Cookie
	 */
	public void addCookie(String name, String value, int maxAge)
	{
	    HttpCookie cookie = new HttpCookie(name, value);
	    cookie.setMaxAge(maxAge);
	    response.addCookie(cookie);
	}
	
	/**
	 * @param name Name of the Cookie
	 * @param value Value of the Cookie
	 * @param maxAge MaxAge of the Cookie
	 * @param secure security of the Cookie
	 */
	public void addCookie(String name, String value, int maxAge, boolean secure)
	{
	    HttpCookie cookie = new HttpCookie(name, value);
	    cookie.setMaxAge(maxAge);
		cookie.setSecure( secure );
	    response.addCookie(cookie);
	}
	
	/**
	 * @param arg0
	 */
	public void addCookie(Cookie arg0) {
		response.addCookie(arg0);
	}

	/**
	 * @param contentType Content Type of the response
	 */
	public void setContentType(String contentType)
	{
		response.setHeader("Content-Type", contentType);<commit_msg>[bufgix] rev. 11853 generated a syntax error in Cocoon extension code. Fixed. Please, developers, test the whole code base before committing !<commit_after>/*
 * eXist Open Source Native XML Database
 * Copyright (C) 2001-2006 The eXist team
 *  http://exist-db.org
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *  
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.
 * 
 * You should have received a copy of the GNU Lesser General Public License
 * along with this program; if not, write to the Free Software Foundation
 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
 *  
 *  $Id$
 */

package org.exist.cocoon;

import java.io.IOException;
import java.io.OutputStream;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;

import org.apache.cocoon.environment.Cookie;
import org.apache.cocoon.environment.Response;
import org.apache.cocoon.environment.http.HttpCookie;
import org.apache.cocoon.environment.http.HttpResponse;
import org.exist.http.servlets.ResponseWrapper;

/**
 * @author <NAME> (<EMAIL>)
 */
public class CocoonResponseWrapper implements ResponseWrapper {

	private Response response;
	
	/**
	 * 
	 */
	public CocoonResponseWrapper(Response response) {
		this.response = response;
	}

	/**
	 * @param name Name of the Cookie
	 * @param value Value of the Cookie
	 */
	public void addCookie(String name, String value)
	{
		response.addCookie(new HttpCookie(name, value));
	}

	/**
	 * @param name Name of the Cookie
	 * @param value Value of the Cookie
	 * @param maxAge MaxAge of the Cookie
	 */
	public void addCookie(String name, String value, int maxAge)
	{
	    HttpCookie cookie = new HttpCookie(name, value);
	    cookie.setMaxAge(maxAge);
	    response.addCookie(cookie);
	}
	
	/**
	 * @param name Name of the Cookie
	 * @param value Value of the Cookie
	 * @param maxAge MaxAge of the Cookie
	 * @param secure security of the Cookie
	 */
	public void addCookie(String name, String value, int maxAge, boolean secure)
	{
	    HttpCookie cookie = new HttpCookie(name, value);
	    cookie.setMaxAge(maxAge);
		cookie.setSecure( secure );
	    response.addCookie(cookie);
	}
	
	/**
	 * The method <code>addCookie</code>
	 *
	 * @param name Name of the Cookie
	 * @param value Value of the Cookie
	 * @param maxAge an <code>int</code> value
	 * @param secure security of the Cookie
	 * @param domain domain of the cookie
	 * @param path path scope of the cookie
	 */
	public void addCookie(String name, String value, int maxAge, boolean secure, String domain, String path) {
	    HttpCookie cookie = new HttpCookie(name, value);
	    cookie.setMaxAge(maxAge);
	    cookie.setSecure( secure );
	    cookie.setDomain(domain);
	    cookie.setPath(path);
	    response.addCookie(cookie);
	}
	
	/**
	 * @param arg0
	 */
	public void addCookie(Cookie arg0) {
		response.addCookie(arg0);
	}

	/**
	 * @param contentType Content Type of the response
	 */
	public void setContentType(String contentType)
	{
		response.setHeader("Content-Type", contentType);
{'fraction_non_alphanumeric': 0.09356629653821032, 'fraction_numerical': 0.008327890267798824, 'mean_word_length': 3.7443841982958945, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2014679', 'n_tokens_mistral': 1910, 'n_tokens_neox': 1709, 'n_words': 656}