summaryrefslogtreecommitdiffstats
path: root/sdnr/wt/helpserver/provider/src/main/java
diff options
context:
space:
mode:
authorHerbert Eiselt <herbert.eiselt@highstreet-technologies.com>2019-03-29 10:53:28 +0100
committerHerbert Eiselt <herbert.eiselt@highstreet-technologies.com>2019-03-29 10:54:18 +0100
commite26f1bfa9bdad0562b9d0be226e8b7fa756c7345 (patch)
tree3e8cea63e6e3e2aa85510ec5df6682e6f99aca56 /sdnr/wt/helpserver/provider/src/main/java
parentf2bb490d9c82decbdb50c1e4db1be2f34b28d097 (diff)
SDNR prepare for readthedocs
Adjust helpserver to generate help content Change-Id: I913615019d1415d88942b8d2050ed39e55e1dc2e Issue-ID: SDNC-716 Signed-off-by: Herbert Eiselt <herbert.eiselt@highstreet-technologies.com>
Diffstat (limited to 'sdnr/wt/helpserver/provider/src/main/java')
-rw-r--r--sdnr/wt/helpserver/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/helpserver/HelpServlet.java73
1 files changed, 15 insertions, 58 deletions
diff --git a/sdnr/wt/helpserver/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/helpserver/HelpServlet.java b/sdnr/wt/helpserver/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/helpserver/HelpServlet.java
index 35e351563..f91e96b79 100644
--- a/sdnr/wt/helpserver/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/helpserver/HelpServlet.java
+++ b/sdnr/wt/helpserver/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/helpserver/HelpServlet.java
@@ -26,8 +26,6 @@ import java.io.OutputStream;
import java.net.URISyntaxException;
import java.net.URLDecoder;
import java.nio.file.Path;
-import java.util.regex.Matcher;
-import java.util.regex.Pattern;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
@@ -67,11 +65,7 @@ public class HelpServlet extends HttpServlet implements AutoCloseable {
resp.addHeader("Access-Control-Allow-Methods", "OPTIONS, HEAD, GET, POST, PUT, DELETE");
resp.addHeader("Access-Control-Allow-Headers", "X-Requested-With, Content-Type, Content-Length");
if (query != null && query.contains("meta")) {
- /*
- * LOG.debug("received post with uri="+req.getRequestURI()); String
- * uri=req.getRequestURI().substring(BASEURI.length()); if(uri.startsWith("/"))
- * uri=uri.substring(1);
- */
+
File f = new File(HelpInfrastructureObject.KARAFHELPDIRECTORY, "meta.json");
if (f.exists()) {
LOG.debug("found local meta file");
@@ -120,36 +114,20 @@ public class HelpServlet extends HttpServlet implements AutoCloseable {
}
LOG.debug("delivering file");
OutputStream out = resp.getOutputStream();
- String version = null;
- if (REDIRECT_LINKS) {
- version = getVersionFromRequestedUri(uri);
- }
- if (this.isTextFile(f) && REDIRECT_LINKS && version != null) {
- final String regex =
- "(!?\\[[^\\]]*?\\])\\(((?:(?!http|www\\.|\\#|\\.com|\\.net|\\.info|\\.org|\\.svg|\\.png|\\.jpg|\\.gif|\\.jpeg|\\.pdf).)*?)\\)";
- final Pattern pattern = Pattern.compile(regex);
- Matcher matcher;
- String line;
- try (BufferedReader br = new BufferedReader(new FileReader(f))) {
- line = br.readLine();
- while (line != null) {
- // check line for internal link
- matcher = pattern.matcher(line);
- if (matcher.find()) {
- // extend link with specific version
- line = line.replace(matcher.group(2),
- "../" + matcher.group(2) + version + "/README.md");
- }
- out.write((line + "\n").getBytes());
- line = br.readLine();
-
- }
- out.flush();
- out.close();
- br.close();
- }
-
- } else {
+// if (this.isTextFile(f) && REDIRECT_LINKS) {
+// String line;
+// try (BufferedReader br = new BufferedReader(new FileReader(f))) {
+// line = br.readLine();
+// while (line != null) {
+// out.write((line + "\n").getBytes());
+// line = br.readLine();
+// }
+// out.flush();
+// out.close();
+// br.close();
+// }
+// } else
+ {
try (FileInputStream in = new FileInputStream(f)) {
byte[] buffer = new byte[1024];
@@ -169,27 +147,6 @@ public class HelpServlet extends HttpServlet implements AutoCloseable {
}
}
- /**
- * Extract version from URI string
- * @param uri = "help/folder1/folder2/version/README.md"
- * @return version as a string
- */
- private static String getVersionFromRequestedUri(String uri) {
- if (uri == null) {
- return null;
- }
- int lastidx = uri.lastIndexOf("/");
- if (lastidx < 0) {
- return null;
- }
- int slastidx = uri.lastIndexOf("/", lastidx - 1);
- if (slastidx < 0) {
- return null;
- }
- return uri.substring(slastidx + 1, lastidx);
-
- }
-
private boolean ispdf(File f) {
return f != null ? this.ispdf(f.getName()) : false;
}