Source:
<code>public void storeItem( Repository repository, StorageItem item ) throws UnsupportedStorageOperationException, LocalStorageException { final File target; final ContentLocator originalContentLocator; if ( item instanceof StorageFileItem ) { originalContentLocator = ( (StorageFileItem) item ).getContentLocator(); } else { originalContentLocator = null; } try { item.setStoredLocally( System.currentTimeMillis() ); item.setRemoteChecked( item.getStoredLocally() ); item.setExpired( false ); ContentLocator cl = null; if ( item instanceof StorageFileItem ) { StorageFileItem fItem = (StorageFileItem) item; prepareStorageFileItemForStore( fItem ); cl = fItem.getContentLocator(); } else if ( item instanceof StorageLinkItem ) { ByteArrayOutputStream bos = new ByteArrayOutputStream(); try { getLinkPersister().writeLinkContent( (StorageLinkItem) item, bos ); } catch ( IOException e ) { throw new LocalStorageException( "Problem ", e ); } cl = new ByteArrayContentLocator( bos.toByteArray(), "text/xml" ); } target = getFileFromBase( repository, item.getResourceStoreRequest() ); getFSPeer().storeItem( repository, getBaseDir( repository, item.getResourceStoreRequest() ), item, target, cl ); } finally { if ( originalContentLocator != null <START> && ( originalContentLocator instanceof PreparedContentLocator ) ) <END> { Closeables.closeQuietly( ( (PreparedContentLocator) originalContentLocator ) ); } } if ( item instanceof StorageFileItem ) { ( (StorageFileItem) item ).setLength( target.length() ); ( (StorageFileItem) item ).setContentLocator( new FileContentLocator( target, ( (StorageFileItem) item ).getMimeType() ) ); } final ContentLocator mdis = item instanceof StorageFileItem ? ( (StorageFileItem) item ).getContentLocator() : null; try { repository.getAttributesHandler().storeAttributes( item, mdis ); } catch ( IOException e ) { throw new LocalStorageException( "Cannot store attributes!", e ); } }</code><technical_language>fyi, instanceof implies !=null</technical_language>

Target:
public void storeItem( Repository repository, StorageItem item ) throws UnsupportedStorageOperationException, LocalStorageException { final File target; final ContentLocator originalContentLocator; if ( item instanceof StorageFileItem ) { originalContentLocator = ( (StorageFileItem) item ).getContentLocator(); } else { originalContentLocator = null; } try { item.setStoredLocally( System.currentTimeMillis() ); item.setRemoteChecked( item.getStoredLocally() ); item.setExpired( false ); ContentLocator cl = null; if ( item instanceof StorageFileItem ) { StorageFileItem fItem = (StorageFileItem) item; prepareStorageFileItemForStore( fItem ); cl = fItem.getContentLocator(); } else if ( item instanceof StorageLinkItem ) { ByteArrayOutputStream bos = new ByteArrayOutputStream(); try { getLinkPersister().writeLinkContent( (StorageLinkItem) item, bos ); } catch ( IOException e ) { throw new LocalStorageException( "Problem ", e ); } cl = new ByteArrayContentLocator( bos.toByteArray(), "text/xml" ); } target = getFileFromBase( repository, item.getResourceStoreRequest() ); getFSPeer().storeItem( repository, getBaseDir( repository, item.getResourceStoreRequest() ), item, target, cl ); } finally { if ( originalContentLocator instanceof Closeable ) { Closeables.closeQuietly( (Closeable) originalContentLocator ); } } if ( item instanceof StorageFileItem ) { ( (StorageFileItem) item ).setLength( target.length() ); ( (StorageFileItem) item ).setContentLocator( new FileContentLocator( target, ( (StorageFileItem) item ).getMimeType() ) ); } final ContentLocator mdis = item instanceof StorageFileItem ? ( (StorageFileItem) item ).getContentLocator() : null; try { repository.getAttributesHandler().storeAttributes( item, mdis ); } catch ( IOException e ) { throw new LocalStorageException( "Cannot store attributes!", e ); } }