diff --git a/client/tomcatconf/commands.properties.in b/client/tomcatconf/commands.properties.in index 485abea099c..32f33c98805 100644 --- a/client/tomcatconf/commands.properties.in +++ b/client/tomcatconf/commands.properties.in @@ -798,3 +798,4 @@ quotaTariffUpdate=1 quotaCredits=1 quotaEmailTemplateList=1 quotaEmailTemplateUpdate=1 +quotaIsEnabled=15 diff --git a/plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaBalanceCmd.java b/plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaBalanceCmd.java index ef9d49a3beb..32bbfc84980 100644 --- a/plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaBalanceCmd.java +++ b/plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaBalanceCmd.java @@ -33,7 +33,7 @@ import org.apache.cloudstack.api.response.QuotaResponseBuilder; import org.apache.cloudstack.quota.vo.QuotaBalanceVO; import org.apache.cloudstack.api.response.QuotaStatementItemResponse; -@APICommand(name = "quotaBalance", responseObject = QuotaStatementItemResponse.class, description = "Create a quota balance statement", since = "4.6.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) +@APICommand(name = "quotaBalance", responseObject = QuotaStatementItemResponse.class, description = "Create a quota balance statement", since = "4.7.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class QuotaBalanceCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(QuotaBalanceCmd.class); diff --git a/plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaCreditsCmd.java b/plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaCreditsCmd.java index ce00e23e5c9..125844548af 100644 --- a/plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaCreditsCmd.java +++ b/plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaCreditsCmd.java @@ -33,7 +33,7 @@ import org.apache.log4j.Logger; import javax.inject.Inject; -@APICommand(name = "quotaCredits", responseObject = QuotaCreditsResponse.class, description = "Add +-credits to an account", since = "4.6.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) +@APICommand(name = "quotaCredits", responseObject = QuotaCreditsResponse.class, description = "Add +-credits to an account", since = "4.7.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class QuotaCreditsCmd extends BaseCmd { @Inject diff --git a/plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaEmailTemplateListCmd.java b/plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaEmailTemplateListCmd.java index 8b717eb41ec..9d013207654 100644 --- a/plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaEmailTemplateListCmd.java +++ b/plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaEmailTemplateListCmd.java @@ -26,7 +26,7 @@ import org.apache.log4j.Logger; import javax.inject.Inject; -@APICommand(name = "quotaEmailTemplateList", responseObject = QuotaEmailTemplateResponse.class, description = "Lists all quota email templates", since = "4.6.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) +@APICommand(name = "quotaEmailTemplateList", responseObject = QuotaEmailTemplateResponse.class, description = "Lists all quota email templates", since = "4.7.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class QuotaEmailTemplateListCmd extends BaseListCmd { public static final Logger s_logger = Logger.getLogger(QuotaEmailTemplateListCmd.class); private static final String s_name = "quotaemailtemplatelistresponse"; diff --git a/plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaEmailTemplateUpdateCmd.java b/plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaEmailTemplateUpdateCmd.java index 469fd4dd002..a47a7832e8c 100644 --- a/plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaEmailTemplateUpdateCmd.java +++ b/plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaEmailTemplateUpdateCmd.java @@ -30,7 +30,7 @@ import org.apache.log4j.Logger; import javax.inject.Inject; import java.util.Arrays; -@APICommand(name = "quotaEmailTemplateUpdate", responseObject = SuccessResponse.class, description = "Updates existing email templates for quota alerts", since = "4.6.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) +@APICommand(name = "quotaEmailTemplateUpdate", responseObject = SuccessResponse.class, description = "Updates existing email templates for quota alerts", since = "4.7.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class QuotaEmailTemplateUpdateCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(QuotaEmailTemplateUpdateCmd.class); private static final String s_name = "quotaemailtemplateupdateresponse"; diff --git a/plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaEnabledCmd.java b/plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaEnabledCmd.java new file mode 100644 index 00000000000..a10be67599a --- /dev/null +++ b/plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaEnabledCmd.java @@ -0,0 +1,62 @@ +//Licensed to the Apache Software Foundation (ASF) under one +//or more contributor license agreements. See the NOTICE file +//distributed with this work for additional information +//regarding copyright ownership. The ASF licenses this file +//to you under the Apache License, Version 2.0 (the +//"License"); you may not use this file except in compliance +//with the License. You may obtain a copy of the License at +// +//http://www.apache.org/licenses/LICENSE-2.0 +// +//Unless required by applicable law or agreed to in writing, +//software distributed under the License is distributed on an +//"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +//KIND, either express or implied. See the License for the +//specific language governing permissions and limitations +//under the License. +package org.apache.cloudstack.api.command; + +import com.cloud.user.Account; + +import org.apache.cloudstack.api.APICommand; +import org.apache.cloudstack.api.BaseCmd; +import org.apache.cloudstack.api.response.QuotaEnabledResponse; +import org.apache.cloudstack.quota.QuotaService; +import org.apache.log4j.Logger; + + +import javax.inject.Inject; + +@APICommand(name = "quotaIsEnabled", responseObject = QuotaEnabledResponse.class, description = "Return true if the plugin is enabled", since = "4.7.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) +public class QuotaEnabledCmd extends BaseCmd { + + public static final Logger s_logger = Logger.getLogger(QuotaEnabledCmd.class); + + private static final String s_name = "quotaisenabledresponse"; + + @Inject + QuotaService _quotaService; + + public QuotaEnabledCmd() { + super(); + } + + @Override + public String getCommandName() { + return s_name; + } + + @Override + public void execute() { + Boolean isEnabled = _quotaService.isQuotaServiceEnabled(); + QuotaEnabledResponse response = new QuotaEnabledResponse(isEnabled); + response.setResponseName(getCommandName()); + setResponseObject(response); + } + + @Override + public long getEntityOwnerId() { + return Account.ACCOUNT_ID_SYSTEM; + } + +} diff --git a/plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaStatementCmd.java b/plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaStatementCmd.java index fa9796009b7..3efdf113da5 100644 --- a/plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaStatementCmd.java +++ b/plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaStatementCmd.java @@ -36,7 +36,7 @@ import org.apache.cloudstack.api.response.QuotaStatementItemResponse; import com.cloud.user.Account; -@APICommand(name = "quotaStatement", responseObject = QuotaStatementItemResponse.class, description = "Create a quota statement", since = "4.6.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) +@APICommand(name = "quotaStatement", responseObject = QuotaStatementItemResponse.class, description = "Create a quota statement", since = "4.7.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class QuotaStatementCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(QuotaStatementCmd.class); diff --git a/plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaSummaryCmd.java b/plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaSummaryCmd.java index 773bac6e0e4..b4f2001f95b 100644 --- a/plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaSummaryCmd.java +++ b/plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaSummaryCmd.java @@ -34,7 +34,7 @@ import java.util.List; import javax.inject.Inject; -@APICommand(name = "quotaSummary", responseObject = QuotaSummaryResponse.class, description = "Lists balance and quota usage for all accounts", since = "4.6.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) +@APICommand(name = "quotaSummary", responseObject = QuotaSummaryResponse.class, description = "Lists balance and quota usage for all accounts", since = "4.7.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class QuotaSummaryCmd extends BaseListCmd { public static final Logger s_logger = Logger.getLogger(QuotaSummaryCmd.class); private static final String s_name = "quotasummaryresponse"; diff --git a/plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaTariffListCmd.java b/plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaTariffListCmd.java index c1905944c52..9e7d1bc0206 100644 --- a/plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaTariffListCmd.java +++ b/plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaTariffListCmd.java @@ -34,7 +34,7 @@ import java.util.ArrayList; import java.util.Date; import java.util.List; -@APICommand(name = "quotaTariffList", responseObject = QuotaTariffResponse.class, description = "Lists all quota tariff plans", since = "4.6.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) +@APICommand(name = "quotaTariffList", responseObject = QuotaTariffResponse.class, description = "Lists all quota tariff plans", since = "4.7.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class QuotaTariffListCmd extends BaseListCmd { public static final Logger s_logger = Logger.getLogger(QuotaTariffListCmd.class); private static final String s_name = "quotatarifflistresponse"; diff --git a/plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaTariffUpdateCmd.java b/plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaTariffUpdateCmd.java index 04af3eca1ee..42aa825b094 100644 --- a/plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaTariffUpdateCmd.java +++ b/plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaTariffUpdateCmd.java @@ -33,7 +33,7 @@ import javax.inject.Inject; import java.util.Date; -@APICommand(name = "quotaTariffUpdate", responseObject = QuotaTariffResponse.class, description = "Update the tariff plan for a resource", since = "4.6.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) +@APICommand(name = "quotaTariffUpdate", responseObject = QuotaTariffResponse.class, description = "Update the tariff plan for a resource", since = "4.7.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class QuotaTariffUpdateCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(QuotaTariffUpdateCmd.class); private static final String s_name = "quotatariffupdateresponse"; diff --git a/plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaUpdateCmd.java b/plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaUpdateCmd.java index e3c0fd279fe..75e2c2c403a 100644 --- a/plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaUpdateCmd.java +++ b/plugins/database/quota/src/org/apache/cloudstack/api/command/QuotaUpdateCmd.java @@ -30,7 +30,7 @@ import java.util.Calendar; import javax.inject.Inject; -@APICommand(name = "quotaUpdate", responseObject = QuotaUpdateResponse.class, description = "Update quota calculations, alerts and statements", since = "4.6.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) +@APICommand(name = "quotaUpdate", responseObject = QuotaUpdateResponse.class, description = "Update quota calculations, alerts and statements", since = "4.7.0", requestHasSensitiveInfo = false, responseHasSensitiveInfo = false) public class QuotaUpdateCmd extends BaseCmd { public static final Logger s_logger = Logger.getLogger(QuotaUpdateCmd.class); diff --git a/plugins/database/quota/src/org/apache/cloudstack/api/response/QuotaEnabledResponse.java b/plugins/database/quota/src/org/apache/cloudstack/api/response/QuotaEnabledResponse.java new file mode 100644 index 00000000000..ddc2fd0817f --- /dev/null +++ b/plugins/database/quota/src/org/apache/cloudstack/api/response/QuotaEnabledResponse.java @@ -0,0 +1,37 @@ +// Licensed to the Apache Software Foundation (ASF) under one +// or more contributor license agreements. See the NOTICE file +// distributed with this work for additional information +// regarding copyright ownership. The ASF licenses this file +// to you under the Apache License, Version 2.0 (the +// "License"); you may not use this file except in compliance +// with the License. You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, +// software distributed under the License is distributed on an +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +// KIND, either express or implied. See the License for the +// specific language governing permissions and limitations +// under the License. +package org.apache.cloudstack.api.response; + +import com.google.gson.annotations.SerializedName; + +import org.apache.cloudstack.api.BaseResponse; + +import com.cloud.serializer.Param; + +public class QuotaEnabledResponse extends BaseResponse { + + @SerializedName("isenabled") + @Param(description = "is quota service enabled") + private Boolean isEnabled; + + + public QuotaEnabledResponse(Boolean isEnabled) { + this.isEnabled = isEnabled; + setObjectName("isenabled"); + } + +} diff --git a/plugins/database/quota/src/org/apache/cloudstack/quota/QuotaService.java b/plugins/database/quota/src/org/apache/cloudstack/quota/QuotaService.java index 8ee39b878af..6c645de9656 100644 --- a/plugins/database/quota/src/org/apache/cloudstack/quota/QuotaService.java +++ b/plugins/database/quota/src/org/apache/cloudstack/quota/QuotaService.java @@ -36,4 +36,6 @@ public interface QuotaService extends PluggableService { void setMinBalance(Long accountId, Double balance); + Boolean isQuotaServiceEnabled(); + } diff --git a/plugins/database/quota/src/org/apache/cloudstack/quota/QuotaServiceImpl.java b/plugins/database/quota/src/org/apache/cloudstack/quota/QuotaServiceImpl.java index 1b4c98f6997..9894f1163c8 100644 --- a/plugins/database/quota/src/org/apache/cloudstack/quota/QuotaServiceImpl.java +++ b/plugins/database/quota/src/org/apache/cloudstack/quota/QuotaServiceImpl.java @@ -29,6 +29,7 @@ import com.cloud.utils.db.Filter; import org.apache.cloudstack.api.command.QuotaBalanceCmd; import org.apache.cloudstack.api.command.QuotaCreditsCmd; import org.apache.cloudstack.api.command.QuotaEmailTemplateUpdateCmd; +import org.apache.cloudstack.api.command.QuotaEnabledCmd; import org.apache.cloudstack.api.command.QuotaEmailTemplateListCmd; import org.apache.cloudstack.api.command.QuotaStatementCmd; import org.apache.cloudstack.api.command.QuotaSummaryCmd; @@ -114,6 +115,7 @@ public class QuotaServiceImpl extends ManagerBase implements QuotaService, Confi @Override public List> getCommands() { final List> cmdList = new ArrayList>(); + cmdList.add(QuotaEnabledCmd.class); if (!isQuotaServiceEnabled()) { return cmdList; } @@ -140,6 +142,7 @@ public class QuotaServiceImpl extends ManagerBase implements QuotaService, Confi QuotaSmtpAuthType, QuotaSmtpSender }; } + @Override public Boolean isQuotaServiceEnabled() { return QuotaPluginEnabled.value(); } diff --git a/ui/plugins/quota/quota.js b/ui/plugins/quota/quota.js index 6051b2c8fc8..94a8730b5ef 100644 --- a/ui/plugins/quota/quota.js +++ b/ui/plugins/quota/quota.js @@ -25,12 +25,12 @@ id: 'quota', title: 'Quota', preFilter: function(args) { - var retval = $.ajax({ - url: createURL("listConfigurations&name=quota.enable.service"), - async: false - }); - var json = JSON.parse(retval.responseText); - return json.listconfigurationsresponse.configuration[0].value == 'true'; + var retval = $.ajax({ + url: createURL("quotaIsEnabled"), + async: false + }); + var json = JSON.parse(retval.responseText); + return json.quotaisenabledresponse.isenabled.isenabled; }, showOnNavigation: true, sectionSelect: {