Author: wkeil
Date: Fri Jul 25 20:24:19 2014
New Revision: 1613512
URL: http://svn.apache.org/r1613512
Log:
DMAP-48: Create example project and web service
Improved input and handling of User-agent strings
Task-Url: https://issues.apache.org/jira/browse/DMAP-48
Modified:
incubator/devicemap/trunk/examples/console/src/main/java/org/apache/devicemap/example/console/Example.java
incubator/devicemap/trunk/examples/pom.xml
incubator/devicemap/trunk/examples/servlet/ (props changed)
incubator/devicemap/trunk/examples/servlet/pom.xml
Modified:
incubator/devicemap/trunk/examples/console/src/main/java/org/apache/devicemap/example/console/Example.java
URL:
http://svn.apache.org/viewvc/incubator/devicemap/trunk/examples/console/src/main/java/org/apache/devicemap/example/console/Example.java?rev=1613512&r1=1613511&r2=1613512&view=diff
==============================================================================
---
incubator/devicemap/trunk/examples/console/src/main/java/org/apache/devicemap/example/console/Example.java
(original)
+++
incubator/devicemap/trunk/examples/console/src/main/java/org/apache/devicemap/example/console/Example.java
Fri Jul 25 20:24:19 2014
@@ -28,21 +28,32 @@ import org.apache.devicemap.loader.Loade
* @author Werner Keil
*/
public class Example {
+ private static final String DEFAULT_USER_AGENT = "Mozilla/5.0 (Linux;
U; Android 2.2; en; HTC Aria A6380 Build/ERE27) AppleWebKit/540.13+ (KHTML,
like Gecko) Version/3.1 Mobile Safari/524.15.0";
- public static void main(String[] args) throws Exception {
- //create a client object, store this somewhere permanent
+ public static void main(String[] args) throws Exception {
+ //create a client object, store this somewhere permanent
DeviceMapClient client = new DeviceMapClient();
//load the device data, do this only once!!!
client.initDeviceData(LoaderOption.JAR);
//classify a User-Agent string
- String test = "Mozilla/5.0 (Linux; U; Android 2.2; en; HTC Aria A6380
Build/ERE27) AppleWebKit/540.13+ (KHTML, like Gecko) Version/3.1 Mobile
Safari/524.15.0";
- Map<String, String> m = client.classify(test);
+ String test = DEFAULT_USER_AGENT;
+
+ if (args != null && args.length > 0) {
+ test = args[0];
+ }
+
+ final Map<String, String> m = client.classify(test);
//iterate thru the attributes
- for (String attr : m.keySet()) {
- System.out.println(attr + ": " + m.get(attr));
+ if (m!=null && (m.keySet()!= null && m.keySet().size()>0)) {
+ System.out.println("### ATTRIBUTES ###");
+ for (String attr : m.keySet()) {
+ System.out.println(attr + ": " + m.get(attr));
+ }
+ } else {
+ System.out.println("No device or attributes found for '" + test
+ "'.");
}
}
}
Modified: incubator/devicemap/trunk/examples/pom.xml
URL:
http://svn.apache.org/viewvc/incubator/devicemap/trunk/examples/pom.xml?rev=1613512&r1=1613511&r2=1613512&view=diff
==============================================================================
--- incubator/devicemap/trunk/examples/pom.xml (original)
+++ incubator/devicemap/trunk/examples/pom.xml Fri Jul 25 20:24:19 2014
@@ -26,6 +26,7 @@
<name>Apache DeviceMap Examples</name>
<modules>
<module>console</module>
+ <module>servlet</module>
</modules>
<parent>
<groupId>org.apache</groupId>
@@ -40,9 +41,9 @@
<jdkVersion>${java.version}</jdkVersion>
<maven.compile.targetLevel>${jdkVersion}</maven.compile.targetLevel>
<maven.compile.sourceLevel>${jdkVersion}</maven.compile.sourceLevel>
- <devicemap.version>1.0.0</devicemap.version>
- <devicemap.data.version>1.0.0</devicemap.data.version>
-
+ <devicemap.version>1.1.0-SNAPSHOT</devicemap.version>
+ <devicemap.data.version>1.0.1-SNAPSHOT</devicemap.data.version>
+ <devicemap.testdata.version>1.0.0</devicemap.testdata.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
@@ -79,4 +80,5 @@
</plugin>
</plugins>
</build>
+ <inceptionYear>2014</inceptionYear>
</project>
\ No newline at end of file
Propchange: incubator/devicemap/trunk/examples/servlet/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Fri Jul 25 20:24:19 2014
@@ -0,0 +1,4 @@
+.settings
+target
+.classpath
+.project
Modified: incubator/devicemap/trunk/examples/servlet/pom.xml
URL:
http://svn.apache.org/viewvc/incubator/devicemap/trunk/examples/servlet/pom.xml?rev=1613512&r1=1613511&r2=1613512&view=diff
==============================================================================
--- incubator/devicemap/trunk/examples/servlet/pom.xml (original)
+++ incubator/devicemap/trunk/examples/servlet/pom.xml Fri Jul 25 20:24:19 2014
@@ -25,7 +25,7 @@
<artifactId>dmap-servlet</artifactId>
<packaging>war</packaging>
<version>1.0.0-SNAPSHOT</version>
- <name>devicemap-servlet-example</name>
+ <name>DeviceMap Servlet Example</name>
<description>Apache DeviceMap Servlet Example</description>
@@ -44,7 +44,7 @@
<dependency>
<groupId>org.apache.devicemap</groupId>
<artifactId>devicemap-data</artifactId>
- <version>1.0.0</version>
+ <version>1.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>javax.servlet</groupId>