@Test( expected = BinaryStoreException.class ) public void shouldRaiseAnExceptionWhenMovingAKeyThatDoesntExist() throws BinaryStoreException { store.moveValue(new BinaryKey("this-doesnt-exist"), alternativeHint); }
public BinaryKey moveValue( BinaryKey key, String source, String destination ) throws BinaryStoreException { final BinaryStore sourceStore; if (source == null) { sourceStore = findBinaryStoreContainingKey(key); } else { sourceStore = selectBinaryStore(source); } if (sourceStore == null || !sourceStore.hasBinary(key)) { throw new BinaryStoreException(JcrI18n.unableToFindBinaryValue.text(key, sourceStore)); } BinaryStore destinationStore = selectBinaryStore(destination); if (sourceStore.equals(destinationStore)) { return key; } final BinaryValue binaryValue = storeValue(sourceStore.getInputStream(key), destination, false); sourceStore.markAsUnused(java.util.Collections.singleton(key)); return binaryValue.getKey(); }
CompositeBinaryStore implements BinaryStore { public BinaryKey moveValue( BinaryKey key, String source, String destination ) throws BinaryStoreException { final BinaryStore sourceStore; if (source == null) { sourceStore = findBinaryStoreContainingKey(key); } else { sourceStore = selectBinaryStore(source); } if (sourceStore == null || !sourceStore.hasBinary(key)) { throw new BinaryStoreException(JcrI18n.unableToFindBinaryValue.text(key, sourceStore)); } BinaryStore destinationStore = selectBinaryStore(destination); if (sourceStore.equals(destinationStore)) { return key; } final BinaryValue binaryValue = storeValue(sourceStore.getInputStream(key), destination, false); sourceStore.markAsUnused(java.util.Collections.singleton(key)); return binaryValue.getKey(); } }
CompositeBinaryStore implements BinaryStore { public BinaryKey moveValue( BinaryKey key, String source, String destination ) throws BinaryStoreException { final BinaryStore sourceStore; if (source == null) { sourceStore = findBinaryStoreContainingKey(key); } else { sourceStore = selectBinaryStore(source); } if (sourceStore == null || !sourceStore.hasBinary(key)) { throw new BinaryStoreException(JcrI18n.unableToFindBinaryValue.text(key, sourceStore)); } BinaryStore destinationStore = selectBinaryStore(destination); if (sourceStore.equals(destinationStore)) { return key; } final BinaryValue binaryValue = storeValue(sourceStore.getInputStream(key), destination, false); sourceStore.markAsUnused(java.util.Collections.singleton(key)); return binaryValue.getKey(); } CompositeBinaryStore( Map<String, BinaryStore> namedStores ); }
CompositeBinaryStore implements BinaryStore { public BinaryKey moveValue( BinaryKey key, String source, String destination ) throws BinaryStoreException { final BinaryStore sourceStore; if (source == null) { sourceStore = findBinaryStoreContainingKey(key); } else { sourceStore = selectBinaryStore(source); } if (sourceStore == null || !sourceStore.hasBinary(key)) { throw new BinaryStoreException(JcrI18n.unableToFindBinaryValue.text(key, sourceStore)); } BinaryStore destinationStore = selectBinaryStore(destination); if (sourceStore.equals(destinationStore)) { return key; } final BinaryValue binaryValue = storeValue(sourceStore.getInputStream(key), destination, false); sourceStore.markAsUnused(java.util.Collections.singleton(key)); return binaryValue.getKey(); } CompositeBinaryStore( Map<String, BinaryStore> namedStores ); @Override void start(); @Override void shutdown(); @Override long getMinimumBinarySizeInBytes(); @Override void setMinimumBinarySizeInBytes( long minSizeInBytes ); @Override void setTextExtractors( TextExtractors textExtractors ); @Override void setMimeTypeDetector( MimeTypeDetector mimeTypeDetector ); @Override BinaryValue storeValue( InputStream stream, boolean markAsUnused ); @Override BinaryValue storeValue( InputStream stream, String hint, boolean markAsUnused ); BinaryKey moveValue( BinaryKey key,
                                String source,
                                String destination ); void moveValue( BinaryKey key,
                           String destination ); @Override InputStream getInputStream( BinaryKey key ); @Override boolean hasBinary( BinaryKey key ); @SuppressWarnings( "unused" ) @Override void markAsUnused( Iterable<BinaryKey> keys ); @Override void markAsUsed( Iterable<BinaryKey> keys ); @SuppressWarnings( "unused" ) @Override void removeValuesUnusedLongerThan( long minimumAge,
                                              TimeUnit unit ); @Override String getText( BinaryValue binary ); @Override String getMimeType( BinaryValue binary,
                               String name ); @Override Iterable<BinaryKey> getAllBinaryKeys(); Iterator<Map.Entry<String, BinaryStore>> getNamedStoreIterator(); BinaryStore findBinaryStoreContainingKey( BinaryKey key ); }
CompositeBinaryStore implements BinaryStore { public BinaryKey moveValue( BinaryKey key, String source, String destination ) throws BinaryStoreException { final BinaryStore sourceStore; if (source == null) { sourceStore = findBinaryStoreContainingKey(key); } else { sourceStore = selectBinaryStore(source); } if (sourceStore == null || !sourceStore.hasBinary(key)) { throw new BinaryStoreException(JcrI18n.unableToFindBinaryValue.text(key, sourceStore)); } BinaryStore destinationStore = selectBinaryStore(destination); if (sourceStore.equals(destinationStore)) { return key; } final BinaryValue binaryValue = storeValue(sourceStore.getInputStream(key), destination, false); sourceStore.markAsUnused(java.util.Collections.singleton(key)); return binaryValue.getKey(); } CompositeBinaryStore( Map<String, BinaryStore> namedStores ); @Override void start(); @Override void shutdown(); @Override long getMinimumBinarySizeInBytes(); @Override void setMinimumBinarySizeInBytes( long minSizeInBytes ); @Override void setTextExtractors( TextExtractors textExtractors ); @Override void setMimeTypeDetector( MimeTypeDetector mimeTypeDetector ); @Override BinaryValue storeValue( InputStream stream, boolean markAsUnused ); @Override BinaryValue storeValue( InputStream stream, String hint, boolean markAsUnused ); BinaryKey moveValue( BinaryKey key,
                                String source,
                                String destination ); void moveValue( BinaryKey key,
                           String destination ); @Override InputStream getInputStream( BinaryKey key ); @Override boolean hasBinary( BinaryKey key ); @SuppressWarnings( "unused" ) @Override void markAsUnused( Iterable<BinaryKey> keys ); @Override void markAsUsed( Iterable<BinaryKey> keys ); @SuppressWarnings( "unused" ) @Override void removeValuesUnusedLongerThan( long minimumAge,
                                              TimeUnit unit ); @Override String getText( BinaryValue binary ); @Override String getMimeType( BinaryValue binary,
                               String name ); @Override Iterable<BinaryKey> getAllBinaryKeys(); Iterator<Map.Entry<String, BinaryStore>> getNamedStoreIterator(); BinaryStore findBinaryStoreContainingKey( BinaryKey key );  }