EMMA Coverage Report (generated Sun Sep 18 11:34:27 PHT 2011)
[all classes][org.apache.continuum.web.util]

COVERAGE SUMMARY FOR SOURCE FILE [AuditLog.java]

nameclass, %method, %block, %line, %
AuditLog.java100% (1/1)45%  (5/11)59%  (61/103)61%  (16.6/27)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class AuditLog100% (1/1)45%  (5/11)59%  (61/103)61%  (16.6/27)
AuditLog (String): void 0%   (0/1)0%   (0/11)0%   (0/4)
getAction (): String 0%   (0/1)0%   (0/3)0%   (0/1)
getCategory (): String 0%   (0/1)0%   (0/3)0%   (0/1)
getCurrentUser (): String 0%   (0/1)0%   (0/3)0%   (0/1)
getResource (): String 0%   (0/1)0%   (0/3)0%   (0/1)
setResource (String): void 0%   (0/1)0%   (0/4)0%   (0/2)
log (): void 100% (1/1)70%  (35/50)86%  (6/7)
AuditLog (String, String): void 100% (1/1)100% (14/14)100% (5/5)
setAction (String): void 100% (1/1)100% (4/4)100% (2/2)
setCategory (String): void 100% (1/1)100% (4/4)100% (2/2)
setCurrentUser (String): void 100% (1/1)100% (4/4)100% (2/2)

1package org.apache.continuum.web.util;
2 
3/*
4 * Licensed to the Apache Software Foundation (ASF) under one
5 * or more contributor license agreements.  See the NOTICE file
6 * distributed with this work for additional information
7 * regarding copyright ownership.  The ASF licenses this file
8 * to you under the Apache License, Version 2.0 (the
9 * "License"); you may not use this file except in compliance
10 * with the License.  You may obtain a copy of the License at
11 *
12 *   http://www.apache.org/licenses/LICENSE-2.0
13 *
14 * Unless required by applicable law or agreed to in writing,
15 * software distributed under the License is distributed on an
16 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17 * KIND, either express or implied.  See the License for the
18 * specific language governing permissions and limitations
19 * under the License.
20 */
21 
22import org.slf4j.Logger;
23import org.slf4j.LoggerFactory;
24import org.slf4j.MDC;
25 
26/**
27 * @author Jevica Arianne B. Zurbano
28 * @version $Id: AuditLog.java
29 * @since 17 apr 09
30 */
31public class AuditLog
32{
33    private Logger logger = LoggerFactory.getLogger( AuditLog.class.getName() );
34 
35    private String action;
36 
37    private String category;
38    
39    private String resource;
40 
41    private String currentUser;
42 
43    public AuditLog( String action )
44    {
45        this.action = action;
46    }
47 
48    public AuditLog( String resource, String action )
49    {
50        this.action = action;
51        this.resource = resource;
52    }
53 
54    public void setCurrentUser( String currentUser )
55    {
56        this.currentUser = currentUser;
57    }
58 
59    public String getCurrentUser()
60    {
61        return currentUser;
62    }
63 
64    public void setResource( String resource )
65    {
66        this.resource = resource;
67    }
68 
69    public String getResource()
70    {
71        return resource;
72    }
73 
74    public void setCategory( String category )
75    {
76        this.category = category;
77    }
78 
79    public String getCategory()
80    {
81        return category;
82    }
83 
84    public void setAction( String action )
85    {
86        this.action = action;
87    }
88 
89    public String getAction()
90    {
91        return action;
92    }
93 
94    public void log()
95    {
96        if ( currentUser != null )
97        {
98            MDC.put( "security.currentUser", currentUser );
99        }
100        
101        if ( resource != null )
102        {
103            if ( category != null )
104            {
105                logger.info( category + " " + resource + " - " + action );
106            }
107            else
108            {
109                logger.info( resource + " - " + action );
110            }
111        }
112    }
113}
114 

[all classes][org.apache.continuum.web.util]
EMMA 2.0.5312 (C) Vladimir Roubtsov