Package org.dspace.content

Examples of org.dspace.content.Bitstream


        Context context = null;
        try {
            context = new Context();
            refreshParams(context);

            Bitstream comm = Bitstream.find(context, Integer.parseInt(id));
            return comm != null ? true : false;
        } catch (SQLException ex) {
            throw new EntityException("Internal server error", "SQL error", 500);
        } catch (NumberFormatException ex) {
            throw new EntityException("Bad request", "Could not parse input", 400);
View Full Code Here


    public String createLogo(EntityReference ref, Object inputVar, Context context) {

        try {
            Collection col = Collection.find(context, Integer.parseInt(ref.getId()));
            if (col != null) {
                Bitstream bitstream = col.setLogo((InputStream) inputVar);
                col.update();
                return String.valueOf(bitstream.getID());
            } else {
                throw new EntityException("Not found", "Entity not found", 404);
            }
        } catch (SQLException ex) {
            throw new EntityException("Internal server error", "SQL error", 500);
View Full Code Here

    public Object getLogo(EntityReference ref, UserRequestParams uparams, Context context) {
        try {
            Collection res = Collection.find(context, Integer.parseInt(ref.getId()));
            AuthorizeManager.authorizeAction(context, res, Constants.READ);
            Bitstream logo = res.getLogo();

            if (logo != null) {
                return new BitstreamEntityId(logo);
            }
        } catch (SQLException ex) {
View Full Code Here

    }

    public void removeBitstream(EntityReference ref, Map<String, Object> inputVar, Context context) {
        try {
            int itemID=0;
            Bitstream bitstream = Bitstream.find(context, Integer.parseInt(ref.getId()));
            if ((bitstream != null)) {
                Bundle[] bundles = bitstream.getBundles();
                for (Bundle bundle : bundles) {
                    bundle.removeBitstream(bitstream);
                    itemID = bundle.getItems()[0].getID();
                }
            }
View Full Code Here

    public String createLogo(EntityReference ref, Object inputVar, Context context) {

        try {
            Community com = Community.find(context, Integer.parseInt(ref.getId()));
            if (com != null) {
                Bitstream bitstream = com.setLogo((InputStream) inputVar);
                com.update();
                return String.valueOf(bitstream.getID());
            } else {
                throw new EntityException("Not found", "Entity not found", 404);
            }
        } catch (SQLException ex) {
            throw new EntityException("Internal server error", "SQL error", 500);
View Full Code Here

    public Object getLogo(EntityReference ref, UserRequestParams uparams, Context context) {
        try {
            Community res = Community.find(context, Integer.parseInt(ref.getId()));
            AuthorizeManager.authorizeAction(context, res, Constants.READ);
            Bitstream logo = res.getLogo();

            if (logo != null) {
                return new BitstreamEntityId(logo);
            }
        } catch (SQLException ex) {
View Full Code Here

          Bitstream[] bitstreams = origBundles[0].getBitstreams();
          // add a URL for each original that has a thumbnail
          for (int j = 0; j < bitstreams.length; j++)
          {
            String tName = bitstreams[j].getName() + ".jpg";
        Bitstream tb = null;

                if (thumbBundles.length > 0)
                {
                    tb = thumbBundles[0].getBitstreamByName(tName);
                }

        if (tb != null)
        {
          String thumbUrl = null;
          try
          {
            thumbUrl = baseUrl + "/retrieve/" + tb.getID() + "/" +
                   Util.encodeBitstreamName(tb.getName(),
                           Constants.DEFAULT_ENCODING);
          }
          catch(Exception e)
          {
          }
View Full Code Here

            showUploadFileList(context, request, response, subInfo, false, true);
        }
        else if (buttonPressed.startsWith("submit_describe_"))
        {
            // Change the description of a bitstream
            Bitstream bitstream;

            // Which bitstream does the user want to describe?
            try
            {
                int id = Integer.parseInt(buttonPressed.substring(16));
                bitstream = Bitstream.find(context, id);
            }
            catch (NumberFormatException nfe)
            {
                bitstream = null;
            }

            if (bitstream == null)
            {
                // Invalid or mangled bitstream ID
                // throw an error and return immediately
                log.warn(LogManager.getHeader(context, "integrity_error",
                        UIUtil.getRequestLogInfo(request)));
                JSPManager.showIntegrityError(request, response);
            }

            // save the bitstream
            subInfo.setBitstream(bitstream);

            // load the change file description page
            showFileDescription(context, request, response, subInfo);
        }
        else if (buttonPressed.startsWith("submit_format_"))
        {
            // A "format is wrong" button must have been pressed
            Bitstream bitstream;

            // Which bitstream does the user want to describe?
            try
            {
                int id = Integer.parseInt(buttonPressed.substring(14));
View Full Code Here

        int sequence = par.getParameterAsInteger("sequence", -1);
        String name = par.getParameter("name", null);


        // Reslove the bitstream
        Bitstream bitstream = null;
        Item item;
        DSpaceObject dso;

        if (bitstreamID > -1)
        {
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

TOP

Related Classes of org.dspace.content.Bitstream

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.