Commit ccd457c9 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

include generated docs in the war file and expose urls using configuration root url

parent c83ef460
package lcsb.mapviewer.api;
import java.nio.charset.StandardCharsets;
import javax.servlet.ServletContext;
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;
@RequestMapping(value = "/docs", produces = MediaType.TEXT_HTML_VALUE)
public class DocsController extends BaseController {
private Logger logger = LogManager.getLogger();
private ServletContext context;
private IConfigurationService configurationService;
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("", root);
logger.debug(page + " - " + root);
return content.getBytes();
} else {
throw new ObjectNotFoundException("File does not exist");
\ No newline at end of file
......@@ -348,6 +348,12 @@
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment