AnsweredAssumed Answered

Problème d'ajout d'un fichier PDF dans alfresco via JCR

Question asked by wassim on Mar 4, 2009
Bonjour,
j'ai un problème d'ajout d'un fichier PDF dans alfresco via JCR !

je suis entrain d'ajouter un fichier pdf dans alfresco avec JCR via un code java.

La connexion au jcr est réussite !

voila le code suivant :



String fileName = "AlfrescoFAQ_1_1_FR.pdf";           
FileInputStream inputStream = new FileInputStream(fileName);

vJcrNode = vJcrSession.getRootNode();
Node createdNodeRef = vJcrNode.addNode(new File(fileName).getName(), "nt:folder");
createdNodeRef.addMixin("mix:referenceable");
createdNodeRef.addMixin("mix:lockable");
createdNodeRef.addMixin("mix:versionable"); 

Node dataNode = createdNodeRef.addNode("jcr:content", "nt:resource");  
dataNode.setProperty("jcr:mimeType", "application/pdf");
dataNode.setProperty("jcr:data", inputStream);

vJcrSession.save();

Mais, je n'arrive pas d'ajouter le fichier pdf (sachant que le fichier pdf se trouve dans le même répertoire avec la classe qui contient le code au dessus)

et voila l'erreur :


11:10:13,517 User:admin ERROR [alfresco.thread.WorkerThreadImpl] java.lang.reflect.InvocationTargetException
java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.alfresco.thread.WorkerThreadImpl.run(WorkerThreadImpl.java:97)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
        at java.lang.Thread.run(Thread.java:619)
Caused by: javax.jcr.RepositoryException: Cannot determine child association for node type '{http://www.jcp.org/jcr/nt/1
.0}resource within parent workspace://SpacesStore/2145e6dd-d908-4457-8f20-bd20854666fe: Cannot determine child associati
on for node type '{http://www.jcp.org/jcr/nt/1.0}resource within parent workspace://SpacesStore/2145e6dd-d908-4457-8f20-
bd20854666fe
        at org.alfresco.jcr.util.JCRProxyFactory$SessionContextInvocationHandler.invoke(JCRProxyFactory.java:175)
        at $Proxy175.addNode(Unknown Source)
        … 8 more
Caused by: org.alfresco.error.AlfrescoRuntimeException: Cannot determine child association for node type '{http://www.jc
p.org/jcr/nt/1.0}resource within parent workspace://SpacesStore/2145e6dd-d908-4457-8f20-bd20854666fe
        at org.alfresco.jcr.item.NodeImpl.getNodeTypeChildAssocDefForParent(NodeImpl.java:283)
        at org.alfresco.jcr.item.NodeImpl.addNode(NodeImpl.java:189)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.alfresco.jcr.util.JCRProxyFactory$SessionContextInvocationHandler.invoke(JCRProxyFactory.java:138)
        … 9 more
11:10:13,533  ERROR [alfresco.thread.WorkerThreadManager] error on dispatched method [addNode]
javax.jcr.RepositoryException: Cannot determine child association for node type '{http://www.jcp.org/jcr/nt/1.0}resource
within parent workspace://SpacesStore/2145e6dd-d908-4457-8f20-bd20854666fe: Cannot determine child association for node
type '{http://www.jcp.org/jcr/nt/1.0}resource within parent workspace://SpacesStore/2145e6dd-d908-4457-8f20-bd20854666f
e
        at org.alfresco.jcr.util.JCRProxyFactory$SessionContextInvocationHandler.invoke(JCRProxyFactory.java:175)
        at $Proxy175.addNode(Unknown Source)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.alfresco.thread.WorkerThreadImpl.run(WorkerThreadImpl.java:97)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
        at java.lang.Thread.run(Thread.java:619)
Caused by: org.alfresco.error.AlfrescoRuntimeException: Cannot determine child association for node type '{http://www.jc
p.org/jcr/nt/1.0}resource within parent workspace://SpacesStore/2145e6dd-d908-4457-8f20-bd20854666fe
        at org.alfresco.jcr.item.NodeImpl.getNodeTypeChildAssocDefForParent(NodeImpl.java:283)
        at org.alfresco.jcr.item.NodeImpl.addNode(NodeImpl.java:189)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.alfresco.jcr.util.JCRProxyFactory$SessionContextInvocationHandler.invoke(JCRProxyFactory.java:138)
        … 9 more
org.alfresco.error.AlfrescoRuntimeException: Cannot determine child association for node type '{http://www.jcp.org/jcr/n
t/1.0}resource within parent workspace://SpacesStore/2145e6dd-d908-4457-8f20-bd20854666fe
        at org.alfresco.jcr.item.NodeImpl.getNodeTypeChildAssocDefForParent(NodeImpl.java:283)
        at org.alfresco.jcr.item.NodeImpl.addNode(NodeImpl.java:189)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.alfresco.jcr.util.JCRProxyFactory$SessionContextInvocationHandler.invoke(JCRProxyFactory.java:138)
        at $Proxy175.addNode(Unknown Source)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
        at java.lang.reflect.Method.invoke(Method.java:597)
        at org.alfresco.thread.WorkerThreadImpl.run(WorkerThreadImpl.java:97)
        at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
        at java.lang.Thread.run(Thread.java:619)

Merci d'avance !

Outcomes