<commit_before>/*
 * Copyright 2005 The JA-SIG Collaborative. All rights reserved. See license
 * distributed with this file and available online at
 * http://www.uportal.org/license.html
 */
package org.jasig.cas.web.flow.util;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.flow.RequestContext;
import org.springframework.web.flow.execution.servlet.HttpServletRequestEvent;

/**
 * Common utilities for extracting information from the RequestContext.
 * 
 * @author <NAME>
 * @version $Revision$ $Date$
 * @since 3.0
 *
 */
public class ContextUtils {

    public static HttpServletRequest getHttpServletRequest(final RequestContext context) {
        if (context.getOriginatingEvent() instanceof HttpServletRequestEvent) {
           return ((HttpServletRequestEvent) context.getOriginatingEvent()).getRequest(); 
        }
        
        throw new IllegalStateException("Cannot obtain HttpServletRequest from event of type: " + context.getOriginatingEvent().getClass().getName());
    }
    
    public static HttpServletResponse getHttpServletResponseFromContext(final RequestContext context) {
        if (context.getOriginatingEvent() instanceof HttpServletRequestEvent) {
           return ((HttpServletRequestEvent) context.getOriginatingEvent()).getResponse(); 
        }
        
        throw new IllegalStateException("Cannot obtain HttpServletResponse from event of type: " + context.getOriginatingEvent().getClass().getName());
    }
    
    public static void addAttribute(final RequestContext context, final String attributeName, final Object attribute) {
        context.getRequestScope().setAttribute(attributeName, attribute);
    }
}<commit_msg>addition of getAttribute<commit_after>/*
 * Copyright 2005 The JA-SIG Collaborative. All rights reserved. See license
 * distributed with this file and available online at
 * http://www.uportal.org/license.html
 */
package org.jasig.cas.web.flow.util;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.flow.RequestContext;
import org.springframework.web.flow.execution.servlet.HttpServletRequestEvent;

/**
 * Common utilities for extracting information from the RequestContext.
 * 
 * @author <NAME>
 * @version $Revision$ $Date$
 * @since 3.0
 *
 */
public class ContextUtils {

    public static HttpServletRequest getHttpServletRequest(final RequestContext context) {
        if (context.getOriginatingEvent() instanceof HttpServletRequestEvent) {
           return ((HttpServletRequestEvent) context.getOriginatingEvent()).getRequest(); 
        }
        
        throw new IllegalStateException("Cannot obtain HttpServletRequest from event of type: " + context.getOriginatingEvent().getClass().getName());
    }
    
    public static HttpServletResponse getHttpServletResponseFromContext(final RequestContext context) {
        if (context.getOriginatingEvent() instanceof HttpServletRequestEvent) {
           return ((HttpServletRequestEvent) context.getOriginatingEvent()).getResponse(); 
        }
        
        throw new IllegalStateException("Cannot obtain HttpServletResponse from event of type: " + context.getOriginatingEvent().getClass().getName());
    }
    
    public static void addAttribute(final RequestContext context, final String attributeName, final Object attribute) {
        context.getRequestScope().setAttribute(attributeName, attribute);
    }
    
    public static Object getAttribute(final RequestContext context, final String attributeName) {
        return context.getRequestScope().getAttribute(attributeName);
    }
}
{'fraction_non_alphanumeric': 0.09007053716766142, 'fraction_numerical': 0.0032555615843733042, 'mean_word_length': 4.229787234042553, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '3315107', 'n_tokens_mistral': 885, 'n_tokens_neox': 885, 'n_words': 229}