[dna-commits] DNA SVN: r145 - in trunk: dna-common and 36 other directories.

dna-commits at lists.jboss.org dna-commits at lists.jboss.org
Mon May 12 16:12:30 EDT 2008


Author: rhauch
Date: 2008-05-12 16:12:29 -0400 (Mon, 12 May 2008)
New Revision: 145

Added:
   trunk/docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencers/MediaInfo.java
   trunk/docs/examples/gettingstarted/sequencers/src/test/resources/sample1.mp3
   trunk/sequencers/dna-sequencer-mp3/
   trunk/sequencers/dna-sequencer-mp3/.classpath
   trunk/sequencers/dna-sequencer-mp3/.project
   trunk/sequencers/dna-sequencer-mp3/pom.xml
   trunk/sequencers/dna-sequencer-mp3/src/
   trunk/sequencers/dna-sequencer-mp3/src/main/
   trunk/sequencers/dna-sequencer-mp3/src/main/java/
   trunk/sequencers/dna-sequencer-mp3/src/main/java/org/
   trunk/sequencers/dna-sequencer-mp3/src/main/java/org/jboss/
   trunk/sequencers/dna-sequencer-mp3/src/main/java/org/jboss/dna/
   trunk/sequencers/dna-sequencer-mp3/src/main/java/org/jboss/dna/sequencer/
   trunk/sequencers/dna-sequencer-mp3/src/main/java/org/jboss/dna/sequencer/mp3/
   trunk/sequencers/dna-sequencer-mp3/src/main/java/org/jboss/dna/sequencer/mp3/Mp3Metadata.java
   trunk/sequencers/dna-sequencer-mp3/src/main/java/org/jboss/dna/sequencer/mp3/Mp3MetadataSequencer.java
   trunk/sequencers/dna-sequencer-mp3/src/main/resources/
   trunk/sequencers/dna-sequencer-mp3/src/main/resources/org/
   trunk/sequencers/dna-sequencer-mp3/src/main/resources/org/jboss/
   trunk/sequencers/dna-sequencer-mp3/src/main/resources/org/jboss/dna/
   trunk/sequencers/dna-sequencer-mp3/src/main/resources/org/jboss/dna/sequencer/
   trunk/sequencers/dna-sequencer-mp3/src/main/resources/org/jboss/dna/sequencer/mp3/
   trunk/sequencers/dna-sequencer-mp3/src/main/resources/org/jboss/dna/sequencer/mp3/mp3.cnd
   trunk/sequencers/dna-sequencer-mp3/src/test/
   trunk/sequencers/dna-sequencer-mp3/src/test/java/
   trunk/sequencers/dna-sequencer-mp3/src/test/java/org/
   trunk/sequencers/dna-sequencer-mp3/src/test/java/org/jboss/
   trunk/sequencers/dna-sequencer-mp3/src/test/java/org/jboss/dna/
   trunk/sequencers/dna-sequencer-mp3/src/test/java/org/jboss/dna/sequencer/
   trunk/sequencers/dna-sequencer-mp3/src/test/java/org/jboss/dna/sequencer/mp3/
   trunk/sequencers/dna-sequencer-mp3/src/test/java/org/jboss/dna/sequencer/mp3/Mp3MetadataTest.java
   trunk/sequencers/dna-sequencer-mp3/src/test/resources/
   trunk/sequencers/dna-sequencer-mp3/src/test/resources/sample1.mp3
Removed:
   trunk/docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencers/ImageInfo.java
   trunk/docs/examples/gettingstarted/sequencers/src/test/resources/log4j.properties
Modified:
   trunk/dna-common/
   trunk/dna-common/pom.xml
   trunk/dna-integration-tests/
   trunk/dna-maven-classloader/
   trunk/dna-maven-classloader/pom.xml
   trunk/dna-repository/
   trunk/dna-repository/pom.xml
   trunk/dna-spi/
   trunk/dna-spi/pom.xml
   trunk/docs/examples/gettingstarted/sequencers/pom.xml
   trunk/docs/examples/gettingstarted/sequencers/src/main/assembly/basic.xml
   trunk/docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencers/ConsoleInput.java
   trunk/docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencers/SequencingClient.java
   trunk/docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencers/UserInterface.java
   trunk/docs/examples/gettingstarted/sequencers/src/main/resources/jackrabbitNodeTypes.cnd
   trunk/docs/examples/gettingstarted/sequencers/src/test/java/org/jboss/example/dna/sequencers/MockUserInterface.java
   trunk/docs/examples/gettingstarted/sequencers/src/test/java/org/jboss/example/dna/sequencers/SequencingClientTest.java
   trunk/pom.xml
   trunk/sequencers/dna-sequencer-images/
   trunk/sequencers/dna-sequencer-images/pom.xml
   trunk/sequencers/dna-sequencer-images/src/main/resources/org/jboss/dna/sequencer/images/images.cnd
Log:
Added dna-sequencer-mp3


Property changes on: trunk/dna-common
___________________________________________________________________
Name: svn:ignore
   - target

   + .settings
target


Modified: trunk/dna-common/pom.xml
===================================================================
--- trunk/dna-common/pom.xml	2008-05-12 20:02:42 UTC (rev 144)
+++ trunk/dna-common/pom.xml	2008-05-12 20:12:29 UTC (rev 145)
@@ -1,4 +1,7 @@
-<?xml version="1.0" encoding="UTF-8"?><project>
+<?xml version="1.0" encoding="UTF-8"?>
+<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.jboss.dna</groupId>


Property changes on: trunk/dna-integration-tests
___________________________________________________________________
Name: svn:ignore
   - target

   + .settings
target



Property changes on: trunk/dna-maven-classloader
___________________________________________________________________
Name: svn:ignore
   - target

   + .settings
target


Modified: trunk/dna-maven-classloader/pom.xml
===================================================================
--- trunk/dna-maven-classloader/pom.xml	2008-05-12 20:02:42 UTC (rev 144)
+++ trunk/dna-maven-classloader/pom.xml	2008-05-12 20:12:29 UTC (rev 145)
@@ -1,4 +1,7 @@
-<?xml version="1.0" encoding="UTF-8"?><project>
+<?xml version="1.0" encoding="UTF-8"?>
+<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.jboss.dna</groupId>


