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

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

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

Bitstream.getName介绍

[英]Get the name of this bitstream - typically the filename, without any path information
[中]获取此位流的名称-通常为文件名,不包含任何路径信息

代码示例

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

public String getFileName() {
  return StringUtils.trimToEmpty(bitstream.getName());
}

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

@Override
public Bitstream getBitstreamByName(Bundle bundle, String name) {
  Bitstream target = null;
  for (Bitstream bitstream : bundle.getBitstreams()) {
    if (name.equals(bitstream.getName())) {
      target = bitstream;
      break;
    }
  }
  return target;
}

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

/**
 * Tests bitstream by matching the regular expression in the
 * properties against the bitstream name
 *
 * @param bitstream Bitstream
 * @return whether bitstream name matches the regular expression
 * @throws BitstreamFilterException if filter error
 */
@Override
public boolean accept(Bitstream bitstream) throws BitstreamFilterException {
  if (filenameRegex == null) {
    filenameRegex = props.getProperty("filename");
    if (filenameRegex == null) {
      throw new BitstreamFilterException("BitstreamFilter property 'filename' not found.");
    }
    pattern = Pattern.compile(filenameRegex);
  }
  Matcher m = pattern.matcher(bitstream.getName());
  return m.matches();
}

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

@Override
public Bitstream getBitstreamByName(Item item, String bundleName, String bitstreamName) throws SQLException {
  List<Bundle> bundles = itemService.getBundles(item, bundleName);
  for (int i = 0; i < bundles.size(); i++) {
    Bundle bundle = bundles.get(i);
    List<Bitstream> bitstreams = bundle.getBitstreams();
    for (int j = 0; j < bitstreams.size(); j++) {
      Bitstream bitstream = bitstreams.get(j);
      if (StringUtils.equals(bitstream.getName(), bitstreamName)) {
        return bitstream;
      }
    }
  }
  return null;
}

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

protected String urlOfBitstream(HttpServletRequest request, Bitstream logo) {
  String name = logo.getName();
  return resolveURL(request, null) +
    (uiType.equalsIgnoreCase(UITYPE_XMLUI) ? "/bitstream/id/" : "/retrieve/") +
    logo.getID() + "/" + (name == null ? "" : name);
}

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

@Override
public BitstreamFormat guessFormat(Context context, Bitstream bitstream) throws SQLException {
  String filename = bitstream.getName();

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

@Override
  public String getBitstreamProvenanceMessage(Context context, Item myitem)
    throws SQLException {
    // Get non-internal format bitstreams
    List<Bitstream> bitstreams = itemService.getNonInternalBitstreams(context, myitem);

    // Create provenance description
    StringBuilder myMessage = new StringBuilder();
    myMessage.append("No. of bitstreams: ").append(bitstreams.size()).append("\n");

    // Add sizes and checksums of bitstreams
    for (Bitstream bitstream : bitstreams) {
      myMessage.append(bitstream.getName()).append(": ")
           .append(bitstream.getSizeBytes()).append(" bytes, checksum: ")
           .append(bitstream.getChecksum()).append(" (")
           .append(bitstream.getChecksumAlgorithm()).append(")\n");
    }

    return myMessage.toString();
  }
}

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

public String getActionableBitstreamUrl(Bitstream bitstream)
  throws DSpaceSwordException {
  return this.getSwordBaseUrl() + "/edit-media/bitstream/" +
    bitstream.getID() + "/" + bitstream.getName();
}

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

static List<String> getBitstreamNames(BundleName bundleName, Item item) {
  ArrayList<String> names = new ArrayList<String>();
  for (Bundle bundle : item.getBundles()) {
    if (!bundle.getName().equals(bundleName.name())) {
      continue;
    }
    for (Bitstream bit : bundle.getBitstreams()) {
      names.add(bit.getName());
    }
  }
  return names;
}

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

