Package org.dspace.content

Examples of org.dspace.content.BitstreamFormat


        }

        //Create the License bitstream
        Bitstream lbs = lb.createBitstream(lis);
        lis.close();
        BitstreamFormat bf = BitstreamFormat.findByShortDescription(context, "License");
        if (bf == null)
        {
            bf = FormatIdentifier.guessFormat(context, lbs);
        }
        lbs.setFormat(bf);
View Full Code Here


     */
     public static BitstreamFormat findOrCreateBitstreamFormat(Context context,
            String shortDesc, String MIMEType, String desc, int supportLevel, boolean internal)
        throws SQLException, AuthorizeException
     {
        BitstreamFormat bsf = BitstreamFormat.findByShortDescription(context,
                                shortDesc);
        // not found, try to create one
        if (bsf == null)
        {
            bsf = BitstreamFormat.create(context);
            bsf.setShortDescription(shortDesc);
            bsf.setMIMEType(MIMEType);
            bsf.setDescription(desc);
            bsf.setSupportLevel(supportLevel);
            bsf.setInternal(internal);
            bsf.update();
        }
        return bsf;
    }
View Full Code Here

    public static Bitstream findDepositLicense(Context context, Item item)
            throws SQLException, IOException, AuthorizeException
    {
        // get license format ID
        int licenseFormatId = -1;
        BitstreamFormat bf = BitstreamFormat.findByShortDescription(context,
                "License");
        if (bf != null)
        {
            licenseFormatId = bf.getID();
        }

        Bundle[] bundles = item.getBundles(Constants.LICENSE_BUNDLE_NAME);
        for (int i = 0; i < bundles.length; i++)
        {
View Full Code Here

                .getContentFiles();
        List<Element> manifestBundleFiles = manifest
                .getBundleFiles();

        boolean setPrimaryBitstream = false;
        BitstreamFormat unknownFormat = BitstreamFormat.findUnknown(context);

        for (Iterator<Element> mi = manifestContentFiles.iterator(); mi
                .hasNext();)
        {
            Element mfile = mi.next();

            // basic validation -- check that it has an ID attribute
            String mfileID = mfile.getAttributeValue("ID");
            if (mfileID == null)
            {
                throw new PackageValidationException(
                        "Invalid METS Manifest: file element without ID attribute.");
            }

            // retrieve path/name of file in manifest
            String path = METSManifest.getFileName(mfile);

            // extract the file input stream from package (or retrieve
            // externally, if it is an externally referenced file)
            InputStream fileStream = getFileInputStream(pkgFile, params, path);

            // retrieve bundle name from manifest
            String bundleName = METSManifest.getBundleName(mfile);

            // Find or create the bundle where bitstream should be attached
            Bundle bundle;
            Bundle bns[] = item.getBundles(bundleName);
            if (bns != null && bns.length > 0)
            {
                bundle = bns[0];
            }
            else
            {
                bundle = item.createBundle(bundleName);
            }

            // Create the bitstream in the bundle & initialize its name
            Bitstream bitstream = bundle.createBitstream(fileStream);
            bitstream.setName(path);

             // Set bitstream sequence id, if known
            String seqID = mfile.getAttributeValue("SEQ");
            if(seqID!=null && !seqID.isEmpty())
                bitstream.setSequenceID(Integer.parseInt(seqID));
           
            // crosswalk this bitstream's administrative metadata located in
            // METS manifest (or referenced externally)
            manifest.crosswalkBitstream(context, params, bitstream, mfileID,
                    mdRefCallback);

            // is this the primary bitstream?
            if (primaryID != null && mfileID.equals(primaryID))
            {
                bundle.setPrimaryBitstreamID(bitstream.getID());
                bundle.update();
                setPrimaryBitstream = true;
            }

            // Run any finishing activities -- this allows subclasses to
            // change default bitstream information
            finishBitstream(context, bitstream, mfile, manifest, params);

            // Last-ditch attempt to divine the format, if crosswalk failed to
            // set it:
            // 1. attempt to guess from MIME type
            // 2. if that fails, guess from "name" extension.
            if (bitstream.getFormat().equals(unknownFormat))
            {
                if (log.isDebugEnabled())
                {
                    log.debug("Guessing format of Bitstream left un-set: "
                            + bitstream.toString());
                }
                String mimeType = mfile.getAttributeValue("MIMETYPE");
                BitstreamFormat bf = (mimeType == null) ? null
                        : BitstreamFormat.findByMIMEType(context, mimeType);
                if (bf == null)
                {
                    bf = FormatIdentifier.guessFormat(context, bitstream);
                }
View Full Code Here

        {
            throw new PackageValidationException(
                    "Configuration Error: No Manifest BitstreamFormat configured for METS ingester type="
                            + getConfigurationName());
        }
        BitstreamFormat manifestFormat = PackageUtils
                .findOrCreateBitstreamFormat(context, fmtName,
                        "application/xml", fmtName + " package manifest");
        manifestBitstream.setFormat(manifestFormat);
        manifestBitstream.update();
    }
View Full Code Here

            String bsName = resource.getAttributeValue("title");
            newBitstream.setName(bsName);
           
              // Identify the format
            String mimeString = resource.getAttributeValue("type");
            BitstreamFormat bsFormat = BitstreamFormat.findByMIMEType(context, mimeString);
            if (bsFormat == null) {
              bsFormat = FormatIdentifier.guessFormat(context, newBitstream);
            }
            newBitstream.setFormat(bsFormat);
              newBitstream.update();
View Full Code Here

            String bsUfmt = bitstream.getUserFormatDescription();
            if (bsUfmt != null)
            {
                dc.add(makeDC("format", null, bsUfmt));
            }
            BitstreamFormat bsf = bitstream.getFormat();
            dc.add(makeDC("format", "medium", bsf.getShortDescription()));
            dc.add(makeDC("format", "mimetype", bsf.getMIMEType()));
            dc.add(makeDC("format", "supportlevel", bsf.getSupportLevelText()));
            dc.add(makeDC("format", "internal", Boolean.toString(bsf.isInternal())));
        }
        else if (dso.getType() == Constants.COLLECTION)
        {
            Collection collection = (Collection)dso;
            dc.add(makeDC("identifier", "uri", "hdl:" + dso.getHandle()));
View Full Code Here

        // final step: find or create bitstream format since it
        // takes the accumulation of a few values:
        if (type == Constants.BITSTREAM && bsfShortName != null)
        {
            BitstreamFormat bsf = BitstreamFormat.findByShortDescription(context, bsfShortName);
            if (bsf == null && bsfMIMEType != null)
            {
                bsf = PackageUtils.findOrCreateBitstreamFormat(context,
                        bsfShortName,
                        bsfMIMEType,
View Full Code Here

            logoBS.setName(noPath);
            logoBS.setSource(wrapper.getFilesystemName("file"));

            // Identify the format
            BitstreamFormat bf = FormatIdentifier.guessFormat(context, logoBS);
            logoBS.setFormat(bf);
            AuthorizeManager.addPolicy(context, logoBS, Constants.WRITE, context.getCurrentUser());
            logoBS.update();

            String jsp;
View Full Code Here

            b.setName(noPath);
            b.setSource(wrapper.getFilesystemName("file"));

            // Identify the format
            BitstreamFormat bf = FormatIdentifier.guessFormat(context, b);
            b.setFormat(bf);
            b.update();

            item.update();
View Full Code Here

TOP

Related Classes of org.dspace.content.BitstreamFormat

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.