You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jackrabbit.apache.org by "Felix Meschberger (JIRA)" <ji...@apache.org> on 2007/09/12 08:06:32 UTC

[jira] Created: (JCR-1119) SimpleFieldsHelper emits a lot warnings

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:

   * If the property is declared to be required in the descriptor, yield an error

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


[jira] Commented: (JCR-1119) SimpleFieldsHelper emits a lot warnings

Posted by "Felix Meschberger (JIRA)" <ji...@apache.org>.
    [ 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.


[jira] Updated: (JCR-1119) SimpleFieldsHelper emits a lot warnings

Posted by "Felix Meschberger (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/JCR-1119?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Felix Meschberger updated JCR-1119:
-----------------------------------

    Description: 
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 ?

  was:
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:

   * If the property is declared to be required in the descriptor, yield an error


> 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.


[jira] Closed: (JCR-1119) SimpleFieldsHelper emits a lot warnings

Posted by "Felix Meschberger (JIRA)" <ji...@apache.org>.
     [ https://issues.apache.org/jira/browse/JCR-1119?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]

Felix Meschberger closed JCR-1119.
----------------------------------

    Resolution: Fixed

Assuming that this fix is ok and all test cases pass, I close this issue

> 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.


[jira] Commented: (JCR-1119) SimpleFieldsHelper emits a lot warnings

Posted by "Christophe Lombart (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/jira/browse/JCR-1119?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12526690 ] 

Christophe Lombart commented on JCR-1119:
-----------------------------------------

>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 ?

Right now, I don't see a use case where it should possible. Maybe we can start with your proposal and if needed, we can review the code later. 



> 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.