Author: wkeil
Date: Mon Mar 17 02:08:18 2014
New Revision: 1578205

URL: http://svn.apache.org/r1578205
Log:
Updated Examples

Added:
    incubator/devicemap/trunk/examples/web-filter/src/main/java/
    incubator/devicemap/trunk/examples/web-filter/src/main/java/org/
    incubator/devicemap/trunk/examples/web-filter/src/main/java/org/apache/
    
incubator/devicemap/trunk/examples/web-filter/src/main/java/org/apache/devicemap/
    
incubator/devicemap/trunk/examples/web-filter/src/main/java/org/apache/devicemap/example/
    
incubator/devicemap/trunk/examples/web-filter/src/main/java/org/apache/devicemap/example/webfilter/
    
incubator/devicemap/trunk/examples/web-filter/src/main/java/org/apache/devicemap/example/webfilter/ClassificationFilter.java
    
incubator/devicemap/trunk/examples/web-filter/src/main/java/org/apache/devicemap/example/webfilter/package-info.java
    incubator/devicemap/trunk/examples/web-filter/src/main/webapp/WEB-INF/lib/
    
incubator/devicemap/trunk/examples/web-filter/src/main/webapp/WEB-INF/lib/DDR-Simple-API.jar
   (with props)
    incubator/devicemap/trunk/examples/web-filter/src/test/
    incubator/devicemap/trunk/examples/web-filter/src/test/java/
Modified:
    incubator/devicemap/trunk/examples/web-filter/.classpath
    incubator/devicemap/trunk/examples/web-filter/pom.xml

Modified: incubator/devicemap/trunk/examples/web-filter/.classpath
URL: 
http://svn.apache.org/viewvc/incubator/devicemap/trunk/examples/web-filter/.classpath?rev=1578205&r1=1578204&r2=1578205&view=diff
==============================================================================
--- incubator/devicemap/trunk/examples/web-filter/.classpath (original)
+++ incubator/devicemap/trunk/examples/web-filter/.classpath Mon Mar 17 
02:08:18 2014
@@ -6,11 +6,6 @@
                        <attribute name="maven.pomderived" value="true"/>
                </attributes>
        </classpathentry>
-       <classpathentry excluding="**" kind="src" output="target/classes" 
path="src/main/resources">
-               <attributes>
-                       <attribute name="maven.pomderived" value="true"/>
-               </attributes>
-       </classpathentry>
        <classpathentry kind="src" output="target/test-classes" 
path="src/test/java">
                <attributes>
                        <attribute name="optional" value="true"/>
@@ -23,10 +18,12 @@
                        <attribute name="org.eclipse.jst.component.dependency" 
value="/WEB-INF/lib"/>
                </attributes>
        </classpathentry>
-       <classpathentry kind="con" 
path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.4">
+       <classpathentry kind="con" 
path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6">
                <attributes>
-                       <attribute name="owner.project.facets" value="java"/>
+                       <attribute name="maven.pomderived" value="true"/>
                </attributes>
        </classpathentry>
+       <classpathentry kind="con" 
path="org.eclipse.jst.server.core.container/org.eclipse.jst.server.tomcat.runtimeTarget/Apache
 Tomcat v7.0"/>
+       <classpathentry kind="con" 
path="org.eclipse.jst.j2ee.internal.web.container"/>
        <classpathentry kind="output" path="target/classes"/>
 </classpath>

Modified: incubator/devicemap/trunk/examples/web-filter/pom.xml
URL: 
http://svn.apache.org/viewvc/incubator/devicemap/trunk/examples/web-filter/pom.xml?rev=1578205&r1=1578204&r2=1578205&view=diff
==============================================================================
--- incubator/devicemap/trunk/examples/web-filter/pom.xml (original)
+++ incubator/devicemap/trunk/examples/web-filter/pom.xml Mon Mar 17 02:08:18 
2014
@@ -1,24 +1,42 @@
 <?xml version="1.0"?>
