public class DBUtils extends Object
Constructor and Description |
---|
DBUtils() |
Modifier and Type | Method and Description |
---|---|
static boolean |
authenticate(String username,
String password) |
static org.apache.axiom.om.OMElement |
cloneAndReturnBuiltElement(org.apache.axiom.om.OMElement result)
Creates a new OMElement from the given element and build it and return.
|
static Object |
convertInputParamValue(String value,
String type)
Convert the string input param value to its typed object value.
|
static Object[] |
convertInputParamValues(List<InternalParam> params)
Convert the input parameter values to its types object values.
|
static org.apache.axis2.AxisFault |
createAxisFault(Exception e)
Creates an AxisFault.
|
static Map<Integer,String> |
createColumnMappings(String[] header)
create a map which maps the column numbers to column names,
column numbers starts with 1 (1 based).
|
static org.apache.axiom.om.OMElement |
createDSFaultOM(String msg)
Creates OMElement using error details.
|
static String |
encodeBase64(String value)
Encode the given string with base64 encoding.
|
static String |
evaluateString(String source,
ExternalParamCollection params) |
static Map<String,String> |
extractProperties(org.apache.axiom.om.OMElement propsParentEl) |
static String |
extractUDTObjectName(String param)
Extracts the UDT column name from a given parameter name
|
static AuthorizationProvider |
generateAuthProviderFromXMLOMElement(org.apache.axiom.om.OMElement authorizationProviderElement)
Helper method to generate Authorization provider using config element
|
static org.apache.axis2.description.AxisService |
getActiveAxisServiceAccordingToDataServiceGroup(org.apache.axis2.engine.AxisConfiguration axisConfiguration,
String serviceName)
This method returns an active existing Axis Service for the given name data service group.
|
static String[] |
getAllRoles(int tenantId)
Retrieves all roles for a given tenantId to be used in role based filtering when creating dataservice.
|
static String[] |
getAllRolesUsingAuthorizationProvider(String authProviderConfig)
Get roles using the AuthorizationProvider using the config given.
|
static String[] |
getAvailableDS(org.apache.axis2.engine.AxisConfiguration axisConfiguration)
This method returns the available data services names.
|
static boolean |
getChangeFetchSizeForRDBMS(String jdbcUrl)
Returns whether or not to apply fetch size for the given jdbc connection
|
static String |
getConnectionURL4XADataSource(Config config) |
static TransactionManager |
getContainerTransactionManager(String txManagerJNDIName)
Get the container managed transaction manager; if a JNDI name is given,
that name is looked for a TransactionManager object, if not, the standard JNDI
names are checked.
|
static String |
getCurrentContextUsername(DataService dataService) |
static int |
getCurrentTenantId()
Returns the best effort way of finding the current tenant id,
even if this is not in a current message request, i.e.
|
static int |
getCurrentUserTenantId()
This method is to get current user tenant ID, This will be only called when creating data service with
role based filtering.
|
static Date |
getDate(String value)
Create a Date object from the given date string.
|
static InputStream |
getInputStreamFromPath(String path)
Creates and returns an InputStream from the file path / http location given.
|
static String |
getJavaTypeFromSQLType(String sqlType)
Converts from DS SQL types to Java types, e.g.
|
static List<Integer> |
getNestedIndices(String indexString)
Util method to parse index string and produce the list of nested indices.
|
static org.apache.axiom.om.OMFactory |
getOMFactory() |
static int |
getOptimalRSFetchSizeForRDBMS(String jdbcUrl)
Returns the most suitable value for the JDBC Result Set FetchSize property,
for the DBMS engine of the given JDBC URL.
|
static QName |
getSimpleSchemaTypeName(org.apache.axis2.description.java2wsdl.TypeTable typeTable,
String typeName)
Returns the simple schema type from the type name,
|
static String |
getSQLTypeFromXsdType(String xsdType)
Converts from XML schema types to DS SQL types, e.g.
|
static String |
getStacktraceFromException(Throwable e)
Utility method that returns a string which contains the stack trace of the given
Exception object.
|
static void |
getSyntaxEmbeddedQueue(Queue<String> tokens,
Queue<String> syntaxQueue,
boolean isIndex)
This method is used to embed syntaxes associated with UDT attribute notations to
a queue of string tokens extracted from a UDT parameter.
|
static String |
getTenantDomainFromId(int tid) |
static Time |
getTime(String value)
Create a Time object from the given time string.
|
static Timestamp |
getTimestamp(String value)
Create a Timestamp object from the given timestamp string.
|
static Queue<String> |
getTokens(String param)
This util method is used to retrieve the string tokens resides in a particular
udt parameter.
|
static String[] |
getUserRoles(String username)
Retrieves the current user's roles given the username.
|
static XMLInputFactory |
getXMLInputFactory() |
static XMLOutputFactory |
getXMLOutputFactory() |
static boolean |
isAvailableDS(org.apache.axis2.engine.AxisConfiguration axisConfiguration,
String dataService)
This method verifies whether there's an existing data service for the given name.
|
static boolean |
isAvailableDSServiceGroup(org.apache.axis2.engine.AxisConfiguration axisConfiguration,
String dataServiceGroup)
This method verifies whether there's an existing data service group for the given name data service group.
|
static boolean |
isEmptyString(String text)
Check the given text is empty or not.
|
static boolean |
isRegistryPath(String path) |
static boolean |
isSQLArray(ParamValue paramValue) |
static boolean |
isUDT(ParamValue paramValue) |
static String |
loadFromSecureVault(String alias) |
static void |
populateStandardCustomDSProps(Map<String,String> dsProps,
DataService dataService,
Config config) |
static String |
prettifyXML(String xmlContent)
Prettify a given XML string
|
static void |
prettifyXMLFile(String filePath)
Prettify a given XML file
|
static ParamValue |
processSQLArray(Array sqlArray,
ParamValue paramValue)
Processes a particular SQL Array object and interprets its value as a ParamValue object.
|
static String |
resolvePasswordValue(DataService dataService,
String password)
Check the given password is encrypted or not, if its encrypted resolve the password.
|
static void |
scheduleTask(Runnable task,
long delay)
Schedules a given task for one-time execution using the executer framework.
|
static org.apache.axiom.om.OMElement |
wrapBoxCarringResponse(org.apache.axiom.om.OMElement result) |
public static XMLOutputFactory getXMLOutputFactory()
public static XMLInputFactory getXMLInputFactory()
public static org.apache.axiom.om.OMFactory getOMFactory()
public static String getJavaTypeFromSQLType(String sqlType)
public static String getSQLTypeFromXsdType(String xsdType)
public static String getCurrentContextUsername(DataService dataService)
public static String[] getUserRoles(String username) throws DataServiceFault
username
- The usernameDataServiceFault
public static String[] getAllRoles(int tenantId) throws DataServiceFault
DataServiceFault
public static int getCurrentUserTenantId() throws DataServiceFault
DataServiceFault
public static boolean authenticate(String username, String password) throws DataServiceFault
DataServiceFault
public static String[] getAvailableDS(org.apache.axis2.engine.AxisConfiguration axisConfiguration) throws org.apache.axis2.AxisFault
axisConfiguration
- Axis configurationorg.apache.axis2.AxisFault
public static boolean isAvailableDS(org.apache.axis2.engine.AxisConfiguration axisConfiguration, String dataService) throws org.apache.axis2.AxisFault
axisConfiguration
- Axis configurationdataService
- Data serviceorg.apache.axis2.AxisFault
public static boolean isAvailableDSServiceGroup(org.apache.axis2.engine.AxisConfiguration axisConfiguration, String dataServiceGroup) throws org.apache.axis2.AxisFault
axisConfiguration
- Axis configurationdataServiceGroup
- Data service Grouporg.apache.axis2.AxisFault
public static org.apache.axis2.description.AxisService getActiveAxisServiceAccordingToDataServiceGroup(org.apache.axis2.engine.AxisConfiguration axisConfiguration, String serviceName) throws org.apache.axis2.AxisFault
axisConfiguration
- Axis configurationserviceName
- Data service Nameorg.apache.axis2.AxisFault
public static boolean isRegistryPath(String path)
public static InputStream getInputStreamFromPath(String path) throws IOException, DataServiceFault
DataServiceFault
IOException
InputStream
public static Map<Integer,String> createColumnMappings(String[] header) throws IOException
IOException
public static String getStacktraceFromException(Throwable e)
public static int getOptimalRSFetchSizeForRDBMS(String jdbcUrl)
public static boolean getChangeFetchSizeForRDBMS(String jdbcUrl)
public static Timestamp getTimestamp(String value) throws DataServiceFault, ParseException
DataServiceFault
ParseException
public static Time getTime(String value) throws DataServiceFault, ParseException
DataServiceFault
ParseException
public static Date getDate(String value) throws DataServiceFault
DataServiceFault
public static void prettifyXMLFile(String filePath) throws IOException, URISyntaxException
IOException
URISyntaxException
public static String encodeBase64(String value)
public static org.apache.axis2.AxisFault createAxisFault(Exception e)
public static org.apache.axiom.om.OMElement createDSFaultOM(String msg)
public static String evaluateString(String source, ExternalParamCollection params) throws DataServiceFault
DataServiceFault
public static void scheduleTask(Runnable task, long delay)
task
- The task to be executeddelay
- The delay in milliseconds for the task to be executedpublic static boolean isEmptyString(String text)
text
- The text to be checkedpublic static String resolvePasswordValue(DataService dataService, String password)
dataService
- Data service objectpassword
- Password before resolvingpublic static int getCurrentTenantId()
public static QName getSimpleSchemaTypeName(org.apache.axis2.description.java2wsdl.TypeTable typeTable, String typeName)
public static Map<String,String> extractProperties(org.apache.axiom.om.OMElement propsParentEl)
public static TransactionManager getContainerTransactionManager(String txManagerJNDIName) throws DataServiceFault
txManagerJNDIName
- The user given JNDI name of the TransactionManagerDataServiceFault
public static org.apache.axiom.om.OMElement cloneAndReturnBuiltElement(org.apache.axiom.om.OMElement result)
result
- The object to be cloned and builtpublic static Queue<String> getTokens(String param)
param
- Name of the parameterpublic static void getSyntaxEmbeddedQueue(Queue<String> tokens, Queue<String> syntaxQueue, boolean isIndex)
tokens
- Queue of string tokenssyntaxQueue
- Syntax embedded tokensisIndex
- Flag to determine whether a particular string token is an inidex
or a column namepublic static String getConnectionURL4XADataSource(Config config) throws XMLStreamException
XMLStreamException
public static boolean isUDT(ParamValue paramValue)
public static boolean isSQLArray(ParamValue paramValue)
public static List<Integer> getNestedIndices(String indexString) throws DataServiceFault
indexString
- Index String.DataServiceFault
- DataServiceFault.public static ParamValue processSQLArray(Array sqlArray, ParamValue paramValue) throws SQLException
sqlArray
- SQL Array element.paramValue
- Parameter value object initialized to contain an array of ParamValues.SQLException
- Throws an SQL Exception if the result set is not accessible.public static String extractUDTObjectName(String param)
param
- User specified parameter namepublic static org.apache.axiom.om.OMElement wrapBoxCarringResponse(org.apache.axiom.om.OMElement result)
public static void populateStandardCustomDSProps(Map<String,String> dsProps, DataService dataService, Config config)
public static Object[] convertInputParamValues(List<InternalParam> params) throws DataServiceFault
params
- The input paramsDataServiceFault
public static Object convertInputParamValue(String value, String type) throws DataServiceFault
value
- The string value of the input paramtype
- The type of the input value, defined at DBConstants.DataTypes.DataServiceFault
public static String getTenantDomainFromId(int tid)
public static String[] getAllRolesUsingAuthorizationProvider(String authProviderConfig) throws DataServiceFault
authProviderConfig
- xml config.DataServiceFault
public static AuthorizationProvider generateAuthProviderFromXMLOMElement(org.apache.axiom.om.OMElement authorizationProviderElement) throws DataServiceFault
authorizationProviderElement
- config elementDataServiceFault
Copyright © 2019 WSO2. All rights reserved.