summaryrefslogtreecommitdiffstats
path: root/sdnr/wt/odlux/core
diff options
context:
space:
mode:
Diffstat (limited to 'sdnr/wt/odlux/core')
-rw-r--r--sdnr/wt/odlux/core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/IndexServlet.java47
-rw-r--r--sdnr/wt/odlux/core/provider/src/main/resources/OSGI-INF/blueprint/blueprint.xml12
2 files changed, 50 insertions, 9 deletions
diff --git a/sdnr/wt/odlux/core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/IndexServlet.java b/sdnr/wt/odlux/core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/IndexServlet.java
index 8b92774f9..d6d466ab9 100644
--- a/sdnr/wt/odlux/core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/IndexServlet.java
+++ b/sdnr/wt/odlux/core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/IndexServlet.java
@@ -17,7 +17,12 @@
******************************************************************************/
package org.onap.ccsdk.features.sdnr.wt.odlux;
+import java.io.File;
import java.io.IOException;
+import java.io.OutputStream;
+import java.net.HttpURLConnection;
+import java.nio.file.Files;
+
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
@@ -27,14 +32,40 @@ import org.slf4j.LoggerFactory;
public class IndexServlet extends HttpServlet {
- private static final long serialVersionUID = 3039669437157215355L;
- private static Logger LOG = LoggerFactory.getLogger(IndexServlet.class);
+ private static final long serialVersionUID = 3039669437157215355L;
+ private static Logger LOG = LoggerFactory.getLogger(IndexServlet.class);
+
+ @Override
+ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+ if (req.getRequestURI() != null && req.getRequestURI().contains("favicon.ico")) {
+ this.sendFile(resp, "etc/favicon.ico","image/x-icon");
+ } else {
+
+ LOG.debug("redirect to odlux/index.html");
+ resp.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY);
+ resp.setHeader("Location", "odlux/index.html");
+ }
+ }
- @Override
- protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- LOG.debug("redirect to odlux/index.html");
- resp.setStatus(HttpServletResponse.SC_MOVED_PERMANENTLY);
- resp.setHeader("Location", "odlux/index.html");
- }
+ private void sendFile(HttpServletResponse response, String filename, String mimeType) {
+ File f = new File(filename);
+ if (f.exists()) {
+ try {
+ byte[] bytes = Files.readAllBytes(f.toPath());
+ response.setContentType(mimeType);
+ response.setContentLength(bytes.length);
+ response.setStatus(HttpURLConnection.HTTP_OK);
+ OutputStream os = response.getOutputStream();
+ os.write(bytes);
+ os.flush();
+ os.close();
+ } catch (IOException e) {
+ LOG.debug("problem sending {}: {}", filename, e);
+ }
+ } else {
+ LOG.debug("file not found: {}",filename);
+ response.setStatus(HttpURLConnection.HTTP_NOT_FOUND);
+ }
+ }
}
diff --git a/sdnr/wt/odlux/core/provider/src/main/resources/OSGI-INF/blueprint/blueprint.xml b/sdnr/wt/odlux/core/provider/src/main/resources/OSGI-INF/blueprint/blueprint.xml
index 76be14512..5dab578de 100644
--- a/sdnr/wt/odlux/core/provider/src/main/resources/OSGI-INF/blueprint/blueprint.xml
+++ b/sdnr/wt/odlux/core/provider/src/main/resources/OSGI-INF/blueprint/blueprint.xml
@@ -13,7 +13,17 @@ xmlns:jaxrs="http://cxf.apache.org/blueprint/jaxrs">
<entry key="alias" value="/index2.html" />
</service-properties>
</service>
-
+
+ <bean id="indexServlet2"
+ class="org.onap.ccsdk.features.sdnr.wt.odlux.IndexServlet">
+ </bean>
+
+ <service interface="javax.servlet.http.HttpServlet" ref="indexServlet2">
+ <service-properties>
+ <entry key="alias" value="/favicon.ico" />
+ </service-properties>
+ </service>
+
<bean id="resFilesServlet"
class="org.onap.ccsdk.features.sdnr.wt.odlux.ResFilesServlet">
</bean>