Package org.dspace.content

Examples of org.dspace.content.BitstreamFormat


  {
    AttributeMap attributes;
   
    // //////////////////////////////
      // Determine the file attributes
        BitstreamFormat format = bitstream.getFormat();
        String mimeType = null;
        if (format != null)
        {
            mimeType = format.getMIMEType();
        }
        String checksumType = bitstream.getChecksumAlgorithm();
        String checksum = bitstream.getChecksum();
        long size = bitstream.getSize();
     
View Full Code Here


                Element bs = prop.getChild("bitstream", DAV.NS_DSPACE);
                if (bs != null)
                {
                    InputStream bis = DAVBitstream.getXmlBitstreamContent(
                            this.context, bs);
                    BitstreamFormat bsf = DAVBitstream.getXmlBitstreamFormat(
                            this.context, bs);
                    if (bis == null || bsf == null)
                    {
                        throw new DAVStatusException(DAV.SC_CONFLICT,
                                "Unacceptable value for logo property.");
View Full Code Here

        boolean internal = Boolean.valueOf(internalString).booleanValue();

        String[] extensions = getRepeatedElementData(node, "extension");

        // Check if this format already exists in our registry (by mime type)
        BitstreamFormat exists = BitstreamFormat.findByMIMEType(context, mimeType);
       
        // If not found by mimeType, check by short description (since this must also be unique)
        if(exists==null)
        {   
            exists = BitstreamFormat.findByShortDescription(context, shortDesc);
        }
           
        // If it doesn't exist, create it..otherwise skip it.
        if(exists==null)
        {
            // Create the format object
            BitstreamFormat format = BitstreamFormat.create(context);

            // Fill it out with the values
            format.setMIMEType(mimeType);
            format.setShortDescription(shortDesc);
            format.setDescription(desc);
            format.setSupportLevel(supportLevel);
            format.setInternal(internal);
            format.setExtensions(extensions);

            // Write to database
            format.update();
        }
    }
View Full Code Here

  {
    AttributeMap attributes;
   
    // //////////////////////////////
      // Determine the file attributes
        BitstreamFormat format = bitstream.getFormat();
        String mimeType = null;
        if (format != null)
        {
            mimeType = format.getMIMEType();
        }
        String checksumType = bitstream.getChecksumAlgorithm();
        String checksum = bitstream.getChecksum();
        long size = bitstream.getSize();
     
View Full Code Here

        {
            Context c = new Context();
            StringBuilder sb = new StringBuilder();
            for (String fmt : fmtTable.keySet())
            {
                BitstreamFormat bsf = BitstreamFormat.findByShortDescription(c, fmt);
                sb.append(String.format("%6d", fmtTable.get(fmt))).append(" (").
                append(bsf.getSupportLevelText().charAt(0)).append(") ").
                append(bsf.getDescription()).append("\n");
            }
            report(sb.toString());
            setResult(sb.toString());
            c.complete();
        }
View Full Code Here

            throws ServletException, IOException, SQLException,
            AuthorizeException
    {
        boolean formatKnown = true;
        boolean fileOK = false;
        BitstreamFormat bf = null;
        Bitstream b = null;
        //NOTE: File should already be uploaded.
        //Manakin does this automatically via Cocoon.
        //For JSP-UI, the SubmissionController.uploadFiles() does the actual upload

        Enumeration attNames = request.getAttributeNames();
       
        //loop through our request attributes
        while(attNames.hasMoreElements())
        {
            String attr = (String) attNames.nextElement();
           
            //if this ends with "-path", this attribute
            //represents a newly uploaded file
            if(attr.endsWith("-path"))
            {
                //strip off the -path to get the actual parameter
                //that the file was uploaded as
                String param = attr.replace("-path", "");
               
                // Load the file's path and input stream and description
                String filePath = (String) request.getAttribute(param + "-path");
                InputStream fileInputStream = (InputStream) request.getAttribute(param + "-inputstream");
               
                //attempt to get description from attribute first, then direct from a parameter
                String fileDescription =  (String) request.getAttribute(param + "-description");
                if(fileDescription==null ||fileDescription.length()==0)
                {
                    fileDescription = request.getParameter("description");
                }
               
                // if information wasn't passed by User Interface, we had a problem
                // with the upload
                if (filePath == null || fileInputStream == null)
                {
                    return STATUS_UPLOAD_ERROR;
                }

                if (subInfo == null)
                {
                    // In any event, if we don't have the submission info, the request
                    // was malformed
                    return STATUS_INTEGRITY_ERROR;
                }


                // Create the bitstream
                Item item = subInfo.getSubmissionItem().getItem();

                // do we already have a bundle?
                Bundle[] bundles = item.getBundles("ORIGINAL");

                if (bundles.length < 1)
                {
                    // set bundle's name to ORIGINAL
                    b = item.createSingleBitstream(fileInputStream, "ORIGINAL");
                }
                else
                {
                    // we have a bundle already, just add bitstream
                    b = bundles[0].createBitstream(fileInputStream);
                }

                // Strip all but the last filename. It would be nice
                // to know which OS the file came from.
                String noPath = filePath;

                while (noPath.indexOf('/') > -1)
                {
                    noPath = noPath.substring(noPath.indexOf('/') + 1);
                }

                while (noPath.indexOf('\\') > -1)
                {
                    noPath = noPath.substring(noPath.indexOf('\\') + 1);
                }

                b.setName(noPath);
                b.setSource(filePath);
                b.setDescription(fileDescription);

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

                // Update to DB
                b.update();
                item.update();

                if ((bf != null) && (bf.isInternal()))
                {
                    log.warn("Attempt to upload file format marked as internal system use only");
                    backoutBitstream(subInfo, b, item);
                    return STATUS_UPLOAD_ERROR;
                }
View Full Code Here

    // utility to grovel bitstream formats..
    private static void setFormatToMIMEType(Context context, Bitstream bs, String mimeType)
        throws SQLException
    {
        BitstreamFormat bf[] = BitstreamFormat.findNonInternal(context);
        for (int i = 0; i < bf.length; ++i)
        {
            if (bf[i].getMIMEType().equalsIgnoreCase(mimeType))
            {
                bs.setFormat(bf[i]);
View Full Code Here

        {
            throw new PackageValidationException("This disseminator can only handle objects of type ITEM.");
        }

        Item item = (Item)dso;
        BitstreamFormat pdff = BitstreamFormat.findByShortDescription(context,
                                BITSTREAM_FORMAT_NAME);
        if (pdff == null)
        {
            throw new PackageValidationException("Cannot find BitstreamFormat \"" + BITSTREAM_FORMAT_NAME + "\"");
        }
View Full Code Here

        if (subInfo.getBitstream() != null)
        {
            // Did the user select a format?
            int typeID = Util.getIntParameter(request, "format");

            BitstreamFormat format = BitstreamFormat.find(context, typeID);

            if (format != null)
            {
                subInfo.getBitstream().setFormat(format);
            }
View Full Code Here

                }

                // reconcile bitstream format; if there's a MIMEtype,
                // get it from that, otherwise try to divine from file extension
                // (guessFormat() looks at bitstream Name, which we just set)
                BitstreamFormat bf = (MIMEType == null) ? null :
                        BitstreamFormat.findByMIMEType(context, MIMEType);
                if (bf == null)
                {
                    bf = FormatIdentifier.guessFormat(context, bitstream);
                }
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.