4 Replies Latest reply on Aug 1, 2012 9:12 PM by frank zheng

    Issue on versioning when using federation repository

    frank zheng Newbie

      Hi all,

       

      We are facing a problem on realising versioning when using federation repository. The federation repository has 1 filesystem source and 2 jpa source(including the system source).

      We versioned the node in jpa source by checking it in and the version information has successfully stored in the database.

      When we tried to checkout the versioned node in jpa source, an exception was thrown out.

       

      Exception in thread "main" org.modeshape.graph.property.PathNotFoundException: Unable to find "[{http://www.modeshape.org/1.0}uuid = 5794fb8f-41de-4864-993c-09d7db18d4f8]"; lowest existing path is "/"
          at org.modeshape.graph.connector.base.PathTransaction.getNode(PathTransaction.java:151)
          at org.modeshape.graph.connector.base.PathTransaction.getNode(PathTransaction.java:59)
          at org.modeshape.graph.connector.base.Processor.getTargetNode(Processor.java:658)
          at org.modeshape.graph.connector.base.Processor.process(Processor.java:414)
          at org.modeshape.graph.request.processor.RequestProcessor.process(RequestProcessor.java:315)
          at org.modeshape.graph.request.processor.RequestProcessor.process(RequestProcessor.java:363)
          at org.modeshape.graph.request.processor.RequestProcessor.process(RequestProcessor.java:235)
          at org.modeshape.graph.connector.base.Connection.execute(Connection.java:115)
          at org.modeshape.graph.connector.RepositoryConnectionPool$ConnectionWrapper.execute(RepositoryConnectionPool.java:1124)
          at org.modeshape.graph.request.CompositeRequestChannel$2.call(CompositeRequestChannel.java:223)
          at org.modeshape.graph.request.CompositeRequestChannel$2.call(CompositeRequestChannel.java:212)
          at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
          at java.util.concurrent.FutureTask.run(FutureTask.java:138)
          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)
      

       

      Does the federation repository supports versioning?

       

      Thanks a lot.

        • 1. Re: Issue on versioning when using federation repository
          Randall Hauch Master

          Yes federation does support versioning, but we strongly encourage you to try it with the latest stable version (currently 2.8.2.Final). You should be able to upgrade (at least for testing, if not in general) very easily, as the newer version will be API-compatible and uses the same configuration.

           

          However, if you find you still have a problem with 2.8.2.Final, please create a small test case that we can use to replicate your situation, and log a bug in JIRA.

           

          Best regards,

           

          Randall

          • 2. Re: Issue on versioning when using federation repository
            frank zheng Newbie

            I tried but it still didn't work.

            Here is my configuration file.

            <mode:sources jcr:primaryType="nt:unstructured">
                    <mode:source jcr:name="systemSource" mode:classname="org.modeshape.connector.store.jpa.JpaSource"
                         mode:defaultWorkspaceName="system"
                         mode:autoGenerateSchema="update"
                         dialect="org.hibernate.dialect.MySQLDialect"
                         driverClassName="com.mysql.jdbc.Driver"
                         username="root"
                         password=""
                         url="jdbc:mysql://localhost:3306/esp_systemsource">
                    </mode:source>
            
                    <mode:source jcr:name="metaData" mode:classname="org.modeshape.connector.store.jpa.JpaSource"
                         mode:defaultWorkspaceName="meta"
                         mode:autoGenerateSchema="update"
                         dialect="org.hibernate.dialect.MySQLDialect"
                         driverClassName="com.mysql.jdbc.Driver"
                         username="root"
                         password=""
                         url="jdbc:mysql://localhost:3306/meta">
                    </mode:source>
                    
                    <mode:source jcr:name="gometaFS" mode:classname="org.modeshape.connector.filesystem.FileSystemSource"
                        mode:workspaceRootPath="/tmp/full"
                        mode:defaultWorkspaceName="go"
                        mode:creatingWorkspacesAllowed="true"
                        mode:updatesAllowed="true">
                        <mode:cachePolicy jcr:name="nodeCachePolicy" 
                            mode:classname="org.modeshape.graph.connector.base.cache.InMemoryNodeCache$PathCachePolicy"
                            mode:timeToLive="300" />
                    </mode:source>
                    
                    <mode:source jcr:name="federationSource"
                        mode:classname="org.modeshape.graph.connector.federation.FederatedRepositorySource">
                         <mode:workspaces>
                            <mode:workspace jcr:name="default">
                                <mode:projections>
                                    <mode:projection jcr:name="File projection"
                                            mode:source="gometaFS"
                                            mode:workspaceName="go">
                                        <mode:projectionRules>/filesystem => /</mode:projectionRules>
                                    </mode:projection>
                                    
                                    <mode:projection jcr:name="Meta projection"
                                            mode:source="metaData"
                                            mode:workspaceName="meta">
                                        <mode:projectionRules>/metasystem => /</mode:projectionRules>
                                    </mode:projection>
                                
                                </mode:projections>
                            </mode:workspace>
                        </mode:workspaces>
                    </mode:source>
                </mode:sources>
            
                <mode:mimeTypeDetectors>
                    <mode:mimeTypeDetector jcr:name="Detector">
                        <mode:description>Standard extension-based MIME type detector</mode:description>
                        <mode:classname>org.modeshape.graph.mimetype.ExtensionBasedMimeTypeDetector</mode:classname>
                    </mode:mimeTypeDetector>
                 </mode:mimeTypeDetectors>
            
                <mode:repositories>
                 <mode:repository jcr:name="federationRepo" repositoryJndiLocation="jndi:federationRepo">
                        <mode:source>federationSource</mode:source>            
                        <mode:options jcr:primaryType="mode:options">
                            <queryIndexDirectory jcr:primaryType="mode:option" mode:value="/tmp/full/index" />
                            <systemSourceName jcr:primaryType="mode:option" mode:value="system@systemSource"/>
                        </mode:options>
                  </mode:repository>
                </mode:repositories>
            

             

            Here is my simple test case

             

            public static void testCheckIn(Session session, File file) throws Exception{
                    String fileName = file.getName();
                    String filePath = "/metasystem/" + fileName;
                    JcrTools tools = new JcrTools();
                    Node fileNode = tools.findOrCreateNode(session, filePath, "nt:folder", "nt:file");
                    Node resourceNode = fileNode.addNode("jcr:content", "nt:resource");
                    InputStream is = new FileInputStream(file);
                    Binary binaryValue = session.getValueFactory().createBinary(is);
                    resourceNode.setProperty("jcr:data", binaryValue);
                    resourceNode.addMixin("mix:versionable");
                    session.save();
                    session.getWorkspace().getVersionManager().checkin(resourceNode.getPath());
                }
                
                public static void testCheckOut(Session session, File file) throws Exception{
                    String fileName = file.getName();
                    String filePath = "/metasystem/" + fileName;
                    Node resourceNode = session.getNode(filePath + "/jcr:content");
                    System.out.println("1");
                    session.getWorkspace().getVersionManager().checkout(resourceNode.getPath()); //wrong here
                    System.out.println("2");
                    session.getWorkspace().getVersionManager().checkin(resourceNode.getPath());
                }
            
                 
            public static void main(String[] args) throws Exception {
                    RepositoryFactory rFactory = null;
                    SecurityFactory.prepare();
                    try {
                        ClassPathResource cr = new ClassPathResource("modeshape-repositories-full.xml");
                        
                        Properties fedParameters = new Properties();
                        fedParameters.put("org.modeshape.jcr.URL", cr.getURL());
                        fedParameters.put("org.modeshape.jcr.RepositoryName", "federationRepo");
                        Repository fedRepository = null;
                        for (RepositoryFactory factory : ServiceLoader.load(RepositoryFactory.class)) {
                            fedRepository = factory.getRepository(fedParameters);
                            if (fedRepository != null)
                                rFactory = factory;
                                break;
                        }
                        Session fedSession = createSession(fedRepository, "default");
            
                        File file = new File("C://222.txt");
            
                        testCheckIn(fedSession, file);
                        testCheckOut(fedSession, file);
                   } finally {
                        if (rFactory instanceof JcrRepositoryFactory) {
                            //((JcrRepositoryFactory) rFactory).shutdown();
                        }
                    }
                }
            

            Here is the error

             

            Exception in thread "main" org.modeshape.graph.property.PathNotFoundException: Unable to find "[{http://www.modeshape.org/1.0}uuid = 6a085534-b9ac-4a33-a377-bfd64f527532]"; lowest existing path is "/"
                at org.modeshape.graph.connector.base.PathTransaction.getNode(PathTransaction.java:151)
                at org.modeshape.graph.connector.base.PathTransaction.getNode(PathTransaction.java:59)
                at org.modeshape.graph.connector.base.Processor.getTargetNode(Processor.java:658)
                at org.modeshape.graph.connector.base.Processor.process(Processor.java:414)
                at org.modeshape.graph.request.processor.RequestProcessor.process(RequestProcessor.java:315)
                at org.modeshape.graph.request.processor.RequestProcessor.process(RequestProcessor.java:363)
                at org.modeshape.graph.request.processor.RequestProcessor.process(RequestProcessor.java:235)
                at org.modeshape.graph.connector.base.Connection.execute(Connection.java:115)
                at org.modeshape.graph.connector.RepositoryConnectionPool$ConnectionWrapper.execute(RepositoryConnectionPool.java:1124)
                at org.modeshape.graph.request.CompositeRequestChannel$2.call(CompositeRequestChannel.java:223)
                at org.modeshape.graph.request.CompositeRequestChannel$2.call(CompositeRequestChannel.java:212)
                at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
                at java.util.concurrent.FutureTask.run(FutureTask.java:138)
                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)
            

             

            Is there anything wrong?

             

            Thanks a lot.

            • 3. Re: Issue on versioning when using federation repository
              Randall Hauch Master

              After a quick glance, I don't see anything wrong with the code or the configuration. Can you log a bug in our JIRA with the above information?