jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From monteka <mont...@anshinsoft.com>
Subject Re: Problem in deleting the first version
Date Fri, 07 Dec 2007 08:29:16 GMT

Sorry I forgot to explain the problem in depth.

Actually when i try to delete the first version as stated in Case 4. below,
the base node gets deleted and so I loose the following versions also.

Expected behavior is that I should be able to delete any node (template).

Thank you.


monteka 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:
> 
> The tree is something like this
> 
> jcr:rootVersion
>                     - port:template*
> 
> Now I can add any number of templates (i.e. different versions of the same
> template).
> 
> Problem:
> 
> I have the following API that takes care of the selected template
> (identified by the UUID) removal.
> 
> 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:
> 
> 1. I have only 1 template and delete it - WORKING AS EXPECTED
> 2. I have 2 templates and I delete the most recent one - WORKING AS
> EXPECTED
> 3. I have 3 templates and I delete the second template - WORKING AS
> EXPECTED
> 4. I have 2 or 3 templates and I want to delete the first template - NOT
> WORKING
> 
> I am unable to reconnect the jcr:rootVersion to the second template.
> 
> Please advice ASAP.
> 
> Thank you.
> 

-- 
View this message in context: http://www.nabble.com/Problem-in-deleting-the-first-version-tf4960866.html#a14208723
Sent from the Jackrabbit - Users mailing list archive at Nabble.com.


Mime
View raw message