cancel
Showing results for 
Search instead for 
Did you mean: 

Trying to read the content of a document

pau_carre
Champ in-the-making
Champ in-the-making
Hi, I am trying to read the content of a document whitin a custom action. I can get the Node and the NodeRef using browseBean.getDocument().
Then I try to use fileFolderService.getReader(nodeRef) to get the content but when I call that function Alfresco throws an exception:


java.lang.NullPointerException
        at org.alfresco.repo.model.filefolder.FileFolderServiceImpl.toFileInfo(FileFolderServiceImpl.java:224)
        at org.alfresco.repo.model.filefolder.FileFolderServiceImpl.getReader(FileFolderServiceImpl.java:924)
        at org.alfresco.sample.AddSignatureDialog.finishImpl(AddSignatureDialog.java:68)

I know that the node references a document because the name and the path fields of that Node have the name of the document.

Here you have the source code

65: Node documentNode = browseBean.getDocument();
66: NodeRef documentNodeRef = documentNode.getNodeRef();
67: fileFolderService = new FileFolderServiceImpl();
68: ContentReader contentReader = fileFolderService.getReader(documentNodeRef);
69: String contentURL = contentReader.getContentUrl();

Any idea?

Thanks,
Pau Carré Cardona
1 REPLY 1

algoworks
Champ in-the-making
Champ in-the-making
The problem is in line # 67

fileFolderService = new FileFolderServiceImpl();

You should never instantiate a spring service bean using "new". Rather inject the service bean in your faces bean in faces-config-bean.xml and declare a "getter" and "setter" of your service bean in your custom action. This is the basic fundamental of spring's dependency injection.

Hope this helps.