You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by monteka <mo...@anshinsoft.com> on 2007/12/07 11:08:19 UTC
Problem deleting the first version in version graph
Hi,
I am new to the Jackrabbit world. I have just started working on a Portal
based project for reporting solution. We are using Jackrabbit 1.3.
I am stuck with the following problem:
I have a versionable node which has a default jcr:rootVersion and additional
versions.
Now I can add any number of versions (i.e. different versions of the same
template).
Problem:
I have the following API that takes care of deleting the selected version of
the template (identified by the UUID):
public Object doInJcr(Session session) throws IOException,
RepositoryException {
String uuid = null;
try {
uuid = (String) PropertyUtils.getProperty(bean,
"uuid");
} catch (IllegalAccessException iae) {
log.error("Error in getting property 'uuid'", iae);
} catch (InvocationTargetException ite) {
log.error("Error in getting property 'uuid'", ite);
} catch (NoSuchMethodException nsme) {
log.error("Error in getting property 'uuid'", nsme);
}
Node root = session.getRootNode();
Node domainRoot = getDomainRoot(root);
Node domainNode = domainRoot.getNode(this.nodeName);
//nodeName is "template"
VersionHistory history = domainNode.getVersionHistory();
Version previous = null;
for (VersionIterator vit = history.getAllVersions();
vit.hasNext();) {
Version version = vit.nextVersion();
Node frozen = version.getNode("jcr:frozenNode");
if (uuid.equals(frozen.getUUID())) {
if
(version.equals(domainNode.getBaseVersion())) {
if (history.getAllVersions().getSize() >
2) {
domainNode.restore(previous,
true);
history.removeVersion(version.getName());
} else {
domainNode.remove();
}
} else {
history.removeVersion(version.getName());
}
break;
} else {
previous = version;
continue;
}
}
session.save();
return null;
}
Cases:
Case #1
--------
Say my version graph is like this:
VH (Version History) has child nodes VR (jcr:RootVersion) and V1
I have only 1 version (template), V1 and I choose to delete it - WORKING AS
EXPECTED
Case #2
--------
Say my version graph is like this:
VH (Version History) has child nodes VR (jcr:RootVersion) , V1 and V2
I want to delete version V2 - WORKING AS EXPECTED
Case #3
--------
Say my version graph is like this:
VH (Version History) has child nodes VR (jcr:RootVersion) , V1, V2 and V3
I want to delete version V2 - WORKING AS EXPECTED
Case #4
--------
Say my version graph is like this:
VH (Version History) has child nodes VR (jcr:RootVersion) , V1 and V2
I want to delete version V1 - NOT WORKING
I am unable to reconnect the VR to the second version, V2.
Actually when i try to delete the first version V1, the base node gets
deleted and so I loose the following versions also.
Expected behavior is that I should be able to delete any version (template).
Please advice ASAP.
Thank you.
--
View this message in context: http://www.nabble.com/Problem-deleting-the-first-version-in-version-graph-tf4961225.html#a14209765
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.
Re: Problem deleting the first version in version graph
Posted by Tobias Bocanegra <to...@day.com>.
ok. can you create test-code and open a jira issue? thanks.
regards, toby
On 12/17/07, monteka <mo...@anshinsoft.com> wrote:
>
> Hi Toby,
>
> Let me reiterate over the problem.
>
> The Problem:
>
> Say I have a VersionHistory (VH) node which has a jcr:rootVersion (VR) by
> default. Now I add multiple versions say V1, V2 and V3.
>
> So the links are as follows
>
> VH->VR->V1->V2->V3
>
> Now, I want to delete the base version V1, so that the version history links
> become
>
> VH->VR->V2->V3
>
> The problem is that if I delete the base version then I am unable to view
> the whole version history in my application. But this doesn't happen if I
> delete either V2 or V3 in the first case. The problem only comes if I delete
> the base version.
>
> Please revert back if the problem is still not clear.
>
> Regards,
> Montek
>
>
>
>
>
>
> Tobias Bocanegra wrote:
> >
> > hi,
> > i don't understand what you are trying to achieve here. the
> > jcr:frozenNode/jcr:uuid is the uuid of the frozen node - and i'm not
> > sure for what you use this?
> >
> > however, there could be a problem deleting a version while you are
> > iterating of the them.
> > further i don't think that you can delete a version as long it's still
> > referenced as base version.
> >
> > regards, toby
> >
> > On 12/7/07, monteka <mo...@anshinsoft.com> wrote:
> >>
> >> Hi,
> >>
> >> I am new to the Jackrabbit world. I have just started working on a Portal
> >> based project for reporting solution. We are using Jackrabbit 1.3.
> >>
> >> I am stuck with the following problem:
> >>
> >> I have a versionable node which has a default jcr:rootVersion and
> >> additional
> >> versions.
> >>
> >> Now I can add any number of versions (i.e. different versions of the same
> >> template).
> >>
> >> Problem:
> >>
> >> I have the following API that takes care of deleting the selected version
> >> of
> >> the template (identified by the UUID):
> >>
> >> public Object doInJcr(Session session) throws IOException,
> >> RepositoryException {
> >>
> >> String uuid = null;
> >> try {
> >> uuid = (String) PropertyUtils.getProperty(bean,
> >> "uuid");
> >> } catch (IllegalAccessException iae) {
> >> log.error("Error in getting property 'uuid'",
> >> iae);
> >> } catch (InvocationTargetException ite) {
> >> log.error("Error in getting property 'uuid'",
> >> ite);
> >> } catch (NoSuchMethodException nsme) {
> >> log.error("Error in getting property 'uuid'",
> >> nsme);
> >> }
> >>
> >> Node root = session.getRootNode();
> >>
> >> Node domainRoot = getDomainRoot(root);
> >>
> >> Node domainNode = domainRoot.getNode(this.nodeName);
> >> //nodeName is "template"
> >>
> >> VersionHistory history = domainNode.getVersionHistory();
> >> Version previous = null;
> >>
> >> for (VersionIterator vit = history.getAllVersions();
> >> vit.hasNext();) {
> >>
> >> Version version = vit.nextVersion();
> >> Node frozen = version.getNode("jcr:frozenNode");
> >>
> >> if (uuid.equals(frozen.getUUID())) {
> >> if
> >> (version.equals(domainNode.getBaseVersion())) {
> >>
> >> if
> >> (history.getAllVersions().getSize() >
> >> 2) {
> >>
> >> domainNode.restore(previous,
> >> true);
> >>
> >> history.removeVersion(version.getName());
> >> } else {
> >> domainNode.remove();
> >> }
> >> } else {
> >>
> >> history.removeVersion(version.getName());
> >> }
> >> break;
> >> } else {
> >> previous = version;
> >> continue;
> >> }
> >> }
> >>
> >> session.save();
> >> return null;
> >> }
> >>
> >> Cases:
> >>
> >> Case #1
> >> --------
> >> Say my version graph is like this:
> >>
> >> VH (Version History) has child nodes VR (jcr:RootVersion) and V1
> >>
> >> I have only 1 version (template), V1 and I choose to delete it - WORKING
> >> AS
> >> EXPECTED
> >>
> >> Case #2
> >> --------
> >>
> >> Say my version graph is like this:
> >>
> >> VH (Version History) has child nodes VR (jcr:RootVersion) , V1 and V2
> >>
> >> I want to delete version V2 - WORKING AS EXPECTED
> >>
> >> Case #3
> >> --------
> >>
> >> Say my version graph is like this:
> >>
> >> VH (Version History) has child nodes VR (jcr:RootVersion) , V1, V2 and V3
> >>
> >> I want to delete version V2 - WORKING AS EXPECTED
> >>
> >> Case #4
> >> --------
> >>
> >> Say my version graph is like this:
> >>
> >> VH (Version History) has child nodes VR (jcr:RootVersion) , V1 and V2
> >>
> >> I want to delete version V1 - NOT WORKING
> >>
> >> I am unable to reconnect the VR to the second version, V2.
> >>
> >> Actually when i try to delete the first version V1, the base node gets
> >> deleted and so I loose the following versions also.
> >>
> >> Expected behavior is that I should be able to delete any version
> >> (template).
> >>
> >> Please advice ASAP.
> >>
> >> Thank you.
> >> --
> >> View this message in context:
> >> http://www.nabble.com/Problem-deleting-the-first-version-in-version-graph-tf4961225.html#a14209765
> >> Sent from the Jackrabbit - Users mailing list archive at Nabble.com.
> >>
> >>
> >
> >
> > --
> > -----------------------------------------< tobias.bocanegra@day.com >---
> > Tobias Bocanegra, Day Management AG, Barfuesserplatz 6, CH - 4001 Basel
> > T +41 61 226 98 98, F +41 61 226 98 97
> > -----------------------------------------------< http://www.day.com >---
> >
> >
>
> --
> View this message in context: http://www.nabble.com/Problem-deleting-the-first-version-in-version-graph-tp14209765p14370045.html
> Sent from the Jackrabbit - Users mailing list archive at Nabble.com.
>
>
--
-----------------------------------------< tobias.bocanegra@day.com >---
Tobias Bocanegra, Day Management AG, Barfuesserplatz 6, CH - 4001 Basel
T +41 61 226 98 98, F +41 61 226 98 97
-----------------------------------------------< http://www.day.com >---
Re: Problem deleting the first version in version graph
Posted by monteka <mo...@anshinsoft.com>.
Hi Toby,
Let me reiterate over the problem.
The Problem:
Say I have a VersionHistory (VH) node which has a jcr:rootVersion (VR) by
default. Now I add multiple versions say V1, V2 and V3.
So the links are as follows
VH->VR->V1->V2->V3
Now, I want to delete the base version V1, so that the version history links
become
VH->VR->V2->V3
The problem is that if I delete the base version then I am unable to view
the whole version history in my application. But this doesn't happen if I
delete either V2 or V3 in the first case. The problem only comes if I delete
the base version.
Please revert back if the problem is still not clear.
Regards,
Montek
Tobias Bocanegra wrote:
>
> hi,
> i don't understand what you are trying to achieve here. the
> jcr:frozenNode/jcr:uuid is the uuid of the frozen node - and i'm not
> sure for what you use this?
>
> however, there could be a problem deleting a version while you are
> iterating of the them.
> further i don't think that you can delete a version as long it's still
> referenced as base version.
>
> regards, toby
>
> On 12/7/07, monteka <mo...@anshinsoft.com> wrote:
>>
>> Hi,
>>
>> I am new to the Jackrabbit world. I have just started working on a Portal
>> based project for reporting solution. We are using Jackrabbit 1.3.
>>
>> I am stuck with the following problem:
>>
>> I have a versionable node which has a default jcr:rootVersion and
>> additional
>> versions.
>>
>> Now I can add any number of versions (i.e. different versions of the same
>> template).
>>
>> Problem:
>>
>> I have the following API that takes care of deleting the selected version
>> of
>> the template (identified by the UUID):
>>
>> public Object doInJcr(Session session) throws IOException,
>> RepositoryException {
>>
>> String uuid = null;
>> try {
>> uuid = (String) PropertyUtils.getProperty(bean,
>> "uuid");
>> } catch (IllegalAccessException iae) {
>> log.error("Error in getting property 'uuid'",
>> iae);
>> } catch (InvocationTargetException ite) {
>> log.error("Error in getting property 'uuid'",
>> ite);
>> } catch (NoSuchMethodException nsme) {
>> log.error("Error in getting property 'uuid'",
>> nsme);
>> }
>>
>> Node root = session.getRootNode();
>>
>> Node domainRoot = getDomainRoot(root);
>>
>> Node domainNode = domainRoot.getNode(this.nodeName);
>> //nodeName is "template"
>>
>> VersionHistory history = domainNode.getVersionHistory();
>> Version previous = null;
>>
>> for (VersionIterator vit = history.getAllVersions();
>> vit.hasNext();) {
>>
>> Version version = vit.nextVersion();
>> Node frozen = version.getNode("jcr:frozenNode");
>>
>> if (uuid.equals(frozen.getUUID())) {
>> if
>> (version.equals(domainNode.getBaseVersion())) {
>>
>> if
>> (history.getAllVersions().getSize() >
>> 2) {
>>
>> domainNode.restore(previous,
>> true);
>>
>> history.removeVersion(version.getName());
>> } else {
>> domainNode.remove();
>> }
>> } else {
>>
>> history.removeVersion(version.getName());
>> }
>> break;
>> } else {
>> previous = version;
>> continue;
>> }
>> }
>>
>> session.save();
>> return null;
>> }
>>
>> Cases:
>>
>> Case #1
>> --------
>> Say my version graph is like this:
>>
>> VH (Version History) has child nodes VR (jcr:RootVersion) and V1
>>
>> I have only 1 version (template), V1 and I choose to delete it - WORKING
>> AS
>> EXPECTED
>>
>> Case #2
>> --------
>>
>> Say my version graph is like this:
>>
>> VH (Version History) has child nodes VR (jcr:RootVersion) , V1 and V2
>>
>> I want to delete version V2 - WORKING AS EXPECTED
>>
>> Case #3
>> --------
>>
>> Say my version graph is like this:
>>
>> VH (Version History) has child nodes VR (jcr:RootVersion) , V1, V2 and V3
>>
>> I want to delete version V2 - WORKING AS EXPECTED
>>
>> Case #4
>> --------
>>
>> Say my version graph is like this:
>>
>> VH (Version History) has child nodes VR (jcr:RootVersion) , V1 and V2
>>
>> I want to delete version V1 - NOT WORKING
>>
>> I am unable to reconnect the VR to the second version, V2.
>>
>> Actually when i try to delete the first version V1, the base node gets
>> deleted and so I loose the following versions also.
>>
>> Expected behavior is that I should be able to delete any version
>> (template).
>>
>> Please advice ASAP.
>>
>> Thank you.
>> --
>> View this message in context:
>> http://www.nabble.com/Problem-deleting-the-first-version-in-version-graph-tf4961225.html#a14209765
>> Sent from the Jackrabbit - Users mailing list archive at Nabble.com.
>>
>>
>
>
> --
> -----------------------------------------< tobias.bocanegra@day.com >---
> Tobias Bocanegra, Day Management AG, Barfuesserplatz 6, CH - 4001 Basel
> T +41 61 226 98 98, F +41 61 226 98 97
> -----------------------------------------------< http://www.day.com >---
>
>
--
View this message in context: http://www.nabble.com/Problem-deleting-the-first-version-in-version-graph-tp14209765p14370045.html
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.
Re: Problem deleting the first version in version graph
Posted by Tobias Bocanegra <to...@day.com>.
hi,
i don't understand what you are trying to achieve here. the
jcr:frozenNode/jcr:uuid is the uuid of the frozen node - and i'm not
sure for what you use this?
however, there could be a problem deleting a version while you are
iterating of the them.
further i don't think that you can delete a version as long it's still
referenced as base version.
regards, toby
On 12/7/07, monteka <mo...@anshinsoft.com> wrote:
>
> Hi,
>
> I am new to the Jackrabbit world. I have just started working on a Portal
> based project for reporting solution. We are using Jackrabbit 1.3.
>
> I am stuck with the following problem:
>
> I have a versionable node which has a default jcr:rootVersion and additional
> versions.
>
> Now I can add any number of versions (i.e. different versions of the same
> template).
>
> Problem:
>
> I have the following API that takes care of deleting the selected version of
> the template (identified by the UUID):
>
> public Object doInJcr(Session session) throws IOException,
> RepositoryException {
>
> String uuid = null;
> try {
> uuid = (String) PropertyUtils.getProperty(bean,
> "uuid");
> } catch (IllegalAccessException iae) {
> log.error("Error in getting property 'uuid'", iae);
> } catch (InvocationTargetException ite) {
> log.error("Error in getting property 'uuid'", ite);
> } catch (NoSuchMethodException nsme) {
> log.error("Error in getting property 'uuid'", nsme);
> }
>
> Node root = session.getRootNode();
>
> Node domainRoot = getDomainRoot(root);
>
> Node domainNode = domainRoot.getNode(this.nodeName);
> //nodeName is "template"
>
> VersionHistory history = domainNode.getVersionHistory();
> Version previous = null;
>
> for (VersionIterator vit = history.getAllVersions();
> vit.hasNext();) {
>
> Version version = vit.nextVersion();
> Node frozen = version.getNode("jcr:frozenNode");
>
> if (uuid.equals(frozen.getUUID())) {
> if
> (version.equals(domainNode.getBaseVersion())) {
>
> if (history.getAllVersions().getSize() >
> 2) {
> domainNode.restore(previous,
> true);
>
> history.removeVersion(version.getName());
> } else {
> domainNode.remove();
> }
> } else {
> history.removeVersion(version.getName());
> }
> break;
> } else {
> previous = version;
> continue;
> }
> }
>
> session.save();
> return null;
> }
>
> Cases:
>
> Case #1
> --------
> Say my version graph is like this:
>
> VH (Version History) has child nodes VR (jcr:RootVersion) and V1
>
> I have only 1 version (template), V1 and I choose to delete it - WORKING AS
> EXPECTED
>
> Case #2
> --------
>
> Say my version graph is like this:
>
> VH (Version History) has child nodes VR (jcr:RootVersion) , V1 and V2
>
> I want to delete version V2 - WORKING AS EXPECTED
>
> Case #3
> --------
>
> Say my version graph is like this:
>
> VH (Version History) has child nodes VR (jcr:RootVersion) , V1, V2 and V3
>
> I want to delete version V2 - WORKING AS EXPECTED
>
> Case #4
> --------
>
> Say my version graph is like this:
>
> VH (Version History) has child nodes VR (jcr:RootVersion) , V1 and V2
>
> I want to delete version V1 - NOT WORKING
>
> I am unable to reconnect the VR to the second version, V2.
>
> Actually when i try to delete the first version V1, the base node gets
> deleted and so I loose the following versions also.
>
> Expected behavior is that I should be able to delete any version (template).
>
> Please advice ASAP.
>
> Thank you.
> --
> View this message in context: http://www.nabble.com/Problem-deleting-the-first-version-in-version-graph-tf4961225.html#a14209765
> Sent from the Jackrabbit - Users mailing list archive at Nabble.com.
>
>
--
-----------------------------------------< tobias.bocanegra@day.com >---
Tobias Bocanegra, Day Management AG, Barfuesserplatz 6, CH - 4001 Basel
T +41 61 226 98 98, F +41 61 226 98 97
-----------------------------------------------< http://www.day.com >---