From 1940acb4ae02b4f9454530606a6d817914c1a953 Mon Sep 17 00:00:00 2001 From: delvh Date: Wed, 5 Feb 2020 21:53:36 +0100 Subject: [PATCH] deleted applyAction method as per @CyB3RC0nN0R s request additionally inserted necessary TODO for a method that may cause problems in the future. --- .../server/database/PersistenceManager.java | 31 ------------------- .../processors/UserStatusChangeProcessor.java | 13 ++++---- 2 files changed, 6 insertions(+), 38 deletions(-) diff --git a/src/main/java/envoy/server/database/PersistenceManager.java b/src/main/java/envoy/server/database/PersistenceManager.java index 2d611ee..803f177 100644 --- a/src/main/java/envoy/server/database/PersistenceManager.java +++ b/src/main/java/envoy/server/database/PersistenceManager.java @@ -132,37 +132,6 @@ public class PersistenceManager { entityManager.getTransaction().commit(); } - /** - * @param action the action that should be applied for this entity. Case does - * not matter.
- * Currently supported values are:
- * -"add"/"persist" to add an object to the database
- * -"update"/"merge" to update this object in the database
- * -"delete"/"remove" to delete this object in the database - * @param entity the object to apply the action to - * @since Envoy Server Standalone v0.1-alpha - */ - public void applyAction(String action, Object entity) { - entityManager.getTransaction().begin(); - switch (action.trim().toLowerCase()) { - case "add": - case "persist": - entityManager.persist(entity); - break; - case "update": - case "merge": - entityManager.merge(entity); - break; - case "delete": - case "remove": - entityManager.remove(entity); - break; - default: - throw new IllegalStateException("Unknown action: " + action + " was selected to be executed in the database"); - } - entityManager.getTransaction().commit(); - } - /** * Searches for a {@link User} with a specific id. * diff --git a/src/main/java/envoy/server/processors/UserStatusChangeProcessor.java b/src/main/java/envoy/server/processors/UserStatusChangeProcessor.java index 0ed56bc..43e6153 100644 --- a/src/main/java/envoy/server/processors/UserStatusChangeProcessor.java +++ b/src/main/java/envoy/server/processors/UserStatusChangeProcessor.java @@ -22,8 +22,8 @@ import envoy.server.net.ObjectWriteProxy; */ public class UserStatusChangeProcessor implements ObjectProcessor { - private static ObjectWriteProxy writeProxy; - private static PersistenceManager persistenceManager = PersistenceManager.getPersistenceManager(); + private static ObjectWriteProxy writeProxy; + private static PersistenceManager persistenceManager = PersistenceManager.getPersistenceManager(); @Override public Class getInputClass() { return UserStatusChangeEvent.class; } @@ -59,9 +59,7 @@ public class UserStatusChangeProcessor implements ObjectProcessor