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

COVERAGE SUMMARY FOR SOURCE FILE [GenerateRecipentNotifier.java]

nameclass, %method, %block, %line, %
GenerateRecipentNotifier.java0%   (0/1)0%   (0/2)0%   (0/117)0%   (0/20)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class GenerateRecipentNotifier0%   (0/1)0%   (0/2)0%   (0/117)0%   (0/20)
GenerateRecipentNotifier (): void 0%   (0/1)0%   (0/3)0%   (0/2)
generate (ProjectNotifier): String 0%   (0/1)0%   (0/114)0%   (0/18)

1package org.apache.continuum.web.util;
2 
3import java.util.Map;
4 
5import org.apache.commons.lang.StringEscapeUtils;
6import org.apache.maven.continuum.model.project.ProjectNotifier;
7import org.apache.maven.continuum.notification.AbstractContinuumNotifier;
8import org.codehaus.plexus.util.StringUtils;
9 
10/*
11 * Licensed to the Apache Software Foundation (ASF) under one
12 * or more contributor license agreements.  See the NOTICE file
13 * distributed with this work for additional information
14 * regarding copyright ownership.  The ASF licenses this file
15 * to you under the Apache License, Version 2.0 (the
16 * "License"); you may not use this file except in compliance
17 * with the License.  You may obtain a copy of the License at
18 *
19 *   http://www.apache.org/licenses/LICENSE-2.0
20 *
21 * Unless required by applicable law or agreed to in writing,
22 * software distributed under the License is distributed on an
23 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
24 * KIND, either express or implied.  See the License for the
25 * specific language governing permissions and limitations
26 * under the License.
27 */
28 
29/**
30 * @author Jos√© Morales Mart√≠nez
31 * @version $Id: GenerateRecipentNotifier.java 1101669 2011-05-10 22:46:21Z ctan $
32 */
33public final class GenerateRecipentNotifier
34{
35    private GenerateRecipentNotifier()
36    {
37 
38    }
39 
40    @SuppressWarnings("unchecked")
41    public static String generate( ProjectNotifier notifier )
42    {
43        Map<String, String> configuration = notifier.getConfiguration();
44        String recipent = "unknown";
45        if ( ( "mail".equals( notifier.getType() ) ) || ( "msn".equals( notifier.getType() ) ) ||
46            ( "jabber".equals( notifier.getType() ) ) )
47        {
48            if ( StringUtils.isNotEmpty( configuration.get( AbstractContinuumNotifier.ADDRESS_FIELD ) ) )
49            {
50                recipent = configuration.get( AbstractContinuumNotifier.ADDRESS_FIELD );
51            }
52            if ( StringUtils.isNotEmpty( configuration.get( AbstractContinuumNotifier.COMMITTER_FIELD ) ) )
53            {
54                if ( Boolean.parseBoolean( configuration.get( AbstractContinuumNotifier.COMMITTER_FIELD ) ) )
55                {
56                    if ( "unknown".equals( recipent ) )
57                    {
58                        recipent = "latest committers";
59                    }
60                    else
61                    {
62                        recipent += ", " + "latest committers";
63                    }
64                }
65            }
66        }
67        if ( "irc".equals( notifier.getType() ) )
68        {
69            recipent = configuration.get( "host" );
70            if ( configuration.get( "port" ) != null )
71            {
72                recipent = recipent + ":" + configuration.get( "port" );
73            }
74            recipent = recipent + ":" + configuration.get( "channel" );
75        }
76        if ( "wagon".equals( notifier.getType() ) )
77        {
78            recipent = configuration.get( "url" );
79        }
80        // escape the characters, it may contain characters possible for an XSS attack
81        return StringEscapeUtils.escapeXml( recipent );
82    }
83}

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