jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sunil Dhage <sunil.dh...@coreobjects.com>
Subject problem in retrieving versions containing images
Date Tue, 13 Oct 2009 07:05:46 GMT

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();

        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

Sunil Kumar Dhage
-No one will manufacture lock without key. Similarly God wont give problems without solutions.
So defeat your problems with great confidence.

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message