use of org.pentaho.platform.api.engine.IParameterProvider in project pentaho-platform by pentaho.
the class WsdlPageTest method testMissingPathParamProvider.
@Test
public void testMissingPathParamProvider() throws Exception {
// $NON-NLS-1$
assertNotNull("Logger is null", contentGenerator.getLogger());
Map<String, IParameterProvider> parameterProviders = Collections.<String, IParameterProvider>singletonMap(IParameterProvider.SCOPE_REQUEST, new SimpleParameterProvider());
contentGenerator.setParameterProviders(parameterProviders);
contentGenerator.createContent();
String content = new String(out.toByteArray());
assertTrue(content, content.contains(Messages.getInstance().getErrorString(// $NON-NLS-1$
"WebServiceContentGenerator.ERROR_0004_PATH_PARAMS_IS_MISSING")));
}
use of org.pentaho.platform.api.engine.IParameterProvider in project pentaho-platform by pentaho.
the class WsdlPageTest method testMissingServiceName.
@Test
public void testMissingServiceName() throws Exception {
// $NON-NLS-1$
assertNotNull("Logger is null", contentGenerator.getLogger());
Map<String, IParameterProvider> parameterProviders = new HashMap<String, IParameterProvider>();
parameterProviders.put(IParameterProvider.SCOPE_REQUEST, new SimpleParameterProvider());
// $NON-NLS-1$
parameterProviders.put("path", new SimpleParameterProvider());
contentGenerator.setParameterProviders(parameterProviders);
contentGenerator.createContent();
String content = new String(out.toByteArray());
assertTrue(content, content.contains(Messages.getInstance().getErrorString(// $NON-NLS-1$
"WebServiceContentGenerator.ERROR_0005_SERVICE_NAME_IS_MISSING")));
}
use of org.pentaho.platform.api.engine.IParameterProvider in project pentaho-platform by pentaho.
the class ContentGeneratorUtil method getContentAsString.
/**
* Convenience method for executing a content generator and getting back it's output as a string. Useful for
* testing.
*
* @param cg
* the content generator to execute
* @return the output of the content generator
* @throws Exception
* if there was a problem creating the content
*/
public static String getContentAsString(IContentGenerator cg) throws Exception {
ByteArrayOutputStream out = new ByteArrayOutputStream();
IOutputHandler outputHandler = new SimpleOutputHandler(out, false);
Map<String, IParameterProvider> parameterProviders = new HashMap<String, IParameterProvider>();
SimpleParameterProvider requestParams = new SimpleParameterProvider();
parameterProviders.put(IParameterProvider.SCOPE_REQUEST, requestParams);
// $NON-NLS-1$
SimpleUrlFactory urlFactory = new SimpleUrlFactory("?");
List<String> messages = new ArrayList<String>();
cg.setOutputHandler(outputHandler);
IMimeTypeListener mimeTypeListener = new IMimeTypeListener() {
@SuppressWarnings("unused")
public String mimeType = null;
@SuppressWarnings("unused")
public String name = null;
public void setMimeType(String mimeType) {
this.mimeType = mimeType;
}
public void setName(String name) {
this.name = name;
}
};
outputHandler.setMimeTypeListener(mimeTypeListener);
cg.setMessagesList(messages);
cg.setParameterProviders(parameterProviders);
cg.setSession(PentahoSessionHolder.getSession());
cg.setUrlFactory(urlFactory);
cg.createContent();
String content = new String(out.toByteArray());
return content;
}
use of org.pentaho.platform.api.engine.IParameterProvider in project pentaho-platform by pentaho.
the class DefaultChartBeansGenerator method runActionSequence.
/**
* Executes an action sequence from an <code>ActionSequenceDocument</code>.
*
* @param pentahoSession
* current <code>IPentahoSession</code>
* @param parameterProviders
* map of parameter providers; there should a single entry with "request" as the key
* @param outputHandler
* output handler
* @param doc
* action sequence document
* @throws RuntimeException
* if anything goes wrong
*/
protected void runActionSequence(final IPentahoSession pentahoSession, final Map<String, IParameterProvider> parameterProviders, final IOutputHandler outputHandler, final ActionSequenceDocument doc) throws RuntimeException {
// Get the solution engine
ISolutionEngine solutionEngine = PentahoSystem.get(ISolutionEngine.class, pentahoSession);
if (solutionEngine == null) {
// $NON-NLS-1$
throw new RuntimeException("solutionEngine is null");
}
solutionEngine.setLoggingLevel(ILogger.DEBUG);
solutionEngine.init(pentahoSession);
IPentahoRequestContext requestContext = PentahoRequestContextHolder.getRequestContext();
String contextPath = requestContext.getContextPath();
// $NON-NLS-1$
IPentahoUrlFactory urlFactory = new SimpleUrlFactory(contextPath);
IRuntimeContext runtime;
IParameterProvider requestParmProvider = parameterProviders.get("request");
if (requestParmProvider.hasParameter("obj_id")) {
final String obj_id = (String) requestParmProvider.getParameter("obj_id");
final String msg_name = (String) requestParmProvider.getParameter("message_name");
final String job_id = (String) requestParmProvider.getParameter("job_id");
runtime = // $NON-NLS-1$ //$NON-NLS-2$
solutionEngine.execute(// $NON-NLS-1$ //$NON-NLS-2$
doc.toString(), // $NON-NLS-1$ //$NON-NLS-2$
obj_id, // $NON-NLS-1$ //$NON-NLS-2$
job_id, // $NON-NLS-1$ //$NON-NLS-2$
false, // $NON-NLS-1$ //$NON-NLS-2$
true, msg_name, true, parameterProviders, outputHandler, null, urlFactory, // $NON-NLS-1$
new ArrayList());
} else {
runtime = // $NON-NLS-1$ //$NON-NLS-2$
solutionEngine.execute(// $NON-NLS-1$ //$NON-NLS-2$
doc.toString(), // $NON-NLS-1$ //$NON-NLS-2$
"chartbeans_mql", // $NON-NLS-1$ //$NON-NLS-2$
"myprocessid", // $NON-NLS-1$ //$NON-NLS-2$
false, // $NON-NLS-1$ //$NON-NLS-2$
true, "myinstanceid", true, parameterProviders, outputHandler, null, urlFactory, // $NON-NLS-1$
new ArrayList());
}
if ((runtime != null) && (runtime.getStatus() != IRuntimeContext.RUNTIME_STATUS_SUCCESS)) {
StringBuilder buf = new StringBuilder();
boolean firstIteration = true;
for (Object /* String */
message : runtime.getMessages()) {
if (message instanceof Exception) {
Exception ex = (Exception) message;
if (ex.getCause() instanceof RuntimeException) {
throw (RuntimeException) ex.getCause();
}
}
if (!firstIteration) {
// $NON-NLS-1$
buf.append(" \\\\ ");
}
buf.append(message);
}
String errorStr;
if (buf.indexOf("action_sequence_failed") > -1 && buf.indexOf("MQLRelationalDataComponent") > -1) {
errorStr = Messages.getInstance().getString("DefaultChartBeansGenerator.ERROR_0001_SECURITY_ERROR");
} else {
errorStr = Messages.getInstance().getString("DefaultChartBeansGenerator.ERROR_0002_UNKNOWN_ERROR");
}
throw new RuntimeException(errorStr);
}
}
use of org.pentaho.platform.api.engine.IParameterProvider in project pentaho-platform by pentaho.
the class PentahoReportConfiguration method lookupVariable.
@Override
protected String lookupVariable(final String property) {
final IApplicationContext context = PentahoSystem.getApplicationContext();
if (context != null) {
final String contextParam = context.getProperty(property);
if (contextParam != null) {
return contextParam;
}
}
final IParameterProvider globalParameters = PentahoSystem.getGlobalParameters();
if (globalParameters != null) {
final String globalParam = globalParameters.getStringParameter(property, null);
if (globalParam != null) {
return globalParam;
}
}
final String systemSetting = PentahoSystem.getSystemSetting(property, null);
if (systemSetting != null) {
return systemSetting;
}
if (context != null) {
if ("base-url".equals(property)) {
// $NON-NLS-1$
return context.getFullyQualifiedServerURL();
}
}
return null;
}
Aggregations