4 Replies Latest reply on Jan 18, 2011 1:41 PM by Souvik Dutta

    Adding a mixin property to a node using sequencing

    Souvik Dutta Newbie

      I have an image repository where the images have the EXIF UserComment field containing the image tags. I have written a custom sequencer to extract this metadata and would like to add these tags as a mixin to the 'same' nt:file node.

       

      I am able to add mixins programaticaly to the nt:file node easily using the Node.addMixin() method. For this, I have defined a cnd like the following:

       

      [tfmi:taggable] mixin

      - tfmi:tags (STRING) multiple

       

       

      However, the custom sequencer fails to add the mixin automatically. The sequencer config has the following path-expression:

       

      <mode:pathExpression>content:photos:/files(//*.(jpg|jpeg|gif|bmp|pcx|png|iff|ras|pbm|pgm|ppm|psd)[*])/jcr:content[@jcr:data] =>

                                                                                                                                             content:photos:/files/$1</mode:pathExpression>

       

       

      With this configuration I get the following exception:

       

      21:16:33,811 ERROR Error finding sequencers to run against node 2011-01-17T15:46:33.654Z @Fred [content] - 3 changes

      java.lang.NullPointerException

                at org.modeshape.graph.Graph$BatchResultsNode.addProperty(Graph.java:7095)

                at org.modeshape.graph.Graph$BatchResults.<init>(Graph.java:6956)

                at org.modeshape.graph.Graph$Batch.execute(Graph.java:4823)

                at org.modeshape.repository.sequencer.StreamSequencerAdapter.saveOutput(StreamSequencerAdapter.java:335)

                at org.modeshape.repository.sequencer.StreamSequencerAdapter.execute(StreamSequencerAdapter.java:228)

                at org.modeshape.repository.sequencer.SequencingService.processChange(SequencingService.java:495)

                at org.modeshape.repository.sequencer.SequencingService$RepositoryObserver$1.run(SequencingService.java:657)

                at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)

                at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)

                at java.lang.Thread.run(Thread.java:662)

       

       

      Can a sequencer output the results as mxin types to the source node? If yes, what would be the correct path expression?

        • 1. Adding a mixin property to a node using sequencing
          Randall Hauch Master

          That's a really good use case, but unfortunately at this time sequencers can't add values to existing properties. Could you log a feature request in JIRA?

          • 2. Adding a mixin property to a node using sequencing
            Souvik Dutta Newbie

            Randall, thanks for your reply. I have logged a feature request (MODE-1075) as suggested.

             

            I am building a workflow for publishing photos where the editors would tag the content and would upload it using the WebDAV interface. Assuming my sequencer takes it's input from content:photos:/files/A/B/photo.jpg and outputs the result to content:photos:/meta/A/B/photo.jpg/tfmi:taggable, I noticed that if I move the file to a location /files/A/C/photo.jpg the sequencer is triggered and it regenerates the metadata nodes at /meta/A/C/photo.jpg/tfmi:taggable. However, the stale output at /meta/A/B/photo.jpg/tfmi:taggable still remains in the repository and now correspond to ghost nodes. I fear, my queries based on tfmi:taggable will return results corresponding to these ghost nodes also.

             

            If I could add the sequencing output as mixins to the source node, I would not need to worry since my metadata would move with the node and will always be bound to the source.

             

            As an alternative approach, I think I will give the custom sequencer a skip and use listeners to extract the metadata and add it as mixins to the file node on the ADD_NODE event. However, I will have to keep a house-keeping thread running with a long lived JCR session for this.

             

            Any reflections on this approach is highly appreciated.

            • 3. Adding a mixin property to a node using sequencing
              Randall Hauch Master

              Thanks for logging that feature request. I'll target it to our next release (2.5).

               

              You might want to try the latest release (2.4.0.Final, just released this past Friday). When you move a file that was sequenced, it should re-sequence the file at the new location and remove the previous (stale) output derived from the file at the old location.

               

              However, I understand how having the metadata on the original file nodes would be much easier and better. So as much as I hate to say it, maybe using your own mechanism would be the easiest short-term solution. Our image sequencer is pretty simple, and you might be able to reuse the sequencer module by directly calling it, or copying what it's doing and customizing it for what you need.

               

              Sorry I don't have a better solution.

              • 4. Re: Adding a mixin property to a node using sequencing
                Souvik Dutta Newbie

                Nice! The sequencing engine indeed moves the metadata to correspond to the moved file node. I guess I had missed this earlier.

                 

                I had been browsing the repository using the WebDAV interface in Nautilus which showed that the parent nodes for the stale metadata was not being deleted on move. Since Nautilus does not show the properties of the parent node, I had wrongly assumed that the stale sequenced output was left behind.

                 

                I have already upgraded to 2.4. I did actually customize the bundled image sequencer for my solution. Appreciate all the help Randall.