devicemap-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wk...@apache.org
Subject svn commit: r1648970 - in /devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr: builder/device/ builder/os/mozilla/ model/ model/os/
Date Fri, 02 Jan 2015 03:05:39 GMT
Author: wkeil
Date: Fri Jan  2 03:05:39 2015
New Revision: 1648970

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

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

Modified:
    devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/device/AndroidDeviceBuilder.java
    devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/device/OrderedTokenDeviceBuilder.java
    devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/device/SymbianDeviceBuilder.java
    devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/os/mozilla/AndroidMozillaSubBuilder.java
    devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/os/mozilla/LinuxMozillaSubBuilder.java
    devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/model/UserAgent.java
    devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/model/os/OperatingSystem.java

Modified: devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/device/AndroidDeviceBuilder.java
URL: http://svn.apache.org/viewvc/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/device/AndroidDeviceBuilder.java?rev=1648970&r1=1648969&r2=1648970&view=diff
==============================================================================
--- devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/device/AndroidDeviceBuilder.java
(original)
+++ devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/device/AndroidDeviceBuilder.java
Fri Jan  2 03:05:39 2015
@@ -18,6 +18,7 @@
  */
 package org.apache.devicemap.simpleddr.builder.device;
 
+import static org.apache.devicemap.simpleddr.model.os.OperatingSystem.ANDROID;
 import static org.apache.devicemap.simpleddr.ODDRService.ODDR_DEFAULT_THRESHOLD;
 
 import java.util.ArrayList;
