Package org.apache.archiva.common.filelock

Examples of org.apache.archiva.common.filelock.Lock


    private void moveTempToTarget( File temp, File target )
        throws ProxyException
    {

        // TODO file lock library
        Lock lock = null;
        try
        {
            lock = fileLockManager.writeFileLock( target );
            if ( lock.getFile().exists() && !lock.getFile().delete() )
            {
                throw new ProxyException( "Unable to overwrite existing target file: " + target.getAbsolutePath() );
            }

            lock.getFile().getParentFile().mkdirs();

            if ( !temp.renameTo( lock.getFile() ) )
            {
                log.warn( "Unable to rename tmp file to its final name... resorting to copy command." );

                try
                {
                    FileUtils.copyFile( temp, lock.getFile() );
                }
                catch ( IOException e )
                {
                    if ( lock.getFile().exists() )
                    {
                        log.debug( "Tried to copy file {} to {} but file with this name already exists.",
                                   temp.getName(), lock.getFile().getAbsolutePath() );
                    }
                    else
                    {
                        throw new ProxyException(
                            "Cannot copy tmp file " + temp.getAbsolutePath() + " to its final location", e );
View Full Code Here


        try
        {
            if ( !isCollection() && outputContext.hasStream() )
            {
                Lock lock = fileLockManager.readFileLock( localResource );
                try (InputStream is = Files.newInputStream( lock.getFile().toPath() ))
                {
                    IOUtils.copy( is, outputContext.getOutputStream() );
                }
            }
            else if ( outputContext.hasStream() )
View Full Code Here

    private void moveTempToTarget( File temp, File target )
        throws ProxyException
    {

        // TODO file lock library
        Lock lock = null;
        try
        {
            lock = fileLockManager.writeFileLock( target );
            if ( lock.getFile().exists() && !lock.getFile().delete() )
            {
                throw new ProxyException( "Unable to overwrite existing target file: " + target.getAbsolutePath() );
            }

            lock.getFile().getParentFile().mkdirs();

            if ( !temp.renameTo( lock.getFile() ) )
            {
                log.warn( "Unable to rename tmp file to its final name... resorting to copy command." );

                try
                {
                    FileUtils.copyFile( temp, lock.getFile() );
                }
                catch ( IOException e )
                {
                    if ( lock.getFile().exists() )
                    {
                        log.debug( "Tried to copy file {} to {} but file with this name already exists.",
                                   temp.getName(), lock.getFile().getAbsolutePath() );
                    }
                    else
                    {
                        throw new ProxyException(
                            "Cannot copy tmp file " + temp.getAbsolutePath() + " to its final location", e );
View Full Code Here

        try
        {
            if ( !isCollection() && outputContext.hasStream() )
            {
                Lock lock = fileLockManager.readFileLock( localResource );
                try (InputStream is = Files.newInputStream( lock.getFile().toPath() ))
                {
                    IOUtils.copy( is, outputContext.getOutputStream() );
                }
            }
            else if ( outputContext.hasStream() )
View Full Code Here

        try
        {
            if ( !isCollection() && outputContext.hasStream() )
            {
                Lock lock = fileLockManager.readFileLock( localResource );
                FileInputStream is = null;
                try
                {
                    // Write content to stream
                    is = new FileInputStream( lock.getFile() );
                    IOUtils.copy( is, outputContext.getOutputStream() );
                }
                finally
                {
                    IOUtils.closeQuietly( is );
View Full Code Here

    private void moveTempToTarget( File temp, File target )
        throws ProxyException
    {

        // TODO file lock library
        Lock lock = null;
        try
        {
            lock = fileLockManager.writeFileLock( target );
            if ( lock.getFile().exists() && !lock.getFile().delete() )
            {
                throw new ProxyException( "Unable to overwrite existing target file: " + target.getAbsolutePath() );
            }

            lock.getFile().getParentFile().mkdirs();

            if ( !temp.renameTo( lock.getFile() ) )
            {
                log.warn( "Unable to rename tmp file to its final name... resorting to copy command." );

                try
                {
                    FileUtils.copyFile( temp, lock.getFile() );
                }
                catch ( IOException e )
                {
                    if ( lock.getFile().exists() )
                    {
                        log.debug( "Tried to copy file {} to {} but file with this name already exists.",
                                   temp.getName(), lock.getFile().getAbsolutePath() );
                    }
                    else
                    {
                        throw new ProxyException(
                            "Cannot copy tmp file " + temp.getAbsolutePath() + " to its final location", e );
View Full Code Here

TOP

Related Classes of org.apache.archiva.common.filelock.Lock

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.