Examples of MetadataValidationException


Examples of org.dspace.content.crosswalk.MetadataValidationException

        Element fptr = firstDiv.getChild("fptr", metsNS);
        if (fptr == null)
            return null;
        String id = fptr.getAttributeValue("FILEID");
        if (id == null)
            throw new MetadataValidationException("fptr for Primary Bitstream is missing the required FILEID attribute.");
        Element result = getElementByXPath("descendant::mets:file[@ID=\""+id+"\"]", false);
        if (result == null)
            throw new MetadataValidationException("Cannot find file element for Primary Bitstream: looking for ID="+id);
        return result;
    }
View Full Code Here

Examples of org.dspace.content.crosswalk.MetadataValidationException

    {
        Element md = mdSec.getChild("mdRef", metsNS);
        if (md == null)
            md = mdSec.getChild("mdWrap", metsNS);
        if (md == null)
            throw new MetadataValidationException("Invalid METS Manifest: ?mdSec element has neither mdRef nor mdWrap child.");
        String result = md.getAttributeValue("MDTYPE");
        if (result != null && result.equals("OTHER"))
            result = md.getAttributeValue("OTHERMDTYPE");
        if (result == null)
            throw new MetadataValidationException("Invalid METS Manifest: "+md.getName()+" has no MDTYPE or OTHERMDTYPE attribute.");
        return result;
    }
View Full Code Here

Examples of org.dspace.content.crosswalk.MetadataValidationException

                Element xmlData = mdWrap.getChild("xmlData", metsNS);
                if (xmlData == null)
                {
                    Element bin = mdWrap.getChild("binData", metsNS);
                    if (bin == null)
                        throw new MetadataValidationException("Invalid METS Manifest: mdWrap element with neither xmlData nor binData child.");

                    // if binData is actually XML, return it; otherwise ignore.
                    else
                    {
                        String mimeType = mdWrap.getAttributeValue("MIMETYPE");
                        if (mimeType != null && mimeType.equalsIgnoreCase("text/xml"))
                        {
                            byte value[] = Base64.decodeBase64(bin.getText().getBytes());
                            Document mdd = parser.build(new ByteArrayInputStream(value));
                            List result = new ArrayList(1);
                            result.add(mdd.getRootElement());
                            return result;
                        }
                        else
                        {
                            log.warn("Ignoring binData section because MIMETYPE is not XML, but: "+mimeType);
                            return new ArrayList(0);
                        }
                   }
                }
                else
                {
                    return xmlData.getChildren();
                }
            }
            else if ((mdRef = mdSec.getChild("mdRef", metsNS)) != null)
            {
                String mimeType = mdRef.getAttributeValue("MIMETYPE");
                if (mimeType != null && mimeType.equalsIgnoreCase("text/xml"))
                {
                    Document mdd = parser.build(callback.getInputStream(mdRef));
                    List result = new ArrayList(1);
                    result.add(mdd.getRootElement());
                    return result;
                }
                else
                {
                    log.warn("Ignoring mdRef section because MIMETYPE is not XML, but: "+mimeType);
                    return new ArrayList(0);
                }
            }
            else
                throw new MetadataValidationException("Invalid METS Manifest: ?mdSec element with neither mdRef nor mdWrap child.");
        }
        catch (JDOMException je)
        {
            throw new MetadataValidationException("Error parsing or validating metadata section in mdRef or binData within "+mdSec.toString(), je);
        }

    }
View Full Code Here

Examples of org.dspace.content.crosswalk.MetadataValidationException

            Element xmlData = mdWrap.getChild("xmlData", metsNS);
            if (xmlData == null)
            {
                Element bin = mdWrap.getChild("binData", metsNS);
                if (bin == null)
                    throw new MetadataValidationException("Invalid METS Manifest: mdWrap element with neither xmlData nor binData child.");

                else
                {
                    byte value[] = Base64.decodeBase64(bin.getText().getBytes());
                    return new ByteArrayInputStream(value);
                }
            }
            else
            {
                XMLOutputter outputPretty = new XMLOutputter(Format.getPrettyFormat());
                return new ByteArrayInputStream(
                        outputPretty.outputString(xmlData.getChildren()).getBytes());
            }
        }
        else if ((mdRef = mdSec.getChild("mdRef", metsNS)) != null)
        {
            return callback.getInputStream(mdRef);
        }
        else
            throw new MetadataValidationException("Invalid METS Manifest: ?mdSec element with neither mdRef nor mdWrap child.");
    }
View Full Code Here

Examples of org.dspace.content.crosswalk.MetadataValidationException

    private Element getFirstDiv()
        throws MetadataValidationException
    {
        Element sm = mets.getChild("structMap", metsNS);
        if (sm == null)
            throw new MetadataValidationException("METS document is missing the required structMap element.");

        Element result = sm.getChild("div", metsNS);
        if (result == null)
            throw new MetadataValidationException("METS document is missing the required first div element in first structMap.");

        log.debug("Got firstDiv result="+result.toString());
        return (Element)result;
    }
View Full Code Here

Examples of org.dspace.content.crosswalk.MetadataValidationException

            if (result == null && nullOk)
                return null;
            else if (result instanceof Element)
                return (Element)result;
            else
                throw new MetadataValidationException("METSManifest: Failed to resolve XPath, path=\""+path+"\"");
        }
        catch (JDOMException je)
        {
            throw new MetadataValidationException("METSManifest: Failed to resolve XPath, path=\""+path+"\"", je);
        }
    }
View Full Code Here

Examples of org.dspace.content.crosswalk.MetadataValidationException

    {
        // div@DMDID is actually IDREFS, a space-separated list of IDs:
        Element firstDiv = getFirstDiv();
        String dmds = firstDiv.getAttributeValue("DMDID");
        if (dmds == null)
            throw new MetadataValidationException("Invalid METS: Missing reference to Item descriptive metadata, first div on first structmap must have a DMDID attribute.");
        String dmdID[] = dmds.split("\\s+");
        Element result[] = new Element[dmdID.length];

        for (int i = 0; i < dmdID.length; ++i)
            result[i] = getElementByXPath("mets:dmdSec[@ID=\""+dmdID[i]+"\"]", false);
View Full Code Here

Examples of org.dspace.content.crosswalk.MetadataValidationException

    {
        String type = getMdType(dmd);
        IngestionCrosswalk xwalk = getCrosswalk(type);

        if (xwalk == null)
            throw new MetadataValidationException("Cannot process METS Manifest: "+
                "No crosswalk found for MDTYPE="+type);
        crosswalkMdContent(dmd, callback, xwalk, context, item);
    }
View Full Code Here

Examples of org.dspace.content.crosswalk.MetadataValidationException

        throws MetadataValidationException,
               CrosswalkException, IOException, SQLException, AuthorizeException
    {
        Element file = getElementByXPath("descendant::mets:file[@ID=\""+fileId+"\"]", false);
        if (file == null)
            throw new MetadataValidationException("Failed in Bitstream crosswalk, Could not find file element with ID="+fileId);

        // In DSpace METS SIP spec, admin metadata is only "highly
        // recommended", not "required", so it is OK if there is no ADMID.
        String amds = file.getAttributeValue("ADMID");
        if (amds == null)
        {
            log.warn("Got no bitstream ADMID, file@ID="+fileId);
            return;
        }
        String amdID[] = amds.split("\\s+");
        for (int i = 0; i < amdID.length; ++i)
        {
            List techMDs = getElementByXPath("mets:amdSec[@ID=\""+amdID[i]+"\"]", false).
                                 getChildren("techMD", metsNS);
            Iterator ti = techMDs.iterator();
            while (ti.hasNext())
            {
                Element techMD = (Element)ti.next();
                if (techMD != null)
                {
                    String type = getMdType(techMD);
                    IngestionCrosswalk xwalk = getCrosswalk(type);
                    log.debug("Got bitstream techMD of type="+type+", for file ID="+fileId);
                    
                    if (xwalk == null)
                        throw new MetadataValidationException("Cannot process METS Manifest: "+
                            "No crosswalk found for techMD MDTYPE="+type);
                    crosswalkMdContent(techMD, callback, xwalk, context, bitstream);
                }
            }
        }
View Full Code Here

Examples of org.dspace.content.crosswalk.MetadataValidationException

        {
            return handle.substring(4);
        }
        else
        {
            throw new MetadataValidationException("Item has no valid Handle (OBJID)");
        }
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.