Return-Path: Delivered-To: apmail-jackrabbit-users-archive@locus.apache.org Received: (qmail 45731 invoked from network); 2 Mar 2008 09:09:35 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 2 Mar 2008 09:09:35 -0000 Received: (qmail 90375 invoked by uid 500); 2 Mar 2008 09:09:29 -0000 Delivered-To: apmail-jackrabbit-users-archive@jackrabbit.apache.org Received: (qmail 90359 invoked by uid 500); 2 Mar 2008 09:09:29 -0000 Mailing-List: contact users-help@jackrabbit.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: users@jackrabbit.apache.org Delivered-To: mailing list users@jackrabbit.apache.org Received: (qmail 90350 invoked by uid 99); 2 Mar 2008 09:09:29 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 02 Mar 2008 01:09:29 -0800 X-ASF-Spam-Status: No, hits=2.0 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of christophe.lombart@gmail.com designates 209.85.200.173 as permitted sender) Received: from [209.85.200.173] (HELO wf-out-1314.google.com) (209.85.200.173) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 02 Mar 2008 09:08:55 +0000 Received: by wf-out-1314.google.com with SMTP id 23so6338609wfg.13 for ; Sun, 02 Mar 2008 01:09:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; bh=IH2kZdTbuydJs2x3s2LqVKQXIfBnYb4qOpIPycUMbqw=; b=oFjFzfLcWelJPCTfUxcUwmS4HC7A35WsbWHvprUuml1pMK8alH0fJ583TZqm6V1Ydmf2fkqL6qAoYP45jR00d4XnN6xEhSusNOCrVbB0A8si5UJGFO1FJYjOc+8tOm7y4fsXl67eA/Oe5mXb/W5VI7Wys5EGD3geMII0LinY9GQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version:content-type:references; b=TF0ykuh41nJ1HzBFwS+2l52Bi0cexoLg2Xs+fiNWXHsEEy+6QqK6Yb/AUsjjrexeO6ukPZyZuNV6H7ni6FUEvIfIi1jhie7dx6pIy0Cg2O4SbadVB9CSAVFIRpmhiNgwNUbK8dlr5we1OR1Lz+3iGR00p6d5k0LHHzbdv8eOOMY= Received: by 10.142.44.11 with SMTP id r11mr8233794wfr.13.1204448945593; Sun, 02 Mar 2008 01:09:05 -0800 (PST) Received: by 10.142.12.16 with HTTP; Sun, 2 Mar 2008 01:09:05 -0800 (PST) Message-ID: <3b728ee90803020109j1470c20dy253395ed3cc00f7c@mail.gmail.com> Date: Sun, 2 Mar 2008 10:09:05 +0100 From: "Christophe Lombart" To: users@jackrabbit.apache.org, jackrabbit@wesware.securebeer.com Subject: Re: OCM: nt:versionedChild problem In-Reply-To: MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_Part_5243_8521191.1204448945582" References: X-Virus-Checked: Checked by ClamAV on apache.org ------=_Part_5243_8521191.1204448945582 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline Thanks for your patch. Can you create an issue in Jira for this patch. I will review and apply it. br, Christophe On Fri, Feb 29, 2008 at 9:58 PM, Wes wrote: > After digging thru the code I made the following changes that appear to > solve the problem. > > Within ObjectConverterImpl created the below method. > > public Node getActualNode(Session session,Node node) throws > RepositoryException > { > NodeType type = node.getPrimaryNodeType(); > if (type.getName().equals("nt:versionedChild")) > { > > String uuid = > node.getProperty("jcr:childVersionHistory").getValue().getString(); > Node actualNode = session.getNodeByUUID(uuid); > String name = actualNode.getName(); > actualNode = session.getNodeByUUID(name); > > return actualNode; > } > > return node; > } > > AND modified the following to call the above method > > > public Object getObject(Session session, Class clazz, String path) > { > try { > if (!session.itemExists(path)) { > return null; > } > > if (requestObjectCache.isCached(path)) > { > return requestObjectCache.getObject(path); > } > > ClassDescriptor classDescriptor = > getClassDescriptor(clazz); > > checkNodeType(session, classDescriptor); > > Node node = (Node) session.getItem(path); > if (!classDescriptor.isInterface()) { > { > node = getActualNode(session,node); > checkCompatiblePrimaryNodeTypes(session, > node, classDescriptor, true); > } > } > > ClassDescriptor alternativeDescriptor = null; > if > (classDescriptor.usesNodeTypePerHierarchyStrategy()) > { > if > (node.hasProperty(ManagerConstant.DISCRIMINATOR_PROPERTY_NAME)) > { > String className = > node.getProperty(ManagerConstant.DISCRIMINATOR_PROPERTY_NAME > ).getValue().getString(); > alternativeDescriptor = > getClassDescriptor(ReflectionUtils.forName(className)); > } > } else { > if > (classDescriptor.usesNodeTypePerConcreteClassStrategy()) > { > String nodeType = > node.getPrimaryNodeType().getName(); > if > (!nodeType.equals(classDescriptor.getJcrType())) > { > alternativeDescriptor = > classDescriptor.getDescendantClassDescriptor(nodeType); > > // in case we an alternative > could not be found by walking > // the class descriptor > hierarchy, check whether we > would > // have a descriptor for the > node type directly (which > // may the case if the class > descriptor hierarchy is > // incomplete due to missing > configuration. See JCR-1145 > // for details. > if (alternativeDescriptor == > null) { > alternativeDescriptor = > mapper.getClassDescriptorByNodeType(nodeType); > } > } > } > } > > // if we have an alternative class descriptor, > check whether its > // extends (or is the same) as the requested class. > if (alternativeDescriptor != null) { > Class alternativeClazz = > ReflectionUtils.forName(alternativeDescriptor.getClassName()); > if (clazz.isAssignableFrom(alternativeClazz)) { > clazz = alternativeClazz; > classDescriptor = alternativeDescriptor; > } > } > > // ensure class is concrete (neither interface nor > abstract) > if (clazz.isInterface() || > Modifier.isAbstract(clazz.getModifiers())) { > throw new JcrMappingException( "Cannot > instantiate non-concrete > class " + clazz.getName() > + " for node " + path + " of type " + > node.getPrimaryNodeType().getName()); > } > > Object object = > ReflectionUtils.newInstance(classDescriptor.getClassName()); > > if (! requestObjectCache.isCached(path)) > { > requestObjectCache.cache(path, object); > } > > simpleFieldsHelp.retrieveSimpleFields(session, > classDescriptor, node, object); > retrieveBeanFields(session, classDescriptor, node, > path, object, false); > retrieveCollectionFields(session, classDescriptor, > node, object, false); > > return object; > } catch (PathNotFoundException pnfe) { > // HINT should never get here > throw new > ObjectContentManagerException("Impossible to get > the object > at " + path, pnfe); > } catch (RepositoryException re) { > throw new > org.apache.jackrabbit.ocm.exception.RepositoryException("Impossible to > get the object at " + path, re); > } > } > > > Any comments or suggestions? > > Thanks > Wes > > > > > > I am building a test application against OCM. I have the following > > classes that are annotated for OCM. The problem is that when I update > and > > version the root object PressRelease the Bean Author is versioned to > > nt:versionedChild. While the OCM is checking for node type > compatibility > > it is throwing the following exception. It looks like the > versionedChild > > is not handled correctly. Any suggestions? > > > > I also attempted to retrieve the version based on the version name for > the > > rootVersion but also trapped. From a Version object how should I access > > each of the versioned entries? > > > > Thanks > > Wes > > > > @Node (jcrMixinTypes="mix:versionable") > > public class PressRelease > > { > > @Field(path=true) String path; > > @Field String title; > > @Field Date pubDate; > > @Field String content; > > @Bean Author author; > > @Collection (elementClassName=Comment.class) List > comments = new > > ArrayList(); > > > > public String getPath() { > > return path; > > } > > public void setPath(String path) { > > this.path = path; > > } > > public String getContent() { > > return content; > > } > > public void setContent(String content) { > > this.content = content; > > } > > public Date getPubDate() { > > return pubDate; > > } > > public void setPubDate(Date pubDate) { > > this.pubDate = pubDate; > > } > > public String getTitle() { > > return title; > > } > > public void setTitle(String title) { > > this.title = title; > > } > > public Author getAuthor() { > > return author; > > } > > public void setAuthor(Author author) { > > this.author = author; > > } > > public List getComments() { > > return comments; > > } > > public void setComments(List comments) { > > this.comments = comments; > > } > > > > > > } > > > > @Node (jcrMixinTypes="mix:versionable") > > public class Author { > > > > @Field(path=true) String path; > > @Field String name; > > > > > > public String getName() { > > return name; > > } > > public void setName(String name) { > > this.name = name; > > } > > public String getPath() { > > return path; > > } > > public void setPath(String path) { > > this.path = path; > > } > > > > } > > > > MAIN > > > > while (versionIterator.hasNext()) > > { > > Version version = (Version) versionIterator.next(); > > System.out.println("version found : "+ version.getName() + " - > " + > > version.getPath() + " - " + > > version.getCreated().getTime()); > > > > > > if (!version.getName().equals("jcr:rootVersion")) > > { > > > > // Get the object matching to the first version > > pressRelease = (PressRelease) > > ocm.getObject("/newtutorial",version.getName()); > > > > > > System.out.println("PressRelease title : " + > pressRelease.getTitle()); > > System.out.println(" author: " + > > pressRelease.getAuthor().getName()); > > System.out.println(" content: " + > pressRelease.getContent()); > > List comments = pressRelease.getComments(); > > Iterator iterator = comments.iterator(); > > while (iterator.hasNext()) > > { > > comment = (Comment) iterator.next(); > > System.out.println("Comment : <" + comment.getData() > + ">" + > > comment.getText()); > > } > > } > > } > > > > > > CONSOLE > > version found : jcr:rootVersion - > > > /jcr:system/jcr:versionStorage/fc/0b/fd/fc0bfd89-c487-4fbe-930f-d837e5dfed79/jcr:rootVersion > > - Thu Feb 28 15:54:42 EST 2008 > > version found : 1.0 - > > > /jcr:system/jcr:versionStorage/fc/0b/fd/fc0bfd89-c487-4fbe-930f-d837e5dfed79/1.0 > > - Thu Feb 28 15:54:59 EST 2008 > > Exception in thread "main" > > org.apache.jackrabbit.ocm.exception.ObjectContentManagerException: > Cannot > > map object of type 'com..pc.repository.Author'. Node type > > 'nt:versionedChild' does not match descriptor node type > 'nt:unstructured' > > at > > > org.apache.jackrabbit.ocm.manager.objectconverter.impl.ObjectConverterImpl.checkCompatiblePrimaryNodeTypes > (ObjectConverterImpl.java:552) > > at > > > org.apache.jackrabbit.ocm.manager.objectconverter.impl.ObjectConverterImpl.getObject > (ObjectConverterImpl.java:361) > > at > > > org.apache.jackrabbit.ocm.manager.beanconverter.impl.DefaultBeanConverterImpl.getObject > (DefaultBeanConverterImpl.java:80) > > at > > > org.apache.jackrabbit.ocm.manager.objectconverter.impl.ObjectConverterImpl.retrieveBeanField > (ObjectConverterImpl.java:666) > > at > > > org.apache.jackrabbit.ocm.manager.objectconverter.impl.ObjectConverterImpl.retrieveBeanFields > (ObjectConverterImpl.java:621) > > at > > > org.apache.jackrabbit.ocm.manager.objectconverter.impl.ObjectConverterImpl.getObject > (ObjectConverterImpl.java:309) > > at > > > org.apache.jackrabbit.ocm.manager.impl.ObjectContentManagerImpl.getObject( > ObjectContentManagerImpl.java:313) > > at com.pc.repository.Main.main(Main.java:345) > > > > > ------=_Part_5243_8521191.1204448945582--