List of usage examples for org.apache.commons.lang3 StringUtils containsIgnoreCase
public static boolean containsIgnoreCase(final CharSequence str, final CharSequence searchStr)
Checks if CharSequence contains a search CharSequence irrespective of case, handling null .
From source file:org.apache.nifi.web.api.FlowResource.java
/** * Searches the cluster for a node with a given address. * * @param value Search value that will be matched against a node's address * @return Nodes that match the specified criteria *//*from w w w. j a va 2 s . c om*/ @GET @Consumes(MediaType.WILDCARD) @Produces(MediaType.APPLICATION_JSON) @Path("cluster/search-results") @ApiOperation(value = "Searches the cluster for a node with the specified address", notes = NON_GUARANTEED_ENDPOINT, response = ClusterSearchResultsEntity.class, authorizations = { @Authorization(value = "Read - /flow", type = "") }) @ApiResponses(value = { @ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."), @ApiResponse(code = 401, message = "Client could not be authenticated."), @ApiResponse(code = 403, message = "Client is not authorized to make this request."), @ApiResponse(code = 404, message = "The specified resource could not be found."), @ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.") }) public Response searchCluster( @ApiParam(value = "Node address to search for.", required = true) @QueryParam("q") @DefaultValue(StringUtils.EMPTY) String value) { authorizeFlow(); // ensure connected to the cluster if (!isConnectedToCluster()) { throw new IllegalClusterResourceRequestException( "Only a node connected to a cluster can process the request."); } final List<NodeSearchResultDTO> nodeMatches = new ArrayList<>(); // get the nodes in the cluster final ClusterDTO cluster = serviceFacade.getCluster(); // check each to see if it matches the search term for (NodeDTO node : cluster.getNodes()) { // ensure the node is connected if (!NodeConnectionState.CONNECTED.name().equals(node.getStatus())) { continue; } // determine the current nodes address final String address = node.getAddress() + ":" + node.getApiPort(); // count the node if there is no search or it matches the address if (StringUtils.isBlank(value) || StringUtils.containsIgnoreCase(address, value)) { final NodeSearchResultDTO nodeMatch = new NodeSearchResultDTO(); nodeMatch.setId(node.getNodeId()); nodeMatch.setAddress(address); nodeMatches.add(nodeMatch); } } // build the response ClusterSearchResultsEntity results = new ClusterSearchResultsEntity(); results.setNodeResults(nodeMatches); // generate an 200 - OK response return noCache(Response.ok(results)).build(); }
From source file:org.apache.nifi.web.api.TenantsResource.java
/** * Searches for a tenant with a given identity. * * @param value Search value that will be matched against a user/group identity * @return Tenants match the specified criteria *///from w w w .j a va 2 s . c o m @GET @Consumes(MediaType.WILDCARD) @Produces(MediaType.APPLICATION_JSON) @Path("search-results") @ApiOperation(value = "Searches for a tenant with the specified identity", notes = NON_GUARANTEED_ENDPOINT, response = TenantsEntity.class, authorizations = { @Authorization(value = "Read - /tenants", type = "") }) @ApiResponses(value = { @ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."), @ApiResponse(code = 401, message = "Client could not be authenticated."), @ApiResponse(code = 403, message = "Client is not authorized to make this request."), @ApiResponse(code = 404, message = "The specified resource could not be found."), @ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.") }) public Response searchCluster( @ApiParam(value = "Identity to search for.", required = true) @QueryParam("q") @DefaultValue(StringUtils.EMPTY) String value) { // ensure we're running with a configurable authorizer if (!(authorizer instanceof AbstractPolicyBasedAuthorizer)) { throw new IllegalStateException(AccessPolicyDAO.MSG_NON_ABSTRACT_POLICY_BASED_AUTHORIZER); } if (isReplicateRequest()) { return replicate(HttpMethod.GET); } // authorize access serviceFacade.authorizeAccess(lookup -> { final Authorizable tenants = lookup.getTenant(); tenants.authorize(authorizer, RequestAction.READ, NiFiUserUtils.getNiFiUser()); }); final List<TenantEntity> userMatches = new ArrayList<>(); final List<TenantEntity> userGroupMatches = new ArrayList<>(); // get the users for (final UserEntity userEntity : serviceFacade.getUsers()) { final UserDTO user = userEntity.getComponent(); if (StringUtils.isBlank(value) || StringUtils.containsIgnoreCase(user.getIdentity(), value)) { final TenantDTO tenant = new TenantDTO(); tenant.setId(user.getId()); tenant.setIdentity(user.getIdentity()); final TenantEntity entity = new TenantEntity(); entity.setPermissions(userEntity.getPermissions()); entity.setRevision(userEntity.getRevision()); entity.setId(userEntity.getId()); entity.setComponent(tenant); userMatches.add(entity); } } // get the user groups for (final UserGroupEntity userGroupEntity : serviceFacade.getUserGroups()) { final UserGroupDTO userGroup = userGroupEntity.getComponent(); if (StringUtils.isBlank(value) || StringUtils.containsIgnoreCase(userGroup.getIdentity(), value)) { final TenantDTO tenant = new TenantDTO(); tenant.setId(userGroup.getId()); tenant.setIdentity(userGroup.getIdentity()); final TenantEntity entity = new TenantEntity(); entity.setPermissions(userGroupEntity.getPermissions()); entity.setRevision(userGroupEntity.getRevision()); entity.setId(userGroupEntity.getId()); entity.setComponent(tenant); userGroupMatches.add(entity); } } // build the response final TenantsEntity results = new TenantsEntity(); results.setUsers(userMatches); results.setUserGroups(userGroupMatches); // generate an 200 - OK response return noCache(Response.ok(results)).build(); }
From source file:org.apache.nifi.web.api.UserResource.java
/** * Searches for users with match the specified query. * * @param value Search value that will be matched against users * @return A userSearchResultsEntity// w w w .jav a 2s .c om */ @GET @Consumes(MediaType.WILDCARD) @Produces({ MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML }) @Path("/search-results") @PreAuthorize("hasAnyRole('ROLE_DFM', 'ROLE_ADMIN')") @ApiOperation(value = "Searches for users", response = UserSearchResultsEntity.class, authorizations = { @Authorization(value = "Data Flow Manager", type = "ROLE_DFM"), @Authorization(value = "Administrator", type = "ROLE_ADMIN") }) @ApiResponses(value = { @ApiResponse(code = 400, message = "NiFi was unable to complete the request because it was invalid. The request should not be retried without modification."), @ApiResponse(code = 401, message = "Client could not be authenticated."), @ApiResponse(code = 403, message = "Client is not authorized to make this request."), @ApiResponse(code = 409, message = "The request was valid but NiFi was not in the appropriate state to process it. Retrying the same request later may be successful.") }) public Response searchUsers( @ApiParam(value = "The search terms.", required = true) @QueryParam("q") @DefaultValue(StringUtils.EMPTY) String value) { final List<UserSearchResultDTO> userMatches = new ArrayList<>(); final List<UserGroupSearchResultDTO> userGroupMatches = new ArrayList<>(); // get the users final Collection<UserDTO> users = serviceFacade.getUsers(Boolean.FALSE); final Collection<String> matchedGroups = new HashSet<>(); // check each to see if it matches the search term for (UserDTO user : users) { // count the user if there is no search or it matches the address if (StringUtils.isBlank(value)) { // record the group match if there is one and it hasn't already been encountered if (user.getUserGroup() != null && !matchedGroups.contains(user.getUserGroup())) { // add the matched group matchedGroups.add(user.getUserGroup()); // record the group match final UserGroupSearchResultDTO userGroupMatch = new UserGroupSearchResultDTO(); userGroupMatch.setGroup(user.getUserGroup()); userGroupMatches.add(userGroupMatch); } // record the user match final UserSearchResultDTO userMatch = new UserSearchResultDTO(); userMatch.setUserDn(user.getDn()); userMatch.setUserName(user.getUserName()); userMatches.add(userMatch); } else { // look for a user match if (StringUtils.containsIgnoreCase(user.getDn(), value) || StringUtils.containsIgnoreCase(user.getUserName(), value)) { // record the user match final UserSearchResultDTO userMatch = new UserSearchResultDTO(); userMatch.setUserDn(user.getDn()); userMatch.setUserName(user.getUserName()); userMatches.add(userMatch); } // look for a dn match if (StringUtils.containsIgnoreCase(user.getUserGroup(), value)) { // record the group match if it hasn't already been encountered if (!matchedGroups.contains(user.getUserGroup())) { // add the matched group matchedGroups.add(user.getUserGroup()); // record the group match final UserGroupSearchResultDTO userGroupMatch = new UserGroupSearchResultDTO(); userGroupMatch.setGroup(user.getUserGroup()); userGroupMatches.add(userGroupMatch); } } } } // sort the user matches Collections.sort(userMatches, new Comparator<UserSearchResultDTO>() { @Override public int compare(UserSearchResultDTO user1, UserSearchResultDTO user2) { return user1.getUserName().compareTo(user2.getUserName()); } }); // sort the user group matches Collections.sort(userGroupMatches, new Comparator<UserGroupSearchResultDTO>() { @Override public int compare(UserGroupSearchResultDTO userGroup1, UserGroupSearchResultDTO userGroup2) { return userGroup1.getGroup().compareTo(userGroup2.getGroup()); } }); // build the response final UserSearchResultsEntity results = new UserSearchResultsEntity(); results.setUserResults(userMatches); results.setUserGroupResults(userGroupMatches); // generate an 200 - OK response return noCache(Response.ok(results)).build(); }
From source file:org.apache.nifi.web.controller.ControllerFacade.java
private ComponentSearchResultDTO search(final String searchStr, final Port port) { final List<String> matches = new ArrayList<>(); addIfAppropriate(searchStr, port.getIdentifier(), "Id", matches); addIfAppropriate(searchStr, port.getName(), "Name", matches); addIfAppropriate(searchStr, port.getComments(), "Comments", matches); // consider scheduled state if (ScheduledState.DISABLED.equals(port.getScheduledState())) { if (StringUtils.containsIgnoreCase("disabled", searchStr)) { matches.add("Run status: Disabled"); }/*from w w w . j av a 2 s . com*/ } else { if (StringUtils.containsIgnoreCase("invalid", searchStr) && !port.isValid()) { matches.add("Run status: Invalid"); } else if (ScheduledState.RUNNING.equals(port.getScheduledState()) && StringUtils.containsIgnoreCase("running", searchStr)) { matches.add("Run status: Running"); } else if (ScheduledState.STOPPED.equals(port.getScheduledState()) && StringUtils.containsIgnoreCase("stopped", searchStr)) { matches.add("Run status: Stopped"); } } if (port instanceof RootGroupPort) { final RootGroupPort rootGroupPort = (RootGroupPort) port; // user access controls for (final String userAccessControl : rootGroupPort.getUserAccessControl()) { addIfAppropriate(searchStr, userAccessControl, "User access control", matches); } // group access controls for (final String groupAccessControl : rootGroupPort.getGroupAccessControl()) { addIfAppropriate(searchStr, groupAccessControl, "Group access control", matches); } } if (matches.isEmpty()) { return null; } final ComponentSearchResultDTO dto = new ComponentSearchResultDTO(); dto.setId(port.getIdentifier()); dto.setName(port.getName()); dto.setMatches(matches); return dto; }
From source file:org.apache.nifi.web.controller.ControllerFacade.java
private ComponentSearchResultDTO search(final String searchStr, final ProcessorNode procNode) { final List<String> matches = new ArrayList<>(); final Processor processor = procNode.getProcessor(); addIfAppropriate(searchStr, procNode.getIdentifier(), "Id", matches); addIfAppropriate(searchStr, procNode.getName(), "Name", matches); addIfAppropriate(searchStr, procNode.getComments(), "Comments", matches); // consider scheduling strategy if (SchedulingStrategy.EVENT_DRIVEN.equals(procNode.getSchedulingStrategy()) && StringUtils.containsIgnoreCase("event", searchStr)) { matches.add("Scheduling strategy: Event driven"); } else if (SchedulingStrategy.TIMER_DRIVEN.equals(procNode.getSchedulingStrategy()) && StringUtils.containsIgnoreCase("timer", searchStr)) { matches.add("Scheduling strategy: Timer driven"); } else if (SchedulingStrategy.PRIMARY_NODE_ONLY.equals(procNode.getSchedulingStrategy()) && StringUtils.containsIgnoreCase("primary", searchStr)) { // PRIMARY_NODE_ONLY has been deprecated as a SchedulingStrategy and replaced by PRIMARY as an ExecutionNode. matches.add("Scheduling strategy: On primary node"); }/*from w ww .ja v a 2s. c o m*/ // consider execution node if (ExecutionNode.PRIMARY.equals(procNode.getExecutionNode()) && StringUtils.containsIgnoreCase("primary", searchStr)) { matches.add("Execution node: primary"); } // consider scheduled state if (ScheduledState.DISABLED.equals(procNode.getScheduledState())) { if (StringUtils.containsIgnoreCase("disabled", searchStr)) { matches.add("Run status: Disabled"); } } else { if (StringUtils.containsIgnoreCase("invalid", searchStr) && !procNode.isValid()) { matches.add("Run status: Invalid"); } else if (ScheduledState.RUNNING.equals(procNode.getScheduledState()) && StringUtils.containsIgnoreCase("running", searchStr)) { matches.add("Run status: Running"); } else if (ScheduledState.STOPPED.equals(procNode.getScheduledState()) && StringUtils.containsIgnoreCase("stopped", searchStr)) { matches.add("Run status: Stopped"); } } for (final Relationship relationship : procNode.getRelationships()) { addIfAppropriate(searchStr, relationship.getName(), "Relationship", matches); } // Add both the actual class name and the component type. This allows us to search for 'Ghost' // to search for components that could not be instantiated. addIfAppropriate(searchStr, processor.getClass().getSimpleName(), "Type", matches); addIfAppropriate(searchStr, procNode.getComponentType(), "Type", matches); for (final Map.Entry<PropertyDescriptor, String> entry : procNode.getProperties().entrySet()) { final PropertyDescriptor descriptor = entry.getKey(); addIfAppropriate(searchStr, descriptor.getName(), "Property name", matches); addIfAppropriate(searchStr, descriptor.getDescription(), "Property description", matches); // never include sensitive properties values in search results if (descriptor.isSensitive()) { continue; } String value = entry.getValue(); // if unset consider default value if (value == null) { value = descriptor.getDefaultValue(); } // evaluate if the value matches the search criteria if (StringUtils.containsIgnoreCase(value, searchStr)) { matches.add("Property value: " + descriptor.getName() + " - " + value); } } // consider searching the processor directly if (processor instanceof Searchable) { final Searchable searchable = (Searchable) processor; final SearchContext context = new StandardSearchContext(searchStr, procNode, flowController, variableRegistry); // search the processor using the appropriate thread context classloader try (final NarCloseable x = NarCloseable.withComponentNarLoader(processor.getClass(), processor.getIdentifier())) { final Collection<SearchResult> searchResults = searchable.search(context); if (CollectionUtils.isNotEmpty(searchResults)) { for (final SearchResult searchResult : searchResults) { matches.add(searchResult.getLabel() + ": " + searchResult.getMatch()); } } } catch (final Throwable t) { // log this as error } } if (matches.isEmpty()) { return null; } final ComponentSearchResultDTO result = new ComponentSearchResultDTO(); result.setId(procNode.getIdentifier()); result.setMatches(matches); result.setName(procNode.getName()); return result; }
From source file:org.apache.nifi.web.controller.ControllerFacade.java
private ComponentSearchResultDTO search(final String searchStr, final Connection connection) { final List<String> matches = new ArrayList<>(); // search id and name addIfAppropriate(searchStr, connection.getIdentifier(), "Id", matches); addIfAppropriate(searchStr, connection.getName(), "Name", matches); // search relationships for (final Relationship relationship : connection.getRelationships()) { addIfAppropriate(searchStr, relationship.getName(), "Relationship", matches); }/* ww w.j av a2 s . com*/ // search prioritizers final FlowFileQueue queue = connection.getFlowFileQueue(); for (final FlowFilePrioritizer comparator : queue.getPriorities()) { addIfAppropriate(searchStr, comparator.getClass().getName(), "Prioritizer", matches); } // search expiration if (StringUtils.containsIgnoreCase("expires", searchStr) || StringUtils.containsIgnoreCase("expiration", searchStr)) { final int expirationMillis = connection.getFlowFileQueue().getFlowFileExpiration(TimeUnit.MILLISECONDS); if (expirationMillis > 0) { matches.add("FlowFile expiration: " + connection.getFlowFileQueue().getFlowFileExpiration()); } } // search back pressure if (StringUtils.containsIgnoreCase("back pressure", searchStr) || StringUtils.containsIgnoreCase("pressure", searchStr)) { final String backPressureDataSize = connection.getFlowFileQueue().getBackPressureDataSizeThreshold(); final Double backPressureBytes = DataUnit.parseDataSize(backPressureDataSize, DataUnit.B); if (backPressureBytes > 0) { matches.add("Back pressure data size: " + backPressureDataSize); } final long backPressureCount = connection.getFlowFileQueue().getBackPressureObjectThreshold(); if (backPressureCount > 0) { matches.add("Back pressure count: " + backPressureCount); } } // search the source final Connectable source = connection.getSource(); addIfAppropriate(searchStr, source.getIdentifier(), "Source id", matches); addIfAppropriate(searchStr, source.getName(), "Source name", matches); addIfAppropriate(searchStr, source.getComments(), "Source comments", matches); // search the destination final Connectable destination = connection.getDestination(); addIfAppropriate(searchStr, destination.getIdentifier(), "Destination id", matches); addIfAppropriate(searchStr, destination.getName(), "Destination name", matches); addIfAppropriate(searchStr, destination.getComments(), "Destination comments", matches); if (matches.isEmpty()) { return null; } final ComponentSearchResultDTO result = new ComponentSearchResultDTO(); result.setId(connection.getIdentifier()); // determine the name of the search match if (StringUtils.isNotBlank(connection.getName())) { result.setName(connection.getName()); } else if (!connection.getRelationships().isEmpty()) { final List<String> relationships = new ArrayList<>(connection.getRelationships().size()); for (final Relationship relationship : connection.getRelationships()) { if (StringUtils.isNotBlank(relationship.getName())) { relationships.add(relationship.getName()); } } if (!relationships.isEmpty()) { result.setName(StringUtils.join(relationships, ", ")); } } // ensure a name is added if (result.getName() == null) { result.setName("From source " + connection.getSource().getName()); } result.setMatches(matches); return result; }
From source file:org.apache.nifi.web.controller.ControllerFacade.java
private ComponentSearchResultDTO search(final String searchStr, final RemoteProcessGroup group) { final List<String> matches = new ArrayList<>(); addIfAppropriate(searchStr, group.getIdentifier(), "Id", matches); addIfAppropriate(searchStr, group.getName(), "Name", matches); addIfAppropriate(searchStr, group.getComments(), "Comments", matches); addIfAppropriate(searchStr, group.getTargetUris(), "URLs", matches); // consider the transmission status if ((StringUtils.containsIgnoreCase("transmitting", searchStr) || StringUtils.containsIgnoreCase("transmission enabled", searchStr)) && group.isTransmitting()) { matches.add("Transmission: On"); } else if ((StringUtils.containsIgnoreCase("not transmitting", searchStr) || StringUtils.containsIgnoreCase("transmission disabled", searchStr)) && !group.isTransmitting()) { matches.add("Transmission: Off"); }/* ww w .j a v a 2 s. c o m*/ if (matches.isEmpty()) { return null; } final ComponentSearchResultDTO result = new ComponentSearchResultDTO(); result.setId(group.getIdentifier()); result.setName(group.getName()); result.setMatches(matches); return result; }
From source file:org.apache.nifi.web.controller.ControllerFacade.java
private void addIfAppropriate(final String searchStr, final String value, final String label, final List<String> matches) { if (StringUtils.containsIgnoreCase(value, searchStr)) { matches.add(label + ": " + value); }/* ww w . j a va 2 s. c o m*/ }
From source file:org.apache.nifi.web.controller.ControllerSearchService.java
private ComponentSearchResultDTO search(final String searchStr, final Port port) { final List<String> matches = new ArrayList<>(); addIfAppropriate(searchStr, port.getIdentifier(), "Id", matches); addIfAppropriate(searchStr, port.getVersionedComponentId().orElse(null), "Version Control ID", matches); addIfAppropriate(searchStr, port.getName(), "Name", matches); addIfAppropriate(searchStr, port.getComments(), "Comments", matches); // consider scheduled state if (ScheduledState.DISABLED.equals(port.getScheduledState())) { if (StringUtils.containsIgnoreCase("disabled", searchStr)) { matches.add("Run status: Disabled"); }//from www . jav a2 s. c om } else { if (StringUtils.containsIgnoreCase("invalid", searchStr) && !port.isValid()) { matches.add("Run status: Invalid"); } else if (ScheduledState.RUNNING.equals(port.getScheduledState()) && StringUtils.containsIgnoreCase("running", searchStr)) { matches.add("Run status: Running"); } else if (ScheduledState.STOPPED.equals(port.getScheduledState()) && StringUtils.containsIgnoreCase("stopped", searchStr)) { matches.add("Run status: Stopped"); } } if (port instanceof RootGroupPort) { final RootGroupPort rootGroupPort = (RootGroupPort) port; // user access controls for (final String userAccessControl : rootGroupPort.getUserAccessControl()) { addIfAppropriate(searchStr, userAccessControl, "User access control", matches); } // group access controls for (final String groupAccessControl : rootGroupPort.getGroupAccessControl()) { addIfAppropriate(searchStr, groupAccessControl, "Group access control", matches); } } if (matches.isEmpty()) { return null; } final ComponentSearchResultDTO dto = new ComponentSearchResultDTO(); dto.setId(port.getIdentifier()); dto.setName(port.getName()); dto.setMatches(matches); return dto; }
From source file:org.apache.nifi.web.controller.ControllerSearchService.java
private ComponentSearchResultDTO search(final String searchStr, final ProcessorNode procNode) { final List<String> matches = new ArrayList<>(); final Processor processor = procNode.getProcessor(); addIfAppropriate(searchStr, procNode.getIdentifier(), "Id", matches); addIfAppropriate(searchStr, procNode.getVersionedComponentId().orElse(null), "Version Control ID", matches); addIfAppropriate(searchStr, procNode.getName(), "Name", matches); addIfAppropriate(searchStr, procNode.getComments(), "Comments", matches); // consider scheduling strategy if (SchedulingStrategy.EVENT_DRIVEN.equals(procNode.getSchedulingStrategy()) && StringUtils.containsIgnoreCase("event", searchStr)) { matches.add("Scheduling strategy: Event driven"); } else if (SchedulingStrategy.TIMER_DRIVEN.equals(procNode.getSchedulingStrategy()) && StringUtils.containsIgnoreCase("timer", searchStr)) { matches.add("Scheduling strategy: Timer driven"); } else if (SchedulingStrategy.PRIMARY_NODE_ONLY.equals(procNode.getSchedulingStrategy()) && StringUtils.containsIgnoreCase("primary", searchStr)) { // PRIMARY_NODE_ONLY has been deprecated as a SchedulingStrategy and replaced by PRIMARY as an ExecutionNode. matches.add("Scheduling strategy: On primary node"); }/* w w w .j a v a 2 s .c o m*/ // consider execution node if (ExecutionNode.PRIMARY.equals(procNode.getExecutionNode()) && StringUtils.containsIgnoreCase("primary", searchStr)) { matches.add("Execution node: primary"); } // consider scheduled state if (ScheduledState.DISABLED.equals(procNode.getScheduledState())) { if (StringUtils.containsIgnoreCase("disabled", searchStr)) { matches.add("Run status: Disabled"); } } else { if (StringUtils.containsIgnoreCase("invalid", searchStr) && procNode.getValidationStatus() == ValidationStatus.INVALID) { matches.add("Run status: Invalid"); } else if (StringUtils.containsIgnoreCase("validating", searchStr) && procNode.getValidationStatus() == ValidationStatus.VALIDATING) { matches.add("Run status: Validating"); } else if (ScheduledState.RUNNING.equals(procNode.getScheduledState()) && StringUtils.containsIgnoreCase("running", searchStr)) { matches.add("Run status: Running"); } else if (ScheduledState.STOPPED.equals(procNode.getScheduledState()) && StringUtils.containsIgnoreCase("stopped", searchStr)) { matches.add("Run status: Stopped"); } } for (final Relationship relationship : procNode.getRelationships()) { addIfAppropriate(searchStr, relationship.getName(), "Relationship", matches); } // Add both the actual class name and the component type. This allows us to search for 'Ghost' // to search for components that could not be instantiated. addIfAppropriate(searchStr, processor.getClass().getSimpleName(), "Type", matches); addIfAppropriate(searchStr, procNode.getComponentType(), "Type", matches); for (final Map.Entry<PropertyDescriptor, String> entry : procNode.getProperties().entrySet()) { final PropertyDescriptor descriptor = entry.getKey(); addIfAppropriate(searchStr, descriptor.getName(), "Property name", matches); addIfAppropriate(searchStr, descriptor.getDescription(), "Property description", matches); // never include sensitive properties values in search results if (descriptor.isSensitive()) { continue; } String value = entry.getValue(); // if unset consider default value if (value == null) { value = descriptor.getDefaultValue(); } // evaluate if the value matches the search criteria if (StringUtils.containsIgnoreCase(value, searchStr)) { matches.add("Property value: " + descriptor.getName() + " - " + value); } } // consider searching the processor directly if (processor instanceof Searchable) { final Searchable searchable = (Searchable) processor; final SearchContext context = new StandardSearchContext(searchStr, procNode, flowController.getControllerServiceProvider(), variableRegistry); // search the processor using the appropriate thread context classloader try (final NarCloseable x = NarCloseable.withComponentNarLoader(flowController.getExtensionManager(), processor.getClass(), processor.getIdentifier())) { final Collection<SearchResult> searchResults = searchable.search(context); if (CollectionUtils.isNotEmpty(searchResults)) { for (final SearchResult searchResult : searchResults) { matches.add(searchResult.getLabel() + ": " + searchResult.getMatch()); } } } catch (final Throwable t) { // log this as error } } if (matches.isEmpty()) { return null; } final ComponentSearchResultDTO result = new ComponentSearchResultDTO(); result.setId(procNode.getIdentifier()); result.setMatches(matches); result.setName(procNode.getName()); return result; }