use of com.ctrip.framework.apollo.biz.entity.AccessKey in project apollo by ctripcorp.
the class AccessKeyService method create.
@Transactional
public AccessKey create(String appId, AccessKey entity) {
long count = accessKeyRepository.countByAppId(appId);
if (count >= ACCESSKEY_COUNT_LIMIT) {
throw new BadRequestException("AccessKeys count limit exceeded");
}
entity.setId(0L);
entity.setAppId(appId);
entity.setDataChangeLastModifiedBy(entity.getDataChangeCreatedBy());
AccessKey accessKey = accessKeyRepository.save(entity);
auditService.audit(AccessKey.class.getSimpleName(), accessKey.getId(), Audit.OP.INSERT, accessKey.getDataChangeCreatedBy());
return accessKey;
}
use of com.ctrip.framework.apollo.biz.entity.AccessKey in project apollo by ctripcorp.
the class AccessKeyService method delete.
@Transactional
public void delete(String appId, long id, String operator) {
AccessKey accessKey = accessKeyRepository.findOneByAppIdAndId(appId, id);
if (accessKey == null) {
throw new BadRequestException("AccessKey not exist");
}
if (accessKey.isEnabled()) {
throw new BadRequestException("AccessKey should disable first");
}
accessKey.setDeleted(Boolean.TRUE);
accessKey.setDataChangeLastModifiedBy(operator);
accessKeyRepository.save(accessKey);
auditService.audit(AccessKey.class.getSimpleName(), id, Audit.OP.DELETE, operator);
}
Aggregations