Examples of Tenant


Examples of org.wso2.carbon.user.core.tenant.Tenant

            log.error(msg);
            throw new Exception(msg);
        }
        int tenantId = registry.getTenantId();
        // get the tenant information from the tenant manager
        Tenant tenant;
        try {
            tenant = (Tenant) tenantManager.getTenant(tenantId);
        } catch (UserStoreException e) {
            String msg = "Error in retrieving the tenant information for the tenant id: " +
                         tenantId + ".";
            log.info(msg, e);
            throw new Exception(msg, e);
        }
        RealmService realmService = Util.getRealmService();
        try {
            Map<String, String> claimsMap = new HashMap<String, String>();
            claimsMap.put(UserCoreConstants.ClaimTypeURIs.GIVEN_NAME,
                          accountInfoBean.getFirstname());
            claimsMap.put(UserCoreConstants.ClaimTypeURIs.SURNAME, accountInfoBean.getLastname());
            UserStoreManager userStoreManager =
                    (UserStoreManager) realmService.getTenantUserRealm(tenantId)
                            .getUserStoreManager();
            userStoreManager.setUserClaimValues(
                    ClaimsMgtUtil.getAdminUserNameFromTenantId(realmService, tenantId),
                    claimsMap, UserCoreConstants.DEFAULT_PROFILE);
            log.info("FirstName: " + accountInfoBean.getFirstname() +
                     " has been updated to the tenant admin " +
                     ClaimsMgtUtil.getAdminUserNameFromTenantId(realmService, tenantId) + " of " +
                     tenant.getDomain());
            return true;
        } catch (Exception e) {
            // this is expected, as many users haven't given their fullnames
            // during their registration.
            String msg =
View Full Code Here

Examples of org.wso2.carbon.user.core.tenant.Tenant

            log.error(msg);
            throw new Exception(msg);
        }
        int tenantId = registry.getTenantId();
        // get the tenant information from the tenant manager
        Tenant tenant;
        try {
            tenant = (Tenant) tenantManager.getTenant(tenantId);
        } catch (UserStoreException e) {
            String msg = "Error in retrieving the tenant information for the tenant id: " +
                         tenantId + ".";
            log.info(msg, e);
            throw new Exception(msg, e);
        }

        // getting the other parameters from the claims.
        try {
            firstname = ClaimsMgtUtil.getFirstName(Util.getRealmService(), tenant, tenantId);

        } catch (Exception e) {
            String msg = "Error in retrieving the firstname for the admin of the domain " +
                         tenant.getDomain();
            log.info(msg);
        }
        try {
            lastname = ClaimsMgtUtil.getLastName(Util.getRealmService(), tenant, tenantId);
        } catch (Exception e) {
            // this is expected, as many users haven't given their lastnames
            // during their registration.
            String msg = "Error in retrieving the Lastname for the admin of the domain " +
                         tenant.getDomain();
            log.info(msg);
        }

        AccountInfoBean accountInfoBean = new AccountInfoBean();
        accountInfoBean.setFirstname(firstname);
View Full Code Here

Examples of org.wso2.carbon.user.core.tenant.Tenant

            log.error(msg);
            throw new Exception(msg);
        }
        int tenantId = registry.getTenantId();
        // get the tenant information from the tenant manager
        Tenant tenant;
        try {
            tenant = (Tenant) tenantManager.getTenant(tenantId);
        } catch (UserStoreException e) {
            String msg = "Error in retrieving the tenant information for the tenant id: " +
                         tenantId + ".";
            log.error(msg, e);
            throw new Exception(msg, e);
        }
        String domainName = tenant.getDomain();

        int indexOfDot = domainName.lastIndexOf(".");
        if (indexOfDot < 0) {
            String msg = "Invalid domain: " + domainName;
            log.error(msg);
View Full Code Here

Examples of org.wso2.carbon.user.core.tenant.Tenant

        Customer customer = getCurrentCustomer(userRegistry);
        // if customer doesn't exist, we are making a one
        if (customer == null) {
            int currentTenantId = userRegistry.getTenantId();
            TenantManager tenantManger = getRealmService().getTenantManager();
            Tenant currentTenant = (Tenant) tenantManger.getTenant(currentTenantId);
            if (currentTenant == null || currentTenant.getDomain() == null) {
                String msg = "Error in getting the customer information.";
                throw new Exception(msg);
            }
            customer = new Customer();
            customer.setName(currentTenant.getDomain());
            customer.setEmail(currentTenant.getEmail());
            customer.setStartedDate(new Date());

            billingEngine.addCustomer(customer);
        }
View Full Code Here

Examples of org.wso2.carbon.user.core.tenant.Tenant

    }

    public static Customer getCurrentCustomer(UserRegistry userRegistry) throws Exception {
        int currentTenantId = userRegistry.getTenantId();
        TenantManager tenantManger = getRealmService().getTenantManager();
        Tenant currentTenant = (Tenant) tenantManger.getTenant(currentTenantId);
        BillingEngine billingEngine =
                billingManager.getBillingEngine(StratosConstants.MULTITENANCY_SCHEDULED_TASK_ID);
        List<Customer> customers = billingEngine.getCustomersWithName(currentTenant.getDomain());
        if (customers == null || customers.size() == 0) {
            return null;
        }
        return customers.get(0);
    }
