questions about JcrFileNode

7 views
Skip to first unread message

decebal

unread,
Aug 20, 2009, 10:21:06 AM8/20/09
to jcrom
Hello,

My first question is how can I read the content of a JcrFileNode
property (@JcrFileNode private JcrFile xmlFile;)?
I use this code for write to jcr:

JcrFile xmlFile = new JcrFile();
xmlFile.setName("xmlFile");
xmlFile.setLastModified(Calendar.getInstance());
xmlFile.setPath(StorageUtil.createPath(reportContent.getPath(),
"xmlFile"));
xmlFile.setMimeType(upload.getContentType());
xmlFile.setDataProvider(new JcrDataProviderImpl(TYPE.STREAM,
upload.getInputStream()));
reportContent.setXmlFile(xmlFile);

Another problem is that JcrFile is Serailizable (ok) but
JcrDataProviderImpl (contains a InputStream, ...) is not Serializable
and I want to use my entity (contains only a xml file property) as a
DTO.

Thanks,
Decebal

decebal

unread,
Aug 20, 2009, 11:38:41 AM8/20/09
to jcrom
In my unit test I used JcrFile.fromFile("xmlFile", file, "text/xml")
to write the file in jcr and I read with jcrFile.getDataProvider
().getInputStream() (bytes and file properties from JcrFile are null)
and all is OK.
In my application the jcrFile is an uploaded file and I use and input
stream not a file like in the unit test.

decebal

unread,
Aug 20, 2009, 4:54:03 PM8/20/09
to jcrom
I understand now that I can use JcrFileNode.LoadType.BYTES (default is
STREAM), I can create a custom JcrDataProvider (TYPE.BYTES and a byte
[]) that implements Serializable but in FileNodeMapper.java you use
JcrDataProviderImpl to map node to file object. Can I specify/inject
my custom JcrDataProvider in FileNodeMapper ?
Reply all
Reply to author
Forward
0 new messages