aboutsummaryrefslogtreecommitdiffstats
path: root/sdnr/wt/odlux/core
diff options
context:
space:
mode:
authorsai-neetha <sai-neetha.phulmali@highstreet-technologies.com>2019-08-12 17:51:27 +0200
committersai-neetha <sai-neetha.phulmali@highstreet-technologies.com>2019-08-12 17:52:01 +0200
commitf6f34d5b2a197e57bab0db49cd8e7ad39df7b527 (patch)
treeeeb49595351dd1ba0a5d61e5c417a0390c0b1d66 /sdnr/wt/odlux/core
parented0e6be174e1445b6c47a69dccf25a642f17bdd7 (diff)
SDN-R odlux timing fix
fixing timing issue and added licenses in source files Issue-ID: SDNC-844 Signed-off-by: sai-neetha <sai-neetha.phulmali@highstreet-technologies.com> Change-Id: I65f6b51f841074f9b8e88bf9b230038e0a224fd3
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>