Skip to content

Commit 6079bb6

Browse files
author
Hattinger04
committed
fixing big bug
1 parent 6b5c18d commit 6079bb6

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+68
-100
lines changed

src/main/java/io/github/Hattinger04/configuration/SecurityConfiguration.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public void addResourceHandlers(ResourceHandlerRegistry registry) {
2727

2828
@Override
2929
public void addCorsMappings(CorsRegistry registry) {
30-
// TODO: delete not needed origins when publising
30+
// TODO: delete not needed origins when publishing
3131
registry.addMapping("/**").allowedOrigins("https://localhost", "https://192.168.0.42", "https://93.82.91.106", "https://192.168.31.65", "https://192.168.31.64").allowedMethods("GET", "POST", "OPTIONS")
3232
.allowCredentials(true).allowedHeaders("*").exposedHeaders("set-cookie").maxAge(3600);
3333
}

src/main/java/io/github/Hattinger04/hamster/HamsterController.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public class HamsterController {
3838
private File createNewFile(String path) {
3939
try {
4040
File file = new File(path);
41-
file.getParentFile().mkdir();
41+
new File(path.substring(0, path.lastIndexOf("/"))).mkdirs();
4242
file.createNewFile();
4343
return file;
4444
} catch (IOException e) {

src/main/java/io/github/Hattinger04/hamsterEvaluation/compiler/controller/CompilerController.java

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -75,12 +75,7 @@ public boolean ensureCompiled(HamsterFile file) {
7575
System.out.println("Ensuring Compiled...");
7676
return this.compilerModel.compile(file); // dibo 15.11.2010
7777
} catch (IOException e) { // dibo 25.10.2011
78-
String msg = Utils.getResource("compiler.msg.rights1")
79-
+ Utils.HOME
80-
+ Utils.getResource("compiler.msg.rights2");
81-
String title = Utils.getResource("compiler.msg.title");
82-
System.out.println(title);
83-
System.out.println(msg);
78+
System.out.println("Compiling error! " + e.getMessage());
8479
}
8580
}
8681
return true;

src/main/java/io/github/Hattinger04/hamsterEvaluation/compiler/model/JavaCompiler.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
import java.util.regex.Matcher;
1212
import java.util.regex.Pattern;
1313

14+
import org.springframework.security.core.context.SecurityContextHolder;
15+
1416
import com.sun.tools.javac.Main;
1517

1618
import io.github.Hattinger04.hamsterEvaluation.model.HamsterFile;
@@ -30,7 +32,7 @@ public class JavaCompiler {
3032
* In diese Temporaere Datei werden die javac-Fehlermeldungen geschrieben,
3133
* bevor sie dann wieder eingelesen werden.
3234
*/
33-
public static final String TEMP_FILE = "compiler.tmp";
35+
public static final String TEMP_FILE = "compiler.tmp"; // TODO: very ugly programming by myself -> make better someday
3436

3537
/**
3638
* Der Classpath waehrend der Compilierung
@@ -95,7 +97,7 @@ public static String readTempFile() throws IOException {
9597

9698
FileInputStream input = null;
9799
try {
98-
input = new FileInputStream(Utils.HOME + Utils.FSEP + TEMP_FILE);
100+
input = new FileInputStream(Utils.HOME + Utils.FSEP + SecurityContextHolder.getContext().getAuthentication().getName() + Utils.FSEP + TEMP_FILE);
99101
buffer = new byte[input.available()];
100102
input.read(buffer);
101103
} finally {
@@ -128,7 +130,7 @@ public List compile(HamsterFile file) throws IOException {
128130
PrintWriter writer = null;
129131
FileWriter fwriter = null;
130132
try {
131-
fwriter = new FileWriter(Utils.HOME + Utils.FSEP + TEMP_FILE);
133+
fwriter = new FileWriter(Utils.HOME + Utils.FSEP + SecurityContextHolder.getContext().getAuthentication().getName() + Utils.FSEP + TEMP_FILE);
132134

133135
writer = new PrintWriter(fwriter);
134136
Main.compile(args, writer);

src/main/java/io/github/Hattinger04/hamsterEvaluation/lego/model/KornDaException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public int getSpalte() {
3131
}
3232

3333
public String toString() {
34-
return Utils.getResource("hamster.KornDaException") + " (" + reihe + ", " + spalte + ")";
34+
return "hamster.KornDaException" + " (" + reihe + ", " + spalte + ")";
3535
}
3636

3737

src/main/java/io/github/Hattinger04/hamsterEvaluation/lego/model/MaulNichtLeerException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ public MaulNichtLeerException(Hamster hamster) {
2020
}
2121

2222
public String toString() {
23-
return Utils.getResource("hamster.MaulNichtLeerException");
23+
return "hamster.MaulNichtLeerException";
2424
}
2525

2626

src/main/java/io/github/Hattinger04/hamsterEvaluation/model/HamsterFile.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,10 @@ public HamsterFile(char type) {
114114
changeSupport = new PropertyChangeSupport(this);
115115
this.type = type;
116116
file = new File(Utils.HOME + Utils.FSEP
117-
+ Utils.getResource("model.neuerhamster") + count++);
117+
+ "model.neuerhamster" + count++);
118118
while (file.exists())
119119
file = new File(Utils.HOME + Utils.FSEP
120-
+ Utils.getResource("model.neuerhamster") + count++);
120+
+ "model.neuerhamster" + count++);
121121
}
122122

123123
public HamsterFile(String code, char type) {
@@ -407,7 +407,7 @@ public String load() {
407407
} else if (type == OBJECT) {
408408
return "void main() {\n \n}\n";
409409
} else if (type == HAMSTERCLASS) {
410-
return "class " + Utils.getResource("model.meinhamster")
410+
return "class " + "model.meinhamster"
411411
+ " extends Hamster {\n \n}\n";
412412
} else if (type == SCHEMEPROGRAM) { // Martin
413413
return "(define (start Territorium)\n()\n)";

src/main/java/io/github/Hattinger04/hamsterEvaluation/model/HamsterInitialisierungsException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ public HamsterInitialisierungsException(Hamster hamster) {
1616
}
1717

1818
public String toString() {
19-
return Utils.getResource("hamster.HamsterInitialisierungsException");
19+
return "hamster.HamsterInitialisierungsException";
2020
}
2121
}

src/main/java/io/github/Hattinger04/hamsterEvaluation/model/HamsterInstruction.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -52,27 +52,27 @@ public int getHamster() {
5252
public String toString() {
5353
switch (getType()) {
5454
case FORWARD:
55-
return Utils.getResource("hamster.vor") + "()";
55+
return "hamster.vor" + "()";
5656
case TURN_LEFT:
57-
return Utils.getResource("hamster.linksUm") + "()";
57+
return "hamster.linksUm" + "()";
5858
case LAY_DOWN:
59-
return Utils.getResource("hamster.gib") + "()";
59+
return "hamster.gib" + "()";
6060
case PICK_UP:
61-
return Utils.getResource("hamster.nimm") + "()";
61+
return "hamster.nimm" + "()";
6262
case FREE:
63-
return Utils.getResource("hamster.vornFrei") + "()";
63+
return "hamster.vornFrei" + "()";
6464
case CORN_AVAILABLE:
65-
return Utils.getResource("hamster.kornDa") + "()";
65+
return "hamster.kornDa" + "()";
6666
case MOUTH_EMPTY:
67-
return Utils.getResource("hamster.maulLeer") + "()";
67+
return "hamster.maulLeer" + "()";
6868
case GET_ROW:
69-
return Utils.getResource("hamster.getReihe") + "()";
69+
return "hamster.getReihe" + "()";
7070
case GET_COL:
71-
return Utils.getResource("hamster.getSpalte") + "()";
71+
return "hamster.getSpalte" + "()";
7272
case GET_DIR:
73-
return Utils.getResource("hamster.getBlickrichtung") + "()";
73+
return "hamster.getBlickrichtung" + "()";
7474
case GET_MOUTH:
75-
return Utils.getResource("hamster.getAnzahlKoerner") + "()";
75+
return "hamster.getAnzahlKoerner" + "()";
7676

7777
case GET_DATA:
7878
return "";

src/main/java/io/github/Hattinger04/hamsterEvaluation/model/HamsterNichtInitialisiertException.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,6 @@ public HamsterNichtInitialisiertException(Hamster hamster) {
1616
}
1717

1818
public String toString() {
19-
return Utils.getResource("hamster.HamsterNichtInitialisiertException");
19+
return "hamster.HamsterNichtInitialisiertException";
2020
}
2121
}

0 commit comments

Comments
 (0)