cancel
Showing results for 
Search instead for 
Did you mean: 

Can't save big files on repository using contentWriter.putContent

eradan
Champ in-the-making
Champ in-the-making
Hello,

I've this piece of code like this in a custom JavaService (simplified in order to get to the point):



public class CatalogManager extends BaseScopableProcessorExtension {

….

public void saveFileOnRepositoty(String fileName, File zipfile) {
   File zipfile = File.createTempFile(fileName, ".zip");
   …
   InputStream in = null;
   ScriptNode node = null;
   try {
      in = new FileInputStream(zipfile);
      node = parentDir.createFile(fileName + ".zip");;
      ContentWriter contentWriter = contentService.getWriter(node.getNodeRef(), ContentModel.PROP_CONTENT, true);
      contentWriter.putContent(in);
   } catch (Exception e) {
      throw new RuntimeException(e);
   } finally {
      IOUtils.closeQuietly(in);
   }
   
   String nodeRefResult = "";
   if (node != null) {
      nodeRefResult = node.getNodeRef().toString();
   }
   return nodeRefResult;
}

….

}


It works most of the time but if the zipfile is too big (say 100MB) it doesn't.

I've no error on log and no exception occurs.

The method correctly returns.
Logging the returning "nodeRefResult" variable and using the node browser in order to search the node itself it says that there is no such node in the workspace.

The search returns something like this:

Search failed due to: org.alfresco.error.AlfrescoRuntimeException: 09060020 Node workspace://SpacesStore/a2ee9154-a4a0-4aba-a873-f1ae303428a4 does not exist.   

Any idea?

Ivan


4 REPLIES 4

mrogers
Star Contributor
Star Contributor
Why are you using a scriptNode from within Java?   Use the nodeService or FileFolder service directly.   However I don't think that is your problem.

Your exception processing is wrong.  In particular you are swallowing concurrency exceptions that may need to be retried.

eradan
Champ in-the-making
Champ in-the-making
Hello, thanks for your reply.

Excuse me, why are you saying I'm swallowing the exception? I was just wrapping and re-throwing it as RuntimeException if it occurs.

Anyway, as you suggested, I tried unboxing the Exceptions:

<java>
public class CatalogManager extends BaseScopableProcessorExtension {

….

public void saveFileOnRepositoty(String fileName, File zipfile) throws FileNotFoundException, IOException {
   File zipfile = File.createTempFile(fileName, ".zip");
   …
   InputStream in = new FileInputStream(zipfile);
   ScriptNode node = parentDir.createFile(fileName + ".zip");;
   ContentWriter contentWriter = contentService.getWriter(node.getNodeRef(), ContentModel.PROP_CONTENT, true);
   contentWriter.putContent(in);
   IOUtils.closeQuietly(in);

   String nodeRefResult = "";
   if (node != null) {
      nodeRefResult = node.getNodeRef().toString();
   }
   return nodeRefResult;
}

….

}
</java>

But I've the same behaviour: nothing in the log.
I get back a noderef but when I try to get the node it doesn't exist.

I'm wondering if there is something like a content limit that I've to set in order to create a node with a content bigger than a certain threshold.

mrogers
Star Contributor
Star Contributor
No there is no content limit.   There may be quota, if set. But if you exceed quota you will get a fairly self explanatory exception to deal with.

What are the details of your statement. "I get back a noderef but when I try to get the node it doesn't exist."   You are not using search are you ?  

eradan
Champ in-the-making
Champ in-the-making
Hi,

once node has been created and method returns I return to the client the parent folder and the noderef of the newly created file.

Browsing the parent folder I don't find the node. Neither programmatically nor - after a while - browsing the repository using explorer or share, nor searching it using the node browser.