Package org.pentaho.cdf

Source Code of org.pentaho.cdf.ServiceCallAction

package org.pentaho.cdf;

import java.io.OutputStream;
import java.util.HashMap;
import java.util.Iterator;
import org.pentaho.platform.api.engine.IParameterProvider;
import org.pentaho.platform.api.engine.IPentahoSession;
import org.pentaho.platform.api.engine.IRuntimeContext;
import org.pentaho.platform.api.engine.ISolutionEngine;
import org.pentaho.platform.engine.services.solution.SolutionHelper;

public class ServiceCallAction  {

  private static ServiceCallAction serviceCallAction = new ServiceCallAction();
 
  static ServiceCallAction getInstance() {
    return serviceCallAction;
  }
 
 
  @SuppressWarnings("unchecked")
  public boolean execute(IParameterProvider requestParams,IPentahoSession userSession, OutputStream out){
   
   
    String solutionName = requestParams.getStringParameter("solution","");
      String actionPath = requestParams.getStringParameter("path","");
      String actionName = requestParams.getStringParameter("action","");
      actionPath = actionPath.startsWith("/") || solutionName.endsWith("/") ? actionPath : "/" + actionPath;
      actionPath = actionPath.endsWith("/") || actionName.startsWith("/") ? actionPath : actionPath + "/";
     

      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));
      }
     
      ISolutionEngine engine = SolutionHelper.execute("executeAction", userSession, solutionName + actionPath + actionName, parameters, out);
      int status = engine.getExecutionContext().getStatus();
     
      return status == IRuntimeContext.RUNTIME_STATUS_SUCCESS;
       
  }

}
TOP

Related Classes of org.pentaho.cdf.ServiceCallAction

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.