Package org.dspace.content

Examples of org.dspace.content.Bundle


            // get deposited file as file object
      File depositFile = deposit.getFile();

            // get the original bundle
            Bundle[] originals = item.getBundles("ORIGINAL");
            Bundle original = null;
            if (originals.length > 0)
            {
                original = originals[0];
            }
            else
View Full Code Here


                {
                    bundleName = "SWORD";
                }
                Item item = result.getItem();
                Bundle[] bundles = item.getBundles(bundleName);
                Bundle swordBundle = null;
                if (bundles.length > 0)
                {
                    swordBundle = bundles[0];
                }
                if (swordBundle == null)
                {
                    swordBundle = item.createBundle(bundleName);
                }

                if (deposit.isMultipart() || deposit.isEntryOnly())
                {
                    String entry = deposit.getSwordEntry().toString();
                    ByteArrayInputStream bais = new ByteArrayInputStream(entry.getBytes());
                    Bitstream entryBitstream = swordBundle.createBitstream(bais);

                    String fn = this.createEntryFilename(context, deposit, true);
                    entryBitstream.setName(fn);
                    entryBitstream.setDescription("Original SWORD entry document");

                    BitstreamFormat bf = BitstreamFormat.findByMIMEType(context, "application/xml");
                    if (bf != null)
                    {
                        entryBitstream.setFormat(bf);
                    }

                    entryBitstream.update();

                    verboseDescription.append("Original entry stored as " + fn + ", in item bundle " + swordBundle);
                }

                if (deposit.isMultipart() || deposit.isBinaryOnly())
                {
                    String fn = this.createFilename(context, deposit, true);

                    Bitstream bitstream;
                    InputStream fis = null;
                    try
                    {
                        fis = deposit.getInputStream();
                        bitstream = swordBundle.createBitstream(fis);
                    }
                    finally
                    {
                        if (fis != null)
                        {
                            try
                            {
                                fis.close();
                            }
                            catch (IOException e)
                            {
                                // problem closing input stream; leave it to the garbage collector
                            }
                        }
                    }

                    bitstream.setName(fn);
                    bitstream.setDescription("Orignal SWORD deposit file");

                    BitstreamFormat bf = BitstreamFormat.findByMIMEType(context, deposit.getMimeType());
                    if (bf != null)
                    {
                        bitstream.setFormat(bf);
                    }

                    bitstream.update();
                    if (result.getOriginalDeposit() == null)
                    {
                        // it may be that the original deposit is already set, in which case we
                        // shouldn't mess with it
                        result.setOriginalDeposit(bitstream);
                    }
                    verboseDescription.append("Original deposit stored as " + fn + ", in item bundle " + swordBundle);
                }

                swordBundle.update();
                item.update();

                // now reset the context ignore authorisation
                context.setIgnoreAuthorization(ignoreAuth);
            }
View Full Code Here

     *             if a db error occur
     */
    public static void authorizeManageBitstreamPolicy(Context context,
            Bitstream bitstream) throws AuthorizeException, SQLException
    {
        Bundle bundle = bitstream.getBundles()[0];
        authorizeManageBundlePolicy(context, bundle);
    }
