Search in sources :

Example 16 with IParameterProvider

use of org.pentaho.platform.api.engine.IParameterProvider in project pentaho-platform by pentaho.

the class BaseUIComponent method getParameter.

public String getParameter(final String name, final String defaultValue) {
    // $NON-NLS-1$
    IParameterProvider parameterProvider = (IParameterProvider) parameterProviders.get("options");
    String value = null;
    if (parameterProvider != null) {
        value = parameterProvider.getStringParameter(name, null);
        if (value != null) {
            return value;
        }
    }
    parameterProvider = (IParameterProvider) parameterProviders.get(IParameterProvider.SCOPE_REQUEST);
    if (parameterProvider != null) {
        value = parameterProvider.getStringParameter(name, null);
        if (value != null) {
            return value;
        }
    }
    if (parameterProvider != null) {
        value = parameterProvider.getStringParameter(name, null);
        if (value != null) {
            return value;
        }
    }
    return defaultValue;
}
Also used : IParameterProvider(org.pentaho.platform.api.engine.IParameterProvider)

Example 17 with IParameterProvider

use of org.pentaho.platform.api.engine.IParameterProvider in project pentaho-platform by pentaho.

the class AxisServiceExecutor method createServiceContent.

@Override
public void createServiceContent(AxisService axisService, String operationName, AxisConfiguration axisConfiguration, ConfigurationContext context, OutputStream out) throws Exception {
    // $NON-NLS-1$
    IParameterProvider pathParams = parameterProviders.get("path");
    // get the HTTP objects from the 'path' parameter provider
    // $NON-NLS-1$
    HttpServletRequest request = (HttpServletRequest) pathParams.getParameter("httprequest");
    @SuppressWarnings("unchecked") Enumeration names = request.getParameterNames();
    while (names.hasMoreElements()) {
        String name = (String) names.nextElement();
        if (name.equalsIgnoreCase("wsdl")) {
            // $NON-NLS-1$
            axisService.printWSDL(out, AxisUtil.getWebServiceExecuteUrl());
            return;
        }
    }
    // $NON-NLS-1$
    HttpServletResponse response = (HttpServletResponse) pathParams.getParameter("httpresponse");
    // $NON-NLS-1$
    ServletConfig servletConfig = (ServletConfig) pathParams.getParameter("servletconfig");
    // create a service group and group context for this service
    AxisServiceGroup axisServiceGroup = new AxisServiceGroup(context.getAxisConfiguration());
    axisServiceGroup.addService(axisService);
    ServiceGroupContext serviceGroupContext = new ServiceGroupContext(context, axisServiceGroup);
    // create a service context
    ServiceContext serviceContext = serviceGroupContext.getServiceContext(axisService);
    // get an operation by name, if possible
    AxisOperation axisOperation = axisService.getOperationByAction(operationName);
    OperationContext operationContext = serviceContext.createOperationContext(axisOperation);
    // create an object to hook into Axis and give it everything we have
    AxisServletHooks hooks = new AxisServletHooks();
    hooks.setContext(context);
    hooks.setServletConfig(servletConfig);
    hooks.setConfiguration(axisConfiguration);
    hooks.initContextRoot(request);
    hooks.setAxisService(axisService);
    hooks.setAxisOperation(axisOperation);
    hooks.setOperationContext(operationContext);
    hooks.setServiceContext(serviceContext);
    hooks.setAxisOperation(axisOperation);
    hooks.setOperationContext(operationContext);
    // now execute the operation
    if (request != null && response != null) {
        try {
            PentahoSessionHolder.setSession(userSession);
            String method = request.getMethod();
            if ("GET".equalsIgnoreCase(method)) {
                // $NON-NLS-1$
                hooks.handleGet(method, request, response);
            } else if ("POST".equalsIgnoreCase(request.getMethod())) {
                // $NON-NLS-1$
                hooks.handlePost(method, request, response);
            } else if ("PUT".equalsIgnoreCase(request.getMethod())) {
                // $NON-NLS-1$
                hooks.handlePut(method, request, response);
            }
        } catch (Exception e) {
            processAxisFault(hooks.getMessageContext(), out, e);
            // $NON-NLS-1$
            error(Messages.getInstance().getErrorString("RunService.ERROR_0001_ERROR_DURING_EXECUTION"), e);
        }
    }
}
Also used : OperationContext(org.apache.axis2.context.OperationContext) Enumeration(java.util.Enumeration) AxisOperation(org.apache.axis2.description.AxisOperation) ServiceContext(org.apache.axis2.context.ServiceContext) ServletConfig(javax.servlet.ServletConfig) HttpServletResponse(javax.servlet.http.HttpServletResponse) AxisServiceGroup(org.apache.axis2.description.AxisServiceGroup) HttpServletRequest(javax.servlet.http.HttpServletRequest) IParameterProvider(org.pentaho.platform.api.engine.IParameterProvider) ServiceGroupContext(org.apache.axis2.context.ServiceGroupContext) AxisServletHooks(org.pentaho.platform.plugin.services.webservices.AxisServletHooks)

