Author: rhauch
Date: 2008-05-27 17:31:52 -0400 (Tue, 27 May 2008)
New Revision: 201
Modified:
trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencers/SequencerOutputMap.java
trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencers/StreamSequencerAdapter.java
trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencers/StreamSequencerAdapterTest.java
trunk/dna-spi/src/main/java/org/jboss/dna/spi/sequencers/SequencerOutput.java
trunk/dna-spi/src/test/java/org/jboss/dna/spi/sequencers/MockSequencerOutput.java
trunk/sequencers/dna-sequencer-images/src/main/java/org/jboss/dna/sequencer/images/ImageMetadataSequencer.java
trunk/sequencers/dna-sequencer-images/src/test/java/org/jboss/dna/sequencer/images/ImageMetadataSequencerTest.java
Log:
DNA-77: SequencerOutput setProperty and setReference method signatures need to be changed
http://jira.jboss.org/jira/browse/DNA-77
Added two methods to the SequencerOutput interface: a method to obtain the
org.jboss.dna.spi.graph.ValueFactories instance that can be used to create paths, names,
and other value objects (like binary objects, date-time instants, strings, doubles, etc.);
and a method to set the property values using a Path object for the node path, and a Name
object for the property name. The Path, Name, DateTime, Reference, Binary, ValueFactory,
and ValueFactories interfaces are all part of the SPI, and will be used by the federation
engine, connectors, and (now) sequencers. The existing SequencerOutput methods (that take
string paths and names) simply create the Path and Name objects and then delegate to the
new method.
Modified:
trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencers/SequencerOutputMap.java
===================================================================
---
trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencers/SequencerOutputMap.java 2008-05-27
19:54:50 UTC (rev 200)
+++
trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencers/SequencerOutputMap.java 2008-05-27
21:31:52 UTC (rev 201)
@@ -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:
trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencers/StreamSequencerAdapter.java
===================================================================
---
trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencers/StreamSequencerAdapter.java 2008-05-27
19:54:50 UTC (rev 200)
+++
trunk/dna-repository/src/main/java/org/jboss/dna/repository/sequencers/StreamSequencerAdapter.java 2008-05-27
21:31:52 UTC (rev 201)
@@ -35,6 +35,7 @@
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.Name;
import org.jboss.dna.spi.graph.NamespaceRegistry;
import org.jboss.dna.spi.graph.Path;
import org.jboss.dna.spi.graph.PathFactory;
@@ -90,7 +91,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 +170,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 +191,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,7 +202,7 @@
// 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) {
Modified:
trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencers/StreamSequencerAdapterTest.java
===================================================================
---
trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencers/StreamSequencerAdapterTest.java 2008-05-27
19:54:50 UTC (rev 200)
+++
trunk/dna-repository/src/test/java/org/jboss/dna/repository/sequencers/StreamSequencerAdapterTest.java 2008-05-27
21:31:52 UTC (rev 201)
@@ -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: trunk/dna-spi/src/main/java/org/jboss/dna/spi/sequencers/SequencerOutput.java
===================================================================
---
trunk/dna-spi/src/main/java/org/jboss/dna/spi/sequencers/SequencerOutput.java 2008-05-27
19:54:50 UTC (rev 200)
+++
trunk/dna-spi/src/main/java/org/jboss/dna/spi/sequencers/SequencerOutput.java 2008-05-27
21:31:52 UTC (rev 201)
@@ -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:
trunk/dna-spi/src/test/java/org/jboss/dna/spi/sequencers/MockSequencerOutput.java
===================================================================
---
trunk/dna-spi/src/test/java/org/jboss/dna/spi/sequencers/MockSequencerOutput.java 2008-05-27
19:54:50 UTC (rev 200)
+++
trunk/dna-spi/src/test/java/org/jboss/dna/spi/sequencers/MockSequencerOutput.java 2008-05-27
21:31:52 UTC (rev 201)
@@ -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:
trunk/sequencers/dna-sequencer-images/src/main/java/org/jboss/dna/sequencer/images/ImageMetadataSequencer.java
===================================================================
---
trunk/sequencers/dna-sequencer-images/src/main/java/org/jboss/dna/sequencer/images/ImageMetadataSequencer.java 2008-05-27
19:54:50 UTC (rev 200)
+++
trunk/sequencers/dna-sequencer-images/src/main/java/org/jboss/dna/sequencer/images/ImageMetadataSequencer.java 2008-05-27
21:31:52 UTC (rev 201)
@@ -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:
trunk/sequencers/dna-sequencer-images/src/test/java/org/jboss/dna/sequencer/images/ImageMetadataSequencerTest.java
===================================================================
---
trunk/sequencers/dna-sequencer-images/src/test/java/org/jboss/dna/sequencer/images/ImageMetadataSequencerTest.java 2008-05-27
19:54:50 UTC (rev 200)
+++
trunk/sequencers/dna-sequencer-images/src/test/java/org/jboss/dna/sequencer/images/ImageMetadataSequencerTest.java 2008-05-27
21:31:52 UTC (rev 201)
@@ -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));
}
}