CLOUDSTACK-8592: updated quota email templates

This commit is contained in:
Abhinandan Prateek 2015-07-06 14:27:28 +05:30 committed by Rohit Yadav
parent 1345b9fbfb
commit 3103dcf7bc
3 changed files with 159 additions and 161 deletions

View File

@ -20,14 +20,8 @@ import javax.inject.Inject;
import org.apache.log4j.Logger;
import org.apache.cloudstack.api.APICommand;
import org.apache.cloudstack.api.ApiConstants;
import org.apache.cloudstack.api.ApiErrorCode;
import org.apache.cloudstack.api.BaseListCmd;
import org.apache.cloudstack.api.Parameter;
import org.apache.cloudstack.api.ServerApiException;
import org.apache.cloudstack.api.response.DomainResponse;
import org.apache.cloudstack.api.response.QuotaCreditsResponse;
import org.apache.cloudstack.context.CallContext;
import org.apache.cloudstack.quota.QuotaManager;
import org.apache.cloudstack.api.response.QuotaEmailTemplateResponse;
@ -42,45 +36,15 @@ private static final String s_name = "quotaemailtemplateresponse";
@Inject
private QuotaManager _quotaManager;
@Parameter(name = ApiConstants.ACCOUNT, type = CommandType.STRING, description = "Account Id for which quota credits need to be added")
private String accountName;
@Parameter(name = "templatename", type = CommandType.STRING, description = "The name of email template")
private String templateName;
@Parameter(name = ApiConstants.DOMAIN_ID, type = CommandType.UUID, entityType = DomainResponse.class, description = "Domain for which quota credits need to be added")
private Long domainId;
@Parameter(name = "templatetext", type = CommandType.STRING, description = "The text of the email")
private Long templateText;
@Parameter(name = "locale", type = CommandType.STRING, description = "The locale of the email text")
private Integer locale;
@Parameter(name = ApiConstants.VALUE, type = CommandType.INTEGER, entityType = DomainResponse.class, description = "Value of the credits to be added+, subtracted-")
private Integer value;
public String getAccountName() {
return accountName;
}
public void setAccountName(String accountName) {
this.accountName = accountName;
}
public Long getDomainId() {
return domainId;
}
public void setDomainId(Long domainId) {
this.domainId = domainId;
}
public Integer getValue() {
return value;
}
public void setValue(Integer value) {
this.value = value;
}
public QuotaEmailTemplateAddCmd() {
@ -102,14 +66,40 @@ public String getCommandName() {
@Override
public void execute() {
Long accountId = _accountService.finalyzeAccountId(accountName, domainId, null, true);
if (accountId==null){
throw new ServerApiException(ApiErrorCode.INTERNAL_ERROR, "The account does not exists or has been removed/disabled");
}
final QuotaCreditsResponse credit_response = _quotaManager.addQuotaCredits(accountId, domainId, value, CallContext.current().getCallingAccount().getId());
final QuotaEmailTemplateResponse templResponse = null;
setResponseObject(credit_response);
setResponseObject(templResponse);
}
public String getTemplateName() {
return templateName;
}
public void setTemplateName(String templateName) {
this.templateName = templateName;
}
public Long getTemplateText() {
return templateText;
}
public void setTemplateText(Long templateText) {
this.templateText = templateText;
}
public Integer getLocale() {
return locale;
}
public void setLocale(Integer locale) {
this.locale = locale;
}

View File

@ -40,28 +40,16 @@ public class QuotaEmailTemplateResponse extends BaseResponse {
@Param(description = "the domain ID of the iam policy")
private String domainId;
@SerializedName("credits")
@Param(description = "the credit deposited")
private String credits;
@SerializedName("balance")
@Param(description = "the balance credit in account")
private String balance;
@SerializedName("updated_by")
@SerializedName("sent_on")
@Param(description = "the account name of the admin who updated the credits")
private String updatedBy;
@SerializedName("updated_on")
@Param(description = "the account name of the admin who updated the credits")
private Timestamp updatedOn;
private Timestamp SentOn;
public QuotaEmailTemplateResponse() {
super();
}
public String getId() {
return id;
}
@ -92,43 +80,13 @@ public class QuotaEmailTemplateResponse extends BaseResponse {
}
public String getCredits() {
return credits;
public Timestamp getSentOn() {
return SentOn;
}
public void setCredits(String credits) {
this.credits = credits;
}
public String getBalance() {
return balance;
}
public void setBalance(String balance) {
this.balance = balance;
}
public String getUpdatedBy() {
return updatedBy;
}
public void setUpdatedBy(String updatedBy) {
this.updatedBy = updatedBy;
}
public Timestamp getUpdatedOn() {
return updatedOn;
}
public void setUpdatedOn(Timestamp updatedOn) {
this.updatedOn = updatedOn;
public void setSentOn(Timestamp sentOn) {
SentOn = sentOn;
}

View File

@ -16,7 +16,6 @@
//under the License.
package org.apache.cloudstack.quota;
import java.math.BigDecimal;
import java.util.Date;
import javax.persistence.Column;
@ -31,85 +30,136 @@ import org.apache.cloudstack.api.InternalIdentity;
@Entity
@Table(name = "quota_sent_emails")
public class QuotaSentEmailsVO implements InternalIdentity {
/*
*
CREATE TABLE `cloud_usage.quota_sent_emails` (
`id` bigint(20) NOT NULL AUTO_INCREMENT,
`from_address` varchar(1024) NOT NULL,
`to_address` varchar(1024) NOT NULL,
`cc_address` varchar(1024) DEFAULT NULL,
`bcc_address` varchar(1024) DEFAULT NULL,
`send_date` datetime NOT NULL,
`subject` varchar(1024) NOT NULL,
`mail_text` longtext NOT NULL,
`version` int(11) DEFAULT '0',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
*/
public QuotaSentEmailsVO(Long id, String fromAddress, String toAddress,
String ccAddress, String bccAddress, Date sendDate, String subject,
String mailText, Long version, Long updatedBy) {
super();
this.id = id;
this.fromAddress = fromAddress;
this.toAddress = toAddress;
this.ccAddress = ccAddress;
this.bccAddress = bccAddress;
this.sendDate = sendDate;
this.subject = subject;
this.mailText = mailText;
this.version = version;
this.updatedBy = updatedBy;
}
private static final long serialVersionUID = -7117933845287653210L;
@Id
@Column(name = "id")
private Long id;
private static final long serialVersionUID = -7117933845287653210L;
@Column(name = "from_address")
private String fromAddress = null;
@Id
@Column(name = "id")
private Long id;
@Column(name = "to_address")
private String toAddress = null;
@Column(name = "from_address")
private String fromAddress = null;
@Column(name = "cc_address")
private String ccAddress = null;
@Column(name = "to_address")
private String toAddress = null;
@Column(name = "bcc_address")
private String bccAddress = null;
@Column(name = "cc_address")
private String ccAddress = null;
@Column(name = "credit")
private BigDecimal credit;
@Column(name = "bcc_address")
private String bccAddress = null;
@Column(name = "updated_on")
@Temporal(value = TemporalType.TIMESTAMP)
private Date updatedOn = null;
@Column(name = "send_date")
@Temporal(value = TemporalType.TIMESTAMP)
private Date sendDate = null;
public QuotaSentEmailsVO() {
super();
}
@Column(name = "subject")
private String subject = null;
public BigDecimal getCredit() {
return credit;
}
@Column(name = "mail_text")
private String mailText = null;
public void setCredit(BigDecimal credit) {
this.credit = credit;
}
@Column(name = "version")
private Long version;
public Date getUpdatedOn() {
return updatedOn;
}
public QuotaSentEmailsVO() {
super();
}
public void setUpdatedOn(Date updatedOn) {
this.updatedOn = updatedOn;
}
@Column(name = "updated_by")
private Long updatedBy = null;
public Long getUpdatedBy() {
return updatedBy;
}
@Override
public long getId() {
// TODO Auto-generated method stub
return this.id;
}
public void setUpdatedBy(Long updatedBy) {
this.updatedBy = updatedBy;
}
public String getFromAddress() {
return fromAddress;
}
public void setId(Long id) {
this.id = id;
}
public void setFromAddress(String fromAddress) {
this.fromAddress = fromAddress;
}
@Column(name = "updated_by")
private Long updatedBy = null;
public String getToAddress() {
return toAddress;
}
@Override
public long getId() {
// TODO Auto-generated method stub
return this.id;
}
public void setToAddress(String toAddress) {
this.toAddress = toAddress;
}
public String getCcAddress() {
return ccAddress;
}
public void setCcAddress(String ccAddress) {
this.ccAddress = ccAddress;
}
public String getBccAddress() {
return bccAddress;
}
public void setBccAddress(String bccAddress) {
this.bccAddress = bccAddress;
}
public Date getSendDate() {
return sendDate;
}
public void setSendDate(Date sendDate) {
this.sendDate = sendDate;
}
public String getSubject() {
return subject;
}
public void setSubject(String subject) {
this.subject = subject;
}
public String getMailText() {
return mailText;
}
public void setMailText(String mailText) {
this.mailText = mailText;
}
public Long getVersion() {
return version;
}
public void setVersion(Long version) {
this.version = version;
}
public Long getUpdatedBy() {
return updatedBy;
}
public void setUpdatedBy(Long updatedBy) {
this.updatedBy = updatedBy;
}
}