You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@devicemap.apache.org by wk...@apache.org on 2014/03/24 01:52:49 UTC
svn commit: r1580679 [1/6] - in /incubator/devicemap/trunk/devicemap/java:
./ classifier/ simpleddr/ simpleddr/src/ simpleddr/src/main/
simpleddr/src/main/java/ simpleddr/src/main/java/org/
simpleddr/src/main/java/org/apache/ simpleddr/src/main/java/or...
Author: wkeil
Date: Mon Mar 24 00:52:47 2014
New Revision: 1580679
URL: http://svn.apache.org/r1580679
Log:
OPEN - issue DMAP-35: Refactor Simple DDR
https://issues.apache.org/jira/browse/DMAP-35
Added:
incubator/devicemap/trunk/devicemap/java/simpleddr/pom.xml
incubator/devicemap/trunk/devicemap/java/simpleddr/src/
incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/
incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/
incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/
incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/
incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/
incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/
incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/ODDRService.java
incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/ODDRVocabularyService.java
incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/
incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/Builder.java
incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/browser/
incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/browser/AndroidMobileBrowserBuilder.java
incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/browser/BlackBerryBrowserBuilder.java
incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/browser/ChromeBrowserBuilder.java
incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/browser/ChromeMobileBrowserBuilder.java
incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/browser/DefaultBrowserBuilder.java
incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/browser/DolfinBrowserBuilder.java
incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/browser/FennecBrowserBuilder.java
incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/browser/FirefoxBrowserBuilder.java
incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/browser/HintedResolutionBrowserBuilder.java
incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/browser/IEMobileBrowserBuilder.java
incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/browser/InternetExplorerBrowserBuilder.java
incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/browser/JasmineBrowserBuilder.java
incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/browser/KonquerorBrowserBuilder.java
incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/browser/LayoutEngineBrowserBuilder.java
incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/browser/NetFrontBrowserBuilder.java
incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/browser/NokiaBrowserBuilder.java
incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/browser/ObigoBrowserBuilder.java
incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/browser/OpenWaveBrowserBuilder.java
incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/browser/OperaBrowserBuilder.java
incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/browser/OperaMiniBrowserBuilder.java
incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/browser/PolarisBrowserBuilder.java
incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/browser/SEMCBrowserBuilder.java
incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/browser/SafariBrowserBuilder.java
incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/browser/SafariMobileBrowserBuilder.java
incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/browser/SilkBrowserBuilder.java
incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/browser/UPBrowserBuilder.java
incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/browser/WebOsBrowserBuilder.java
incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/device/
incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/device/AndroidDeviceBuilder.java
incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/device/DeviceBuilder.java
incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/device/IOSDeviceBuilder.java
incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/device/OrderedTokenDeviceBuilder.java
incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/device/SimpleDeviceBuilder.java
incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/device/SymbianDeviceBuilder.java
incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/device/TwoStepDeviceBuilder.java
incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/device/WinPhoneDeviceBuilder.java
incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/os/
incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/os/BlackBerryOSBuilder.java
incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/os/DefaultOSBuilder.java
incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/os/MozillaOSModelBuilder.java
incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/os/OperaOSModelBuilder.java
incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/os/mozilla/
incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/os/mozilla/AndroidMozillaSubBuilder.java
incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/os/mozilla/BadaMozillaSubBuilder.java
incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/os/mozilla/BlackBerryMozillaSubBuilder.java
incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/os/mozilla/BrewMozillaSubBuilder.java
incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/os/mozilla/IOSMozillaSubBuilder.java
incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/os/mozilla/LinuxMozillaSubBuilder.java
incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/os/mozilla/MacOSXMozillaSubBuilder.java
incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/os/mozilla/SymbianMozillaSubBuilder.java
incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/os/mozilla/WebOSMozillaSubBuilder.java
incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/os/mozilla/WinCEMozillaSubBuilder.java
incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/builder/os/mozilla/WinPhoneMozillaSubBuilder.java
incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/cache/
incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/cache/Cache.java
incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/cache/CacheImpl.java
incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/documenthandler/
incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/documenthandler/BrowserDatasourceHandler.java
incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/documenthandler/DeviceBuilderHandler.java
incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/documenthandler/DeviceDatasourceHandler.java
incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/documenthandler/OperatingSystemDatasourceHandler.java
incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/documenthandler/VocabularyHandler.java
incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/identificator/
incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/identificator/BrowserIdentificator.java
incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/identificator/DeviceIdentificator.java
incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/identificator/Identificator.java
incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/identificator/OSIdentificator.java
incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/model/
incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/model/BufferedODDRHTTPEvidence.java
incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/model/BuiltObject.java
incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/model/ODDRHTTPEvidence.java
incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/model/ODDRPropertyName.java
incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/model/ODDRPropertyRef.java
incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/model/ODDRPropertyValue.java
incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/model/ODDRPropertyValues.java
incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/model/UserAgent.java
incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/model/UserAgentFactory.java
incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/model/browser/
incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/model/browser/Browser.java
incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/model/device/
incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/model/device/Device.java
incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/model/os/
incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/model/os/OperatingSystem.java
incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/model/vocabulary/
incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/model/vocabulary/Vocabulary.java
incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/model/vocabulary/VocabularyProperty.java
incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/model/vocabulary/VocabularyVariable.java
incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/vocabulary/
incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/vocabulary/VocabularyHolder.java
incubator/devicemap/trunk/devicemap/java/simpleddr/src/oddr.properties
incubator/devicemap/trunk/devicemap/java/simpleddr/src/test/
incubator/devicemap/trunk/devicemap/java/simpleddr/src/test/java/
incubator/devicemap/trunk/devicemap/java/simpleddr/src/test/java/org/
incubator/devicemap/trunk/devicemap/java/simpleddr/src/test/java/org/apache/
incubator/devicemap/trunk/devicemap/java/simpleddr/src/test/java/org/apache/devicemap/
incubator/devicemap/trunk/devicemap/java/simpleddr/src/test/java/org/apache/devicemap/simpleddr/
incubator/devicemap/trunk/devicemap/java/simpleddr/src/test/java/org/apache/devicemap/simpleddr/test/
incubator/devicemap/trunk/devicemap/java/simpleddr/src/test/java/org/apache/devicemap/simpleddr/test/DeviceMapService.java
incubator/devicemap/trunk/devicemap/java/simpleddr/src/test/java/org/apache/devicemap/simpleddr/test/ServiceSetup.java
incubator/devicemap/trunk/devicemap/java/simpleddr/src/test/java/org/apache/devicemap/simpleddr/test/TestDataFileEntries.java
incubator/devicemap/trunk/devicemap/java/simpleddr/src/test/java/org/apache/devicemap/simpleddr/test/TestDataService.java
incubator/devicemap/trunk/devicemap/java/simpleddr/src/test/java/org/apache/devicemap/simpleddr/test/TestDeviceDataQueries.java
incubator/devicemap/trunk/devicemap/java/simpleddr/src/test/java/org/apache/devicemap/simpleddr/test/TestServiceCreation.java
incubator/devicemap/trunk/devicemap/java/simpleddr/src/test/java/org/apache/devicemap/simpleddr/test/TestSimpleQueries.java
incubator/devicemap/trunk/devicemap/java/simpleddr/src/test/java/org/apache/devicemap/simpleddr/test/UserAgentEvidence.java
incubator/devicemap/trunk/devicemap/java/simpleddr/src/test/java/org/apache/devicemap/simpleddr/test/Util.java
incubator/devicemap/trunk/devicemap/java/simpleddr/src/test/resources/
incubator/devicemap/trunk/devicemap/java/simpleddr/src/test/resources/config/
incubator/devicemap/trunk/devicemap/java/simpleddr/src/test/resources/config/openddr.devicemap.properties
incubator/devicemap/trunk/devicemap/java/simpleddr/src/test/resources/config/openddr.test.properties
incubator/devicemap/trunk/devicemap/java/simpleddr/src/test/resources/openddr-test-data/
incubator/devicemap/trunk/devicemap/java/simpleddr/src/test/resources/openddr-test-data/TEST_BrowserDataSource.xml
incubator/devicemap/trunk/devicemap/java/simpleddr/src/test/resources/openddr-test-data/TEST_BuilderDataSource.xml
incubator/devicemap/trunk/devicemap/java/simpleddr/src/test/resources/openddr-test-data/TEST_BuilderDataSourcePatch.xml
incubator/devicemap/trunk/devicemap/java/simpleddr/src/test/resources/openddr-test-data/TEST_DeviceDataSource.xml
incubator/devicemap/trunk/devicemap/java/simpleddr/src/test/resources/openddr-test-data/TEST_DeviceDataSourcePatch.xml
incubator/devicemap/trunk/devicemap/java/simpleddr/src/test/resources/openddr-test-data/TEST_OperatingSystemDataSource.xml
incubator/devicemap/trunk/devicemap/java/simpleddr/src/test/resources/openddr-test-data/TEST_coreVocabulary.xml
incubator/devicemap/trunk/devicemap/java/simpleddr/src/test/resources/openddr-test-data/TEST_oddrLimitedVocabulary.xml
incubator/devicemap/trunk/devicemap/java/simpleddr/src/test/resources/openddr-test-data/TEST_oddrVocabulary.xml
Modified:
incubator/devicemap/trunk/devicemap/java/classifier/ (props changed)
incubator/devicemap/trunk/devicemap/java/classifier/pom.xml
incubator/devicemap/trunk/devicemap/java/pom.xml
incubator/devicemap/trunk/devicemap/java/simpleddr/ (props changed)
Propchange: incubator/devicemap/trunk/devicemap/java/classifier/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Mon Mar 24 00:52:47 2014
@@ -0,0 +1,4 @@
+target
+.settings
+.classpath
+.project
Modified: incubator/devicemap/trunk/devicemap/java/classifier/pom.xml
URL: http://svn.apache.org/viewvc/incubator/devicemap/trunk/devicemap/java/classifier/pom.xml?rev=1580679&r1=1580678&r2=1580679&view=diff
==============================================================================
--- incubator/devicemap/trunk/devicemap/java/classifier/pom.xml (original)
+++ incubator/devicemap/trunk/devicemap/java/classifier/pom.xml Mon Mar 24 00:52:47 2014
@@ -20,31 +20,18 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
- <groupId>org.apache</groupId>
- <artifactId>apache</artifactId>
- <version>9</version>
+ <groupId>org.apache.devicemap</groupId>
+ <artifactId>devicemap-parent</artifactId>
+ <version>0.9.9-SNAPSHOT</version>
<relativePath/>
</parent>
<groupId>org.apache.devicemap</groupId>
<artifactId>org.apache.devicemap.classifier</artifactId>
<packaging>jar</packaging>
- <version>0.9.9-SNAPSHOT</version>
<name>Apache DeviceMap Classifier</name>
<description>Apache DeviceMap Java Device Classifier</description>
<url>http://incubator.apache.org/devicemap</url>
-
- <!-- Test settings that can be overridden from the Maven command line -->
- <properties>
- <!-- Set this to N to execute only N tests -->
- <devicemap.max.tests>0</devicemap.max.tests>
-
- <!-- The test data file maps User-Agent values to expected device properties -->
- <devicemap.test.data.file>${project.build.directory}/devicemap/test-data/dmap_20130522.txt</devicemap.test.data.file>
-
- <!-- Where to find the device data -->
- <devicemap.device.data.folder>${project.build.directory}/devicemap/devicedata</devicemap.device.data.folder>
- </properties>
<scm>
<connection>scm:svn:http://svn.apache.org/repos/asf/incubator/devicemap/trunk/devicemapjava</connection>
@@ -92,8 +79,8 @@
<artifactId>maven-compiler-plugin</artifactId>
<version>3.0</version>
<configuration>
- <source>1.6</source>
- <target>1.6</target>
+ <source>${jdkVersion}</source>
+ <target>${jdkVersion}</target>
<debug>true</debug>
</configuration>
</plugin>
Modified: incubator/devicemap/trunk/devicemap/java/pom.xml
URL: http://svn.apache.org/viewvc/incubator/devicemap/trunk/devicemap/java/pom.xml?rev=1580679&r1=1580678&r2=1580679&view=diff
==============================================================================
--- incubator/devicemap/trunk/devicemap/java/pom.xml (original)
+++ incubator/devicemap/trunk/devicemap/java/pom.xml Mon Mar 24 00:52:47 2014
@@ -27,15 +27,27 @@
</parent>
<groupId>org.apache.devicemap</groupId>
- <artifactId>org.apache.devicemap.classifier</artifactId>
- <packaging>jar</packaging>
+ <artifactId>devicemap-parent</artifactId>
+ <packaging>pom</packaging>
<version>0.9.9-SNAPSHOT</version>
- <name>Apache DeviceMap Classifier</name>
- <description>Apache DeviceMap Java Device Classifier</description>
+ <name>Apache DeviceMap Parent</name>
+ <description>Apache DeviceMap Java Parent</description>
<url>http://incubator.apache.org/devicemap</url>
+ <modules>
+ <module>classifier</module>
+ <module>simpleddr</module>
+ </modules>
+
<!-- Test settings that can be overridden from the Maven command line -->
<properties>
+ <jdkVersion>1.6</jdkVersion>
+ <maven.compile.targetLevel>${jdkVersion}</maven.compile.targetLevel>
+ <maven.compile.sourceLevel>${jdkVersion}</maven.compile.sourceLevel>
+
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
+
<!-- Set this to N to execute only N tests -->
<devicemap.max.tests>0</devicemap.max.tests>
@@ -47,9 +59,9 @@
</properties>
<scm>
- <connection>scm:svn:http://svn.apache.org/repos/asf/incubator/devicemap/trunk/devicemapjava</connection>
+ <connection>scm:svn:http://svn.apache.org/repos/asf/incubator/devicemap/trunk/devicemap/java</connection>
<developerConnection>scm:svn:https://svn.apache.org/repos/asf/incubator/devicemap/trunk/devicemapjava</developerConnection>
- <url>http://svn.apache.org/viewvc/incubator/devicemap/trunk/devicemapjava</url>
+ <url>http://svn.apache.org/viewvc/incubator/devicemap/trunk/java</url>
</scm>
<dependencies>
@@ -84,54 +96,5 @@
<scope>test</scope>
</dependency>
</dependencies>
-
- <build>
- <plugins>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-compiler-plugin</artifactId>
- <version>3.0</version>
- <configuration>
- <source>1.6</source>
- <target>1.6</target>
- <debug>true</debug>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-surefire-plugin</artifactId>
- <version>2.16</version>
- <configuration>
- <argLine>-Xmx512M -XX:MaxPermSize=256m -Dfile.encoding=UTF-8</argLine>
- <systemPropertyVariables>
- <devicemap.test.data.file>${devicemap.test.data.file}</devicemap.test.data.file>
- <devicemap.max.tests>${devicemap.max.tests}</devicemap.max.tests>
- <devicemap.test.data.file>${devicemap.test.data.file}</devicemap.test.data.file>
- <devicemap.device.data.folder>${devicemap.device.data.folder}</devicemap.device.data.folder>
- </systemPropertyVariables>
- </configuration>
- </plugin>
- <plugin>
- <groupId>org.apache.maven.plugins</groupId>
- <artifactId>maven-dependency-plugin</artifactId>
- <version>2.6</version>
- <executions>
- <execution>
- <id>unpack-dependencies</id>
- <phase>process-resources</phase>
- <goals>
- <goal>unpack-dependencies</goal>
- </goals>
- <configuration>
- <includes>**/*.xml,**/*.txt</includes>
- <outputDirectory>${project.build.directory}/devicemap</outputDirectory>
- <overWriteReleases>false</overWriteReleases>
- <overWriteSnapshots>true</overWriteSnapshots>
- </configuration>
- </execution>
- </executions>
- </plugin>
- </plugins>
- </build>
- </project>
+</project>
Propchange: incubator/devicemap/trunk/devicemap/java/simpleddr/
------------------------------------------------------------------------------
--- svn:ignore (added)
+++ svn:ignore Mon Mar 24 00:52:47 2014
@@ -0,0 +1,4 @@
+.settings
+.classpath
+.project
+target
Added: incubator/devicemap/trunk/devicemap/java/simpleddr/pom.xml
URL: http://svn.apache.org/viewvc/incubator/devicemap/trunk/devicemap/java/simpleddr/pom.xml?rev=1580679&view=auto
==============================================================================
--- incubator/devicemap/trunk/devicemap/java/simpleddr/pom.xml (added)
+++ incubator/devicemap/trunk/devicemap/java/simpleddr/pom.xml Mon Mar 24 00:52:47 2014
@@ -0,0 +1,165 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ Licensed to the Apache Software Foundation (ASF) under one or
+ more contributor license agreements. See the NOTICE file
+ distributed with this work for additional information regarding
+ copyright ownership. The ASF licenses this file to you under the
+ Apache License, Version 2.0 (the "License"); you may not use
+ this file except in compliance with the License. You may obtain
+ a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0 Unless required by
+ applicable law or agreed to in writing, software distributed
+ under the License is distributed on an "AS IS" BASIS, WITHOUT
+ WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ See the License for the specific language governing permissions
+ and limitations under the License.
+-->
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>org.apache.devicemap</groupId>
+ <relativePath/>
+ <artifactId>devicemap-parent</artifactId>
+ <version>0.9.9-SNAPSHOT</version>
+ </parent>
+
+ <groupId>org.apache.devicemap</groupId>
+ <artifactId>org.apache.devicemap.simpleddr</artifactId>
+ <packaging>jar</packaging>
+ <name>Apache DeviceMap Simple DDR Java module</name>
+ <description>Simple DDR Java module</description>
+ <inceptionYear>2012</inceptionYear>
+ <url>http://incubator.apache.org/devicemap</url>
+
+ <prerequisites>
+ <maven>3.0.2</maven>
+ </prerequisites>
+ <scm>
+
+ <connection>scm:svn:http://svn.apache.org/repos/asf/incubator/devicemap/trunk/java/simpleddr</connection>
+ <developerConnection>scm:svn:https://svn.apache.org/repos/asf/incubator/devicemap/trunk/devicemap/java/simpleddr</developerConnection>
+ <url>http://svn.apache.org/viewvc/incubator/devicemap/trunk/openddr/java</url>
+ </scm>
+
+ <build>
+ <testResources>
+ <testResource>
+ <targetPath>${project.build.directory}/test-classes</targetPath>
+ <filtering>true</filtering>
+ <directory>${basedir}/src/test/resources</directory>
+ </testResource>
+ </testResources>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <version>3.0</version>
+ <configuration>
+ <source>${jdkVersion}</source>
+ <target>${jdkVersion}</target>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-surefire-plugin</artifactId>
+ <version>2.13</version>
+ <configuration>
+ <systemPropertyVariables>
+ <devicemap.test.data.file>${project.build.directory}/devicemap/test-data/ua-to-properties.txt</devicemap.test.data.file>
+ </systemPropertyVariables>
+ </configuration>
+ </plugin>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-dependency-plugin</artifactId>
+ <version>2.6</version>
+ <executions>
+ <execution>
+ <id>unpack-dependencies</id>
+ <phase>process-resources</phase>
+ <goals>
+ <goal>unpack-dependencies</goal>
+ </goals>
+ <configuration>
+ <includes>**/*.xml,**/*.txt</includes>
+ <outputDirectory>${project.build.directory}/devicemap</outputDirectory>
+ <overWriteReleases>false</overWriteReleases>
+ <overWriteSnapshots>true</overWriteSnapshots>
+ </configuration>
+ </execution>
+ </executions>
+ </plugin>
+ </plugins>
+ </build>
+
+ <dependencies>
+ <dependency>
+ <groupId>org.apache.commons</groupId>
+ <artifactId>commons-jexl</artifactId>
+ <version>2.1</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>1.6.6</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-simple</artifactId>
+ <version>1.6.6</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>commons-lang</groupId>
+ <artifactId>commons-lang</artifactId>
+ <version>2.1</version>
+ </dependency>
+ <dependency>
+ <!-- TODO not in Maven central so far, can be downloaded at
+ http://www.w3.org/TR/2008/WD-DDR-Simple-API-20080404/ -->
+ <groupId>org.w3c.ddr.simple</groupId>
+ <artifactId>DDR-Simple-API</artifactId>
+ <version>2008-04-04</version>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.devicemap</groupId>
+ <artifactId>devicemap-device-data</artifactId>
+ <version>0.9.9-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>org.apache.devicemap</groupId>
+ <artifactId>devicemap-test-data</artifactId>
+ <version>0.9.9-SNAPSHOT</version>
+ <scope>test</scope>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit</artifactId>
+ <version>4.11</version>
+ <scope>test</scope>
+ </dependency>
+ </dependencies>
+
+ <profiles>
+ <profile>
+ <id>rat</id>
+ <activation>
+ <activeByDefault>false</activeByDefault>
+ </activation>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.rat</groupId>
+ <artifactId>apache-rat-plugin</artifactId>
+ <configuration>
+ <excludeSubProjects>false</excludeSubProjects>
+ <excludes></excludes>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ </profile>
+ </profiles>
+</project>
Added: incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/ODDRService.java
URL: http://svn.apache.org/viewvc/incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/ODDRService.java?rev=1580679&view=auto
==============================================================================
--- incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/ODDRService.java (added)
+++ incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/ODDRService.java Mon Mar 24 00:52:47 2014
@@ -0,0 +1,899 @@
+/**
+ * Copyright 2011 OpenDDR LLC
+ * This software is distributed under the terms of the GNU Lesser General Public License.
+ *
+ *
+ * This file is part of OpenDDR Simple APIs.
+ * OpenDDR Simple APIs is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, version 3 of the License.
+ *
+ * OpenDDR Simple APIs is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Simple APIs. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+package org.apache.devicemap.simpleddr;
+
+import org.apache.devicemap.simpleddr.model.ODDRPropertyValue;
+import org.apache.devicemap.simpleddr.model.ODDRPropertyRef;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+import org.apache.commons.jexl2.Expression;
+import org.apache.commons.jexl2.JexlContext;
+import org.apache.commons.jexl2.JexlEngine;
+import org.apache.commons.jexl2.MapContext;
+import org.apache.devicemap.simpleddr.builder.Builder;
+import org.apache.devicemap.simpleddr.builder.browser.DefaultBrowserBuilder;
+import org.apache.devicemap.simpleddr.builder.device.DeviceBuilder;
+import org.apache.devicemap.simpleddr.builder.os.DefaultOSBuilder;
+import org.apache.devicemap.simpleddr.documenthandler.BrowserDatasourceHandler;
+import org.apache.devicemap.simpleddr.documenthandler.DeviceBuilderHandler;
+import org.apache.devicemap.simpleddr.documenthandler.DeviceDatasourceHandler;
+import org.apache.devicemap.simpleddr.documenthandler.OperatingSystemDatasourceHandler;
+import org.apache.devicemap.simpleddr.identificator.BrowserIdentificator;
+import org.apache.devicemap.simpleddr.identificator.DeviceIdentificator;
+import org.apache.devicemap.simpleddr.identificator.OSIdentificator;
+import org.apache.devicemap.simpleddr.model.BufferedODDRHTTPEvidence;
+import org.apache.devicemap.simpleddr.model.device.Device;
+import org.apache.devicemap.simpleddr.model.ODDRHTTPEvidence;
+import org.apache.devicemap.simpleddr.model.ODDRPropertyName;
+import org.apache.devicemap.simpleddr.model.ODDRPropertyValues;
+import org.apache.devicemap.simpleddr.model.UserAgent;
+import org.apache.devicemap.simpleddr.model.UserAgentFactory;
+import org.apache.devicemap.simpleddr.model.browser.Browser;
+import org.apache.devicemap.simpleddr.model.os.OperatingSystem;
+import org.apache.devicemap.simpleddr.model.vocabulary.Vocabulary;
+import org.apache.devicemap.simpleddr.model.vocabulary.VocabularyProperty;
+import org.apache.devicemap.simpleddr.vocabulary.VocabularyHolder;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.w3c.ddr.simple.Evidence;
+import org.w3c.ddr.simple.PropertyName;
+import org.w3c.ddr.simple.PropertyRef;
+import org.w3c.ddr.simple.PropertyValue;
+import org.w3c.ddr.simple.PropertyValues;
+import org.w3c.ddr.simple.Service;
+import org.w3c.ddr.simple.exception.InitializationException;
+import org.w3c.ddr.simple.exception.NameException;
+import org.xml.sax.SAXException;
+
+public class ODDRService implements Service {
+
+ public static final String ASPECT_DEVICE = "device";
+ public static final String ASPECT_WEB_BROWSER = "webBrowser";
+ public static final String ASPECT_OPERATIVE_SYSTEM = "operativeSystem";
+ public static final String ASPECT_GROUP = "group";
+ public static final String ODDR_UA_DEVICE_BUILDER_PATH_PROP = "oddr.ua.device.builder.path";
+ public static final String ODDR_UA_DEVICE_DATASOURCE_PATH_PROP = "oddr.ua.device.datasource.path";
+ public static final String ODDR_UA_DEVICE_BUILDER_PATCH_PATHS_PROP = "oddr.ua.device.builder.patch.paths";
+ public static final String ODDR_UA_DEVICE_DATASOURCE_PATCH_PATHS_PROP = "oddr.ua.device.datasource.patch.paths";
+ public static final String ODDR_UA_BROWSER_DATASOURCE_PATH_PROP = "oddr.ua.browser.datasource.path";
+ public static final String ODDR_UA_OPERATINGSYSTEM_DATASOURCE_PATH_PROP = "oddr.ua.operatingSystem.datasource.path";
+ public static final String ODDR_UA_DEVICE_BUILDER_STREAM_PROP = "oddr.ua.device.builder.stream";
+ public static final String ODDR_UA_DEVICE_DATASOURCE_STREAM_PROP = "oddr.ua.device.datasource.stream";
+ public static final String ODDR_UA_DEVICE_BUILDER_PATCH_STREAMS_PROP = "oddr.ua.device.builder.patch.streams";
+ public static final String ODDR_UA_DEVICE_DATASOURCE_PATCH_STREAMS_PROP = "oddr.ua.device.datasource.patch.streams";
+ public static final String ODDR_UA_BROWSER_DATASOURCE_STREAM_PROP = "oddr.ua.browser.datasource.stream";
+ public static final String ODDR_UA_OPERATINGSYSTEM_DATASOURCE_STREAM_PROP = "oddr.ua.operatingSystem.datasource.stream";
+ public static final String ODDR_THRESHOLD_PROP = "oddr.threshold";
+ public static final String ODDR_VOCABULARY_IRI = "oddr.vocabulary.device";
+ private static final String ODDR_API_VERSION = "1.0.0";
+ private static final String ODDR_DATA_VERSION = "2012";
+ private static final int ODDR_DEFAULT_THRESHOLD = 70;
+ private String defaultVocabularyIRI = null;
+ private DeviceIdentificator deviceIdentificator = null;
+ private BrowserIdentificator browserIdentificator = null;
+ private OSIdentificator osIdentificator = null;
+ private VocabularyHolder vocabularyHolder = null;
+ private int threshold = ODDR_DEFAULT_THRESHOLD;
+ private static final String GROUP_REGEXPR = "\\$([^ ]+)";
+ private Pattern groupRegexprPattern = Pattern.compile(GROUP_REGEXPR);
+ protected final Logger logger = LoggerFactory.getLogger(getClass());
+
+ public void initialize(String defaultVocabularyIRI, Properties prprts) throws NameException, InitializationException {
+ if (defaultVocabularyIRI == null || defaultVocabularyIRI.trim().length() == 0) {
+ throw new InitializationException(InitializationException.INITIALIZATION_ERROR, new NullPointerException("defaultVocabularyIRI can not be null"));
+ }
+
+ /*Initializing VocabularyHolder*/
+ ODDRVocabularyService oddrVocabularyService = new ODDRVocabularyService();
+ oddrVocabularyService.initialize(prprts);
+
+ vocabularyHolder = oddrVocabularyService.getVocabularyHolder();
+ vocabularyHolder.existVocabulary(defaultVocabularyIRI);
+
+ String oddrUaDeviceBuilderPath = prprts.getProperty(ODDR_UA_DEVICE_BUILDER_PATH_PROP);
+ String oddrUaDeviceDatasourcePath = prprts.getProperty(ODDR_UA_DEVICE_DATASOURCE_PATH_PROP);
+ String oddrUaDeviceBuilderPatchPaths = prprts.getProperty(ODDR_UA_DEVICE_BUILDER_PATCH_PATHS_PROP);
+ String oddrUaDeviceDatasourcePatchPaths = prprts.getProperty(ODDR_UA_DEVICE_DATASOURCE_PATCH_PATHS_PROP);
+ String oddrUaBrowserDatasourcePaths = prprts.getProperty(ODDR_UA_BROWSER_DATASOURCE_PATH_PROP);
+ String oddrUaOperatingSystemDatasourcePaths = prprts.getProperty(ODDR_UA_OPERATINGSYSTEM_DATASOURCE_PATH_PROP);
+
+ InputStream oddrUaDeviceBuilderStream = null;
+ InputStream oddrUaDeviceDatasourceStream = null;
+ InputStream[] oddrUaDeviceBuilderPatchStreams = null;
+ InputStream[] oddrUaDeviceDatasourcePatchStreams = null;
+ InputStream oddrUaBrowserDatasourceStream = null;
+ InputStream oddrUaOperatingSystemDatasourceStream = null;
+
+ try {
+ oddrUaDeviceBuilderStream = (InputStream) prprts.get(ODDR_UA_DEVICE_BUILDER_STREAM_PROP);
+ } catch (Exception ex) {
+ oddrUaDeviceBuilderStream = null;
+ }
+ try {
+ oddrUaDeviceDatasourceStream = (InputStream) prprts.get(ODDR_UA_DEVICE_DATASOURCE_STREAM_PROP);
+ } catch (Exception ex) {
+ oddrUaDeviceDatasourceStream = null;
+ }
+ try {
+ oddrUaDeviceBuilderPatchStreams = (InputStream[]) prprts.get(ODDR_UA_DEVICE_BUILDER_PATCH_STREAMS_PROP);
+ } catch (Exception ex) {
+ oddrUaDeviceBuilderPatchStreams = null;
+ }
+ try {
+ oddrUaDeviceDatasourcePatchStreams = (InputStream[]) prprts.get(ODDR_UA_DEVICE_DATASOURCE_PATCH_STREAMS_PROP);
+ } catch (Exception ex) {
+ oddrUaDeviceDatasourcePatchStreams = null;
+ }
+ try {
+ oddrUaBrowserDatasourceStream = (InputStream) prprts.get(ODDR_UA_BROWSER_DATASOURCE_STREAM_PROP);
+ } catch (Exception ex) {
+ oddrUaBrowserDatasourceStream = null;
+ }
+ try {
+ oddrUaOperatingSystemDatasourceStream = (InputStream) prprts.get(ODDR_UA_OPERATINGSYSTEM_DATASOURCE_STREAM_PROP);
+ } catch (Exception ex) {
+ oddrUaOperatingSystemDatasourceStream = null;
+ }
+
+ String oddrThreshold = prprts.getProperty(ODDR_THRESHOLD_PROP);
+
+ if ((oddrUaDeviceBuilderPath == null || oddrUaDeviceBuilderPath.trim().length() == 0) && oddrUaDeviceBuilderStream == null) {
+ throw new InitializationException(InitializationException.INITIALIZATION_ERROR, new IllegalArgumentException("Can not find property " + ODDR_UA_DEVICE_BUILDER_PATH_PROP));
+ }
+
+ if ((oddrUaDeviceDatasourcePath == null || oddrUaDeviceDatasourcePath.trim().length() == 0) && oddrUaDeviceDatasourceStream == null) {
+ throw new InitializationException(InitializationException.INITIALIZATION_ERROR, new IllegalArgumentException("Can not find property " + ODDR_UA_DEVICE_DATASOURCE_PATH_PROP));
+ }
+
+ String oddrUaDeviceBuilderPatchPathArray[] = null;
+
+ if (oddrUaDeviceBuilderPatchPaths != null && oddrUaDeviceBuilderPatchPaths.trim().length() != 0) {
+ oddrUaDeviceBuilderPatchPathArray = oddrUaDeviceBuilderPatchPaths.split(",");
+
+ } else {
+ oddrUaDeviceBuilderPatchPathArray = new String[0];
+ }
+
+ String ooddrUaDeviceDatasourcePatchPathArray[] = null;
+
+ if (oddrUaDeviceDatasourcePatchPaths != null && oddrUaDeviceDatasourcePatchPaths.trim().length() != 0) {
+ ooddrUaDeviceDatasourcePatchPathArray = oddrUaDeviceDatasourcePatchPaths.split(",");
+
+ } else {
+ ooddrUaDeviceDatasourcePatchPathArray = new String[0];
+ }
+
+// if (oddrUaDeviceBuilderPatchStreams == null) {
+// oddrUaDeviceBuilderPatchStreams = new InputStream[0];
+// }
+//
+// if (oddrUaDeviceDatasourcePatchStreams == null) {
+// oddrUaDeviceDatasourcePatchStreams = new InputStream[0];
+// }
+
+ if ((oddrUaBrowserDatasourcePaths == null || oddrUaBrowserDatasourcePaths.trim().length() == 0) && oddrUaBrowserDatasourceStream == null) {
+ throw new InitializationException(InitializationException.INITIALIZATION_ERROR, new IllegalArgumentException("Can not find property " + ODDR_UA_BROWSER_DATASOURCE_PATH_PROP));
+ }
+
+ if ((oddrUaOperatingSystemDatasourcePaths == null || oddrUaOperatingSystemDatasourcePaths.trim().length() == 0) && oddrUaOperatingSystemDatasourceStream == null) {
+ throw new InitializationException(InitializationException.INITIALIZATION_ERROR, new IllegalArgumentException("Can not find property " + ODDR_UA_OPERATINGSYSTEM_DATASOURCE_PATH_PROP));
+ }
+
+ if (oddrThreshold == null || oddrThreshold.trim().length() == 0) {
+ this.threshold = ODDR_DEFAULT_THRESHOLD;
+
+ } else {
+ try {
+ this.threshold = Integer.parseInt(oddrThreshold);
+ if (this.threshold <= 0) {
+ this.threshold = ODDR_DEFAULT_THRESHOLD;
+ }
+
+ } catch (NumberFormatException x) {
+ this.threshold = ODDR_DEFAULT_THRESHOLD;
+ }
+ }
+
+ Map<String, Device> devices = new HashMap<String, Device>();
+ DeviceDatasourceHandler deviceDatasourceHandler = new DeviceDatasourceHandler(devices, vocabularyHolder);
+
+ InputStream stream = null;
+ SAXParser parser = null;
+
+ try {
+ if (oddrUaDeviceDatasourceStream != null) {
+ stream = oddrUaDeviceDatasourceStream;
+ } else {
+ stream = new FileInputStream(new File(oddrUaDeviceDatasourcePath));
+ }
+
+ } catch (IOException ex) {
+ throw new InitializationException(InitializationException.INITIALIZATION_ERROR, new IllegalArgumentException("Can not open " + ODDR_UA_DEVICE_DATASOURCE_PATH_PROP + " " + oddrUaDeviceDatasourcePath));
+ }
+
+ try {
+ parser = SAXParserFactory.newInstance().newSAXParser();
+
+ } catch (ParserConfigurationException ex) {
+ throw new InitializationException(InitializationException.INITIALIZATION_ERROR, new IllegalStateException("Can not instantiate SAXParserFactory.newInstance().newSAXParser()"));
+
+ } catch (SAXException ex) {
+ throw new InitializationException(InitializationException.INITIALIZATION_ERROR, new IllegalStateException("Can not instantiate SAXParserFactory.newInstance().newSAXParser()"));
+ }
+
+ try {
+ parser.parse(stream, deviceDatasourceHandler);
+
+ } catch (SAXException ex) {
+ throw new InitializationException(InitializationException.INITIALIZATION_ERROR, new RuntimeException("Can not parse document: " + oddrUaDeviceDatasourcePath));
+
+ } catch (IOException ex) {
+ throw new InitializationException(InitializationException.INITIALIZATION_ERROR, new RuntimeException("Can not open " + ODDR_UA_DEVICE_DATASOURCE_PATH_PROP + " :" + oddrUaDeviceDatasourcePath));
+ }
+
+ try {
+ stream.close();
+
+ } catch (IOException ex) {
+ logger.warn("", ex);
+ }
+
+ deviceDatasourceHandler.setPatching(true);
+
+ if (oddrUaDeviceDatasourcePatchStreams != null) {
+ for (int i = 0; i < oddrUaDeviceDatasourcePatchStreams.length; i++) {
+ stream = oddrUaDeviceDatasourcePatchStreams[i];
+
+ try {
+ parser = SAXParserFactory.newInstance().newSAXParser();
+
+ } catch (ParserConfigurationException ex) {
+ throw new InitializationException(InitializationException.INITIALIZATION_ERROR, new IllegalStateException("Can not instantiate SAXParserFactory.newInstance().newSAXParser()"));
+
+ } catch (SAXException ex) {
+ throw new InitializationException(InitializationException.INITIALIZATION_ERROR, new IllegalStateException("Can not instantiate SAXParserFactory.newInstance().newSAXParser()"));
+ }
+
+ try {
+ parser.parse(stream, deviceDatasourceHandler);
+
+ } catch (Exception ex) {
+ throw new InitializationException(InitializationException.INITIALIZATION_ERROR, new RuntimeException("Can not parse DeviceDatasource input stream " + i));
+ }
+
+ try {
+ stream.close();
+
+ } catch (IOException ex) {
+ logger.warn("", ex);
+ }
+ }
+ } else {
+ for (int i = 0; i < ooddrUaDeviceDatasourcePatchPathArray.length; i++) {
+ try {
+ stream = new FileInputStream(new File(ooddrUaDeviceDatasourcePatchPathArray[i]));
+
+ } catch (IOException ex) {
+ throw new InitializationException(InitializationException.INITIALIZATION_ERROR, new IllegalArgumentException("Can not open " + ODDR_UA_DEVICE_DATASOURCE_PATH_PROP + " " + ooddrUaDeviceDatasourcePatchPathArray[i]));
+ }
+
+ try {
+ parser = SAXParserFactory.newInstance().newSAXParser();
+
+ } catch (ParserConfigurationException ex) {
+ throw new InitializationException(InitializationException.INITIALIZATION_ERROR, new IllegalStateException("Can not instantiate SAXParserFactory.newInstance().newSAXParser()"));
+
+ } catch (SAXException ex) {
+ throw new InitializationException(InitializationException.INITIALIZATION_ERROR, new IllegalStateException("Can not instantiate SAXParserFactory.newInstance().newSAXParser()"));
+ }
+
+ try {
+ parser.parse(stream, deviceDatasourceHandler);
+
+ } catch (SAXException ex) {
+ throw new InitializationException(InitializationException.INITIALIZATION_ERROR, new RuntimeException("Can not parse document: " + ooddrUaDeviceDatasourcePatchPathArray[i]));
+
+ } catch (IOException ex) {
+ throw new InitializationException(InitializationException.INITIALIZATION_ERROR, new RuntimeException("Can not open " + ODDR_UA_DEVICE_DATASOURCE_PATH_PROP + " :" + ooddrUaDeviceDatasourcePatchPathArray[i]));
+ }
+
+ try {
+ stream.close();
+
+ } catch (IOException ex) {
+ logger.warn("", ex);
+ }
+ }
+
+ }
+
+ List<DeviceBuilder> builders = new ArrayList<DeviceBuilder>();
+ DeviceBuilderHandler deviceBuilderHandler = new DeviceBuilderHandler(builders);
+
+ try {
+ if (oddrUaDeviceBuilderStream != null) {
+ stream = oddrUaDeviceBuilderStream;
+ } else {
+ stream = new FileInputStream(new File(oddrUaDeviceBuilderPath));
+ }
+
+ } catch (IOException ex) {
+ throw new InitializationException(InitializationException.INITIALIZATION_ERROR, new IllegalArgumentException("Can not open " + ODDR_UA_DEVICE_BUILDER_PATH_PROP + " " + oddrUaDeviceBuilderPath));
+ }
+
+ try {
+ parser = SAXParserFactory.newInstance().newSAXParser();
+
+ } catch (ParserConfigurationException ex) {
+ throw new InitializationException(InitializationException.INITIALIZATION_ERROR, new IllegalStateException("Can not instantiate SAXParserFactory.newInstance().newSAXParser()"));
+
+ } catch (SAXException ex) {
+ throw new InitializationException(InitializationException.INITIALIZATION_ERROR, new IllegalStateException("Can not instantiate SAXParserFactory.newInstance().newSAXParser()"));
+ }
+
+ try {
+ parser.parse(stream, deviceBuilderHandler);
+
+ } catch (SAXException ex) {
+ throw new InitializationException(InitializationException.INITIALIZATION_ERROR, new RuntimeException("Can not parse document: " + oddrUaDeviceBuilderPath));
+
+ } catch (IOException ex) {
+ throw new InitializationException(InitializationException.INITIALIZATION_ERROR, new RuntimeException("Can not open " + ODDR_UA_DEVICE_DATASOURCE_PATH_PROP + " :" + oddrUaDeviceBuilderPath));
+ }
+
+ try {
+ stream.close();
+
+ } catch (IOException ex) {
+ logger.warn("", ex);
+ }
+
+ if (oddrUaDeviceBuilderPatchStreams != null) {
+ for (int i = 0; i < oddrUaDeviceBuilderPatchStreams.length; i++) {
+ stream = oddrUaDeviceBuilderPatchStreams[i];
+
+ try {
+ parser = SAXParserFactory.newInstance().newSAXParser();
+
+ } catch (ParserConfigurationException ex) {
+ throw new InitializationException(InitializationException.INITIALIZATION_ERROR, new IllegalStateException("Can not instantiate SAXParserFactory.newInstance().newSAXParser()"));
+
+ } catch (SAXException ex) {
+ throw new InitializationException(InitializationException.INITIALIZATION_ERROR, new IllegalStateException("Can not instantiate SAXParserFactory.newInstance().newSAXParser()"));
+ }
+
+ try {
+ parser.parse(stream, deviceBuilderHandler);
+
+ } catch (Exception ex) {
+ throw new InitializationException(InitializationException.INITIALIZATION_ERROR, new RuntimeException("Can not parse DeviceBuilder input stream " + i));
+ }
+
+ try {
+ stream.close();
+
+ } catch (IOException ex) {
+ logger.warn("", ex);
+ }
+ }
+
+ } else {
+ for (int i = 0; i < oddrUaDeviceBuilderPatchPathArray.length; i++) {
+ try {
+ stream = new FileInputStream(new File(oddrUaDeviceBuilderPatchPathArray[i]));
+
+ } catch (IOException ex) {
+ throw new InitializationException(InitializationException.INITIALIZATION_ERROR, new IllegalArgumentException("Can not open " + ODDR_UA_DEVICE_BUILDER_PATCH_PATHS_PROP + " " + oddrUaDeviceBuilderPatchPathArray[i]));
+ }
+
+ try {
+ parser = SAXParserFactory.newInstance().newSAXParser();
+
+ } catch (ParserConfigurationException ex) {
+ throw new InitializationException(InitializationException.INITIALIZATION_ERROR, new IllegalStateException("Can not instantiate SAXParserFactory.newInstance().newSAXParser()"));
+
+ } catch (SAXException ex) {
+ throw new InitializationException(InitializationException.INITIALIZATION_ERROR, new IllegalStateException("Can not instantiate SAXParserFactory.newInstance().newSAXParser()"));
+ }
+
+ try {
+ parser.parse(stream, deviceBuilderHandler);
+
+ } catch (SAXException ex) {
+ throw new InitializationException(InitializationException.INITIALIZATION_ERROR, new RuntimeException("Can not parse document: " + oddrUaDeviceBuilderPatchPathArray[i]));
+
+ } catch (IOException ex) {
+ throw new InitializationException(InitializationException.INITIALIZATION_ERROR, new RuntimeException("Can not open " + ODDR_UA_DEVICE_DATASOURCE_PATH_PROP + " :" + oddrUaDeviceBuilderPatchPathArray[i]));
+ }
+
+ try {
+ stream.close();
+
+ } catch (IOException ex) {
+ logger.warn("", ex);
+ }
+ }
+ }
+
+ BrowserDatasourceHandler browserDatasourceHandler = new BrowserDatasourceHandler(vocabularyHolder);
+
+ try {
+ if (oddrUaBrowserDatasourceStream != null) {
+ stream = oddrUaBrowserDatasourceStream;
+ } else {
+ stream = new FileInputStream(new File(oddrUaBrowserDatasourcePaths));
+ }
+
+ } catch (IOException ex) {
+ throw new InitializationException(InitializationException.INITIALIZATION_ERROR, new IllegalArgumentException("Can not open " + ODDR_UA_BROWSER_DATASOURCE_PATH_PROP + " " + oddrUaBrowserDatasourcePaths));
+ }
+
+ try {
+ parser = SAXParserFactory.newInstance().newSAXParser();
+
+ } catch (ParserConfigurationException ex) {
+ throw new InitializationException(InitializationException.INITIALIZATION_ERROR, new IllegalStateException("Can not instantiate SAXParserFactory.newInstance().newSAXParser()"));
+
+ } catch (SAXException ex) {
+ throw new InitializationException(InitializationException.INITIALIZATION_ERROR, new IllegalStateException("Can not instantiate SAXParserFactory.newInstance().newSAXParser()"));
+ }
+
+ try {
+ parser.parse(stream, browserDatasourceHandler);
+
+ } catch (SAXException ex) {
+ throw new InitializationException(InitializationException.INITIALIZATION_ERROR, new RuntimeException("Can not parse document: " + oddrUaBrowserDatasourcePaths));
+
+ } catch (IOException ex) {
+ throw new InitializationException(InitializationException.INITIALIZATION_ERROR, new RuntimeException("Can not open " + ODDR_UA_BROWSER_DATASOURCE_PATH_PROP + " :" + oddrUaBrowserDatasourcePaths));
+ }
+
+ try {
+ stream.close();
+
+ } catch (IOException ex) {
+ logger.warn("", ex);
+ }
+
+ OperatingSystemDatasourceHandler operatingSystemDatasourceHandler = new OperatingSystemDatasourceHandler(vocabularyHolder);
+
+ try {
+ if (oddrUaOperatingSystemDatasourceStream != null) {
+ stream = oddrUaOperatingSystemDatasourceStream;
+ } else {
+ stream = new FileInputStream(new File(oddrUaOperatingSystemDatasourcePaths));
+ }
+
+ } catch (IOException ex) {
+ throw new InitializationException(InitializationException.INITIALIZATION_ERROR, new IllegalArgumentException("Can not open " + ODDR_UA_OPERATINGSYSTEM_DATASOURCE_PATH_PROP + " " + oddrUaOperatingSystemDatasourcePaths));
+ }
+
+ try {
+ parser = SAXParserFactory.newInstance().newSAXParser();
+
+ } catch (ParserConfigurationException ex) {
+ throw new InitializationException(InitializationException.INITIALIZATION_ERROR, new IllegalStateException("Can not instantiate SAXParserFactory.newInstance().newSAXParser()"));
+
+ } catch (SAXException ex) {
+ throw new InitializationException(InitializationException.INITIALIZATION_ERROR, new IllegalStateException("Can not instantiate SAXParserFactory.newInstance().newSAXParser()"));
+ }
+
+ try {
+ parser.parse(stream, operatingSystemDatasourceHandler);
+
+ } catch (SAXException ex) {
+ throw new InitializationException(InitializationException.INITIALIZATION_ERROR, new RuntimeException("Can not parse document: " + oddrUaOperatingSystemDatasourcePaths));
+
+ } catch (IOException ex) {
+ throw new InitializationException(InitializationException.INITIALIZATION_ERROR, new RuntimeException("Can not open " + ODDR_UA_OPERATINGSYSTEM_DATASOURCE_PATH_PROP + " :" + oddrUaOperatingSystemDatasourcePaths));
+ }
+
+ try {
+ stream.close();
+
+ } catch (IOException ex) {
+ logger.warn("", ex);
+ }
+
+ deviceIdentificator = new DeviceIdentificator(deviceBuilderHandler.getBuilders(), deviceDatasourceHandler.getDevices());
+ deviceIdentificator.completeInit();
+
+ browserIdentificator = new BrowserIdentificator(new Builder[]{DefaultBrowserBuilder.getInstance()}, browserDatasourceHandler.getBrowsers());
+ browserIdentificator.completeInit();
+
+ osIdentificator = new OSIdentificator(new Builder[]{DefaultOSBuilder.getInstance()}, operatingSystemDatasourceHandler.getOperatingSystems());
+ osIdentificator.completeInit();
+
+ deviceDatasourceHandler = null;
+ deviceBuilderHandler = null;
+ browserDatasourceHandler = null;
+ operatingSystemDatasourceHandler = null;
+
+ this.defaultVocabularyIRI = defaultVocabularyIRI;
+
+ parser = null;
+
+ oddrVocabularyService = null;
+
+ return;
+ }
+
+ public String getAPIVersion() {
+ return ODDR_API_VERSION;
+ }
+
+ public String getDataVersion() {
+ return ODDR_DATA_VERSION;
+ }
+
+ public PropertyRef[] listPropertyRefs() {
+ List<PropertyRef> propertyRefsList = new ArrayList<PropertyRef>();
+ Map<String, Vocabulary> vocabularies = vocabularyHolder.getVocabularies();
+ Set<String> vocabularyKeys = vocabularies.keySet();
+
+ for (String vocabularyKey : vocabularyKeys) {
+ Vocabulary vocabulary = vocabularies.get(vocabularyKey);
+ Map<String, VocabularyProperty> properties = vocabulary.getProperties();
+ Set<String> propertyKeys = properties.keySet();
+ for (String propertyKey : propertyKeys) {
+ PropertyName propertyName = new ODDRPropertyName(propertyKey, vocabularyKey);
+ for (int i = 0; i < properties.get(propertyKey).getAspects().length; i++) {
+ PropertyRef propertyRef = new ODDRPropertyRef(propertyName, properties.get(propertyKey).getAspects()[i]);
+ propertyRefsList.add(propertyRef);
+ }
+ }
+ }
+
+ PropertyRef[] propertyRefs = new PropertyRef[propertyRefsList.size()];
+ propertyRefs = propertyRefsList.toArray(propertyRefs);
+
+ return propertyRefs;
+ }
+
+ public PropertyValue getPropertyValue(Evidence evdnc, PropertyRef pr) throws NameException {
+ return getPropertyValues(evdnc, new PropertyRef[]{pr}).getValue(pr);
+ }
+
+ public PropertyValue getPropertyValue(Evidence evdnc, String localPropertyName, String localAspectName, String vocabularyIRI) throws NameException {
+ return getPropertyValue(evdnc, newPropertyRef(newPropertyName(localPropertyName, vocabularyIRI), localAspectName));
+ }
+
+ public PropertyValue getPropertyValue(Evidence evdnc, PropertyName pn) throws NameException {
+ return getPropertyValue(evdnc, newPropertyRef(pn));
+ }
+
+ public PropertyValue getPropertyValue(Evidence evdnc, String localPropertyName) throws NameException {
+ return getPropertyValue(evdnc, newPropertyName(localPropertyName));
+ }
+
+ public PropertyValues getPropertyValues(Evidence evdnc) {
+ Device deviceFound = null;
+ Browser browserFound = null;
+ OperatingSystem osFound = null;
+ boolean deviceIdentified = false;
+ boolean browserIdentified = false;
+ boolean osIdentified = false;
+ UserAgent deviceUA = null;
+ UserAgent browserUA = null;
+
+ JexlEngine jexl = new JexlEngine();
+ ODDRPropertyValues ret = new ODDRPropertyValues();
+ Map<String, Vocabulary> vocabularies = vocabularyHolder.getVocabularies();
+ Set<String> vocabularyKeys = vocabularies.keySet();
+
+ for (String vocabularyKey : vocabularyKeys) {
+ Vocabulary vocabulary = vocabularies.get(vocabularyKey);
+ Map<String, VocabularyProperty> properties = vocabulary.getProperties();
+ Set<String> propertyKeys = properties.keySet();
+ for (String propertyKey : propertyKeys) {
+ PropertyName propertyName = new ODDRPropertyName(propertyKey, vocabularyKey);
+ for (int i = 0; i < properties.get(propertyKey).getAspects().length; i++) {
+ PropertyRef propertyRef = new ODDRPropertyRef(propertyName, properties.get(propertyKey).getAspects()[i]);
+ if (ASPECT_DEVICE.equals(propertyRef.getAspectName())) {
+ if (!deviceIdentified) {
+ if (deviceUA == null) {
+ deviceUA = UserAgentFactory.newDeviceUserAgent(evdnc);
+ }
+ if (evdnc instanceof BufferedODDRHTTPEvidence) {
+ deviceFound = ((BufferedODDRHTTPEvidence) evdnc).getDeviceFound();
+ }
+ if (deviceFound == null) {
+ deviceFound = deviceIdentificator.get(deviceUA, this.threshold);
+ }
+ if (evdnc instanceof BufferedODDRHTTPEvidence) {
+ ((BufferedODDRHTTPEvidence) evdnc).setDeviceFound(deviceFound);
+ }
+ deviceIdentified = true;
+ }
+ String property = null;
+ if (deviceFound != null) {
+ property = deviceFound.get(propertyRef.getLocalPropertyName());
+ ret.addProperty(new ODDRPropertyValue(property, properties.get(propertyKey).getType(), propertyRef));
+
+ } else {
+ ret.addProperty(new ODDRPropertyValue(null, properties.get(propertyKey).getType(), propertyRef));
+ }
+ continue;
+
+ } else if (ASPECT_WEB_BROWSER.equals(propertyRef.getAspectName())) {
+ if (!browserIdentified) {
+ if (browserUA == null) {
+ browserUA = UserAgentFactory.newBrowserUserAgent(evdnc);
+ }
+ if (evdnc instanceof BufferedODDRHTTPEvidence) {
+ browserFound = ((BufferedODDRHTTPEvidence) evdnc).getBrowserFound();
+ }
+ if (browserFound == null) {
+ browserFound = browserIdentificator.get(browserUA, this.threshold);
+ }
+ if (evdnc instanceof BufferedODDRHTTPEvidence) {
+ ((BufferedODDRHTTPEvidence) evdnc).setBrowserFound(browserFound);
+ }
+
+ browserIdentified = true;
+ }
+ String property = null;
+ if (browserFound != null) {
+ property = browserFound.get(propertyRef.getLocalPropertyName());
+ ret.addProperty(new ODDRPropertyValue(property, properties.get(propertyKey).getType(), propertyRef));
+
+ } else {
+ ret.addProperty(new ODDRPropertyValue(null, properties.get(propertyKey).getType(), propertyRef));
+ }
+ continue;
+
+ } else if (ASPECT_OPERATIVE_SYSTEM.equals(propertyRef.getAspectName())) {
+ if (!osIdentified) {
+ if (deviceUA == null) {
+ deviceUA = UserAgentFactory.newDeviceUserAgent(evdnc);
+ }
+ if (evdnc instanceof BufferedODDRHTTPEvidence) {
+ osFound = ((BufferedODDRHTTPEvidence) evdnc).getOsFound();
+ }
+ if (osFound == null) {
+ osFound = osIdentificator.get(deviceUA, this.threshold);
+ }
+ if (evdnc instanceof BufferedODDRHTTPEvidence) {
+ ((BufferedODDRHTTPEvidence) evdnc).setOsFound(osFound);
+ }
+
+ osIdentified = true;
+ }
+ String property = null;
+ if (osFound != null) {
+ property = osFound.get(propertyRef.getLocalPropertyName());
+ ret.addProperty(new ODDRPropertyValue(property, properties.get(propertyKey).getType(), propertyRef));
+
+ } else {
+ ret.addProperty(new ODDRPropertyValue(null, properties.get(propertyKey).getType(), propertyRef));
+ }
+ continue;
+
+ } else if (ASPECT_GROUP.equals(propertyRef.getAspectName())) {
+ try {
+ String jexlExp = properties.get(propertyKey).getExpr();
+ Matcher m = groupRegexprPattern.matcher(jexlExp);
+ while (m.find()) {
+ String id = m.group(1);
+ String propertyValueString = null;
+ PropertyValue propertyValue = getPropertyValue(evdnc, vocabulary.getVocabularyVariables().get(id).getName(), vocabulary.getVocabularyVariables().get(id).getAspect(), vocabulary.getVocabularyVariables().get(id).getVocabulary());
+ propertyValueString = (propertyValue.exists() ? propertyValue.getString() : "-");
+ String toReplace = "$" + id;
+ jexlExp = jexlExp.replaceAll(Matcher.quoteReplacement(toReplace), "'" + propertyValueString + "'");
+ }
+ Expression e = jexl.createExpression(jexlExp);
+ JexlContext jc = new MapContext();
+ Object o = e.evaluate(jc);
+ ret.addProperty(new ODDRPropertyValue(o.toString(), properties.get(propertyKey).getType(), propertyRef));
+
+ } catch (Exception ex) {
+ throw new RuntimeException(ex);
+ }
+ }
+ }
+ }
+ }
+
+ return ret;
+ }
+
+ public PropertyValues getPropertyValues(Evidence evdnc, PropertyRef[] prs) throws NameException {
+ Device deviceFound = null;
+ Browser browserFound = null;
+ OperatingSystem osFound = null;
+ boolean deviceIdentified = false;
+ boolean browserIdentified = false;
+ boolean osIdentified = false;
+ UserAgent deviceUA = null;
+ UserAgent browserUA = null;
+
+ JexlEngine jexl = new JexlEngine();
+ ODDRPropertyValues ret = new ODDRPropertyValues();
+ Map<String, Vocabulary> vocabularies = vocabularyHolder.getVocabularies();
+
+ for (PropertyRef propertyRef : prs) {
+ VocabularyProperty vocabularyProperty = vocabularyHolder.existProperty(propertyRef.getLocalPropertyName(), propertyRef.getAspectName(), propertyRef.getNamespace());
+ Vocabulary vocabulary = vocabularies.get(propertyRef.getNamespace());
+ if (ASPECT_DEVICE.equals(propertyRef.getAspectName())) {
+ if (!deviceIdentified) {
+ if (deviceUA == null) {
+ deviceUA = UserAgentFactory.newDeviceUserAgent(evdnc);
+ }
+ if (evdnc instanceof BufferedODDRHTTPEvidence) {
+ deviceFound = ((BufferedODDRHTTPEvidence) evdnc).getDeviceFound();
+ }
+ if (deviceFound == null) {
+ deviceFound = deviceIdentificator.get(deviceUA, this.threshold);
+ }
+ if (evdnc instanceof BufferedODDRHTTPEvidence) {
+ ((BufferedODDRHTTPEvidence) evdnc).setDeviceFound(deviceFound);
+ }
+
+ deviceIdentified = true;
+ }
+ String property = null;
+
+ if (deviceFound != null) {
+ property = deviceFound.get(propertyRef.getLocalPropertyName());
+ ret.addProperty(new ODDRPropertyValue(property, vocabularyProperty.getType(), propertyRef));
+
+ } else {
+ ret.addProperty(new ODDRPropertyValue(null, vocabularyProperty.getType(), propertyRef));
+ }
+ continue;
+
+ } else if (ASPECT_WEB_BROWSER.equals(propertyRef.getAspectName())) {
+ //TODO: evaluate ua-pixels header in evidence
+ if (!browserIdentified) {
+ if (browserUA == null) {
+ browserUA = UserAgentFactory.newBrowserUserAgent(evdnc);
+ }
+ if (evdnc instanceof BufferedODDRHTTPEvidence) {
+ browserFound = ((BufferedODDRHTTPEvidence) evdnc).getBrowserFound();
+ }
+ if (browserFound == null) {
+ browserFound = browserIdentificator.get(browserUA, this.threshold);
+ }
+ if (evdnc instanceof BufferedODDRHTTPEvidence) {
+ ((BufferedODDRHTTPEvidence) evdnc).setBrowserFound(browserFound);
+ }
+ browserIdentified = true;
+ }
+ String property = null;
+ if (browserFound != null) {
+ property = browserFound.get(propertyRef.getLocalPropertyName());
+ ret.addProperty(new ODDRPropertyValue(property, vocabularyProperty.getType(), propertyRef));
+
+ } else {
+ ret.addProperty(new ODDRPropertyValue(null, vocabularyProperty.getType(), propertyRef));
+ }
+ continue;
+
+ } else if (ASPECT_OPERATIVE_SYSTEM.equals(propertyRef.getAspectName())) {
+ //TODO: evaluate ua-os header in evidence
+ if (!osIdentified) {
+ if (deviceUA == null) {
+ deviceUA = UserAgentFactory.newDeviceUserAgent(evdnc);
+ }
+ if (evdnc instanceof BufferedODDRHTTPEvidence) {
+ osFound = ((BufferedODDRHTTPEvidence) evdnc).getOsFound();
+ }
+ if (osFound == null) {
+ osFound = osIdentificator.get(deviceUA, this.threshold);
+ }
+ if (evdnc instanceof BufferedODDRHTTPEvidence) {
+ ((BufferedODDRHTTPEvidence) evdnc).setOsFound(osFound);
+ }
+ osIdentified = true;
+ }
+ String property = null;
+ if (osFound != null) {
+ property = osFound.get(propertyRef.getLocalPropertyName());
+ ret.addProperty(new ODDRPropertyValue(property, vocabularyProperty.getType(), propertyRef));
+
+ } else {
+ ret.addProperty(new ODDRPropertyValue(null, vocabularyProperty.getType(), propertyRef));
+ }
+ continue;
+
+ } else if (ASPECT_GROUP.equals(propertyRef.getAspectName())) {
+ try {
+ String jexlExp = vocabularyProperty.getExpr();
+ Matcher m = groupRegexprPattern.matcher(jexlExp);
+ while (m.find()) {
+ String id = m.group(1);
+ String propertyValueString = null;
+ PropertyValue propertyValue = getPropertyValue(evdnc, vocabulary.getVocabularyVariables().get(id).getName(), vocabulary.getVocabularyVariables().get(id).getAspect(), vocabulary.getVocabularyVariables().get(id).getVocabulary());
+ propertyValueString = (propertyValue.exists() ? propertyValue.getString() : "-");
+ String toReplace = "$" + id;
+ jexlExp = jexlExp.replaceAll(Matcher.quoteReplacement(toReplace), "'" + propertyValueString + "'");
+ }
+ Expression e = jexl.createExpression(jexlExp);
+ JexlContext jc = new MapContext();
+ Object o = e.evaluate(jc);
+ ret.addProperty(new ODDRPropertyValue(o.toString(), vocabularyProperty.getType(), propertyRef));
+
+ } catch (Exception ex) {
+ throw new RuntimeException(ex);
+ }
+ }
+ }
+
+ return ret;
+ }
+
+ public PropertyValues getPropertyValues(Evidence evdnc, String localAspectName) throws NameException {
+ return getPropertyValues(evdnc, localAspectName, defaultVocabularyIRI);
+ }
+
+ public PropertyValues getPropertyValues(Evidence evdnc, String localAspectName, String vocabularyIRI) throws NameException {
+ VocabularyProperty vocabularyProperty = vocabularyHolder.existProperty(localAspectName, null, vocabularyIRI);
+
+ PropertyName propertyName = new ODDRPropertyName(localAspectName, vocabularyIRI);
+ PropertyRef propertyRef = new ODDRPropertyRef(propertyName, vocabularyProperty.getDefaultAspect());
+
+ return getPropertyValues(evdnc, new PropertyRef[]{propertyRef});
+ }
+
+ public PropertyName newPropertyName(String localPropertyName, String vocabularyIRI) throws NameException {
+ vocabularyHolder.existProperty(localPropertyName, null, vocabularyIRI);
+ return new ODDRPropertyName(localPropertyName, vocabularyIRI);
+ }
+
+ public PropertyName newPropertyName(String localPropertyName) throws NameException {
+ return newPropertyName(localPropertyName, defaultVocabularyIRI);
+ }
+
+ public PropertyRef newPropertyRef(PropertyName pn, String localAspectName) throws NameException {
+ vocabularyHolder.existProperty(pn.getLocalPropertyName(), localAspectName, pn.getNamespace());
+ return new ODDRPropertyRef(pn, localAspectName);
+ }
+
+ public PropertyRef newPropertyRef(PropertyName pn) throws NameException {
+ VocabularyProperty vocabularyProperty = vocabularyHolder.existProperty(pn.getLocalPropertyName(), null, pn.getNamespace());
+ return newPropertyRef(pn, vocabularyProperty.getDefaultAspect());
+ }
+
+ public PropertyRef newPropertyRef(String localPropertyName) throws NameException {
+ return newPropertyRef(newPropertyName(localPropertyName));
+ }
+
+ public Evidence newHTTPEvidence() {
+ return new ODDRHTTPEvidence();
+ }
+
+ public Evidence newHTTPEvidence(Map<String, String> map) {
+ return new ODDRHTTPEvidence(map);
+ }
+}
Added: incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/ODDRVocabularyService.java
URL: http://svn.apache.org/viewvc/incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/ODDRVocabularyService.java?rev=1580679&view=auto
==============================================================================
--- incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/ODDRVocabularyService.java (added)
+++ incubator/devicemap/trunk/devicemap/java/simpleddr/src/main/java/org/apache/devicemap/simpleddr/ODDRVocabularyService.java Mon Mar 24 00:52:47 2014
@@ -0,0 +1,211 @@
+/**
+ * Copyright 2011 OpenDDR LLC
+ * This software is distributed under the terms of the GNU Lesser General Public License.
+ *
+ *
+ * This file is part of OpenDDR Simple APIs.
+ * OpenDDR Simple APIs is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published by
+ * the Free Software Foundation, version 3 of the License.
+ *
+ * OpenDDR Simple APIs is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ *
+ * GNU Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with Simple APIs. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+package org.apache.devicemap.simpleddr;
+
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.Properties;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+import javax.xml.parsers.ParserConfigurationException;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+import org.apache.devicemap.simpleddr.documenthandler.VocabularyHandler;
+import org.apache.devicemap.simpleddr.model.vocabulary.Vocabulary;
+import org.apache.devicemap.simpleddr.vocabulary.VocabularyHolder;
+import org.w3c.ddr.simple.exception.InitializationException;
+import org.xml.sax.SAXException;
+
+public class ODDRVocabularyService {
+
+ public static final String DDR_CORE_VOCABULARY_PATH_PROP = "ddr.vocabulary.core.path";
+ public static final String ODDR_VOCABULARY_PATH_PROP = "oddr.vocabulary.path";
+ public static final String ODDR_LIMITED_VOCABULARY_PATH_PROP = "oddr.limited.vocabulary.path";
+ public static final String DDR_CORE_VOCABULARY_STREAM_PROP = "ddr.vocabulary.core.stream";
+ public static final String ODDR_VOCABULARY_STREAM_PROP = "oddr.vocabulary.stream";
+ public static final String ODDR_LIMITED_VOCABULARY_STREAM_PROP = "oddr.limited.vocabulary.stream";
+ public static final String ODDR_LIMITED_VOCABULARY_IRI = "limitedVocabulary";
+ private VocabularyHolder vocabularyHolder = null;
+
+ public void initialize(Properties props) throws InitializationException {
+ Map<String, Vocabulary> vocabularies = new HashMap<String, Vocabulary>();
+
+ String ddrCoreVocabularyPath = props.getProperty(DDR_CORE_VOCABULARY_PATH_PROP);
+ String oddrVocabularyPath = props.getProperty(ODDR_VOCABULARY_PATH_PROP);
+
+ InputStream ddrCoreVocabulayStream = null;
+ InputStream[] oddrVocabularyStream = null;
+ try {
+ ddrCoreVocabulayStream = (InputStream) props.get(DDR_CORE_VOCABULARY_STREAM_PROP);
+ } catch (Exception ex) {
+ ddrCoreVocabulayStream = null;
+ }
+ try {
+ oddrVocabularyStream = (InputStream[]) props.get(ODDR_VOCABULARY_STREAM_PROP);
+ } catch (Exception ex) {
+ oddrVocabularyStream = null;
+ }
+
+ if ((ddrCoreVocabularyPath == null || ddrCoreVocabularyPath.trim().length() == 0) && ddrCoreVocabulayStream == null) {
+ throw new InitializationException(InitializationException.INITIALIZATION_ERROR, new IllegalArgumentException("Can not find property " + DDR_CORE_VOCABULARY_PATH_PROP));
+ }
+
+ if ((oddrVocabularyPath == null || oddrVocabularyPath.trim().length() == 0) && oddrVocabularyStream == null) {
+ throw new InitializationException(InitializationException.INITIALIZATION_ERROR, new IllegalArgumentException("Can not find property " + ODDR_VOCABULARY_PATH_PROP));
+ }
+
+ VocabularyHandler vocabularyHandler = new VocabularyHandler();
+ Vocabulary vocabulary = null;
+
+ if (ddrCoreVocabulayStream != null) {
+ parseVocabularyFromStream(vocabularyHandler, DDR_CORE_VOCABULARY_STREAM_PROP, ddrCoreVocabulayStream);
+ } else {
+ parseVocabularyFromPath(vocabularyHandler, DDR_CORE_VOCABULARY_PATH_PROP, ddrCoreVocabularyPath);
+ }
+ vocabulary = vocabularyHandler.getVocabulary();
+ vocabularies.put(vocabulary.getVocabularyIRI(), vocabulary);
+
+ if (oddrVocabularyStream != null) {
+ for (InputStream stream : oddrVocabularyStream) {
+ vocabularyHandler = new VocabularyHandler();
+ parseVocabularyFromStream(vocabularyHandler, ODDR_VOCABULARY_STREAM_PROP, stream);
+ vocabulary = vocabularyHandler.getVocabulary();
+ vocabularies.put(vocabulary.getVocabularyIRI(), vocabulary);
+ }
+ } else {
+ String[] oddrVocabularyPaths = oddrVocabularyPath.split(",");
+ for (int i = 0; i < oddrVocabularyPaths.length; i++) {
+ oddrVocabularyPaths[i] = oddrVocabularyPaths[i].trim();
+ }
+ for (String oddVocabularyString : oddrVocabularyPaths) {
+ vocabularyHandler = new VocabularyHandler();
+ parseVocabularyFromPath(vocabularyHandler, ODDR_VOCABULARY_PATH_PROP, oddVocabularyString);
+ vocabulary = vocabularyHandler.getVocabulary();
+ vocabularies.put(vocabulary.getVocabularyIRI(), vocabulary);
+ }
+ }
+
+ String oddrLimitedVocabularyPath = props.getProperty(ODDR_LIMITED_VOCABULARY_PATH_PROP);
+ InputStream oddrLimitedVocabularyStream = (InputStream)props.get(ODDR_LIMITED_VOCABULARY_STREAM_PROP);
+
+ if (oddrLimitedVocabularyStream != null) {
+ parseVocabularyFromStream(vocabularyHandler, ODDR_LIMITED_VOCABULARY_STREAM_PROP, oddrLimitedVocabularyStream);
+
+ } else {
+ if (oddrLimitedVocabularyPath != null && oddrLimitedVocabularyPath.trim().length() != 0) {
+ vocabularyHandler = new VocabularyHandler();
+ parseVocabularyFromPath(vocabularyHandler, ODDR_LIMITED_VOCABULARY_PATH_PROP, oddrLimitedVocabularyPath);
+ }
+ }
+ vocabulary = vocabularyHandler.getVocabulary();
+ vocabularies.put(ODDR_LIMITED_VOCABULARY_IRI, vocabulary);
+
+ vocabularyHolder = new VocabularyHolder(vocabularies);
+
+ vocabularyHandler = null;
+ vocabularies = null;
+
+ }
+
+ private void parseVocabularyFromPath(VocabularyHandler vocabularyHandler, String prop, String path) throws InitializationException {
+ InputStream stream = null;
+ SAXParser parser = null;
+
+ try {
+ stream = new FileInputStream(new File(path));
+
+ } catch (IOException ex) {
+ throw new InitializationException(InitializationException.INITIALIZATION_ERROR, new IllegalArgumentException("Can not open " + prop + " : " + path));
+ }
+
+ try {
+ parser = SAXParserFactory.newInstance().newSAXParser();
+
+ } catch (ParserConfigurationException ex) {
+ throw new InitializationException(InitializationException.INITIALIZATION_ERROR, new IllegalStateException("Can not instantiate SAXParserFactory.newInstance().newSAXParser()"));
+
+ } catch (SAXException ex) {
+ throw new InitializationException(InitializationException.INITIALIZATION_ERROR, new IllegalStateException("Can not instantiate SAXParserFactory.newInstance().newSAXParser()"));
+ }
+
+ try {
+ parser.parse(stream, vocabularyHandler);
+
+ } catch (SAXException ex) {
+ throw new InitializationException(InitializationException.INITIALIZATION_ERROR, new RuntimeException("Can not parse document: " + path));
+
+ } catch (IOException ex) {
+ throw new InitializationException(InitializationException.INITIALIZATION_ERROR, new RuntimeException("Can not open " + prop + " : " + path));
+ }
+
+ try {
+ stream.close();
+
+ } catch (IOException ex) {
+ Logger.getLogger(ODDRService.class.getName()).log(Level.WARNING, null, ex);
+ }
+
+ parser = null;
+ }
+
+ private void parseVocabularyFromStream(VocabularyHandler vocabularyHandler, String prop, InputStream inputStream) throws InitializationException {
+ InputStream stream = null;
+ SAXParser parser = null;
+ stream = inputStream;
+
+ try {
+ parser = SAXParserFactory.newInstance().newSAXParser();
+
+ } catch (ParserConfigurationException ex) {
+ throw new InitializationException(InitializationException.INITIALIZATION_ERROR, new IllegalStateException("Can not instantiate SAXParserFactory.newInstance().newSAXParser()"));
+
+ } catch (SAXException ex) {
+ throw new InitializationException(InitializationException.INITIALIZATION_ERROR, new IllegalStateException("Can not instantiate SAXParserFactory.newInstance().newSAXParser()"));
+ }
+
+ try {
+ parser.parse(stream, vocabularyHandler);
+
+ } catch (SAXException ex) {
+ throw new InitializationException(InitializationException.INITIALIZATION_ERROR, new RuntimeException("Can not parse document in property: " + prop));
+
+ } catch (IOException ex) {
+ throw new InitializationException(InitializationException.INITIALIZATION_ERROR, new RuntimeException("Can not open " + prop));
+ }
+
+ try {
+ stream.close();
+
+ } catch (IOException ex) {
+ Logger.getLogger(ODDRService.class.getName()).log(Level.WARNING, null, ex);
+ }
+
+ parser = null;
+ }
+
+ public VocabularyHolder getVocabularyHolder() {
+ return vocabularyHolder;
+ }
+}