protected void runScript( PortletConfig portletConfig, ActionRequest actionRequest, ActionResponse actionResponse) throws Exception { String language = ParamUtil.getString(actionRequest, "language"); String script = ParamUtil.getString(actionRequest, "script"); PortletContext portletContext = portletConfig.getPortletContext(); Map<String, Object> portletObjects = ScriptingUtil.getPortletObjects( portletConfig, portletContext, actionRequest, actionResponse); UnsyncByteArrayOutputStream unsyncByteArrayOutputStream = new UnsyncByteArrayOutputStream(); UnsyncPrintWriter unsyncPrintWriter = UnsyncPrintWriterPool.borrow(unsyncByteArrayOutputStream); portletObjects.put("out", unsyncPrintWriter); try { SessionMessages.add(actionRequest, "language", language); SessionMessages.add(actionRequest, "script", script); ScriptingUtil.exec(null, portletObjects, language, script); unsyncPrintWriter.flush(); SessionMessages.add(actionRequest, "scriptOutput", unsyncByteArrayOutputStream.toString()); } catch (ScriptingException se) { SessionErrors.add(actionRequest, ScriptingException.class.getName(), se); _log.error(se.getMessage()); } }
@Override public InputStream getLoadIndexesInputStreamFromCluster(long companyId, Address bootupAddress) { if (!isLoadIndexFromClusterEnabled()) { return null; } InputStream inputStream = null; try { ObjectValuePair<String, URL> bootupClusterNodeObjectValuePair = _getBootupClusterNodeObjectValuePair(bootupAddress); URL url = bootupClusterNodeObjectValuePair.getValue(); URLConnection urlConnection = url.openConnection(); urlConnection.setDoOutput(true); UnsyncPrintWriter unsyncPrintWriter = UnsyncPrintWriterPool.borrow(urlConnection.getOutputStream()); unsyncPrintWriter.write("transientToken="); unsyncPrintWriter.write(bootupClusterNodeObjectValuePair.getKey()); unsyncPrintWriter.write("&companyId="); unsyncPrintWriter.write(String.valueOf(companyId)); unsyncPrintWriter.close(); inputStream = urlConnection.getInputStream(); return inputStream; } catch (IOException ioe) { throw new SystemException(ioe); } }