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

Issue on versioning when using federation repository

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Major
    • Resolution: Done
    • Affects Version/s: 2.8.2.Final
    • Fix Version/s: 2.8.3.Final
    • Component/s: Federation
    • Labels:
      None

      Description

      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)
      
      

      It didn't work. Is there anything wrong?

        Gliffy Diagrams

          Attachments

            Activity

              People

              • Assignee:
                hchiorean Horia Chiorean
                Reporter:
                fff13 frank zheng
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: