This is the codeAbility Sharing Platform! Learn more about the codeAbility Sharing Platform.

Skip to content
Snippets Groups Projects
Commit 28cf9d4b authored by Michael Breu's avatar Michael Breu :speech_balloon:
Browse files

Sonar

parent dd111349
2 merge requests!188Merging Peer Reviewing et. al to Master,!164211 peer reviewing functionality
......@@ -38,7 +38,11 @@ import at.ac.uibk.gitsearch.web.util.HeaderUtil;
@RequestMapping("/api")
public class ExerciseResource {
private final Logger log = LoggerFactory.getLogger(ExerciseResource.class);
private static final String NOT_FOUND = "not found";
private static final String REPOSITORYFILE = "RepositoryFile";
private final Logger log = LoggerFactory.getLogger(ExerciseResource.class);
@Autowired
private GitlabService gitLabService;
......@@ -65,7 +69,7 @@ public class ExerciseResource {
try {
parsedId = ExerciseId.fromString(exerciseId);
} catch (ParseException e) {
return ResponseEntity.notFound().headers(HeaderUtil.createFailureAlert(applicationName, true, "RepositoryFile", "not found",
return ResponseEntity.notFound().headers(HeaderUtil.createFailureAlert(applicationName, true, REPOSITORYFILE, NOT_FOUND,
"There was an error finding your exercise " + exerciseId + ".")).build();
}
......@@ -74,7 +78,7 @@ public class ExerciseResource {
repositoryStream = gitLabService.getRepositoryFile(parsedId, filePath);
} catch (IOException | GitLabApiException e) {
log.warn("Cannot read file for exercise {} and path {}: {}", exerciseId, filePath, e.getMessage());
return ResponseEntity.notFound().headers(HeaderUtil.createFailureAlert(applicationName, true, "RepositoryFile", "not found",
return ResponseEntity.notFound().headers(HeaderUtil.createFailureAlert(applicationName, true, REPOSITORYFILE, NOT_FOUND,
"There was an error on the server and the resource file could not be created.")).build(); }
InputStreamResource resource = new InputStreamResource(repositoryStream);
......@@ -98,7 +102,7 @@ public class ExerciseResource {
try {
parsedId = ExerciseId.fromString(exerciseId);
} catch (ParseException e) {
return ResponseEntity.notFound().headers(HeaderUtil.createFailureAlert(applicationName, true, "RepositoryFile", "not found",
return ResponseEntity.notFound().headers(HeaderUtil.createFailureAlert(applicationName, true, REPOSITORYFILE, NOT_FOUND,
"There was an error with your requested id " + exerciseId + ".")).build();
}
......@@ -108,7 +112,7 @@ public class ExerciseResource {
if(result.isPresent()) {
return ResponseEntity.ok().contentType(MediaType.APPLICATION_JSON).body(result.get());
} else {
return ResponseEntity.notFound().headers(HeaderUtil.createFailureAlert(applicationName, true, "RepositoryFile", "not found",
return ResponseEntity.notFound().headers(HeaderUtil.createFailureAlert(applicationName, true, REPOSITORYFILE, NOT_FOUND,
"There was an error finding your exercise " + exerciseId + ".")).build();
}
}
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment