Item.match() incorrect logic for schema testing
-----------------------------------------------

                 Key: DS-806
                 URL: https://jira.duraspace.org/browse/DS-806
             Project: DSpace
          Issue Type: Bug
          Components: DSpace API
    Affects Versions: 1.7.0, 1.6.2, 1.6.1, 1.6.0, 1.5.2, 1.5.1, 1.5.0
            Reporter: Stuart Lewis
            Priority: Blocker
             Fix For: 1.7.1


Item.match(String schema, String element, String qualifier, String language, 
DCValue dcv) contains the following code:

        if (language == null)
        {
            // Value must be null language to match
            if (dcv.language != null)
            {
                // Value is qualified, so no match
                return false;
            }
        }
        else if (!language.equals(Item.ANY))
        {
            // Not a wildcard, so language must match exactly
            if (!language.equals(dcv.language))
            {
                return false;
            }
        }
        else if (!schema.equals(Item.ANY))
        {
            if (dcv.schema != null && !dcv.schema.equals(schema))
            {
                // The namespace doesn't match
                return false;
            }
        }

Therefore, the schema is not being checked if the language of the metadata 
field is empty (null) or set to Item.ANY.  This leads to the following case:

dc.type = foo
dc2.type = bar

MyItem.getMetadata("dc", "type", null, null) should return 1 result 'foo'.

Instead, it returns 'foo' and 'bar'.

To fix, change the 'else if' for the 'else if (language == null)' to 'if 
(language == null)'.

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
https://jira.duraspace.org/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

------------------------------------------------------------------------------
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires 
February 28th, so secure your free ArcSight Logger TODAY! 
http://p.sf.net/sfu/arcsight-sfd2d
_______________________________________________
Dspace-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/dspace-devel

Reply via email to