missing attribute mappings in ocm ClassDescriptorReader
-------------------------------------------------------
Key: SLING-1064
URL: https://issues.apache.org/jira/browse/SLING-1064
Project: Sling
Issue Type: Bug
Affects Versions: JCR OCM 2.0.4
Reporter: Markus Pallo
Attachments: slingclassdescriptor.patch
I started using ocm mapping and there are attributes missing in ClassDescriptor
reader.
---mappings.xml-----------------------------------------------------
<!--
Class: de.dig.cms.common.ocm.Base
-->
<class-descriptor
className="de.dig.cms.common.ocm.Base"
jcrMixinTypes="mix:referenceable">
<field-descriptor
fieldName="id"
uuid="true" />
<field-descriptor
fieldName="name"
jcrName="true" />
<field-descriptor
fieldName="path"
path="true" />
<bean-descriptor
fieldName="parentBase"
converter="org.apache.jackrabbit.ocm.manager.beanconverter.impl.ReferenceBeanConverterImpl"
/>
</class-descriptor>
---Base.class------------------------------------
package ocm;
/**
* @ocm.mapped discriminator="true" jcrMixinTypes="mix:referenceable,
mix:lockable"
*/
public class Base {
private String resourceType;
/**
* @ocm.field uuid="true"
*/
private String id;
/**
* @ocm.field jcrName="true"
*/
private String name;
/**
* @ocm.field path="true"
*/
private String path;
/**
* @ocm.bean
converter="org.apache.jackrabbit.ocm.manager.beanconverter.impl.ReferenceBeanConverterImpl
*/
Base parentBase;
public Base() {
}
public String getUuid() {
return uuid;
}
public void setUuid(String uuid) {
this.uuid = uuid;
}
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;
}
....
}
1. "Uuid" missing in parseFieldDescriptor
i have a mapped class (see below) and after inserting and retrieving the
object out of the repository, the id (uuid) is not filled.
Base base = new Base();
base.setPath("/ocmtestpath");
base.setTitle("ocmtesttitle");
base.setName("ocmtestname");
objectContentManager.insert(base);
try {
Base base = (Base) objectContentManager.getObject(base.getPath());
// error id is not filled with uuid
} catch (Exception e) {
}
The generated (jcrocm) mappings.xml file has the entry for uuid.
After patching sling ClassDescriptorReader.parseFieldDescriptor and add
the following line
fd.setUuid(this.getOptionalAttribute("uuid", false));
it works.
2. "converter" attribute missing in parseBeanDescriptor
I have a relation to another bean and i am unable to specify the converter
class, its not set to jackrabbit in ClassReader
3. unable to set JcrMixinTypes to more than one, due to an error in setting
setJcrMixinTypes in parseClassDescriptor reason strange jackrabbit behaviour.
In ClassDescriptor you call
fd.setJcrMixinTypes(this.getOptionalAttribute("jcrMixinTypes", (String[])
null));
with a String[], thats correct.
Jackrabbit ClassDescriptor looks like
/**
* Sets a comma separated list of mixin types.
*
* @param mixinTypes command separated list of mixins
*/
public void setJcrMixinTypes(String[] mixinTypes) {
if (null != mixinTypes && mixinTypes.length == 1) {
jcrMixinTypes = mixinTypes[0].split(" *, *");
}
}
public void setJcrMixinTypes(String mixinTypes) {
if (mixinTypes != null && ! mixinTypes.equals(""))
{
jcrMixinTypes = mixinTypes.split(" *, *");
}
}
as you see "setJcrMixinTypes(String[] mixinTypes)" uses only the first!!! array
entry and only if it has a length of 1 !
so i prefer calling the method setJcrMixinTypes(String mixinTypes), it will
split by themself and then it will work.
fd.setJcrMixinTypes(this.getOptionalAttribute("jcrMixinTypes", (String) null));
Markus
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.