Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
corpus-web-services
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Lange, Dr. Herbert
corpus-web-services
Commits
a18b65b8
Commit
a18b65b8
authored
3 years ago
by
Lange, Dr. Herbert
Browse files
Options
Downloads
Patches
Plain Diff
cleanup static file handler
parent
ba273481
No related branches found
No related tags found
No related merge requests found
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/de/uni_hamburg/corpora/server/Static.java
+1
-29
1 addition, 29 deletions
src/main/java/de/uni_hamburg/corpora/server/Static.java
with
1 addition
and
29 deletions
src/main/java/de/uni_hamburg/corpora/server/Static.java
+
1
−
29
View file @
a18b65b8
...
@@ -4,22 +4,14 @@ import jakarta.ws.rs.GET;
...
@@ -4,22 +4,14 @@ import jakarta.ws.rs.GET;
import
jakarta.ws.rs.Path
;
import
jakarta.ws.rs.Path
;
import
jakarta.ws.rs.PathParam
;
import
jakarta.ws.rs.PathParam
;
import
jakarta.ws.rs.core.Response
;
import
jakarta.ws.rs.core.Response
;
import
org.apache.velocity.VelocityContext
;
import
org.apache.velocity.app.Velocity
;
import
org.slf4j.Logger
;
import
org.slf4j.Logger
;
import
org.slf4j.LoggerFactory
;
import
org.slf4j.LoggerFactory
;
import
java.io.File
;
import
java.io.FileInputStream
;
import
java.io.IOException
;
import
java.io.IOException
;
import
java.io.StringWriter
;
import
java.net.URISyntaxException
;
import
java.net.URL
;
import
java.nio.file.Files
;
/**
/**
* @author bba1792 Dr. Herbert Lange
* @author bba1792 Dr. Herbert Lange
* @version 202
11004
* @version 202
20405
* Class handling static files
* Class handling static files
*/
*/
@Path
(
"/static/{staticFile}"
)
@Path
(
"/static/{staticFile}"
)
...
@@ -35,26 +27,6 @@ public class Static {
...
@@ -35,26 +27,6 @@ public class Static {
@GET
@GET
public
Response
getStatic
(
@PathParam
(
"staticFile"
)
String
fileName
)
{
public
Response
getStatic
(
@PathParam
(
"staticFile"
)
String
fileName
)
{
logger
.
info
(
"Loading file "
+
fileName
);
logger
.
info
(
"Loading file "
+
fileName
);
// // Get file from resource
// URL resource = this.getClass().getClassLoader().getResource("static/"+ fileName);
// if (resource == null) {
// logger.info("Resource is null");
// return Response.status(404,"Invalid static file").build();
// }
// else {
// try {
// logger.info("Resource is " + resource.toURI());
// File staticFile = new File(resource.toURI());
// return Response.ok(new FileInputStream(staticFile),Files.probeContentType(staticFile.toPath())).build();
// } catch (URISyntaxException | IOException e) {
// return Response.status(500, "Error loading file").build();
// }
// }
StringWriter
result
=
new
StringWriter
();
VelocityContext
context
=
new
VelocityContext
();
// Velocity.mergeTemplate("static/" + fileName, "UTF-8",context,result) ;
// return Response.ok(result.toString()).build() ;
//return Response.ok(Velocity.getTemplate("static/" + fileName).toString()).build();
try
{
try
{
return
Response
.
ok
(
this
.
getClass
().
getModule
().
getResourceAsStream
(
"static/"
+
fileName
).
readAllBytes
()).
build
();
return
Response
.
ok
(
this
.
getClass
().
getModule
().
getResourceAsStream
(
"static/"
+
fileName
).
readAllBytes
()).
build
();
}
}
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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