simonbence commented on a change in pull request #4123: NIFI-7188: Adding filter capabilities into search & prerequisite refactors URL: https://github.com/apache/nifi/pull/4123#discussion_r402149812
########## File path: nifi-nar-bundles/nifi-framework-bundle/nifi-framework/nifi-web/nifi-web-api/src/main/java/org/apache/nifi/web/search/resultenrichment/AbstractComponentSearchResultEnricher.java ########## @@ -0,0 +1,87 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.nifi.web.search.resultenrichment; + +import org.apache.nifi.authorization.Authorizer; +import org.apache.nifi.authorization.RequestAction; +import org.apache.nifi.authorization.user.NiFiUser; +import org.apache.nifi.groups.ProcessGroup; +import org.apache.nifi.web.api.dto.search.SearchResultGroupDTO; + +abstract class AbstractComponentSearchResultEnricher implements ComponentSearchResultEnricher { + protected final ProcessGroup processGroup; + protected final NiFiUser user; + protected final Authorizer authorizer; + + AbstractComponentSearchResultEnricher(final ProcessGroup processGroup, final NiFiUser user, final Authorizer authorizer) { + this.processGroup = processGroup; + this.user = user; + this.authorizer = authorizer; + } + + /** + * Builds the nearest versioned parent result group for a given user. + * + * @param group The containing group + * @param user The current NiFi user + * @return Versioned parent group + */ + protected SearchResultGroupDTO buildVersionedGroup(final ProcessGroup group, final NiFiUser user) { + if (group == null) { + return null; + } + + ProcessGroup tmpParent = group.getParent(); + ProcessGroup tmpGroup = group; + + // search for a versioned group by traversing the group tree up to the root + while (!tmpGroup.isRootGroup()) { + if (tmpGroup.getVersionControlInformation() != null) { + return buildResultGroup(tmpGroup, user); + } + + tmpGroup = tmpParent; + tmpParent = tmpGroup.getParent(); + } Review comment: Copied from previous implementation but makes sense, thanks ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] With regards, Apache Git Services
