You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@stratos.apache.org by sa...@apache.org on 2013/07/02 11:37:44 UTC

[02/23] Refactoring org.wso2.carbon to org.apache.stratos

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/ee2ab783/components/stratos/billing/org.wso2.carbon.billing.mgt/2.1.0/src/main/java/org/wso2/carbon/billing/mgt/services/BillingService.java
----------------------------------------------------------------------
diff --git a/components/stratos/billing/org.wso2.carbon.billing.mgt/2.1.0/src/main/java/org/wso2/carbon/billing/mgt/services/BillingService.java b/components/stratos/billing/org.wso2.carbon.billing.mgt/2.1.0/src/main/java/org/wso2/carbon/billing/mgt/services/BillingService.java
deleted file mode 100644
index 261f705..0000000
--- a/components/stratos/billing/org.wso2.carbon.billing.mgt/2.1.0/src/main/java/org/wso2/carbon/billing/mgt/services/BillingService.java
+++ /dev/null
@@ -1,606 +0,0 @@
-/*
-*  Copyright (c) 2005-2010, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-*
-*  WSO2 Inc. 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.wso2.carbon.billing.mgt.services;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.billing.core.BillingConstants;
-import org.wso2.carbon.billing.core.BillingEngine;
-import org.wso2.carbon.billing.core.BillingEngineContext;
-import org.wso2.carbon.billing.core.BillingManager;
-import org.wso2.carbon.billing.core.beans.OutstandingBalanceInfoBean;
-import org.wso2.carbon.billing.core.beans.PaginatedBalanceInfoBean;
-import org.wso2.carbon.billing.core.dataobjects.*;
-import org.wso2.carbon.billing.mgt.beans.*;
-import org.wso2.carbon.billing.mgt.util.Util;
-import org.wso2.carbon.stratos.common.constants.StratosConstants;
-import org.wso2.carbon.stratos.common.util.ClaimsMgtUtil;
-import org.wso2.carbon.stratos.common.util.CommonUtil;
-import org.wso2.carbon.core.AbstractAdmin;
-import org.wso2.carbon.registry.core.session.UserRegistry;
-import org.wso2.carbon.user.core.tenant.Tenant;
-import org.wso2.carbon.user.core.tenant.TenantManager;
-import org.wso2.carbon.utils.DataPaginator;
-import org.wso2.carbon.utils.multitenancy.MultitenantConstants;
-
-import java.text.SimpleDateFormat;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-
-public class BillingService extends AbstractAdmin {
-
-    private static final Log log = LogFactory.getLog(BillingService.class);
-
-    /**
-     * Gets the available billing periods of the available invoices for the
-     * current customer. Tenant id is taken from registry
-     * @return  an array of BillingPeriod objects
-     * @throws Exception Exception
-     */
-    public BillingPeriod[] getAvailableBillingPeriods() throws Exception {
-        UserRegistry registry = (UserRegistry) getGovernanceUserRegistry();
-        return getAvailableBillingPeriods(registry);
-    }
-
-    /**
-     * Gets the available billigs dates of a given tenant
-     * @param tenantDomain is the tenant domain
-     * @return an array of BillingPeriods
-     * @throws Exception if an error occurs during the process
-     */
-    public BillingPeriod[] getAvailableBillingPeriodsBySuperTenant(String tenantDomain) throws Exception{
-
-        BillingManager billingManager = Util.getBillingManager();
-        BillingEngine billingEngine =
-                billingManager.getBillingEngine(StratosConstants.MULTITENANCY_VIEWING_TASK_ID);
-        
-        List<Customer> customers = billingEngine.getCustomersWithName(tenantDomain);
-        if(customers.size()>0){
-            return getBillingPeriodsFromInvoices(billingEngine.getInvoices(customers.get(0)));
-        }else{
-            return new BillingPeriod[0];
-        }
-    }
-
-    /**
-     * Gets the invoice with a given invoice id
-     * @param invoiceId is the id of the invoice expected
-     * @return  a MultitenancyInvoice object
-     * @throws Exception Exception
-     */
-    public MultitenancyInvoice getPastInvoice(int invoiceId) throws Exception {
-        UserRegistry registry = (UserRegistry) getGovernanceUserRegistry();
-        return getPastInvoiceById(registry, invoiceId);
-    }
-
-    /**
-     * Gets the current invoice (interim invoice) of the current customer.
-     * Tenant id is taken from the registry
-     * @return a MultitenancyInvoice object
-     * @throws Exception Exception
-     */
-    public MultitenancyInvoice getCurrentInvoice() throws Exception {
-        UserRegistry registry = (UserRegistry) getGovernanceUserRegistry();
-        return getCurrentInvoiceOfCustomer(registry);
-    }
-
-    /**
-     * Adds a payment record to the BC_PAYMENT table. Sends a notification email
-     * after adding the record
-     * @param payment is the Payment object which contains the payment record details
-     * @param amount is the paid amount (had to pass this as a string)
-     * @return  the payment id for the added record
-     * @throws Exception if an error occurs during the operation
-     */
-    public int addPayment(Payment payment, String amount) throws Exception {
-        int paymentId = addPaymentRecord(payment, amount);
-        if(paymentId>0){
-            payment.setId(paymentId);
-            sendPaymentReceivedEmail(payment);
-        }
-        return paymentId;
-    }
-
-    /**
-     * Adds a payment record to the BC_REGISTRATION_PAYMENT table. Sends a notification email
-     * after adding the record
-     *
-     * @param payment   the Payment object which contains the payment record details
-     * @param amount    the registration fee paid
-     * @param usagePlan the registered usage plan
-     * @return the payment id for the added record
-     * @throws Exception thrown if an error occurs while adding the record
-     */
-    public int addRegistrationPayment(Payment payment, String amount, String usagePlan)
-            throws Exception {
-        BillingManager billingManager = Util.getBillingManager();
-        BillingEngine billingEngine =
-                billingManager.getBillingEngine(StratosConstants.MULTITENANCY_VIEWING_TASK_ID);
-        Cash cashAmount = new Cash(amount);
-        payment.setAmount(cashAmount);
-        int paymentId = billingEngine.addRegistrationPayment(payment, usagePlan);
-        if (paymentId > 0) {
-            payment.setId(paymentId);
-            sendRegistrationPaymentReceivedEmail(payment);
-        }
-        return paymentId;
-    }
-
-    /**
-     * Adds a payment record for invoice adjustment purposes
-     * @param payment is the Payment object which contains the adjustment details
-     * @param amount is the adjustment amount (had to pass this as a string)
-     * @return the payment id for the added adjustment record
-     * @throws Exception if an error occurs during the operation
-     */
-    public int makeAdjustment(Payment payment, String amount) throws Exception {
-        return addPaymentRecord(payment, amount);
-    }
-    
-    private int addPaymentRecord(Payment payment, String amount) throws Exception{
-        BillingManager billingManager = Util.getBillingManager();
-        BillingEngine billingEngine =
-                billingManager.getBillingEngine(StratosConstants.MULTITENANCY_VIEWING_TASK_ID);
-        Cash cashAmount = new Cash(amount);
-        payment.setAmount(cashAmount);
-        if(payment.getInvoice()!=null){
-            payment.setSubscriptions(billingEngine.getInvoiceSubscriptions(payment.getInvoice().getId()));
-        }
-        int paymentId = billingEngine.addPayment(payment);
-        return paymentId;
-    }
-
-    /**
-     * Gets the paginated BalanceInfoBean to be shown for the super tenant in the paginated mode
-     * @param pageNumber is the expected page number
-     * @return a PaginatedBalanceInfoBean object
-     * @throws Exception Exception
-     */
-    public PaginatedBalanceInfoBean getPaginatedBalances(int pageNumber) throws Exception {
-        BillingManager billingManager = Util.getBillingManager();
-        BillingEngine billingEngine =
-                billingManager.getBillingEngine(StratosConstants.MULTITENANCY_VIEWING_TASK_ID);
-        List<OutstandingBalanceInfoBean> balanceBeans = billingEngine.getAllOutstandingBalances(null); //no tenant domain
-        PaginatedBalanceInfoBean paginatedBalanceBean = new PaginatedBalanceInfoBean();
-        DataPaginator.doPaging(pageNumber, balanceBeans, paginatedBalanceBean);
-
-        return paginatedBalanceBean;
-    }
-
-    /**
-     * Gets OutstandingBalanceInfo bean(s).
-     * @param tenantDomain  is the domain of the expected tenant which the super-tenant
-     * wants to view the balance. If this is null, balance info of all the tenants will be shown
-     * @return  an array of OutstandingBalanceInfoBeans
-     * @throws Exception Exception
-     */
-    public OutstandingBalanceInfoBean[] getOutstandingBalance(String tenantDomain) throws Exception {
-        BillingManager billingManager = Util.getBillingManager();
-        BillingEngine billingEngine =
-                billingManager.getBillingEngine(StratosConstants.MULTITENANCY_VIEWING_TASK_ID);
-        List<OutstandingBalanceInfoBean> balanceBeans = billingEngine.getAllOutstandingBalanceInfoBeans(tenantDomain);
-        return balanceBeans.toArray(new OutstandingBalanceInfoBean[balanceBeans.size()]);
-    }
-
-    /**
-     * Adds a discount entry
-     * @param discount is the discount object which contains discount information
-     * @param tenantDomain is passed to get the tenant id and set to the discount object
-     * @return true or false based on the result of the operation
-     * @throws Exception if an error occurs during the operation
-     */
-    public boolean addDiscount (Discount discount, String tenantDomain) throws Exception {
-        TenantManager tenantManager = Util.getRealmService().getTenantManager();
-        int tenantId = tenantManager.getTenantId(tenantDomain);
-        if(tenantId== MultitenantConstants.INVALID_TENANT_ID){
-            throw new Exception("Invalid tenant domain submitted for a discount");
-        }
-        discount.setTenantId(tenantId);
-
-        BillingManager billingManager = Util.getBillingManager();
-        BillingEngine billingEngine = billingManager.getBillingEngine(StratosConstants.MULTITENANCY_VIEWING_TASK_ID);
-
-        boolean added = billingEngine.addDiscount(discount);
-        if(added){
-            log.info("Discount entry added for tenant: " + discount.getTenantId());
-        }
-        return added;
-    }
-    
-    /**
-     * Gets the past invoice for a given invoice id
-     * @param registry  is the GovernanceUserRegistry
-     * @param invoiceId is the expected invoice id
-     * @return  a MultitenancyInvoice object
-     * @throws Exception Exception
-     */
-    private MultitenancyInvoice getPastInvoiceById(UserRegistry registry,
-                                               int invoiceId) throws Exception {
-        BillingManager billingManager = Util.getBillingManager();
-        BillingEngine billingEngine =
-                billingManager.getBillingEngine(StratosConstants.MULTITENANCY_VIEWING_TASK_ID);
-
-        Invoice invoice = billingEngine.getInvoice(invoiceId);
-        if (invoice == null) {
-            return null;
-        }
-        
-        Customer customer = getCurrentCustomer(registry, billingEngine);
-        if (customer == null || customer.getId() != invoice.getCustomer().getId()) {
-            String msg = "Trying to looking at an invoice of another customer, customer: " +
-                            (customer == null ? "unknown" : customer.getId()) + ", invoice: " +
-                            invoice.getId() + ".";
-            log.error(msg);
-            throw new Exception(msg);
-        }
-        
-        MultitenancyInvoice multitenancyInvoice = new MultitenancyInvoice();
-        multitenancyInvoice.setInvoiceId(invoice.getId());
-        multitenancyInvoice.setBillingDate(invoice.getDate());
-        multitenancyInvoice.setBoughtForward(invoice.getBoughtForward().serializeToString());
-        multitenancyInvoice.setCarriedForward(invoice.getCarriedForward().serializeToString());
-        multitenancyInvoice.setStartDate(invoice.getStartDate());
-        multitenancyInvoice.setEndDate(invoice.getEndDate());
-        multitenancyInvoice.setTotalCost(invoice.getTotalCost().serializeToString());
-        multitenancyInvoice.setTotalPayments(invoice.getTotalPayment().serializeToString());
-
-        List<Subscription> subscriptions = invoice.getSubscriptions();
-        MultitenancySubscription[] multitenancySubscriptions =
-                new MultitenancySubscription[subscriptions.size()];
-        for (int i = 0; i < subscriptions.size(); i++) {
-            Subscription subscription = subscriptions.get(i);
-            MultitenancySubscription multitenancySubscription = new MultitenancySubscription();
-            multitenancySubscription.setSubscribedPackage(subscription.getItem().getName());
-            multitenancySubscription.setActiveSince(subscription.getActiveSince());
-            multitenancySubscription.setActiveUntil(subscription.getActiveUntil());
-            multitenancySubscription.setActive(subscription.isActive());
-
-            // now iterating the items
-            List<Item> billedItems = billingEngine.getBilledItems(subscription);
-            BilledEntry[] itemEntries = new BilledEntry[billedItems.size()];
-            for (int j = 0; j < billedItems.size(); j++) {
-                Item billedItem = billedItems.get(j);
-                if (billedItem.getName().equals(multitenancySubscription.getSubscribedPackage())) {
-                    // ignoring the parent item..
-                    continue;
-                }
-                BilledEntry itemEntry = new BilledEntry();
-                itemEntry.setName(billedItem.getDescription());
-                itemEntry.setCost(billedItem.getCost().serializeToString());
-                itemEntries[j] = itemEntry;
-            }
-            multitenancySubscription.setBilledEntries(itemEntries);
-            multitenancySubscriptions[i] = multitenancySubscription;
-        }
-
-        multitenancyInvoice.setSubscriptions(multitenancySubscriptions);
-
-        // getting the purchase orders
-        List<Payment> payments = invoice.getPayments();
-        if (payments != null) {
-            MultitenancyPurchaseOrder[] multitenancyPurchaseOrders =
-                    new MultitenancyPurchaseOrder[payments.size()];
-
-            for (int i = 0; i < payments.size(); i++) {
-                Payment payment = payments.get(i);
-                MultitenancyPurchaseOrder multitenancyPurchaseOrder =
-                        new MultitenancyPurchaseOrder();
-
-                multitenancyPurchaseOrder.setId(payment.getId());
-                multitenancyPurchaseOrder.setPaymentDate(payment.getDate());
-                multitenancyPurchaseOrder.setPayment(payment.getAmount().serializeToString());
-                multitenancyPurchaseOrder.setTransactionId(payment.getDescription());
-                multitenancyPurchaseOrders[i] = multitenancyPurchaseOrder;
-            }
-            multitenancyInvoice.setPurchaseOrders(multitenancyPurchaseOrders);
-        }
-
-        return multitenancyInvoice;
-    }
-
-    /**
-     * Gets the interim invoice of the current customer
-     * @param registry is the GovernanceUserRegistry
-     * @return an MultiTenancyInvoice object
-     * @throws Exception Exception
-     */
-    private MultitenancyInvoice getCurrentInvoiceOfCustomer(UserRegistry registry) throws Exception {
-        // we have to generate the invoice for this.
-        
-
-        BillingManager billingManager = Util.getBillingManager();
-        BillingEngine billingEngineViewer =
-                billingManager.getBillingEngine(StratosConstants.MULTITENANCY_VIEWING_TASK_ID);
-        Customer customer = getCurrentCustomer(registry, billingEngineViewer);
-        if (customer == null) {
-            // no customer => no invoices
-            return null;
-        }
-        
-        BillingEngineContext billingEngineContext = new BillingEngineContext();
-        billingEngineContext.setCustomer(customer);
-        billingEngineViewer.generateBill(billingEngineContext);
-
-        // reloading the customer with new updates
-        customer = billingEngineContext.getCustomer();
-        Invoice invoice = customer.getActiveInvoice();
-
-        // convert it and return
-        if (invoice == null) {
-            return null;
-        }
-
-        if (customer.getId() != invoice.getCustomer().getId()) {
-            String msg = "Trying to looking at an invoice of another customer, customer: " +
-                            customer.getId() + ", invoice: " + invoice.getId() + ".";
-            log.error(msg);
-            throw new Exception(msg);
-        }
-        
-        MultitenancyInvoice multitenancyInvoice = new MultitenancyInvoice();
-        multitenancyInvoice.setBillingDate(invoice.getDate());
-        multitenancyInvoice.setBoughtForward(invoice.getBoughtForward().serializeToString());
-        multitenancyInvoice.setCarriedForward(invoice.getCarriedForward().serializeToString());
-        multitenancyInvoice.setEndDate(invoice.getEndDate());
-        multitenancyInvoice.setInvoiceId(invoice.getId());
-        multitenancyInvoice.setStartDate(invoice.getStartDate());
-        
-        // getting the purchase orders
-        List<Payment> payments = invoice.getPayments();
-        MultitenancyPurchaseOrder[] multitenancyPurchaseOrders =
-                new MultitenancyPurchaseOrder[payments.size()];
-        for (int i = 0; i < payments.size(); i++) {
-            Payment payment = payments.get(i);
-            MultitenancyPurchaseOrder multitenancyPurchaseOrder = new MultitenancyPurchaseOrder();
-            multitenancyPurchaseOrder.setId(payment.getId());
-            multitenancyPurchaseOrder.setPaymentDate(payment.getDate());
-            multitenancyPurchaseOrder.setPayment(payment.getAmount().serializeToString());
-            multitenancyPurchaseOrder.setTransactionId(payment.getDescription());
-            multitenancyPurchaseOrders[i] = multitenancyPurchaseOrder;
-        }
-        multitenancyInvoice.setPurchaseOrders(multitenancyPurchaseOrders);
-
-        List<Subscription> subscriptions = invoice.getSubscriptions();
-        MultitenancySubscription[] multitenancySubscriptions =
-                new MultitenancySubscription[subscriptions.size()];
-        for (int i = 0; i < subscriptions.size(); i++) {
-            Subscription subscription = subscriptions.get(i);
-            MultitenancySubscription multitenancySubscription = new MultitenancySubscription();
-            multitenancySubscription.setSubscribedPackage(subscription.getItem().getName());
-            multitenancySubscription.setActiveSince(subscription.getActiveSince());
-            multitenancySubscription.setActiveUntil(subscription.getActiveUntil());
-            multitenancySubscription.setActive(subscription.isActive());
-
-            BilledEntry[] itemEntries;
-            List<? extends Item> subItems = subscription.getItem().getChildren();
-            if(subItems!=null){
-                itemEntries = new BilledEntry[subItems.size()];
-                for(int j=0; j<subItems.size(); j++){
-                    BilledEntry billedEntry = new BilledEntry();
-                    Item billedItem = subItems.get(j);
-                    billedEntry.setName(billedItem.getDescription()); //description
-                    if(billedItem.getCost()!=null){
-                        billedEntry.setCost(billedItem.getCost().toString());   //cost
-                    }else{
-                        billedEntry.setCost(new Cash("$0").toString());
-                    }
-                    itemEntries[j] = billedEntry;
-                }
-            }else{
-                itemEntries = new BilledEntry[0];
-            }
-
-
-            multitenancySubscription.setBilledEntries(itemEntries);
-            multitenancySubscriptions[i] = multitenancySubscription;
-        }
-        multitenancyInvoice.setSubscriptions(multitenancySubscriptions);
-
-        Cash totalCost = invoice.getTotalCost();
-        if (totalCost == null) {
-            totalCost = new Cash("$0");
-        }
-        multitenancyInvoice.setTotalCost(totalCost.serializeToString());
-        
-        Cash totalPaymentCash = invoice.getTotalPayment();
-        if (totalPaymentCash == null) {
-            totalPaymentCash = new Cash("$0");
-        }
-        multitenancyInvoice.setTotalPayments(totalPaymentCash.serializeToString());
-
-        return multitenancyInvoice;
-    }
-
-    /**
-     * Gets the tenant is and then fills the customer details
-     * @param userRegistry to get the tenant id
-     * @param billingEngine to fill the customer details
-     * @return   a customer object
-     * @throws Exception Exception
-     */
-    private Customer getCurrentCustomer(UserRegistry userRegistry,
-                                        BillingEngine billingEngine) throws Exception {
-        int currentTenantId = userRegistry.getTenantId();
-        TenantManager tenantManger = Util.getRealmService().getTenantManager();
-        Tenant currentTenant = (Tenant) tenantManger.getTenant(currentTenantId);
-
-        List<Customer> customers = billingEngine.getCustomersWithName(currentTenant.getDomain());
-        if (customers == null || customers.isEmpty()) {
-            return null;
-        }
-        return customers.get(0);
-    }
-
-    private BillingPeriod[] getAvailableBillingPeriods(UserRegistry registry) throws Exception {
-        BillingManager billingManager = Util.getBillingManager();
-        BillingEngine billingEngine =
-                billingManager.getBillingEngine(StratosConstants.MULTITENANCY_VIEWING_TASK_ID);
-        
-        Customer customer = getCurrentCustomer(registry, billingEngine);
-        if (customer == null) {
-            return new BillingPeriod[0];
-        }
-        
-        List<Invoice> invoices = billingEngine.getInvoices(customer);
-        if (invoices == null || invoices.size() == 0) {
-            return new BillingPeriod[0];
-        }
-        
-        return getBillingPeriodsFromInvoices(invoices);
-    }
-
-    /**
-     * Get the billing period details when given the invoices
-     * @param invoices is list of invoices
-     * @return an array of billing periods
-     */
-    private BillingPeriod[] getBillingPeriodsFromInvoices(List<Invoice> invoices){
-        BillingPeriod[] billingPeriods = new BillingPeriod[invoices.size()];
-        int index = 0;
-        for (Invoice invoice : invoices) {
-            BillingPeriod billingPeriod = new BillingPeriod();
-            billingPeriod.setInvoiceId(invoice.getId());
-            billingPeriod.setStartDate(invoice.getStartDate());
-            billingPeriod.setEndDate(invoice.getEndDate());
-            billingPeriod.setInvoiceDate(invoice.getDate());
-            billingPeriods[index++] = billingPeriod;
-        }
-        return billingPeriods;
-    }
-
-    /**
-     * Sends the payment received email to the customer
-     * @param payment is the payment object with the payment details 
-     * @throws Exception Exception
-     */
-    private void sendPaymentReceivedEmail(Payment payment) throws Exception{
-        BillingManager billingManager = Util.getBillingManager();
-        BillingEngine billingEngine =
-                billingManager.getBillingEngine(StratosConstants.MULTITENANCY_VIEWING_TASK_ID);
-        if(payment.getInvoice()!=null){
-            Invoice invoice = billingEngine.getInvoice(payment.getInvoice().getId());
-            if(invoice!=null){
-                Customer customer = invoice.getCustomer();
-                if(customer!=null){
-                    Map<String, String> mailParameters = new HashMap<String, String>();
-                    mailParameters.put("date",
-                            new SimpleDateFormat("dd-MMM-yyyy").format(payment.getDate()));
-                    mailParameters.put("transaction-id", payment.getDescription());
-                    mailParameters.put("amount", payment.getAmount().toString());
-                    mailParameters.put("invoice-id", String.valueOf(payment.getInvoice().getId()));
-
-                    try{
-                        String customerName =
-                                ClaimsMgtUtil.getFirstName(Util.getRealmService(), customer.getId());
-                        if(customerName!=null){
-                            mailParameters.put("customer-name", customerName);
-                        }else{
-                            mailParameters.put("customer-name", "");
-                        }
-
-                    }catch(Exception e){
-                        log.error("Could not get tenant information for tenant: " +
-                                customer.getName() + "\n" + e.getMessage());
-                        mailParameters.put("customer-name", "");
-                    }
-
-                    //sending the mail to the customer
-                    billingEngine.sendPaymentReceivedEmail(
-                            customer.getEmail(),
-                            BillingConstants.PAYMENT_RECEIVED_EMAIL_CUSTOMER_FILE,
-                            mailParameters);
-
-                    String financeEmail = CommonUtil.getStratosConfig().getFinanceNotificationEmail();
-                    //customer's first name is not important to finance team. Therefore it is
-                    //being replace with the domain name
-                    mailParameters.put("customer-name", customer.getName());
-                    billingEngine.sendPaymentReceivedEmail(
-                            financeEmail,
-                            BillingConstants.PAYMENT_RECEIVED_EMAIL_WSO2_FILE,
-                            mailParameters
-                    );
-                }else{
-                    String msg = "Cannot send email to customer. Customer details not available";
-                    log.error(msg);
-                    throw new Exception(msg);
-                }
-            }else{
-                String msg = "Cannot send email to customer. Invoice details not available";
-                log.error(msg);
-                throw new Exception(msg);
-            }
-        }else{
-            String msg = "Cannot send email to customer. Invoice Id is not available";
-            log.error(msg);
-            throw new Exception(msg);
-        }
-    }
-
-
-    private void sendRegistrationPaymentReceivedEmail(Payment payment) throws Exception {
-        BillingManager billingManager = Util.getBillingManager();
-        BillingEngine billingEngine = billingManager.getBillingEngine(StratosConstants.MULTITENANCY_VIEWING_TASK_ID);
-
-        String tenantDomain = payment.getDescription().split(" ")[0];
-        int tenantId = Util.getTenantManager().getTenantId(tenantDomain);
-        Tenant tenant = (Tenant) Util.getTenantManager().getTenant(tenantId);
-
-        Map<String, String> mailParameters = new HashMap<String, String>();
-        mailParameters.put("date", new SimpleDateFormat("dd-MMM-yyyy").format(payment.getDate()));
-        mailParameters.put("transaction-id", payment.getDescription().split(" ")[1]);
-        mailParameters.put("amount", payment.getAmount().toString());
-        mailParameters.put("invoice-id", "Registration - " + tenantDomain);
-        mailParameters.put("tenant-domain", tenantDomain);
-
-        String customerName = null;
-        String customerEmail = tenant.getEmail();
-        try {
-            customerName = ClaimsMgtUtil.getFirstName(Util.getRealmService(), tenantId);
-            if (customerName != null) {
-                mailParameters.put("customer-name", customerName);
-            } else {
-                mailParameters.put("customer-name", "");
-            }
-
-        } catch (Exception e) {
-            log.error("Could not get tenant information for tenant: " +
-                      customerName + "\n" + e.getMessage());
-            mailParameters.put("customer-name", "");
-        }
-
-        //sending the mail to the customer
-        billingEngine.sendPaymentReceivedEmail(
-                customerEmail,
-                BillingConstants.REGISTRATION_PAYMENT_RECEIVED_EMAIL_CUSTOMER_FILE,
-                mailParameters);
-
-        String financeEmail = CommonUtil.getStratosConfig().getFinanceNotificationEmail();
-        //customer's first name is not important to finance team. Therefore it is
-        //being replace with the domain name
-        mailParameters.put("customer-name", customerName);
-        billingEngine.sendPaymentReceivedEmail(
-                financeEmail,
-                BillingConstants.PAYMENT_RECEIVED_EMAIL_WSO2_FILE,
-                mailParameters
-        );
-
-
-    }
-
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/ee2ab783/components/stratos/billing/org.wso2.carbon.billing.mgt/2.1.0/src/main/java/org/wso2/carbon/billing/mgt/util/Util.java
----------------------------------------------------------------------
diff --git a/components/stratos/billing/org.wso2.carbon.billing.mgt/2.1.0/src/main/java/org/wso2/carbon/billing/mgt/util/Util.java b/components/stratos/billing/org.wso2.carbon.billing.mgt/2.1.0/src/main/java/org/wso2/carbon/billing/mgt/util/Util.java
deleted file mode 100644
index 7c354e4..0000000
--- a/components/stratos/billing/org.wso2.carbon.billing.mgt/2.1.0/src/main/java/org/wso2/carbon/billing/mgt/util/Util.java
+++ /dev/null
@@ -1,173 +0,0 @@
-/*
-*  Copyright (c) 2005-2011, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-*
-*  WSO2 Inc. 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.wso2.carbon.billing.mgt.util;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.osgi.framework.BundleContext;
-import org.osgi.util.tracker.ServiceTracker;
-import org.wso2.carbon.billing.core.*;
-import org.wso2.carbon.billing.mgt.api.DefaultTenantBilling;
-import org.wso2.carbon.billing.mgt.api.MultitenancyBillingInfo;
-import org.wso2.carbon.billing.mgt.handlers.MultitenancySubscriptionFeedingHandler;
-import org.wso2.carbon.stratos.common.TenantBillingService;
-import org.wso2.carbon.stratos.common.constants.StratosConstants;
-import org.wso2.carbon.registry.core.service.RegistryService;
-import org.wso2.carbon.usage.api.TenantUsageRetriever;
-import org.wso2.carbon.user.core.service.RealmService;
-import org.wso2.carbon.user.core.tenant.TenantManager;
-import org.wso2.carbon.throttling.agent.ThrottlingAgent;
-import org.wso2.carbon.utils.ConfigurationContextService;
-
-public class Util {
-    private static BillingManager billingManager = null;
-    private static DataAccessManager dataAccessManager = null;
-    private static RegistryService registryService;
-    private static RealmService realmService;
-    private static TenantUsageRetriever tenantUsageRetriever;
-    private static MultitenancyBillingInfo billingInfo;
-
-    public static ConfigurationContextService getContextService() {
-        return contextService;
-    }
-
-    public static void setContextService(ConfigurationContextService contextService) {
-        Util.contextService = contextService;
-    }
-
-    private static ServiceTracker throttlingRuleInvokerTracker = null;
-    private static BundleContext bundleContext;
-    private static Log log = LogFactory.getLog(Util.class);
-    private static ConfigurationContextService contextService;
-
-    public static synchronized void setRegistryService(RegistryService service) {
-        if (registryService == null) {
-            registryService = service;
-        }
-    }
-
-    public static synchronized void setRealmService(RealmService service) {
-        if (realmService == null) {
-            realmService = service;
-        }
-    }
-
-    public static void setTenantUsageRetriever(TenantUsageRetriever tenantUsageRetriever) {
-        Util.tenantUsageRetriever = tenantUsageRetriever;
-    }
-
-    public static RealmService getRealmService() {
-        return realmService;
-    }
-
-    public static RegistryService getRegistryService() {
-        return registryService;
-    }
-
-    public static TenantUsageRetriever getTenantUsageRetriever() {
-        return tenantUsageRetriever;
-    }
-
-    public static TenantManager getTenantManager() {
-        if (realmService == null) {
-            return null;
-        }
-        return realmService.getTenantManager();
-    }
-
-    public static BillingManager getBillingManager() {
-        return billingManager;
-    }
-
-    public static void setBillingManager(BillingManager billingManager) {
-        Util.billingManager = billingManager;
-    }
-
-    public static void registerSubscriptionFeedingHandlers(BundleContext bundleContext) {
-        bundleContext.registerService(BillingHandler.class.getName(),
-                new MultitenancySubscriptionFeedingHandler(), null);
-    }
-    
-    public static void registerTenantBillingService(BundleContext bundleContext) {
-        bundleContext.registerService(TenantBillingService.class.getName(),
-                new DefaultTenantBilling(), null);
-    }
-
-    public static void scheduleBilling() throws BillingException {
-        BillingEngine billingEngine =
-                billingManager.getBillingEngine(StratosConstants.MULTITENANCY_SCHEDULED_TASK_ID);
-        if (billingEngine != null) {
-            billingEngine.scheduleBilling();
-        } else {
-            log.info("No billing engine for scheduled tasks");
-        }
-
-    }
-
-    public static void registerBillingInfo(BundleContext bundleContext) throws Exception {
-        billingInfo = new MultitenancyBillingInfo();
-        bundleContext.registerService(MultitenancyBillingInfo.class.getName(), billingInfo, null);
-    }
-
-    public static MultitenancyBillingInfo getMultitenancyBillingInfo() {
-        return billingInfo;
-    }
-
-    public static DataAccessManager getDataAccessManager() {
-        return dataAccessManager;
-    }
-
-    public static void setDataAccessManager(DataAccessManager dataAccessManager) {
-        Util.dataAccessManager = dataAccessManager;
-    }
-
-    public static void initDataAccessManager() {
-        DataAccessManager dataAccessManager = new DataAccessManager(
-                billingManager.getBillingConfiguration().getDataSource());
-        Util.dataAccessManager = dataAccessManager;
-    }
-
-    /**
-     * This method used to create service tracker that tracks throttlingAgent service which
-     * registered when throttling agent starts
-     *
-     * @param bundleContext bundle context that belongs to component
-     */
-    public static void initializeThrottling(BundleContext bundleContext) {
-        throttlingRuleInvokerTracker = new ServiceTracker(bundleContext, ThrottlingAgent.class.getName(),
-                null);
-        throttlingRuleInvokerTracker.open();
-    }
-
-    /**
-     * This method updates the throttling rules for given tenant and update the cache at manager
-     *
-     * @param tenantId Tenant Id of the tenant that need to update throttling rules at manager
-     */
-    public static void executeThrottlingRules(int tenantId) {
-        try {
-            ThrottlingAgent embeddedRuleInvoker =
-                    (ThrottlingAgent) throttlingRuleInvokerTracker.getService();
-            if (embeddedRuleInvoker != null) {
-                embeddedRuleInvoker.executeThrottlingRules(tenantId);
-            }
-        } catch (Exception e) {
-            log.error("Error in executing throttling rules in manager" + e.toString());
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/ee2ab783/components/stratos/billing/org.wso2.carbon.billing.mgt/2.1.0/src/main/resources/META-INF/component.xml
----------------------------------------------------------------------
diff --git a/components/stratos/billing/org.wso2.carbon.billing.mgt/2.1.0/src/main/resources/META-INF/component.xml b/components/stratos/billing/org.wso2.carbon.billing.mgt/2.1.0/src/main/resources/META-INF/component.xml
deleted file mode 100644
index 71e6e35..0000000
--- a/components/stratos/billing/org.wso2.carbon.billing.mgt/2.1.0/src/main/resources/META-INF/component.xml
+++ /dev/null
@@ -1,29 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!--
-  ~  Copyright (c) 2009, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-  ~
-  ~  Licensed 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.
-  -->
-
-<component xmlns="http://products.wso2.org/carbon">
-    <ManagementPermissions>
-        <ManagementPermission>
-            <DisplayName>Billing</DisplayName>
-            <ResourceId>/permission/admin/billing</ResourceId>
-        </ManagementPermission>
-        <ManagementPermission>
-            <DisplayName>View Invoice</DisplayName>
-            <ResourceId>/permission/admin/billing/invoice</ResourceId>
-        </ManagementPermission>
-    </ManagementPermissions>
-</component>

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/ee2ab783/components/stratos/billing/org.wso2.carbon.billing.mgt/2.1.0/src/main/resources/META-INF/services.xml
----------------------------------------------------------------------
diff --git a/components/stratos/billing/org.wso2.carbon.billing.mgt/2.1.0/src/main/resources/META-INF/services.xml b/components/stratos/billing/org.wso2.carbon.billing.mgt/2.1.0/src/main/resources/META-INF/services.xml
deleted file mode 100644
index 3aaf3de..0000000
--- a/components/stratos/billing/org.wso2.carbon.billing.mgt/2.1.0/src/main/resources/META-INF/services.xml
+++ /dev/null
@@ -1,96 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-	<!--
-		! ! Copyright 2006 The Apache Software Foundation. ! ! Licensed 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. !
-	-->
-<serviceGroup>
-
-	<service name="MultitenancyBillingService" scope="transportsession">
-		<transports>
-			<transport>https</transport>
-		</transports>
-
-		<parameter name="ServiceClass" locked="false">
-			org.wso2.carbon.billing.mgt.services.BillingService
-        </parameter>
-
-        <parameter name="adminService" locked="true">true</parameter>
-
-        <parameter name="AuthorizationAction" locked="true">/permission/admin/billing/invoice</parameter>
-
-        <operation name="getPaginatedBalances">
-            <parameter name="superTenantService" locked="true">true</parameter>
-        </operation>
-
-        <operation name="getOutstandingBalance">
-            <parameter name="superTenantService" locked="true">true</parameter>
-        </operation>
-
-        <operation name="getAvailableBillingPeriodsBySuperTenant">
-            <parameter name="superTenantService" locked="true">true</parameter>
-        </operation>
-
-        <operation name="makeAdjustment">
-            <parameter name="superTenantService" locked="true">true</parameter>
-        </operation>
-
-        <operation name="addRegistrationPayment">
-            <parameter name="superTenantService" locked="true">true</parameter>
-        </operation>
-  	</service>
-
-    <service name="BillingDataAccessService" scope="transportsession">
-        <parameter name="AuthorizationAction" locked="true">/permission/admin/billing/invoice</parameter>
-
-		<transports>
-			<transport>https</transport>
-		</transports>
-
-		<parameter name="ServiceClass" locked="false">
-			org.wso2.carbon.billing.mgt.services.BillingDataAccessService
-        </parameter>
-
-        <parameter name="adminService" locked="true">true</parameter>
-
-        <operation name="changeSubscriptionBySuperTenant">
-            <parameter name="superTenantService" locked="true">true</parameter>
-        </operation>
-
-        <operation name="deactivateActiveSubscriptionBySuperTenant">
-            <parameter name="superTenantService" locked="true">true</parameter>
-        </operation>
-
-        <operation name="getActiveSubscriptionOfCustomerBySuperTenant">
-            <parameter name="superTenantService" locked="true">true</parameter>
-        </operation>
-
-        <operation name="addSubscription">
-            <parameter name="superTenantService" locked="true">true</parameter>
-        </operation>
-
-        <operation name="getSubscription">
-            <parameter name="superTenantService" locked="true">true</parameter>
-        </operation>
-
-        <operation name="getInactiveSubscriptionsOfCustomer">
-            <parameter name="superTenantService" locked="true">true</parameter>
-        </operation>
-
-        <operation name="activateSubscription">
-            <parameter name="superTenantService" locked="true">true</parameter>
-        </operation>
-        
-        <operation name="changeSubscriptionForTenant">
-            <parameter name="superTenantService" locked="true">true</parameter>
-        </operation>
-  	</service>
-
-    <parameter name="hiddenService" locked="true">true</parameter>
-</serviceGroup>

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/ee2ab783/components/stratos/billing/org.wso2.carbon.billing.mgt/2.1.3/pom.xml
----------------------------------------------------------------------
diff --git a/components/stratos/billing/org.wso2.carbon.billing.mgt/2.1.3/pom.xml b/components/stratos/billing/org.wso2.carbon.billing.mgt/2.1.3/pom.xml
deleted file mode 100644
index 03fb6c5..0000000
--- a/components/stratos/billing/org.wso2.carbon.billing.mgt/2.1.3/pom.xml
+++ /dev/null
@@ -1,117 +0,0 @@
-<!--
-# Copyright (c) 2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
-#
-# Licensed 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.
-  -->
-<project xmlns="http://maven.apache.org/POM/4.0.0"
-         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
-    <parent>
-        <groupId>org.wso2.carbon</groupId>
-        <artifactId>billing-parent</artifactId>
-        <version>2.1.0</version>
-	<relativePath>../../pom.xml</relativePath>
-    </parent>
-
-    <modelVersion>4.0.0</modelVersion>
-    <artifactId>org.wso2.carbon.billing.mgt</artifactId>
-    <version>2.1.3</version>
-    <packaging>bundle</packaging>
-    <name>WSO2 Stratos - Billing</name>
-
-    <build>
-
-        <plugins>
-            <plugin>
-                <groupId>org.apache.felix</groupId>
-                <artifactId>maven-scr-plugin</artifactId>
-            </plugin>
-            <plugin>
-                <groupId>org.apache.felix</groupId>
-                <artifactId>maven-bundle-plugin</artifactId>
-                
-                <extensions>true</extensions>
-                <configuration>
-                    <instructions>
-                        <Bundle-SymbolicName>${project.artifactId}</Bundle-SymbolicName>
-                        <Bundle-Name>${project.artifactId}</Bundle-Name>
-                        <!--<Require-Bundle>
-                            drools;visibility:=reexport
-                        </Require-Bundle>-->
-                        <Private-Package>
-                            org.wso2.carbon.billing.mgt.internal.*,
-                            org.wso2.carbon.billing.mgt.beans.*,
-                            org.wso2.carbon.billing.mgt.util.*,
-                        </Private-Package>
-                        <Export-Package>
-                            org.wso2.carbon.billing.mgt.dataobjects.*,
-                            org.wso2.carbon.billing.mgt.handlers.*,
-                            org.wso2.carbon.billing.mgt.api.*,
-                            org.wso2.carbon.billing.mgt.services.*,
-                        </Export-Package>
-                        <Import-Package>
-                            org.wso2.carbon.rule.*,
-                            org.quartz.*; version=2.1.1,
-                            org.apache.synapse.task.*,
-                            org.wso2.carbon.stratos.common.*,
-                            org.wso2.carbon.throttling.agent.client.*,
-                            org.wso2.carbon.throttling.agent.*,
-                            org.wso2.carbon.registry.core.*;version=1.0.1,
-                            org.wso2.carbon.registry.resource.*,
-                            !javax.xml.namespace,
-                            javax.xml.namespace; version=0.0.0,
-                            javax.servlet;version="${imp.pkg.version.javax.servlet}",
-                            javax.servlet.http;version="${imp.pkg.version.javax.servlet}",
-                            org.apache.axiom.*; version="${axiom.osgi.version.range}",
-                            *;resolution:=optional
-                        </Import-Package>
-                    </instructions>
-                </configuration>
-            </plugin>
-        </plugins>
-    </build>
-
-    <dependencies>
-
-        <dependency>
-            <groupId>org.wso2.carbon</groupId>
-            <artifactId>org.wso2.carbon.registry.core</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.wso2.carbon</groupId>
-            <artifactId>org.wso2.carbon.user.core</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>commons-logging</groupId>
-            <artifactId>commons-logging</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.wso2.carbon</groupId>
-			<artifactId>org.wso2.carbon.billing.core</artifactId>
-			<version>2.1.3</version>
-        </dependency>
-        <dependency>
-            <groupId>org.wso2.carbon</groupId>
-            <artifactId>org.wso2.carbon.usage</artifactId>
-	    <version>2.1.3</version>
-        </dependency>
-        <dependency>
-            <groupId>org.wso2.carbon</groupId>
-            <artifactId>org.wso2.carbon.stratos.common</artifactId>
-        </dependency>
-        <dependency>
-            <groupId>org.wso2.carbon</groupId>
-            <artifactId>org.wso2.carbon.throttling.agent</artifactId>
-        </dependency>
-    </dependencies>
-</project>

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/ee2ab783/components/stratos/billing/org.wso2.carbon.billing.mgt/2.1.3/src/main/java/org/wso2/carbon/billing/mgt/api/DefaultTenantBilling.java
----------------------------------------------------------------------
diff --git a/components/stratos/billing/org.wso2.carbon.billing.mgt/2.1.3/src/main/java/org/wso2/carbon/billing/mgt/api/DefaultTenantBilling.java b/components/stratos/billing/org.wso2.carbon.billing.mgt/2.1.3/src/main/java/org/wso2/carbon/billing/mgt/api/DefaultTenantBilling.java
deleted file mode 100644
index cd9b4bd..0000000
--- a/components/stratos/billing/org.wso2.carbon.billing.mgt/2.1.3/src/main/java/org/wso2/carbon/billing/mgt/api/DefaultTenantBilling.java
+++ /dev/null
@@ -1,201 +0,0 @@
-package org.wso2.carbon.billing.mgt.api;
-
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.wso2.carbon.billing.core.dataobjects.Customer;
-import org.wso2.carbon.billing.core.dataobjects.Item;
-import org.wso2.carbon.billing.core.dataobjects.Subscription;
-import org.wso2.carbon.billing.mgt.services.BillingDataAccessService;
-import org.wso2.carbon.stratos.common.TenantBillingService;
-import org.wso2.carbon.stratos.common.exception.StratosException;
-import org.wso2.carbon.stratos.common.internal.CloudCommonServiceComponent;
-import org.wso2.carbon.user.api.Tenant;
-import org.wso2.carbon.user.api.TenantManager;
-
-import java.util.Calendar;
-
-public class DefaultTenantBilling implements TenantBillingService {
-    
-    private static final Log log = LogFactory.getLog(DefaultTenantBilling.class);
-    
-    public void addUsagePlan(Tenant tenant, String usagePlan) throws StratosException {
-
-        Customer customer = new Customer();
-        customer.setName(tenant.getDomain());
-        customer.setEmail(tenant.getEmail());
-        customer.setStartedDate(tenant.getCreatedDate());
-        customer.setFullName(tenant.getAdminFirstName() + " " + tenant.getAdminLastName());
-
-        customer.setId(tenant.getId());
-        Subscription subscription = new Subscription();
-        subscription.setCustomer(customer);
-        subscription.setActive(false);
-        subscription.setActiveSince(Calendar.getInstance().getTime());
-        Item item = new Item();
-        subscription.setItem(item);
-        subscription.setSubscriptionPlan(usagePlan);
-        try {
-            BillingDataAccessService dataAccessService = new BillingDataAccessService();
-            dataAccessService.addSubscription(subscription);
-        } catch (Exception e) {
-            log.error("Could not add new subscription for tenant: " +
-                      tenant.getDomain() + " " + e.getMessage(), e);
-        }
-    }
-
-    public String getActiveUsagePlan(String tenantDomain) throws StratosException {
-        Subscription subscription;
-        try {
-            TenantManager tenantMan = CloudCommonServiceComponent.getRealmService().getTenantManager();
-            int tenantId = tenantMan.getTenantId(tenantDomain);
-            BillingDataAccessService billingDataAccessService = new BillingDataAccessService();
-            subscription = billingDataAccessService.getActiveSubscriptionOfCustomerBySuperTenant(tenantId);
-        } catch (Exception e) {
-            String msg = "Error occurred while getting the usage plan for tenant: " + 
-                         tenantDomain + " " + e.getMessage();
-            log.error(msg);
-            throw new StratosException(msg, e);
-        }
-
-        if(subscription!=null){
-            return subscription.getSubscriptionPlan();
-        }else{
-            return null;
-        }
-    }
-
-    public void updateUsagePlan(String tenantDomain, String usagePlan) throws StratosException {
-        try {
-            TenantManager tenantManager = CloudCommonServiceComponent.getRealmService().getTenantManager();
-            int tenantId = tenantManager.getTenantId(tenantDomain);
-
-            BillingDataAccessService billingDataAccessService = new BillingDataAccessService();
-            Subscription currentSubscription = billingDataAccessService.
-                    getActiveSubscriptionOfCustomerBySuperTenant(tenantId);
-
-            if (currentSubscription != null && currentSubscription.getSubscriptionPlan() != null) {
-                if (!currentSubscription.getSubscriptionPlan().equals(usagePlan)) {
-                    boolean updated = billingDataAccessService.changeSubscriptionBySuperTenant(tenantId, usagePlan);
-                    if (updated) {
-                        log.debug("Usage plan was changed successfully from " + currentSubscription.getSubscriptionPlan() +
-                                  " to " + usagePlan);
-                    } else {
-                        log.debug("Usage plan was not changed");
-                    }
-                }
-            }else{
-                //tenant does not have an active subscription. First we have to check whether the tenant
-                //is active. If he is active only we will add a new usage plan. Otherwise it is useless
-                //to add a usage plan to an inactive tenant
-                Tenant tenant = tenantManager.getTenant(tenantId);
-                if(tenant.isActive()){
-                    //we add a new subscription
-                    Subscription subscription = new Subscription();
-                    subscription.setActive(true);
-                    subscription.setSubscriptionPlan(usagePlan);
-                    subscription.setActiveSince(null);
-                    subscription.setActiveUntil(null);
-                    Customer customer = new Customer();
-                    customer.setName(tenantDomain);
-                    customer.setId(tenantId);
-                    subscription.setCustomer(customer);
-
-                    int subsId = billingDataAccessService.addSubscription(subscription);
-                    if(subsId>0){
-                        log.info("Added a new " + subscription.getSubscriptionPlan() + " plan for the tenant " +
-                                 tenantDomain);
-                    }
-                }
-            }
-        } catch (Exception e) {
-            String msg = "Error occurred while changing the subscription plan for tenant: " + tenantDomain;
-            log.error(msg, e);
-            throw new StratosException(msg, e);
-        }
-    }
-
-    public void activateUsagePlan(String tenantDomain) throws StratosException {
-        try {
-            TenantManager tenantManager = CloudCommonServiceComponent.getRealmService().getTenantManager();
-            int tenantId = tenantManager.getTenantId(tenantDomain);
-            BillingDataAccessService dataAccessService = new BillingDataAccessService();
-            Subscription subscription = dataAccessService.getActiveSubscriptionOfCustomerBySuperTenant(tenantId);
-            if (subscription != null) {
-                String msg = "Unable to activate the subscription for tenant: " + tenantId +
-                             ". An active subscription already exists";
-                log.info(msg);
-            } else {
-                Subscription[] inactiveSubscriptions = dataAccessService.getInactiveSubscriptionsOfCustomer(tenantId);
-                if (inactiveSubscriptions.length == 1) {
-                    //This is the scenario where the tenant has registered, but not activated yet
-                    subscription = inactiveSubscriptions[0];
-                    boolean activated = dataAccessService.activateSubscription(subscription.getId());
-                    if (activated) {
-                        log.info("Subscription was activated for tenant: " + tenantId);
-                    }
-                }else if(inactiveSubscriptions.length > 1){
-                    //this is the scenario where the tenant has been deactivated by admin and
-                    //again activated. Here, I am adding a new active subscription which is similar to the
-                    //last existed one
-                    Subscription subscriptionToAdd = inactiveSubscriptions[0];
-                    subscriptionToAdd.setActive(true);
-                    subscriptionToAdd.setActiveSince(null);
-                    subscriptionToAdd.setActiveUntil(null);
-
-                    int subsId = dataAccessService.addSubscription(subscriptionToAdd);
-                    if(subsId>0){
-                        log.info("New subscription: " + subscriptionToAdd.getSubscriptionPlan() +
-                                " added and it was activated for tenant: " + tenantId);
-                    }
-                }else{
-                    //this means there are no subscriptions. Lets handle this later
-                }
-            }
-        } catch (Exception e) {
-            String msg = "Error occurred while activating the subscription for tenant: " +
-                    tenantDomain;
-            log.error(msg, e);
-            throw new StratosException(msg, e);
-        }
-    }
-
-    public void deactivateActiveUsagePlan(String tenantDomain) throws StratosException {
-        try {
-            TenantManager tenantMan = 
-                    CloudCommonServiceComponent.getRealmService().getTenantManager();
-            int tenantId = tenantMan.getTenantId(tenantDomain);
-            BillingDataAccessService dataAccessService = new BillingDataAccessService();
-
-            Subscription subscription = 
-                    dataAccessService.getActiveSubscriptionOfCustomerBySuperTenant(tenantId);
-
-            if (subscription == null) {
-                String msg = "Unable to deactivate the subscription for tenant: " + tenantId +
-                        ". An active subscription doesn't exist";
-                log.info(msg);
-            } else {
-                boolean deactivated = 
-                        dataAccessService.deactivateActiveSubscriptionBySuperTenant(tenantId);
-                if (deactivated) {
-                    log.info("Active subscription of tenant " + tenantId + " was deactivated");
-                }
-            }
-        } catch (Exception e) {
-            String msg = "Error occurred while deactivating the active subscription of tenant: " +
-                    tenantDomain;
-            log.error(msg, e);
-            throw new StratosException(msg, e);
-        }
-    }
-
-    public void deleteBillingData(int tenantId) throws StratosException{
-        try {
-            BillingDataAccessService dataAccessService = new BillingDataAccessService();
-            dataAccessService.deleteBillingData(tenantId);
-        } catch (Exception e) {
-            String msg = "Error deleting subscription  for tenant: " + tenantId;
-            log.error(msg, e);
-            throw new StratosException(msg, e);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/ee2ab783/components/stratos/billing/org.wso2.carbon.billing.mgt/2.1.3/src/main/java/org/wso2/carbon/billing/mgt/api/MultitenancyBillingInfo.java
----------------------------------------------------------------------
diff --git a/components/stratos/billing/org.wso2.carbon.billing.mgt/2.1.3/src/main/java/org/wso2/carbon/billing/mgt/api/MultitenancyBillingInfo.java b/components/stratos/billing/org.wso2.carbon.billing.mgt/2.1.3/src/main/java/org/wso2/carbon/billing/mgt/api/MultitenancyBillingInfo.java
deleted file mode 100644
index eacb0d4..0000000
--- a/components/stratos/billing/org.wso2.carbon.billing.mgt/2.1.3/src/main/java/org/wso2/carbon/billing/mgt/api/MultitenancyBillingInfo.java
+++ /dev/null
@@ -1,178 +0,0 @@
-/*
- * Copyright (c) 2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * Licensed 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.wso2.carbon.billing.mgt.api;
-
-import org.apache.axiom.om.OMElement;
-import org.apache.axiom.om.xpath.AXIOMXPath;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
-import org.jaxen.JaxenException;
-import org.wso2.carbon.billing.core.BillingException;
-import org.wso2.carbon.billing.core.dataobjects.Cash;
-import org.wso2.carbon.billing.mgt.dataobjects.MultitenancyPackage;
-import org.wso2.carbon.stratos.common.constants.StratosConstants;
-import org.wso2.carbon.stratos.common.util.CommonUtil;
-import org.wso2.carbon.utils.CarbonUtils;
-
-import javax.xml.namespace.QName;
-import java.io.File;
-import java.io.FileInputStream;
-import java.util.ArrayList;
-import java.util.Iterator;
-import java.util.List;
-
-/**
- * Reads the multitenancy-packages.xml and populates the
- * multitenancy packages list
- */
-public class MultitenancyBillingInfo {
-    private static Log log = LogFactory.getLog(MultitenancyBillingInfo.class);
-    private static final String PACKAGE_DESCRIPTION_CONFIG_FILENAME = "multitenancy-packages.xml";
-    private static final String PACKAGE_DESCRIPTION_CONFIG_NS =
-            "http://wso2.com/carbon/multitenancy/billing/pacakges";
-    
-    List<MultitenancyPackage> multitenancyPackages = new ArrayList<MultitenancyPackage>();
-
-    public MultitenancyBillingInfo() throws BillingException {
-        // this should be only available to the super tenants..
-        multitenancyPackages = deserializePackageDescriptionConfig();
-    }
-
-    public List<MultitenancyPackage> getMultitenancyPackages() {
-        return multitenancyPackages;
-    }
-
-    /*
-     * Deserialize following XML
-    <packages xmlns="http://wso2.com/carbon/multitenancy/billing/pacakges">
-        <package name="multitenancy-free">
-            <!--<subscriptionCharge>0</subscriptionCharge>--> <!-- $ per month -->
-            <users>
-                <limit>5</limit>
-                <charge>0</charge> <!-- charge per month -->
-            </users>
-            <resourceVolume>
-                <limit>10</limit> <!--mb per user -->
-            </resourceVolume>
-            <bandwidth>
-                <limit>1000</limit> <!-- mb per user -->
-                <overuseCharge>0</overuseCharge> <!-- $ per user per month -->
-            </bandwidth>
-        </package>
-        <package name="multitenancy-small">
-            ...
-        </package>
-    </packages>
-     */
-    private List<MultitenancyPackage> deserializePackageDescriptionConfig() throws BillingException {
-        String configFilePath = CarbonUtils.getCarbonConfigDirPath() + File.separator +
-                StratosConstants.MULTITENANCY_CONFIG_FOLDER + File.separator +
-                PACKAGE_DESCRIPTION_CONFIG_FILENAME;
-        
-        OMElement packageConfigs;
-        try {
-            packageConfigs = CommonUtil.buildOMElement(new FileInputStream(configFilePath));
-        } catch (Exception e) {
-            String msg = "Error in deserializing the packageConfigs file: " + configFilePath + ".";
-            log.error(msg, e);
-            throw new BillingException(msg, e);
-        }
-
-        Iterator packageConfigsChildsIt = packageConfigs.getChildElements();
-        while (packageConfigsChildsIt.hasNext()) {
-            OMElement packageConfigEle = (OMElement) packageConfigsChildsIt.next();
-            if (!new QName(PACKAGE_DESCRIPTION_CONFIG_NS, "package").equals(
-                    packageConfigEle.getQName())) {
-                continue;
-            }
-            
-            MultitenancyPackage multitenancyPackage = new MultitenancyPackage();
-            String packageName = packageConfigEle.getAttributeValue(new QName("name"));
-            String subscriptionCharge = getPackageConfigValue("subscriptionCharge", packageConfigEle);
-            String usersLimit = getPackageConfigValue("users.limit", packageConfigEle);
-            String usersCharge = getPackageConfigValue("users.charge", packageConfigEle);
-
-            String resourceVolumeLimit =
-                    getPackageConfigValue("resourceVolume.limit", packageConfigEle);
-            String resourceVolumeOveruseCharge =
-                    getPackageConfigValue("resourceVolume.overuseCharge", packageConfigEle);
-            String bandwidthLimit = getPackageConfigValue("bandwidth.limit", packageConfigEle);
-            String bandwidthOveruseCharge =
-                    getPackageConfigValue("bandwidth.overuseCharge", packageConfigEle);
-            String cartridgeCPUHourLimit =
-                    getPackageConfigValue("cartridge.hourLimit", packageConfigEle);
-            String cartridgeCPUHourOverUsageCharge =
-                    getPackageConfigValue("cartridge.overUsageCharge", packageConfigEle);
-            int usersLimitInt = -1;
-            if (!usersLimit.equals("unlimited")) {
-                usersLimitInt = Integer.parseInt(usersLimit);
-            }
-            int resourceVolumeLimitInt = -1;
-            if (!resourceVolumeLimit.equals("unlimited")) {
-                resourceVolumeLimitInt = Integer.parseInt(resourceVolumeLimit);
-            }
-            int bandwidthLimitInt = -1;
-            if (!bandwidthLimit.equals("unlimited")) {
-                bandwidthLimitInt = Integer.parseInt(bandwidthLimit);
-            }
-            
-            int cartridgeCPUHourLimitInt = -1;
-            if(cartridgeCPUHourLimit!=null && !cartridgeCPUHourLimit.equals("unlimited")){
-                cartridgeCPUHourLimitInt = Integer.parseInt(cartridgeCPUHourLimit);
-            }
-
-
-            multitenancyPackage.setName(packageName);
-            multitenancyPackage.setSubscriptionCharge(new Cash(subscriptionCharge));
-            multitenancyPackage.setUsersLimit(usersLimitInt);
-            multitenancyPackage.setChargePerUser(new Cash(usersCharge));
-            multitenancyPackage.setResourceVolumeLimit(resourceVolumeLimitInt);
-            multitenancyPackage.setResourceVolumeOveruseCharge(new Cash(resourceVolumeOveruseCharge));
-            multitenancyPackage.setBandwidthLimit(bandwidthLimitInt);
-            multitenancyPackage.setBandwidthOveruseCharge(new Cash(bandwidthOveruseCharge));
-            multitenancyPackage.setCartridgeCPUHourLimit(cartridgeCPUHourLimitInt);
-            multitenancyPackage.setCartridgeCPUOveruseCharge(new Cash(cartridgeCPUHourOverUsageCharge));
-
-            
-            multitenancyPackages.add(multitenancyPackage);
-        }
-        return multitenancyPackages;
-    }
-
-    private String getPackageConfigValue(String key, OMElement packageNode) throws BillingException {
-        String qualifiedKey = "ns:" + key.replaceAll("\\.", "/ns:");
-        AXIOMXPath xpathExpression;
-        try {
-            xpathExpression = new AXIOMXPath(qualifiedKey);
-            xpathExpression.addNamespace("ns", PACKAGE_DESCRIPTION_CONFIG_NS);
-            List valueNodes = xpathExpression.selectNodes(packageNode);
-            if (valueNodes.isEmpty()) {
-                if (log.isDebugEnabled()) {
-                    String msg = "No results found parsing package configuration for key: " + 
-                            qualifiedKey + ".";
-                    log.debug(msg);
-                }
-                return null;
-            }
-            OMElement valueNode = (OMElement) valueNodes.get(0);
-            return valueNode.getText();
-        } catch (JaxenException e) {
-            String msg = "Error in retrieving the key: " + qualifiedKey + ".";
-            log.error(msg, e);
-            throw new BillingException(msg, e);
-        }
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/ee2ab783/components/stratos/billing/org.wso2.carbon.billing.mgt/2.1.3/src/main/java/org/wso2/carbon/billing/mgt/beans/BilledEntry.java
----------------------------------------------------------------------
diff --git a/components/stratos/billing/org.wso2.carbon.billing.mgt/2.1.3/src/main/java/org/wso2/carbon/billing/mgt/beans/BilledEntry.java b/components/stratos/billing/org.wso2.carbon.billing.mgt/2.1.3/src/main/java/org/wso2/carbon/billing/mgt/beans/BilledEntry.java
deleted file mode 100644
index 8b88b99..0000000
--- a/components/stratos/billing/org.wso2.carbon.billing.mgt/2.1.3/src/main/java/org/wso2/carbon/billing/mgt/beans/BilledEntry.java
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- * Copyright (c) 2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * Licensed 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.wso2.carbon.billing.mgt.beans;
-
-/**
- * Under a subscription there are billed items. For example
- * subscription fee, bandwidth overuse charge, storage overuse charge
- */
-public class BilledEntry {
-    String name;
-    String cost;
-
-    public String getName() {
-        return name;
-    }
-
-    public void setName(String name) {
-        this.name = name;
-    }
-
-    public String getCost() {
-        return cost;
-    }
-
-    public void setCost(String cost) {
-        this.cost = cost;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/ee2ab783/components/stratos/billing/org.wso2.carbon.billing.mgt/2.1.3/src/main/java/org/wso2/carbon/billing/mgt/beans/BillingPeriod.java
----------------------------------------------------------------------
diff --git a/components/stratos/billing/org.wso2.carbon.billing.mgt/2.1.3/src/main/java/org/wso2/carbon/billing/mgt/beans/BillingPeriod.java b/components/stratos/billing/org.wso2.carbon.billing.mgt/2.1.3/src/main/java/org/wso2/carbon/billing/mgt/beans/BillingPeriod.java
deleted file mode 100644
index 76ff4e6..0000000
--- a/components/stratos/billing/org.wso2.carbon.billing.mgt/2.1.3/src/main/java/org/wso2/carbon/billing/mgt/beans/BillingPeriod.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (c) 2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * Licensed 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.wso2.carbon.billing.mgt.beans;
-
-import java.util.Date;
-
-/**
- * This class is used when providing available invoices to the user
- */
-public class BillingPeriod {
-    private int invoiceId;
-    private Date startDate;
-    private Date endDate;
-    private Date invoiceDate;
-
-    public int getInvoiceId() {
-        return invoiceId;
-    }
-
-    public void setInvoiceId(int invoiceId) {
-        this.invoiceId = invoiceId;
-    }
-
-    public Date getStartDate() {
-        return new Date(startDate.getTime());
-    }
-
-    public void setStartDate(Date startDate) {
-        this.startDate = new Date(startDate.getTime());
-    }
-
-    public Date getEndDate() {
-        return new Date(endDate.getTime());
-    }
-
-    public void setEndDate(Date endDate) {
-        this.endDate = new Date(endDate.getTime());
-    }
-
-    public Date getInvoiceDate() {
-        return new Date(invoiceDate.getTime());
-    }
-
-    public void setInvoiceDate(Date invoiceDate) {
-        this.invoiceDate = new Date(invoiceDate.getTime());
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/ee2ab783/components/stratos/billing/org.wso2.carbon.billing.mgt/2.1.3/src/main/java/org/wso2/carbon/billing/mgt/beans/MultitenancyInvoice.java
----------------------------------------------------------------------
diff --git a/components/stratos/billing/org.wso2.carbon.billing.mgt/2.1.3/src/main/java/org/wso2/carbon/billing/mgt/beans/MultitenancyInvoice.java b/components/stratos/billing/org.wso2.carbon.billing.mgt/2.1.3/src/main/java/org/wso2/carbon/billing/mgt/beans/MultitenancyInvoice.java
deleted file mode 100644
index 994a161..0000000
--- a/components/stratos/billing/org.wso2.carbon.billing.mgt/2.1.3/src/main/java/org/wso2/carbon/billing/mgt/beans/MultitenancyInvoice.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * Copyright (c) 2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * Licensed 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.wso2.carbon.billing.mgt.beans;
-
-import java.util.Arrays;
-import java.util.Date;
-
-public class MultitenancyInvoice {
-    private int invoiceId;
-    private Date billingDate;
-    private Date startDate;
-    private Date endDate;
-    private String boughtForward;
-    private String carriedForward;
-    private String totalPayments;
-    private String totalCost;
-    private boolean lastInvoice;
-    private MultitenancySubscription[] subscriptions;
-    private MultitenancyPurchaseOrder[] purchaseOrders;
-
-    public int getInvoiceId() {
-        return invoiceId;
-    }
-
-    public void setInvoiceId(int invoiceId) {
-        this.invoiceId = invoiceId;
-    }
-
-    public Date getBillingDate() {
-        return new Date(billingDate.getTime());
-    }
-
-    public void setBillingDate(Date billingDate) {
-        this.billingDate = new Date(billingDate.getTime());
-    }
-
-    public Date getStartDate() {
-        return new Date(startDate.getTime());
-    }
-
-    public void setStartDate(Date startDate) {
-        this.startDate = new Date(startDate.getTime());
-    }
-
-    public Date getEndDate() {
-        return new Date(endDate.getTime());
-    }
-
-    public void setEndDate(Date endDate) {
-        this.endDate = new Date(endDate.getTime());
-    }
-
-    public String getBoughtForward() {
-        return boughtForward;
-    }
-
-    public void setBoughtForward(String boughtForward) {
-        this.boughtForward = boughtForward;
-    }
-
-    public String getCarriedForward() {
-        return carriedForward;
-    }
-
-    public void setCarriedForward(String carriedForward) {
-        this.carriedForward = carriedForward;
-    }
-
-    public String getTotalPayments() {
-        return totalPayments;
-    }
-
-    public void setTotalPayments(String totalPayments) {
-        this.totalPayments = totalPayments;
-    }
-
-    public String getTotalCost() {
-        return totalCost;
-    }
-
-    public void setTotalCost(String totalCost) {
-        this.totalCost = totalCost;
-    }
-
-    public boolean isLastInvoice() {
-        return lastInvoice;
-    }
-
-    public void setLastInvoice(boolean lastInvoice) {
-        this.lastInvoice = lastInvoice;
-    }
-
-    public MultitenancySubscription[] getSubscriptions() {
-        return Arrays.copyOf(subscriptions, subscriptions.length);
-    }
-
-    public void setSubscriptions(MultitenancySubscription[] subscriptions) {
-        this.subscriptions = Arrays.copyOf(subscriptions, subscriptions.length);
-    }
-
-    public MultitenancyPurchaseOrder[] getPurchaseOrders() {
-        return Arrays.copyOf(purchaseOrders, purchaseOrders.length);
-    }
-
-    public void setPurchaseOrders(MultitenancyPurchaseOrder[] purchaseOrders) {
-        this.purchaseOrders = Arrays.copyOf(purchaseOrders, purchaseOrders.length);
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/ee2ab783/components/stratos/billing/org.wso2.carbon.billing.mgt/2.1.3/src/main/java/org/wso2/carbon/billing/mgt/beans/MultitenancyPurchaseOrder.java
----------------------------------------------------------------------
diff --git a/components/stratos/billing/org.wso2.carbon.billing.mgt/2.1.3/src/main/java/org/wso2/carbon/billing/mgt/beans/MultitenancyPurchaseOrder.java b/components/stratos/billing/org.wso2.carbon.billing.mgt/2.1.3/src/main/java/org/wso2/carbon/billing/mgt/beans/MultitenancyPurchaseOrder.java
deleted file mode 100644
index ffddda0..0000000
--- a/components/stratos/billing/org.wso2.carbon.billing.mgt/2.1.3/src/main/java/org/wso2/carbon/billing/mgt/beans/MultitenancyPurchaseOrder.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*
- * Copyright (c) 2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * Licensed 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.wso2.carbon.billing.mgt.beans;
-
-import java.util.Date;
-
-/**
- * Payment record details
- */
-public class MultitenancyPurchaseOrder {
-    private Date paymentDate;
-    private String payment;
-    private int id;
-    private String transactionId;
-
-    public Date getPaymentDate() {
-        return new Date(paymentDate.getTime());
-    }
-
-    public void setPaymentDate(Date paymentDate) {
-        this.paymentDate = new Date(paymentDate.getTime());
-    }
-
-    public String getPayment() {
-        return payment;
-    }
-
-    public void setPayment(String payment) {
-        this.payment = payment;
-    }
-
-    public int getId() {
-        return id;
-    }
-
-    public void setId(int id) {
-        this.id = id;
-    }
-
-    public String getTransactionId() {
-        return transactionId;
-    }
-
-    public void setTransactionId(String transactionId) {
-        this.transactionId = transactionId;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/ee2ab783/components/stratos/billing/org.wso2.carbon.billing.mgt/2.1.3/src/main/java/org/wso2/carbon/billing/mgt/beans/MultitenancySubscription.java
----------------------------------------------------------------------
diff --git a/components/stratos/billing/org.wso2.carbon.billing.mgt/2.1.3/src/main/java/org/wso2/carbon/billing/mgt/beans/MultitenancySubscription.java b/components/stratos/billing/org.wso2.carbon.billing.mgt/2.1.3/src/main/java/org/wso2/carbon/billing/mgt/beans/MultitenancySubscription.java
deleted file mode 100644
index 5490e9f..0000000
--- a/components/stratos/billing/org.wso2.carbon.billing.mgt/2.1.3/src/main/java/org/wso2/carbon/billing/mgt/beans/MultitenancySubscription.java
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Copyright (c) 2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * Licensed 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.wso2.carbon.billing.mgt.beans;
-
-import java.util.Arrays;
-import java.util.Date;
-
-public class MultitenancySubscription {
-    String subscribedPackage;
-    BilledEntry[] billedEntries;
-    Date activeSince;
-    Date activeUntil;
-    boolean isActive;
-
-    public String getSubscribedPackage() {
-        return subscribedPackage;
-    }
-
-    public void setSubscribedPackage(String subscribedPackage) {
-        this.subscribedPackage = subscribedPackage;
-    }
-
-    public BilledEntry[] getBilledEntries() {
-        return Arrays.copyOf(billedEntries, billedEntries.length);
-    }
-
-    public void setBilledEntries(BilledEntry[] billedEntries) {
-        this.billedEntries = Arrays.copyOf(billedEntries, billedEntries.length);
-    }
-
-    public Date getActiveSince() {
-        return new Date(activeSince.getTime());
-    }
-
-    public void setActiveSince(Date activeSince) {
-        this.activeSince = new Date(activeSince.getTime());
-    }
-
-    public Date getActiveUntil() {
-        return new Date(activeUntil.getTime());
-    }
-
-    public void setActiveUntil(Date activeUntil) {
-        this.activeUntil = new Date( activeUntil.getTime());
-    }
-
-    public boolean isActive() {
-        return isActive;
-    }
-
-    public void setActive(boolean active) {
-        isActive = active;
-    }
-}

http://git-wip-us.apache.org/repos/asf/incubator-stratos/blob/ee2ab783/components/stratos/billing/org.wso2.carbon.billing.mgt/2.1.3/src/main/java/org/wso2/carbon/billing/mgt/dataobjects/MultitenancyCustomer.java
----------------------------------------------------------------------
diff --git a/components/stratos/billing/org.wso2.carbon.billing.mgt/2.1.3/src/main/java/org/wso2/carbon/billing/mgt/dataobjects/MultitenancyCustomer.java b/components/stratos/billing/org.wso2.carbon.billing.mgt/2.1.3/src/main/java/org/wso2/carbon/billing/mgt/dataobjects/MultitenancyCustomer.java
deleted file mode 100644
index 5d8aea6..0000000
--- a/components/stratos/billing/org.wso2.carbon.billing.mgt/2.1.3/src/main/java/org/wso2/carbon/billing/mgt/dataobjects/MultitenancyCustomer.java
+++ /dev/null
@@ -1,135 +0,0 @@
-/*
- * Copyright (c) 2008, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
- *
- * Licensed 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.wso2.carbon.billing.mgt.dataobjects;
-
-import org.wso2.carbon.billing.core.dataobjects.Customer;
-import org.wso2.carbon.utils.multitenancy.MultitenantConstants;
-
-/**
- * Multitenancy customer class
- */
-public class MultitenancyCustomer extends Customer {
-
-    private int numberOfUsers;
-    private long incomingBandwidth;
-    private long outgoingBandwidth;
-    private long totalBandwidth;
-    private long currentStorage;
-    private long historyStorage;
-    private long totalStorage;
-    private long cartridgeCPUHours;
-    private int tenantId = MultitenantConstants.INVALID_TENANT_ID;
-
-    public int getTenantId() {
-        return tenantId;
-    }
-
-    public void setTenantId(int tenantId) {
-        this.tenantId = tenantId;
-    }
-
-    public int getNumberOfUsers() {
-        return numberOfUsers;
-    }
-
-    public void setNumberOfUsers(int numberOfUsers) {
-        this.numberOfUsers = numberOfUsers;
-    }
-
-    public long getIncomingBandwidth() {
-        return incomingBandwidth;
-    }
-
-    public void setIncomingBandwidth(long incomingBandwidth) {
-        this.incomingBandwidth = incomingBandwidth;
-    }
-
-    public long getOutgoingBandwidth() {
-        return outgoingBandwidth;
-    }
-
-    public void setOutgoingBandwidth(long outgoingBandwidth) {
-        this.outgoingBandwidth = outgoingBandwidth;
-    }
-
-    public long getTotalBandwidth() {
-        return totalBandwidth;
-    }
-
-    public void setTotalBandwidth(long totalBandwidth) {
-        this.totalBandwidth = totalBandwidth;
-    }
-
-    public long getCurrentStorage() {
-        return currentStorage;
-    }
-
-    public void setCurrentStorage(long currentStorage) {
-        this.currentStorage = currentStorage;
-    }
-
-    public long getHistoryStorage() {
-        return historyStorage;
-    }
-
-    public void setHistoryStorage(long historyStorage) {
-        this.historyStorage = historyStorage;
-    }
-
-    public long getTotalStorage() {
-        return totalStorage;
-    }
-
-    public void setTotalStorage(long totalStorage) {
-        this.totalStorage = totalStorage;
-    }
-
-    public long getCartridgeCPUHours() {
-        return cartridgeCPUHours;
-    }
-
-    public void setCartridgeCPUHours(long cartridgeCPUHours) {
-        this.cartridgeCPUHours = cartridgeCPUHours;
-    }
-
-    @Override
-    public boolean equals(Object o) {
-        if (this == o) {
-            return true;
-        }
-        if (o == null || getClass() != o.getClass()) {
-            return false;
-        }
-        if (!super.equals(o)) {
-            return false;
-        }
-
-        MultitenancyCustomer that = (MultitenancyCustomer) o;
-
-        if (tenantId != that.tenantId) {
-            return false;
-        }
-
-        return true;
-    }
-
-    @Override
-    public int hashCode() {
-        int result = super.hashCode();
-        result = 31 * result + tenantId;
-        return result;
-    }
-}