Package org.dspace.content

Examples of org.dspace.content.BitstreamFormat


                logoBS.setName(noPath);
                logoBS.setSource(wrapper.getFilesystemName("file"));

                // Identify the format
                BitstreamFormat bf = FormatIdentifier.guessFormat(context, logoBS);
                logoBS.setFormat(bf);
                AuthorizeManager.addPolicy(context, logoBS, Constants.WRITE, context.getCurrentUser());
                logoBS.update();

                // Remove temp file
View Full Code Here


    }

    private void populateEntry(Context context, Entry entry, Bitstream bitstream)
            throws DSpaceSwordException
    {
        BitstreamFormat format = bitstream.getFormat();
        String contentType = null;
        if (format != null)
        {
            contentType = format.getMIMEType();
        }

        SwordUrlManager urlManager = new SwordUrlManager(new SwordConfigurationDSpace(), context);
        String bsUrl = urlManager.getBitstreamUrl(bitstream);
View Full Code Here

        wsi = WorkspaceItem.create(context, collection, true);
        item = wsi.getItem();
      }

      Bitstream bs = item.createSingleBitstream(deposit.getInputStream());
      BitstreamFormat format = this.getFormat(context, deposit.getFilename());
      bs.setName(deposit.getFilename());
      bs.setFormat(format);
      bs.update();

      // now we have an item in the workspace, and we need to consider adding some metadata to it,
