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:
parent
c1dd4fa9fb
commit
9020598335
1
.classpath
Normal file → Executable file
1
.classpath
Normal file → Executable file
@ -3,7 +3,6 @@
|
||||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
<attribute name="module" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
|
||||
|
0
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file → Executable file
0
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Normal file → Executable file
0
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file → Executable file
0
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Normal file → Executable file
0
.github/PULL_REQUEST_TEMPLATE/bugfix.md
vendored
Normal file → Executable file
0
.github/PULL_REQUEST_TEMPLATE/bugfix.md
vendored
Normal file → Executable file
0
.github/PULL_REQUEST_TEMPLATE/feature_integration.md
vendored
Normal file → Executable file
0
.github/PULL_REQUEST_TEMPLATE/feature_integration.md
vendored
Normal file → Executable file
0
.github/PULL_REQUEST_TEMPLATE/javadoc_upgrade.md
vendored
Normal file → Executable file
0
.github/PULL_REQUEST_TEMPLATE/javadoc_upgrade.md
vendored
Normal file → Executable file
0
.github/workflows/maven.yml
vendored
Normal file → Executable file
0
.github/workflows/maven.yml
vendored
Normal file → Executable file
0
.github/workflows/stale.yml
vendored
Normal file → Executable file
0
.github/workflows/stale.yml
vendored
Normal file → Executable file
0
.gitignore
vendored
Normal file → Executable file
0
.gitignore
vendored
Normal file → Executable file
0
.settings/org.eclipse.core.resources.prefs
Normal file → Executable file
0
.settings/org.eclipse.core.resources.prefs
Normal file → Executable file
0
.settings/org.eclipse.jdt.core.prefs
Normal file → Executable file
0
.settings/org.eclipse.jdt.core.prefs
Normal file → Executable file
0
.settings/org.eclipse.jdt.ui.prefs
Normal file → Executable file
0
.settings/org.eclipse.jdt.ui.prefs
Normal file → Executable file
0
.settings/org.eclipse.jpt.core.prefs
Normal file → Executable file
0
.settings/org.eclipse.jpt.core.prefs
Normal file → Executable file
0
.settings/org.eclipse.m2e.core.prefs
Normal file → Executable file
0
.settings/org.eclipse.m2e.core.prefs
Normal file → Executable file
0
.settings/org.eclipse.wst.common.project.facet.core.prefs.xml
Normal file → Executable file
0
.settings/org.eclipse.wst.common.project.facet.core.prefs.xml
Normal file → Executable file
0
.settings/org.eclipse.wst.common.project.facet.core.xml
Normal file → Executable file
0
.settings/org.eclipse.wst.common.project.facet.core.xml
Normal file → Executable file
0
.settings/org.hibernate.eclipse.console.prefs
Normal file → Executable file
0
.settings/org.hibernate.eclipse.console.prefs
Normal file → Executable file
0
CODE_OF_CONDUCT.md
Normal file → Executable file
0
CODE_OF_CONDUCT.md
Normal file → Executable file
0
CONTRIBUTING.md
Normal file → Executable file
0
CONTRIBUTING.md
Normal file → Executable file
2
pom.xml
Normal file → Executable file
2
pom.xml
Normal file → Executable file
@ -89,4 +89,4 @@
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
||||
</project>
|
||||
|
2
src/main/java/envoy/server/Startup.java
Normal file → Executable file
2
src/main/java/envoy/server/Startup.java
Normal file → Executable file
@ -58,4 +58,4 @@ public class Startup {
|
||||
PersistenceManager persMan = PersistenceManager.getInstance();
|
||||
if (persMan.getConfigItemById("currentMessageId") == null) persMan.addConfigItem(new ConfigItem("currentMessageId", "0"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
0
src/main/java/envoy/server/data/ConfigItem.java
Normal file → Executable file
0
src/main/java/envoy/server/data/ConfigItem.java
Normal file → Executable file
21
src/main/java/envoy/server/data/Message.java
Normal file → Executable file
21
src/main/java/envoy/server/data/Message.java
Normal file → Executable file
@ -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; }
|
||||
}
|
||||
|
0
src/main/java/envoy/server/data/PersistenceManager.java
Normal file → Executable file
0
src/main/java/envoy/server/data/PersistenceManager.java
Normal file → Executable file
5
src/main/java/envoy/server/data/User.java
Normal file → Executable file
5
src/main/java/envoy/server/data/User.java
Normal file → Executable file
@ -46,15 +46,14 @@ public class User {
|
||||
private List<User> 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
|
||||
|
2
src/main/java/envoy/server/data/package-info.java
Normal file → Executable file
2
src/main/java/envoy/server/data/package-info.java
Normal file → Executable file
@ -6,4 +6,4 @@
|
||||
* @author Maximilian Käfer
|
||||
* @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
0
src/main/java/envoy/server/net/ConnectionManager.java
Normal file → Executable file
2
src/main/java/envoy/server/net/ObjectMessageProcessor.java
Normal file → Executable file
2
src/main/java/envoy/server/net/ObjectMessageProcessor.java
Normal file → Executable file
@ -57,4 +57,4 @@ public class ObjectMessageProcessor implements IMessageProcessor {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
7
src/main/java/envoy/server/net/ObjectMessageReader.java
Normal file → Executable file
7
src/main/java/envoy/server/net/ObjectMessageReader.java
Normal file → Executable file
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
0
src/main/java/envoy/server/net/ObjectWriteProxy.java
Normal file → Executable file
0
src/main/java/envoy/server/net/ObjectWriteProxy.java
Normal file → Executable file
2
src/main/java/envoy/server/net/package-info.java
Normal file → Executable file
2
src/main/java/envoy/server/net/package-info.java
Normal file → Executable file
@ -6,4 +6,4 @@
|
||||
* @author Maximilian Käfer
|
||||
* @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
4
src/main/java/envoy/server/package-info.java
Normal file → Executable file
@ -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;
|
||||
package envoy.server;
|
||||
|
0
src/main/java/envoy/server/processors/ContactOperationProcessor.java
Normal file → Executable file
0
src/main/java/envoy/server/processors/ContactOperationProcessor.java
Normal file → Executable file
0
src/main/java/envoy/server/processors/ContactsRequestEventProcessor.java
Normal file → Executable file
0
src/main/java/envoy/server/processors/ContactsRequestEventProcessor.java
Normal file → Executable file
0
src/main/java/envoy/server/processors/IdGeneratorRequestProcessor.java
Normal file → Executable file
0
src/main/java/envoy/server/processors/IdGeneratorRequestProcessor.java
Normal file → Executable file
0
src/main/java/envoy/server/processors/LoginCredentialProcessor.java
Normal file → Executable file
0
src/main/java/envoy/server/processors/LoginCredentialProcessor.java
Normal file → Executable file
0
src/main/java/envoy/server/processors/MessageProcessor.java
Normal file → Executable file
0
src/main/java/envoy/server/processors/MessageProcessor.java
Normal file → Executable file
0
src/main/java/envoy/server/processors/MessageStatusChangeProcessor.java
Normal file → Executable file
0
src/main/java/envoy/server/processors/MessageStatusChangeProcessor.java
Normal file → Executable file
2
src/main/java/envoy/server/processors/ObjectProcessor.java
Normal file → Executable file
2
src/main/java/envoy/server/processors/ObjectProcessor.java
Normal file → Executable file
@ -32,4 +32,4 @@ public interface ObjectProcessor<T> {
|
||||
* @since Envoy Server Standalone v0.1-alpha
|
||||
*/
|
||||
void process(T input, long socketId, ObjectWriteProxy writeProxy) throws IOException;
|
||||
}
|
||||
}
|
||||
|
0
src/main/java/envoy/server/processors/UserStatusChangeProcessor.java
Normal file → Executable file
0
src/main/java/envoy/server/processors/UserStatusChangeProcessor.java
Normal file → Executable file
2
src/main/java/envoy/server/processors/package-info.java
Normal file → Executable file
2
src/main/java/envoy/server/processors/package-info.java
Normal file → Executable file
@ -7,4 +7,4 @@
|
||||
* @author Maximilian Käfer
|
||||
* @since Envoy v0.1-alpha
|
||||
*/
|
||||
package envoy.server.processors;
|
||||
package envoy.server.processors;
|
||||
|
0
src/main/java/module-info.java
Normal file → Executable file
0
src/main/java/module-info.java
Normal file → Executable file
0
src/main/resources/META-INF/persistence.xml
Normal file → Executable file
0
src/main/resources/META-INF/persistence.xml
Normal file → Executable file
Reference in New Issue
Block a user