deleted applyAction method as per @CyB3RC0nN0R s request
additionally inserted necessary TODO for a method that may cause problems in the future.
This commit is contained in:
parent
f04c81bbf0
commit
1940acb4ae
@ -132,37 +132,6 @@ public class PersistenceManager {
|
||||
entityManager.getTransaction().commit();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param action the action that should be applied for this entity. Case does
|
||||
* <b>not</b> matter.<br>
|
||||
* Currently supported values are:<br>
|
||||
* -"add"/"persist" to add an object to the database<br>
|
||||
* -"update"/"merge" to update this object in the database<br>
|
||||
* -"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.
|
||||
*
|
||||
|
@ -22,8 +22,8 @@ import envoy.server.net.ObjectWriteProxy;
|
||||
*/
|
||||
public class UserStatusChangeProcessor implements ObjectProcessor<UserStatusChangeEvent> {
|
||||
|
||||
private static ObjectWriteProxy writeProxy;
|
||||
private static PersistenceManager persistenceManager = PersistenceManager.getPersistenceManager();
|
||||
private static ObjectWriteProxy writeProxy;
|
||||
private static PersistenceManager persistenceManager = PersistenceManager.getPersistenceManager();
|
||||
|
||||
@Override
|
||||
public Class<UserStatusChangeEvent> getInputClass() { return UserStatusChangeEvent.class; }
|
||||
@ -59,9 +59,7 @@ public class UserStatusChangeProcessor implements ObjectProcessor<UserStatusChan
|
||||
* @param evt the {@link UserStatusChangeEvent}
|
||||
* @since Envoy Server Standalone v0.1-alpha
|
||||
*/
|
||||
public static void updateUserStatus(UserStatusChangeEvent evt) {
|
||||
updateUserStatus(persistenceManager.getUserById(evt.getId()));
|
||||
}
|
||||
public static void updateUserStatus(UserStatusChangeEvent evt) { updateUserStatus(persistenceManager.getUserById(evt.getId())); }
|
||||
|
||||
/**
|
||||
* notifies active contacts of this {@link User} that his {@link UserStatus} has
|
||||
@ -94,5 +92,6 @@ public class UserStatusChangeProcessor implements ObjectProcessor<UserStatusChan
|
||||
* @since Envoy Server Standalone v0.1-alpha
|
||||
*/
|
||||
public static void setWriteProxy(ObjectWriteProxy writeProxy) { UserStatusChangeProcessor.writeProxy = writeProxy; }
|
||||
|
||||
// TODO may cause an problem if two clients log in at the same time.
|
||||
// Change Needed.
|
||||
}
|
Reference in New Issue
Block a user