6 Replies Latest reply on Dec 14, 2010 8:40 PM by rhauch

    Modeshape sequencers

    mcaspers

      try
      {
      final String REPO_NAME = "repo";
      final String SOURCE_NAME = "source";
      JcrConfiguration config = new JcrConfiguration();
      config.repositorySource(SOURCE_NAME)
      .usingClass(FileSystemSource.class)
      .setProperty("workspaceRootPath", "/home/matthew/Documents")
      .setProperty("defaultWorkspaceName", "ModeshapeRepoTest");
      config.repository(REPO_NAME)
          .setSource(SOURCE_NAME);
      config.sequencer("Xml")
      .usingClass(XmlSequencer.class)
      .setDescription("XML Sequencer")
      .sequencingFrom("//(*.xml[*])/jcr:content[@jcr:data]")
      .andOutputtingTo("/xml/$1");
      JcrEngine engine = config.build();
      engine.start();        
      Repository repository = engine.getRepository(REPO_NAME);
      Session session = repository.login();
      List<Sequencer> list = engine.getSequencingService().getSequencersList();
      boolean found = session.getRootNode().hasNode("xml");
      session.logout();
      engine.shutdown();
      engine.awaitTermination(4, TimeUnit.SECONDS);
      }
      catch (Exception ex)
      {
      ex.printStackTrace();
      }

      I'm trying to get the XmlSequencer to work in a filesystem to allow me to search xml files. I know the repository is loading OK because I can dump the nodes and they reflect the contents of the directory I am looking at. But I can't seem to get the sequencer to work, and engine.getSequencingService().getSequencersList() always returns an empty list. What am I doing wrong?

       

      try

      {

      final String REPO_NAME = "repo";

      final String SOURCE_NAME = "source";

       

      JcrConfiguration config = new JcrConfiguration();

      config.repositorySource(SOURCE_NAME)

      .usingClass(FileSystemSource.class)

      .setProperty("workspaceRootPath", "/home/matthew/Documents")

      .setProperty("defaultWorkspaceName", "ModeshapeRepoTest");

      config.repository(REPO_NAME)

          .setSource(SOURCE_NAME);

      config.sequencer("Xml")

      .usingClass(XmlSequencer.class)

      .setDescription("XML Sequencer")

      .sequencingFrom("//(*.xml[*])/jcr:content[@jcr:data]")

      .andOutputtingTo("/xml/$1");

       

      JcrEngine engine = config.build();

      engine.start();        

       

      Repository repository = engine.getRepository(REPO_NAME);

      Session session = repository.login();

       

      List<Sequencer> list = engine.getSequencingService().getSequencersList();

       

      boolean found = session.getRootNode().hasNode("xml");

       

      session.logout();

       

      engine.shutdown();

      engine.awaitTermination(4, TimeUnit.SECONDS);

      }

      catch (Exception ex)

      {

      ex.printStackTrace();

      }

        • 1. Re: Modeshape sequencers
          rhauch

          Are there any warnings or errors in the 'config' object's list of problems, which you can access via config.getProblems()? A best-practice is to always verify no errors (and optionally print warnings) in the configuration before building the engine.

           

          One problem is that the FileSystem connector really is designed to store 'nt:file' and 'nt:folder' nodes on the file system (since those are the node types that JCR defines to represent a file and folder, respectively), so it is not designed to store arbitrary content (say, 'nt:unstructured' or custom node types) like what the XML sequencer generates. To do this, you probably want to set up a second source (e.g., JPA or in-memory or Infinispan) to store the arbitrary content. Your sequencer configuration can sequence from the file system source and output to the second source. You can leave these as separate JCR repositories, or you can create a federating repository that unifies the content from these two sources into a single virtual repository.

          • 2. Re: Modeshape sequencers
            mcaspers

            config.getProblems() returns null, so I assume that the config is good?

             

            I did try using a federated source with an in memory source to hold the sequenced data, but it still doesn't seem to fix the issue. I also set a break point in the XmlSequencer sequence() function, and it appears that the function is never called.

            • 3. Re: Modeshape sequencers
              mcaspers

              Looking into the issue some more, it seems that the sequencers will only look at content that is added to a repo, not existing content. Is this the expected behavior?

              • 4. Re: Modeshape sequencers
                rhauch

                At this time, sequencers only look at content after it is *added* or *changed* (e.g., adding or updating a file), and there is no explicit way to kick off a sequencing operation on content that already exists.

                • 5. Re: Modeshape sequencers
                  mcaspers

                  So I can't sequence (and therefor can't search binary content) of existing content?

                  • 6. Re: Modeshape sequencers
                    rhauch

                    At this time, not without causing a change to the content.