Search in sources :

Example 36 with ConfigInfo

use of com.alibaba.nacos.config.server.model.ConfigInfo in project nacos by alibaba.

the class ConfigController method deleteConfigs.

/**
 * Execute delete config operation.
 *
 * @return java.lang.Boolean
 * @author klw
 * @Description: delete configuration based on multiple config ids
 * @Date 2019/7/5 10:26
 * @Param [request, response, dataId, group, tenant, tag]
 */
@DeleteMapping(params = "delType=ids")
@Secured(action = ActionTypes.WRITE, parser = ConfigResourceParser.class)
public RestResult<Boolean> deleteConfigs(HttpServletRequest request, HttpServletResponse response, @RequestParam(value = "ids") List<Long> ids) {
    String clientIp = RequestUtil.getRemoteIp(request);
    final Timestamp time = TimeUtils.getCurrentTime();
    List<ConfigInfo> configInfoList = persistService.removeConfigInfoByIds(ids, clientIp, null);
    if (CollectionUtils.isEmpty(configInfoList)) {
        return RestResultUtils.success(true);
    }
    for (ConfigInfo configInfo : configInfoList) {
        ConfigChangePublisher.notifyConfigChange(new ConfigDataChangeEvent(false, configInfo.getDataId(), configInfo.getGroup(), configInfo.getTenant(), time.getTime()));
        ConfigTraceService.logPersistenceEvent(configInfo.getDataId(), configInfo.getGroup(), configInfo.getTenant(), null, time.getTime(), clientIp, ConfigTraceService.PERSISTENCE_EVENT_REMOVE, null);
    }
    return RestResultUtils.success(true);
}
Also used : ConfigDataChangeEvent(com.alibaba.nacos.config.server.model.event.ConfigDataChangeEvent) ConfigInfo(com.alibaba.nacos.config.server.model.ConfigInfo) Timestamp(java.sql.Timestamp) DeleteMapping(org.springframework.web.bind.annotation.DeleteMapping) Secured(com.alibaba.nacos.auth.annotation.Secured)

Aggregations

ConfigInfo (com.alibaba.nacos.config.server.model.ConfigInfo)36 ArrayList (java.util.ArrayList)17 Timestamp (java.sql.Timestamp)11 HashMap (java.util.HashMap)10 Secured (com.alibaba.nacos.auth.annotation.Secured)8 ConfigDataChangeEvent (com.alibaba.nacos.config.server.model.event.ConfigDataChangeEvent)8 NacosException (com.alibaba.nacos.api.exception.NacosException)6 Page (com.alibaba.nacos.config.server.model.Page)6 CannotGetJdbcConnectionException (org.springframework.jdbc.CannotGetJdbcConnectionException)6 ConfigAllInfo (com.alibaba.nacos.config.server.model.ConfigAllInfo)5 NacosConfigException (com.alibaba.nacos.config.server.exception.NacosConfigException)4 PersistService (com.alibaba.nacos.config.server.service.repository.PersistService)4 Map (java.util.Map)4 PostMapping (org.springframework.web.bind.annotation.PostMapping)4 ConfigInfoAggr (com.alibaba.nacos.config.server.model.ConfigInfoAggr)3 ConfigKey (com.alibaba.nacos.config.server.model.ConfigKey)3 List (java.util.List)3 Test (org.junit.Test)3 RestResult (com.alibaba.nacos.common.model.RestResult)2 Pair (com.alibaba.nacos.common.utils.Pair)2