Property changes on: trunk/dna-repository
___________________________________________________________________
Name: svn:ignore
   - target

   + .settings
target


Modified: trunk/dna-repository/pom.xml
===================================================================
--- trunk/dna-repository/pom.xml	2008-05-12 20:02:42 UTC (rev 144)
+++ trunk/dna-repository/pom.xml	2008-05-12 20:12:29 UTC (rev 145)
@@ -1,4 +1,7 @@
-<?xml version="1.0" encoding="UTF-8"?><project>
+<?xml version="1.0" encoding="UTF-8"?>
+<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.jboss.dna</groupId>


Property changes on: trunk/dna-spi
___________________________________________________________________
Name: svn:ignore
   - target

   + .settings
target


Modified: trunk/dna-spi/pom.xml
===================================================================
--- trunk/dna-spi/pom.xml	2008-05-12 20:02:42 UTC (rev 144)
+++ trunk/dna-spi/pom.xml	2008-05-12 20:12:29 UTC (rev 145)
@@ -1,4 +1,7 @@
-<?xml version="1.0" encoding="UTF-8"?><project>
+<?xml version="1.0" encoding="UTF-8"?>
+<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.jboss.dna</groupId>

Modified: trunk/docs/examples/gettingstarted/sequencers/pom.xml
===================================================================
--- trunk/docs/examples/gettingstarted/sequencers/pom.xml	2008-05-12 20:02:42 UTC (rev 144)
+++ trunk/docs/examples/gettingstarted/sequencers/pom.xml	2008-05-12 20:12:29 UTC (rev 145)
@@ -1,5 +1,5 @@
-<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">
+<?xml version="1.0" encoding="UTF-8"?>
+<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 
   <parent>
     <groupId>org.jboss.dna.examples</groupId>
@@ -73,6 +73,11 @@
       <artifactId>junit</artifactId>
       <scope>test</scope>
     </dependency>
+    <dependency>
+      <groupId>org.jboss.dna</groupId>
+      <artifactId>dna-sequencer-mp3</artifactId>
+      <version>0.1-SNAPSHOT</version>
+    </dependency>
   </dependencies>
 
   <build>

Modified: trunk/docs/examples/gettingstarted/sequencers/src/main/assembly/basic.xml
===================================================================
--- trunk/docs/examples/gettingstarted/sequencers/src/main/assembly/basic.xml	2008-05-12 20:02:42 UTC (rev 144)
+++ trunk/docs/examples/gettingstarted/sequencers/src/main/assembly/basic.xml	2008-05-12 20:12:29 UTC (rev 145)
@@ -20,6 +20,7 @@
         <include>*.gif</include>
         <include>*.jpg</include>
         <include>*.pict</include>
+        <include>*.mp3</include>
       </includes>
     </fileSet>
   </fileSets>

Modified: trunk/docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencers/ConsoleInput.java
===================================================================
--- trunk/docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencers/ConsoleInput.java	2008-05-12 20:02:42 UTC (rev 144)
+++ trunk/docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencers/ConsoleInput.java	2008-05-12 20:12:29 UTC (rev 145)
@@ -171,24 +171,25 @@
         return path;
     }
 
