From 6d8294a96a0a828b73fd90c39fc43d7be90cc3f5 Mon Sep 17 00:00:00 2001 From: delvh Date: Thu, 26 Mar 2020 16:54:12 +0100 Subject: [PATCH] restored functionality with envoy-common (#32) --- src/main/java/envoy/server/data/Message.java | 6 +++--- src/main/java/envoy/server/data/User.java | 3 +-- .../server/processors/ContactOperationProcessor.java | 2 +- .../processors/IDGeneratorRequestProcessor.java | 12 ++++++------ .../envoy/server/processors/MessageProcessor.java | 8 ++++---- .../processors/MessageStatusChangeProcessor.java | 2 +- .../server/processors/UserStatusChangeProcessor.java | 6 +++--- 7 files changed, 19 insertions(+), 20 deletions(-) diff --git a/src/main/java/envoy/server/data/Message.java b/src/main/java/envoy/server/data/Message.java index e5f600c..f2584d3 100755 --- a/src/main/java/envoy/server/data/Message.java +++ b/src/main/java/envoy/server/data/Message.java @@ -68,14 +68,14 @@ public class Message { */ public Message(envoy.data.Message message) { PersistenceManager persMan = PersistenceManager.getInstance(); - id = message.getId(); + id = message.getID(); status = message.getStatus(); text = message.getText(); creationDate = message.getCreationDate(); receivedDate = message.getReceivedDate(); readDate = message.getReadDate(); - sender = persMan.getUserById(message.getSenderId()); - recipient = persMan.getUserById(message.getRecipientId()); + sender = persMan.getUserById(message.getSenderID()); + recipient = persMan.getUserById(message.getRecipientID()); forwarded = message.isForwarded(); // TODO: attachment = message.getAttachment().toByteArray();DOES NOT WORK YET } diff --git a/src/main/java/envoy/server/data/User.java b/src/main/java/envoy/server/data/User.java index b356147..327a030 100755 --- a/src/main/java/envoy/server/data/User.java +++ b/src/main/java/envoy/server/data/User.java @@ -5,7 +5,6 @@ import java.util.List; import javax.persistence.*; - /** * This class serves as a way to let Hibernate communicate with the server * without bringing the dependency of JPA/Hibernate into the client.
@@ -60,7 +59,7 @@ public class User { * @since Envoy Server Standalone v0.1-alpha */ public User(envoy.data.User user) { - id = user.getId(); + id = user.getID(); name = user.getName(); status = user.getStatus(); } diff --git a/src/main/java/envoy/server/processors/ContactOperationProcessor.java b/src/main/java/envoy/server/processors/ContactOperationProcessor.java index 3c6c6d8..e0f0645 100755 --- a/src/main/java/envoy/server/processors/ContactOperationProcessor.java +++ b/src/main/java/envoy/server/processors/ContactOperationProcessor.java @@ -26,7 +26,7 @@ public class ContactOperationProcessor implements ObjectProcessor { +public class IDGeneratorRequestProcessor implements ObjectProcessor { private static final long ID_RANGE = 200; @Override - public Class getInputClass() { return IdGeneratorRequest.class; } + public Class getInputClass() { return IDGeneratorRequest.class; } @Override - public void process(IdGeneratorRequest input, long socketId, ObjectWriteProxy writeProxy) throws IOException { + public void process(IDGeneratorRequest input, long socketId, ObjectWriteProxy writeProxy) throws IOException { System.out.println("Received id generation request."); ConfigItem currentId = PersistenceManager.getInstance().getConfigItemById("currentMessageId"); - IdGenerator generator = new IdGenerator(Integer.parseInt(currentId.getValue()), ID_RANGE); + IDGenerator generator = new IDGenerator(Integer.parseInt(currentId.getValue()), ID_RANGE); currentId.setValue(String.valueOf(Integer.parseInt(currentId.getValue()) + ID_RANGE)); PersistenceManager.getInstance().updateConfigItem(currentId); diff --git a/src/main/java/envoy/server/processors/MessageProcessor.java b/src/main/java/envoy/server/processors/MessageProcessor.java index 1a62829..13dc49a 100755 --- a/src/main/java/envoy/server/processors/MessageProcessor.java +++ b/src/main/java/envoy/server/processors/MessageProcessor.java @@ -26,21 +26,21 @@ public class MessageProcessor implements ObjectProcessor { ConnectionManager connectionManager = ConnectionManager.getInstance(); message.nextStatus(); - if (connectionManager.isOnline(message.getRecipientId())) try { + if (connectionManager.isOnline(message.getRecipientID())) try { // If recipient is online, send the message directly - writeProxy.write(connectionManager.getSocketId(message.getRecipientId()), message); + writeProxy.write(connectionManager.getSocketId(message.getRecipientID()), message); // Update the message status to RECEIVED message.setReceivedDate(new Date()); message.nextStatus(); writeProxy.write(socketId, new MessageStatusChangeEvent(message)); } catch (IOException e) { - System.err.println("Recipient online. Failed to send message" + message.getId()); + System.err.println("Recipient online. Failed to send message" + message.getID()); e.printStackTrace(); } PersistenceManager.getInstance().addMessage(new envoy.server.data.Message(message)); } - + @Override public Class getInputClass() { return Message.class; } } diff --git a/src/main/java/envoy/server/processors/MessageStatusChangeProcessor.java b/src/main/java/envoy/server/processors/MessageStatusChangeProcessor.java index b01772e..80c9ceb 100755 --- a/src/main/java/envoy/server/processors/MessageStatusChangeProcessor.java +++ b/src/main/java/envoy/server/processors/MessageStatusChangeProcessor.java @@ -27,7 +27,7 @@ public class MessageStatusChangeProcessor implements ObjectProcessor