From 1d4492b3d588d950a3b1e831360649ababfa685f Mon Sep 17 00:00:00 2001 From: DieGurke <55625494+DieGurke@users.noreply.github.com> Date: Thu, 26 Mar 2020 17:09:52 +0100 Subject: [PATCH] Implemented a GroupCreationProcessor and revised/added Javadoc --- src/main/java/envoy/server/data/Group.java | 2 +- .../envoy/server/data/PersistenceManager.java | 6 ++-- .../processors/GroupCreationProcessor.java | 34 +++++++++++++++++++ .../IDGeneratorRequestProcessor.java | 9 +++++ 4 files changed, 47 insertions(+), 4 deletions(-) create mode 100644 src/main/java/envoy/server/processors/GroupCreationProcessor.java diff --git a/src/main/java/envoy/server/data/Group.java b/src/main/java/envoy/server/data/Group.java index a98f2db..592475f 100644 --- a/src/main/java/envoy/server/data/Group.java +++ b/src/main/java/envoy/server/data/Group.java @@ -46,7 +46,7 @@ public class Group extends Contact { /** * Sets the members of this group. * - * @param Members a list of all users, that should be assigned to this group. + * @param members a list of all users, that should be assigned to this group. * @since Envoy Server Standalone v0.1-beta */ public void setMembers(List members) { this.members = members; } diff --git a/src/main/java/envoy/server/data/PersistenceManager.java b/src/main/java/envoy/server/data/PersistenceManager.java index b7261c2..669cf7e 100755 --- a/src/main/java/envoy/server/data/PersistenceManager.java +++ b/src/main/java/envoy/server/data/PersistenceManager.java @@ -52,7 +52,7 @@ public class PersistenceManager { /** * Adds a {@link Contact} to the database. * - * @param user the {@link Contact} to add to the database + * @param contact the {@link Contact} to add to the database * @since Envoy Server Standalone v0.1-alpha */ public void addContact(Contact contact) { persist(contact); } @@ -76,7 +76,7 @@ public class PersistenceManager { /** * Updates a {@link Contact} in the database * - * @param user the {@link Contact} to add to the database + * @param contact the {@link Contact} to add to the database * @since Envoy Server Standalone v0.1-alpha */ public void updateContact(Contact contact) { merge(contact); } @@ -100,7 +100,7 @@ public class PersistenceManager { /** * Deletes a {@link Contact} in the database. * - * @param user the {@link Contact} to delete + * @param contact the {@link Contact} to delete * @since Envoy Server Standalone v0.1-alpha */ public void deleteContact(Contact contact) { remove(contact); } diff --git a/src/main/java/envoy/server/processors/GroupCreationProcessor.java b/src/main/java/envoy/server/processors/GroupCreationProcessor.java new file mode 100644 index 0000000..85ac6af --- /dev/null +++ b/src/main/java/envoy/server/processors/GroupCreationProcessor.java @@ -0,0 +1,34 @@ +package envoy.server.processors; + +import java.io.IOException; + +import envoy.event.GroupCreationEvent; +import envoy.server.data.PersistenceManager; +import envoy.server.net.ObjectWriteProxy; + +/** + * Project: envoy-server-standalone
+ * File: GroupCreationProcessor.java
+ * Created: 26.03.2020
+ * + * @author Maximilian Käfer + * @since Envoy Server Standalone v0.1-beta + */ +public class GroupCreationProcessor implements ObjectProcessor { + + private final PersistenceManager persistenceManager = PersistenceManager.getInstance(); + + @Override + public void process(GroupCreationEvent input, long socketId, ObjectWriteProxy writeProxy) throws IOException { + envoy.server.data.Group group = new envoy.server.data.Group(); + group.setName(input.get()); + // TODO adjust event, so it sends a members list as well, which can be initially + // set here + persistenceManager.addContact(group); + writeProxy.write(socketId, group); // TODO Prepare the client to receive the group object after sending the + // groupCreationEvent to the server. + } + + @Override + public Class getInputClass() { return GroupCreationEvent.class; } +} diff --git a/src/main/java/envoy/server/processors/IDGeneratorRequestProcessor.java b/src/main/java/envoy/server/processors/IDGeneratorRequestProcessor.java index bb6be36..38a799d 100755 --- a/src/main/java/envoy/server/processors/IDGeneratorRequestProcessor.java +++ b/src/main/java/envoy/server/processors/IDGeneratorRequestProcessor.java @@ -33,8 +33,17 @@ public class IDGeneratorRequestProcessor implements ObjectProcessor