Added database support to forward messages (#30)

* Added server support for forwarding messages

* added newline at EOF for any file not having one at its end
This commit is contained in:
delvh 2020-03-23 22:12:27 +01:00 committed by GitHub
parent c1dd4fa9fb
commit 9020598335
46 changed files with 31 additions and 21 deletions

1
.classpath Normal file → Executable file
View File

@ -3,7 +3,6 @@
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER"> <classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
<attributes> <attributes>
<attribute name="maven.pomderived" value="true"/> <attribute name="maven.pomderived" value="true"/>
<attribute name="module" value="true"/>
</attributes> </attributes>
</classpathentry> </classpathentry>
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources"> <classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">

0
.github/ISSUE_TEMPLATE/bug_report.md vendored Normal file → Executable file
View File

0
.github/ISSUE_TEMPLATE/feature_request.md vendored Normal file → Executable file
View File

0
.github/PULL_REQUEST_TEMPLATE/bugfix.md vendored Normal file → Executable file
View File

0
.github/PULL_REQUEST_TEMPLATE/feature_integration.md vendored Normal file → Executable file
View File

0
.github/PULL_REQUEST_TEMPLATE/javadoc_upgrade.md vendored Normal file → Executable file
View File

0
.github/workflows/maven.yml vendored Normal file → Executable file
View File

0
.github/workflows/stale.yml vendored Normal file → Executable file
View File

0
.gitignore vendored Normal file → Executable file
View File

0
.project Normal file → Executable file
View File

0
.settings/org.eclipse.core.resources.prefs Normal file → Executable file
View File

0
.settings/org.eclipse.jdt.core.prefs Normal file → Executable file
View File

0
.settings/org.eclipse.jdt.ui.prefs Normal file → Executable file
View File

0
.settings/org.eclipse.jpt.core.prefs Normal file → Executable file
View File

0
.settings/org.eclipse.m2e.core.prefs Normal file → Executable file
View File

View File

View File

0
.settings/org.hibernate.eclipse.console.prefs Normal file → Executable file
View File

0
CODE_OF_CONDUCT.md Normal file → Executable file
View File

0
CONTRIBUTING.md Normal file → Executable file
View File

0
LICENSE Normal file → Executable file
View File

0
README.md Normal file → Executable file
View File

2
pom.xml Normal file → Executable file
View File

@ -89,4 +89,4 @@
</plugin> </plugin>
</plugins> </plugins>
</build> </build>
</project> </project>

2
src/main/java/envoy/server/Startup.java Normal file → Executable file
View File

@ -58,4 +58,4 @@ public class Startup {
PersistenceManager persMan = PersistenceManager.getInstance(); PersistenceManager persMan = PersistenceManager.getInstance();
if (persMan.getConfigItemById("currentMessageId") == null) persMan.addConfigItem(new ConfigItem("currentMessageId", "0")); if (persMan.getConfigItemById("currentMessageId") == null) persMan.addConfigItem(new ConfigItem("currentMessageId", "0"));
} }
} }

0
src/main/java/envoy/server/data/ConfigItem.java Normal file → Executable file
View File

21
src/main/java/envoy/server/data/Message.java Normal file → Executable file
View File

@ -47,9 +47,10 @@ public class Message {
@Temporal(TemporalType.TIMESTAMP) @Temporal(TemporalType.TIMESTAMP)
private Date readDate; private Date readDate;
private envoy.data.Message.MessageStatus status;
private String text; private String text;
private envoy.data.Message.MessageStatus status;
private byte[] attachment; private byte[] attachment;
private boolean forwarded;
/** /**
* The constructor for a database object. * The constructor for a database object.
@ -60,7 +61,7 @@ public class Message {
/** /**
* Constructs a database message from a common message. * Constructs a database message from a common message.
* *
* @param message the {@link envoy.data.Message} to convert into a database * @param message the {@link envoy.data.Message} to convert into a database
* {@link Message} * {@link Message}
* @since Envoy Server Standalone v0.1-alpha * @since Envoy Server Standalone v0.1-alpha
@ -75,12 +76,13 @@ public class Message {
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();
// TODO: attachment = message.getAttachment().toByteArray();DOES NOT WORK YET // TODO: attachment = message.getAttachment().toByteArray();DOES NOT WORK YET
} }
/** /**
* Converts this message into an instance of {@link envoy.data.Message}. * Converts this message into an instance of {@link envoy.data.Message}.
* *
* @return a {@link envoy.data.Message} containing the same values as this * @return a {@link envoy.data.Message} containing the same values as this
* message * message
* @since Envoy Server Standalone v0.1-alpha * @since Envoy Server Standalone v0.1-alpha
@ -90,6 +92,7 @@ public class Message {
envoy.data.Message message = new MessageBuilder(sender.getId(), recipient.getId(), id).setText(text) envoy.data.Message message = new MessageBuilder(sender.getId(), recipient.getId(), id).setText(text)
.setDate(creationDate) .setDate(creationDate)
.setStatus(status) .setStatus(status)
.setForwarded(forwarded)
.build(); .build();
message.setReceivedDate(receivedDate); message.setReceivedDate(receivedDate);
message.setReadDate(readDate); message.setReadDate(readDate);
@ -210,4 +213,16 @@ public class Message {
* @since Envoy Server Standalone v0.1-alpha * @since Envoy Server Standalone v0.1-alpha
*/ */
public void setAttachment(byte[] attachment) { this.attachment = attachment; } public void setAttachment(byte[] attachment) { this.attachment = attachment; }
/**
* @return whether this message is a forwarded message
* @since Envoy Server Standalone v0.1-alpha
*/
public boolean isForwarded() { return forwarded; }
/**
* @param forwarded this message should be a forwarded message.
* @since Envoy Server Standalone v0.1-alpha
*/
public void setForwarded(boolean forwarded) { this.forwarded = forwarded; }
} }

