public class ResourceUtil extends Object
TemplateListOfResource and
TemplateRestResource| Modifier and Type | Method and Description |
|---|---|
static void |
addCommandLog(RestActionReporter ar,
String commandName,
ParameterMap parameters) |
static void |
addMethodMetaData(ActionReport ar,
Map<String,MethodMetaData> mmd) |
static void |
addQueryString(javax.ws.rs.core.MultivaluedMap<String,String> qs,
Map<String,String> data)
This method takes any query string parameters and adds them to the
specified map.
|
static void |
addQueryString(javax.ws.rs.core.MultivaluedMap<String,String> qs,
Properties data) |
static void |
adjustParameters(Map<String,String> data)
Adjust the input parameters.
|
static Subject |
authenticateViaAdminRealm(org.glassfish.hk2.api.ServiceLocator habitat,
org.glassfish.grizzly.http.server.Request req,
String remoteHost)
Authenticate the given req as originated from given remoteHost against
admin realm.
|
static Map |
buildMethodMetadataMap(MethodMetaData mmd) |
static boolean |
canShowDeprecatedItems(org.glassfish.hk2.api.ServiceLocator habitat) |
static boolean |
commandIsPresent(org.glassfish.hk2.api.ServiceLocator habitat,
String commandName) |
static String |
convertToXMLName(String name) |
protected static void |
copyParameterMetaDataAttribute(ParameterMetaData from,
ParameterMetaData to,
String key) |
static void |
defineDefaultParameters(Map<String,String> data)
Adjust the input parameters.
|
static String |
encodeString(String text) |
static ActionReportResult |
getActionReportResult(ActionReport.ExitCode status,
String message,
javax.ws.rs.core.HttpHeaders requestHeaders,
javax.ws.rs.core.UriInfo uriInfo) |
static ActionReportResult |
getActionReportResult(RestActionReporter ar,
String message,
javax.ws.rs.core.HttpHeaders requestHeaders,
javax.ws.rs.core.UriInfo uriInfo) |
static String |
getAttributeBooleanMethodName(String attributeName) |
static String |
getAttributeMethodName(String attributeName) |
protected static byte[] |
getBytesFromStream(InputStream is) |
static String |
getCommand(RestRedirect.OpType type,
org.jvnet.hk2.config.ConfigModel model)
Returns the name of the command associated with this resource,if any, for
the given operation.
|
static List<Map<String,String>> |
getCommandLinks(String[][] commandResourcesPaths) |
static javax.ws.rs.core.Response |
getDeleteResponse(int status,
String message,
javax.ws.rs.core.HttpHeaders requestHeaders,
javax.ws.rs.core.UriInfo uriInfo)
special case for the delete operation: we need to give back the URI of
the parent since the resource we are on is deleted
|
protected static void |
getInterfaces(Class<?> clazz,
List<Class<?>> interfaces) |
static MethodMetaData |
getMethodMetaData(org.jvnet.hk2.config.ConfigModel configBeanModel)
Constructs and returns the resource method meta-data.
|
static MethodMetaData |
getMethodMetaData(String command,
HashMap<String,String> commandParamsToSkip,
org.glassfish.hk2.api.ServiceLocator habitat)
Constructs and returns the resource method meta-data.
|
static MethodMetaData |
getMethodMetaData(String command,
org.glassfish.hk2.api.ServiceLocator habitat)
Constructs and returns the resource method meta-data.
|
static MethodMetaData |
getMethodMetaData2(org.jvnet.hk2.config.Dom parent,
org.jvnet.hk2.config.ConfigModel childModel,
int parameterType) |
static String |
getParameterList(ParameterMap parameters) |
static Collection<CommandModel.ParamModel> |
getParamMetaData(String commandName,
Collection<String> commandParamsToSkip,
org.glassfish.hk2.api.ServiceLocator habitat)
Constructs and returns the parameter meta-data.
|
static Collection<CommandModel.ParamModel> |
getParamMetaData(String commandName,
org.glassfish.hk2.api.ServiceLocator habitat)
Constructs and returns the parameter meta-data.
|
static List<org.jvnet.hk2.config.ConfigModel> |
getRealChildConfigModels(org.jvnet.hk2.config.ConfigModel childModel,
org.jvnet.hk2.config.DomDocument domDocument) |
static Map<String,String> |
getResourceLinks(org.jvnet.hk2.config.Dom dom,
javax.ws.rs.core.UriInfo uriInfo,
boolean canShowDeprecated) |
static Map<String,String> |
getResourceLinks(List<org.jvnet.hk2.config.Dom> proxyList,
javax.ws.rs.core.UriInfo uriInfo) |
static javax.ws.rs.core.Response |
getResponse(int status,
String message,
javax.ws.rs.core.HttpHeaders requestHeaders,
javax.ws.rs.core.UriInfo uriInfo)
Constructs and returns the appropriate response object based on the
client.
|
static RestConfig |
getRestConfig(org.glassfish.hk2.api.ServiceLocator habitat) |
static String |
getResultType(javax.ws.rs.core.HttpHeaders requestHeaders) |
static String |
getUnqualifiedTypeName(String qualifiedTypeName) |
static boolean |
isAuthorized(org.glassfish.hk2.api.ServiceLocator habitat,
Subject subject,
String resource,
String action)
Indicates whether the subject can perform the action on the resource.
|
static boolean |
isDeprecated(org.jvnet.hk2.config.ConfigModel model) |
static boolean |
isOnlyATag(org.jvnet.hk2.config.ConfigModel model) |
static void |
purgeEmptyEntries(Map<String,String> data) |
static void |
resolveParamValues(Map<String,String> commandParams,
javax.ws.rs.core.UriInfo uriInfo) |
static RestActionReporter |
runCommand(String commandName,
Map<String,String> parameters,
Subject subject)
Executes the specified __asadmin command.
|
static RestActionReporter |
runCommand(String commandName,
ParameterMap parameters,
Subject subject)
Executes the specified __asadmin command.
|
static RestActionReporter |
runCommand(String commandName,
ParameterMap parameters,
Subject subject,
boolean managedJob)
Executes the specified __asadmin command.
|
static org.glassfish.jersey.media.sse.EventOutput |
runCommandWithSse(String commandName,
ParameterMap parameters,
Subject subject,
SseCommandHelper.ActionReportProcessor processor) |
static HashMap<String,String> |
translateCamelCasedNamesToXMLNames(Map<String,String> sourceData) |
protected static byte[] getBytesFromStream(InputStream is)
public static void adjustParameters(Map<String,String> data)
public static void defineDefaultParameters(Map<String,String> data)
public static String getCommand(RestRedirect.OpType type, org.jvnet.hk2.config.ConfigModel model)
type - the given resource operationpublic static RestActionReporter runCommand(String commandName, ParameterMap parameters, Subject subject)
commandName - parameters - subject - public static RestActionReporter runCommand(String commandName, ParameterMap parameters, Subject subject, boolean managedJob)
commandName - parameters - subject - managedJob - public static RestActionReporter runCommand(String commandName, Map<String,String> parameters, Subject subject)
commandName - the command to executeparameters - the command parameterssubject - Subjectpublic static org.glassfish.jersey.media.sse.EventOutput runCommandWithSse(String commandName, ParameterMap parameters, Subject subject, SseCommandHelper.ActionReportProcessor processor)
public static void addCommandLog(RestActionReporter ar, String commandName, ParameterMap parameters)
public static String getParameterList(ParameterMap parameters)
public static MethodMetaData getMethodMetaData(String command, org.glassfish.hk2.api.ServiceLocator habitat)
command - the command associated with the resource methodhabitat - the habitatlogger - the logger to usepublic static MethodMetaData getMethodMetaData(String command, HashMap<String,String> commandParamsToSkip, org.glassfish.hk2.api.ServiceLocator habitat)
command - the command associated with the resource methodcommandParamsToSkip - the command parameters for which not to
include the meta-data.habitat - the habitatlogger - the logger to usepublic static void resolveParamValues(Map<String,String> commandParams, javax.ws.rs.core.UriInfo uriInfo)
public static MethodMetaData getMethodMetaData(org.jvnet.hk2.config.ConfigModel configBeanModel)
configBeanModel - the config bean associated with the resource.public static MethodMetaData getMethodMetaData2(org.jvnet.hk2.config.Dom parent, org.jvnet.hk2.config.ConfigModel childModel, int parameterType)
protected static void copyParameterMetaDataAttribute(ParameterMetaData from, ParameterMetaData to, String key)
public static boolean commandIsPresent(org.glassfish.hk2.api.ServiceLocator habitat,
String commandName)
public static Collection<CommandModel.ParamModel> getParamMetaData(String commandName, org.glassfish.hk2.api.ServiceLocator habitat)
commandName - the command associated with the resource methodhabitat - the habitatlogger - the logger to usepublic static Collection<CommandModel.ParamModel> getParamMetaData(String commandName, Collection<String> commandParamsToSkip, org.glassfish.hk2.api.ServiceLocator habitat)
commandName - the command associated with the resource methodcommandParamsToSkip - the command parameters for which not to
include the meta-data.habitat - the habitatlogger - the logger to usepublic static javax.ws.rs.core.Response getResponse(int status,
String message,
javax.ws.rs.core.HttpHeaders requestHeaders,
javax.ws.rs.core.UriInfo uriInfo)
status - the http status code for the responsemessage - message for the responserequestHeaders - request headers of the requestpublic static ActionReportResult getActionReportResult(ActionReport.ExitCode status, String message, javax.ws.rs.core.HttpHeaders requestHeaders, javax.ws.rs.core.UriInfo uriInfo)
public static ActionReportResult getActionReportResult(RestActionReporter ar, String message, javax.ws.rs.core.HttpHeaders requestHeaders, javax.ws.rs.core.UriInfo uriInfo)
public static javax.ws.rs.core.Response getDeleteResponse(int status,
String message,
javax.ws.rs.core.HttpHeaders requestHeaders,
javax.ws.rs.core.UriInfo uriInfo)
status - message - requestHeaders - uriInfo - public static void addQueryString(javax.ws.rs.core.MultivaluedMap<String,String> qs, Map<String,String> data)
This method takes any query string parameters and adds them to the specified map. This is used, for example, with the delete operation when cascading deletes are required:
DELETE http://localhost:4848/.../foo?cascade=true
The reason we need to use query parameters versus "body" variables is the limitation that HttpURLConnection has in this regard.
data - public static void addQueryString(javax.ws.rs.core.MultivaluedMap<String,String> qs, Properties data)
public static String getAttributeBooleanMethodName(String attributeName)
public static HashMap<String,String> translateCamelCasedNamesToXMLNames(Map<String,String> sourceData)
sourceData where key of each entry from it is converted to
xml namepublic static String getResultType(javax.ws.rs.core.HttpHeaders requestHeaders)
public static Map buildMethodMetadataMap(MethodMetaData mmd)
public static boolean isDeprecated(org.jvnet.hk2.config.ConfigModel model)
public static Map<String,String> getResourceLinks(org.jvnet.hk2.config.Dom dom, javax.ws.rs.core.UriInfo uriInfo, boolean canShowDeprecated)
public static String getUnqualifiedTypeName(String qualifiedTypeName)
qualifiedTypeName - public static boolean isOnlyATag(org.jvnet.hk2.config.ConfigModel model)
public static List<org.jvnet.hk2.config.ConfigModel> getRealChildConfigModels(org.jvnet.hk2.config.ConfigModel childModel, org.jvnet.hk2.config.DomDocument domDocument)
public static Map<String,String> getResourceLinks(List<org.jvnet.hk2.config.Dom> proxyList, javax.ws.rs.core.UriInfo uriInfo)
public static List<Map<String,String>> getCommandLinks(String[][] commandResourcesPaths)
public static void addMethodMetaData(ActionReport ar, Map<String,MethodMetaData> mmd)
public static RestConfig getRestConfig(org.glassfish.hk2.api.ServiceLocator habitat)
public static boolean canShowDeprecatedItems(org.glassfish.hk2.api.ServiceLocator habitat)
public static Subject authenticateViaAdminRealm(org.glassfish.hk2.api.ServiceLocator habitat, org.glassfish.grizzly.http.server.Request req, String remoteHost) throws LoginException, IOException
LoginExceptionIOExceptionpublic static boolean isAuthorized(org.glassfish.hk2.api.ServiceLocator habitat,
Subject subject,
String resource,
String action)
throws URISyntaxException
habitat - ServiceLocator for finding servicessubject - the Subject to be qualifiedresource - the resource affected by the actionaction - the action being attempted by the subject on the resourceURISyntaxExceptionCopyright © 2017. All rights reserved.