public void postReplaceFav(final FavoriteInternal oldFav, 
            final  FavoriteInternal newFav) {
        this.addTask(new Runnable() {
            public void run() {
                DataOutputStream out = null;
                try {
                    //the changes will be appended
                    out = openChangesFile().openDataOutputStream(true);
                    
                    //delete the old one
                    out.writeInt(OPERATION_SET_FAV_STATUS);
                    out.writeInt(oldFav.getPersistanceIndex());
                    out.writeInt(oldFav.getStatus());
                    
                    //add the new one
                    out.writeInt(OPERATION_ADD_FAV);
                    newFav.setPersistanceIndex(nextIndex++);
                    newFav.write(out);
                    out.flush();
                } catch (Exception e) {
                    if(LOG.isError()) {
                        LOG.error("FavoritePersistence.postReplaceFav()", e);
                    }
                    exHandler.handleWriteChangeError(oldFav, e);
                } finally {
                    try {
                        if (out != null) out.close();
                    } catch (IOException e) {
                        if(LOG.isError()) {
                            LOG.error("FavoritePersistence.closeOut", e);
                        }
                    }
                }
            }        
        });
    }