Package org.apache.maven.wagon.resource

Examples of org.apache.maven.wagon.resource.Resource


    public void get( String resourceName, File destination )
        throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
    {
        String path = StringUtils.replace( resourceName, "\\", "/" );

        Resource resource = new Resource( path );

        fireGetInitiated( resource, destination );

        createParentDirectories( destination );
View Full Code Here


    }

    public void putFromStream( InputStream stream, String destination, long contentLength, long lastModified )
        throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
    {
        Resource resource = new Resource( destination );

        firePutInitiated( resource, null );

        resource.setContentLength( contentLength );

        resource.setLastModified( lastModified );

        putFromStream( stream, resource );
    }
View Full Code Here

    public void testChecksum()
        throws NoSuchAlgorithmException
    {
        ChecksumObserver listener = new ChecksumObserver( "SHA-1" );

        Resource resource = new Resource( "resource" );

        TransferEvent transferEvent =
            new TransferEvent( wagon, resource, TransferEvent.TRANSFER_INITIATED, TransferEvent.REQUEST_GET );

        listener.transferInitiated( transferEvent );
View Full Code Here

        if ( supportsGetIfNewer() )
        {
            setupRepositories();
            setupWagonTestingFixtures();
            int expectedSize = putFile();
            getIfNewerToStream( getExpectedLastModifiedOnGet( testRepository, new Resource( resource ) ) + 30000, false,
                                expectedSize );
        }
    }
View Full Code Here

        if ( supportsGetIfNewer() )
        {
            setupRepositories();
            setupWagonTestingFixtures();
            int expectedSize = putFile();
            getIfNewerToStream( getExpectedLastModifiedOnGet( testRepository, new Resource( resource ) ), false,
                                expectedSize );
        }
    }
View Full Code Here

        File tempFile = File.createTempFile( "wagon", "tmp" );
        tempFile.deleteOnExit();
        String content = "content";
        FileUtils.fileWrite( tempFile.getAbsolutePath(), content );

        Resource resource = new Resource( "resource" );

        transferListener.transferInitiated( null );
        transferListenerControl.setMatcher( MockControl.ALWAYS_MATCHER );
        transferListener.transferStarted( null );
        transferListenerControl.setMatcher( MockControl.ALWAYS_MATCHER );
View Full Code Here

        final long timestamp = System.currentTimeMillis();

        final Exception exception = new AuthenticationException( "dummy" );

        Resource resource = new Resource();

        resource.setName( "mm" );

        TransferEvent event = new TransferEvent( wagon, resource, TransferEvent.TRANSFER_COMPLETED,
                                                 TransferEvent.REQUEST_GET );

        assertEquals( wagon, event.getWagon() );

        assertEquals( "mm", event.getResource().getName() );

        assertEquals( TransferEvent.TRANSFER_COMPLETED, event.getEventType() );

        assertEquals( TransferEvent.REQUEST_GET, event.getRequestType() );

        Resource res = new Resource();

        res.setName( "mm" );

        event = new TransferEvent( wagon, res, exception, TransferEvent.REQUEST_GET );

        assertEquals( wagon, event.getWagon() );

        assertEquals( "mm", event.getResource().getName() );

        assertEquals( TransferEvent.TRANSFER_ERROR, event.getEventType() );

        assertEquals( TransferEvent.REQUEST_GET, event.getRequestType() );

        assertEquals( exception, event.getException() );

        event.setResource( null );

        assertEquals( null, event.getResource() );

        res.setName( "/foo/baa" );

        event.setResource( res );

        assertEquals( "/foo/baa", event.getResource().getName() );
View Full Code Here

    }

    public void put( File source, String resourceName )
        throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
    {
        Resource resource = new Resource( resourceName );

        firePutInitiated( resource, source );

        resource.setContentLength( source.length() );

        resource.setLastModified( source.lastModified() );

        put( null, resource, source );
    }
View Full Code Here

    }

    public void putFromStream( final InputStream stream, String destination, long contentLength, long lastModified )
        throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException
    {
        Resource resource = new Resource( destination );

        firePutInitiated( resource, null );

        resource.setContentLength( contentLength );

        resource.setLastModified( lastModified );

        put( stream, resource, null );
    }
View Full Code Here

    public void fillOutputData( OutputData outputData )
        throws TransferFailedException
    {
        OutputStream os;

        Resource resource = outputData.getResource();

        RepositoryPermissions permissions = repository.getPermissions();

        try
        {
            if ( !ftp.changeWorkingDirectory( getRepository().getBasedir() ) )
            {
                throw new TransferFailedException(
                    "Required directory: '" + getRepository().getBasedir() + "' " + "is missing" );
            }

            String[] dirs = PathUtils.dirnames( resource.getName() );

            for ( int i = 0; i < dirs.length; i++ )
            {
                boolean dirChanged = ftp.changeWorkingDirectory( dirs[i] );

                if ( !dirChanged )
                {
                    // first, try to create it
                    boolean success = ftp.makeDirectory( dirs[i] );

                    if ( success )
                    {
                        if ( permissions != null && permissions.getGroup() != null )
                        {
                            // ignore failures
                            ftp.sendSiteCommand( "CHGRP " + permissions.getGroup() + " " + dirs[i] );
                        }

                        if ( permissions != null && permissions.getDirectoryMode() != null )
                        {
                            // ignore failures
                            ftp.sendSiteCommand( "CHMOD " + permissions.getDirectoryMode() + " " + dirs[i] );
                        }

                        dirChanged = ftp.changeWorkingDirectory( dirs[i] );
                    }
                }

                if ( !dirChanged )
                {
                    throw new TransferFailedException( "Unable to create directory " + dirs[i] );
                }
            }

            // we come back to original basedir so
            // FTP wagon is ready for next requests
            if ( !ftp.changeWorkingDirectory( getRepository().getBasedir() ) )
            {
                throw new TransferFailedException( "Unable to return to the base directory" );
            }

            os = ftp.storeFileStream( resource.getName() );

            if ( os == null )
            {
                String msg =
                    "Cannot transfer resource:  '" + resource + "'. Output stream is null. FTP Server response: "
View Full Code Here

TOP

Related Classes of org.apache.maven.wagon.resource.Resource

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.