Package org.dspace.content.crosswalk

Examples of org.dspace.content.crosswalk.MetadataValidationException


        public Bitstream getBitstreamForMdRef(Element mdref)
            throws MetadataValidationException, IOException, SQLException, AuthorizeException
        {
            String path = METSManifest.getFileName(mdref);
            if (mdBundle == null)
                throw new MetadataValidationException("Failed referencing mdRef element, because there were no metadata files.");
            return mdBundle.getBitstreamByName(path);
        }
View Full Code Here


        public InputStream getInputStream(Element mdref)
            throws MetadataValidationException, IOException, SQLException, AuthorizeException
        {
            Bitstream mdbs = getBitstreamForMdRef(mdref);
            if (mdbs == null)
                throw new MetadataValidationException("Failed dereferencing bitstream for mdRef element="+mdref.toString());
            return mdbs.retrieve();
        }
View Full Code Here

    void checkManifest(METSManifest manifest)
        throws MetadataValidationException
    {
        String profile = manifest.getProfile();
        if (profile == null)
            throw new MetadataValidationException("Cannot accept METS with no PROFILE attribute!");
        else if (!profile.startsWith(PROFILE_START))
            throw new MetadataValidationException("METS has unacceptable PROFILE value, profile="+profile);
    }
View Full Code Here

            log.debug(outputPretty.outputString(metsDocument));
              */
        }
        catch (JDOMException je)
        {
            throw new MetadataValidationException("Error validating METS in "
                    + is.toString(),  je);
        }

        return new METSManifest(builder, metsDocument.getRootElement());
    }
View Full Code Here

        if (contentFiles != null)
            return contentFiles;

        Element fileSec = mets.getChild("fileSec", metsNS);
        if (fileSec == null)
            throw new MetadataValidationException("Invalid METS Manifest: DSpace requires a fileSec element, but it is missing.");

        contentFiles = new ArrayList();
        Iterator fgi = fileSec.getChildren("fileGrp", metsNS).iterator();
        while (fgi.hasNext())
        {
View Full Code Here

                xpath.addNamespace(metsNS);
                mdFiles = xpath.selectNodes(mets);
            }
            catch (JDOMException je)
            {
                throw new MetadataValidationException("Failed while searching for mdRef elements in manifest: ", je);
            }
        }
        return mdFiles;
    }
View Full Code Here

        throws MetadataValidationException
    {
        Element fg = file.getParentElement();
        String fgUse = fg.getAttributeValue("USE");
        if (fgUse == null)
            throw new MetadataValidationException("Invalid METS Manifest: every fileGrp element must have a USE attribute.");
        return normalizeBundleName(fgUse);
    }
View Full Code Here

            ref = file.getChild("FLocat", metsNS);
            if (ref == null)
            {
                // check for forbidden FContent child first:
                if (file.getChild("FContent", metsNS) == null)
                    throw new MetadataValidationException("Invalid METS Manifest: Every file element must have FLocat child.");
                else
                    throw new MetadataValidationException("Invalid METS Manifest: file element has forbidden FContent child, only FLocat is allowed.");
            }
        }
        else if (file.getName().equals("mdRef"))
            ref = file;
        else
            throw new MetadataValidationException("getFileName() called with recognized element type: "+file.toString());
        String loctype = ref.getAttributeValue("LOCTYPE");
        if (loctype != null && loctype.equals("URL"))
        {
            String result = ref.getAttributeValue("href", xlinkNS);
            if (result == null)
                throw new MetadataValidationException("Invalid METS Manifest: FLocat/mdRef is missing the required xlink:href attribute.");
            return result;
        }
        throw new MetadataValidationException("Invalid METS Manifest: FLocat/mdRef does not have LOCTYPE=\"URL\" attribute.");
    }
View Full Code Here

        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

    {
        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

TOP

Related Classes of org.dspace.content.crosswalk.MetadataValidationException

Copyright © 2018 www.massapicom. 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.