Author: rhauch
Date: 2008-05-27 22:46:17 -0400 (Tue, 27 May 2008)
New Revision: 203
Modified:
branches/federation/dna-repository/src/main/java/org/jboss/dna/repository/sequencers/SequencerOutputMap.java
branches/federation/dna-repository/src/main/java/org/jboss/dna/repository/sequencers/StreamSequencerAdapter.java
branches/federation/dna-repository/src/test/java/org/jboss/dna/repository/sequencers/StreamSequencerAdapterTest.java
branches/federation/dna-spi/src/main/java/org/jboss/dna/spi/sequencers/SequencerOutput.java
branches/federation/dna-spi/src/test/java/org/jboss/dna/spi/sequencers/MockSequencerOutput.java
branches/federation/sequencers/dna-sequencer-images/src/main/java/org/jboss/dna/sequencer/images/ImageMetadataSequencer.java
branches/federation/sequencers/dna-sequencer-images/src/test/java/org/jboss/dna/sequencer/images/ImageMetadataSequencerTest.java
Log:
Merged changes from turnk to federation branch
Modified:
branches/federation/dna-repository/src/main/java/org/jboss/dna/repository/sequencers/SequencerOutputMap.java
===================================================================
---
branches/federation/dna-repository/src/main/java/org/jboss/dna/repository/sequencers/SequencerOutputMap.java 2008-05-27
21:50:04 UTC (rev 202)
+++
branches/federation/dna-repository/src/main/java/org/jboss/dna/repository/sequencers/SequencerOutputMap.java 2008-05-28
02:46:17 UTC (rev 203)
@@ -32,8 +32,10 @@
import net.jcip.annotations.NotThreadSafe;
import org.jboss.dna.common.util.ArgCheck;
import org.jboss.dna.common.util.StringUtil;
+import org.jboss.dna.spi.graph.Name;
import org.jboss.dna.spi.graph.Path;
import org.jboss.dna.spi.graph.PathFactory;
+import org.jboss.dna.spi.graph.ValueFactories;
import org.jboss.dna.spi.sequencers.SequencerOutput;
/**
@@ -48,37 +50,45 @@
private static final String JCR_NAME_PROPERTY_NAME = "jcr:name";
private final Map<Path, List<PropertyValue>> data;
- private boolean valuesSorted = true;
- private final PathFactory pathFactory;
+ private transient boolean valuesSorted = true;
+ private final ValueFactories factories;
+ private final Name jcrName;
- public SequencerOutputMap( PathFactory pathFactory ) {
- ArgCheck.isNotNull(pathFactory, "pathFactory");
+ public SequencerOutputMap( ValueFactories factories ) {
+ ArgCheck.isNotNull(factories, "factories");
this.data = new HashMap<Path, List<PropertyValue>>();
- this.pathFactory = pathFactory;
+ this.factories = factories;
+ this.jcrName = this.factories.getNameFactory().create(JCR_NAME_PROPERTY_NAME);
}
/**
* {@inheritDoc}
*/
- public void setProperty( String nodePath, String property, Object... values ) {
- property = property.trim();
- if (JCR_NAME_PROPERTY_NAME.equals(property)) return; // ignore the
"jcr:name" property
- nodePath = nodePath.trim();
- if (nodePath.endsWith("/")) nodePath =
nodePath.replaceFirst("/+$", "");
+ public ValueFactories getFactories() {
+ return this.factories;
+ }
+ /**
+ * {@inheritDoc}
+ */
+ public void setProperty( Path nodePath, Name propertyName, Object... values ) {
+ ArgCheck.isNotNull(nodePath, "nodePath");
+ ArgCheck.isNotNull(propertyName, "property");
+ // Ignore the "jcr:name" property, as that's handled by the path
...
+ if (this.jcrName.equals(propertyName)) return;
+
// Find or create the entry for this node ...
- Path path = pathFactory.create(nodePath);
- List<PropertyValue> properties = this.data.get(path);
+ List<PropertyValue> properties = this.data.get(nodePath);
if (properties == null) {
if (values == null || values.length == 0) return; // do nothing
properties = new ArrayList<PropertyValue>();
- this.data.put(path, properties);
+ this.data.put(nodePath, properties);
}
if (values == null || values.length == 0) {
- properties.remove(new PropertyValue(property, null));
+ properties.remove(new PropertyValue(propertyName, null));
} else {
Object propValue = values.length == 1 ? values[0] : values;
- PropertyValue value = new PropertyValue(property, propValue);
+ PropertyValue value = new PropertyValue(propertyName, propValue);
properties.add(value);
valuesSorted = false;
}
@@ -87,18 +97,30 @@
/**
* {@inheritDoc}
*/
- public void setReference( String nodePath, String property, String... paths ) {
- if (paths == null || paths.length == 0) {
- setProperty(nodePath, property, (Object[])null);
- } else if (paths.length == 1) {
- setProperty(nodePath, property, pathFactory.create(paths[0]));
- } else {
- Path[] pathsArray = new Path[paths.length];
- for (int i = 0; i != paths.length; ++i) {
- pathsArray[i] = pathFactory.create(paths[i]);
+ public void setProperty( String nodePath, String property, Object... values ) {
+ ArgCheck.isNotEmpty(nodePath, "nodePath");
+ ArgCheck.isNotEmpty(property, "property");
+ Path path = this.factories.getPathFactory().create(nodePath);
+ Name propertyName = this.factories.getNameFactory().create(property);
+ setProperty(path, propertyName, values);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setReference( String nodePath, String propertyName, String... paths ) {
+ PathFactory pathFactory = this.factories.getPathFactory();
+ Path path = pathFactory.create(nodePath);
+ Name name = this.factories.getNameFactory().create(propertyName);
+ Object[] values = null;
+ if (paths != null && paths.length != 0) {
+ values = new Path[paths.length];
+ for (int i = 0, len = paths.length; i != len; ++i) {
+ String pathValue = paths[i];
+ values[i] = pathFactory.create(pathValue);
}
- setProperty(nodePath, property, (Object[])pathsArray);
}
+ setProperty(path, name, values);
}
/**
@@ -167,10 +189,10 @@
@Immutable
public class PropertyValue implements Comparable<PropertyValue> {
- private final String name;
+ private final Name name;
private final Object value;
- protected PropertyValue( String propertyName, Object value ) {
+ protected PropertyValue( Name propertyName, Object value ) {
this.name = propertyName;
this.value = value;
}
@@ -179,7 +201,7 @@
* Get the property name.
* @return the property name; never null
*/
- public String getName() {
+ public Name getName() {
return this.name;
}
@@ -241,7 +263,7 @@
public class Entry {
private final Path path;
- private final String primaryType;
+ private final Name primaryType;
private final List<PropertyValue> properties;
protected Entry( Path path, List<PropertyValue> properties ) {
@@ -251,7 +273,7 @@
this.properties = properties;
if (this.properties.size() > 0 &&
this.properties.get(0).getName().equals("jcr:primaryType")) {
PropertyValue primaryTypeProperty = this.properties.remove(0);
- this.primaryType = primaryTypeProperty.getValue().toString();
+ this.primaryType =
getFactories().getNameFactory().create(primaryTypeProperty.getValue());
} else {
this.primaryType = null;
}
@@ -268,7 +290,7 @@
* Get the primary type specified for this node, or null if the type was not
specified
* @return the primary type, or null
*/
- public String getPrimaryTypeValue() {
+ public Name getPrimaryTypeValue() {
return this.primaryType;
}
Modified:
branches/federation/dna-repository/src/main/java/org/jboss/dna/repository/sequencers/StreamSequencerAdapter.java
===================================================================
---
branches/federation/dna-repository/src/main/java/org/jboss/dna/repository/sequencers/StreamSequencerAdapter.java 2008-05-27
21:50:04 UTC (rev 202)
+++
branches/federation/dna-repository/src/main/java/org/jboss/dna/repository/sequencers/StreamSequencerAdapter.java 2008-05-28
02:46:17 UTC (rev 203)
@@ -22,7 +22,9 @@
package org.jboss.dna.repository.sequencers;
import java.io.InputStream;
+import java.math.BigDecimal;
import java.util.Calendar;
+import java.util.Date;
import java.util.Set;
import javax.jcr.Node;
import javax.jcr.PathNotFoundException;
@@ -35,6 +37,9 @@
import org.jboss.dna.repository.observation.NodeChange;
import org.jboss.dna.repository.util.ExecutionContext;
import org.jboss.dna.repository.util.RepositoryNodePath;
+import org.jboss.dna.spi.graph.Binary;
+import org.jboss.dna.spi.graph.DateTime;
+import org.jboss.dna.spi.graph.Name;
import org.jboss.dna.spi.graph.NamespaceRegistry;
import org.jboss.dna.spi.graph.Path;
import org.jboss.dna.spi.graph.PathFactory;
@@ -90,7 +95,7 @@
progressMonitor.worked(10);
// Get the binary property with the image content, and build the image
metadata from the image ...
- SequencerOutputMap output = new
SequencerOutputMap(context.getValueFactories().getPathFactory());
+ SequencerOutputMap output = new
SequencerOutputMap(context.getValueFactories());
InputStream stream = null;
Throwable firstError = null;
ProgressMonitor sequencingMonitor = progressMonitor.createSubtask(50);
@@ -169,7 +174,7 @@
// prefix and name)
for (SequencerOutputMap.Entry entry : output) {
Path targetNodePath = entry.getPath();
- String primaryType = entry.getPrimaryTypeValue();
+ Name primaryType = entry.getPrimaryTypeValue();
// Resolve this path relative to the output node path, handling any parent or
self references ...
Path absolutePath = targetNodePath.isAbsolute() ? targetNodePath :
outputNodePath.resolve(targetNodePath);
@@ -190,7 +195,7 @@
}
// We only have the primary type for the final one ...
if (i == (max - 1) && primaryType != null) {
- targetNode = targetNode.addNode(qualifiedName, primaryType);
+ targetNode = targetNode.addNode(qualifiedName,
primaryType.getString(namespaceRegistry, Path.NO_OP_ENCODER));
} else {
targetNode = targetNode.addNode(qualifiedName);
}
@@ -201,13 +206,15 @@
// Set all of the properties on this
for (SequencerOutputMap.PropertyValue property : entry.getPropertyValues())
{
- String propertyName = property.getName();
+ String propertyName = property.getName().getString(namespaceRegistry,
Path.NO_OP_ENCODER);
Object value = property.getValue();
Logger.getLogger(this.getClass()).trace("Writing property
{0}/{1}={2}", targetNode.getPath(), propertyName, value);
if (value instanceof Boolean) {
targetNode.setProperty(propertyName,
((Boolean)value).booleanValue());
} else if (value instanceof String) {
targetNode.setProperty(propertyName, (String)value);
+ } else if (value instanceof String[]) {
+ targetNode.setProperty(propertyName, (String[])value);
} else if (value instanceof Integer) {
targetNode.setProperty(propertyName, ((Integer)value).intValue());
} else if (value instanceof Short) {
@@ -218,8 +225,27 @@
targetNode.setProperty(propertyName, ((Float)value).floatValue());
} else if (value instanceof Double) {
targetNode.setProperty(propertyName, ((Double)value).doubleValue());
+ } else if (value instanceof Binary) {
+ Binary binaryValue = (Binary)value;
+ try {
+ binaryValue.acquire();
+ targetNode.setProperty(propertyName, binaryValue.getStream());
+ } finally {
+ binaryValue.release();
+ }
+ } else if (value instanceof BigDecimal) {
+ targetNode.setProperty(propertyName,
((BigDecimal)value).doubleValue());
+ } else if (value instanceof DateTime) {
+ targetNode.setProperty(propertyName,
((DateTime)value).toCalendar());
+ } else if (value instanceof Date) {
+ DateTime instant =
context.getValueFactories().getDateFactory().create((Date)value);
+ targetNode.setProperty(propertyName, instant.toCalendar());
} else if (value instanceof Calendar) {
targetNode.setProperty(propertyName, (Calendar)value);
+ } else if (value instanceof Name) {
+ Name nameValue = (Name)value;
+ String stringValue = nameValue.getString(namespaceRegistry);
+ targetNode.setProperty(propertyName, stringValue);
} else if (value instanceof Path) {
// Find the path to reference node ...
Path pathToReferencedNode = (Path)value;
Modified:
branches/federation/dna-repository/src/test/java/org/jboss/dna/repository/sequencers/StreamSequencerAdapterTest.java
===================================================================
---
branches/federation/dna-repository/src/test/java/org/jboss/dna/repository/sequencers/StreamSequencerAdapterTest.java 2008-05-27
21:50:04 UTC (rev 202)
+++
branches/federation/dna-repository/src/test/java/org/jboss/dna/repository/sequencers/StreamSequencerAdapterTest.java 2008-05-28
02:46:17 UTC (rev 203)
@@ -39,16 +39,14 @@
import org.jboss.dna.common.monitor.ProgressMonitor;
import org.jboss.dna.common.monitor.RecordingProgressMonitor;
import org.jboss.dna.repository.observation.NodeChange;
-import org.jboss.dna.repository.sequencers.SequencerConfig;
-import org.jboss.dna.repository.sequencers.SequencerException;
-import org.jboss.dna.repository.sequencers.SequencerOutputMap;
-import org.jboss.dna.repository.sequencers.StreamSequencerAdapter;
import org.jboss.dna.repository.util.ExecutionContext;
+import org.jboss.dna.repository.util.JcrNamespaceRegistry;
import org.jboss.dna.repository.util.JcrTools;
import org.jboss.dna.repository.util.RepositoryNodePath;
import org.jboss.dna.repository.util.SessionFactory;
import org.jboss.dna.repository.util.SimpleExecutionContext;
-import org.jboss.dna.spi.graph.impl.BasicNamespaceRegistry;
+import org.jboss.dna.spi.graph.NamespaceRegistry;
+import org.jboss.dna.spi.graph.Path;
import org.jboss.dna.spi.sequencers.SequencerOutput;
import org.jboss.dna.spi.sequencers.StreamSequencer;
import org.junit.After;
@@ -82,8 +80,9 @@
return createTestSession();
}
};
- this.context = new SimpleExecutionContext(sessionFactory, new
BasicNamespaceRegistry(), null);
- this.sequencerOutput = new
SequencerOutputMap(this.context.getValueFactories().getPathFactory());
+ NamespaceRegistry registry = new JcrNamespaceRegistry(sessionFactory,
"doesn't matter");
+ this.context = new SimpleExecutionContext(sessionFactory, registry, null);
+ this.sequencerOutput = new SequencerOutputMap(this.context.getValueFactories());
this.progressMonitor = new
RecordingProgressMonitor(StreamSequencerAdapterTest.class.getName());
final SequencerOutputMap finalOutput = sequencerOutput;
this.streamSequencer = new StreamSequencer() {
@@ -94,7 +93,7 @@
*/
public void sequence( InputStream stream, SequencerOutput output,
ProgressMonitor progressMonitor ) {
for (SequencerOutputMap.Entry entry : finalOutput) {
- String nodePath = entry.getPath().getString();
+ Path nodePath = entry.getPath();
for (SequencerOutputMap.PropertyValue property :
entry.getPropertyValues()) {
output.setProperty(nodePath, property.getName(),
property.getValue());
}
Modified:
branches/federation/dna-spi/src/main/java/org/jboss/dna/spi/sequencers/SequencerOutput.java
===================================================================
---
branches/federation/dna-spi/src/main/java/org/jboss/dna/spi/sequencers/SequencerOutput.java 2008-05-27
21:50:04 UTC (rev 202)
+++
branches/federation/dna-spi/src/main/java/org/jboss/dna/spi/sequencers/SequencerOutput.java 2008-05-28
02:46:17 UTC (rev 203)
@@ -21,48 +21,62 @@
*/
package org.jboss.dna.spi.sequencers;
-import java.io.InputStream;
-import java.util.Calendar;
+import org.jboss.dna.spi.graph.Name;
+import org.jboss.dna.spi.graph.Path;
+import org.jboss.dna.spi.graph.ValueFactories;
/**
* Interface for sequencers to use to generate their output.
- *
* @author Randall Hauch
*/
public interface SequencerOutput {
- /**
- * Set the supplied property on the supplied node.
- * <p>
- * The allowable values are any of the following:
- * <ul>
- * <li>primitives (which will be autoboxed)</li>
- * <li>{@link String} instances</li>
- * <li>{@link String} arrays</li>
- * <li>byte arrays</li>
- * <li>{@link InputStream} instances</li>
- * <li>{@link Calendar} instances</li>
- * <li></li>
- * </ul>
- * </p>
- *
- * @param nodePath the path to the node containing the property; may not be null
- * @param property the name of the property to be set
- * @param values the value(s) for the property; may be empty if any existing property is
to be removed
- */
- void setProperty( String nodePath,
- String property,
- Object... values );
+ /**
+ * Get the factories that can be used to create {@link Path paths} and other property
values.
+ * @return the collection of factories; never null
+ */
+ ValueFactories getFactories();
- /**
- * Set the supplied reference on the supplied node.
- *
- * @param nodePath the path to the node containing the property; may not be null
- * @param property the name of the property to be set
- * @param paths the paths to the referenced property, which may be absolute paths or
relative to the sequencer output node;
- * may be empty if any existing property is to be removed
- */
- void setReference( String nodePath,
- String property,
- String... paths );
+ /**
+ * Set the supplied property on the supplied node.
+ * <p>
+ * The {@link #getFactories() value factories} should be used to create paths, names,
and values. These factories can be used
+ * to create new values or convert values from one property type to another. (Note
that each of the factories have methods
+ * that create values from all of the property types.)
+ * </p>
+ * <p>
+ * This method is provided as a convenience, but it identical to creating a {@link
Path} and {@link Name} using the
+ * {@link #getFactories() factories} and calling {@link #setProperty(Path, Name,
Object...)}.
+ * </p>
+ * @param nodePath the path to the node containing the property; may not be null
+ * @param propertyName the name of the property to be set
+ * @param values the value(s) for the property; may be empty if any existing property
is to be removed
+ */
+ void setProperty( String nodePath, String propertyName, Object... values );
+
+ /**
+ * Set the supplied reference on the supplied node.
+ * <p>
+ * This method is provided as a convenience, but it identical to creating a {@link
Path} and {@link Name} using the
+ * {@link #getFactories() factories} and calling {@link #setProperty(Path, Name,
Object...)}.
+ * </p>
+ * @param nodePath the path to the node containing the property; may not be null
+ * @param propertyName the name of the property to be set
+ * @param paths the paths to the referenced property, which may be absolute paths or
relative to the sequencer output node;
+ * may be empty if any existing property is to be removed
+ */
+ void setReference( String nodePath, String propertyName, String... paths );
+
+ /**
+ * Set the supplied property on the supplied node.
+ * <p>
+ * The {@link #getFactories() value factories} should be used to create paths, names,
and values. These factories can be used
+ * to create new values or convert values from one property type to another. (Note
that each of the factories have methods
+ * that create values from all of the property types.)
+ * </p>
+ * @param nodePath the path to the node containing the property; may not be null
+ * @param propertyName the name of the property to be set
+ * @param values the value(s) for the property; may be empty if any existing property
is to be removed
+ */
+ void setProperty( Path nodePath, Name propertyName, Object... values );
}
Modified:
branches/federation/dna-spi/src/test/java/org/jboss/dna/spi/sequencers/MockSequencerOutput.java
===================================================================
---
branches/federation/dna-spi/src/test/java/org/jboss/dna/spi/sequencers/MockSequencerOutput.java 2008-05-27
21:50:04 UTC (rev 202)
+++
branches/federation/dna-spi/src/test/java/org/jboss/dna/spi/sequencers/MockSequencerOutput.java 2008-05-28
02:46:17 UTC (rev 203)
@@ -24,6 +24,11 @@
import java.util.HashMap;
import java.util.Map;
import net.jcip.annotations.NotThreadSafe;
+import org.jboss.dna.common.util.ArgCheck;
+import org.jboss.dna.spi.graph.Name;
+import org.jboss.dna.spi.graph.Path;
+import org.jboss.dna.spi.graph.PathFactory;
+import org.jboss.dna.spi.graph.ValueFactories;
/**
* @author Randall Hauch
@@ -31,22 +36,30 @@
@NotThreadSafe
public class MockSequencerOutput implements SequencerOutput {
- private final Map<String, Object[]> properties;
- private final Map<String, String[]> references;
+ private final Map<Path, Object[]> properties;
+ private final ValueFactories factories;
/**
- *
+ * @param factories the factories to be used to create output property values
*/
- public MockSequencerOutput() {
- this.properties = new HashMap<String, Object[]>();
- this.references = new HashMap<String, String[]>();
+ public MockSequencerOutput( ValueFactories factories ) {
+ ArgCheck.isNotNull(factories, "factories");
+ this.properties = new HashMap<Path, Object[]>();
+ this.factories = factories;
}
/**
* {@inheritDoc}
*/
- public void setProperty( String nodePath, String property, Object... values ) {
- String key = getKey(nodePath, property);
+ public ValueFactories getFactories() {
+ return this.factories;
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setProperty( Path nodePath, Name propertyName, Object... values ) {
+ Path key = getKey(nodePath, propertyName);
if (values == null || values.length == 0) {
this.properties.remove(key);
} else {
@@ -57,45 +70,52 @@
/**
* {@inheritDoc}
*/
- public void setReference( String nodePath, String property, String... paths ) {
- String key = getKey(nodePath, property);
- if (paths == null || paths.length == 0) {
- this.references.remove(key);
- } else {
- this.references.put(key, paths);
+ public void setProperty( String nodePath, String propertyName, Object... values ) {
+ Path path = this.factories.getPathFactory().create(nodePath);
+ Name name = this.factories.getNameFactory().create(propertyName);
+ setProperty(path, name, values);
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ public void setReference( String nodePath, String propertyName, String... paths ) {
+ PathFactory pathFactory = this.factories.getPathFactory();
+ Path path = pathFactory.create(nodePath);
+ Name name = this.factories.getNameFactory().create(propertyName);
+ Object[] values = null;
+ if (paths != null && paths.length != 0) {
+ values = new Path[paths.length];
+ for (int i = 0, len = paths.length; i != len; ++i) {
+ String pathValue = paths[i];
+ values[i] = pathFactory.create(pathValue);
+ }
}
+ setProperty(path, name, values);
}
public Object[] getPropertyValues( String nodePath, String property ) {
- String key = getKey(nodePath, property);
+ Path key = getKey(nodePath, property);
return this.properties.get(key);
}
- public String[] getReferenceValues( String nodePath, String property ) {
- String key = getKey(nodePath, property);
- return this.references.get(key);
- }
-
public boolean hasProperty( String nodePath, String property ) {
- String key = nodePath + "@" + property;
+ Path key = getKey(nodePath, property);
return this.properties.containsKey(key);
}
- public boolean hasReference( String nodePath, String property ) {
- String key = nodePath + "@" + property;
- return this.references.containsKey(key);
- }
-
public boolean hasProperties() {
return this.properties.size() > 0;
}
- public boolean hasReferences() {
- return this.references.size() > 0;
+ protected Path getKey( String nodePath, String propertyName ) {
+ Path path = this.factories.getPathFactory().create(nodePath);
+ Name name = this.factories.getNameFactory().create(propertyName);
+ return getKey(path, name);
}
- protected String getKey( String nodePath, String property ) {
- return nodePath + "@" + property;
+ protected Path getKey( Path nodePath, Name propertyName ) {
+ return this.factories.getPathFactory().create(nodePath, propertyName);
}
}
Modified:
branches/federation/sequencers/dna-sequencer-images/src/main/java/org/jboss/dna/sequencer/images/ImageMetadataSequencer.java
===================================================================
---
branches/federation/sequencers/dna-sequencer-images/src/main/java/org/jboss/dna/sequencer/images/ImageMetadataSequencer.java 2008-05-27
21:50:04 UTC (rev 202)
+++
branches/federation/sequencers/dna-sequencer-images/src/main/java/org/jboss/dna/sequencer/images/ImageMetadataSequencer.java 2008-05-28
02:46:17 UTC (rev 203)
@@ -23,6 +23,9 @@
import java.io.InputStream;
import org.jboss.dna.common.monitor.ProgressMonitor;
+import org.jboss.dna.spi.graph.NameFactory;
+import org.jboss.dna.spi.graph.Path;
+import org.jboss.dna.spi.graph.PathFactory;
import org.jboss.dna.spi.sequencers.SequencerOutput;
import org.jboss.dna.spi.sequencers.StreamSequencer;
@@ -99,21 +102,25 @@
// Generate the output graph if we found useful metadata ...
if (metadata != null) {
+ NameFactory nameFactory = output.getFactories().getNameFactory();
+ PathFactory pathFactory = output.getFactories().getPathFactory();
+ Path metadataNode = pathFactory.create(METADATA_NODE);
+
// Place the image metadata into the output map ...
- output.setProperty(METADATA_NODE, IMAGE_PRIMARY_TYPE,
"image:metadata");
- // output.psetProperty(METADATA_NODE, IMAGE_MIXINS, "");
- output.setProperty(METADATA_NODE, IMAGE_MIME_TYPE, metadata.getMimeType());
- // output.setProperty(METADATA_NODE, IMAGE_ENCODING, "");
- output.setProperty(METADATA_NODE, IMAGE_FORMAT_NAME,
metadata.getFormatName());
- output.setProperty(METADATA_NODE, IMAGE_WIDTH, metadata.getWidth());
- output.setProperty(METADATA_NODE, IMAGE_HEIGHT, metadata.getHeight());
- output.setProperty(METADATA_NODE, IMAGE_BITS_PER_PIXEL,
metadata.getBitsPerPixel());
- output.setProperty(METADATA_NODE, IMAGE_PROGRESSIVE,
metadata.isProgressive());
- output.setProperty(METADATA_NODE, IMAGE_NUMBER_OF_IMAGES,
metadata.getNumberOfImages());
- output.setProperty(METADATA_NODE, IMAGE_PHYSICAL_WIDTH_DPI,
metadata.getPhysicalWidthDpi());
- output.setProperty(METADATA_NODE, IMAGE_PHYSICAL_HEIGHT_DPI,
metadata.getPhysicalHeightDpi());
- output.setProperty(METADATA_NODE, IMAGE_PHYSICAL_WIDTH_INCHES,
metadata.getPhysicalWidthInch());
- output.setProperty(METADATA_NODE, IMAGE_PHYSICAL_HEIGHT_INCHES,
metadata.getPhysicalHeightInch());
+ output.setProperty(metadataNode, nameFactory.create(IMAGE_PRIMARY_TYPE),
"image:metadata");
+ // output.psetProperty(metadataNode, nameFactory.create(IMAGE_MIXINS),
"");
+ output.setProperty(metadataNode, nameFactory.create(IMAGE_MIME_TYPE),
metadata.getMimeType());
+ // output.setProperty(metadataNode, nameFactory.create(IMAGE_ENCODING),
"");
+ output.setProperty(metadataNode, nameFactory.create(IMAGE_FORMAT_NAME),
metadata.getFormatName());
+ output.setProperty(metadataNode, nameFactory.create(IMAGE_WIDTH),
metadata.getWidth());
+ output.setProperty(metadataNode, nameFactory.create(IMAGE_HEIGHT),
metadata.getHeight());
+ output.setProperty(metadataNode, nameFactory.create(IMAGE_BITS_PER_PIXEL),
metadata.getBitsPerPixel());
+ output.setProperty(metadataNode, nameFactory.create(IMAGE_PROGRESSIVE),
metadata.isProgressive());
+ output.setProperty(metadataNode, nameFactory.create(IMAGE_NUMBER_OF_IMAGES),
metadata.getNumberOfImages());
+ output.setProperty(metadataNode,
nameFactory.create(IMAGE_PHYSICAL_WIDTH_DPI), metadata.getPhysicalWidthDpi());
+ output.setProperty(metadataNode,
nameFactory.create(IMAGE_PHYSICAL_HEIGHT_DPI), metadata.getPhysicalHeightDpi());
+ output.setProperty(metadataNode,
nameFactory.create(IMAGE_PHYSICAL_WIDTH_INCHES), metadata.getPhysicalWidthInch());
+ output.setProperty(metadataNode,
nameFactory.create(IMAGE_PHYSICAL_HEIGHT_INCHES), metadata.getPhysicalHeightInch());
}
progressMonitor.done();
Modified:
branches/federation/sequencers/dna-sequencer-images/src/test/java/org/jboss/dna/sequencer/images/ImageMetadataSequencerTest.java
===================================================================
---
branches/federation/sequencers/dna-sequencer-images/src/test/java/org/jboss/dna/sequencer/images/ImageMetadataSequencerTest.java 2008-05-27
21:50:04 UTC (rev 202)
+++
branches/federation/sequencers/dna-sequencer-images/src/test/java/org/jboss/dna/sequencer/images/ImageMetadataSequencerTest.java 2008-05-28
02:46:17 UTC (rev 203)
@@ -30,6 +30,9 @@
import java.net.URL;
import org.jboss.dna.common.monitor.ProgressMonitor;
import org.jboss.dna.common.monitor.SimpleProgressMonitor;
+import org.jboss.dna.spi.graph.NamespaceRegistry;
+import org.jboss.dna.spi.graph.impl.BasicNamespaceRegistry;
+import org.jboss.dna.spi.graph.impl.StandardValueFactories;
import org.jboss.dna.spi.sequencers.MockSequencerOutput;
import org.junit.After;
import org.junit.Before;
@@ -52,7 +55,12 @@
@Before
public void beforeEach() throws Exception {
this.sequencer = new ImageMetadataSequencer();
- this.output = new MockSequencerOutput();
+ NamespaceRegistry registry = new BasicNamespaceRegistry();
+ registry.register("image",
"http://jboss.org/dna/images/1.0");
+ registry.register("jcr", "http://www.jcp.org/jcr/1.0");
+ registry.register("nt", "http://www.jcp.org/jcr/nt/1.0");
+ registry.register("mix", "http://www.jcp.org/jcr/mix/1.0");
+ this.output = new MockSequencerOutput(new StandardValueFactories(registry));
this.progress = new SimpleProgressMonitor("Test activity");
this.cautionGif =
this.getClass().getClassLoader().getResource("caution.gif");
this.cautionJpg =
this.getClass().getClassLoader().getResource("caution.jpg");
@@ -90,7 +98,6 @@
assertThat(output.getPropertyValues("image:metadata",
"image:physicalHeightDpi"), is(new Object[] {72}));
assertThat(((Float)(output.getPropertyValues("image:metadata",
"image:physicalWidthInches")[0])).doubleValue(), is(closeTo(0.666667d,
0.0001d)));
assertThat(((Float)(output.getPropertyValues("image:metadata",
"image:physicalHeightInches")[0])).doubleValue(), is(closeTo(0.666667d,
0.0001d)));
- assertThat(output.hasReferences(), is(false));
}
@Test
@@ -112,7 +119,6 @@
assertThat(output.getPropertyValues("image:metadata",
"image:physicalHeightDpi"), is(new Object[] {-1}));
assertThat(((Float)(output.getPropertyValues("image:metadata",
"image:physicalWidthInches")[0])), is(-1f));
assertThat(((Float)(output.getPropertyValues("image:metadata",
"image:physicalHeightInches")[0])), is(-1f));
- assertThat(output.hasReferences(), is(false));
}
@Test
@@ -133,7 +139,6 @@
assertThat(output.getPropertyValues("image:metadata",
"image:physicalHeightDpi"), is(new Object[] {-1}));
assertThat(((Float)(output.getPropertyValues("image:metadata",
"image:physicalWidthInches")[0])), is(-1f));
assertThat(((Float)(output.getPropertyValues("image:metadata",
"image:physicalHeightInches")[0])), is(-1f));
- assertThat(output.hasReferences(), is(false));
}
@Test
@@ -144,7 +149,6 @@
assertThat(content, is(notNullValue()));
sequencer.sequence(content, output, progress);
assertThat(output.hasProperties(), is(false));
- assertThat(output.hasReferences(), is(false));
}
}