Package org.glassfish.admin.rest.utils
Class Util
- java.lang.Object
-
- org.glassfish.admin.rest.utils.Util
-
public class Util extends Object
Utilities class. Extended by ResourceUtil and ProviderUtil utilities. Used by resource and providers.- Author:
- Rajeshwar Patil
-
-
Field Summary
Fields Modifier and Type Field Description static LocalStringManagerImpl
localStrings
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static RestActionReporter
applyChanges(Map<String,String> data, jakarta.ws.rs.core.UriInfo uriInfo, Subject subject)
Apply changes passed indata
using CLI "set".static RestActionReporter
applyChanges(Map<String,String> data, String basePath, Subject subject)
static File
createTempDirectory()
static String
decode(String string)
Decodes an encoded URL using UTF-8static void
deleteDirectory(File dir)
static String
eleminateHypen(String string)
Removes any hypens ( - ) from the given string.static String
getBeanName(String elementName)
static Map<String,String>
getCurrentValues(String basePath, Subject subject)
static Map<String,String>
getCurrentValues(String basePath, org.glassfish.hk2.api.ServiceLocator habitat, Subject subject)
static Class<?>
getFirstGenericType(Type genericType)
This method takes a Type argument that represents a generic class (e.g.,List<String>) and returns the
Class
for the first generic type.static int
getFormattingIndentLevel()
Get the current configured indenting value for the REST layerstatic String
getGrandparentName(jakarta.ws.rs.core.UriInfo uriInfo)
static String
getGrandparentName(String url)
protected static String
getHtml(String message, jakarta.ws.rs.core.UriInfo uriInfo, boolean delete)
Returns the html for the given message.static jakarta.ws.rs.client.Client
getJerseyClient()
static String
getKeyAttributeName(ConfigModel model)
static String
getMethodParameterList(CommandModel cm, boolean withType, boolean includeOptional)
static String
getName(String typeName)
Returns just the name of the given fully qualified name.static String
getName(String typeName, char delimiter)
Returns just the name of the given fully qualified name.static String
getParentName(jakarta.ws.rs.core.UriInfo uriInfo)
Returns name of the resource parent from UriInfo.static String
getParentName(String url)
returns just the parent name of the resource from the resource url.static String
getResourceName(jakarta.ws.rs.core.UriInfo uriInfo)
Returns name of the resource from UriInfo.static boolean
isGenericType(Type type)
static void
logTimingMessage(String msg)
static String
lowerCaseFirstLetter(String string)
Converts the first letter of the given string to lower case.static String
methodNameFromBeanName(String elementName, String prefix)
Constructs a method name from element's bean name for a given prefix.(schema2beans convention)static String
methodNameFromDtdName(String elementName, String prefix)
Constructs a method name from element's dtd name name for a given prefix.(schema2beans convention)static ParameterMap
parameterMap()
Convenience wrapper around ParameterMap constructor to make it easier to use its fluent APIstatic File
saveFile(String fileName, String mimeType, InputStream fileStream)
static String
upperCaseFirstLetter(String string)
Converts the first letter of the given string to Uppercase.static boolean
useLegacyResponseFormat(jakarta.ws.rs.core.HttpHeaders requestHeaders)
-
-
-
Field Detail
-
localStrings
public static final LocalStringManagerImpl localStrings
-
-
Method Detail
-
logTimingMessage
public static void logTimingMessage(String msg)
-
getResourceName
public static String getResourceName(jakarta.ws.rs.core.UriInfo uriInfo)
Returns name of the resource from UriInfo.
-
getParentName
public static String getParentName(jakarta.ws.rs.core.UriInfo uriInfo)
Returns name of the resource parent from UriInfo.
-
getGrandparentName
public static String getGrandparentName(jakarta.ws.rs.core.UriInfo uriInfo)
-
getName
public static String getName(String typeName)
Returns just the name of the given fully qualified name.
-
getName
public static String getName(String typeName, char delimiter)
Returns just the name of the given fully qualified name.
-
getParentName
public static String getParentName(String url)
returns just the parent name of the resource from the resource url.
-
eleminateHypen
public static String eleminateHypen(String string)
Removes any hypens ( - ) from the given string. When it removes a hypen, it converts next immediate character, if any, to an Uppercase.(schema2beans convention)- Parameters:
string
- the input string- Returns:
- a
String
resulted after removing the hypens
-
decode
public static String decode(String string)
Decodes an encoded URL using UTF-8- Parameters:
string
- string to decode- Returns:
- decoded string, or the original string if decoding failed
-
upperCaseFirstLetter
public static String upperCaseFirstLetter(String string)
Converts the first letter of the given string to Uppercase.- Parameters:
string
- the input string- Returns:
- the string with the Uppercase first letter
-
lowerCaseFirstLetter
public static String lowerCaseFirstLetter(String string)
Converts the first letter of the given string to lower case.- Parameters:
string
- the input string- Returns:
- the string with the lower case first letter
-
getHtml
protected static String getHtml(String message, jakarta.ws.rs.core.UriInfo uriInfo, boolean delete)
Returns the html for the given message.- Parameters:
uriInfo
- the uriInfo context of the request- Returns:
- String the html representation of the given message
-
methodNameFromDtdName
public static String methodNameFromDtdName(String elementName, String prefix)
Constructs a method name from element's dtd name name for a given prefix.(schema2beans convention)- Parameters:
elementName
- the given element nameprefix
- the given prefix- Returns:
- a method name formed from the given name and the prefix
-
methodNameFromBeanName
public static String methodNameFromBeanName(String elementName, String prefix)
Constructs a method name from element's bean name for a given prefix.(schema2beans convention)- Parameters:
elementName
- the given element nameprefix
- the given prefix- Returns:
- a method name formed from the given name and the prefix
-
getJerseyClient
public static jakarta.ws.rs.client.Client getJerseyClient()
-
applyChanges
public static RestActionReporter applyChanges(Map<String,String> data, jakarta.ws.rs.core.UriInfo uriInfo, Subject subject)
Apply changes passed indata
using CLI "set".- Parameters:
data
- The set of changes to be applied- Returns:
- ActionReporter containing result of "set" execution
-
applyChanges
public static RestActionReporter applyChanges(Map<String,String> data, String basePath, Subject subject)
-
getCurrentValues
public static Map<String,String> getCurrentValues(String basePath, Subject subject)
-
getCurrentValues
public static Map<String,String> getCurrentValues(String basePath, org.glassfish.hk2.api.ServiceLocator habitat, Subject subject)
-
getKeyAttributeName
public static String getKeyAttributeName(ConfigModel model)
- Parameters:
model
-- Returns:
- name of the key attribute for the given model.
-
createTempDirectory
public static File createTempDirectory()
-
deleteDirectory
public static void deleteDirectory(File dir)
-
getMethodParameterList
public static String getMethodParameterList(CommandModel cm, boolean withType, boolean includeOptional)
-
saveFile
public static File saveFile(String fileName, String mimeType, InputStream fileStream)
-
isGenericType
public static boolean isGenericType(Type type)
-
getFirstGenericType
public static Class<?> getFirstGenericType(Type genericType)
This method takes a Type argument that represents a generic class (e.g.,List<String>) and returns the
Class
for the first generic type. If theClass
is not a generic type,null
is returned. The primary intended usage for this is in theMessageBodyReader
s to help return a more accurate result fromisReadable
, though it may also be helpful in other, more general situations.- Parameters:
genericType
-- Returns:
-
getFormattingIndentLevel
public static int getFormattingIndentLevel()
Get the current configured indenting value for the REST layer- Returns:
-
useLegacyResponseFormat
public static boolean useLegacyResponseFormat(jakarta.ws.rs.core.HttpHeaders requestHeaders)
-
parameterMap
public static ParameterMap parameterMap()
Convenience wrapper around ParameterMap constructor to make it easier to use its fluent API- Returns:
- ParameterMap
-
-