CPD Results

The following document contains the results of PMD's CPD 4.2.5.

Duplications

File Line
org/apache/maven/continuum/core/action/CheckoutProjectContinuumAction.java 241
org/apache/maven/continuum/core/action/UpdateWorkingDirectoryFromScmContinuumAction.java 296
    }

    // TODO: migrate to the SvnCommandLineUtils version (preferably properly encapsulated in the provider)
    private String maskPassword( String commandLine )
    {
        String cmd = commandLine;

        if ( cmd != null && cmd.startsWith( "svn" ) )
        {
            String pwdString = "--password";

            if ( cmd.indexOf( pwdString ) > 0 )
            {
                int index = cmd.indexOf( pwdString ) + pwdString.length() + 1;

                int nextSpace = cmd.indexOf( " ", index );

                cmd = cmd.substring( 0, index ) + "********" + cmd.substring( nextSpace );
            }
        }

        return cmd;
    }

    private String getValidationMessages( ScmRepositoryException ex )
    {
        List<String> messages = ex.getValidationMessages();

        StringBuffer message = new StringBuffer();

        if ( messages != null && !messages.isEmpty() )
        {
            for ( Iterator<String> i = messages.iterator(); i.hasNext(); )
            {
                message.append( i.next() );

                if ( i.hasNext() )
                {
                    message.append( System.getProperty( "line.separator" ) );
                }
            }
        }
        return message.toString();
    }

    public static ScmResult getUpdateScmResult( Map<String, Object> context )
File Line
org/apache/maven/continuum/execution/maven/m1/MavenOneBuildExecutor.java 95
org/apache/maven/continuum/execution/maven/m2/MavenTwoBuildExecutor.java 147
            arguments.append( "-f " ).append( buildFile ).append( " " );
        }

        arguments.append( StringUtils.clean( buildDefinition.getArguments() ) ).append( " " );

        Properties props = getContinuumSystemProperties( project );
        for ( Enumeration itr = props.propertyNames(); itr.hasMoreElements(); )
        {
            String name = (String) itr.nextElement();
            String value = props.getProperty( name );
            arguments.append( "\"-D" ).append( name ).append( "=" ).append( value ).append( "\" " );
        }

        // append -Dmaven.repo.local if project group has a local repository
        LocalRepository repository = project.getProjectGroup().getLocalRepository();
        if ( repository != null )
        {
            arguments.append( "\"-Dmaven.repo.local=" ).append( StringUtils.clean( repository.getLocation() ) ).append( "\" " );
        }
        
        arguments.append( StringUtils.clean( buildDefinition.getGoals() ) );
        
        Map<String, String> environments = getEnvironments( buildDefinition );
        String m2Home = environments.get( getInstallationService().getEnvVar( InstallationService.MAVEN2_TYPE ) );
File Line
org/apache/maven/continuum/execution/ant/AntBuildExecutor.java 103
org/apache/maven/continuum/execution/maven/m1/MavenOneBuildExecutor.java 122
            executable = m1Home + File.separator + "bin" + File.separator + executable;
            setResolveExecutable( false );
        }

        return executeShellCommand( project, executable, arguments.toString(), buildOutput, environments );
    }

    protected Map<String, String> getEnvironments( BuildDefinition buildDefinition )
    {
        Profile profile = buildDefinition.getProfile();
        if ( profile == null )
        {
            return Collections.EMPTY_MAP;
        }
        Map<String, String> envVars = new HashMap<String, String>();
        String javaHome = getJavaHomeValue( buildDefinition );
        if ( !StringUtils.isEmpty( javaHome ) )
        {
            envVars.put( getInstallationService().getEnvVar( InstallationService.JDK_TYPE ), javaHome );
        }
        Installation builder = profile.getBuilder();
        if ( builder != null )
        {
            envVars.put( getInstallationService().getEnvVar( InstallationService.MAVEN1_TYPE ), builder.getVarValue() );
File Line
org/apache/maven/continuum/core/action/CheckoutProjectContinuumAction.java 142
org/apache/maven/continuum/core/action/UpdateWorkingDirectoryFromScmContinuumAction.java 144
            result = convertScmResult( scmResult );
        }
        catch ( ScmRepositoryException e )
        {
            result = new ScmResult();

            result.setSuccess( false );

            result.setProviderMessage( e.getMessage() + ": " + getValidationMessages( e ) );

            getLogger().error( e.getMessage(), e );
        }
        catch ( NoSuchScmProviderException e )
        {
            // TODO: this is not making it back into a result of any kind - log it at least. Same is probably the case for ScmException
            result = new ScmResult();

            result.setSuccess( false );

            result.setProviderMessage( e.getMessage() );

            getLogger().error( e.getMessage(), e );
        }
        catch ( ScmException e )
        {
            result = new ScmResult();

            result.setSuccess( false );

            result.setException( ContinuumUtils.throwableMessagesToString( e ) );

            getLogger().error( e.getMessage(), e );
        }
File Line
org/apache/maven/continuum/notification/mail/MailContinuumNotifier.java 768
org/apache/maven/continuum/notification/mail/MailContinuumNotifier.java 871
                            }
                        }
                    }
                }
            }
            else
            {
                // TODO: use configuration file instead of to load it fron component configuration
                // TODO: set a proper name
                InternetAddress to = new InternetAddress( toOverride.trim() );
                log.info( "Recipient: To '" + to + "'." );

                message.addRecipient( Message.RecipientType.TO, to );
            }

            message.setSentDate( new Date() );

            if ( message.getAllRecipients() != null && ( message.getAllRecipients() ).length > 0 )
            {
                javaMailSender.send( message );
            }
        }
        catch ( AddressException ex )
        {
            throw new NotificationException( "Exception while sending message.", ex );
        }
        catch ( MessagingException ex )
        {
            throw new NotificationException( "Exception while sending message.", ex );
        }
        catch ( UnsupportedEncodingException ex )
        {
            throw new NotificationException( "Exception while sending message.", ex );
        }
    }

    private Map<String, String> mapDevelopersToRecipients( List<ProjectDeveloper> developers )