-    public void displaySearchResults( List<ImageInfo> images ) {
+    public void displaySearchResults( List<MediaInfo> medias ) {
         System.out.println();
-        if (images.isEmpty()) {
+        if (medias.isEmpty()) {
             System.out.println("No results were found.");
             System.out.println();
             return;
         }
-        if (images.size() == 1) {
+        if (medias.size() == 1) {
             System.out.println("1 image was found:");
         } else {
-            System.out.println("" + images.size() + " images were found:");
+            System.out.println("" + medias.size() + " images were found:");
         }
         int counter = 1;
-        for (ImageInfo image : images) {
-            System.out.println(" Image " + counter++);
-            System.out.println("   Name: " + image.getName());
-            System.out.println("   Path: " + image.getPath());
-            for (Map.Entry<Object, Object> entry : image.getProperties().entrySet()) {
+        for (MediaInfo media : medias) {
+            System.out.println(" Media " + counter++);
+            System.out.println("   Name: " + media.getName());
+            System.out.println("   Path: " + media.getPath());
+            System.out.println("   Type: " + media.getMediaType());
+            for (Map.Entry<Object, Object> entry : media.getProperties().entrySet()) {
                 System.out.println("   " + entry.getKey() + ": " + entry.getValue());
             }
         }

Deleted: trunk/docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencers/ImageInfo.java
===================================================================
--- trunk/docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencers/ImageInfo.java	2008-05-12 20:02:42 UTC (rev 144)
+++ trunk/docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencers/ImageInfo.java	2008-05-12 20:12:29 UTC (rev 145)
@@ -1,69 +0,0 @@
-/*
- * JBoss, Home of Professional Open Source.
- * Copyright 2008, Red Hat Middleware LLC, and individual contributors
- * as indicated by the @author tags. See the copyright.txt file in the
- * distribution for a full listing of individual contributors. 
- *
- * This 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; either version 2.1 of
- * the License, or (at your option) any later version.
- *
- * This software 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 this software; if not, write to the Free
- * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
- * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
- */
-package org.jboss.example.dna.sequencers;
-
-import java.util.Map;
-import java.util.Properties;
-
-/**
- * @author Randall Hauch
- */
-public class ImageInfo {
-
-    private final Properties properties = new Properties();
-    private final String name;
-    private final String path;
-
-    protected ImageInfo( String path, String name, Properties props ) {
-        this.name = name;
-        this.path = path;
-        if (props != null) this.properties.putAll(props);
-    }
-
-    public String getName() {
-        return this.name;
-    }
-
-    public String getPath() {
-        return this.path;
-    }
-
-    public Properties getProperties() {
-        return this.properties;
-    }
-
-    @Override
-    public String toString() {
-        StringBuilder sb = new StringBuilder();
-        boolean first = true;
-        for (Map.Entry<Object, Object> entry : this.properties.entrySet()) {
-            sb.append(entry.getKey()).append("=>").append(entry.getValue());
-            if (first) {
-                first = false;
-            } else {
-                sb.append(", ");
-            }
-        }
-        return this.name + " (at " + this.path + ") with properties {" + sb.toString() + "}";
-    }
-
-}

Added: trunk/docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencers/MediaInfo.java
===================================================================
--- trunk/docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencers/MediaInfo.java	                        (rev 0)
+++ trunk/docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencers/MediaInfo.java	2008-05-12 20:12:29 UTC (rev 145)
@@ -0,0 +1,75 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors. 
+ *
+ * This 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; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.example.dna.sequencers;
+
+import java.util.Map;
+import java.util.Properties;
+
+/**
+ * @author Randall Hauch
+ */
+public class MediaInfo {
+
+    private final Properties properties = new Properties();
+    private final String name;
+    private final String path;
+    private final String mediaType;
+
+    protected MediaInfo( String path, String name, String mediaType, Properties props ) {
+        this.name = name;
+        this.path = path;
+        this.mediaType = mediaType;
+        if (props != null) this.properties.putAll(props);
+    }
+
+    public String getName() {
+        return this.name;
+    }
+
+    public String getPath() {
+        return this.path;
+    }
+
+    public String getMediaType() {
+        return this.mediaType;
+    }
+
+    public Properties getProperties() {
+        return this.properties;
+    }
+
+    @Override
+    public String toString() {
+        StringBuilder sb = new StringBuilder();
+        boolean first = true;
+        for (Map.Entry<Object, Object> entry : this.properties.entrySet()) {
+            sb.append(entry.getKey()).append("=>").append(entry.getValue());
+            if (first) {
+                first = false;
+            } else {
+                sb.append(", ");
+            }
+        }
+        return this.name + " (at " + this.path + ") of type \"" + this.mediaType + "\" with properties {" + sb.toString() + "}";
+    }
+
+}

Modified: trunk/docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencers/SequencingClient.java
===================================================================
--- trunk/docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencers/SequencingClient.java	2008-05-12 20:02:42 UTC (rev 144)
+++ trunk/docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencers/SequencingClient.java	2008-05-12 20:12:29 UTC (rev 145)
@@ -31,6 +31,7 @@
 import javax.jcr.Credentials;
 import javax.jcr.Node;
 import javax.jcr.NodeIterator;
+import javax.jcr.PathNotFoundException;
 import javax.jcr.Property;
 import javax.jcr.PropertyIterator;
 import javax.jcr.Repository;
@@ -38,6 +39,7 @@
 import javax.jcr.Session;
 import javax.jcr.SimpleCredentials;
 import javax.jcr.Value;
+import javax.jcr.ValueFormatException;
 import javax.jcr.observation.Event;
 import org.apache.jackrabbit.api.JackrabbitNodeTypeManager;
 import org.apache.jackrabbit.core.TransientRepository;
@@ -210,8 +212,9 @@
             this.sequencingService = new SequencingService();
             this.sequencingService.setExecutionContext(executionContext);
 
-            // Configure the sequencers. In this example, we only use a single sequencer that processes image files.
-            // So create a configuration. Note that the sequencing service expects the class to be on the thread's current context
+            // Configure the sequencers. In this example, we only two sequencers that processes image and mp3 files.
+            // So create a configurations. Note that the sequencing service expects the class to be on the thread's current
+            // context
             // classloader, or if that's null the classloader that loaded the SequencingService class.
             //
             // Part of the configuration includes telling DNA which JCR paths should be processed by the sequencer.
@@ -231,6 +234,13 @@
             SequencerConfig imageSequencerConfig = new SequencerConfig(name, desc, classname, classpath, pathExpressions);
             this.sequencingService.addSequencer(imageSequencerConfig);
 
+            name = "Mp3 Sequencer";
+            desc = "Sequences mp3 files to extract the id3 tags of the audio file";
+            classname = "org.jboss.dna.sequencer.mp3.Mp3MetadataSequencer";
+            String[] mp3PathExpressions = {"//(*.(mp3))[*]/jcr:content[@jcr:data] => /mp3s/$1"};
+            SequencerConfig mp3SequencerConfig = new SequencerConfig(name, desc, classname, classpath, mp3PathExpressions);
+            this.sequencingService.addSequencer(mp3SequencerConfig);
+
             // Use the DNA observation service to listen to the JCR repository (or multiple ones), and
             // then register the sequencing service as a listener to this observation service...
             this.observationService = new ObservationService(this.executionContext.getSessionFactory());
@@ -303,59 +313,84 @@
      */
     public void search() throws Exception {
         // Use JCR to search the repository for image metadata ...
-        List<ImageInfo> images = new ArrayList<ImageInfo>();
+        List<MediaInfo> medias = new ArrayList<MediaInfo>();
         Session session = createSession();
         try {
             // Find the image node ...
             Node root = session.getRootNode();
-            if (root.hasNode("images")) {
-                Node imagesNode = root.getNode("images");
 
-                // Iterate over each child ...
-                for (NodeIterator iter = imagesNode.getNodes(); iter.hasNext();) {
-                    Node imageNode = iter.nextNode();
-                    String nodePath = imageNode.getPath();
-                    String nodeName = imageNode.getName();
-                    if (imageNode.hasNode("image:metadata")) {
-                        imageNode = imageNode.getNode("image:metadata");
+            if (root.hasNode("images") || root.hasNode("mp3s")) {
+                Node mediasNode;
+                if (root.hasNode("images")) {
+                    mediasNode = root.getNode("images");
 
-                        // Create a Properties object containing the properties for this node; ignore any children ...
-                        Properties props = new Properties();
-                        for (PropertyIterator propertyIter = imageNode.getProperties(); propertyIter.hasNext();) {
-                            Property property = propertyIter.nextProperty();
-                            String name = property.getName();
-                            String stringValue = null;
-                            if (property.getDefinition().isMultiple()) {
-                                StringBuilder sb = new StringBuilder();
-                                boolean first = true;
-                                for (Value value : property.getValues()) {
-                                    if (!first) {
-                                        sb.append(", ");
-                                        first = false;
-                                    }
-                                    sb.append(value.getString());
-                                }
-                                stringValue = sb.toString();
-                            } else {
-                                stringValue = property.getValue().getString();
-                            }
-                            props.put(name, stringValue);
+                    for (NodeIterator iter = mediasNode.getNodes(); iter.hasNext();) {
+                        Node mediaNode = iter.nextNode();
+                        if (mediaNode.hasNode("image:metadata")) {
+                            medias.add(extractMediaInfo("image:metadata", "image", mediaNode));
                         }
-                        // Create the image information object, and add it to the collection ...
-                        ImageInfo info = new ImageInfo(nodePath, nodeName, props);
-                        images.add(info);
                     }
                 }
+                if (root.hasNode("mp3s")) {
+                    mediasNode = root.getNode("mp3s");
+
+                    for (NodeIterator iter = mediasNode.getNodes(); iter.hasNext();) {
+                        Node mediaNode = iter.nextNode();
+                        if (mediaNode.hasNode("mp3:metadata")) {
+                            medias.add(extractMediaInfo("mp3:metadata", "mp3", mediaNode));
+                        }
+                    }
+                }
+
             }
         } finally {
             session.logout();
         }
 
         // Display the search results ...
-        this.userInterface.displaySearchResults(images);
+        this.userInterface.displaySearchResults(medias);
     }
 
     /**
+     * @param metadataNodeName
+     * @param mediaType
+     * @param mediaNode media node
+     * @throws RepositoryException
+     * @throws PathNotFoundException
+     * @throws ValueFormatException
+     */
+    private MediaInfo extractMediaInfo( String metadataNodeName, String mediaType, Node mediaNode ) throws RepositoryException, PathNotFoundException, ValueFormatException {
+        String nodePath = mediaNode.getPath();
+        String nodeName = mediaNode.getName();
+        mediaNode = mediaNode.getNode(metadataNodeName);
+
+        // Create a Properties object containing the properties for this node; ignore any children ...
+        Properties props = new Properties();
+        for (PropertyIterator propertyIter = mediaNode.getProperties(); propertyIter.hasNext();) {
+            Property property = propertyIter.nextProperty();
+            String name = property.getName();
+            String stringValue = null;
+            if (property.getDefinition().isMultiple()) {
+                StringBuilder sb = new StringBuilder();
+                boolean first = true;
+                for (Value value : property.getValues()) {
+                    if (!first) {
+                        sb.append(", ");
+                        first = false;
+                    }
+                    sb.append(value.getString());
+                }
+                stringValue = sb.toString();
+            } else {
+                stringValue = property.getValue().getString();
+            }
+            props.put(name, stringValue);
+        }
+        // Create the image information object, and add it to the collection ...
+        return new MediaInfo(nodePath, nodeName, mediaType, props);
+    }
+
+    /**
      * Utility method to create a new JCR session from the execution context's {@link SessionFactory}.
      * @return the session
      * @throws RepositoryException
@@ -374,6 +409,7 @@
         if (filename.endsWith(".jpe")) return "image/jpeg";
         if (filename.endsWith(".jpeg")) return "image/jpeg";
         if (filename.endsWith(".ras")) return "image/x-cmu-raster";
+        if (filename.endsWith(".mp3")) return "audio/mpeg";
         throw new SystemFailureException("Unknown mime type for " + file);
     }
 

Modified: trunk/docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencers/UserInterface.java
===================================================================
--- trunk/docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencers/UserInterface.java	2008-05-12 20:02:42 UTC (rev 144)
+++ trunk/docs/examples/gettingstarted/sequencers/src/main/java/org/jboss/example/dna/sequencers/UserInterface.java	2008-05-12 20:12:29 UTC (rev 145)
@@ -34,5 +34,5 @@
 
     public String getRepositoryPath( String defaultPath ) throws IllegalArgumentException, IOException;
 
-    public void displaySearchResults( List<ImageInfo> images ) throws IOException;
+    public void displaySearchResults( List<MediaInfo> images ) throws IOException;
 }

Modified: trunk/docs/examples/gettingstarted/sequencers/src/main/resources/jackrabbitNodeTypes.cnd
===================================================================
--- trunk/docs/examples/gettingstarted/sequencers/src/main/resources/jackrabbitNodeTypes.cnd	2008-05-12 20:02:42 UTC (rev 144)
+++ trunk/docs/examples/gettingstarted/sequencers/src/main/resources/jackrabbitNodeTypes.cnd	2008-05-12 20:12:29 UTC (rev 145)
@@ -2,12 +2,12 @@
 <nt='http://www.jcp.org/jcr/nt/1.0'>
 <mix='http://www.jcp.org/jcr/mix/1.0'>
 <image='http://jboss.org/dna/images/1.0'>
-
+<mp3='http://jboss.org/dna/mp3/1.0'>
 // ----------------------------------------------------------
 // JCR Pre-defined Mixin Types that are not loaded by default
 // ----------------------------------------------------------
 
-[mix:mimeType] mixin 
+[mix:mimeTyped] mixin 
   - jcr:mimeType (string)  
   - jcr:encoding (string)
 
@@ -17,12 +17,11 @@
 // -------------------
 
 /**
- * Marker mixin that defines the root of a Maven 2 repository.
+ * Node type that defines the metadata for an image
  */
-[image:metadata] > nt:unstructured
-  - image:mimeType (string)  
-  - image:encoding (string)
+[image:metadata] > nt:unstructured, mix:mimeTyped
   - image:formatName (string) mandatory
+    < 'JPEG', 'GIF', 'PNG', 'BMP', 'PCX', 'IFF', 'RAS', 'PBM', 'PGM', 'PPM', 'PSD'
   - image:width (long)
   - image:height (long)
   - image:bitsPerPixel (long)
@@ -33,5 +32,14 @@
   - image:physicalWidthInches (long)
   - image:physicalHeightInches (long)
 
+/**
+ * Node type that defines the metadata for an MP3 audio file
+ */
+[mp3:metadata] > nt:unstructured, mix:mimeTyped
+  - mp3:title (string)
+  - mp3:author (string)
+  - mp3:album (string)
+  - mp3:year (long)
+  - mp3:comment (string)
 
 

Modified: trunk/docs/examples/gettingstarted/sequencers/src/test/java/org/jboss/example/dna/sequencers/MockUserInterface.java
===================================================================
--- trunk/docs/examples/gettingstarted/sequencers/src/test/java/org/jboss/example/dna/sequencers/MockUserInterface.java	2008-05-12 20:02:42 UTC (rev 144)
+++ trunk/docs/examples/gettingstarted/sequencers/src/test/java/org/jboss/example/dna/sequencers/MockUserInterface.java	2008-05-12 20:12:29 UTC (rev 145)
@@ -44,9 +44,9 @@
     /**
      * {@inheritDoc}
      */
-    public void displaySearchResults( List<ImageInfo> images ) {
+    public void displaySearchResults( List<MediaInfo> images ) {
         assertThat(images.size(), is(this.numberOfSearchResults));
-        for (ImageInfo image : images) {
+        for (MediaInfo image : images) {
             System.out.println("Image: " + image);
         }
     }

Modified: trunk/docs/examples/gettingstarted/sequencers/src/test/java/org/jboss/example/dna/sequencers/SequencingClientTest.java
===================================================================
--- trunk/docs/examples/gettingstarted/sequencers/src/test/java/org/jboss/example/dna/sequencers/SequencingClientTest.java	2008-05-12 20:02:42 UTC (rev 144)
+++ trunk/docs/examples/gettingstarted/sequencers/src/test/java/org/jboss/example/dna/sequencers/SequencingClientTest.java	2008-05-12 20:12:29 UTC (rev 145)
@@ -38,6 +38,7 @@
     private URL pngImageUrl;
     private URL pictImageUrl;
     private URL jpegImageUrl;
+    private URL mp3Url;
     private SequencingClient client;
 
     @Before
@@ -45,6 +46,7 @@
         this.pngImageUrl = Thread.currentThread().getContextClassLoader().getResource("caution.png");
         this.pictImageUrl = Thread.currentThread().getContextClassLoader().getResource("caution.pict");
         this.jpegImageUrl = Thread.currentThread().getContextClassLoader().getResource("caution.jpg");
+        this.mp3Url = Thread.currentThread().getContextClassLoader().getResource("sample1.mp3");
         client = new SequencingClient();
         client.setWorkingDirectory("target/repositoryData");
         client.setJackrabbitConfigPath("src/main/resources/jackrabbitConfig.xml");
@@ -59,10 +61,11 @@
     }
 
     @Test
-    public void shouldFindImages() {
+    public void shouldFindMedias() {
         assertThat(this.pictImageUrl, is(notNullValue()));
         assertThat(this.pngImageUrl, is(notNullValue()));
         assertThat(this.jpegImageUrl, is(notNullValue()));
+        assertThat(this.mp3Url, is(notNullValue()));
     }
 
     @Test
@@ -137,4 +140,23 @@
         assertThat(client.getStatistics().getNumberOfNodesSequenced(), is(0l));
     }
 
+    @Test
+    public void shouldUploadAndSequenceMp3File() throws Exception {
+        client.setUserInterface(new MockUserInterface(this.mp3Url, "/a/b/test.mp3", 1));
+        client.startRepository();
+        client.startDnaServices();
+        client.uploadFile();
+
+        // Use a trick to wait until the sequencing has been done by sleeping (to give the sequencing time to start)
+        // and to then shut down the DNA services (which will block until all sequencing has been completed) ...
+        Thread.sleep(1000);
+        client.shutdownDnaServices();
+
+        // The sequencers should have run, so perform the search.
+        // The mock user interface checks the results.
+        client.search();
+
+        assertThat(client.getStatistics().getNumberOfNodesSequenced(), is(1l));
+    }
+
 }

Deleted: trunk/docs/examples/gettingstarted/sequencers/src/test/resources/log4j.properties
===================================================================
--- trunk/docs/examples/gettingstarted/sequencers/src/test/resources/log4j.properties	2008-05-12 20:02:42 UTC (rev 144)
+++ trunk/docs/examples/gettingstarted/sequencers/src/test/resources/log4j.properties	2008-05-12 20:12:29 UTC (rev 145)
@@ -1,16 +0,0 @@
-# Direct log messages to stdout
-log4j.appender.stdout=org.apache.log4j.ConsoleAppender
-log4j.appender.stdout.Target=System.out
-log4j.appender.stdout.layout=org.apache.log4j.PatternLayout
-log4j.appender.stdout.layout.ConversionPattern=%d{ABSOLUTE} %5p %m%n
-
-# Root logger option
-log4j.rootLogger=INFO, stdout
-
-# Set up the default logging to be INFO level, then override specific units
-log4j.logger.org.jboss.dna=INFO
-
-# Jackrabbit logging
-log4j.logger.org.apache.jackrabbit=WARN, stdout
-log4j.logger.org.apache.derby=INFO, stdout
-

Added: trunk/docs/examples/gettingstarted/sequencers/src/test/resources/sample1.mp3
===================================================================
(Binary files differ)


Property changes on: trunk/docs/examples/gettingstarted/sequencers/src/test/resources/sample1.mp3
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Modified: trunk/pom.xml
===================================================================
--- trunk/pom.xml	2008-05-12 20:02:42 UTC (rev 144)
+++ trunk/pom.xml	2008-05-12 20:12:29 UTC (rev 145)
@@ -1,5 +1,7 @@
-<?xml version="1.0"?>
-<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">
+<?xml version="1.0" encoding="UTF-8"?>
+<project
+	xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"
+	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
 	<modelVersion>4.0.0</modelVersion>
 	<groupId>org.jboss.dna</groupId>
 	<artifactId>dna</artifactId>
@@ -7,18 +9,24 @@
 	<packaging>pom</packaging>
 	<name>JBoss DNA</name>
 	<url>http://www.jboss.org/dna</url>
-	<description>JBoss DNA provides tools for working with JCR repositories.</description>
+	<description>
+		JBoss DNA provides tools for working with JCR repositories.
+	</description>
 	<scm>
-		<connection>scm:svn:https://svn.jboss.org/repos/dna/trunk</connection>
+		<connection>
+			scm:svn:https://svn.jboss.org/repos/dna/trunk
+		</connection>
 	</scm>
 	<modules>
 		<module>dna-common</module>
 		<module>dna-spi</module>
 		<module>dna-repository</module>
+		<module>dna-maven-classloader</module>
 		<module>sequencers/dna-sequencer-images</module>
-		<module>dna-maven-classloader</module>
+		<module>sequencers/dna-sequencer-mp3</module>
         <module>dna-integration-tests</module>
 	</modules>
+
 	<properties>
 		<dna-version>${project.version}</dna-version>
 	</properties>
@@ -71,12 +79,22 @@
 	              </execution>
 	            </executions>
 	            <configuration>
-	              <finalName>jboss-dna-${project.version}</finalName>
+							<finalName>
+								jboss-dna-${project.version}
+							</finalName>
 	              <descriptors>
-	                <descriptor>build/assembly/examples.xml</descriptor>
-	                <descriptor>build/assembly/javadoc.xml</descriptor>
-	                <descriptor>build/assembly/dist.xml</descriptor>
-	                <descriptor>build/assembly/src.xml</descriptor>
+								<descriptor>
+									build/assembly/examples.xml
+								</descriptor>
+								<descriptor>
+									build/assembly/javadoc.xml
+								</descriptor>
+								<descriptor>
+									build/assembly/dist.xml
+								</descriptor>
+								<descriptor>
+									build/assembly/src.xml
+								</descriptor>
 	              </descriptors>
 	            </configuration>
 	          </plugin>
@@ -166,11 +184,17 @@
 				<configuration>
 					<archive>
 						<manifest>
-							<addDefaultSpecificationEntries>true</addDefaultSpecificationEntries>
-							<addDefaultImplementationEntries>true</addDefaultImplementationEntries>
+							<addDefaultSpecificationEntries>
+								true
+							</addDefaultSpecificationEntries>
+							<addDefaultImplementationEntries>
+								true
+							</addDefaultImplementationEntries>
 						</manifest>
 						<manifestEntries>
-							<Implementation-URL>${pom.url}</Implementation-URL>
+							<Implementation-URL>
+								${pom.url}
+							</Implementation-URL>
 						</manifestEntries>
 					</archive>
 				</configuration>
@@ -340,4 +364,4 @@
 			</plugin>
 	    </plugins>
 	</reporting>
-</project>
+</project>
\ No newline at end of file


Property changes on: trunk/sequencers/dna-sequencer-images
___________________________________________________________________
Name: svn:ignore
   - target

   + .settings
target


Modified: trunk/sequencers/dna-sequencer-images/pom.xml
===================================================================
--- trunk/sequencers/dna-sequencer-images/pom.xml	2008-05-12 20:02:42 UTC (rev 144)
+++ trunk/sequencers/dna-sequencer-images/pom.xml	2008-05-12 20:12:29 UTC (rev 145)
@@ -1,4 +1,7 @@
-<?xml version="1.0" encoding="UTF-8"?><project>
+<?xml version="1.0" encoding="UTF-8"?>
+<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.jboss.dna</groupId>

Modified: trunk/sequencers/dna-sequencer-images/src/main/resources/org/jboss/dna/sequencer/images/images.cnd
===================================================================
--- trunk/sequencers/dna-sequencer-images/src/main/resources/org/jboss/dna/sequencer/images/images.cnd	2008-05-12 20:02:42 UTC (rev 144)
+++ trunk/sequencers/dna-sequencer-images/src/main/resources/org/jboss/dna/sequencer/images/images.cnd	2008-05-12 20:12:29 UTC (rev 145)
@@ -23,30 +23,39 @@
 //------------------------------------------------------------------------------
 // N A M E S P A C E S
 //------------------------------------------------------------------------------
-<dna = 'http://www.jboss.org/dna-repository/1.0'>
-<image = 'http://www.jboss.org/dna-repository/images/1.0'>
+<jcr='http://www.jcp.org/jcr/1.0'>
 <nt='http://www.jcp.org/jcr/nt/1.0'>
 <mix='http://www.jcp.org/jcr/mix/1.0'>
+<image='http://jboss.org/dna/images/1.0'>
 
+// ----------------------------------------------------------
+// JCR Pre-defined Mixin Types that are not loaded by default
+// ----------------------------------------------------------
+
+[mix:mimeType] mixin 
+  - jcr:mimeType (string)  
+  - jcr:encoding (string)
+
+
 //------------------------------------------------------------------------------
 // N O D E T Y P E S
 //------------------------------------------------------------------------------
 
-[image:metadata] > nt:unstructured, mix:mimeTyped
-  //Inherited from 'mix:mimeTyped'
-  //- jcr:mimeType (string)  
-  //- jcr:encoding (string)
+/**
+ * Mixin that defines the metadata for an image
+ */
+[image:metadata] > nt:unstructured, mix:mimeType
   - image:formatName (string) mandatory
     < 'JPEG', 'GIF', 'PNG', 'BMP', 'PCX', 'IFF', 'RAS', 'PBM', 'PGM', 'PPM', 'PSD'
-  - image:width (int)
-  - image:height (int)
-  - image:bitsPerPixel (int)
+  - image:width (long)
+  - image:height (long)
+  - image:bitsPerPixel (long)
   - image:progressive (boolean)
-  - image:imageCount (int)
-  - image:physicalWidthDpi (int)
-  - image:physicalHeightDpi (int)
-  - image:physicalWidthInches (double)
-  - image:physicalHeightInches (double)
-  - image:comments (string) multiple
- 
+  - image:numberOfImages (long)
+  - image:physicalWidthDpi (long)
+  - image:physicalHeightDpi (long)
+  - image:physicalWidthInches (long)
+  - image:physicalHeightInches (long)
+
+
  
\ No newline at end of file


Property changes on: trunk/sequencers/dna-sequencer-mp3
___________________________________________________________________
Name: svn:ignore
   + .settings
target


Added: trunk/sequencers/dna-sequencer-mp3/.classpath
===================================================================
--- trunk/sequencers/dna-sequencer-mp3/.classpath	                        (rev 0)
+++ trunk/sequencers/dna-sequencer-mp3/.classpath	2008-05-12 20:12:29 UTC (rev 145)
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+	<classpathentry kind="src" path="src/main/java"/>
+	<classpathentry kind="src" path="src/main/resources"/>
+	<classpathentry kind="src" output="target/test-classes" path="src/test/java"/>
+	<classpathentry kind="src" output="target/test-classes" path="src/test/resources"/>
+	<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
+	<classpathentry kind="con" path="org.maven.ide.eclipse.MAVEN2_CLASSPATH_CONTAINER"/>
+	<classpathentry kind="output" path="target/classes"/>
+</classpath>

Added: trunk/sequencers/dna-sequencer-mp3/.project
===================================================================
--- trunk/sequencers/dna-sequencer-mp3/.project	                        (rev 0)
+++ trunk/sequencers/dna-sequencer-mp3/.project	2008-05-12 20:12:29 UTC (rev 145)
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+	<name>dna-sequencer-mp3</name>
+	<comment></comment>
+	<projects>
+	</projects>
+	<buildSpec>
+		<buildCommand>
+			<name>org.eclipse.jdt.core.javabuilder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+		<buildCommand>
+			<name>org.maven.ide.eclipse.maven2Builder</name>
+			<arguments>
+			</arguments>
+		</buildCommand>
+	</buildSpec>
+	<natures>
+		<nature>org.eclipse.jdt.core.javanature</nature>
+		<nature>org.maven.ide.eclipse.maven2Nature</nature>
+	</natures>
+</projectDescription>

Added: trunk/sequencers/dna-sequencer-mp3/pom.xml
===================================================================
--- trunk/sequencers/dna-sequencer-mp3/pom.xml	                        (rev 0)
+++ trunk/sequencers/dna-sequencer-mp3/pom.xml	2008-05-12 20:12:29 UTC (rev 145)
@@ -0,0 +1,40 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<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>
+    <artifactId>dna</artifactId>
+    <groupId>org.jboss.dna</groupId>
+    <version>0.1-SNAPSHOT</version>
+    <relativePath>../..</relativePath>
+  </parent>
+  <!-- The groupId and version values are inherited from parent -->
+  <artifactId>dna-sequencer-mp3</artifactId>
+  <packaging>jar</packaging>
+  <name>JBoss DNA MP3 Sequencer</name>
+  <description>JBoss DNA Sequencer that processes MP3 audio files</description>
+  <url>http://labs.jboss.org/dna</url>
+  <dependencies>
+    <dependency>
+      <groupId>org.jboss.dna</groupId>
+      <artifactId>dna-common</artifactId>
+      <version>0.1-SNAPSHOT</version>
+    </dependency>
+    <dependency>
+      <groupId>org.jboss.dna</groupId>
+      <artifactId>dna-spi</artifactId>
+      <version>0.1-SNAPSHOT</version>
+    </dependency>
+    <dependency>
+      <groupId>org.jaudiotagger</groupId>
+      <artifactId>jaudiotagger</artifactId>
+      <version>1.0.8</version>
+   </dependency>
+    <dependency>
+      <groupId>junit</groupId>
+      <artifactId>junit-dep</artifactId>
+      <version>4.4</version>
+    </dependency>
+  </dependencies>
+</project>
\ No newline at end of file

Added: trunk/sequencers/dna-sequencer-mp3/src/main/java/org/jboss/dna/sequencer/mp3/Mp3Metadata.java
===================================================================
--- trunk/sequencers/dna-sequencer-mp3/src/main/java/org/jboss/dna/sequencer/mp3/Mp3Metadata.java	                        (rev 0)
+++ trunk/sequencers/dna-sequencer-mp3/src/main/java/org/jboss/dna/sequencer/mp3/Mp3Metadata.java	2008-05-12 20:12:29 UTC (rev 145)
@@ -0,0 +1,82 @@
+package org.jboss.dna.sequencer.mp3;
+
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.InputStream;
+import java.util.logging.Level;
+import org.jaudiotagger.audio.AudioFile;
+import org.jaudiotagger.audio.AudioFileIO;
+import org.jaudiotagger.tag.Tag;
+
+/**
+ * Utility for extracting metadata from MP3 files.
+ * @author Stefano Maestri
+ */
+public class Mp3Metadata {
+
+    private String title;
+    private String author;
+    private String album;
+    private String year;
+    private String comment;
+
+    private Mp3Metadata() {
+
+    }
+
+    public static Mp3Metadata instance( InputStream stream ) {
+
+        Mp3Metadata me = null;
+        File tmpFile = null;
+        try {
+            tmpFile = File.createTempFile("dna-sequencer-mp3", ".mp3");
+            FileOutputStream writer = new FileOutputStream(tmpFile);
+            byte[] b = new byte[128];
+            while (stream.read(b) != -1) {
+                writer.write(b);
+            }
+            writer.close();
+            AudioFileIO.logger.getParent().setLevel(Level.OFF);
+            AudioFile f = AudioFileIO.read(tmpFile);
+            Tag tag = f.getTag();
+
+            me = new Mp3Metadata();
+
+            me.author = tag.getFirstArtist();
+            me.album = tag.getFirstAlbum();
+            me.title = tag.getFirstTitle();
+            me.comment = tag.getFirstComment();
+            me.year = tag.getFirstYear();
+
+        } catch (Exception e) {
+            e.printStackTrace();
+        } finally {
+            if (tmpFile != null) {
+                tmpFile.delete();
+            }
+        }
+        return me;
+
+    }
+
+    public String getTitle() {
+        return title;
+    }
+
+    public String getAuthor() {
+        return author;
+    }
+
+    public String getAlbum() {
+        return album;
+    }
+
+    public String getYear() {
+        return year;
+    }
+
+    public String getComment() {
+        return comment;
+    }
+
+}

Added: trunk/sequencers/dna-sequencer-mp3/src/main/java/org/jboss/dna/sequencer/mp3/Mp3MetadataSequencer.java
===================================================================
--- trunk/sequencers/dna-sequencer-mp3/src/main/java/org/jboss/dna/sequencer/mp3/Mp3MetadataSequencer.java	                        (rev 0)
+++ trunk/sequencers/dna-sequencer-mp3/src/main/java/org/jboss/dna/sequencer/mp3/Mp3MetadataSequencer.java	2008-05-12 20:12:29 UTC (rev 145)
@@ -0,0 +1,79 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors. 
+ *
+ * This 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; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+package org.jboss.dna.sequencer.mp3;
+
+import java.io.InputStream;
+import org.jboss.dna.common.monitor.ProgressMonitor;
+import org.jboss.dna.spi.sequencers.SequencerOutput;
+import org.jboss.dna.spi.sequencers.StreamSequencer;
+
+/**
+ * A sequencer that processes the binary content of an MP3 audio file, extracts the metadata for the file, and then writes that
+ * audio metadata to the repository.
+ * <p>
+ * This sequencer produces data that corresponds to the following structure:
+ * <ul>
+ * <li><strong>mp3:metadata</strong> node of type <code>mp3:metadata</code>
+ * <ul>
+ * <li><strong>jcr:mimeType</strong> - optional string property for the mime type of the image</li>
+ * <li><strong>jcr:encoding</strong> - optional string property for the encoding of the image</li>
+ * <li><strong>mp3:title</strong> - optional string property for the name of the audio file or recording</li>
+ * <li><strong>mp3:author</strong> - optional string property for the author of the recording</li>
+ * <li><strong>mp3:album</strong> - optional string property for the name of the album</li>
+ * <li><strong>mp3:year</strong> - optional integer property for the year the recording as created</li>
+ * <li><strong>mp3:comment</strong> - optional string property specifying a comment</li>
+ * </ul>
+ * </li>
+ * </ul>
+ * </p>
+ * @author Stefano Maestri
+ * @author Randall Hauch
+ */
+public class Mp3MetadataSequencer implements StreamSequencer {
+
+    public static final String METADATA_NODE = "mp3:metadata";
+    public static final String MP3_PRIMARY_TYPE = "jcr:primaryType";
+    public static final String MP3_TITLE = "mp3:title";
+    public static final String MP3_AUTHOR = "mp3:author";
+    public static final String MP3_ALBUM = "mp3:album";
+    public static final String MP3_YEAR = "mp3:year";
+    public static final String MP3_COMMENT = "mp3:comment";
+
+    /**
+     * {@inheritDoc}
+     */
+    public void sequence( InputStream stream, SequencerOutput output, ProgressMonitor progressMonitor ) {
+        Mp3Metadata metadata = Mp3Metadata.instance(stream);
+
+        if (metadata != null) {
+            // Place the image metadata into the output map ...
+            output.setProperty(METADATA_NODE, MP3_PRIMARY_TYPE, "mp3:metadata");
+            // output.psetProperty(METADATA_NODE, IMAGE_MIXINS, "");
+            output.setProperty(METADATA_NODE, MP3_TITLE, metadata.getTitle());
+            // output.setProperty(METADATA_NODE, IMAGE_ENCODING, "");
+            output.setProperty(METADATA_NODE, MP3_AUTHOR, metadata.getAuthor());
+            output.setProperty(METADATA_NODE, MP3_ALBUM, metadata.getAlbum());
+            output.setProperty(METADATA_NODE, MP3_YEAR, metadata.getYear());
+            output.setProperty(METADATA_NODE, MP3_COMMENT, metadata.getComment());
+        }
+    }
+}

Added: trunk/sequencers/dna-sequencer-mp3/src/main/resources/org/jboss/dna/sequencer/mp3/mp3.cnd
===================================================================
--- trunk/sequencers/dna-sequencer-mp3/src/main/resources/org/jboss/dna/sequencer/mp3/mp3.cnd	                        (rev 0)
+++ trunk/sequencers/dna-sequencer-mp3/src/main/resources/org/jboss/dna/sequencer/mp3/mp3.cnd	2008-05-12 20:12:29 UTC (rev 145)
@@ -0,0 +1,51 @@
+/*
+ * JBoss, Home of Professional Open Source.
+ * Copyright 2008, Red Hat Middleware LLC, and individual contributors
+ * as indicated by the @author tags. See the copyright.txt file in the
+ * distribution for a full listing of individual contributors. 
+ *
+ * This 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; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software 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 this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+ 
+//------------------------------------------------------------------------------
+// N A M E S P A C E S
+//------------------------------------------------------------------------------
+<jcr='http://www.jcp.org/jcr/1.0'>
+<nt='http://www.jcp.org/jcr/nt/1.0'>
+<mix='http://www.jcp.org/jcr/mix/1.0'>
+<mp3='http://jboss.org/dna/mp3/1.0'>
+
+// ----------------------------------------------------------
+// JCR Pre-defined Mixin Types that are not loaded by default
+// ----------------------------------------------------------
+
+[mix:mimeType] mixin 
+  - jcr:mimeType (string)  
+  - jcr:encoding (string)
+
+
+//------------------------------------------------------------------------------
+// N O D E T Y P E S
+//------------------------------------------------------------------------------
+
+[mp3:metadata] > nt:unstructured, mix:mimeTyped
+  - mp3:title (string)
+  - mp3:author (string)
+  - mp3:album (string)
+  - mp3:year (long)
+  - mp3:comment (string)
+ 
+ 
\ No newline at end of file

Added: trunk/sequencers/dna-sequencer-mp3/src/test/java/org/jboss/dna/sequencer/mp3/Mp3MetadataTest.java
===================================================================
--- trunk/sequencers/dna-sequencer-mp3/src/test/java/org/jboss/dna/sequencer/mp3/Mp3MetadataTest.java	                        (rev 0)
+++ trunk/sequencers/dna-sequencer-mp3/src/test/java/org/jboss/dna/sequencer/mp3/Mp3MetadataTest.java	2008-05-12 20:12:29 UTC (rev 145)
@@ -0,0 +1,39 @@
+package org.jboss.dna.sequencer.mp3;
+
+import static org.hamcrest.core.Is.is;
+import static org.junit.Assert.assertThat;
+import java.io.InputStream;
+import org.junit.After;
+import org.junit.Test;
+
+public class Mp3MetadataTest {
+
+    private Mp3Metadata metadata;
+    private InputStream imageStream;
+
+    @After
+    public void afterEach() throws Exception {
+        if (imageStream != null) {
+            try {
+                imageStream.close();
+            } finally {
+                imageStream = null;
+            }
+        }
+    }
+
+    protected InputStream getTestMp3( String resourcePath ) {
+        return this.getClass().getResourceAsStream("/" + resourcePath);
+    }
+
+    @Test
+    public void shouldBeAbleToCreateMetadataForSample1() {
+        metadata = Mp3Metadata.instance(this.getTestMp3("sample1.mp3"));
+        assertThat(metadata.getAlbum(), is("Badwater Slim Performs Live"));
+        assertThat(metadata.getAuthor(), is("Badwater Slim"));
+        assertThat(metadata.getComment(), is("This is a test audio file."));
+        assertThat(metadata.getTitle(), is("Sample MP3"));
+        assertThat(metadata.getYear(), is("2008"));
+    }
+
+}

Added: trunk/sequencers/dna-sequencer-mp3/src/test/resources/sample1.mp3
===================================================================
(Binary files differ)


Property changes on: trunk/sequencers/dna-sequencer-mp3/src/test/resources/sample1.mp3
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream




More information about the dna-commits mailing list