/** * @param uriInfo {@link UriInfo} from where to extract query parameters * @param queryParams {@link List<QueryParam>} to where add the query parameters extracted from {@link UriInfo} * @return the updated {@link List<QueryParam>} passed in the queryParams parameter * @throws NullPointerException if queryParams is null */ public static List<QueryParam> addQueryParams(UriInfo uriInfo, List<QueryParam> queryParams) { if (uriInfo != null) { MultivaluedMap<String, String> params = uriInfo.getQueryParameters(); if (!params.isEmpty()) { queryParams.addAll(WSUtils.buildQueryParameters(params)); } } return queryParams; }
private List<QueryParam> buildClusterIdAwareQueryParams(Long clusterId, UriInfo uriInfo) { List<QueryParam> queryParams = new ArrayList<>(); queryParams.add(new QueryParam("clusterId", clusterId.toString())); if (uriInfo != null) { MultivaluedMap<String, String> params = uriInfo.getQueryParameters(); if (!params.isEmpty()) { queryParams.addAll(WSUtils.buildQueryParameters(params)); } } return queryParams; }
public static List<QueryParam> buildDashboardIdAwareQueryParams(Long dashboardId, UriInfo uriInfo) { List<QueryParam> queryParams = new ArrayList<>(); queryParams.add(new QueryParam(Dashboard.DASHBOARD_ID, dashboardId.toString())); if (uriInfo != null) { MultivaluedMap<String, String> params = uriInfo.getQueryParameters(); if (!params.isEmpty()) { queryParams.addAll(WSUtils.buildQueryParameters(params)); } } return queryParams; }
private List<QueryParam> buildServiceIdAwareQueryParams(Long serviceId, UriInfo uriInfo) { List<QueryParam> queryParams = new ArrayList<>(); queryParams.add(new QueryParam("serviceId", serviceId.toString())); if (uriInfo != null) { MultivaluedMap<String, String> params = uriInfo.getQueryParameters(); if (!params.isEmpty()) { queryParams.addAll(WSUtils.buildQueryParameters(params)); } } return queryParams; }
private List<QueryParam> buildServiceIdAwareQueryParams(Long serviceId, UriInfo uriInfo) { List<QueryParam> queryParams = new ArrayList<QueryParam>(); queryParams.add(new QueryParam("serviceId", serviceId.toString())); if (uriInfo != null) { MultivaluedMap<String, String> params = uriInfo.getQueryParameters(); if (!params.isEmpty()) { queryParams.addAll(WSUtils.buildQueryParameters(params)); } } return queryParams; }
/** * List all service bundles only the ones that match query params */ @GET @Path("/servicebundles") @Timed public Response listServiceBundles(@Context UriInfo uriInfo) { List<QueryParam> queryParams; MultivaluedMap<String, String> params = uriInfo.getQueryParameters(); queryParams = WSUtils.buildQueryParameters(params); Collection<ServiceBundle> serviceBundles = environmentService .listServiceBundles(queryParams); if (serviceBundles != null) { return WSUtils.respondEntities(serviceBundles, OK); } throw EntityNotFoundException.byFilter(queryParams.toString()); }
@GET @Path("/notifications/") @Timed public Response listNotifications(@Context UriInfo uriInfo, @Context SecurityContext securityContext) { SecurityUtil.checkRole(authorizer, securityContext, Roles.ROLE_NOTIFICATION_USER); List<QueryParam> queryParams = new ArrayList<>(); MultivaluedMap<String, String> uriInfoParams = uriInfo.getQueryParameters(); Collection<Notification> notifications = null; if (!uriInfoParams.isEmpty()) { queryParams = WSUtils.buildQueryParameters(uriInfoParams); } else { LOG.info("Query params empty, will use default criteria to return notifications."); } notifications = notificationService.findNotifications(queryParams); if (notifications != null && !notifications.isEmpty()) { return WSUtils.respondEntities(notifications, OK); } throw EntityNotFoundException.byFilter(queryParams.toString()); }
/** * List all component bundles registered for a type(SOURCE, SINK, etc) or only the ones that match query params * <p> * GET api/v1/catalog/streams/componentbundles/SOURCE?name=kafkaSpoutComponent * </p> */ @GET @Path("/componentbundles/{component}") @Timed public Response listTopologyComponentBundlesForTypeWithFilter (@PathParam ("component") TopologyComponentBundle.TopologyComponentType componentType, @Context UriInfo uriInfo, @Context SecurityContext securityContext) { SecurityUtil.checkRole(authorizer, securityContext, Roles.ROLE_TOPOLOGY_COMPONENT_BUNDLE_USER); List<QueryParam> queryParams; MultivaluedMap<String, String> params = uriInfo.getQueryParameters(); queryParams = WSUtils.buildQueryParameters(params); Collection<TopologyComponentBundle> topologyComponentBundles = catalogService .listTopologyComponentBundlesForTypeWithFilter(componentType, queryParams); if (topologyComponentBundles != null) { return WSUtils.respondEntities(topologyComponentBundles, OK); } throw EntityNotFoundException.byFilter(queryParams.toString()); }
@GET @Path("/files") @Timed public Response listFiles(@Context UriInfo uriInfo, @Context SecurityContext securityContext) { Collection<File> files = null; MultivaluedMap<String, String> params = uriInfo.getQueryParameters(); if (params == null || params.isEmpty()) { files = catalogService.listFiles(); } else { files = catalogService.listFiles(WSUtils.buildQueryParameters(params)); } Collection<File> result = SecurityUtil.filter(authorizer, securityContext, File.NAMESPACE, files, READ); return WSUtils.respondEntities(result, OK); }
@GET @Path("/acls") @Timed public Response listAcls(@Context UriInfo uriInfo, @Context SecurityContext securityContext) throws Exception { Collection<AclEntry> acls; MultivaluedMap<String, String> params = uriInfo.getQueryParameters(); List<QueryParam> queryParams = WSUtils.buildQueryParameters(params); if (params == null || params.isEmpty()) { acls = catalogService.listAcls(); } else { acls = catalogService.listAcls(queryParams); } if (acls != null) { return WSUtils.respondEntities(filter(acls, securityContext), OK); } throw EntityNotFoundException.byFilter(queryParams.toString()); }
@GET @Timed public Response listDashboards(@Context UriInfo uriInfo) { Collection<Dashboard> dashboards = null; MultivaluedMap<String, String> params = uriInfo.getQueryParameters(); List<QueryParam> queryParams = WSUtils.buildQueryParameters(params); if (params == null || params.isEmpty()) { dashboards = dashboardCatalogService.listDashboards(); } else { dashboards = dashboardCatalogService.listDashboards(queryParams); } if (dashboards != null) { return WSUtils.respondEntities(dashboards, OK); } throw EntityNotFoundException.byFilter(queryParams.toString()); }
/** * List custom processors matching specific query parameter filters. */ @GET @Path("/componentbundles/{processor}/custom") @Timed public Response listCustomProcessorsWithFilters (@PathParam("processor") TopologyComponentBundle.TopologyComponentType componentType, @Context UriInfo uriInfo, @Context SecurityContext securityContext) throws IOException { SecurityUtil.checkRole(authorizer, securityContext, Roles.ROLE_TOPOLOGY_COMPONENT_BUNDLE_USER); if (!TopologyComponentBundle.TopologyComponentType.PROCESSOR.equals(componentType)) { throw new CustomProcessorOnlyException(); } List<QueryParam> queryParams; MultivaluedMap<String, String> params = uriInfo.getQueryParameters(); queryParams = WSUtils.buildQueryParameters(params); Collection<CustomProcessorInfo> customProcessorInfos = catalogService.listCustomProcessorsFromBundleWithFilter(queryParams); if (customProcessorInfos != null) { return WSUtils.respondEntities(customProcessorInfos, OK); } throw EntityNotFoundException.byFilter(queryParams.toString()); }
@GET @Path("/users") @Timed public Response listUsers(@Context UriInfo uriInfo, @Context SecurityContext securityContext) throws Exception { if (!SecurityUtil.hasRole(authorizer, securityContext, ROLE_SECURITY_ADMIN)) { LOG.debug("Allowing logged-in user '{}'", SecurityUtil.getUserName(securityContext.getUserPrincipal().getName())); } Collection<User> users; MultivaluedMap<String, String> params = uriInfo.getQueryParameters(); List<QueryParam> queryParams = WSUtils.buildQueryParameters(params); if (params == null || params.isEmpty()) { users = catalogService.listUsers(); } else { users = catalogService.listUsers(queryParams); } if (users != null) { return WSUtils.respondEntities(users, OK); } throw EntityNotFoundException.byFilter(queryParams.toString()); }
@GET @Path("/roles") @Timed public Response listRoles(@Context UriInfo uriInfo, @Context SecurityContext securityContext) throws Exception { if (!SecurityUtil.hasRole(authorizer, securityContext, ROLE_SECURITY_ADMIN)) { LOG.debug("Allowing logged-in user '{}'", SecurityUtil.getUserName(securityContext.getUserPrincipal().getName())); } Collection<Role> roles; MultivaluedMap<String, String> params = uriInfo.getQueryParameters(); List<QueryParam> queryParams = WSUtils.buildQueryParameters(params); if (params == null || params.isEmpty()) { roles = catalogService.listRoles(); } else { roles = catalogService.listRoles(queryParams); } if (roles != null) { return WSUtils.respondEntities(roles, OK); } throw EntityNotFoundException.byFilter(queryParams.toString()); }
/** * List ALL notifiers or the ones matching specific query params. */ @GET @Path("/notifiers") @Timed public Response listNotifiers(@Context UriInfo uriInfo, @Context SecurityContext securityContext) { List<QueryParam> queryParams = new ArrayList<>(); MultivaluedMap<String, String> params = uriInfo.getQueryParameters(); Collection<Notifier> notifiers; if (params.isEmpty()) { notifiers = catalogService.listNotifierInfos(); } else { queryParams = WSUtils.buildQueryParameters(params); notifiers = catalogService.listNotifierInfos(queryParams); } if (notifiers != null) { boolean notifierUser = SecurityUtil.hasRole(authorizer, securityContext, Roles.ROLE_NOTIFIER_USER); if (notifierUser) { LOG.debug("Returning all Notifiers since user has role: {}", Roles.ROLE_NOTIFIER_USER); } else { notifiers = SecurityUtil.filter(authorizer, securityContext, Notifier.NAMESPACE, notifiers, READ); } return WSUtils.respondEntities(notifiers, OK); } throw EntityNotFoundException.byFilter(queryParams.toString()); }
queryParams = WSUtils.buildQueryParameters(copiedParams); namespaces = environmentService.listNamespaces(queryParams);
queryParams = WSUtils.buildQueryParameters(copiedParams); clusters = environmentService.listClusters(queryParams);
udfs = catalogService.listUDFs(); } else { queryParams = WSUtils.buildQueryParameters(params); udfs = catalogService.listUDFs(queryParams);
tags = tagService.listTags(); } else { queryParams = WSUtils.buildQueryParameters(params); tags = tagService.listTags(queryParams);
params.putSingle(TopologyComponentBundle.STREAMING_ENGINE, topologyComponentBundle.getStreamingEngine()); params.putSingle(TopologyComponentBundle.SUB_TYPE, topologyComponentBundle.getSubType()); queryParams = WSUtils.buildQueryParameters(params); Collection<TopologyComponentBundle> topologyComponentBundles = catalogService.listTopologyComponentBundlesForTypeWithFilter(componentType, queryParams);