use of com.ctrip.framework.apollo.biz.entity.Item in project apollo by ctripcorp.
the class NamespacePublishInfoTest method createItem.
private Item createItem(long namespaceId, String key, String value) {
Item item = new Item();
item.setNamespaceId(namespaceId);
item.setKey(key);
item.setValue(value);
return item;
}
use of com.ctrip.framework.apollo.biz.entity.Item in project apollo by ctripcorp.
the class ReleaseService method getNamespaceItems.
private Map<String, String> getNamespaceItems(Namespace namespace) {
List<Item> items = itemService.findItemsWithoutOrdered(namespace.getId());
Map<String, String> configurations = new HashMap<String, String>();
for (Item item : items) {
if (StringUtils.isEmpty(item.getKey())) {
continue;
}
configurations.put(item.getKey(), item.getValue());
}
return configurations;
}
use of com.ctrip.framework.apollo.biz.entity.Item in project apollo by ctripcorp.
the class NamespaceAcquireLockAspect method requireLockAdvice.
// delete item
@Before("@annotation(PreAcquireNamespaceLock) && args(itemId, operator, ..)")
public void requireLockAdvice(long itemId, String operator) {
Item item = itemService.findOne(itemId);
if (item == null) {
throw new BadRequestException("item not exist.");
}
acquireLock(item.getNamespaceId(), operator);
}
use of com.ctrip.framework.apollo.biz.entity.Item in project apollo by ctripcorp.
the class NamespaceUnlockAspect method requireLockAdvice.
// delete item
@After("@annotation(PreAcquireNamespaceLock) && args(itemId, operator, ..)")
public void requireLockAdvice(long itemId, String operator) {
Item item = itemService.findOne(itemId);
if (item == null) {
throw new BadRequestException("item not exist.");
}
tryUnlock(namespaceService.findOne(item.getNamespaceId()));
}
use of com.ctrip.framework.apollo.biz.entity.Item in project apollo by ctripcorp.
the class NamespaceUnlockAspectTest method testNamespaceModifyItem.
@Test
public void testNamespaceModifyItem() {
long namespaceId = 1;
Namespace namespace = createNamespace(namespaceId);
Release release = createRelease("{\"k1\":\"v1\"}");
List<Item> items = Arrays.asList(createItem("k1", "v2"));
when(releaseService.findLatestActiveRelease(namespace)).thenReturn(release);
when(itemService.findItemsWithOrdered(namespaceId)).thenReturn(items);
when(namespaceService.findParentNamespace(namespace)).thenReturn(null);
boolean isModified = namespaceUnlockAspect.isModified(namespace);
Assert.assertTrue(isModified);
}
Aggregations