use of org.pentaho.platform.api.engine.IContentGenerator in project pentaho-platform by pentaho.
the class PentahoSystemPluginManager method getContentGenerator.
@Override
public IContentGenerator getContentGenerator(String type, String perspectiveName) {
IContentGenerator cg = null;
String beanId;
if (perspectiveName == null || perspectiveName.equals(DEFAULT_PERSPECTIVE)) {
beanId = type;
} else {
beanId = type + "." + perspectiveName;
}
IContentGenerator contentGenerator = PentahoSystem.get(IContentGenerator.class, PentahoSessionHolder.getSession(), Collections.singletonMap(CONTENT_TYPE, beanId));
if (contentGenerator == null) {
contentGenerator = PentahoSystem.get(IContentGenerator.class, PentahoSessionHolder.getSession(), Collections.singletonMap(CONTENT_TYPE, perspectiveName));
}
return contentGenerator;
}
use of org.pentaho.platform.api.engine.IContentGenerator in project pentaho-platform by pentaho.
the class AxisWebServiceManagerIT method testMetaInf.
@Test
public void testMetaInf() throws Exception {
IContentGenerator serviceLister = new StyledHtmlAxisServiceLister();
String html = ContentGeneratorUtil.getContentAsString(serviceLister);
System.out.println(html);
assertTrue("title is not displayed", html.contains("junit echo service"));
}
use of org.pentaho.platform.api.engine.IContentGenerator in project pentaho-platform by pentaho.
the class AxisWebServiceManagerIT method testExecuteUrlListed.
/*
* The following tests are checking that the HtmlServiceLister (content generator) outputs the correct meta
* information about the services defined in the test plugin. They are integration tests in the sense that all the
* work of registering the plugin that defines the services and content generators is done by actual platform modules
* as it would normally happen, and is not mocked for these tests.
*/
@Test
public void testExecuteUrlListed() throws Exception {
IContentGenerator serviceLister = new StyledHtmlAxisServiceLister();
String html = ContentGeneratorUtil.getContentAsString(serviceLister);
System.out.println(html);
assertTrue("Run URL is missing", html.contains("/content/ws-run/echoService"));
}
use of org.pentaho.platform.api.engine.IContentGenerator in project pentaho-platform by pentaho.
the class AxisWebServiceManagerIT method testWsdlUrlListed.
@Test
public void testWsdlUrlListed() throws Exception {
IContentGenerator serviceLister = new StyledHtmlAxisServiceLister();
String html = ContentGeneratorUtil.getContentAsString(serviceLister);
System.out.println(html);
assertTrue("WSDL URL is missing", html.contains("/content/ws-wsdl/echoService"));
}
use of org.pentaho.platform.api.engine.IContentGenerator in project pentaho-platform by pentaho.
the class FileResource method doIsParameterizable.
/**
* Determines whether a selected file supports parameters or not
*
* @param pathId Colon separated path for the repository file.
*
* @return ("true" or "false")
* @throws FileNotFoundException
*/
@GET
@Path("{pathId : .+}/parameterizable")
@Produces(MediaType.TEXT_PLAIN)
@Facet(name = "Unsupported")
@StatusCodes({ @ResponseCode(code = 200, condition = "Successfully get the file or directory."), @ResponseCode(code = 404, condition = "Failed to find the file or resource.") })
public // have to accept anything for browsers to work
String doIsParameterizable(@PathParam("pathId") String pathId) throws FileNotFoundException {
boolean hasParameterUi = false;
RepositoryFile repositoryFile = getRepository().getFile(fileService.idToPath(pathId));
if (repositoryFile != null) {
try {
hasParameterUi = hasParameterUi(repositoryFile);
} catch (NoSuchBeanDefinitionException e) {
// Do nothing.
}
}
boolean hasParameters = false;
if (hasParameterUi) {
try {
IContentGenerator parameterContentGenerator = getContentGenerator(repositoryFile);
if (parameterContentGenerator != null) {
ByteArrayOutputStream outputStream = getByteArrayOutputStream();
parameterContentGenerator.setOutputHandler(new SimpleOutputHandler(outputStream, false));
parameterContentGenerator.setMessagesList(new ArrayList<String>());
Map<String, IParameterProvider> parameterProviders = new HashMap<String, IParameterProvider>();
SimpleParameterProvider parameterProvider = getSimpleParameterProvider();
parameterProvider.setParameter("path", encode(repositoryFile.getPath()));
parameterProvider.setParameter("renderMode", "PARAMETER");
parameterProviders.put(IParameterProvider.SCOPE_REQUEST, parameterProvider);
parameterContentGenerator.setParameterProviders(parameterProviders);
parameterContentGenerator.setSession(getSession());
parameterContentGenerator.createContent();
if (outputStream.size() > 0) {
Document document = parseText(outputStream.toString());
// exclude all parameters that are of type "system", xactions set system params that have to be ignored.
@SuppressWarnings("rawtypes") List nodes = document.selectNodes("parameters/parameter");
for (int i = 0; i < nodes.size() && !hasParameters; i++) {
Element elem = (Element) nodes.get(i);
if (elem.attributeValue("name").equalsIgnoreCase("output-target") && elem.attributeValue("is-mandatory").equalsIgnoreCase("true")) {
hasParameters = true;
continue;
}
Element attrib = (Element) elem.selectSingleNode("attribute[@namespace='http://reporting.pentaho" + ".org/namespaces/engine/parameter-attributes/core' and @name='role']");
if (attrib == null || !"system".equals(attrib.attributeValue("value"))) {
hasParameters = true;
}
}
}
}
} catch (Exception e) {
logger.error(getMessagesInstance().getString("FileResource.PARAM_FAILURE", e.getMessage()), e);
}
}
return Boolean.toString(hasParameters);
}
Aggregations