String originalFilename = derived.getName().substring(0,
                           derived.getName().length() - 4);
      if (bitstream.getName().equals(originalFilename)) {
        return bitstream;

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

private static Bitstream getItemBitstreamByName(Item item, String bsName)
            throws SQLException
{
  Bundle[] bundles = item.getBundles();
  for (int i = 0; i < bundles.length; i++)
  {
    Bitstream[] bitstreams = bundles[i].getBitstreams();
    for (int k = 0; k < bitstreams.length; k++)
    {
      if (bsName.equals(bitstreams[k].getName()))
      {
        return bitstreams[k];
      }
    }
  }
  return null;
}

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

/**
 * Add the title from the bibliographic metadata
 */
protected void addTitle() {
  Title title = new Title();
  title.setContent(this.bitstream.getName());
  title.setType(ContentType.TEXT);
  entry.setTitle(title);
  log.debug("Added title to entry");
}

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

/**
 * Add the title from the bibliographic metadata
 *
 */
protected void addTitle()
{
  Title title = new Title();
  title.setContent(this.bitstream.getName());
  title.setType(ContentType.TEXT);
  entry.setTitle(title);
  log.debug("Added title to entry");
}

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

static int countBitstreamMime(Context context, BundleName bundleName, Item item, String[] mimeList) {
  int count = 0;
  for (Bundle bundle : item.getBundles()) {
    if (!bundle.getName().equals(bundleName.name())) {
      continue;
    }
    for (Bitstream bit : bundle.getBitstreams()) {
      for (String mime : mimeList) {
        try {
          if (bit.getFormat(context).getMIMEType().equals(mime.trim())) {
            count++;
          }
        } catch (SQLException e) {
          log.error("Get format error for bitstream " + bit.getName());
        }
      }
    }
  }
  return count;
}

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

/**
 * Find bitstream by its Name, looking in specific named bundle.
 *
 * @param item   - dspace item whose bundles to search.
 * @param bsName - name of bitstream to match.
 * @param bnName - bundle name to match, or null for all.
 * @return the format found or null if none found.
 * @throws SQLException if database error
 */
public static Bitstream getBitstreamByName(Item item, String bsName, String bnName)
  throws SQLException {
  List<Bundle> bundles;
  if (bnName == null) {
    bundles = item.getBundles();
  } else {
    bundles = itemService.getBundles(item, bnName);
  }
  for (Bundle bundle : bundles) {
    List<Bitstream> bitstreams = bundle.getBitstreams();
    for (Bitstream bitstream : bitstreams) {
      if (bsName.equals(bitstream.getName())) {
        return bitstream;
      }
    }
  }
  return null;
}

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

private void buildFullTextList(Item parentItem) {
  // now get full text of any bitstreams in the TEXT bundle
  // trundle through the bundles
  List<Bundle> myBundles = parentItem.getBundles();
  for (Bundle myBundle : emptyIfNull(myBundles)) {
    if (StringUtils.equals(FULLTEXT_BUNDLE, myBundle.getName())) {
      // a-ha! grab the text out of the bitstreams
      List<Bitstream> bitstreams = myBundle.getBitstreams();
      for (Bitstream fulltextBitstream : emptyIfNull(bitstreams)) {
        fullTextStreams.add(new FullTextBitstream(sourceInfo, fulltextBitstream));
        log.debug("Added BitStream: "
               + fulltextBitstream.getStoreNumber() + " "
               + fulltextBitstream.getSequenceID() + " "
               + fulltextBitstream.getName());
      }
    }
  }
}

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

@Override
  public void additionalIndex(Context context, DSpaceObject dso, SolrInputDocument document) {
    if (dso instanceof Item) {
      Item item = (Item) dso;
      List<Bundle> bundles = item.getBundles();
      if (bundles != null) {
        for (Bundle bundle : bundles) {
          String bundleName = bundle.getName();
          if ((bundleName != null) && bundleName.equals(BUNDLE_NAME)) {
            List<Bitstream> bitstreams = bundle.getBitstreams();
            if (bitstreams != null) {
              for (Bitstream bitstream : bitstreams) {
                document.addField(SOLR_FIELD_NAME_FOR_FILENAMES, bitstream.getName());

                String description = bitstream.getDescription();
                if ((description != null) && (!description.isEmpty())) {
                  document.addField(SOLR_FIELD_NAME_FOR_DESCRIPTIONS, description);
                }
              }
            }
          }
        }
      }
    }
  }
}

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

@Override
public Thumbnail getThumbnail(Context context, Item item, boolean requireOriginal) throws SQLException {
  Bitstream thumbBitstream;
  List<Bundle> originalBundles = getBundles(item, "ORIGINAL");
  Bitstream primaryBitstream = null;
  if (CollectionUtils.isNotEmpty(originalBundles)) {
    primaryBitstream = originalBundles.get(0).getPrimaryBitstream();
  }
  if (primaryBitstream != null) {
    if (primaryBitstream.getFormat(context).getMIMEType().equals("text/html")) {
      return null;
    }
    thumbBitstream = bitstreamService
      .getBitstreamByName(item, "THUMBNAIL", primaryBitstream.getName() + ".jpg");
  } else {
    if (requireOriginal) {
      primaryBitstream = bitstreamService.getFirstBitstream(item, "ORIGINAL");
    }
    thumbBitstream = bitstreamService.getFirstBitstream(item, "THUMBNAIL");
  }
  if (thumbBitstream != null) {
    return new Thumbnail(thumbBitstream, primaryBitstream);
  }
  return null;
}

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

entry.setTitle(bitstream.getName());
String desc = bitstream.getDescription();
if ("".equals(desc) || desc == null) {
  desc = bitstream.getName();

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

/**
   * Add the bitstream metadata to the item
   *
   * @param item      The item
   * @param bitstream The bitstream
   * @param type      The type of bitstream
   * @throws SQLException An exception that provides information on a database access error or other errors.
   */
  protected void addMetadata(Item item, Bitstream bitstream, String type) throws SQLException {
    String value = bitstream.getFormat(Curator.curationContext()).getMIMEType() + "##";
    value += bitstream.getName() + "##";
    value += bitstream.getSizeBytes() + "##";
    value += item.getHandle() + "##";
    value += bitstream.getSequenceID() + "##";
    value += bitstream.getChecksum() + "##";
    if (bitstream.getDescription() != null) {
      value += bitstream.getDescription();
    }
    itemService.addMetadata(Curator.curationContext(), item, "dc", "format", type, "en", value);
  }
}

相关文章