use of org.glassfish.api.admin.CommandRunner in project Payara by payara.
the class ResourceUtil method getParamMetaData.
/**
* Constructs and returns the parameter meta-data.
*
* @param commandName the command associated with the resource method
* @param commandParamsToSkip the command parameters for which not to
* include the meta-data.
* @param habitat the habitat
* @return Collection the meta-data for the parameter of the resource
* method.
*/
public static Collection<CommandModel.ParamModel> getParamMetaData(String commandName, Collection<String> commandParamsToSkip, ServiceLocator habitat) {
CommandModel cm = habitat.<CommandRunner>getService(CommandRunner.class).getModel(commandName, RestLogging.restLogger);
Collection<String> parameterNames = cm.getParametersNames();
ArrayList<CommandModel.ParamModel> metaData = new ArrayList<CommandModel.ParamModel>();
CommandModel.ParamModel paramModel;
for (String name : parameterNames) {
paramModel = cm.getModelFor(name);
String parameterName = (paramModel.getParam().primary()) ? "id" : paramModel.getName();
if (!commandParamsToSkip.contains(parameterName)) {
metaData.add(paramModel);
}
}
return metaData;
}
use of org.glassfish.api.admin.CommandRunner in project Payara by payara.
the class PayaraServerNameGenerator method getAllNamesInUse.
private static List<String> getAllNamesInUse(AdminCommandContext context) {
List<String> namesInUse = new ArrayList<>();
CommandRunner commandRunner = Globals.getDefaultBaseServiceLocator().getService(CommandRunner.class);
namesInUse.addAll(getInstanceNames(new DoNothingActionReporter(), context, commandRunner));
namesInUse.addAll(getNodeNames(new DoNothingActionReporter(), context, commandRunner));
namesInUse.addAll(getClusterNames(new DoNothingActionReporter(), context, commandRunner));
namesInUse.addAll(getDeploymentGroupNames(new DoNothingActionReporter(), context, commandRunner));
namesInUse.addAll(getConfigNames(new DoNothingActionReporter(), context, commandRunner));
return namesInUse;
}
use of org.glassfish.api.admin.CommandRunner in project Payara by payara.
the class PayaraServerNameGenerator method getDeploymentGroupNames.
private static List<String> getDeploymentGroupNames(ActionReport report, AdminCommandContext context, CommandRunner commandRunner) {
List<String> deploymentGroupNames = new ArrayList<>();
CommandRunner.CommandInvocation listDeploymentGroupsCommand = commandRunner.getCommandInvocation("list-deployment-groups", report, context.getSubject());
listDeploymentGroupsCommand.execute();
Properties extraProperties = listDeploymentGroupsCommand.report().getExtraProperties();
if (extraProperties != null) {
deploymentGroupNames.addAll((List<String>) extraProperties.get("listOfDeploymentGroups"));
}
return deploymentGroupNames;
}
use of org.glassfish.api.admin.CommandRunner in project Payara by payara.
the class PayaraServerNameGenerator method getClusterNames.
private static List<String> getClusterNames(ActionReport report, AdminCommandContext context, CommandRunner commandRunner) {
List<String> clusterNames = new ArrayList<>();
CommandRunner.CommandInvocation listClustersCommand = commandRunner.getCommandInvocation("list-clusters", report, context.getSubject());
listClustersCommand.execute();
Properties extraProperties = listClustersCommand.report().getExtraProperties();
if (extraProperties != null) {
clusterNames.addAll((Set<String>) extraProperties.get("clusterNames"));
}
return clusterNames;
}
use of org.glassfish.api.admin.CommandRunner in project Payara by payara.
the class PayaraServerNameGenerator method getInstanceNames.
private static List<String> getInstanceNames(ActionReport report, AdminCommandContext context, CommandRunner commandRunner) {
List<String> instanceNames = new ArrayList<>();
CommandRunner.CommandInvocation listInstancesCommand = commandRunner.getCommandInvocation("list-instances", report, context.getSubject());
ParameterMap commandParameters = new ParameterMap();
commandParameters.add("nostatus", "true");
listInstancesCommand.parameters(commandParameters);
listInstancesCommand.execute();
Properties extraProperties = listInstancesCommand.report().getExtraProperties();
if (extraProperties != null) {
List<Map<String, String>> instanceList = (List<Map<String, String>>) extraProperties.get("instanceList");
for (Map<String, String> instanceMap : instanceList) {
instanceNames.add(instanceMap.get("name"));
}
}
return instanceNames;
}
Aggregations