Package org.wso2.carbon.user.core.tenant

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


     * Delete a specific tenant
     *
     * @param tenantDomain The domain name of the tennat that needs to be deleted
     */
    public void deleteTenant(String tenantDomain) throws Exception {
        TenantManager tenantManager = TenantMgtCoreServiceComponent.getTenantManager();
        int tenantId = tenantManager.getTenantId(tenantDomain);
        try {
            TenantMgtServiceComponent.getBillingService().deleteBillingData(tenantId);
            TenantMgtUtil.deleteTenantRegistryData(tenantId);
            TenantMgtUtil.deleteTenantUMData(tenantId);
            tenantManager.deleteTenant(tenantId);
            log.info("Deleted tenant with domain: " + tenantDomain + " and tenant id: " + tenantId +
                     " from the system.");
        } catch (Exception e) {
            String msg = "Error deleting tenant with domain: " + tenantDomain + " and tenant id: " +
                    tenantId + ".";
View Full Code Here


    private static final Log log = LogFactory.getLog(GAppTenantRegistrationService.class);
   
   
    public boolean isRegisteredAsGoogleAppDomain(String domain) throws TenantManagementException {

        TenantManager tenantManager =
            TenantMgtServiceComponent.getRealmService().getTenantManager();
        try {
            int tenantId = tenantManager.getTenantId(domain);

            if (tenantId == -1) {
                return false;
            }

            Tenant tenant = (Tenant) tenantManager.getTenant(tenantId);
            RealmConfiguration realmConfig = tenant.getRealmConfig();
            String value = realmConfig.getUserStoreProperties().get(
                            UserCoreConstants.RealmConfig.PROPERTY_EXTERNAL_IDP);

            if (value == null) {
View Full Code Here

     * Emails the tenant admin notifying the account creation.
     *
     * @param tenantId tenant Id
     */
    public static void notifyTenantInitialActivation(int tenantId) {
        TenantManager tenantManager = DataHolder.getTenantManager();
        String firstName = "";
        String domainName = "";
        String adminName = "";
        String email = "";
        try {
            Tenant tenant = tenantManager.getTenant(tenantId);
            domainName = tenant.getDomain();
            firstName = ClaimsMgtUtil.getFirstName(DataHolder.getRealmService(), tenantId);
            adminName = tenant.getAdminName();
            email = tenant.getEmail();
        } catch (Exception e) {
View Full Code Here

     * @param email      - tenant email
     * @return the parameters
     */
    private static Map<String, String> initializeSuperTenantNotificationParams(
            String domainName, String adminName, String email) {
        TenantManager tenantManager = DataHolder.getTenantManager();
        String firstName = "";
        String lastName = "";
        try {
            int tenantId = tenantManager.getTenantId(domainName);
            firstName = ClaimsMgtUtil.getFirstName(DataHolder.getRealmService(), tenantId);
            lastName = ClaimsMgtUtil.getLastName(DataHolder.getRealmService(), tenantId);

        } catch (Exception e) {
            String msg = "Unable to get the tenant with the tenant domain";
View Full Code Here

     * @return tenantId - the tenant id
     * @throws Exception - UserStoreException
     */
    private int addTenant(Tenant tenant) throws Exception {
        int tenantId;
        TenantManager tenantManager = TenantMgtCoreServiceComponent.getTenantManager();
        try {
            tenantId = tenantManager.addTenant(tenant);
            if (log.isDebugEnabled()) {
                log.debug("Tenant is successfully added: " + tenant.getDomain());
            }
        } catch (UserStoreException e) {
            String msg = "Error in adding tenant with domain: " + tenant.getDomain();
View Full Code Here

     *
     * @return Tenant[]
     * @throws UserStoreException, if getting the tenants failed.
     */
    public static Tenant[] getAllTenants() throws UserStoreException {
        TenantManager tenantManager = realmService.getTenantManager();
        try {
            return (Tenant[]) tenantManager.getAllTenants();
        } catch (org.wso2.carbon.user.api.UserStoreException e) {
            throw new UserStoreException(e);
        }
    }
View Full Code Here

    }

    public TenantUsage getTenantUsage(int tenantId, String yearMonth) throws Exception {
        //get the domain name
        TenantManager tenantManger = Util.getRealmService().getTenantManager();
        String domain = tenantManger.getDomain(tenantId);
        TenantUsage tenantUsage = new TenantUsage(tenantId, domain);

        //Get the startDate, endDate from yearMonth String
        Date date = CommonUtil.getDateFromMonthString(yearMonth);
        Calendar startDate = Calendar.getInstance();
View Full Code Here

     * @param yearMonth
     * @return
     * @throws Exception
     */
    public TenantUsage[] retrieveTenantUsages(String yearMonth) throws Exception {
        TenantManager tenantManager = Util.getRealmService().getTenantManager();
        Tenant[] tenants = (Tenant[]) tenantManager.getAllTenants();
        List<TenantUsage> tenantUsages = new ArrayList<TenantUsage>();
        for (Tenant tenant : tenants) {
            if (tenant.isActive()) {
                TenantUsage tenantUsage = Util.getTenantUsageRetriever().getTenantUsage(
                        tenant.getId(), yearMonth);
View Full Code Here

     * @return PaginatedTenantUsageInfo
     * @throws Exception
     */
    public PaginatedTenantUsageInfo retrievePaginatedTenantUsages(String yearMonth, int pageNumber,
                                                                  int entriesPerPage) throws Exception {
        TenantManager tenantManager = Util.getRealmService().getTenantManager();
        Tenant[] tenants = (Tenant[]) tenantManager.getAllTenants();
        List<TenantUsage> tenantUsages = new ArrayList<TenantUsage>();

        int i = 0;
        int numberOfPages = 0;
        for (Tenant tenant : tenants) {
View Full Code Here

     * @return true, if the domain is available to register
     * @throws Exception, if checking the existence of the tenant is failed.
     */
    public static boolean isDomainNameAvailable(String tenantDomain) throws Exception {

        TenantManager tenantManager = CloudCommonServiceComponent.getTenantManager();
          // The registry reserved words are checked first.
          if (tenantDomain.equals("atom") || tenantDomain.equals("registry")
                  || tenantDomain.equals("resource")) {
              String msg = "You can not use a registry reserved word:" + tenantDomain +
                           ":as a tenant domain. Please choose a different one.";
              log.error(msg);
              throw new Exception(msg);
          }

          int tenantId;
          try {
              tenantId = tenantManager.getTenantId(tenantDomain);
          } catch (UserStoreException e) {
              String msg = "Error in getting the tenant id for the given domain  " +
                           tenantDomain + ".";
              log.error(msg);
              throw new Exception(msg, e);
View Full Code Here

TOP

Related Classes of org.wso2.carbon.user.core.tenant.TenantManager

Copyright © 2018 www.massapicom. 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.