Search in sources :

Example 21 with IPluginManager

use of org.pentaho.platform.api.engine.IPluginManager in project pentaho-platform by pentaho.

the class UserConsoleResource method getMantleSettings.

/**
 * Return the current user console settings
 *
 * @return current settings
 */
@GET
@Path("/settings")
@Produces({ APPLICATION_JSON, APPLICATION_XML })
@Facet(name = "Unsupported")
public List<Setting> getMantleSettings() {
    ArrayList<Setting> settings = new ArrayList<Setting>();
    settings.add(// $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    new Setting("login-show-users-list", PentahoSystem.getSystemSetting("login-show-users-list", "")));
    // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    settings.add(new Setting("documentation-url", PentahoSystem.getSystemSetting("documentation-url", "")));
    // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    settings.add(new Setting("submit-on-enter-key", PentahoSystem.getSystemSetting("submit-on-enter-key", "true")));
    // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    settings.add(new Setting("user-console-revision", PentahoSystem.getSystemSetting("user-console-revision", "")));
    // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    settings.add(new Setting("startupPerspective", PentahoSystem.getSystemSetting("startup-perspective", "")));
    // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    settings.add(new Setting("showOnlyPerspective", PentahoSystem.getSystemSetting("show-only-perspective", "")));
    int startupUrls = Integer.parseInt(PentahoSystem.getSystemSetting("num-startup-urls", "0"));
    // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
    settings.add(new Setting("num-startup-urls", PentahoSystem.getSystemSetting("num-startup-urls", "0")));
    for (int i = 1; i <= startupUrls; i++) {
        // $NON-NLS-1$
        settings.add(new Setting("startup-url-" + i, PentahoSystem.getSystemSetting("startup-url-" + i, "")));
        // $NON-NLS-1$
        settings.add(new Setting("startup-name-" + i, PentahoSystem.getSystemSetting("startup-name-" + i, "")));
    }
    // Check for override of New Analysis View via pentaho.xml
    // Poked in via pentaho.xml entries
    // <new-analysis-view>
    // <command-url>http://www.google.com</command-url>
    // <command-title>Marc Analysis View</command-title>
    // </new-analysis-view>
    // <new-report>
    // <command-url>http://www.yahoo.com</command-url>
    // <command-title>Marc New Report</command-title>
    // </new-report>
    // 
    // $NON-NLS-1$
    String overrideNewAnalysisViewCommmand = PentahoSystem.getSystemSetting("new-analysis-view/command-url", null);
    // $NON-NLS-1$
    String overrideNewAnalysisViewTitle = PentahoSystem.getSystemSetting("new-analysis-view/command-title", null);
    if ((overrideNewAnalysisViewCommmand != null) && (overrideNewAnalysisViewTitle != null)) {
        // $NON-NLS-1$
        settings.add(new Setting("new-analysis-view-command-url", overrideNewAnalysisViewCommmand));
        // $NON-NLS-1$
        settings.add(new Setting("new-analysis-view-command-title", overrideNewAnalysisViewTitle));
    }
    // $NON-NLS-1$
    String overrideNewReportCommmand = PentahoSystem.getSystemSetting("new-report/command-url", null);
    // $NON-NLS-1$
    String overrideNewReportTitle = PentahoSystem.getSystemSetting("new-report/command-title", null);
    if ((overrideNewReportCommmand != null) && (overrideNewReportTitle != null)) {
        // $NON-NLS-1$
        settings.add(new Setting("new-report-command-url", overrideNewReportCommmand));
        // $NON-NLS-1$
        settings.add(new Setting("new-report-command-title", overrideNewReportTitle));
    }
    // $NON-NLS-1$
    IPluginManager pluginManager = PentahoSystem.get(IPluginManager.class, UserConsoleService.getPentahoSession());
    if (pluginManager != null) {
        // load content types from IPluginSettings
        int i = 0;
        for (String contentType : pluginManager.getContentTypes()) {
            IContentInfo info = pluginManager.getContentTypeInfo(contentType);
            if (info != null) {
                // $NON-NLS-1$ //$NON-NLS-2$
                settings.add(new Setting("plugin-content-type-" + i, "." + contentType));
                // $NON-NLS-1$
                settings.add(new Setting("plugin-content-type-icon-" + i, info.getIconUrl()));
                int j = 0;
                for (IPluginOperation operation : info.getOperations()) {
                    // $NON-NLS-1$
                    settings.add(new Setting("plugin-content-type-" + i + "-command-" + j, operation.getId()));
                    settings.add(new Setting("plugin-content-type-" + i + "-command-perspective-" + j, // $NON-NLS-1$
                    operation.getPerspective()));
                    j++;
                }
                i++;
            }
        }
    }
    return settings;
}
Also used : IContentInfo(org.pentaho.platform.api.engine.IContentInfo) IPluginOperation(org.pentaho.platform.api.engine.IPluginOperation) ArrayList(java.util.ArrayList) IPluginManager(org.pentaho.platform.api.engine.IPluginManager) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) Facet(org.codehaus.enunciate.Facet)

Example 22 with IPluginManager

use of org.pentaho.platform.api.engine.IPluginManager in project pentaho-platform by pentaho.

the class PluginManagerResource method getOverlays.

