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