use of org.pentaho.platform.api.util.IPdiContentProvider in project pdi-platform-plugin by pentaho.
the class UserParametersTest method testJobUserParameters.
@Test
public void testJobUserParameters() throws Exception {
PdiAction action = new PdiAction();
action.setRepositoryName(KettleFileRepositoryMeta.REPOSITORY_TYPE_ID);
action.setArguments(new String[] { "dummyArg" });
action.setDirectory(SOLUTION_REPOSITORY);
action.setJob(SAMPLE_JOB);
action.execute();
Assert.isTrue(action.localJob != null && action.localJob.getJobMeta() != null);
NamedParams np = action.localJob.getJobMeta();
boolean protectedParameterNameExistsInKjb = false;
for (String param : np.listParameters()) {
protectedParameterNameExistsInKjb |= param != null && param.equals(SAMPLE_PROTECTED_PARAMETER_NAME);
}
// we make sure: this kjb does indeed have a system/hidden parameter
Assert.isTrue(protectedParameterNameExistsInKjb);
// reset attribute
protectedParameterNameExistsInKjb = false;
// we now call IPdiContentProvider.getUserParameters( kjb ), that should filter out protected parameters
IPdiContentProvider pdiContentProvider = new PdiContentProvider(PentahoSystem.get(IUnifiedRepository.class));
String[] userParams = pdiContentProvider.getUserParameters(SOLUTION_REPOSITORY + SAMPLE_JOB + ".kjb");
for (String userParam : userParams) {
protectedParameterNameExistsInKjb |= userParam != null && userParam.equals(SAMPLE_PROTECTED_PARAMETER_NAME);
}
// we make sure: IPdiContentProvider has filtered it out
Assert.isTrue(!protectedParameterNameExistsInKjb);
}
use of org.pentaho.platform.api.util.IPdiContentProvider in project pdi-platform-plugin by pentaho.
the class ParameterContentGenerator method createContent.
@Override
public void createContent(OutputStream out) throws Exception {
IParameterProvider pathParams = parameterProviders.get(PATH);
IParameterProvider requestParams = parameterProviders.get(IParameterProvider.SCOPE_REQUEST);
RepositoryFile file = null;
if (pathParams != null) {
file = (RepositoryFile) pathParams.getParameter(FILE);
} else {
IUnifiedRepository repo = PentahoSystem.get(IUnifiedRepository.class, null);
String path = URLDecoder.decode(requestParams.getStringParameter(PATH, StringUtils.EMPTY), LocaleHelper.UTF_8);
file = repo.getFile(idTopath(path));
}
IPdiContentProvider provider = (IPdiContentProvider) PentahoSystem.get(IPluginManager.class).getBean(IPdiContentProvider.class.getSimpleName());
String[] userParams = provider.getUserParameters(file.getPath());
ParametersBean paramBean = new ParametersBean(userParams, requestParameterToStringMap(requestParams));
String response = paramBean.getParametersXmlString();
out.write(response.getBytes(LocaleHelper.getSystemEncoding()));
out.flush();
}
use of org.pentaho.platform.api.util.IPdiContentProvider in project pdi-platform-plugin by pentaho.
the class UserParametersTest method testTransformationUserParameters.
@Test
public void testTransformationUserParameters() throws Exception {
PdiAction action = new PdiAction();
action.setRepositoryName(KettleFileRepositoryMeta.REPOSITORY_TYPE_ID);
action.setArguments(new String[] { "dummyArg" });
action.setDirectory(SOLUTION_REPOSITORY);
action.setTransformation(SAMPLE_TRANS);
action.execute();
Assert.isTrue(action.localTrans != null && action.localTrans.getTransMeta() != null);
NamedParams np = action.localTrans.getTransMeta();
boolean protectedParameterNameExistsInKtr = false;
for (String param : np.listParameters()) {
protectedParameterNameExistsInKtr |= param != null && param.equals(SAMPLE_PROTECTED_PARAMETER_NAME);
}
// we make sure: this ktr does indeed have a system/hidden parameter
Assert.isTrue(protectedParameterNameExistsInKtr);
// reset attribute
protectedParameterNameExistsInKtr = false;
// we now call IPdiContentProvider.getUserParameters( kjb ), that should filter out protected parameters
IPdiContentProvider pdiContentProvider = new PdiContentProvider(PentahoSystem.get(IUnifiedRepository.class));
String[] userParams = pdiContentProvider.getUserParameters(SOLUTION_REPOSITORY + SAMPLE_TRANS + ".ktr");
for (String userParam : userParams) {
protectedParameterNameExistsInKtr |= userParam != null && userParam.equals(SAMPLE_PROTECTED_PARAMETER_NAME);
}
// we make sure: IPdiContentProvider has filtered it out
Assert.isTrue(!protectedParameterNameExistsInKtr);
}
Aggregations