Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B
BigDataViewer_Server_Extension
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
BioinformaticDataCompression
BigDataViewer_Server_Extension
Commits
a271ec36
Commit
a271ec36
authored
10 years ago
by
Tobias Pietzsch
Browse files
Options
Downloads
Patches
Plain Diff
move "respond-with-utf8-string" pattern into helper method
parent
bd31dc16
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/bdv/server/CellHandler.java
+19
-36
19 additions, 36 deletions
src/main/java/bdv/server/CellHandler.java
with
19 additions
and
36 deletions
src/main/java/bdv/server/CellHandler.java
+
19
−
36
View file @
a271ec36
...
...
@@ -101,7 +101,8 @@ public class CellHandler extends ContextHandler
{
if
(
target
.
equals
(
"/settings"
)
)
{
provideSettings
(
baseRequest
,
response
);
if
(
settingsXmlString
!=
null
)
respondWithString
(
baseRequest
,
response
,
"application/xml"
,
settingsXmlString
);
return
;
}
...
...
@@ -115,7 +116,7 @@ public class CellHandler extends ContextHandler
if
(
cellString
==
null
)
{
provideXML
(
baseRequest
,
response
);
respondWithString
(
baseRequest
,
response
,
"application/xml"
,
datasetXmlString
);
return
;
}
...
...
@@ -159,43 +160,10 @@ public class CellHandler extends ContextHandler
}
else
if
(
parts
[
0
].
equals
(
"init"
)
)
{
response
.
setContentType
(
"application/octet-stream"
);
response
.
setStatus
(
HttpServletResponse
.
SC_OK
);
baseRequest
.
setHandled
(
true
);
final
PrintWriter
ow
=
response
.
getWriter
();
ow
.
write
(
metadataJson
);
ow
.
close
();
respondWithString
(
baseRequest
,
response
,
"application/json"
,
metadataJson
);
}
}
public
void
provideXML
(
final
Request
baseRequest
,
final
HttpServletResponse
response
)
throws
IOException
{
response
.
setContentType
(
"application/xml"
);
response
.
setCharacterEncoding
(
"UTF-8"
);
response
.
setStatus
(
HttpServletResponse
.
SC_OK
);
baseRequest
.
setHandled
(
true
);
final
PrintWriter
ow
=
response
.
getWriter
();
ow
.
write
(
datasetXmlString
);
ow
.
close
();
}
public
void
provideSettings
(
final
Request
baseRequest
,
final
HttpServletResponse
response
)
throws
IOException
{
if
(
settingsXmlString
==
null
)
// there is no settings.xml for the dataset
return
;
response
.
setContentType
(
"application/xml"
);
response
.
setCharacterEncoding
(
"UTF-8"
);
response
.
setStatus
(
HttpServletResponse
.
SC_OK
);
baseRequest
.
setHandled
(
true
);
final
PrintWriter
ow
=
response
.
getWriter
();
ow
.
write
(
settingsXmlString
);
ow
.
close
();
}
public
void
provideThumbnail
(
final
Request
baseRequest
,
final
HttpServletResponse
response
)
{
// Just check it once
...
...
@@ -332,4 +300,19 @@ public class CellHandler extends ContextHandler
}
return
null
;
}
/**
* Handle request by sending a UTF-8 string.
*/
private
static
void
respondWithString
(
final
Request
baseRequest
,
final
HttpServletResponse
response
,
final
String
contentType
,
final
String
string
)
throws
IOException
{
response
.
setContentType
(
contentType
);
response
.
setCharacterEncoding
(
"UTF-8"
);
response
.
setStatus
(
HttpServletResponse
.
SC_OK
);
baseRequest
.
setHandled
(
true
);
final
PrintWriter
ow
=
response
.
getWriter
();
ow
.
write
(
string
);
ow
.
close
();
}
}
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