private CompletableFuture<Void> uploadMedia(MediaFileInfo fileInfo) {
        if (fileInfo == null) {
            return CompletableFuture.completedFuture(null);
        }
        int mediaId = fileInfo.getId();
        return getDelegate(fileInfo.getType()).onUploadMedia(fileInfo)
            .thenAcceptAsync((result) -> {
                // @todo: replace with StringBuilder
                if (result != null && result.isSuccessful()) {
                    logger.info("uploading of media id=" + mediaId + " succeeded.");
                    AsyncTask.execute(() -> {
                        mediaFileDao.insertOrUpdate(fileInfo);
                        mediaFileDao.setRemoteAvailable(mediaId);
                    });
                } else {
                    logger.warn("uploading of media id=" + mediaId + " failed.");
                    if (result.getErrorType() == ActionResult.NETWORK_ERROR) {
                        logger.warn("due to network error.");
                    } else {
                        logger.warn("due to unknown error.");
                    }
                }
            }).exceptionally((e) -> {
                logger.error("uploading of media id=" + mediaId + " failed spectacularly:");
                e.printStackTrace();
                return null;
            });
    }
private CompletableFuture<Void> uploadMedia(MediaFileInfo fileInfo) {
        if (fileInfo == null) {
            return CompletableFuture.completedFuture(null);
        }
        int mediaId = fileInfo.getId();
        return getDelegate(fileInfo.getType()).onUploadMedia(fileInfo)
            .thenAcceptAsync((result) -> {
               
                if (result != null && result.isSuccessful()) {
                    logger.info("uploading of media id=" + mediaId + " succeeded.");
                    AsyncTask.execute(() -> {
                        mediaFileDao.insertOrUpdate(fileInfo);
                        mediaFileDao.setRemoteAvailable(mediaId);
                    });
                } else {
                    logger.warn("uploading of media id=" + mediaId + " failed.");
                    if (result.getErrorType() == ActionResult.NETWORK_ERROR) {
                        logger.warn("due to network error.");
                    } else {
                        logger.warn("due to unknown error.");
                    }
                }
            }).exceptionally((e) -> {
                logger.error("uploading of media id=" + mediaId + " failed spectacularly:");
                e.printStackTrace();
                return null;
            });
    }
private completablefuture<void> uploadmedia(mediafileinfo fileinfo) { if (fileinfo == null) { return completablefuture.completedfuture(null); } int mediaid = fileinfo.getid(); return getdelegate(fileinfo.gettype()).onuploadmedia(fileinfo) .thenacceptasync((result) -> { if (result != null && result.issuccessful()) { logger.info("uploading of media id=" + mediaid + " succeeded."); asynctask.execute(() -> { mediafiledao.insertorupdate(fileinfo); mediafiledao.setremoteavailable(mediaid); }); } else { logger.warn("uploading of media id=" + mediaid + " failed."); if (result.geterrortype() == actionresult.network_error) { logger.warn("due to network error."); } else { logger.warn("due to unknown error."); } } }).exceptionally((e) -> { logger.error("uploading of media id=" + mediaid + " failed spectacularly:"); e.printstacktrace(); return null; }); }