9
9
using OJS . Services . Infrastructure . Exceptions ;
10
10
using OJS . Services . Worker . Business ;
11
11
using OJS . Services . Common . Models . Submissions . ExecutionContext ;
12
+ using OJS . Services . Infrastructure . Constants ;
12
13
using OJS . Services . Infrastructure . Extensions ;
13
14
using System ;
14
15
using System . Threading . Tasks ;
18
19
public class SubmissionsController : BaseApiController
19
20
{
20
21
private readonly ISubmissionsBusinessService submissionsBusiness ;
21
- // private readonly ILogger<SubmissionsController> logger;
22
+ private readonly ILogger < SubmissionsController > logger ;
23
+ private readonly IHostInfoService hostInfoService ;
22
24
23
25
public SubmissionsController (
24
26
ISubmissionsBusinessService submissionsBusiness ,
25
- ILogger < SubmissionsController > logger ) =>
27
+ ILogger < SubmissionsController > logger ,
28
+ IHostInfoService hostInfoService )
29
+ {
26
30
this . submissionsBusiness = submissionsBusiness ;
31
+ this . logger = logger ;
32
+ this . hostInfoService = hostInfoService ;
33
+ }
27
34
28
35
[ HttpPost ]
29
36
[ ProducesResponseType ( typeof ( FullExecutionResultResponseModel ) , Status200OK ) ]
@@ -49,17 +56,6 @@ public async Task<IActionResult> ExecuteFileSubmission(
49
56
submissionFileRequestModel . WithExceptionStackTrace )
50
57
. ToOkResult ( ) ;
51
58
52
- // Dont think thats used anymore
53
- // [HttpPost]
54
- // [ProducesResponseType(typeof(FullExecutionResultResponseModel), Status200OK)]
55
- // public async Task<IActionResult> ExecuteFileSubmissionWithJson(
56
- // [ModelBinder(typeof(JsonWithFilesFormDataModelBinder), Name = "executionContextJson")]
57
- // SubmissionFileRequestModel submissionFileRequestModel)
58
- // => await this.ExecuteSubmission(
59
- // submissionFileRequestModel.Map<SubmissionServiceModel>(),
60
- // submissionFileRequestModel.WithExceptionStackTrace)
61
- // .ToOkResult();
62
-
63
59
private async Task < FullExecutionResultResponseModel > ExecuteSubmission (
64
60
SubmissionServiceModel submission ,
65
61
bool withStackTrace )
@@ -74,13 +70,10 @@ private async Task<FullExecutionResultResponseModel> ExecuteSubmission(
74
70
75
71
result . SetExecutionResult ( executionResultResponseModel ) ;
76
72
}
77
- catch ( BusinessServiceException ex )
78
- {
79
- result . SetException ( ex , false ) ;
80
- }
81
73
catch ( Exception ex )
82
74
{
83
- result . SetException ( ex , withStackTrace ) ;
75
+ this . logger . LogErrorProcessingSubmission ( submission . Id , this . hostInfoService . GetHostIp ( ) , ex ) ;
76
+ result . SetException ( ex , ex is not BusinessServiceException && withStackTrace ) ;
84
77
}
85
78
finally
86
79
{
0 commit comments