Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
minerva
core
Commits
ccd457c9
Commit
ccd457c9
authored
Aug 25, 2020
by
Piotr Gawron
Browse files
include generated docs in the war file and expose urls using configuration root url
parent
c83ef460
Changes
2
Hide whitespace changes
Inline
Side-by-side
rest-api/src/main/java/lcsb/mapviewer/api/DocsController.java
0 → 100644
View file @
ccd457c9
package
lcsb.mapviewer.api
;
import
java.io.File
;
import
java.io.IOException
;
import
java.nio.charset.StandardCharsets
;
import
javax.servlet.ServletContext
;
import
org.apache.commons.io.FileUtils
;
import
org.apache.logging.log4j.LogManager
;
import
org.apache.logging.log4j.Logger
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.MediaType
;
import
org.springframework.web.bind.annotation.*
;
import
lcsb.mapviewer.model.user.ConfigurationElementType
;
import
lcsb.mapviewer.services.interfaces.IConfigurationService
;
@RestController
@RequestMapping
(
value
=
"/docs"
,
produces
=
MediaType
.
TEXT_HTML_VALUE
)
public
class
DocsController
extends
BaseController
{
private
Logger
logger
=
LogManager
.
getLogger
();
private
ServletContext
context
;
private
IConfigurationService
configurationService
;
@Autowired
public
DocsController
(
ServletContext
context
,
IConfigurationService
configurationService
)
{
this
.
context
=
context
;
this
.
configurationService
=
configurationService
;
}
@GetMapping
(
value
=
"/{page:.+}"
)
public
byte
[]
getTaxonomy
(
@PathVariable
String
page
)
throws
ObjectNotFoundException
,
IOException
{
File
file
=
new
File
(
context
.
getRealPath
(
"/docs/"
+
page
));
if
(
file
.
exists
())
{
String
content
=
FileUtils
.
readFileToString
(
file
,
StandardCharsets
.
UTF_8
);
String
root
=
configurationService
.
getConfigurationValue
(
ConfigurationElementType
.
MINERVA_ROOT
);
if
(
root
!=
null
&&
!
root
.
trim
().
isEmpty
())
{
content
=
content
.
replace
(
"https://minerva-service.lcsb.uni.lu/minerva/"
,
root
);
}
logger
.
debug
(
page
+
" - "
+
root
);
return
content
.
getBytes
();
}
else
{
throw
new
ObjectNotFoundException
(
"File does not exist"
);
}
}
}
\ No newline at end of file
web/pom.xml
View file @
ccd457c9
...
...
@@ -348,6 +348,12 @@
<version>
3.2.2
</version>
<configuration>
<failOnMissingWebXml>
false
</failOnMissingWebXml>
<webResources>
<resource>
<directory>
${project.build.directory}/generated-docs
</directory>
<targetPath>
docs/
</targetPath>
</resource>
</webResources>
</configuration>
</plugin>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment