diff --git a/src/main/java/net/frozenorb/apiv3/model/AccessToken.java b/src/main/java/net/frozenorb/apiv3/model/AccessToken.java index 8b312d7..6fbf1be 100644 --- a/src/main/java/net/frozenorb/apiv3/model/AccessToken.java +++ b/src/main/java/net/frozenorb/apiv3/model/AccessToken.java @@ -3,14 +3,13 @@ package net.frozenorb.apiv3.model; import com.google.common.collect.ImmutableList; import com.mongodb.async.SingleResultCallback; import com.mongodb.async.client.MongoCollection; -import com.mongodb.client.result.DeleteResult; -import com.mongodb.client.result.UpdateResult; import fr.javatic.mongo.jacksonCodec.Entity; import fr.javatic.mongo.jacksonCodec.objectId.Id; import lombok.AllArgsConstructor; import lombok.Getter; import net.frozenorb.apiv3.APIv3; import net.frozenorb.apiv3.actor.ActorType; +import net.frozenorb.apiv3.unsorted.MongoToVoidMongoCallback; import net.frozenorb.apiv3.util.SyncUtils; import org.bson.Document; @@ -64,12 +63,12 @@ public final class AccessToken { accessTokensCollection.insertOne(this, SyncUtils.vertxWrap(callback)); } - public void save(SingleResultCallback callback) { - accessTokensCollection.replaceOne(new Document("_id", id), this, SyncUtils.vertxWrap(callback)); + public void save(SingleResultCallback callback) { + accessTokensCollection.replaceOne(new Document("_id", id), this, SyncUtils.vertxWrap(new MongoToVoidMongoCallback<>(callback))); } - public void delete(SingleResultCallback callback) { - accessTokensCollection.deleteOne(new Document("_id", id), SyncUtils.vertxWrap(callback)); + public void delete(SingleResultCallback callback) { + accessTokensCollection.deleteOne(new Document("_id", id), SyncUtils.vertxWrap(new MongoToVoidMongoCallback<>(callback))); } } \ No newline at end of file diff --git a/src/main/java/net/frozenorb/apiv3/model/BannedAsn.java b/src/main/java/net/frozenorb/apiv3/model/BannedAsn.java index 381e474..4afdd30 100644 --- a/src/main/java/net/frozenorb/apiv3/model/BannedAsn.java +++ b/src/main/java/net/frozenorb/apiv3/model/BannedAsn.java @@ -3,13 +3,12 @@ package net.frozenorb.apiv3.model; import com.google.common.collect.ImmutableList; import com.mongodb.async.SingleResultCallback; import com.mongodb.async.client.MongoCollection; -import com.mongodb.client.result.DeleteResult; -import com.mongodb.client.result.UpdateResult; import fr.javatic.mongo.jacksonCodec.Entity; import fr.javatic.mongo.jacksonCodec.objectId.Id; import lombok.Getter; import lombok.Setter; import net.frozenorb.apiv3.APIv3; +import net.frozenorb.apiv3.unsorted.MongoToVoidMongoCallback; import net.frozenorb.apiv3.util.SyncUtils; import org.bson.Document; @@ -83,14 +82,14 @@ public final class BannedAsn { bannedAsnsCollection.insertOne(this, SyncUtils.vertxWrap(callback)); } - public void save(SingleResultCallback callback) { - bannedAsnsCollection.replaceOne(new Document("_id", id), this, SyncUtils.vertxWrap(callback)); + public void save(SingleResultCallback callback) { + bannedAsnsCollection.replaceOne(new Document("_id", id), this, SyncUtils.vertxWrap(new MongoToVoidMongoCallback<>(callback))); } - public void delete(SingleResultCallback callback) { + public void delete(SingleResultCallback callback) { bannedAsnCache.remove(this); bannedAsnIdCache.remove(id); - bannedAsnsCollection.deleteOne(new Document("_id", id), SyncUtils.vertxWrap(callback)); + bannedAsnsCollection.deleteOne(new Document("_id", id), SyncUtils.vertxWrap(new MongoToVoidMongoCallback<>(callback))); } } \ No newline at end of file diff --git a/src/main/java/net/frozenorb/apiv3/model/BannedCellCarrier.java b/src/main/java/net/frozenorb/apiv3/model/BannedCellCarrier.java index 7ab7427..1dde0c8 100644 --- a/src/main/java/net/frozenorb/apiv3/model/BannedCellCarrier.java +++ b/src/main/java/net/frozenorb/apiv3/model/BannedCellCarrier.java @@ -4,13 +4,12 @@ package net.frozenorb.apiv3.model; import com.google.common.collect.ImmutableList; import com.mongodb.async.SingleResultCallback; import com.mongodb.async.client.MongoCollection; -import com.mongodb.client.result.DeleteResult; -import com.mongodb.client.result.UpdateResult; import fr.javatic.mongo.jacksonCodec.Entity; import fr.javatic.mongo.jacksonCodec.objectId.Id; import lombok.Getter; import lombok.Setter; import net.frozenorb.apiv3.APIv3; +import net.frozenorb.apiv3.unsorted.MongoToVoidMongoCallback; import net.frozenorb.apiv3.util.SyncUtils; import org.bson.Document; @@ -84,14 +83,14 @@ public final class BannedCellCarrier { bannedCellCarriersCollection.insertOne(this, SyncUtils.vertxWrap(callback)); } - public void save(SingleResultCallback callback) { - bannedCellCarriersCollection.replaceOne(new Document("_id", id), this, SyncUtils.vertxWrap(callback)); + public void save(SingleResultCallback callback) { + bannedCellCarriersCollection.replaceOne(new Document("_id", id), this, SyncUtils.vertxWrap(new MongoToVoidMongoCallback<>(callback))); } - public void delete(SingleResultCallback callback) { + public void delete(SingleResultCallback callback) { bannedCellCarrierCache.remove(this); bannedCellCarrierIdCache.remove(id); - bannedCellCarriersCollection.deleteOne(new Document("_id", id), SyncUtils.vertxWrap(callback)); + bannedCellCarriersCollection.deleteOne(new Document("_id", id), SyncUtils.vertxWrap(new MongoToVoidMongoCallback<>(callback))); } } \ No newline at end of file diff --git a/src/main/java/net/frozenorb/apiv3/model/Grant.java b/src/main/java/net/frozenorb/apiv3/model/Grant.java index 9ba66f2..8985aab 100644 --- a/src/main/java/net/frozenorb/apiv3/model/Grant.java +++ b/src/main/java/net/frozenorb/apiv3/model/Grant.java @@ -3,12 +3,12 @@ package net.frozenorb.apiv3.model; import com.google.common.collect.Collections2; import com.mongodb.async.SingleResultCallback; import com.mongodb.async.client.MongoCollection; -import com.mongodb.client.result.UpdateResult; import fr.javatic.mongo.jacksonCodec.Entity; import fr.javatic.mongo.jacksonCodec.objectId.Id; import lombok.AllArgsConstructor; import lombok.Getter; import net.frozenorb.apiv3.APIv3; +import net.frozenorb.apiv3.unsorted.MongoToVoidMongoCallback; import net.frozenorb.apiv3.util.SyncUtils; import org.bson.Document; import org.bson.types.ObjectId; @@ -128,12 +128,12 @@ public final class Grant { grantsCollection.insertOne(this, SyncUtils.vertxWrap(callback)); } - public void delete(User removedBy, String reason, SingleResultCallback callback) { + public void delete(User removedBy, String reason, SingleResultCallback callback) { this.removedBy = removedBy.getId(); this.removedAt = Instant.now(); this.removalReason = reason; - grantsCollection.replaceOne(new Document("_id", id), this, SyncUtils.vertxWrap(callback)); + grantsCollection.replaceOne(new Document("_id", id), this, SyncUtils.vertxWrap(new MongoToVoidMongoCallback<>(callback))); } } \ No newline at end of file diff --git a/src/main/java/net/frozenorb/apiv3/model/IpBan.java b/src/main/java/net/frozenorb/apiv3/model/IpBan.java index 8c1d6c1..7055df1 100644 --- a/src/main/java/net/frozenorb/apiv3/model/IpBan.java +++ b/src/main/java/net/frozenorb/apiv3/model/IpBan.java @@ -2,7 +2,6 @@ package net.frozenorb.apiv3.model; import com.mongodb.async.SingleResultCallback; import com.mongodb.async.client.MongoCollection; -import com.mongodb.client.result.UpdateResult; import fr.javatic.mongo.jacksonCodec.Entity; import fr.javatic.mongo.jacksonCodec.objectId.Id; import lombok.AllArgsConstructor; @@ -10,6 +9,7 @@ import lombok.Getter; import net.frozenorb.apiv3.APIv3; import net.frozenorb.apiv3.actor.Actor; import net.frozenorb.apiv3.actor.ActorType; +import net.frozenorb.apiv3.unsorted.MongoToVoidMongoCallback; import net.frozenorb.apiv3.util.SyncUtils; import net.frozenorb.apiv3.util.TimeUtils; import org.bson.Document; @@ -149,12 +149,12 @@ public final class IpBan { ipBansCollection.insertOne(this, SyncUtils.vertxWrap(callback)); } - public void delete(User removedBy, String reason, SingleResultCallback callback) { + public void delete(User removedBy, String reason, SingleResultCallback callback) { this.removedBy = removedBy.getId(); this.removedAt = Instant.now(); this.removalReason = reason; - ipBansCollection.replaceOne(new Document("_id", id), this, SyncUtils.vertxWrap(callback)); + ipBansCollection.replaceOne(new Document("_id", id), this, SyncUtils.vertxWrap(new MongoToVoidMongoCallback<>(callback))); } } \ No newline at end of file diff --git a/src/main/java/net/frozenorb/apiv3/model/IpLogEntry.java b/src/main/java/net/frozenorb/apiv3/model/IpLogEntry.java index 93dd53e..c80af2b 100644 --- a/src/main/java/net/frozenorb/apiv3/model/IpLogEntry.java +++ b/src/main/java/net/frozenorb/apiv3/model/IpLogEntry.java @@ -2,12 +2,12 @@ package net.frozenorb.apiv3.model; import com.mongodb.async.SingleResultCallback; import com.mongodb.async.client.MongoCollection; -import com.mongodb.client.result.UpdateResult; import fr.javatic.mongo.jacksonCodec.Entity; import fr.javatic.mongo.jacksonCodec.objectId.Id; import lombok.AllArgsConstructor; import lombok.Getter; import net.frozenorb.apiv3.APIv3; +import net.frozenorb.apiv3.unsorted.MongoToVoidMongoCallback; import net.frozenorb.apiv3.util.SyncUtils; import org.bson.Document; import org.bson.types.ObjectId; @@ -78,8 +78,8 @@ public final class IpLogEntry { ipLogCollection.insertOne(this, SyncUtils.vertxWrap(callback)); } - public void save(SingleResultCallback callback) { - ipLogCollection.replaceOne(new Document("_id", id), this, SyncUtils.vertxWrap(callback)); + public void save(SingleResultCallback callback) { + ipLogCollection.replaceOne(new Document("_id", id), this, SyncUtils.vertxWrap(new MongoToVoidMongoCallback<>(callback))); } } \ No newline at end of file diff --git a/src/main/java/net/frozenorb/apiv3/model/NotificationTemplate.java b/src/main/java/net/frozenorb/apiv3/model/NotificationTemplate.java index f471088..27eb982 100644 --- a/src/main/java/net/frozenorb/apiv3/model/NotificationTemplate.java +++ b/src/main/java/net/frozenorb/apiv3/model/NotificationTemplate.java @@ -2,12 +2,12 @@ package net.frozenorb.apiv3.model; import com.mongodb.async.SingleResultCallback; import com.mongodb.async.client.MongoCollection; -import com.mongodb.client.result.DeleteResult; import fr.javatic.mongo.jacksonCodec.Entity; import fr.javatic.mongo.jacksonCodec.objectId.Id; import lombok.Getter; import lombok.Setter; import net.frozenorb.apiv3.APIv3; +import net.frozenorb.apiv3.unsorted.MongoToVoidMongoCallback; import net.frozenorb.apiv3.util.SyncUtils; import org.bson.Document; @@ -63,8 +63,8 @@ public final class NotificationTemplate { notificationTemplatesCollection.insertOne(this, SyncUtils.vertxWrap(callback)); } - public void delete(SingleResultCallback callback) { - notificationTemplatesCollection.deleteOne(new Document("_id", id), SyncUtils.vertxWrap(callback)); + public void delete(SingleResultCallback callback) { + notificationTemplatesCollection.deleteOne(new Document("_id", id), SyncUtils.vertxWrap(new MongoToVoidMongoCallback<>(callback))); } } \ No newline at end of file diff --git a/src/main/java/net/frozenorb/apiv3/model/Punishment.java b/src/main/java/net/frozenorb/apiv3/model/Punishment.java index 21c774b..ed89bda 100644 --- a/src/main/java/net/frozenorb/apiv3/model/Punishment.java +++ b/src/main/java/net/frozenorb/apiv3/model/Punishment.java @@ -2,7 +2,6 @@ package net.frozenorb.apiv3.model; import com.mongodb.async.SingleResultCallback; import com.mongodb.async.client.MongoCollection; -import com.mongodb.client.result.UpdateResult; import fr.javatic.mongo.jacksonCodec.Entity; import fr.javatic.mongo.jacksonCodec.objectId.Id; import lombok.AllArgsConstructor; @@ -10,6 +9,7 @@ import lombok.Getter; import net.frozenorb.apiv3.APIv3; import net.frozenorb.apiv3.actor.Actor; import net.frozenorb.apiv3.actor.ActorType; +import net.frozenorb.apiv3.unsorted.MongoToVoidMongoCallback; import net.frozenorb.apiv3.util.SyncUtils; import net.frozenorb.apiv3.util.TimeUtils; import org.bson.Document; @@ -152,13 +152,13 @@ public final class Punishment { punishmentsCollection.insertOne(this, SyncUtils.vertxWrap(callback)); } - public void delete(User removedBy, String reason, SingleResultCallback callback) { + public void delete(User removedBy, String reason, SingleResultCallback callback) { this.removedBy = removedBy.getId(); this.removedAt = Instant.now(); this.removalReason = reason; if (linkedIpBanId == null) { - punishmentsCollection.replaceOne(new Document("_id", id), this, SyncUtils.vertxWrap(callback)); + punishmentsCollection.replaceOne(new Document("_id", id), this, SyncUtils.vertxWrap(new MongoToVoidMongoCallback<>(callback))); return; } @@ -173,11 +173,11 @@ public final class Punishment { if (error2 != null) { callback.onResult(null, error2); } else { - punishmentsCollection.replaceOne(new Document("_id", id), this, SyncUtils.vertxWrap(callback)); + punishmentsCollection.replaceOne(new Document("_id", id), this, SyncUtils.vertxWrap(new MongoToVoidMongoCallback<>(callback))); } }); } else { - punishmentsCollection.replaceOne(new Document("_id", id), this, SyncUtils.vertxWrap(callback)); + punishmentsCollection.replaceOne(new Document("_id", id), this, SyncUtils.vertxWrap(new MongoToVoidMongoCallback<>(callback))); } }); } diff --git a/src/main/java/net/frozenorb/apiv3/model/Rank.java b/src/main/java/net/frozenorb/apiv3/model/Rank.java index 3625191..8703fd2 100644 --- a/src/main/java/net/frozenorb/apiv3/model/Rank.java +++ b/src/main/java/net/frozenorb/apiv3/model/Rank.java @@ -3,11 +3,11 @@ package net.frozenorb.apiv3.model; import com.google.common.collect.ImmutableList; import com.mongodb.async.SingleResultCallback; import com.mongodb.async.client.MongoCollection; -import com.mongodb.client.result.DeleteResult; import fr.javatic.mongo.jacksonCodec.Entity; import fr.javatic.mongo.jacksonCodec.objectId.Id; import lombok.Getter; import net.frozenorb.apiv3.APIv3; +import net.frozenorb.apiv3.unsorted.MongoToVoidMongoCallback; import net.frozenorb.apiv3.util.SyncUtils; import org.bson.Document; @@ -83,10 +83,10 @@ public final class Rank { ranksCollection.insertOne(this, SyncUtils.vertxWrap(callback)); } - public void delete(SingleResultCallback callback) { + public void delete(SingleResultCallback callback) { rankCache.remove(this); rankIdCache.remove(id); - ranksCollection.deleteOne(new Document("_id", id), SyncUtils.vertxWrap(callback)); + ranksCollection.deleteOne(new Document("_id", id), SyncUtils.vertxWrap(new MongoToVoidMongoCallback<>(callback))); } } \ No newline at end of file diff --git a/src/main/java/net/frozenorb/apiv3/model/Server.java b/src/main/java/net/frozenorb/apiv3/model/Server.java index b9e48dc..143f3a4 100644 --- a/src/main/java/net/frozenorb/apiv3/model/Server.java +++ b/src/main/java/net/frozenorb/apiv3/model/Server.java @@ -4,13 +4,12 @@ import com.google.common.collect.ImmutableList; import com.google.common.collect.ImmutableSet; import com.mongodb.async.SingleResultCallback; import com.mongodb.async.client.MongoCollection; -import com.mongodb.client.result.DeleteResult; -import com.mongodb.client.result.UpdateResult; import fr.javatic.mongo.jacksonCodec.Entity; import fr.javatic.mongo.jacksonCodec.objectId.Id; import lombok.Getter; import net.frozenorb.apiv3.APIv3; import net.frozenorb.apiv3.serialization.gson.ExcludeFromReplies; +import net.frozenorb.apiv3.unsorted.MongoToVoidMongoCallback; import net.frozenorb.apiv3.util.SyncUtils; import org.bson.Document; @@ -125,14 +124,14 @@ public final class Server { serversCollection.insertOne(this, SyncUtils.vertxWrap(callback)); } - public void save(SingleResultCallback callback) { - serversCollection.replaceOne(new Document("_id", id), this, SyncUtils.vertxWrap(callback)); + public void save(SingleResultCallback callback) { + serversCollection.replaceOne(new Document("_id", id), this, SyncUtils.vertxWrap(new MongoToVoidMongoCallback<>(callback))); } - public void delete(SingleResultCallback callback) { + public void delete(SingleResultCallback callback) { serverCache.remove(this); serverIdCache.remove(id); - serversCollection.deleteOne(new Document("_id", id), SyncUtils.vertxWrap(callback)); + serversCollection.deleteOne(new Document("_id", id), SyncUtils.vertxWrap(new MongoToVoidMongoCallback<>(callback))); } } \ No newline at end of file diff --git a/src/main/java/net/frozenorb/apiv3/model/ServerGroup.java b/src/main/java/net/frozenorb/apiv3/model/ServerGroup.java index 5cbf74b..d350bf2 100644 --- a/src/main/java/net/frozenorb/apiv3/model/ServerGroup.java +++ b/src/main/java/net/frozenorb/apiv3/model/ServerGroup.java @@ -3,14 +3,13 @@ package net.frozenorb.apiv3.model; import com.google.common.collect.ImmutableList; import com.mongodb.async.SingleResultCallback; import com.mongodb.async.client.MongoCollection; -import com.mongodb.client.result.DeleteResult; -import com.mongodb.client.result.UpdateResult; import fr.javatic.mongo.jacksonCodec.Entity; import fr.javatic.mongo.jacksonCodec.objectId.Id; import lombok.Getter; import lombok.Setter; import net.frozenorb.apiv3.APIv3; import net.frozenorb.apiv3.serialization.gson.ExcludeFromReplies; +import net.frozenorb.apiv3.unsorted.MongoToVoidMongoCallback; import net.frozenorb.apiv3.util.PermissionUtils; import net.frozenorb.apiv3.util.SyncUtils; import org.bson.Document; @@ -78,14 +77,14 @@ public final class ServerGroup { serverGroupsCollection.insertOne(this, SyncUtils.vertxWrap(callback)); } - public void save(SingleResultCallback callback) { - serverGroupsCollection.replaceOne(new Document("_id", id), this, SyncUtils.vertxWrap(callback)); + public void save(SingleResultCallback callback) { + serverGroupsCollection.replaceOne(new Document("_id", id), this, SyncUtils.vertxWrap(new MongoToVoidMongoCallback<>(callback))); } - public void delete(SingleResultCallback callback) { + public void delete(SingleResultCallback callback) { serverGroupCache.remove(this); serverGroupIdCache.remove(id); - serverGroupsCollection.deleteOne(new Document("_id", id), SyncUtils.vertxWrap(callback)); + serverGroupsCollection.deleteOne(new Document("_id", id), SyncUtils.vertxWrap(new MongoToVoidMongoCallback<>(callback))); } } \ No newline at end of file diff --git a/src/main/java/net/frozenorb/apiv3/model/User.java b/src/main/java/net/frozenorb/apiv3/model/User.java index 8eda6de..d33435a 100644 --- a/src/main/java/net/frozenorb/apiv3/model/User.java +++ b/src/main/java/net/frozenorb/apiv3/model/User.java @@ -10,7 +10,6 @@ import com.google.common.hash.Hashing; import com.google.common.primitives.Ints; import com.mongodb.async.SingleResultCallback; import com.mongodb.async.client.MongoCollection; -import com.mongodb.client.result.UpdateResult; import fr.javatic.mongo.jacksonCodec.Entity; import fr.javatic.mongo.jacksonCodec.objectId.Id; import io.vertx.core.CompositeFuture; @@ -24,10 +23,7 @@ import net.frozenorb.apiv3.maxmind.MaxMindUserType; import net.frozenorb.apiv3.serialization.gson.ExcludeFromReplies; import net.frozenorb.apiv3.serialization.jackson.UuidJsonDeserializer; import net.frozenorb.apiv3.serialization.jackson.UuidJsonSerializer; -import net.frozenorb.apiv3.unsorted.MongoToVertxCallback; -import net.frozenorb.apiv3.unsorted.Permissions; -import net.frozenorb.apiv3.unsorted.RequiresTotpResult; -import net.frozenorb.apiv3.unsorted.TotpAuthorizationResult; +import net.frozenorb.apiv3.unsorted.*; import net.frozenorb.apiv3.util.*; import org.bson.Document; @@ -614,8 +610,8 @@ public final class User { usersCollection.insertOne(this, SyncUtils.vertxWrap(callback)); } - public void save(SingleResultCallback callback) { - usersCollection.replaceOne(new Document("_id", id), this, SyncUtils.vertxWrap(callback)); + public void save(SingleResultCallback callback) { + usersCollection.replaceOne(new Document("_id", id), this, SyncUtils.vertxWrap(new MongoToVoidMongoCallback<>(callback))); } } \ No newline at end of file diff --git a/src/main/java/net/frozenorb/apiv3/route/accessTokens/DELETEAccessTokensId.java b/src/main/java/net/frozenorb/apiv3/route/accessTokens/DELETEAccessTokensId.java index 7ea7edf..c839456 100644 --- a/src/main/java/net/frozenorb/apiv3/route/accessTokens/DELETEAccessTokensId.java +++ b/src/main/java/net/frozenorb/apiv3/route/accessTokens/DELETEAccessTokensId.java @@ -1,7 +1,6 @@ package net.frozenorb.apiv3.route.accessTokens; import com.google.common.collect.ImmutableMap; -import com.mongodb.client.result.DeleteResult; import io.vertx.core.Handler; import io.vertx.core.json.JsonObject; import io.vertx.ext.web.RoutingContext; @@ -23,7 +22,8 @@ public final class DELETEAccessTokensId implements Handler { return; } - SyncUtils.runBlocking(v -> accessToken.delete(v)); + SyncUtils.runBlocking(v -> accessToken.delete(v)); + JsonObject requestBody = ctx.getBodyAsJson(); if (requestBody.containsKey("removedBy")) { diff --git a/src/main/java/net/frozenorb/apiv3/route/bannedAsns/DELETEBannedAsnsId.java b/src/main/java/net/frozenorb/apiv3/route/bannedAsns/DELETEBannedAsnsId.java index ac88894..b77f0ed 100644 --- a/src/main/java/net/frozenorb/apiv3/route/bannedAsns/DELETEBannedAsnsId.java +++ b/src/main/java/net/frozenorb/apiv3/route/bannedAsns/DELETEBannedAsnsId.java @@ -1,7 +1,6 @@ package net.frozenorb.apiv3.route.bannedAsns; import com.google.common.collect.ImmutableMap; -import com.mongodb.client.result.DeleteResult; import io.vertx.core.Handler; import io.vertx.core.json.JsonObject; import io.vertx.ext.web.RoutingContext; @@ -23,7 +22,7 @@ public final class DELETEBannedAsnsId implements Handler { return; } - SyncUtils.runBlocking(v -> bannedAsn.delete(v)); + SyncUtils.runBlocking(v -> bannedAsn.delete(v)); JsonObject requestBody = ctx.getBodyAsJson(); diff --git a/src/main/java/net/frozenorb/apiv3/route/bannedCellCarriers/DELETEBannedCellCarriersId.java b/src/main/java/net/frozenorb/apiv3/route/bannedCellCarriers/DELETEBannedCellCarriersId.java index 5d8d92b..abd14cf 100644 --- a/src/main/java/net/frozenorb/apiv3/route/bannedCellCarriers/DELETEBannedCellCarriersId.java +++ b/src/main/java/net/frozenorb/apiv3/route/bannedCellCarriers/DELETEBannedCellCarriersId.java @@ -1,7 +1,6 @@ package net.frozenorb.apiv3.route.bannedCellCarriers; import com.google.common.collect.ImmutableMap; -import com.mongodb.client.result.DeleteResult; import io.vertx.core.Handler; import io.vertx.core.json.JsonObject; import io.vertx.ext.web.RoutingContext; @@ -23,7 +22,7 @@ public final class DELETEBannedCellCarriersId implements Handler return; } - SyncUtils.runBlocking(v -> bannedCellCarrier.delete(v)); + SyncUtils.runBlocking(v -> bannedCellCarrier.delete(v)); JsonObject requestBody = ctx.getBodyAsJson(); diff --git a/src/main/java/net/frozenorb/apiv3/route/emailTokens/POSTEmailTokensIdConfirm.java b/src/main/java/net/frozenorb/apiv3/route/emailTokens/POSTEmailTokensIdConfirm.java index 3d9c438..1953d45 100644 --- a/src/main/java/net/frozenorb/apiv3/route/emailTokens/POSTEmailTokensIdConfirm.java +++ b/src/main/java/net/frozenorb/apiv3/route/emailTokens/POSTEmailTokensIdConfirm.java @@ -1,7 +1,6 @@ package net.frozenorb.apiv3.route.emailTokens; import com.google.common.collect.ImmutableMap; -import com.mongodb.client.result.UpdateResult; import io.vertx.core.Handler; import io.vertx.core.json.JsonObject; import io.vertx.ext.web.RoutingContext; @@ -44,7 +43,7 @@ public final class POSTEmailTokensIdConfirm implements Handler { user.completeEmailRegistration(user.getPendingEmail()); user.updatePassword(password); - SyncUtils.runBlocking(v -> user.save(v)); + SyncUtils.runBlocking(v -> user.save(v)); AuditLog.log(user.getId(), requestBody.getString("userIp"), ctx, AuditLogActionType.USER_CONFIRM_EMAIL, (ignored, error) -> { if (error != null) { diff --git a/src/main/java/net/frozenorb/apiv3/route/grants/DELETEGrantsId.java b/src/main/java/net/frozenorb/apiv3/route/grants/DELETEGrantsId.java index 18777bf..5c3aa3c 100644 --- a/src/main/java/net/frozenorb/apiv3/route/grants/DELETEGrantsId.java +++ b/src/main/java/net/frozenorb/apiv3/route/grants/DELETEGrantsId.java @@ -1,7 +1,6 @@ package net.frozenorb.apiv3.route.grants; import com.google.common.collect.ImmutableMap; -import com.mongodb.client.result.UpdateResult; import io.vertx.core.Handler; import io.vertx.core.json.JsonObject; import io.vertx.ext.web.RoutingContext; @@ -41,7 +40,7 @@ public final class DELETEGrantsId implements Handler { return; } - SyncUtils.runBlocking(v -> grant.delete(removedBy, reason, v)); + SyncUtils.runBlocking(v -> grant.delete(removedBy, reason, v)); AuditLog.log(removedBy.getId(), requestBody.getString("removedByIp"), ctx, AuditLogActionType.GRANT_DELETE, ImmutableMap.of("grantId", grant.getId()), (ignored, error) -> { if (error != null) { diff --git a/src/main/java/net/frozenorb/apiv3/route/ipBans/DELETEIpBansId.java b/src/main/java/net/frozenorb/apiv3/route/ipBans/DELETEIpBansId.java index 906a826..cd4af8a 100644 --- a/src/main/java/net/frozenorb/apiv3/route/ipBans/DELETEIpBansId.java +++ b/src/main/java/net/frozenorb/apiv3/route/ipBans/DELETEIpBansId.java @@ -1,7 +1,6 @@ package net.frozenorb.apiv3.route.ipBans; import com.google.common.collect.ImmutableMap; -import com.mongodb.client.result.UpdateResult; import io.vertx.core.Handler; import io.vertx.core.json.JsonObject; import io.vertx.ext.web.RoutingContext; @@ -41,7 +40,7 @@ public final class DELETEIpBansId implements Handler { return; } - SyncUtils.runBlocking(v -> ipBan.delete(removedBy, reason, v)); + SyncUtils.runBlocking(v -> ipBan.delete(removedBy, reason, v)); AuditLog.log(removedBy.getId(), requestBody.getString("removedByIp"), ctx, AuditLogActionType.IP_BAN_DELETE, ImmutableMap.of("punishmentId", ipBan.getId()), (ignored, error) -> { if (error != null) { diff --git a/src/main/java/net/frozenorb/apiv3/route/notificationTemplates/DELETENotificationTemplatesId.java b/src/main/java/net/frozenorb/apiv3/route/notificationTemplates/DELETENotificationTemplatesId.java index ebea234..758f847 100644 --- a/src/main/java/net/frozenorb/apiv3/route/notificationTemplates/DELETENotificationTemplatesId.java +++ b/src/main/java/net/frozenorb/apiv3/route/notificationTemplates/DELETENotificationTemplatesId.java @@ -1,7 +1,6 @@ package net.frozenorb.apiv3.route.notificationTemplates; import com.google.common.collect.ImmutableMap; -import com.mongodb.client.result.DeleteResult; import io.vertx.core.Handler; import io.vertx.core.json.JsonObject; import io.vertx.ext.web.RoutingContext; @@ -23,7 +22,7 @@ public final class DELETENotificationTemplatesId implements HandlerrunBlocking(v -> notificationTemplate.delete(v)); + SyncUtils.runBlocking(v -> notificationTemplate.delete(v)); JsonObject requestBody = ctx.getBodyAsJson(); diff --git a/src/main/java/net/frozenorb/apiv3/route/punishments/DELETEPunishmentsId.java b/src/main/java/net/frozenorb/apiv3/route/punishments/DELETEPunishmentsId.java index b67f627..2db9398 100644 --- a/src/main/java/net/frozenorb/apiv3/route/punishments/DELETEPunishmentsId.java +++ b/src/main/java/net/frozenorb/apiv3/route/punishments/DELETEPunishmentsId.java @@ -1,7 +1,6 @@ package net.frozenorb.apiv3.route.punishments; import com.google.common.collect.ImmutableMap; -import com.mongodb.client.result.UpdateResult; import io.vertx.core.Handler; import io.vertx.core.json.JsonObject; import io.vertx.ext.web.RoutingContext; @@ -41,7 +40,7 @@ public final class DELETEPunishmentsId implements Handler { return; } - SyncUtils.runBlocking(v -> punishment.delete(removedBy, reason, v)); + SyncUtils.runBlocking(v -> punishment.delete(removedBy, reason, v)); AuditLog.log(removedBy.getId(), requestBody.getString("removedByIp"), ctx, AuditLogActionType.PUNISHMENT_DELETE, ImmutableMap.of("punishmentId", punishment.getId()), (ignored, error) -> { if (error != null) { diff --git a/src/main/java/net/frozenorb/apiv3/route/punishments/DELETEUsersIdActivePunishment.java b/src/main/java/net/frozenorb/apiv3/route/punishments/DELETEUsersIdActivePunishment.java index dc73b3a..7a204d2 100644 --- a/src/main/java/net/frozenorb/apiv3/route/punishments/DELETEUsersIdActivePunishment.java +++ b/src/main/java/net/frozenorb/apiv3/route/punishments/DELETEUsersIdActivePunishment.java @@ -2,7 +2,6 @@ package net.frozenorb.apiv3.route.punishments; import com.google.common.collect.ImmutableMap; import com.google.common.collect.ImmutableSet; -import com.mongodb.client.result.UpdateResult; import io.vertx.core.Handler; import io.vertx.core.json.JsonObject; import io.vertx.ext.web.RoutingContext; @@ -58,7 +57,7 @@ public final class DELETEUsersIdActivePunishment implements HandlerrunBlocking(v -> finalActivePunishment.delete(removedBy, reason, v)); + SyncUtils.runBlocking(v -> finalActivePunishment.delete(removedBy, reason, v)); AuditLog.log(removedBy.getId(), requestBody.getString("removedByIp"), ctx, AuditLogActionType.PUNISHMENT_DELETE, ImmutableMap.of("punishmentId", activePunishment.getId()), (ignored, error) -> { if (error != null) { diff --git a/src/main/java/net/frozenorb/apiv3/route/ranks/DELETERanksId.java b/src/main/java/net/frozenorb/apiv3/route/ranks/DELETERanksId.java index 38df4f3..aaab43e 100644 --- a/src/main/java/net/frozenorb/apiv3/route/ranks/DELETERanksId.java +++ b/src/main/java/net/frozenorb/apiv3/route/ranks/DELETERanksId.java @@ -1,7 +1,6 @@ package net.frozenorb.apiv3.route.ranks; import com.google.common.collect.ImmutableMap; -import com.mongodb.client.result.DeleteResult; import io.vertx.core.Handler; import io.vertx.core.json.JsonObject; import io.vertx.ext.web.RoutingContext; @@ -23,7 +22,7 @@ public final class DELETERanksId implements Handler { return; } - SyncUtils.runBlocking(v -> rank.delete(v)); + SyncUtils.runBlocking(v -> rank.delete(v)); JsonObject requestBody = ctx.getBodyAsJson(); diff --git a/src/main/java/net/frozenorb/apiv3/route/serverGroups/DELETEServerGroupsId.java b/src/main/java/net/frozenorb/apiv3/route/serverGroups/DELETEServerGroupsId.java index 19375df..c4e9d35 100644 --- a/src/main/java/net/frozenorb/apiv3/route/serverGroups/DELETEServerGroupsId.java +++ b/src/main/java/net/frozenorb/apiv3/route/serverGroups/DELETEServerGroupsId.java @@ -1,7 +1,6 @@ package net.frozenorb.apiv3.route.serverGroups; import com.google.common.collect.ImmutableMap; -import com.mongodb.client.result.DeleteResult; import io.vertx.core.Handler; import io.vertx.core.json.JsonObject; import io.vertx.ext.web.RoutingContext; @@ -23,7 +22,7 @@ public final class DELETEServerGroupsId implements Handler { return; } - SyncUtils.runBlocking(v -> serverGroup.delete(v)); + SyncUtils.runBlocking(v -> serverGroup.delete(v)); JsonObject requestBody = ctx.getBodyAsJson(); diff --git a/src/main/java/net/frozenorb/apiv3/route/users/POSTUsersIdChangePassword.java b/src/main/java/net/frozenorb/apiv3/route/users/POSTUsersIdChangePassword.java index 3394f22..aac39d5 100644 --- a/src/main/java/net/frozenorb/apiv3/route/users/POSTUsersIdChangePassword.java +++ b/src/main/java/net/frozenorb/apiv3/route/users/POSTUsersIdChangePassword.java @@ -1,7 +1,6 @@ package net.frozenorb.apiv3.route.users; import com.google.common.collect.ImmutableMap; -import com.mongodb.client.result.UpdateResult; import io.vertx.core.Handler; import io.vertx.core.json.JsonObject; import io.vertx.ext.web.RoutingContext; @@ -71,7 +70,7 @@ public final class POSTUsersIdChangePassword implements Handler } user.updatePassword(newPassword); - SyncUtils.runBlocking(v -> user.save(v)); + SyncUtils.runBlocking(v -> user.save(v)); AuditLog.log(user.getId(), requestBody.getString("userIp"), ctx, AuditLogActionType.USER_CHANGE_PASSWORD, (ignored, error) -> { if (error != null) { diff --git a/src/main/java/net/frozenorb/apiv3/route/users/POSTUsersIdConfirmPhone.java b/src/main/java/net/frozenorb/apiv3/route/users/POSTUsersIdConfirmPhone.java index e867e4c..c232a2a 100644 --- a/src/main/java/net/frozenorb/apiv3/route/users/POSTUsersIdConfirmPhone.java +++ b/src/main/java/net/frozenorb/apiv3/route/users/POSTUsersIdConfirmPhone.java @@ -1,7 +1,6 @@ package net.frozenorb.apiv3.route.users; import com.google.common.collect.ImmutableMap; -import com.mongodb.client.result.UpdateResult; import io.vertx.core.Handler; import io.vertx.core.json.JsonObject; import io.vertx.ext.web.RoutingContext; @@ -54,14 +53,14 @@ public final class POSTUsersIdConfirmPhone implements Handler { if (!String.valueOf(phoneCode).equals(user.getPendingPhoneToken())) { user.failedPhoneRegistration(); - SyncUtils.runBlocking(v -> user.save(v)); + SyncUtils.runBlocking(v -> user.save(v)); ErrorUtils.respondOther(ctx, 409, "Phone token doesn't match", "phoneTokenNoMatch", ImmutableMap.of()); return; } user.completePhoneRegistration(user.getPendingPhone()); - SyncUtils.runBlocking(v -> user.save(v)); + SyncUtils.runBlocking(v -> user.save(v)); AuditLog.log(user.getId(), requestBody.getString("userIp"), ctx, AuditLogActionType.USER_CONFIRM_PHONE, (ignored, error) -> { if (error != null) { diff --git a/src/main/java/net/frozenorb/apiv3/route/users/POSTUsersIdLogin.java b/src/main/java/net/frozenorb/apiv3/route/users/POSTUsersIdLogin.java index bcd6d46..a720afc 100644 --- a/src/main/java/net/frozenorb/apiv3/route/users/POSTUsersIdLogin.java +++ b/src/main/java/net/frozenorb/apiv3/route/users/POSTUsersIdLogin.java @@ -1,7 +1,6 @@ package net.frozenorb.apiv3.route.users; import com.google.common.collect.ImmutableMap; -import com.mongodb.client.result.UpdateResult; import io.vertx.core.Handler; import io.vertx.core.json.JsonObject; import io.vertx.ext.web.RoutingContext; @@ -69,7 +68,7 @@ public final class POSTUsersIdLogin implements Handler { ipLogEntry.used(); IpLogEntry finalIpLogEntry = ipLogEntry; - SyncUtils.runBlocking(v -> finalIpLogEntry.save(v)); + SyncUtils.runBlocking(v -> finalIpLogEntry.save(v)); } String lastUsername = user.getLastUsername(); diff --git a/src/main/java/net/frozenorb/apiv3/route/users/POSTUsersIdPasswordReset.java b/src/main/java/net/frozenorb/apiv3/route/users/POSTUsersIdPasswordReset.java index 68f0057..4bc9274 100644 --- a/src/main/java/net/frozenorb/apiv3/route/users/POSTUsersIdPasswordReset.java +++ b/src/main/java/net/frozenorb/apiv3/route/users/POSTUsersIdPasswordReset.java @@ -1,7 +1,6 @@ package net.frozenorb.apiv3.route.users; import com.google.common.collect.ImmutableMap; -import com.mongodb.client.result.UpdateResult; import io.vertx.core.Handler; import io.vertx.core.json.JsonObject; import io.vertx.ext.web.RoutingContext; @@ -33,7 +32,7 @@ public final class POSTUsersIdPasswordReset implements Handler { } user.startPasswordReset(); - SyncUtils.runBlocking(v -> user.save(v)); + SyncUtils.runBlocking(v -> user.save(v)); Map replacements = ImmutableMap.of( "username", user.getLastUsername(), diff --git a/src/main/java/net/frozenorb/apiv3/route/users/POSTUsersIdRegisterEmail.java b/src/main/java/net/frozenorb/apiv3/route/users/POSTUsersIdRegisterEmail.java index 1e4ccfd..0d1ab5a 100644 --- a/src/main/java/net/frozenorb/apiv3/route/users/POSTUsersIdRegisterEmail.java +++ b/src/main/java/net/frozenorb/apiv3/route/users/POSTUsersIdRegisterEmail.java @@ -1,7 +1,6 @@ package net.frozenorb.apiv3.route.users; import com.google.common.collect.ImmutableMap; -import com.mongodb.client.result.UpdateResult; import io.vertx.core.Handler; import io.vertx.core.json.JsonObject; import io.vertx.ext.web.RoutingContext; @@ -59,7 +58,7 @@ public final class POSTUsersIdRegisterEmail implements Handler { } user.startEmailRegistration(email); - SyncUtils.runBlocking(v -> user.save(v)); + SyncUtils.runBlocking(v -> user.save(v)); Map replacements = ImmutableMap.of( "username", user.getLastUsername(), diff --git a/src/main/java/net/frozenorb/apiv3/route/users/POSTUsersIdRegisterPhone.java b/src/main/java/net/frozenorb/apiv3/route/users/POSTUsersIdRegisterPhone.java index d45c078..8335992 100644 --- a/src/main/java/net/frozenorb/apiv3/route/users/POSTUsersIdRegisterPhone.java +++ b/src/main/java/net/frozenorb/apiv3/route/users/POSTUsersIdRegisterPhone.java @@ -1,7 +1,6 @@ package net.frozenorb.apiv3.route.users; import com.google.common.collect.ImmutableMap; -import com.mongodb.client.result.UpdateResult; import io.vertx.core.Handler; import io.vertx.core.json.JsonObject; import io.vertx.ext.web.RoutingContext; @@ -63,7 +62,7 @@ public final class POSTUsersIdRegisterPhone implements Handler { } user.startPhoneRegistration(phone); - SyncUtils.runBlocking(v -> user.save(v)); + SyncUtils.runBlocking(v -> user.save(v)); Map replacements = ImmutableMap.of( "username", user.getLastUsername(), diff --git a/src/main/java/net/frozenorb/apiv3/route/users/POSTUsersIdSetupTotp.java b/src/main/java/net/frozenorb/apiv3/route/users/POSTUsersIdSetupTotp.java index 1a48150..bcc160b 100644 --- a/src/main/java/net/frozenorb/apiv3/route/users/POSTUsersIdSetupTotp.java +++ b/src/main/java/net/frozenorb/apiv3/route/users/POSTUsersIdSetupTotp.java @@ -1,7 +1,6 @@ package net.frozenorb.apiv3.route.users; import com.google.common.collect.ImmutableMap; -import com.mongodb.client.result.UpdateResult; import io.vertx.core.Handler; import io.vertx.core.json.JsonObject; import io.vertx.ext.web.RoutingContext; @@ -34,7 +33,7 @@ public final class POSTUsersIdSetupTotp implements Handler { if (TotpUtils.authorizeUser(secret, totpCode)) { user.setTotpSecret(secret); - SyncUtils.runBlocking(v -> user.save(v)); + SyncUtils.runBlocking(v -> user.save(v)); AuditLog.log(user.getId(), requestBody.getString("userIp"), ctx, AuditLogActionType.USER_SETUP_TOTP, (ignored, error) -> { if (error != null) { diff --git a/src/main/java/net/frozenorb/apiv3/unsorted/MongoToVertxCallback.java b/src/main/java/net/frozenorb/apiv3/unsorted/MongoToVertxCallback.java index 4e07839..9527a35 100644 --- a/src/main/java/net/frozenorb/apiv3/unsorted/MongoToVertxCallback.java +++ b/src/main/java/net/frozenorb/apiv3/unsorted/MongoToVertxCallback.java @@ -3,7 +3,7 @@ package net.frozenorb.apiv3.unsorted; import com.mongodb.async.SingleResultCallback; import io.vertx.core.Future; -public class MongoToVertxCallback implements SingleResultCallback { +public final class MongoToVertxCallback implements SingleResultCallback { private final Future future; diff --git a/src/main/java/net/frozenorb/apiv3/unsorted/MongoToVoidMongoCallback.java b/src/main/java/net/frozenorb/apiv3/unsorted/MongoToVoidMongoCallback.java new file mode 100644 index 0000000..9b4b65e --- /dev/null +++ b/src/main/java/net/frozenorb/apiv3/unsorted/MongoToVoidMongoCallback.java @@ -0,0 +1,17 @@ +package net.frozenorb.apiv3.unsorted; + +import com.mongodb.async.SingleResultCallback; + +public final class MongoToVoidMongoCallback implements SingleResultCallback { + + private final SingleResultCallback wrapped; + + public MongoToVoidMongoCallback(SingleResultCallback wrapped) { + this.wrapped = wrapped; + } + + public void onResult(T ignored, Throwable error) { + wrapped.onResult(null, error); + } + +} \ No newline at end of file