class AbstractBinaryStore implements BinaryStore {

    @Override
    public String getMimeType( BinaryValue binary,
                               String name ) throws IOException, RepositoryException {
        
        if (detector == NullMimeTypeDetector.INSTANCE) {
            // no mime type detection is explicitly configured, so just return
            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;
    }

}