File Line
org/apache/continuum/builder/distributed/DefaultDistributedBuildService.java 338
org/apache/maven/continuum/execution/maven/m2/DefaultMavenBuilderHelper.java 331
                if ( notifier.isFromUser() )
                {
                    ProjectNotifier userNotifier = new ProjectNotifier();

                    userNotifier.setType( notifier.getType() );

                    userNotifier.setEnabled( notifier.isEnabled() );

                    userNotifier.setConfiguration( notifier.getConfiguration() );

                    userNotifier.setFrom( notifier.getFrom() );

                    userNotifier.setRecipientType( notifier.getRecipientType() );

                    userNotifier.setSendOnError( notifier.isSendOnError() );

                    userNotifier.setSendOnFailure( notifier.isSendOnFailure() );

                    userNotifier.setSendOnSuccess( notifier.isSendOnSuccess() );

                    userNotifier.setSendOnWarning( notifier.isSendOnWarning() );

                    userNotifier.setSendOnScmFailure( notifier.isSendOnScmFailure() );

                    userNotifiers.add( userNotifier );
                }
            }
        }
File Line
org/apache/continuum/release/distributed/manager/DefaultDistributedReleaseManager.java 301
org/apache/continuum/release/distributed/manager/DefaultDistributedReleaseManager.java 353
        String buildAgentUrl = buildResult.getBuildUrl();

        if ( !checkBuildAgent( buildAgentUrl ) )
        {
            throw new BuildAgentConfigurationException( buildAgentUrl );
        }

        if ( goals == null )
        {
            goals = "";
        }

        if ( arguments == null )
        {
            arguments = "";
        }

        Map<String, String> map = new HashMap<String, String>();

        if ( repository != null )
        {
            map.put( DistributedReleaseUtil.KEY_LOCAL_REPOSITORY, repository.getLocation() );
            map.put( DistributedReleaseUtil.KEY_LOCAL_REPOSITORY_NAME, repository.getName() );
            map.put( DistributedReleaseUtil.KEY_LOCAL_REPOSITORY_LAYOUT, repository.getLayout() );
        }

        try
        {
            SlaveBuildAgentTransportClient client = new SlaveBuildAgentTransportClient( new URL( buildAgentUrl ) );
File Line
org/apache/continuum/release/distributed/DistributedReleaseUtil.java 271
org/apache/maven/continuum/core/action/AbstractContinuumAction.java 340
        }
    }

    protected static Object getObject( Map<String, Object> context, String key )
    {
        if ( !context.containsKey( key ) )
        {
            throw new RuntimeException( "Missing key '" + key + "'." );
        }

        Object value = context.get( key );

        if ( value == null )
        {
            throw new RuntimeException( "Missing value for key '" + key + "'." );
        }

        return value;
    }

    protected static Object getObject( Map<String, Object> context, String key, Object defaultValue )
    {
        Object value = context.get( key );

        if ( value == null )
        {
            return defaultValue;
        }

        return value;
    }
}
File Line
org/apache/maven/continuum/execution/ant/AntBuildExecutor.java 110
org/apache/maven/continuum/execution/maven/m2/MavenTwoBuildExecutor.java 479
    protected Map<String, String> getEnvironments( BuildDefinition buildDefinition )
    {
        Profile profile = buildDefinition.getProfile();
        if ( profile == null )
        {
            return Collections.EMPTY_MAP;
        }
        Map<String, String> envVars = new HashMap<String, String>();
        String javaHome = getJavaHomeValue( buildDefinition );
        if ( !StringUtils.isEmpty( javaHome ) )
        {
            envVars.put( getInstallationService().getEnvVar( InstallationService.JDK_TYPE ), javaHome );
        }
        Installation builder = profile.getBuilder();
        if ( builder != null )
        {
            envVars.put( getInstallationService().getEnvVar( InstallationService.MAVEN2_TYPE ), builder.getVarValue() );
File Line
org/apache/maven/continuum/execution/ant/AntBuildExecutor.java 82
org/apache/maven/continuum/execution/maven/m2/MavenTwoBuildExecutor.java 145
        if ( !StringUtils.isEmpty( buildFile ) && !"pom.xml".equals( buildFile ) )
        {
            arguments.append( "-f " ).append( buildFile ).append( " " );
        }

        arguments.append( StringUtils.clean( buildDefinition.getArguments() ) ).append( " " );

        Properties props = getContinuumSystemProperties( project );
        for ( Enumeration itr = props.propertyNames(); itr.hasMoreElements(); )
        {
            String name = (String) itr.nextElement();
            String value = props.getProperty( name );
            arguments.append( "\"-D" ).append( name ).append( "=" ).append( value ).append( "\" " );
        }
File Line
org/apache/continuum/builder/distributed/util/DistributedBuildUtil.java 91
org/apache/maven/continuum/buildcontroller/DefaultBuildController.java 639
                                                                                        context.getOldBuildResult().getEndTime() );
                    if ( nbBuild > 0 )
                    {
                        log.debug( "Dependency changed: " + dep.getGroupId() + ":" + dep.getArtifactId() + ":" +
                            dep.getVersion() );
                        modifiedDependencies.add( dep );
                    }
                    else
                    {
                        log.debug( "Dependency not changed: " + dep.getGroupId() + ":" + dep.getArtifactId() + ":" +
                            dep.getVersion() );
                    }
                }
                else
                {
                    log.debug( "Skip non Continuum project: " + dep.getGroupId() + ":" + dep.getArtifactId() + ":" +
                        dep.getVersion() );
                }
            }
