Commit 04bb1e5f4f396efb62985bb274d7577620d82d4c

Authored by Igor Kulikov
1 parent d6c6a2e3

Add missing cases for email and sms api limits

@@ -125,6 +125,10 @@ public class TenantApiUsageState { @@ -125,6 +125,10 @@ public class TenantApiUsageState {
125 return apiUsageState.getDbStorageState(); 125 return apiUsageState.getDbStorageState();
126 case JS: 126 case JS:
127 return apiUsageState.getJsExecState(); 127 return apiUsageState.getJsExecState();
  128 + case EMAIL:
  129 + return apiUsageState.getEmailExecState();
  130 + case SMS:
  131 + return apiUsageState.getSmsExecState();
128 default: 132 default:
129 return ApiUsageStateValue.ENABLED; 133 return ApiUsageStateValue.ENABLED;
130 } 134 }
@@ -145,6 +149,12 @@ public class TenantApiUsageState { @@ -145,6 +149,12 @@ public class TenantApiUsageState {
145 case JS: 149 case JS:
146 apiUsageState.setJsExecState(value); 150 apiUsageState.setJsExecState(value);
147 break; 151 break;
  152 + case EMAIL:
  153 + apiUsageState.setEmailExecState(value);
  154 + break;
  155 + case SMS:
  156 + apiUsageState.setSmsExecState(value);
  157 + break;
148 } 158 }
149 return !currentValue.equals(value); 159 return !currentValue.equals(value);
150 } 160 }
@@ -304,6 +304,9 @@ public class DefaultMailService implements MailService { @@ -304,6 +304,9 @@ public class DefaultMailService implements MailService {
304 return "invoke"; 304 return "invoke";
305 case RE: 305 case RE:
306 return "process"; 306 return "process";
  307 + case EMAIL:
  308 + case SMS:
  309 + return "send";
307 default: 310 default:
308 throw new RuntimeException("Not implemented!"); 311 throw new RuntimeException("Not implemented!");
309 } 312 }
@@ -319,6 +322,9 @@ public class DefaultMailService implements MailService { @@ -319,6 +322,9 @@ public class DefaultMailService implements MailService {
319 return "invoked"; 322 return "invoked";
320 case RE: 323 case RE:
321 return "processed"; 324 return "processed";
  325 + case EMAIL:
  326 + case SMS:
  327 + return "sent";
322 default: 328 default:
323 throw new RuntimeException("Not implemented!"); 329 throw new RuntimeException("Not implemented!");
324 } 330 }
@@ -337,6 +343,10 @@ public class DefaultMailService implements MailService { @@ -337,6 +343,10 @@ public class DefaultMailService implements MailService {
337 return valueInM + " out of " + thresholdInM + " allowed JavaScript functions"; 343 return valueInM + " out of " + thresholdInM + " allowed JavaScript functions";
338 case RE_EXEC_COUNT: 344 case RE_EXEC_COUNT:
339 return valueInM + " out of " + thresholdInM + " allowed Rule Engine messages"; 345 return valueInM + " out of " + thresholdInM + " allowed Rule Engine messages";
  346 + case EMAIL_EXEC_COUNT:
  347 + return valueInM + " out of " + thresholdInM + " allowed Email messages";
  348 + case SMS_EXEC_COUNT:
  349 + return valueInM + " out of " + thresholdInM + " allowed SMS messages";
340 default: 350 default:
341 throw new RuntimeException("Not implemented!"); 351 throw new RuntimeException("Not implemented!");
342 } 352 }
@@ -353,6 +363,10 @@ public class DefaultMailService implements MailService { @@ -353,6 +363,10 @@ public class DefaultMailService implements MailService {
353 return "JavaScript functions " + getValueAsString(value) + " times"; 363 return "JavaScript functions " + getValueAsString(value) + " times";
354 case RE_EXEC_COUNT: 364 case RE_EXEC_COUNT:
355 return getValueAsString(value) + " Rule Engine messages"; 365 return getValueAsString(value) + " Rule Engine messages";
  366 + case EMAIL_EXEC_COUNT:
  367 + return getValueAsString(value) + " Email messages";
  368 + case SMS_EXEC_COUNT:
  369 + return getValueAsString(value) + " SMS messages";
356 default: 370 default:
357 throw new RuntimeException("Not implemented!"); 371 throw new RuntimeException("Not implemented!");
358 } 372 }
@@ -96,6 +96,10 @@ public class ApiUsageStateServiceImpl extends AbstractEntityService implements A @@ -96,6 +96,10 @@ public class ApiUsageStateServiceImpl extends AbstractEntityService implements A
96 new StringDataEntry(ApiFeature.RE.getApiStateKey(), ApiUsageStateValue.ENABLED.name()))); 96 new StringDataEntry(ApiFeature.RE.getApiStateKey(), ApiUsageStateValue.ENABLED.name())));
97 apiUsageStates.add(new BasicTsKvEntry(saved.getCreatedTime(), 97 apiUsageStates.add(new BasicTsKvEntry(saved.getCreatedTime(),
98 new StringDataEntry(ApiFeature.JS.getApiStateKey(), ApiUsageStateValue.ENABLED.name()))); 98 new StringDataEntry(ApiFeature.JS.getApiStateKey(), ApiUsageStateValue.ENABLED.name())));
  99 + apiUsageStates.add(new BasicTsKvEntry(saved.getCreatedTime(),
  100 + new StringDataEntry(ApiFeature.EMAIL.getApiStateKey(), ApiUsageStateValue.ENABLED.name())));
  101 + apiUsageStates.add(new BasicTsKvEntry(saved.getCreatedTime(),
  102 + new StringDataEntry(ApiFeature.SMS.getApiStateKey(), ApiUsageStateValue.ENABLED.name())));
99 tsService.save(tenantId, saved.getId(), apiUsageStates, 0L); 103 tsService.save(tenantId, saved.getId(), apiUsageStates, 0L);
100 104
101 List<TsKvEntry> profileThresholds = new ArrayList<>(); 105 List<TsKvEntry> profileThresholds = new ArrayList<>();