Search in sources :

Example 1 with PreviewVariableParam

use of com.emc.storageos.model.customconfig.PreviewVariableParam in project coprhd-controller by CoprHD.

the class CustomConfigService method getCustomConfigPreviewValue.

/**
 * Get a config preview value.
 *
 * @param param create parameters
 * @brief Get config preview value
 * @return preview value
 */
@POST
@Path("/preview")
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.RESTRICTED_SYSTEM_ADMIN })
public CustomConfigPreviewRep getCustomConfigPreviewValue(CustomConfigPreviewParam param) {
    String configType = param.getConfigType();
    String theVal = param.getValue();
    ArgValidator.checkFieldNotEmpty(configType, CONFIG_TYPE);
    ArgValidator.checkFieldNotEmpty(theVal, VALUE);
    ScopeParam scopeParm = param.getScope();
    StringMap scope = null;
    if (scopeParm != null) {
        scope = new StringMap();
        scope.put(scopeParm.getType(), scopeParm.getValue());
    }
    List<PreviewVariableParam> variables = param.getPreviewVariables();
    Map<String, String> variableValues = null;
    if (variables != null && !variables.isEmpty()) {
        variableValues = new HashMap<String, String>();
        for (PreviewVariableParam variable : variables) {
            variableValues.put(variable.getVariableName(), variable.getValue());
        }
    }
    String result = customConfigHandler.getCustomConfigPreviewValue(configType, theVal, scope, variableValues);
    CustomConfigPreviewRep preview = new CustomConfigPreviewRep(result);
    return preview;
}
Also used : StringMap(com.emc.storageos.db.client.model.StringMap) CustomConfigPreviewRep(com.emc.storageos.model.customconfig.CustomConfigPreviewRep) ConfigTypeScopeParam(com.emc.storageos.model.customconfig.ConfigTypeScopeParam) ScopeParam(com.emc.storageos.model.customconfig.ScopeParam) PreviewVariableParam(com.emc.storageos.model.customconfig.PreviewVariableParam) Path(javax.ws.rs.Path) POST(javax.ws.rs.POST) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Aggregations

StringMap (com.emc.storageos.db.client.model.StringMap)1 ConfigTypeScopeParam (com.emc.storageos.model.customconfig.ConfigTypeScopeParam)1 CustomConfigPreviewRep (com.emc.storageos.model.customconfig.CustomConfigPreviewRep)1 PreviewVariableParam (com.emc.storageos.model.customconfig.PreviewVariableParam)1 ScopeParam (com.emc.storageos.model.customconfig.ScopeParam)1 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)1 Consumes (javax.ws.rs.Consumes)1 POST (javax.ws.rs.POST)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1