Package org.dspace.content

Examples of org.dspace.content.Bundle


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

        /*
         * Now respond to button presses, other than "Remove" or "Delete" button
         * presses which were dealt with in the above loop.
         */
        if (button.equals("submit_addfield"))
        {
            // Adding a metadata field
            int dcTypeID = UIUtil.getIntParameter(request, "addfield_dctype");
            String value = request.getParameter("addfield_value").trim();
            String lang = request.getParameter("addfield_language");

            // trim language and set empty string language = null
            if (lang != null)
            {
                lang = lang.trim();
                if (lang.equals(""))
                {
                    lang = null;
                }
            }

            MetadataField field = MetadataField.find(context, dcTypeID);
            MetadataSchema schema = MetadataSchema.find(context, field
                    .getSchemaID());
            item.addMetadata(schema.getName(), field.getElement(), field
                    .getQualifier(), lang, value);
        }

        item.update();

        if (button.equals("submit_addcc"))
        {
            // Show cc-edit page
            request.setAttribute("item", item);
            JSPManager
                    .showJSP(request, response, "/tools/creative-commons-edit.jsp");
        }
       
        if (button.equals("submit_addbitstream"))
        {
            // Show upload bitstream page
            request.setAttribute("item", item);
            JSPManager
                    .showJSP(request, response, "/tools/upload-bitstream.jsp");
        }else
        if(button.equals("submit_update_order") || button.startsWith("submit_order_"))
        {
            Bundle[] bundles = item.getBundles("ORIGINAL");
            for (Bundle bundle : bundles) {
                Bitstream[] bitstreams = bundle.getBitstreams();
                int[] newBitstreamOrder = new int[bitstreams.length];
                if (button.equals("submit_update_order")) {
                    for (Bitstream bitstream : bitstreams) {
                        //The order is determined by javascript
                        //For each of our bitstream retrieve the order value
                        int order = Util.getIntParameter(request, "order_" + bitstream.getID());
                        //-1 the order since the order needed to start from one
                        order--;
                        //Place the bitstream identifier in the correct order
                        newBitstreamOrder[order] = bitstream.getID();
                    }
                }else{
                    //Javascript isn't operational retrieve the value from the hidden field
                    //Retrieve the button key
                    String inputKey = button.replace("submit_order_", "") + "_value";
                    if(inputKey.startsWith(bundle.getID() + "_")){
                        String[] vals = request.getParameter(inputKey).split(",");
                        for (int i = 0; i < vals.length; i++) {
                            String val = vals[i];
                            newBitstreamOrder[i] = Integer.parseInt(val);
                        }
                    }else{
                        newBitstreamOrder = null;
                    }

                }

                if(newBitstreamOrder != null){
                    //Set the new order in our bundle !
                    bundle.setOrder(newBitstreamOrder);
                    bundle.update();
                }
            }

            // Show edit page again
            showEditForm(context, request, response, item);
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

        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<ResourcePolicy> myPolicies = AuthorizeManager.getPolicies(c, myBundle);

            // add bundle's policies to bundle_policies map
            bundlePolicies.put(Integer.valueOf(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

                    {
                        bundles[0].addBitstream(result.getOriginalDeposit());
                    }
                    else
                    {
                        Bundle bundle = item.createBundle("ORIGINAL");
                        bundle.addBitstream(result.getOriginalDeposit());
                    }
                }

            }
View Full Code Here

                validityKey.append(dcv.value);
            }
        }
        else if (dso instanceof Bundle)
        {
            Bundle bundle = (Bundle) dso;
           
            validityKey.append("Bundle:");
            validityKey.append(bundle.getID());
            validityKey.append(bundle.getName());
            validityKey.append(bundle.getPrimaryBitstreamID());
           
            for(Bitstream bitstream : bundle.getBitstreams())
            {
                this.add(bitstream);
            }
        }
        else if (dso instanceof Bitstream)
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

                        }
     
      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

      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

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.