Go to most recent revision | Blame | Compare with Previous | Last modification | View Log | RSS feed
package in.shop2020.support.controllers;import java.util.Collection;import in.shop2020.model.v1.order.TransactionService.Client;import in.shop2020.support.utils.ReportsUtils;import in.shop2020.thrift.clients.TransactionClient;import javax.servlet.http.HttpServletRequest;import javax.servlet.http.HttpSession;import org.apache.struts2.convention.annotation.InterceptorRef;import org.apache.struts2.convention.annotation.InterceptorRefs;import org.apache.struts2.convention.annotation.Result;import org.apache.struts2.convention.annotation.Results;import org.apache.struts2.interceptor.ServletRequestAware;import org.apache.thrift.transport.TTransportException;import org.slf4j.Logger;import org.slf4j.LoggerFactory;import com.opensymphony.xwork2.ActionSupport;@SuppressWarnings("serial")@InterceptorRefs({@InterceptorRef("defaultStack"),@InterceptorRef("login")})@Results({@Result(name="authfail", type="redirectAction", params = {"actionName" , "reports"})})public class RechargeTopupController extends ActionSupport implements ServletRequestAware {private static Logger logger = LoggerFactory.getLogger(RechargeTopupController.class);private HttpServletRequest request;private HttpSession session;private String errorMsg = "";private long companyId;private long amount;public String index() {if(!ReportsUtils.canAccessReport((Long)session.getAttribute(ReportsUtils.ROLE), request.getServletPath()))return "authfail";return "authsuccess";}public String create() {//addActionError("Error while writing COD report to the local file system");TransactionClient tsc = null;try {tsc = new TransactionClient();} catch (TTransportException e) {logger.error("Unable to establish connection to the transaction service", e);addActionError("Unable to establish connection to the transaction service");}Client txnClient = tsc.getClient();try {txnClient.topupCompanyWallet(companyId, amount);} catch (Exception e){logger.error("Unable to establish connection to the transaction service", e);addActionError("Unable to top up company wallet");}Collection<String> actionErrors = getActionErrors();return "authsuccess";}public long getWalletBalance(long companyId) throws Exception {Client txnClient = (new TransactionClient()).getClient();return txnClient.getWalletBalanceForCompany(companyId);}@Overridepublic void setServletRequest(HttpServletRequest request) {this.request = request;this.session = request.getSession();}public String getErrorMsg(){return this.errorMsg;}public void setCompanyId(long companyId) {this.companyId = companyId;}public long getCompanyId() {return companyId;}public void setAmount(long amount) {this.amount = amount;}public long getAmount() {return amount;}}