Package org.apache.maven.wagon

Examples of org.apache.maven.wagon.Wagon


        File tmpResource = null;

        File workingDirectory = createWorkingDirectory( repository );
        try
        {
            Wagon wagon = null;
            try
            {
                RepositoryURL repoUrl = remoteRepository.getURL();
                String protocol = repoUrl.getProtocol();
                wagon = (Wagon) wagonFactory.getWagon( "wagon#" + protocol );
                if ( wagon == null )
                {
                    throw new ProxyException( "Unsupported target repository protocol: " + protocol );
                }

                boolean connected = connectToRepository( connector, wagon, remoteRepository );
                if ( connected )
                {
                    tmpResource = new File( workingDirectory, resource.getName() );
                    transferSimpleFile( wagon, remoteRepository, remotePath, repository, resource, tmpResource );

                    // TODO: these should be used to validate the download based on the policies, not always downloaded
                    // to
                    // save on connections since md5 is rarely used
                    tmpSha1 =
                        transferChecksum( wagon, remoteRepository, remotePath, repository, resource, workingDirectory,
                                          ".sha1" );
                    tmpMd5 =
                        transferChecksum( wagon, remoteRepository, remotePath, repository, resource, workingDirectory,
                                          ".md5" );
                }
            }
            catch ( NotFoundException e )
            {
                urlFailureCache.cacheFailure( url );
                throw e;
            }
            catch ( NotModifiedException e )
            {
                // Do not cache url here.
                throw e;
            }
            catch ( ProxyException e )
            {
                urlFailureCache.cacheFailure( url );
                throw e;
            }
            finally
            {
                if ( wagon != null )
                {
                    try
                    {
                        wagon.disconnect();
                    }
                    catch ( ConnectionException e )
                    {
                        log.warn( "Unable to disconnect wagon.", e );
                    }
View Full Code Here


            throw new ContinuumException( "The URL to the site is not defined." );
        }

        Repository repository = new Repository( id, url );

        Wagon wagon;
        try
        {
            wagon = wagonManager.getWagon( repository.getProtocol() );
        }
        catch ( UnsupportedProtocolException e )
        {
            throw new ContinuumException( "Unsupported protocol: '" + repository.getProtocol() + "'", e );
        }

        if ( !wagon.supportsDirectoryCopy() )
        {
            throw new ContinuumException(
                "Wagon protocol '" + repository.getProtocol() + "' doesn't support directory copying" );
        }

        try
        {
            if ( log.isDebugEnabled() )
            {
                Debug debug = new Debug();

                wagon.addSessionListener( debug );
                wagon.addTransferListener( debug );
            }

            ProxyInfo proxyInfo = getProxyInfo( repository );

            if ( proxyInfo != null )
            {
                wagon.connect( repository, getAuthenticationInfo( id ), proxyInfo );
            }
            else
            {
                wagon.connect( repository, getAuthenticationInfo( id ) );
            }

            File buildOutputFile = configurationService.getBuildOutputFile( build.getId(), build.getProject().getId() );

            wagon.put( buildOutputFile, BUILD_OUTPUT_FILE_NAME );

            // TODO: current wagon uses zip which will use the umask on remote host instead of honouring our settings
            //  Force group writeable
            if ( wagon instanceof CommandExecutor )
            {
                CommandExecutor exec = (CommandExecutor) wagon;
                exec.executeCommand( "chmod -Rf g+w " + repository.getBasedir() );
            }
        }
        catch ( ConfigurationException e )
        {
            throw new ContinuumException( "Error uploading build results to deployed site.", e );
        }
        catch ( ResourceDoesNotExistException e )
        {
            throw new ContinuumException( "Error uploading site", e );
        }
        catch ( TransferFailedException e )
        {
            throw new ContinuumException( "Error uploading site", e );
        }
        catch ( AuthorizationException e )
        {
            throw new ContinuumException( "Error uploading site", e );
        }
        catch ( ConnectionException e )
        {
            throw new ContinuumException( "Error uploading site", e );
        }
        catch ( AuthenticationException e )
        {
            throw new ContinuumException( "Error uploading site", e );
        }
        catch ( CommandExecutionException e )
        {
            throw new ContinuumException( "Error uploading site", e );
        }
        finally
        {
            try
            {
                wagon.disconnect();
            }
            catch ( ConnectionException e )
            {
                log.error( "Error disconnecting wagon - ignored", e );
            }
View Full Code Here

        File tmpResource = null;

        File workingDirectory = createWorkingDirectory( repository );
        try
        {
            Wagon wagon = null;
            try
            {
                RepositoryURL repoUrl = remoteRepository.getURL();
                String protocol = repoUrl.getProtocol();
                wagon = (Wagon) wagonFactory.getWagon( "wagon#" + protocol );
                if ( wagon == null )
                {
                    throw new ProxyException( "Unsupported target repository protocol: " + protocol );
                }

                boolean connected = connectToRepository( connector, wagon, remoteRepository );
                if ( connected )
                {
                    tmpResource = new File( workingDirectory, resource.getName() );
                    transferSimpleFile( wagon, remoteRepository, remotePath, repository, resource, tmpResource );

                    // TODO: these should be used to validate the download based on the policies, not always downloaded
                    // to
                    // save on connections since md5 is rarely used
                    tmpSha1 =
                        transferChecksum( wagon, remoteRepository, remotePath, repository, resource, workingDirectory,
                                          ".sha1" );
                    tmpMd5 =
                        transferChecksum( wagon, remoteRepository, remotePath, repository, resource, workingDirectory,
                                          ".md5" );
                }
            }
            catch ( NotFoundException e )
            {
                urlFailureCache.cacheFailure( url );
                throw e;
            }
            catch ( NotModifiedException e )
            {
                // Do not cache url here.
                throw e;
            }
            catch ( ProxyException e )
            {
                urlFailureCache.cacheFailure( url );
                throw e;
            }
            finally
            {
                if ( wagon != null )
                {
                    try
                    {
                        wagon.disconnect();
                    }
                    catch ( ConnectionException e )
                    {
                        log.warn( "Unable to disconnect wagon.", e );
                    }
View Full Code Here

                            //FileUtils.copyURLToFile(downloadUrl, tempDownloadFile);

                            //vharseko@openam.org.ru
                            String endPointUrl = downloadUrl.getProtocol() + "://"+ downloadUrl.getAuthority();
                            Repository repository = new Repository("additonal-configs", endPointUrl);
                            Wagon wagon = wagonManager.getWagon(downloadUrl.getProtocol());
                            if (getLog().isDebugEnabled())
                            {
                                Debug debug = new Debug();
                                wagon.addSessionListener(debug);
                                wagon.addTransferListener(debug);
                            }
                            wagon.setTimeout(artifactItem.getTimeout());
                            Settings settings = mavenSettingsBuilder.buildSettings();
                            ProxyInfo proxyInfo = null;
                            if (settings != null&& settings.getActiveProxy() != null)
                            {
                                Proxy settingsProxy = settings.getActiveProxy();
                                proxyInfo = new ProxyInfo();
                                proxyInfo.setHost(settingsProxy.getHost());
                                proxyInfo.setType(settingsProxy.getProtocol());
                                proxyInfo.setPort(settingsProxy.getPort());
                                proxyInfo.setNonProxyHosts(settingsProxy.getNonProxyHosts());
                                proxyInfo.setUserName(settingsProxy.getUsername());
                                proxyInfo.setPassword(settingsProxy.getPassword());
                            }

                            if (proxyInfo != null)
                                wagon.connect(repository, wagonManager.getAuthenticationInfo(repository.getId()),proxyInfo);
                            else
                                wagon.connect(repository, wagonManager.getAuthenticationInfo(repository.getId()));
                           
                            wagon.get(downloadUrl.getPath().substring(1), tempDownloadFile);

                            getLog().debug(
                                "caching temporary file for later");
                            cachedDownloads.put(downloadUrl, tempDownloadFile);
                        }
View Full Code Here

     * @throws ConnectionException
     * @throws AuthenticationException
     */
    public void testNullFileWagon() throws ConnectionException, AuthenticationException
    {
        Wagon wagon = new FileWagon();
        Resource resource = new Resource();
        resource.setContentLength( 100000 );
        Repository repository = new Repository();
        wagon.connect( repository );
    }
View Full Code Here

    public void testResourceExists()
        throws Exception
    {
        String url = "file://" + getBasedir();
       
        Wagon wagon = new FileWagon();
        Repository repository = new Repository( "someID", url );
        wagon.connect( repository );
       
        assertTrue( wagon.resourceExists( "target" ) );
        assertTrue( wagon.resourceExists( "target/" ) );
        assertTrue( wagon.resourceExists( "pom.xml" ) );
       
        assertFalse( wagon.resourceExists( "pom.xml/" ) );
       
        wagon.disconnect();
    }
View Full Code Here

    {
        setupRepositories();

        setupWagonTestingFixtures();

        Wagon wagon = getWagon();

        if ( wagon.supportsDirectoryCopy() )
        {
            // do the cleanup first
            File destDir = new File( getRepositoryDirectory(), "dirExists" );
            FileUtils.deleteDirectory(destDir);
            destDir.mkdirs();
            destDir = new File( destDir, "not_yet_existing/also_not" );

            File sourceDir = new File( getRepositoryDirectory(), "testDirectory" );

            FileUtils.deleteDirectory(sourceDir);
            sourceDir.mkdir();

            File testRes = new File( sourceDir, "test-resource-1.txt" );
            testRes.createNewFile();

            // This is the difference to our normal use case:
            // the directory specified in the repo string doesn't yet exist!

            testRepository.setUrl( testRepository.getUrl() + "/dirExists/not_yet_existing/also_not" );

            wagon.connect( testRepository, getAuthInfo() );

            wagon.putDirectory( sourceDir, "testDirectory" );

            destFile = FileTestUtils.createUniqueFile(getName(), getName());

            destFile.deleteOnExit();

            wagon.get( "testDirectory/test-resource-1.txt", destFile );

            wagon.disconnect();
        }

        tearDownWagonTestingFixtures();

View Full Code Here

        addConnectors( server );
        server.start();

        try
        {
            Wagon wagon = getWagon();

            Repository testRepository = new Repository( "id", getRepositoryUrl( server ) );

            File sourceFile = new File( localRepositoryPath + "/gzip" );

            sourceFile.deleteOnExit();

            String resName = "gzip-res.txt";
            String sourceContent = writeTestFileGzip( sourceFile, resName );

            wagon.connect( testRepository );

            File destFile = FileTestUtils.createUniqueFile( getName(), getName() );

            destFile.deleteOnExit();

            wagon.get( "gzip/" + resName, destFile );

            wagon.disconnect();

            String destContent = FileUtils.fileRead( destFile );

            assertEquals( sourceContent, destContent );
        }
View Full Code Here

        for ( int i = 0; i < dirnames.length; i++ )
        {
            new File( getDavRepository(), dirName + "/" + dirnames[i] ).mkdirs();
        }

        Wagon wagon = getWagon();

        wagon.connect( testRepository, getAuthInfo() );

        List<String> list = wagon.getFileList( dirName );

        assertNotNull( "file list should not be null.", list );
        assertEquals( "file list should contain 6 items", 6, list.size() );

        for ( int i = 0; i < filenames.length; i++ )
        {
            assertTrue( "Filename '" + filenames[i] + "' should be in list.", list.contains( filenames[i] ) );
        }

        for ( int i = 0; i < dirnames.length; i++ )
        {
            assertTrue( "Directory '" + dirnames[i] + "' should be in list.", list.contains( dirnames[i] + "/" ) );
        }

        ///////////////////////////////////////////////////////////////////////////
        list = wagon.getFileList( "" );
        assertNotNull( "file list should not be null.", list );
        assertEquals( "file list should contain 1 items", 1, list.size() );

        ///////////////////////////////////////////////////////////////////////////
        list = wagon.getFileList( dirName + "/test-dir1" );
        assertNotNull( "file list should not be null.", list );
        assertEquals( "file list should contain 0 items", 0, list.size() );

        /////////////////////////////////////////////////////////////////////////////
        try
        {
            list = wagon.getFileList( dirName + "/test-dir-bogus" );
            fail( "Exception expected" );
        }
        catch ( ResourceDoesNotExistException e )
        {

        }

        wagon.disconnect();

        tearDownWagonTestingFixtures();
    }
View Full Code Here

        {
            getLogger().debug( "Path [" + targetPath + "] is part of blacklist (skipping transfer)." );
            return null;
        }

        Wagon wagon = null;
        try
        {
            String protocol = targetRepository.getUrl().getProtocol();
            wagon = (Wagon) wagons.get( protocol );
            if ( wagon == null )
            {
                throw new ProxyException( "Unsupported target repository protocol: " + protocol );
            }

            boolean connected = connectToRepository( connector, wagon, targetRepository );
            if ( connected )
            {
                localFile = transferSimpleFile( wagon, targetRepository, targetPath, localFile );

                transferChecksum( wagon, targetRepository, targetPath, localFile, ".sha1" );
                transferChecksum( wagon, targetRepository, targetPath, localFile, ".md5" );
            }
        }
        catch ( ResourceDoesNotExistException e )
        {
            // Do not cache url here.
            return null;
        }
        catch ( WagonException e )
        {
            urlFailureCache.cacheFailure( url );
            return null;
        }
        finally
        {
            if ( wagon != null )
            {
                try
                {
                    wagon.disconnect();
                }
                catch ( ConnectionException e )
                {
                    getLogger().warn( "Unable to disconnect wagon.", e );
                }
View Full Code Here

TOP

Related Classes of org.apache.maven.wagon.Wagon

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.