bonjour j'ai ecrit un programme qui permet de creer un noeud qui a un contenu (le contenu est un fichier xml), apres je cree un noeud fils qui lui a son tour a un contenu (tjr de type xml) , le programme cree le noeud pere ,mais il ne cree pas le noeud fils:voici le code
public class AddNodeWithJCR {
/**
* @param args
*/
public static void main(String[] args) throws Exception {
// access the Alfresco JCR Repository (here it's via programmatic approach, but it could also be injected)
ApplicationContext context = new ClassPathXmlApplicationContext("classpath:alfresco/application-context.xml");
Repository repository = (Repository)context.getBean("JCR.Repository");
// login to workspace (here we rely on the default workspace defined by JCR.Repository bean)
Session session = repository.login(new SimpleCredentials("admin", "alfrescoadmin".toCharArray()));
// TODO Auto-generated method stub
try
{
// first, access the company home
Node rootNode = session.getRootNode();
Node companyHome = rootNode.getNode("app:company_home");
// create the content node
String name = "RM4";
Node content = companyHome.addNode("cm:" + name, "cm:content");
content.setProperty("cm:name", name);
// add titled aspect (for Web Client display)
content.addMixin("cm:titled");
content.setProperty("cm:title", name);
content.setProperty("cm:description", name);
//
// write some content to new node
//
ClassPathResource resource = new ClassPathResource("org/alfresco/sample/jcr/wikiModel.xml");
content.setProperty("cm:content", resource.getInputStream());
//
// To set the content mime type, we need to use an Alfresco native service
// as there isn't an equivalent call in JCR
//
// setMimeType(context, content, MimetypeMap.MIMETYPE_TEXT_PLAIN);
// save changes
session.save();
}
finally
{
session.logout();
//System.exit(0);
}
try {
// login to workspace (here we rely on the default workspace defined by JCR.Repository bean)
session = repository.login(new SimpleCredentials("admin", "alfrescoadmin".toCharArray()));
// access a RM node directly from root node (by path and by UUID)
Node rootNode = session.getRootNode();
Node section = rootNode.getNode("app:company_home/cm:RM4");
// create the section node
String name = "Section";
Node sectionNode = section.addNode("cm:" + name, "cm:content");
sectionNode.setProperty("cm:name", name);
// add titled aspect (for Web Client display)
sectionNode.addMixin("cm:titled");
sectionNode.setProperty("cm:title", name);
sectionNode.setProperty("cm:description", name);
// write some content to new node
//
ClassPathResource resource = new ClassPathResource("org/alfresco/sample/jcr/wiki-context.xml");
sectionNode.setProperty("cm:content", resource.getInputStream());
}
finally
{
session.logout();
}
}
}voici l'erreur
Exception in thread "main" javax.jcr.RepositoryException: 04310001 Cannot determine child association for node type '{http://www.alfresco.org/model/content/1.0}content within parent workspace://SpacesStore/b1c0521a-0cca-4303-a810-47cd59c2a299: 04310001 Cannot determine child association for node type '{http://www.alfresco.org/model/content/1.0}content within parent workspace://SpacesStore/b1c0521a-0cca-4303-a810-47cd59c2a299
at org.alfresco.jcr.util.JCRProxyFactory$SessionContextInvocationHandler.invoke(JCRProxyFactory.java:169)
at $Proxy131.addNode(Unknown Source)
at org.alfresco.sample.jcr.AddNodeWithJCR.main(AddNodeWithJCR.java:121)
Caused by: org.alfresco.error.AlfrescoRuntimeException: 04310001 Cannot determine child association for node type '{http://www.alfresco.org/model/content/1.0}content within parent workspace://SpacesStore/b1c0521a-0cca-4303-a810-47cd59c2a299
at org.alfresco.jcr.item.NodeImpl.getNodeTypeChildAssocDefForParent(NodeImpl.java:277)
at org.alfresco.jcr.item.NodeImpl.addNode(NodeImpl.java:183)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.alfresco.jcr.util.JCRProxyFactory$SessionContextInvocationHandler.invoke(JCRProxyFactory.java:132)
… 2 more
org.alfresco.error.AlfrescoRuntimeException: 04310001 Cannot determine child association for node type '{http://www.alfresco.org/model/content/1.0}content within parent workspace://SpacesStore/b1c0521a-0cca-4303-a810-47cd59c2a299
at org.alfresco.jcr.item.NodeImpl.getNodeTypeChildAssocDefForParent(NodeImpl.java:277)
at org.alfresco.jcr.item.NodeImpl.addNode(NodeImpl.java:183)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at org.alfresco.jcr.util.JCRProxyFactory$SessionContextInvocationHandler.invoke(JCRProxyFactory.java:132)
at $Proxy131.addNode(Unknown Source)
at org.alfresco.sample.jcr.AddNodeWithJCR.main(AddNodeWithJCR.java:121)
merci pour votre aide