@Override public void createContent() throws Exception { try { IContentItem responseContentItem = outputHandler.getOutputContentItem( IOutputHandler.RESPONSE, IOutputHandler.CONTENT, null, null); // mime type setting will blow up since servlet api used by grizzly is too old try { responseContentItem.setMimeType("text/plain"); } catch (Throwable t) { } OutputStream outputStream = responseContentItem.getOutputStream(null); IParameterProvider pathParams = parameterProviders.get("path"); String command = pathParams.getStringParameter("cmd", ""); Object testParamValue = parameterProviders.get(IParameterProvider.SCOPE_REQUEST).getParameter("testParam"); assertEquals("testParam is missing from request", "testParamValue", testParamValue); IOUtils.write( "hello this is service content generator servicing command " + command, outputStream); outputStream.close(); } catch (Throwable t) { t.printStackTrace(); } }
@SuppressWarnings({"unchecked", "rawtypes"}) public static String executeXml( RepositoryFile file, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, IPentahoSession userSession) throws Exception { try { HttpSessionParameterProvider sessionParameters = new HttpSessionParameterProvider(userSession); HttpRequestParameterProvider requestParameters = new HttpRequestParameterProvider(httpServletRequest); Map parameterProviders = new HashMap(); parameterProviders.put("request", requestParameters); // $NON-NLS-1$ parameterProviders.put("session", sessionParameters); // $NON-NLS-1$ List messages = new ArrayList(); IParameterProvider requestParams = new HttpRequestParameterProvider(httpServletRequest); httpServletResponse.setContentType("text/xml"); // $NON-NLS-1$ httpServletResponse.setCharacterEncoding(LocaleHelper.getSystemEncoding()); boolean forcePrompt = "true" .equalsIgnoreCase( requestParams.getStringParameter( "prompt", "false")); // $NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ OutputStream contentStream = new ByteArrayOutputStream(); SimpleOutputHandler outputHandler = new SimpleOutputHandler(contentStream, false); IRuntimeContext runtime = null; try { runtime = executeInternal( file, requestParams, httpServletRequest, outputHandler, parameterProviders, userSession, forcePrompt, messages); Document responseDoc = SoapHelper.createSoapResponseDocument(runtime, outputHandler, contentStream, messages); OutputFormat format = OutputFormat.createCompactFormat(); format.setSuppressDeclaration(true); format.setEncoding("utf-8"); // $NON-NLS-1$ ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); XMLWriter writer = new XMLWriter(outputStream, format); writer.write(responseDoc); writer.flush(); return outputStream.toString("utf-8"); // $NON-NLS-1$ } finally { if (runtime != null) { runtime.dispose(); } } } catch (Exception e) { logger.warn( Messages.getInstance().getString("XactionUtil.XML_OUTPUT_NOT_SUPPORTED")); // $NON-NLS-1$ throw e; } }
public void syncronize( IPentahoSession userSession, OutputStream out, IParameterProvider requestParams) throws Exception { // Read parameters Iterator<String> keys = requestParams.getParameterNames(); HashMap<String, String> parameters = new HashMap<String, String>(); while (keys.hasNext()) { String key = keys.next(); parameters.put(key, requestParams.getStringParameter(key, null)); } String operation = requestParams.getStringParameter("operation", "").toLowerCase(); // Call sync method try { Class<?>[] params = new Class[1]; params[0] = HashMap.class; Method mthd = this.getClass().getMethod(operation, params); Object result = mthd.invoke(this, parameters); if (result != null) { JsonUtils.buildJsonResult(out, true, result); } JsonUtils.buildJsonResult(out, true, null); } catch (NoSuchMethodException e) { throw new Exception( Messages.getString("CdfTemplates.ERROR_001_INVALID_SYNCRONIZE_METHOD_EXCEPTION")); } }
@Override public void execute() throws Exception { IParameterProvider pathParams = parameterProviders.get("path"); String command = pathParams.getStringParameter("cmd", ""); IOUtils.write("hello this is service content generator servicing command " + command, out); out.close(); }
private String getWcdfPath(final IParameterProvider pathParams) { final String path = "/" + pathParams.getStringParameter(MethodParams.SOLUTION, null) + "/" + pathParams.getStringParameter(MethodParams.PATH, null) + "/" + pathParams.getStringParameter(MethodParams.FILE, null); return path.replaceAll("//+", "/"); }
public MobileDashboard( IParameterProvider pathParams, DashboardDesignerContentGenerator generator) { super(pathParams, generator); IPentahoSession userSession = PentahoSessionHolder.getSession(); final ISolutionRepository solutionRepository = PentahoSystem.get(ISolutionRepository.class, userSession); final String absRoot = pathParams.hasParameter("root") ? !pathParams.getParameter("root").toString().isEmpty() ? "http://" + pathParams.getParameter("root").toString() : "" : ""; final boolean absolute = (!absRoot.isEmpty()) || pathParams.hasParameter("absolute") && pathParams.getParameter("absolute").equals("true"); final RenderMobileLayout layoutRenderer = new RenderMobileLayout(); final RenderComponents componentsRenderer = new RenderComponents(); try { final JSONObject json = (JSONObject) JsonUtils.readJsonFromInputStream( solutionRepository.getResourceInputStream(dashboardLocation, true)); json.put("settings", getWcdf().toJSON()); final JXPathContext doc = JXPathContext.newContext(json); final StringBuilder dashboardBody = new StringBuilder(); dashboardBody.append(layoutRenderer.render(doc)); dashboardBody.append(componentsRenderer.render(doc)); // set all dashboard members this.content = replaceTokens(dashboardBody.toString(), absolute, absRoot); this.header = renderHeaders(pathParams, this.content.toString()); this.loaded = new Date(); } catch (Exception e) { logger.error(e); } }
public Dashboard loadDashboard(Map<String, IParameterProvider> params) throws FileNotFoundException { IParameterProvider pathParams = params.get("path"), requestParams = params.get("request"); String scheme = requestParams.hasParameter("inferScheme") && requestParams.getParameter("inferScheme").equals("false") ? "" : DashboardDesignerContentGenerator.getScheme(pathParams); String root = requestParams.getStringParameter("root", ""); boolean absolute = (!root.equals("")) || requestParams.hasParameter("absolute") && requestParams.getParameter("absolute").equals("true"), bypassCache = requestParams.hasParameter("bypassCache") && requestParams.getParameter("bypassCache").equals("true"); final boolean debug = requestParams.hasParameter("debug") && requestParams.getParameter("debug").equals("true"); String wcdfPath = getWcdfPath(requestParams); return loadDashboard(wcdfPath, debug, absolute, scheme, root, bypassCache, ""); }
private static String callPlugin( final String pluginName, final String method, final Map<String, Object> parameters) throws ReportDataFactoryException { final IPentahoSession userSession = PentahoSessionHolder.getSession(); final IPluginManager pluginManager = PentahoSystem.get(IPluginManager.class, userSession); try { Object cdaBean = pluginManager.getBean("cda.api"); Class cdaBeanClass = cdaBean.getClass(); Class[] paramTypes; Object[] paramValues; Method m; final ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); if ("listParameters".equals(method)) { IParameterProvider params = new SimpleParameterProvider(parameters); paramTypes = new Class[] { String.class, String.class, String.class, String.class, String.class, HttpServletResponse.class, HttpServletRequest.class }; m = cdaBeanClass.getMethod("listParameters", paramTypes); paramValues = new Object[7]; paramValues[0] = params.getStringParameter("path", null); paramValues[1] = params.getStringParameter("solution", ""); paramValues[2] = params.getStringParameter("file", ""); paramValues[3] = params.getStringParameter("outputType", "json"); paramValues[4] = params.getStringParameter("dataAccessId", "<blank>"); paramValues[5] = getResponse(outputStream); paramValues[6] = getRequest(parameters); m.invoke(cdaBean, paramValues); return outputStream.toString(); } else { paramTypes = new Class[] {HttpServletRequest.class}; m = cdaBeanClass.getMethod("doQueryInterPlugin", paramTypes); paramValues = new Object[1]; paramValues[0] = getRequest(parameters); return (String) m.invoke(cdaBean, paramValues); } } catch (Exception e) { throw new ReportDataFactoryException("Failed to acquire " + pluginName + " plugin: ", e); } }
@SuppressWarnings("rawtypes") protected static IRuntimeContext executeInternal( RepositoryFile file, IParameterProvider requestParams, HttpServletRequest httpServletRequest, IOutputHandler outputHandler, Map<String, IParameterProvider> parameterProviders, IPentahoSession userSession, boolean forcePrompt, List messages) throws Exception { String processId = XactionUtil.class.getName(); String instanceId = httpServletRequest.getParameter("instance-id"); // $NON-NLS-1$ SimpleUrlFactory urlFactory = new SimpleUrlFactory(""); // $NON-NLS-1$ ISolutionEngine solutionEngine = PentahoSystem.get(ISolutionEngine.class, userSession); ISystemSettings systemSettings = PentahoSystem.getSystemSettings(); if (solutionEngine == null) { throw new ObjectFactoryException("No Solution Engine"); } boolean instanceEnds = "true" .equalsIgnoreCase( requestParams.getStringParameter( "instanceends", "true")); // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ String parameterXsl = systemSettings.getSystemSetting( "default-parameter-xsl", "DefaultParameterForm.xsl"); // $NON-NLS-1$ //$NON-NLS-2$ solutionEngine.setLoggingLevel(2); solutionEngine.init(userSession); solutionEngine.setForcePrompt(forcePrompt); if (parameterXsl != null) { solutionEngine.setParameterXsl(parameterXsl); } return solutionEngine.execute( file.getPath(), processId, false, instanceEnds, instanceId, false, parameterProviders, outputHandler, null, urlFactory, messages); }
public String getContext(IParameterProvider requestParams) { try { String solution = requestParams.getStringParameter("solution", ""), path = requestParams.getStringParameter("path", ""), // Fix #29. Because there is no file parameter in CDF, but action parameter // file parameter is used in CDE file = requestParams.getStringParameter( "file", requestParams.getStringParameter("action", "")), fullPath = ("/" + solution + "/" + path + "/" + file).replaceAll("/+", "/"); final JSONObject context = new JSONObject(); Calendar cal = Calendar.getInstance(); Document config = getConfigFile(); context.put("queryData", processAutoIncludes(fullPath, config)); context.put("sessionAttributes", processSessionAttributes(config)); context.put("serverLocalDate", cal.getTimeInMillis()); context.put("serverUTCDate", cal.getTimeInMillis() + cal.getTimeZone().getRawOffset()); context.put("user", userSession.getName()); context.put("locale", userSession.getLocale()); context.put("solution", solution); context.put("path", path); context.put("file", file); context.put("fullPath", fullPath); SecurityParameterProvider securityParams = new SecurityParameterProvider(userSession); context.put("roles", securityParams.getParameter("principalRoles")); JSONObject params = new JSONObject(); Iterator it = requestParams.getParameterNames(); while (it.hasNext()) { String p = (String) it.next(); if (p.indexOf("param") == 0) { params.put(p.substring(5), requestParams.getParameter(p)); } } context.put("params", params); final StringBuilder s = new StringBuilder(); s.append("\n<script language=\"javascript\" type=\"text/javascript\">\n"); s.append(" Dashboards.context = "); s.append(context.toString(2) + "\n"); s.append("</script>\n"); // setResponseHeaders(MIME_PLAIN,0,null); logger.info( "[Timing] Finished building context: " + (new SimpleDateFormat("HH:mm:ss.SSS")).format(new Date())); return s.toString(); } catch (JSONException e) { return ""; } }
/** * Start Audit Event * * @param processId Id for the audit process (usually the plugin name) * @param actionName Name of the action * @param objectName Object of the action * @param userSession Pentaho User Session * @param logger Logger object * @param requestParams parameters associated to the request * @return UUID of start event */ public static UUID startAudit( String processId, String actionName, String objectName, IPentahoSession userSession, ILogger logger, IParameterProvider requestParams) { UUID uuid = UUID.randomUUID(); StringBuilder sb = new StringBuilder(); if (requestParams != null) { @SuppressWarnings("unchecked") Iterator<String> iter = requestParams.getParameterNames(); while (iter.hasNext()) { String paramName = iter.next().toString(); sb.append(paramName) .append("=") .append(requestParams.getStringParameter(paramName, "novalue")) .append(";"); } } AuditHelper.audit( userSession.getId(), userSession.getName(), actionName, objectName, processId, MessageTypes.INSTANCE_START, uuid.toString(), sb.toString(), 0, logger); return uuid; }
@SuppressWarnings({"unchecked", "rawtypes"}) public static String doParameter( final RepositoryFile file, IParameterProvider parameterProvider, final IPentahoSession userSession) throws IOException { ActionSequenceJCRHelper helper = new ActionSequenceJCRHelper(); final IActionSequence actionSequence = helper.getActionSequence( file.getPath(), PentahoSystem.loggingLevel, RepositoryFilePermission.READ); final Document document = DocumentHelper.createDocument(); try { final Element parametersElement = document.addElement("parameters"); // noinspection unchecked final Map<String, IActionParameter> params = actionSequence.getInputDefinitionsForParameterProvider(IParameterProvider.SCOPE_REQUEST); for (final Map.Entry<String, IActionParameter> entry : params.entrySet()) { final String paramName = entry.getKey(); final IActionParameter paramDef = entry.getValue(); final String value = paramDef.getStringValue(); final Class type; // yes, the actual type-code uses equals-ignore-case and thus allows the user // to specify type information in a random case. sTrInG is equal to STRING is equal to the // value // defined as constant (string) if (IActionParameter.TYPE_LIST.equalsIgnoreCase(paramDef.getType())) { type = String[].class; } else { type = String.class; } final String label = paramDef.getSelectionDisplayName(); final String[] values; if (StringUtils.isEmpty(value)) { values = new String[0]; } else { values = new String[] {value}; } createParameterElement( parametersElement, paramName, type, label, "user", "parameters", values); } createParameterElement( parametersElement, "path", String.class, null, "system", "system", new String[] {file.getPath()}); createParameterElement( parametersElement, "prompt", String.class, null, "system", "system", new String[] {"yes", "no"}); createParameterElement( parametersElement, "instance-id", String.class, null, "system", "system", new String[] {parameterProvider.getStringParameter("instance-id", null)}); // no close, as far as I know tomcat does not like it that much .. OutputFormat format = OutputFormat.createCompactFormat(); format.setSuppressDeclaration(true); format.setEncoding("utf-8"); // $NON-NLS-1$ ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); XMLWriter writer = new XMLWriter(outputStream, format); writer.write(document); writer.flush(); return outputStream.toString("utf-8"); } catch (Exception e) { logger.warn(Messages.getInstance().getString("HttpWebService.ERROR_0003_UNEXPECTED"), e); return null; } }
/** * This method executes an xaction with forcePrompt=true and outputPreference=PARAMETERS, allowing * for the xaction to render the secure filter appropriately when being executed in the background * or while being scheduled. * * @param file the location of the xaction * @param httpServletRequest the request object * @param httpServletResponse the response object * @param userSession the user session * @return potential response message * @throws Exception */ @SuppressWarnings({"unchecked", "rawtypes"}) public static String executeScheduleUi( RepositoryFile file, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, IPentahoSession userSession, IMimeTypeListener mimeTypeListener) throws Exception { IParameterProvider requestParams = new HttpRequestParameterProvider(httpServletRequest); IRuntimeContext runtime = null; try { HttpSessionParameterProvider sessionParameters = new HttpSessionParameterProvider(userSession); HttpRequestParameterProvider requestParameters = new HttpRequestParameterProvider(httpServletRequest); boolean doMessages = "true" .equalsIgnoreCase( requestParams.getStringParameter( "debug", "false")); // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ boolean doWrapper = "true" .equalsIgnoreCase( requestParams.getStringParameter( "wrapper", "true")); // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ IOutputHandler outputHandler = createOutputHandler( httpServletResponse, getOutputStream(httpServletResponse, doMessages)); if (mimeTypeListener == null) { mimeTypeListener = new HttpMimeTypeListener(httpServletRequest, httpServletResponse, null); } outputHandler.setMimeTypeListener(mimeTypeListener); outputHandler.setSession(userSession); Map parameterProviders = new HashMap(); parameterProviders.put("request", requestParameters); // $NON-NLS-1$ parameterProviders.put("session", sessionParameters); // $NON-NLS-1$ createOutputFileName(file, outputHandler); int outputPreference = IOutputHandler.OUTPUT_TYPE_PARAMETERS; outputHandler.setOutputPreference(outputPreference); List messages = new ArrayList(); // forcePrompt=true when displaying the scheduling UI runtime = executeInternal( file, requestParams, httpServletRequest, outputHandler, parameterProviders, userSession, true, messages); String str = postExecute( runtime, doMessages, doWrapper, outputHandler, parameterProviders, httpServletRequest, httpServletResponse, messages, false); return str; } catch (Exception e) { logger.error( Messages.getInstance() .getString("XactionUtil.ERROR_EXECUTING_ACTION_SEQUENCE", file.getName()), e); //$NON-NLS-1$ throw e; } finally { if (runtime != null) { runtime.dispose(); } } }
public void createReportContent( final OutputStream outputStream, final Serializable fileId, final String path, final boolean forceDefaultOutputTarget) throws Exception { final long start = System.currentTimeMillis(); final Map<String, Object> inputs = contentGenerator.createInputs(); AuditHelper.audit( userSession.getId(), userSession.getName(), path, contentGenerator.getObjectName(), getClass().getName(), MessageTypes.INSTANCE_START, contentGenerator.getInstanceId(), "", 0, contentGenerator); //$NON-NLS-1$ String result = MessageTypes.INSTANCE_END; StagingHandler reportStagingHandler = null; try { final Object rawSessionId = inputs.get(ParameterXmlContentHandler.SYS_PARAM_SESSION_ID); if ((rawSessionId instanceof String) == false || "".equals(rawSessionId)) { inputs.put(ParameterXmlContentHandler.SYS_PARAM_SESSION_ID, UUIDUtil.getUUIDAsString()); } // produce rendered report final SimpleReportingComponent reportComponent = new SimpleReportingComponent(); reportComponent.setReportFileId(fileId); reportComponent.setPaginateOutput(true); reportComponent.setForceDefaultOutputTarget(forceDefaultOutputTarget); reportComponent.setDefaultOutputTarget(HtmlTableModule.TABLE_HTML_PAGE_EXPORT_TYPE); if (path.endsWith(".prpti")) { reportComponent.setForceUnlockPreferredOutput(true); } reportComponent.setInputs(inputs); final MasterReport report = reportComponent.getReport(); final StagingMode stagingMode = getStagingMode(inputs, report); reportStagingHandler = new StagingHandler(outputStream, stagingMode, this.userSession); if (reportStagingHandler.isFullyBuffered()) { // it is safe to disable the buffered writing for the report now that we have a // extra buffering in place. report.getReportConfiguration().setConfigProperty(FORCED_BUFFERED_WRITING, "false"); } reportComponent.setOutputStream(reportStagingHandler.getStagingOutputStream()); // the requested mime type can be null, in that case the report-component will resolve the // desired // type from the output-target. // Hoever, the report-component will inspect the inputs independently from the mimetype here. final IUnifiedRepository repository = PentahoSystem.get(IUnifiedRepository.class, userSession); final RepositoryFile file = repository.getFileById(fileId); // add all inputs (request parameters) to report component final String mimeType = reportComponent.getMimeType(); // If we haven't set an accepted page, -1 will be the default, which will give us a report // with no pages. This default is used so that when we do our parameter interaction with the // engine we can spend as little time as possible rendering unused pages, making it no pages. // We are going to intentionally reset the accepted page to the first page, 0, at this point, // if the accepted page is -1. final String outputTarget = reportComponent.getComputedOutputTarget(); if (HtmlTableModule.TABLE_HTML_PAGE_EXPORT_TYPE.equals(outputTarget) && reportComponent.getAcceptedPage() < 0) { reportComponent.setAcceptedPage(0); } if (logger.isDebugEnabled()) { logger.debug( Messages.getInstance() .getString( "ReportPlugin.logStartGenerateContent", mimeType, //$NON-NLS-1$ outputTarget, String.valueOf(reportComponent.getAcceptedPage()))); } HttpServletResponse response = null; boolean streamToBrowser = false; final IParameterProvider pathProviders = contentGenerator.getParameterProviders().get("path"); if (pathProviders != null) { final Object httpResponse = pathProviders.getParameter("httpresponse"); if (httpResponse instanceof HttpServletResponse) { // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ response = (HttpServletResponse) httpResponse; // $NON-NLS-1$ //$NON-NLS-2$ if (reportStagingHandler.getStagingMode() == StagingMode.THRU) { // Direct back - check output stream... final OutputStream respOutputStream = response.getOutputStream(); if (respOutputStream == outputStream) { // // Massive assumption here - // Assume the container returns the same object on successive calls to // response.getOutputStream() streamToBrowser = true; } } } } final String extension = MimeHelper.getExtension(mimeType); String filename = file.getName(); if (filename.lastIndexOf(".") != -1) { // $NON-NLS-1$ filename = filename.substring(0, filename.lastIndexOf(".")); // $NON-NLS-1$ } String disposition = "inline; filename*=UTF-8''" + RepositoryPathEncoder.encode( RepositoryPathEncoder.encodeRepositoryPath(filename + extension)); final boolean validates = reportComponent.validate(); if (!validates) { sendErrorResponse(response, outputStream, reportStagingHandler); } else { if (response != null) { // Send headers before we begin execution response.setHeader("Content-Disposition", disposition); response.setHeader("Content-Description", file.getName()); // $NON-NLS-1$ response.setHeader("Cache-Control", "private, max-age=0, must-revalidate"); } if (reportComponent.execute()) { if (response != null) { if (reportStagingHandler.canSendHeaders()) { response.setHeader("Content-Disposition", disposition); response.setHeader("Content-Description", file.getName()); // $NON-NLS-1$ response.setHeader("Cache-Control", "private, max-age=0, must-revalidate"); response.setContentLength(reportStagingHandler.getWrittenByteCount()); } } if (logger.isDebugEnabled()) { logger.debug( Messages.getInstance() .getString( "ReportPlugin.logEndGenerateContent", String.valueOf(reportStagingHandler.getWrittenByteCount()))); // $NON-NLS-1$ } reportStagingHandler.complete(); // will copy bytes to final destination... } else { // failed execution sendErrorResponse(response, outputStream, reportStagingHandler); } } } catch (Exception ex) { result = MessageTypes.INSTANCE_FAILED; throw ex; } finally { if (reportStagingHandler != null) { reportStagingHandler.close(); } final long end = System.currentTimeMillis(); AuditHelper.audit( userSession.getId(), userSession.getName(), path, contentGenerator.getObjectName(), getClass().getName(), result, contentGenerator.getInstanceId(), "", ((float) (end - start) / 1000), contentGenerator); //$NON-NLS-1$ } }
public void test1() throws ObjectFactoryException { StandaloneSession session = new StandaloneSession("test"); StandaloneApplicationContext appContext = new StandaloneApplicationContext("test-res/solution", ""); StandaloneSpringPentahoObjectFactory factory = new StandaloneSpringPentahoObjectFactory(); factory.init( "test-res/solution/system/pentahoObjects.GlobalListPublisherTest.spring.xml", null); PentahoSystem.setObjectFactory(factory); PentahoSystem.setSystemSettingsService( factory.get(ISystemSettings.class, "systemSettingsService", session)); PentahoSystem.init(appContext); List<ISessionStartupAction> actions = new ArrayList<ISessionStartupAction>(); SessionStartupAction startupAction1 = new SessionStartupAction(); startupAction1.setSessionType(PentahoSystem.SCOPE_GLOBAL); startupAction1.setActionPath("testsolution/testpath/test.xaction"); startupAction1.setActionOutputScope(PentahoSystem.SCOPE_GLOBAL); actions.add(startupAction1); TestRuntimeContext context = new TestRuntimeContext(); context.status = IRuntimeContext.RUNTIME_STATUS_SUCCESS; TestSolutionEngine engine = PentahoSystem.get(TestSolutionEngine.class, "ISolutionEngine", session); engine.testRuntime = context; Map<String, IActionParameter> outputs = new HashMap<String, IActionParameter>(); TestActionParameter param = new TestActionParameter(); param.setValue("testvalue"); outputs.put("testoutput", param); context.outputParameters = outputs; engine.executeCount = 0; GlobalListsPublisher globals = new GlobalListsPublisher(); assertEquals( Messages.getInstance().getString("GlobalListsPublisher.USER_SYSTEM_SETTINGS"), globals.getName()); assertEquals( Messages.getInstance().getString("GlobalListsPublisher.USER_DESCRIPTION"), globals.getDescription()); assertTrue(!globals.getName().startsWith("!")); assertTrue(!globals.getDescription().startsWith("!")); assertNotNull(globals.getLogger()); String resultMsg = globals.publish(session); assertEquals( Messages.getInstance().getString("GlobalListsPublisher.USER_SYSTEM_SETTINGS_UPDATED"), resultMsg); assertEquals(0, engine.executeCount); PentahoSystem.setSessionStartupActions(actions); IParameterProvider globalParams = PentahoSystem.getGlobalParameters(); resultMsg = globals.publish(session); assertEquals(1, engine.executeCount); assertEquals( Messages.getInstance().getString("GlobalListsPublisher.USER_SYSTEM_SETTINGS_UPDATED"), resultMsg); // check that we made it all the way to executing the startup action assertEquals(session, engine.initSession); assertEquals(startupAction1.getActionPath(), engine.actionPath); assertEquals("testvalue", globalParams.getParameter("testoutput")); param.setValue("testvalue2"); resultMsg = globals.publish(session); assertEquals( Messages.getInstance().getString("GlobalListsPublisher.USER_SYSTEM_SETTINGS_UPDATED"), resultMsg); assertEquals(2, engine.executeCount); assertNotNull(globalParams); assertEquals("testvalue2", globalParams.getParameter("testoutput")); engine.errorMsg = "test exception"; resultMsg = globals.publish(session); assertEquals( Messages.getInstance().getString("GlobalListsPublisher.USER_ERROR_PUBLISH_FAILED") + "test exception", resultMsg); assertEquals(3, engine.executeCount); }