use of com.ctrip.framework.apollo.biz.entity.AccessKey in project apollo by ctripcorp.
the class AccessKeyServiceTest method testCreate.
@Test
public void testCreate() {
String appId = "someAppId";
String secret = "someSecret";
AccessKey entity = assembleAccessKey(appId, secret);
AccessKey accessKey = accessKeyService.create(appId, entity);
assertNotNull(accessKey);
}
use of com.ctrip.framework.apollo.biz.entity.AccessKey in project apollo by ctripcorp.
the class AccessKeyServiceTest method testCreateWithException.
@Test(expected = BadRequestException.class)
public void testCreateWithException() {
String appId = "someAppId";
String secret = "someSecret";
int maxCount = 5;
for (int i = 0; i <= maxCount; i++) {
AccessKey entity = assembleAccessKey(appId, secret);
accessKeyService.create(appId, entity);
}
}
use of com.ctrip.framework.apollo.biz.entity.AccessKey in project apollo by ctripcorp.
the class AccessKeyService method update.
@Transactional
public AccessKey update(String appId, AccessKey entity) {
long id = entity.getId();
String operator = entity.getDataChangeLastModifiedBy();
AccessKey accessKey = accessKeyRepository.findOneByAppIdAndId(appId, id);
if (accessKey == null) {
throw new BadRequestException("AccessKey not exist");
}
accessKey.setEnabled(entity.isEnabled());
accessKey.setDataChangeLastModifiedBy(operator);
accessKeyRepository.save(accessKey);
auditService.audit(AccessKey.class.getSimpleName(), id, Audit.OP.UPDATE, operator);
return accessKey;
}
use of com.ctrip.framework.apollo.biz.entity.AccessKey in project apollo by ctripcorp.
the class AccessKeyController method enable.
@PutMapping(value = "/apps/{appId}/accesskeys/{id}/enable")
public void enable(@PathVariable String appId, @PathVariable long id, String operator) {
AccessKey entity = new AccessKey();
entity.setId(id);
entity.setEnabled(true);
entity.setDataChangeLastModifiedBy(operator);
accessKeyService.update(appId, entity);
}
use of com.ctrip.framework.apollo.biz.entity.AccessKey in project apollo by ctripcorp.
the class AccessKeyServiceWithCache method handleDeletedAccessKeys.
private void handleDeletedAccessKeys(Set<Long> deletedIds) {
if (CollectionUtils.isEmpty(deletedIds)) {
return;
}
for (Long deletedId : deletedIds) {
AccessKey deleted = accessKeyIdCache.remove(deletedId);
if (deleted == null) {
continue;
}
accessKeyCache.remove(deleted.getAppId(), deleted);
logger.info("Found AccessKey deleted, {}", deleted);
}
}
Aggregations