Author: maeste
Date: 2008-06-08 16:47:13 -0400 (Sun, 08 Jun 2008)
New Revision: 249
Added:
branches/maeste/sequencers/dna-sequencer-esbMessage/
branches/maeste/sequencers/dna-sequencer-esbMessage/.classpath
branches/maeste/sequencers/dna-sequencer-esbMessage/.project
branches/maeste/sequencers/dna-sequencer-esbMessage/pom.xml
branches/maeste/sequencers/dna-sequencer-esbMessage/src/
branches/maeste/sequencers/dna-sequencer-esbMessage/src/main/
branches/maeste/sequencers/dna-sequencer-esbMessage/src/main/java/
branches/maeste/sequencers/dna-sequencer-esbMessage/src/main/java/org/
branches/maeste/sequencers/dna-sequencer-esbMessage/src/main/java/org/jboss/
branches/maeste/sequencers/dna-sequencer-esbMessage/src/main/java/org/jboss/dna/
branches/maeste/sequencers/dna-sequencer-esbMessage/src/main/java/org/jboss/dna/sequencer/
branches/maeste/sequencers/dna-sequencer-esbMessage/src/main/java/org/jboss/dna/sequencer/esbMessage/
branches/maeste/sequencers/dna-sequencer-esbMessage/src/main/java/org/jboss/dna/sequencer/esbMessage/ESBMessageMetaData.java
branches/maeste/sequencers/dna-sequencer-esbMessage/src/main/java/org/jboss/dna/sequencer/esbMessage/ESBMessageSequencer.java
branches/maeste/sequencers/dna-sequencer-esbMessage/src/test/
branches/maeste/sequencers/dna-sequencer-esbMessage/src/test/java/
Modified:
branches/maeste/dna-repository/pom.xml
branches/maeste/pom.xml
Log:
[DNA-78 [DNA-109], [DNA-108 partial]] first implementation of ESBMessage Sequencer and
metadata
Modified: branches/maeste/dna-repository/pom.xml
===================================================================
--- branches/maeste/dna-repository/pom.xml 2008-06-07 20:29:57 UTC (rev 248)
+++ branches/maeste/dna-repository/pom.xml 2008-06-08 20:47:13 UTC (rev 249)
@@ -1,4 +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">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.jboss.dna</groupId>
@@ -80,6 +81,7 @@
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
+ <version>1.3</version>
<scope>test</scope>
</dependency>
<!--
Modified: branches/maeste/pom.xml
===================================================================
--- branches/maeste/pom.xml 2008-06-07 20:29:57 UTC (rev 248)
+++ branches/maeste/pom.xml 2008-06-08 20:47:13 UTC (rev 249)
@@ -61,6 +61,7 @@
<module>dna-maven-classloader</module>
<module>sequencers/dna-sequencer-images</module>
<module>sequencers/dna-sequencer-mp3</module>
+ <module>sequencers/dna-sequencer-esbMessage</module>
<module>connectors/dna-connector-jbosscache</module>
<module>dna-integration-tests</module>
</modules>
Added: branches/maeste/sequencers/dna-sequencer-esbMessage/.classpath
===================================================================
--- branches/maeste/sequencers/dna-sequencer-esbMessage/.classpath
(rev 0)
+++ branches/maeste/sequencers/dna-sequencer-esbMessage/.classpath 2008-06-08 20:47:13 UTC
(rev 249)
@@ -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: branches/maeste/sequencers/dna-sequencer-esbMessage/.project
===================================================================
--- branches/maeste/sequencers/dna-sequencer-esbMessage/.project
(rev 0)
+++ branches/maeste/sequencers/dna-sequencer-esbMessage/.project 2008-06-08 20:47:13 UTC
(rev 249)
@@ -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: branches/maeste/sequencers/dna-sequencer-esbMessage/pom.xml
===================================================================
--- branches/maeste/sequencers/dna-sequencer-esbMessage/pom.xml
(rev 0)
+++ branches/maeste/sequencers/dna-sequencer-esbMessage/pom.xml 2008-06-08 20:47:13 UTC
(rev 249)
@@ -0,0 +1,35 @@
+<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.2-SNAPSHOT</version>
+ <relativePath>../..</relativePath>
+ </parent>
+ <!-- The groupId and version values are inherited from parent -->
+ <artifactId>dna-sequencer-esbMessage</artifactId>
+ <packaging>jar</packaging>
+ <name>JBoss DNA ESB Message Sequencer</name>
+ <description>JBoss DNA Sequencer that processes ESB Message</description>
+ <
url>http://labs.jboss.org/dna</url>
+ <dependencies>
+ <dependency>
+ <groupId>org.jboss.dna</groupId>
+ <artifactId>dna-common</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>org.jboss.dna</groupId>
+ <artifactId>dna-spi</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>junit</groupId>
+ <artifactId>junit-dep</artifactId>
+ <version>4.4</version>
+ </dependency>
+ <dependency>
+ <groupId>jbossesb-rosetta.jar</groupId>
+ <artifactId>jbossesb-rosetta-dep</artifactId>
+ <version>4.3</version>
+ </dependency>
+ </dependencies>
+</project>
\ No newline at end of file
Added:
branches/maeste/sequencers/dna-sequencer-esbMessage/src/main/java/org/jboss/dna/sequencer/esbMessage/ESBMessageMetaData.java
===================================================================
---
branches/maeste/sequencers/dna-sequencer-esbMessage/src/main/java/org/jboss/dna/sequencer/esbMessage/ESBMessageMetaData.java
(rev 0)
+++
branches/maeste/sequencers/dna-sequencer-esbMessage/src/main/java/org/jboss/dna/sequencer/esbMessage/ESBMessageMetaData.java 2008-06-08
20:47:13 UTC (rev 249)
@@ -0,0 +1,169 @@
+/*
+ * 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.esbMessage;
+
+import java.io.InputStream;
+import java.io.Serializable;
+import java.net.URI;
+import java.util.HashMap;
+import java.util.Map;
+import org.jboss.dna.common.util.StringUtil;
+import org.jboss.internal.soa.esb.util.Encoding;
+import org.jboss.soa.esb.addressing.EPR;
+import org.jboss.soa.esb.message.Message;
+import org.jboss.soa.esb.util.Util;
+
+/**
+ * Utility for extracting metadata from MP3 files.
+ *
+ * @author Stefano Maestri
+ */
+public class ESBMessageMetaData {
+
+ private URI messageType;
+ private EPR to = null;
+ private EPR from = null;
+ private EPR faultTo = null;
+ private EPR replyTo = null;
+ private URI relatesTo = null;
+ private URI action = null;
+ private URI messageID = null;
+ private Map<String, Object> bodyMap = null;
+ private Map<String, Object> propertiesMap = null;
+ private Map<String, Object> attachmentsMap = null;
+ private URI faultCode = null;
+ private String faultReason;
+ private Throwable faultCause;
+
+ private ESBMessageMetaData() {
+
+ }
+
+ public static ESBMessageMetaData instance( InputStream stream ) {
+
+ ESBMessageMetaData me = null;
+ Message message = null;
+ try {
+ me = new ESBMessageMetaData();
+ message =
Util.deserialize((Serializable)Encoding.decodeToObject(StringUtil.read(stream)));
+ } catch (Exception e) {
+ e.printStackTrace();
+ return null;
+ }
+
+ me.messageType = message.getType();
+ // Context not yet implemented in JBossESB
+ // message.getContext();
+
+ me.to = message.getHeader().getCall().getTo();
+ me.from = message.getHeader().getCall().getFrom();
+ me.faultTo = message.getHeader().getCall().getFaultTo();
+ me.replyTo = message.getHeader().getCall().getReplyTo();
+ me.relatesTo = message.getHeader().getCall().getRelatesTo();
+ me.action = message.getHeader().getCall().getAction();
+ me.messageID = message.getHeader().getCall().getMessageID();
+
+ if (message.getBody().getNames().length != 0) {
+ me.bodyMap = new HashMap<String, Object>();
+ }
+ for (String name : message.getBody().getNames()) {
+ me.bodyMap.put(name, message.getBody().get(name));
+ }
+
+ if (message.getProperties().getNames().length != 0) {
+ me.propertiesMap = new HashMap<String, Object>();
+ }
+ for (String name : message.getProperties().getNames()) {
+ me.propertiesMap.put(name, message.getProperties().getProperty(name));
+ }
+
+ if (message.getAttachment().getNames().length != 0) {
+ me.attachmentsMap = new HashMap<String, Object>();
+ }
+ for (String name : message.getAttachment().getNames()) {
+ me.attachmentsMap.put(name, message.getAttachment().get(name));
+ }
+
+ me.faultCause = message.getFault().getCause();
+ me.faultCode = message.getFault().getCode();
+ me.faultReason = message.getFault().getReason();
+
+ return me;
+
+ }
+
+ public URI getMessageType() {
+ return messageType;
+ }
+
+ public EPR getTo() {
+ return to;
+ }
+
+ public EPR getFrom() {
+ return from;
+ }
+
+ public EPR getFaultTo() {
+ return faultTo;
+ }
+
+ public EPR getReplyTo() {
+ return replyTo;
+ }
+
+ public URI getRelatesTo() {
+ return relatesTo;
+ }
+
+ public URI getAction() {
+ return action;
+ }
+
+ public URI getMessageID() {
+ return messageID;
+ }
+
+ public Map<String, Object> getBodyMap() {
+ return bodyMap;
+ }
+
+ public Map<String, Object> getPropertiesMap() {
+ return propertiesMap;
+ }
+
+ public Map<String, Object> getAttachmentsMap() {
+ return attachmentsMap;
+ }
+
+ public URI getFaultCode() {
+ return faultCode;
+ }
+
+ public String getFaultReason() {
+ return faultReason;
+ }
+
+ public Throwable getFaultCause() {
+ return faultCause;
+ }
+}
Added:
branches/maeste/sequencers/dna-sequencer-esbMessage/src/main/java/org/jboss/dna/sequencer/esbMessage/ESBMessageSequencer.java
===================================================================
---
branches/maeste/sequencers/dna-sequencer-esbMessage/src/main/java/org/jboss/dna/sequencer/esbMessage/ESBMessageSequencer.java
(rev 0)
+++
branches/maeste/sequencers/dna-sequencer-esbMessage/src/main/java/org/jboss/dna/sequencer/esbMessage/ESBMessageSequencer.java 2008-06-08
20:47:13 UTC (rev 249)
@@ -0,0 +1,70 @@
+/*
+ * 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.esbMessage;
+
+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>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
+ */
+public class ESBMessageSequencer implements StreamSequencer {
+
+ public static final String METADATA_NODE = "esbMessage:metadata";
+ public static final String ESB_MESSAGE_PRIMARY_TYPE = "jcr:primaryType";
+
+ public void sequence( InputStream stream,
+ SequencerOutput output,
+ ProgressMonitor progressMonitor ) {
+ ESBMessageMetaData metadata = ESBMessageMetaData.instance(stream);
+
+ if (metadata != null) {
+ // Place the image metadata into the output map ...
+ output.setProperty(METADATA_NODE, ESB_MESSAGE_PRIMARY_TYPE,
"esbMessage:metadata");
+ // output.setProperty(METADATA_NODE, MP3_TITLE, metadata.getTitle());
+ // 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());
+ }
+ }
+
+}