File Line
org/apache/maven/continuum/execution/ant/AntBuildExecutor.java 107
org/apache/maven/continuum/execution/shell/ShellBuildExecutor.java 76
                                    getEnvironments( buildDefinition ) );
    }

    protected Map<String, String> getEnvironments( BuildDefinition buildDefinition )
    {
        Profile profile = buildDefinition.getProfile();
        if ( profile == null )
        {
            return Collections.EMPTY_MAP;
        }
        Map<String, String> envVars = new HashMap<String, String>();
        String javaHome = getJavaHomeValue( buildDefinition );
        if ( !StringUtils.isEmpty( javaHome ) )
        {
            envVars.put( getInstallationService().getEnvVar( InstallationService.JDK_TYPE ), javaHome );
        }
        Installation builder = profile.getBuilder();
        if ( builder != null )
        {
            envVars.put( builder.getVarName(), builder.getVarValue() );
File Line
org/apache/maven/continuum/execution/maven/m2/MavenTwoBuildExecutor.java 479
org/apache/maven/continuum/execution/shell/ShellBuildExecutor.java 79
    protected Map<String, String> getEnvironments( BuildDefinition buildDefinition )
    {
        Profile profile = buildDefinition.getProfile();
        if ( profile == null )
        {
            return Collections.EMPTY_MAP;
        }
        Map<String, String> envVars = new HashMap<String, String>();
        String javaHome = getJavaHomeValue( buildDefinition );
        if ( !StringUtils.isEmpty( javaHome ) )
        {
            envVars.put( getInstallationService().getEnvVar( InstallationService.JDK_TYPE ), javaHome );
        }
        Installation builder = profile.getBuilder();
        if ( builder != null )
        {
            envVars.put( builder.getVarName(), builder.getVarValue() );
File Line
org/apache/maven/continuum/execution/ant/AntBuildExecutor.java 84
org/apache/maven/continuum/execution/maven/m1/MavenOneBuildExecutor.java 95
            arguments.append( "-p " ).append( buildFile ).append( " " );
        }

        arguments.append( StringUtils.clean( buildDefinition.getArguments() ) ).append( " " );

        Properties props = getContinuumSystemProperties( project );
        for ( Enumeration itr = props.propertyNames(); itr.hasMoreElements(); )
        {
            String name = (String) itr.nextElement();
            String value = props.getProperty( name );
            arguments.append( "\"-D" ).append( name ).append( "=" ).append( value ).append( "\" " );
        }
File Line
org/apache/maven/continuum/buildcontroller/DefaultBuildController.java 579
org/apache/maven/continuum/core/action/CheckoutProjectContinuumAction.java 263
    }

    private String getValidationMessages( ScmRepositoryException ex )
    {
        List<String> messages = ex.getValidationMessages();

        StringBuffer message = new StringBuffer();

        if ( messages != null && !messages.isEmpty() )
        {
            for ( Iterator<String> i = messages.iterator(); i.hasNext(); )
            {
                message.append( i.next() );

                if ( i.hasNext() )
                {
                    message.append( System.getProperty( "line.separator" ) );
                }
            }
        }
        return message.toString();
    }