Search in sources :

Example 1 with CustomConfigRestRep

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;
}
Also used : RelatedConfigTypeRep(com.emc.storageos.model.customconfig.RelatedConfigTypeRep) StringMap(com.emc.storageos.db.client.model.StringMap) CustomConfigRestRep(com.emc.storageos.model.customconfig.CustomConfigRestRep) RestLinkRep(com.emc.storageos.model.RestLinkRep) ScopeParam(com.emc.storageos.model.customconfig.ScopeParam) URISyntaxException(java.net.URISyntaxException) NamedURI(com.emc.storageos.db.client.model.NamedURI) URI(java.net.URI) Map(java.util.Map) StringMap(com.emc.storageos.db.client.model.StringMap)

Example 2 with CustomConfigRestRep

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)));
    }
}
Also used : CustomConfigRestRep(com.emc.storageos.model.customconfig.CustomConfigRestRep) ConfigTypeScopeParam(com.emc.storageos.model.customconfig.ConfigTypeScopeParam) ScopeParam(com.emc.storageos.model.customconfig.ScopeParam) ServiceErrorException(com.emc.vipr.client.exceptions.ServiceErrorException) FlashException(controllers.util.FlashException)

Aggregations

CustomConfigRestRep (com.emc.storageos.model.customconfig.CustomConfigRestRep)2 ScopeParam (com.emc.storageos.model.customconfig.ScopeParam)2 NamedURI (com.emc.storageos.db.client.model.NamedURI)1 StringMap (com.emc.storageos.db.client.model.StringMap)1 RestLinkRep (com.emc.storageos.model.RestLinkRep)1 ConfigTypeScopeParam (com.emc.storageos.model.customconfig.ConfigTypeScopeParam)1 RelatedConfigTypeRep (com.emc.storageos.model.customconfig.RelatedConfigTypeRep)1 ServiceErrorException (com.emc.vipr.client.exceptions.ServiceErrorException)1 FlashException (controllers.util.FlashException)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 Map (java.util.Map)1