Clover Coverage Report - Atlassian XWork(Aggregated)
Coverage timestamp: Wed Jul 27 2011 23:39:31 CDT
16   60   8   5.33
10   44   0.5   3
3     2.67  
1    
 
 
  RequestParameterHackInterceptor       Line # 13 16 8 0% 0.0
 
No Tests
 
1    package com.atlassian.xwork.interceptors;
2   
3    import com.opensymphony.xwork.interceptor.AroundInterceptor;
4    import com.opensymphony.xwork.ActionInvocation;
5    import com.opensymphony.xwork.ActionContext;
6   
7    import java.util.*;
8   
9    /**
10    * This interceptor looks for a map in the ActionContext context, and if it finds it BUT
11    * those parameters are NOT in the existing Http Request, then it calls them as setters on the action.
12    */
 
13    public class RequestParameterHackInterceptor extends AroundInterceptor
14    {
15    private static ThreadLocal hack = new ThreadLocal();
16   
 
17  0 toggle public static void setHackMap(Map hackMap)
18    {
19  0 com.atlassian.xwork.interceptors.RequestParameterHackInterceptor.hack.set(hackMap);
20    }
21   
 
22  0 toggle protected void before(ActionInvocation invocation) throws Exception
23    {
24  0 Map hackMap = (Map) com.atlassian.xwork.interceptors.RequestParameterHackInterceptor.hack.get();
25   
26  0 if (hackMap != null)
27    {
28  0 Map acParameters = ActionContext.getContext().getParameters();
29   
30  0 List parametersToSetOnAction = new ArrayList(hackMap.size());
31  0 for (Iterator iterator = hackMap.keySet().iterator(); iterator.hasNext();)
32    {
33  0 String key = (String) iterator.next();
34  0 if (!acParameters.containsKey(key))
35    {
36  0 parametersToSetOnAction.add(key);
37    }
38    }
39   
40    // if we have hack parameters, let's replace the webwork parameters map completely
41  0 if (parametersToSetOnAction.size() > 0)
42    {
43  0 Map parameters = new HashMap(acParameters);
44  0 for (Iterator iterator = parametersToSetOnAction.iterator(); iterator.hasNext();)
45    {
46  0 String key = (String) iterator.next();
47  0 parameters.put(key, hackMap.get(key));
48    }
49   
50  0 ActionContext.getContext().setParameters(parameters);
51    }
52   
53  0 com.atlassian.xwork.interceptors.RequestParameterHackInterceptor.setHackMap(null);
54    }
55    }
56   
 
57  0 toggle protected void after(ActionInvocation actionInvocation, String s) throws Exception
58    {
59    }
60    }