Uploaded image for project: 'ModeShape'
  1. ModeShape
  2. MODE-1263

Query is not addressing existing nodes inside FileSystem Connector's repository (The Query can't search existing repository nodes)

    Details

    • Steps to Reproduce:
      Hide

      We can use the FileSystemRepositoryIntegrationTest.java to illustrate the issue, let us add some folders ie:folder1 & folder2 into the repository before running the unit tests.

        
      @Override
      public void beforeEach() throws Exception {
          // Delete the directory used for the FS store ...
          FileUtil.delete("target/fsRepoWithProps");
              
          // Now make the root directory ...
          new File("target/fsRepoWithProps/root").mkdirs();
          new File("target/fsRepoWithProps/root/defaultWorkspace/folder1").mkdirs();
          new File("target/fsRepoWithProps/root/defaultWorkspace/folder2").mkdirs();
      
          super.beforeEach();
      }
      

      Let us create a new unit @Test TestQueryingExistingContent() as below:

          @Test
          public void TestQueryingExistingContent() throws Exception {
          startEngineUsing("config/configRepositoryForFileSystemWithExtraProperties.xml");
          Session session = session();
          
          //Create a new Node (after session is started)
          session.getRootNode().addNode("NewFolder", "nt:folder");
          session.save();
          
          //Query all nodes
          String sql = "SELECT * FROM [nt:base]";
          Query query = session.getWorkspace().getQueryManager().createQuery(sql, Query.JCR_SQL2);
          QueryResult result = query.execute();
          System.out.println(result.toString());
          
          logout();    
          }
      

      The result of @Test TestQueryingExistingContent() :-

       
      -------------------------------------------------------
       T E S T S
      -------------------------------------------------------
      Running org.modeshape.test.integration.filesystem.FileSystemRepositoryIntegrationTest
      +---+-----------------+------------+-----------+-----------+----------------+------------+------------------------------------------------------------------------------------+----------------+
      | # | jcr:primaryType | jcr:path   | jcr:name  | jcr:score | mode:localName | mode:depth | Location(nt:base)                                                                  | Score(nt:base) |
      +---+-----------------+------------+-----------+-----------+----------------+------------+------------------------------------------------------------------------------------+----------------+
      | 1 | mode:root       | /          |           | 1.0       |                | 0          | </ && [{http://www.modeshape.org/1.0}uuid = cafebabe-cafe-babe-cafe-babecafebabe]> | 1.0            |
      | 2 | nt:folder       | /NewFolder | NewFolder | 1.0       | NewFolder      | 1          | /{}NewFolder                                                                       | 1.0            |
      +---+-----------------+------------+-----------+-----------+----------------+------------+------------------------------------------------------------------------------------+----------------+
      

      As shown above, only the Root node and the newly created "NewFolder" node are returned by the Query. The Query won't address the existing "folder1" or "folder2", we can even put some text file into "folder1" or "folder2", it won't show either. So, all existing nodes (except Root node) before session start won't be addressed by the Query. Putting Thread.sleep(3000) before Query.execute() won't help either.

      *Pls noted that for @Test shouldFindAllNodesWhenQueryingContent(), it doesn't address any existing nodes inside the Repository, all its print out via printQuery("SELECT * FROM [nt:base]", 5L, Collections.<String, String>emptyMap()); only return Root node and its newly created nodes after session started (Total 5 rows). However, this @Test still PASS, but by right, it should FAIL because we are expecting 7 rows returned due to the existing "folder1" & "folder2" and is not match with "5L". But of course, if we change the printQuery() -> "5L" to "7L", then this @Test will FAIL with Error:"Expected different number of rows from 'SELECT * FROM [nt:base]".

      Show
      We can use the FileSystemRepositoryIntegrationTest.java to illustrate the issue, let us add some folders ie:folder1 & folder2 into the repository before running the unit tests. @Override public void beforeEach() throws Exception { // Delete the directory used for the FS store ... FileUtil.delete( "target/fsRepoWithProps" ); // Now make the root directory ... new File( "target/fsRepoWithProps/root" ).mkdirs(); new File( "target/fsRepoWithProps/root/defaultWorkspace/folder1" ).mkdirs(); new File( "target/fsRepoWithProps/root/defaultWorkspace/folder2" ).mkdirs(); super .beforeEach(); } Let us create a new unit @Test TestQueryingExistingContent() as below: @Test public void TestQueryingExistingContent() throws Exception { startEngineUsing( "config/configRepositoryForFileSystemWithExtraProperties.xml" ); Session session = session(); //Create a new Node (after session is started) session.getRootNode().addNode( "NewFolder" , "nt:folder" ); session.save(); //Query all nodes String sql = "SELECT * FROM [nt:base]" ; Query query = session.getWorkspace().getQueryManager().createQuery(sql, Query.JCR_SQL2); QueryResult result = query.execute(); System .out.println(result.toString()); logout(); } The result of @Test TestQueryingExistingContent() :- ------------------------------------------------------- T E S T S ------------------------------------------------------- Running org.modeshape.test.integration.filesystem.FileSystemRepositoryIntegrationTest +---+-----------------+------------+-----------+-----------+----------------+------------+------------------------------------------------------------------------------------+----------------+ | # | jcr:primaryType | jcr:path | jcr:name | jcr:score | mode:localName | mode:depth | Location(nt:base) | Score(nt:base) | +---+-----------------+------------+-----------+-----------+----------------+------------+------------------------------------------------------------------------------------+----------------+ | 1 | mode:root | / | | 1.0 | | 0 | </ && [{http: //www.modeshape.org/1.0}uuid = cafebabe-cafe-babe-cafe-babecafebabe]> | 1.0 | | 2 | nt:folder | /NewFolder | NewFolder | 1.0 | NewFolder | 1 | /{}NewFolder | 1.0 | +---+-----------------+------------+-----------+-----------+----------------+------------+------------------------------------------------------------------------------------+----------------+ As shown above, only the Root node and the newly created "NewFolder" node are returned by the Query. The Query won't address the existing "folder1" or "folder2", we can even put some text file into "folder1" or "folder2", it won't show either. So, all existing nodes (except Root node) before session start won't be addressed by the Query. Putting Thread.sleep(3000) before Query.execute() won't help either. *Pls noted that for @Test shouldFindAllNodesWhenQueryingContent(), it doesn't address any existing nodes inside the Repository, all its print out via printQuery("SELECT * FROM [nt:base] ", 5L, Collections.<String, String>emptyMap()); only return Root node and its newly created nodes after session started (Total 5 rows). However, this @Test still PASS, but by right, it should FAIL because we are expecting 7 rows returned due to the existing "folder1" & "folder2" and is not match with "5L". But of course, if we change the printQuery() -> "5L" to "7L", then this @Test will FAIL with Error:"Expected different number of rows from 'SELECT * FROM [nt:base] ".

      Description

      • The Query is not addressing those existing nodes inside the FileSystem Connector's repository before the Session start. So, the query will just return Root node even though the repository already have multiple folder or files.
      • The Query is only address those nodes created (save or not saved) after Session start.
      • This Query problem confirmed happen to FileSystem connector (as tested so far using Standalone or App Server), whereas for Disk,Database,InMemory connectors, the Query is working just fine. Not tested with other type of connector yet.
      • Putting Thread.sleep(3000) before Query.execute won't help.
      • Related unit @Test is at \modeshape-integration-tests\src\test\java\org\modeshape\test\integration\filesystem\FileSystemRepositoryIntegrationTest.java

        Gliffy Diagrams

          Attachments

            Issue Links

              Activity

                People

                • Assignee:
                  rhauch Randall Hauch
                  Reporter:
                  penkween Danny C
                • Votes:
                  0 Vote for this issue
                  Watchers:
                  1 Start watching this issue

                  Dates

                  • Created:
                    Updated:
                    Resolved: