Uploaded image for project: 'DSpace'
  1. DSpace
  2. DS-806

Item.match() incorrect logic for schema testing

    Details

    • Type: Bug
    • Status: Closed (View Workflow)
    • Priority: Blocker
    • Resolution: Fixed
    • Affects Version/s: 1.5.0, 1.5.1, 1.5.2, 1.6.0, 1.6.1, 1.6.2, 1.7.0
    • Fix Version/s: 1.7.1, 1.8.0
    • Component/s: DSpace API
    • Labels:
      None
    • Attachments:
      1
    • Comments:
      5
    • Documentation Status:
      Not Required

      Description

      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 (!schema.equals(Item.ANY))' to 'if (!schema.equals(Item.ANY))'.

        Attachments

          Activity

            People

            • Assignee:
              stuartlewis Stuart Lewis
              Reporter:
              stuartlewis Stuart Lewis
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: