jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Wes" <jackrab...@wesware.securebeer.com>
Subject OCM: nt:versionedChild problem
Date Thu, 28 Feb 2008 20:59:19 GMT
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<Comment> comments = new
ArrayList<Comment>();

	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<Comment> getComments() {
		return comments;
	}
	public void setComments(List<Comment> 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)




Mime
View raw message