Problems with namespaces defined in cnd-File
forcam Oct 22, 2012 10:39 AMHi,
i try to set the workspace test from a cnd-File. Here ist my cnd-File:
<jcr='http://www.jcp.org/jcr/1.0'> <nt='http://www.jcp.org/jcr/nt/1.0'> <mix='http://www.jcp.org/jcr/mix/1.0'> <test='http://www.test.com'>
Here is my repository configuration json file:
{ "name" : "configuration", "transactionMode" : "auto", "monitoring" : { "enabled" : true, }, "workspaces" : { "predefined" : ["primaryWorkspace"], "default" : "default", "allowCreation" : true, }, "node-types" : ["jcr/configurationNodeType.cnd"], "storage" : { "cacheName" : "repositoryCache" }, "security" : { "anonymous" : { "roles" : ["readonly","readwrite","admin"], "useOnFailedLogin" : false }, }, }
Here is my code for reading als namespaces:
@Test public void test() throws Exception { final ModeShapeEngine engine = new ModeShapeEngine(); engine.start(); final LocalEnvironment env = new LocalEnvironment(); env.defineCache("repositoryCache", mCache.getCacheConfiguration("repositoryCache")); final File file = new File("src/test/resources/jcr/testRepositoryConfiguration.json"); final RepositoryConfiguration repositoryConfiguration = RepositoryConfiguration.read(file).with(env); final Repository repository = engine.deploy(repositoryConfiguration); final Session session = repository.login("primaryWorkspace"); try { final String user = session.getUserID(); final String name = repository.getDescriptor(Repository.REP_NAME_DESC); final Workspace workspace = (Workspace) session.getWorkspace(); System.out.println("Namespaces: " + ArrayUtils.toString(workspace.getNamespaceRegistry().getPrefixes())); } catch (Exception ex) { ex.printStackTrace(); } session.logout(); }
Output:
Namespaces: {xmlns,,mode,xs,xsi,jcr,mix,sv,nt,xml}
No namespace with name test was found.
When i add the following line:
final Workspace workspace = (Workspace) session.getWorkspace(); workspace.getNamespaceRegistry().registerNamespace("test", "http://www.test.com");
Output:
Namespaces: {xmlns,,mode,xs,xsi,jcr,test,mix,sv,nt,xml}
The namespace test was found.
Why is the namespace not read from the cnd-File? Error?
-------------------
Peter