From 90205983352feb6eecae894af2ea59b9288f009d Mon Sep 17 00:00:00 2001 From: delvh Date: Mon, 23 Mar 2020 22:12:27 +0100 Subject: [PATCH] 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 --- .classpath | 1 - .github/ISSUE_TEMPLATE/bug_report.md | 0 .github/ISSUE_TEMPLATE/feature_request.md | 0 .github/PULL_REQUEST_TEMPLATE/bugfix.md | 0 .../feature_integration.md | 0 .../PULL_REQUEST_TEMPLATE/javadoc_upgrade.md | 0 .github/workflows/maven.yml | 0 .github/workflows/stale.yml | 0 .gitignore | 0 .project | 0 .settings/org.eclipse.core.resources.prefs | 0 .settings/org.eclipse.jdt.core.prefs | 0 .settings/org.eclipse.jdt.ui.prefs | 0 .settings/org.eclipse.jpt.core.prefs | 0 .settings/org.eclipse.m2e.core.prefs | 0 ...se.wst.common.project.facet.core.prefs.xml | 0 ....eclipse.wst.common.project.facet.core.xml | 0 .settings/org.hibernate.eclipse.console.prefs | 0 CODE_OF_CONDUCT.md | 0 CONTRIBUTING.md | 0 LICENSE | 0 README.md | 0 pom.xml | 2 +- src/main/java/envoy/server/Startup.java | 2 +- .../java/envoy/server/data/ConfigItem.java | 0 src/main/java/envoy/server/data/Message.java | 21 ++++++++++++++++--- .../envoy/server/data/PersistenceManager.java | 0 src/main/java/envoy/server/data/User.java | 5 ++--- .../java/envoy/server/data/package-info.java | 2 +- .../envoy/server/net/ConnectionManager.java | 0 .../server/net/ObjectMessageProcessor.java | 2 +- .../envoy/server/net/ObjectMessageReader.java | 7 ++----- .../envoy/server/net/ObjectWriteProxy.java | 0 .../java/envoy/server/net/package-info.java | 2 +- src/main/java/envoy/server/package-info.java | 4 ++-- .../processors/ContactOperationProcessor.java | 0 .../ContactsRequestEventProcessor.java | 0 .../IdGeneratorRequestProcessor.java | 0 .../processors/LoginCredentialProcessor.java | 0 .../server/processors/MessageProcessor.java | 0 .../MessageStatusChangeProcessor.java | 0 .../server/processors/ObjectProcessor.java | 2 +- .../processors/UserStatusChangeProcessor.java | 0 .../envoy/server/processors/package-info.java | 2 +- src/main/java/module-info.java | 0 src/main/resources/META-INF/persistence.xml | 0 46 files changed, 31 insertions(+), 21 deletions(-) mode change 100644 => 100755 .classpath mode change 100644 => 100755 .github/ISSUE_TEMPLATE/bug_report.md mode change 100644 => 100755 .github/ISSUE_TEMPLATE/feature_request.md mode change 100644 => 100755 .github/PULL_REQUEST_TEMPLATE/bugfix.md mode change 100644 => 100755 .github/PULL_REQUEST_TEMPLATE/feature_integration.md mode change 100644 => 100755 .github/PULL_REQUEST_TEMPLATE/javadoc_upgrade.md mode change 100644 => 100755 .github/workflows/maven.yml mode change 100644 => 100755 .github/workflows/stale.yml mode change 100644 => 100755 .gitignore mode change 100644 => 100755 .project mode change 100644 => 100755 .settings/org.eclipse.core.resources.prefs mode change 100644 => 100755 .settings/org.eclipse.jdt.core.prefs mode change 100644 => 100755 .settings/org.eclipse.jdt.ui.prefs mode change 100644 => 100755 .settings/org.eclipse.jpt.core.prefs mode change 100644 => 100755 .settings/org.eclipse.m2e.core.prefs mode change 100644 => 100755 .settings/org.eclipse.wst.common.project.facet.core.prefs.xml mode change 100644 => 100755 .settings/org.eclipse.wst.common.project.facet.core.xml mode change 100644 => 100755 .settings/org.hibernate.eclipse.console.prefs mode change 100644 => 100755 CODE_OF_CONDUCT.md mode change 100644 => 100755 CONTRIBUTING.md mode change 100644 => 100755 LICENSE mode change 100644 => 100755 README.md mode change 100644 => 100755 pom.xml mode change 100644 => 100755 src/main/java/envoy/server/Startup.java mode change 100644 => 100755 src/main/java/envoy/server/data/ConfigItem.java mode change 100644 => 100755 src/main/java/envoy/server/data/Message.java mode change 100644 => 100755 src/main/java/envoy/server/data/PersistenceManager.java mode change 100644 => 100755 src/main/java/envoy/server/data/User.java mode change 100644 => 100755 src/main/java/envoy/server/data/package-info.java mode change 100644 => 100755 src/main/java/envoy/server/net/ConnectionManager.java mode change 100644 => 100755 src/main/java/envoy/server/net/ObjectMessageProcessor.java mode change 100644 => 100755 src/main/java/envoy/server/net/ObjectMessageReader.java mode change 100644 => 100755 src/main/java/envoy/server/net/ObjectWriteProxy.java mode change 100644 => 100755 src/main/java/envoy/server/net/package-info.java mode change 100644 => 100755 src/main/java/envoy/server/package-info.java mode change 100644 => 100755 src/main/java/envoy/server/processors/ContactOperationProcessor.java mode change 100644 => 100755 src/main/java/envoy/server/processors/ContactsRequestEventProcessor.java mode change 100644 => 100755 src/main/java/envoy/server/processors/IdGeneratorRequestProcessor.java mode change 100644 => 100755 src/main/java/envoy/server/processors/LoginCredentialProcessor.java mode change 100644 => 100755 src/main/java/envoy/server/processors/MessageProcessor.java mode change 100644 => 100755 src/main/java/envoy/server/processors/MessageStatusChangeProcessor.java mode change 100644 => 100755 src/main/java/envoy/server/processors/ObjectProcessor.java mode change 100644 => 100755 src/main/java/envoy/server/processors/UserStatusChangeProcessor.java mode change 100644 => 100755 src/main/java/envoy/server/processors/package-info.java mode change 100644 => 100755 src/main/java/module-info.java mode change 100644 => 100755 src/main/resources/META-INF/persistence.xml diff --git a/.classpath b/.classpath old mode 100644 new mode 100755 index a093bb9..05e358d --- a/.classpath +++ b/.classpath @@ -3,7 +3,6 @@ - diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md old mode 100644 new mode 100755 diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md old mode 100644 new mode 100755 diff --git a/.github/PULL_REQUEST_TEMPLATE/bugfix.md b/.github/PULL_REQUEST_TEMPLATE/bugfix.md old mode 100644 new mode 100755 diff --git a/.github/PULL_REQUEST_TEMPLATE/feature_integration.md b/.github/PULL_REQUEST_TEMPLATE/feature_integration.md old mode 100644 new mode 100755 diff --git a/.github/PULL_REQUEST_TEMPLATE/javadoc_upgrade.md b/.github/PULL_REQUEST_TEMPLATE/javadoc_upgrade.md old mode 100644 new mode 100755 diff --git a/.github/workflows/maven.yml b/.github/workflows/maven.yml old mode 100644 new mode 100755 diff --git a/.github/workflows/stale.yml b/.github/workflows/stale.yml old mode 100644 new mode 100755 diff --git a/.gitignore b/.gitignore old mode 100644 new mode 100755 diff --git a/.project b/.project old mode 100644 new mode 100755 diff --git a/.settings/org.eclipse.core.resources.prefs b/.settings/org.eclipse.core.resources.prefs old mode 100644 new mode 100755 diff --git a/.settings/org.eclipse.jdt.core.prefs b/.settings/org.eclipse.jdt.core.prefs old mode 100644 new mode 100755 diff --git a/.settings/org.eclipse.jdt.ui.prefs b/.settings/org.eclipse.jdt.ui.prefs old mode 100644 new mode 100755 diff --git a/.settings/org.eclipse.jpt.core.prefs b/.settings/org.eclipse.jpt.core.prefs old mode 100644 new mode 100755 diff --git a/.settings/org.eclipse.m2e.core.prefs b/.settings/org.eclipse.m2e.core.prefs old mode 100644 new mode 100755 diff --git a/.settings/org.eclipse.wst.common.project.facet.core.prefs.xml b/.settings/org.eclipse.wst.common.project.facet.core.prefs.xml old mode 100644 new mode 100755 diff --git a/.settings/org.eclipse.wst.common.project.facet.core.xml b/.settings/org.eclipse.wst.common.project.facet.core.xml old mode 100644 new mode 100755 diff --git a/.settings/org.hibernate.eclipse.console.prefs b/.settings/org.hibernate.eclipse.console.prefs old mode 100644 new mode 100755 diff --git a/CODE_OF_CONDUCT.md b/CODE_OF_CONDUCT.md old mode 100644 new mode 100755 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md old mode 100644 new mode 100755 diff --git a/LICENSE b/LICENSE old mode 100644 new mode 100755 diff --git a/README.md b/README.md old mode 100644 new mode 100755 diff --git a/pom.xml b/pom.xml old mode 100644 new mode 100755 index edb27fa..046ec55 --- a/pom.xml +++ b/pom.xml @@ -89,4 +89,4 @@ - \ No newline at end of file + diff --git a/src/main/java/envoy/server/Startup.java b/src/main/java/envoy/server/Startup.java old mode 100644 new mode 100755 index 76e436a..d0c2730 --- a/src/main/java/envoy/server/Startup.java +++ b/src/main/java/envoy/server/Startup.java @@ -58,4 +58,4 @@ public class Startup { PersistenceManager persMan = PersistenceManager.getInstance(); if (persMan.getConfigItemById("currentMessageId") == null) persMan.addConfigItem(new ConfigItem("currentMessageId", "0")); } -} \ No newline at end of file +} diff --git a/src/main/java/envoy/server/data/ConfigItem.java b/src/main/java/envoy/server/data/ConfigItem.java old mode 100644 new mode 100755 diff --git a/src/main/java/envoy/server/data/Message.java b/src/main/java/envoy/server/data/Message.java old mode 100644 new mode 100755 index 7a33de0..e5f600c --- a/src/main/java/envoy/server/data/Message.java +++ b/src/main/java/envoy/server/data/Message.java @@ -47,9 +47,10 @@ public class Message { @Temporal(TemporalType.TIMESTAMP) private Date readDate; - private envoy.data.Message.MessageStatus status; private String text; + private envoy.data.Message.MessageStatus status; private byte[] attachment; + private boolean forwarded; /** * The constructor for a database object. @@ -60,7 +61,7 @@ public class Message { /** * Constructs a database message from a common message. - * + * * @param message the {@link envoy.data.Message} to convert into a database * {@link Message} * @since Envoy Server Standalone v0.1-alpha @@ -75,12 +76,13 @@ public class Message { readDate = message.getReadDate(); sender = persMan.getUserById(message.getSenderId()); recipient = persMan.getUserById(message.getRecipientId()); + forwarded = message.isForwarded(); // TODO: attachment = message.getAttachment().toByteArray();DOES NOT WORK YET } /** * Converts this message into an instance of {@link envoy.data.Message}. - * + * * @return a {@link envoy.data.Message} containing the same values as this * message * @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) .setDate(creationDate) .setStatus(status) + .setForwarded(forwarded) .build(); message.setReceivedDate(receivedDate); message.setReadDate(readDate); @@ -210,4 +213,16 @@ public class Message { * @since Envoy Server Standalone v0.1-alpha */ 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; } } diff --git a/src/main/java/envoy/server/data/PersistenceManager.java b/src/main/java/envoy/server/data/PersistenceManager.java old mode 100644 new mode 100755 diff --git a/src/main/java/envoy/server/data/User.java b/src/main/java/envoy/server/data/User.java old mode 100644 new mode 100755 index cb12b7e..6b26459 --- a/src/main/java/envoy/server/data/User.java +++ b/src/main/java/envoy/server/data/User.java @@ -46,15 +46,14 @@ public class User { private List contacts; /** - * Creates an instance of @link{User}. - * Solely used for JPA/ Hibernate + * Creates an instance of {@link User}. * * @since Envoy Server Standalone v0.1-alpha */ public User() {} /** - * Creates an instance of @link{User}. + * Creates an instance of {@link User}. * * @param user the {@link envoy.data.User} to convert * @since Envoy Server Standalone v0.1-alpha diff --git a/src/main/java/envoy/server/data/package-info.java b/src/main/java/envoy/server/data/package-info.java old mode 100644 new mode 100755 index 81b16a3..acbd83e --- a/src/main/java/envoy/server/data/package-info.java +++ b/src/main/java/envoy/server/data/package-info.java @@ -6,4 +6,4 @@ * @author Maximilian Käfer * @since Envoy v0.1-alpha */ -package envoy.server.data; \ No newline at end of file +package envoy.server.data; diff --git a/src/main/java/envoy/server/net/ConnectionManager.java b/src/main/java/envoy/server/net/ConnectionManager.java old mode 100644 new mode 100755 diff --git a/src/main/java/envoy/server/net/ObjectMessageProcessor.java b/src/main/java/envoy/server/net/ObjectMessageProcessor.java old mode 100644 new mode 100755 index 5f0d098..a35f955 --- a/src/main/java/envoy/server/net/ObjectMessageProcessor.java +++ b/src/main/java/envoy/server/net/ObjectMessageProcessor.java @@ -57,4 +57,4 @@ public class ObjectMessageProcessor implements IMessageProcessor { e.printStackTrace(); } } -} \ No newline at end of file +} diff --git a/src/main/java/envoy/server/net/ObjectMessageReader.java b/src/main/java/envoy/server/net/ObjectMessageReader.java old mode 100644 new mode 100755 index db0fee7..34c034b --- a/src/main/java/envoy/server/net/ObjectMessageReader.java +++ b/src/main/java/envoy/server/net/ObjectMessageReader.java @@ -5,10 +5,7 @@ import java.nio.ByteBuffer; import java.util.ArrayList; import java.util.List; -import com.jenkov.nioserver.IMessageReader; -import com.jenkov.nioserver.Message; -import com.jenkov.nioserver.MessageBuffer; -import com.jenkov.nioserver.Socket; +import com.jenkov.nioserver.*; import envoy.util.SerializationUtils; @@ -71,4 +68,4 @@ public class ObjectMessageReader implements IMessageReader { } while (nextMessage.length >= length); } -} \ No newline at end of file +} diff --git a/src/main/java/envoy/server/net/ObjectWriteProxy.java b/src/main/java/envoy/server/net/ObjectWriteProxy.java old mode 100644 new mode 100755 diff --git a/src/main/java/envoy/server/net/package-info.java b/src/main/java/envoy/server/net/package-info.java old mode 100644 new mode 100755 index 0c1e178..b527a76 --- a/src/main/java/envoy/server/net/package-info.java +++ b/src/main/java/envoy/server/net/package-info.java @@ -6,4 +6,4 @@ * @author Maximilian Käfer * @since Envoy v0.1-alpha */ -package envoy.server.net; \ No newline at end of file +package envoy.server.net; diff --git a/src/main/java/envoy/server/package-info.java b/src/main/java/envoy/server/package-info.java old mode 100644 new mode 100755 index 7297478..4994f65 --- a/src/main/java/envoy/server/package-info.java +++ b/src/main/java/envoy/server/package-info.java @@ -1,9 +1,9 @@ /** * This package contains the class that manages application startup. - * + * * @author Kai S. K. Engelbart * @author Leon Hofmeister * @author Maximilian Käfer * @since Envoy Server Standalone v0.1-alpha */ -package envoy.server; \ No newline at end of file +package envoy.server; diff --git a/src/main/java/envoy/server/processors/ContactOperationProcessor.java b/src/main/java/envoy/server/processors/ContactOperationProcessor.java old mode 100644 new mode 100755 diff --git a/src/main/java/envoy/server/processors/ContactsRequestEventProcessor.java b/src/main/java/envoy/server/processors/ContactsRequestEventProcessor.java old mode 100644 new mode 100755 diff --git a/src/main/java/envoy/server/processors/IdGeneratorRequestProcessor.java b/src/main/java/envoy/server/processors/IdGeneratorRequestProcessor.java old mode 100644 new mode 100755 diff --git a/src/main/java/envoy/server/processors/LoginCredentialProcessor.java b/src/main/java/envoy/server/processors/LoginCredentialProcessor.java old mode 100644 new mode 100755 diff --git a/src/main/java/envoy/server/processors/MessageProcessor.java b/src/main/java/envoy/server/processors/MessageProcessor.java old mode 100644 new mode 100755 diff --git a/src/main/java/envoy/server/processors/MessageStatusChangeProcessor.java b/src/main/java/envoy/server/processors/MessageStatusChangeProcessor.java old mode 100644 new mode 100755 diff --git a/src/main/java/envoy/server/processors/ObjectProcessor.java b/src/main/java/envoy/server/processors/ObjectProcessor.java old mode 100644 new mode 100755 index 00eabe9..91204b2 --- a/src/main/java/envoy/server/processors/ObjectProcessor.java +++ b/src/main/java/envoy/server/processors/ObjectProcessor.java @@ -32,4 +32,4 @@ public interface ObjectProcessor { * @since Envoy Server Standalone v0.1-alpha */ void process(T input, long socketId, ObjectWriteProxy writeProxy) throws IOException; -} \ No newline at end of file +} diff --git a/src/main/java/envoy/server/processors/UserStatusChangeProcessor.java b/src/main/java/envoy/server/processors/UserStatusChangeProcessor.java old mode 100644 new mode 100755 diff --git a/src/main/java/envoy/server/processors/package-info.java b/src/main/java/envoy/server/processors/package-info.java old mode 100644 new mode 100755 index 02a68a0..d96d161 --- a/src/main/java/envoy/server/processors/package-info.java +++ b/src/main/java/envoy/server/processors/package-info.java @@ -7,4 +7,4 @@ * @author Maximilian Käfer * @since Envoy v0.1-alpha */ -package envoy.server.processors; \ No newline at end of file +package envoy.server.processors; diff --git a/src/main/java/module-info.java b/src/main/java/module-info.java old mode 100644 new mode 100755 diff --git a/src/main/resources/META-INF/persistence.xml b/src/main/resources/META-INF/persistence.xml old mode 100644 new mode 100755