@@ -61,7 +62,7 @@ public class AndroidDeviceBuilder extend
         Iterator<String> it = orderedRules.keySet().iterator();
         while (it.hasNext()) {
             String token = it.next();
-//            logger.debug.println(token);
+//            logger.info("T: " + token);
             Device d = elaborateAndroidDeviceWithToken(userAgent, token);
             if (d != null) {
             	logger.debug("Token: " + token);
@@ -107,7 +108,7 @@ public class AndroidDeviceBuilder extend
 //logger.debug("Loose Token: " + looseToken);
             Pattern loosePattern = Pattern.compile("(?i).*" + looseToken + ".*");
 //logger.debug("Loose Pattern: " + loosePattern);
-            if (!loosePattern.matcher(userAgent.getCompleteUserAgent().replaceAll("Android",
"")).matches()) {
+            if (!loosePattern.matcher(userAgent.getCompleteUserAgent().replaceAll(ANDROID,
"")).matches()) {
                 return null;
             }
 
@@ -233,20 +234,21 @@ public class AndroidDeviceBuilder extend
     }
     
     private Device fixFromUserAgent(final Device device, final UserAgent userAgent) {
-//    	if (device.containsProperty("device_os_version")) {
+//    	if (device.containsProperty(DEVICE_OS_VERSION)) {
     		String pattern = userAgent.getPatternElementsInside();
     		String[] parts = pattern.split(";");
     		for (String part : parts) {
-    			if (part.trim().startsWith("Android")) {
-    				final String versionPart = part.trim().substring("Android".length());
-    				final String versionExisting = device.get("device_os_version");
+    			if (part.trim().startsWith(ANDROID)) {
+    				final String versionPart = part.trim().substring(ANDROID.length()).trim();
+    				final String versionExisting = device.get(DEVICE_OS_VERSION);
     				if (!versionPart.equals(versionExisting)) {
     					logger.info("Fixing '" + versionExisting +"' to '" + versionPart + "'" );
-    					device.putProperty("device_os_version", versionPart);
+    					device.putProperty(DEVICE_OS_VERSION, versionPart);
     				}
     			}
     		}
 //    	}
+//    	logger.info("Device: " + device.getId() + " - " + device.getPropertiesMap());
     	return device;
     }
 
@@ -271,7 +273,7 @@ public class AndroidDeviceBuilder extend
 	    patternElementInsideClean = patternElementInsideClean.replaceAll("Build/" + Pattern.quote(build),
"Build/");
 
         }
-        patternElementInsideClean = patternElementInsideClean.replaceAll("Android", "");
+        patternElementInsideClean = patternElementInsideClean.replaceAll(ANDROID, "");
 
         return patternElementInsideClean;
     }

Modified: devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/device/OrderedTokenDeviceBuilder.java
URL: http://svn.apache.org/viewvc/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/device/OrderedTokenDeviceBuilder.java?rev=1648970&r1=1648969&r2=1648970&view=diff
==============================================================================
--- devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/device/OrderedTokenDeviceBuilder.java
(original)
+++ devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/device/OrderedTokenDeviceBuilder.java
Fri Jan  2 03:05:39 2015
@@ -28,7 +28,8 @@ import java.util.Map;
 import org.apache.devicemap.simpleddr.model.device.Device;
 
 public abstract class OrderedTokenDeviceBuilder implements DeviceBuilder {
-
+	protected static final String DEVICE_OS_VERSION = "device_os_version";
+	
     protected Map<String, Object> orderedRules;
 
     public OrderedTokenDeviceBuilder() {

Modified: devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/device/SymbianDeviceBuilder.java
URL: http://svn.apache.org/viewvc/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/device/SymbianDeviceBuilder.java?rev=1648970&r1=1648969&r2=1648970&view=diff
==============================================================================
--- devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/device/SymbianDeviceBuilder.java
(original)
+++ devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/device/SymbianDeviceBuilder.java
Fri Jan  2 03:05:39 2015
@@ -100,7 +100,7 @@ public class SymbianDeviceBuilder extend
                 if (userAgent.getPatternElementsInside() != null && currentPattern.matcher(userAgent.getPatternElementsInside()).matches())
{// userAgent.getPatternElementsInside().matches(".*Series60.?(\\d+)\\.(\\d+).?" + currentToken
+ ".*")) {
                     String deviceId = (String) orderedRules.get(originalToken);
 
-		    if (devices.containsKey(deviceId)) {
+                    if (devices.containsKey(deviceId)) {
                         Device retDevice = (Device) devices.get(deviceId).clone();
                         retDevice.setConfidence(100 - subtract);
                         return retDevice;
@@ -177,7 +177,7 @@ public class SymbianDeviceBuilder extend
                 subtract += 20;
             }
         } else {
-            String ua = userAgent.getCompleteUserAgent().replaceAll("SN[0-9]*", "");
+            final String ua = userAgent.getCompleteUserAgent().replaceAll("SN[0-9]*", "");
 
             int subtract = 0;
             String currentToken = token;

Modified: devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/os/mozilla/AndroidMozillaSubBuilder.java
URL: http://svn.apache.org/viewvc/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/os/mozilla/AndroidMozillaSubBuilder.java?rev=1648970&r1=1648969&r2=1648970&view=diff
==============================================================================
--- devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/os/mozilla/AndroidMozillaSubBuilder.java
(original)
+++ devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/os/mozilla/AndroidMozillaSubBuilder.java
Fri Jan  2 03:05:39 2015
@@ -43,7 +43,7 @@ public class AndroidMozillaSubBuilder im
         OperatingSystem model = new OperatingSystem();
         model.setMajorRevision("1");
         model.setVendor("Google");
-        model.setModel("Android");
+        model.setModel(OperatingSystem.ANDROID);
         model.setConfidence(40);
 
         String[] splittedTokens = userAgent.getPatternElementsInside().split(";");

Modified: devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/os/mozilla/LinuxMozillaSubBuilder.java
URL: http://svn.apache.org/viewvc/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/os/mozilla/LinuxMozillaSubBuilder.java?rev=1648970&r1=1648969&r2=1648970&view=diff
==============================================================================
--- devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/os/mozilla/LinuxMozillaSubBuilder.java
(original)
+++ devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/os/mozilla/LinuxMozillaSubBuilder.java
Fri Jan  2 03:05:39 2015
@@ -32,7 +32,7 @@ public class LinuxMozillaSubBuilder impl
     private Pattern descriptionPattern = Pattern.compile(DESCRIPTION_REGEXP);
 
     public boolean canBuild(UserAgent userAgent) {
-        return userAgent.getCompleteUserAgent().contains("Linux") && !userAgent.getCompleteUserAgent().contains("Android");
+        return userAgent.getCompleteUserAgent().contains("Linux") && !userAgent.getCompleteUserAgent().contains(OperatingSystem.ANDROID);
     }
 
     public BuiltObject build(UserAgent userAgent, int confidenceTreshold) {

Modified: devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/model/UserAgent.java
URL: http://svn.apache.org/viewvc/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/model/UserAgent.java?rev=1648970&r1=1648969&r2=1648970&view=diff
==============================================================================
--- devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/model/UserAgent.java
(original)
+++ devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/model/UserAgent.java
Fri Jan  2 03:05:39 2015
@@ -18,11 +18,13 @@
  */
 package org.apache.devicemap.simpleddr.model;
 
+import static org.apache.devicemap.simpleddr.model.os.OperatingSystem.ANDROID;
+
 import java.util.regex.Matcher;
 import java.util.regex.Pattern;
 
 public class UserAgent {
-
+	
     public static final String MOZILLA_AND_OPERA_PATTERN = "(.*?)((?:Mozilla)|(?:Opera))[/
](\\d+\\.\\d+).*?\\(((?:.*?)(?:.*?\\(.*?\\))*(?:.*?))\\)(.*)";
     public static final int INDEX_MOZILLA_PATTERN_GROUP_PRE = 1;
     public static final int INDEX_MOZILLA_PATTERN_GROUP_INSIDE = 4;
@@ -90,7 +92,7 @@ public class UserAgent {
             operaVersion = null;
         }
 
-        if (userAgent.contains("Android")) {
+        if (userAgent.contains(ANDROID)) {
             containsAndroid = true;
 
         } else {

Modified: devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/model/os/OperatingSystem.java
URL: http://svn.apache.org/viewvc/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/model/os/OperatingSystem.java?rev=1648970&r1=1648969&r2=1648970&view=diff
==============================================================================
--- devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/model/os/OperatingSystem.java
(original)
+++ devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/model/os/OperatingSystem.java
Fri Jan  2 03:05:39 2015
@@ -19,10 +19,12 @@
 package org.apache.devicemap.simpleddr.model.os;
 
 import java.util.Map;
+
 import org.apache.devicemap.simpleddr.model.BuiltObject;
 
 public class OperatingSystem extends BuiltObject implements Comparable {
-
+	public static final String ANDROID = "Android";
+	
     private String majorRevision = "0";
     private String minorRevision = "0";
     private String microRevision = "0";



Mime
View raw message