Package org.apache.maven.wagon.repository

Examples of org.apache.maven.wagon.repository.RepositoryPermissions


            //    "cd " + path + "; unzip -q -o " + zipFile.getName() + "; rm -f " + zipFile.getName() );
            executor.executeCommand( "cd \"" + path + "\"; unzip -q -o \"" + zipFile.getName() + "\"; rm -f \"" + zipFile.getName() + "\"" );

            zipFile.delete();

            RepositoryPermissions permissions = repository.getPermissions();

            if ( permissions != null && permissions.getGroup() != null )
            {
                //executor.executeCommand( "chgrp -Rf " + permissions.getGroup() + " " + path );
                executor.executeCommand( "chgrp -Rf " + permissions.getGroup() + " \"" + path + "\"" );
            }

            if ( permissions != null && permissions.getFileMode() != null )
            {
                //executor.executeCommand( "chmod -Rf " + permissions.getFileMode() + " " + path );
                executor.executeCommand( "chmod -Rf " + permissions.getFileMode() + " \"" + path + "\"" );
            }
        }
        catch ( CommandExecutionException e )
        {
            throw new TransferFailedException( "Error performing commands for file transfer", e );
View Full Code Here


        postProcessListeners( resource, source, TransferEvent.REQUEST_PUT );

        try
        {
            RepositoryPermissions permissions = getRepository().getPermissions();

            if ( permissions != null && permissions.getGroup() != null )
            {
                executeCommand( "chgrp -f " + permissions.getGroup() + " " + basedir + "/" + resourceName + "\n",
                                true );
            }

            if ( permissions != null && permissions.getFileMode() != null )
            {
                executeCommand( "chmod -f " + permissions.getFileMode() + " " + basedir + "/" + resourceName + "\n",
                                true );
            }
        }
        catch ( CommandExecutionException e )
        {
View Full Code Here

    public void testRepositoryPermissionsOverride()
        throws ConnectionException, AuthenticationException
    {
        Repository repository = new Repository();

        RepositoryPermissions original = new RepositoryPermissions();
        original.setFileMode( "664" );
        repository.setPermissions( original );

        RepositoryPermissions override = new RepositoryPermissions();
        override.setFileMode( "644" );
        wagon.setPermissionsOverride( override );

        wagon.connect( repository );

        assertEquals( override, repository.getPermissions() );
View Full Code Here

        try
        {
            // TODO [BP]: verify the order is correct
            ftp.completePendingCommand();

            RepositoryPermissions permissions = repository.getPermissions();

            if ( permissions != null && permissions.getGroup() != null )
            {
                // ignore failures
                ftp.sendSiteCommand( "CHGRP " + permissions.getGroup() + " " + resource.getName() );
            }

            if ( permissions != null && permissions.getFileMode() != null )
            {
                // ignore failures
                ftp.sendSiteCommand( "CHMOD " + permissions.getFileMode() + " " + resource.getName() );
            }
        }
        catch ( IOException e )
        {
            // TODO: handle
View Full Code Here

    {
        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] );
                    }
                }
View Full Code Here

        // Change to root.
        try
        {
            if ( !ftp.changeWorkingDirectory( getRepository().getBasedir() ) )
            {
                RepositoryPermissions permissions = getRepository().getPermissions();
                if ( !makeFtpDirectoryRecursive( getRepository().getBasedir(), permissions ) )
                {
                    throw new TransferFailedException(
                        "Required directory: '" + getRepository().getBasedir() + "' " + "could not get created" );
                }
View Full Code Here

    }

    private void ftpRecursivePut( File sourceFile, String fileName )
        throws TransferFailedException
    {
        final RepositoryPermissions permissions = repository.getPermissions();

        fireTransferDebug( "processing = " + sourceFile.getAbsolutePath() + " as " + fileName );

        if ( sourceFile.isDirectory() )
        {
            if ( !fileName.equals( "." ) )
            {
                try
                {
                    // change directory if it already exists.
                    if ( !ftp.changeWorkingDirectory( fileName ) )
                    {
                        // first, try to create it
                        if ( makeFtpDirectoryRecursive( fileName, permissions ) )
                        {
                            if ( !ftp.changeWorkingDirectory( fileName ) )
                            {
                                throw new TransferFailedException(
                                    "Unable to change cwd on ftp server to " + fileName + " when processing "
                                        + sourceFile.getAbsolutePath() );
                            }
                        }
                        else
                        {
                            throw new TransferFailedException(
                                "Unable to create directory " + fileName + " when processing "
                                    + sourceFile.getAbsolutePath() );
                        }
                    }
                }
                catch ( IOException e )
                {
                    throw new TransferFailedException(
                        "IOException caught while processing path at " + sourceFile.getAbsolutePath(), e );
                }
            }

            File[] files = sourceFile.listFiles();
            if ( files != null && files.length > 0 )
            {
                fireTransferDebug( "listing children of = " + sourceFile.getAbsolutePath() + " found " + files.length );

                // Directories first, then files. Let's go deep early.
                for ( int i = 0; i < files.length; i++ )
                {
                    if ( files[i].isDirectory() )
                    {
                        ftpRecursivePut( files[i], files[i].getName() );
                    }
                }
                for ( int i = 0; i < files.length; i++ )
                {
                    if ( !files[i].isDirectory() )
                    {
                        ftpRecursivePut( files[i], files[i].getName() );
                    }
                }
            }

            // Step back up a directory once we're done with the contents of this one.
            try
            {
                ftp.changeToParentDirectory();
            }
            catch ( IOException e )
            {
                throw new TransferFailedException( "IOException caught while attempting to step up to parent directory"
                                                       + " after successfully processing "
                                                       + sourceFile.getAbsolutePath(), e );
            }
        }
        else
        {
            // Oh how I hope and pray, in denial, but today I am still just a file.

            FileInputStream sourceFileStream = null;
            try
            {
                sourceFileStream = new FileInputStream( sourceFile );

                // It's a file. Upload it in the current directory.
                if ( ftp.storeFile( fileName, sourceFileStream ) )
                {
                    if ( permissions != null )
                    {
                        // Process permissions; note that if we get errors or exceptions here, they are ignored.
                        // This appears to be a conscious decision, based on other parts of this code.
                        String group = permissions.getGroup();
                        if ( group != null )
                        {
                            try
                            {
                                ftp.sendSiteCommand( "CHGRP " + permissions.getGroup() );
                            }
                            catch ( IOException e )
                            {
                            }
                        }
                        String mode = permissions.getFileMode();
                        if ( mode != null )
                        {
                            try
                            {
                                ftp.sendSiteCommand( "CHMOD " + permissions.getDirectoryMode() );
                            }
                            catch ( IOException e )
                            {
                            }
                        }
View Full Code Here

                {
                    wagonManager.addConfiguration( server.getId(), (Xpp3Dom) server.getConfiguration() );
                }
            }

            RepositoryPermissions defaultPermissions = new RepositoryPermissions();

            defaultPermissions.setDirectoryMode( "775" );

            defaultPermissions.setFileMode( "664" );

            wagonManager.setDefaultRepositoryPermissions( defaultPermissions );

            for ( Iterator i = settings.getMirrors().iterator(); i.hasNext(); )
            {
View Full Code Here

                {
                    wagonManager.addConfiguration( server.getId(), (Xpp3Dom) server.getConfiguration() );
                }
            }

            RepositoryPermissions defaultPermissions = new RepositoryPermissions();

            defaultPermissions.setDirectoryMode( "775" );

            defaultPermissions.setFileMode( "664" );

            wagonManager.setDefaultRepositoryPermissions( defaultPermissions );

            for ( Iterator i = settings.getMirrors().iterator(); i.hasNext(); )
            {
View Full Code Here

        {
            Repository artifactRepository = new Repository( repository.getId(), repository.getUrl() );

            if ( serverPermissionsMap.containsKey( repository.getId() ) )
            {
                RepositoryPermissions perms = (RepositoryPermissions) serverPermissionsMap.get( repository.getId() );

                getLogger().debug(
                    "adding permissions to wagon connection: " + perms.getFileMode() + " " + perms.getDirectoryMode() );

                artifactRepository.setPermissions( perms );
            }
            else
            {
View Full Code Here

TOP

Related Classes of org.apache.maven.wagon.repository.RepositoryPermissions

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.