4343import org .apache .cloudstack .api .command .QuotaTariffCreateCmd ;
4444import org .apache .cloudstack .api .command .QuotaTariffListCmd ;
4545import org .apache .cloudstack .api .command .QuotaTariffUpdateCmd ;
46+ import org .apache .cloudstack .context .CallContext ;
4647import org .apache .cloudstack .quota .QuotaManager ;
4748import org .apache .cloudstack .quota .QuotaService ;
4849import org .apache .cloudstack .quota .QuotaStatement ;
7576import com .cloud .user .dao .UserDao ;
7677import com .cloud .utils .Pair ;
7778import com .cloud .utils .db .Filter ;
79+ import com .cloud .event .ActionEvent ;
80+ import com .cloud .event .EventTypes ;
7881
7982@ Component
8083public class QuotaResponseBuilderImpl implements QuotaResponseBuilder {
@@ -380,6 +383,7 @@ public Pair<List<QuotaTariffVO>, Integer> listQuotaTariffPlans(final QuotaTariff
380383 }
381384
382385 @ Override
386+ @ ActionEvent (eventType = EventTypes .EVENT_QUOTA_TARIFF_UPDATE , eventDescription = "updating Quota Tariff" )
383387 public QuotaTariffVO updateQuotaTariffPlan (QuotaTariffUpdateCmd cmd ) {
384388 String name = cmd .getName ();
385389 Double value = cmd .getValue ();
@@ -403,6 +407,9 @@ public QuotaTariffVO updateQuotaTariffPlan(QuotaTariffUpdateCmd cmd) {
403407 QuotaTariffVO newQuotaTariff = persistNewQuotaTariff (currentQuotaTariff , name , 0 , currentQuotaTariffStartDate , cmd .getEntityOwnerId (), endDate , value , description ,
404408 activationRule );
405409 _quotaTariffDao .updateQuotaTariff (currentQuotaTariff );
410+
411+ CallContext .current ().setEventResourceId (newQuotaTariff .getId ());
412+
406413 return newQuotaTariff ;
407414 }
408415
@@ -619,6 +626,7 @@ private Date createDateAtTheStartOfNextDay(LocalDate localDate) {
619626 }
620627
621628 @ Override
629+ @ ActionEvent (eventType = EventTypes .EVENT_QUOTA_TARIFF_CREATE , eventDescription = "creating Quota Tariff" )
622630 public QuotaTariffVO createQuotaTariff (QuotaTariffCreateCmd cmd ) {
623631 String name = cmd .getName ();
624632 int usageType = cmd .getUsageType ();
@@ -640,9 +648,14 @@ public QuotaTariffVO createQuotaTariff(QuotaTariffCreateCmd cmd) {
640648 throw new InvalidParameterValueException (String .format ("The quota tariff's start date [%s] cannot be less than now [%s]" , startDate , now ));
641649 }
642650
643- return persistNewQuotaTariff (null , name , usageType , startDate , cmd .getEntityOwnerId (), endDate , value , description , activationRule );
651+ QuotaTariffVO newQuotaTariff = persistNewQuotaTariff (null , name , usageType , startDate , cmd .getEntityOwnerId (), endDate , value , description , activationRule );
652+
653+ CallContext .current ().setEventResourceId (newQuotaTariff .getId ());
654+
655+ return newQuotaTariff ;
644656 }
645657
658+ @ ActionEvent (eventType = EventTypes .EVENT_QUOTA_TARIFF_DELETE , eventDescription = "removing Quota Tariff" )
646659 public boolean deleteQuotaTariff (String quotaTariffUuid ) {
647660 QuotaTariffVO quotaTariff = _quotaTariffDao .findByUuid (quotaTariffUuid );
648661
@@ -651,6 +664,9 @@ public boolean deleteQuotaTariff(String quotaTariffUuid) {
651664 }
652665
653666 quotaTariff .setRemoved (_quotaService .computeAdjustedTime (new Date ()));
667+
668+ CallContext .current ().setEventResourceId (quotaTariff .getId ());
669+
654670 return _quotaTariffDao .updateQuotaTariff (quotaTariff );
655671 }
656672}
0 commit comments