Skip to content
Browse files

- More work on UI

- Added images
- Added CPF
- Initial content generator support
  • Loading branch information...
1 parent 44dd43b commit ebc32aab4b33fc7877da7d4835f6ef9dfe44be40 Pedro Alves committed Feb 28, 2012
View
1 .gitignore
@@ -2,6 +2,7 @@
####################
bin
dist
+/build
/lib
test-lib
dev-lib
View
4 ivy.xml
@@ -23,6 +23,8 @@
<dependency org="commons-codec" name="commons-codec" rev="1.3"/>
<dependency org="net.sf.flexjson" name="flexjson" rev="2.1" transitive="false" conf="default->default"/>
<dependency org="org.springframework.security" name="spring-security-core" rev="2.0.5.RELEASE" transitive="false"/>
+ <dependency org="javax.servlet" name="servlet-api" rev="2.4" />
+
<!-- Pentaho dependencies -->
<dependency org="pentaho" name="pentaho-bi-platform-api" rev="${dependency.bi-platform.revision}" changing="true" transitive="false"/>
@@ -33,7 +35,7 @@
<dependency org="pentaho" name="pentaho-bi-platform-plugin-actions" rev="${dependency.bi-platform.revision}" changing="true" transitive="false"/>
<dependency org="pentaho" name="pentaho-bi-platform-plugin-services" rev="${dependency.bi-platform.revision}" changing="true" transitive="false"/>
<dependency org="pentaho" name="pentaho-bi-platform-web" rev="${dependency.bi-platform.revision}" changing="true" transitive="false"/>
-
+
<dependency org="pentaho-kettle" name="kettle-db" rev="${dependency.kettle.revision}" changing="true"/>
<dependency org="pentaho-kettle" name="kettle-core" rev="${dependency.kettle.revision}" changing="true"/>
<dependency org="pentaho-kettle" name="kettle-engine" rev="${dependency.kettle.revision}" changing="true"/>
View
2 nbproject/project.properties
@@ -47,6 +47,7 @@ file.reference.pentaho-bi-platform-plugin-actions-3.9.0-stable.jar=lib/pentaho-b
file.reference.pentaho-bi-platform-plugin-services-3.9.0-stable.jar=lib/pentaho-bi-platform-plugin-services-3.9.0-stable.jar
file.reference.pentaho-bi-platform-util-3.9.0-stable.jar=lib/pentaho-bi-platform-util-3.9.0-stable.jar
file.reference.pentaho-bi-platform-web-3.9.0-stable.jar=lib/pentaho-bi-platform-web-3.9.0-stable.jar
+file.reference.servlet-api-2.4.jar=lib/servlet-api-2.4.jar
file.reference.spring-security-core-2.0.5.RELEASE.jar=lib/spring-security-core-2.0.5.RELEASE.jar
file.reference.xercesImpl-2.9.1.jar=lib/xercesImpl-2.9.1.jar
file.reference.xml-apis-1.3.04.jar=lib/xml-apis-1.3.04.jar
@@ -70,6 +71,7 @@ javac.classpath=\
${file.reference.pentaho-bi-platform-plugin-services-3.9.0-stable.jar}:\
${file.reference.pentaho-bi-platform-util-3.9.0-stable.jar}:\
${file.reference.pentaho-bi-platform-web-3.9.0-stable.jar}:\
+ ${file.reference.servlet-api-2.4.jar}:\
${file.reference.spring-security-core-2.0.5.RELEASE.jar}:\
${file.reference.xercesImpl-2.9.1.jar}:\
${file.reference.xml-apis-1.3.04.jar}
View
20 package-res/plugin.xml
@@ -1,18 +1,24 @@
<?xml version="1.0" encoding="UTF-8"?>
<plugin title="Pentaho Marketplace">
- <static-paths>
- <static-path url="/marketplace/resources" localFolder="resources"/>
- </static-paths>
+ <static-paths>
+ <static-path url="/marketplace/resources" localFolder="resources"/>
+ </static-paths>
<!-- Menu entry -->
- <menu-items>
- <menu-item id="cda_refresh" anchor="tools-submenu" label="Marketplace" command="content/marketplace/resources/marketplace.html" type="MENU_ITEM" how="LAST_CHILD"/>
- </menu-items>
+ <menu-items>
+ <menu-item id="cda_refresh" anchor="tools-submenu" label="Marketplace" command="content/marketplace/resources/marketplace.html" type="MENU_ITEM" how="LAST_CHILD"/>
+ </menu-items>
- <webservice
+ <webservice
id="MarketplaceService"
type="xml"
class="org.pentaho.marketplace.MarketplaceService"/>
+
+ <content-generator scope="local" id="marketplace" type="MarketplaceContentGenerator" url="">
+ <classname>org.pentaho.marketplace.MarketplaceContentGenerator</classname>
+ <title>Marketplace</title>
+ </content-generator>
+
</plugin>
View
58 package-res/resources/PentahoMarketplacePlugins.xml
@@ -0,0 +1,58 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<availablePlugins>
+ <plugin id="cde">
+ <img>wt_transparent.png</img>
+ <name>Community Dashboard Editor</name>
+ <learnMoreUrl>http://cde.webdetails.org</learnMoreUrl>
+ <downloadUrl>http://www.webdetails.pt/ficheiros/CDE-bundle-1.0-RC3.tar.bz2</downloadUrl>
+ <availableVersion>1.0-RC3</availableVersion>
+ <description>The Community Dashboard Editor (CDE) is the outcome of real-world needs: It was born to greatly simplify the creation, edition and rendering of dashboards.
+
+CDE and the technology underneath (CDF, CDA and CCC) allows to develop and deploy dashboards in the Pentaho platform in a fast and effective way.
+ </description>
+ <company>WebDetails</company>
+ <companyUrl>http://webdetails.pt</companyUrl>
+ <alternativeVersions>
+ <alternativeVersion id='RC'>
+ <name>Release Candidate</name>
+ <downloadUrl>http://www.webdetails.pt/RC/ficheiros/CDE-bundle-1.0-RC3.tar.bz2</downloadUrl>
+ <samplesDownloadUrl>http://www.webdetails.pt/RC/ficheiros/CDE-bundle-1.0-RC3-samples.tar.bz2</samplesDownloadUrl>
+ <description>This is RC1 - pretty cool version but still not quite there</description>
+ </alternativeVersion>
+ <alternativeVersion id='TRUNK'>
+ <name>Trunk</name>
+ <downloadUrl>http://www.webdetails.pt/TRUNK/ficheiros/CDE-bundle-1.0-RC3.tar.bz2</downloadUrl>
+ <samplesDownloadUrl>http://www.webdetails.pt/TRUNK/ficheiros/CDE-bundle-1.0-RC3.tar.bz2</samplesDownloadUrl>
+ <description>Trunk Snapshot. Install at your own risk....</description>
+ </alternativeVersion>
+ </alternativeVersions>
+ </plugin>
+ <plugin id="cda">
+ <img>wt_transparent.png</img>
+ <name>Community Data Access</name>
+ <learnMoreUrl>http://cda.webdetails.org</learnMoreUrl>
+ <downloadUrl>http://localhost:8080/cda-1.0.zip</downloadUrl>
+ <downloadUrl2>http://www.webdetails.pt/ficheiros/cda-installer-v1.0.jar</downloadUrl2>
+ <availableVersion>1.0</availableVersion>
+ <description>Community Data Access (CDA) is a Pentaho plugin designed for accessing data with great flexibility. Born for overcoming some cons of the older implementation, CDA allows you to access any of the various Pentaho data sources. </description>
+ <company>WebDetails</company>
+ <companyUrl>http://webdetails.pt</companyUrl>
+ </plugin>
+
+ <plugin id="cdf">
+ <img>wt_transparent.png</img>
+ <name>Community Dashboards Framework</name>
+ <learnMoreUrl>http://cdf.webdetails.org</learnMoreUrl>
+ <downloadUrl>http://localhost:8080/cdf-1.0.zip</downloadUrl>
+ <downloadUrl2>http://www.webdetails.pt/ficheiros/cdf-installer-v1.0.jar</downloadUrl2>
+ <samplesDownloadUrl>http://localhost:8080/cdf-1.0.samples.zip</samplesDownloadUrl>
+ <availableVersion>1.0</availableVersion>
+ <changelog>Changelog</changelog>
+ <installationNotes>Notes after install</installationNotes>
+ <description>Community Dashboards Framework (CDF) is a Pentaho plugin designed for drawing dashboards.</description>
+ <company>WebDetails</company>
+ <companyUrl>http://webdetails.pt</companyUrl>
+ </plugin>
+
+
+</availablePlugins>
View
BIN package-res/resources/img/updateAvailable.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN package-res/resources/img/updatedVersion.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
57 src/org/pentaho/marketplace/MarketplaceContentGenerator.java
@@ -0,0 +1,57 @@
+/*
+ * To change this template, choose Tools | Templates
+ * and open the template in the editor.
+ */
+package org.pentaho.marketplace;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import javax.servlet.http.HttpServletResponse;
+import org.pentaho.platform.api.engine.ServiceException;
+import org.pentaho.platform.engine.core.system.PentahoSystem;
+import pt.webdetails.cpf.SimpleContentGenerator;
+import pt.webdetails.cpf.annotations.AccessLevel;
+import pt.webdetails.cpf.annotations.Exposed;
+
+/**
+ *
+ * @author pedro
+ */
+public class MarketplaceContentGenerator extends SimpleContentGenerator {
+
+ private static final long serialVersionUID = 1L;
+ public static final String ENCODING = "utf-8";
+ private static final String MIME_JSON = "application/json";
+
+ protected MarketplaceService getMarketplaceService() throws ServiceException {
+
+
+ return ((MarketplaceService) PentahoSystem.get(org.pentaho.platform.api.engine.IServiceManager.class).getServiceBean("xml", "MarketplaceService"));
+
+ }
+
+ @Exposed(accessLevel = AccessLevel.PUBLIC)
+ public void test(OutputStream out) throws IOException {
+
+ out.write("{test:123}".getBytes(ENCODING));
+ setResponseHeaders(MIME_JSON, null);
+
+ }
+
+ private void setResponseHeaders(final String mimeType, final String attachmentName) {
+ // Make sure we have the correct mime type
+ final HttpServletResponse response = (HttpServletResponse) parameterProviders.get("path").getParameter("httpresponse");
+ if (response == null) {
+ return;
+ }
+
+ response.setHeader("Content-Type", mimeType);
+
+ if (attachmentName != null) {
+ response.setHeader("content-disposition", "attachment; filename=" + attachmentName);
+ }
+
+ // We can't cache this request
+ response.setHeader("Cache-Control", "max-age=0, no-store");
+ }
+}
View
147 src/pt/webdetails/cpf/InterPluginComms.java
@@ -0,0 +1,147 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+package pt.webdetails.cpf;
+
+import java.io.ByteArrayOutputStream;
+import java.io.OutputStream;
+import java.util.HashMap;
+import java.util.Map;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.pentaho.platform.api.engine.IContentGenerator;
+import org.pentaho.platform.api.engine.IOutputHandler;
+import org.pentaho.platform.api.engine.IParameterProvider;
+import org.pentaho.platform.api.engine.IPentahoSession;
+import org.pentaho.platform.api.engine.IPluginManager;
+import org.pentaho.platform.engine.core.output.SimpleOutputHandler;
+import org.pentaho.platform.engine.core.solution.SimpleParameterProvider;
+import org.pentaho.platform.engine.core.system.PentahoSessionHolder;
+import org.pentaho.platform.engine.core.system.PentahoSystem;
+
+/**
+ *
+ * @author pdpi
+ */
+public class InterPluginComms
+{
+
+
+ public static class Plugin {
+
+ public final static Plugin CDA = new Plugin("cda", "cda");
+ public final static Plugin CDE = new Plugin("pentaho-cdf-dd", "pentaho-cdf-dd");
+ public final static Plugin CDC = new Plugin("cdc", "cdc");
+ public final static Plugin CDF = new Plugin("pentaho-cdf", "Pentaho Community Dashboard Framework");
+
+ private String name;
+ private String title;
+
+ public String getName() {
+ return name;
+ }
+
+ public String getTitle() {
+ return title;
+ }
+
+ public Plugin(String name, String title){
+ this.name = name;
+ this.title = title;
+ }
+
+ }
+
+ private static final Log logger = LogFactory.getLog(InterPluginComms.class);
+
+ public static String callPlugin(Plugin plugin, String method, Map<String, Object> params){
+ return callPlugin(plugin, method, params, false);
+ }
+
+ public static String callPlugin(Plugin plugin, String method, Map<String, Object> params, boolean switchClassLoader)
+ {
+ IParameterProvider requestParams = new SimpleParameterProvider(params);
+ return callPlugin(plugin, method, requestParams, switchClassLoader);
+
+ }
+
+ public static String callPlugin(Plugin plugin, String method, IParameterProvider params, boolean switchClassLoader)
+ {
+
+ IPentahoSession userSession = PentahoSessionHolder.getSession();
+ IPluginManager pluginManager = PentahoSystem.get(IPluginManager.class, userSession);
+ IContentGenerator contentGenerator;
+ try
+ {
+ contentGenerator = pluginManager.getContentGenerator(plugin.getName(), userSession);
+ }
+ catch (Exception e)
+ {
+ logger.error("Failed to acquire " + plugin.getName() + " plugin: " + e.toString());
+ return null;
+ }
+ if(contentGenerator == null){
+ logger.error("Failed to acquire " + plugin.getName() + " plugin.");
+ return null;
+ }
+
+ if(switchClassLoader){
+ ClassLoader currentClassLoader = Thread.currentThread().getContextClassLoader();
+ try{
+ ClassLoader pluginClassLoader = pluginManager.getClassLoader(plugin.getTitle());
+
+ if(pluginClassLoader != null) Thread.currentThread().setContextClassLoader(pluginClassLoader);
+ else logger.error("Couldn't fetch PluginClassLoader for " + plugin.getTitle());
+
+ return callPlugin(userSession, contentGenerator, method, params);
+ }
+ finally{
+ Thread.currentThread().setContextClassLoader(currentClassLoader);
+ }
+ }
+ else {
+ return callPlugin(userSession, contentGenerator, method, params);
+ }
+
+ }
+
+
+
+ public static String callPlugin(IPentahoSession userSession, IContentGenerator contentGenerator, String method, Map<String, Object> params)
+ {
+ IParameterProvider requestParams = new SimpleParameterProvider(params);
+ return callPlugin(userSession, contentGenerator, method, requestParams);
+ }
+ public static String callPlugin(IPentahoSession userSession, IContentGenerator contentGenerator, String method, IParameterProvider params)
+ {
+ ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+ IParameterProvider requestParams = params;
+ Map<String, Object> pathMap = new HashMap<String, Object>();
+ pathMap.put("path", "/" + method);
+ IParameterProvider pathParams = new SimpleParameterProvider(pathMap);
+ Map<String, IParameterProvider> paramProvider = new HashMap<String, IParameterProvider>();
+ paramProvider.put(IParameterProvider.SCOPE_REQUEST, requestParams);
+ paramProvider.put("path", pathParams);
+
+
+ return callPlugin(userSession, contentGenerator, outputStream, paramProvider);
+ }
+ public static String callPlugin(IPentahoSession userSession, IContentGenerator contentGenerator, OutputStream outputStream, Map<String, IParameterProvider> paramProvider)
+ {
+ IOutputHandler outputHandler = new SimpleOutputHandler(outputStream, false);
+ try
+ {
+ contentGenerator.setSession(userSession);
+ contentGenerator.setOutputHandler(outputHandler);
+ contentGenerator.setParameterProviders(paramProvider);
+ contentGenerator.createContent();
+ return outputStream.toString();
+ }
+ catch (Exception e)
+ {
+ logger.error("Failed to execute call to plugin: " + e.toString());
+ return null;
+ }
+ }
+}
View
80 src/pt/webdetails/cpf/SimpleContentGenerator.java
@@ -0,0 +1,80 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+package pt.webdetails.cpf;
+
+import java.io.IOException;
+import java.io.OutputStream;
+import java.lang.reflect.InvocationTargetException;
+import java.lang.reflect.Method;
+
+import org.apache.commons.lang.StringUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.pentaho.platform.api.engine.IParameterProvider;
+import org.pentaho.platform.api.repository.IContentItem;
+import org.pentaho.platform.engine.services.solution.BaseContentGenerator;
+import pt.webdetails.cpf.annotations.AccessLevel;
+import pt.webdetails.cpf.annotations.Exposed;
+
+/**
+ *
+ * @author pdpi
+ */
+public class SimpleContentGenerator extends BaseContentGenerator {
+
+ private static final long serialVersionUID = 1L;
+ protected Log logger = LogFactory.getLog(this.getClass());
+
+ @Override
+ public void createContent() {
+ IParameterProvider pathParams = parameterProviders.get("path");
+ //requestParams = parameterProviders.get("request");
+ final IContentItem contentItem = outputHandler.getOutputContentItem("response", "content", "", instanceId, "text/html");
+
+ try {
+ final OutputStream out = contentItem.getOutputStream(null);
+ final Class<?>[] params = {OutputStream.class};
+
+ String[] pathSections = StringUtils.split(pathParams.getStringParameter("path", null), "/");
+
+ if (pathSections != null && pathSections.length > 0) {
+
+ final String method = StringUtils.lowerCase(pathSections[0]);
+
+ try {
+ final Method mthd = this.getClass().getMethod(method, params);
+ boolean exposed = mthd.isAnnotationPresent(Exposed.class);
+ boolean accessible = exposed && mthd.getAnnotation(Exposed.class).accessLevel() == AccessLevel.PUBLIC;
+ if (accessible) {
+ mthd.invoke(this, out);
+ } else {
+ throw new IllegalAccessException("Method " + method + " has the wrong access level");
+ }
+ } catch (NoSuchMethodException e) {
+ logger.warn("could't locate method: " + method);
+ } catch (InvocationTargetException e) {
+ logger.error(e.toString());
+
+ } catch (IllegalAccessException e) {
+ logger.warn(e.toString());
+
+ } catch (IllegalArgumentException e) {
+
+ logger.error(e.toString());
+ }
+ } else {
+ logger.error("No method supplied.");
+ }
+ } catch (SecurityException e) {
+ logger.warn(e.toString());
+ } catch (IOException e) {
+ logger.error(e.toString());
+ }
+ }
+
+ @Override
+ public Log getLogger() {
+ return logger;
+ }
+}
View
14 src/pt/webdetails/cpf/annotations/AccessLevel.java
@@ -0,0 +1,14 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+package pt.webdetails.cpf.annotations;
+
+/**
+ *
+ * @author pdpi
+ */
+public enum AccessLevel {
+ PUBLIC
+
+}
View
21 src/pt/webdetails/cpf/annotations/Exposed.java
@@ -0,0 +1,21 @@
+/*
+ * /* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this file,
+ * You can obtain one at http://mozilla.org/MPL/2.0/. */
+package pt.webdetails.cpf.annotations;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+/**
+ *
+ * @author pdpi
+ */
+@Retention(RetentionPolicy.RUNTIME)
+@Target(ElementType.METHOD)
+public @interface Exposed {
+
+ AccessLevel accessLevel();
+}

0 comments on commit ebc32aa

Please sign in to comment.
Something went wrong with that request. Please try again.