Assign ID to message
This commit is contained in:
parent
cbf1d040ef
commit
e04c154859
@ -11,6 +11,7 @@ public class Message {
|
||||
private Email from;
|
||||
private String subject;
|
||||
private String data;
|
||||
private Integer id;
|
||||
|
||||
public Message() {
|
||||
}
|
||||
@ -71,6 +72,14 @@ public class Message {
|
||||
this.data = data;
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "from " + getFrom().toString() + "\n" +
|
||||
|
||||
@ -110,6 +110,7 @@ public class DMTPConnection implements Runnable {
|
||||
|
||||
private synchronized void storeMessage() throws UnknownRecipientException {
|
||||
logger.info("Storing message " + msg.toString());
|
||||
this.msg.setId(MailboxServer.id++);
|
||||
String errorUnknownRecipient = "";
|
||||
for (Email recipient : this.msg.getTo()) {
|
||||
if (this.messageStorage.containsKey(recipient)) {
|
||||
|
||||
@ -29,6 +29,8 @@ public class MailboxServer implements IMailboxServer, Runnable {
|
||||
private final ConcurrentHashMap<Email, LinkedList<Message>> messageStorage = new ConcurrentHashMap<>();
|
||||
private final ConcurrentHashMap<String, String> userStorage = new ConcurrentHashMap<>();
|
||||
|
||||
public static volatile Integer id;
|
||||
|
||||
/**
|
||||
* Creates a new server instance.
|
||||
*
|
||||
@ -51,6 +53,8 @@ public class MailboxServer implements IMailboxServer, Runnable {
|
||||
messageStorage.put(current, new LinkedList<>());
|
||||
}
|
||||
|
||||
id = 0;
|
||||
|
||||
this.shell = new Shell(in, out);
|
||||
this.shell.register(this);
|
||||
this.shell.setPrompt("Mailboxserver> ");
|
||||
@ -78,7 +82,6 @@ public class MailboxServer implements IMailboxServer, Runnable {
|
||||
@Command
|
||||
@Override
|
||||
public void shutdown() {
|
||||
// TODO shutdown DMTPListener
|
||||
// TODO shutdown DMAPListener
|
||||
try {
|
||||
if (dmtpServerSocket != null)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user