Skip to content

Commit 26e1457

Browse files
committed
Add stdout and stderr text, fix example1.json returned
1 parent 3751ccd commit 26e1457

File tree

2 files changed

+22
-67
lines changed

2 files changed

+22
-67
lines changed

src/main/java/de/uni_stuttgart/tik/viplab/dummybackend/MessageResponder.java

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
import java.io.InputStream;
44
import java.io.StringReader;
5+
import java.text.SimpleDateFormat;
6+
import java.util.Base64;
7+
import java.util.Date;
58
import java.util.Optional;
69

710
import javax.enterprise.context.ApplicationScoped;
@@ -40,15 +43,26 @@ public String processCompuation(String message) {
4043
is = getClass().getClassLoader()
4144
.getResourceAsStream("results/example1.json");
4245
} else {
43-
//TODO: setup resources
46+
// TODO: setup resources
4447
}
48+
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm:ss z");
49+
String errMessage = "some random stderr at: " + formatter.format(new Date(System.currentTimeMillis()));
50+
String outMessage = "some random stdout at: " + formatter.format(new Date(System.currentTimeMillis()));
51+
4552
jsonReader = Json.createReader(is);
4653
JsonObject result = jsonReader.readObject();
4754
result = Json.createPatchBuilder()
4855
.replace("/computation",
4956
Json.createValue(computationID))
57+
.replace("/output/stderr",
58+
Json.createValue(Base64.getUrlEncoder()
59+
.encodeToString(errMessage.getBytes())))
60+
.replace("/output/stdout",
61+
Json.createValue(Base64.getUrlEncoder()
62+
.encodeToString(outMessage.getBytes())))
5063
.build()
5164
.apply(result);
65+
5266
logger.info(result);
5367
return result.toString();
5468
}

src/main/resources/results/example1.json

Lines changed: 7 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -9,79 +9,20 @@
99
"stdout" : "",
1010
"stderr" : ""
1111
},
12-
"artifacts" : [
13-
{
14-
"type": "notifications",
15-
"identifier" : "1dd479d9-c9bd-4711-aed8-5bfb3ec5fcfa",
16-
"summary" : "(C chain)v1.9 failed.",
17-
"elements" : [
18-
{
19-
"severity" : "info",
20-
"type" : "compiler",
21-
"message" : "source_0.c: In function \u2018trapez\u2019:",
22-
"output" : {
23-
"source" : "stderr",
24-
"extract" : "source_0.c: In function \u2018trapez\u2019:",
25-
"begin" : 0,
26-
"end" : 37
27-
}
28-
},
29-
{
30-
"severity" : "warning",
31-
"type" : "compiler",
32-
"message" : "source_0.c:21:10: warning: unused variable \u2018x\u2019 [-Wunused-variable]",
33-
"origin" : {
34-
"source" : "parts://7a1808d0-c997-4e28-acdf-bfda3ce70960",
35-
"extract" : " double x = 0;",
36-
"begin" : 406,
37-
"end" : 421,
38-
"line" : 15,
39-
"col" : 10
40-
},
41-
"output" : {
42-
"source" : "stderr",
43-
"extract" : "source_0.c:21:10: warning: unused variable \u2018x\u2019 [-Wunused-variable]",
44-
"begin" : 38,
45-
"end" : 108
46-
}
47-
},
48-
{
49-
"severity" : "error",
50-
"type" : "callcheck",
51-
"message" : "[C function filtering] Function call not allowed:\n\"system\"; original source: codeFromStudent, line (corrected): 20, col: 3\nForbidden calls:\nsystem.\n",
52-
"origin" : {
53-
"elementID" : "parts://7a1808d0-c997-4e28-acdf-bfda3ce70960",
54-
"extract" : " system(\"/bin/rm /tmp/foo.txt\"); // illegal call (should be catched by checker)",
55-
"begin" : 325,
56-
"end" : 405,
57-
"line" : 14,
58-
"col" : 3
59-
}
60-
}
61-
]
62-
},
12+
"artifacts" : [
6313
{
6414
"type" : "file",
6515
"identifier" : "de762095-6cd2-439f-80eb-313e85d33869",
66-
"MIMEtype": "image/png",
67-
"path" : "/images/img.png",
68-
"content": ""
16+
"MIMEtype": "text/plain",
17+
"path" : "/output/text1.txt",
18+
"content": "c29tZSBjb250ZW50"
6919
},
7020
{
7121
"type" : "file",
7222
"identifier" : "10516761-d937-4ba4-a82f-dc2847d45032",
73-
"MIMEtype": "image/png",
74-
"path" : "/images/img2.png",
75-
"content": ""
76-
},
77-
{
78-
"type" : "s3file",
79-
"identifier" : "cc3c1cf9-c02d-4694-902c-93c298d68c51",
80-
"MIMEtype": "application/gzip",
81-
"path" : "/largefile/result.tar.gz",
82-
"url": "https://s3.temporary.file.url/result.tar.gz",
83-
"size" : 123456789,
84-
"hash" : "sha512:hashcode_of_file"
23+
"MIMEtype": "text/plain",
24+
"path" : "/output/text2.txt",
25+
"content": "c29tZSBvdGhlciBjb250ZW50"
8526
}
8627
]
8728
}

0 commit comments

Comments
 (0)