/** * Calculates a SHA1 digest for a stream. * * @param content * @return */ public static String getMd5Digest( InputStream is ) { try { return getDigest( "MD5", is ); } catch ( NoSuchAlgorithmException e ) { // will not happen return null; } }
private void packIndex( IndexPacker packer, IndexPackingRequest request, boolean debug, boolean quiet ) { try { packer.packIndex( request ); } catch ( IOException e ) { if ( !quiet ) { System.err.printf( "Cannot zip index; \n", e.getMessage() ); if ( debug ) { e.printStackTrace(); } } } }
void writeIndexProperties( IndexPackingRequest request, Properties info ) throws IOException { File propertyFile = new File( request.getContext().getIndexDirectoryFile(), IndexingContext.INDEX_PACKER_PROPERTIES_FILE ); File targetPropertyFile = new File( request.getTargetDir(), IndexingContext.INDEX_REMOTE_PROPERTIES_FILE ); info.setProperty( IndexingContext.INDEX_ID, request.getContext().getId() ); try ( OutputStream os = new FileOutputStream( propertyFile ) ) { info.store( os, null ); } try ( OutputStream os = new FileOutputStream( targetPropertyFile ) ) { info.store( os, null ); } if ( request.isCreateChecksumFiles() ) { FileUtils.fileWrite( new File( targetPropertyFile.getParentFile(), targetPropertyFile.getName() + ".sha1" ).getAbsolutePath(), DigesterUtils.getSha1Digest( targetPropertyFile ) ); FileUtils.fileWrite( new File( targetPropertyFile.getParentFile(), targetPropertyFile.getName() + ".md5" ).getAbsolutePath(), DigesterUtils.getMd5Digest( targetPropertyFile ) ); } }
void writeIndexData( IndexPackingRequest request, List<Integer> docIndexes, File targetArchive ) throws IOException { if ( targetArchive.exists() ) { targetArchive.delete(); } try ( OutputStream os = new FileOutputStream( targetArchive ) ) { IndexDataWriter dw = new IndexDataWriter( os ); dw.write( request.getContext(), request.getIndexReader(), docIndexes ); os.flush(); } }
/** * Calculates a SHA1 digest for a stream. * * @param content * @return */ public static String getSha1Digest( InputStream is ) { try { return getDigest( "SHA1", is ); } catch ( NoSuchAlgorithmException e ) { // will not happen return null; } }
void writeIndexData( IndexPackingRequest request, List<Integer> docIndexes, File targetArchive ) throws IOException { if ( targetArchive.exists() ) { targetArchive.delete(); } try ( OutputStream os = new FileOutputStream( targetArchive ) ) { IndexDataWriter dw = new IndexDataWriter( os ); dw.write( request.getContext(), request.getIndexReader(), docIndexes ); os.flush(); } }
/** * Calculates a SHA1 digest for a stream. * * @param is * @return */ public static String getSha1Digest( InputStream is ) { try { return getDigest( "SHA1", is ); } catch ( NoSuchAlgorithmException e ) { // will not happen return null; } }
/** * Calculates a SHA1 digest for a stream. * * @param is * @return */ public static String getSha1Digest( InputStream is ) { try { return getDigest( "SHA1", is ); } catch ( NoSuchAlgorithmException e ) { // will not happen return null; } }
/** * Calculates a SHA1 digest for a stream. * * @param is * @return */ public static String getMd5Digest( InputStream is ) { try { return getDigest( "MD5", is ); } catch ( NoSuchAlgorithmException e ) { // will not happen return null; } }
/** * Calculates a SHA1 digest for a stream. * * @param is * @return */ public static String getMd5Digest( InputStream is ) { try { return getDigest( "MD5", is ); } catch ( NoSuchAlgorithmException e ) { // will not happen return null; } }
/** * Calculates a SHA1 digest for a file. * * @param file * @return */ public static String getMd5Digest( File file ) throws IOException { try ( InputStream fis = new FileInputStream( file ) ) { return getDigest( "MD5", fis ); } catch ( NoSuchAlgorithmException e ) { // will not happen return null; } catch ( FileNotFoundException e ) { // will not happen return null; } }
/** * Calculates a SHA1 digest for a file. * * @param file * @return */ public static String getSha1Digest( File file ) throws IOException { try ( FileInputStream fis = new FileInputStream( file ) ) { return getDigest( "SHA1", fis ); } catch ( NoSuchAlgorithmException e ) { // will not happen return null; } catch ( FileNotFoundException e ) { // will not happen return null; } }
/** * Calculates a SHA1 digest for a file. * * @param file * @return */ public static String getSha1Digest( File file ) throws IOException { try ( FileInputStream fis = new FileInputStream( file ) ) { return getDigest( "SHA1", fis ); } catch ( NoSuchAlgorithmException e ) { // will not happen return null; } catch ( FileNotFoundException e ) { // will not happen return null; } }
/** * Calculates a SHA1 digest for a file. * * @param file * @return */ public static String getMd5Digest( File file ) throws IOException { try ( InputStream fis = new FileInputStream( file ) ) { return getDigest( "MD5", fis ); } catch ( NoSuchAlgorithmException e ) { // will not happen return null; } catch ( FileNotFoundException e ) { // will not happen return null; } }
/** * Calculates a SHA1 digest for a string. * * @param content * @return */ public static String getMd5Digest( String content ) { try { InputStream fis = new ByteArrayInputStream( content.getBytes( "UTF-8" ) ); return getDigest( "MD5", fis ); } catch ( NoSuchAlgorithmException e ) { // will not happen return null; } catch ( UnsupportedEncodingException e ) { // will not happen return null; } }
/** * Calculates a SHA1 digest for a string. * * @param content * @return */ public static String getSha1Digest( String content ) { try { InputStream fis = new ByteArrayInputStream( content.getBytes( "UTF-8" ) ); return getDigest( "SHA1", fis ); } catch ( NoSuchAlgorithmException e ) { // will not happen return null; } catch ( UnsupportedEncodingException e ) { // will not happen return null; } }
/** * Calculates a SHA1 digest for a string. * * @param content * @return */ public static String getSha1Digest( String content ) { try { InputStream fis = new ByteArrayInputStream( content.getBytes( "UTF-8" ) ); return getDigest( "SHA1", fis ); } catch ( NoSuchAlgorithmException e ) { // will not happen return null; } catch ( UnsupportedEncodingException e ) { // will not happen return null; } }
/** * Calculates a SHA1 digest for a string. * * @param content * @return */ public static String getMd5Digest( String content ) { try { InputStream fis = new ByteArrayInputStream( content.getBytes( "UTF-8" ) ); return getDigest( "MD5", fis ); } catch ( NoSuchAlgorithmException e ) { // will not happen return null; } catch ( UnsupportedEncodingException e ) { // will not happen return null; } }
/** * Calculates a SHA1 digest for a string. * * @param content * @return */ public static String getMd5Digest( String content ) { try { InputStream fis = new ByteArrayInputStream( content.getBytes( "UTF-8" ) ); return getDigest( "MD5", fis ); } catch ( NoSuchAlgorithmException e ) { // will not happen return null; } catch ( UnsupportedEncodingException e ) { // will not happen return null; } }
/** * Calculates a SHA1 digest for a string. * * @param content * @return */ public static String getSha1Digest( String content ) { try { InputStream fis = new ByteArrayInputStream( content.getBytes( "UTF-8" ) ); return getDigest( "SHA1", fis ); } catch ( NoSuchAlgorithmException e ) { // will not happen return null; } catch ( UnsupportedEncodingException e ) { // will not happen return null; } }