Package org.dspace.content

Examples of org.dspace.content.Bundle


        throw new UIException("Unable to parse id into bundle and bitstream id: "+id);
     
      int bundleID = Integer.valueOf(parts[0]);
      int bitstreamID = Integer.valueOf(parts[1]);
     
      Bundle bundle = Bundle.find(context, bundleID);
      Bitstream bitstream = Bitstream.find(context,bitstreamID);
     
      bundle.removeBitstream(bitstream);
     
      if (bundle.getBitstreams().length == 0)
      {
        item.removeBundle(bundle);
      }
    }
   
View Full Code Here


                value = String.valueOf(sid);
            }
        }
        else if (elementsEqualIsh(property, bundleProperty))
        {
            Bundle bn[] = this.bitstream.getBundles();
            if (bn != null && bn.length > 0)
            {
                value = bn[0].getName();
            }
        }
View Full Code Here

      }

      // Now create the special ORE bundle and drop the ORE document in it
    if (harvestRow.getHarvestType() == 2 || harvestRow.getHarvestType() == 3)
    {
      Bundle OREBundle = item.createBundle("ORE");

      XMLOutputter outputter = new XMLOutputter();
      String OREString = outputter.outputString(oreREM);
      ByteArrayInputStream OREStream = new ByteArrayInputStream(OREString.getBytes());

      Bitstream OREBitstream = OREBundle.createBitstream(OREStream);
      OREBitstream.setName("ORE.xml");

      BitstreamFormat bf = FormatIdentifier.guessFormat(ourContext, OREBitstream);
      OREBitstream.setFormat(bf);
      OREBitstream.update();

      OREBundle.addBitstream(OREBitstream);
      OREBundle.update();
    }

    //item.setHarvestDate(new Date());
    hi.setHarvestDate(new Date());
View Full Code Here

                value = String.valueOf(sid);
            }
        }
        else if (elementsEqualIsh(property, bundleProperty))
        {
            Bundle bn[] = this.bitstream.getBundles();
            if (bn != null && bn.length > 0)
            {
                value = bn[0].getName();
            }
        }
View Full Code Here

                || event.getEventType() == Event.MODIFY
                || event.getEventType() == Event.MODIFY_METADATA)
        {
            // either a Bitstream was added or removed or the Bundle was changed
            // update its item.
            Bundle bundle = Bundle.find(ctx, event.getSubjectID());
            if (bundle == null)
            {
                log.warn("Cannot find bundle " + event.getSubjectID() + "! "
                        + "Ignoring, as it is likely it was deleted "
                        + "and we'll cover it by a REMOVE event on its item.");
                return;
            }
            Item[] items = bundle.getItems();
            for (Item i : items)
            {
                DSOIdentifier id = new DSOIdentifier(i, ctx);
                if (!this.toDelete.contains(id) && !this.toConvert.contains(id))
                {
View Full Code Here

                return Curator.CURATE_ERROR;
            }
           
            try
            {
                Bundle bundle = item.getBundles("ORIGINAL")[0];
                results = new ArrayList<String>();
                for (Bitstream bitstream : bundle.getBitstreams())
                {
                    InputStream inputstream = bitstream.retrieve();
                    logDebugMessage("Scanning " + bitstream.getName() + " . . . ");
                    int bstatus = scan(bitstream, inputstream, getItemHandle(item));
                    inputstream.close();
View Full Code Here

        if (bundles == null || bundles.length == 0)
        {
            return;
        }

        Bundle bundle = bundles[0];

        Bitstream bitstream = bundle.getBitstreamByName("license_rdf");

        String license_rdf = new String(copy(bitstream));

        /* quickly fix xml by ripping out offensive parts */
        license_rdf = license_rdf.replaceFirst("<license", "");
        license_rdf = license_rdf.replaceFirst("</license>", "");

        StringWriter result = new StringWriter();

        try
        {
            templates.newTransformer().transform(
                    new StreamSource(new ByteArrayInputStream(license_rdf
                            .getBytes())), new StreamResult(result));
        }
        catch (TransformerException e)
        {
            throw new IllegalStateException(e.getMessage(), e);
        }

        StringBuffer buffer = result.getBuffer();

        Bitstream newBitstream = bundle
                .createBitstream(new ByteArrayInputStream(buffer.toString()
                        .getBytes()));

        newBitstream.setName(bitstream.getName());
        newBitstream.setDescription(bitstream.getDescription());
        newBitstream.setFormat(bitstream.getFormat());
        newBitstream.setSource(bitstream.getSource());
        newBitstream.setUserFormatDescription(bitstream
                .getUserFormatDescription());
        newBitstream.update();

        bundle.removeBitstream(bitstream);

        bundle.update();

    }
View Full Code Here

     */
    public static void setLicenseRDF(Context context, Item item, String licenseRdf)
      throws SQLException, IOException,
            AuthorizeException
    {
        Bundle bundle = getCcBundle(item);
        // set the format
        BitstreamFormat bs_rdf_format = BitstreamFormat.findByShortDescription(context, "RDF XML");
        // set the RDF bitstream
        setBitstreamFromBytes(item, bundle, BSN_LICENSE_RDF, bs_rdf_format, licenseRdf.getBytes());
    }
View Full Code Here

     */
    public static void setLicense(Context context, Item item,
            String cc_license_url) throws SQLException, IOException,
            AuthorizeException
    {
        Bundle bundle = getCcBundle(item);

        // get some more information
        String license_text = fetchLicenseText(cc_license_url);
        String license_rdf = fetchLicenseRDF(cc_license_url);
       
View Full Code Here

    public static void setLicense(Context context, Item item,
                                  InputStream licenseStm, String mimeType)
            throws SQLException, IOException, AuthorizeException
    {
        Bundle bundle = getCcBundle(item);

     // set the format
        BitstreamFormat bs_format;
        if (mimeType.equalsIgnoreCase("text/xml"))
        {
          bs_format = BitstreamFormat.findByShortDescription(context, "CC License");
        } else if (mimeType.equalsIgnoreCase("text/rdf")) {
            bs_format = BitstreamFormat.findByShortDescription(context, "RDF XML");
        } else {
          bs_format = BitstreamFormat.findByShortDescription(context, "License");
        }

        Bitstream bs = bundle.createBitstream(licenseStm);
        bs.setSource(CC_BS_SOURCE);
        bs.setName((mimeType != null &&
                    (mimeType.equalsIgnoreCase("text/xml") ||
                     mimeType.equalsIgnoreCase("text/rdf"))) ?
                   BSN_LICENSE_RDF : BSN_LICENSE_TEXT);
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.