View Full Code Here

       
        // get bitstream filename, calculate destination filename
        String newName = formatFilter.getFilteredName(source.getName());

        Bitstream existingBitstream = null; // is there an existing rendition?
        Bundle targetBundle = null; // bundle we're modifying

        Bundle[] bundles = item.getBundles(formatFilter.getBundleName());

        // check if destination bitstream exists
        if (bundles.length > 0)
        {
            // only finds the last match (FIXME?)
            for (int i = 0; i < bundles.length; i++)
            {
                Bitstream[] bitstreams = bundles[i].getBitstreams();

                for (int j = 0; j < bitstreams.length; j++)
                {
                    if (bitstreams[j].getName().equals(newName))
                    {
                        targetBundle = bundles[i];
                        existingBitstream = bitstreams[j];
                    }
                }
            }
        }

        // if exists and overwrite = false, exit
        if (!overWrite && (existingBitstream != null))
        {
            if (!isQuiet)
            {
                System.out.println("SKIPPED: bitstream " + source.getID()
                        + " (item: " + item.getHandle() + ") because '" + newName + "' already exists");
            }

            return false;
        }
       
        if(isVerbose) {
            System.out.println("PROCESSING: bitstream " + source.getID()
                + " (item: " + item.getHandle() + ")");
        }

        InputStream destStream = formatFilter.getDestinationStream(source.retrieve());
        if (destStream == null)
        {
            if (!isQuiet)
            {
                System.out.println("SKIPPED: bitstream " + source.getID()
                        + " (item: " + item.getHandle() + ") because filtering was unsuccessful");
            }

            return false;
        }

        // create new bundle if needed
        if (bundles.length < 1)
        {
            targetBundle = item.createBundle(formatFilter.getBundleName());
        }
        else
        {
            // take the first match
            targetBundle = bundles[0];
        }

        Bitstream b = targetBundle.createBitstream(destStream);

        // Now set the format and name of the bitstream
        b.setName(newName);
        b.setSource("Written by FormatFilter " + formatFilter.getClass().getName() +
              " on " + DCDate.getCurrent() + " (GMT).");
        b.setDescription(formatFilter.getDescription());

        // Find the proper format
        BitstreamFormat bf = BitstreamFormat.findByShortDescription(c,
                formatFilter.getFormatString());
        b.setFormat(bf);
        b.update();
       
        //Set permissions on the derivative bitstream
        //- First remove any existing policies
        AuthorizeManager.removeAllPolicies(c, b);

        //- Determine if this is a public-derivative format
        if(publicFiltersClasses.contains(formatFilter.getClass().getSimpleName())) {
            //- Set derivative bitstream to be publicly accessible
            Group anonymous = Group.find(c, 0);
            AuthorizeManager.addPolicy(c, b, Constants.READ, anonymous);
        } else {
            //- Inherit policies from the source bitstream
            AuthorizeManager.inheritPolicies(c, source, b);
        }

        // fixme - set date?
        // we are overwriting, so remove old bitstream
        if (existingBitstream != null)
        {
            targetBundle.removeBitstream(existingBitstream);
        }

        if (!isQuiet)
        {
            System.out.println("FILTERED: bitstream " + source.getID()
View Full Code Here

        {
          bundleName = "SWORD";
        }
        Item item = result.getItem();
        Bundle[] bundles = item.getBundles(bundleName);
        Bundle swordBundle = null;
        if (bundles.length > 0)
        {
          swordBundle = bundles[0];
        }
        if (swordBundle == null)
        {
          swordBundle = item.createBundle(bundleName);
        }

        String fn = swordService.getFilename(context, deposit, true);

                Bitstream bitstream;
        FileInputStream fis = null;
                try
                {
                    fis = new FileInputStream(deposit.getFile());
                    bitstream = swordBundle.createBitstream(fis);
                }
                finally
                {
                    if (fis != null)
                    {
                        fis.close();
                    }
                }

                bitstream.setName(fn);
                bitstream.setDescription("SWORD deposit package");

                BitstreamFormat bf = BitstreamFormat.findByMIMEType(context, deposit.getContentType());
                if (bf != null)
                {
                    bitstream.setFormat(bf);
                }

                bitstream.update();

                swordBundle.update();
                item.update();

        swordService.message("Original package stored as " + fn + ", in item bundle " + swordBundle);

        // now reset the context ignore authorisation
View Full Code Here

                    return false;
                }
            } else
            {
                // At least one bundle exists, does the user have privileges to upload to it?
                Bundle bundle = bundles[0];
                if (!AuthorizeManager.authorizeActionBoolean(context, bundle, Constants.ADD))
                {
                    return false; // you can't upload to this bundle.
                }
View Full Code Here

      markInfo.setImageName(nonAvailableImageName)
     
      return markInfo;
    }
    else {
      Bundle originalBundle = bundles[0];
      if (originalBundle.getBitstreams().length == 0){
        ItemMarkingInfo markInfo = new ItemMarkingInfo();
        markInfo.setImageName(nonAvailableImageName);
       
        return markInfo;
      }
      else {
        Bitstream bitstream = originalBundle.getBitstreams()[0];
       
        ItemMarkingInfo signInfo = new ItemMarkingInfo();
        signInfo.setImageName(availableImageName);
        signInfo.setTooltip(bitstream.getName());
       
View Full Code Here

TOP

Related Classes of org.dspace.content.Bundle

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.