/** * Write the attachment out to a string. * * @param encoding The string encoding format of the data. Eg, "UTF-8". * @return A string representation of the attachment data. * @throws IOException */ public static String writeAttachmentDataToString( AttachmentData data, String encoding) throws IOException { ByteArrayOutputStream stream = new ByteArrayOutputStream(); writeTo(data.getInputStream(), stream); return stream.toString(encoding); }
waveletName = AttachmentUtil.waveRef2WaveletName(waveRefStr); } else { response.sendError(HttpServletResponse.SC_NOT_FOUND); waveletName = AttachmentUtil.waveRef2WaveletName(metadata.getWaveRef()); response.setStatus(HttpServletResponse.SC_OK); response.setDateHeader("Last-Modified", Calendar.getInstance().getTimeInMillis()); AttachmentUtil.writeTo(data.getInputStream(), response.getOutputStream());
WaveletName waveletName = AttachmentUtil.waveRef2WaveletName(waveRefStr); ParticipantId user = sessionManager.getLoggedInUser(request.getSession(false)); boolean isAuthorized = waveletProvider.checkAccessPermission(waveletName, user);
if (metadata != null) { boolean isAuthorized = false; WaveletName waveletName = AttachmentUtil.waveRef2WaveletName(metadata.getWaveRef()); try { isAuthorized = waveletProvider.checkAccessPermission(waveletName, user);
protected String dataToString(AttachmentData data) throws IOException { ByteArrayOutputStream out = new ByteArrayOutputStream(); InputStream io = data.getInputStream(); try { AttachmentUtil.writeTo(io, out); } finally { io.close(); } return out.toString("UTF-8"); } }
protected String dataToString(AttachmentData data) throws IOException { ByteArrayOutputStream out = new ByteArrayOutputStream(); InputStream io = data.getInputStream(); try { AttachmentUtil.writeTo(io, out); } finally { io.close(); } return out.toString("UTF-8"); } }
public void testAttachmentCanWriteToOutputStream() throws Exception { String testData = "maybe there's some easy way to generate test strings"; AttachmentId id = new AttachmentId("", "id_4"); AttachmentStore store = makeStoreWithData(id, testData); AttachmentData data = store.getAttachment(id); ByteArrayOutputStream stream = new ByteArrayOutputStream(); InputStream io = data.getInputStream(); try { AttachmentUtil.writeTo(io, stream); assertEquals(testData, stream.toString("UTF-8")); } finally { io.close(); } }
public void testAttachmentCanWriteToOutputStream() throws Exception { String testData = "maybe there's some easy way to generate test strings"; AttachmentId id = new AttachmentId("", "id_4"); AttachmentStore store = makeStoreWithData(id, testData); AttachmentData data = store.getAttachment(id); ByteArrayOutputStream stream = new ByteArrayOutputStream(); InputStream io = data.getInputStream(); try { AttachmentUtil.writeTo(io, stream); assertEquals(testData, stream.toString("UTF-8")); } finally { io.close(); } }