Examples of Bitstream


Examples of org.dspace.content.Bitstream

    {
        if (license == null)
            license = collection.getLicense();
        InputStream lis = new ByteArrayInputStream(license.getBytes());
        Bundle lb = item.createBundle(Constants.LICENSE_BUNDLE_NAME);
        Bitstream lbs = lb.createBitstream(lis);
        lis.close();
        BitstreamFormat bf = BitstreamFormat.findByShortDescription(context, "License");
        if (bf == null)
            bf = FormatIdentifier.guessFormat(context, lbs);
        lbs.setFormat(bf);
        lbs.setName(Constants.LICENSE_BITSTREAM_NAME);
        lbs.setSource(Constants.LICENSE_BITSTREAM_NAME);
        lbs.update();
    }
View Full Code Here

Examples of org.dspace.content.Bitstream

        // get an input stream
        BufferedInputStream bis = new BufferedInputStream(new FileInputStream(
                fullpath));

        Bitstream bs = null;
        String newBundleName = bundleName;

        if (bundleName == null)
        {
            // is it license.txt?
            if (fileName.equals("license.txt"))
            {
                newBundleName = "LICENSE";
            }
            else
            {
                // call it ORIGINAL
                newBundleName = "ORIGINAL";
            }
        }
       
        if (!isTest)
        {
            // find the bundle
            Bundle[] bundles = i.getBundles(newBundleName);
            Bundle targetBundle = null;

            if (bundles.length < 1)
            {
                // not found, create a new one
                targetBundle = i.createBundle(newBundleName);
            }
            else
            {
                // put bitstreams into first bundle
                targetBundle = bundles[0];
            }

            // now add the bitstream
            bs = targetBundle.createBitstream(bis);

            bs.setName(fileName);

            // Identify the format
            // FIXME - guessing format guesses license.txt incorrectly as a text
            // file format!
            BitstreamFormat bf = FormatIdentifier.guessFormat(c, bs);
            bs.setFormat(bf);

            // Is this a the primary bitstream?
            if (primary)
            {
                targetBundle.setPrimaryBitstreamID(bs.getID());
                targetBundle.update();
            }

            bs.update();
        }
    }
View Full Code Here

Examples of org.dspace.content.Bitstream

          throws SQLException, IOException, AuthorizeException
    {
        // TODO validate assetstore number
        // TODO make sure the bitstream is there

        Bitstream bs = null;
        String newBundleName = bundleName;
       
        if (bundleName == null)
        {
            // is it license.txt?
            if (bitstreamPath.endsWith("license.txt"))
            {
                newBundleName = "LICENSE";
            }
            else
            {
                // call it ORIGINAL
                newBundleName = "ORIGINAL";
            }
        }

        if(!isTest)
        {
          // find the bundle
          Bundle[] bundles = i.getBundles(newBundleName);
          Bundle targetBundle = null;
             
          if( bundles.length < 1 )
          {
              // not found, create a new one
              targetBundle = i.createBundle(newBundleName);
          }
          else
          {
              // put bitstreams into first bundle
              targetBundle = bundles[0];
          }
 
          // now add the bitstream
          bs = targetBundle.registerBitstream(assetstore, bitstreamPath);
 
          // set the name to just the filename
          int iLastSlash = bitstreamPath.lastIndexOf('/');
          bs.setName(bitstreamPath.substring(iLastSlash + 1));
 
          // Identify the format
          // FIXME - guessing format guesses license.txt incorrectly as a text file format!
          BitstreamFormat bf = FormatIdentifier.guessFormat(c, bs);
          bs.setFormat(bf);
 
          bs.update();
        }
    }
View Full Code Here

