cancel
Showing results for 
Search instead for 
Did you mean: 

Problems to get file content

dacedos
Champ in-the-making
Champ in-the-making
Alfresco behaves oddly when I try to get file contents from java.

I want to sign a PDF with iText but I need to get the file content from the repository before. If I upload a file within Company_Home/departamentos it doesn't work, alfresco can't locate the file and itext returns a PDF not found Exception. If I cut that document and I paste into Company_Home/departamentos/calidad it works fine and Alfresco retrieve the content and itext sign the document.

I uses urls like : http://localhost:8080/alfresco/d/d/workspace/SpacesStore/158bdb99-1aef-4cc4-b212-335ec4dcc352/qwerty...

To get the "http://localhost:8080/alfresco" reading from a file.
To get the next part I use:

name = (String) nodeService.getProperty(nodeRef, QName.createQName(Constants.PROP_NAME));       
String path= DownloadContentServlet.generateBrowserURL(nodeRef, name);

Any idea/suggestion? Why does Alfresco find only sometimes if noderef or path is the same in both cases??
2 REPLIES 2

rliu
Champ in-the-making
Champ in-the-making
2 things to confirm …

1. Are you looking at the right noderef?
2. Is Constants.PROP_NAME the same as ContentModel.PROP_NAME? Best to use ContentModel.PROP_NAME if possible.

What is the result of the "path" output?

dacedos
Champ in-the-making
Champ in-the-making
thanks!

Noderef is the same in both cases because I print on screen and they point to the same alfresco uses to browse content.

About Constant.PROP_NAME … Alfresco built the string

public static final String NAMESPACE_CONTENT_MODEL  = "http://www.alfresco.org/model/content/1.0";
public static final String PROP_NAME =              createQNameString(NAMESPACE_CONTENT_MODEL, "name");

    public static String createQNameString(String namespace, String name)
    {
        return "{" + namespace + "}" + name;
    }

I think Constant.PROP_NAME is also ContentModel.PROP_NAME.

I finally chose readind the property "content" (QName.createQName("{http://www.alfresco.org/model/content/1.0}content")) and get the file Alfresco stores in the local disk. What kind of problems can this solution cause?