Commit b804bcc5 by 张乐 Committed by GitHub

Merge pull request #382 from nobodyiam/release-lock-fix

add namespace lock limit in create release service
parents 96d04faf 32dcdc2f
...@@ -5,6 +5,7 @@ import com.google.gson.Gson; ...@@ -5,6 +5,7 @@ import com.google.gson.Gson;
import com.ctrip.framework.apollo.biz.entity.Audit; import com.ctrip.framework.apollo.biz.entity.Audit;
import com.ctrip.framework.apollo.biz.entity.Item; import com.ctrip.framework.apollo.biz.entity.Item;
import com.ctrip.framework.apollo.biz.entity.Namespace; import com.ctrip.framework.apollo.biz.entity.Namespace;
import com.ctrip.framework.apollo.biz.entity.NamespaceLock;
import com.ctrip.framework.apollo.biz.entity.Release; import com.ctrip.framework.apollo.biz.entity.Release;
import com.ctrip.framework.apollo.biz.repository.ItemRepository; import com.ctrip.framework.apollo.biz.repository.ItemRepository;
import com.ctrip.framework.apollo.biz.repository.ReleaseRepository; import com.ctrip.framework.apollo.biz.repository.ReleaseRepository;
...@@ -79,6 +80,10 @@ public class ReleaseService { ...@@ -79,6 +80,10 @@ public class ReleaseService {
@Transactional @Transactional
public Release buildRelease(String name, String comment, Namespace namespace, String operator) { public Release buildRelease(String name, String comment, Namespace namespace, String operator) {
NamespaceLock lock = namespaceLockService.findLock(namespace.getId());
if (lock != null && lock.getDataChangeCreatedBy().equals(operator)) {
throw new BadRequestException(String.format("Current editor %s is not allowed to release the config", operator));
}
List<Item> items = itemRepository.findByNamespaceIdOrderByLineNumAsc(namespace.getId()); List<Item> items = itemRepository.findByNamespaceIdOrderByLineNumAsc(namespace.getId());
Map<String, String> configurations = new HashMap<String, String>(); Map<String, String> configurations = new HashMap<String, String>();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment