4 Replies Latest reply on Mar 26, 2012 3:36 PM by rhauch

    How to create a workspace programatically in modeshape 2.x ?

    akrambenaissi

      Hi modeshapers,

       

      I am trying to create a workspace programatically in an existing repository.

      It seems that this point is not described by documentation, so I experimented the following:

       

      Credentials credentials = new SimpleCredentials("admin", "admin".toCharArray());
      Repository repository = getRepository("repository" );
      Session session = repository.login(credentials, "default");
      session.getWorkspace().createWorkspace("myWorkspace");
      

       

      The last line throws unexpectingly the following exception:

      javax.jcr.AccessDeniedException: java.security.AccessControlException: Permission denied to perform actions "create_workspace" on path <unknown>
      

       

      If I check the Session object, it seems that it uses admin as a user. And, according to documentation, admin user is granted create_workspace role.

       

      Any idea ?

       

      Greetings

      Akram