<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.6000.16890" name=GENERATOR></HEAD>
<BODY>
<DIV dir=ltr align=left><SPAN class=677222817-25082009><FONT face=Arial
color=#0000ff size=2>Self-replying. :-)</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=677222817-25082009><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=677222817-25082009><FONT face=Arial
color=#0000ff size=2>This was easy to do once I found out how, but actually
finding out how was</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=677222817-25082009><FONT face=Arial
color=#0000ff size=2>a little tricky. I couldn't find much </FONT></SPAN><SPAN
class=677222817-25082009><FONT face=Arial color=#0000ff size=2>on the web and
had to resolve to the old </FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=677222817-25082009><FONT face=Arial
color=#0000ff size=2>"browse-the-source-code-you-f**ing-noob" to get a grip. I
haven't tested this</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=677222817-25082009><FONT face=Arial
color=#0000ff size=2>much, so I don't know if I'm actually doing it right, but
so far it seems to </FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=677222817-25082009><FONT face=Arial
color=#0000ff size=2>be working.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=677222817-25082009><FONT face=Arial
color=#0000ff size=2>---</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=677222817-25082009><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=677222817-25082009><FONT face=Arial
color=#0000ff size=2>To add a user-defined custom relation type, you'll have to
edit opencms-vfs.xml.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=677222817-25082009><FONT face=Arial
color=#0000ff size=2>(opencms-vfs.xml is one of OpenCms' configuration
files, and is found in: </FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=677222817-25082009><FONT face=Arial
color=#0000ff
size=2>$TOMCAT_HOME/webapps/$OPENCMS_WEBAPP_NAME/WEB-INF/config/)</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=677222817-25082009><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=677222817-25082009><FONT face=Arial
color=#0000ff size=2>Find the <FONT face="Courier New"><resources></FONT>
node in this file, and add your relation inside it</FONT></SPAN><SPAN
class=677222817-25082009><FONT face=Arial color=#0000ff size=2> like
this:</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=677222817-25082009><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=677222817-25082009><FONT face="Courier New"
color=#0000ff size=2><resources></FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=677222817-25082009><FONT
face="Courier New"> <FONT color=#0000ff
size=2>....</FONT></FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=677222817-25082009><FONT face="Courier New"
color=#0000ff size=2>
<relationtypes></FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=677222817-25082009><FONT
face="Courier New"> <FONT
color=#0000ff size=2><relationtype name="YOUR_RELATIONTYPE_NAME"
type="strong" /><!-- the type can be either strong or weak
--></FONT></FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=677222817-25082009><FONT face="Courier New"
color=#0000ff size=2>
</relationtypes></FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=677222817-25082009><FONT
face="Courier New"> <FONT color=#0000ff
size=2>...</FONT></FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=677222817-25082009><FONT face="Courier New"
color=#0000ff size=2></resources></FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=677222817-25082009><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=677222817-25082009><FONT face=Arial
color=#0000ff size=2>(Note that the <FONT
face="Courier New"><relationtypes></FONT> element does not exist out
of the box. It does not </FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=677222817-25082009><FONT face=Arial
color=#0000ff size=2>matter </FONT></SPAN><SPAN class=677222817-25082009><FONT
face=Arial color=#0000ff size=2>where you decide to put it, as long as
it becomes an "immediate child" </FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=677222817-25082009><FONT face=Arial
color=#0000ff size=2>to the <FONT
face="Courier New"><resources></FONT> element. I placed mine directly
after <FONT face="Courier New"></mimetypes></FONT>.)</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=677222817-25082009><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=677222817-25082009><FONT face=Arial
color=#0000ff size=2>In order for these changes to take effect, re-initialize
OpenCms (restart Tomcat).</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=677222817-25082009><FONT face=Arial
color=#0000ff size=2> </FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=677222817-25082009><FONT face=Arial
color=#0000ff size=2>You can test that your new relation type exists
</FONT></SPAN><SPAN class=677222817-25082009><FONT face=Arial color=#0000ff
size=2>by listing all relation types. </FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=677222817-25082009><FONT face=Arial
color=#0000ff size=2>Use a simple JSP like this one to do
that:</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=677222817-25082009><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><FONT face="Courier New"><SPAN
class=677222817-25082009><FONT color=#0000ff size=2><%@ page
import="org.opencms.relations.*, java.util.*</FONT></SPAN><SPAN
class=677222817-25082009><FONT color=#0000ff size=2>" session="true"
%></FONT></SPAN></FONT></DIV>
<DIV dir=ltr align=left><SPAN class=677222817-25082009><FONT face="Courier New"
color=#0000ff size=2><%</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=677222817-25082009><FONT face="Courier New"
color=#0000ff size=2>List relationTypesAll =
CmsRelationType.getAll();<BR>CmsRelationType rt = null;<BR>Iterator i =
relationTypesAll.iterator();<BR>out.print("<ul>");<BR>while (i.hasNext())
{<BR> rt = (CmsRelationType)i.next();<BR>
out.print("<li>NAME: " + rt.getName() + ", TYPE: " +
rt.getType());<BR>}<BR>out.print("</ul>");</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=677222817-25082009><FONT face="Courier New"
color=#0000ff size=2>%></FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=677222817-25082009><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=677222817-25082009><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=677222817-25082009><FONT face=Arial
color=#0000ff size=2>To use a relation
programatically:</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=677222817-25082009><FONT face="Courier New"
color=#0000ff size=2>CmsRelationType rt =
CmsRelationType.valueOf("YOUR_RELATIONTYPE_NAME");</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=677222817-25082009><FONT face="Courier New"
color=#0000ff
size=2>yourCmsObjectInstance.addRelationToResource(fromResourcePath,
toResourcePath, rt.getName());</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=677222817-25082009><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=677222817-25082009><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left><SPAN class=677222817-25082009><FONT face=Arial
color=#0000ff size=2>Cheers,</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=677222817-25082009><FONT face=Arial
color=#0000ff size=2>Paul</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=677222817-25082009><FONT face=Arial
color=#0000ff size=2></FONT></SPAN> </DIV>
<DIV dir=ltr align=left>
<HR tabIndex=-1>
</DIV>
<DIV dir=ltr align=left><FONT face=Tahoma size=2><B>From:</B>
opencms-dev-bounces@opencms.org [mailto:opencms-dev-bounces@opencms.org] <B>On
Behalf Of </B>Paul-Inge Flakstad<BR><B>Sent:</B> 25. august 2009
17:10<BR><B>To:</B> opencms-dev@opencms.org<BR><B>Subject:</B> [opencms-dev]
Adding a user-defined relation<BR></FONT><BR></DIV>
<BLOCKQUOTE dir=ltr
style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #0000ff 2px solid; MARGIN-RIGHT: 0px">
<DIV></DIV>
<DIV><SPAN class=308255514-25082009><FONT face=Arial size=2>Hello
list!</FONT></SPAN></DIV>
<DIV><SPAN class=308255514-25082009><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=308255514-25082009><FONT face=Arial size=2>I've tried to
add a user-defined relation to OpenCms using the following
approaches:</FONT></SPAN></DIV>
<DIV><SPAN class=308255514-25082009><FONT face=Arial size=2>1.) in a JSP
file by calling the constructor in org.opencms.relations.CmsRelationType.
</FONT></SPAN></DIV>
<DIV><SPAN class=308255514-25082009><FONT face=Arial size=2>2.) by
creating a module with an action class, and calling the above
mentioned constructor </FONT></SPAN></DIV>
<DIV><SPAN class=308255514-25082009><FONT face=Arial size=2>from the
action class' initialize-method.</FONT></SPAN></DIV>
<DIV><SPAN class=308255514-25082009><FONT face=Arial
size=2></FONT></SPAN> </DIV>
<DIV><SPAN class=308255514-25082009><FONT face=Arial size=2>Approach 1.)
produced an error.</FONT></SPAN></DIV>
<DIV><SPAN class=308255514-25082009><FONT face=Arial size=2>Approach 2.) did
not produce any error, but when getting the list of relation types from
</FONT></SPAN></DIV>
<DIV><SPAN class=308255514-25082009><FONT face=Arial
size=2>CmsRelationType.getAll(), my user-defined relation is not there. Also,
trying to use </FONT></SPAN></DIV>
<DIV><SPAN class=308255514-25082009><FONT face=Arial size=2>my user-defined
relation with </FONT></SPAN><SPAN class=308255514-25082009><FONT
face=Arial size=2>addRelationToResource() does not work. It gives an
</FONT></SPAN></DIV>
<DIV><FONT face=Arial><FONT size=2><SPAN class=308255514-25082009>exception
telling me that: </SPAN></FONT></FONT></DIV>
<DIV><FONT face=Arial><FONT size=2><SPAN class=308255514-25082009></SPAN><SPAN
class=308255514-25082009> </SPAN></FONT></FONT></DIV>
<DIV><FONT face=Arial><FONT size=2><SPAN class=308255514-25082009>The value
"801" can not be parsed into an enum </SPAN></FONT><SPAN
class=308255514-25082009><FONT size=2>element of type
"org.opencms.relations.CmsRelationType"</FONT></SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=308255514-25082009></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=308255514-25082009>(Which btw is
kinda interesting, sice I actually try to use the value "901", not "801",
which is</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN class=308255514-25082009>the ID
I assigned my user-defined relation.)</SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN
class=308255514-25082009></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=308255514-25082009><SPAN
class=308255514-25082009><FONT face=Arial size=2>Is anyone able to tell me how
to add a user-defined relation?</FONT></SPAN></SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN class=308255514-25082009><SPAN
class=308255514-25082009></SPAN></SPAN></FONT> </DIV>
<DIV><FONT face=Arial size=2><SPAN class=308255514-25082009><SPAN
class=308255514-25082009>Thanks,</SPAN></SPAN></FONT></DIV>
<DIV><FONT face=Arial size=2><SPAN class=308255514-25082009><SPAN
class=308255514-25082009>Paul</SPAN></SPAN></FONT></DIV></BLOCKQUOTE></BODY></HTML>