Example 18 with IParameterProvider

use of org.pentaho.platform.api.engine.IParameterProvider in project pentaho-platform by pentaho.

the class ActionSequenceContentGenerator method getMimeType.

public String getMimeType() {
    IParameterProvider requestParams = getRequestParameters();
    IParameterProvider pathParams = getPathParameters();
    if ((requestParams != null) && (requestParams.getStringParameter("contentType", null) != null)) {
        // $NON-NLS-1$
        // $NON-NLS-1$
        contentType = requestParams.getStringParameter("contentType", TEXT_HTML);
    } else if ((pathParams != null) && (pathParams.getStringParameter("contentType", null) != null)) {
        // $NON-NLS-1$
        // $NON-NLS-1$
        contentType = pathParams.getStringParameter("contentType", TEXT_HTML);
    }
    return contentType;
}
Also used : IParameterProvider(org.pentaho.platform.api.engine.IParameterProvider)

Example 19 with IParameterProvider

use of org.pentaho.platform.api.engine.IParameterProvider in project pentaho-platform by pentaho.

the class ActionSequenceParameterContentGenerator method getPathParameters.

@SuppressWarnings("unchecked")
public IParameterProvider getPathParameters() {
    if (this.pathParameters != null) {
        return this.pathParameters;
    }
    // $NON-NLS-1$
    IParameterProvider pathParams = this.parameterProviders.get("path");
    SimpleParameterSetter parameters = new SimpleParameterSetter();
    if (pathParams != null) {
        Iterator pathParamIterator = pathParams.getParameterNames();
        while (pathParamIterator.hasNext()) {
            String param = (String) pathParamIterator.next();
            parameters.setParameter(param, pathParams.getParameter(param));
        }
    }
    this.pathParameters = parameters;
    return parameters;
}
Also used : IParameterProvider(org.pentaho.platform.api.engine.IParameterProvider) SimpleParameterSetter(org.pentaho.platform.engine.services.solution.SimpleParameterSetter) Iterator(java.util.Iterator)

Example 20 with IParameterProvider

use of org.pentaho.platform.api.engine.IParameterProvider in project pentaho-platform by pentaho.

the class ActionSequenceParameterContentGenerator method getRequestParameters.

@SuppressWarnings("unchecked")
private IParameterProvider getRequestParameters() {
    if (this.requestParameters != null) {
        return this.requestParameters;
    }
    if (this.parameterProviders == null) {
        return new SimpleParameterProvider();
    }
    // $NON-NLS-1$
    IParameterProvider requestParams = this.parameterProviders.get("request");
    SimpleParameterSetter parameters = new SimpleParameterSetter();
    Iterator requestParamIterator = requestParams.getParameterNames();
    while (requestParamIterator.hasNext()) {
        String param = (String) requestParamIterator.next();
        parameters.setParameter(param, requestParams.getParameter(param));
    }
    this.requestParameters = parameters;
    return parameters;
}
Also used : IParameterProvider(org.pentaho.platform.api.engine.IParameterProvider) SimpleParameterSetter(org.pentaho.platform.engine.services.solution.SimpleParameterSetter) Iterator(java.util.Iterator) SimpleParameterProvider(org.pentaho.platform.engine.core.solution.SimpleParameterProvider)

Aggregations

IParameterProvider (org.pentaho.platform.api.engine.IParameterProvider)57 HashMap (java.util.HashMap)27 SimpleParameterProvider (org.pentaho.platform.engine.core.solution.SimpleParameterProvider)21 ArrayList (java.util.ArrayList)14 List (java.util.List)11 Test (org.junit.Test)11 SimpleUrlFactory (org.pentaho.platform.util.web.SimpleUrlFactory)11 ByteArrayOutputStream (java.io.ByteArrayOutputStream)10 IOException (java.io.IOException)9 Iterator (java.util.Iterator)8 SimpleOutputHandler (org.pentaho.platform.engine.core.output.SimpleOutputHandler)8 HttpRequestParameterProvider (org.pentaho.platform.web.http.request.HttpRequestParameterProvider)8 MockHttpServletRequest (com.mockrunner.mock.web.MockHttpServletRequest)7 MockHttpServletResponse (com.mockrunner.mock.web.MockHttpServletResponse)7 IOutputHandler (org.pentaho.platform.api.engine.IOutputHandler)6 IPentahoSession (org.pentaho.platform.api.engine.IPentahoSession)6 IRuntimeContext (org.pentaho.platform.api.engine.IRuntimeContext)6 RepositoryFile (org.pentaho.platform.api.repository2.unified.RepositoryFile)6 SimpleParameterSetter (org.pentaho.platform.engine.services.solution.SimpleParameterSetter)6 OutputStream (java.io.OutputStream)5