Search in sources :

Example 16 with CustomConfig

use of com.emc.storageos.db.client.model.CustomConfig in project coprhd-controller by CoprHD.

the class CustomConfigService method updateCustomConfig.

/**
 * Modify a config.
 *
 * @param id URN of the config
 * @param param create parameters
 * @brief Modify config
 * @return NamedRelatedResourceRep
 */
@PUT
@Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@Path("/{id}")
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.RESTRICTED_SYSTEM_ADMIN })
public CustomConfigRestRep updateCustomConfig(@PathParam("id") URI id, CustomConfigUpdateParam param) {
    CustomConfig config = getCustomConfigById(id, true);
    if (config.getSystemDefault()) {
        // system default could not be modified
        throw APIException.badRequests.systemDefaultConfigCouldNotBeModifiedOrDeactivated(config.getId());
    }
    customConfigHandler.validate(config.getConfigType(), config.getScope(), param.getValue(), false);
    if (param.getValue() != null && !param.getValue().isEmpty()) {
        config.setValue(param.getValue());
    }
    _dbClient.updateAndReindexObject(config);
    auditOp(OperationTypeEnum.UPDATE_CONFIG, true, null, config.getId().toString(), config.getLabel(), config.getScope());
    return DbObjectMapper.map(config);
}
Also used : CustomConfig(com.emc.storageos.db.client.model.CustomConfig) MapCustomConfig(com.emc.storageos.api.mapper.functions.MapCustomConfig) Path(javax.ws.rs.Path) Consumes(javax.ws.rs.Consumes) Produces(javax.ws.rs.Produces) PUT(javax.ws.rs.PUT) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 17 with CustomConfig

use of com.emc.storageos.db.client.model.CustomConfig in project coprhd-controller by CoprHD.

the class CustomConfigService method getCustomConfigs.

/**
 * List custom configurations.
 *
 * @brief List config names and ids
 * @return A reference to a CustomConfigList.
 */
@GET
@Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
@CheckPermission(roles = { Role.SYSTEM_ADMIN, Role.SYSTEM_MONITOR })
public CustomConfigList getCustomConfigs() {
    CustomConfigList configList = new CustomConfigList();
    List<URI> ids = _dbClient.queryByType(CustomConfig.class, true);
    Iterator<CustomConfig> iter = _dbClient.queryIterativeObjects(CustomConfig.class, ids);
    while (iter.hasNext()) {
        configList.getCustomConfigs().add(toNamedRelatedResource(iter.next()));
    }
    return configList;
}
Also used : CustomConfig(com.emc.storageos.db.client.model.CustomConfig) MapCustomConfig(com.emc.storageos.api.mapper.functions.MapCustomConfig) CustomConfigList(com.emc.storageos.model.customconfig.CustomConfigList) URI(java.net.URI) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET) CheckPermission(com.emc.storageos.security.authorization.CheckPermission)

Example 18 with CustomConfig

use of com.emc.storageos.db.client.model.CustomConfig in project coprhd-controller by CoprHD.

the class IsilonCommunicationInterface method getCustomConfigPath.

private String getCustomConfigPath() {
    String custompath = "";
    URIQueryResultList results = new URIQueryResultList();
    _dbClient.queryByConstraint(AlternateIdConstraint.Factory.getCustomConfigByConfigType(ISILON_PATH_CUSTOMIZATION), results);
    Iterator<URI> iter = results.iterator();
    List<CustomConfig> configList = new ArrayList<>();
    while (iter.hasNext()) {
        CustomConfig config = _dbClient.queryObject(CustomConfig.class, iter.next());
        if (config != null && !config.getInactive()) {
            configList.add(config);
            _log.info("Getting custom Config {}  ", config.getLabel());
        }
    }
    // only 1 config value means only default
    if (configList.size() == 1) {
        custompath = configList.get(0).getValue();
        _log.info("Selecting custom Config {} with value: {} ", configList.get(0).getLabel(), configList.get(0).getValue());
    // More than 1 config means return the custom one, NOT the default one..
    } else {
        for (CustomConfig conf : configList) {
            if (conf.getSystemDefault()) {
                continue;
            } else {
                custompath = conf.getValue();
                _log.info("Selecting custom Config {} with value: {} ", conf.getLabel(), conf.getValue());
            }
        }
    }
    return custompath;
}
Also used : CustomConfig(com.emc.storageos.db.client.model.CustomConfig) ArrayList(java.util.ArrayList) URI(java.net.URI) URIQueryResultList(com.emc.storageos.db.client.constraint.URIQueryResultList)

Aggregations

CustomConfig (com.emc.storageos.db.client.model.CustomConfig)18 MapCustomConfig (com.emc.storageos.api.mapper.functions.MapCustomConfig)10 Produces (javax.ws.rs.Produces)8 CheckPermission (com.emc.storageos.security.authorization.CheckPermission)7 Consumes (javax.ws.rs.Consumes)6 Path (javax.ws.rs.Path)6 URIQueryResultList (com.emc.storageos.db.client.constraint.URIQueryResultList)5 StringMap (com.emc.storageos.db.client.model.StringMap)4 ArrayList (java.util.ArrayList)4 POST (javax.ws.rs.POST)4 URI (java.net.URI)3 GET (javax.ws.rs.GET)3 CustomConfigType (com.emc.storageos.customconfigcontroller.CustomConfigType)2 CustomConfigList (com.emc.storageos.model.customconfig.CustomConfigList)2 HashMap (java.util.HashMap)2 BulkList (com.emc.storageos.api.service.impl.response.BulkList)1 SearchedResRepList (com.emc.storageos.api.service.impl.response.SearchedResRepList)1 CustomConfigConstraint (com.emc.storageos.customconfigcontroller.CustomConfigConstraint)1 RestLinkRep (com.emc.storageos.model.RestLinkRep)1 ConfigTypeScopeParam (com.emc.storageos.model.customconfig.ConfigTypeScopeParam)1