View Full Code Here

      {
        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();

      // update the item metadata to inclue the current time as
View Full Code Here

        BitstreamFormat[] formats = BitstreamFormat.findNonInternal(context);

        request.setAttribute("bitstream.formats", formats);

        // What does the system think it is?
        BitstreamFormat guess = FormatIdentifier.guessFormat(context, subInfo
                .getBitstream());

        request.setAttribute("guessed.format", guess);

        // display choose file format JSP next
View Full Code Here

      while (zenum.hasMoreElements())
      {
        ZipEntry entry = (ZipEntry) zenum.nextElement();
        InputStream stream = zip.getInputStream(entry);
        Bitstream bs = target.createBitstream(stream);
        BitstreamFormat format = this.getFormat(context, entry.getName());
        bs.setFormat(format);
        bs.setName(entry.getName());
        bs.update();
        derivedResources.add(bs);
      }
View Full Code Here

                    String fn = this.createEntryFilename(context, deposit, true);
                    entryBitstream.setName(fn);
                    entryBitstream.setDescription("Original SWORD entry document");

                    BitstreamFormat bf = BitstreamFormat.findByMIMEType(context, "application/xml");
                    if (bf != null)
                    {
                        entryBitstream.setFormat(bf);
                    }

                    entryBitstream.update();

                    verboseDescription.append("Original entry stored as " + fn + ", in item bundle " + swordBundle);
                }

                if (deposit.isMultipart() || deposit.isBinaryOnly())
                {
                    String fn = this.createFilename(context, deposit, true);

                    Bitstream bitstream;
                    InputStream fis = null;
                    try
                    {
                        fis = deposit.getInputStream();
                        bitstream = swordBundle.createBitstream(fis);
                    }
                    finally
                    {
                        if (fis != null)
                        {
                            try
                            {
                                fis.close();
                            }
                            catch (IOException e)
                            {
                                // problem closing input stream; leave it to the garbage collector
                            }
                        }
                    }

                    bitstream.setName(fn);
                    bitstream.setDescription("Orignal SWORD deposit file");

                    BitstreamFormat bf = BitstreamFormat.findByMIMEType(context, deposit.getMimeType());
                    if (bf != null)
                    {
                        bitstream.setFormat(bf);
                    }
View Full Code Here

    public String createFilename(Context context, Deposit deposit, boolean original)
            throws DSpaceSwordException
    {
        try
        {
            BitstreamFormat bf = BitstreamFormat.findByMIMEType(context, deposit.getMimeType());
            String[] exts = null;
            if (bf != null)
            {
                exts = bf.getExtensions();
            }

            String fn = deposit.getFilename();
            if (fn == null || "".equals(fn))
            {
View Full Code Here

    int bitstreamID = parameters.getParameterAsInteger("bitstreamID",-1);

    // Get the bitstream and all the various formats
                // Administrator is allowed to see internal formats too.
    Bitstream bitstream = Bitstream.find(context, bitstreamID);
    BitstreamFormat currentFormat = bitstream.getFormat();
                BitstreamFormat[] bitstreamFormats = AuthorizeManager.isAdmin(context) ?
                    BitstreamFormat.findAll(context) :
                    BitstreamFormat.findNonInternal(context);
   
    boolean primaryBitstream = false;
    Bundle[] bundles = bitstream.getBundles();
    if (bundles != null && bundles.length > 0)
    {
      if (bitstreamID == bundles[0].getPrimaryBitstreamID())
      {
        primaryBitstream = true;
      }
    }

    // File name & url
    String fileUrl = contextPath + "/bitstream/id/" +bitstream.getID() + "/" + bitstream.getName();
    String fileName = bitstream.getName();




    // DIVISION: main
    Division div = body.addInteractiveDivision("edit-bitstream", contextPath+"/admin/item", Division.METHOD_MULTIPART, "primary administrative item");     
    div.setHead(T_head1);

    // LIST: edit form
    List edit = div.addList("edit-bitstream-list", List.TYPE_FORM);
        edit.addLabel(T_file_label);
        edit.addItem().addXref(fileUrl, fileName);

        Text bitstreamName = edit.addItem().addText("bitstreamName");
        bitstreamName.setLabel(T_filename_label);
        bitstreamName.setHelp(T_filename_help);
        bitstreamName.setValue(fileName);
   
    Select primarySelect = edit.addItem().addSelect("primary");
    primarySelect.setLabel(T_primary_label);
    primarySelect.addOption(primaryBitstream,"yes",T_primary_option_yes);
    primarySelect.addOption(!primaryBitstream,"no",T_primary_option_no);
   
    Text description = edit.addItem().addText("description");
    description.setLabel(T_description_label);
    description.setHelp(T_description_help);
    description.setValue(bitstream.getDescription());

        // EMBARGO FIELD
        // if AdvancedAccessPolicy=false: add Embargo Fields.
        if(!isAdvancedFormEnabled){
            AccessStepUtil asu = new AccessStepUtil(context);
            // if the item is embargoed default value will be displayed.
            asu.addEmbargoDateSimpleForm(bitstream, edit, -1);
            asu.addReason(null, edit, -1);
        }

    edit.addItem(T_para1);

    // System supported formats
    Select format = edit.addItem().addSelect("formatID");
    format.setLabel(T_format_label);

                // load the options menu, skipping the "Unknown" format since "Not on list" takes its place
                int unknownFormatID = BitstreamFormat.findUnknown(context).getID();
    format.addOption(-1,T_format_default);
    for (BitstreamFormat bitstreamFormat : bitstreamFormats)
    {
            if (bitstreamFormat.getID() == unknownFormatID)
            {
                continue;
            }
      String supportLevel = "Unknown";
      if (bitstreamFormat.getSupportLevel() == BitstreamFormat.KNOWN)
            {
                supportLevel = "known";
            }
      else if (bitstreamFormat.getSupportLevel() == BitstreamFormat.SUPPORTED)
            {
                supportLevel = "Supported";
            }
      String name = bitstreamFormat.getShortDescription()+" ("+supportLevel+")";
            if (bitstreamFormat.isInternal())
            {
                name += " (Internal)";
            }
      int id = bitstreamFormat.getID();

      format.addOption(id,name);
    }
    if (currentFormat != null)
    {
      format.setOptionSelected(currentFormat.getID());
    }
    else
    {
      format.setOptionSelected(-1);
    }
View Full Code Here

    String idsString = parameters.getParameter("formatIDs", null);
   
    ArrayList<BitstreamFormat> formats = new ArrayList<BitstreamFormat>();
    for (String id : idsString.split(","))
    {
      BitstreamFormat format = BitstreamFormat.find(context,Integer.valueOf(id));
      formats.add(format);
    }
    // DIVISION: bitstream-format-confirm-delete
      Division deleted = body.addInteractiveDivision("bitstream-format-confirm-delete",contextPath+"/admin/format-registry",Division.METHOD_POST,"primary administrative format-registry");
      deleted.setHead(T_head);
      deleted.addPara(T_para1);
     
      Table table = deleted.addTable("format-confirm-delete",formats.size() + 1, 3);
        Row header = table.addRow(Row.ROLE_HEADER);
        header.addCell().addContent(T_column1);
        header.addCell().addContent(T_column2);
        header.addCell().addContent(T_column3);
     
      for (BitstreamFormat format : formats)
      {
        if (format == null)
            {
                continue;
            }
       
        String formatID = String.valueOf(format.getID());
        String mimetype = format.getMIMEType();
        String name = format.getShortDescription();

       
        Row row = table.addRow();
        row.addCell().addContent(formatID);
          row.addCell().addContent(mimetype);
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.