/** * Returns a attribute value for the given domain (namespace) and attribute-name. Some generic attribute domains and * names are defined as constants in the {@link LibRepositoryBoot} class. * * @param domain the attribute domain. * @param key the name of the attribute. * @return the value or null, if the content-entity does not have a value for this attribute. */ public Object getAttribute( final String domain, final String key ) { try { if ( LibRepositoryBoot.REPOSITORY_DOMAIN.equals( domain ) ) { if ( LibRepositoryBoot.SIZE_ATTRIBUTE.equals( key ) ) { return new Long( backend.getContent().getSize() ); } else if ( LibRepositoryBoot.VERSION_ATTRIBUTE.equals( key ) ) { return new Date( backend.getContent().getLastModifiedTime() ); } } } catch ( FileSystemException ex ) { throw new RuntimeException( ex ); } return null; }
if ( file.exists() ) { if ( file.getType().equals( FileType.FILE ) ) { filesize = file.getContent().getSize(); } else { throw new RuntimeException( "[" + ArgList[0] + "] is not a file!" );
private void getFileSize( FileObject file, Result result, Job parentJob ) { try { incrementFilesCount(); if ( isDetailed() ) { logDetailed( BaseMessages.getString( PKG, "JobEvalFilesMetrics.Log.GetFile", file.toString(), String .valueOf( getFilesCount() ) ) ); } switch ( evaluationType ) { case EVALUATE_TYPE_SIZE: BigDecimal fileSize = BigDecimal.valueOf( file.getContent().getSize() ); evaluationValue = evaluationValue.add( fileSize ); if ( isDebug() ) { logDebug( BaseMessages.getString( PKG, "JobEvalFilesMetrics.Log.AddedFileSize", String .valueOf( fileSize ), file.toString() ) ); } break; default: evaluationValue = evaluationValue.add( ONE ); break; } } catch ( Exception e ) { incrementErrors(); logError( BaseMessages.getString( PKG, "JobEvalFilesMetrics.Error.GettingFileSize", file.toString(), e .toString() ) ); } }
@Test public void testOpenConnectionUseKey_2() throws Exception { when( fileObject.exists() ).thenReturn( true ); when( fileObject.getContent() ).thenReturn( fileContent ); when( fileContent.getSize() ).thenReturn( 1000L ); when( fileContent.getInputStream() ).thenReturn( new ByteArrayInputStream( new byte[] { 1, 2, 3, 4, 5 } ) ); when( variableSpace.environmentSubstitute( passPhrase ) ).thenReturn( passPhrase ); when( connection.authenticateWithPublicKey( eq( username ), Matchers.<char[]>any(), eq( passPhrase ) ) ).thenReturn( true ); SSHData.OpenConnection( server, port, username, null, true, keyFilePath, passPhrase, 0, variableSpace, null, 0, null, null ); verify( connection ).connect(); verify( connection ).authenticateWithPublicKey( eq( username ), Matchers.<char[]>any(), eq( passPhrase ) ); }
long size = KettleVFS.getFileObject( filename, getTransMeta() ).getContent().getSize(); data.fileSizes.add( size ); data.totalFileSize += size;
throwsErrorOnFileNotFound( file ); is = KettleVFS.getInputStream( file ); int fileSize = (int) file.getContent().getSize(); content = Const.createByteArray( fileSize ); is.read( content, 0, fileSize );
final FileObject child = file.resolveFile( name ); if ( child.exists() ) { if ( child.getContent().getSize() == 0 ) {
if ( file.exists() ) { if ( file.getType().equals( FileType.FILE ) ) { filesize = file.getContent().getSize(); } else { Context.reportRuntimeError( "[" + Context.toString( ArgList[0] ) + "] is not a file!" );
public void setSecretKeyFromFile( String filename ) throws CryptoKeyException { FileObject file = null; try { file = KettleVFS.getFileObject( filename ); if ( !file.exists() ) { throw new CryptoException( BaseMessages.getString( PKG, "SymmetricCrypto.CanNotFindFile", file.getName() ) ); } byte[] KeyBytes = new byte[(int) file.getContent().getSize()]; setSecretKey( KeyBytes ); } catch ( Exception e ) { throw new CryptoKeyException( e ); } finally { if ( file != null ) { try { file.close(); } catch ( Exception e ) { /* Ignore */ } } } }
data.stepNumber = getUniqueStepNrAcrossSlaves(); data.totalNumberOfSteps = getUniqueStepCountAcrossSlaves(); data.fileSize = fileObject.getContent().getSize();
/** * Prepare file-dependent data for fill additional fields. */ protected void fillFileAdditionalFields( D data, FileObject file ) throws FileSystemException { data.shortFilename = file.getName().getBaseName(); data.path = KettleVFS.getFilename( file.getParent() ); data.hidden = file.isHidden(); data.extension = file.getName().getExtension(); data.uriName = file.getName().getURI(); data.rootUriName = file.getName().getRootURI(); if ( file.getType().hasContent() ) { data.lastModificationDateTime = new Date( file.getContent().getLastModifiedTime() ); data.size = file.getContent().getSize(); } else { data.lastModificationDateTime = null; data.size = null; } } }
if ( meta.isIgnoreEmptyFile() && data.file.getContent().getSize() == 0 ) { if ( isBasic() ) { logBasic( BaseMessages.getString( PKG, "YamlInput.Error.FileSizeZero", data.file.getName() ) );
fileSize = data.file.getContent().getSize(); } catch ( FileSystemException e ) { fileSize = -1;
CharArrayWriter charArrayWriter = new CharArrayWriter( (int) keyFileContent.getSize() );
data.size = new Long( data.file.getContent().getSize() );
data.headerImageHeight = m.getHeight() * 0.0625; byte[] imageData = new byte[(int) imageFile.getContent().getSize()]; imageStream = KettleVFS.getInputStream( imageFile ); imageStream.read( imageData );
data.size = new Long( data.file.getContent().getSize() );
data.size = new Long( data.file.getContent().getSize() );
public boolean onNewFile( FileObject file ) throws FileSystemException { if ( file == null ) { String errMsg = BaseMessages.getString( PKG, "JsonInput.Log.IsNotAFile", "null" ); logError( errMsg ); inputError( errMsg ); return false; } else if ( !file.exists() ) { String errMsg = BaseMessages.getString( PKG, "JsonInput.Log.IsNotAFile", file.getName().getFriendlyURI() ); logError( errMsg ); inputError( errMsg ); return false; } if ( hasAdditionalFileFields() ) { fillFileAdditionalFields( data, file ); } if ( file.getContent().getSize() == 0 ) { // log only basic as a warning (was before logError) if ( meta.isIgnoreEmptyFile() ) { logBasic( BaseMessages.getString( PKG, "JsonInput.Error.FileSizeZero", "" + file.getName() ) ); } else { logError( BaseMessages.getString( PKG, "JsonInput.Error.FileSizeZero", "" + file.getName() ) ); incrementErrors(); return false; } } return true; }
Long entrySize = sourceFile.getContent().getSize(); Long destinationSize = destination.length();