HttpWebService extends ServletBase { public void doGetFixMe( final HttpServletRequest request, final HttpServletResponse response ) throws ServletException, IOException { try { String actionPath = request.getParameter( "path" ); String solutionName = actionPath.substring( 0, actionPath.indexOf( '/', 1 ) ); String actionName = actionPath.substring( actionPath.lastIndexOf( '/' ) ); String actionSeqPath = ActionInfo.buildSolutionPath( solutionName, actionPath, actionName ); String component = request.getParameter( "component" ); String content = getPayloadAsString( request ); IParameterProvider parameterProvider = null; HashMap parameters = new HashMap(); if ( ( content != null ) && ( content.length() > 0 ) ) { Document doc = XmlDom4JHelper.getDocFromString( content, new PentahoEntityResolver() ); List parameterNodes = doc.selectNodes( " for ( int i = 0; i < parameterNodes.size(); i++ ) { Node parameterNode = (Node) parameterNodes.get( i ); String parameterName = parameterNode.getName(); String parameterValue = parameterNode.getText(); if ( "action".equals( parameterName ) ) { ActionInfo info = ActionInfo.parseActionString( parameterValue ); solutionName = info.getSolutionName(); actionPath = info.getPath(); actionName = info.getActionName(); } else if ( "component".equals( parameterName ) ) { component = parameterValue; } else { parameters.put( parameterName, parameterValue ); } } parameterProvider = new SimpleParameterProvider( parameters ); } else { parameterProvider = new HttpRequestParameterProvider( request ); } response.setContentType( "text/xml" ); response.setCharacterEncoding( LocaleHelper.getSystemEncoding() ); IPentahoSession userSession = getPentahoSession( request ); String instanceId = request.getParameter( "instance-id" ); String processId = this.getClass().getName(); OutputStream contentStream = new ByteArrayOutputStream(); SimpleOutputHandler outputHandler = new SimpleOutputHandler( contentStream, false ); OutputStream outputStream = response.getOutputStream(); if ( ( component == null ) || "action".equals( component ) ) { HttpWebServiceRequestHandler requestHandler = new HttpWebServiceRequestHandler( userSession, null, outputHandler, parameterProvider, null ); requestHandler.setParameterProvider( IParameterProvider.SCOPE_SESSION, new HttpSessionParameterProvider( userSession ) ); requestHandler.setInstanceId( instanceId ); requestHandler.setProcessId( processId ); requestHandler.setActionPath( actionSeqPath ); if ( ServletBase.debug ) { debug( Messages.getInstance().getString( "HttpWebService.DEBUG_WEB_SERVICE_START" ) ); } IRuntimeContext runtime = null; try { runtime = requestHandler.handleActionRequest( 0, 0 ); Document responseDoc = SoapHelper.createSoapResponseDocument( runtime, outputHandler, contentStream, requestHandler .getMessages() ); XmlDom4JHelper.saveDom( responseDoc, outputStream, PentahoSystem.getSystemSetting( "web-service-encoding", "utf-8" ), true ); } finally { if ( runtime != null ) { runtime.dispose(); } } } else if ( "dial".equals( component ) ) { doDial( solutionName, actionPath, actionName, parameterProvider, outputStream, userSession ); } else if ( "chart".equals( component ) ) { doChart( actionPath, parameterProvider, outputStream, userSession ); } else if ( "xaction-parameter".equals( component ) ) { doParameter( solutionName, actionPath, actionName, parameterProvider, outputStream, userSession, response ); } } catch ( Throwable t ) { error( Messages.getInstance().getErrorString( "HttpWebService.ERROR_0001_ERROR_DURING_WEB_SERVICE" ), t ); } if ( ServletBase.debug ) { debug( Messages.getInstance().getString( "HttpWebService.DEBUG_WEB_SERVICE_END" ) ); } } HttpWebService(); @Override Log getLogger(); String getPayloadAsString( final HttpServletRequest request ); void doGetFixMe( final HttpServletRequest request, final HttpServletResponse response ); @Override void doGet( final HttpServletRequest request, final HttpServletResponse response );  }
@Test public void testDoGetFixMe_nullComponent() throws Exception { when( request.getReader() ).thenReturn( reader ); when( request.getParameter( "path" ) ).thenReturn( "solutionName/actionName" ); when( request.getParameter( "component" ) ).thenReturn( null ); HttpWebService service = spy( httpWebService ); service.doGetFixMe( request, response ); }