@Test(expected = BinaryStoreException.class) public void shouldFailWhenGettingTheMimeTypeOfBinaryWhichIsntStored() throws IOException, RepositoryException { getBinaryStore().getMimeType(new StoredBinaryValue(getBinaryStore(), invalidBinaryKey(), 0), "foobar.txt"); }
@Override public String getMimeType( BinaryValue binary, String name ) throws IOException, RepositoryException { if (detector == NullMimeTypeDetector.INSTANCE) { return null; } if (binary instanceof StoredBinaryValue) { String storedMimeType = getStoredMimeType(binary); if (!StringUtil.isBlank(storedMimeType)) { return storedMimeType; } } String detectedMimeType = detector().mimeTypeOf(name, binary); if (binary instanceof InMemoryBinaryValue) { return detectedMimeType; } else if (!StringUtil.isBlank(detectedMimeType)) { storeMimeType(binary, detectedMimeType); } return detectedMimeType; }
AbstractBinaryStore implements BinaryStore { @Override public String getMimeType( BinaryValue binary, String name ) throws IOException, RepositoryException { if (detector == NullMimeTypeDetector.INSTANCE) { return null; } if (binary instanceof StoredBinaryValue) { String storedMimeType = getStoredMimeType(binary); if (!StringUtil.isBlank(storedMimeType)) { return storedMimeType; } } String detectedMimeType = detector().mimeTypeOf(name, binary); if (binary instanceof InMemoryBinaryValue) { return detectedMimeType; } else if (!StringUtil.isBlank(detectedMimeType)) { storeMimeType(binary, detectedMimeType); } return detectedMimeType; } }
AbstractBinaryStore implements BinaryStore { @Override public String getMimeType( BinaryValue binary, String name ) throws IOException, RepositoryException { if (detector == NullMimeTypeDetector.INSTANCE) { return null; } if (binary instanceof StoredBinaryValue) { String storedMimeType = getStoredMimeType(binary); if (!StringUtil.isBlank(storedMimeType)) { return storedMimeType; } } String detectedMimeType = detector().mimeTypeOf(name, binary); if (binary instanceof InMemoryBinaryValue) { return detectedMimeType; } else if (!StringUtil.isBlank(detectedMimeType)) { storeMimeType(binary, detectedMimeType); } return detectedMimeType; }  }
AbstractBinaryStore implements BinaryStore { @Override public String getMimeType( BinaryValue binary, String name ) throws IOException, RepositoryException { if (detector == NullMimeTypeDetector.INSTANCE) { return null; } if (binary instanceof StoredBinaryValue) { String storedMimeType = getStoredMimeType(binary); if (!StringUtil.isBlank(storedMimeType)) { return storedMimeType; } } String detectedMimeType = detector().mimeTypeOf(name, binary); if (binary instanceof InMemoryBinaryValue) { return detectedMimeType; } else if (!StringUtil.isBlank(detectedMimeType)) { storeMimeType(binary, detectedMimeType); } return detectedMimeType; }  static int bestBufferSize( long fileSize ); @Override long getMinimumBinarySizeInBytes(); @Override void setMinimumBinarySizeInBytes( long minSizeInBytes ); @Override void setTextExtractors( TextExtractors textExtractors ); @Override void setMimeTypeDetector( MimeTypeDetector mimeTypeDetector ); @Override final String getText( BinaryValue binary ); @Override String getMimeType( BinaryValue binary,
                               String name ); @Override boolean hasBinary( BinaryKey key ); abstract void storeExtractedText( BinaryValue source,
                                             String extractedText ); abstract String getExtractedText( BinaryValue source ); @Override BinaryValue storeValue( InputStream stream, String hint, boolean markAsUnused ); @Override void start(); @Override void shutdown(); }
AbstractBinaryStore implements BinaryStore { @Override public String getMimeType( BinaryValue binary, String name ) throws IOException, RepositoryException { if (detector == NullMimeTypeDetector.INSTANCE) { return null; } if (binary instanceof StoredBinaryValue) { String storedMimeType = getStoredMimeType(binary); if (!StringUtil.isBlank(storedMimeType)) { return storedMimeType; } } String detectedMimeType = detector().mimeTypeOf(name, binary); if (binary instanceof InMemoryBinaryValue) { return detectedMimeType; } else if (!StringUtil.isBlank(detectedMimeType)) { storeMimeType(binary, detectedMimeType); } return detectedMimeType; }  static int bestBufferSize( long fileSize ); @Override long getMinimumBinarySizeInBytes(); @Override void setMinimumBinarySizeInBytes( long minSizeInBytes ); @Override void setTextExtractors( TextExtractors textExtractors ); @Override void setMimeTypeDetector( MimeTypeDetector mimeTypeDetector ); @Override final String getText( BinaryValue binary ); @Override String getMimeType( BinaryValue binary,
                               String name ); @Override boolean hasBinary( BinaryKey key ); abstract void storeExtractedText( BinaryValue source,
                                             String extractedText ); abstract String getExtractedText( BinaryValue source ); @Override BinaryValue storeValue( InputStream stream, String hint, boolean markAsUnused ); @Override void start(); @Override void shutdown();  }