Revision 52781
Added by Panagiotis Kanakakis over 5 years ago
ValidatorApiImpl.java | ||
---|---|---|
17 | 17 |
import org.apache.log4j.Logger; |
18 | 18 |
import org.json.JSONException; |
19 | 19 |
import org.springframework.beans.factory.annotation.Autowired; |
20 |
import org.springframework.http.HttpStatus; |
|
21 |
import org.springframework.http.ResponseEntity; |
|
20 | 22 |
import org.springframework.security.access.prepost.PreAuthorize; |
21 | 23 |
import org.springframework.stereotype.Component; |
22 | 24 |
import org.springframework.web.bind.annotation.PathVariable; |
... | ... | |
86 | 88 |
} |
87 | 89 |
|
88 | 90 |
@Override |
89 |
@PreAuthorize("hasRole('ROLE_USER')") |
|
90 |
public void submitJobForValidation(@RequestBody JobForValidation jobForValidation) {
|
|
91 |
@PreAuthorize("hasRole('ROLE_USER') and #jobForValidation.userEmail == authentication.userInfo.email")
|
|
92 |
public JobForValidation submitJobForValidation(@RequestBody JobForValidation jobForValidation) throws ValidatorServiceException {
|
|
91 | 93 |
LOGGER.debug("Submit job for validation with id : " + jobForValidation.getDatasourceId()); |
92 | 94 |
try { |
93 | 95 |
this.getValidationService().submitValidationJob(jobForValidation); |
94 | 96 |
} catch (ValidatorServiceException e) { |
95 | 97 |
LOGGER.debug("Exception on submitJobForValidation" , e); |
96 | 98 |
emailUtils.reportException(e); |
99 |
throw e; |
|
97 | 100 |
} |
101 |
return jobForValidation; |
|
98 | 102 |
} |
99 | 103 |
|
100 | 104 |
@Override |
101 |
@PreAuthorize("hasRole('ROLE_USER')") |
|
102 |
public void reSubmitJobForValidation(@PathVariable("jobId") String jobId) throws JSONException { |
|
105 |
@PreAuthorize("hasRole('ROLE_USER') and #email == authentication.userInfo.email") |
|
106 |
public ResponseEntity<Object> reSubmitJobForValidation(@PathVariable("email") String email, |
|
107 |
@PathVariable("jobId") String jobId) throws JSONException, ValidatorServiceException { |
|
103 | 108 |
LOGGER.debug("Resubmit validation job with id : " + jobId); |
104 | 109 |
StoredJob job = monitorApi.getJobSummary(jobId,"all"); |
105 | 110 |
Set<Integer> contentRules = new HashSet<Integer>(); |
... | ... | |
125 | 130 |
if (!usageRules.isEmpty()) |
126 | 131 |
job.setSelectedUsageRules(usageRules); |
127 | 132 |
this.submitJobForValidation(job); |
133 |
return new ResponseEntity<>("OK",HttpStatus.OK); |
|
128 | 134 |
} |
129 | 135 |
|
130 | 136 |
@Override |
Also available in: Unified diff
1. Dockerize service
2. Add authorization checks
3. Handle exceptions ( controller advice, exception package)
4. Login-logout operations bug fixes