Github user drigodwin commented on a diff in the pull request:

    https://github.com/apache/brooklyn-server/pull/802#discussion_r134224747
  
    --- Diff: 
karaf/commands/src/main/java/org/apache/brooklyn/karaf/commands/EntityInfo.java 
---
    @@ -0,0 +1,137 @@
    +/*
    + * 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.brooklyn.karaf.commands;
    +
    +import org.apache.brooklyn.api.entity.Entity;
    +import org.apache.brooklyn.api.mgmt.ManagementContext;
    +import org.apache.brooklyn.api.sensor.AttributeSensor;
    +import org.apache.brooklyn.core.entity.Attributes;
    +import org.apache.brooklyn.core.mgmt.BrooklynTags;
    +import org.apache.brooklyn.karaf.commands.completers.EntityIdCompleter;
    +import org.apache.karaf.shell.api.action.Action;
    +import org.apache.karaf.shell.api.action.Argument;
    +import org.apache.karaf.shell.api.action.Command;
    +import org.apache.karaf.shell.api.action.Completion;
    +import org.apache.karaf.shell.api.action.Option;
    +import org.apache.karaf.shell.api.action.lifecycle.Reference;
    +import org.apache.karaf.shell.api.action.lifecycle.Service;
    +import org.apache.karaf.shell.support.ansi.SimpleAnsi;
    +import org.apache.karaf.shell.support.table.ShellTable;
    +
    +import java.util.Collections;
    +import java.util.Optional;
    +
    +@Command(scope = "brooklyn", name = "entity-info", description = "Display 
entity info")
    +@Service
    +public class EntityInfo implements Action {
    +
    +    @Reference
    +    private ManagementContext managementContext;
    +
    +    @Option(name = "-a", aliases = {"--all"}, description = "Display all 
information")
    +    private Boolean displayAll = false;
    +
    +    @Option(name = "-c", aliases = {"--children"}, description = "Display 
child information")
    +    private Boolean displayChildren = false;
    +
    +    @Option(name = "-s", aliases = {"--sensors"}, description = "Display 
sensor information")
    +    private Boolean displaySensors = false;
    +
    +    @Option(name = "--cfg", aliases = {"--config"}, description = "Display 
config information")
    +    private Boolean displayConfig = false;
    +
    +    @Option(name = "--blueprint", description = "Display blueprint")
    +    private Boolean displayBlueprint = false;
    +
    +    @Argument(index = 0, name = "id", description = "The entity id", 
required = true)
    +    @Completion(EntityIdCompleter.class)
    +    private String id = null;
    +
    +    @Override
    +    public Object execute() throws Exception {
    +        final Entity entity = 
managementContext.getEntityManager().getEntity(id);
    +        printHeader("Basic Information");
    +        final ShellTable infoTable = new ShellTable();
    +        infoTable.column("").bold();
    +        infoTable.column("");
    +        infoTable.noHeaders();
    +        infoTable.addRow().addContent("Application Id", 
entity.getApplicationId());
    --- End diff --
    
    If the entity id is invalid, this throws a NPE
    ```
    karaf@brooklyn()> brooklyn:entity-info invalid-id
    
    Basic Information
    -----------------
    Error executing command: java.lang.NullPointerException
    ```
    Catch this and report an error message?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

Reply via email to