View Full Code Here

Examples of org.wso2.carbon.user.core.tenant.Tenant

    public static Customer getCurrentBillingCustomer(int tenantId) throws RegistryException {
        // get the host name of the current domain
        if (tenantId == MultitenantConstants.SUPER_TENANT_ID) {
            return null;
        }
        Tenant tenant;
        try {
            tenant = (Tenant) realmService.getTenantManager().getTenant(tenantId);
        } catch (org.wso2.carbon.user.api.UserStoreException e) {
            String msg = "Error in getting the realm Information.";
            log.error(msg, e);
            throw new RegistryException(msg, e);
        }
        if (tenant == null) {
            return null;
        }
        String customerName = tenant.getDomain();

        BillingEngine billingEngine =
                billingManager.getBillingEngine(StratosConstants.MULTITENANCY_SCHEDULED_TASK_ID);
        Customer customer;
        try {
View Full Code Here

Examples of org.wso2.carbon.user.core.tenant.Tenant

                log.error(msg, e);
                // not throwing the exception in finally more up.
            }
        }
        // persists the tenant.
        Tenant tenant = TenantMgtUtil.initializeTenant(tenantInfoBean);
        TenantPersistor persistor = TenantMgtServiceComponent.getTenantPersistor();
        persistor.persistTenant(tenant, true, tenantInfoBean.getSuccessKey(), tenantInfoBean.getOriginatedService());
        TenantMgtUtil.addClaimsToUserStoreManager(tenant);

        // For the registration validation - mail for the tenant email address
        TenantMgtUtil.sendEmail(tenant, tenantInfoBean.getOriginatedService());

        // Notifies the super admin about the new tenant creation
        TenantMgtUtil.notifyTenantCreationToSuperAdmin(
                tenantInfoBean.getTenantDomain(), tenantInfoBean.getAdmin(),
                tenantInfoBean.getEmail());

        //adding the subscription entry
        try{
            boolean subscriptionAdded = TenantMgtUtil.addUsagePlan(tenantInfoBean);
            if(subscriptionAdded){
                log.debug("Subscription added successfully for the tenant: " + tenantInfoBean.getTenantDomain());
            }else{
                log.error("Could not add the subscription for tenant: " + tenantInfoBean.getTenantDomain());
            }
        }catch(Exception e){
            log.error("Error occurred while adding the subscription for tenant: " +
                    tenantInfoBean.getTenantDomain() + " " + e.getMessage(), e);
        }

        return TenantMgtUtil.prepareStringToShowThemeMgtPage(tenant.getId());
    }
View Full Code Here

Examples of org.wso2.carbon.user.core.tenant.Tenant

    public static void notifyTenantCreation(String domainName, String adminName, String email) {
        TenantManager tenantManager = TenantMgtServiceComponent.getTenantManager();
        String firstName = "";
        try {
            int tenantId = tenantManager.getTenantId(domainName);
            Tenant tenant = (Tenant) tenantManager.getTenant(tenantId);
            firstName = ClaimsMgtUtil.getFirstName(TenantMgtServiceComponent.getRealmService(),
                                                   tenant, tenantId);
        } catch (Exception e) {
            String msg = "Unable to get the tenant with the tenant domain";
            log.error(msg, e);
View Full Code Here

Examples of org.wso2.carbon.user.core.tenant.Tenant

        TenantManager tenantManager = TenantMgtServiceComponent.getTenantManager();
        String firstName = "";
        String lastName = "";
        try {
            int tenantId = tenantManager.getTenantId(domainName);
            Tenant tenant = (Tenant) tenantManager.getTenant(tenantId);
            firstName = ClaimsMgtUtil.getFirstName(TenantMgtServiceComponent.getRealmService(),
                                                   tenant, tenantId);
            lastName = ClaimsMgtUtil.getLastName(TenantMgtServiceComponent.getRealmService(),
                                                 tenant, tenantId);
View Full Code Here

Examples of org.wso2.carbon.user.core.tenant.Tenant

     *
     * @param tenantInfoBean input
     * @return tenant
     */
    public static Tenant initializeTenant(TenantInfoBean tenantInfoBean) {
        Tenant tenant = new Tenant();
        tenant.setDomain(tenantInfoBean.getTenantDomain());
        tenant.setEmail(tenantInfoBean.getEmail());
        tenant.setAdminName(tenantInfoBean.getAdmin());

        // we are duplicating the params stored in the claims here as well; they
        // are in Tenant class
        // to make it work with LDAP; but they do not make it to the databases.
        tenant.setAdminFirstName(tenantInfoBean.getFirstname());
        tenant.setAdminLastName(tenantInfoBean.getLastname());

        tenant.setAdminPassword(tenantInfoBean.getAdminPassword());

        // sets created date.
        Calendar createdDateCal = tenantInfoBean.getCreatedDate();
        long createdDate;
        if (createdDateCal != null) {
            createdDate = createdDateCal.getTimeInMillis();
        } else {
            createdDate = System.currentTimeMillis();
        }
        tenant.setCreatedDate(new Date(createdDate));

        if (log.isDebugEnabled()) {
            log.debug("Tenant object Initialized from the TenantInfoBean");
        }
        return tenant;
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.