use of com.emc.storageos.model.customconfig.CustomConfigRestRep in project coprhd-controller by CoprHD.
the class DbObjectMapper method map.
public static CustomConfigRestRep map(CustomConfig from) {
if (from == null) {
return null;
}
CustomConfigRestRep to = new CustomConfigRestRep();
to.setLink(new RestLinkRep("self", RestLinkFactory.newLink(from)));
// build the config type Link
String service = ResourceTypeEnum.CONFIG_TYPE.getService();
StringBuilder build = (new StringBuilder(service)).append('/').append(from.getConfigType());
try {
RelatedConfigTypeRep type = new RelatedConfigTypeRep();
type.setConfigName(from.getConfigType());
type.setSelfLink(new RestLinkRep("self", new URI(build.toString())));
to.setConfigType(type);
} catch (URISyntaxException e) {
// it should not happen
}
to.setId(from.getId());
to.setName(from.getLabel());
StringMap scopeMap = from.getScope();
ScopeParam scopeParm = new ScopeParam();
for (Map.Entry<String, String> entry : scopeMap.entrySet()) {
scopeParm.setType(entry.getKey());
scopeParm.setValue(entry.getValue());
}
to.setScope(scopeParm);
to.setValue(from.getValue());
to.setRegistered(from.getRegistered());
to.setSystemDefault(from.getSystemDefault());
return to;
}
use of com.emc.storageos.model.customconfig.CustomConfigRestRep in project coprhd-controller by CoprHD.
the class CustomConfigs method update.
@FlashException
public static void update(String id, String configType, String scopeType, String scopeValue, String value) {
CustomConfigRestRep customConfig = CustomConfigUtils.getCustomConfig(uri(id));
ScopeParam scope = customConfig.getScope();
try {
if (!scope.getType().equals(scopeType) || !scope.getValue().equals(scopeValue)) {
CustomConfigUtils.deleteCustomConfig(uri(id));
CustomConfigUtils.createCustomConfig(configType, scopeType, scopeValue, value);
} else {
CustomConfigUtils.updateCustomConfig(uri(id), value);
}
} catch (ServiceErrorException ex) {
flash.error(MessagesUtils.get("CustomConfigs.error.update", value, MessagesUtils.get("CustomConfigs.configType." + configType)));
}
}
Aggregations