Examples of org.dspace.rest.common.Bitstream

            throws WebApplicationException
    {

        log.info("Adding bitstream to item(id=" + itemId + ").");
        org.dspace.core.Context context = null;
        Bitstream bitstream = null;

        try
        {
            context = createContext(getUser(headers));
            org.dspace.content.Item dspaceItem = findItem(context, itemId, org.dspace.core.Constants.WRITE);

            writeStats(dspaceItem, UsageEvent.Action.UPDATE, user_ip, user_agent, xforwarderfor, headers, request, context);

            // Is better to add bitstream to ORIGINAL bundle or to item own?
            log.trace("Creating bitstream in item.");
            org.dspace.content.Bundle bundle = null;
            org.dspace.content.Bitstream dspaceBitstream = null;
            if ((dspaceItem.getBundles().length == 0) || (dspaceItem.getBundles() == null))
            {
                log.trace("Creating bundle in item.");
                dspaceBitstream = dspaceItem.createSingleBitstream(inputStream);
            }
            else
            {
                log.trace("Getting bundle from item.");
                bundle = dspaceItem.getBundles()[0];
                dspaceBitstream = bundle.createBitstream(inputStream);
            }

            dspaceBitstream.setSource("DSpace Rest api");

            // Set bitstream name and description
            if (name != null)
            {
                if (BitstreamResource.getMimeType(name) == null)
                {
                    dspaceBitstream.setFormat(BitstreamFormat.findUnknown(context));
                }
                else
                {
                    dspaceBitstream.setFormat(BitstreamFormat.findByMIMEType(context, BitstreamResource.getMimeType(name)));
                }
                dspaceBitstream.setName(name);
            }
            if (description != null)
            {
                dspaceBitstream.setDescription(description);
            }

            dspaceBitstream.update();

            // Create policy for bitstream
            if (groupId != null)
            {
                Bundle[] bundles = dspaceBitstream.getBundles();
                for (Bundle dspaceBundle : bundles)
                {
                    List<org.dspace.authorize.ResourcePolicy> bitstreamsPolicies = dspaceBundle.getBitstreamPolicies();

                    // Remove default bitstream policies
                    List<org.dspace.authorize.ResourcePolicy> policiesToRemove = new ArrayList<org.dspace.authorize.ResourcePolicy>();
                    for (org.dspace.authorize.ResourcePolicy policy : bitstreamsPolicies)
                    {
                        if (policy.getResourceID() == dspaceBitstream.getID())
                        {
                            policiesToRemove.add(policy);
                        }
                    }
                    for (org.dspace.authorize.ResourcePolicy policy : policiesToRemove)
                    {
                        bitstreamsPolicies.remove(policy);
                    }

                    org.dspace.authorize.ResourcePolicy dspacePolicy = org.dspace.authorize.ResourcePolicy.create(context);
                    dspacePolicy.setAction(org.dspace.core.Constants.READ);
                    dspacePolicy.setGroup(Group.find(context, groupId));
                    dspacePolicy.setResourceID(dspaceBitstream.getID());
                    dspacePolicy.setResource(dspaceBitstream);
                    dspacePolicy.setResourceType(org.dspace.core.Constants.BITSTREAM);
                    if ((year != null) || (month != null) || (day != null))
                    {
                        Date date = new Date();
                        if (year != null)
                        {
                            date.setYear(year - 1900);
                        }
                        if (month != null)
                        {
                            date.setMonth(month - 1);
                        }
                        if (day != null)
                        {
                            date.setDate(day);
                        }
                        date.setHours(0);
                        date.setMinutes(0);
                        date.setSeconds(0);
                        dspacePolicy.setStartDate(date);
                    }
                    dspacePolicy.update();
                    bitstreamsPolicies.add(dspacePolicy);

                    dspaceBundle.replaceAllBitstreamPolicies(bitstreamsPolicies);
                    dspaceBundle.update();
                }
            }

            dspaceBitstream = org.dspace.content.Bitstream.find(context, dspaceBitstream.getID());
            bitstream = new Bitstream(dspaceBitstream, "");

            context.complete();

        }
        catch (SQLException e)
        {
            processException("Could not create bitstream in item(id=" + itemId + "), SQLException. Message: " + e, context);
        }
        catch (AuthorizeException e)
        {
            processException("Could not create bitstream in item(id=" + itemId + "), AuthorizeException. Message: " + e, context);
        }
        catch (IOException e)
        {
            processException("Could not create bitstream in item(id=" + itemId + "), IOException Message: " + e, context);
        }
        catch (ContextException e)
        {
            processException(
                    "Could not create bitstream in item(id=" + itemId + "), ContextException Message: " + e.getMessage(), context);
        }
        finally
        {
            processFinally(context);
        }

        log.info("Bitstream(id=" + bitstream.getId() + ") was successfully added into item(id=" + itemId + ").");
        return bitstream;
    }
View Full Code Here

Examples of org.red5.app.sip.codecs.ilbc.bitstream

    public int codecToPcm( byte[] bufferIn, float[] bufferOut ) {

        short[] encodedData = CodecUtils.byteToShortArray(bufferIn, 0, bufferIn.length, false);

        bitstream encodedBitStream = new bitstream( getOutgoingDecodedFrameSize() * 2 );
       
        for (int i = 0; i < encodedData.length; i++) {
            encodedBitStream.buffer[2*i+1] = (char) (encodedData[i] & 0xff);
            encodedBitStream.buffer[2*i] = (char) ((encodedData[i] >> 8) & 0xff);
        }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.