You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by Sunil Dhage <su...@coreobjects.com> on 2009/10/13 09:05:46 UTC
problem in retrieving versions containing images
Hi,
I am working on an application which should hold multiple versions of images.
While retrieving those versions I am getting all the properties but the image,what I am getting is the latest image what is stored.
I have added img1.png ,
Then I have updated it to img2.png, img3.png, img4.png.
All are of different resolutions and sizes.
When trying to retrieve the versions, I could get all four versions of images, but all contain img4.png only.
I tried printing the no of bytes of each version's inputStream, I am getting the actual sizes.
VersionHistory versionHistory = photocontent.getVersionHistory();
VersionIterator versionIter = versionHistory.getAllVersions();
versionIter.skip(1);
InputStream imageDataStream = null;
String imageMimeType = null;
while (versionIter.hasNext()) {
Version version = versionIter.nextVersion();
log.info("version "+version.getUUID());
log.info("version created time "+version.getCreated().getTime());
NodeIterator nodeIter = version.getNodes();
while(nodeIter.hasNext()) {
Node versionedNode = nodeIter.nextNode();
//Node versionedNode = version.getNode(JcrConstants.JCR_FROZENNODE);
imageDataStream = versionedNode.getProperty(JcrConstants.JCR_DATA).getStream();
imageMimeType = versionedNode.getProperty(JcrConstants.JCR_MIMETYPE).getString();
if (imageDataStream != null && imageMimeType != null) {
log.info("no of bytes "+imageDataStream.available());
DataSource source = new ByteArrayDataSource(imageDataStream, imageMimeType);
candidateContent.setContent(new DataHandler(source));
Can you please help me in resolving this issue
Regards,
Sunil Kumar Dhage
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
-No one will manufacture lock without key. Similarly God wont give problems without solutions. So defeat your problems with great confidence.
RE: problem in retrieving versions containing images
Posted by Sunil Dhage <su...@coreobjects.com>.
Alex,
Thanks for your reply.
Actually I was using the same object to set the datahandler.
Hence all the images were containing the last added photo.
It got resolved.
/Sunil
-----Original Message-----
From: Alexander Klimetschek [mailto:aklimets@day.com]
Sent: Tuesday, October 13, 2009 1:38 PM
To: users@jackrabbit.apache.org
Subject: Re: problem in retrieving versions containing images
On Tue, Oct 13, 2009 at 09:05, Sunil Dhage <su...@coreobjects.com> wrote:
> I am working on an application which should hold multiple versions of images.
> While retrieving those versions I am getting all the properties but the image,what I am getting is the latest image what is stored.
>
> I have added img1.png ,
> Then I have updated it to img2.png, img3.png, img4.png.
>
> All are of different resolutions and sizes.
>
> When trying to retrieve the versions, I could get all four versions of images, but all contain img4.png only.
How does your content look like? Where do you set the mix:versionable?
I also wonder why you commented out the line that accesses the
jcr:frozenNode child of the versions - this should be required, as
this child node of nt:version holds the actual content.
Regards,
Alex
--
Alexander Klimetschek
alexander.klimetschek@day.com
Re: problem in retrieving versions containing images
Posted by Alexander Klimetschek <ak...@day.com>.
On Tue, Oct 13, 2009 at 09:05, Sunil Dhage <su...@coreobjects.com> wrote:
> I am working on an application which should hold multiple versions of images.
> While retrieving those versions I am getting all the properties but the image,what I am getting is the latest image what is stored.
>
> I have added img1.png ,
> Then I have updated it to img2.png, img3.png, img4.png.
>
> All are of different resolutions and sizes.
>
> When trying to retrieve the versions, I could get all four versions of images, but all contain img4.png only.
How does your content look like? Where do you set the mix:versionable?
I also wonder why you commented out the line that accesses the
jcr:frozenNode child of the versions - this should be required, as
this child node of nt:version holds the actual content.
Regards,
Alex
--
Alexander Klimetschek
alexander.klimetschek@day.com