summaryrefslogtreecommitdiffstats
path: root/sdnr/wt/helpserver/provider
diff options
context:
space:
mode:
Diffstat (limited to 'sdnr/wt/helpserver/provider')
-rw-r--r--sdnr/wt/helpserver/provider/pom.xml3
-rw-r--r--sdnr/wt/helpserver/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/helpserver/HelpServlet.java29
2 files changed, 10 insertions, 22 deletions
diff --git a/sdnr/wt/helpserver/provider/pom.xml b/sdnr/wt/helpserver/provider/pom.xml
index 82205d553..f37c07e65 100644
--- a/sdnr/wt/helpserver/provider/pom.xml
+++ b/sdnr/wt/helpserver/provider/pom.xml
@@ -47,6 +47,7 @@
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
+ <scope>provided</scope>
</dependency>
<dependency>
<groupId>org.json</groupId>
@@ -68,7 +69,7 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>org.onap.ccsdk.features.sdnr.wt</groupId>
+ <groupId>${project.groupId}</groupId>
<artifactId>sdnr-wt-common</artifactId>
<version>${project.version}</version>
<scope>test</scope>
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 683311e8a..e9470ab09 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
@@ -41,8 +41,6 @@ public class HelpServlet extends HttpServlet implements AutoCloseable {
private static final String BASEURI = "/help";
- private static final boolean REDIRECT_LINKS = true;
-
private final Path basePath;
public HelpServlet() {
@@ -113,21 +111,7 @@ public class HelpServlet extends HttpServlet implements AutoCloseable {
return;
}
LOG.debug("delivering file");
- OutputStream out = resp.getOutputStream();
- // 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 (OutputStream out = resp.getOutputStream()) {
try (FileInputStream in = new FileInputStream(f)) {
byte[] buffer = new byte[1024];
@@ -139,6 +123,9 @@ public class HelpServlet extends HttpServlet implements AutoCloseable {
out.flush();
out.close();
}
+ } catch (IOException e) {
+ LOG.warn("Can not write meta file", e);
+ resp.setStatus(500);
}
} else {
LOG.debug("found not file for request");
@@ -148,15 +135,15 @@ public class HelpServlet extends HttpServlet implements AutoCloseable {
}
private boolean ispdf(File f) {
- return f != null ? this.ispdf(f.getName()) : false;
+ return f != null && this.ispdf(f.getName());
}
private boolean ispdf(String name) {
- return name != null ? name.toLowerCase().endsWith("pdf") : false;
+ return name != null && name.toLowerCase().endsWith("pdf");
}
private boolean isImageFile(File f) {
- return f != null ? this.isImageFile(f.getName()) : false;
+ return f != null && this.isImageFile(f.getName());
}
private boolean isImageFile(String name) {
@@ -169,7 +156,7 @@ public class HelpServlet extends HttpServlet implements AutoCloseable {
}
private boolean isTextFile(File f) {
- return f != null ? this.isTextFile(f.getName()) : false;
+ return f != null && this.isTextFile(f.getName());
}