use of org.apache.nifi.toolkit.cli.impl.client.nifi.ControllerClient in project nifi by apache.
the class UpdateRegistryClient method doExecute.
@Override
public VoidResult doExecute(final NiFiClient client, final Properties properties) throws NiFiClientException, IOException, MissingOptionException, CommandException {
final ControllerClient controllerClient = client.getControllerClient();
final String id = getRequiredArg(properties, CommandOption.REGISTRY_CLIENT_ID);
final RegistryClientEntity existingRegClient = controllerClient.getRegistryClient(id);
if (existingRegClient == null) {
throw new CommandException("Registry client does not exist for id " + id);
}
final String name = getArg(properties, CommandOption.REGISTRY_CLIENT_NAME);
final String url = getArg(properties, CommandOption.REGISTRY_CLIENT_URL);
final String desc = getArg(properties, CommandOption.REGISTRY_CLIENT_DESC);
if (StringUtils.isBlank(name) && StringUtils.isBlank(url) && StringUtils.isBlank(desc)) {
throw new CommandException("Name, url, and desc were all blank, nothing to update");
}
if (StringUtils.isNotBlank(name)) {
existingRegClient.getComponent().setName(name);
}
if (StringUtils.isNotBlank(url)) {
existingRegClient.getComponent().setUri(url);
}
if (StringUtils.isNotBlank(desc)) {
existingRegClient.getComponent().setDescription(desc);
}
final String clientId = getContext().getSession().getNiFiClientID();
existingRegClient.getRevision().setClientId(clientId);
controllerClient.updateRegistryClient(existingRegClient);
return VoidResult.getInstance();
}
Aggregations