### Eclipse Workspace Patch 1.0 #P opencms Index: src/org/opencms/relations/CmsRelationType.java =================================================================== RCS file: /usr/local/cvs/opencms/src/org/opencms/relations/CmsRelationType.java,v retrieving revision 1.5 diff -u -r1.5 CmsRelationType.java --- src/org/opencms/relations/CmsRelationType.java 27 Feb 2008 12:05:42 -0000 1.5 +++ src/org/opencms/relations/CmsRelationType.java 10 Sep 2008 13:38:57 -0000 @@ -163,6 +163,26 @@ m_id = USER_DEFINED_MODE_LIMIT + id; } + /** + * Public constructor for user defined relation types with parameter wether link is defined in content.

+ * + * @param id the id of the relation type + * @param name the name of the relation + * @param type the type of relation type, strong or weak + * @param defInContent true if the link is defined in the content + */ + public CmsRelationType(int id, String name, String type, boolean defInContent) { + + m_name = name.toUpperCase(); + if (OpenCms.getRunLevel() > OpenCms.RUNLEVEL_2_INITIALIZING) { + // allow relation type definitions only during startup + throw new CmsInitException(Messages.get().container(Messages.ERR_RELATION_TYPE_INIT_1, m_name)); + } + m_strong = type.toUpperCase().equals(VALUE_STRONG); + m_defInContent = defInContent; + m_id = USER_DEFINED_MODE_LIMIT + id; + } + /** * Private constructor for system relation types.

* @@ -387,7 +407,7 @@ return VALUE_ARRAY[id - 1]; } id -= USER_DEFINED_MODE_LIMIT; - if ((id >= 0) && (id <= OpenCms.getResourceManager().getRelationTypes().size())) { + if ((id >= 0) && (id < getAllUserDefined().size())) { return (CmsRelationType)getAllUserDefined().get(id); } throw new CmsIllegalArgumentException(org.opencms.db.Messages.get().container( Index: src/org/opencms/loader/CmsResourceManager.java =================================================================== RCS file: /usr/local/cvs/opencms/src/org/opencms/loader/CmsResourceManager.java,v retrieving revision 1.47 diff -u -r1.47 CmsResourceManager.java --- src/org/opencms/loader/CmsResourceManager.java 27 Feb 2008 12:05:32 -0000 1.47 +++ src/org/opencms/loader/CmsResourceManager.java 10 Sep 2008 13:38:56 -0000 @@ -438,6 +438,30 @@ return relationType; } + /** + * Adds a new relation type from the XML configuration to the list of user defined relation types. + * This signature adds the "defined in content" parameter

+ * + * @param name the name of the relation type + * @param type the type of the relation type, weak or strong + * @param defincontent "true" or "false" wether the link relation is defined by a files content or not + * + * @return the new created relation type instance + * + * @throws CmsConfigurationException in case the resource manager configuration is already initialized + */ + public CmsRelationType addRelationType(String name, String type, String defincontent) throws CmsConfigurationException { + + // check if new relation types can still be added + if (m_frozen) { + throw new CmsConfigurationException(Messages.get().container(Messages.ERR_NO_CONFIG_AFTER_STARTUP_0)); + } + boolean isDefinedInContent = Boolean.valueOf(defincontent).booleanValue(); + CmsRelationType relationType = new CmsRelationType(m_configuredRelationTypes.size(), name, type, isDefinedInContent); + m_configuredRelationTypes.add(relationType); + return relationType; + } + /** * Adds a new resource type from the XML configuration to the internal list of loaded resource types.

* Index: src/org/opencms/configuration/CmsVfsConfiguration.java =================================================================== RCS file: /usr/local/cvs/opencms/src/org/opencms/configuration/CmsVfsConfiguration.java,v retrieving revision 1.46 diff -u -r1.46 CmsVfsConfiguration.java --- src/org/opencms/configuration/CmsVfsConfiguration.java 3 Apr 2008 15:26:28 -0000 1.46 +++ src/org/opencms/configuration/CmsVfsConfiguration.java 10 Sep 2008 13:38:55 -0000 @@ -78,6 +78,9 @@ /** The target attribute name. */ public static final String A_TARGET = "target"; + /** The "relationtype defined in content" attribute name. */ + public static final String A_DEFINCONTENT = "defincontent"; + /** The name of the DTD for this configuration. */ public static final String CONFIGURATION_DTD_NAME = "opencms-vfs.dtd"; @@ -490,7 +493,7 @@ digester.addCallMethod( "*/" + N_VFS + "/" + N_RESOURCES + "/" + N_RELATIONTYPES + "/" + N_RELATIONTYPE, "addRelationType", - 2); + 3); digester.addCallParam( "*/" + N_VFS + "/" + N_RESOURCES + "/" + N_RELATIONTYPES + "/" + N_RELATIONTYPE, 0, @@ -499,6 +502,10 @@ "*/" + N_VFS + "/" + N_RESOURCES + "/" + N_RELATIONTYPES + "/" + N_RELATIONTYPE, 1, A_TYPE); + digester.addCallParam( + "*/" + N_VFS + "/" + N_RESOURCES + "/" + N_RELATIONTYPES + "/" + N_RELATIONTYPE, + 2, + A_DEFINCONTENT); // generic parameter rules digester.addCallMethod( Index: src/org/opencms/configuration/opencms-vfs.dtd =================================================================== RCS file: /usr/local/cvs/opencms/src/org/opencms/configuration/opencms-vfs.dtd,v retrieving revision 1.18 diff -u -r1.18 opencms-vfs.dtd --- src/org/opencms/configuration/opencms-vfs.dtd 6 Aug 2007 13:33:05 -0000 1.18 +++ src/org/opencms/configuration/opencms-vfs.dtd 10 Sep 2008 13:38:55 -0000 @@ -41,7 +41,7 @@ --> - +