Refactored every identifier to fit the new naming convention, pom.xml
This commit is contained in:
parent
24b7e15ff2
commit
732a2d49e6
2
pom.xml
2
pom.xml
@ -28,7 +28,7 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.informatik-ag-ngl</groupId>
|
<groupId>com.github.informatik-ag-ngl</groupId>
|
||||||
<artifactId>envoy-common</artifactId>
|
<artifactId>envoy-common</artifactId>
|
||||||
<version>f~groups-SNAPSHOT</version>
|
<version>develop-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.informatik-ag-ngl</groupId>
|
<groupId>com.github.informatik-ag-ngl</groupId>
|
||||||
|
@ -76,14 +76,14 @@ public class Message {
|
|||||||
*/
|
*/
|
||||||
public Message(envoy.data.Message message) {
|
public Message(envoy.data.Message message) {
|
||||||
PersistenceManager persMan = PersistenceManager.getInstance();
|
PersistenceManager persMan = PersistenceManager.getInstance();
|
||||||
id = message.getId();
|
id = message.getID();
|
||||||
status = message.getStatus();
|
status = message.getStatus();
|
||||||
text = message.getText();
|
text = message.getText();
|
||||||
creationDate = message.getCreationDate();
|
creationDate = message.getCreationDate();
|
||||||
receivedDate = message.getReceivedDate();
|
receivedDate = message.getReceivedDate();
|
||||||
readDate = message.getReadDate();
|
readDate = message.getReadDate();
|
||||||
sender = persMan.getUserById(message.getSenderId());
|
sender = persMan.getUserById(message.getSenderID());
|
||||||
recipient = persMan.getUserById(message.getRecipientId());
|
recipient = persMan.getUserById(message.getRecipientID());
|
||||||
forwarded = message.isForwarded();
|
forwarded = message.isForwarded();
|
||||||
// TODO: attachment = message.getAttachment().toByteArray();DOES NOT WORK YET
|
// TODO: attachment = message.getAttachment().toByteArray();DOES NOT WORK YET
|
||||||
}
|
}
|
||||||
|
@ -26,7 +26,7 @@ public class ContactOperationProcessor implements ObjectProcessor<ContactOperati
|
|||||||
switch (evt.getOperationType()) {
|
switch (evt.getOperationType()) {
|
||||||
case ADD:
|
case ADD:
|
||||||
final long userId = ConnectionManager.getInstance().getUserIdBySocketId(socketId);
|
final long userId = ConnectionManager.getInstance().getUserIdBySocketId(socketId);
|
||||||
final long contactId = evt.get().getId();
|
final long contactId = evt.get().getID();
|
||||||
|
|
||||||
System.out.printf("Adding user %s to the contact list of user %d.%n", evt.get(), userId);
|
System.out.printf("Adding user %s to the contact list of user %d.%n", evt.get(), userId);
|
||||||
PersistenceManager.getInstance().addUserContact(userId, contactId);
|
PersistenceManager.getInstance().addUserContact(userId, contactId);
|
||||||
|
@ -30,7 +30,7 @@ public class MessageProcessor implements ObjectProcessor<Message> {
|
|||||||
|
|
||||||
message.nextStatus();
|
message.nextStatus();
|
||||||
ConnectionManager connectionManager = ConnectionManager.getInstance();
|
ConnectionManager connectionManager = ConnectionManager.getInstance();
|
||||||
Contact recipient = PersistenceManager.getInstance().getContactById(message.getId());
|
Contact recipient = PersistenceManager.getInstance().getContactById(message.getID());
|
||||||
|
|
||||||
if (recipient instanceof envoy.server.data.User) {
|
if (recipient instanceof envoy.server.data.User) {
|
||||||
System.out.println("The received message is a direct message.");
|
System.out.println("The received message is a direct message.");
|
||||||
@ -39,15 +39,15 @@ public class MessageProcessor implements ObjectProcessor<Message> {
|
|||||||
try {
|
try {
|
||||||
writeProxy.write(socketId, new MessageStatusChangeEvent(message));
|
writeProxy.write(socketId, new MessageStatusChangeEvent(message));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
System.err.println("Could not send messageStatusChangeEvent to the sender of this message with ID: " + message.getId());
|
System.err.println("Could not send messageStatusChangeEvent to the sender of this message with ID: " + message.getID());
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
System.out.println("The received message is a group message.");
|
System.out.println("The received message is a group message.");
|
||||||
final var members = PersistenceManager.getInstance().getGroupById(message.getRecipientId()).getMembers();
|
final var members = PersistenceManager.getInstance().getGroupById(message.getRecipientID()).getMembers();
|
||||||
final var generator = IDGeneratorRequestProcessor.createIDGenerator(members.size());
|
final var generator = IDGeneratorRequestProcessor.createIDGenerator(members.size());
|
||||||
members.forEach(user -> {
|
members.forEach(user -> {
|
||||||
envoy.data.Message returnMessage = new MessageBuilder(message.getRecipientId(), user.getID(), generator)
|
envoy.data.Message returnMessage = new MessageBuilder(message.getRecipientID(), user.getID(), generator)
|
||||||
.setDate(message.getCreationDate())
|
.setDate(message.getCreationDate())
|
||||||
.setText(message.getText())
|
.setText(message.getText())
|
||||||
.setAttachment(message.getAttachment())
|
.setAttachment(message.getAttachment())
|
||||||
@ -64,15 +64,15 @@ public class MessageProcessor implements ObjectProcessor<Message> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void sendToUser(ConnectionManager connectionManager, Message message, ObjectWriteProxy writeProxy) {
|
private void sendToUser(ConnectionManager connectionManager, Message message, ObjectWriteProxy writeProxy) {
|
||||||
if (connectionManager.isOnline(message.getRecipientId())) try {
|
if (connectionManager.isOnline(message.getRecipientID())) try {
|
||||||
// If recipient is online, send the message directly
|
// 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
|
// Update the message status to RECEIVED
|
||||||
message.setReceivedDate(new Date());
|
message.setReceivedDate(new Date());
|
||||||
message.nextStatus();
|
message.nextStatus();
|
||||||
|
|
||||||
} catch (IOException e) {
|
} 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();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ public class MessageStatusChangeProcessor implements ObjectProcessor<MessageStat
|
|||||||
// Any other status than READ is not supposed to be sent to the server
|
// Any other status than READ is not supposed to be sent to the server
|
||||||
if (input.get() != MessageStatus.READ) throw new IOException(new EnvoyException("Message " + input + " has an invalid status"));
|
if (input.get() != MessageStatus.READ) throw new IOException(new EnvoyException("Message " + input + " has an invalid status"));
|
||||||
|
|
||||||
envoy.server.data.Message msg = persistenceManager.getMessageById(input.getId());
|
envoy.server.data.Message msg = persistenceManager.getMessageById(input.getID());
|
||||||
msg.setStatus(input.get());
|
msg.setStatus(input.get());
|
||||||
msg.setReadDate(input.getDate());
|
msg.setReadDate(input.getDate());
|
||||||
persistenceManager.updateMessage(msg);
|
persistenceManager.updateMessage(msg);
|
||||||
|
@ -30,7 +30,7 @@ public class UserStatusChangeProcessor implements ObjectProcessor<UserStatusChan
|
|||||||
@Override
|
@Override
|
||||||
public void process(UserStatusChangeEvent input, long socketId, ObjectWriteProxy writeProxy) throws IOException {
|
public void process(UserStatusChangeEvent input, long socketId, ObjectWriteProxy writeProxy) throws IOException {
|
||||||
// new status should not equal old status
|
// new status should not equal old status
|
||||||
if (input.get().equals(persistenceManager.getUserById(input.getId()).getStatus())) {
|
if (input.get().equals(persistenceManager.getUserById(input.getID()).getStatus())) {
|
||||||
System.out.println("Received an unnecessary UserStatusChangeEvent");
|
System.out.println("Received an unnecessary UserStatusChangeEvent");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -58,7 +58,7 @@ public class UserStatusChangeProcessor implements ObjectProcessor<UserStatusChan
|
|||||||
* @param evt the {@link UserStatusChangeEvent}
|
* @param evt the {@link UserStatusChangeEvent}
|
||||||
* @since Envoy Server Standalone v0.1-alpha
|
* @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
|
* notifies active contacts of this {@link User} that his {@link UserStatus} has
|
||||||
@ -75,7 +75,7 @@ public class UserStatusChangeProcessor implements ObjectProcessor<UserStatusChan
|
|||||||
if (connectionManager.isOnline(contact.getID())) writeProxy.write(connectionManager.getSocketId(contact.getID()), evt);
|
if (connectionManager.isOnline(contact.getID())) writeProxy.write(connectionManager.getSocketId(contact.getID()), evt);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
System.err.println("Could not notify online contacts of user " + evt.getId() + " that his status has been changed");
|
System.err.println("Could not notify online contacts of user " + evt.getID() + " that his status has been changed");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user