EMMA Coverage Report (generated Wed Feb 13 07:49:24 ICT 2008)
[all classes][net.sourceforge.hiveboard.util]

COVERAGE SUMMARY FOR SOURCE FILE [VersionControlManagerImpl.java]

nameclass, %method, %block, %line, %
VersionControlManagerImpl.java100% (1/1)100% (2/2)59%  (30/51)82%  (9/11)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class VersionControlManagerImpl100% (1/1)100% (2/2)59%  (30/51)82%  (9/11)
checkClientVersion (HttpServletRequest, HttpServletResponse): Exception 100% (1/1)46%  (18/39)67%  (4/6)
VersionControlManagerImpl (Log, String, String): void 100% (1/1)100% (12/12)100% (5/5)

1//  Copyright 2004-2007 Jean-Francois Poilpret
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7//     http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14 
15package net.sourceforge.hiveboard.util;
16 
17import javax.servlet.http.HttpServletRequest;
18import javax.servlet.http.HttpServletResponse;
19 
20import org.apache.commons.logging.Log;
21 
22// Singleton model
23public class VersionControlManagerImpl implements VersionControlManager
24{
25        public VersionControlManagerImpl(        Log                logger,
26                                                                                String        serverVersion,
27                                                                                String        supportedClientVersions)
28        {
29                _logger = logger;
30                _serverVersion = serverVersion;
31                _supportedClientVersions = supportedClientVersions;
32        }
33        
34        public Exception        checkClientVersion(        HttpServletRequest        request,
35                                                                                        HttpServletResponse        response)
36        {
37                String clientVersion = request.getHeader(VersionContext.CLIENT_VERSION_KEY);
38                response.setHeader(VersionContext.SERVER_VERSION_KEY, _serverVersion);
39 
40                if (        clientVersion != null
41                        &&        _supportedClientVersions.indexOf(clientVersion) >= 0)
42                {
43                        return null;
44                }
45                _logger.info("Unsupported client version: " + clientVersion);
46                return new VersionMismatchException("Unsupported client version",
47                                                                                        clientVersion, 
48                                                                                        _serverVersion,
49                                                                                        _supportedClientVersions);
50        }
51 
52        private final Log                _logger;
53        private final String        _serverVersion;
54        private final String        _supportedClientVersions;
55}

[all classes][net.sourceforge.hiveboard.util]
EMMA 2.0.5312 (C) Vladimir Roubtsov