devicemap-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wk...@apache.org
Subject svn commit: r1648894 - in /devicemap/trunk/examples/ddr-service/src/main: java/org/apache/devicemap/simpleddr/web/filter/IdentificationFilter.java webapp/index.jsp
Date Thu, 01 Jan 2015 17:12:42 GMT
Author: wkeil
Date: Thu Jan  1 17:12:42 2015
New Revision: 1648894

URL: http://svn.apache.org/r1648894
Log:
DMAP-111: Improve Web Examples 

Task-Url: https://issues.apache.org/jira/browse/DMAP-111

Modified:
    devicemap/trunk/examples/ddr-service/src/main/java/org/apache/devicemap/simpleddr/web/filter/IdentificationFilter.java
    devicemap/trunk/examples/ddr-service/src/main/webapp/index.jsp

Modified: devicemap/trunk/examples/ddr-service/src/main/java/org/apache/devicemap/simpleddr/web/filter/IdentificationFilter.java
URL: http://svn.apache.org/viewvc/devicemap/trunk/examples/ddr-service/src/main/java/org/apache/devicemap/simpleddr/web/filter/IdentificationFilter.java?rev=1648894&r1=1648893&r2=1648894&view=diff
==============================================================================
--- devicemap/trunk/examples/ddr-service/src/main/java/org/apache/devicemap/simpleddr/web/filter/IdentificationFilter.java
(original)
+++ devicemap/trunk/examples/ddr-service/src/main/java/org/apache/devicemap/simpleddr/web/filter/IdentificationFilter.java
Thu Jan  1 17:12:42 2015
@@ -50,12 +50,12 @@ public class IdentificationFilter implem
     private Service identificationService = null;
 
     public void init(FilterConfig filterConfig) throws ServletException {
-    log.debug("DeviceMap IdentificationFilter Initialize filter");
-    Properties initializationProperties = new Properties();
-    ServletContext context = filterConfig.getServletContext();                
+	    log.info("Initialize filter");
+	    Properties initializationProperties = new Properties();
+	    ServletContext context = filterConfig.getServletContext();                
 
 	    try {
-	        initializationProperties.load(context.getResourceAsStream("/WEB-INF/oddr.properties"));
+	        initializationProperties.load(context.getResourceAsStream("/WEB-INF/classes/oddr.properties"));
 	        identificationService = ServiceFactory.newService("org.apache.devicemap.simpleddr.ODDRService",
initializationProperties.getProperty(ODDRService.ODDR_VOCABULARY_IRI), initializationProperties);
 	
 	    } catch (Exception ex) {
@@ -64,86 +64,87 @@ public class IdentificationFilter implem
     }
 
     public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
throws IOException, ServletException {
-    PropertyRef vendorRef;
-    PropertyRef modelRef;
-    PropertyRef displayWidthRef;
-    PropertyRef displayHeightRef;
-    PropertyRef inputDevicesRef;
-    PropertyRef idRef;
-    PropertyRef tabletRef;
-    PropertyRef wirelessRef;
-
-    try {
-        vendorRef = identificationService.newPropertyRef("vendor");
-        modelRef = identificationService.newPropertyRef("model");
-        displayWidthRef = identificationService.newPropertyRef("displayWidth");
-        displayHeightRef = identificationService.newPropertyRef("displayHeight");
-        inputDevicesRef = identificationService.newPropertyRef("inputDevices");
-        idRef = identificationService.newPropertyRef("id");
-        tabletRef = identificationService.newPropertyRef("is_tablet");
-        wirelessRef = identificationService.newPropertyRef("is_wireless_device");
-
-    } catch (NameException ex) {
-        throw new RuntimeException(ex);
-    }
-
-    PropertyRef[] propertyRefs = new PropertyRef[] {vendorRef, modelRef, displayWidthRef,
displayHeightRef, inputDevicesRef,
-                                                    idRef, tabletRef, wirelessRef};
-    Evidence e = new ODDRHTTPEvidence();
-
-    String ua=((HttpServletRequest)request).getParameter("ua");
-    if(ua==null || ua.isEmpty()) {
-      ua=((HttpServletRequest)request).getHeader("User-Agent");
-    }
-
-   ((HttpServletRequest)request).setAttribute("dmapUA", ua);
-
-    e.put("User-Agent", ua);
-
-    try {
-        PropertyValues propertyValues = identificationService.getPropertyValues(e, propertyRefs);
-        PropertyValue vendor = propertyValues.getValue(vendorRef);
-        PropertyValue model = propertyValues.getValue(modelRef);
-        PropertyValue displayWidth = propertyValues.getValue(displayWidthRef);
-        PropertyValue displayHeight = propertyValues.getValue(displayHeightRef);
-        PropertyValue inputDevices = propertyValues.getValue(inputDevicesRef);
-        PropertyValue id = propertyValues.getValue(idRef);
-        PropertyValue tablet = propertyValues.getValue(tabletRef);
-        PropertyValue wireless = propertyValues.getValue(wirelessRef);
-
-        if (vendor!=null && vendor.exists()) {
-            ((HttpServletRequest)request).setAttribute("dmapVendor", vendor.getString());
-        }
-        if (model!=null && model.exists()) {
-            ((HttpServletRequest)request).setAttribute("dmapModel", model.getString());
-        }
-        if (displayWidth!=null && displayWidth.exists()) {
-            ((HttpServletRequest)request).setAttribute("dmapDisplayWidth", displayWidth.getInteger());
-        }
-        if (displayWidth!=null && displayHeight.exists()) {
-            ((HttpServletRequest)request).setAttribute("dmapDisplayHeight", displayHeight.getInteger());
-        }
-        if (inputDevices!=null && inputDevices.exists()) {
-            ((HttpServletRequest)request).setAttribute("dmapInputDevices", inputDevices.getString());
-        }
-        if (id!=null && id.exists()) {
-            ((HttpServletRequest)request).setAttribute("dmapId", id.getString());
-        }
-        if (tablet!=null && tablet.exists()) {
-            ((HttpServletRequest)request).setAttribute("dmapTablet", tablet.getString());
-        }
-        if (wireless!=null && wireless.exists()) {
-            ((HttpServletRequest)request).setAttribute("dmapWireless", wireless.getString());
-        }
-
-    } catch (Exception ex) {
-        throw new RuntimeException(ex);
-    }
-
-    chain.doFilter(request, response);
+    	log.info("Do filter");
+    	PropertyRef vendorRef;
+	    PropertyRef modelRef;
+	    PropertyRef displayWidthRef;
+	    PropertyRef displayHeightRef;
+	    PropertyRef inputDevicesRef;
+	    PropertyRef idRef;
+	    PropertyRef tabletRef;
+	    PropertyRef wirelessRef;
+	
+	    try {
+	        vendorRef = identificationService.newPropertyRef("vendor");
+	        modelRef = identificationService.newPropertyRef("model");
+	        displayWidthRef = identificationService.newPropertyRef("displayWidth");
+	        displayHeightRef = identificationService.newPropertyRef("displayHeight");
+	        inputDevicesRef = identificationService.newPropertyRef("inputDevices");
+	        idRef = identificationService.newPropertyRef("id");
+	        tabletRef = identificationService.newPropertyRef("is_tablet");
+	        wirelessRef = identificationService.newPropertyRef("is_wireless_device");
+	
+	    } catch (NameException ex) {
+	        throw new RuntimeException(ex);
+	    }
+	
+	    PropertyRef[] propertyRefs = new PropertyRef[] {vendorRef, modelRef, displayWidthRef,
displayHeightRef, inputDevicesRef,
+	                                                    idRef, tabletRef, wirelessRef};
+	    Evidence e = new ODDRHTTPEvidence();
+	
+	    String ua=((HttpServletRequest)request).getParameter("ua");
+	    if(ua==null || ua.isEmpty()) {
+	      ua=((HttpServletRequest)request).getHeader("User-Agent");
+	    }
+	
+	   ((HttpServletRequest)request).setAttribute("dmapUA", ua);
+	
+	    e.put("User-Agent", ua);
+	
+	    try {
+	        PropertyValues propertyValues = identificationService.getPropertyValues(e, propertyRefs);
+	        PropertyValue vendor = propertyValues.getValue(vendorRef);
+	        PropertyValue model = propertyValues.getValue(modelRef);
+	        PropertyValue displayWidth = propertyValues.getValue(displayWidthRef);
+	        PropertyValue displayHeight = propertyValues.getValue(displayHeightRef);
+	        PropertyValue inputDevices = propertyValues.getValue(inputDevicesRef);
+	        PropertyValue id = propertyValues.getValue(idRef);
+	        PropertyValue tablet = propertyValues.getValue(tabletRef);
+	        PropertyValue wireless = propertyValues.getValue(wirelessRef);
+	
+	        if (vendor!=null && vendor.exists()) {
+	            ((HttpServletRequest)request).setAttribute("dmapVendor", vendor.getString());
+	        }
+	        if (model!=null && model.exists()) {
+	            ((HttpServletRequest)request).setAttribute("dmapModel", model.getString());
+	        }
+	        if (displayWidth!=null && displayWidth.exists()) {
+	            ((HttpServletRequest)request).setAttribute("dmapDisplayWidth", displayWidth.getInteger());
+	        }
+	        if (displayWidth!=null && displayHeight.exists()) {
+	            ((HttpServletRequest)request).setAttribute("dmapDisplayHeight", displayHeight.getInteger());
+	        }
+	        if (inputDevices!=null && inputDevices.exists()) {
+	            ((HttpServletRequest)request).setAttribute("dmapInputDevices", inputDevices.getString());
+	        }
+	        if (id!=null && id.exists()) {
+	            ((HttpServletRequest)request).setAttribute("dmapId", id.getString());
+	        }
+	        if (tablet!=null && tablet.exists()) {
+	            ((HttpServletRequest)request).setAttribute("dmapTablet", tablet.getString());
+	        }
+	        if (wireless!=null && wireless.exists()) {
+	            ((HttpServletRequest)request).setAttribute("dmapWireless", wireless.getString());
+	        }
+	
+	    } catch (Exception ex) {
+	        throw new RuntimeException(ex);
+	    }
+	
+	    chain.doFilter(request, response);
     }
 
     public void destroy() {
-      log.debug("DeviceMap IdentificationFilter Destroy Filter");
+      log.debug("Destroy Filter");
     }
 }

