[opencms-dev] How to add a relation

Paul-Inge Flakstad flakstad at npolar.no
Thu Aug 13 20:39:42 CEST 2009


Hi everyone

I'm trying to programatically add a relation between two resources, and things are not going so well.

What I want to do is establish a relation between an xmlcontents type resource (structured content) and an image resource, so that the image gets published when the xmlcontents file is published with related resources. This is actually quite important, because many editors forget to publish images, resulting in an error message for any user who's not logged in...

I'm putting my code inside a Java class method that creates the image (thumbnail) resource. When using the call like this (tried other CmsRelationTypes as well, same result):
cmso.addRelationToResource("/en/index.html", "/images/thumbs/image.jpg", CmsRelationType.JSP_WEAK.getName());

I get the following error:
Error while adding a relation from resource "/en/index.html" to resource "/images/thumbs/image.jpg" with type "JSP_WEAK".

Can anyone tell me what I'm doing wrong - and/or show me how it's done?

Cheers,
Paul
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20090813/0da6660b/attachment.htm>


More information about the opencms-dev mailing list