// @todo: replace with StringBuilder
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;
            });
    }
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.");
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.");
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;
});
}