3 Replies Latest reply on Sep 5, 2012 10:52 AM by Randall Hauch

    Creating workspaces at runtime

    Jaroslaw Palka Newbie

      Hi,

       

      I have a question about creating workspaces in Modeshape 3beta3. I have set "allowCreation" to true in configRepository.json and have used following code snippet to create workspaces at runtime:

       

      {code}

      Session defaultSession = repository.login("default");
      Workspace defaultWorkspace = defaultSession.getWorkspace();
      defaultWorkspace.createWorkspace("ships");
      defaultSession.save();
      defaultSession.logout();

      {code}

       

      What happens is when I run my example with this snippet commented out I got:

       

      Exception in thread "main" javax.jcr.NoSuchWorkspaceException: The workspace ships was not found

          at org.modeshape.jcr.JcrRepository.login(JcrRepository.java:667)

          at org.modeshape.jcr.JcrRepository.login(JcrRepository.java:578)

          at org.modeshape.jcr.JcrRepository.login(JcrRepository.java:147)

          at org.modeshape.jcr.client.App.main(App.java:47)

       

      What is more interesting when I add content to "ships" workspace the content is persisted, but I have to create workspace every time between restarts. What's worse worspaces at runtime ar not visible from WebDAV server. One of requirment for my case is that I will create workspaces at runtime and they content of the workspace will be visible for other systems through WebDAV.

       

      I checked JCR spec and it doesn't say anything interesting about createWorkspace method. Is there any way I can work around it?

       

      Regards,

      Jarek