Merge remote-tracking branch 'server/develop' into develop
This commit is contained in:
commit
2bbdb82168
32
.classpath
Executable file
32
.classpath
Executable file
@ -0,0 +1,32 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<classpath>
|
||||||
|
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry excluding="**" kind="src" output="target/classes" path="src/main/resources">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry kind="src" output="target/classes" path="src/main/java">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="optional" value="true"/>
|
||||||
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry kind="src" output="target/test-classes" path="src/test/java">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="optional" value="true"/>
|
||||||
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
<attribute name="test" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-11">
|
||||||
|
<attributes>
|
||||||
|
<attribute name="maven.pomderived" value="true"/>
|
||||||
|
</attributes>
|
||||||
|
</classpathentry>
|
||||||
|
<classpathentry kind="output" path="target/classes"/>
|
||||||
|
</classpath>
|
1
.github/CODEOWNERS
vendored
Normal file
1
.github/CODEOWNERS
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
* @CyB3RC0nN0R
|
38
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Executable file
38
.github/ISSUE_TEMPLATE/bug_report.md
vendored
Executable file
@ -0,0 +1,38 @@
|
|||||||
|
---
|
||||||
|
name: Bug report
|
||||||
|
about: Create a report to help us improve
|
||||||
|
title: ''
|
||||||
|
labels: bug
|
||||||
|
assignees: CyB3RC0nN0R, delvh, DieGurke, derharry333
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**Describe the bug**
|
||||||
|
A clear and concise description of what the bug is.
|
||||||
|
|
||||||
|
**To Reproduce**
|
||||||
|
Steps to reproduce the behavior:
|
||||||
|
1. Go to '...'
|
||||||
|
2. Click on '....'
|
||||||
|
3. Scroll down to '....'
|
||||||
|
4. See error
|
||||||
|
|
||||||
|
**Expected behavior**
|
||||||
|
A clear and concise description of what you expected to happen.
|
||||||
|
|
||||||
|
**Screenshots**
|
||||||
|
If applicable, add screenshots to help explain your problem.
|
||||||
|
|
||||||
|
**Desktop (please complete the following information):**
|
||||||
|
- OS: [e.g. iOS]
|
||||||
|
- Browser [e.g. chrome, safari]
|
||||||
|
- Version [e.g. 22]
|
||||||
|
|
||||||
|
**Smartphone (please complete the following information):**
|
||||||
|
- Device: [e.g. iPhone6]
|
||||||
|
- OS: [e.g. iOS8.1]
|
||||||
|
- Browser [e.g. stock browser, safari]
|
||||||
|
- Version [e.g. 22]
|
||||||
|
|
||||||
|
**Additional context**
|
||||||
|
Add any other context about the problem here.
|
20
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Executable file
20
.github/ISSUE_TEMPLATE/feature_request.md
vendored
Executable file
@ -0,0 +1,20 @@
|
|||||||
|
---
|
||||||
|
name: Feature request
|
||||||
|
about: Suggest an idea for this project
|
||||||
|
title: ''
|
||||||
|
labels: enhancement
|
||||||
|
assignees: CyB3RC0nN0R, delvh, DieGurke
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**Is your feature request related to a problem? Please describe.**
|
||||||
|
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
|
||||||
|
|
||||||
|
**Describe the solution you'd like**
|
||||||
|
A clear and concise description of what you want to happen.
|
||||||
|
|
||||||
|
**Describe alternatives you've considered**
|
||||||
|
A clear and concise description of any alternative solutions or features you've considered.
|
||||||
|
|
||||||
|
**Additional context**
|
||||||
|
Add any other context or screenshots about the feature request here.
|
10
.github/PULL_REQUEST_TEMPLATE/bugfix.md
vendored
Executable file
10
.github/PULL_REQUEST_TEMPLATE/bugfix.md
vendored
Executable file
@ -0,0 +1,10 @@
|
|||||||
|
---
|
||||||
|
name: Bug fix
|
||||||
|
title: Fixed Bug
|
||||||
|
labels: bug
|
||||||
|
assignees: CyB3RC0nN0R, delvh, DieGurke
|
||||||
|
reviewers: CyB3RC0nN0R, delvh
|
||||||
|
projects: Envoy
|
||||||
|
milestone: Envoy v0.3-alpha
|
||||||
|
---
|
||||||
|
Fixes #{issue}
|
9
.github/PULL_REQUEST_TEMPLATE/feature_integration.md
vendored
Executable file
9
.github/PULL_REQUEST_TEMPLATE/feature_integration.md
vendored
Executable file
@ -0,0 +1,9 @@
|
|||||||
|
---
|
||||||
|
name: Feature integration
|
||||||
|
title: Added feature
|
||||||
|
labels: enhancement
|
||||||
|
assignees: CyB3RC0nN0R, delvh, DieGurke
|
||||||
|
reviewers: CyB3RC0nN0R, delvh
|
||||||
|
projects: Envoy
|
||||||
|
milestone: Envoy v0.3-alpha
|
||||||
|
---
|
9
.github/PULL_REQUEST_TEMPLATE/javadoc_upgrade.md
vendored
Executable file
9
.github/PULL_REQUEST_TEMPLATE/javadoc_upgrade.md
vendored
Executable file
@ -0,0 +1,9 @@
|
|||||||
|
---
|
||||||
|
name: Updated Javadoc
|
||||||
|
title: Updated Javadoc
|
||||||
|
labels: documentation
|
||||||
|
assignees: CyB3RC0nN0R, delvh
|
||||||
|
reviewers: CyB3RC0nN0R, delvh
|
||||||
|
projects: Envoy
|
||||||
|
milestone: Envoy v0.3-alpha
|
||||||
|
---
|
17
.github/workflows/maven.yml
vendored
Executable file
17
.github/workflows/maven.yml
vendored
Executable file
@ -0,0 +1,17 @@
|
|||||||
|
name: Java CI
|
||||||
|
|
||||||
|
on: [push]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v1
|
||||||
|
- name: Set up JDK 11
|
||||||
|
uses: actions/setup-java@v1
|
||||||
|
with:
|
||||||
|
java-version: 11
|
||||||
|
- name: Build with Maven
|
||||||
|
run: mvn -B package --file pom.xml
|
22
.github/workflows/stale.yml
vendored
Executable file
22
.github/workflows/stale.yml
vendored
Executable file
@ -0,0 +1,22 @@
|
|||||||
|
name: Mark stale issues and pull requests
|
||||||
|
|
||||||
|
on:
|
||||||
|
schedule:
|
||||||
|
- cron: "0 0 * * *"
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
stale:
|
||||||
|
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/stale@v1
|
||||||
|
with:
|
||||||
|
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
stale-issue-message: 'Stale issue message'
|
||||||
|
stale-pr-message: 'Stale pull request message'
|
||||||
|
stale-issue-label: 'no-issue-activity'
|
||||||
|
days-before-stale: 60
|
||||||
|
days-before-close: 7
|
||||||
|
stale-pr-label: 'no-pr-activity'
|
||||||
|
operations-per-run: 30
|
1
.gitignore
vendored
Executable file
1
.gitignore
vendored
Executable file
@ -0,0 +1 @@
|
|||||||
|
/target/
|
40
.project
Executable file
40
.project
Executable file
@ -0,0 +1,40 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<projectDescription>
|
||||||
|
<name>envoy-server-standalone</name>
|
||||||
|
<comment></comment>
|
||||||
|
<projects>
|
||||||
|
</projects>
|
||||||
|
<buildSpec>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.wst.common.project.facet.core.builder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.wst.validation.validationbuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.hibernate.eclipse.console.hibernateBuilder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
<buildCommand>
|
||||||
|
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||||
|
<arguments>
|
||||||
|
</arguments>
|
||||||
|
</buildCommand>
|
||||||
|
</buildSpec>
|
||||||
|
<natures>
|
||||||
|
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||||
|
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
||||||
|
<nature>org.eclipse.wst.common.project.facet.core.nature</nature>
|
||||||
|
<nature>org.hibernate.eclipse.console.hibernateNature</nature>
|
||||||
|
</natures>
|
||||||
|
</projectDescription>
|
6
.settings/org.eclipse.core.resources.prefs
Executable file
6
.settings/org.eclipse.core.resources.prefs
Executable file
@ -0,0 +1,6 @@
|
|||||||
|
eclipse.preferences.version=1
|
||||||
|
encoding//src/main/java=UTF-8
|
||||||
|
encoding//src/main/resources=UTF-8
|
||||||
|
encoding//src/test/java=UTF-8
|
||||||
|
encoding//src/test/resources=UTF-8
|
||||||
|
encoding/<project>=UTF-8
|
476
.settings/org.eclipse.jdt.core.prefs
Executable file
476
.settings/org.eclipse.jdt.core.prefs
Executable file
@ -0,0 +1,476 @@
|
|||||||
|
eclipse.preferences.version=1
|
||||||
|
org.eclipse.jdt.core.compiler.annotation.inheritNullAnnotations=disabled
|
||||||
|
org.eclipse.jdt.core.compiler.annotation.missingNonNullByDefaultAnnotation=ignore
|
||||||
|
org.eclipse.jdt.core.compiler.annotation.nonnull=org.eclipse.jdt.annotation.NonNull
|
||||||
|
org.eclipse.jdt.core.compiler.annotation.nonnull.secondary=
|
||||||
|
org.eclipse.jdt.core.compiler.annotation.nonnullbydefault=org.eclipse.jdt.annotation.NonNullByDefault
|
||||||
|
org.eclipse.jdt.core.compiler.annotation.nonnullbydefault.secondary=
|
||||||
|
org.eclipse.jdt.core.compiler.annotation.nullable=org.eclipse.jdt.annotation.Nullable
|
||||||
|
org.eclipse.jdt.core.compiler.annotation.nullable.secondary=
|
||||||
|
org.eclipse.jdt.core.compiler.annotation.nullanalysis=disabled
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.targetPlatform=11
|
||||||
|
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||||
|
org.eclipse.jdt.core.compiler.compliance=11
|
||||||
|
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||||
|
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||||
|
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||||
|
org.eclipse.jdt.core.compiler.problem.APILeak=warning
|
||||||
|
org.eclipse.jdt.core.compiler.problem.annotationSuperInterface=warning
|
||||||
|
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||||
|
org.eclipse.jdt.core.compiler.problem.autoboxing=ignore
|
||||||
|
org.eclipse.jdt.core.compiler.problem.comparingIdentical=warning
|
||||||
|
org.eclipse.jdt.core.compiler.problem.deadCode=warning
|
||||||
|
org.eclipse.jdt.core.compiler.problem.deprecation=warning
|
||||||
|
org.eclipse.jdt.core.compiler.problem.deprecationInDeprecatedCode=disabled
|
||||||
|
org.eclipse.jdt.core.compiler.problem.deprecationWhenOverridingDeprecatedMethod=disabled
|
||||||
|
org.eclipse.jdt.core.compiler.problem.discouragedReference=warning
|
||||||
|
org.eclipse.jdt.core.compiler.problem.emptyStatement=info
|
||||||
|
org.eclipse.jdt.core.compiler.problem.enablePreviewFeatures=disabled
|
||||||
|
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||||
|
org.eclipse.jdt.core.compiler.problem.explicitlyClosedAutoCloseable=warning
|
||||||
|
org.eclipse.jdt.core.compiler.problem.fallthroughCase=ignore
|
||||||
|
org.eclipse.jdt.core.compiler.problem.fatalOptionalError=disabled
|
||||||
|
org.eclipse.jdt.core.compiler.problem.fieldHiding=ignore
|
||||||
|
org.eclipse.jdt.core.compiler.problem.finalParameterBound=warning
|
||||||
|
org.eclipse.jdt.core.compiler.problem.finallyBlockNotCompletingNormally=warning
|
||||||
|
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
||||||
|
org.eclipse.jdt.core.compiler.problem.hiddenCatchBlock=warning
|
||||||
|
org.eclipse.jdt.core.compiler.problem.includeNullInfoFromAsserts=disabled
|
||||||
|
org.eclipse.jdt.core.compiler.problem.incompatibleNonInheritedInterfaceMethod=warning
|
||||||
|
org.eclipse.jdt.core.compiler.problem.incompleteEnumSwitch=ignore
|
||||||
|
org.eclipse.jdt.core.compiler.problem.indirectStaticAccess=warning
|
||||||
|
org.eclipse.jdt.core.compiler.problem.localVariableHiding=ignore
|
||||||
|
org.eclipse.jdt.core.compiler.problem.methodWithConstructorName=warning
|
||||||
|
org.eclipse.jdt.core.compiler.problem.missingDefaultCase=ignore
|
||||||
|
org.eclipse.jdt.core.compiler.problem.missingDeprecatedAnnotation=ignore
|
||||||
|
org.eclipse.jdt.core.compiler.problem.missingEnumCaseDespiteDefault=disabled
|
||||||
|
org.eclipse.jdt.core.compiler.problem.missingHashCodeMethod=ignore
|
||||||
|
org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotation=warning
|
||||||
|
org.eclipse.jdt.core.compiler.problem.missingOverrideAnnotationForInterfaceMethodImplementation=enabled
|
||||||
|
org.eclipse.jdt.core.compiler.problem.missingSerialVersion=warning
|
||||||
|
org.eclipse.jdt.core.compiler.problem.missingSynchronizedOnInheritedMethod=ignore
|
||||||
|
org.eclipse.jdt.core.compiler.problem.noEffectAssignment=warning
|
||||||
|
org.eclipse.jdt.core.compiler.problem.noImplicitStringConversion=warning
|
||||||
|
org.eclipse.jdt.core.compiler.problem.nonExternalizedStringLiteral=ignore
|
||||||
|
org.eclipse.jdt.core.compiler.problem.nonnullParameterAnnotationDropped=warning
|
||||||
|
org.eclipse.jdt.core.compiler.problem.nonnullTypeVariableFromLegacyInvocation=warning
|
||||||
|
org.eclipse.jdt.core.compiler.problem.nullAnnotationInferenceConflict=error
|
||||||
|
org.eclipse.jdt.core.compiler.problem.nullReference=warning
|
||||||
|
org.eclipse.jdt.core.compiler.problem.nullSpecViolation=error
|
||||||
|
org.eclipse.jdt.core.compiler.problem.nullUncheckedConversion=warning
|
||||||
|
org.eclipse.jdt.core.compiler.problem.overridingPackageDefaultMethod=warning
|
||||||
|
org.eclipse.jdt.core.compiler.problem.parameterAssignment=ignore
|
||||||
|
org.eclipse.jdt.core.compiler.problem.pessimisticNullAnalysisForFreeTypeVariables=warning
|
||||||
|
org.eclipse.jdt.core.compiler.problem.possibleAccidentalBooleanAssignment=ignore
|
||||||
|
org.eclipse.jdt.core.compiler.problem.potentialNullReference=ignore
|
||||||
|
org.eclipse.jdt.core.compiler.problem.potentiallyUnclosedCloseable=ignore
|
||||||
|
org.eclipse.jdt.core.compiler.problem.rawTypeReference=warning
|
||||||
|
org.eclipse.jdt.core.compiler.problem.redundantNullAnnotation=warning
|
||||||
|
org.eclipse.jdt.core.compiler.problem.redundantNullCheck=warning
|
||||||
|
org.eclipse.jdt.core.compiler.problem.redundantSpecificationOfTypeArguments=warning
|
||||||
|
org.eclipse.jdt.core.compiler.problem.redundantSuperinterface=warning
|
||||||
|
org.eclipse.jdt.core.compiler.problem.reportMethodCanBePotentiallyStatic=ignore
|
||||||
|
org.eclipse.jdt.core.compiler.problem.reportMethodCanBeStatic=ignore
|
||||||
|
org.eclipse.jdt.core.compiler.problem.reportPreviewFeatures=warning
|
||||||
|
org.eclipse.jdt.core.compiler.problem.specialParameterHidingField=disabled
|
||||||
|
org.eclipse.jdt.core.compiler.problem.staticAccessReceiver=warning
|
||||||
|
org.eclipse.jdt.core.compiler.problem.suppressOptionalErrors=disabled
|
||||||
|
org.eclipse.jdt.core.compiler.problem.suppressWarnings=enabled
|
||||||
|
org.eclipse.jdt.core.compiler.problem.suppressWarningsNotFullyAnalysed=info
|
||||||
|
org.eclipse.jdt.core.compiler.problem.syntacticNullAnalysisForFields=disabled
|
||||||
|
org.eclipse.jdt.core.compiler.problem.syntheticAccessEmulation=ignore
|
||||||
|
org.eclipse.jdt.core.compiler.problem.terminalDeprecation=warning
|
||||||
|
org.eclipse.jdt.core.compiler.problem.typeParameterHiding=warning
|
||||||
|
org.eclipse.jdt.core.compiler.problem.unavoidableGenericTypeProblems=disabled
|
||||||
|
org.eclipse.jdt.core.compiler.problem.uncheckedTypeOperation=warning
|
||||||
|
org.eclipse.jdt.core.compiler.problem.unclosedCloseable=warning
|
||||||
|
org.eclipse.jdt.core.compiler.problem.undocumentedEmptyBlock=ignore
|
||||||
|
org.eclipse.jdt.core.compiler.problem.unhandledWarningToken=warning
|
||||||
|
org.eclipse.jdt.core.compiler.problem.unlikelyCollectionMethodArgumentType=warning
|
||||||
|
org.eclipse.jdt.core.compiler.problem.unlikelyCollectionMethodArgumentTypeStrict=disabled
|
||||||
|
org.eclipse.jdt.core.compiler.problem.unlikelyEqualsArgumentType=info
|
||||||
|
org.eclipse.jdt.core.compiler.problem.unnecessaryElse=warning
|
||||||
|
org.eclipse.jdt.core.compiler.problem.unnecessaryTypeCheck=warning
|
||||||
|
org.eclipse.jdt.core.compiler.problem.unqualifiedFieldAccess=ignore
|
||||||
|
org.eclipse.jdt.core.compiler.problem.unstableAutoModuleName=warning
|
||||||
|
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownException=warning
|
||||||
|
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionExemptExceptionAndThrowable=enabled
|
||||||
|
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionIncludeDocCommentReference=enabled
|
||||||
|
org.eclipse.jdt.core.compiler.problem.unusedDeclaredThrownExceptionWhenOverriding=disabled
|
||||||
|
org.eclipse.jdt.core.compiler.problem.unusedExceptionParameter=ignore
|
||||||
|
org.eclipse.jdt.core.compiler.problem.unusedImport=warning
|
||||||
|
org.eclipse.jdt.core.compiler.problem.unusedLabel=warning
|
||||||
|
org.eclipse.jdt.core.compiler.problem.unusedLocal=warning
|
||||||
|
org.eclipse.jdt.core.compiler.problem.unusedObjectAllocation=ignore
|
||||||
|
org.eclipse.jdt.core.compiler.problem.unusedParameter=warning
|
||||||
|
org.eclipse.jdt.core.compiler.problem.unusedParameterIncludeDocCommentReference=enabled
|
||||||
|
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenImplementingAbstract=disabled
|
||||||
|
org.eclipse.jdt.core.compiler.problem.unusedParameterWhenOverridingConcrete=disabled
|
||||||
|
org.eclipse.jdt.core.compiler.problem.unusedPrivateMember=warning
|
||||||
|
org.eclipse.jdt.core.compiler.problem.unusedTypeParameter=warning
|
||||||
|
org.eclipse.jdt.core.compiler.problem.unusedWarningToken=warning
|
||||||
|
org.eclipse.jdt.core.compiler.problem.varargsArgumentNeedCast=warning
|
||||||
|
org.eclipse.jdt.core.compiler.release=disabled
|
||||||
|
org.eclipse.jdt.core.compiler.source=11
|
||||||
|
org.eclipse.jdt.core.formatter.align_assignment_statements_on_columns=true
|
||||||
|
org.eclipse.jdt.core.formatter.align_fields_grouping_blank_lines=1
|
||||||
|
org.eclipse.jdt.core.formatter.align_type_members_on_columns=true
|
||||||
|
org.eclipse.jdt.core.formatter.align_variable_declarations_on_columns=true
|
||||||
|
org.eclipse.jdt.core.formatter.align_with_spaces=false
|
||||||
|
org.eclipse.jdt.core.formatter.alignment_for_additive_operator=16
|
||||||
|
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
|
||||||
|
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=84
|
||||||
|
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16
|
||||||
|
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16
|
||||||
|
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=80
|
||||||
|
org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=20
|
||||||
|
org.eclipse.jdt.core.formatter.alignment_for_assignment=0
|
||||||
|
org.eclipse.jdt.core.formatter.alignment_for_bitwise_operator=16
|
||||||
|
org.eclipse.jdt.core.formatter.alignment_for_compact_if=16
|
||||||
|
org.eclipse.jdt.core.formatter.alignment_for_compact_loops=16
|
||||||
|
org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80
|
||||||
|
org.eclipse.jdt.core.formatter.alignment_for_conditional_expression_chain=0
|
||||||
|
org.eclipse.jdt.core.formatter.alignment_for_enum_constants=16
|
||||||
|
org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16
|
||||||
|
org.eclipse.jdt.core.formatter.alignment_for_expressions_in_for_loop_header=0
|
||||||
|
org.eclipse.jdt.core.formatter.alignment_for_logical_operator=16
|
||||||
|
org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0
|
||||||
|
org.eclipse.jdt.core.formatter.alignment_for_module_statements=16
|
||||||
|
org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16
|
||||||
|
org.eclipse.jdt.core.formatter.alignment_for_multiplicative_operator=16
|
||||||
|
org.eclipse.jdt.core.formatter.alignment_for_parameterized_type_references=0
|
||||||
|
org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16
|
||||||
|
org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16
|
||||||
|
org.eclipse.jdt.core.formatter.alignment_for_relational_operator=0
|
||||||
|
org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80
|
||||||
|
org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=84
|
||||||
|
org.eclipse.jdt.core.formatter.alignment_for_shift_operator=0
|
||||||
|
org.eclipse.jdt.core.formatter.alignment_for_string_concatenation=16
|
||||||
|
org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16
|
||||||
|
org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16
|
||||||
|
org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16
|
||||||
|
org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16
|
||||||
|
org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16
|
||||||
|
org.eclipse.jdt.core.formatter.alignment_for_type_arguments=0
|
||||||
|
org.eclipse.jdt.core.formatter.alignment_for_type_parameters=0
|
||||||
|
org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch=16
|
||||||
|
org.eclipse.jdt.core.formatter.blank_lines_after_imports=1
|
||||||
|
org.eclipse.jdt.core.formatter.blank_lines_after_last_class_body_declaration=0
|
||||||
|
org.eclipse.jdt.core.formatter.blank_lines_after_package=1
|
||||||
|
org.eclipse.jdt.core.formatter.blank_lines_before_abstract_method=1
|
||||||
|
org.eclipse.jdt.core.formatter.blank_lines_before_field=0
|
||||||
|
org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=1
|
||||||
|
org.eclipse.jdt.core.formatter.blank_lines_before_imports=1
|
||||||
|
org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1
|
||||||
|
org.eclipse.jdt.core.formatter.blank_lines_before_method=1
|
||||||
|
org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1
|
||||||
|
org.eclipse.jdt.core.formatter.blank_lines_before_package=0
|
||||||
|
org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1
|
||||||
|
org.eclipse.jdt.core.formatter.blank_lines_between_statement_group_in_switch=0
|
||||||
|
org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1
|
||||||
|
org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line
|
||||||
|
org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line
|
||||||
|
org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line
|
||||||
|
org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line
|
||||||
|
org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line
|
||||||
|
org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line
|
||||||
|
org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line
|
||||||
|
org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line
|
||||||
|
org.eclipse.jdt.core.formatter.brace_position_for_lambda_body=end_of_line
|
||||||
|
org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line
|
||||||
|
org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line
|
||||||
|
org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line
|
||||||
|
org.eclipse.jdt.core.formatter.comment.align_tags_descriptions_grouped=true
|
||||||
|
org.eclipse.jdt.core.formatter.comment.align_tags_names_descriptions=false
|
||||||
|
org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=true
|
||||||
|
org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false
|
||||||
|
org.eclipse.jdt.core.formatter.comment.count_line_length_from_starting_position=true
|
||||||
|
org.eclipse.jdt.core.formatter.comment.format_block_comments=true
|
||||||
|
org.eclipse.jdt.core.formatter.comment.format_header=true
|
||||||
|
org.eclipse.jdt.core.formatter.comment.format_html=true
|
||||||
|
org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true
|
||||||
|
org.eclipse.jdt.core.formatter.comment.format_line_comments=true
|
||||||
|
org.eclipse.jdt.core.formatter.comment.format_source_code=true
|
||||||
|
org.eclipse.jdt.core.formatter.comment.indent_parameter_description=false
|
||||||
|
org.eclipse.jdt.core.formatter.comment.indent_root_tags=false
|
||||||
|
org.eclipse.jdt.core.formatter.comment.indent_tag_description=false
|
||||||
|
org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert
|
||||||
|
org.eclipse.jdt.core.formatter.comment.insert_new_line_between_different_tags=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.comment.line_length=80
|
||||||
|
org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true
|
||||||
|
org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true
|
||||||
|
org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=false
|
||||||
|
org.eclipse.jdt.core.formatter.compact_else_if=true
|
||||||
|
org.eclipse.jdt.core.formatter.continuation_indentation=2
|
||||||
|
org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2
|
||||||
|
org.eclipse.jdt.core.formatter.disabling_tag=@formatter\:off
|
||||||
|
org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on
|
||||||
|
org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=true
|
||||||
|
org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=true
|
||||||
|
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true
|
||||||
|
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true
|
||||||
|
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true
|
||||||
|
org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true
|
||||||
|
org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true
|
||||||
|
org.eclipse.jdt.core.formatter.indent_empty_lines=false
|
||||||
|
org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true
|
||||||
|
org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true
|
||||||
|
org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true
|
||||||
|
org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=true
|
||||||
|
org.eclipse.jdt.core.formatter.indentation.size=4
|
||||||
|
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_enum_constant=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_new_line_after_label=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_new_line_after_type_annotation=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_additive_operator=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_arrow_in_switch_case=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_arrow_in_switch_default=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_bitwise_operator=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_switch_case_expressions=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_lambda_arrow=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_logical_operator=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_multiplicative_operator=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_not_operator=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_relational_operator=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_shift_operator=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_string_concatenation=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_additive_operator=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_arrow_in_switch_case=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_arrow_in_switch_default=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_bitwise_operator=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_switch_case_expressions=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_logical_operator=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_multiplicative_operator=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_relational_operator=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_shift_operator=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_string_concatenation=insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert
|
||||||
|
org.eclipse.jdt.core.formatter.join_lines_in_comments=false
|
||||||
|
org.eclipse.jdt.core.formatter.join_wrapped_lines=true
|
||||||
|
org.eclipse.jdt.core.formatter.keep_annotation_declaration_on_one_line=one_line_if_single_item
|
||||||
|
org.eclipse.jdt.core.formatter.keep_anonymous_type_declaration_on_one_line=one_line_never
|
||||||
|
org.eclipse.jdt.core.formatter.keep_code_block_on_one_line=one_line_if_empty
|
||||||
|
org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=true
|
||||||
|
org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false
|
||||||
|
org.eclipse.jdt.core.formatter.keep_enum_constant_declaration_on_one_line=one_line_never
|
||||||
|
org.eclipse.jdt.core.formatter.keep_enum_declaration_on_one_line=one_line_never
|
||||||
|
org.eclipse.jdt.core.formatter.keep_if_then_body_block_on_one_line=one_line_if_single_item
|
||||||
|
org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false
|
||||||
|
org.eclipse.jdt.core.formatter.keep_lambda_body_block_on_one_line=one_line_always
|
||||||
|
org.eclipse.jdt.core.formatter.keep_loop_body_block_on_one_line=one_line_if_empty
|
||||||
|
org.eclipse.jdt.core.formatter.keep_method_body_on_one_line=one_line_if_single_item
|
||||||
|
org.eclipse.jdt.core.formatter.keep_simple_do_while_body_on_same_line=false
|
||||||
|
org.eclipse.jdt.core.formatter.keep_simple_for_body_on_same_line=false
|
||||||
|
org.eclipse.jdt.core.formatter.keep_simple_getter_setter_on_one_line=true
|
||||||
|
org.eclipse.jdt.core.formatter.keep_simple_while_body_on_same_line=false
|
||||||
|
org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=true
|
||||||
|
org.eclipse.jdt.core.formatter.keep_type_declaration_on_one_line=one_line_never
|
||||||
|
org.eclipse.jdt.core.formatter.lineSplit=150
|
||||||
|
org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false
|
||||||
|
org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false
|
||||||
|
org.eclipse.jdt.core.formatter.number_of_blank_lines_after_code_block=0
|
||||||
|
org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_code_block=0
|
||||||
|
org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0
|
||||||
|
org.eclipse.jdt.core.formatter.number_of_blank_lines_at_end_of_code_block=0
|
||||||
|
org.eclipse.jdt.core.formatter.number_of_blank_lines_at_end_of_method_body=0
|
||||||
|
org.eclipse.jdt.core.formatter.number_of_blank_lines_before_code_block=0
|
||||||
|
org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1
|
||||||
|
org.eclipse.jdt.core.formatter.parentheses_positions_in_annotation=separate_lines_if_wrapped
|
||||||
|
org.eclipse.jdt.core.formatter.parentheses_positions_in_catch_clause=common_lines
|
||||||
|
org.eclipse.jdt.core.formatter.parentheses_positions_in_enum_constant_declaration=common_lines
|
||||||
|
org.eclipse.jdt.core.formatter.parentheses_positions_in_for_statment=common_lines
|
||||||
|
org.eclipse.jdt.core.formatter.parentheses_positions_in_if_while_statement=common_lines
|
||||||
|
org.eclipse.jdt.core.formatter.parentheses_positions_in_lambda_declaration=common_lines
|
||||||
|
org.eclipse.jdt.core.formatter.parentheses_positions_in_method_delcaration=common_lines
|
||||||
|
org.eclipse.jdt.core.formatter.parentheses_positions_in_method_invocation=common_lines
|
||||||
|
org.eclipse.jdt.core.formatter.parentheses_positions_in_switch_statement=common_lines
|
||||||
|
org.eclipse.jdt.core.formatter.parentheses_positions_in_try_clause=common_lines
|
||||||
|
org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true
|
||||||
|
org.eclipse.jdt.core.formatter.tabulation.char=tab
|
||||||
|
org.eclipse.jdt.core.formatter.tabulation.size=4
|
||||||
|
org.eclipse.jdt.core.formatter.text_block_indentation=0
|
||||||
|
org.eclipse.jdt.core.formatter.use_on_off_tags=false
|
||||||
|
org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false
|
||||||
|
org.eclipse.jdt.core.formatter.wrap_before_additive_operator=true
|
||||||
|
org.eclipse.jdt.core.formatter.wrap_before_assignment_operator=false
|
||||||
|
org.eclipse.jdt.core.formatter.wrap_before_bitwise_operator=true
|
||||||
|
org.eclipse.jdt.core.formatter.wrap_before_conditional_operator=true
|
||||||
|
org.eclipse.jdt.core.formatter.wrap_before_logical_operator=true
|
||||||
|
org.eclipse.jdt.core.formatter.wrap_before_multiplicative_operator=true
|
||||||
|
org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true
|
||||||
|
org.eclipse.jdt.core.formatter.wrap_before_relational_operator=true
|
||||||
|
org.eclipse.jdt.core.formatter.wrap_before_shift_operator=true
|
||||||
|
org.eclipse.jdt.core.formatter.wrap_before_string_concatenation=true
|
||||||
|
org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true
|
||||||
|
org.eclipse.jdt.core.javaFormatter=org.eclipse.jdt.core.defaultJavaFormatter
|
5
.settings/org.eclipse.jdt.ui.prefs
Executable file
5
.settings/org.eclipse.jdt.ui.prefs
Executable file
File diff suppressed because one or more lines are too long
3
.settings/org.eclipse.jpt.core.prefs
Executable file
3
.settings/org.eclipse.jpt.core.prefs
Executable file
@ -0,0 +1,3 @@
|
|||||||
|
eclipse.preferences.version=1
|
||||||
|
org.eclipse.jpt.core.platform=eclipselink2_5
|
||||||
|
org.eclipse.jpt.jpa.core.discoverAnnotatedClasses=true
|
4
.settings/org.eclipse.m2e.core.prefs
Executable file
4
.settings/org.eclipse.m2e.core.prefs
Executable file
@ -0,0 +1,4 @@
|
|||||||
|
activeProfiles=
|
||||||
|
eclipse.preferences.version=1
|
||||||
|
resolveWorkspaceProjects=false
|
||||||
|
version=1
|
@ -0,0 +1,7 @@
|
|||||||
|
<root>
|
||||||
|
<facet id="jpt.jpa">
|
||||||
|
<node name="libprov">
|
||||||
|
<attribute name="provider-id" value="jpa-no-op-library-provider"/>
|
||||||
|
</node>
|
||||||
|
</facet>
|
||||||
|
</root>
|
5
.settings/org.eclipse.wst.common.project.facet.core.xml
Executable file
5
.settings/org.eclipse.wst.common.project.facet.core.xml
Executable file
@ -0,0 +1,5 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<faceted-project>
|
||||||
|
<installed facet="java" version="11"/>
|
||||||
|
<installed facet="jpt.jpa" version="2.1"/>
|
||||||
|
</faceted-project>
|
3
.settings/org.hibernate.eclipse.console.prefs
Executable file
3
.settings/org.hibernate.eclipse.console.prefs
Executable file
@ -0,0 +1,3 @@
|
|||||||
|
default.configuration=envoy-server-standalone
|
||||||
|
eclipse.preferences.version=1
|
||||||
|
hibernate3.enabled=true
|
76
CODE_OF_CONDUCT.md
Executable file
76
CODE_OF_CONDUCT.md
Executable file
@ -0,0 +1,76 @@
|
|||||||
|
# Contributor Covenant Code of Conduct
|
||||||
|
|
||||||
|
## Our Pledge
|
||||||
|
|
||||||
|
In the interest of fostering an open and welcoming environment, we as
|
||||||
|
contributors and maintainers pledge to making participation in our project and
|
||||||
|
our community a harassment-free experience for everyone, regardless of age, body
|
||||||
|
size, disability, ethnicity, sex characteristics, gender identity and expression,
|
||||||
|
level of experience, education, socio-economic status, nationality, personal
|
||||||
|
appearance, race, religion, or sexual identity and orientation.
|
||||||
|
|
||||||
|
## Our Standards
|
||||||
|
|
||||||
|
Examples of behavior that contributes to creating a positive environment
|
||||||
|
include:
|
||||||
|
|
||||||
|
* Using welcoming and inclusive language
|
||||||
|
* Being respectful of differing viewpoints and experiences
|
||||||
|
* Gracefully accepting constructive criticism
|
||||||
|
* Focusing on what is best for the community
|
||||||
|
* Showing empathy towards other community members
|
||||||
|
|
||||||
|
Examples of unacceptable behavior by participants include:
|
||||||
|
|
||||||
|
* The use of sexualized language or imagery and unwelcome sexual attention or
|
||||||
|
advances
|
||||||
|
* Trolling, insulting/derogatory comments, and personal or political attacks
|
||||||
|
* Public or private harassment
|
||||||
|
* Publishing others' private information, such as a physical or electronic
|
||||||
|
address, without explicit permission
|
||||||
|
* Other conduct which could reasonably be considered inappropriate in a
|
||||||
|
professional setting
|
||||||
|
|
||||||
|
## Our Responsibilities
|
||||||
|
|
||||||
|
Project maintainers are responsible for clarifying the standards of acceptable
|
||||||
|
behavior and are expected to take appropriate and fair corrective action in
|
||||||
|
response to any instances of unacceptable behavior.
|
||||||
|
|
||||||
|
Project maintainers have the right and responsibility to remove, edit, or
|
||||||
|
reject comments, commits, code, wiki edits, issues, and other contributions
|
||||||
|
that are not aligned to this Code of Conduct, or to ban temporarily or
|
||||||
|
permanently any contributor for other behaviors that they deem inappropriate,
|
||||||
|
threatening, offensive, or harmful.
|
||||||
|
|
||||||
|
## Scope
|
||||||
|
|
||||||
|
This Code of Conduct applies both within project spaces and in public spaces
|
||||||
|
when an individual is representing the project or its community. Examples of
|
||||||
|
representing a project or community include using an official project e-mail
|
||||||
|
address, posting via an official social media account, or acting as an appointed
|
||||||
|
representative at an online or offline event. Representation of a project may be
|
||||||
|
further defined and clarified by project maintainers.
|
||||||
|
|
||||||
|
## Enforcement
|
||||||
|
|
||||||
|
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
||||||
|
reported by contacting the project team at kske@outlook.de. All
|
||||||
|
complaints will be reviewed and investigated and will result in a response that
|
||||||
|
is deemed necessary and appropriate to the circumstances. The project team is
|
||||||
|
obligated to maintain confidentiality with regard to the reporter of an incident.
|
||||||
|
Further details of specific enforcement policies may be posted separately.
|
||||||
|
|
||||||
|
Project maintainers who do not follow or enforce the Code of Conduct in good
|
||||||
|
faith may face temporary or permanent repercussions as determined by other
|
||||||
|
members of the project's leadership.
|
||||||
|
|
||||||
|
## Attribution
|
||||||
|
|
||||||
|
This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
|
||||||
|
available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
|
||||||
|
|
||||||
|
[homepage]: https://www.contributor-covenant.org
|
||||||
|
|
||||||
|
For answers to common questions about this code of conduct, see
|
||||||
|
https://www.contributor-covenant.org/faq
|
161
CONTRIBUTING.md
Executable file
161
CONTRIBUTING.md
Executable file
@ -0,0 +1,161 @@
|
|||||||
|
# Contributing to Envoy
|
||||||
|
|
||||||
|
Looking to contribute something to Envoy? **Here's how you can help.**
|
||||||
|
|
||||||
|
Please take a moment to review this document in order to make the contribution
|
||||||
|
process easy and effective for everyone involved.
|
||||||
|
|
||||||
|
Following these guidelines helps to communicate that you respect the time of
|
||||||
|
the developers managing and developing this open source project. In return,
|
||||||
|
they should reciprocate that respect in addressing your issue or assessing
|
||||||
|
patches and features.
|
||||||
|
|
||||||
|
|
||||||
|
## Using the issue tracker
|
||||||
|
|
||||||
|
The [issue tracker](https://github.com/informatik-ag-ngl/envoy-server-standalone/issues) is
|
||||||
|
the preferred channel for [bug reports](#bug-reports), [features requests](#feature-requests)
|
||||||
|
and [submitting pull requests](#pull-requests), but please respect the following
|
||||||
|
restrictions:
|
||||||
|
|
||||||
|
* Please **do not** derail or troll issues. Keep the discussion on topic and
|
||||||
|
respect the opinions of others.
|
||||||
|
|
||||||
|
* Please **do not** post comments consisting solely of "+1" or ":thumbsup:".
|
||||||
|
Use [GitHub's "reactions" feature](https://blog.github.com/2016-03-10-add-reactions-to-pull-requests-issues-and-comments/)
|
||||||
|
instead. We reserve the right to delete comments which violate this rule.
|
||||||
|
|
||||||
|
However, as we know, we are all software engineers that like being funny hence doing it on purpose. Please also refrain from that kind of behaviour.
|
||||||
|
|
||||||
|
## Issues and labels
|
||||||
|
|
||||||
|
Our bug tracker utilizes several labels to help organize and identify issues. Here's what they represent and how we use them:
|
||||||
|
|
||||||
|
- `Documentation` & `Javadoc`- Issues regarding the documentation of Envoy
|
||||||
|
- `Enhancement` & `Feature` - Issues suggesting a new feature
|
||||||
|
- `Maven` - Issues concerned with Maven problems
|
||||||
|
- `Bug` - Issues concerned with a general bug
|
||||||
|
|
||||||
|
For a complete look at our labels, see the [project labels page](https://github.com/informatik-ag-ngl/envoy-server-standalone/labels).
|
||||||
|
|
||||||
|
## Bug reports
|
||||||
|
|
||||||
|
A bug is a _demonstrable problem_ that is caused by the code in the repository.
|
||||||
|
Good bug reports are extremely helpful, so thanks!
|
||||||
|
|
||||||
|
Guidelines for bug reports:
|
||||||
|
|
||||||
|
0. **ensure your problem isn't caused by a simple error in your own code**.
|
||||||
|
|
||||||
|
1. **Use the GitHub issue search** — check if the issue has already been
|
||||||
|
reported.
|
||||||
|
|
||||||
|
2. **Check if the issue has been fixed** — try to reproduce it using the
|
||||||
|
latest `master` or development branch in the repository.
|
||||||
|
|
||||||
|
3. **Isolate the problem** — ideally create a reduced test
|
||||||
|
case and a live example.
|
||||||
|
|
||||||
|
|
||||||
|
A good bug report shouldn't leave others needing to chase you up for more
|
||||||
|
information. Please try to be as detailed as possible in your report. What is
|
||||||
|
your environment? What steps will reproduce the issue? These details will help people to fix
|
||||||
|
any potential bugs.
|
||||||
|
|
||||||
|
Example:
|
||||||
|
|
||||||
|
> Short and descriptive example bug report title
|
||||||
|
>
|
||||||
|
> 1. This is the first step
|
||||||
|
> 2. This is the second step
|
||||||
|
> 3. Further steps, etc.
|
||||||
|
>
|
||||||
|
> Any other information you want to share that is relevant to the issue being
|
||||||
|
> reported. This might include the lines of code that you have identified as
|
||||||
|
> causing the bug, and potential solutions (and your opinions on their
|
||||||
|
> merits).
|
||||||
|
|
||||||
|
## Feature requests
|
||||||
|
|
||||||
|
Feature requests are welcome. But take a moment to find out whether your idea
|
||||||
|
fits with the scope and aims of the project. It's up to *you* to make a strong
|
||||||
|
case to convince the project's developers of the merits of this feature. Please
|
||||||
|
provide as much detail and context as possible.
|
||||||
|
|
||||||
|
|
||||||
|
## Pull requests
|
||||||
|
|
||||||
|
Good pull requests—patches, improvements, new features—are a fantastic
|
||||||
|
help. They should remain focused in scope and avoid containing unrelated
|
||||||
|
commits.
|
||||||
|
|
||||||
|
**Please ask first** before embarking on any significant pull request (e.g.
|
||||||
|
implementing features, refactoring code, porting to a different language),
|
||||||
|
otherwise you risk spending a lot of time working on something that the
|
||||||
|
project's developers might not want to merge into the project.
|
||||||
|
|
||||||
|
Please adhere to the [coding guidelines](#code-guidelines) used throughout the
|
||||||
|
project (indentation, accurate comments, etc.) and any other requirements
|
||||||
|
(such as test coverage).
|
||||||
|
|
||||||
|
Adhering to the following process is the best way to get your work
|
||||||
|
included in the project:
|
||||||
|
|
||||||
|
1. Download, clone or [Fork](https://help.github.com/articles/fork-a-repo/) the project, using [https://github.com/informatik-ag-ngl/envoy-server-standalone/](https://github.com/informatik-ag-ngl/envoy-server-standalone/)as Remote.
|
||||||
|
|
||||||
|
2. If you cloned a while ago, get the latest changes from upstream:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git checkout master
|
||||||
|
git pull upstream master
|
||||||
|
```
|
||||||
|
Or, if your IDE of choice supports this, simply use `pull`
|
||||||
|
|
||||||
|
3. Create a new topic branch (off the main project development branch) to
|
||||||
|
contain your feature, change, or fix:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git checkout -b <topic-branch-name>
|
||||||
|
```
|
||||||
|
Or, simply use "New branch" if your IDE supports this
|
||||||
|
|
||||||
|
4. Commit your changes in logical chunks. Please adhere to these [git commit
|
||||||
|
message guidelines](https://tbaggery.com/2008/04/19/a-note-about-git-commit-messages.html)
|
||||||
|
or your code is unlikely be merged into the main project. Use Git's
|
||||||
|
[interactive rebase](https://help.github.com/articles/about-git-rebase/)
|
||||||
|
feature to tidy up your commits before making them public.
|
||||||
|
|
||||||
|
5. Locally merge (or rebase) the upstream development branch into your topic branch:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git pull [--rebase] upstream master
|
||||||
|
```
|
||||||
|
|
||||||
|
6. Push your topic branch up to your fork:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
git push origin <topic-branch-name>
|
||||||
|
```
|
||||||
|
|
||||||
|
7. [Open a Pull Request](https://help.github.com/articles/about-pull-requests/)
|
||||||
|
with a clear title and description against the `master` branch.
|
||||||
|
|
||||||
|
**IMPORTANT**: By submitting a patch, you agree to allow the project owners to
|
||||||
|
license your work under the terms of the [MIT License](../LICENSE) (if it
|
||||||
|
includes code changes) and under the terms of the
|
||||||
|
[Creative Commons Attribution 3.0 Unported License](https://creativecommons.org/licenses/by/3.0/)
|
||||||
|
(if it includes documentation changes).
|
||||||
|
|
||||||
|
|
||||||
|
## Code guidelines
|
||||||
|
|
||||||
|
### Java
|
||||||
|
|
||||||
|
Please use the formatter provided with this project. Especially before saving. For best results, select the option "format code" in the "Save Actions" tab in Preferences in Eclipse, so that you never accidentally forget it.
|
||||||
|
Every public function (not annotated with `@Override`) must be delivered with Javadoc. For best project-appropriate Javadoc please take a look at the other functions which are all already equipped with Javadoc.
|
||||||
|
|
||||||
|
|
||||||
|
## License
|
||||||
|
|
||||||
|
By contributing your code, you agree to license your contribution under the [MIT License](../LICENSE).
|
||||||
|
By contributing to the documentation, you agree to license your contribution under the [Creative Commons Attribution 3.0 Unported License](https://creativecommons.org/licenses/by/3.0/).
|
21
LICENSE
Executable file
21
LICENSE
Executable file
@ -0,0 +1,21 @@
|
|||||||
|
MIT License
|
||||||
|
|
||||||
|
Copyright (c) 2019 Informatik-AG
|
||||||
|
|
||||||
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
|
in the Software without restriction, including without limitation the rights
|
||||||
|
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||||
|
copies of the Software, and to permit persons to whom the Software is
|
||||||
|
furnished to do so, subject to the following conditions:
|
||||||
|
|
||||||
|
The above copyright notice and this permission notice shall be included in all
|
||||||
|
copies or substantial portions of the Software.
|
||||||
|
|
||||||
|
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||||
|
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||||
|
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||||
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
|
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||||
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
|
SOFTWARE.
|
3
README.md
Executable file
3
README.md
Executable file
@ -0,0 +1,3 @@
|
|||||||
|
# envoy-server-standalone
|
||||||
|
Standalone server for the
|
||||||
|
<a href="https://github.com/informatik-ag-ngl/envoy-client"><img src="https://raw.githubusercontent.com/informatik-ag-ngl/envoy-client/develop/src/main/resources/icons/envoy_logo.png" align="left" width="200" height="200">Envoy project</a>
|
5
drop_all_tables.sql
Normal file
5
drop_all_tables.sql
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
DROP SCHEMA public CASCADE;
|
||||||
|
CREATE SCHEMA public;
|
||||||
|
GRANT ALL ON SCHEMA public TO postgres;
|
||||||
|
GRANT ALL ON SCHEMA public TO envoy;
|
||||||
|
GRANT ALL ON SCHEMA public TO public;
|
92
pom.xml
Executable file
92
pom.xml
Executable file
@ -0,0 +1,92 @@
|
|||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<groupId>informatik-ag-ngl</groupId>
|
||||||
|
<artifactId>envoy-server-standalone</artifactId>
|
||||||
|
<version>0.1-beta</version>
|
||||||
|
|
||||||
|
<name>Envoy Server</name>
|
||||||
|
<url>https://github.com/informatik-ag-ngl/envoy-server-standalone</url>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||||
|
<maven.compiler.source>11</maven.compiler.source>
|
||||||
|
<maven.compiler.target>11</maven.compiler.target>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>jitpack.io</id>
|
||||||
|
<url>https://jitpack.io</url>
|
||||||
|
</repository>
|
||||||
|
</repositories>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.informatik-ag-ngl</groupId>
|
||||||
|
<artifactId>envoy-common</artifactId>
|
||||||
|
<version>develop-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.informatik-ag-ngl</groupId>
|
||||||
|
<artifactId>java-nio-server</artifactId>
|
||||||
|
<version>master-SNAPSHOT</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.hibernate</groupId>
|
||||||
|
<artifactId>hibernate-core</artifactId>
|
||||||
|
<version>5.4.10.Final</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.postgresql</groupId>
|
||||||
|
<artifactId>postgresql</artifactId>
|
||||||
|
<version>42.2.9</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<finalName>envoy-server-standalone</finalName>
|
||||||
|
<resources>
|
||||||
|
<resource>
|
||||||
|
<directory>src/main/resources</directory>
|
||||||
|
</resource>
|
||||||
|
</resources>
|
||||||
|
<pluginManagement>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.8.1</version>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</pluginManagement>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-assembly-plugin</artifactId>
|
||||||
|
<version>3.2.0</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>single</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<archive>
|
||||||
|
<manifest>
|
||||||
|
<mainClass>envoy.server.Startup</mainClass>
|
||||||
|
</manifest>
|
||||||
|
</archive>
|
||||||
|
<descriptorRefs>
|
||||||
|
<descriptorRef>jar-with-dependencies</descriptorRef>
|
||||||
|
</descriptorRefs>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
89
src/main/java/envoy/server/Startup.java
Executable file
89
src/main/java/envoy/server/Startup.java
Executable file
@ -0,0 +1,89 @@
|
|||||||
|
package envoy.server;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
|
||||||
|
import com.jenkov.nioserver.Server;
|
||||||
|
|
||||||
|
import envoy.data.Config;
|
||||||
|
import envoy.data.ConfigItem;
|
||||||
|
import envoy.server.data.PersistenceManager;
|
||||||
|
import envoy.server.net.ConnectionManager;
|
||||||
|
import envoy.server.net.ObjectMessageProcessor;
|
||||||
|
import envoy.server.net.ObjectMessageReader;
|
||||||
|
import envoy.server.processors.*;
|
||||||
|
import envoy.util.EnvoyLog;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Starts the server.<br>
|
||||||
|
* <br>
|
||||||
|
* Project: <strong>envoy-server-standalone</strong><br>
|
||||||
|
* File: <strong>Startup.java</strong><br>
|
||||||
|
* Created: <strong>24.12.2019</strong><br>
|
||||||
|
*
|
||||||
|
* @author Kai S. K. Engelbart
|
||||||
|
* @since Envoy Server Standalone v0.1-alpha
|
||||||
|
*/
|
||||||
|
public class Startup {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initializes the logger with a new config instance.
|
||||||
|
*
|
||||||
|
* @since Envoy Server Standalone v0.1-beta
|
||||||
|
*/
|
||||||
|
private static void initLogging() {
|
||||||
|
final var items = new HashMap<String, ConfigItem<?>>();
|
||||||
|
items.put("homeDirectory",
|
||||||
|
new ConfigItem<>("homeDirectory", "h", File::new, new File(System.getProperty("user.home"), ".envoy-server"), true));
|
||||||
|
items.put("fileLevelBarrier", new ConfigItem<>("fileLevelBarrier", "fb", Level::parse, Level.WARNING, true));
|
||||||
|
items.put("consoleLevelBarrier", new ConfigItem<>("consoleLevelBarrier", "cb", Level::parse, Level.FINEST, true));
|
||||||
|
|
||||||
|
final var config = new Config();
|
||||||
|
config.load(items);
|
||||||
|
|
||||||
|
EnvoyLog.initialize(config);
|
||||||
|
EnvoyLog.attach("envoy");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Starts the server.
|
||||||
|
*
|
||||||
|
* @param args the run configuration. If it is "no-enter-to-stop" at position 0,
|
||||||
|
* no command to read in an enter press will be generated
|
||||||
|
* @throws IOException if the server crashes
|
||||||
|
* @since Envoy Server Standalone v0.1-alpha
|
||||||
|
*/
|
||||||
|
public static void main(String[] args) throws IOException {
|
||||||
|
initLogging();
|
||||||
|
|
||||||
|
final Server server = new Server(8080, ObjectMessageReader::new,
|
||||||
|
new ObjectMessageProcessor(Set.of(new LoginCredentialProcessor(),
|
||||||
|
new MessageProcessor(),
|
||||||
|
new GroupMessageProcessor(),
|
||||||
|
new GroupCreationProcessor(),
|
||||||
|
new MessageStatusChangeProcessor(),
|
||||||
|
new GroupMessageStatusChangeProcessor(),
|
||||||
|
new UserStatusChangeProcessor(),
|
||||||
|
new IDGeneratorRequestProcessor(),
|
||||||
|
new ContactSearchProcessor(),
|
||||||
|
new ContactOperationProcessor())));
|
||||||
|
|
||||||
|
// Initialize the current message ID
|
||||||
|
final PersistenceManager persistenceManager = PersistenceManager.getInstance();
|
||||||
|
if (persistenceManager.getConfigItemByID("currentMessageId") == null)
|
||||||
|
persistenceManager.addConfigItem(new envoy.server.data.ConfigItem("currentMessageId", "0"));
|
||||||
|
|
||||||
|
server.start();
|
||||||
|
server.getSocketProcessor().registerSocketIdListener(ConnectionManager.getInstance());
|
||||||
|
|
||||||
|
if (args.length == 0 || !args[0].equalsIgnoreCase("no-enter-to-stop")) {
|
||||||
|
System.out.println("Press the return key to stop the server...");
|
||||||
|
System.in.read();
|
||||||
|
System.out.println("Stopped");
|
||||||
|
System.exit(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
65
src/main/java/envoy/server/data/ConfigItem.java
Executable file
65
src/main/java/envoy/server/data/ConfigItem.java
Executable file
@ -0,0 +1,65 @@
|
|||||||
|
package envoy.server.data;
|
||||||
|
|
||||||
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.Id;
|
||||||
|
import javax.persistence.Table;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Project: <strong>envoy-server-standalone</strong><br>
|
||||||
|
* File: <strong>ConfigItem.java</strong><br>
|
||||||
|
* Created: <strong>28 Jan 2020</strong><br>
|
||||||
|
*
|
||||||
|
* @author Kai S. K. Engelbart
|
||||||
|
* @since Envoy Server Standalone v0.1-alpha
|
||||||
|
*/
|
||||||
|
@Entity
|
||||||
|
@Table(name = "configuration")
|
||||||
|
public class ConfigItem {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
private String key;
|
||||||
|
private String value;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an instance of @link{ConfigItem}.
|
||||||
|
*
|
||||||
|
* @since Envoy Server Standalone v0.1-alpha
|
||||||
|
*/
|
||||||
|
public ConfigItem() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an instance of @link{ConfigItem}.
|
||||||
|
*
|
||||||
|
* @param key the name of this {@link ConfigItem}
|
||||||
|
* @param value the value of this {@link ConfigItem}
|
||||||
|
* @since Envoy Server Standalone v0.1-alpha
|
||||||
|
*/
|
||||||
|
public ConfigItem(String key, String value) {
|
||||||
|
this.key = key;
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the key
|
||||||
|
* @since Envoy Server Standalone v0.1-alpha
|
||||||
|
*/
|
||||||
|
public String getKey() { return key; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param key the key to set
|
||||||
|
* @since Envoy Server Standalone v0.1-alpha
|
||||||
|
*/
|
||||||
|
public void setKey(String key) { this.key = key; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the value
|
||||||
|
* @since Envoy Server Standalone v0.1-alpha
|
||||||
|
*/
|
||||||
|
public String getValue() { return value; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param value the value to set
|
||||||
|
* @since Envoy Server Standalone v0.1-alpha
|
||||||
|
*/
|
||||||
|
public void setValue(String value) { this.value = value; }
|
||||||
|
}
|
107
src/main/java/envoy/server/data/Contact.java
Normal file
107
src/main/java/envoy/server/data/Contact.java
Normal file
@ -0,0 +1,107 @@
|
|||||||
|
package envoy.server.data;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
import javax.persistence.*;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class acts as a superclass for all contacts, being {@link User}s and
|
||||||
|
* {@link Group}s. <br>
|
||||||
|
* <br>
|
||||||
|
* Project: <strong>envoy-server-standalone</strong><br>
|
||||||
|
* File: <strong>Contact.java</strong><br>
|
||||||
|
* Created: <strong>24.03.2020</strong><br>
|
||||||
|
*
|
||||||
|
* @author Maximilian Käfer
|
||||||
|
* @since Envoy Server Standalone v0.1-alpha
|
||||||
|
*/
|
||||||
|
|
||||||
|
@Entity
|
||||||
|
@Table(name = "contacts")
|
||||||
|
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
|
||||||
|
public abstract class Contact {
|
||||||
|
|
||||||
|
@Id
|
||||||
|
@GeneratedValue
|
||||||
|
protected long id;
|
||||||
|
protected String name;
|
||||||
|
|
||||||
|
@Column(name = "creation_date")
|
||||||
|
private LocalDateTime creationDate;
|
||||||
|
|
||||||
|
@ManyToMany(fetch = FetchType.EAGER)
|
||||||
|
protected Set<Contact> contacts;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return a {@link envoy.data.Contact} object of this envoy.server.data.Contact
|
||||||
|
* object.
|
||||||
|
* @since Envoy Server Standalone v0.1-beta
|
||||||
|
*/
|
||||||
|
public abstract envoy.data.Contact toCommon();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Transforms this contact into a {@link envoy.data.Contact} where the contacts
|
||||||
|
* set of contacts is empty.
|
||||||
|
*
|
||||||
|
* @return a {@link envoy.data.Contact} object of this contact
|
||||||
|
* object.
|
||||||
|
* @since Envoy Server Standalone v0.1-beta
|
||||||
|
*/
|
||||||
|
protected abstract envoy.data.Contact toFlatCommon();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the ID of this contact.
|
||||||
|
* @since Envoy Server Standalone v0.1-beta
|
||||||
|
*/
|
||||||
|
public long getID() { return id; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the ID of this contact.
|
||||||
|
*
|
||||||
|
* @param id to set for this contact
|
||||||
|
* @since Envoy Server Standalone v0.1-beta
|
||||||
|
*/
|
||||||
|
public void setID(long id) { this.id = id; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the name of this contact.
|
||||||
|
* @since Envoy Server Standalone v0.1-beta
|
||||||
|
*/
|
||||||
|
public String getName() { return name; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the name of this contact.
|
||||||
|
*
|
||||||
|
* @param name to set for this contact
|
||||||
|
* @since Envoy Server Standalone v0.1-beta
|
||||||
|
*/
|
||||||
|
public void setName(String name) { this.name = name; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the contacts
|
||||||
|
* @since Envoy Server Standalone v0.1-beta
|
||||||
|
*/
|
||||||
|
public Set<Contact> getContacts() { return contacts; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param contacts the contacts to set
|
||||||
|
* @since Envoy Server Standalone v0.1-beta
|
||||||
|
*/
|
||||||
|
public void setContacts(Set<Contact> contacts) { this.contacts = contacts; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the creationDate
|
||||||
|
* @since Envoy Server Standalone v0.1-beta
|
||||||
|
*/
|
||||||
|
public LocalDateTime getCreationDate() { return creationDate; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param creationDate the creationDate to set
|
||||||
|
* @since Envoy Server Standalone v0.1-beta
|
||||||
|
*/
|
||||||
|
public void setCreationDate(LocalDateTime creationDate) { this.creationDate = creationDate; }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString() { return String.format("%s[id=%d,name=%s, %d contact(s)]", getClass().getSimpleName(), id, name, contacts.size()); }
|
||||||
|
}
|
54
src/main/java/envoy/server/data/Group.java
Normal file
54
src/main/java/envoy/server/data/Group.java
Normal file
@ -0,0 +1,54 @@
|
|||||||
|
package envoy.server.data;
|
||||||
|
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import javax.persistence.Entity;
|
||||||
|
import javax.persistence.NamedQueries;
|
||||||
|
import javax.persistence.NamedQuery;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a group inside the database. Referred to as "server group" as
|
||||||
|
* opposed to "group" from Envoy Common.<br>
|
||||||
|
* <br>
|
||||||
|
* Project: <strong>envoy-server-standalone</strong><br>
|
||||||
|
* File: <strong>Group.java</strong><br>
|
||||||
|
* Created: <strong>24.03.2020</strong><br>
|
||||||
|
*
|
||||||
|
* @author Maximilian Käfer
|
||||||
|
* @since Envoy Server Standalone v0.1-alpha
|
||||||
|
*/
|
||||||
|
@Entity
|
||||||
|
@NamedQueries({
|
||||||
|
@NamedQuery(
|
||||||
|
name = Group.findByName,
|
||||||
|
query = "SELECT g FROM Group g WHERE g.name = :name"
|
||||||
|
),
|
||||||
|
@NamedQuery(
|
||||||
|
name = Group.findPendingGroups,
|
||||||
|
query = "SELECT g FROM Group g WHERE g.creationDate > :lastSeen AND :user MEMBER OF g.contacts"
|
||||||
|
)
|
||||||
|
})
|
||||||
|
public class Group extends Contact {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Named query retrieving a group by name (parameter {@code :name}).
|
||||||
|
*
|
||||||
|
* @since Envoy Server Standalone v0.1-beta
|
||||||
|
*/
|
||||||
|
public static final String findByName = "Group.findByName";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Named query retrieving all pending groups for a specific user (parameter {@code :user}, {@code :lastSeen}).
|
||||||
|
*
|
||||||
|
* @since Envoy Server Standalone v0.1-beta
|
||||||
|
*/
|
||||||
|
public static final String findPendingGroups = "Group.findPendingGroups";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public envoy.data.Group toCommon() {
|
||||||
|
return new envoy.data.Group(id, name, contacts.parallelStream().map(User.class::cast).map(User::toFlatCommon).collect(Collectors.toSet()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected envoy.data.Group toFlatCommon() { return toCommon(); }
|
||||||
|
}
|
104
src/main/java/envoy/server/data/GroupMessage.java
Normal file
104
src/main/java/envoy/server/data/GroupMessage.java
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
package envoy.server.data;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import javax.persistence.*;
|
||||||
|
|
||||||
|
import envoy.data.Group;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Project: <strong>envoy-server-standalone</strong><br>
|
||||||
|
* File: <strong>GroupMessage.java</strong><br>
|
||||||
|
* Created: <strong>18.04.2020</strong><br>
|
||||||
|
*
|
||||||
|
* @author Maximilian Käfer
|
||||||
|
* @since Envoy Server Standalone v0.1-beta
|
||||||
|
*/
|
||||||
|
@Entity
|
||||||
|
@NamedQuery(
|
||||||
|
name = GroupMessage.getPendingGroupMsg,
|
||||||
|
query = "SELECT m FROM GroupMessage m JOIN m.memberMessageStatus s WHERE (KEY(s) = :userId) AND ((m.creationDate > :lastSeen)"
|
||||||
|
+ "OR ((m.status = envoy.data.Message$MessageStatus.RECEIVED) AND (m.receivedDate > :lastSeen))"
|
||||||
|
+ "OR ((m.status = envoy.data.Message$MessageStatus.READ) AND (m.readDate > :lastSeen))"
|
||||||
|
+ "OR ((m.lastStatusChangeDate > :lastSeen)))"
|
||||||
|
)
|
||||||
|
public class GroupMessage extends Message {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Named query retrieving pending group messages sent to a group containing a
|
||||||
|
* specific user (parameter {@code userId}) that were sent after a certain time
|
||||||
|
* stamp (parameter {@code :lastSeen}).
|
||||||
|
*
|
||||||
|
* @since Envoy Server Standalone v0.1-beta
|
||||||
|
*/
|
||||||
|
public static final String getPendingGroupMsg = "GroupMessage.getPendingGroupMsg";
|
||||||
|
|
||||||
|
@ElementCollection
|
||||||
|
private Map<Long, envoy.data.Message.MessageStatus> memberMessageStatus;
|
||||||
|
|
||||||
|
@Column(name = "last_status_change_date")
|
||||||
|
protected LocalDateTime lastStatusChangeDate;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The constructor for a database object.
|
||||||
|
*
|
||||||
|
* @since Envoy Server Standalone v0.1-beta
|
||||||
|
*/
|
||||||
|
public GroupMessage() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Constructs a database groupMessage from a common groupMessage.
|
||||||
|
*
|
||||||
|
* @param groupMessage the {@link envoy.data.GroupMessage} to convert
|
||||||
|
* into a
|
||||||
|
* database {@link GroupMessage}
|
||||||
|
* @param lastStatusChangeDate the time stamp to set
|
||||||
|
* @since Envoy Server Standalone v0.1-beta
|
||||||
|
*/
|
||||||
|
public GroupMessage(envoy.data.GroupMessage groupMessage, LocalDateTime lastStatusChangeDate) {
|
||||||
|
super(groupMessage);
|
||||||
|
memberMessageStatus = groupMessage.getMemberStatuses();
|
||||||
|
this.lastStatusChangeDate = lastStatusChangeDate;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Converts this groupMessage into an instance of
|
||||||
|
* {@link envoy.data.GroupMessage}.
|
||||||
|
*
|
||||||
|
* @return a {@link envoy.data.GroupMessage} containing the same values as this
|
||||||
|
* groupMessage
|
||||||
|
* @since Envoy Server Standalone v0.1-beta
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public envoy.data.GroupMessage toCommon() {
|
||||||
|
return prepareBuilder().buildGroupMessage((Group) recipient.toCommon(), new HashMap<>(memberMessageStatus));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the memberMessageStatus
|
||||||
|
* @since Envoy Server Standalone v0.1-beta
|
||||||
|
*/
|
||||||
|
public Map<Long, envoy.data.Message.MessageStatus> getMemberMessageStatus() { return memberMessageStatus; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param memberMessageStatus the memberMessageStatus to set
|
||||||
|
* @since Envoy Server Standalone v0.1-beta
|
||||||
|
*/
|
||||||
|
public void setMemberMessageStatus(Map<Long, envoy.data.Message.MessageStatus> memberMessageStatus) {
|
||||||
|
this.memberMessageStatus = memberMessageStatus;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the date at which one of the member statuses changed last
|
||||||
|
* @since Envoy Server Standalone v0.1-beta
|
||||||
|
*/
|
||||||
|
public LocalDateTime getLastStatusChangeDate() { return lastStatusChangeDate; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param date the date to set
|
||||||
|
* @since Envoy Server Standalone v0.1-beta
|
||||||
|
*/
|
||||||
|
public void setLastStatusChangeDate(LocalDateTime date) { lastStatusChangeDate = date; }
|
||||||
|
}
|
290
src/main/java/envoy/server/data/Message.java
Executable file
290
src/main/java/envoy/server/data/Message.java
Executable file
@ -0,0 +1,290 @@
|
|||||||
|
package envoy.server.data;
|
||||||
|
|
||||||
|
import static envoy.data.Message.MessageStatus.*;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
import javax.persistence.*;
|
||||||
|
|
||||||
|
import envoy.data.Attachment;
|
||||||
|
import envoy.data.Attachment.AttachmentType;
|
||||||
|
import envoy.data.Message.MessageStatus;
|
||||||
|
import envoy.data.MessageBuilder;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class serves as a way to let Hibernate communicate with the server
|
||||||
|
* without bringing the dependency of JPA/Hibernate into the client.<br>
|
||||||
|
* It will be referenced as "database message" to clarify between the different
|
||||||
|
* message objects.<br>
|
||||||
|
* <br>
|
||||||
|
* Project: <strong>envoy-server-standalone</strong><br>
|
||||||
|
* File: <strong>Message.java</strong><br>
|
||||||
|
* Created: <strong>02.01.2020</strong><br>
|
||||||
|
*
|
||||||
|
* @author Kai S. K. Engelbart
|
||||||
|
* @since Envoy Server Standalone v0.1-alpha
|
||||||
|
*/
|
||||||
|
@Entity
|
||||||
|
@Table(name = "messages")
|
||||||
|
@Inheritance(strategy = InheritanceType.SINGLE_TABLE)
|
||||||
|
@NamedQuery(
|
||||||
|
name = Message.getPending,
|
||||||
|
query = "SELECT m FROM Message m WHERE (m.recipient = :user AND m.status = envoy.data.Message$MessageStatus.SENT) "
|
||||||
|
+ "OR (m.sender = :user) AND ((m.status = envoy.data.Message$MessageStatus.RECEIVED) AND (m.receivedDate > :lastSeen)"
|
||||||
|
+ "OR (m.status = envoy.data.Message$MessageStatus.READ) AND (m.readDate > :lastSeen))"
|
||||||
|
)
|
||||||
|
public class Message {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Named query retrieving pending messages for a user (parameter {@code :user})
|
||||||
|
* which was last seen after a specific date (parameter {@code :lastSeen}).
|
||||||
|
*
|
||||||
|
* @since Envoy Server Standalone v0.1-beta
|
||||||
|
*/
|
||||||
|
public static final String getPending = "Message.getPending";
|
||||||
|
|
||||||
|
@Id
|
||||||
|
protected long id;
|
||||||
|
|
||||||
|
@ManyToOne
|
||||||
|
@JoinColumn
|
||||||
|
protected User sender;
|
||||||
|
|
||||||
|
@ManyToOne
|
||||||
|
@JoinColumn
|
||||||
|
protected Contact recipient;
|
||||||
|
|
||||||
|
@Column(name = "creation_date")
|
||||||
|
protected LocalDateTime creationDate;
|
||||||
|
|
||||||
|
@Column(name = "received_date")
|
||||||
|
protected LocalDateTime receivedDate;
|
||||||
|
|
||||||
|
@Column(name = "read_date")
|
||||||
|
protected LocalDateTime readDate;
|
||||||
|
|
||||||
|
protected String text;
|
||||||
|
protected envoy.data.Message.MessageStatus status;
|
||||||
|
protected AttachmentType attachmentType;
|
||||||
|
protected byte[] attachment;
|
||||||
|
protected boolean forwarded;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The constructor for a database object.
|
||||||
|
*
|
||||||
|
* @since Envoy Server Standalone v0.1-alpha
|
||||||
|
*/
|
||||||
|
public 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
|
||||||
|
*/
|
||||||
|
public Message(envoy.data.Message message) {
|
||||||
|
PersistenceManager persistenceManager = PersistenceManager.getInstance();
|
||||||
|
id = message.getID();
|
||||||
|
status = message.getStatus();
|
||||||
|
text = message.getText();
|
||||||
|
creationDate = message.getCreationDate();
|
||||||
|
receivedDate = message.getReceivedDate();
|
||||||
|
readDate = message.getReadDate();
|
||||||
|
sender = persistenceManager.getUserByID(message.getSenderID());
|
||||||
|
recipient = persistenceManager.getContactByID(message.getRecipientID());
|
||||||
|
forwarded = message.isForwarded();
|
||||||
|
if (message.hasAttachment()) {
|
||||||
|
attachment = message.getAttachment().getData();
|
||||||
|
attachmentType = message.getAttachment().getType();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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
|
||||||
|
*/
|
||||||
|
public envoy.data.Message toCommon() {
|
||||||
|
return prepareBuilder().build();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return a message builder containing the state of this message
|
||||||
|
* @since Envoy Server Standalone v0.1-beta
|
||||||
|
*/
|
||||||
|
MessageBuilder prepareBuilder() {
|
||||||
|
var builder = new MessageBuilder(sender.getID(), recipient.getID(), id).setText(
|
||||||
|
text)
|
||||||
|
.setCreationDate(creationDate)
|
||||||
|
.setReceivedDate(receivedDate)
|
||||||
|
.setReadDate(readDate)
|
||||||
|
.setStatus(status)
|
||||||
|
.setForwarded(forwarded);
|
||||||
|
if (attachment != null) builder.setAttachment(new Attachment(attachment, attachmentType));
|
||||||
|
return builder;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the message status to {@link MessageStatus#RECEIVED} and sets the
|
||||||
|
* current time stamp as the received date.
|
||||||
|
*
|
||||||
|
* @since Envoy Server Standalone v0.1-beta
|
||||||
|
*/
|
||||||
|
public void received() {
|
||||||
|
receivedDate = LocalDateTime.now();
|
||||||
|
status = RECEIVED;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the message status to {@link MessageStatus#READ} and sets the
|
||||||
|
* current time stamp as the read date.
|
||||||
|
*
|
||||||
|
* @since Envoy Server Standalone v0.1-beta
|
||||||
|
*/
|
||||||
|
public void read() {
|
||||||
|
readDate = LocalDateTime.now();
|
||||||
|
status = READ;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the id of a {link envoy.data.Message}
|
||||||
|
* @since Envoy Server Standalone v0.1-alpha
|
||||||
|
*/
|
||||||
|
public long getID() { return id; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param id the id to set
|
||||||
|
* @since Envoy Server Standalone v0.1-alpha
|
||||||
|
* @see Message#getID()
|
||||||
|
*/
|
||||||
|
public void setId(long id) { this.id = id; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the sender of a {link envoy.data.Message}
|
||||||
|
* @since Envoy Server Standalone v0.1-alpha
|
||||||
|
*/
|
||||||
|
public User getSender() { return sender; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param sender the sender to set
|
||||||
|
* @since Envoy Server Standalone v0.1-alpha
|
||||||
|
* @see Message#getSender()
|
||||||
|
*/
|
||||||
|
public void setSender(User sender) { this.sender = sender; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the recipient of a {link envoy.data.Message}
|
||||||
|
* @since Envoy Server Standalone v0.1-alpha
|
||||||
|
*/
|
||||||
|
public Contact getRecipient() { return recipient; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param recipient the recipient to set
|
||||||
|
* @since Envoy Server Standalone v0.1-alpha
|
||||||
|
* @see Message#getRecipient()
|
||||||
|
*/
|
||||||
|
public void setRecipient(User recipient) { this.recipient = recipient; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the date at which a {link envoy.data.Message} has been created
|
||||||
|
* @since Envoy Server Standalone v0.1-alpha
|
||||||
|
*/
|
||||||
|
public LocalDateTime getCreationDate() { return creationDate; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param creationDate the creation date to set
|
||||||
|
* @since Envoy Server Standalone v0.1-alpha
|
||||||
|
* @see Message#getCreationDate()
|
||||||
|
*/
|
||||||
|
public void setCreationDate(LocalDateTime creationDate) { this.creationDate = creationDate; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the date at which a {link envoy.data.Message} has been received by
|
||||||
|
* the server
|
||||||
|
* @since Envoy Server Standalone v0.1-alpha
|
||||||
|
*/
|
||||||
|
public LocalDateTime getReceivedDate() { return receivedDate; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param receivedDate the received date to set
|
||||||
|
* @since Envoy Server Standalone v0.1-alpha
|
||||||
|
* @see Message#getReceivedDate()
|
||||||
|
*/
|
||||||
|
public void setReceivedDate(LocalDateTime receivedDate) { this.receivedDate = receivedDate; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the date at which a {link envoy.data.Message} has been read
|
||||||
|
* @since Envoy Server Standalone v0.1-alpha
|
||||||
|
*/
|
||||||
|
public LocalDateTime getReadDate() { return readDate; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param readDate the read date to set
|
||||||
|
* @since Envoy Server Standalone v0.1-alpha
|
||||||
|
* @see Message#getReadDate()
|
||||||
|
*/
|
||||||
|
public void setReadDate(LocalDateTime readDate) { this.readDate = readDate; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the status of a {link envoy.data.Message}
|
||||||
|
* @since Envoy Server Standalone v0.1-alpha
|
||||||
|
*/
|
||||||
|
public envoy.data.Message.MessageStatus getStatus() { return status; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param status the new status of a {link envoy.data.Message}
|
||||||
|
* @since Envoy Server Standalone v0.1-alpha
|
||||||
|
*/
|
||||||
|
public void setStatus(envoy.data.Message.MessageStatus status) { this.status = status; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the text content of a {link envoy.data.Message}
|
||||||
|
* @since Envoy Server Standalone v0.1-alpha
|
||||||
|
*/
|
||||||
|
public String getText() { return text; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param text the new text content of a {@link envoy.data.Message}
|
||||||
|
* @since Envoy Server Standalone v0.1-alpha
|
||||||
|
*/
|
||||||
|
public void setText(String text) { this.text = text; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the attachment of a {@link envoy.data.Message}
|
||||||
|
* @since Envoy Server Standalone v0.1-alpha
|
||||||
|
*/
|
||||||
|
public byte[] getAttachment() { return attachment; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param attachment the new attachment
|
||||||
|
* @since Envoy Server Standalone v0.1-alpha
|
||||||
|
*/
|
||||||
|
public void setAttachment(byte[] attachment) { this.attachment = attachment; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the attachmentType
|
||||||
|
* @since Envoy Server Standalone v0.1-beta
|
||||||
|
*/
|
||||||
|
public AttachmentType getAttachmentType() { return attachmentType; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param attachmentType the attachmentType to set
|
||||||
|
* @since Envoy Server Standalone v0.1-beta
|
||||||
|
*/
|
||||||
|
public void setAttachmentType(AttachmentType attachmentType) { this.attachmentType = attachmentType; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @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; }
|
||||||
|
}
|
281
src/main/java/envoy/server/data/PersistenceManager.java
Executable file
281
src/main/java/envoy/server/data/PersistenceManager.java
Executable file
@ -0,0 +1,281 @@
|
|||||||
|
package envoy.server.data;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import javax.persistence.EntityManager;
|
||||||
|
import javax.persistence.EntityTransaction;
|
||||||
|
import javax.persistence.Persistence;
|
||||||
|
|
||||||
|
import envoy.data.User.UserStatus;
|
||||||
|
import envoy.server.net.ConnectionManager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Project: <strong>envoy-server-standalone</strong><br>
|
||||||
|
* File: <strong>PersistenceManager.java</strong><br>
|
||||||
|
* Created: <strong>1 Jan 2020</strong><br>
|
||||||
|
*
|
||||||
|
* @author Leon Hofmeister
|
||||||
|
* @author Maximilian Käfer
|
||||||
|
* @since Envoy Server Standalone v0.1-alpha
|
||||||
|
*/
|
||||||
|
public class PersistenceManager {
|
||||||
|
|
||||||
|
private final EntityManager entityManager = Persistence.createEntityManagerFactory("envoy").createEntityManager();
|
||||||
|
private final EntityTransaction transaction = entityManager.getTransaction();
|
||||||
|
|
||||||
|
private static final PersistenceManager persistenceManager = new PersistenceManager();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates the singleton instance of the @link{PersistenceManager}.
|
||||||
|
*
|
||||||
|
* @since Envoy Server Standalone v0.1-alpha
|
||||||
|
*/
|
||||||
|
private PersistenceManager() {
|
||||||
|
Runtime.getRuntime().addShutdownHook(new Thread(() -> {
|
||||||
|
transaction.begin();
|
||||||
|
ConnectionManager.getInstance()
|
||||||
|
.getOnlineUsers()
|
||||||
|
.stream()
|
||||||
|
.map(this::getUserByID)
|
||||||
|
.forEach(user -> { user.setStatus(UserStatus.OFFLINE); user.setLastSeen(LocalDateTime.now()); entityManager.merge(user); });
|
||||||
|
transaction.commit();
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the {@link PersistenceManager} singleton
|
||||||
|
* @since Envoy Server Standalone v0.1-alpha
|
||||||
|
*/
|
||||||
|
public static PersistenceManager getInstance() { return persistenceManager; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a {@link Contact} to the database.
|
||||||
|
*
|
||||||
|
* @param contact the {@link Contact} to add to the database
|
||||||
|
* @since Envoy Server Standalone v0.1-alpha
|
||||||
|
*/
|
||||||
|
public void addContact(Contact contact) { persist(contact); }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a {@link Message} to the database.
|
||||||
|
*
|
||||||
|
* @param message the {@link Message} to add to the database
|
||||||
|
* @since Envoy Server Standalone v0.1-alpha
|
||||||
|
*/
|
||||||
|
public void addMessage(Message message) { persist(message); }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a {@link ConfigItem} to the database.
|
||||||
|
*
|
||||||
|
* @param configItem the {@link ConfigItem} to add to the database
|
||||||
|
* @since Envoy Server Standalone v0.1-alpha
|
||||||
|
*/
|
||||||
|
public void addConfigItem(ConfigItem configItem) { persist(configItem); }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates a {@link Contact} in the database
|
||||||
|
*
|
||||||
|
* @param contact the {@link Contact} to add to the database
|
||||||
|
* @since Envoy Server Standalone v0.1-alpha
|
||||||
|
*/
|
||||||
|
public void updateContact(Contact contact) { merge(contact); }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates a {@link Message} in the database.
|
||||||
|
*
|
||||||
|
* @param message the message to update
|
||||||
|
* @since Envoy Server Standalone v0.1-alpha
|
||||||
|
*/
|
||||||
|
public void updateMessage(Message message) { merge(message); }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Updates a {@link ConfigItem} in the database.
|
||||||
|
*
|
||||||
|
* @param configItem the configItem to update
|
||||||
|
* @since Envoy Server Standalone v0.1-alpha
|
||||||
|
*/
|
||||||
|
public void updateConfigItem(ConfigItem configItem) { merge(configItem); }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deletes a {@link Contact} in the database.
|
||||||
|
*
|
||||||
|
* @param contact the {@link Contact} to delete
|
||||||
|
* @since Envoy Server Standalone v0.1-alpha
|
||||||
|
*/
|
||||||
|
public void deleteContact(Contact contact) { remove(contact); }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Deletes a {@link Message} in the database.
|
||||||
|
*
|
||||||
|
* @param message the {@link Message} to delete
|
||||||
|
* @since Envoy Server Standalone v0.1-alpha
|
||||||
|
*/
|
||||||
|
public void deleteMessage(Message message) { remove(message); }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Searches for a {@link User} with a specific ID.
|
||||||
|
*
|
||||||
|
* @param id the id to search for
|
||||||
|
* @return the user with the specified ID or {@code null} if none was found
|
||||||
|
* @since Envoy Server Standalone v0.1-alpha
|
||||||
|
*/
|
||||||
|
public User getUserByID(long id) { return entityManager.find(User.class, id); }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Searches for a {@link Group} with a specific ID.
|
||||||
|
*
|
||||||
|
* @param id the id to search for
|
||||||
|
* @return the group with the specified ID or {@code null} if none was found
|
||||||
|
* @since Envoy Server Standalone v0.1-beta
|
||||||
|
*/
|
||||||
|
public Group getGroupByID(long id) { return entityManager.find(Group.class, id); }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Searches for a {@link Contact} with a specific ID.
|
||||||
|
*
|
||||||
|
* @param id the id to search for
|
||||||
|
* @return the contact with the specified ID or {@code null} if none was found
|
||||||
|
* @since Envoy Server Standalone v0.1-beta
|
||||||
|
*/
|
||||||
|
public Contact getContactByID(long id) { return entityManager.find(Contact.class, id); }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Searched for a {@link User} with a specific name.
|
||||||
|
*
|
||||||
|
* @param name the name of the user
|
||||||
|
* @return the user with the specified name
|
||||||
|
* @since Envoy Server Standalone v0.1-alpha
|
||||||
|
*/
|
||||||
|
public User getUserByName(String name) {
|
||||||
|
return (User) entityManager.createNamedQuery(User.findByName).setParameter("name", name).getSingleResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Searched for a {@link Group} with a specific name.
|
||||||
|
*
|
||||||
|
* @param name the name of the group
|
||||||
|
* @return the group with the specified name
|
||||||
|
* @since Envoy Server Standalone v0.1-alpha
|
||||||
|
*/
|
||||||
|
public Group getGroupByName(String name) {
|
||||||
|
return (Group) entityManager.createNamedQuery(Group.findByName).setParameter("name", name).getSingleResult();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Searches for a {@link Message} with a specific id.
|
||||||
|
*
|
||||||
|
* @param id the id to search for
|
||||||
|
* @return the message with the specified ID or {@code null} if none is found
|
||||||
|
* @since Envoy Server Standalone v0.1-alpha
|
||||||
|
*/
|
||||||
|
public Message getMessageByID(long id) { return entityManager.find(Message.class, id); }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param key the name of this {@link ConfigItem}
|
||||||
|
* @return the {@link ConfigItem} with the given name
|
||||||
|
* @since Envoy Server Standalone v0.1-alpha
|
||||||
|
*/
|
||||||
|
public ConfigItem getConfigItemByID(String key) { return entityManager.find(ConfigItem.class, key); }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns all messages received while being offline or the ones that have
|
||||||
|
* changed.
|
||||||
|
*
|
||||||
|
* @param user the user who wants to receive his unread messages
|
||||||
|
* @return all messages that the client does not yet have (unread messages)
|
||||||
|
* @since Envoy Server Standalone v0.1-alpha
|
||||||
|
*/
|
||||||
|
public List<Message> getPendingMessages(User user) {
|
||||||
|
return entityManager
|
||||||
|
.createNamedQuery(Message.getPending)
|
||||||
|
.setParameter("user", user)
|
||||||
|
.setParameter("lastSeen", user.getLastSeen())
|
||||||
|
.getResultList();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns all groupMessages received while being offline or the ones that have
|
||||||
|
* changed.
|
||||||
|
*
|
||||||
|
* @param user the user who wants to receive his unread groupMessages
|
||||||
|
* @return all groupMessages that the client does not yet have (unread
|
||||||
|
* groupMessages)
|
||||||
|
* @since Envoy Server Standalone v0.1-alpha
|
||||||
|
*/
|
||||||
|
public List<GroupMessage> getPendingGroupMessages(User user) {
|
||||||
|
return entityManager.createNamedQuery(GroupMessage.getPendingGroupMsg)
|
||||||
|
.setParameter("userId", user.getID())
|
||||||
|
.setParameter("lastSeen", user.getLastSeen())
|
||||||
|
.getResultList();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Searches for users matching a search phrase. Contacts of the attached user
|
||||||
|
* and the attached user is ignored.
|
||||||
|
*
|
||||||
|
* @param searchPhrase the search phrase
|
||||||
|
* @param userId the ID of the user in whose context the search is
|
||||||
|
* performed
|
||||||
|
* @return a list of all users who matched the criteria
|
||||||
|
* @since Envoy Server Standalone v0.1-alpha
|
||||||
|
*/
|
||||||
|
public List<User> searchUsers(String searchPhrase, long userId) {
|
||||||
|
return entityManager.createNamedQuery(
|
||||||
|
User.searchByName)
|
||||||
|
.setParameter("searchPhrase", searchPhrase + "%")
|
||||||
|
.setParameter("context", getUserByID(userId))
|
||||||
|
.getResultList();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds a contact to the contact list of another contact and vice versa.
|
||||||
|
*
|
||||||
|
* @param contactID1 the ID of the first contact
|
||||||
|
* @param contactID2 the ID of the second contact
|
||||||
|
* @since Envoy Server Standalone v0.1-alpha
|
||||||
|
*/
|
||||||
|
public void addContactBidirectional(long contactID1, long contactID2) {
|
||||||
|
|
||||||
|
// Get users by ID
|
||||||
|
Contact c1 = getContactByID(contactID1);
|
||||||
|
Contact c2 = getContactByID(contactID2);
|
||||||
|
|
||||||
|
// Add users to each others contact lists
|
||||||
|
c1.getContacts().add(c2);
|
||||||
|
c2.getContacts().add(c1);
|
||||||
|
|
||||||
|
// Synchronize changes with the database
|
||||||
|
transaction.begin();
|
||||||
|
entityManager.merge(c1);
|
||||||
|
entityManager.merge(c2);
|
||||||
|
transaction.commit();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param user the User whose contacts should be retrieved
|
||||||
|
* @return the contacts of this User
|
||||||
|
* @since Envoy Server Standalone v0.1-alpha
|
||||||
|
*/
|
||||||
|
public List<User> getContacts(User user) {
|
||||||
|
return entityManager.createNamedQuery(User.findContacts).setParameter("user", user).getResultList();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void persist(Object obj) {
|
||||||
|
transaction.begin();
|
||||||
|
entityManager.persist(obj);
|
||||||
|
transaction.commit();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void merge(Object obj) {
|
||||||
|
transaction.begin();
|
||||||
|
entityManager.merge(obj);
|
||||||
|
transaction.commit();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void remove(Object obj) {
|
||||||
|
transaction.begin();
|
||||||
|
entityManager.remove(obj);
|
||||||
|
transaction.commit();
|
||||||
|
}
|
||||||
|
}
|
116
src/main/java/envoy/server/data/User.java
Executable file
116
src/main/java/envoy/server/data/User.java
Executable file
@ -0,0 +1,116 @@
|
|||||||
|
package envoy.server.data;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import javax.persistence.*;
|
||||||
|
|
||||||
|
import envoy.data.User.UserStatus;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class enables the storage of user specific data inside a database using
|
||||||
|
* Hibernate. Its objects will be referred to as database users as opposed to
|
||||||
|
* the common user objects present on both the client and the server.<br>
|
||||||
|
* <br>
|
||||||
|
* Project: <strong>envoy-server-standalone</strong><br>
|
||||||
|
* File: <strong>User.java</strong><br>
|
||||||
|
* Created: <strong>02.01.2020</strong><br>
|
||||||
|
*
|
||||||
|
* @author Kai S. K. Engelbart
|
||||||
|
* @author Maximilian Käfer
|
||||||
|
* @since Envoy Server Standalone v0.1-alpha
|
||||||
|
*/
|
||||||
|
@Entity
|
||||||
|
@NamedQueries({
|
||||||
|
@NamedQuery(
|
||||||
|
name = User.findByName,
|
||||||
|
query = "SELECT u FROM User u WHERE u.name = :name"
|
||||||
|
),
|
||||||
|
@NamedQuery(
|
||||||
|
name = User.findContacts,
|
||||||
|
query = "SELECT u.contacts FROM User u WHERE u = :user"
|
||||||
|
),
|
||||||
|
@NamedQuery(
|
||||||
|
name = User.searchByName,
|
||||||
|
query = "SELECT u FROM User u WHERE (lower(u.name) LIKE lower(:searchPhrase) AND u <> :context AND :context NOT MEMBER OF u.contacts)"
|
||||||
|
)
|
||||||
|
})
|
||||||
|
public class User extends Contact {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Named query retrieving a user by name (parameter {@code :name}).
|
||||||
|
*
|
||||||
|
* @since Envoy Server Standalone v0.1-beta
|
||||||
|
*/
|
||||||
|
public static final String findByName = "User.findByName";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Named query retrieving the contacts of a given user (parameter
|
||||||
|
* {@code :user}).
|
||||||
|
*
|
||||||
|
* @since Envoy Server Standalone v0.1-beta
|
||||||
|
*/
|
||||||
|
public static final String findContacts = "User.findContacts";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Named query searching for users with a name like a search phrase (parameter
|
||||||
|
* {@code :searchPhrase}) that are not in the contact list of a given user
|
||||||
|
* (parameter {@code :context}).
|
||||||
|
*
|
||||||
|
* @since Envoy Server Standalone v0.1-beta
|
||||||
|
*/
|
||||||
|
public static final String searchByName = "User.searchByName";
|
||||||
|
|
||||||
|
@Column(name = "password_hash")
|
||||||
|
private String passwordHash;
|
||||||
|
|
||||||
|
@Column(name = "last_seen")
|
||||||
|
private LocalDateTime lastSeen;
|
||||||
|
|
||||||
|
private UserStatus status;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public envoy.data.User toCommon() {
|
||||||
|
return new envoy.data.User(id, name, status, contacts.parallelStream().map(Contact::toFlatCommon).collect(Collectors.toSet()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected envoy.data.User toFlatCommon() { return new envoy.data.User(id, name, status, Set.of()); }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the password hash
|
||||||
|
* @since Envoy Server Standalone v0.1-beta
|
||||||
|
*/
|
||||||
|
public String getPasswordHash() { return passwordHash; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param passwordHash the password hash to set
|
||||||
|
* @since Envoy Server Standalone v0.1-beta
|
||||||
|
*/
|
||||||
|
public void setPasswordHash(String passwordHash) { this.passwordHash = passwordHash; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the last date the user has been online
|
||||||
|
* @since Envoy Server Standalone v0.1-alpha
|
||||||
|
*/
|
||||||
|
public LocalDateTime getLastSeen() { return lastSeen; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param lastSeen the latest date at which the user has been online to set
|
||||||
|
* @since Envoy Server Standalone v0.1-alpha
|
||||||
|
*/
|
||||||
|
public void setLastSeen(LocalDateTime lastSeen) { this.lastSeen = lastSeen; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the status
|
||||||
|
* @since Envoy Server Standalone v0.1-alpha
|
||||||
|
*/
|
||||||
|
public UserStatus getStatus() { return status; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param status the status to set
|
||||||
|
* @since Envoy Server Standalone v0.1-alpha
|
||||||
|
*/
|
||||||
|
public void setStatus(UserStatus status) { this.status = status; }
|
||||||
|
}
|
9
src/main/java/envoy/server/data/package-info.java
Executable file
9
src/main/java/envoy/server/data/package-info.java
Executable file
@ -0,0 +1,9 @@
|
|||||||
|
/**
|
||||||
|
* This package contains classes related to persistence.
|
||||||
|
*
|
||||||
|
* @author Kai S. K. Engelbart
|
||||||
|
* @author Leon Hofmeister
|
||||||
|
* @author Maximilian Käfer
|
||||||
|
* @since Envoy v0.1-alpha
|
||||||
|
*/
|
||||||
|
package envoy.server.data;
|
115
src/main/java/envoy/server/net/ConnectionManager.java
Executable file
115
src/main/java/envoy/server/net/ConnectionManager.java
Executable file
@ -0,0 +1,115 @@
|
|||||||
|
package envoy.server.net;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.*;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import com.jenkov.nioserver.ISocketIdListener;
|
||||||
|
|
||||||
|
import envoy.data.User.UserStatus;
|
||||||
|
import envoy.server.data.Group;
|
||||||
|
import envoy.server.data.PersistenceManager;
|
||||||
|
import envoy.server.processors.UserStatusChangeProcessor;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Project: <strong>envoy-server-standalone</strong><br>
|
||||||
|
* File: <strong>ConnectionManager.java</strong><br>
|
||||||
|
* Created: <strong>03.01.2020</strong><br>
|
||||||
|
*
|
||||||
|
* @author Kai S. K. Engelbart
|
||||||
|
* @since Envoy Server Standalone v0.1-alpha
|
||||||
|
*/
|
||||||
|
public class ConnectionManager implements ISocketIdListener {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Contains all socket IDs that have not yet performed a handshake / acquired
|
||||||
|
* their corresponding user ID.
|
||||||
|
*
|
||||||
|
* @since Envoy Server Standalone v0.1-alpha
|
||||||
|
*/
|
||||||
|
private Set<Long> pendingSockets = new HashSet<>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Contains all socket IDs that have acquired a user ID as keys to these IDs.
|
||||||
|
*
|
||||||
|
* @since Envoy Server Standalone v0.1-alpha
|
||||||
|
*/
|
||||||
|
private Map<Long, Long> sockets = new HashMap<>();
|
||||||
|
|
||||||
|
private static ConnectionManager connectionManager = new ConnectionManager();
|
||||||
|
|
||||||
|
private ConnectionManager() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return a singleton instance of this object
|
||||||
|
* @since Envoy Server Standalone v0.1-alpha
|
||||||
|
*/
|
||||||
|
public static ConnectionManager getInstance() { return connectionManager; }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void socketCancelled(long socketID) {
|
||||||
|
if (!pendingSockets.remove(socketID)) {
|
||||||
|
// Notify contacts of this users offline-going
|
||||||
|
envoy.server.data.User user = PersistenceManager.getInstance().getUserByID(getUserIDBySocketID(socketID));
|
||||||
|
user.setStatus(UserStatus.OFFLINE);
|
||||||
|
user.setLastSeen(LocalDateTime.now());
|
||||||
|
UserStatusChangeProcessor.updateUserStatus(user);
|
||||||
|
|
||||||
|
// Remove the socket
|
||||||
|
sockets.entrySet().removeIf(e -> e.getValue() == socketID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void socketRegistered(long socketID) { pendingSockets.add(socketID); }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Associates a socket ID with a user ID.
|
||||||
|
*
|
||||||
|
* @param userID the user ID
|
||||||
|
* @param socketID the socket ID
|
||||||
|
* @since Envoy Server Standalone v0.1-alpha
|
||||||
|
*/
|
||||||
|
public void registerUser(long userID, long socketID) {
|
||||||
|
sockets.put(userID, socketID);
|
||||||
|
pendingSockets.remove(socketID);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param userID the ID of the user registered at a socket
|
||||||
|
* @return the ID of the socket
|
||||||
|
* @since Envoy Server Standalone v0.1-alpha
|
||||||
|
*/
|
||||||
|
public long getSocketID(long userID) { return sockets.get(userID); }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param socketID the id of the socket whose User is needed
|
||||||
|
* @return the userId associated with this socketId
|
||||||
|
* @since Envoy Server Standalone v0.1-alpha
|
||||||
|
*/
|
||||||
|
public long getUserIDBySocketID(long socketID) {
|
||||||
|
return sockets.entrySet().stream().filter(entry -> entry.getValue().equals(socketID)).findFirst().get().getKey();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param userID the ID of the user to check for
|
||||||
|
* @return {@code true} if the user is online
|
||||||
|
* @since Envoy Server Standalone v0.1-alpha
|
||||||
|
*/
|
||||||
|
public boolean isOnline(long userID) { return sockets.containsKey(userID); }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the userIDs of all users who are currently online
|
||||||
|
* @since Envoy Server Standalone v0.1-alpha
|
||||||
|
*/
|
||||||
|
public Set<Long> getOnlineUsers() { return sockets.keySet(); }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param group the group to search for
|
||||||
|
* @return a set of all IDs of currently active members in this group
|
||||||
|
* @since Envoy Server Standalone v0.1-beta
|
||||||
|
*/
|
||||||
|
public Set<Long> getOnlineUsersOfGroup(Group group) {
|
||||||
|
return group.getContacts().stream().map(envoy.server.data.Contact::getID).filter(this::isOnline).collect(Collectors.toSet());
|
||||||
|
}
|
||||||
|
}
|
65
src/main/java/envoy/server/net/ObjectMessageProcessor.java
Executable file
65
src/main/java/envoy/server/net/ObjectMessageProcessor.java
Executable file
@ -0,0 +1,65 @@
|
|||||||
|
package envoy.server.net;
|
||||||
|
|
||||||
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.ObjectInputStream;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import com.jenkov.nioserver.IMessageProcessor;
|
||||||
|
import com.jenkov.nioserver.Message;
|
||||||
|
import com.jenkov.nioserver.WriteProxy;
|
||||||
|
|
||||||
|
import envoy.server.processors.ObjectProcessor;
|
||||||
|
import envoy.util.EnvoyLog;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Handles incoming objects.<br>
|
||||||
|
* <br>
|
||||||
|
* Project: <strong>envoy-server-standalone</strong><br>
|
||||||
|
* File: <strong>ObjectMessageProcessor.java</strong><br>
|
||||||
|
* Created: <strong>28.12.2019</strong><br>
|
||||||
|
*
|
||||||
|
* @author Kai S. K. Engelbart
|
||||||
|
* @since Envoy Server Standalone v0.1-alpha
|
||||||
|
*/
|
||||||
|
public class ObjectMessageProcessor implements IMessageProcessor {
|
||||||
|
|
||||||
|
private final Set<ObjectProcessor<?>> processors;
|
||||||
|
|
||||||
|
private static final Logger logger = EnvoyLog.getLogger(ObjectMessageProcessor.class);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The constructor to set the {@link ObjectProcessor}s.
|
||||||
|
*
|
||||||
|
* @param processors the {@link ObjectProcessor} to set
|
||||||
|
* @since Envoy Server Standalone v0.1-alpha
|
||||||
|
*/
|
||||||
|
public ObjectMessageProcessor(Set<ObjectProcessor<?>> processors) { this.processors = processors; }
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
@Override
|
||||||
|
public void process(Message message, WriteProxy writeProxy) {
|
||||||
|
try (ObjectInputStream in = new ObjectInputStream(new ByteArrayInputStream(message.sharedArray, message.offset + 4, message.length - 4))) {
|
||||||
|
Object obj = in.readObject();
|
||||||
|
if (obj == null) {
|
||||||
|
logger.warning("Received a null object");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.fine("Received " + obj);
|
||||||
|
|
||||||
|
// Process object
|
||||||
|
processors.stream().filter(p -> p.getInputClass().equals(obj.getClass())).forEach((@SuppressWarnings("rawtypes") ObjectProcessor p) -> {
|
||||||
|
try {
|
||||||
|
p.process(p.getInputClass().cast(obj), message.socketId, new ObjectWriteProxy(writeProxy));
|
||||||
|
} catch (IOException e) {
|
||||||
|
logger.log(Level.SEVERE, "Exception during processor execution: ", e);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} catch (IOException | ClassNotFoundException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
71
src/main/java/envoy/server/net/ObjectMessageReader.java
Executable file
71
src/main/java/envoy/server/net/ObjectMessageReader.java
Executable file
@ -0,0 +1,71 @@
|
|||||||
|
package envoy.server.net;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.ByteBuffer;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import com.jenkov.nioserver.*;
|
||||||
|
|
||||||
|
import envoy.util.SerializationUtils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This {@link IMessageReader} decodes serialized Java objects.<br>
|
||||||
|
* <br>
|
||||||
|
* Project: <strong>envoy-server-standalone</strong><br>
|
||||||
|
* File: <strong>ObjectMessageReader.java</strong><br>
|
||||||
|
* Created: <strong>28.12.2019</strong><br>
|
||||||
|
*
|
||||||
|
* @author Kai S. K. Engelbart
|
||||||
|
* @since Envoy Server Standalone v0.1-alpha
|
||||||
|
*/
|
||||||
|
public class ObjectMessageReader implements IMessageReader {
|
||||||
|
|
||||||
|
private List<Message> completeMessages = new ArrayList<>();
|
||||||
|
private Message nextMessage;
|
||||||
|
private MessageBuffer messageBuffer;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Message> getMessages() { return completeMessages; }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void init(MessageBuffer messageBuffer) {
|
||||||
|
this.messageBuffer = messageBuffer;
|
||||||
|
nextMessage = messageBuffer.getMessage();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void read(Socket socket, ByteBuffer buffer) throws IOException {
|
||||||
|
socket.read(buffer);
|
||||||
|
buffer.flip();
|
||||||
|
|
||||||
|
if (!buffer.hasRemaining()) {
|
||||||
|
buffer.clear();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
nextMessage.writeToMessage(buffer);
|
||||||
|
buffer.clear();
|
||||||
|
|
||||||
|
// Get message length
|
||||||
|
if (nextMessage.length < 4) return;
|
||||||
|
int length = SerializationUtils.bytesToInt(nextMessage.sharedArray, nextMessage.offset) + 4;
|
||||||
|
do {
|
||||||
|
|
||||||
|
// Separate first complete message
|
||||||
|
if (nextMessage.length >= length) {
|
||||||
|
Message message = messageBuffer.getMessage();
|
||||||
|
message.writePartialMessageToMessage(nextMessage, length);
|
||||||
|
message.length = nextMessage.length - length;
|
||||||
|
nextMessage.length = length;
|
||||||
|
completeMessages.add(nextMessage);
|
||||||
|
nextMessage = message;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get message length
|
||||||
|
if (nextMessage.length < 4) return;
|
||||||
|
length = SerializationUtils.bytesToInt(nextMessage.sharedArray, nextMessage.offset) + 4;
|
||||||
|
|
||||||
|
} while (nextMessage.length >= length);
|
||||||
|
}
|
||||||
|
}
|
88
src/main/java/envoy/server/net/ObjectWriteProxy.java
Executable file
88
src/main/java/envoy/server/net/ObjectWriteProxy.java
Executable file
@ -0,0 +1,88 @@
|
|||||||
|
package envoy.server.net;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
|
import com.jenkov.nioserver.Message;
|
||||||
|
import com.jenkov.nioserver.WriteProxy;
|
||||||
|
|
||||||
|
import envoy.server.data.Contact;
|
||||||
|
import envoy.util.EnvoyLog;
|
||||||
|
import envoy.util.SerializationUtils;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This class defines methods to send an object to a client.<br>
|
||||||
|
* <br>
|
||||||
|
* Project: <strong>envoy-server-standalone</strong><br>
|
||||||
|
* File: <strong>ObjectWriteProxy.java</strong><br>
|
||||||
|
* Created: <strong>04.01.2020</strong><br>
|
||||||
|
*
|
||||||
|
* @author Kai S. K. Engelbart
|
||||||
|
* @since Envoy Server Standalone v0.1-alpha
|
||||||
|
*/
|
||||||
|
public class ObjectWriteProxy {
|
||||||
|
|
||||||
|
private final WriteProxy writeProxy;
|
||||||
|
|
||||||
|
private static final ConnectionManager connectionManager = ConnectionManager.getInstance();
|
||||||
|
private static final Logger logger = EnvoyLog.getLogger(ObjectWriteProxy.class);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates an instance of {@link ObjectWriteProxy}.
|
||||||
|
*
|
||||||
|
* @param writeProxy the {@link WriteProxy} to write objects to another client
|
||||||
|
* @since Envoy Server Standalone v0.1-alpha
|
||||||
|
*/
|
||||||
|
public ObjectWriteProxy(WriteProxy writeProxy) { this.writeProxy = writeProxy; }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param recipientSocketID the socket id of the recipient
|
||||||
|
* @param obj the object to return to the client
|
||||||
|
* @throws RuntimeException if the serialization of the object failed (this is
|
||||||
|
* highly unlikely)
|
||||||
|
* @since Envoy Server Standalone v0.1-alpha
|
||||||
|
*/
|
||||||
|
public void write(long recipientSocketID, Object obj) {
|
||||||
|
// Create message targeted at the client
|
||||||
|
final Message response = writeProxy.getMessage();
|
||||||
|
response.socketId = recipientSocketID;
|
||||||
|
logger.fine("Sending " + obj);
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
// Serialize object to byte array
|
||||||
|
final byte[] objBytes = SerializationUtils.writeToByteArray(obj);
|
||||||
|
|
||||||
|
// Acquire object length in bytes
|
||||||
|
final byte[] objLen = SerializationUtils.intToBytes(objBytes.length);
|
||||||
|
|
||||||
|
response.writeToMessage(objLen);
|
||||||
|
response.writeToMessage(objBytes);
|
||||||
|
writeProxy.enqueue(response);
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends an object to all contact in a set that are online.
|
||||||
|
*
|
||||||
|
* @param contacts the contacts to send the object to
|
||||||
|
* @param message the object to send
|
||||||
|
* @since Envoy Server Standalone v0.1-beta
|
||||||
|
*/
|
||||||
|
public void writeToOnlineContacts(Set<? extends Contact> contacts, Object message) { writeToOnlineContacts(contacts.stream(), message); }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sends an object to all contact in a set that are online.
|
||||||
|
*
|
||||||
|
* @param contacts the contacts to send the object to
|
||||||
|
* @param message the object to send
|
||||||
|
* @since Envoy Server Standalone v0.1-beta
|
||||||
|
*/
|
||||||
|
public void writeToOnlineContacts(Stream<? extends Contact> contacts, Object message) {
|
||||||
|
contacts.map(Contact::getID).filter(connectionManager::isOnline).map(connectionManager::getSocketID).forEach(id -> write(id, message));
|
||||||
|
}
|
||||||
|
}
|
9
src/main/java/envoy/server/net/package-info.java
Executable file
9
src/main/java/envoy/server/net/package-info.java
Executable file
@ -0,0 +1,9 @@
|
|||||||
|
/**
|
||||||
|
* This package contains all classes related to client connection management.
|
||||||
|
*
|
||||||
|
* @author Kai S. K. Engelbart
|
||||||
|
* @author Leon Hofmeister
|
||||||
|
* @author Maximilian Käfer
|
||||||
|
* @since Envoy v0.1-alpha
|
||||||
|
*/
|
||||||
|
package envoy.server.net;
|
9
src/main/java/envoy/server/package-info.java
Executable file
9
src/main/java/envoy/server/package-info.java
Executable file
@ -0,0 +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;
|
47
src/main/java/envoy/server/processors/ContactOperationProcessor.java
Executable file
47
src/main/java/envoy/server/processors/ContactOperationProcessor.java
Executable file
@ -0,0 +1,47 @@
|
|||||||
|
package envoy.server.processors;
|
||||||
|
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import envoy.event.ElementOperation;
|
||||||
|
import envoy.event.contact.ContactOperation;
|
||||||
|
import envoy.server.data.PersistenceManager;
|
||||||
|
import envoy.server.net.ConnectionManager;
|
||||||
|
import envoy.server.net.ObjectWriteProxy;
|
||||||
|
import envoy.util.EnvoyLog;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Project: <strong>envoy-server-standalone</strong><br>
|
||||||
|
* File: <strong>ContactOperationProcessor.java</strong><br>
|
||||||
|
* Created: <strong>08.02.2020</strong><br>
|
||||||
|
*
|
||||||
|
* @author Kai S. K. Engelbart
|
||||||
|
* @since Envoy Server Standalone v0.1-alpha
|
||||||
|
*/
|
||||||
|
public class ContactOperationProcessor implements ObjectProcessor<ContactOperation> {
|
||||||
|
|
||||||
|
private static final ConnectionManager connectionManager = ConnectionManager.getInstance();
|
||||||
|
private static final Logger logger = EnvoyLog.getLogger(ContactOperationProcessor.class);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void process(ContactOperation evt, long socketId, ObjectWriteProxy writeProxy) {
|
||||||
|
switch (evt.getOperationType()) {
|
||||||
|
case ADD:
|
||||||
|
final long userID = ConnectionManager.getInstance().getUserIDBySocketID(socketId);
|
||||||
|
final long contactId = evt.get().getID();
|
||||||
|
|
||||||
|
logger.fine(String.format("Adding user %s to the contact list of user %d.%n", evt.get(), userID));
|
||||||
|
PersistenceManager.getInstance().addContactBidirectional(userID, contactId);
|
||||||
|
|
||||||
|
// Notify the contact if online
|
||||||
|
if (ConnectionManager.getInstance().isOnline(contactId))
|
||||||
|
writeProxy.write(connectionManager.getSocketID(contactId),
|
||||||
|
new ContactOperation(PersistenceManager.getInstance().getUserByID(userID).toCommon(), ElementOperation.ADD));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
logger.warning(String.format("Received %s with an unsupported operation.", evt));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<ContactOperation> getInputClass() { return ContactOperation.class; }
|
||||||
|
}
|
44
src/main/java/envoy/server/processors/ContactSearchProcessor.java
Executable file
44
src/main/java/envoy/server/processors/ContactSearchProcessor.java
Executable file
@ -0,0 +1,44 @@
|
|||||||
|
package envoy.server.processors;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
import envoy.data.Contact;
|
||||||
|
import envoy.event.contact.ContactSearchRequest;
|
||||||
|
import envoy.event.contact.ContactSearchResult;
|
||||||
|
import envoy.server.data.PersistenceManager;
|
||||||
|
import envoy.server.data.User;
|
||||||
|
import envoy.server.net.ConnectionManager;
|
||||||
|
import envoy.server.net.ObjectWriteProxy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Project: <strong>envoy-server-standalone</strong><br>
|
||||||
|
* File: <strong>ContactSearchProcessor.java</strong><br>
|
||||||
|
* Created: <strong>08.02.2020</strong><br>
|
||||||
|
*
|
||||||
|
* @author Kai S. K. Engelbart
|
||||||
|
* @author Maximilian Käfer
|
||||||
|
* @since Envoy Server Standalone v0.1-alpha
|
||||||
|
*/
|
||||||
|
public class ContactSearchProcessor implements ObjectProcessor<ContactSearchRequest> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Writes a list of contacts to the client containing all {@link Contact}s
|
||||||
|
* matching the search phrase contained inside the request. The client and their
|
||||||
|
* contacts are excluded from the result.
|
||||||
|
*
|
||||||
|
* @since Envoy Server Standalone v0.1-alpha
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void process(ContactSearchRequest request, long socketID, ObjectWriteProxy writeProxy) throws IOException {
|
||||||
|
writeProxy.write(socketID,
|
||||||
|
new ContactSearchResult(PersistenceManager.getInstance()
|
||||||
|
.searchUsers(request.get(), ConnectionManager.getInstance().getUserIDBySocketID(socketID))
|
||||||
|
.stream()
|
||||||
|
.map(User::toCommon)
|
||||||
|
.collect(Collectors.toList())));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<ContactSearchRequest> getInputClass() { return ContactSearchRequest.class; }
|
||||||
|
}
|
@ -0,0 +1,46 @@
|
|||||||
|
package envoy.server.processors;
|
||||||
|
|
||||||
|
import java.util.HashSet;
|
||||||
|
|
||||||
|
import envoy.event.ElementOperation;
|
||||||
|
import envoy.event.GroupCreation;
|
||||||
|
import envoy.event.contact.ContactOperation;
|
||||||
|
import envoy.server.data.Contact;
|
||||||
|
import envoy.server.data.PersistenceManager;
|
||||||
|
import envoy.server.net.ConnectionManager;
|
||||||
|
import envoy.server.net.ObjectWriteProxy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Project: <strong>envoy-server-standalone</strong><br>
|
||||||
|
* File: <strong>GroupCreationProcessor.java</strong><br>
|
||||||
|
* Created: <strong>26.03.2020</strong><br>
|
||||||
|
*
|
||||||
|
* @author Maximilian Käfer
|
||||||
|
* @since Envoy Server Standalone v0.1-beta
|
||||||
|
*/
|
||||||
|
public class GroupCreationProcessor implements ObjectProcessor<GroupCreation> {
|
||||||
|
|
||||||
|
private final PersistenceManager persistenceManager = PersistenceManager.getInstance();
|
||||||
|
private final ConnectionManager connectionManager = ConnectionManager.getInstance();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void process(GroupCreation groupCreation, long socketID, ObjectWriteProxy writeProxy) {
|
||||||
|
envoy.server.data.Group group = new envoy.server.data.Group();
|
||||||
|
group.setName(groupCreation.get());
|
||||||
|
group.setContacts(new HashSet<>());
|
||||||
|
groupCreation.getInitialMemberIDs().stream().map(persistenceManager::getUserByID).forEach(group.getContacts()::add);
|
||||||
|
group.getContacts().add(persistenceManager.getContactByID(connectionManager.getUserIDBySocketID(socketID)));
|
||||||
|
group.getContacts().forEach(c -> c.getContacts().add(group));
|
||||||
|
group.getContacts().add(persistenceManager.getUserByID(connectionManager.getUserIDBySocketID(socketID)));
|
||||||
|
persistenceManager.addContact(group);
|
||||||
|
group.getContacts()
|
||||||
|
.stream()
|
||||||
|
.map(Contact::getID)
|
||||||
|
.filter(connectionManager::isOnline)
|
||||||
|
.map(connectionManager::getSocketID)
|
||||||
|
.forEach(memberSocketID -> writeProxy.write(memberSocketID, new ContactOperation(group.toCommon(), ElementOperation.ADD)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<GroupCreation> getInputClass() { return GroupCreation.class; }
|
||||||
|
}
|
@ -0,0 +1,67 @@
|
|||||||
|
package envoy.server.processors;
|
||||||
|
|
||||||
|
import static envoy.data.Message.MessageStatus.*;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import javax.persistence.EntityExistsException;
|
||||||
|
|
||||||
|
import envoy.data.GroupMessage;
|
||||||
|
import envoy.event.MessageStatusChange;
|
||||||
|
import envoy.server.data.PersistenceManager;
|
||||||
|
import envoy.server.net.ConnectionManager;
|
||||||
|
import envoy.server.net.ObjectWriteProxy;
|
||||||
|
import envoy.util.EnvoyLog;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Project: <strong>envoy-server-standalone</strong><br>
|
||||||
|
* File: <strong>GroupMessageProcessor.java</strong><br>
|
||||||
|
* Created: <strong>18.04.2020</strong><br>
|
||||||
|
*
|
||||||
|
* @author Maximilian Käfer
|
||||||
|
* @since Envoy Server Standalone v0.1-beta
|
||||||
|
*/
|
||||||
|
public class GroupMessageProcessor implements ObjectProcessor<GroupMessage> {
|
||||||
|
|
||||||
|
private static final ConnectionManager connectionManager = ConnectionManager.getInstance();
|
||||||
|
private static final PersistenceManager persistenceManager = PersistenceManager.getInstance();
|
||||||
|
private static final Logger logger = EnvoyLog.getLogger(GroupCreationProcessor.class);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void process(GroupMessage groupMessage, long socketID, ObjectWriteProxy writeProxy) {
|
||||||
|
groupMessage.nextStatus();
|
||||||
|
|
||||||
|
// Update statuses to SENT / RECEIVED depending on online status
|
||||||
|
groupMessage.getMemberStatuses().replaceAll((memberID, status) -> connectionManager.isOnline(memberID) ? RECEIVED : SENT);
|
||||||
|
|
||||||
|
// Set status for sender to READ
|
||||||
|
groupMessage.getMemberStatuses().replace(groupMessage.getSenderID(), READ);
|
||||||
|
|
||||||
|
// Increment the overall status to RECEIVED if necessary
|
||||||
|
if (Collections.min(groupMessage.getMemberStatuses().values()) == RECEIVED) {
|
||||||
|
groupMessage.nextStatus();
|
||||||
|
|
||||||
|
// Notify the sender of the status change
|
||||||
|
writeProxy.write(socketID, new MessageStatusChange(groupMessage));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Deliver the message to the recipients that are online
|
||||||
|
writeProxy.writeToOnlineContacts(
|
||||||
|
persistenceManager.getGroupByID(groupMessage.getRecipientID())
|
||||||
|
.getContacts()
|
||||||
|
.stream()
|
||||||
|
.filter(c -> c.getID() != groupMessage.getSenderID()),
|
||||||
|
groupMessage);
|
||||||
|
|
||||||
|
try {
|
||||||
|
PersistenceManager.getInstance().addMessage(new envoy.server.data.GroupMessage(groupMessage, LocalDateTime.now()));
|
||||||
|
} catch (EntityExistsException e) {
|
||||||
|
logger.warning("Received a groupMessage with an ID that already exists");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<GroupMessage> getInputClass() { return GroupMessage.class; }
|
||||||
|
}
|
@ -0,0 +1,69 @@
|
|||||||
|
package envoy.server.processors;
|
||||||
|
|
||||||
|
import static envoy.data.Message.MessageStatus.READ;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import envoy.data.Message.MessageStatus;
|
||||||
|
import envoy.event.GroupMessageStatusChange;
|
||||||
|
import envoy.event.MessageStatusChange;
|
||||||
|
import envoy.server.data.GroupMessage;
|
||||||
|
import envoy.server.data.PersistenceManager;
|
||||||
|
import envoy.server.net.ConnectionManager;
|
||||||
|
import envoy.server.net.ObjectWriteProxy;
|
||||||
|
import envoy.util.EnvoyLog;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Project: <strong>envoy-server-standalone</strong><br>
|
||||||
|
* File: <strong>GroupMessageStatusChangeProcessor.java</strong><br>
|
||||||
|
* Created: <strong>03.07.2020</strong><br>
|
||||||
|
*
|
||||||
|
* @author Maximilian Käfer
|
||||||
|
* @since Envoy Server Standalone v0.1-beta
|
||||||
|
*/
|
||||||
|
public class GroupMessageStatusChangeProcessor implements ObjectProcessor<GroupMessageStatusChange> {
|
||||||
|
|
||||||
|
private static final ConnectionManager connectionManager = ConnectionManager.getInstance();
|
||||||
|
private static final PersistenceManager persistenceManager = PersistenceManager.getInstance();
|
||||||
|
private static final Logger logger = EnvoyLog.getLogger(MessageStatusChangeProcessor.class);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void process(GroupMessageStatusChange statusChange, long socketID, ObjectWriteProxy writeProxy) {
|
||||||
|
GroupMessage gmsg = (GroupMessage) persistenceManager.getMessageByID(statusChange.getID());
|
||||||
|
|
||||||
|
// Any other status than READ is not supposed to be sent to the server
|
||||||
|
if (statusChange.get() != MessageStatus.READ) {
|
||||||
|
logger.log(Level.WARNING, "Invalid " + statusChange);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Apply the status change
|
||||||
|
gmsg.getMemberMessageStatus().replace(statusChange.getMemberID(), statusChange.get());
|
||||||
|
gmsg.setLastStatusChangeDate(LocalDateTime.now());
|
||||||
|
|
||||||
|
// Notifying the other members about the status change
|
||||||
|
final var userID = connectionManager.getUserIDBySocketID(socketID);
|
||||||
|
gmsg.getMemberMessageStatus()
|
||||||
|
.keySet()
|
||||||
|
.stream()
|
||||||
|
.filter(k -> userID != k)
|
||||||
|
.filter(connectionManager::isOnline)
|
||||||
|
.forEach(k -> writeProxy.write(connectionManager.getSocketID(k), statusChange));
|
||||||
|
|
||||||
|
// Increment overall status to READ if necessary
|
||||||
|
if (Collections.min(gmsg.getMemberMessageStatus().values()) == READ) {
|
||||||
|
gmsg.read();
|
||||||
|
|
||||||
|
// Notify online members about the status change
|
||||||
|
writeProxy.writeToOnlineContacts(gmsg.getRecipient().getContacts(),
|
||||||
|
new MessageStatusChange(gmsg.getID(), gmsg.getStatus(), LocalDateTime.now()));
|
||||||
|
}
|
||||||
|
persistenceManager.updateMessage(gmsg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<GroupMessageStatusChange> getInputClass() { return GroupMessageStatusChange.class; }
|
||||||
|
}
|
@ -0,0 +1,53 @@
|
|||||||
|
package envoy.server.processors;
|
||||||
|
|
||||||
|
import envoy.event.GroupResize;
|
||||||
|
import envoy.server.data.Contact;
|
||||||
|
import envoy.server.data.PersistenceManager;
|
||||||
|
import envoy.server.net.ConnectionManager;
|
||||||
|
import envoy.server.net.ObjectWriteProxy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Project: <strong>envoy-server-standalone</strong><br>
|
||||||
|
* File: <strong>GroupResizeProcessor.java</strong><br>
|
||||||
|
* Created: <strong>03.04.2020</strong><br>
|
||||||
|
*
|
||||||
|
* @author Maximilian Käfer
|
||||||
|
* @since Envoy Server Standalone v0.1-beta
|
||||||
|
*/
|
||||||
|
public class GroupResizeProcessor implements ObjectProcessor<GroupResize> {
|
||||||
|
|
||||||
|
private static final PersistenceManager persistenceManager = PersistenceManager.getInstance();
|
||||||
|
private static final ConnectionManager connectionManager = ConnectionManager.getInstance();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void process(GroupResize groupResize, long socketID, ObjectWriteProxy writeProxy) {
|
||||||
|
|
||||||
|
// Acquire the group to resize from the database
|
||||||
|
var group = persistenceManager.getGroupByID(groupResize.getGroupID());
|
||||||
|
|
||||||
|
// Perform the desired operation
|
||||||
|
switch (groupResize.getOperation()) {
|
||||||
|
case ADD:
|
||||||
|
group.getContacts().add(persistenceManager.getUserByID(groupResize.get().getID()));
|
||||||
|
break;
|
||||||
|
case REMOVE:
|
||||||
|
group.getContacts().remove(persistenceManager.getUserByID(groupResize.get().getID()));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Update the group in the database
|
||||||
|
persistenceManager.updateContact(group);
|
||||||
|
|
||||||
|
// Send the updated group to all of its members
|
||||||
|
var commonGroup = group.toCommon();
|
||||||
|
group.getContacts()
|
||||||
|
.stream()
|
||||||
|
.map(Contact::getID)
|
||||||
|
.filter(connectionManager::isOnline)
|
||||||
|
.map(connectionManager::getSocketID)
|
||||||
|
.forEach(memberSocketID -> writeProxy.write(memberSocketID, commonGroup));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<GroupResize> getInputClass() { return GroupResize.class; }
|
||||||
|
}
|
50
src/main/java/envoy/server/processors/IDGeneratorRequestProcessor.java
Executable file
50
src/main/java/envoy/server/processors/IDGeneratorRequestProcessor.java
Executable file
@ -0,0 +1,50 @@
|
|||||||
|
package envoy.server.processors;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import envoy.data.IDGenerator;
|
||||||
|
import envoy.event.IDGeneratorRequest;
|
||||||
|
import envoy.server.data.ConfigItem;
|
||||||
|
import envoy.server.data.PersistenceManager;
|
||||||
|
import envoy.server.net.ObjectWriteProxy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Project: <strong>envoy-server-standalone</strong><br>
|
||||||
|
* File: <strong>IDGeneratorRequestProcessor.java</strong><br>
|
||||||
|
* Created: <strong>28 Jan 2020</strong><br>
|
||||||
|
*
|
||||||
|
* @author Kai S. K. Engelbart
|
||||||
|
* @author Maximilian Käfer
|
||||||
|
* @since Envoy Server Standalone v0.1-alpha
|
||||||
|
*/
|
||||||
|
public class IDGeneratorRequestProcessor implements ObjectProcessor<IDGeneratorRequest> {
|
||||||
|
|
||||||
|
private static final long ID_RANGE = 200;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<IDGeneratorRequest> getInputClass() { return IDGeneratorRequest.class; }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void process(IDGeneratorRequest input, long socketID, ObjectWriteProxy writeProxy) throws IOException {
|
||||||
|
writeProxy.write(socketID, createIDGenerator());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return a new IDGenerator
|
||||||
|
* @since Envoy Server Standalone v0.1-beta
|
||||||
|
*/
|
||||||
|
public static IDGenerator createIDGenerator() { return createIDGenerator(ID_RANGE); }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param range of IDs used by the new IDGenerator
|
||||||
|
* @return a new IDGenerator with a specific range of IDs
|
||||||
|
* @since Envoy Server Standalone v0.1-beta
|
||||||
|
*/
|
||||||
|
public static IDGenerator createIDGenerator(long range) {
|
||||||
|
ConfigItem currentID = PersistenceManager.getInstance().getConfigItemByID("currentMessageId");
|
||||||
|
IDGenerator generator = new IDGenerator(Integer.parseInt(currentID.getValue()), range);
|
||||||
|
currentID.setValue(String.valueOf(Integer.parseInt(currentID.getValue()) + range));
|
||||||
|
PersistenceManager.getInstance().updateConfigItem(currentID);
|
||||||
|
return generator;
|
||||||
|
}
|
||||||
|
}
|
189
src/main/java/envoy/server/processors/LoginCredentialProcessor.java
Executable file
189
src/main/java/envoy/server/processors/LoginCredentialProcessor.java
Executable file
@ -0,0 +1,189 @@
|
|||||||
|
package envoy.server.processors;
|
||||||
|
|
||||||
|
import static envoy.data.Message.MessageStatus.*;
|
||||||
|
import static envoy.data.User.UserStatus.ONLINE;
|
||||||
|
import static envoy.event.HandshakeRejection.*;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import javax.persistence.NoResultException;
|
||||||
|
|
||||||
|
import envoy.data.LoginCredentials;
|
||||||
|
import envoy.event.GroupMessageStatusChange;
|
||||||
|
import envoy.event.HandshakeRejection;
|
||||||
|
import envoy.event.MessageStatusChange;
|
||||||
|
import envoy.server.data.GroupMessage;
|
||||||
|
import envoy.server.data.PersistenceManager;
|
||||||
|
import envoy.server.data.User;
|
||||||
|
import envoy.server.net.ConnectionManager;
|
||||||
|
import envoy.server.net.ObjectWriteProxy;
|
||||||
|
import envoy.server.util.PasswordUtil;
|
||||||
|
import envoy.server.util.VersionUtil;
|
||||||
|
import envoy.util.Bounds;
|
||||||
|
import envoy.util.EnvoyLog;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This {@link ObjectProcessor} handles {@link LoginCredentials}.<br>
|
||||||
|
* <br>
|
||||||
|
* Project: <strong>envoy-server-standalone</strong><br>
|
||||||
|
* File: <strong>LoginCredentialProcessor.java</strong><br>
|
||||||
|
* Created: <strong>30.12.2019</strong><br>
|
||||||
|
*
|
||||||
|
* @author Kai S. K. Engelbart
|
||||||
|
* @author Maximilian Käfer
|
||||||
|
* @since Envoy Server Standalone v0.1-alpha
|
||||||
|
*/
|
||||||
|
public final class LoginCredentialProcessor implements ObjectProcessor<LoginCredentials> {
|
||||||
|
|
||||||
|
private final PersistenceManager persistenceManager = PersistenceManager.getInstance();
|
||||||
|
private final ConnectionManager connectionManager = ConnectionManager.getInstance();
|
||||||
|
|
||||||
|
private static final Logger logger = EnvoyLog.getLogger(LoginCredentialProcessor.class);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void process(LoginCredentials credentials, long socketID, ObjectWriteProxy writeProxy) {
|
||||||
|
|
||||||
|
// Cache this write proxy for user-independant notifications
|
||||||
|
UserStatusChangeProcessor.setWriteProxy(writeProxy);
|
||||||
|
|
||||||
|
if (!VersionUtil.verifyCompatibility(credentials.getClientVersion())) {
|
||||||
|
logger.info("The client has the wrong version.");
|
||||||
|
writeProxy.write(socketID, new HandshakeRejection(WRONG_VERSION));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Acquire a user object (or reject the handshake if that's impossible)
|
||||||
|
User user = null;
|
||||||
|
if (!credentials.isRegistration()) {
|
||||||
|
try {
|
||||||
|
user = persistenceManager.getUserByName(credentials.getIdentifier());
|
||||||
|
|
||||||
|
// Checking if user is already online
|
||||||
|
if (connectionManager.isOnline(user.getID())) {
|
||||||
|
logger.warning(user + " is already online!");
|
||||||
|
writeProxy.write(socketID, new HandshakeRejection(INTERNAL_ERROR));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// Evaluating the correctness of the password hash
|
||||||
|
if (!PasswordUtil.validate(credentials.getPassword(), user.getPasswordHash())) {
|
||||||
|
logger.info(user + " has entered the wrong password.");
|
||||||
|
writeProxy.write(socketID, new HandshakeRejection(WRONG_PASSWORD_OR_USER));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} catch (NoResultException e) {
|
||||||
|
logger.info("The requested user does not exist.");
|
||||||
|
writeProxy.write(socketID, new HandshakeRejection(WRONG_PASSWORD_OR_USER));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Validate user name
|
||||||
|
if (!Bounds.isValidContactName(credentials.getIdentifier())) {
|
||||||
|
logger.info("The requested user name is not valid.");
|
||||||
|
writeProxy.write(socketID, new HandshakeRejection(INTERNAL_ERROR));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
// Checking that no user already has this identifier
|
||||||
|
PersistenceManager.getInstance().getUserByName(credentials.getIdentifier());
|
||||||
|
|
||||||
|
// This code only gets executed if this user already exists
|
||||||
|
logger.info("The requested user already exists.");
|
||||||
|
writeProxy.write(socketID, new HandshakeRejection(USERNAME_TAKEN));
|
||||||
|
return;
|
||||||
|
} catch (NoResultException e) {
|
||||||
|
// Creation of a new user
|
||||||
|
user = new User();
|
||||||
|
user.setName(credentials.getIdentifier());
|
||||||
|
user.setLastSeen(LocalDateTime.now());
|
||||||
|
user.setStatus(ONLINE);
|
||||||
|
user.setPasswordHash(PasswordUtil.hash(credentials.getPassword()));
|
||||||
|
user.setContacts(new HashSet<>());
|
||||||
|
persistenceManager.addContact(user);
|
||||||
|
logger.info("Registered new " + user);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
logger.info(user + " successfully authenticated.");
|
||||||
|
connectionManager.registerUser(user.getID(), socketID);
|
||||||
|
|
||||||
|
// Change status and notify contacts about it
|
||||||
|
user.setStatus(ONLINE);
|
||||||
|
UserStatusChangeProcessor.updateUserStatus(user);
|
||||||
|
|
||||||
|
// Complete the handshake
|
||||||
|
writeProxy.write(socketID, user.toCommon());
|
||||||
|
|
||||||
|
final var pendingMessages = PersistenceManager.getInstance().getPendingMessages(user);
|
||||||
|
pendingMessages.removeIf(GroupMessage.class::isInstance);
|
||||||
|
logger.fine("Sending " + pendingMessages.size() + " pending messages to " + user + "...");
|
||||||
|
|
||||||
|
for (var msg : pendingMessages) {
|
||||||
|
final var msgCommon = msg.toCommon();
|
||||||
|
if (msg.getStatus() == SENT) {
|
||||||
|
|
||||||
|
// Send the message
|
||||||
|
writeProxy.write(socketID, msgCommon);
|
||||||
|
msg.received();
|
||||||
|
PersistenceManager.getInstance().updateMessage(msg);
|
||||||
|
|
||||||
|
// Notify the sender about the delivery
|
||||||
|
if (connectionManager.isOnline(msg.getSender().getID())) {
|
||||||
|
msgCommon.nextStatus();
|
||||||
|
writeProxy.write(connectionManager.getSocketID(msg.getSender().getID()), new MessageStatusChange(msgCommon));
|
||||||
|
}
|
||||||
|
} else writeProxy.write(socketID, new MessageStatusChange(msgCommon));
|
||||||
|
}
|
||||||
|
|
||||||
|
List<GroupMessage> pendingGroupMessages = PersistenceManager.getInstance().getPendingGroupMessages(user);
|
||||||
|
logger.fine("Sending " + pendingGroupMessages.size() + " pending group messages to " + user + "...");
|
||||||
|
|
||||||
|
for (var gmsg : pendingGroupMessages) {
|
||||||
|
final var gmsgCommon = gmsg.toCommon();
|
||||||
|
|
||||||
|
// Deliver the message to the user if he hasn't received it yet
|
||||||
|
if (gmsg.getMemberMessageStatus().get(user.getID()) == SENT) {
|
||||||
|
gmsg.getMemberMessageStatus().replace(user.getID(), RECEIVED);
|
||||||
|
|
||||||
|
gmsg.setLastStatusChangeDate(LocalDateTime.now());
|
||||||
|
|
||||||
|
writeProxy.write(socketID, gmsgCommon);
|
||||||
|
|
||||||
|
// Notify all online group members about the status change
|
||||||
|
writeProxy.writeToOnlineContacts(gmsg.getRecipient().getContacts(),
|
||||||
|
new GroupMessageStatusChange(gmsg.getID(), RECEIVED, LocalDateTime
|
||||||
|
.now(),
|
||||||
|
connectionManager.getUserIDBySocketID(socketID)));
|
||||||
|
|
||||||
|
if (Collections.min(gmsg.getMemberMessageStatus().values()) == RECEIVED) {
|
||||||
|
gmsg.received();
|
||||||
|
|
||||||
|
// Notify online members about the status change
|
||||||
|
writeProxy.writeToOnlineContacts(gmsg.getRecipient().getContacts(),
|
||||||
|
new MessageStatusChange(gmsg.getID(), gmsg.getStatus(), LocalDateTime.now()));
|
||||||
|
}
|
||||||
|
|
||||||
|
PersistenceManager.getInstance().updateMessage(gmsg);
|
||||||
|
} else {
|
||||||
|
|
||||||
|
// Sending group message status changes
|
||||||
|
if (gmsg.getStatus() == SENT && gmsg.getLastStatusChangeDate().isAfter(gmsg.getCreationDate())
|
||||||
|
|| gmsg.getStatus() == RECEIVED && gmsg.getLastStatusChangeDate().isAfter(gmsg.getReceivedDate())) {
|
||||||
|
gmsg.getMemberMessageStatus().forEach((memberID, memberStatus) ->
|
||||||
|
writeProxy.write(socketID, new GroupMessageStatusChange(gmsg.getID(), memberStatus, gmsg.getLastStatusChangeDate(), memberID)));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Deliver just a status change instead of the whole message
|
||||||
|
if (gmsg.getStatus() == SENT && user.getLastSeen().isBefore(gmsg.getCreationDate())
|
||||||
|
|| gmsg.getStatus() == RECEIVED && user.getLastSeen().isBefore(gmsg.getReceivedDate()))
|
||||||
|
writeProxy.write(socketID, new MessageStatusChange(gmsgCommon));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<LoginCredentials> getInputClass() { return LoginCredentials.class; }
|
||||||
|
}
|
64
src/main/java/envoy/server/processors/MessageProcessor.java
Executable file
64
src/main/java/envoy/server/processors/MessageProcessor.java
Executable file
@ -0,0 +1,64 @@
|
|||||||
|
package envoy.server.processors;
|
||||||
|
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import javax.persistence.EntityExistsException;
|
||||||
|
|
||||||
|
import envoy.data.Message;
|
||||||
|
import envoy.event.MessageStatusChange;
|
||||||
|
import envoy.server.data.PersistenceManager;
|
||||||
|
import envoy.server.net.ConnectionManager;
|
||||||
|
import envoy.server.net.ObjectWriteProxy;
|
||||||
|
import envoy.util.EnvoyLog;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This {@link ObjectProcessor} handles incoming {@link Message}s.
|
||||||
|
* <p>
|
||||||
|
* Project: <strong>envoy-server-standalone</strong><br>
|
||||||
|
* File: <strong>MessageProcessor.java</strong><br>
|
||||||
|
* Created: <strong>30.12.2019</strong><br>
|
||||||
|
*
|
||||||
|
* @author Kai S. K. Engelbart
|
||||||
|
* @author Maximilian Käfer
|
||||||
|
* @since Envoy Server Standalone v0.1-alpha
|
||||||
|
*/
|
||||||
|
public class MessageProcessor implements ObjectProcessor<Message> {
|
||||||
|
|
||||||
|
private static final PersistenceManager persistenceManager = PersistenceManager.getInstance();
|
||||||
|
private static final ConnectionManager connectionManager = ConnectionManager.getInstance();
|
||||||
|
private static final Logger logger = EnvoyLog.getLogger(MessageProcessor.class);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void process(Message message, long socketID, ObjectWriteProxy writeProxy) {
|
||||||
|
message.nextStatus();
|
||||||
|
|
||||||
|
// Convert to server message
|
||||||
|
final var serverMessage = new envoy.server.data.Message(message);
|
||||||
|
|
||||||
|
try {
|
||||||
|
|
||||||
|
// Persist the message
|
||||||
|
persistenceManager.addMessage(serverMessage);
|
||||||
|
|
||||||
|
// Send the message to the recipient if online
|
||||||
|
if (connectionManager.isOnline(message.getRecipientID())) {
|
||||||
|
writeProxy.write(connectionManager.getSocketID(message.getRecipientID()), message);
|
||||||
|
|
||||||
|
// Increment status
|
||||||
|
message.nextStatus();
|
||||||
|
serverMessage.received();
|
||||||
|
persistenceManager.updateMessage(serverMessage);
|
||||||
|
|
||||||
|
// Notify the sender about the delivery
|
||||||
|
// Note that the exact time stamp might differ slightly
|
||||||
|
writeProxy.write(socketID, new MessageStatusChange(message));
|
||||||
|
}
|
||||||
|
} catch (EntityExistsException e) {
|
||||||
|
logger.log(Level.WARNING, "Received " + message + " with an ID that already exists!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<Message> getInputClass() { return Message.class; }
|
||||||
|
}
|
48
src/main/java/envoy/server/processors/MessageStatusChangeProcessor.java
Executable file
48
src/main/java/envoy/server/processors/MessageStatusChangeProcessor.java
Executable file
@ -0,0 +1,48 @@
|
|||||||
|
package envoy.server.processors;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.logging.Level;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import envoy.data.Message.MessageStatus;
|
||||||
|
import envoy.event.MessageStatusChange;
|
||||||
|
import envoy.server.data.PersistenceManager;
|
||||||
|
import envoy.server.net.ConnectionManager;
|
||||||
|
import envoy.server.net.ObjectWriteProxy;
|
||||||
|
import envoy.util.EnvoyLog;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Project: <strong>envoy-server-standalone</strong><br>
|
||||||
|
* File: <strong>MessageStatusChangeProcessor.java</strong><br>
|
||||||
|
* Created: <strong>10 Jan 2020</strong><br>
|
||||||
|
*
|
||||||
|
* @author Leon Hofmeister
|
||||||
|
* @since Envoy Server Standalone v0.1-alpha
|
||||||
|
*/
|
||||||
|
public class MessageStatusChangeProcessor implements ObjectProcessor<MessageStatusChange> {
|
||||||
|
|
||||||
|
private final ConnectionManager connectionManager = ConnectionManager.getInstance();
|
||||||
|
private final PersistenceManager persistenceManager = PersistenceManager.getInstance();
|
||||||
|
private final Logger logger = EnvoyLog.getLogger(MessageStatusChangeProcessor.class);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void process(MessageStatusChange statusChange, long socketID, ObjectWriteProxy writeProxy) throws IOException {
|
||||||
|
|
||||||
|
// Any other status than READ is not supposed to be sent to the server
|
||||||
|
if (statusChange.get() != MessageStatus.READ) {
|
||||||
|
logger.log(Level.WARNING, "Invalid " + statusChange);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final var msg = persistenceManager.getMessageByID(statusChange.getID());
|
||||||
|
msg.read();
|
||||||
|
persistenceManager.updateMessage(msg);
|
||||||
|
|
||||||
|
// Notifies the sender of the message about the status-update to READ
|
||||||
|
final long senderID = msg.getSender().getID();
|
||||||
|
if (connectionManager.isOnline(senderID)) writeProxy.write(connectionManager.getSocketID(senderID), statusChange);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<MessageStatusChange> getInputClass() { return MessageStatusChange.class; }
|
||||||
|
}
|
@ -0,0 +1,34 @@
|
|||||||
|
package envoy.server.processors;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import envoy.event.NameChange;
|
||||||
|
import envoy.server.data.Contact;
|
||||||
|
import envoy.server.data.PersistenceManager;
|
||||||
|
import envoy.server.net.ObjectWriteProxy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Project: <strong>envoy-server-standalone</strong><br>
|
||||||
|
* File: <strong>NameChangeProcessor.java</strong><br>
|
||||||
|
* Created: <strong>26 Mar 2020</strong><br>
|
||||||
|
*
|
||||||
|
* @author Leon Hofmeister
|
||||||
|
* @since Envoy Server Standalone v0.1-beta
|
||||||
|
*/
|
||||||
|
public class NameChangeProcessor implements ObjectProcessor<NameChange> {
|
||||||
|
|
||||||
|
private static final PersistenceManager persistenceManager = PersistenceManager.getInstance();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void process(NameChange nameChange, long socketID, ObjectWriteProxy writeProxy) throws IOException {
|
||||||
|
Contact toUpdate = persistenceManager.getContactByID(nameChange.getID());
|
||||||
|
toUpdate.setName(nameChange.get());
|
||||||
|
persistenceManager.updateContact(toUpdate);
|
||||||
|
|
||||||
|
// Notify online contacts of the name change
|
||||||
|
writeProxy.writeToOnlineContacts(toUpdate.getContacts(), nameChange);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<NameChange> getInputClass() { return NameChange.class; }
|
||||||
|
}
|
35
src/main/java/envoy/server/processors/ObjectProcessor.java
Executable file
35
src/main/java/envoy/server/processors/ObjectProcessor.java
Executable file
@ -0,0 +1,35 @@
|
|||||||
|
package envoy.server.processors;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
import envoy.server.net.ObjectWriteProxy;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This interface defines methods for processing objects of a specific
|
||||||
|
* type incoming from a client.<br>
|
||||||
|
* <br>
|
||||||
|
* Project: <strong>envoy-server-standalone</strong><br>
|
||||||
|
* File: <strong>ObjectProcessor.java</strong><br>
|
||||||
|
* Created: <strong>30.12.2019</strong><br>
|
||||||
|
*
|
||||||
|
* @author Kai S. K. Engelbart
|
||||||
|
* @param <T> type of the request object
|
||||||
|
* @since Envoy Server Standalone v0.1-alpha
|
||||||
|
*/
|
||||||
|
public interface ObjectProcessor<T> {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the class of the request object
|
||||||
|
* @since Envoy Server Standalone v0.1-alpha
|
||||||
|
*/
|
||||||
|
Class<T> getInputClass();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param input the request object
|
||||||
|
* @param socketID the ID of the socket from which the object was received
|
||||||
|
* @param writeProxy the object that allows writing to a client
|
||||||
|
* @throws IOException if something went wrong during processing
|
||||||
|
* @since Envoy Server Standalone v0.1-alpha
|
||||||
|
*/
|
||||||
|
void process(T input, long socketID, ObjectWriteProxy writeProxy) throws IOException;
|
||||||
|
}
|
77
src/main/java/envoy/server/processors/UserStatusChangeProcessor.java
Executable file
77
src/main/java/envoy/server/processors/UserStatusChangeProcessor.java
Executable file
@ -0,0 +1,77 @@
|
|||||||
|
package envoy.server.processors;
|
||||||
|
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import envoy.data.User.UserStatus;
|
||||||
|
import envoy.event.UserStatusChange;
|
||||||
|
import envoy.server.data.PersistenceManager;
|
||||||
|
import envoy.server.data.User;
|
||||||
|
import envoy.server.net.ObjectWriteProxy;
|
||||||
|
import envoy.util.EnvoyLog;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This processor handles incoming {@link UserStatusChange}.
|
||||||
|
* <p>
|
||||||
|
* Project: <strong>envoy-server-standalone</strong><br>
|
||||||
|
* File: <strong>UserStatusChangeProcessor.java</strong><br>
|
||||||
|
* Created: <strong>1 Feb 2020</strong><br>
|
||||||
|
*
|
||||||
|
* @author Leon Hofmeister
|
||||||
|
* @since Envoy Server Standalone v0.1-alpha
|
||||||
|
*/
|
||||||
|
public class UserStatusChangeProcessor implements ObjectProcessor<UserStatusChange> {
|
||||||
|
|
||||||
|
private static ObjectWriteProxy writeProxy;
|
||||||
|
|
||||||
|
private static final PersistenceManager persistenceManager = PersistenceManager.getInstance();
|
||||||
|
private static final Logger logger = EnvoyLog.getLogger(UserStatusChangeProcessor.class);
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<UserStatusChange> getInputClass() { return UserStatusChange.class; }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void process(UserStatusChange input, long socketID, ObjectWriteProxy writeProxy) {
|
||||||
|
// new status should not equal old status
|
||||||
|
if (input.get().equals(persistenceManager.getUserByID(input.getID()).getStatus())) {
|
||||||
|
logger.warning("Received an unnecessary UserStatusChange");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
updateUserStatus(input);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the {@link UserStatus} for a given user. Both offline contacts and
|
||||||
|
* currently online contacts are notified.
|
||||||
|
*
|
||||||
|
* @param user the {@link UserStatusChange} that signals the change
|
||||||
|
* @since Envoy Server Standalone v0.1-alpha
|
||||||
|
*/
|
||||||
|
|
||||||
|
public static void updateUserStatus(User user) {
|
||||||
|
|
||||||
|
// Handling for newly logged in clients
|
||||||
|
persistenceManager.updateContact(user);
|
||||||
|
|
||||||
|
// Handling for contacts that are already online
|
||||||
|
writeProxy.writeToOnlineContacts(user.getContacts(), new UserStatusChange(user.getID(), user.getStatus()));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param evt the {@link UserStatusChange}
|
||||||
|
* @since Envoy Server Standalone v0.1-alpha
|
||||||
|
*/
|
||||||
|
public static void updateUserStatus(UserStatusChange evt) { updateUserStatus(persistenceManager.getUserByID(evt.getID())); }
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This method is only called by the LoginCredentialProcessor because every
|
||||||
|
* user needs to login (open a socket) before changing his status.
|
||||||
|
* Needed to ensure propagation of events because an uninitialized writeProxy
|
||||||
|
* would cause problems.
|
||||||
|
*
|
||||||
|
* @param writeProxy the writeProxy that is used to send objects back to clients
|
||||||
|
* @since Envoy Server Standalone v0.1-alpha
|
||||||
|
*/
|
||||||
|
public static void setWriteProxy(ObjectWriteProxy writeProxy) { UserStatusChangeProcessor.writeProxy = writeProxy; }
|
||||||
|
// TODO may cause an problem if two clients log in at the same time.
|
||||||
|
// Change Needed.
|
||||||
|
}
|
10
src/main/java/envoy/server/processors/package-info.java
Executable file
10
src/main/java/envoy/server/processors/package-info.java
Executable file
@ -0,0 +1,10 @@
|
|||||||
|
/**
|
||||||
|
* This package contains all classes that process data received from client
|
||||||
|
* connections.
|
||||||
|
*
|
||||||
|
* @author Kai S. K. Engelbart
|
||||||
|
* @author Leon Hofmeister
|
||||||
|
* @author Maximilian Käfer
|
||||||
|
* @since Envoy v0.1-alpha
|
||||||
|
*/
|
||||||
|
package envoy.server.processors;
|
98
src/main/java/envoy/server/util/PasswordUtil.java
Normal file
98
src/main/java/envoy/server/util/PasswordUtil.java
Normal file
@ -0,0 +1,98 @@
|
|||||||
|
package envoy.server.util;
|
||||||
|
|
||||||
|
import java.math.BigInteger;
|
||||||
|
import java.security.GeneralSecurityException;
|
||||||
|
import java.security.NoSuchAlgorithmException;
|
||||||
|
import java.security.SecureRandom;
|
||||||
|
|
||||||
|
import javax.crypto.SecretKeyFactory;
|
||||||
|
import javax.crypto.spec.PBEKeySpec;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Provides a password hashing and comparison mechanism using the
|
||||||
|
* {@code PBKDF2WithHmacSHA1} algorithm.
|
||||||
|
* <p>
|
||||||
|
* Project: <strong>envoy-server-standalone</strong><br>
|
||||||
|
* File: <strong>PasswordUtil.java</strong><br>
|
||||||
|
* Created: <strong>10.07.2020</strong><br>
|
||||||
|
*
|
||||||
|
* @author Kai S. K. Engelbart
|
||||||
|
* @since Envoy Server Standalone v0.1-beta
|
||||||
|
*/
|
||||||
|
public class PasswordUtil {
|
||||||
|
|
||||||
|
private static final int ITERATIONS = 1000;
|
||||||
|
private static final int KEY_LENGTH = 64 * 8;
|
||||||
|
private static final String SALT_ALGORITHM = "SHA1PRNG";
|
||||||
|
private static final String SECRET_KEY_ALGORITHM = "PBKDF2WithHmacSHA1";
|
||||||
|
|
||||||
|
private PasswordUtil() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Validates a password against a stored password hash
|
||||||
|
*
|
||||||
|
* @param current the password to validate
|
||||||
|
* @param stored the hash to validate against
|
||||||
|
* @return {@code true} if the password is correct
|
||||||
|
* @since Envoy Server Standalone v0.1-beta
|
||||||
|
*/
|
||||||
|
public static boolean validate(String current, String stored) {
|
||||||
|
try {
|
||||||
|
String[] parts = stored.split(":");
|
||||||
|
int iterations = Integer.parseInt(parts[0]);
|
||||||
|
byte[] salt = fromHex(parts[1]);
|
||||||
|
byte[] hash = fromHex(parts[2]);
|
||||||
|
|
||||||
|
var spec = new PBEKeySpec(current.toCharArray(), salt, iterations, KEY_LENGTH);
|
||||||
|
var skf = SecretKeyFactory.getInstance(SECRET_KEY_ALGORITHM);
|
||||||
|
byte[] testHash = skf.generateSecret(spec).getEncoded();
|
||||||
|
|
||||||
|
int diff = hash.length ^ testHash.length;
|
||||||
|
for (int i = 0; i < hash.length && i < testHash.length; ++i)
|
||||||
|
diff |= hash[i] ^ testHash[i];
|
||||||
|
|
||||||
|
return diff == 0;
|
||||||
|
} catch (GeneralSecurityException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a parameterized salted password hash.
|
||||||
|
*
|
||||||
|
* @param password the password to hash
|
||||||
|
* @return a result string in the form of {@code iterations:salt:hash}
|
||||||
|
* @since Envoy Server Standalone v0.1-beta
|
||||||
|
*/
|
||||||
|
public static String hash(String password) {
|
||||||
|
try {
|
||||||
|
byte[] salt = salt();
|
||||||
|
var spec = new PBEKeySpec(password.toCharArray(), salt, ITERATIONS, KEY_LENGTH);
|
||||||
|
var skf = SecretKeyFactory.getInstance(SECRET_KEY_ALGORITHM);
|
||||||
|
byte[] hash = skf.generateSecret(spec).getEncoded();
|
||||||
|
return ITERATIONS + ":" + toHex(salt) + ":" + toHex(hash);
|
||||||
|
} catch (GeneralSecurityException e) {
|
||||||
|
throw new RuntimeException(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static byte[] salt() throws NoSuchAlgorithmException {
|
||||||
|
SecureRandom sr = SecureRandom.getInstance(SALT_ALGORITHM);
|
||||||
|
byte[] salt = new byte[16];
|
||||||
|
sr.nextBytes(salt);
|
||||||
|
return salt;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String toHex(byte[] bytes) {
|
||||||
|
String hex = new BigInteger(1, bytes).toString(16);
|
||||||
|
int padding = bytes.length * 2 - hex.length();
|
||||||
|
return padding > 0 ? String.format("%0" + padding + "d", 0) + hex : hex;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static byte[] fromHex(String hex) {
|
||||||
|
byte[] bytes = new byte[hex.length() / 2];
|
||||||
|
for (int i = 0; i < bytes.length; ++i)
|
||||||
|
bytes[i] = (byte) Integer.parseInt(hex.substring(2 * i, 2 * i + 2), 16);
|
||||||
|
return bytes;
|
||||||
|
}
|
||||||
|
}
|
94
src/main/java/envoy/server/util/VersionUtil.java
Normal file
94
src/main/java/envoy/server/util/VersionUtil.java
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
package envoy.server.util;
|
||||||
|
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Implements a comparison algorithm between Envoy versions and defines minimal
|
||||||
|
* and maximal client versions compatible with this server.
|
||||||
|
* <p>
|
||||||
|
* Project: <strong>envoy-server-standalone</strong><br>
|
||||||
|
* File: <strong>VersionUtil.java</strong><br>
|
||||||
|
* Created: <strong>23.06.2020</strong><br>
|
||||||
|
*
|
||||||
|
* @author Kai S. K. Engelbart
|
||||||
|
* @since Envoy Server Standalone v0.1-beta
|
||||||
|
*/
|
||||||
|
public class VersionUtil {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The minimal client version compatible with this server.
|
||||||
|
*
|
||||||
|
* @since Envoy Server Standalone v0.1-beta
|
||||||
|
*/
|
||||||
|
public static final String MIN_CLIENT_VERSION = "0.1-beta";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The maximal client version compatible with this server.
|
||||||
|
*
|
||||||
|
* @since Envoy Server Standalone v0.1-beta
|
||||||
|
*/
|
||||||
|
public static final String MAX_CLIENT_VERSION = "0.1-beta";
|
||||||
|
|
||||||
|
private static final Pattern versionPattern = Pattern.compile("(?<major>\\d).(?<minor>\\d)(?:-(?<suffix>\\w+))?");
|
||||||
|
|
||||||
|
private VersionUtil() {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parses an Envoy Client version string and checks whether that version is
|
||||||
|
* compatible with this server.
|
||||||
|
*
|
||||||
|
* @param version the version string to parse
|
||||||
|
* @return {@code true} if the given version is compatible with this server
|
||||||
|
* @since Envoy Server Standalone v0.1-beta
|
||||||
|
*/
|
||||||
|
public static boolean verifyCompatibility(String version) {
|
||||||
|
final var currentMatcher = versionPattern.matcher(version);
|
||||||
|
|
||||||
|
if (!currentMatcher.matches()) return false;
|
||||||
|
|
||||||
|
final var minMatcher = versionPattern.matcher(MIN_CLIENT_VERSION);
|
||||||
|
final var maxMatcher = versionPattern.matcher(MAX_CLIENT_VERSION);
|
||||||
|
|
||||||
|
if (!minMatcher.matches() || !maxMatcher.matches()) throw new RuntimeException("Invalid min or max client version configured!");
|
||||||
|
|
||||||
|
// Compare suffixes
|
||||||
|
{
|
||||||
|
final var currentSuffix = convertSuffix(currentMatcher.group("suffix"));
|
||||||
|
final var minSuffix = convertSuffix(minMatcher.group("suffix"));
|
||||||
|
final var maxSuffix = convertSuffix(maxMatcher.group("suffix"));
|
||||||
|
|
||||||
|
if (currentSuffix < minSuffix || currentSuffix > maxSuffix) return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Compare major
|
||||||
|
{
|
||||||
|
final var currentMajor = Integer.parseInt(currentMatcher.group("major"));
|
||||||
|
final var minMajor = Integer.parseInt(minMatcher.group("major"));
|
||||||
|
final var maxMajor = Integer.parseInt(maxMatcher.group("major"));
|
||||||
|
|
||||||
|
if (currentMajor < minMajor || currentMajor > maxMajor) return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Compare minor
|
||||||
|
{
|
||||||
|
final var currentMinor = Integer.parseInt(currentMatcher.group("minor"));
|
||||||
|
final var minMinor = Integer.parseInt(minMatcher.group("minor"));
|
||||||
|
final var maxMinor = Integer.parseInt(maxMatcher.group("minor"));
|
||||||
|
|
||||||
|
if (currentMinor < minMinor || currentMinor > maxMinor) return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int convertSuffix(String suffix) {
|
||||||
|
switch (suffix == null ? "" : suffix) {
|
||||||
|
case "alpha":
|
||||||
|
return 0;
|
||||||
|
case "beta":
|
||||||
|
return 1;
|
||||||
|
default:
|
||||||
|
return 2;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
11
src/main/java/envoy/server/util/package-info.java
Normal file
11
src/main/java/envoy/server/util/package-info.java
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
/**
|
||||||
|
* This package contains utility classes used in Envoy Server.
|
||||||
|
* <p>
|
||||||
|
* Project: <strong>envoy-server-standalone</strong><br>
|
||||||
|
* File: <strong>package-info.java</strong><br>
|
||||||
|
* Created: <strong>23.06.2020</strong><br>
|
||||||
|
*
|
||||||
|
* @author Kai S. K. Engelbart
|
||||||
|
* @since Envoy Server Standalone v0.1-beta
|
||||||
|
*/
|
||||||
|
package envoy.server.util;
|
20
src/main/java/module-info.java
Executable file
20
src/main/java/module-info.java
Executable file
@ -0,0 +1,20 @@
|
|||||||
|
/**
|
||||||
|
* This module contains all classes defining the server application of the Envoy
|
||||||
|
* project.
|
||||||
|
*
|
||||||
|
* @author Kai S. K. Engelbart
|
||||||
|
* @author Leon Hofmeister
|
||||||
|
* @author Maximilian Käfer
|
||||||
|
* @since Envoy Server Standalone v0.1-beta
|
||||||
|
*/
|
||||||
|
module envoy.server {
|
||||||
|
|
||||||
|
opens envoy.server.data;
|
||||||
|
|
||||||
|
requires transitive envoy.common;
|
||||||
|
requires transitive java.nio.server;
|
||||||
|
requires transitive java.persistence;
|
||||||
|
requires transitive java.sql;
|
||||||
|
requires transitive org.hibernate.orm.core;
|
||||||
|
|
||||||
|
}
|
27
src/main/resources/META-INF/persistence.xml
Executable file
27
src/main/resources/META-INF/persistence.xml
Executable file
@ -0,0 +1,27 @@
|
|||||||
|
<persistence xmlns="http://xmlns.jcp.org/xml/ns/persistence"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/persistence
|
||||||
|
http://xmlns.jcp.org/xml/ns/persistence/persistence_2_1.xsd"
|
||||||
|
version="2.1">
|
||||||
|
<persistence-unit name="envoy"
|
||||||
|
transaction-type="RESOURCE_LOCAL">
|
||||||
|
<properties>
|
||||||
|
|
||||||
|
<!-- JDBC -->
|
||||||
|
<property name="javax.persistence.jdbc.driver"
|
||||||
|
value="org.postgresql.Driver" />
|
||||||
|
<property name="javax.persistence.jdbc.url"
|
||||||
|
value="jdbc:postgresql://localhost/envoy" />
|
||||||
|
<property name="javax.persistence.jdbc.user" value="envoy" />
|
||||||
|
<property name="javax.persistence.jdbc.password"
|
||||||
|
value="envoy" />
|
||||||
|
|
||||||
|
|
||||||
|
<!-- Hibernate -->
|
||||||
|
<property name="hibernate.dialect"
|
||||||
|
value="org.hibernate.dialect.PostgreSQL95Dialect" />
|
||||||
|
<property name="hibernate.hbm2ddl.auto" value="update" />
|
||||||
|
|
||||||
|
</properties>
|
||||||
|
</persistence-unit>
|
||||||
|
</persistence>
|
Reference in New Issue
Block a user