jackrabbit-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Felix Meschberger (JIRA)" <j...@apache.org>
Subject [jira] Commented: (JCR-1119) SimpleFieldsHelper emits a lot warnings
Date Wed, 12 Sep 2007 09:48:32 GMT

    [ https://issues.apache.org/jira/browse/JCR-1119?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12526726
] 

Felix Meschberger commented on JCR-1119:
----------------------------------------

> Right now, I don't see a use case

Thinking about it, I am even at unease to do such a check on retrieve .... Thus, I did not
implement it.

What I did implement is the following algorithm:

   If the property exists, get its value
   else if the field descriptor has a default value, use that value
   else if there exists a PropertyDescriptor and that PropertyDescriptor has a default value,
use that value
   else set the field to null

At the same time I modified the SimpleFieldsHelper as follows.

(1) retrieveSimpleField

If the initializedBean is null, it would only be created if the field value is not null. In
case of a null value, the bean is not created but it is tried to set the field value null
on that null bean. The fix is to just return null immediately if the field value turns out
to be null and the bean has not been initialized

(2) getPropertyDescriptor

I added two getPropertyDescriptor methods, which require the property definition to be single-valued
and also take residual property definitions (where getName() returns null) into account. The
main method used is the getProperyDescriptor(Node, String) while the other method getPropertyDescriptor(NodeType,
String) is used internally by the former.

(3) isProtectedProperty

Now first checks, whether a property of the given name happens to exist. If so, the isProtected
setting of that property is returned. Otherwise, the new getPropertyDescriptor(Node, String)
method is called to find a PropertyDescriptor to ask about the isProperty setting.

(4) checkProperty

This method only does work if the value is null (previously it always looked up a PropertyDescriptor
(with potential NPE if stumbled upon a residual property descriptor) and checked its mandatory
state together with the value's value). If the value is null, then the new getPropertyDescriptor(Node,
String) method is called to find the property descriptor. Then an exception is raised if the
property is mandatory and is not automatically created.


Finally I also added a simple Test Case for this new default value handling.

> SimpleFieldsHelper emits a lot warnings
> ---------------------------------------
>
>                 Key: JCR-1119
>                 URL: https://issues.apache.org/jira/browse/JCR-1119
>             Project: Jackrabbit
>          Issue Type: Improvement
>          Components: jcr-mapping
>            Reporter: Felix Meschberger
>            Assignee: Felix Meschberger
>             Fix For: 1.4
>
>
> The SimpleFieldsHelper.retrieveSimpleField method is used to load JCR properties into
simple Java object fields according to the mapping descriptor. If the node does not have the
named property, a WARN message is emited.
> If the missing property is defined as optional in the node type definition, it is quite
normal, that it may be missing. Therefore emitting a WARN message does not seem appropriate.
It would be better, to do the following (in order):
>    If the missing property is declared to be required in the descriptor, throw an exception
>    else if the descriptor has a default value for the missing property, use that value
>    else if the property is defined with a default value in the node type definition,
use that value
>    else emit a DEBUG message and leave the field undefined
> Not sure, whether it makes absolute sense to define a property as mandatory in the descriptor
but not in the node type definition. Are there any opinions on that ?

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


Mime
View raw message