MimeType and sequencing
manuel.gentile Jun 16, 2010 1:19 PMIn the StreamSequencerAdapter.java I change
protected StreamSequencerContext createStreamSequencerContext(Node input, Property sequencedProperty, SequencerContext context, Problems problems) { assert input != null; assert sequencedProperty != null; assert context != null; assert problems != null; ValueFactories factories = context.getExecutionContext() .getValueFactories(); Path path = factories.getPathFactory().create( input.getLocation().getPath()); Set<org.modeshape.graph.property.Property> props = new HashSet<org.modeshape.graph.property.Property>( input.getPropertiesByName().values()); props = Collections.unmodifiableSet(props); String name = path.getLastSegment().getName().getLocalName(); String mimeType = getMimeType(context, sequencedProperty, name); return new StreamSequencerContext(context.getExecutionContext(), path, props, mimeType, problems); }
with this code
protected StreamSequencerContext createStreamSequencerContext(Node input, Property sequencedProperty, SequencerContext context, Problems problems) { assert input != null; assert sequencedProperty != null; assert context != null; assert problems != null; ValueFactories factories = context.getExecutionContext() .getValueFactories(); Path path = factories.getPathFactory().create( input.getLocation().getPath()); Set<org.modeshape.graph.property.Property> props = new HashSet<org.modeshape.graph.property.Property>( input.getPropertiesByName().values()); props = Collections.unmodifiableSet(props); String name = path.getLastSegment().getName().getLocalName(); if (name.equalsIgnoreCase("content")) name = path.getAncestor(1).getLastSegment().getName() .getLocalName(); String mimeType = getMimeType(context, sequencedProperty, nome); return new StreamSequencerContext(context.getExecutionContext(), path, props, mimeType, problems); }
The idea is to use the following code
String name = path.getLastSegment().getName().getLocalName(); if (name.equalsIgnoreCase("content")) name = path.getAncestor(1).getLastSegment().getName().getLocalName();
to get the right filename and obtain the MimeType using the extension of the file.
Do you suggest other way to obtain the same result?