-<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd"; 
xmlns="http://maven.apache.org/POM/4.0.0";
-    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
-  <modelVersion>4.0.0</modelVersion>
-  <parent>
-    <groupId>org.apache.devicemap.examples</groupId>
-    <artifactId>org.apache.devicemap.examples</artifactId>
-    <version>0.1.0-SNAPSHOT</version>
-  </parent>
-  <artifactId>org.apache.devicemap.examples.webfilter</artifactId>
-  <packaging>war</packaging>
-  <name>Apache DeviceMap Web Filter Example</name>
-  <dependencies>
-    <dependency>
-      <groupId>junit</groupId>
-      <artifactId>junit</artifactId>
-      <version>3.8.1</version>
-      <scope>test</scope>
-    </dependency>
-  </dependencies>
-  <build>
-    <finalName>devicemap-web-filter</finalName>
-  </build>
+<project
+       xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/xsd/maven-4.0.0.xsd";
+       xmlns="http://maven.apache.org/POM/4.0.0"; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance";>
+       <modelVersion>4.0.0</modelVersion>
+       <parent>
+               <groupId>org.apache.devicemap.examples</groupId>
+               <artifactId>org.apache.devicemap.examples</artifactId>
+               <version>0.1.0-SNAPSHOT</version>
+       </parent>
+       <artifactId>org.apache.devicemap.examples.webfilter</artifactId>
+       <packaging>war</packaging>
+       <name>Apache DeviceMap Web Filter Example</name>
+       <dependencies>
+               <dependency>
+                       <groupId>org.apache.devicemap</groupId>
+                       <artifactId>org.apache.devicemap.classifier</artifactId>
+                       <version>0.9.9-SNAPSHOT</version>
+               </dependency>
+               <dependency>
+                       <groupId>junit</groupId>
+                       <artifactId>junit</artifactId>
+                       <version>4.11</version>
+                       <scope>test</scope>
+               </dependency>
+       </dependencies>
+       <build>
+               <finalName>web-filter</finalName>
+               <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>
+        </plugins>
+       </build>
 </project>

Added: 
incubator/devicemap/trunk/examples/web-filter/src/main/java/org/apache/devicemap/example/webfilter/ClassificationFilter.java
URL: 
http://svn.apache.org/viewvc/incubator/devicemap/trunk/examples/web-filter/src/main/java/org/apache/devicemap/example/webfilter/ClassificationFilter.java?rev=1578205&view=auto
==============================================================================
--- 
incubator/devicemap/trunk/examples/web-filter/src/main/java/org/apache/devicemap/example/webfilter/ClassificationFilter.java
 (added)
+++ 
incubator/devicemap/trunk/examples/web-filter/src/main/java/org/apache/devicemap/example/webfilter/ClassificationFilter.java
 Mon Mar 17 02:08:18 2014
