Search in sources :

Example 6 with IContentInfo

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

the class DefaultPluginManagerIT method test10_ContentTypeRegistration.

@Test
public void test10_ContentTypeRegistration() throws PlatformInitializationException {
    microPlatform.define(IPluginProvider.class, Tst10PluginProvider.class).start();
    pluginManager.reload();
    Set<String> types = pluginManager.getContentTypes();
    // FIXME: getContentTypes returns the list of types configured by content generators, not the list
    // of types defined by IContentInfo's. Is this really what we want? If a type has no content
    // generator configured, then it is invisible through this API.
    assertTrue("test10type1 should be registered", types.contains("test10type1-ext"));
    assertTrue("test10type2 should be registered", types.contains("test10type2-ext"));
    IContentInfo contentInfo = pluginManager.getContentTypeInfo("test10type1-ext");
    assertNotNull("type should be registered for extension test10type1-ext", contentInfo);
    assertEquals("test10type1-title", contentInfo.getTitle());
    assertEquals("test10type1-description", contentInfo.getDescription());
    assertEquals("test10type1-ext", contentInfo.getExtension());
    assertEquals("test10type1-url", contentInfo.getIconUrl());
    List<IPluginOperation> ops = contentInfo.getOperations();
    assertNotNull("Operations are null", ops);
    assertEquals("Wrong number of ops", 2, ops.size());
    assertEquals("Operation name is wrong", "test10type1-oper1-id", ops.get(0).getId());
    assertEquals("Operation name is wrong", "test10type1-oper2-id", ops.get(1).getId());
    assertEquals("Operation command is wrong", "test10type1-oper2-perspective", ops.get(1).getPerspective());
}
Also used : IContentInfo(org.pentaho.platform.api.engine.IContentInfo) IPluginOperation(org.pentaho.platform.api.engine.IPluginOperation) IPluginProvider(org.pentaho.platform.api.engine.IPluginProvider) Test(org.junit.Test)

Example 7 with IContentInfo

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

the class RepositoryResource method getExecutableTypes.

/**
 * Retrieves the list of supported content type in the platform
 *
 * @return list of <code> ExecutableFileTypeDto </code>
 */
@Path("/executableTypes")
@GET
@Produces({ APPLICATION_XML, APPLICATION_JSON })
@Facet(name = "Unsupported")
public Response getExecutableTypes() {
    ArrayList<ExecutableFileTypeDto> executableTypes = new ArrayList<ExecutableFileTypeDto>();
    for (String contentType : pluginManager.getContentTypes()) {
        IContentInfo contentInfo = pluginManager.getContentTypeInfo(contentType);
        ExecutableFileTypeDto executableFileType = new ExecutableFileTypeDto();
        executableFileType.setDescription(contentInfo.getDescription());
        executableFileType.setExtension(contentInfo.getExtension());
        executableFileType.setTitle(contentInfo.getTitle());
        executableFileType.setCanSchedule(hasOperationId(contentInfo.getOperations(), "SCHEDULE_NEW"));
        executableFileType.setCanEdit(hasOperationId(contentInfo.getOperations(), "EDIT"));
        executableTypes.add(executableFileType);
    }
    final GenericEntity<List<ExecutableFileTypeDto>> entity = new GenericEntity<List<ExecutableFileTypeDto>>(executableTypes) {
    };
    return Response.ok(entity).build();
}
Also used : IContentInfo(org.pentaho.platform.api.engine.IContentInfo) GenericEntity(javax.ws.rs.core.GenericEntity) ExecutableFileTypeDto(org.pentaho.platform.repository2.unified.webservices.ExecutableFileTypeDto) ArrayList(java.util.ArrayList) ArrayList(java.util.ArrayList) List(java.util.List) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) Facet(org.codehaus.enunciate.Facet)

Example 8 with IContentInfo

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

the class RepositoryResource method doExecuteDefault.

/**
 * Takes a pathId to a file and generates a URI that represents the URL to call to generate content from that file.
 *
 * <p><b>Example Request:</b><br />
 *    GET pentaho/api/repos/public:steel%20wheels:Invoice%20(report).prpt/default
 * </p>
 *
 * @param pathId @param pathId
 *
 * @return URI that represents a forwarding URL to execute to generate content from the file {pathId}.
 *
 * <p><b>Example Response:</b></p>
 *  <pre function="syntax.xml">
 *    This response does not contain data.
 *  </pre>
 */
@GET
@Path("{pathId : .+}/default")
@Produces({ WILDCARD })
@StatusCodes({ @ResponseCode(code = 303, condition = "Successfully get the resource."), @ResponseCode(code = 404, condition = "Failed to find the resource.") })
public Response doExecuteDefault(@PathParam("pathId") String pathId) throws FileNotFoundException, MalformedURLException, URISyntaxException {
    String perspective = null;
    StringBuffer buffer = null;
    String url = null;
    String path = FileResource.idToPath(pathId);
    String extension = path.substring(path.lastIndexOf('.') + 1);
    IPluginManager pluginManager = PentahoSystem.get(IPluginManager.class, PentahoSessionHolder.getSession());
    IContentInfo info = pluginManager.getContentTypeInfo(extension);
    for (IPluginOperation operation : info.getOperations()) {
        if (operation.getId().equalsIgnoreCase("RUN")) {
            // $NON-NLS-1$
            perspective = operation.getPerspective();
            break;
        }
    }
    if (perspective == null) {
        perspective = GENERATED_CONTENT_PERSPECTIVE;
    }
    buffer = httpServletRequest.getRequestURL();
    String queryString = httpServletRequest.getQueryString();
    url = // $NON-NLS-1$
    buffer.substring(0, buffer.lastIndexOf("/") + 1) + perspective + ((queryString != null && queryString.length() > 0) ? "?" + httpServletRequest.getQueryString() : "");
    return Response.seeOther((new URL(url)).toURI()).build();
}
Also used : IContentInfo(org.pentaho.platform.api.engine.IContentInfo) IPluginOperation(org.pentaho.platform.api.engine.IPluginOperation) IPluginManager(org.pentaho.platform.api.engine.IPluginManager) URL(java.net.URL) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) StatusCodes(org.codehaus.enunciate.jaxrs.StatusCodes)

Example 9 with IContentInfo

use of org.pentaho.platform.api.engine.IContentInfo 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)

Aggregations

IContentInfo (org.pentaho.platform.api.engine.IContentInfo)9 GET (javax.ws.rs.GET)4 Path (javax.ws.rs.Path)4 Produces (javax.ws.rs.Produces)4 IPluginOperation (org.pentaho.platform.api.engine.IPluginOperation)4 ArrayList (java.util.ArrayList)3 Facet (org.codehaus.enunciate.Facet)3 List (java.util.List)2 GenericEntity (javax.ws.rs.core.GenericEntity)2 Test (org.junit.Test)2 IPluginManager (org.pentaho.platform.api.engine.IPluginManager)2 StandaloneSession (org.pentaho.platform.engine.core.system.StandaloneSession)2 ExecutableFileTypeDto (org.pentaho.platform.repository2.unified.webservices.ExecutableFileTypeDto)2 URL (java.net.URL)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Predicate (org.apache.commons.collections.Predicate)1 StatusCodes (org.codehaus.enunciate.jaxrs.StatusCodes)1 IPentahoObjectRegistration (org.pentaho.platform.api.engine.IPentahoObjectRegistration)1 IPlatformPlugin (org.pentaho.platform.api.engine.IPlatformPlugin)1