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 ); }
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 ); }
/** * {@inheritDoc} */ public void fillInputData(InputData inputData) throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException { log.debug("Invoked fillInputData()"); Resource resource = inputData.getResource(); File file = new File(git.workDir, resource.getName()); if (!file.exists()) { throw new ResourceDoesNotExistException("File: " + file + " does not exist"); } try { InputStream in = new BufferedInputStream(new FileInputStream(file)); inputData.setInputStream(in); resource.setContentLength(file.length()); resource.setLastModified(file.lastModified()); } catch (FileNotFoundException e) { throw new TransferFailedException("Could not read from file: " + file.getAbsolutePath(), e); } }
@Override public void put(File file, String resourceName) throws TransferFailedException, ResourceDoesNotExistException, AuthorizationException { Resource resource = new Resource(resourceName); firePutInitiated(resource, file); resource.setContentLength(file.length()); resource.setLastModified(file.lastModified()); RetryableSource source = new FileSource(resource, file); put(source, file, resource); }
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() ); OutputStream os = getOutputStream( resource ); checkOutputStream( resource, os ); putTransfer( resource, source, os, true ); }
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() ); OutputStream os = getOutputStream( resource ); checkOutputStream( resource, os ); putTransfer( resource, source, os, true ); }
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 ); }
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 ); }
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 ); }
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 ); }
public void fillInputData( InputData inputData ) throws TransferFailedException, ResourceDoesNotExistException { if ( getRepository().getBasedir() == null ) { throw new TransferFailedException( "Unable to operate with a null basedir." ); } Resource resource = inputData.getResource(); File file = new File( getRepository().getBasedir(), resource.getName() ); if ( !file.exists() ) { throw new ResourceDoesNotExistException( "File: " + file + " does not exist" ); } try { InputStream in = new BufferedInputStream( new FileInputStream( file ) ); inputData.setInputStream( in ); resource.setContentLength( file.length() ); resource.setLastModified( file.lastModified() ); } catch ( FileNotFoundException e ) { throw new TransferFailedException( "Could not read from file: " + file.getAbsolutePath(), e ); } }
public void fillInputData( InputData inputData ) throws TransferFailedException, ResourceDoesNotExistException { if ( getRepository().getBasedir() == null ) { throw new TransferFailedException( "Unable to operate with a null basedir." ); } Resource resource = inputData.getResource(); File file = new File( getRepository().getBasedir(), resource.getName() ); if ( !file.exists() ) { throw new ResourceDoesNotExistException( "File: " + file + " does not exist" ); } try { InputStream in = new BufferedInputStream( new FileInputStream( file ) ); inputData.setInputStream( in ); resource.setContentLength( file.length() ); resource.setLastModified( file.lastModified() ); } catch ( FileNotFoundException e ) { throw new TransferFailedException( "Could not read from file: " + file.getAbsolutePath(), e ); } }
private void putFile( File source, Resource resource, RepositoryPermissions permissions ) throws SftpException, TransferFailedException { resource.setContentLength( source.length() ); resource.setLastModified( source.lastModified() ); String filename = ScpHelper.getResourceFilename( resource.getName() ); firePutStarted( resource, source ); channel.put( source.getAbsolutePath(), filename ); postProcessListeners( resource, source, TransferEvent.REQUEST_PUT ); if ( permissions != null && permissions.getGroup() != null ) { setGroup( filename, permissions ); } if ( permissions != null && permissions.getFileMode() != null ) { setFileMode( filename, permissions ); } firePutCompleted( resource, source ); }
private void putFile( File source, Resource resource, RepositoryPermissions permissions ) throws SftpException, TransferFailedException { resource.setContentLength( source.length() ); resource.setLastModified( source.lastModified() ); String filename = ScpHelper.getResourceFilename( resource.getName() ); firePutStarted( resource, source ); channel.put( source.getAbsolutePath(), filename ); postProcessListeners( resource, source, TransferEvent.REQUEST_PUT ); if ( permissions != null && permissions.getGroup() != null ) { setGroup( filename, permissions ); } if ( permissions != null && permissions.getFileMode() != null ) { setFileMode( filename, permissions ); } firePutCompleted( resource, source ); }
public void fillInputData( InputData inputData ) throws TransferFailedException, ResourceDoesNotExistException { Resource resource = inputData.getResource(); String filename = ScpHelper.getResourceFilename( resource.getName() ); String dir = ScpHelper.getResourceDirectory( resource.getName() ); // we already setuped the root directory. Ignore beginning / if ( dir.length() > 0 && dir.charAt( 0 ) == ScpHelper.PATH_SEPARATOR ) { dir = dir.substring( 1 ); } try { SftpATTRS attrs = changeToRepositoryDirectory( dir, filename ); long lastModified = attrs.getMTime() * MILLIS_PER_SEC; resource.setContentLength( attrs.getSize() ); resource.setLastModified( lastModified ); inputData.setInputStream( channel.get( filename ) ); } catch ( SftpException e ) { handleGetException( resource, e ); } }
public void fillInputData( InputData inputData ) throws TransferFailedException, ResourceDoesNotExistException { Resource resource = inputData.getResource(); String filename = ScpHelper.getResourceFilename( resource.getName() ); String dir = ScpHelper.getResourceDirectory( resource.getName() ); // we already setuped the root directory. Ignore beginning / if ( dir.length() > 0 && dir.charAt( 0 ) == ScpHelper.PATH_SEPARATOR ) { dir = dir.substring( 1 ); } try { SftpATTRS attrs = changeToRepositoryDirectory( dir, filename ); long lastModified = attrs.getMTime() * MILLIS_PER_SEC; resource.setContentLength( attrs.getSize() ); resource.setLastModified( lastModified ); inputData.setInputStream( channel.get( filename ) ); } catch ( SftpException e ) { handleGetException( resource, e ); } }
private void replaceMockForSkippedGetIfNewer( Wagon wagon, int expectedSize ) { Resource resource = new Resource( this.resource ); mockTransferListener.transferInitiated( createTransferEvent( wagon, resource, TransferEvent.TRANSFER_INITIATED, TransferEvent.REQUEST_GET, destFile ) ); resource = new Resource( this.resource ); resource.setContentLength( getExpectedContentLengthOnGet( expectedSize ) ); resource.setLastModified( getExpectedLastModifiedOnGet( testRepository, resource ) ); // TODO: transfer skipped event? // mockTransferListener.transferSkipped( createTransferEvent( wagon, resource, TransferEvent.TRANSFER_STARTED, // TransferEvent.REQUEST_GET, destFile ) ); mockTransferListener.debug( anyString() ); expectLastCall().anyTimes(); replay( mockTransferListener ); }
private void replaceMockForSkippedGetIfNewer( Wagon wagon, int expectedSize ) { Resource resource = new Resource( this.resource ); mockTransferListener.transferInitiated( createTransferEvent( wagon, resource, TransferEvent.TRANSFER_INITIATED, TransferEvent.REQUEST_GET, destFile ) ); resource = new Resource( this.resource ); resource.setContentLength( getExpectedContentLengthOnGet( expectedSize ) ); resource.setLastModified( getExpectedLastModifiedOnGet( testRepository, resource ) ); // TODO: transfer skipped event? // mockTransferListener.transferSkipped( createTransferEvent( wagon, resource, TransferEvent.TRANSFER_STARTED, // TransferEvent.REQUEST_GET, destFile ) ); mockTransferListener.debug( anyString() ); expectLastCall().anyTimes(); replay( mockTransferListener ); }
protected ProgressAnswer replayMockForPut( String resourceName, String content, Wagon wagon ) { Resource resource = new Resource( resourceName ); mockTransferListener.transferInitiated( createTransferEvent( wagon, resource, TransferEvent.TRANSFER_INITIATED, TransferEvent.REQUEST_PUT, sourceFile ) ); resource = new Resource( resourceName ); resource.setContentLength( content.length() ); resource.setLastModified( sourceFile.lastModified() ); mockTransferListener.transferStarted( createTransferEvent( wagon, resource, TransferEvent.TRANSFER_STARTED, TransferEvent.REQUEST_PUT, sourceFile ) ); mockTransferListener.transferProgress( eq( createTransferEvent( wagon, resource, TransferEvent.TRANSFER_PROGRESS, TransferEvent.REQUEST_PUT, sourceFile ) ), anyObject( byte[].class ), anyInt() ); ProgressAnswer progressAnswer = new ProgressAnswer(); expectLastCall().andStubAnswer( progressAnswer ); mockTransferListener.debug( anyString() ); expectLastCall().anyTimes(); mockTransferListener.transferCompleted( createTransferEvent( wagon, resource, TransferEvent.TRANSFER_COMPLETED, TransferEvent.REQUEST_PUT, sourceFile ) ); replay( mockTransferListener ); return progressAnswer; }
protected ProgressAnswer replayMockForPut( String resourceName, String content, Wagon wagon ) { Resource resource = new Resource( resourceName ); mockTransferListener.transferInitiated( createTransferEvent( wagon, resource, TransferEvent.TRANSFER_INITIATED, TransferEvent.REQUEST_PUT, sourceFile ) ); resource = new Resource( resourceName ); resource.setContentLength( content.length() ); resource.setLastModified( sourceFile.lastModified() ); mockTransferListener.transferStarted( createTransferEvent( wagon, resource, TransferEvent.TRANSFER_STARTED, TransferEvent.REQUEST_PUT, sourceFile ) ); mockTransferListener.transferProgress( eq( createTransferEvent( wagon, resource, TransferEvent.TRANSFER_PROGRESS, TransferEvent.REQUEST_PUT, sourceFile ) ), anyObject( byte[].class ), anyInt() ); ProgressAnswer progressAnswer = new ProgressAnswer(); expectLastCall().andStubAnswer( progressAnswer ); mockTransferListener.debug( anyString() ); expectLastCall().anyTimes(); mockTransferListener.transferCompleted( createTransferEvent( wagon, resource, TransferEvent.TRANSFER_COMPLETED, TransferEvent.REQUEST_PUT, sourceFile ) ); replay( mockTransferListener ); return progressAnswer; }