⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 abstractmetsdisseminator.java

📁 DSPACE的源码 dspace-1.4-source
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
                    String groupID = "GROUP_" + xmlIDstart + sid;                             /*                     * If we're in THUMBNAIL or TEXT bundles, the bitstream is                     * extracted text or a thumbnail, so we use the name to work                     * out which bitstream to be in the same group as                     */                    if ((bundles[i].getName() != null)                            && (bundles[i].getName().equals("THUMBNAIL") ||                                bundles[i].getName().startsWith("TEXT")))                    {                        // Try and find the original bitstream, and chuck the                        // derived bitstream in the same group                        Bitstream original = findOriginalBitstream(item,                                bitstreams[bits]);                                 if (original != null)                        {                            groupID = "GROUP_" + xmlIDstart                                    + original.getSequenceID();                        }                    }                             file.setGROUPID(groupID);                    file.setMIMETYPE(bitstreams[bits].getFormat().getMIMEType());                             // FIXME: CREATED: no date                    file.setSIZE(auth ? bitstreams[bits].getSize() : 0);                    // translate checksum and type to METS, if available.                    String csType = bitstreams[bits].getChecksumAlgorithm();                    String cs = bitstreams[bits].getChecksum();                    if (auth && cs != null && csType != null)                    {                        try                        {                            file.setCHECKSUMTYPE(Checksumtype.parse(csType));                            file.setCHECKSUM(cs);                        }                        catch (MetsException e)                        {                            log.warn("Cannot set bitstream checksum type="+csType+" in METS.");                        }                    }                             // FLocat: filename is MD5 checksum                    FLocat flocat = new FLocat();                    flocat.setLOCTYPE(Loctype.URL);                    flocat.setXlinkHref(makeBitstreamName(bitstreams[bits]));                    // Make bitstream techMD metadata, add to file.                    String techID = "techMd_for_bitstream_"+bitstreams[bits].getSequenceID();                    AmdSec fAmdSec = new AmdSec();                    fAmdSec.setID(techID);                    TechMD techMd = new TechMD();                    techMd.setID(gensym("tech"));                    MdWrap mdWrap = new MdWrap();                    setMdType(mdWrap, metsName);                    XmlData xmlData = new XmlData();                    mdWrap.getContent().add(xmlData);                    techMd.getContent().add(mdWrap);                    fAmdSec.getContent().add(techMd);                    mets.getContent().add(fAmdSec);                    crosswalkToMets(xwalk, bitstreams[bits], xmlData);                    file.setADMID(techID);                    // Add FLocat to File, and File to FileGrp                    file.getContent().add(flocat);                    fileGrp.getContent().add(file);                }                         // Add fileGrp to fileSec                fileSec.getContent().add(fileGrp);            }                     // Add fileSec to document            mets.getContent().add(fileSec);                     // Create simple structMap: initial div represents the Item,            // and user-visible content bitstreams are in its child divs.            StringBuffer dmdIds = new StringBuffer();            for (int i = 0; i < dmdId.length; ++i)                dmdIds.append(" "+dmdId[i]);            StructMap structMap = new StructMap();            structMap.setID(gensym("struct"));            structMap.setTYPE("LOGICAL");            structMap.setLABEL("DSpace");            Div div0 = new Div();            div0.setID(gensym("div"));            div0.setTYPE("DSpace Item");            div0.setDMDID(dmdIds.substring(1));            if (licenseID != null)                div0.setADMID(licenseID);            // if there is a primary bitstream, add FPTR to it.            if (primaryBitstreamFileID != null)            {                Fptr fptr = new Fptr();                fptr.setFILEID(primaryBitstreamFileID);                div0.getContent().add(fptr);            }            // add DIV for each content bitstream            div0.getContent().addAll(contentDivs);            structMap.getContent().add(div0);            // Does subclass have something to add to structMap?            addStructMap(context, item, params, mets);            mets.getContent().add(structMap);            mets.validate(new MetsValidator());                     mets.write(new MetsWriter(out));        }        catch (MetsException e)        {            // We don't pass up a MetsException, so callers don't need to            // know the details of the METS toolkit            // e.printStackTrace();            throw new PackageValidationException(e);        }    }    /**     * For a bitstream that's a thumbnail or extracted text, find the     * corresponding bitstream it was derived from, in the ORIGINAL bundle.     *     * @param item     *            the item we're dealing with     * @param derived     *            the derived bitstream     *     * @return the corresponding original bitstream (or null)     */    protected static Bitstream findOriginalBitstream(Item item, Bitstream derived)        throws SQLException    {        Bundle[] bundles = item.getBundles();        // Filename of original will be filename of the derived bitstream        // minus the extension (last 4 chars - .jpg or .txt)        String originalFilename = derived.getName().substring(0,                derived.getName().length() - 4);        // First find "original" bundle        for (int i = 0; i < bundles.length; i++)        {            if ((bundles[i].getName() != null)                    && bundles[i].getName().equals("ORIGINAL"))            {                // Now find the corresponding bitstream                Bitstream[] bitstreams = bundles[i].getBitstreams();                for (int bsnum = 0; bsnum < bitstreams.length; bsnum++)                {                    if (bitstreams[bsnum].getName().equals(originalFilename))                    {                        return bitstreams[bsnum];                    }                }            }        }        // Didn't find it        return null;    }    // Get result from crosswalk plugin and add it to the document,    // including namespaces and schema.    private void crosswalkToMets(DisseminationCrosswalk xwalk,                                 DSpaceObject dso, MetsElement me)        throws CrosswalkException,               IOException, SQLException, AuthorizeException    {        // add crosswalk's namespaces and schemaLocation to this element:        String raw = xwalk.getSchemaLocation();        String sloc[] = raw == null ? null : raw.split("\\s+");        Namespace ns[] = xwalk.getNamespaces();        for (int i = 0; i < ns.length; ++i)        {            String uri = ns[i].getURI();            if (sloc != null && sloc.length > 1 && uri.equals(sloc[0]))                me.setSchema(ns[i].getPrefix(), uri, sloc[1]);            else                me.setSchema(ns[i].getPrefix(), uri);        }        // add result of crosswalk        PreformedXML pXML =          new PreformedXML(            xwalk.preferList() ?              outputter.outputString(xwalk.disseminateList(dso)) :              outputter.outputString(xwalk.disseminateElement(dso)));        me.getContent().add(pXML);    }    /**     * Returns name of METS profile to which this package conforms, e.g.     *  "DSpace METS DIP Profile 1.0"     * @return string name of profile.     */    abstract public String getProfile();    /**     * Returns fileGrp's USE attribute value corresponding to a DSpace bundle name.     *     * @param bname name of DSpace bundle.     * @return string name of fileGrp     */    abstract public String bundleToFileGrp(String bname);    /**     * Get the types of Item-wide DMD to include in package.     * Each element of the returned array is a String, which     * MAY be just a simple name, naming both the Crosswalk Plugin and     * the METS "MDTYPE", <em>or</em> a colon-separated pair consisting of     * the METS name followed by a colon and the Crosswalk Plugin name.     * E.g. the type string <code>"DC:qualifiedDublinCore"</code> tells it to     * create a METS section with <code>MDTYPE="DC"</code> and use the plugin     * named "qualifiedDublinCore" to obtain the data.     * @param params the PackageParameters passed to the disseminator.     * @return array of metadata type strings, never null.     */    abstract public String [] getDmdTypes(PackageParameters params)        throws SQLException, IOException, AuthorizeException;    /**     * Get the type string of the technical metadata to create for each     * Bitstream in the Item.  The type string may be a simple name or     * colon-separated compound as specified for <code>getDmdTypes()</code> above.     * @param params the PackageParameters passed to the disseminator.     * @return array of metadata type strings, never null.     */    abstract public String getTechMdType(PackageParameters params)        throws SQLException, IOException, AuthorizeException;    /**     * Add Rights metadata for the Item, in the form of     * (<code>rightsMd</code> elements) to the given metadata section.     *     */    abstract public void addRightsMd(Context context, Item item, AmdSec amdSec)        throws SQLException, IOException, AuthorizeException, MetsException;    /**     * Add any additional <code>structMap</code> elements to the     * METS document, as required by this subclass.  A simple default     * structure map which fulfills the minimal DSpace METS DIP/SIP     * requirements is already present, so this does not need to do anything.     * @param mets the METS document to which to add structMaps     */    abstract public void addStructMap(Context context, Item item,                               PackageParameters params, Mets mets)        throws SQLException, IOException, AuthorizeException, MetsException;}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -