bbende commented on a change in pull request #3366: NIFI-6112: Add some useful commands to NiFi Toolkit for automating NiFi cluster construction. URL: https://github.com/apache/nifi/pull/3366#discussion_r266018763
########## File path: nifi-toolkit/nifi-toolkit-cli/src/main/java/org/apache/nifi/toolkit/cli/impl/result/ControllerServiceResult.java ########## @@ -0,0 +1,53 @@ +/* + * 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.toolkit.cli.impl.result; + +import org.apache.commons.lang3.Validate; +import org.apache.nifi.toolkit.cli.api.ResultType; +import org.apache.nifi.web.api.dto.BundleDTO; +import org.apache.nifi.web.api.dto.ControllerServiceDTO; +import org.apache.nifi.web.api.entity.ControllerServiceEntity; + +import java.io.IOException; +import java.io.PrintStream; + +public class ControllerServiceResult extends AbstractWritableResult<ControllerServiceEntity> { + + private final ControllerServiceEntity controllerServiceEntity; + + public ControllerServiceResult(ResultType resultType, ControllerServiceEntity controllerServiceEntity) { + super(resultType); + this.controllerServiceEntity = controllerServiceEntity; + Validate.notNull(controllerServiceEntity); + } + + @Override + public ControllerServiceEntity getResult() { + return controllerServiceEntity; + } + + @Override + protected void writeSimpleResult(PrintStream output) throws IOException { + final ControllerServiceDTO controllerServiceDTO = controllerServiceEntity.getComponent(); + final String[] typeSplit = controllerServiceDTO.getType().split("\\.", -1); + + final BundleDTO bundle = controllerServiceDTO.getBundle(); + output.printf("Name : %s\nType : %s %s\nBundle: %s - %s\nState : %s\n", + controllerServiceDTO.getName(), typeSplit[typeSplit.length - 1], bundle.getVersion(), + bundle.getGroup(), bundle.getArtifact(), controllerServiceDTO.getState()); Review comment: Using this produced the following: ``` #> nifi get-service -cs 81d6eda9-0169-1000-e2bc-59af37b52d79 Name : Sample SSL context service Type : StandardRestrictedSSLContextService 1.10.0-SNAPSHOT Bundle: org.apache.nifi - nifi-ssl-context-service-nar State : DISABLED ``` Could we make it so that Type showed the fully qualified classname, and the version was moved to the bundle part? I think that would be more consistent with how we typically represent it. As an example, the json output for this command shows: ``` "name" : "Sample SSL context service", "type" : "org.apache.nifi.ssl.StandardRestrictedSSLContextService", "bundle" : { "group" : "org.apache.nifi", "artifact" : "nifi-ssl-context-service-nar", "version" : "1.10.0-SNAPSHOT" }, ``` ---------------------------------------------------------------- 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
