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.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
......@@ -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>
......
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