super.close();
bucket.store( ref.identity(), toString() ).execute();
}
catch( RiakException ex )
{
throw new EntityStoreException( "Unable to apply entity change: newEntity", ex );
}
}
};
}
@Override
public Writer updateEntity( final EntityReference ref, EntityDescriptor entityDescriptor )
throws IOException
{
return new StringWriter( 1000 )
{
@Override
public void close()
throws IOException
{
try
{
super.close();
IRiakObject entity = bucket.fetch( ref.identity() ).execute();
if( entity == null )
{
throw new EntityNotFoundException( ref );
}
bucket.store( ref.identity(), toString() ).execute();
}
catch( RiakException ex )
{
throw new EntityStoreException( "Unable to apply entity change: updateEntity", ex );
}
}
};
}
@Override
public void removeEntity( EntityReference ref, EntityDescriptor entityDescriptor )
throws EntityNotFoundException
{
try
{
IRiakObject entity = bucket.fetch( ref.identity() ).execute();
if( entity == null )
{
throw new EntityNotFoundException( ref );
}
bucket.delete( ref.identity() ).execute();
}
catch( RiakException ex )
{
throw new EntityStoreException( "Unable to apply entity change: removeEntity", ex );
}
}
} );
}
catch( RiakRetryFailedException ex )
{
throw new EntityStoreException( "Unable to apply entity changes.", ex );
}
}