Opened 15 years ago

Closed 15 years ago

#99 closed defect (fixed)

FGDC metadata extension with online linkage causes ClassCastException

Reported by: mattblanchette Owned by: geonetwork-devel@…
Priority: critical Milestone: v2.4.0 RC2
Component: General Version: v2.2.0 Final
Keywords: FGDC, metextns, onlink, ClassCastException Cc:

Description

Attempting to add a FGDC metextns (Metadata Extension) element with an onlink (Online Linkage) in the metadata edit forms causes the following Error message:

Error
The requested operation could not be performed.
ClassCastException : java.util.ArrayList cannot be cast to java.lang.String

Once these elements (<metextns><onlink/></metextns>) are added to an FGDC metadata entry, it can no longer be opened for editing since it will always throw this Error.

Error log shows that this Exception originated from the addValues method of org.fao.geonet.kernel.EditLib class, which appears to be line 999 since it performs a String cast:
text.setAttribute(Edit.Attribute.Attr.VALUE, (String) values.get(i));

Change History (2)

comment:1 by mattblanchette, 15 years ago

Current workaround: Add test in addValues method:

if( values.get(i) instanceof String ) {
    Element text  = new Element(Edit.Element.Child.TEXT, Edit.NAMESPACE);
    text.setAttribute(Edit.Attribute.Attr.VALUE, (String) values.get(i));

    elem.addContent(text);
}

comment:2 by ticheler, 15 years ago

Milestone: v2.4.0 RC2
Resolution: fixed
Status: newclosed

Fixed and tested by Simon Pigot

Note: See TracTickets for help on using tickets.