org.dspace.core.Utils类的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(7.2k)|赞(0)|评价(0)|浏览(212)

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

Utils介绍

[英]Utility functions for DSpace.
[中]DSpace的实用功能。

代码示例

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

Utils.bufferedCopy(is, response.getOutputStream());

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

/**
 * Copy stream-data from source to destination, with buffering. This is
 * equivalent to passing {@link #copy}a
 * <code>java.io.BufferedInputStream</code> and
 * <code>java.io.BufferedOutputStream</code> to {@link #copy}, and
 * flushing the output stream afterwards. The streams are not closed after
 * the copy.
 *
 * @param source      The InputStream to obtain data from.
 * @param destination The OutputStream to copy data to.
 * @throws IOException if IO error
 */
public static void bufferedCopy(final InputStream source,
                final OutputStream destination) throws IOException {
  final BufferedInputStream input = new BufferedInputStream(source);
  final BufferedOutputStream output = new BufferedOutputStream(
    destination);
  copy(input, output);
  output.flush();
}

代码示例来源: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

/**
 * Generate a unique key. The key is a 32-character long sequence of hex
 * digits.
 *
 * @return A unique key as a long sequence of hex digits.
 */
public static String generateHexKey() {
  return toHex(generateBytesKey());
}

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

Utils.bufferedCopy(dis, fos);
  in.close();
  bitstream.setChecksum(Utils.toHex(dis.getMessageDigest().digest()));
  bitstream.setChecksumAlgorithm(CSA);
} catch (NoSuchAlgorithmException nsae) {

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

+ "qualifier=\"" + qualifier + "\""
  + language + ">"
  + Utils.addEntities(dcv.getValue()) + "</dcvalue>\n")
  .getBytes("UTF-8");
utf8 = ("  <dcvalue element=\"date\" "
  + "qualifier=\"issued\">"
  + Utils.addEntities(dateIssued) + "</dcvalue>\n")
  .getBytes("UTF-8");
out.write(utf8, 0, utf8.length);

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

@Override
public String createRequest(Context context, Bitstream bitstream, Item item, boolean allFiles, String reqEmail,
              String reqName, String reqMessage) throws SQLException {
  RequestItem requestItem = requestItemDAO.create(context, new RequestItem());
  requestItem.setToken(Utils.generateHexKey());
  requestItem.setBitstream(bitstream);
  requestItem.setItem(item);
  requestItem.setAllfiles(allFiles);
  requestItem.setReqEmail(reqEmail);
  requestItem.setReqName(reqName);
  requestItem.setReqMessage(reqMessage);
  requestItem.setRequest_date(new Date());
  requestItemDAO.save(context, requestItem);
  if (log.isDebugEnabled()) {
    log.debug("Created requestitem_token " + requestItem.getID()
           + " with token " + requestItem.getToken() + "\"");
  }
  return requestItem.getToken();
}

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

/**
 * Generate a unique key. The key is a long (length 38 to 40) sequence of
 * digits.
 *
 * @return A unique key as a long sequence of base-10 digits.
 */
public static String generateKey() {
  return new BigInteger(generateBytesKey()).abs().toString();
}

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

remPublished.addContent(Utils.formatISO8601Date(new Date()));
Element remUpdated = new Element("updated", ATOM_NS);
remUpdated.addContent(Utils.formatISO8601Date(new Date()));
updateCategory.setAttribute("term", Utils.formatISO8601Date(item.getLastModified()));
rdfType.setAttribute("resource", DS_NS.getURI() + "DSpaceItem", RDF_NS);
dcModified = new Element("modified", DCTERMS_NS);
dcModified.addContent(Utils.formatISO8601Date(item.getLastModified()));

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

spec.append(Utils.addEntities(collName));
spec.append("</setName>");
spec.append(Utils.addEntities(commName));
spec.append("</setName>");

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

rd.setToken(Utils.generateHexKey());

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

protected byte[] getBytesFromBitstream(Context context, Item item, String bitstream_name)
  throws SQLException, IOException, AuthorizeException {
  Bitstream bs = getBitstream(item, bitstream_name);
  // no such bitstream
  if (bs == null) {
    return null;
  }
  // create a ByteArrayOutputStream
  ByteArrayOutputStream baos = new ByteArrayOutputStream();
  Utils.copy(bitstreamService.retrieve(context, bs), baos);
  return baos.toByteArray();
}

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

Utils.bufferedCopy(is, this.out);
is.close();
this.out.flush();

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

+ Utils.addEntities(values[j].value) + "</a>");
      + Utils.addEntities(value) + "</a>");
    out.print("<a href=\"" + url
        + value + "\">"
        + Utils.addEntities(values[j].value)
        + "</a>");
      + URLEncoder.encode(value, "UTF-8") + "\">" + Utils.addEntities(values[j].value)
      + "</a>");
out.print(Utils.addEntities(values[j].value));

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

for (Handle handle : Utils.emptyIfNull(dso.getHandles())) {
  uncacheEntity(handle);
for (ResourcePolicy policy : Utils.emptyIfNull(dso.getResourcePolicies())) {
  uncacheEntity(policy);
for (Bundle bundle : Utils.emptyIfNull(item.getBundles())) {
  uncacheEntity(bundle);
for (Bitstream bitstream : Utils.emptyIfNull(bundle.getBitstreams())) {
  uncacheEntity(bitstream);

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

@Override
public void ingest(Context context, DSpaceObject dso, InputStream in, String MIMEType)
  throws CrosswalkException, IOException, SQLException, AuthorizeException {
  // If package includes a Creative Commons license, add that:
  if (dso.getType() == Constants.ITEM) {
    if (log.isDebugEnabled()) {
      log.debug("Reading a DSpace Deposit license, MIMEtype=" + MIMEType);
    }
    ByteArrayOutputStream baos = new ByteArrayOutputStream();
    Utils.copy(in, baos);
    PackageUtils.addDepositLicense(context, baos.toString(),
                    (Item) dso, null);
  }
}

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

"attachment;filename=" + filename);
Utils.bufferedCopy(exportStream, response.getOutputStream());
exportStream.close();
response.getOutputStream().flush();

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

metadata = Utils.addEntities(metadataArray[0].value);
+ Utils.addEntities(metadataArray[0].value)
+ "</a>";
  sb.append(Utils.addEntities(metadataArray[j].value));
  sb.append(endLink);
  if (j < (loopLimit - 1))

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

@Override
public void disseminate(Context context, DSpaceObject dso, OutputStream out)
  throws CrosswalkException, IOException, SQLException, AuthorizeException {
  if (dso.getType() == Constants.ITEM) {
    Bitstream licenseBs = PackageUtils.findDepositLicense(context, (Item) dso);
    if (licenseBs != null) {
      Utils.copy(bitstreamService.retrieve(context, licenseBs), out);
      out.close();
    }
  }
}

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

InputStream is = bitstreamService.retrieve(c, bitstream);
FileOutputStream fos = new FileOutputStream(fout);
Utils.bufferedCopy(is, fos);

相关文章