/**
 * Retrieve the list of XUL overlays for the provided id
 *
 * @param id
 * @return list of <code> Overlay </code>
 */
@GET
@Path("/overlays")
@Produces({ APPLICATION_JSON })
@Facet(name = "Unsupported")
public List<Overlay> getOverlays(@QueryParam("id") @DefaultValue("") String id) {
    // $NON-NLS-1$
    IPluginManager pluginManager = PentahoSystem.get(IPluginManager.class, PentahoSessionHolder.getSession());
    List<XulOverlay> overlays = pluginManager.getOverlays();
    ArrayList<Overlay> result = new ArrayList<Overlay>();
    for (XulOverlay overlay : overlays) {
        if (!id.isEmpty() && !overlay.getId().equals(id)) {
            continue;
        }
        Overlay tempOverlay = new Overlay(overlay.getId(), overlay.getOverlayUri(), overlay.getSource(), overlay.getResourceBundleUri(), overlay.getPriority());
        result.add(tempOverlay);
    }
    return result;
}
Also used : XulOverlay(org.pentaho.ui.xul.XulOverlay) ArrayList(java.util.ArrayList) IPluginManager(org.pentaho.platform.api.engine.IPluginManager) XulOverlay(org.pentaho.ui.xul.XulOverlay) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) Facet(org.codehaus.enunciate.Facet)

Example 23 with IPluginManager

use of org.pentaho.platform.api.engine.IPluginManager in project pentaho-platform by pentaho.

the class PluginManagerResource method getPluginSettings.

/**
 * Retrieve the list of setting of a selected setting name from all registered plugins.
 *
 * @param settingName (name of the plugin setting)
 * @return list of <code> Setting </code>
 */
@GET
@Path("/settings/{settingName}")
@Produces({ APPLICATION_JSON })
@Facet(name = "Unsupported")
public Response getPluginSettings(@PathParam("settingName") String settingName) {
    // A non-admin still require this setting. All other settings should be admin only
    if (!NEW_TOOLBAR_BUTTON_SETTING.equals(settingName)) {
        if (!canAdminister()) {
            return Response.status(UNAUTHORIZED).build();
        }
    }
    // $NON-NLS-1$
    IPluginManager pluginManager = PentahoSystem.get(IPluginManager.class, PentahoSessionHolder.getSession());
    ArrayList<Setting> settings = new ArrayList<Setting>();
    for (String id : pluginManager.getRegisteredPlugins()) {
        Setting s = new Setting(id, (String) pluginManager.getPluginSetting(id, settingName, null));
        if (!StringUtils.isEmpty(s.getValue())) {
            settings.add(s);
        }
    }
    return Response.ok(new JaxbList<Setting>(settings), MediaType.APPLICATION_JSON).build();
}
Also used : ArrayList(java.util.ArrayList) IPluginManager(org.pentaho.platform.api.engine.IPluginManager) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) Facet(org.codehaus.enunciate.Facet)

Example 24 with IPluginManager

use of org.pentaho.platform.api.engine.IPluginManager in project pdi-platform-plugin by pentaho.

the class ParameterUIContentGenerator method createContent.

@Override
public void createContent(OutputStream outputStream) throws Exception {
    IPluginResourceLoader resourceLoader = PentahoSystem.get(IPluginResourceLoader.class);
    IPluginManager pluginManager = PentahoSystem.get(IPluginManager.class);
    ClassLoader classLoader = pluginManager.getClassLoader(pluginId);
    String filePath = !viewerFilePath.startsWith("/") ? "/" + viewerFilePath : viewerFilePath;
    String viewer = IOUtils.toString(resourceLoader.getResourceAsStream(classLoader, filePath), LocaleHelper.getSystemEncoding());
    viewer = doResourceReplacement(viewer);
    InputStream is = IOUtils.toInputStream(viewer, LocaleHelper.getSystemEncoding());
    IOUtils.copy(is, outputStream);
    outputStream.flush();
}
Also used : InputStream(java.io.InputStream) IPluginManager(org.pentaho.platform.api.engine.IPluginManager) IPluginResourceLoader(org.pentaho.platform.api.engine.IPluginResourceLoader)

Aggregations

IPluginManager (org.pentaho.platform.api.engine.IPluginManager)24 ArrayList (java.util.ArrayList)7 GET (javax.ws.rs.GET)5 Path (javax.ws.rs.Path)5 Produces (javax.ws.rs.Produces)5 IPentahoSession (org.pentaho.platform.api.engine.IPentahoSession)5 IOException (java.io.IOException)4 Facet (org.codehaus.enunciate.Facet)4 InputStream (java.io.InputStream)3 HashMap (java.util.HashMap)3 Test (org.junit.Test)2 IContentInfo (org.pentaho.platform.api.engine.IContentInfo)2 IPentahoRequestContext (org.pentaho.platform.api.engine.IPentahoRequestContext)2 IPluginOperation (org.pentaho.platform.api.engine.IPluginOperation)2 IPluginResourceLoader (org.pentaho.platform.api.engine.IPluginResourceLoader)2 PluginBeanException (org.pentaho.platform.api.engine.PluginBeanException)2 StandaloneSession (org.pentaho.platform.engine.core.system.StandaloneSession)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)1 OutputStream (java.io.OutputStream)1 PrintWriter (java.io.PrintWriter)1