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
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
BioinformaticDataCompression
BigDataViewer_Server_Extension
Commits
b23527df
Commit
b23527df
authored
Jan 14, 2015
by
HongKee Moon
Browse files
Options
Downloads
Patches
Plain Diff
Create the remote xml file only once and keep it ready as a String
parent
e148512c
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/bdv/server/CellHandler.java
+29
-45
29 additions, 45 deletions
src/main/java/bdv/server/CellHandler.java
with
29 additions
and
45 deletions
src/main/java/bdv/server/CellHandler.java
+
29
−
45
View file @
b23527df
...
...
@@ -27,6 +27,7 @@ import javax.servlet.http.HttpServletResponse;
import
java.io.IOException
;
import
java.io.OutputStream
;
import
java.io.PrintWriter
;
import
java.io.StringWriter
;
public
class
CellHandler
extends
ContextHandler
{
...
...
@@ -42,6 +43,9 @@ public class CellHandler extends ContextHandler
private
final
String
dataSetURL
;
// Cached XML string for provideXML()
private
String
remoteXmlString
=
null
;
public
CellHandler
(
final
String
baseUrl
,
final
String
xmlFilename
)
throws
SpimDataException
{
final
SpimDataMinimal
spimData
=
new
XmlIoSpimDataMinimal
().
load
(
xmlFilename
);
...
...
@@ -122,8 +126,9 @@ public class CellHandler extends ContextHandler
}
}
// TODO: create the remote xml file only once and keep it ready as a String
public
void
provideXML
(
final
Request
baseRequest
,
final
HttpServletResponse
response
)
throws
IOException
,
ServletException
{
if
(
null
==
remoteXmlString
)
{
try
{
...
...
@@ -132,47 +137,26 @@ public class CellHandler extends ContextHandler
final
SequenceDescriptionMinimal
seq
=
spimData
.
getSequenceDescription
();
seq
.
setImgLoader
(
new
RemoteImageLoader
(
dataSetURL
)
);
final
Document
doc
=
new
Document
(
io
.
toXml
(
spimData
,
spimData
.
getBasePath
()
)
);
response
.
setContentType
(
"application/xml"
);
response
.
setStatus
(
HttpServletResponse
.
SC_OK
);
baseRequest
.
setHandled
(
true
);
final
XMLOutputter
xout
=
new
XMLOutputter
(
Format
.
getPrettyFormat
()
);
xout
.
output
(
doc
,
response
.
getOutputStream
()
);
// xout.output( doc, System.out );
final
StringWriter
sw
=
new
StringWriter
();
xout
.
output
(
doc
,
sw
);
remoteXmlString
=
sw
.
toString
();
}
catch
(
final
Exception
e
)
catch
(
final
SpimData
Exception
e
)
{
throw
new
ServletException
(
e
);
}
// final SAXBuilder sax = new SAXBuilder();
// Document doc;
// try
// {
// doc = sax.build( xmlFile );
// }
// catch ( final Exception e )
// {
// throw new ServletException( e );
// }
// final Element root = doc.getRootElement();
// final Element SequenceDescription = root.getChild( "SequenceDescription" );
// final Element ImageLoader = SequenceDescription.getChild( "ImageLoader" );
//
// ImageLoader.setAttribute( "format", "bdv.remote" );
//
// ImageLoader.removeChild( "hdf5" );
//
// final Element baseUrl = new Element( "baseUrl" );
// baseUrl.setText( dataSetURL );
// ImageLoader.setContent( baseUrl );
//
// response.setContentType( "application/xml" );
// response.setStatus( HttpServletResponse.SC_OK );
// baseRequest.setHandled( true );
// final PrintWriter ow = response.getWriter();
// ow.write( new XMLOutputter().outputString( doc ) );
// ow.close();
}
response
.
setContentType
(
"application/xml"
);
response
.
setStatus
(
HttpServletResponse
.
SC_OK
);
baseRequest
.
setHandled
(
true
);
final
PrintWriter
ow
=
response
.
getWriter
();
ow
.
write
(
remoteXmlString
);
ow
.
close
();
}
public
String
getXmlFile
()
...
...
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