-
1. Re: The Sns nodes
hchiorean Nov 12, 2015 10:12 AM (in response to jessie_jie_xie)Is this something you're seeing while using the JCR API (e.g. you're unable to access the indexed-based paths) or is it something you're only looking at through the Explorer webapp ?
If the former, can you please a provide a test case for your issue ? If the latter, it may very well be some sort of bug in the Explorer UI.
-
2. Re: The Sns nodes
jessie_jie_xie Nov 15, 2015 10:37 PM (in response to hchiorean)Thanks for reply!
I found this issue when I was using JCR API, then verified it with Explorer UI. Here is the JCR test codes. (Please see the cnd definition in my first post)
package jcrtest;
import java.io.FileNotFoundException;
import javax.jcr.Node;
import javax.jcr.NodeIterator;
import javax.jcr.PathNotFoundException;
import javax.jcr.Repository;
import javax.jcr.RepositoryException;
import javax.jcr.Session;
import org.infinispan.schematic.document.ParsingException;
import org.modeshape.common.collection.Problems;
import org.modeshape.jcr.ConfigurationException;
import org.modeshape.jcr.JcrRepository;
import org.modeshape.jcr.ModeShapeEngine;
import org.modeshape.jcr.NoSuchRepositoryException;
import org.modeshape.jcr.RepositoryConfiguration;
public class JcrSNSTester {
private Repository repository = null;
private ModeShapeEngine engine = null;
private JcrSNSTester(String fileName,String repoName) {
try {
this.engine = new ModeShapeEngine();
this.engine.start();
RepositoryConfiguration config = RepositoryConfiguration.read(fileName);
Problems problems = config.validate();
if (problems.hasErrors()) {
String msg = "Problems with the configuration "+ fileName + problems.toString();
System.out.println(msg);
throw new RuntimeException(msg);
}
JcrRepository repository = this.engine.deploy(config);
try {
problems = repository.getStartupProblems();
if (problems.hasErrors() || problems.hasWarnings()) {
String msg = "Problems deploying the repository "+ fileName + problems.toString();
System.out.println(msg);
throw new RuntimeException(msg);
}
} catch (Exception e) {
System.out.println(e.getMessage());
throw new RuntimeException(e);
}
this.repository = this.engine.getRepository(repoName);
} catch (ParsingException | FileNotFoundException e) {
String msg = "Can not read/parse configuration file "+ fileName;
System.out.println(msg);
throw new RuntimeException(e);
} catch (NoSuchRepositoryException e) {
System.out.println(e.getMessage());
throw new RuntimeException(e);
} catch (RepositoryException|ConfigurationException e) {
String msg = "Error deploy repository " + e.getMessage();
System.out.println(msg);
throw new RuntimeException(e);
}
}
private void printChildNodes(Session session,Node parent) {
try {
System.out.println("Parent Node("+parent.getPrimaryNodeType().getName()+")"+parent.getPath());
NodeIterator ni = parent.getNodes();
while (ni.hasNext()) {
Node node = (Node) ni.next();
System.out.println("-- Child Node("+node.getPrimaryNodeType().getName()+")"+node.getPath());
}
System.out.println();
} catch (Exception e) {
e.printStackTrace();
}
}
private Node getNode(Session session,Node parent,String childName,String childType) throws RepositoryException {
Node node = null;
try {
node = parent.getNode(childName);
} catch (PathNotFoundException e) {
node = parent.addNode(childName, childType);
}
return node;
}
public static void main(String argv[]) {
JcrSNSTester tester = new JcrSNSTester("repository_config.json","Repository");
Session session = null;
try {
session = tester.repository.login();
Node root = session.getRootNode();
Node unstructured= tester.getNode(session,root,"TestUnstructured", "cds:SiblingUnstructured");
unstructured.addNode("cds:sibling","cds:Sibling");
unstructured.addNode("cds:sibling","cds:Sibling");
session.save();
Node folder = tester.getNode(session,root,"TestFolder", "cds:SiblingFolder");
folder.addNode("cds:sibling","cds:Sibling");
folder.addNode("cds:sibling","cds:Sibling");
session.save();
tester.printChildNodes(session, unstructured);
tester.printChildNodes(session, folder);
} catch (Exception e) {
e.printStackTrace();
} finally {
if (session != null) session.logout();
if (tester != null) tester.engine.shutdown();
}
}
}
And the execution output:
2015-11-16 11:08:56 INFO LogFactory:182 - SLF4J implementation located in the classpath. It will be used by ModeShape for logging.
2015-11-16 11:08:56 INFO JcrRepository:182 - ModeShape version 4.4.0.Final
2015-11-16 11:08:57 INFO GlobalComponentRegistry:229 - ISPN000128: Infinispan version: Infinispan 'Insanely Bad Elf' 7.2.3.Final
2015-11-16 11:08:57 INFO log:186 - Logging initialized @926ms
2015-11-16 11:08:57 WARN GenericTransactionManagerLookup:116 - ISPN000104: Falling back to DummyTransactionManager from Infinispan
Parent Node(cds:SiblingUnstructured)/TestUnstructured
-- Child Node(cds:Sibling)/TestUnstructured/cds:sibling
-- Child Node(cds:Sibling)/TestUnstructured/cds:sibling[2]
Parent Node(cds:SiblingFolder)/TestFolder
-- Child Node(cds:Sibling)/TestFolder/cds:sibling
-- Child Node(cds:Sibling)/TestFolder/cds:sibling
-
3. Re: The Sns nodes
hchiorean Nov 16, 2015 4:17 AM (in response to jessie_jie_xie)This does seem to be a valid bug (see [MODE-2533] SNS not correctly created when parent node type definition allows SNS and is not [nt:unstructured] - JBoss I…). We'll fix this for 4.5.0.Final.
Thanks for spotting it.
-
4. Re: The Sns nodes
jessie_jie_xie Nov 16, 2015 8:46 PM (in response to hchiorean)Thank you very much! I will try it on 4.5.0.