Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
E
Enigma
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Uli Bähr
Enigma
Commits
bb984ff2
Commit
bb984ff2
authored
5 years ago
by
Dennis Eisold
Browse files
Options
Downloads
Patches
Plain Diff
Anpassungen auf Java Konventionen
Dependencys für Unittest hinzugefügt
parent
dc0a785a
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
pom.xml
+7
-6
7 additions, 6 deletions
pom.xml
src/main/java/Enigma/model/Codebuch.java
+9
-3
9 additions, 3 deletions
src/main/java/Enigma/model/Codebuch.java
src/main/java/Enigma/model/Funkraum.java
+9
-10
9 additions, 10 deletions
src/main/java/Enigma/model/Funkraum.java
with
25 additions
and
19 deletions
pom.xml
+
7
−
6
View file @
bb984ff2
...
@@ -31,12 +31,6 @@
...
@@ -31,12 +31,6 @@
<artifactId>
sqlite-jdbc
</artifactId>
<artifactId>
sqlite-jdbc
</artifactId>
<version>
3.28.0
</version>
<version>
3.28.0
</version>
</dependency>
</dependency>
<!-- https://mvnrepository.com/artifact/org.mariadb.jdbc/mariadb-java-client -->
<dependency>
<groupId>
org.mariadb.jdbc
</groupId>
<artifactId>
mariadb-java-client
</artifactId>
<version>
2.5.2
</version>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient -->
<!-- https://mvnrepository.com/artifact/org.apache.httpcomponents/httpclient -->
<dependency>
<dependency>
<groupId>
org.apache.httpcomponents
</groupId>
<groupId>
org.apache.httpcomponents
</groupId>
...
@@ -49,6 +43,13 @@
...
@@ -49,6 +43,13 @@
<artifactId>
json
</artifactId>
<artifactId>
json
</artifactId>
<version>
20190722
</version>
<version>
20190722
</version>
</dependency>
</dependency>
<!-- https://mvnrepository.com/artifact/junit/junit -->
<dependency>
<groupId>
junit
</groupId>
<artifactId>
junit
</artifactId>
<version>
4.12
</version>
<scope>
test
</scope>
</dependency>
</dependencies>
</dependencies>
<build>
<build>
<plugins>
<plugins>
...
...
This diff is collapsed.
Click to expand it.
src/main/java/Enigma/model/Codebuch.java
+
9
−
3
View file @
bb984ff2
...
@@ -18,9 +18,15 @@ package Enigma.model;
...
@@ -18,9 +18,15 @@ package Enigma.model;
*/
*/
public
class
Codebuch
{
public
class
Codebuch
{
private
int
tag
;
private
int
tag
;
private
String
[]
Walzenlage
=
new
String
[
3
];
private
String
[]
Walzenlage
;
private
String
[]
Ringstellung
=
new
String
[
3
];
private
String
[]
Ringstellung
;
private
String
[]
Steckverbindung
=
new
String
[
10
];
private
String
[]
Steckverbindung
;
Codebuch
()
{
this
.
Walzenlage
=
new
String
[
3
];
this
.
Ringstellung
=
new
String
[
3
];
this
.
Steckverbindung
=
new
String
[
10
];
}
/**
/**
* Gibt die aktuelle Instanz des Codebuches als String zurück.
* Gibt die aktuelle Instanz des Codebuches als String zurück.
...
...
This diff is collapsed.
Click to expand it.
src/main/java/Enigma/model/Funkraum.java
+
9
−
10
View file @
bb984ff2
package
Enigma.model
;
package
Enigma.model
;
import
org.apache.http.HttpEntity
;
import
org.apache.http.HttpEntity
;
import
org.apache.http.HttpException
;
import
org.apache.http.HttpResponse
;
import
org.apache.http.HttpResponse
;
import
org.apache.http.NameValuePair
;
import
org.apache.http.NameValuePair
;
import
org.apache.http.client.HttpClient
;
import
org.apache.http.client.HttpClient
;
...
@@ -12,6 +13,7 @@ import org.json.JSONObject;
...
@@ -12,6 +13,7 @@ import org.json.JSONObject;
import
java.io.BufferedReader
;
import
java.io.BufferedReader
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.io.InputStreamReader
;
import
java.io.InputStreamReader
;
import
java.io.UnsupportedEncodingException
;
import
java.util.ArrayList
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.List
;
...
@@ -31,7 +33,7 @@ public class Funkraum {
...
@@ -31,7 +33,7 @@ public class Funkraum {
*
*
* @param kenngruppe : String : Kenngruppe dieser Engiam
* @param kenngruppe : String : Kenngruppe dieser Engiam
* @return String[] : String Array wobei Index 0 dem Empfangstag entspricht und index 1 der empfangenen Nachricht
* @return String[] : String Array wobei Index 0 dem Empfangstag entspricht und index 1 der empfangenen Nachricht
* @throws IOException
* @throws IOException
: Exception : wenn keine Verbindung zum Funker aufgebaut werden konnte.
*/
*/
public
String
[]
empfangeFunkspruch
(
String
kenngruppe
)
throws
IOException
{
public
String
[]
empfangeFunkspruch
(
String
kenngruppe
)
throws
IOException
{
String
[]
funkspruch
=
new
String
[
2
];
String
[]
funkspruch
=
new
String
[
2
];
...
@@ -40,7 +42,7 @@ public class Funkraum {
...
@@ -40,7 +42,7 @@ public class Funkraum {
HttpPost
httppost
=
new
HttpPost
(
"https://enigma.itstall.de/"
);
HttpPost
httppost
=
new
HttpPost
(
"https://enigma.itstall.de/"
);
// Anfrage Parameter und Encoding setzen
// Anfrage Parameter und Encoding setzen
List
<
NameValuePair
>
params
=
new
ArrayList
<
NameValuePair
>(
2
);
List
<
NameValuePair
>
params
=
new
ArrayList
<>(
2
);
params
.
add
(
new
BasicNameValuePair
(
"k"
,
kenngruppe
));
params
.
add
(
new
BasicNameValuePair
(
"k"
,
kenngruppe
));
httppost
.
setEntity
(
new
UrlEncodedFormEntity
(
params
,
"UTF-8"
));
httppost
.
setEntity
(
new
UrlEncodedFormEntity
(
params
,
"UTF-8"
));
...
@@ -75,16 +77,14 @@ public class Funkraum {
...
@@ -75,16 +77,14 @@ public class Funkraum {
*
*
* @param funkspruch : String : Der zu sendede Funkspruch
* @param funkspruch : String : Der zu sendede Funkspruch
* @param kenngruppe : String : Die Kenngruppe dieser Engima
* @param kenngruppe : String : Die Kenngruppe dieser Engima
* @return boolean : War das senden erfolgreich? True wenn ja, false wenn nicht erfolgreich
* @throws IOException : Exception : Funkspruch konnte nicht gesendet werden
* @throws IOException
*/
*/
public
boolean
sendeFunkspruch
(
String
funkspruch
,
String
kenngruppe
)
throws
IOException
{
public
void
sendeFunkspruch
(
String
funkspruch
,
String
kenngruppe
)
throws
HttpException
,
IOException
{
boolean
boolReturn
=
false
;
HttpClient
httpclient
=
HttpClients
.
createDefault
();
HttpClient
httpclient
=
HttpClients
.
createDefault
();
HttpPost
httppost
=
new
HttpPost
(
"https://enigma.itstall.de/"
);
HttpPost
httppost
=
new
HttpPost
(
"https://enigma.itstall.de/"
);
// Anfrage Parameter und Encoding setzen
// Anfrage Parameter und Encoding setzen
List
<
NameValuePair
>
params
=
new
ArrayList
<
NameValuePair
>(
2
);
List
<
NameValuePair
>
params
=
new
ArrayList
<>(
2
);
params
.
add
(
new
BasicNameValuePair
(
"k"
,
kenngruppe
));
params
.
add
(
new
BasicNameValuePair
(
"k"
,
kenngruppe
));
params
.
add
(
new
BasicNameValuePair
(
"m"
,
funkspruch
));
params
.
add
(
new
BasicNameValuePair
(
"m"
,
funkspruch
));
httppost
.
setEntity
(
new
UrlEncodedFormEntity
(
params
,
"UTF-8"
));
httppost
.
setEntity
(
new
UrlEncodedFormEntity
(
params
,
"UTF-8"
));
...
@@ -96,11 +96,10 @@ public class Funkraum {
...
@@ -96,11 +96,10 @@ public class Funkraum {
if
(
entity
!=
null
)
{
if
(
entity
!=
null
)
{
BufferedReader
reader
=
new
BufferedReader
(
new
InputStreamReader
(
entity
.
getContent
()));
BufferedReader
reader
=
new
BufferedReader
(
new
InputStreamReader
(
entity
.
getContent
()));
JSONObject
result
=
new
JSONObject
(
reader
.
readLine
());
JSONObject
result
=
new
JSONObject
(
reader
.
readLine
());
if
(
result
.
getInt
(
"result"
)
=
=
200
)
{
if
(
result
.
getInt
(
"result"
)
!
=
200
)
{
boolReturn
=
true
;
throw
new
HttpException
(
"Der andere Funker mag deine Nachricht nicht. Rüge ihn wenn du ihn wieder siehst..."
)
;
}
}
}
}
return
boolReturn
;
}
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment