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

COVERAGE SUMMARY FOR SOURCE FILE [InstallationValidator.java]

nameclass, %method, %block, %line, %
InstallationValidator.java0%   (0/1)0%   (0/5)0%   (0/80)0%   (0/22)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class InstallationValidator0%   (0/1)0%   (0/5)0%   (0/80)0%   (0/22)
<static initializer> 0%   (0/1)0%   (0/4)0%   (0/1)
InstallationValidator (): void 0%   (0/1)0%   (0/3)0%   (0/1)
getFieldName (): String 0%   (0/1)0%   (0/3)0%   (0/1)
setFieldName (String): void 0%   (0/1)0%   (0/4)0%   (0/2)
validate (Object): void 0%   (0/1)0%   (0/66)0%   (0/17)

1package org.apache.maven.continuum.web.validator;
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 com.opensymphony.xwork2.validator.ValidationException;
23import com.opensymphony.xwork2.validator.validators.ValidatorSupport;
24 
25import org.apache.maven.continuum.execution.ExecutorConfigurator;
26import org.apache.maven.continuum.installation.InstallationException;
27import org.apache.maven.continuum.installation.InstallationService;
28import org.codehaus.plexus.util.StringUtils;
29import org.slf4j.Logger;
30import org.slf4j.LoggerFactory;
31 
32 
33/**
34 * @author <a href="mailto:olamy@codehaus.org">olamy</a>
35 * @version $Id: InstallationValidator.java 765340 2009-04-15 20:22:00Z evenisse $
36 * @plexus.component role="com.opensymphony.xwork2.validator.Validator" role-hint="org.apache.maven.continuum.web.validator.InstallationValidator"
37 * @since 19 juin 07
38 */
39public class InstallationValidator
40    extends ValidatorSupport
41{
42    private String fieldName;
43 
44    private static final Logger logger = LoggerFactory.getLogger( InstallationValidator.class );
45 
46    /**
47     * @plexus.requirement role-hint="default"
48     */
49    private InstallationService installationService;
50 
51    /**
52     * @see com.opensymphony.xwork2.validator.Validator#validate(java.lang.Object)
53     */
54    public void validate( Object object )
55        throws ValidationException
56    {
57        String name = (String) this.getFieldValue( "installation.name", object );
58        if ( StringUtils.isEmpty( name ) )
59        {
60            return;
61        }
62 
63        String varValue = (String) this.getFieldValue( "installation.varValue", object );
64        if ( StringUtils.isEmpty( varValue ) )
65        {
66            return;
67        }
68        // TODO validating varValue != null depending on type (not null for envVar)
69 
70        String type = (String) this.getFieldValue( "installation.type", object );
71 
72        ExecutorConfigurator executorConfigurator = installationService.getExecutorConfigurator( type );
73        try
74        {
75            if ( executorConfigurator != null )
76            {
77                if ( executorConfigurator.getVersionArgument() != null )
78                {
79                    // just try to get version infos to validate path is valid
80                    installationService.getExecutorConfiguratorVersion( varValue, executorConfigurator, null );
81                }
82            }
83        }
84        catch ( InstallationException e )
85        {
86            String message = getMessage( getMessageKey() ) + e.getMessage();
87            logger.error( message );
88            addFieldError( "installation.varValue", message );
89        }
90    }
91 
92    public String getFieldName()
93    {
94        return fieldName;
95    }
96 
97    public void setFieldName( String fieldName )
98    {
99        this.fieldName = fieldName;
100    }
101}

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