Search in sources :

Example 1 with CustomConfigPreviewRep

use of com.emc.storageos.model.customconfig.CustomConfigPreviewRep 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)

Example 2 with CustomConfigPreviewRep

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

the class CustomConfigs method preview.

public static void preview(String configType, String scopeType, String scopeValue, String value) {
    try {
        CustomConfigPreviewRep preview = CustomConfigUtils.generatePreview(configType, scopeType, scopeValue, value);
        renderJSON(preview);
    } catch (ServiceErrorException ex) {
        ServiceErrorRestRep error = ex.getServiceError();
        renderJSON(error);
    }
}
Also used : ServiceErrorRestRep(com.emc.storageos.model.errorhandling.ServiceErrorRestRep) CustomConfigPreviewRep(com.emc.storageos.model.customconfig.CustomConfigPreviewRep) ServiceErrorException(com.emc.vipr.client.exceptions.ServiceErrorException)

Aggregations

CustomConfigPreviewRep (com.emc.storageos.model.customconfig.CustomConfigPreviewRep)2 StringMap (com.emc.storageos.db.client.model.StringMap)1 ConfigTypeScopeParam (com.emc.storageos.model.customconfig.ConfigTypeScopeParam)1 PreviewVariableParam (com.emc.storageos.model.customconfig.PreviewVariableParam)1 ScopeParam (com.emc.storageos.model.customconfig.ScopeParam)1 ServiceErrorRestRep (com.emc.storageos.model.errorhandling.ServiceErrorRestRep)1 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)1 ServiceErrorException (com.emc.vipr.client.exceptions.ServiceErrorException)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