@@ -0,0 +1,106 @@
+package org.apache.devicemap.example.webfilter;
+
+import java.io.IOException;
+import java.util.Properties;
+import javax.servlet.Filter;
+import javax.servlet.FilterChain;
+import javax.servlet.FilterConfig;
+import javax.servlet.ServletContext;
+import javax.servlet.ServletException;
+import javax.servlet.ServletRequest;
+import javax.servlet.ServletResponse;
+import javax.servlet.http.HttpServletRequest;
+//import org.openddr.simpleapi.oddr.ODDRService;
+//import org.openddr.simpleapi.oddr.model.ODDRHTTPEvidence;
+import org.w3c.ddr.simple.Evidence;
+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.ServiceFactory;
+import org.w3c.ddr.simple.exception.NameException;
+import org.apache.devicemap.client.DeviceMapClient;
+
+/**
+ * Servlet Filter implementation class ClassificationFilter
+ */
+public class ClassificationFilter implements Filter {
+       private Service identificationService = null;
+       private DeviceMapClient client = null;
+       
+    /**
+     * Default constructor. 
+     */
+    public ClassificationFilter() {
+    }
+    
+       /**
+        * @see Filter#init(FilterConfig)
+        */
+       public void init(FilterConfig filterConfig) throws ServletException {
+            System.out.println("Initialize filter");
+               Properties initializationProperties = new Properties();
+               ServletContext context = filterConfig.getServletContext();      
          
+
+               try {
+                   
initializationProperties.load(context.getResourceAsStream("/WEB-INF/oddr.properties"));
+//                 identificationService = 
ServiceFactory.newService("org.openddr.simpleapi.oddr.ODDRService", 
initializationProperties.getProperty(ODDRService.ODDR_VOCABULARY_IRI), 
initializationProperties);
+                   client = new DeviceMapClient();
+                   
+               } catch (Exception ex) {
+                   throw new RuntimeException(ex);
+               }
+       }
+       /**
+        * @see Filter#destroy()
+        */
+       public void destroy() {
+               System.out.println("Destroy Filter");
+       }
+
+       /**
+        * @see Filter#doFilter(ServletRequest, ServletResponse, FilterChain)
+        */
+       public void doFilter(ServletRequest request, ServletResponse response, 
FilterChain chain) throws IOException, ServletException {
+        PropertyRef vendorRef;
+        PropertyRef modelRef;
+        PropertyRef displayWidthRef;
+        PropertyRef displayHeightRef;
+
+        try {
+            vendorRef = identificationService.newPropertyRef("vendor");
+            modelRef = identificationService.newPropertyRef("model");
+            displayWidthRef = 
identificationService.newPropertyRef("displayWidth");
+            displayHeightRef = 
identificationService.newPropertyRef("displayHeight");
+
+        } catch (NameException ex) {
+            throw new RuntimeException(ex);
+        }
+
+        PropertyRef[] propertyRefs = new PropertyRef[] {vendorRef, modelRef, 
displayWidthRef, displayHeightRef};
+        //Evidence e = new ODDRHTTPEvidence(); FIXME
+        //e.put("User-Agent", 
((HttpServletRequest)request).getHeader("User-Agent"));
+
+        try {
+            //PropertyValues propertyValues = 
identificationService.getPropertyValues(e, propertyRefs); FIXME
+//            PropertyValue vendor = propertyValues.getValue(vendorRef);
+//            PropertyValue model = propertyValues.getValue(modelRef);
+//            PropertyValue displayWidth = 
propertyValues.getValue(displayWidthRef);
+//            PropertyValue displayHeight = 
propertyValues.getValue(displayHeightRef);
+//
+//            if (vendor.exists() && model.exists() && displayWidth.exists() 
&& displayHeight.exists()) {
+//                ((HttpServletRequest)request).setAttribute("vendor", 
vendor.getString());
+//                ((HttpServletRequest)request).setAttribute("model", 
model.getString());
+//                ((HttpServletRequest)request).setAttribute("displayWidth", 
displayWidth.getInteger());
+//                ((HttpServletRequest)request).setAttribute("displayHeight", 
displayHeight.getInteger());
+//
+//            }
+
+        } catch (Exception ex) {
+            throw new RuntimeException(ex);
+        }
+
+        chain.doFilter(request, response);
+       }
+
+}

Added: 
incubator/devicemap/trunk/examples/web-filter/src/main/java/org/apache/devicemap/example/webfilter/package-info.java
URL: 
http://svn.apache.org/viewvc/incubator/devicemap/trunk/examples/web-filter/src/main/java/org/apache/devicemap/example/webfilter/package-info.java?rev=1578205&view=auto
==============================================================================
--- 
incubator/devicemap/trunk/examples/web-filter/src/main/java/org/apache/devicemap/example/webfilter/package-info.java
 (added)
+++ 
incubator/devicemap/trunk/examples/web-filter/src/main/java/org/apache/devicemap/example/webfilter/package-info.java
 Mon Mar 17 02:08:18 2014
@@ -0,0 +1,8 @@
+/**
+ * 
+ */
+/**
+ * @author Werner
+ *
+ */
+package org.apache.devicemap.example.webfilter;
\ No newline at end of file

Added: 
incubator/devicemap/trunk/examples/web-filter/src/main/webapp/WEB-INF/lib/DDR-Simple-API.jar
URL: 
http://svn.apache.org/viewvc/incubator/devicemap/trunk/examples/web-filter/src/main/webapp/WEB-INF/lib/DDR-Simple-API.jar?rev=1578205&view=auto
==============================================================================
Binary file - no diff available.

Propchange: 
incubator/devicemap/trunk/examples/web-filter/src/main/webapp/WEB-INF/lib/DDR-Simple-API.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream


Reply via email to