This is the codeAbility Sharing Platform! Learn more about the
codeAbility Sharing Platform
.
Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
codeAbility Sharing Platform
Manage
Activity
Members
Labels
Plan
Issues
43
Issue boards
Milestones
Wiki
Code
Merge requests
1
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Analyze
Contributor analytics
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
development
sharing
codeAbility Sharing Platform
Commits
28cf9d4b
Commit
28cf9d4b
authored
3 years ago
by
Michael Breu
Browse files
Options
Downloads
Patches
Plain Diff
Sonar
parent
dd111349
2 merge requests
!188
Merging Peer Reviewing et. al to Master
,
!164
211 peer reviewing functionality
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/at/ac/uibk/gitsearch/web/rest/ExerciseResource.java
+9
-5
9 additions, 5 deletions
.../java/at/ac/uibk/gitsearch/web/rest/ExerciseResource.java
with
9 additions
and
5 deletions
src/main/java/at/ac/uibk/gitsearch/web/rest/ExerciseResource.java
+
9
−
5
View file @
28cf9d4b
...
...
@@ -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
();
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment