jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jukka Zitting" <jukka.zitt...@gmail.com>
Subject Re: [JCR Browser] Is there a way to update nt:file nodes property
Date Wed, 14 Mar 2007 08:47:38 GMT

On 3/14/07, Sudhan <s.kanade@gmail.com> wrote:
> Actually my application needs to store difference of file size between
> version 1.1 and 1.0. Say i updated a file abc.txt by adding some 20 kb of
> data. I need to see this 20 kb on version 1.1 so that I can know that how kb
> difference exists between the present version and its predecessor.
> presently i have a listener which listens to /jcr:system/jcr:versionStorage
> node.
> Is there any other way to achive above goal.

The version history keeps a full copy of also the binary properties of
previous versions, so you could use the getLength() method also to
find the previous file sizes.

The following code would print out size of the current version and of
all the predecessor versions:

    Node file = <the checked out copy of the file>;
    System.out.println("Current: "
        + file.getProperty("jcr:content/jcr:data").getLength());
    Version base = file.getBaseVersion();
    System.out.println(base.getCreated() + ": "
        + base.getProperty("jcr:frozenNode/jcr:content/jcr:data").getLength());
    Version[] predecessors = base.getPredecessors();
    for (int i = 0; i < predecessors.length; i++) {
        System.out.println(predecessors[i].getCreated() + ": "
            + file.getProperty("jcr:frozenNode/jcr:content/jcr:data").getLength());


Jukka Zitting

View raw message