Opened 12 years ago

Closed 12 years ago

#1123 closed defect (fixed)

MCP MEF export/import fails... with possible data corruption

Reported by: ianwallen Owned by: geonetwork-devel@…
Priority: critical Milestone: v2.8.0
Component: General Version: v2.8.0RC2
Keywords: Cc:

Description

MEF import fails on MCP record.

Step to reproduce

  • I creat at dummy MCP 1.4 record.
  • Search for the record
  • Check the checkbox related to the record found and then select "action on selected item" and then select "Export Zip" - this seems to have generated a proper MEF file.
  • I unzipped the files
  • Edited the metadata.xml file - as a test I changed the title of the document.
  • I rezipped - the new metadata.xml into the zip/MEF file.
  • I upload the MEF file specifying to overwrite changes.

Expected results

-I expected the title of the document to have changed to the new one bug it did not.

  • Also it seems to have corrupted the document because if I try to export it again I get the following error "Root element not set"

Change History (6)

comment:1 by ianwallen, 12 years ago

I believe I found the source of the problem. I noticed exported MCP exported MEF file contain a folder called metadata which contains "metadata.iso19139.xml" and "metadata.xml"

If I remove the metadata.iso19139.xml file then the import is successful. The info.xml specifies <schema>iso19139.mcp-1.4</schema> so I'm not sure why it would be attempting to load the "metadata.iso19139.xml" file.

Based on the current documentation for MEF V2 on http://geonetwork-opensource.org/manuals/trunk/developer/mef/index.html it does mention that there can be an "(optional) metadata.profil.xml (ISO19139profil)" however it does not indicate the purpose and if it is ignored during the load.

comment:2 by ianwallen, 12 years ago

Note: From a recent test it seems that when the metadata.iso19139.xml file exists, it is putting the "metadata.iso19139.xml" content in the "metadata" field of the database and ignoring the "metadata.xml" record. it is putting "gmd:MD_Metadata" in the "root" field of the database when it should have been "mcp:MD_Metadata" - it did seem to leave the SchemaID as "iso19139.mcp-1.4".

In this case the metadata table contain a mix of iso19139.mcp-1.4 and iso19139 which is causing the errors noted above.

comment:3 by fxp, 12 years ago

In config.xml, you could update the preferredSchema to iso19139.mcp-1.4 so it should load by default mcp record if found. But it looks like there is an issue with the schema detection.

comment:4 by ianwallen, 12 years ago

If I remove the metadata.iso19139.xml file from the MEF file, it load correctly. It does not seem to be related to schema detection. It seems more related to the MEF import process attempting to load the wrong file (or attempting to load both).

comment:5 by ianwallen, 12 years ago

I believe there are 2 issues

1 - I was just looking at the java code and this is what I think it is currently doing.

if metadata is the preferred schema the load that schema.
else if it is a recognized schema then load that schema.
else generate error

But I think the logic should be

if the metadata is a recognized schema and it is the schemaid specified in the info.xml then load that schema.
else if metadata is the preferred schema the load that schema.
else if it is a recognized schema then load that schema.
else generate error

I found some comment which specifies

   // Schema in info.xml is not used anymore.
   // as we use autodetect schema to define
   // metadata schema.
   // String schema = null;

But in this case, it seems like the schema in the info.xml would be useful in picking the right schema.

2 - The other issue seems to be that it is inserting the wrong schemaid in the database. Not sure if I'm reading the code correctly but it seems that "handleInfo" uses a different method than "handleMetadataFiles" in detecting the metadata schema - they should probably use a common function.

comment:6 by simonp, 12 years ago

Resolution: fixed
Status: newclosed

Also just looked at this now (been busy on other things for some time so couldn't until now) - seems that the to19139.xsl should reset the metadataStandardName and metadataStandardVersion to something other than MCP otherwise the metadata.iso19139.xml file will not be recognized as belonging to iso19139 schema.

Check out commit 78cc76f346bdce434867f2ad1bc579684d96cfdb

Note: See TracTickets for help on using tickets.