View File

5
src/main/java/envoy/server/data/User.java Normal file → Executable file
View File

@ -46,15 +46,14 @@ public class User {
private List<User> contacts; private List<User> contacts;
/** /**
* Creates an instance of @link{User}. * Creates an instance of {@link User}.
* Solely used for JPA/ Hibernate
* *
* @since Envoy Server Standalone v0.1-alpha * @since Envoy Server Standalone v0.1-alpha
*/ */
public User() {} public User() {}
/** /**
* Creates an instance of @link{User}. * Creates an instance of {@link User}.
* *
* @param user the {@link envoy.data.User} to convert * @param user the {@link envoy.data.User} to convert
* @since Envoy Server Standalone v0.1-alpha * @since Envoy Server Standalone v0.1-alpha

2
src/main/java/envoy/server/data/package-info.java Normal file → Executable file
View File

@ -6,4 +6,4 @@
* @author Maximilian K&auml;fer * @author Maximilian K&auml;fer
* @since Envoy v0.1-alpha * @since Envoy v0.1-alpha
*/ */
package envoy.server.data; package envoy.server.data;

0
src/main/java/envoy/server/net/ConnectionManager.java Normal file → Executable file
View File

View File

@ -57,4 +57,4 @@ public class ObjectMessageProcessor implements IMessageProcessor {
e.printStackTrace(); e.printStackTrace();
} }
} }
} }

View File

@ -5,10 +5,7 @@ import java.nio.ByteBuffer;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import com.jenkov.nioserver.IMessageReader; import com.jenkov.nioserver.*;
import com.jenkov.nioserver.Message;
import com.jenkov.nioserver.MessageBuffer;
import com.jenkov.nioserver.Socket;
import envoy.util.SerializationUtils; import envoy.util.SerializationUtils;
@ -71,4 +68,4 @@ public class ObjectMessageReader implements IMessageReader {
} while (nextMessage.length >= length); } while (nextMessage.length >= length);
} }
} }

0
src/main/java/envoy/server/net/ObjectWriteProxy.java Normal file → Executable file
View File

2
src/main/java/envoy/server/net/package-info.java Normal file → Executable file
View File

@ -6,4 +6,4 @@
* @author Maximilian K&auml;fer * @author Maximilian K&auml;fer
* @since Envoy v0.1-alpha * @since Envoy v0.1-alpha
*/ */
package envoy.server.net; package envoy.server.net;

4
src/main/java/envoy/server/package-info.java Normal file → Executable file
View File

@ -1,9 +1,9 @@
/** /**
* This package contains the class that manages application startup. * This package contains the class that manages application startup.
* *
* @author Kai S. K. Engelbart * @author Kai S. K. Engelbart
* @author Leon Hofmeister * @author Leon Hofmeister
* @author Maximilian K&auml;fer * @author Maximilian K&auml;fer
* @since Envoy Server Standalone v0.1-alpha * @since Envoy Server Standalone v0.1-alpha
*/ */
package envoy.server; package envoy.server;

View File

View File

View File

View File

View File

@ -32,4 +32,4 @@ public interface ObjectProcessor<T> {
* @since Envoy Server Standalone v0.1-alpha * @since Envoy Server Standalone v0.1-alpha
*/ */
void process(T input, long socketId, ObjectWriteProxy writeProxy) throws IOException; void process(T input, long socketId, ObjectWriteProxy writeProxy) throws IOException;
} }

View File

View File

@ -7,4 +7,4 @@
* @author Maximilian K&auml;fer * @author Maximilian K&auml;fer
* @since Envoy v0.1-alpha * @since Envoy v0.1-alpha
*/ */
package envoy.server.processors; package envoy.server.processors;

0
src/main/java/module-info.java Normal file → Executable file
View File

0
src/main/resources/META-INF/persistence.xml Normal file → Executable file
View File