List of usage examples for com.liferay.portal.kernel.util StreamUtil transfer
public static void transfer(InputStream inputStream, OutputStream outputStream) throws IOException
From source file:com.liferay.antisamy.hook.sanitizer.AntiSamySanitizerImpl.java
License:Open Source License
@Override public void sanitize(long companyId, long groupId, long userId, String className, long classPK, String contentType, String[] modes, InputStream inputStream, OutputStream outputStream, Map<String, Object> options) throws SanitizerException { if (_log.isDebugEnabled()) { _log.debug("Sanitizing " + className + "#" + classPK); }//from w w w.j av a 2 s.com try { StreamUtil.transfer(inputStream, outputStream); } catch (IOException ioe) { throw new SanitizerException(ioe); } }
From source file:com.liferay.document.library.internal.atom.FileEntryAtomCollectionAdapter.java
License:Open Source License
@Override protected FileEntry doPostMedia(String mimeType, String slug, InputStream inputStream, AtomRequestContext atomRequestContext) throws Exception { long folderId = atomRequestContext.getLongParameter("folderId"); long repositoryId = 0; if (folderId != 0) { Folder folder = _dlAppService.getFolder(folderId); repositoryId = folder.getRepositoryId(); } else {/*w w w . j a v a2 s.c o m*/ repositoryId = atomRequestContext.getLongParameter("repositoryId"); } String title = atomRequestContext.getHeader("Title"); String description = atomRequestContext.getHeader("Summary"); ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); StreamUtil.transfer(inputStream, byteArrayOutputStream); byte[] content = byteArrayOutputStream.toByteArray(); ByteArrayInputStream contentInputStream = new ByteArrayInputStream(content); ServiceContext serviceContext = new ServiceContext(); FileEntry fileEntry = _dlAppService.addFileEntry(repositoryId, folderId, title, mimeType, title, description, null, contentInputStream, content.length, serviceContext); return fileEntry; }
From source file:com.liferay.document.library.internal.atom.FileEntryAtomCollectionAdapter.java
License:Open Source License
@Override protected void doPutMedia(FileEntry fileEntry, String mimeType, String slug, InputStream inputStream, AtomRequestContext atomRequestContext) throws Exception { String title = atomRequestContext.getHeader("Title"); String description = atomRequestContext.getHeader("Summary"); ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); StreamUtil.transfer(inputStream, byteArrayOutputStream); byte[] content = byteArrayOutputStream.toByteArray(); ByteArrayInputStream contentInputStream = new ByteArrayInputStream(content); ServiceContext serviceContext = new ServiceContext(); _dlAppService.updateFileEntry(fileEntry.getFileEntryId(), slug, mimeType, title, description, null, true, contentInputStream, content.length, serviceContext); }
From source file:com.liferay.emailtombfilter.hook.sanitizer.EmailToMBMessageFilterSanitizerImpl.java
License:Open Source License
@Override public void sanitize(long companyId, long groupId, long userId, String className, long classPK, String contentType, String[] modes, InputStream inputStream, OutputStream outputStream, Map<String, Object> options) throws SanitizerException { try {//from w w w. jav a 2s . c o m StreamUtil.transfer(inputStream, outputStream); } catch (IOException ioe) { throw new SanitizerException(ioe); } }
From source file:com.liferay.frontend.css.rtl.servlet.internal.RTLServlet.java
License:Open Source License
protected void transfer(URL url, HttpServletResponse response) throws IOException { URLConnection urlConnection = url.openConnection(); response.setContentLength(urlConnection.getContentLength()); response.setStatus(HttpServletResponse.SC_OK); StreamUtil.transfer(url.openStream(), response.getOutputStream()); }
From source file:com.liferay.frontend.editor.alloyeditor.syntax.extension.web.internal.servlet.taglib.FrontendAlloyEditorSyntaxExtensionOnEditOrCreateDynamicInclude.java
License:Open Source License
@Override public void include(HttpServletRequest request, HttpServletResponse response, String key) throws IOException { if (!FrontendAlloyEditorSyntaxExtensionHelper.isEnabled()) { return;/* ww w . j av a 2 s .com*/ } try { Bundle bundle = _bundleContext.getBundle(); URL entryURL = bundle.getEntry(_ALLOYEDITOR_SYNTAX_JS); StreamUtil.transfer(entryURL.openStream(), response.getOutputStream()); } catch (Exception e) { _log.error("Unable to send editor js " + _ALLOYEDITOR_SYNTAX_JS, e); throw new IOException("Unable to include JSP " + _ALLOYEDITOR_SYNTAX_JS, e); } }
From source file:com.liferay.portlet.documentlibrary.atom.FileEntryAtomCollectionAdapter.java
License:Open Source License
@Override protected FileEntry doPostMedia(String mimeType, String slug, InputStream inputStream, AtomRequestContext atomRequestContext) throws Exception { long folderId = atomRequestContext.getLongParameter("folderId"); long repositoryId = 0; if (folderId != 0) { Folder folder = DLAppServiceUtil.getFolder(folderId); repositoryId = folder.getRepositoryId(); } else {/*from www .j a va2 s. c o m*/ repositoryId = atomRequestContext.getLongParameter("repositoryId"); } String title = atomRequestContext.getHeader("Title"); String description = atomRequestContext.getHeader("Summary"); ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); StreamUtil.transfer(inputStream, byteArrayOutputStream); byte[] content = byteArrayOutputStream.toByteArray(); ByteArrayInputStream contentInputStream = new ByteArrayInputStream(content); ServiceContext serviceContext = new ServiceContext(); FileEntry fileEntry = DLAppServiceUtil.addFileEntry(repositoryId, folderId, title, mimeType, title, description, null, contentInputStream, content.length, serviceContext); return fileEntry; }
From source file:com.liferay.portlet.documentlibrary.atom.FileEntryAtomCollectionAdapter.java
License:Open Source License
@Override protected void doPutMedia(FileEntry fileEntry, String mimeType, String slug, InputStream inputStream, AtomRequestContext atomRequestContext) throws Exception { String title = atomRequestContext.getHeader("Title"); String description = atomRequestContext.getHeader("Summary"); ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); StreamUtil.transfer(inputStream, byteArrayOutputStream); byte[] content = byteArrayOutputStream.toByteArray(); ByteArrayInputStream contentInputStream = new ByteArrayInputStream(content); ServiceContext serviceContext = new ServiceContext(); DLAppServiceUtil.updateFileEntry(fileEntry.getFileEntryId(), slug, mimeType, title, description, null, true, contentInputStream, content.length, serviceContext); }
From source file:com.liferay.server.manager.internal.executor.OutputLogExecutor.java
License:Open Source License
@Override public void executeRead(HttpServletRequest request, JSONObject responseJSONObject, Queue<String> arguments) throws Exception { File logFile = getLogFile();//from w w w.j a v a 2s.c om if ((logFile == null) || !logFile.exists()) { return; } InputStream inputStream = new FileInputStream(logFile); int offset = GetterUtil.getInteger(arguments.poll()); inputStream.skip(offset); OutputStream outputStream = new ByteArrayOutputStream(); StreamUtil.transfer(inputStream, outputStream); responseJSONObject.put(JSONKeys.OUTPUT, outputStream.toString()); }
From source file:com.liferay.sync.filter.SyncJSONHttpServletRequestWrapper.java
License:Open Source License
@Override public ServletInputStream getInputStream() throws IOException { if (_byteArrayOutputStream == null) { _byteArrayOutputStream = new ByteArrayOutputStream(); StreamUtil.transfer(super.getInputStream(), _byteArrayOutputStream); }/*from w w w .j av a2 s. co m*/ final ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream( _byteArrayOutputStream.toByteArray()); return new ServletInputStream() { @Override public int read() throws IOException { return byteArrayInputStream.read(); } }; }