org.dspace.content.Bitstream.setFormat()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(7.4k)|赞(0)|评价(0)|浏览(154)

本文整理了Java中org.dspace.content.Bitstream.setFormat()方法的一些代码示例,展示了Bitstream.setFormat()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Bitstream.setFormat()方法的具体详情如下:
包路径:org.dspace.content.Bitstream
类名称:Bitstream
方法名:setFormat

Bitstream.setFormat介绍

[英]Set the format of the bitstream. If the user has supplied a type description, it is cleared. Passing in null sets the type of this bitstream to "unknown".
[中]设置位流的格式。如果用户提供了类型说明,则该类型说明将被清除。传入null会将此位流的类型设置为“未知”。

代码示例

代码示例来源:origin: DSpace/DSpace

protected void setFormatToMIMEType(Context context, Bitstream bs, String mimeType)
  throws SQLException {
  List<BitstreamFormat> bf = bitstreamFormatService.findNonInternal(context);
  for (BitstreamFormat aBf : bf) {
    if (aBf.getMIMEType().equalsIgnoreCase(mimeType)) {
      bs.setFormat(context, aBf);
      break;
    }
  }
}

代码示例来源:origin: DSpace/DSpace

@Override
public void setFormat(Context context, Bitstream bitstream, BitstreamFormat bitstreamFormat) throws SQLException {
  // FIXME: Would be better if this didn't throw an SQLException,
  // but we need to find the unknown format!
  if (bitstreamFormat == null) {
    // Use "Unknown" format
    bitstreamFormat = bitstreamFormatService.findUnknown(context);
  }
  // Remove user type description
  clearMetadata(context, bitstream, MetadataSchema.DC_SCHEMA, "format", null, Item.ANY);
  // Update the ID in the table row
  bitstream.setFormat(bitstreamFormat);
}

代码示例来源:origin: DSpace/DSpace

private List<Bitstream> unzipToBundle(Context context, File depositFile,
                   Bundle target)
  throws DSpaceSwordException, SwordError, SwordAuthException {
  try {
    // get the zip file into a usable form
    ZipFile zip = new ZipFile(depositFile);
    List<Bitstream> derivedResources = new ArrayList<Bitstream>();
    Enumeration zenum = zip.entries();
    while (zenum.hasMoreElements()) {
      ZipEntry entry = (ZipEntry) zenum.nextElement();
      InputStream stream = zip.getInputStream(entry);
      Bitstream bs = bitstreamService.create(context, target, stream);
      BitstreamFormat format = this
        .getFormat(context, entry.getName());
      bs.setFormat(context, format);
      bs.setName(context, entry.getName());
      bitstreamService.update(context, bs);
      derivedResources.add(bs);
    }
    return derivedResources;
  } catch (ZipException e) {
    throw new SwordError(UriRegistry.ERROR_BAD_REQUEST,
               "unable to unzip provided package", e);
  } catch (IOException | SQLException e) {
    throw new DSpaceSwordException(e);
  } catch (AuthorizeException e) {
    throw new SwordAuthException(e);
  }
}

代码示例来源:origin: DSpace/DSpace

