devicemap-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wk...@apache.org
Subject svn commit: r1648284 - in /devicemap/trunk/examples/ddr-filter/src/main: java/org/apache/devicemap/example/webfilter/IdentificationFilter.java webapp/index.jsp
Date Mon, 29 Dec 2014 02:55:12 GMT
Author: wkeil
Date: Mon Dec 29 02:55:12 2014
New Revision: 1648284

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

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

Modified:
    devicemap/trunk/examples/ddr-filter/src/main/java/org/apache/devicemap/example/webfilter/IdentificationFilter.java
    devicemap/trunk/examples/ddr-filter/src/main/webapp/index.jsp

Modified: devicemap/trunk/examples/ddr-filter/src/main/java/org/apache/devicemap/example/webfilter/IdentificationFilter.java
URL: http://svn.apache.org/viewvc/devicemap/trunk/examples/ddr-filter/src/main/java/org/apache/devicemap/example/webfilter/IdentificationFilter.java?rev=1648284&r1=1648283&r2=1648284&view=diff
==============================================================================
--- devicemap/trunk/examples/ddr-filter/src/main/java/org/apache/devicemap/example/webfilter/IdentificationFilter.java
(original)
+++ devicemap/trunk/examples/ddr-filter/src/main/java/org/apache/devicemap/example/webfilter/IdentificationFilter.java
Mon Dec 29 02:55:12 2014
@@ -96,12 +96,21 @@ public class IdentificationFilter implem
             throw new RuntimeException(ex);
         }
 
-        PropertyRef[] propertyRefs = new PropertyRef[] {vendorRef, modelRef, displayWidthRef,
displayHeightRef};
-        Evidence e = new ODDRHTTPEvidence();
+        final PropertyRef[] propertyRefs = new PropertyRef[] {vendorRef, modelRef, displayWidthRef,
displayHeightRef};
+        final Evidence e = new ODDRHTTPEvidence();
+        
+        final String uaParam = ((HttpServletRequest)request).getParameter("ua");
+//        System.out.println("Param: " + uaParam);
+        
 //        String userAgent = ((HttpServletRequest)request).getHeader("User-Agent");
 //        String userAgent = "Mozilla/5.0 (Linux; Android 4.4.2; nl-nl; SAMSUNG SM-T530 Build/KOT49H)
AppleWebKit/537.36 (KHTML, like Gecko) Version/1.5 Chrome/28.0.1500.94 Safari/537.36";
-        String userAgent = "Mozilla/5.0 (Linux; U; Android 2.2.1; en-us; SAMSUNG-SGH-I997
Build/FROYO) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1";
-//        System.out.println("User-Agent: " + userAgent);
+//        String userAgent = "Mozilla/5.0 (Linux; U; Android 2.2.1; en-us; SAMSUNG-SGH-I997
Build/FROYO) AppleWebKit/533.1 (KHTML, like Gecko) Version/4.0 Mobile Safari/533.1";
+        final String userAgent = uaParam != null ? uaParam : ((HttpServletRequest)request).getHeader("User-Agent");
+        if (uaParam!= null) {
+        	System.out.println("User-Agent (*): " + userAgent);
+        } else {
+        	System.out.println("User-Agent: " + userAgent);
+        }
         e.put("User-Agent", userAgent);
 
         try {
@@ -131,8 +140,6 @@ public class IdentificationFilter implem
             System.err.println(ex.getLocalizedMessage());
             throw new RuntimeException(ex);
         }
-
         chain.doFilter(request, response);
 	}
-
 }

Modified: devicemap/trunk/examples/ddr-filter/src/main/webapp/index.jsp
URL: http://svn.apache.org/viewvc/devicemap/trunk/examples/ddr-filter/src/main/webapp/index.jsp?rev=1648284&r1=1648283&r2=1648284&view=diff
==============================================================================
--- devicemap/trunk/examples/ddr-filter/src/main/webapp/index.jsp (original)
+++ devicemap/trunk/examples/ddr-filter/src/main/webapp/index.jsp Mon Dec 29 02:55:12 2014
@@ -8,7 +8,13 @@
         <title>DeviceMap Simple DDR Sample</title>
     </head>
     <body>
-        <h1><%= (request.getAttribute("vendor") != null ? request.getAttribute("vendor")
: "No vendor") %>
-        <%= (request.getAttribute("model") != null ? request.getAttribute("model") : "No
model") %> resolution: <%= request.getAttribute("displayWidth") %> x <%= request.getAttribute("displayHeight")
%></h1>
+    	<h1>DeviceMap W3C DDR Simple Example</h1>
+        <h2><%= (request.getAttribute("vendor") != null ? request.getAttribute("vendor")
: "No vendor") %>
+        <%= (request.getAttribute("model") != null ? request.getAttribute("model") : "No
model") %> resolution: <%= request.getAttribute("displayWidth") %> x <%= request.getAttribute("displayHeight")
%></h2>
+        
+        <form action="/dmap-ddr-filter" method="GET">
+ua <input type="text" name="ua">
+<input type="submit" value="Submit">
+</form>
     </body>
 </html>
\ No newline at end of file



Mime
View raw message