Search in sources :

Example 41 with Facet

use of org.codehaus.enunciate.Facet in project pentaho-platform by pentaho.

the class UserRoleDaoResource method removeAllUsersFromRole.

/**
 * Removes all users from a particular role
 *
 * @param tenantPath (tenant path where the user exist, null of empty string assumes default tenant)
 * @param roleName   (role name)
 * @return
 */
@PUT
@Path("/removeAllUsersFromRole")
@Consumes({ MediaType.WILDCARD })
@Facet(name = "Unsupported")
public Response removeAllUsersFromRole(@QueryParam("tenant") String tenantPath, @QueryParam("roleName") String roleName) {
    if (canAdminister()) {
        try {
            IUserRoleDao roleDao = getUserRoleDao();
            roleDao.setRoleMembers(getTenant(tenantPath), roleName, new String[0]);
            updateRolesForCurrentSession();
            return Response.ok().build();
        } catch (Throwable th) {
            return processErrorResponse(th.getLocalizedMessage());
        }
    } else {
        return Response.status(Response.Status.UNAUTHORIZED).build();
    }
}
Also used : IUserRoleDao(org.pentaho.platform.api.engine.security.userroledao.IUserRoleDao) Path(javax.ws.rs.Path) Consumes(javax.ws.rs.Consumes) PUT(javax.ws.rs.PUT) Facet(org.codehaus.enunciate.Facet)

Example 42 with Facet

use of org.codehaus.enunciate.Facet 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 43 with Facet

use of org.codehaus.enunciate.Facet in project pentaho-platform by pentaho.

the class PluginManagerResource method getPluginPerpectives.

/**
 * Retrieve the list of plugin perspective in the platform
 *
 * @return list of <code> PluginPerspective </code>
 */
@GET
@Path("/perspectives")
@Produces({ APPLICATION_JSON })
@Facet(name = "Unsupported")
public ArrayList<PluginPerspective> getPluginPerpectives() {
    IPluginPerspectiveManager manager = // $NON-NLS-1$
    PentahoSystem.get(IPluginPerspectiveManager.class, PentahoSessionHolder.getSession());
    ArrayList<PluginPerspective> perspectives = new ArrayList<PluginPerspective>();
    for (IPluginPerspective perspective : manager.getPluginPerspectives()) {
        PluginPerspective pp = new PluginPerspective();
        pp.setId(perspective.getId());
        pp.setTitle(perspective.getTitle());
        pp.setContentUrl(perspective.getContentUrl());
        pp.setLayoutPriority(perspective.getLayoutPriority());
        pp.setRequiredSecurityActions(perspective.getRequiredSecurityActions());
        pp.setResourceBundleUri(perspective.getResourceBundleUri());
        if (perspective.getOverlays() != null) {
            ArrayList<Overlay> safeOverlays = new ArrayList<Overlay>();
            for (XulOverlay orig : perspective.getOverlays()) {
                Overlay tempOverlay = new Overlay(orig.getId(), orig.getOverlayUri(), orig.getSource(), orig.getResourceBundleUri(), orig.getPriority());
                safeOverlays.add(tempOverlay);
            }
            pp.setOverlays(safeOverlays);
        }
        perspectives.add(pp);
    }
    return perspectives;
}
Also used : XulOverlay(org.pentaho.ui.xul.XulOverlay) ArrayList(java.util.ArrayList) XulOverlay(org.pentaho.ui.xul.XulOverlay) IPluginPerspectiveManager(org.pentaho.platform.api.engine.perspective.IPluginPerspectiveManager) IPluginPerspective(org.pentaho.platform.api.engine.perspective.pojo.IPluginPerspective) IPluginPerspective(org.pentaho.platform.api.engine.perspective.pojo.IPluginPerspective) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) Facet(org.codehaus.enunciate.Facet)

Example 44 with Facet

use of org.codehaus.enunciate.Facet 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 45 with Facet

use of org.codehaus.enunciate.Facet in project data-access by pentaho.

the class AnalysisDatasourceService method putMondrianSchema.

/**
 * This is used by PUC to use a Jersey put to import a Mondrian Schema XML into PUR
 *
 * @param dataInputStream
 * @param schemaFileInfo
 * @param catalogName
 * @param datasourceName
 * @param overwrite
 * @param xmlaEnabledFlag
 * @param parameters
 * @param acl acl information for the data source. This parameter is optional.
 * @return this method returns a response of "3" for success, 8 if exists, etc.
 * @throws PentahoAccessControlException
 */
