use of com.emc.storageos.model.customconfig.VariableParam in project coprhd-controller by CoprHD.
the class CustomConfigService method getCustomConfigType.
/**
* Show config type.
*
* @brief Show config type details
* @return The config type data.
*/
@GET
@Path("/types/{config_name}")
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.SYSTEM_MONITOR })
public CustomConfigTypeRep getCustomConfigType(@PathParam("config_name") String configName) {
CustomConfigType item = customConfigHandler.getCustomConfigType(configName);
CustomConfigTypeRep result = new CustomConfigTypeRep();
if (item == null) {
log.info("No config type found for :", configName);
throw APIException.badRequests.invalidConfigType(configName);
}
result.setConfigName(configName);
result.setType(item.getType());
result.setConfigType(item.getConfigType());
Map<DataSourceVariable, Boolean> dataSources = item.getDataSourceVariables();
if (dataSources != null && !dataSources.isEmpty()) {
List<VariableParam> variables = new ArrayList<VariableParam>();
for (Map.Entry<DataSourceVariable, Boolean> entry : dataSources.entrySet()) {
DataSourceVariable datasource = entry.getKey();
VariableParam variable = new VariableParam();
variable.setName(datasource.getDisplayName());
variable.setSampleValue(datasource.getSample());
variable.setIsRecommended(entry.getValue());
variables.add(variable);
}
CustomConfigVariableList variableList = new CustomConfigVariableList(variables);
result.setVariables(variableList);
}
Map<String, String> scopes = item.getScope();
if (scopes != null && !scopes.isEmpty()) {
List<ConfigTypeScopeParam> scopeParms = new ArrayList<ConfigTypeScopeParam>();
for (Map.Entry<String, String> entry : scopes.entrySet()) {
String type = entry.getKey();
String value = entry.getValue();
List<String> values = new ArrayList<String>();
if (value.contains(SCOPE_DELIMETER)) {
values = java.util.Arrays.asList(value.split(SCOPE_DELIMETER));
} else {
values.add(value);
}
ConfigTypeScopeParam scopeparm = new ConfigTypeScopeParam(type, values);
scopeParms.add(scopeparm);
}
ScopeParamList scopeList = new ScopeParamList(scopeParms);
result.setScopes(scopeList);
}
// get rules
List<CustomConfigConstraint> constraints = item.getConstraints();
if (constraints != null && !constraints.isEmpty()) {
List<String> rules = new ArrayList<String>();
for (CustomConfigConstraint constraint : constraints) {
rules.add(constraint.getName());
}
CustomConfigRuleList ruleList = new CustomConfigRuleList(rules);
result.setRules(ruleList);
}
return result;
}
Aggregations