org.apache.stratos.common.util
Class CommonUtil

java.lang.Object
  extended by org.apache.stratos.common.util.CommonUtil

public class CommonUtil
extends Object

Common Utility methods for Stratos. Now this class has been growing with several util methods - Should refactor accordingly.


Constructor Summary
CommonUtil()
           
 
Method Summary
static org.apache.axiom.om.OMElement buildOMElement(InputStream inputStream)
          builds the OMElement from the given inputStream
static void denyAnonAuthorization(String path, org.wso2.carbon.user.core.UserRealm userRealm)
           
static String getAdminPassword()
           
static String getAdminUserName()
           
static String getCurrentMonthString()
           
static Date getDateFromMonthString(String yearMonth)
           
static String getEula()
           
static String getMonthString(Calendar calendar)
           
static String getMonthString(int relativeMonth)
           
static String getNotificationEmailAddress()
          Gets the notification email address of the admin upon the tenant creation.
static StratosConfiguration getStratosConfig()
           
static String getSuperAdminEmail()
           
static boolean isChargedOnRegistration()
           
static boolean isDomainNameAvailable(String tenantDomain)
          method to check whether a domain name is available to register given a domain name
static boolean isEmailValidationMandatory()
          Checks whether the email validation is mandatory from the configuration file.
static boolean isPublicCloudSetup()
          Checks whether it is for the public cloud setup or Mars.
static boolean isTenantActivationModerated()
           
static boolean isTenantManagementEmailsDisabled()
          Checks whether the email sending is enabled from the configuration file.
static StratosConfiguration loadStratosConfiguration()
          Returns the configurations from the stratos configuration file.
static String loadTermsOfUsage()
          Loading the EULA.
static void setAnonAuthorization(String path, org.wso2.carbon.user.core.UserRealm userRealm)
           
static void setEula(String eula)
           
static void setStratosConfig(StratosConfiguration stratosConfig)
           
static boolean validateDomainFromSuccessKey(org.wso2.carbon.registry.core.session.UserRegistry governanceSystemRegistry, String domain, String successKey)
          validates domain from the successkey
static void validateEmail(String email)
          validates the email
static void validateName(String name, String variable)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CommonUtil

public CommonUtil()
Method Detail

getStratosConfig

public static StratosConfiguration getStratosConfig()

setStratosConfig

public static void setStratosConfig(StratosConfiguration stratosConfig)

getEula

public static String getEula()

setEula

public static void setEula(String eula)

isEmailValidationMandatory

public static boolean isEmailValidationMandatory()
Checks whether the email validation is mandatory from the configuration file.

Returns:
true, if the email validation is mandatory to login. Default is false.

isTenantManagementEmailsDisabled

public static boolean isTenantManagementEmailsDisabled()
Checks whether the email sending is enabled from the configuration file.

Returns:
true, if the email sending is disabled. By default, this is disabled, and tenant activation is done without any email sending.

getSuperAdminEmail

public static String getSuperAdminEmail()

getAdminUserName

public static String getAdminUserName()

getAdminPassword

public static String getAdminPassword()

isTenantActivationModerated

public static boolean isTenantActivationModerated()

isChargedOnRegistration

public static boolean isChargedOnRegistration()

isPublicCloudSetup

public static boolean isPublicCloudSetup()
Checks whether it is for the public cloud setup or Mars.

Returns:
true, if it is not for the private cloud setups. Default is true.

getNotificationEmailAddress

public static String getNotificationEmailAddress()
Gets the notification email address of the admin upon the tenant creation.

Returns:
notification email address for the tenant creations.

getMonthString

public static String getMonthString(Calendar calendar)

getMonthString

public static String getMonthString(int relativeMonth)

getDateFromMonthString

public static Date getDateFromMonthString(String yearMonth)
                                   throws ParseException
Throws:
ParseException

getCurrentMonthString

public static String getCurrentMonthString()

setAnonAuthorization

public static void setAnonAuthorization(String path,
                                        org.wso2.carbon.user.core.UserRealm userRealm)
                                 throws org.wso2.carbon.registry.core.exceptions.RegistryException
Throws:
org.wso2.carbon.registry.core.exceptions.RegistryException

denyAnonAuthorization

public static void denyAnonAuthorization(String path,
                                         org.wso2.carbon.user.core.UserRealm userRealm)
                                  throws org.wso2.carbon.registry.core.exceptions.RegistryException
Throws:
org.wso2.carbon.registry.core.exceptions.RegistryException

buildOMElement

public static org.apache.axiom.om.OMElement buildOMElement(InputStream inputStream)
                                                    throws Exception
builds the OMElement from the given inputStream

Parameters:
inputStream, - given input - inputStream
Returns:
OMElement
Throws:
Exception, - if building OMElement from the inputStream failed.
Exception

validateEmail

public static void validateEmail(String email)
                          throws Exception
validates the email

Parameters:
email - - email address
Throws:
Exception, - if validation failed
Exception

validateName

public static void validateName(String name,
                                String variable)
                         throws Exception
Parameters:
name - validate the name.
variable - entry name.
Throws:
Exception - if empty

validateDomainFromSuccessKey

public static boolean validateDomainFromSuccessKey(org.wso2.carbon.registry.core.session.UserRegistry governanceSystemRegistry,
                                                   String domain,
                                                   String successKey)
                                            throws org.wso2.carbon.registry.core.exceptions.RegistryException
validates domain from the successkey

Parameters:
governanceSystemRegistry - - The governance system registry
domain - - tenant domain
successKey - - successkey
Returns:
true, if successfully validated
Throws:
RegistryException, - if validation failed
org.wso2.carbon.registry.core.exceptions.RegistryException

loadStratosConfiguration

public static StratosConfiguration loadStratosConfiguration()
Returns the configurations from the stratos configuration file.

Returns:
stratos configurations

loadTermsOfUsage

public static String loadTermsOfUsage()
Loading the EULA. ultimately we shall be loading the eula from the web page itself. But loading from file should be there to customize the EULA based on the private deployments, etc.

Returns:
eula

isDomainNameAvailable

public static boolean isDomainNameAvailable(String tenantDomain)
                                     throws Exception
method to check whether a domain name is available to register given a domain name

Parameters:
tenantDomain, - domain name
Returns:
true, if the domain is available to register
Throws:
Exception, - if checking the existence of the tenant is failed.
Exception


Copyright © 2013 The Apache Software Foundation. All Rights Reserved.