@Test public void shouldAccessStream() throws BinaryStoreException, IOException { InputStream stream = store.getInputStream(aliveValue.getKey()); assertTrue(stream != null); ByteArrayOutputStream bout = new ByteArrayOutputStream(); IOUtils.copy(stream, bout); String s = new String(bout.toByteArray()); assertEquals("Binary value", s); }
@Override public InputStream getInputStream( BinaryKey key ) throws BinaryStoreException { try { ResultSet rs = session.execute("SELECT payload FROM modeshape.binary WHERE cid='" + key.toString() + "'"); Row row = rs.one(); if (row == null) { throw new BinaryStoreException(JcrI18n.unableToFindBinaryValue.text(key, session)); } ByteBuffer buffer = row.getBytes("payload"); return new BufferedInputStream(buffer); } catch (BinaryStoreException e) { throw e; } catch (RuntimeException e) { throw new BinaryStoreException(e); } }
CassandraBinaryStore extends AbstractBinaryStore { @Override public InputStream getInputStream( BinaryKey key ) throws BinaryStoreException { try { ResultSet rs = session.execute("SELECT payload FROM modeshape.binary WHERE cid='" + key.toString() + "'"); Row row = rs.one(); if (row == null) { throw new BinaryStoreException(JcrI18n.unableToFindBinaryValue.text(key, session)); } ByteBuffer buffer = row.getBytes("payload"); return new BufferedInputStream(buffer); } catch (BinaryStoreException e) { throw e; } catch (RuntimeException e) { throw new BinaryStoreException(e); } } }
CassandraBinaryStore extends AbstractBinaryStore { @Override public InputStream getInputStream( BinaryKey key ) throws BinaryStoreException { try { ResultSet rs = session.execute("SELECT payload FROM modeshape.binary WHERE cid='" + key.toString() + "'"); Row row = rs.one(); if (row == null) { throw new BinaryStoreException(JcrI18n.unableToFindBinaryValue.text(key, session)); } ByteBuffer buffer = row.getBytes("payload"); return new BufferedInputStream(buffer); } catch (BinaryStoreException e) { throw e; } catch (RuntimeException e) { throw new BinaryStoreException(e); } } CassandraBinaryStore( String address ); }
CassandraBinaryStore extends AbstractBinaryStore { @Override public InputStream getInputStream( BinaryKey key ) throws BinaryStoreException { try { ResultSet rs = session.execute("SELECT payload FROM modeshape.binary WHERE cid='" + key.toString() + "'"); Row row = rs.one(); if (row == null) { throw new BinaryStoreException(JcrI18n.unableToFindBinaryValue.text(key, session)); } ByteBuffer buffer = row.getBytes("payload"); return new BufferedInputStream(buffer); } catch (BinaryStoreException e) { throw e; } catch (RuntimeException e) { throw new BinaryStoreException(e); } } CassandraBinaryStore( String address ); @Override void storeExtractedText( BinaryValue source,
                                    String extractedText ); @Override String getExtractedText( BinaryValue source ); @Override BinaryValue storeValue( InputStream stream, boolean markAsUnused ); @Override InputStream getInputStream( BinaryKey key ); @Override void markAsUsed( Iterable<BinaryKey> keys ); @Override void markAsUnused( Iterable<BinaryKey> keys ); @Override void removeValuesUnusedLongerThan( long minimumAge,
                                              TimeUnit unit ); @Override Iterable<BinaryKey> getAllBinaryKeys(); @Override void start(); }
CassandraBinaryStore extends AbstractBinaryStore { @Override public InputStream getInputStream( BinaryKey key ) throws BinaryStoreException { try { ResultSet rs = session.execute("SELECT payload FROM modeshape.binary WHERE cid='" + key.toString() + "'"); Row row = rs.one(); if (row == null) { throw new BinaryStoreException(JcrI18n.unableToFindBinaryValue.text(key, session)); } ByteBuffer buffer = row.getBytes("payload"); return new BufferedInputStream(buffer); } catch (BinaryStoreException e) { throw e; } catch (RuntimeException e) { throw new BinaryStoreException(e); } } CassandraBinaryStore( String address ); @Override void storeExtractedText( BinaryValue source,
                                    String extractedText ); @Override String getExtractedText( BinaryValue source ); @Override BinaryValue storeValue( InputStream stream, boolean markAsUnused ); @Override InputStream getInputStream( BinaryKey key ); @Override void markAsUsed( Iterable<BinaryKey> keys ); @Override void markAsUnused( Iterable<BinaryKey> keys ); @Override void removeValuesUnusedLongerThan( long minimumAge,
                                              TimeUnit unit ); @Override Iterable<BinaryKey> getAllBinaryKeys(); @Override void start();  }