newBitstream.setFormat(context, bitstream.getFormat(context));
newBitstream.setSource(context, bitstream.getSource());
newBitstream.setUserFormatDescription(context, bitstream

代码示例来源:origin: DSpace/DSpace

@Override
public void setLicense(Context context, Item item,
            InputStream licenseStm, String mimeType)
  throws SQLException, IOException, AuthorizeException {
  Bundle bundle = getCcBundle(context, item);
  // set the format
  BitstreamFormat bs_format;
  if (mimeType.equalsIgnoreCase("text/xml")) {
    bs_format = bitstreamFormatService.findByShortDescription(context, "CC License");
  } else if (mimeType.equalsIgnoreCase("text/rdf")) {
    bs_format = bitstreamFormatService.findByShortDescription(context, "RDF XML");
  } else {
    bs_format = bitstreamFormatService.findByShortDescription(context, "License");
  }
  Bitstream bs = bitstreamService.create(context, bundle, licenseStm);
  bs.setSource(context, CC_BS_SOURCE);
  bs.setName(context, (mimeType != null &&
    (mimeType.equalsIgnoreCase("text/xml") ||
      mimeType.equalsIgnoreCase("text/rdf"))) ?
    BSN_LICENSE_RDF : BSN_LICENSE_TEXT);
  bs.setFormat(context, bs_format);
  bitstreamService.update(context, bs);
}

代码示例来源:origin: DSpace/DSpace

/**
 * This helper method takes some bytes and stores them as a bitstream for an
 * item, under the CC bundle, with the given bitstream name
 *
 * Note: This helper method assumes that the CC
 * bitstreams are short and easily expressed as byte arrays in RAM
 *
 * @param context        The relevant DSpace Context.
 * @param item           parent item
 * @param bundle         parent bundle
 * @param bitstream_name bitstream name to set
 * @param format         bitstream format
 * @param bytes          bitstream data
 * @throws IOException        A general class of exceptions produced by failed or interrupted I/O operations.
 * @throws SQLException       An exception that provides information on a database access error or other errors.
 * @throws AuthorizeException Exception indicating the current user of the context does not have permission
 *                            to perform a particular action.
 */
protected void setBitstreamFromBytes(Context context, Item item, Bundle bundle,
                   String bitstream_name, BitstreamFormat format, byte[] bytes)
  throws SQLException, IOException, AuthorizeException {
  ByteArrayInputStream bais = new ByteArrayInputStream(bytes);
  Bitstream bs = bitstreamService.create(context, bundle, bais);
  bs.setName(context, bitstream_name);
  bs.setSource(context, CC_BS_SOURCE);
  bs.setFormat(context, format);
  // commit everything
  bitstreamService.update(context, bs);
}

代码示例来源:origin: DSpace/DSpace

bf = bitstreamFormatService.guessFormat(context, lbs);
lbs.setFormat(context, bf);
lbs.setName(context, Constants.LICENSE_BITSTREAM_NAME);
lbs.setSource(context, Constants.LICENSE_BITSTREAM_NAME);

代码示例来源:origin: DSpace/DSpace

bitstream.setFormat(context, bf);

代码示例来源:origin: DSpace/DSpace

b.setFormat(bf);

代码示例来源:origin: DSpace/DSpace

bsFormat = bitstreamFormatService.guessFormat(context, newBitstream);
newBitstream.setFormat(context, bsFormat);
bitstreamService.update(context, newBitstream);

代码示例来源:origin: org.dspace/dspace-jspui-api

b.setFormat(bf);
b.update();

代码示例来源:origin: org.dspace/dspace-jspui-api

logoBS.setFormat(bf);
AuthorizeManager.addPolicy(context, logoBS, Constants.WRITE, context.getCurrentUser());
logoBS.update();

代码示例来源:origin: DSpace/DSpace

.findByMIMEType(context, "application/xml");
if (bf != null) {
  entryBitstream.setFormat(context, bf);
  .findByMIMEType(context, deposit.getMimeType());
if (bf != null) {
  bitstream.setFormat(context, bf);

代码示例来源:origin: DSpace/DSpace

@Override
public Bitstream clone(Context context, Bitstream bitstream)
    throws SQLException {
  // Create a new bitstream with a new ID.
  Bitstream clonedBitstream = bitstreamDAO.create(context, new Bitstream());
  // Set the internal identifier, file size, checksum, and
  // checksum algorithm as same as the given bitstream.
  clonedBitstream.setInternalId(bitstream.getInternalId());
  clonedBitstream.setSizeBytes(bitstream.getSizeBytes());
  clonedBitstream.setChecksum(bitstream.getChecksum());
  clonedBitstream.setChecksumAlgorithm(bitstream.getChecksumAlgorithm());
  clonedBitstream.setFormat(bitstream.getBitstreamFormat());
  try {
    //Update our bitstream but turn off the authorization system since permissions
    //haven't been set at this point in time.
    context.turnOffAuthorisationSystem();
    update(context, clonedBitstream);
  } catch (AuthorizeException e) {
    log.error(e);
    //Can never happen since we turn off authorization before we update
  } finally {
    context.restoreAuthSystemState();
  }
  return clonedBitstream;
}

代码示例来源:origin: org.dspace/dspace-xmlui-api

bitstream.setFormat(format);

代码示例来源:origin: DSpace/DSpace

.findOrCreateBitstreamFormat(context, fmtName,
                 "application/xml", fmtName + " package manifest");
manifestBitstream.setFormat(context, manifestFormat);
bitstreamService.update(context, manifestBitstream);

代码示例来源:origin: org.dspace/dspace-xmlui-api

if (newFormat != null)
  bitstream.setFormat(newFormat);

代码示例来源:origin: DSpace/DSpace

context, deposit.getContentType());
if (bf != null) {
  bs.setFormat(context, bf);

代码示例来源:origin: DSpace/DSpace

BitstreamFormat format = this
  .getFormat(context, deposit.getFilename());
bs.setFormat(context, format);
bs.setName(context, deposit.getFilename());
bitstreamService.update(context, bs);

代码示例来源:origin: DSpace/DSpace

context, deposit.getFilename());
bs.setName(context, deposit.getFilename());
bs.setFormat(context, format);
bitstreamService.update(context, bs);

相关文章