jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Paco Avila <pav...@git.es>
Subject Re: [JCR Browser] Is there a way to update nt:file nodes property
Date Wed, 14 Mar 2007 09:18:42 GMT
El mié, 14-03-2007 a las 10:47 +0200, Jukka Zitting escribió:
> Hi,
> 
> 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());
>     }

The line "file.getProperty("jcr:content/jcr:data").getLength()" read the
data and calculate the lengh. I think this is slower than storing the
document size in a property when you upload it.

-- 
GIT Consultors S.L.
c\ Francesc Rover 2-B
07003 Palma de Mallorca
(Illes Balears)


Mime
View raw message