@PUT
@Path("/putSchema")
@Consumes(MediaType.MULTIPART_FORM_DATA)
@Produces("text/plain")
@Facet(name = "Unsupported")
public Response putMondrianSchema(@FormDataParam(UPLOAD_ANALYSIS) InputStream dataInputStream, @FormDataParam(UPLOAD_ANALYSIS) FormDataContentDisposition schemaFileInfo, // Optional
@FormDataParam(CATALOG_NAME) String catalogName, // Optional
@FormDataParam(ORIG_CATALOG_NAME) String origCatalogName, // Optional
@FormDataParam(DATASOURCE_NAME) String datasourceName, @FormDataParam(OVERWRITE_IN_REPOS) String overwrite, @FormDataParam(XMLA_ENABLED_FLAG) String xmlaEnabledFlag, @FormDataParam(PARAMETERS) String parameters, @FormDataParam(DATASOURCE_ACL) RepositoryFileAclDto acl) throws PentahoAccessControlException {
    Response response = null;
    int statusCode = PlatformImportException.PUBLISH_GENERAL_ERROR;
    try {
        AnalysisService service = new AnalysisService();
        boolean overWriteInRepository = "True".equalsIgnoreCase(overwrite) ? true : false;
        boolean xmlaEnabled = "True".equalsIgnoreCase(xmlaEnabledFlag) ? true : false;
        service.putMondrianSchema(dataInputStream, schemaFileInfo, catalogName, origCatalogName, datasourceName, overWriteInRepository, xmlaEnabled, parameters, acl);
        statusCode = SUCCESS;
    } catch (PentahoAccessControlException pac) {
        logger.error(pac.getMessage());
        statusCode = PlatformImportException.PUBLISH_USERNAME_PASSWORD_FAIL;
    } catch (PlatformImportException pe) {
        statusCode = pe.getErrorStatus();
        logger.error("Error putMondrianSchema " + pe.getMessage() + " status = " + statusCode);
    } catch (Exception e) {
        logger.error("Error putMondrianSchema " + e.getMessage());
        statusCode = PlatformImportException.PUBLISH_GENERAL_ERROR;
    }
    response = Response.ok().status(statusCode).type(MediaType.TEXT_PLAIN).build();
    logger.debug("putMondrianSchema Response " + response);
    return response;
}
Also used : Response(javax.ws.rs.core.Response) PlatformImportException(org.pentaho.platform.plugin.services.importer.PlatformImportException) AnalysisService(org.pentaho.platform.dataaccess.datasource.api.AnalysisService) PentahoAccessControlException(org.pentaho.platform.api.engine.PentahoAccessControlException) PlatformImportException(org.pentaho.platform.plugin.services.importer.PlatformImportException) PentahoAccessControlException(org.pentaho.platform.api.engine.PentahoAccessControlException) Path(javax.ws.rs.Path) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) PUT(javax.ws.rs.PUT) Facet(org.codehaus.enunciate.Facet)

Aggregations

Facet (org.codehaus.enunciate.Facet)48 Path (javax.ws.rs.Path)43 Produces (javax.ws.rs.Produces)33 GET (javax.ws.rs.GET)29 ArrayList (java.util.ArrayList)12 Consumes (javax.ws.rs.Consumes)12 POST (javax.ws.rs.POST)8 PentahoAccessControlException (org.pentaho.platform.api.engine.PentahoAccessControlException)8 PUT (javax.ws.rs.PUT)7 IPentahoSession (org.pentaho.platform.api.engine.IPentahoSession)6 IUserRoleDao (org.pentaho.platform.api.engine.security.userroledao.IUserRoleDao)6 Response (javax.ws.rs.core.Response)5 IDatabaseConnection (org.pentaho.database.model.IDatabaseConnection)5 HashSet (java.util.HashSet)4 StringTokenizer (java.util.StringTokenizer)4 StatusCodes (org.codehaus.enunciate.jaxrs.StatusCodes)4 IPluginManager (org.pentaho.platform.api.engine.IPluginManager)4 IMondrianCatalogService (org.pentaho.platform.plugin.action.mondrian.catalog.IMondrianCatalogService)4 ByteArrayOutputStream (java.io.ByteArrayOutputStream)3 IOException (java.io.IOException)3