Package org.dspace.content

Examples of org.dspace.content.BitstreamFormat


        String button = UIUtil.getSubmitButton(request, "submit");

        if (button.equals("submit_update"))
        {
            // Update the metadata for a bitstream format
            BitstreamFormat bf = BitstreamFormat.find(context, UIUtil
                    .getIntParameter(request, "format_id"));

            bf.setMIMEType(request.getParameter("mimetype"));
            bf.setShortDescription(request.getParameter("short_description"));
            bf.setDescription(request.getParameter("description"));
            bf
                    .setSupportLevel(UIUtil.getIntParameter(request,
                            "support_level"));
            bf.setInternal((request.getParameter("internal") != null)
                    && request.getParameter("internal").equals("true"));

            // Separate comma-separated extensions
            List<String> extensions = new LinkedList<String>();
            String extParam = request.getParameter("extensions");

            while (extParam.length() > 0)
            {
                int c = extParam.indexOf(',');

                if (c > 0)
                {
                    extensions.add(extParam.substring(0, c).trim());
                    extParam = extParam.substring(c + 1).trim();
                }
                else
                {
                    if (extParam.trim().length() > 0)
                    {
                        extensions.add(extParam.trim());
                        extParam = "";
                    }
                }
            }

            // Set extensions in the format - convert to array
            String[] extArray = (String[]) extensions
                    .toArray(new String[extensions.size()]);
            bf.setExtensions(extArray);

            bf.update();

            showFormats(context, request, response);
            context.complete();
        }
        else if (button.equals("submit_add"))
        {
            // Add a new bitstream - simply add to the list, and let the user
            // edit with the main form
            BitstreamFormat bf = BitstreamFormat.create(context);

            // We set the "internal" flag to true, so that the empty bitstream
            // format doesn't show up in the submission UI yet
            bf.setInternal(true);
            bf.update();

            showFormats(context, request, response);
            context.complete();
        }
        else if (button.equals("submit_delete"))
        {
            // Start delete process - go through verification step
            BitstreamFormat bf = BitstreamFormat.find(context, UIUtil
                    .getIntParameter(request, "format_id"));
            request.setAttribute("format", bf);
            JSPManager.showJSP(request, response,
                    "/dspace-admin/confirm-delete-format.jsp");
        }
        else if (button.equals("submit_confirm_delete"))
        {
            // User confirms deletion of format
            BitstreamFormat bf = BitstreamFormat.find(context, UIUtil
                    .getIntParameter(request, "format_id"));
            bf.delete();

            showFormats(context, request, response);
            context.complete();
        }
        else
View Full Code Here


            if (bundles.length > 0)
            {
              Bitstream[] bss = bundles[0].getBitstreams();
              for (int i = 0; i < bss.length; i++)
              {
                BitstreamFormat bf = bss[i].getFormat();
                String format = "application/octet-stream";
                if (bf != null)
                {
                  format = bf.getMIMEType();
                }
                con.setType(format);

                // calculate the bitstream link.
                String bsLink = urlManager.getBitstreamUrl(bss[i]);
View Full Code Here

          Link link = new Link();
          String url = urlManager.getBitstreamUrl(bss[j]);
          link.setHref(url);
          link.setRel("part");

          BitstreamFormat bsf = bss[j].getFormat();
          if (bsf != null)
          {
            link.setType(bsf.getMIMEType());
          }

          entry.addLink(link);
        }
      }
View Full Code Here

      bitstream.setName(name);
      bitstream.setSource(filePart.getUploadName());
      bitstream.setDescription(request.getParameter("description"));

      // Identify the format
      BitstreamFormat format = FormatIdentifier.guessFormat(context, bitstream);
      bitstream.setFormat(format);

      // Update to DB
      bitstream.update();
      item.update();
View Full Code Here

  {
    FlowResult result = new FlowResult();
    result.setContinue(false);
   
    Bitstream bitstream = Bitstream.find(context, bitstreamID);
    BitstreamFormat currentFormat = bitstream.getFormat();

    //Step 1:
    // Update the bitstream's description and name
    if (description != null)
    {
      bitstream.setDescription(description);
    }

        if (bitstreamName != null)
        {
            bitstream.setName(bitstreamName);
        }
   
    //Step 2:
    // Check if the primary bitstream status has changed
    Bundle[] bundles = bitstream.getBundles();
    if (bundles != null && bundles.length > 0)
    {
      if (bitstreamID == bundles[0].getPrimaryBitstreamID())
      {
        // currently the bitstream is primary
        if ("no".equals(primary))
        {
          // However the user has removed this bitstream as a primary bitstream.
          bundles[0].unsetPrimaryBitstreamID();
          bundles[0].update();
        }
      }
      else
      {
        // currently the bitstream is non-primary
        if ("yes".equals(primary))
        {
          // However the user has set this bitstream as primary.
          bundles[0].setPrimaryBitstreamID(bitstreamID);
          bundles[0].update();
        }
      }
    }
   
   
    //Step 2:
    // Update the bitstream's format
    if (formatID > 0)
    {
      if (currentFormat == null || currentFormat.getID() != formatID)
      {
        BitstreamFormat newFormat = BitstreamFormat.find(context, formatID);
        if (newFormat != null)
        {
          bitstream.setFormat(newFormat);
        }
      }
View Full Code Here

            }
        }
       
       
        // Get or create the format
        BitstreamFormat format;
    if (formatID >= 0)
        {
            format = BitstreamFormat.find(context, formatID);
        }
    else
        {
            format = BitstreamFormat.create(context);
        }
       
    // Update values
    format.setMIMEType(mimeType);
    if (formatID != 1) // don't change the unknow format.
        {
            format.setShortDescription(shortDescription);
        }
    format.setDescription(description);
    format.setSupportLevel(Integer.valueOf(supportLevel));
    if (internal == null)
        {
            format.setInternal(false);
        }
    else
        {
            format.setInternal(true);
        }
    format.setExtensions(extensions);

   
    // Commit the change
        format.update();
        context.commit();
   
    // Return status
        result.setContinue(true);
    result.setOutcome(true);
    result.setMessage(T_edit_bitstream_format_success_notice);
    result.setParameter("formatID",format.getID());
       
    return result;
  }
View Full Code Here

          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);
View Full Code Here

      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);
      }
View Full Code Here

      {
        return;
      }

      String bsurl = urlManager.getBitstreamUrl(this.bitstream);
      BitstreamFormat bf = this.bitstream.getFormat();
      String format = "application/octet-stream";
      if (bf != null)
      {
        format = bf.getMIMEType();
      }

      Content con = new Content();
      con.setType(format);
      con.setSource(bsurl);
View Full Code Here

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

    String bsurl = urlManager.getBitstreamUrl(this.bitstream);
    BitstreamFormat bf = this.bitstream.getFormat();
    String format = "application/octet-stream";
    if (bf != null)
    {
      format = bf.getMIMEType();
    }

    Link link = new Link();
    link.setType(format);
    link.setHref(bsurl);
View Full Code Here

TOP

Related Classes of org.dspace.content.BitstreamFormat

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.