Package org.dspace.content

Examples of org.dspace.content.Bundle


       
        if (!isTest)
        {
          // find the bundle
          Bundle[] bundles = item.getBundles(newBundleName);
          Bundle targetBundle = null;
 
          if (bundles.length < 1)
          {
              // not found, create a new one
              targetBundle = item.createBundle(newBundleName);
          }
          else
          {
          //verify bundle + name are not duplicates
            for (Bundle b : bundles)
            {
              Bitstream[] bitstreams = b.getBitstreams();
              for (Bitstream bsm : bitstreams)
              {
                if (bsm.getName().equals(ce.filename))
                {
                  throw new IllegalArgumentException("Duplicate bundle + filename cannot be added: "
                      + b.getName() + " + " + bsm.getName());
                }
              }
            }

              // select first bundle
              targetBundle = bundles[0];
          }
 
          bs = targetBundle.createBitstream(bis)
          bs.setName(ce.filename);
 
          // Identify the format
          // FIXME - guessing format guesses license.txt incorrectly as a text file format!
          BitstreamFormat fmt = FormatIdentifier.guessFormat(context, bs);
        bs.setFormat(fmt);
       
          if (ce.description != null)
          {
            bs.setDescription(ce.description);
          }
                   
          if ((ce.permissionsActionId != -1) && (ce.permissionsGroupName != null))
          {
        Group group = Group.findByName(context, ce.permissionsGroupName);
       
        if (group != null)
        {
              AuthorizeManager.removeAllPolicies(context, bs)// remove the default policy
              ResourcePolicy rp = ResourcePolicy.create(context);
              rp.setResource(bs);
              rp.setAction(ce.permissionsActionId);
              rp.setGroup(group);   
              rp.update();
        }
          }
         
          //update after all changes are applied
          bs.update();
       
          if (!suppressUndo)
          {
            itarch.addUndoDeleteContents(bs.getID());
          }
    return targetBundle.getName();
        }
  return "";
    }
View Full Code Here


      // get the things out of the service that we need
      Context context = swordService.getContext();
      SWORDUrlManager urlManager = swordService.getUrlManager();

      Bundle[] bundles = item.getBundles("ORIGINAL");
      Bundle original;
      if (bundles.length > 0)
      {
        original = bundles[0];
      }
      else
      {
        original = item.createBundle("ORIGINAL");
      }

            Bitstream bs;
      FileInputStream fis = null;

            try
            {
                fis = new FileInputStream(deposit.getFile());
                bs = original.createBitstream(fis);
            }
            finally
            {
                if (fis != null)
                {
                    fis.close();
                }
            }

      String fn = swordService.getFilename(context, deposit, false);
      bs.setName(fn);

      swordService.message("File created in item with filename " + fn);

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

      // to do the updates, we need to ignore authorisation in the context
      boolean ignoreAuth = context.ignoreAuthorization();
      context.setIgnoreAuthorization(true);

      bs.update();
      original.update();
      item.update();

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

        try
        {
            licBundles = item.getBundles(Constants.LICENSE_BUNDLE_NAME);
            if (licBundles.length > 0)
            {
                Bundle licBundle = licBundles[0];
                Bitstream[] licBits = licBundle.getBitstreams();
                if (licBits.length > 0)
                {
                    Bitstream licBit = licBits[0];
                    InputStream in;
                    try
View Full Code Here

      }
      result.setItem(item);

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

            Bitstream bs = original.createBitstream(deposit.getInputStream());
            BitstreamFormat format = this.getFormat(context, deposit.getFilename());
            bs.setFormat(format);
      bs.setName(deposit.getFilename());
      bs.update();
View Full Code Here

        if (bitstream != null)
        {

            // Check whether we got a License and if it should be displayed
            // (Note: list of bundles may be empty array, if a bitstream is a Community/Collection logo)
            Bundle bundle = bitstream.getBundles().length>0 ? bitstream.getBundles()[0] : null;
           
            if (bundle!=null &&
                bundle.getName().equals(Constants.LICENSE_BUNDLE_NAME) &&
                bitstream.getName().equals(Constants.LICENSE_BITSTREAM_NAME))
            {
                    isLicense = true;
            }
           
View Full Code Here

      throws DSpaceSwordException
  {
    try
    {
      Bundle[] bundles = bitstream.getBundles();
      Bundle parent = null;
      if (bundles.length > 0)
      {
        parent = bundles[0];
      }
      else
      {
        throw new DSpaceSwordException("Encountered orphaned bitstream");
      }

      Item[] items = parent.getItems();
      Item item;
      if (items.length > 0)
      {
        item = items[0];
      }
View Full Code Here

  }

  public void removeBitstream(Item item, Bitstream bitstream, boolean keep)
      throws SQLException, AuthorizeException, IOException
  {
    Bundle exempt = null;
    if (keep)
    {
      exempt = this.archiveBitstream(item, bitstream);
    }

    Bundle[] bundles = bitstream.getBundles();
    for (Bundle bundle : bundles)
    {
      if (exempt != null && bundle.getID() != exempt.getID())
      {
        bundle.removeBitstream(bitstream);
      }
    }
View Full Code Here

    {
      swordBundle = "DELETED";
    }
   
    Bundle[] swords = item.getBundles(swordBundle);
    Bundle archive = null;
    if (swords.length == 0)
    {
      archive = item.createBundle(swordBundle);
    }
    else
View Full Code Here

    // get the datestamped root bundle name
    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
    String oldName = "VER" + sdf.format(new Date());
    oldName = this.getNumberedName(item, oldName, 0);

    Bundle old = item.createBundle(oldName);
    for (Bitstream bitstream : source.getBitstreams())
    {
      old.addBitstream(bitstream);
    }
  }
View Full Code Here

                item = wsi.getItem();
            }

            // get the original bundle
            Bundle[] originals = item.getBundles("ORIGINAL");
            Bundle bundle = null;
            if (originals.length > 0)
            {
                bundle = originals[0];
            }
            else
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.