Modified: devicemap/trunk/examples/ddr-service/src/main/webapp/index.jsp
URL: http://svn.apache.org/viewvc/devicemap/trunk/examples/ddr-service/src/main/webapp/index.jsp?rev=1648894&r1=1648893&r2=1648894&view=diff
==============================================================================
--- devicemap/trunk/examples/ddr-service/src/main/webapp/index.jsp (original)
+++ devicemap/trunk/examples/ddr-service/src/main/webapp/index.jsp Thu Jan  1 17:12:42 2015
@@ -1,20 +1,20 @@
 <!DOCTYPE html>
 <html>
 <head>
-<title>Device Map Java Client</title>
+<title>DeviceMap DDR Java Service</title>
 <meta http-equiv="X-UA-Compatible" content="IE=edge">
 <script src="js/dmapclient.js"></script>
 </head>
 <body onload="main();">
-<h1>Device Map Java Client</h1>
+<h1>DeviceMap W3C DDR Simple Java Service</h1>
 User-Agent: <input type="text" name="useragent" id="useragent" size="100" value="">
-<input type="button" name="submit" value="Submit!" onclick="submit()">
+<input type="button" name="submit" value="Submit!" onclick="doSubmit()">
 <br>
 <br>
 <div id="uaresults"></div>
 <br>
 <br>
-<a href="http://incubator.apache.org/devicemap/">DeviceMap</a> Java Service<!--
<a href="javaservice.html">HTML</a> <a href="javaservice.js">JSON</a>--><br>
+<a href="http://devicemap.apache.org/">DeviceMap</a> DDR Service<!-- <a
href="javaservice.html">HTML</a> <a href="javaservice.js">JSON</a>--><br>
 <script>
 
 function main()
@@ -37,8 +37,9 @@ function renderResults(json)
   document.getElementById("uaresults").innerHTML=r;
 }
 
-function submit()
+function doSubmit()
 {
+  alert('Click')
   dmapClient.jsonp(document.getElementById("useragent").value,renderResults);
 }
 



Mime
View raw message