Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
V
vlkb-siav2
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
ViaLactea
vlkb-siav2
Commits
0b278afe
You need to sign in or sign up before continuing.
Commit
0b278afe
authored
1 year ago
by
Robert Butora
Browse files
Options
Downloads
Patches
Plain Diff
(quick hack:) makes response writing exclusive (from Servlet XOR from FormatFilter)
parent
3e6d0827
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
data-discovery/src/main/java/vlkb/webapi/FormatResponseFilter.java
+3
-5
3 additions, 5 deletions
...overy/src/main/java/vlkb/webapi/FormatResponseFilter.java
data-discovery/src/main/java/vlkb/webapi/SearchServlet.java
+7
-32
7 additions, 32 deletions
data-discovery/src/main/java/vlkb/webapi/SearchServlet.java
with
10 additions
and
37 deletions
data-discovery/src/main/java/vlkb/webapi/FormatResponseFilter.java
+
3
−
5
View file @
0b278afe
...
@@ -81,14 +81,12 @@ public class FormatResponseFilter implements Filter
...
@@ -81,14 +81,12 @@ public class FormatResponseFilter implements Filter
{
{
LOGGER
.
info
(
"trace"
);
LOGGER
.
info
(
"trace"
);
LOGGER
.
info
(
"REQUEST START ============================================================================================="
);
LOGGER
.
info
(
"REQUEST START ============================================================================================="
);
long
startTime_msec
=
System
.
currentTimeMillis
();
FormatResponseWrapper
responseWrapper
=
new
FormatResponseWrapper
((
HttpServletResponse
)
response
);
FormatResponseWrapper
responseWrapper
=
new
FormatResponseWrapper
((
HttpServletResponse
)
response
);
chain
.
doFilter
(
request
,
responseWrapper
);
chain
.
doFilter
(
request
,
responseWrapper
);
long
startTime_msec
=
System
.
currentTimeMillis
();
String
[]
pubdidArr
=
responseWrapper
.
getPubdidArr
();
String
[]
pubdidArr
=
responseWrapper
.
getPubdidArr
();
if
((
pubdidArr
!=
null
)
&&
(
pubdidArr
.
length
>
0
))
if
((
pubdidArr
!=
null
)
&&
(
pubdidArr
.
length
>
0
))
...
@@ -100,7 +98,6 @@ public class FormatResponseFilter implements Filter
...
@@ -100,7 +98,6 @@ public class FormatResponseFilter implements Filter
SubsurveyId
subsurveyId
=
new
SubsurveyId
(
params
);
SubsurveyId
subsurveyId
=
new
SubsurveyId
(
params
);
// FIXME add invalid param excpetions -> params already parsed in servlet
// FIXME add invalid param excpetions -> params already parsed in servlet
Dataset
[]
datasetArr
=
queryObsCore
(
Dataset
[]
datasetArr
=
queryObsCore
(
pubdidArr
,
pubdidArr
,
coord
,
// VLKB: calc ovelrap-codes
coord
,
// VLKB: calc ovelrap-codes
...
@@ -114,10 +111,11 @@ public class FormatResponseFilter implements Filter
...
@@ -114,10 +111,11 @@ public class FormatResponseFilter implements Filter
settings
.
serviceUrls
.
mergeUrl
(),
settings
.
serviceUrls
.
mergeUrl
(),
dbSubsurveyArr
);
dbSubsurveyArr
);
response
.
setCharacterEncoding
(
RESPONSE_ENCODING
);
final
String
respFormat
=
settings
.
serviceUrls
.
responseFormat
();
final
String
respFormat
=
settings
.
serviceUrls
.
responseFormat
();
LOGGER
.
info
(
"responseFormat: "
+
respFormat
);
LOGGER
.
info
(
"responseFormat: "
+
respFormat
);
response
.
setCharacterEncoding
(
RESPONSE_ENCODING
);
if
(
respFormat
.
equals
(
"application/x-vlkb+xml"
))
if
(
respFormat
.
equals
(
"application/x-vlkb+xml"
))
{
{
response
.
setContentType
(
"application/xml"
);
response
.
setContentType
(
"application/xml"
);
...
...
This diff is collapsed.
Click to expand it.
data-discovery/src/main/java/vlkb/webapi/SearchServlet.java
+
7
−
32
View file @
0b278afe
...
@@ -52,17 +52,11 @@ public class SearchServlet extends javax.servlet.http.HttpServlet
...
@@ -52,17 +52,11 @@ public class SearchServlet extends javax.servlet.http.HttpServlet
throws
ServletException
,
IOException
,
UnsupportedEncodingException
throws
ServletException
,
IOException
,
UnsupportedEncodingException
{
{
LOGGER
.
info
(
"trace"
);
LOGGER
.
info
(
"trace"
);
PrintWriter
writer
=
response
.
getWriter
();
long
startTime_msec
=
System
.
currentTimeMillis
();
legacyLogEntry
(
request
);
legacyLogEntry
(
request
);
Map
<
String
,
String
[]>
params
=
request
.
getParameterMap
();
try
try
{
{
Map
<
String
,
String
[]>
params
=
request
.
getParameterMap
();
Coord
coord
=
new
Coord
(
params
);
Coord
coord
=
new
Coord
(
params
);
SubsurveyId
subsurveyId
=
new
SubsurveyId
(
params
);
SubsurveyId
subsurveyId
=
new
SubsurveyId
(
params
);
...
@@ -75,8 +69,6 @@ public class SearchServlet extends javax.servlet.http.HttpServlet
...
@@ -75,8 +69,6 @@ public class SearchServlet extends javax.servlet.http.HttpServlet
}
}
String
[]
pubdidArr
=
dbps
.
queryOverlapingPubdid
(
coord
,
subsurveyId
);
String
[]
pubdidArr
=
dbps
.
queryOverlapingPubdid
(
coord
,
subsurveyId
);
final
String
RESPONSE_ENCODING
=
"UTF-8"
;
final
String
RESPONSE_ENCODING
=
"UTF-8"
;
/* if filters installed response will be wrapped */
/* if filters installed response will be wrapped */
...
@@ -100,6 +92,7 @@ public class SearchServlet extends javax.servlet.http.HttpServlet
...
@@ -100,6 +92,7 @@ public class SearchServlet extends javax.servlet.http.HttpServlet
response
.
setContentType
(
"text/plain"
);
response
.
setContentType
(
"text/plain"
);
response
.
setCharacterEncoding
(
RESPONSE_ENCODING
);
response
.
setCharacterEncoding
(
RESPONSE_ENCODING
);
PrintWriter
writer
=
response
.
getWriter
();
for
(
String
pubdid
:
pubdidArr
)
for
(
String
pubdid
:
pubdidArr
)
{
{
writer
.
println
(
pubdid
);
writer
.
println
(
pubdid
);
...
@@ -114,6 +107,7 @@ public class SearchServlet extends javax.servlet.http.HttpServlet
...
@@ -114,6 +107,7 @@ public class SearchServlet extends javax.servlet.http.HttpServlet
response
.
setStatus
(
HttpServletResponse
.
SC_BAD_REQUEST
);
response
.
setStatus
(
HttpServletResponse
.
SC_BAD_REQUEST
);
response
.
setContentType
(
"text/plain"
);
response
.
setContentType
(
"text/plain"
);
PrintWriter
writer
=
response
.
getWriter
();
doMultiValuedParamNotSupported
(
ex
.
getMessage
(),
writer
);
doMultiValuedParamNotSupported
(
ex
.
getMessage
(),
writer
);
writer
.
close
();
writer
.
close
();
}
}
...
@@ -124,6 +118,7 @@ public class SearchServlet extends javax.servlet.http.HttpServlet
...
@@ -124,6 +118,7 @@ public class SearchServlet extends javax.servlet.http.HttpServlet
response
.
setStatus
(
HttpServletResponse
.
SC_BAD_REQUEST
);
response
.
setStatus
(
HttpServletResponse
.
SC_BAD_REQUEST
);
response
.
setContentType
(
"text/plain"
);
response
.
setContentType
(
"text/plain"
);
PrintWriter
writer
=
response
.
getWriter
();
doUsageError
(
ex
.
getMessage
(),
writer
);
doUsageError
(
ex
.
getMessage
(),
writer
);
writer
.
close
();
writer
.
close
();
}
}
...
@@ -135,31 +130,11 @@ public class SearchServlet extends javax.servlet.http.HttpServlet
...
@@ -135,31 +130,11 @@ public class SearchServlet extends javax.servlet.http.HttpServlet
response
.
setStatus
(
HttpServletResponse
.
SC_INTERNAL_SERVER_ERROR
);
response
.
setStatus
(
HttpServletResponse
.
SC_INTERNAL_SERVER_ERROR
);
response
.
setContentType
(
"text/plain"
);
response
.
setContentType
(
"text/plain"
);
PrintWriter
writer
=
response
.
getWriter
();
doError
(
ex
.
toString
(),
writer
);
doError
(
ex
.
toString
(),
writer
);
writer
.
close
();
writer
.
close
();
}
}
finally
{
//writer.close();
}
/*
catch (IllegalArgumentException illArg)
{
response.sendError(HttpServletResponse.SC_BAD_REQUEST,
"Request with incorrect parameters: " + illArg.getMessage());
return;
}
catch(Exception ex)
{
LOGGER.info("Exception: " + ex.getMessage());
ex.printStackTrace();
}
*/
return
;
return
;
}
}
...
...
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