Esempio n. 1
0
 @Override
 public String getConfigContextValue(int configId, int envId) {
   try {
     List<ConfigInstance> topInsts =
         configDao.findInstanceByConfig(configId, envId, ServiceConstants.MAX_AVAIL_CONFIG_INST);
     if (!topInsts.isEmpty()) {
       Iterator<ConfigInstance> iterator = topInsts.iterator();
       while (iterator.hasNext()) {
         ConfigInstance inst = iterator.next();
         if (inst.isDefault()) {
           iterator.remove();
           break;
         }
       }
     }
     JSONArray valueArray = new JSONArray();
     for (ConfigInstance topInst : topInsts) {
       JSONObject valueObj = new JSONObject();
       valueObj.put("value", resolveConfigFinalValue(topInst.getValue(), envId));
       valueObj.put("context", topInst.getContext());
       valueArray.put(valueObj);
     }
     return valueArray.toString();
   } catch (JSONException e) {
     Config config = getConfig(configId);
     throw new RuntimeBusinessException(
         "Cannot create config[key="
             + config.getKey()
             + "]'s register value, "
             + "plz check its instances' value.",
         e);
   }
 }
Esempio n. 2
0
 @Override
 public List<ConfigInstance> findInstancesByConfig(int configId, Integer maxPerEnv) {
   Config config = getConfig(configId);
   if (config == null) {
     return Collections.emptyList();
   }
   return configDao.findInstanceByConfig(config.getId(), maxPerEnv);
 }