Package org.dspace.content

Examples of org.dspace.content.Bundle


      // 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");
      }

      InputStream is = deposit.getFile();
      Bitstream bs = original.createBitstream(is);

      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


                // Bundle ID and bitstream ID next
                int bundleID = Integer.parseInt(st.nextToken());
                int bitstreamID = Integer.parseInt(st.nextToken());

                Bundle bundle = Bundle.find(context, bundleID);
                Bitstream bitstream = Bitstream.find(context, bitstreamID);

                // Get the string "(bundleID)_(bitstreamID)" for finding other
                // parameters related to this bitstream
                String key = String.valueOf(bundleID) + "_" + bitstreamID;

                // Update bitstream metadata, or delete?
                if (button.equals("submit_delete_bitstream_" + key))
                {
                    // "delete" button pressed
                    bundle.removeBitstream(bitstream);

                    // Delete bundle too, if empty
                    if (bundle.getBitstreams().length == 0)
                    {
                        item.removeBundle(bundle);
                    }
                }
                else
                {
                    // Update the bitstream metadata
                    String name = request.getParameter(p);
                    String source = request.getParameter("bitstream_source_"
                            + key);
                    String desc = request.getParameter("bitstream_description_"
                            + key);
                    int formatID = UIUtil.getIntParameter(request,
                            "bitstream_format_id_" + key);
                    String userFormatDesc = request
                            .getParameter("bitstream_user_format_description_"
                                    + key);
                    int primaryBitstreamID = UIUtil.getIntParameter(request,
                            bundleID + "_primary_bitstream_id");

                    // Empty strings become non-null
                    if (source.equals(""))
                    {
                        source = null;
                    }

                    if (desc.equals(""))
                    {
                        desc = null;
                    }

                    if (userFormatDesc.equals(""))
                    {
                        userFormatDesc = null;
                    }

                    bitstream.setName(name);
                    bitstream.setSource(source);
                    bitstream.setDescription(desc);
                    bitstream
                            .setFormat(BitstreamFormat.find(context, formatID));

                    if (primaryBitstreamID > 0)
                    {
                        bundle.setPrimaryBitstreamID(primaryBitstreamID);
                    }

                    if (userFormatDesc != null)
                    {
                        bitstream.setUserFormatDescription(userFormatDesc);
                    }

                    bitstream.update();
                    bundle.update();
                }
            }
        }

        /*
 
View Full Code Here

           
            // set the permission as defined in the owning collection
            Collection owningCollection = item.getOwningCollection();
            if (owningCollection != null)
            {
                Bundle bnd = b.getBundles()[0];
                bnd.inheritCollectionDefaultPolicies(owningCollection);
            }
        }
        else
        {
            // we have a bundle already, just add bitstream
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

      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

        else if (button.equals("submit_bundle_add_policy"))
        {
            // want to add a policy, create an empty one and invoke editor
            Item item = Item
                    .find(c, UIUtil.getIntParameter(request, "item_id"));
            Bundle bundle = Bundle.find(c, UIUtil.getIntParameter(request,
                    "bundle_id"));

            AuthorizeUtil.authorizeManageBundlePolicy(c, bundle);
            ResourcePolicy policy = ResourcePolicy.create(c);
            policy.setResource(bundle);
            policy.update();

            Group[] groups = Group.findAll(c, Group.NAME);
            EPerson[] epeople = EPerson.findAll(c, EPerson.EMAIL);

            // return to item permission page
            request.setAttribute("edit_title", "(Item, Bundle) = ("
                    + item.getID() + "," + bundle.getID() + ")");
            request.setAttribute("policy", policy);
            request.setAttribute("groups", groups);
            request.setAttribute("epeople", epeople);
            request.setAttribute("id_name", "item_id");
            request.setAttribute("id", "" + item.getID());
View Full Code Here

        Bundle[] bundles = item.getBundles();

        for (int i = 0; i < bundles.length; i++)
        {
            Bundle myBundle = bundles[i];
            List myPolicies = AuthorizeManager.getPolicies(c, myBundle);

            // add bundle's policies to bundle_policies map
            bundle_policies.put(new Integer(myBundle.getID()), myPolicies);

            // go through all bundle's bitstreams, add to bitstream map
            Bitstream[] bitstreams = myBundle.getBitstreams();

            for (int j = 0; j < bitstreams.length; j++)
            {
                Bitstream myBitstream = bitstreams[j];
                myPolicies = AuthorizeManager.getPolicies(c, myBitstream);
View Full Code Here

       
        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();
        }
          }
         
          if (alterProvenance && !targetBundle.getName().equals("THUMBMNAIL")
              && !targetBundle.getName().equals("TEXT"))
          {
            DtoMetadata dtom = DtoMetadata.create("dc.description.provenance", "en", "");
           
            String append = "Bitstream added on " + DCDate.getCurrent() + " : "
                            + InstallItem.getBitstreamProvenanceMessage(item);
View Full Code Here

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

       
        // set the permission as defined in the owning collection
        Collection owningCollection = item.getOwningCollection();
        if (owningCollection != null)
        {
            Bundle bnd = bitstream.getBundles()[0];
            bnd.inheritCollectionDefaultPolicies(owningCollection);
        }
      }
      else
      {
        // we have a bundle already, just add bitstream
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.