Utils.bufferedCopy(is, response.getOutputStream());
/** * 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(); }
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()); } } } }
/** * 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()); }
Utils.bufferedCopy(dis, fos); in.close(); bitstream.setChecksum(Utils.toHex(dis.getMessageDigest().digest())); bitstream.setChecksumAlgorithm(CSA); } catch (NoSuchAlgorithmException nsae) {
+ "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);
@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(); }
/** * 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(); }
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()));
spec.append(Utils.addEntities(collName)); spec.append("</setName>"); spec.append(Utils.addEntities(commName)); spec.append("</setName>");
rd.setToken(Utils.generateHexKey());
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(); }
Utils.bufferedCopy(is, this.out); is.close(); this.out.flush();
+ 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));
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);
@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); } }
"attachment;filename=" + filename); Utils.bufferedCopy(exportStream, response.getOutputStream()); exportStream.close(); response.getOutputStream().flush();
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))
@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(); } } }
InputStream is = bitstreamService.retrieve(c, bitstream); FileOutputStream fos = new FileOutputStream(fout); Utils.bufferedCopy(is, fos);