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

📄 abstractmetsdisseminator.java

📁 DSPACE的源码 dspace-1.4-source
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
                            {                                log.warn("Skipping Bitstream, SID="+String.valueOf(bitstreams[k].getSequenceID())+", not authorized for READ.");                            }                            else                            {                                throw new AuthorizeException("Not authorized to read Bitstream, SID="+String.valueOf(bitstreams[k].getSequenceID()));                            }                        }                    }                }                zip.close();                extraFiles = null;            }        }        else            throw new PackageValidationException("Can only disseminate an Item now.");    }    /**     * Create name that bitstream will have in archive.  Name must     * be unique and relative to archive top level, e.g. "bitstream_<id>.ext"     */    private String makeBitstreamName(Bitstream bitstream)    {        String base = "bitstream_"+String.valueOf(bitstream.getID());        String ext[] = bitstream.getFormat().getExtensions();        return (ext.length > 0) ? base+"."+ext[0] : base;    }    // set metadata type - if Mdtype.parse() gets exception,    // that means it's not in the MDTYPE vocabulary, so use OTHER.    private void setMdType(MdWrap mdWrap, String mdtype)    {        try        {            mdWrap.setMDTYPE(Mdtype.parse(mdtype));        }        catch (MetsException e)        {            mdWrap.setMDTYPE(Mdtype.OTHER);            mdWrap.setOTHERMDTYPE(mdtype);        }    }    /**     * Write out a METS manifest.     * Mostly lifted from Rob Tansley's METS exporter.     */    private void writeManifest(Context context, Item item,                               PackageParameters params, OutputStream out)        throws PackageValidationException, CrosswalkException, AuthorizeException, SQLException, IOException    {        try        {            // Create the METS file            Mets mets = new Mets();                     // Top-level stuff            mets.setID(gensym("mets"));            mets.setOBJID("hdl:" + item.getHandle());            mets.setLABEL("DSpace Item");            mets.setPROFILE(getProfile());                     // MetsHdr            MetsHdr metsHdr = new MetsHdr();            metsHdr.setCREATEDATE(new Date()); // FIXME: CREATEDATE is now:                                               // maybe should be item create            // date?            // Agent            Agent agent = new Agent();            agent.setROLE(Role.CUSTODIAN);            agent.setTYPE(Type.ORGANIZATION);            Name name = new Name();            name.getContent()                    .add(new PCData(ConfigurationManager                                    .getProperty("dspace.name")));            agent.getContent().add(name);            metsHdr.getContent().add(agent);            mets.getContent().add(metsHdr);                     // add DMD sections            // Each type element MAY be either just a MODS-and-crosswalk name, OR            // a combination "MODS-name:crosswalk-name" (e.g. "DC:qDC").            String dmdTypes[] = getDmdTypes(params);            // record of ID of each dmdsec to make DMDID in structmap.            String dmdGroup = gensym("dmd_group");            String dmdId[] = new String[dmdTypes.length];            for (int i = 0; i < dmdTypes.length; ++i)            {                dmdId[i] = gensym("dmd");                XmlData xmlData = new XmlData();                String xwalkName, metsName;                String parts[] = dmdTypes[i].split(":", 2);                if (parts.length > 1)                {                    metsName = parts[0];                    xwalkName = parts[1];                }                else                    xwalkName = metsName = dmdTypes[i];                DisseminationCrosswalk xwalk = (DisseminationCrosswalk)                  PluginManager.getNamedPlugin(DisseminationCrosswalk.class, xwalkName);                if (xwalk == null)                    throw new PackageValidationException("Cannot find "+dmdTypes[i]+" crosswalk plugin!");                else                    crosswalkToMets(xwalk, item, xmlData);                DmdSec dmdSec = new DmdSec();                dmdSec.setID(dmdId[i]);                dmdSec.setGROUPID(dmdGroup);                MdWrap mdWrap = new MdWrap();                setMdType(mdWrap, metsName);                mdWrap.getContent().add(xmlData);                dmdSec.getContent().add(mdWrap);                mets.getContent().add(dmdSec);            }                     // Only add license AMD section if there are any licenses.            // Catch authorization failures accessing license bitstreams            // only if we are skipping unauthorized bitstreams.            String licenseID = null;            try            {            AmdSec amdSec = new AmdSec();            addRightsMd(context, item, amdSec);            if (amdSec.getContent().size() > 0)            {                licenseID = gensym("license");                amdSec.setID(licenseID);                mets.getContent().add(amdSec);            }            }            catch (AuthorizeException e)            {                String unauth = (params == null) ? null : params.getProperty("unauthorized");                if (!(unauth != null && unauth.equalsIgnoreCase("skip")))                    throw e;                else                    log.warn("Skipping license metadata because of access failure: "+e.toString());            }            // FIXME: History data???? Nooooo!!!!            // fileSec - all non-metadata bundles go into fileGrp,            // and each bitstream therein into a file.            // Create the bitstream-level techMd and div's for structmap            // at the same time so we can connec the IDREFs to IDs.            FileSec fileSec = new FileSec();                     String techMdType = getTechMdType(params);            String parts[] = techMdType.split(":", 2);            String xwalkName, metsName;            if (parts.length > 1)            {                metsName = parts[0];                xwalkName = parts[1];            }            else                xwalkName = metsName = techMdType;            DisseminationCrosswalk xwalk = (DisseminationCrosswalk)              PluginManager.getNamedPlugin(DisseminationCrosswalk.class, xwalkName);            if (xwalk == null)                throw new PackageValidationException("Cannot find "+xwalkName+" crosswalk plugin!");            // log the primary bitstream for structmap            String primaryBitstreamFileID = null;            // accumulate content DIV items to put in structMap later.            List contentDivs = new ArrayList();            // how to handle unauthorized bundle/bitstream:            String unauth = (params == null) ? null : params.getProperty("unauthorized");            Bundle[] bundles = item.getBundles();            for (int i = 0; i < bundles.length; i++)            {                if (PackageUtils.isMetaInfoBundle(bundles[i]))                    continue;                // unauthorized bundle?                // NOTE: This must match the logic in disseminate()                if (!AuthorizeManager.authorizeActionBoolean(context,                            bundles[i], Constants.READ))                {                    if (unauth != null &&                        (unauth.equalsIgnoreCase("skip")))                        continue;                    else                        throw new AuthorizeException("Not authorized to read Bundle named \""+bundles[i].getName()+"\"");                }                Bitstream[] bitstreams = bundles[i].getBitstreams();                // Create a fileGrp                FileGrp fileGrp = new FileGrp();                         // Bundle name for USE attribute                String bName = bundles[i].getName();                if ((bName != null) && !bName.equals(""))                    fileGrp.setUSE(bundleToFileGrp(bName));                         // watch for primary bitstream                int primaryBitstreamID = -1;                boolean isContentBundle = false;                if ((bName != null) && bName.equals("ORIGINAL"))                {                    isContentBundle = true;                    primaryBitstreamID = bundles[i].getPrimaryBitstreamID();                }                for (int bits = 0; bits < bitstreams.length; bits++)                {                    // Check for authorization.  Handle unauthorized                    // bitstreams to match the logic in disseminate(),                    // i.e. "unauth=zero" means include a 0-length bitstream,                    // "unauth=skip" means to ignore it (and exclude from                    // manifest).                    boolean auth = AuthorizeManager.authorizeActionBoolean(context,                            bitstreams[bits], Constants.READ);                    if (!auth)                    {                        if (unauth != null && unauth.equalsIgnoreCase("skip"))                            continue;                        else if (!(unauth != null && unauth.equalsIgnoreCase("zero")))                            throw new AuthorizeException("Not authorized to read Bitstream, SID="+String.valueOf(bitstreams[bits].getSequenceID()));                    }                    String sid = String.valueOf(bitstreams[bits].getSequenceID());                             edu.harvard.hul.ois.mets.File file = new edu.harvard.hul.ois.mets.File();                             String xmlIDstart = "bitstream_";                    String fileID = xmlIDstart + sid;                    file.setID(fileID);                    // log primary bitstream for later (structMap)                    if (bitstreams[bits].getID() == primaryBitstreamID)                        primaryBitstreamFileID = fileID;                    // if this is content, add to structmap too:                    if (isContentBundle)                    {                        Div div = new Div();                        div.setID(gensym("div"));                        div.setTYPE("DSpace Content Bitstream");                        Fptr fptr = new Fptr();                        fptr.setFILEID(fileID);                        div.getContent().add(fptr);                        contentDivs.add(div);                    }                    file.setSEQ(bitstreams[bits].getSequenceID());         

⌨️ 快捷键说明

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